summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/browser
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-08-24 12:15:48 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-08-28 13:30:04 +0000
commitb014812705fc80bff0a5c120dfcef88f349816dc (patch)
tree25a2e2d9fa285f1add86aa333389a839f81a39ae /chromium/chrome/browser
parent9f4560b1027ae06fdb497023cdcaf91b8511fa74 (diff)
BASELINE: Update Chromium to 68.0.3440.125
Change-Id: I23f19369e01f688e496f5bf179abb521ad73874f Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/chrome/browser')
-rw-r--r--chromium/chrome/browser/BUILD.gn338
-rw-r--r--chromium/chrome/browser/android/vr/BUILD.gn51
-rw-r--r--chromium/chrome/browser/browser_resources.grd45
-rw-r--r--chromium/chrome/browser/chrome_content_browser_manifest_overlay.json91
-rw-r--r--chromium/chrome/browser/chrome_content_gpu_manifest_overlay.json14
-rw-r--r--chromium/chrome/browser/chrome_content_renderer_manifest_overlay.json30
-rw-r--r--chromium/chrome/browser/chrome_content_utility_manifest_overlay.json14
-rw-r--r--chromium/chrome/browser/chromeos/BUILD.gn164
-rw-r--r--chromium/chrome/browser/chromeos/prefs/ash_pref_connector_manifest.json2
-rw-r--r--chromium/chrome/browser/custom_handlers/protocol_handler_registry.cc36
-rw-r--r--chromium/chrome/browser/custom_handlers/protocol_handler_registry.h22
-rw-r--r--chromium/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc82
-rw-r--r--chromium/chrome/browser/devtools/BUILD.gn7
-rw-r--r--chromium/chrome/browser/devtools/chrome_devtools_manager_delegate.cc5
-rw-r--r--chromium/chrome/browser/devtools/chrome_devtools_session.cc3
-rw-r--r--chromium/chrome/browser/devtools/cros_protocol.json21
-rw-r--r--chromium/chrome/browser/devtools/cros_protocol.pdl14
-rw-r--r--chromium/chrome/browser/devtools/device/adb/adb_client_socket.cc18
-rw-r--r--chromium/chrome/browser/devtools/device/adb/adb_client_socket.h6
-rw-r--r--chromium/chrome/browser/devtools/device/adb/adb_client_socket_browsertest.cc1
-rw-r--r--chromium/chrome/browser/devtools/device/adb/mock_adb_server.cc10
-rw-r--r--chromium/chrome/browser/devtools/device/devtools_android_bridge.cc1
-rw-r--r--chromium/chrome/browser/devtools/device/port_forwarding_browsertest.cc2
-rw-r--r--chromium/chrome/browser/devtools/device/port_forwarding_controller.cc1
-rw-r--r--chromium/chrome/browser/devtools/device/usb/android_usb_browsertest.cc10
-rw-r--r--chromium/chrome/browser/devtools/device/usb/android_usb_socket.cc33
-rw-r--r--chromium/chrome/browser/devtools/device/usb/android_usb_socket.h14
-rw-r--r--chromium/chrome/browser/devtools/devtools_eye_dropper.cc13
-rw-r--r--chromium/chrome/browser/devtools/devtools_eye_dropper.h5
-rw-r--r--chromium/chrome/browser/devtools/devtools_file_system_indexer.cc1
-rw-r--r--chromium/chrome/browser/devtools/devtools_file_system_indexer_unittest.cc2
-rw-r--r--chromium/chrome/browser/devtools/devtools_sanity_browsertest.cc196
-rw-r--r--chromium/chrome/browser/devtools/devtools_sanity_interactive_browsertest.cc30
-rw-r--r--chromium/chrome/browser/devtools/devtools_window.cc65
-rw-r--r--chromium/chrome/browser/devtools/devtools_window.h29
-rw-r--r--chromium/chrome/browser/devtools/global_confirm_info_bar.cc8
-rw-r--r--chromium/chrome/browser/devtools/inspector_protocol_config.json3
-rw-r--r--chromium/chrome/browser/devtools/protocol/target_handler.cc214
-rw-r--r--chromium/chrome/browser/devtools/protocol/target_handler.h25
-rw-r--r--chromium/chrome/browser/devtools/remote_debugging_server.cc4
-rw-r--r--chromium/chrome/browser/engagement/BUILD.gn3
-rw-r--r--chromium/chrome/browser/extensions/BUILD.gn31
-rw-r--r--chromium/chrome/browser/extensions/api/activity_log_private/activity_log_private_api.cc2
-rw-r--r--chromium/chrome/browser/extensions/api/automation/automation_apitest.cc5
-rw-r--r--chromium/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc8
-rw-r--r--chromium/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc59
-rw-r--r--chromium/chrome/browser/extensions/api/autotest_private/autotest_private_api.h26
-rw-r--r--chromium/chrome/browser/extensions/api/autotest_private/autotest_private_apitest.cc6
-rw-r--r--chromium/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_apitest.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_apitest_chromeos.cc2
-rw-r--r--chromium/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc11
-rw-r--r--chromium/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_apitest.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/bookmarks/bookmark_apitest.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/bookmarks/bookmarks_api.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/browsing_data/browsing_data_test.cc3
-rw-r--r--chromium/chrome/browser/extensions/api/cast_streaming/OWNERS2
-rw-r--r--chromium/chrome/browser/extensions/api/cast_streaming/cast_streaming_apitest.cc56
-rw-r--r--chromium/chrome/browser/extensions/api/cast_streaming/performance_test.cc9
-rw-r--r--chromium/chrome/browser/extensions/api/certificate_provider/certificate_provider_apitest.cc6
-rw-r--r--chromium/chrome/browser/extensions/api/chrome_extensions_api_client.cc27
-rw-r--r--chromium/chrome/browser/extensions/api/chrome_extensions_api_client.h3
-rw-r--r--chromium/chrome/browser/extensions/api/chrome_extensions_api_client_unittest.cc37
-rw-r--r--chromium/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_api.cc57
-rw-r--r--chromium/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_api.h21
-rw-r--r--chromium/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_apitest.cc6
-rw-r--r--chromium/chrome/browser/extensions/api/command_line_private/command_line_private_apitest.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/cookies/cookies_api.cc33
-rw-r--r--chromium/chrome/browser/extensions/api/dashboard_private/dashboard_private_api.cc2
-rw-r--r--chromium/chrome/browser/extensions/api/data_reduction_proxy/data_reduction_proxy_api.cc7
-rw-r--r--chromium/chrome/browser/extensions/api/debugger/debugger_api.cc12
-rw-r--r--chromium/chrome/browser/extensions/api/debugger/debugger_apitest.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/debugger/debugger_extension_apitest.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/debugger/extension_dev_tools_infobar.cc10
-rw-r--r--chromium/chrome/browser/extensions/api/declarative_content/declarative_content_apitest.cc14
-rw-r--r--chromium/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_apitest.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_browsertest.cc223
-rw-r--r--chromium/chrome/browser/extensions/api/declarative_net_request/rule_indexing_unittest.cc5
-rw-r--r--chromium/chrome/browser/extensions/api/declarative_net_request/ruleset_manager_unittest.cc101
-rw-r--r--chromium/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc1
-rw-r--r--chromium/chrome/browser/extensions/api/desktop_capture/desktop_capture_apitest.cc2
-rw-r--r--chromium/chrome/browser/extensions/api/developer_private/developer_private_api.cc140
-rw-r--r--chromium/chrome/browser/extensions/api/developer_private/developer_private_api.h30
-rw-r--r--chromium/chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc133
-rw-r--r--chromium/chrome/browser/extensions/api/developer_private/developer_private_apitest.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/developer_private/extension_info_generator.cc44
-rw-r--r--chromium/chrome/browser/extensions/api/developer_private/extension_info_generator.h5
-rw-r--r--chromium/chrome/browser/extensions/api/developer_private/extension_info_generator_unittest.cc70
-rw-r--r--chromium/chrome/browser/extensions/api/downloads/downloads_api.cc179
-rw-r--r--chromium/chrome/browser/extensions/api/downloads/downloads_api.h11
-rw-r--r--chromium/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc136
-rw-r--r--chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc400
-rw-r--r--chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.h199
-rw-r--r--chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api_chromeos_unittest.cc463
-rw-r--r--chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_connection_manager.cc6
-rw-r--r--chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_crypto_delegate.h48
-rw-r--r--chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_crypto_delegate_chromeos.cc133
-rw-r--r--chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_crypto_delegate_stub.cc57
-rw-r--r--chromium/chrome/browser/extensions/api/enterprise_device_attributes/enterprise_device_attributes_apitest.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_api_unittest.cc2
-rw-r--r--chromium/chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_apitest_nss.cc15
-rw-r--r--chromium/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.cc8
-rw-r--r--chromium/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.h2
-rw-r--r--chromium/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api_unittest.cc2
-rw-r--r--chromium/chrome/browser/extensions/api/enterprise_reporting_private/chrome_desktop_report_request_helper.cc91
-rw-r--r--chromium/chrome/browser/extensions/api/enterprise_reporting_private/chrome_desktop_report_request_helper_unittest.cc98
-rw-r--r--chromium/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_api.cc3
-rw-r--r--chromium/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_unittest.cc13
-rw-r--r--chromium/chrome/browser/extensions/api/extension_action/browser_action_browsertest.cc1
-rw-r--r--chromium/chrome/browser/extensions/api/extension_action/extension_action_api.cc29
-rw-r--r--chromium/chrome/browser/extensions/api/extension_action/extension_action_api.h9
-rw-r--r--chromium/chrome/browser/extensions/api/extension_action/extension_action_apitest.cc61
-rw-r--r--chromium/chrome/browser/extensions/api/feedback_private/feedback_browsertest.cc1
-rw-r--r--chromium/chrome/browser/extensions/api/file_system/chrome_file_system_delegate.cc35
-rw-r--r--chromium/chrome/browser/extensions/api/file_system/consent_provider_unittest.cc12
-rw-r--r--chromium/chrome/browser/extensions/api/file_system/file_system_apitest.cc16
-rw-r--r--chromium/chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc2
-rw-r--r--chromium/chrome/browser/extensions/api/font_settings/font_settings_apitest.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/history/history_api.cc12
-rw-r--r--chromium/chrome/browser/extensions/api/history/history_api.h5
-rw-r--r--chromium/chrome/browser/extensions/api/i18n/i18n_apitest.cc9
-rw-r--r--chromium/chrome/browser/extensions/api/identity/gaia_web_auth_flow_unittest.cc2
-rw-r--r--chromium/chrome/browser/extensions/api/identity/identity_apitest.cc264
-rw-r--r--chromium/chrome/browser/extensions/api/idltest/idltest_apitest.cc2
-rw-r--r--chromium/chrome/browser/extensions/api/image_writer_private/image_writer_private_apitest.cc1
-rw-r--r--chromium/chrome/browser/extensions/api/image_writer_private/operation_unittest.cc1
-rw-r--r--chromium/chrome/browser/extensions/api/image_writer_private/test_utils.h3
-rw-r--r--chromium/chrome/browser/extensions/api/inline_install_private/inline_install_private_api.cc6
-rw-r--r--chromium/chrome/browser/extensions/api/input_ime/input_ime_api.cc1
-rw-r--r--chromium/chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.cc71
-rw-r--r--chromium/chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.h13
-rw-r--r--chromium/chrome/browser/extensions/api/input_ime/input_ime_apitest_chromeos.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/instance_id/instance_id_api.cc5
-rw-r--r--chromium/chrome/browser/extensions/api/management/chrome_management_api_delegate.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/management/chrome_management_api_delegate.h1
-rw-r--r--chromium/chrome/browser/extensions/api/management/management_api_browsertest.cc29
-rw-r--r--chromium/chrome/browser/extensions/api/management/management_api_unittest.cc105
-rw-r--r--chromium/chrome/browser/extensions/api/management/management_apitest.cc2
-rw-r--r--chromium/chrome/browser/extensions/api/management/management_browsertest.cc30
-rw-r--r--chromium/chrome/browser/extensions/api/mdns/mdns_api_unittest.cc5
-rw-r--r--chromium/chrome/browser/extensions/api/mdns/mdns_apitest.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/media_galleries/blob_data_source_factory.cc83
-rw-r--r--chromium/chrome/browser/extensions/api/media_galleries/blob_data_source_factory.h45
-rw-r--r--chromium/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc17
-rw-r--r--chromium/chrome/browser/extensions/api/media_galleries/media_galleries_api.h3
-rw-r--r--chromium/chrome/browser/extensions/api/media_galleries/media_galleries_api_util.cc63
-rw-r--r--chromium/chrome/browser/extensions/api/media_galleries/media_galleries_api_util.h25
-rw-r--r--chromium/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc2
-rw-r--r--chromium/chrome/browser/extensions/api/media_galleries/media_galleries_watch_apitest.cc8
-rw-r--r--chromium/chrome/browser/extensions/api/media_perception_private/media_perception_api_delegate_chromeos.cc9
-rw-r--r--chromium/chrome/browser/extensions/api/messaging/native_messaging_apitest.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/messaging/native_messaging_test_util.cc3
-rw-r--r--chromium/chrome/browser/extensions/api/messaging/native_process_launcher_posix.cc2
-rw-r--r--chromium/chrome/browser/extensions/api/metrics_private/metrics_apitest.cc6
-rw-r--r--chromium/chrome/browser/extensions/api/module/module_apitest.cc3
-rw-r--r--chromium/chrome/browser/extensions/api/networking_config_chromeos_apitest_chromeos.cc26
-rw-r--r--chromium/chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc81
-rw-r--r--chromium/chrome/browser/extensions/api/networking_private/networking_private_service_client_apitest.cc13
-rw-r--r--chromium/chrome/browser/extensions/api/notifications/notifications_apitest.cc7
-rw-r--r--chromium/chrome/browser/extensions/api/omnibox/omnibox_api_interactive_test.cc9
-rw-r--r--chromium/chrome/browser/extensions/api/omnibox/omnibox_api_testbase.h2
-rw-r--r--chromium/chrome/browser/extensions/api/page_capture/page_capture_apitest.cc6
-rw-r--r--chromium/chrome/browser/extensions/api/passwords_private/passwords_private_api.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/permissions/permissions_api.cc82
-rw-r--r--chromium/chrome/browser/extensions/api/permissions/permissions_api.h6
-rw-r--r--chromium/chrome/browser/extensions/api/platform_keys/platform_keys_apitest_nss.cc131
-rw-r--r--chromium/chrome/browser/extensions/api/platform_keys/platform_keys_test_base.cc12
-rw-r--r--chromium/chrome/browser/extensions/api/platform_keys/platform_keys_test_base.h4
-rw-r--r--chromium/chrome/browser/extensions/api/preference/preference_api.cc2
-rw-r--r--chromium/chrome/browser/extensions/api/preference/preference_apitest.cc8
-rw-r--r--chromium/chrome/browser/extensions/api/processes/processes_api.cc3
-rw-r--r--chromium/chrome/browser/extensions/api/processes/processes_apitest.cc2
-rw-r--r--chromium/chrome/browser/extensions/api/resources_private/resources_private_apitest.cc8
-rw-r--r--chromium/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc8
-rw-r--r--chromium/chrome/browser/extensions/api/runtime/runtime_apitest.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/safe_browsing_private/OWNERS3
-rw-r--r--chromium/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router.cc143
-rw-r--r--chromium/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router.h68
-rw-r--r--chromium/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router_factory.cc59
-rw-r--r--chromium/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router_factory.h53
-rw-r--r--chromium/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router_unittest.cc182
-rw-r--r--chromium/chrome/browser/extensions/api/screenlock_private/screenlock_private_apitest.cc25
-rw-r--r--chromium/chrome/browser/extensions/api/sessions/sessions_apitest.cc2
-rw-r--r--chromium/chrome/browser/extensions/api/settings_private/prefs_util.cc38
-rw-r--r--chromium/chrome/browser/extensions/api/settings_private/settings_private_apitest.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api_unittest.cc2
-rw-r--r--chromium/chrome/browser/extensions/api/socket/mock_tcp_client_socket.h25
-rw-r--r--chromium/chrome/browser/extensions/api/socket/socket_apitest.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/socket/tcp_socket_unittest.cc18
-rw-r--r--chromium/chrome/browser/extensions/api/socket/tls_socket_unittest.cc39
-rw-r--r--chromium/chrome/browser/extensions/api/socket/udp_socket_unittest.cc1
-rw-r--r--chromium/chrome/browser/extensions/api/storage/settings_apitest.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/streams_private/streams_private_apitest.cc28
-rw-r--r--chromium/chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc8
-rw-r--r--chromium/chrome/browser/extensions/api/sync_file_system/sync_file_system_browsertest.cc2
-rw-r--r--chromium/chrome/browser/extensions/api/system_indicator/system_indicator_apitest.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/system_indicator/system_indicator_manager.h4
-rw-r--r--chromium/chrome/browser/extensions/api/system_private/system_private_api.cc44
-rw-r--r--chromium/chrome/browser/extensions/api/system_private/system_private_api.h12
-rw-r--r--chromium/chrome/browser/extensions/api/system_private/system_private_apitest.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/tab_capture/OWNERS4
-rw-r--r--chromium/chrome/browser/extensions/api/tab_capture/offscreen_tab.cc8
-rw-r--r--chromium/chrome/browser/extensions/api/tab_capture/offscreen_tab.h6
-rw-r--r--chromium/chrome/browser/extensions/api/tab_capture/tab_capture_apitest.cc34
-rw-r--r--chromium/chrome/browser/extensions/api/tab_capture/tab_capture_performancetest.cc9
-rw-r--r--chromium/chrome/browser/extensions/api/tabs/tabs_api.cc54
-rw-r--r--chromium/chrome/browser/extensions/api/tabs/tabs_api_unittest.cc70
-rw-r--r--chromium/chrome/browser/extensions/api/tabs/tabs_event_router.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/tabs/tabs_event_router.h4
-rw-r--r--chromium/chrome/browser/extensions/api/tabs/tabs_test.cc33
-rw-r--r--chromium/chrome/browser/extensions/api/terminal/terminal_private_apitest.cc4
-rw-r--r--chromium/chrome/browser/extensions/api/top_sites/top_sites_api.cc26
-rw-r--r--chromium/chrome/browser/extensions/api/top_sites/top_sites_api.h10
-rw-r--r--chromium/chrome/browser/extensions/api/virtual_keyboard_private/chrome_virtual_keyboard_delegate.cc5
-rw-r--r--chromium/chrome/browser/extensions/api/vpn_provider/vpn_provider_apitest.cc8
-rw-r--r--chromium/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc17
-rw-r--r--chromium/chrome/browser/extensions/api/web_request/web_request_apitest.cc501
-rw-r--r--chromium/chrome/browser/extensions/api/web_request/web_request_permissions_unittest.cc29
-rw-r--r--chromium/chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.cc6
-rw-r--r--chromium/chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_api.h17
-rw-r--r--chromium/chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_api_stub.cc95
-rw-r--r--chromium/chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_apitest.cc6
-rw-r--r--chromium/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc75
-rw-r--r--chromium/chrome/browser/extensions/api/webstore_private/webstore_private_api.h19
-rw-r--r--chromium/chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc47
-rw-r--r--chromium/chrome/browser/extensions/api/webstore_widget_private/app_installer.cc1
-rw-r--r--chromium/chrome/browser/extensions/api/webstore_widget_private/webstore_widget_private_api.cc8
-rw-r--r--chromium/chrome/browser/media/BUILD.gn1
-rw-r--r--chromium/chrome/browser/media/media_engagement_score_details.mojom9
-rw-r--r--chromium/chrome/browser/media/router/BUILD.gn6
-rw-r--r--chromium/chrome/browser/media/router/discovery/BUILD.gn6
-rw-r--r--chromium/chrome/browser/printing/background_printing_manager.cc33
-rw-r--r--chromium/chrome/browser/printing/background_printing_manager.h21
-rw-r--r--chromium/chrome/browser/printing/cloud_print/cloud_print_proxy_service_unittest.cc4
-rw-r--r--chromium/chrome/browser/printing/cloud_print/privet_device_lister_unittest.cc8
-rw-r--r--chromium/chrome/browser/printing/cloud_print/privet_http_impl.cc25
-rw-r--r--chromium/chrome/browser/printing/cloud_print/privet_http_impl.h9
-rw-r--r--chromium/chrome/browser/printing/cloud_print/privet_http_unittest.cc77
-rw-r--r--chromium/chrome/browser/printing/cloud_print/privet_notifications_unittest.cc2
-rw-r--r--chromium/chrome/browser/printing/cloud_print/privet_url_fetcher.cc21
-rw-r--r--chromium/chrome/browser/printing/cloud_print/privet_url_fetcher.h4
-rw-r--r--chromium/chrome/browser/printing/cloud_print/privet_url_fetcher_unittest.cc2
-rw-r--r--chromium/chrome/browser/printing/pdf_to_emf_converter.cc419
-rw-r--r--chromium/chrome/browser/printing/pdf_to_emf_converter_browsertest.cc18
-rw-r--r--chromium/chrome/browser/printing/print_browsertest.cc4
-rw-r--r--chromium/chrome/browser/printing/print_job.cc162
-rw-r--r--chromium/chrome/browser/printing/print_job.h85
-rw-r--r--chromium/chrome/browser/printing/print_job_manager.cc8
-rw-r--r--chromium/chrome/browser/printing/print_job_manager.h6
-rw-r--r--chromium/chrome/browser/printing/print_job_unittest.cc36
-rw-r--r--chromium/chrome/browser/printing/print_job_worker.cc185
-rw-r--r--chromium/chrome/browser/printing/print_job_worker.h24
-rw-r--r--chromium/chrome/browser/printing/print_job_worker_owner.cc28
-rw-r--r--chromium/chrome/browser/printing/print_job_worker_owner.h64
-rw-r--r--chromium/chrome/browser/printing/print_preview_data_service.cc16
-rw-r--r--chromium/chrome/browser/printing/print_preview_data_service.h3
-rw-r--r--chromium/chrome/browser/printing/print_preview_message_handler.cc18
-rw-r--r--chromium/chrome/browser/printing/print_preview_message_handler.h7
-rw-r--r--chromium/chrome/browser/printing/print_test_utils.cc1
-rw-r--r--chromium/chrome/browser/printing/print_view_manager.cc2
-rw-r--r--chromium/chrome/browser/printing/print_view_manager.h2
-rw-r--r--chromium/chrome/browser/printing/print_view_manager_base.cc119
-rw-r--r--chromium/chrome/browser/printing/print_view_manager_base.h31
-rw-r--r--chromium/chrome/browser/printing/print_view_manager_common.cc4
-rw-r--r--chromium/chrome/browser/printing/print_view_manager_common.h2
-rw-r--r--chromium/chrome/browser/printing/print_view_manager_unittest.cc14
-rw-r--r--chromium/chrome/browser/printing/printer_manager_dialog_win.cc2
-rw-r--r--chromium/chrome/browser/printing/printer_query.cc25
-rw-r--r--chromium/chrome/browser/printing/printer_query.h56
-rw-r--r--chromium/chrome/browser/printing/printing_layout_browsertest.cc7
-rw-r--r--chromium/chrome/browser/printing/pwg_raster_converter.cc171
-rw-r--r--chromium/chrome/browser/printing/pwg_raster_converter.h14
-rw-r--r--chromium/chrome/browser/printing/pwg_raster_converter_browsertest.cc69
-rw-r--r--chromium/chrome/browser/printing/test_print_job.cc19
-rw-r--r--chromium/chrome/browser/printing/test_print_job.h22
-rw-r--r--chromium/chrome/browser/printing/test_printer_query.h1
-rw-r--r--chromium/chrome/browser/profiling_host/BUILD.gn25
-rw-r--r--chromium/chrome/browser/resource_coordinator/tab_ranker/BUILD.gn31
-rw-r--r--chromium/chrome/browser/resources/BUILD.gn31
-rw-r--r--chromium/chrome/browser/resources/PRESUBMIT.py6
-rw-r--r--chromium/chrome/browser/resources/about_conflicts.html39
-rw-r--r--chromium/chrome/browser/resources/bookmark_manager/css/bmm.css392
-rw-r--r--chromium/chrome/browser/resources/bookmark_manager/images/2x/bookmark_manager_search.pngbin1904 -> 0 bytes
-rw-r--r--chromium/chrome/browser/resources/bookmark_manager/images/2x/bookmark_manager_search_rtl.pngbin1888 -> 0 bytes
-rw-r--r--chromium/chrome/browser/resources/bookmark_manager/images/2x/bookmarks_section_32.pngbin4766 -> 0 bytes
-rw-r--r--chromium/chrome/browser/resources/bookmark_manager/images/bookmark_manager_search.pngbin737 -> 0 bytes
-rw-r--r--chromium/chrome/browser/resources/bookmark_manager/images/bookmark_manager_search_rtl.pngbin737 -> 0 bytes
-rw-r--r--chromium/chrome/browser/resources/bookmark_manager/images/bookmarks_section_32.pngbin1948 -> 0 bytes
-rw-r--r--chromium/chrome/browser/resources/bookmark_manager/js/bmm.js261
-rw-r--r--chromium/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js658
-rw-r--r--chromium/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_tree.js323
-rw-r--r--chromium/chrome/browser/resources/bookmark_manager/js/bmm_test.html113
-rw-r--r--chromium/chrome/browser/resources/bookmark_manager/js/compiled_resources2.gyp58
-rw-r--r--chromium/chrome/browser/resources/bookmark_manager/js/dnd.js562
-rw-r--r--chromium/chrome/browser/resources/bookmark_manager/js/main.js1547
-rw-r--r--chromium/chrome/browser/resources/bookmark_manager/main.html207
-rw-r--r--chromium/chrome/browser/resources/bookmark_manager/manifest.json25
-rw-r--r--chromium/chrome/browser/resources/chromeos/chromevox/BUILD.gn3
-rw-r--r--chromium/chrome/browser/resources/chromeos/chromevox/strings/chromevox_strings.grd171
-rw-r--r--chromium/chrome/browser/resources/chromeos/crosh_builtin/manifest.json12
-rw-r--r--chromium/chrome/browser/resources/chromeos/multidevice_setup/compiled_resources2.gyp73
-rw-r--r--chromium/chrome/browser/resources/chromeos/multidevice_setup/multidevice_setup_resources.grd59
-rw-r--r--chromium/chrome/browser/resources/chromeos/wallpaper_manager/manifest.json8
-rw-r--r--chromium/chrome/browser/resources/chromeos/zip_archiver/BUILD.gn7
-rw-r--r--chromium/chrome/browser/resources/chromeos/zip_archiver/cpp/BUILD.gn1
-rw-r--r--chromium/chrome/browser/resources/component_extension_resources.grd17
-rw-r--r--chromium/chrome/browser/resources/cryptotoken/BUILD.gn50
-rw-r--r--chromium/chrome/browser/resources/cryptotoken/compiled_resources2.gyp47
-rw-r--r--chromium/chrome/browser/resources/device_log_ui/device_log_ui.html4
-rw-r--r--chromium/chrome/browser/resources/discards/discards.css10
-rw-r--r--chromium/chrome/browser/resources/discards/discards.html9
-rw-r--r--chromium/chrome/browser/resources/discards/discards.js25
-rw-r--r--chromium/chrome/browser/resources/download_internals/BUILD.gn36
-rw-r--r--chromium/chrome/browser/resources/download_internals/compiled_resources2.gyp33
-rw-r--r--chromium/chrome/browser/resources/extensions/OWNERS5
-rw-r--r--chromium/chrome/browser/resources/extensions/apps_developer_tools_promo_48.pngbin600 -> 0 bytes
-rw-r--r--chromium/chrome/browser/resources/extensions/compiled_resources2.gyp66
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_code.js119
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_command_list.js425
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_commands_overlay.css80
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_commands_overlay.html55
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_commands_overlay.js85
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_error.css111
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_error.html21
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_error.js376
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_error_overlay.css72
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_error_overlay.html39
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_error_overlay.js502
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_error_severity_fatal.pngbin218 -> 0 bytes
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_error_severity_info.pngbin304 -> 0 bytes
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_error_severity_warning.pngbin242 -> 0 bytes
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_focus_manager.js27
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_list.js1066
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_load_error.css50
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_load_error.html27
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_loader.js234
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_options_overlay.css28
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_options_overlay.html13
-rw-r--r--chromium/chrome/browser/resources/extensions/extension_options_overlay.js257
-rw-r--r--chromium/chrome/browser/resources/extensions/extensions.css443
-rw-r--r--chromium/chrome/browser/resources/extensions/extensions.html283
-rw-r--r--chromium/chrome/browser/resources/extensions/extensions.js461
-rw-r--r--chromium/chrome/browser/resources/extensions/focus_row.js30
-rw-r--r--chromium/chrome/browser/resources/extensions/pack_extension_overlay.css23
-rw-r--r--chromium/chrome/browser/resources/extensions/pack_extension_overlay.html33
-rw-r--r--chromium/chrome/browser/resources/extensions/pack_extension_overlay.js169
-rw-r--r--chromium/chrome/browser/resources/feedback/css/sys_info.css1
-rw-r--r--chromium/chrome/browser/resources/feedback/js/take_screenshot.js4
-rw-r--r--chromium/chrome/browser/resources/gaia_auth_host/authenticator.js41
-rw-r--r--chromium/chrome/browser/resources/inspect/inspect.js2
-rw-r--r--chromium/chrome/browser/resources/interventions_internals/index.html10
-rw-r--r--chromium/chrome/browser/resources/local_ntp/custom_backgrounds.css281
-rw-r--r--chromium/chrome/browser/resources/local_ntp/custom_backgrounds.js402
-rw-r--r--chromium/chrome/browser/resources/local_ntp/local_ntp.css205
-rw-r--r--chromium/chrome/browser/resources/local_ntp/local_ntp.html68
-rw-r--r--chromium/chrome/browser/resources/local_ntp/local_ntp.js207
-rw-r--r--chromium/chrome/browser/resources/local_ntp/most_visited_single.css224
-rw-r--r--chromium/chrome/browser/resources/local_ntp/most_visited_single.js200
-rw-r--r--chromium/chrome/browser/resources/md_bookmarks/BUILD.gn1
-rw-r--r--chromium/chrome/browser/resources/md_bookmarks/command_manager.js2
-rw-r--r--chromium/chrome/browser/resources/md_bookmarks/list.html3
-rw-r--r--chromium/chrome/browser/resources/md_bookmarks/list.js30
-rw-r--r--chromium/chrome/browser/resources/md_bookmarks/reducers.js34
-rw-r--r--chromium/chrome/browser/resources/md_bookmarks/toast_manager.html8
-rw-r--r--chromium/chrome/browser/resources/md_downloads/BUILD.gn89
-rw-r--r--chromium/chrome/browser/resources/md_downloads/compiled_resources2.gyp84
-rw-r--r--chromium/chrome/browser/resources/md_downloads/downloads.html2
-rw-r--r--chromium/chrome/browser/resources/md_downloads/item.html16
-rw-r--r--chromium/chrome/browser/resources/md_downloads/manager.js6
-rw-r--r--chromium/chrome/browser/resources/md_extensions/BUILD.gn299
-rw-r--r--chromium/chrome/browser/resources/md_extensions/compiled_resources2.gyp286
-rw-r--r--chromium/chrome/browser/resources/md_extensions/detail_view.html5
-rw-r--r--chromium/chrome/browser/resources/md_extensions/detail_view.js13
-rw-r--r--chromium/chrome/browser/resources/md_extensions/drag_and_drop_handler.js28
-rw-r--r--chromium/chrome/browser/resources/md_extensions/drop_overlay.js2
-rw-r--r--chromium/chrome/browser/resources/md_extensions/error_page.html21
-rw-r--r--chromium/chrome/browser/resources/md_extensions/error_page.js50
-rw-r--r--chromium/chrome/browser/resources/md_extensions/extensions.html4
-rw-r--r--chromium/chrome/browser/resources/md_extensions/item.html8
-rw-r--r--chromium/chrome/browser/resources/md_extensions/item_list.html3
-rw-r--r--chromium/chrome/browser/resources/md_extensions/item_list.js7
-rw-r--r--chromium/chrome/browser/resources/md_extensions/keyboard_shortcuts.html2
-rw-r--r--chromium/chrome/browser/resources/md_extensions/keyboard_shortcuts.js43
-rw-r--r--chromium/chrome/browser/resources/md_extensions/kiosk_dialog.html8
-rw-r--r--chromium/chrome/browser/resources/md_extensions/kiosk_dialog.js11
-rw-r--r--chromium/chrome/browser/resources/md_extensions/manager.html11
-rw-r--r--chromium/chrome/browser/resources/md_extensions/manager.js22
-rw-r--r--chromium/chrome/browser/resources/md_extensions/navigation_helper.js12
-rw-r--r--chromium/chrome/browser/resources/md_extensions/options_dialog.html7
-rw-r--r--chromium/chrome/browser/resources/md_extensions/service.js60
-rw-r--r--chromium/chrome/browser/resources/md_extensions/shortcut_input.html4
-rw-r--r--chromium/chrome/browser/resources/md_extensions/shortcut_input.js20
-rw-r--r--chromium/chrome/browser/resources/md_extensions/toggle_row.html2
-rw-r--r--chromium/chrome/browser/resources/md_extensions/toggle_row.js12
-rw-r--r--chromium/chrome/browser/resources/md_extensions/toolbar.html32
-rw-r--r--chromium/chrome/browser/resources/md_extensions/toolbar.js2
-rw-r--r--chromium/chrome/browser/resources/md_history/BUILD.gn150
-rw-r--r--chromium/chrome/browser/resources/md_history/compiled_resources2.gyp147
-rw-r--r--chromium/chrome/browser/resources/md_history/history_item.html71
-rw-r--r--chromium/chrome/browser/resources/md_history/history_item.js30
-rw-r--r--chromium/chrome/browser/resources/md_history/lazy_load.html1
-rw-r--r--chromium/chrome/browser/resources/md_history/shared_style.html1
-rw-r--r--chromium/chrome/browser/resources/md_history/synced_device_card.html3
-rw-r--r--chromium/chrome/browser/resources/md_user_manager/BUILD.gn54
-rw-r--r--chromium/chrome/browser/resources/md_user_manager/compiled_resources2.gyp75
-rw-r--r--chromium/chrome/browser/resources/md_user_manager/create_profile.html84
-rw-r--r--chromium/chrome/browser/resources/md_user_manager/create_profile.js299
-rw-r--r--chromium/chrome/browser/resources/md_user_manager/error_dialog.html2
-rw-r--r--chromium/chrome/browser/resources/md_user_manager/import_supervised_user.html94
-rw-r--r--chromium/chrome/browser/resources/md_user_manager/import_supervised_user.js103
-rw-r--r--chromium/chrome/browser/resources/md_user_manager/profile_browser_proxy.js85
-rw-r--r--chromium/chrome/browser/resources/md_user_manager/supervised_user_create_confirm.html63
-rw-r--r--chromium/chrome/browser/resources/md_user_manager/supervised_user_create_confirm.js145
-rw-r--r--chromium/chrome/browser/resources/md_user_manager/supervised_user_learn_more.html55
-rw-r--r--chromium/chrome/browser/resources/md_user_manager/supervised_user_learn_more.js50
-rw-r--r--chromium/chrome/browser/resources/md_user_manager/user_manager_pages.html2
-rw-r--r--chromium/chrome/browser/resources/md_user_manager/user_manager_tutorial.js11
-rw-r--r--chromium/chrome/browser/resources/media/media_engagement.js22
-rw-r--r--chromium/chrome/browser/resources/media_router/BUILD.gn58
-rw-r--r--chromium/chrome/browser/resources/media_router/OWNERS1
-rw-r--r--chromium/chrome/browser/resources/media_router/compiled_resources2.gyp47
-rw-r--r--chromium/chrome/browser/resources/media_router/elements/issue_banner/BUILD.gn18
-rw-r--r--chromium/chrome/browser/resources/media_router/elements/issue_banner/compiled_resources2.gyp15
-rw-r--r--chromium/chrome/browser/resources/media_router/elements/media_router_container/BUILD.gn39
-rw-r--r--chromium/chrome/browser/resources/media_router/elements/media_router_container/compiled_resources2.gyp36
-rw-r--r--chromium/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.css12
-rw-r--r--chromium/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.html25
-rw-r--r--chromium/chrome/browser/resources/media_router/elements/media_router_header/BUILD.gn19
-rw-r--r--chromium/chrome/browser/resources/media_router/elements/media_router_header/compiled_resources2.gyp16
-rw-r--r--chromium/chrome/browser/resources/media_router/elements/media_router_search_highlighter/BUILD.gn17
-rw-r--r--chromium/chrome/browser/resources/media_router/elements/media_router_search_highlighter/compiled_resources2.gyp14
-rw-r--r--chromium/chrome/browser/resources/media_router/elements/route_controls/BUILD.gn28
-rw-r--r--chromium/chrome/browser/resources/media_router/elements/route_controls/compiled_resources2.gyp25
-rw-r--r--chromium/chrome/browser/resources/media_router/elements/route_controls/route_controls.css11
-rw-r--r--chromium/chrome/browser/resources/media_router/elements/route_controls/route_controls.html9
-rw-r--r--chromium/chrome/browser/resources/media_router/elements/route_controls/route_controls.js14
-rw-r--r--chromium/chrome/browser/resources/media_router/elements/route_details/BUILD.gn21
-rw-r--r--chromium/chrome/browser/resources/media_router/elements/route_details/compiled_resources2.gyp18
-rw-r--r--chromium/chrome/browser/resources/media_router/elements/route_details/route_details.js2
-rw-r--r--chromium/chrome/browser/resources/net_internals/browser_bridge.js13
-rw-r--r--chromium/chrome/browser/resources/net_internals/index.html1
-rw-r--r--chromium/chrome/browser/resources/net_internals/index.js1
-rw-r--r--chromium/chrome/browser/resources/net_internals/main.js1
-rw-r--r--chromium/chrome/browser/resources/net_internals/reporting_view.html86
-rw-r--r--chromium/chrome/browser/resources/net_internals/reporting_view.js397
-rw-r--r--chromium/chrome/browser/resources/net_internals/util.js16
-rw-r--r--chromium/chrome/browser/resources/ntp4/BUILD.gn56
-rw-r--r--chromium/chrome/browser/resources/ntp4/apps_page.js2
-rw-r--r--chromium/chrome/browser/resources/ntp4/compiled_resources2.gyp52
-rw-r--r--chromium/chrome/browser/resources/offline_pages/BUILD.gn28
-rw-r--r--chromium/chrome/browser/resources/offline_pages/compiled_resources2.gyp25
-rw-r--r--chromium/chrome/browser/resources/offline_pages/offline_internals.html6
-rw-r--r--chromium/chrome/browser/resources/offline_pages/offline_internals.js92
-rw-r--r--chromium/chrome/browser/resources/omnibox/omnibox.js5
-rw-r--r--chromium/chrome/browser/resources/page_not_available_for_guest/app.html19
-rw-r--r--chromium/chrome/browser/resources/pdf/BUILD.gn60
-rw-r--r--chromium/chrome/browser/resources/pdf/browser_api.js16
-rw-r--r--chromium/chrome/browser/resources/pdf/compiled_resources2.gyp58
-rw-r--r--chromium/chrome/browser/resources/pdf/coords_transformer.js2
-rw-r--r--chromium/chrome/browser/resources/pdf/elements/viewer-bookmark/BUILD.gn17
-rw-r--r--chromium/chrome/browser/resources/pdf/elements/viewer-bookmark/compiled_resources2.gyp15
-rw-r--r--chromium/chrome/browser/resources/pdf/elements/viewer-error-screen/BUILD.gn17
-rw-r--r--chromium/chrome/browser/resources/pdf/elements/viewer-error-screen/compiled_resources2.gyp15
-rw-r--r--chromium/chrome/browser/resources/pdf/elements/viewer-error-screen/viewer-error-screen.html14
-rw-r--r--chromium/chrome/browser/resources/pdf/elements/viewer-page-indicator/BUILD.gn14
-rw-r--r--chromium/chrome/browser/resources/pdf/elements/viewer-page-indicator/compiled_resources2.gyp12
-rw-r--r--chromium/chrome/browser/resources/pdf/elements/viewer-page-selector/BUILD.gn14
-rw-r--r--chromium/chrome/browser/resources/pdf/elements/viewer-page-selector/compiled_resources2.gyp12
-rw-r--r--chromium/chrome/browser/resources/pdf/elements/viewer-page-selector/viewer-page-selector.html12
-rw-r--r--chromium/chrome/browser/resources/pdf/elements/viewer-password-screen/BUILD.gn17
-rw-r--r--chromium/chrome/browser/resources/pdf/elements/viewer-password-screen/compiled_resources2.gyp15
-rw-r--r--chromium/chrome/browser/resources/pdf/elements/viewer-pdf-toolbar/viewer-pdf-toolbar.html6
-rw-r--r--chromium/chrome/browser/resources/pdf/gesture_detector.js28
-rw-r--r--chromium/chrome/browser/resources/pdf/main.js4
-rw-r--r--chromium/chrome/browser/resources/pdf/metrics.js12
-rw-r--r--chromium/chrome/browser/resources/pdf/navigator.js18
-rw-r--r--chromium/chrome/browser/resources/pdf/open_pdf_params_parser.js13
-rw-r--r--chromium/chrome/browser/resources/pdf/pdf.js85
-rw-r--r--chromium/chrome/browser/resources/pdf/pdf_scripting_api.js14
-rw-r--r--chromium/chrome/browser/resources/pdf/toolbar_manager.js6
-rw-r--r--chromium/chrome/browser/resources/pdf/viewport.js61
-rw-r--r--chromium/chrome/browser/resources/pdf/viewport_scroller.js23
-rw-r--r--chromium/chrome/browser/resources/pdf/zoom_manager.js11
-rw-r--r--chromium/chrome/browser/resources/plugin_metadata/plugins_linux.json6
-rw-r--r--chromium/chrome/browser/resources/plugin_metadata/plugins_mac.json6
-rw-r--r--chromium/chrome/browser/resources/plugin_metadata/plugins_win.json6
-rw-r--r--chromium/chrome/browser/resources/policy.html4
-rw-r--r--chromium/chrome/browser/resources/policy_base.js5
-rw-r--r--chromium/chrome/browser/resources/policy_tool.html1
-rw-r--r--chromium/chrome/browser/resources/policy_tool.js8
-rw-r--r--chromium/chrome/browser/resources/print_preview/BUILD.gn212
-rw-r--r--chromium/chrome/browser/resources/print_preview/compiled_resources2.gyp69
-rw-r--r--chromium/chrome/browser/resources/print_preview/component.js4
-rw-r--r--chromium/chrome/browser/resources/print_preview/data/BUILD.gn139
-rw-r--r--chromium/chrome/browser/resources/print_preview/data/compiled_resources2.gyp136
-rw-r--r--chromium/chrome/browser/resources/print_preview/data/destination.html1
-rw-r--r--chromium/chrome/browser/resources/print_preview/data/destination.js8
-rw-r--r--chromium/chrome/browser/resources/print_preview/data/destination_store.js13
-rw-r--r--chromium/chrome/browser/resources/print_preview/data/ticket_items/dpi.js10
-rw-r--r--chromium/chrome/browser/resources/print_preview/data/ticket_items/media_size.js8
-rw-r--r--chromium/chrome/browser/resources/print_preview/native_layer.js8
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/BUILD.gn370
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/advanced_settings_dialog.html6
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/advanced_settings_dialog.js17
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/app.html82
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/app.js151
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/button_css.html9
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/color_settings.html4
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/color_settings.js8
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/compiled_resources2.gyp324
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/copies_settings.js10
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/destination_dialog.html76
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/destination_dialog.js107
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/destination_list.html3
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/destination_list.js5
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/destination_list_item.html20
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/destination_list_item.js73
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/destination_settings.html1
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/dpi_settings.html1
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/header.html1
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/header.js34
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/input_behavior.js7
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/layout_settings.html4
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/layout_settings.js8
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/link_container.html5
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/margins_settings.html4
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/margins_settings.js8
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/model.js120
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/more_settings.html53
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/more_settings.js52
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/number_settings_section.js4
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/other_options_settings.html24
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/other_options_settings.js49
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/pages_per_sheet_settings.html30
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/pages_per_sheet_settings.js28
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/pages_settings.html3
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/pages_settings.js18
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/preview_area.html15
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/preview_area.js242
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/provisional_destination_resolver.html86
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/provisional_destination_resolver.js157
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/scaling_settings.js183
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/search_dialog_css.html21
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/select_behavior.html3
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/select_behavior.js60
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/settings_behavior.js6
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/settings_select.html3
-rw-r--r--chromium/chrome/browser/resources/print_preview/new/settings_select.js12
-rw-r--r--chromium/chrome/browser/resources/print_preview/preview_generator.js20
-rw-r--r--chromium/chrome/browser/resources/print_preview/print_preview.js4
-rw-r--r--chromium/chrome/browser/resources/print_preview/print_preview_resources.grd33
-rw-r--r--chromium/chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings_item.js2
-rw-r--r--chromium/chrome/browser/resources/print_preview/settings/layout_settings.js5
-rw-r--r--chromium/chrome/browser/resources/print_preview/settings/margin_settings.js6
-rw-r--r--chromium/chrome/browser/resources/print_preview/settings/other_options_settings.js8
-rw-r--r--chromium/chrome/browser/resources/print_preview/settings/scaling_settings.js2
-rw-r--r--chromium/chrome/browser/resources/print_preview/settings/settings_section_select.js6
-rw-r--r--chromium/chrome/browser/resources/reset_password/BUILD.gn23
-rw-r--r--chromium/chrome/browser/resources/reset_password/OWNERS3
-rw-r--r--chromium/chrome/browser/resources/reset_password/reset_password.html63
-rw-r--r--chromium/chrome/browser/resources/reset_password/reset_password.js27
-rw-r--r--chromium/chrome/browser/resources/settings/BUILD.gn184
-rw-r--r--chromium/chrome/browser/resources/settings/a11y_page/BUILD.gn46
-rw-r--r--chromium/chrome/browser/resources/settings/a11y_page/a11y_page.html11
-rw-r--r--chromium/chrome/browser/resources/settings/a11y_page/compiled_resources2.gyp39
-rw-r--r--chromium/chrome/browser/resources/settings/a11y_page/externs.js23
-rw-r--r--chromium/chrome/browser/resources/settings/a11y_page/google_tts_engine_subpage.html40
-rw-r--r--chromium/chrome/browser/resources/settings/a11y_page/google_tts_engine_subpage.js38
-rw-r--r--chromium/chrome/browser/resources/settings/a11y_page/manage_a11y_page.html35
-rw-r--r--chromium/chrome/browser/resources/settings/a11y_page/manage_a11y_page.js35
-rw-r--r--chromium/chrome/browser/resources/settings/a11y_page/tts_subpage.html109
-rw-r--r--chromium/chrome/browser/resources/settings/a11y_page/tts_subpage.js293
-rw-r--r--chromium/chrome/browser/resources/settings/about_page/BUILD.gn53
-rw-r--r--chromium/chrome/browser/resources/settings/about_page/about_page.html4
-rw-r--r--chromium/chrome/browser/resources/settings/about_page/channel_switcher_dialog.html16
-rw-r--r--chromium/chrome/browser/resources/settings/about_page/compiled_resources2.gyp50
-rw-r--r--chromium/chrome/browser/resources/settings/about_page/detailed_build_info.html4
-rw-r--r--chromium/chrome/browser/resources/settings/android_apps_page/BUILD.gn41
-rw-r--r--chromium/chrome/browser/resources/settings/android_apps_page/compiled_resources2.gyp38
-rw-r--r--chromium/chrome/browser/resources/settings/animation/BUILD.gn28
-rw-r--r--chromium/chrome/browser/resources/settings/animation/compiled_resources2.gyp25
-rw-r--r--chromium/chrome/browser/resources/settings/appearance_page/BUILD.gn76
-rw-r--r--chromium/chrome/browser/resources/settings/appearance_page/appearance_fonts_page.html1
-rw-r--r--chromium/chrome/browser/resources/settings/appearance_page/appearance_page.html6
-rw-r--r--chromium/chrome/browser/resources/settings/appearance_page/compiled_resources2.gyp69
-rw-r--r--chromium/chrome/browser/resources/settings/basic_page/BUILD.gn25
-rw-r--r--chromium/chrome/browser/resources/settings/basic_page/basic_page.html29
-rw-r--r--chromium/chrome/browser/resources/settings/basic_page/basic_page.js16
-rw-r--r--chromium/chrome/browser/resources/settings/basic_page/compiled_resources2.gyp22
-rw-r--r--chromium/chrome/browser/resources/settings/bluetooth_page/BUILD.gn56
-rw-r--r--chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.html7
-rw-r--r--chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js8
-rw-r--r--chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.html9
-rw-r--r--chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.js8
-rw-r--r--chromium/chrome/browser/resources/settings/bluetooth_page/compiled_resources2.gyp45
-rw-r--r--chromium/chrome/browser/resources/settings/change_password_page/BUILD.gn30
-rw-r--r--chromium/chrome/browser/resources/settings/change_password_page/change_password_page.html4
-rw-r--r--chromium/chrome/browser/resources/settings/change_password_page/compiled_resources2.gyp27
-rw-r--r--chromium/chrome/browser/resources/settings/chrome_cleanup_page/BUILD.gn40
-rw-r--r--chromium/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.html25
-rw-r--r--chromium/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.js207
-rw-r--r--chromium/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_proxy.js11
-rw-r--r--chromium/chrome/browser/resources/settings/chrome_cleanup_page/compiled_resources2.gyp37
-rw-r--r--chromium/chrome/browser/resources/settings/chrome_cleanup_page/items_to_remove_list.html4
-rw-r--r--chromium/chrome/browser/resources/settings/chrome_cleanup_page/items_to_remove_list.js55
-rw-r--r--chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/BUILD.gn31
-rw-r--r--chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html26
-rw-r--r--chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.js54
-rw-r--r--chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/compiled_resources2.gyp28
-rw-r--r--chromium/chrome/browser/resources/settings/compiled_resources2.gyp105
-rw-r--r--chromium/chrome/browser/resources/settings/controls/BUILD.gn114
-rw-r--r--chromium/chrome/browser/resources/settings/controls/compiled_resources2.gyp110
-rw-r--r--chromium/chrome/browser/resources/settings/controls/controlled_button.html2
-rw-r--r--chromium/chrome/browser/resources/settings/controls/controlled_radio_button.html115
-rw-r--r--chromium/chrome/browser/resources/settings/controls/controlled_radio_button.js78
-rw-r--r--chromium/chrome/browser/resources/settings/controls/important_site_checkbox.html16
-rw-r--r--chromium/chrome/browser/resources/settings/controls/settings_boolean_control_behavior.js4
-rw-r--r--chromium/chrome/browser/resources/settings/controls/settings_checkbox.html21
-rw-r--r--chromium/chrome/browser/resources/settings/controls/settings_dropdown_menu.js47
-rw-r--r--chromium/chrome/browser/resources/settings/controls/settings_radio_group.html4
-rw-r--r--chromium/chrome/browser/resources/settings/controls/settings_toggle_button.html2
-rw-r--r--chromium/chrome/browser/resources/settings/controls/settings_toggle_button.js11
-rw-r--r--chromium/chrome/browser/resources/settings/crostini_page/BUILD.gn37
-rw-r--r--chromium/chrome/browser/resources/settings/crostini_page/crostini_browser_proxy.html2
-rw-r--r--chromium/chrome/browser/resources/settings/crostini_page/crostini_browser_proxy.js37
-rw-r--r--chromium/chrome/browser/resources/settings/crostini_page/crostini_page.html64
-rw-r--r--chromium/chrome/browser/resources/settings/crostini_page/crostini_page.js54
-rw-r--r--chromium/chrome/browser/resources/settings/crostini_page/crostini_subpage.html22
-rw-r--r--chromium/chrome/browser/resources/settings/crostini_page/crostini_subpage.js41
-rw-r--r--chromium/chrome/browser/resources/settings/date_time_page/BUILD.gn54
-rw-r--r--chromium/chrome/browser/resources/settings/date_time_page/compiled_resources2.gyp51
-rw-r--r--chromium/chrome/browser/resources/settings/default_browser_page/BUILD.gn26
-rw-r--r--chromium/chrome/browser/resources/settings/default_browser_page/compiled_resources2.gyp23
-rw-r--r--chromium/chrome/browser/resources/settings/device_page/BUILD.gn171
-rw-r--r--chromium/chrome/browser/resources/settings/device_page/compiled_resources2.gyp166
-rw-r--r--chromium/chrome/browser/resources/settings/device_page/device_page_browser_proxy.js26
-rw-r--r--chromium/chrome/browser/resources/settings/device_page/display.html21
-rw-r--r--chromium/chrome/browser/resources/settings/device_page/display.js108
-rw-r--r--chromium/chrome/browser/resources/settings/device_page/display_size_slider.html1
-rw-r--r--chromium/chrome/browser/resources/settings/device_page/display_size_slider.js12
-rw-r--r--chromium/chrome/browser/resources/settings/device_page/drag_behavior.js16
-rw-r--r--chromium/chrome/browser/resources/settings/device_page/layout_behavior.js2
-rw-r--r--chromium/chrome/browser/resources/settings/device_page/night_light_slider.js2
-rw-r--r--chromium/chrome/browser/resources/settings/device_page/pointers.html16
-rw-r--r--chromium/chrome/browser/resources/settings/device_page/pointers.js9
-rw-r--r--chromium/chrome/browser/resources/settings/device_page/power.js2
-rw-r--r--chromium/chrome/browser/resources/settings/downloads_page/BUILD.gn55
-rw-r--r--chromium/chrome/browser/resources/settings/downloads_page/add_smb_share_dialog.html20
-rw-r--r--chromium/chrome/browser/resources/settings/downloads_page/add_smb_share_dialog.js8
-rw-r--r--chromium/chrome/browser/resources/settings/downloads_page/compiled_resources2.gyp52
-rw-r--r--chromium/chrome/browser/resources/settings/downloads_page/downloads_page.html107
-rw-r--r--chromium/chrome/browser/resources/settings/downloads_page/smb_browser_proxy.js20
-rw-r--r--chromium/chrome/browser/resources/settings/downloads_page/smb_shares_page.html10
-rw-r--r--chromium/chrome/browser/resources/settings/downloads_page/smb_shares_page.js43
-rw-r--r--chromium/chrome/browser/resources/settings/find_shortcut_behavior.html4
-rw-r--r--chromium/chrome/browser/resources/settings/find_shortcut_behavior.js51
-rw-r--r--chromium/chrome/browser/resources/settings/google_assistant_page/BUILD.gn28
-rw-r--r--chromium/chrome/browser/resources/settings/google_assistant_page/compiled_resources2.gyp25
-rw-r--r--chromium/chrome/browser/resources/settings/icons.html9
-rw-r--r--chromium/chrome/browser/resources/settings/images/sync_banner.pngbin3894 -> 0 bytes
-rw-r--r--chromium/chrome/browser/resources/settings/images/sync_banner.svg32
-rw-r--r--chromium/chrome/browser/resources/settings/images/sync_banner_2x.pngbin7782 -> 0 bytes
-rw-r--r--chromium/chrome/browser/resources/settings/incompatible_applications_page/BUILD.gn36
-rw-r--r--chromium/chrome/browser/resources/settings/incompatible_applications_page/compiled_resources2.gyp33
-rw-r--r--chromium/chrome/browser/resources/settings/incompatible_applications_page/incompatible_application_item.html2
-rw-r--r--chromium/chrome/browser/resources/settings/incompatible_applications_page/incompatible_application_item.js6
-rw-r--r--chromium/chrome/browser/resources/settings/incompatible_applications_page/incompatible_applications_browser_proxy.js11
-rw-r--r--chromium/chrome/browser/resources/settings/internet_page/BUILD.gn141
-rw-r--r--chromium/chrome/browser/resources/settings/internet_page/compiled_resources2.gyp134
-rw-r--r--chromium/chrome/browser/resources/settings/internet_page/internet_config.js5
-rw-r--r--chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.html50
-rw-r--r--chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.js23
-rw-r--r--chromium/chrome/browser/resources/settings/internet_page/internet_page.js6
-rw-r--r--chromium/chrome/browser/resources/settings/internet_page/internet_shared_css.html15
-rw-r--r--chromium/chrome/browser/resources/settings/internet_page/internet_subpage.html12
-rw-r--r--chromium/chrome/browser/resources/settings/internet_page/internet_subpage.js6
-rw-r--r--chromium/chrome/browser/resources/settings/internet_page/network_summary_item.html8
-rw-r--r--chromium/chrome/browser/resources/settings/internet_page/network_summary_item.js6
-rw-r--r--chromium/chrome/browser/resources/settings/languages_page/BUILD.gn94
-rw-r--r--chromium/chrome/browser/resources/settings/languages_page/add_languages_dialog.html28
-rw-r--r--chromium/chrome/browser/resources/settings/languages_page/add_languages_dialog.js13
-rw-r--r--chromium/chrome/browser/resources/settings/languages_page/compiled_resources2.gyp84
-rw-r--r--chromium/chrome/browser/resources/settings/languages_page/edit_dictionary_page.html3
-rw-r--r--chromium/chrome/browser/resources/settings/languages_page/languages.js17
-rw-r--r--chromium/chrome/browser/resources/settings/languages_page/languages_page.html28
-rw-r--r--chromium/chrome/browser/resources/settings/languages_page/languages_page.js19
-rw-r--r--chromium/chrome/browser/resources/settings/languages_page/manage_input_methods_page.html6
-rw-r--r--chromium/chrome/browser/resources/settings/languages_page/manage_input_methods_page.js2
-rw-r--r--chromium/chrome/browser/resources/settings/multidevice_page/BUILD.gn14
-rw-r--r--chromium/chrome/browser/resources/settings/multidevice_page/compiled_resources2.gyp12
-rw-r--r--chromium/chrome/browser/resources/settings/on_startup_page/BUILD.gn61
-rw-r--r--chromium/chrome/browser/resources/settings/on_startup_page/compiled_resources2.gyp58
-rw-r--r--chromium/chrome/browser/resources/settings/passwords_and_forms_page/BUILD.gn104
-rw-r--r--chromium/chrome/browser/resources/settings/passwords_and_forms_page/address_edit_dialog.html6
-rw-r--r--chromium/chrome/browser/resources/settings/passwords_and_forms_page/compiled_resources2.gyp100
-rw-r--r--chromium/chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.html4
-rw-r--r--chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_edit_dialog.html3
-rw-r--r--chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_list_item.js5
-rw-r--r--chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_section.html23
-rw-r--r--chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_section.js75
-rw-r--r--chromium/chrome/browser/resources/settings/people_page/BUILD.gn297
-rw-r--r--chromium/chrome/browser/resources/settings/people_page/account_manager.html48
-rw-r--r--chromium/chrome/browser/resources/settings/people_page/account_manager.js55
-rw-r--r--chromium/chrome/browser/resources/settings/people_page/compiled_resources2.gyp278
-rw-r--r--chromium/chrome/browser/resources/settings/people_page/fingerprint_progress_arc.js2
-rw-r--r--chromium/chrome/browser/resources/settings/people_page/lock_screen.html18
-rw-r--r--chromium/chrome/browser/resources/settings/people_page/lock_screen.js29
-rw-r--r--chromium/chrome/browser/resources/settings/people_page/lock_state_behavior.html4
-rw-r--r--chromium/chrome/browser/resources/settings/people_page/lock_state_behavior.js60
-rw-r--r--chromium/chrome/browser/resources/settings/people_page/password_prompt_dialog.html10
-rw-r--r--chromium/chrome/browser/resources/settings/people_page/password_prompt_dialog.js38
-rw-r--r--chromium/chrome/browser/resources/settings/people_page/people_page.html52
-rw-r--r--chromium/chrome/browser/resources/settings/people_page/people_page.js31
-rw-r--r--chromium/chrome/browser/resources/settings/people_page/setup_fingerprint_dialog.js5
-rw-r--r--chromium/chrome/browser/resources/settings/people_page/sync_account_control.html39
-rw-r--r--chromium/chrome/browser/resources/settings/people_page/sync_account_control.js36
-rw-r--r--chromium/chrome/browser/resources/settings/people_page/sync_browser_proxy.js12
-rw-r--r--chromium/chrome/browser/resources/settings/people_page/sync_page.html70
-rw-r--r--chromium/chrome/browser/resources/settings/people_page/sync_page.js68
-rw-r--r--chromium/chrome/browser/resources/settings/people_page/users_add_user_dialog.html3
-rw-r--r--chromium/chrome/browser/resources/settings/people_page/users_page.js4
-rw-r--r--chromium/chrome/browser/resources/settings/prefs/BUILD.gn42
-rw-r--r--chromium/chrome/browser/resources/settings/prefs/compiled_resources2.gyp39
-rw-r--r--chromium/chrome/browser/resources/settings/printing_page/BUILD.gn98
-rw-r--r--chromium/chrome/browser/resources/settings/printing_page/compiled_resources2.gyp94
-rw-r--r--chromium/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.html4
-rw-r--r--chromium/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog_util.html11
-rw-r--r--chromium/chrome/browser/resources/settings/printing_page/cups_edit_printer_dialog.html56
-rw-r--r--chromium/chrome/browser/resources/settings/printing_page/cups_edit_printer_dialog.js25
-rw-r--r--chromium/chrome/browser/resources/settings/printing_page/cups_printer_shared_css.html8
-rw-r--r--chromium/chrome/browser/resources/settings/printing_page/cups_printers.html45
-rw-r--r--chromium/chrome/browser/resources/settings/printing_page/cups_printers.js52
-rw-r--r--chromium/chrome/browser/resources/settings/printing_page/cups_printers_browser_proxy.js2
-rw-r--r--chromium/chrome/browser/resources/settings/printing_page/cups_set_manufacturer_model_behavior.js47
-rw-r--r--chromium/chrome/browser/resources/settings/printing_page/printing_page.html3
-rw-r--r--chromium/chrome/browser/resources/settings/privacy_page/BUILD.gn49
-rw-r--r--chromium/chrome/browser/resources/settings/privacy_page/compiled_resources2.gyp34
-rw-r--r--chromium/chrome/browser/resources/settings/privacy_page/personalization_options.html93
-rw-r--r--chromium/chrome/browser/resources/settings/privacy_page/personalization_options.js175
-rw-r--r--chromium/chrome/browser/resources/settings/privacy_page/privacy_page.html66
-rw-r--r--chromium/chrome/browser/resources/settings/privacy_page/privacy_page.js149
-rw-r--r--chromium/chrome/browser/resources/settings/reset_page/BUILD.gn49
-rw-r--r--chromium/chrome/browser/resources/settings/reset_page/compiled_resources2.gyp46
-rw-r--r--chromium/chrome/browser/resources/settings/reset_page/reset_page.html35
-rw-r--r--chromium/chrome/browser/resources/settings/reset_page/reset_page.js11
-rw-r--r--chromium/chrome/browser/resources/settings/reset_page/reset_profile_dialog.html6
-rw-r--r--chromium/chrome/browser/resources/settings/reset_page/reset_profile_dialog.js7
-rw-r--r--chromium/chrome/browser/resources/settings/route.js19
-rw-r--r--chromium/chrome/browser/resources/settings/search_engines_page/BUILD.gn75
-rw-r--r--chromium/chrome/browser/resources/settings/search_engines_page/compiled_resources2.gyp71
-rw-r--r--chromium/chrome/browser/resources/settings/search_engines_page/search_engine_dialog.html6
-rw-r--r--chromium/chrome/browser/resources/settings/search_engines_page/search_engine_dialog.js41
-rw-r--r--chromium/chrome/browser/resources/settings/search_engines_page/search_engine_entry.html5
-rw-r--r--chromium/chrome/browser/resources/settings/search_engines_page/search_engine_entry.js18
-rw-r--r--chromium/chrome/browser/resources/settings/search_engines_page/search_engines_browser_proxy.js1
-rw-r--r--chromium/chrome/browser/resources/settings/search_engines_page/search_engines_list.html7
-rw-r--r--chromium/chrome/browser/resources/settings/search_engines_page/search_engines_list.js25
-rw-r--r--chromium/chrome/browser/resources/settings/search_engines_page/search_engines_page.html10
-rw-r--r--chromium/chrome/browser/resources/settings/search_engines_page/search_engines_page.js79
-rw-r--r--chromium/chrome/browser/resources/settings/search_page/BUILD.gn22
-rw-r--r--chromium/chrome/browser/resources/settings/search_page/compiled_resources2.gyp19
-rw-r--r--chromium/chrome/browser/resources/settings/search_settings.js38
-rw-r--r--chromium/chrome/browser/resources/settings/settings.html2
-rw-r--r--chromium/chrome/browser/resources/settings/settings_main/BUILD.gn25
-rw-r--r--chromium/chrome/browser/resources/settings/settings_main/compiled_resources2.gyp22
-rw-r--r--chromium/chrome/browser/resources/settings/settings_main/settings_main.html1
-rw-r--r--chromium/chrome/browser/resources/settings/settings_menu/BUILD.gn19
-rw-r--r--chromium/chrome/browser/resources/settings/settings_menu/compiled_resources2.gyp16
-rw-r--r--chromium/chrome/browser/resources/settings/settings_menu/settings_menu.html13
-rw-r--r--chromium/chrome/browser/resources/settings/settings_page/BUILD.gn63
-rw-r--r--chromium/chrome/browser/resources/settings/settings_page/compiled_resources2.gyp58
-rw-r--r--chromium/chrome/browser/resources/settings/settings_page/settings_animated_pages.js16
-rw-r--r--chromium/chrome/browser/resources/settings/settings_page/settings_section.html3
-rw-r--r--chromium/chrome/browser/resources/settings/settings_page/settings_section.js1
-rw-r--r--chromium/chrome/browser/resources/settings/settings_page/settings_subpage.html4
-rw-r--r--chromium/chrome/browser/resources/settings/settings_page/settings_subpage.js6
-rw-r--r--chromium/chrome/browser/resources/settings/settings_page/settings_subpage_search.js1
-rw-r--r--chromium/chrome/browser/resources/settings/settings_resources.grd58
-rw-r--r--chromium/chrome/browser/resources/settings/settings_shared_css.html86
-rw-r--r--chromium/chrome/browser/resources/settings/settings_ui/BUILD.gn27
-rw-r--r--chromium/chrome/browser/resources/settings/settings_ui/compiled_resources2.gyp23
-rw-r--r--chromium/chrome/browser/resources/settings/settings_ui/settings_ui.html8
-rw-r--r--chromium/chrome/browser/resources/settings/settings_ui/settings_ui.js21
-rw-r--r--chromium/chrome/browser/resources/settings/settings_vars_css.html7
-rw-r--r--chromium/chrome/browser/resources/settings/site_settings/BUILD.gn223
-rw-r--r--chromium/chrome/browser/resources/settings/site_settings/add_site_dialog.html5
-rw-r--r--chromium/chrome/browser/resources/settings/site_settings/all_sites.html30
-rw-r--r--chromium/chrome/browser/resources/settings/site_settings/all_sites.js11
-rw-r--r--chromium/chrome/browser/resources/settings/site_settings/compiled_resources2.gyp217
-rw-r--r--chromium/chrome/browser/resources/settings/site_settings/edit_exception_dialog.js11
-rw-r--r--chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.html3
-rw-r--r--chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.js5
-rw-r--r--chromium/chrome/browser/resources/settings/site_settings/site_data.html3
-rw-r--r--chromium/chrome/browser/resources/settings/site_settings/site_data.js10
-rw-r--r--chromium/chrome/browser/resources/settings/site_settings/site_details.html4
-rw-r--r--chromium/chrome/browser/resources/settings/site_settings/site_entry.html24
-rw-r--r--chromium/chrome/browser/resources/settings/site_settings/site_entry.js37
-rw-r--r--chromium/chrome/browser/resources/settings/site_settings/site_list.js6
-rw-r--r--chromium/chrome/browser/resources/settings/site_settings/site_settings_behavior.js6
-rw-r--r--chromium/chrome/browser/resources/settings/site_settings_page/BUILD.gn24
-rw-r--r--chromium/chrome/browser/resources/settings/site_settings_page/compiled_resources2.gyp21
-rw-r--r--chromium/chrome/browser/resources/settings/site_settings_page/site_settings_page.html13
-rw-r--r--chromium/chrome/browser/resources/settings/site_settings_page/site_settings_page.js3
-rw-r--r--chromium/chrome/browser/resources/settings/system_page/BUILD.gn28
-rw-r--r--chromium/chrome/browser/resources/settings/system_page/compiled_resources2.gyp25
-rw-r--r--chromium/chrome/browser/resources/signin/dice_sync_confirmation/BUILD.gn35
-rw-r--r--chromium/chrome/browser/resources/signin/dice_sync_confirmation/compiled_resources2.gyp31
-rw-r--r--chromium/chrome/browser/resources/signin/dice_sync_confirmation/images/sync_confirmation_illustration.svg1
-rw-r--r--chromium/chrome/browser/resources/signin/dice_sync_confirmation/sync_confirmation_app.html229
-rw-r--r--chromium/chrome/browser/resources/signin/dice_sync_confirmation/sync_confirmation_app.js54
-rw-r--r--chromium/chrome/browser/resources/signin/signin_email_confirmation/signin_email_confirmation.html20
-rw-r--r--chromium/chrome/browser/resources/signin/signin_error/signin_error.html9
-rw-r--r--chromium/chrome/browser/resources/signin/signin_shared_css.html31
-rw-r--r--chromium/chrome/browser/resources/signin/sync_confirmation/sync_confirmation.html7
-rw-r--r--chromium/chrome/browser/resources/snippets_internals.html251
-rw-r--r--chromium/chrome/browser/resources/snippets_internals.js229
-rw-r--r--chromium/chrome/browser/resources/snippets_internals/.eslintrc.js13
-rw-r--r--chromium/chrome/browser/resources/snippets_internals/BUILD.gn24
-rw-r--r--chromium/chrome/browser/resources/snippets_internals/OWNERS1
-rw-r--r--chromium/chrome/browser/resources/snippets_internals/snippets_internals.css (renamed from chromium/chrome/browser/resources/snippets_internals.css)2
-rw-r--r--chromium/chrome/browser/resources/snippets_internals/snippets_internals.html274
-rw-r--r--chromium/chrome/browser/resources/snippets_internals/snippets_internals.js323
-rw-r--r--chromium/chrome/browser/resources/vr/assets/VERSION2
-rw-r--r--chromium/chrome/browser/resources/vr/assets/google_chrome/normal_gradient.png.sha12
-rw-r--r--chromium/chrome/browser/resources/webapks/BUILD.gn18
-rw-r--r--chromium/chrome/browser/resources/webapks/compiled_resources2.gyp15
-rw-r--r--chromium/chrome/browser/resources/welcome/dice_welcome/BUILD.gn27
-rw-r--r--chromium/chrome/browser/resources/welcome/dice_welcome/compiled_resources2.gyp24
-rw-r--r--chromium/chrome/browser/resources/welcome/welcome_win10.html13
-rw-r--r--chromium/chrome/browser/resources/welcome/welcome_win10.js22
-rw-r--r--chromium/chrome/browser/safe_browsing/BUILD.gn2
-rw-r--r--chromium/chrome/browser/search/BUILD.gn3
-rw-r--r--chromium/chrome/browser/spellchecker/spell_check_host_chrome_impl_mac.cc8
-rw-r--r--chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc6
-rw-r--r--chromium/chrome/browser/spellchecker/spellcheck_service.cc2
-rw-r--r--chromium/chrome/browser/spellchecker/spellcheck_service_browsertest.cc3
-rw-r--r--chromium/chrome/browser/ui/BUILD.gn296
-rw-r--r--chromium/chrome/browser/ui/libgtkui/BUILD.gn1
-rw-r--r--chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.h10
-rw-r--r--chromium/chrome/browser/ui/webui/bookmarks_ui.cc66
-rw-r--r--chromium/chrome/browser/ui/webui/bookmarks_ui.h52
-rw-r--r--chromium/chrome/browser/ui/webui/bookmarks_ui_browsertest.cc120
-rw-r--r--chromium/chrome/browser/ui/webui/browsing_history_handler_unittest.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/chrome_web_contents_handler.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/chrome_web_contents_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc71
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.cc49
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.h40
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc154
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h28
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/first_run/DEPS7
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_ui.cc21
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui_browsertest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/DEPS2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/OWNERS1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.cc102
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.h18
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc50
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler_unittest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc158
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h15
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc154
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h11
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_unittest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc21
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h5
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.cc53
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.h44
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc191
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h44
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.cc44
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.h2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.cc19
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/slow_trace_ui.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/system_web_dialog_browsertest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/chromeos/user_image_source.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/device_log_ui.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/discards/discards.mojom12
-rw-r--r--chromium/chrome/browser/ui/webui/discards/discards_ui.cc57
-rw-r--r--chromium/chrome/browser/ui/webui/discards/discards_ui.h7
-rw-r--r--chromium/chrome/browser/ui/webui/engagement/site_engagement_ui.cc13
-rw-r--r--chromium/chrome/browser/ui/webui/engagement/site_engagement_ui.h8
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_browsertest.js269
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc49
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.h6
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extension_loader_handler.cc225
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extension_loader_handler.h121
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.cc58
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.h2
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.js539
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extension_settings_handler.cc319
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extension_settings_handler.h57
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc490
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/extensions_ui.h6
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/install_extension_handler.cc142
-rw-r--r--chromium/chrome/browser/ui/webui/extensions/install_extension_handler.h63
-rw-r--r--chromium/chrome/browser/ui/webui/fileicon_source.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/fileicon_source_unittest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/flags_ui.cc29
-rw-r--r--chromium/chrome/browser/ui/webui/inspect_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/interstitials/interstitial_ui.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.h8
-rw-r--r--chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc24
-rw-r--r--chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/log_web_ui_url.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/log_web_ui_url_unittest.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.cc10
-rw-r--r--chromium/chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.h8
-rw-r--r--chromium/chrome/browser/ui/webui/md_downloads/downloads_list_tracker.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/md_downloads/md_downloads_dom_handler.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/md_downloads/md_downloads_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/md_history_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/media/media_engagement_ui.cc42
-rw-r--r--chromium/chrome/browser/ui/webui/media/media_engagement_ui.h9
-rw-r--r--chromium/chrome/browser/ui/webui/media/webrtc_logs_ui.cc34
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/OWNERS1
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_dialog_controller_webui_impl_unittest.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_ui.cc931
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_ui.h259
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_ui_unittest.cc101
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_webui_message_handler.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/media_router/media_router_webui_message_handler_unittest.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/memory_internals_ui.cc51
-rw-r--r--chromium/chrome/browser/ui/webui/nacl_ui.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/net_export_ui.cc37
-rw-r--r--chromium/chrome/browser/ui/webui/net_internals/net_internals_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/omnibox/OWNERS2
-rw-r--r--chromium/chrome/browser/ui/webui/omnibox/omnibox.mojom1
-rw-r--r--chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.h5
-rw-r--r--chromium/chrome/browser/ui/webui/page_not_available_for_guest/page_not_available_for_guest_ui.cc52
-rw-r--r--chromium/chrome/browser/ui/webui/page_not_available_for_guest/page_not_available_for_guest_ui.h20
-rw-r--r--chromium/chrome/browser/ui/webui/physical_web/physical_web_ui.cc94
-rw-r--r--chromium/chrome/browser/ui/webui/physical_web/physical_web_ui.h20
-rw-r--r--chromium/chrome/browser/ui/webui/policy_tool_ui.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/policy_tool_ui_browsertest.cc284
-rw-r--r--chromium/chrome/browser/ui/webui/policy_tool_ui_handler.cc103
-rw-r--r--chromium/chrome/browser/ui/webui/policy_tool_ui_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/policy_ui.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/policy_ui_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.cc81
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.h1
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler_unittest.cc63
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.h2
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_handler.cc250
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc12
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_ui.cc22
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_ui.h3
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/print_preview/printer_handler.h1
-rw-r--r--chromium/chrome/browser/ui/webui/quota_internals/OWNERS5
-rw-r--r--chromium/chrome/browser/ui/webui/reset_password/BUILD.gn11
-rw-r--r--chromium/chrome/browser/ui/webui/reset_password/OWNERS8
-rw-r--r--chromium/chrome/browser/ui/webui/reset_password/reset_password.mojom10
-rw-r--r--chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.cc140
-rw-r--r--chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.h37
-rw-r--r--chromium/chrome/browser/ui/webui/sandbox_internals_ui.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/about_handler.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/settings/about_handler.h4
-rw-r--r--chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.cc46
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler.cc81
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler.h7
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/DEPS6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc104
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h55
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc43
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h41
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc201
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h13
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc32
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h6
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc65
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h8
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler_unittest.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc7
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h14
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.cc27
-rw-r--r--chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.h9
-rw-r--r--chromium/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.cc54
-rw-r--r--chromium/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.h12
-rw-r--r--chromium/chrome/browser/ui/webui/settings/languages_handler.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.cc276
-rw-r--r--chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc72
-rw-r--r--chromium/chrome/browser/ui/webui/settings/md_settings_ui.h11
-rw-r--r--chromium/chrome/browser/ui/webui/settings/people_handler.cc49
-rw-r--r--chromium/chrome/browser/ui/webui/settings/people_handler.h13
-rw-r--r--chromium/chrome/browser/ui/webui/settings/profile_info_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/reset_settings_handler.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/settings/search_engines_handler.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/settings/tts_handler.cc124
-rw-r--r--chromium/chrome/browser/ui/webui/settings/tts_handler.h11
-rw-r--r--chromium/chrome/browser/ui/webui/settings_utils_win.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_unittest.cc3
-rw-r--r--chromium/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/signin/login_ui_service.cc129
-rw-r--r--chromium/chrome/browser/ui/webui/signin/login_ui_service.h3
-rw-r--r--chromium/chrome/browser/ui/webui/signin/login_ui_service_factory.cc8
-rw-r--r--chromium/chrome/browser/ui/webui/signin/login_ui_service_factory.h1
-rw-r--r--chromium/chrome/browser/ui/webui/signin/login_ui_service_unittest.cc85
-rw-r--r--chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.cc248
-rw-r--r--chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.h22
-rw-r--r--chromium/chrome/browser/ui/webui/signin/md_user_manager_ui.cc29
-rw-r--r--chromium/chrome/browser/ui/webui/signin/md_user_manager_ui.h9
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc530
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.h128
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler_unittest.cc433
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.cc321
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.h101
-rw-r--r--chromium/chrome/browser/ui/webui/signin/signin_supervised_user_import_handler_unittest.cc234
-rw-r--r--chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.cc48
-rw-r--r--chromium/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/signin/user_manager_ui_browsertest.cc5
-rw-r--r--chromium/chrome/browser/ui/webui/site_settings_helper.cc18
-rw-r--r--chromium/chrome/browser/ui/webui/site_settings_helper.h9
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals/BUILD.gn11
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals/OWNERS4
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom83
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.cc453
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.h106
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.cc59
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.h43
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals_message_handler.cc653
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals_message_handler.h118
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals_ui.cc48
-rw-r--r--chromium/chrome/browser/ui/webui/snippets_internals_ui.h21
-rw-r--r--chromium/chrome/browser/ui/webui/supervised_user_internals_message_handler.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/sync_internals_message_handler.cc21
-rw-r--r--chromium/chrome/browser/ui/webui/sync_internals_message_handler.h3
-rw-r--r--chromium/chrome/browser/ui/webui/sync_internals_message_handler_unittest.cc9
-rw-r--r--chromium/chrome/browser/ui/webui/sync_internals_ui_unittest.cc34
-rw-r--r--chromium/chrome/browser/ui/webui/system_info_ui.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/test_files_request_filter.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/theme_source.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/theme_source_unittest.cc1
-rw-r--r--chromium/chrome/browser/ui/webui/usb_internals/usb_internals_ui.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/usb_internals/usb_internals_ui.h7
-rw-r--r--chromium/chrome/browser/ui/webui/web_dialog_web_contents_delegate_unittest.cc6
-rw-r--r--chromium/chrome/browser/ui/webui/web_ui_test_handler.cc24
-rw-r--r--chromium/chrome/browser/ui/webui/web_ui_test_handler.h16
-rw-r--r--chromium/chrome/browser/ui/webui/webapks_handler.cc16
-rw-r--r--chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc2
-rw-r--r--chromium/chrome/browser/ui/webui/welcome_ui.cc25
-rw-r--r--chromium/chrome/browser/ui/webui/welcome_win10_handler.cc4
-rw-r--r--chromium/chrome/browser/ui/webui/welcome_win10_handler.h1
-rw-r--r--chromium/chrome/browser/ui/webui/welcome_win10_ui.cc2
-rw-r--r--chromium/chrome/browser/vr/BUILD.gn39
1073 files changed, 23981 insertions, 29522 deletions
diff --git a/chromium/chrome/browser/BUILD.gn b/chromium/chrome/browser/BUILD.gn
index e73bbc01264..054c6e2a526 100644
--- a/chromium/chrome/browser/BUILD.gn
+++ b/chromium/chrome/browser/BUILD.gn
@@ -10,6 +10,7 @@ import("//build/config/ui.gni")
import("//build/split_static_library.gni")
import("//chrome/common/features.gni")
import("//components/feature_engagement/features.gni")
+import("//components/feed/features.gni")
import("//components/nacl/features.gni")
import("//components/offline_pages/buildflags/features.gni")
import("//components/os_crypt/features.gni")
@@ -17,7 +18,6 @@ import("//components/signin/features.gni")
import("//components/spellcheck/spellcheck_build_features.gni")
import("//device/vr/buildflags/buildflags.gni")
import("//extensions/buildflags/buildflags.gni")
-import("//media/media_options.gni")
import("//net/features.gni")
import("//ppapi/buildflags/buildflags.gni")
import("//printing/buildflags/buildflags.gni")
@@ -56,6 +56,14 @@ if (is_win) {
}
}
+# This proto library is used for non-android NTPs below.
+proto_library("ntp_background_proto") {
+ sources = [
+ "search/background/ntp_background.proto",
+ ]
+ generate_python = false
+}
+
# Use a static library here because many test binaries depend on this but don't
# require many files from it. This makes linking more efficient.
jumbo_split_static_library("browser") {
@@ -154,8 +162,6 @@ jumbo_split_static_library("browser") {
"browser_process_platform_part_mac.mm",
"browser_process_platform_part_win.cc",
"browser_process_platform_part_win.h",
- "browser_shutdown.cc",
- "browser_shutdown.h",
"browsing_data/browsing_data_appcache_helper.cc",
"browsing_data/browsing_data_appcache_helper.h",
"browsing_data/browsing_data_cache_storage_helper.cc",
@@ -210,6 +216,8 @@ jumbo_split_static_library("browser") {
"browsing_data/counters/site_data_counter.h",
"browsing_data/counters/site_data_counting_helper.cc",
"browsing_data/counters/site_data_counting_helper.h",
+ "browsing_data/counters/site_settings_counter.cc",
+ "browsing_data/counters/site_settings_counter.h",
"browsing_data/local_data_container.cc",
"browsing_data/local_data_container.h",
"browsing_data/navigation_entry_remover.cc",
@@ -392,6 +400,7 @@ jumbo_split_static_library("browser") {
"download/download_history.h",
"download/download_item_model.cc",
"download/download_item_model.h",
+ "download/download_location_dialog_result.h",
"download/download_location_dialog_type.h",
"download/download_path_reservation_tracker.cc",
"download/download_path_reservation_tracker.h",
@@ -429,7 +438,6 @@ jumbo_split_static_library("browser") {
"download/save_package_file_picker.h",
"download/trusted_sources_manager.cc",
"download/trusted_sources_manager.h",
- "download/trusted_sources_manager_posix.cc",
"download/trusted_sources_manager_win.cc",
"engagement/important_sites_usage_counter.cc",
"engagement/important_sites_usage_counter.h",
@@ -449,8 +457,32 @@ jumbo_split_static_library("browser") {
"engagement/site_engagement_service_factory.h",
"engagement/top_sites/site_engagement_top_sites_provider.cc",
"engagement/top_sites/site_engagement_top_sites_provider.h",
- "experiments/memory_ablation_experiment.cc",
- "experiments/memory_ablation_experiment.h",
+ "lifetime/browser_shutdown.cc",
+ "lifetime/browser_shutdown.h",
+ "media/webrtc/audio_debug_recordings_handler.cc",
+ "media/webrtc/audio_debug_recordings_handler.h",
+ "media/webrtc/webrtc_event_log_manager.cc",
+ "media/webrtc/webrtc_event_log_manager.h",
+ "media/webrtc/webrtc_event_log_manager_common.cc",
+ "media/webrtc/webrtc_event_log_manager_common.h",
+ "media/webrtc/webrtc_event_log_manager_local.cc",
+ "media/webrtc/webrtc_event_log_manager_local.h",
+ "media/webrtc/webrtc_event_log_manager_remote.cc",
+ "media/webrtc/webrtc_event_log_manager_remote.h",
+ "media/webrtc/webrtc_event_log_uploader.cc",
+ "media/webrtc/webrtc_event_log_uploader.h",
+ "media/webrtc/webrtc_log_uploader.cc",
+ "media/webrtc/webrtc_log_uploader.h",
+ "media/webrtc/webrtc_log_util.cc",
+ "media/webrtc/webrtc_log_util.h",
+ "media/webrtc/webrtc_logging_handler_host.cc",
+ "media/webrtc/webrtc_logging_handler_host.h",
+ "media/webrtc/webrtc_rtp_dump_handler.cc",
+ "media/webrtc/webrtc_rtp_dump_handler.h",
+ "media/webrtc/webrtc_rtp_dump_writer.cc",
+ "media/webrtc/webrtc_rtp_dump_writer.h",
+ "media/webrtc/webrtc_text_log_handler.cc",
+ "media/webrtc/webrtc_text_log_handler.h",
# Oh hey, all the cool browser/extensions files are hanging out in
# //chrome/browser/extensions/BUILD.gn
@@ -485,8 +517,6 @@ jumbo_split_static_library("browser") {
"gcm/gcm_product_util.h",
"gcm/gcm_profile_service_factory.cc",
"gcm/gcm_profile_service_factory.h",
- "gcm/instance_id/instance_id_profile_service.cc",
- "gcm/instance_id/instance_id_profile_service.h",
"gcm/instance_id/instance_id_profile_service_factory.cc",
"gcm/instance_id/instance_id_profile_service_factory.h",
"generic_sensor/sensor_permission_context.cc",
@@ -507,13 +537,17 @@ jumbo_split_static_library("browser") {
"google/google_brand.h",
"google/google_brand_chromeos.cc",
"google/google_brand_chromeos.h",
- "google/google_update_settings_posix.cc",
+ "google/google_search_domain_mixing_metrics_emitter.cc",
+ "google/google_search_domain_mixing_metrics_emitter.h",
+ "google/google_search_domain_mixing_metrics_emitter_factory.cc",
+ "google/google_search_domain_mixing_metrics_emitter_factory.h",
"google/google_url_tracker_factory.cc",
"google/google_url_tracker_factory.h",
"gpu/gpu_mode_manager.cc",
"gpu/gpu_mode_manager.h",
+ "hang_monitor/hang_crash_dump.h",
+ "hang_monitor/hang_crash_dump_mac.cc",
"hang_monitor/hang_crash_dump_win.cc",
- "hang_monitor/hang_crash_dump_win.h",
"history/chrome_history_backend_client.cc",
"history/chrome_history_backend_client.h",
"history/chrome_history_client.cc",
@@ -571,6 +605,8 @@ jumbo_split_static_library("browser") {
"internal_auth.h",
"interstitials/chrome_metrics_helper.cc",
"interstitials/chrome_metrics_helper.h",
+ "interstitials/enterprise_util.cc",
+ "interstitials/enterprise_util.h",
"intranet_redirect_detector.cc",
"intranet_redirect_detector.h",
"invalidation/profile_invalidation_provider_factory.cc",
@@ -730,8 +766,6 @@ jumbo_split_static_library("browser") {
"metrics/thread_watcher_report_hang.h",
"metrics/variations/chrome_variations_service_client.cc",
"metrics/variations/chrome_variations_service_client.h",
- "mod_pagespeed/mod_pagespeed_metrics.cc",
- "mod_pagespeed/mod_pagespeed_metrics.h",
"native_window_notification_source.h",
"net/chrome_accept_language_settings.cc",
"net/chrome_accept_language_settings.h",
@@ -759,7 +793,6 @@ jumbo_split_static_library("browser") {
"net/loading_predictor_observer.cc",
"net/loading_predictor_observer.h",
"net/net_error_diagnostics_dialog.h",
- "net/net_error_diagnostics_dialog_posix.cc",
"net/net_error_diagnostics_dialog_win.cc",
"net/net_error_tab_helper.cc",
"net/net_error_tab_helper.h",
@@ -801,8 +834,6 @@ jumbo_split_static_library("browser") {
"net/spdyproxy/data_reduction_proxy_chrome_settings.h",
"net/spdyproxy/data_reduction_proxy_chrome_settings_factory.cc",
"net/spdyproxy/data_reduction_proxy_chrome_settings_factory.h",
- "net/sth_distributor_provider.cc",
- "net/sth_distributor_provider.h",
"net/system_network_context_manager.cc",
"net/system_network_context_manager.h",
"net/timed_cache.cc",
@@ -891,8 +922,6 @@ jumbo_split_static_library("browser") {
"page_load_metrics/observers/document_write_page_load_metrics_observer.h",
"page_load_metrics/observers/from_gws_page_load_metrics_observer.cc",
"page_load_metrics/observers/from_gws_page_load_metrics_observer.h",
- "page_load_metrics/observers/google_captcha_observer.cc",
- "page_load_metrics/observers/google_captcha_observer.h",
"page_load_metrics/observers/histogram_suffixes.cc",
"page_load_metrics/observers/histogram_suffixes.h",
"page_load_metrics/observers/https_engagement_metrics/https_engagement_page_load_metrics_observer.cc",
@@ -931,8 +960,6 @@ jumbo_split_static_library("browser") {
"page_load_metrics/observers/security_state_page_load_metrics_observer.h",
"page_load_metrics/observers/service_worker_page_load_metrics_observer.cc",
"page_load_metrics/observers/service_worker_page_load_metrics_observer.h",
- "page_load_metrics/observers/subresource_filter_metrics_observer.cc",
- "page_load_metrics/observers/subresource_filter_metrics_observer.h",
"page_load_metrics/observers/tab_restore_page_load_metrics_observer.cc",
"page_load_metrics/observers/tab_restore_page_load_metrics_observer.h",
"page_load_metrics/observers/ukm_page_load_metrics_observer.cc",
@@ -1028,6 +1055,8 @@ jumbo_split_static_library("browser") {
"policy/cloud/user_cloud_policy_invalidator_factory.h",
"policy/configuration_policy_handler_list_factory.cc",
"policy/configuration_policy_handler_list_factory.h",
+ "policy/developer_tools_policy_handler.cc",
+ "policy/developer_tools_policy_handler.h",
"policy/device_management_service_configuration.cc",
"policy/device_management_service_configuration.h",
"policy/file_selection_dialogs_policy_handler.cc",
@@ -1063,7 +1092,6 @@ jumbo_split_static_library("browser") {
"predictors/loading_data_collector.h",
"predictors/loading_predictor.cc",
"predictors/loading_predictor.h",
- "predictors/loading_predictor_android.cc",
"predictors/loading_predictor_config.cc",
"predictors/loading_predictor_config.h",
"predictors/loading_predictor_factory.cc",
@@ -1241,12 +1269,16 @@ jumbo_split_static_library("browser") {
"resource_coordinator/chrome_browser_main_extra_parts_resource_coordinator.h",
"resource_coordinator/page_signal_receiver.cc",
"resource_coordinator/page_signal_receiver.h",
- "resource_coordinator/resource_coordinator_render_process_probe.cc",
- "resource_coordinator/resource_coordinator_render_process_probe.h",
- "resource_coordinator/resource_coordinator_web_contents_observer.cc",
- "resource_coordinator/resource_coordinator_web_contents_observer.h",
+ "resource_coordinator/render_process_probe.cc",
+ "resource_coordinator/render_process_probe.h",
+ "resource_coordinator/tab_helper.cc",
+ "resource_coordinator/tab_helper.h",
"resource_coordinator/tab_load_tracker.cc",
"resource_coordinator/tab_load_tracker.h",
+ "resource_coordinator/tab_memory_metrics_reporter.cc",
+ "resource_coordinator/tab_memory_metrics_reporter.h",
+ "resource_coordinator/time.cc",
+ "resource_coordinator/time.h",
"resources_util.cc",
"resources_util.h",
"safe_search_api/safe_search_url_checker.cc",
@@ -1398,6 +1430,8 @@ jumbo_split_static_library("browser") {
"ssl/ssl_blocking_page_base.h",
"ssl/ssl_cert_reporter.h",
"ssl/ssl_client_certificate_selector.h",
+ "ssl/ssl_config_service_manager.h",
+ "ssl/ssl_config_service_manager_pref.cc",
"ssl/ssl_error_assistant.cc",
"ssl/ssl_error_assistant.h",
"ssl/ssl_error_controller_client.cc",
@@ -1406,8 +1440,6 @@ jumbo_split_static_library("browser") {
"ssl/ssl_error_handler.h",
"ssl/ssl_error_navigation_throttle.cc",
"ssl/ssl_error_navigation_throttle.h",
- "ssl/ssl_error_tab_helper.cc",
- "ssl/ssl_error_tab_helper.h",
"ssl/typed_navigation_timing_throttle.cc",
"ssl/typed_navigation_timing_throttle.h",
"status_icons/status_icon.cc",
@@ -1443,8 +1475,6 @@ jumbo_split_static_library("browser") {
"sync/sessions/sync_sessions_web_contents_router.h",
"sync/sessions/sync_sessions_web_contents_router_factory.cc",
"sync/sessions/sync_sessions_web_contents_router_factory.h",
- "sync/supervised_user_signin_manager_wrapper.cc",
- "sync/supervised_user_signin_manager_wrapper.h",
"sync/sync_startup_tracker.cc",
"sync/sync_startup_tracker.h",
"sync/user_event_service_factory.cc",
@@ -1577,6 +1607,7 @@ jumbo_split_static_library("browser") {
]
deps = [
":active_use_util",
+ ":ntp_background_proto",
":resource_prefetch_predictor_proto",
"//base:i18n",
"//base/allocator:buildflags",
@@ -1704,7 +1735,6 @@ jumbo_split_static_library("browser") {
"//components/signin/core/browser",
"//components/signin/core/browser:signin_buildflags",
"//components/spellcheck:buildflags",
- "//components/ssl_config",
"//components/ssl_errors",
"//components/startup_metric_utils/browser:host",
"//components/startup_metric_utils/browser:lib",
@@ -1718,7 +1748,7 @@ jumbo_split_static_library("browser") {
"//components/sync_bookmarks",
"//components/sync_preferences",
"//components/sync_sessions",
- "//components/task_scheduler_util/common",
+ "//components/task_scheduler_util",
"//components/tracing:startup_tracing",
"//components/translate/content/browser",
"//components/translate/core/browser",
@@ -1742,8 +1772,11 @@ jumbo_split_static_library("browser") {
"//components/web_resource",
"//components/webdata/common",
"//components/webdata_services",
+ "//components/webrtc_logging/browser",
+ "//components/webrtc_logging/common",
"//content/app/resources",
"//content/public/browser",
+ "//content/public/browser",
"//content/public/common",
"//content/public/common:buildflags",
"//content/public/common:feature_h264_with_openh264_ffmpeg",
@@ -1769,7 +1802,6 @@ jumbo_split_static_library("browser") {
"//media/mojo/interfaces:mirror_service_remoting",
"//media/mojo/interfaces:remoting",
"//media/mojo/services",
- "//mojo/common",
"//mojo/edk",
"//mojo/public/cpp/bindings",
"//net:extras",
@@ -1777,6 +1809,7 @@ jumbo_split_static_library("browser") {
"//ppapi/buildflags",
"//printing/buildflags",
"//rlz/buildflags",
+ "//services/audio/public/cpp",
"//services/data_decoder/public/cpp",
"//services/device/public/cpp:device_features",
"//services/device/public/mojom",
@@ -1807,12 +1840,14 @@ jumbo_split_static_library("browser") {
"//third_party/icu",
"//third_party/leveldatabase",
"//third_party/libaddressinput",
- "//third_party/libaom:av1_features",
+ "//third_party/libaom:av1_buildflags",
"//third_party/libxml",
"//third_party/libyuv",
"//third_party/metrics_proto",
"//third_party/re2",
"//third_party/smhasher:cityhash",
+ "//third_party/webrtc_overrides",
+ "//third_party/webrtc_overrides:init_webrtc",
"//third_party/widevine/cdm:headers",
"//third_party/zlib",
"//third_party/zlib:minizip",
@@ -1835,6 +1870,14 @@ jumbo_split_static_library("browser") {
"//ui/web_dialogs",
]
+ if (is_posix || is_fuchsia) {
+ sources += [
+ "download/trusted_sources_manager_posix.cc",
+ "google/google_update_settings_posix.cc",
+ "net/net_error_diagnostics_dialog_posix.cc",
+ ]
+ }
+
if (is_android) {
sources += [
"after_startup_task_utils_android.cc",
@@ -1872,6 +1915,8 @@ jumbo_split_static_library("browser") {
"android/chrome_feature_list.h",
"android/chrome_startup_flags.cc",
"android/chrome_startup_flags.h",
+ "android/color_helpers.cc",
+ "android/color_helpers.h",
"android/compositor/compositor_view.cc",
"android/compositor/compositor_view.h",
"android/compositor/decoration_title.cc",
@@ -1989,6 +2034,8 @@ jumbo_split_static_library("browser") {
"android/download/download_location_dialog_bridge_impl.h",
"android/download/download_manager_service.cc",
"android/download/download_manager_service.h",
+ "android/download/download_media_parser.cc",
+ "android/download/download_media_parser.h",
"android/download/duplicate_download_infobar_delegate.cc",
"android/download/duplicate_download_infobar_delegate.h",
"android/download/intercept_download_resource_throttle.cc",
@@ -1996,6 +2043,8 @@ jumbo_split_static_library("browser") {
"android/download/intercept_oma_download_navigation_throttle.cc",
"android/download/intercept_oma_download_navigation_throttle.h",
"android/download/items/offline_content_aggregator_factory_android.cc",
+ "android/download/local_media_data_source_factory.cc",
+ "android/download/local_media_data_source_factory.h",
"android/download/service/download_background_task.cc",
"android/download/service/download_task_scheduler.cc",
"android/download/service/download_task_scheduler.h",
@@ -2048,8 +2097,8 @@ jumbo_split_static_library("browser") {
"android/large_icon_bridge.h",
"android/locale/locale_manager.cc",
"android/locale/locale_manager.h",
- "android/locale/special_locale_handler.cc",
- "android/locale/special_locale_handler.h",
+ "android/locale/locale_template_url_loader.cc",
+ "android/locale/locale_template_url_loader.h",
"android/location_settings.h",
"android/location_settings_impl.cc",
"android/location_settings_impl.h",
@@ -2100,8 +2149,6 @@ jumbo_split_static_library("browser") {
"android/password_ui_view_android.h",
"android/payments/service_worker_payment_app_bridge.cc",
"android/photo_picker_sandbox_bridge.cc",
- "android/physical_web/physical_web_data_source_android.cc",
- "android/physical_web/physical_web_data_source_android.h",
"android/policy/policy_auditor.cc",
"android/preferences/autofill/autofill_profile_bridge.cc",
"android/preferences/browser_prefs_android.cc",
@@ -2306,6 +2353,8 @@ jumbo_split_static_library("browser") {
"profiles/profile_android.h",
"search/contextual_search_policy_handler_android.cc",
"search/contextual_search_policy_handler_android.h",
+ "search_engines/template_url_android.cc",
+ "search_engines/template_url_android.h",
"search_engines/template_url_service_android.cc",
"search_engines/template_url_service_android.h",
"signin/oauth2_token_service_delegate_android.cc",
@@ -2325,6 +2374,8 @@ jumbo_split_static_library("browser") {
":delta_file_proto",
":jni_headers",
"//chrome/browser/android/webapk:proto",
+ "//chrome/services/media_gallery_util:manifest", # TODO(xingliu): Tries to remove this.
+ "//chrome/services/media_gallery_util/public/cpp",
"//components/cdm/browser",
"//components/data_usage/android",
"//components/feed:feature_list",
@@ -2361,7 +2412,7 @@ jumbo_split_static_library("browser") {
"supervised_user/child_accounts/child_account_service_android.h",
]
}
- } else {
+ } else { # !is_android
sources += [
"accessibility/invert_bubble_prefs.cc",
"accessibility/invert_bubble_prefs.h",
@@ -2376,8 +2427,6 @@ jumbo_split_static_library("browser") {
"certificate_viewer.h",
"chrome_browser_field_trials_desktop.cc",
"chrome_browser_field_trials_desktop.h",
- "chrome_browser_main_posix.cc",
- "chrome_browser_main_posix.h",
"chrome_process_singleton.cc",
"chrome_process_singleton.h",
"custom_handlers/register_protocol_handler_permission_request.cc",
@@ -2408,6 +2457,8 @@ jumbo_split_static_library("browser") {
"download/download_dir_policy_handler.h",
"download/download_dir_util.cc",
"download/download_dir_util.h",
+ "download/download_open_prompt.cc",
+ "download/download_open_prompt.h",
"download/download_shelf.cc",
"download/download_shelf.h",
"download/download_shelf_context_menu.cc",
@@ -2437,7 +2488,6 @@ jumbo_split_static_library("browser") {
"first_run/first_run_internal.h",
"first_run/first_run_internal_linux.cc",
"first_run/first_run_internal_mac.mm",
- "first_run/first_run_internal_posix.cc",
"first_run/first_run_internal_win.cc",
"first_run/upgrade_util.h",
"first_run/upgrade_util_mac.cc",
@@ -2451,7 +2501,6 @@ jumbo_split_static_library("browser") {
"importer/external_process_importer_host.h",
"importer/firefox_profile_lock.cc",
"importer/firefox_profile_lock.h",
- "importer/firefox_profile_lock_posix.cc",
"importer/firefox_profile_lock_win.cc",
"importer/importer_list.cc",
"importer/importer_list.h",
@@ -2544,6 +2593,9 @@ jumbo_split_static_library("browser") {
"metrics/tab_stats_data_store.h",
"metrics/tab_stats_tracker.cc",
"metrics/tab_stats_tracker.h",
+ "metrics/tab_stats_tracker_delegate.h",
+ "metrics/tab_stats_tracker_delegate_win.cc",
+ "metrics/tab_stats_tracker_win.cc",
"metrics/tab_usage_recorder.cc",
"metrics/tab_usage_recorder.h",
"notifications/message_center_notification_manager.cc",
@@ -2567,7 +2619,6 @@ jumbo_split_static_library("browser") {
"policy/local_sync_policy_handler.h",
"process_singleton_modal_dialog_lock.cc",
"process_singleton_modal_dialog_lock.h",
- "process_singleton_posix.cc",
"process_singleton_startup_lock.cc",
"process_singleton_startup_lock.h",
"profile_resetter/brandcode_config_fetcher.cc",
@@ -2601,9 +2652,13 @@ jumbo_split_static_library("browser") {
"repost_form_warning_controller.h",
"resource_coordinator/background_tab_navigation_throttle.cc",
"resource_coordinator/background_tab_navigation_throttle.h",
+ "resource_coordinator/decision_details.cc",
+ "resource_coordinator/decision_details.h",
"resource_coordinator/discard_metrics_lifecycle_unit_observer.cc",
"resource_coordinator/discard_metrics_lifecycle_unit_observer.h",
"resource_coordinator/discard_reason.h",
+ "resource_coordinator/leveldb_site_characteristics_database.cc",
+ "resource_coordinator/leveldb_site_characteristics_database.h",
"resource_coordinator/lifecycle_unit.cc",
"resource_coordinator/lifecycle_unit.h",
"resource_coordinator/lifecycle_unit_base.cc",
@@ -2616,7 +2671,21 @@ jumbo_split_static_library("browser") {
"resource_coordinator/lifecycle_unit_source_observer.h",
"resource_coordinator/local_site_characteristics_data_impl.cc",
"resource_coordinator/local_site_characteristics_data_impl.h",
- "resource_coordinator/site_characteristic_database.h",
+ "resource_coordinator/local_site_characteristics_data_reader.cc",
+ "resource_coordinator/local_site_characteristics_data_reader.h",
+ "resource_coordinator/local_site_characteristics_data_store.cc",
+ "resource_coordinator/local_site_characteristics_data_store.h",
+ "resource_coordinator/local_site_characteristics_data_writer.cc",
+ "resource_coordinator/local_site_characteristics_data_writer.h",
+ "resource_coordinator/local_site_characteristics_database.h",
+ "resource_coordinator/local_site_characteristics_feature_usage.h",
+ "resource_coordinator/local_site_characteristics_non_recording_data_store.cc",
+ "resource_coordinator/local_site_characteristics_non_recording_data_store.h",
+ "resource_coordinator/local_site_characteristics_noop_data_writer.cc",
+ "resource_coordinator/local_site_characteristics_noop_data_writer.h",
+ "resource_coordinator/site_characteristics_data_reader.h",
+ "resource_coordinator/site_characteristics_data_store.h",
+ "resource_coordinator/site_characteristics_data_writer.h",
"resource_coordinator/tab_activity_watcher.cc",
"resource_coordinator/tab_activity_watcher.h",
"resource_coordinator/tab_lifecycle_observer.h",
@@ -2640,8 +2709,13 @@ jumbo_split_static_library("browser") {
"resource_coordinator/tab_manager_web_contents_data.h",
"resource_coordinator/tab_metrics_logger.cc",
"resource_coordinator/tab_metrics_logger.h",
- "resource_coordinator/time.cc",
- "resource_coordinator/time.h",
+ "search/background/ntp_background_data.cc",
+ "search/background/ntp_background_data.h",
+ "search/background/ntp_background_service.cc",
+ "search/background/ntp_background_service.h",
+ "search/background/ntp_background_service_factory.cc",
+ "search/background/ntp_background_service_factory.h",
+ "search/background/ntp_background_service_observer.h",
"search/iframe_source.cc",
"search/iframe_source.h",
"search/instant_service.cc",
@@ -2656,9 +2730,9 @@ jumbo_split_static_library("browser") {
"search/most_visited_iframe_source.h",
"search/one_google_bar/one_google_bar_data.cc",
"search/one_google_bar/one_google_bar_data.h",
- "search/one_google_bar/one_google_bar_fetcher.h",
- "search/one_google_bar/one_google_bar_fetcher_impl.cc",
- "search/one_google_bar/one_google_bar_fetcher_impl.h",
+ "search/one_google_bar/one_google_bar_loader.h",
+ "search/one_google_bar/one_google_bar_loader_impl.cc",
+ "search/one_google_bar/one_google_bar_loader_impl.h",
"search/one_google_bar/one_google_bar_service.cc",
"search/one_google_bar/one_google_bar_service.h",
"search/one_google_bar/one_google_bar_service_factory.cc",
@@ -2742,7 +2816,6 @@ jumbo_split_static_library("browser") {
"task_manager/providers/web_contents/web_contents_task_provider.cc",
"task_manager/providers/web_contents/web_contents_task_provider.h",
"task_manager/sampling/shared_sampler.h",
- "task_manager/sampling/shared_sampler_posix.cc",
"task_manager/sampling/shared_sampler_win.cc",
"task_manager/sampling/shared_sampler_win_defines.h",
"task_manager/sampling/task_group.cc",
@@ -2784,6 +2857,7 @@ jumbo_split_static_library("browser") {
"//chrome/browser/profile_resetter:profile_reset_report_proto",
"//chrome/browser/resource_coordinator:site_characteristics_proto",
"//chrome/browser/resource_coordinator:tab_metrics_event_proto",
+ "//chrome/browser/resource_coordinator/tab_ranker",
"//chrome/browser/resources:component_extension_resources",
"//chrome/browser/search:generated",
"//chrome/common/importer:interfaces",
@@ -2794,20 +2868,33 @@ jumbo_split_static_library("browser") {
"//components/zoom",
"//net:net",
]
+
+ if (is_posix || is_fuchsia) {
+ sources += [
+ "chrome_browser_main_posix.cc",
+ "chrome_browser_main_posix.h",
+ "first_run/first_run_internal_posix.cc",
+ "importer/firefox_profile_lock_posix.cc",
+ "process_singleton_posix.cc",
+ "task_manager/sampling/shared_sampler_posix.cc",
+ ]
+ }
}
if (is_chromeos) {
sources += [
- "component_updater/cros_component_installer.cc",
- "component_updater/cros_component_installer.h",
+ "ash_service_registry.cc",
+ "ash_service_registry.h",
+ "component_updater/cros_component_installer_chromeos.cc",
+ "component_updater/cros_component_installer_chromeos.h",
+ "component_updater/metadata_table_chromeos.cc",
+ "component_updater/metadata_table_chromeos.h",
"download/notification/download_item_notification.cc",
"download/notification/download_item_notification.h",
"download/notification/download_notification_manager.cc",
"download/notification/download_notification_manager.h",
"feedback/feedback_util_chromeos.cc",
"feedback/feedback_util_chromeos.h",
- "mash_service_registry.cc",
- "mash_service_registry.h",
"media/chromeos_login_media_access_handler.cc",
"media/chromeos_login_media_access_handler.h",
"media/public_session_media_access_handler.cc",
@@ -2865,6 +2952,7 @@ jumbo_split_static_library("browser") {
"//services/ui/public/cpp/input_devices",
"//services/ui/public/cpp/input_devices:input_device_controller",
"//services/ui/public/interfaces",
+ "//services/ui/ws2:lib",
"//ui/ozone",
]
allow_circular_includes_from += [ "//chrome/browser/chromeos" ]
@@ -2910,6 +2998,7 @@ jumbo_split_static_library("browser") {
"//chrome/common:metrics_constants_util_win",
"//chrome/common:version_header",
"//chrome/install_static:install_static_util",
+ "//chrome/notification_helper:constants",
"//chrome/services/util_win/public/mojom",
"//chrome_elf:blacklist",
"//chrome_elf:constants",
@@ -2923,6 +3012,7 @@ jumbo_split_static_library("browser") {
"//third_party/iaccessible2",
"//third_party/isimpledom",
"//third_party/wtl",
+ "//ui/aura_extra",
"//ui/base:fullscreen_win",
]
@@ -2936,26 +3026,31 @@ jumbo_split_static_library("browser") {
"notifications/notification_platform_bridge_win.h",
"notifications/notification_platform_bridge_win_metrics.cc",
"notifications/notification_platform_bridge_win_metrics.h",
+ "notifications/notification_platform_bridge_win_util.cc",
+ "notifications/notification_platform_bridge_win_util.h",
]
}
if (is_chrome_branded) {
deps += [
":conflicts_module_list_proto",
+ "//chrome_elf:third_party_shared_defines",
"//google_update",
]
libs += [ "msi.lib" ]
sources += [
"component_updater/third_party_module_list_component_installer_win.cc",
"component_updater/third_party_module_list_component_installer_win.h",
- "conflicts/installed_programs_win.cc",
- "conflicts/installed_programs_win.h",
+ "conflicts/incompatible_applications_updater_win.cc",
+ "conflicts/incompatible_applications_updater_win.h",
+ "conflicts/installed_applications_win.cc",
+ "conflicts/installed_applications_win.h",
+ "conflicts/module_blacklist_cache_util_win.cc",
+ "conflicts/module_blacklist_cache_util_win.h",
"conflicts/module_list_filter_win.cc",
"conflicts/module_list_filter_win.h",
"conflicts/msi_util_win.cc",
"conflicts/msi_util_win.h",
- "conflicts/problematic_programs_updater_win.cc",
- "conflicts/problematic_programs_updater_win.h",
"conflicts/registry_key_watcher_win.cc",
"conflicts/registry_key_watcher_win.h",
"conflicts/third_party_conflicts_manager_win.cc",
@@ -3017,6 +3112,7 @@ jumbo_split_static_library("browser") {
configs += [ "//build/config/linux:x11" ]
deps += [ "//ui/gfx/x" ]
}
+ deps += [ "//services/service_manager/zygote" ]
}
if (is_desktop_linux) {
@@ -3093,6 +3189,9 @@ jumbo_split_static_library("browser") {
"recovery/recovery_install_global_error_factory.cc",
"recovery/recovery_install_global_error_factory.h",
]
+ } else {
+ # On other platforms, use the generic implementation.
+ sources += [ "hang_monitor/hang_crash_dump.cc" ]
}
if (is_win || is_linux) {
@@ -3214,7 +3313,9 @@ jumbo_split_static_library("browser") {
"media_galleries/fileapi/mtp_file_stream_reader.h",
]
if (is_chromeos && use_dbus) {
- deps += [ "//device/media_transfer_protocol" ]
+ # TODO(donna.wu@intel.com): push this into chrome/browser/chromeos
+ # and chrome/browser/media_galleries/chromeos
+ deps += [ "//services/device/public/mojom" ]
}
}
@@ -3289,7 +3390,7 @@ jumbo_split_static_library("browser") {
]
}
- if (enable_basic_printing || enable_print_preview) {
+ if (enable_basic_printing) {
# Some form of printing support.
sources += [
"printing/print_job.cc",
@@ -3298,8 +3399,6 @@ jumbo_split_static_library("browser") {
"printing/print_job_manager.h",
"printing/print_job_worker.cc",
"printing/print_job_worker.h",
- "printing/print_job_worker_owner.cc",
- "printing/print_job_worker_owner.h",
"printing/print_view_manager_base.cc",
"printing/print_view_manager_base.h",
"printing/print_view_manager_common.cc",
@@ -3317,8 +3416,8 @@ jumbo_split_static_library("browser") {
]
deps += [
"//components/printing/browser",
- "//components/printing/service/public/cpp:utils",
- "//components/printing/service/public/interfaces",
+ "//components/services/pdf_compositor/public/cpp:utils",
+ "//components/services/pdf_compositor/public/interfaces",
"//printing",
]
@@ -3338,7 +3437,6 @@ jumbo_split_static_library("browser") {
"printing/background_printing_manager.h",
"printing/print_dialog_cloud.cc",
"printing/print_dialog_cloud.h",
- "printing/print_dialog_cloud_posix.cc",
"printing/print_dialog_cloud_win.cc",
"printing/print_error_dialog.cc",
"printing/print_error_dialog.h",
@@ -3356,6 +3454,10 @@ jumbo_split_static_library("browser") {
"printing/pwg_raster_converter.h",
]
+ if (is_posix || is_fuchsia) {
+ sources += [ "printing/print_dialog_cloud_posix.cc" ]
+ }
+
if (!is_chromeos) {
sources += [
"printing/cloud_print/cloud_print_proxy_service.cc",
@@ -3682,6 +3784,8 @@ jumbo_split_static_library("browser") {
sources += [
"offline_pages/background_loader_offliner.cc",
"offline_pages/background_loader_offliner.h",
+ "offline_pages/download_archive_manager.cc",
+ "offline_pages/download_archive_manager.h",
"offline_pages/downloads/resource_throttle.cc",
"offline_pages/downloads/resource_throttle.h",
"offline_pages/fresh_offline_content_observer.cc",
@@ -3694,6 +3798,8 @@ jumbo_split_static_library("browser") {
"offline_pages/offline_page_mhtml_archiver.h",
"offline_pages/offline_page_model_factory.h",
"offline_pages/offline_page_origin_utils.h",
+ "offline_pages/offline_page_request_handler.cc",
+ "offline_pages/offline_page_request_handler.h",
"offline_pages/offline_page_request_interceptor.cc",
"offline_pages/offline_page_request_interceptor.h",
"offline_pages/offline_page_request_job.cc",
@@ -3767,7 +3873,6 @@ jumbo_split_static_library("browser") {
"//components/offline_pages/core/background:background_offliner",
"//components/offline_pages/core/downloads:offline_pages_ui_adapter",
"//components/offline_pages/core/prefetch",
- "//components/offline_pages/core/recent_tabs",
"//components/offline_pages/core/renovations",
"//components/offline_pages/core/request_header:request_header",
]
@@ -4050,29 +4155,6 @@ jumbo_split_static_library("browser") {
"supervised_user/legacy/custodian_profile_downloader_service.h",
"supervised_user/legacy/custodian_profile_downloader_service_factory.cc",
"supervised_user/legacy/custodian_profile_downloader_service_factory.h",
- "supervised_user/legacy/permission_request_creator_sync.cc",
- "supervised_user/legacy/permission_request_creator_sync.h",
- "supervised_user/legacy/supervised_user_pref_mapping_service.cc",
- "supervised_user/legacy/supervised_user_pref_mapping_service.h",
- "supervised_user/legacy/supervised_user_pref_mapping_service_factory.cc",
- "supervised_user/legacy/supervised_user_pref_mapping_service_factory.h",
- "supervised_user/legacy/supervised_user_refresh_token_fetcher.cc",
- "supervised_user/legacy/supervised_user_refresh_token_fetcher.h",
- "supervised_user/legacy/supervised_user_registration_utility.cc",
- "supervised_user/legacy/supervised_user_registration_utility.h",
- "supervised_user/legacy/supervised_user_registration_utility_stub.cc",
- "supervised_user/legacy/supervised_user_registration_utility_stub.h",
- "supervised_user/legacy/supervised_user_shared_settings_service.cc",
- "supervised_user/legacy/supervised_user_shared_settings_service.h",
- "supervised_user/legacy/supervised_user_shared_settings_service_factory.cc",
- "supervised_user/legacy/supervised_user_shared_settings_service_factory.h",
- "supervised_user/legacy/supervised_user_shared_settings_update.cc",
- "supervised_user/legacy/supervised_user_shared_settings_update.h",
- "supervised_user/legacy/supervised_user_sync_service.cc",
- "supervised_user/legacy/supervised_user_sync_service.h",
- "supervised_user/legacy/supervised_user_sync_service_factory.cc",
- "supervised_user/legacy/supervised_user_sync_service_factory.h",
- "supervised_user/legacy/supervised_user_sync_service_observer.h",
"supervised_user/supervised_user_theme.cc",
"supervised_user/supervised_user_theme.h",
]
@@ -4109,43 +4191,6 @@ jumbo_split_static_library("browser") {
]
}
- if (enable_webrtc) {
- sources += [
- "media/webrtc/audio_debug_recordings_handler.cc",
- "media/webrtc/audio_debug_recordings_handler.h",
- "media/webrtc/webrtc_event_log_manager.cc",
- "media/webrtc/webrtc_event_log_manager.h",
- "media/webrtc/webrtc_event_log_manager_common.cc",
- "media/webrtc/webrtc_event_log_manager_common.h",
- "media/webrtc/webrtc_event_log_manager_local.cc",
- "media/webrtc/webrtc_event_log_manager_local.h",
- "media/webrtc/webrtc_event_log_manager_remote.cc",
- "media/webrtc/webrtc_event_log_manager_remote.h",
- "media/webrtc/webrtc_event_log_uploader.cc",
- "media/webrtc/webrtc_event_log_uploader.h",
- "media/webrtc/webrtc_log_uploader.cc",
- "media/webrtc/webrtc_log_uploader.h",
- "media/webrtc/webrtc_log_util.cc",
- "media/webrtc/webrtc_log_util.h",
- "media/webrtc/webrtc_logging_handler_host.cc",
- "media/webrtc/webrtc_logging_handler_host.h",
- "media/webrtc/webrtc_rtp_dump_handler.cc",
- "media/webrtc/webrtc_rtp_dump_handler.h",
- "media/webrtc/webrtc_rtp_dump_writer.cc",
- "media/webrtc/webrtc_rtp_dump_writer.h",
- "media/webrtc/webrtc_text_log_handler.cc",
- "media/webrtc/webrtc_text_log_handler.h",
- ]
- deps += [
- "//components/webrtc_logging/browser",
- "//components/webrtc_logging/common",
- "//content/public/browser",
- "//services/audio/public/cpp",
- "//third_party/webrtc_overrides",
- "//third_party/webrtc_overrides:init_webrtc",
- ]
- }
-
if (!is_chrome_branded && !is_android) {
sources += [
"search/local_files_ntp_source.cc",
@@ -4190,6 +4235,18 @@ jumbo_split_static_library("browser") {
if (use_udev) {
deps += [ "//device/udev_linux" ]
}
+
+ if (enable_feed_in_chrome) {
+ sources += [
+ "android/feed/feed_host_service_factory.cc",
+ "android/feed/feed_host_service_factory.h",
+ "android/feed/feed_image_loader_bridge.cc",
+ "android/feed/feed_image_loader_bridge.h",
+ "android/feed/feed_network_bridge.cc",
+ "android/feed/feed_network_bridge.h",
+ ]
+ deps += [ "//components/feed/core:feed_core" ]
+ }
}
if (is_android) {
@@ -4261,7 +4318,6 @@ if (is_android) {
"../android/java/src/org/chromium/chrome/browser/crash/MinidumpUploadService.java",
"../android/java/src/org/chromium/chrome/browser/crash/PureJavaExceptionHandler.java",
"../android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java",
- "../android/java/src/org/chromium/chrome/browser/customtabs/LoadingPredictor.java",
"../android/java/src/org/chromium/chrome/browser/database/SQLiteCursor.java",
"../android/java/src/org/chromium/chrome/browser/datausage/DataUseTabUIManager.java",
"../android/java/src/org/chromium/chrome/browser/datausage/ExternalDataUseObserver.java",
@@ -4296,6 +4352,7 @@ if (is_android) {
"../android/java/src/org/chromium/chrome/browser/infobar/AutofillSaveCardInfoBar.java",
"../android/java/src/org/chromium/chrome/browser/infobar/ConfirmInfoBar.java",
"../android/java/src/org/chromium/chrome/browser/infobar/DataReductionPromoInfoBarDelegate.java",
+ "../android/java/src/org/chromium/chrome/browser/infobar/DownloadProgressInfoBar.java",
"../android/java/src/org/chromium/chrome/browser/infobar/DuplicateDownloadInfoBar.java",
"../android/java/src/org/chromium/chrome/browser/infobar/FramebustBlockInfoBar.java",
"../android/java/src/org/chromium/chrome/browser/infobar/GeneratedPasswordSavedInfoBarDelegate.java",
@@ -4318,7 +4375,7 @@ if (is_android) {
"../android/java/src/org/chromium/chrome/browser/invalidation/InvalidationServiceFactory.java",
"../android/java/src/org/chromium/chrome/browser/jsdialog/JavascriptTabModalDialog.java",
"../android/java/src/org/chromium/chrome/browser/locale/LocaleManager.java",
- "../android/java/src/org/chromium/chrome/browser/locale/SpecialLocaleHandler.java",
+ "../android/java/src/org/chromium/chrome/browser/locale/LocaleTemplateUrlLoader.java",
"../android/java/src/org/chromium/chrome/browser/media/cdm/MediaDrmCredentialManager.java",
"../android/java/src/org/chromium/chrome/browser/media/remote/RecordCastAction.java",
"../android/java/src/org/chromium/chrome/browser/media/remote/RemoteMediaPlayerBridge.java",
@@ -4365,7 +4422,7 @@ if (is_android) {
"../android/java/src/org/chromium/chrome/browser/page_info/CertificateChainHelper.java",
"../android/java/src/org/chromium/chrome/browser/page_info/CertificateViewer.java",
"../android/java/src/org/chromium/chrome/browser/page_info/ConnectionInfoPopup.java",
- "../android/java/src/org/chromium/chrome/browser/page_info/PageInfoPopup.java",
+ "../android/java/src/org/chromium/chrome/browser/page_info/PageInfoController.java",
"../android/java/src/org/chromium/chrome/browser/partnerbookmarks/PartnerBookmarksReader.java",
"../android/java/src/org/chromium/chrome/browser/partnercustomizations/PartnerBrowserCustomizations.java",
"../android/java/src/org/chromium/chrome/browser/password_manager/AccountChooserDialog.java",
@@ -4379,7 +4436,6 @@ if (is_android) {
"../android/java/src/org/chromium/chrome/browser/permissions/PermissionDialogDelegate.java",
"../android/java/src/org/chromium/chrome/browser/permissions/PermissionUmaUtil.java",
"../android/java/src/org/chromium/chrome/browser/photo_picker/DecoderService.java",
- "../android/java/src/org/chromium/chrome/browser/physicalweb/UrlManager.java",
"../android/java/src/org/chromium/chrome/browser/policy/PolicyAuditor.java",
"../android/java/src/org/chromium/chrome/browser/preferences/LocationSettings.java",
"../android/java/src/org/chromium/chrome/browser/preferences/PrefChangeRegistrar.java",
@@ -4399,6 +4455,7 @@ if (is_android) {
"../android/java/src/org/chromium/chrome/browser/rappor/RapporServiceBridge.java",
"../android/java/src/org/chromium/chrome/browser/rlz/RevenueStats.java",
"../android/java/src/org/chromium/chrome/browser/rlz/RlzPingHandler.java",
+ "../android/java/src/org/chromium/chrome/browser/search_engines/TemplateUrl.java",
"../android/java/src/org/chromium/chrome/browser/search_engines/TemplateUrlService.java",
"../android/java/src/org/chromium/chrome/browser/sessions/SessionTabHelper.java",
"../android/java/src/org/chromium/chrome/browser/signin/AccountManagementScreenHelper.java",
@@ -4420,6 +4477,7 @@ if (is_android) {
"../android/java/src/org/chromium/chrome/browser/tab/TabWebContentsDelegateAndroid.java",
"../android/java/src/org/chromium/chrome/browser/tabmodel/SingleTabModel.java",
"../android/java/src/org/chromium/chrome/browser/tabmodel/TabModelJniBridge.java",
+ "../android/java/src/org/chromium/chrome/browser/tabmodel/TabModelObserverJniBridge.java",
"../android/java/src/org/chromium/chrome/browser/toolbar/ToolbarModel.java",
"../android/java/src/org/chromium/chrome/browser/util/ChromeContextUtil.java",
"../android/java/src/org/chromium/chrome/browser/util/FeatureUtilities.java",
@@ -4438,6 +4496,14 @@ if (is_android) {
if (enable_offline_pages_harness) {
sources += [ "../android/java/src/org/chromium/chrome/browser/offlinepages/evaluation/OfflinePageEvaluationBridge.java" ]
}
+
+ if (enable_feed_in_chrome) {
+ sources += [
+ "../android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedImageLoaderBridge.java",
+ "../android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedNetworkBridge.java",
+ ]
+ }
+
jni_package = "chrome"
}
@@ -4548,6 +4614,10 @@ grit("resources") {
deps += [ "//chrome/browser/ui/webui/discards:mojo_bindings_js" ]
}
+ if (is_android) {
+ deps += [ "//chrome/browser/ui/webui/snippets_internals:mojo_bindings_js" ]
+ }
+
if (optimize_webui) {
deps += [
"//chrome/browser/resources/md_bookmarks:build",
@@ -4567,6 +4637,10 @@ grit("resources") {
deps +=
[ "//chrome/browser/resources/safe_browsing:make_file_types_protobuf" ]
}
+
+ if (safe_browsing_mode == 1) {
+ deps += [ "//chrome/browser/ui/webui/reset_password:mojo_bindings_js" ]
+ }
}
if (is_chrome_branded) {
@@ -4923,7 +4997,11 @@ static_library("test_support_ui") {
"ui/webui/web_ui_test_handler.h",
]
- deps += [ "//chrome/common:mojo_bindings" ]
+ deps += [
+ "//chrome:browser_tests_pak",
+ "//chrome/common:mojo_bindings",
+ "//chrome/test/data:web_ui_test_bindings",
+ ]
}
}
diff --git a/chromium/chrome/browser/android/vr/BUILD.gn b/chromium/chrome/browser/android/vr/BUILD.gn
index be7f32c8da4..e27b7b789f8 100644
--- a/chromium/chrome/browser/android/vr/BUILD.gn
+++ b/chromium/chrome/browser/android/vr/BUILD.gn
@@ -29,12 +29,12 @@ static_library("vr_android") {
"mailbox_to_surface_bridge.h",
"metrics_util_android.cc",
"metrics_util_android.h",
+ "scoped_gpu_trace.cc",
+ "scoped_gpu_trace.h",
"vr_controller.cc",
"vr_controller.h",
"vr_core_info.cc",
"vr_core_info.h",
- "vr_dialog.cc",
- "vr_dialog.h",
"vr_gl_thread.cc",
"vr_gl_thread.h",
"vr_input_connection.cc",
@@ -49,6 +49,30 @@ static_library("vr_android") {
"vr_web_contents_observer.h",
]
+ if (enable_arcore) {
+ sources += [
+ "arcore_device/ar_image_transport.cc",
+ "arcore_device/ar_image_transport.h",
+ "arcore_device/arcore.h",
+ "arcore_device/arcore_device.cc",
+ "arcore_device/arcore_device.h",
+ "arcore_device/arcore_device_provider.cc",
+ "arcore_device/arcore_device_provider.h",
+ "arcore_device/arcore_gl.cc",
+ "arcore_device/arcore_gl.h",
+ "arcore_device/arcore_gl_thread.cc",
+ "arcore_device/arcore_gl_thread.h",
+ "arcore_device/arcore_impl.cc",
+ "arcore_device/arcore_impl.h",
+ "arcore_device/arcore_java_utils.cc",
+ "arcore_device/arcore_java_utils.h",
+ "arcore_device/arcore_shim.cc",
+ "arcore_device/arcore_shim.h",
+ "arcore_device/fake_arcore.cc",
+ "arcore_device/fake_arcore.h",
+ ]
+ }
+
deps = [
":vr_shell_jni_headers",
"//base",
@@ -63,6 +87,7 @@ static_library("vr_android") {
"//services/device/public/mojom",
"//services/metrics/public/cpp:ukm_builders",
"//services/ui/public/cpp/gpu",
+ "//third_party/gvr-android-sdk:gvr_shim",
"//ui/android",
"//ui/base",
"//ui/display",
@@ -70,19 +95,24 @@ static_library("vr_android") {
"//ui/gl/init",
]
+ if (enable_arcore) {
+ deps += [ ":ar_jni_headers" ]
+ }
+
public_deps = [
"//device/vr/public/mojom",
]
- libs = [
- "//third_party/gvr-android-sdk/libgvr_shim_static_${current_cpu}.a",
- "android",
- ]
+ libs = [ "android" ]
configs += [
"//third_party/gvr-android-keyboard:kb_config",
"//third_party/gvr-android-sdk:libgvr_config",
]
+
+ if (enable_arcore) {
+ configs += [ "//third_party/arcore-android-sdk:libarcore_config" ]
+ }
}
generate_jni("vr_shell_jni_headers") {
@@ -98,3 +128,12 @@ generate_jni("vr_shell_jni_headers") {
]
jni_package = "vr_shell"
}
+
+if (enable_arcore) {
+ generate_jni("ar_jni_headers") {
+ sources = [
+ "//chrome/android/java/src/org/chromium/chrome/browser/vr/ArCoreJavaUtils.java",
+ ]
+ jni_package = "vr"
+ }
+}
diff --git a/chromium/chrome/browser/browser_resources.grd b/chromium/chrome/browser/browser_resources.grd
index 1cabcd22814..58912721f98 100644
--- a/chromium/chrome/browser/browser_resources.grd
+++ b/chromium/chrome/browser/browser_resources.grd
@@ -8,9 +8,6 @@
</outputs>
<release seq="1">
<structures>
- <if expr="enable_extensions">
- <structure name="IDR_EXTENSIONS_HTML" file="resources\extensions\extensions.html" flattenhtml="true" type="chrome_html" />
- </if>
<if expr="chromeos">
<structure name="IDR_FIRST_RUN_HTML" file="resources\chromeos\first_run\first_run.html" flattenhtml="true" type="chrome_html"/>
<structure name="IDR_FIRST_RUN_JS" file="resources\chromeos\first_run\first_run.js" flattenhtml="true" type="chrome_html" />
@@ -115,7 +112,6 @@
<include name="IDR_BLUETOOTH_INTERNALS_SIDEBAR_JS" file="resources\bluetooth_internals\sidebar.js" type="BINDATA" compress="gzip" />
<include name="IDR_BLUETOOTH_INTERNALS_SNACKBAR_JS" file="resources\bluetooth_internals\snackbar.js" type="BINDATA" compress="gzip" />
<include name="IDR_BLUETOOTH_INTERNALS_VALUE_CONTROL_JS" file="resources\bluetooth_internals\value_control.js" type="BINDATA" compress="gzip" />
- <include name="IDR_BOOKMARKS_MANIFEST" file="resources\bookmark_manager\manifest.json" type="BINDATA" />
<if expr="is_posix and not is_macosx">
<include name="IDR_CERTIFICATE_VIEWER_HTML" file="resources\certificate_viewer.html" type="BINDATA" />
<include name="IDR_CERTIFICATE_VIEWER_JS" file="resources\certificate_viewer.js" type="BINDATA" />
@@ -126,7 +122,7 @@
</if>
<if expr="enable_printing">
<include name="IDR_CLOUDPRINT_MANIFEST" file="resources\cloud_print_app\manifest.json" type="BINDATA" />
- <include name="IDR_PDF_COMPOSITOR_MANIFEST" file="..\..\components\printing\service\pdf_compositor_manifest.json" type="BINDATA" />
+ <include name="IDR_PDF_COMPOSITOR_MANIFEST" file="..\..\components\services\pdf_compositor\pdf_compositor_manifest.json" type="BINDATA" />
</if>
<include name="IDR_CHROME_RENDERER_SERVICE_MANIFEST" file="..\app\chrome_renderer_manifest.json" type="BINDATA" />
<include name="IDR_DEVTOOLS_DISCOVERY_PAGE_HTML" file="devtools\frontend\devtools_discovery_page.html" type="BINDATA"/>
@@ -171,20 +167,16 @@
</else>
</if>
</if>
- <if expr="enable_extensions">
- <include name="IDR_EXTENSION_COMMAND_LIST_JS" file="resources\extensions\extension_command_list.js" flattenhtml="true" type="BINDATA" />
- <include name="IDR_EXTENSION_LIST_JS" file="resources\extensions\extension_list.js" flattenhtml="true" type="BINDATA" />
- <include name="IDR_EXTENSIONS_JS" file="resources\extensions\extensions.js" flattenhtml="true" type="BINDATA" />
- </if>
<include name="IDR_FEEDBACK_MANIFEST" file="resources\feedback\manifest.json" type="BINDATA" />
<if expr="is_android">
<include name="IDR_OFFLINE_INTERNALS_HTML" file="resources\offline_pages\offline_internals.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" compress="gzip" />
<include name="IDR_OFFLINE_INTERNALS_CSS" file="resources\offline_pages\offline_internals.css" type="BINDATA" compress="gzip" />
<include name="IDR_OFFLINE_INTERNALS_JS" file="resources\offline_pages\offline_internals.js" type="BINDATA" compress="gzip" />
<include name="IDR_OFFLINE_INTERNALS_BROWSER_PROXY_JS" file="resources\offline_pages\offline_internals_browser_proxy.js" type="BINDATA" compress="gzip" />
- <include name="IDR_SNIPPETS_INTERNALS_HTML" file="resources\snippets_internals.html" allowexternalscript="true" compress="gzip" type="BINDATA" />
- <include name="IDR_SNIPPETS_INTERNALS_CSS" file="resources\snippets_internals.css" compress="gzip" type="BINDATA" />
- <include name="IDR_SNIPPETS_INTERNALS_JS" file="resources\snippets_internals.js" compress="gzip" type="BINDATA" />
+ <include name="IDR_SNIPPETS_INTERNALS_HTML" file="resources\snippets_internals\snippets_internals.html" allowexternalscript="true" compress="gzip" type="BINDATA" />
+ <include name="IDR_SNIPPETS_INTERNALS_CSS" file="resources\snippets_internals\snippets_internals.css" compress="gzip" type="BINDATA" />
+ <include name="IDR_SNIPPETS_INTERNALS_JS" file="resources\snippets_internals\snippets_internals.js" compress="gzip" type="BINDATA" />
+ <include name="IDR_SNIPPETS_INTERNALS_MOJO_JS" file="${root_gen_dir}\chrome\browser\ui\webui\snippets_internals\snippets_internals.mojom.js" use_base_dir="false" type="BINDATA" compress="gzip" />
</if>
<include name="IDR_SUPERVISED_USER_INTERNALS_HTML" file="resources\supervised_user_internals.html" allowexternalscript="true" compress="gzip" type="BINDATA" />
<include name="IDR_SUPERVISED_USER_INTERNALS_CSS" file="resources\supervised_user_internals.css" compress="gzip" type="BINDATA" />
@@ -295,6 +287,9 @@
<include name="IDR_MD_HISTORY_SYNCED_DEVICE_MANAGER_JS" file="resources\md_history\synced_device_manager.js" type="BINDATA" />
</else>
</if>
+
+ <!-- Page not available for guest. -->
+ <include name="IDR_PAGE_NOT_AVAILABLE_FOR_GUEST_APP_HTML" file="resources\page_not_available_for_guest\app.html" type="BINDATA" />
</if>
<include name="IDR_IDENTITY_API_SCOPE_APPROVAL_MANIFEST" file="resources\identity_scope_approval_dialog\manifest.json" type="BINDATA" />
@@ -330,6 +325,8 @@
<include name="IDR_LOCAL_NTP_JS" file="resources\local_ntp\local_ntp.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_LOCAL_NTP_VOICE_CSS" file="resources\local_ntp\voice.css" flattenhtml="true" type="BINDATA" />
<include name="IDR_LOCAL_NTP_VOICE_JS" file="resources\local_ntp\voice.js" flattenhtml="true" type="BINDATA" />
+ <include name="IDR_LOCAL_NTP_CUSTOM_BACKGROUNDS_CSS" file="resources\local_ntp\custom_backgrounds.css" flattenhtml="true" type="BINDATA" />
+ <include name="IDR_LOCAL_NTP_CUSTOM_BACKGROUNDS_JS" file="resources\local_ntp\custom_backgrounds.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_LOCAL_STATE_HTML" file="resources\local_state\local_state.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" compress="gzip" />
<include name="IDR_LOCAL_STATE_JS" file="resources\local_state\local_state.js" flattenhtml="true" allowexternalscript="true" type="BINDATA" compress="gzip" />
<include name="IDR_MOST_VISITED_IFRAME_CSS" file="resources\local_ntp\most_visited_iframe.css" type="BINDATA" />
@@ -430,10 +427,8 @@
<include name="IDR_USER_ACTIONS_HTML" file="resources\user_actions\user_actions.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" compress="gzip" />
<include name="IDR_USER_ACTIONS_CSS" file="resources\user_actions\user_actions.css" type="BINDATA" compress="gzip" />
<include name="IDR_USER_ACTIONS_JS" file="resources\user_actions\user_actions.js" type="BINDATA" compress="gzip" />
- <if expr="enable_webrtc">
- <include name="IDR_WEBRTC_LOGS_HTML" file="resources\media\webrtc_logs.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
- <include name="IDR_WEBRTC_LOGS_JS" file="resources\media\webrtc_logs.js" type="BINDATA" />
- </if>
+ <include name="IDR_WEBRTC_LOGS_HTML" file="resources\media\webrtc_logs.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
+ <include name="IDR_WEBRTC_LOGS_JS" file="resources\media\webrtc_logs.js" type="BINDATA" />
<include name="IDR_WEBSTORE_MANIFEST" file="resources\webstore_app\manifest.json" type="BINDATA" />
<include name="IDR_CRYPTOTOKEN_MANIFEST" file="resources\cryptotoken\manifest.json" type="BINDATA" />
<include name="IDR_GAIA_AUTH_MANIFEST" file="resources\gaia_auth\manifest.json" type="BINDATA" />
@@ -496,6 +491,7 @@
<include name="IDR_GENIUS_APP_MANIFEST" file="resources\chromeos\genius_app\manifest.json" type="BINDATA" />
<include name="IDR_HELP_MANIFEST" file="resources\help_app\manifest.json" type="BINDATA" />
<include name="IDR_QUICKOFFICE_MANIFEST" file="resources\chromeos\quickoffice\manifest.json" type="BINDATA" />
+ <include name="IDR_PRODUCT_CHROMEOS_SYNC_CONSENT_SCREEN_ICONS" file="internal\resources\chromeos-sync-consent-icons.html" type="BINDATA" />
</if>
<if expr="is_win">
<include name="IDR_SET_AS_DEFAULT_BROWSER_JS" file="resources\set_as_default_browser.js" flattenhtml="true" type="BINDATA" />
@@ -508,14 +504,8 @@
<include name="IDR_MD_CREATE_PROFILE_JS" file="resources\md_user_manager\create_profile.js" type="BINDATA" />
<include name="IDR_MD_ERROR_DIALOG_HTML" file="resources\md_user_manager\error_dialog.html" type="BINDATA" />
<include name="IDR_MD_ERROR_DIALOG_JS" file="resources\md_user_manager\error_dialog.js" type="BINDATA" />
- <include name="IDR_MD_IMPORT_SUPERVISED_USER_HTML" file="resources\md_user_manager\import_supervised_user.html" type="BINDATA" />
- <include name="IDR_MD_IMPORT_SUPERVISED_USER_JS" file="resources\md_user_manager\import_supervised_user.js" type="BINDATA" />
<include name="IDR_MD_PROFILE_BROWSER_PROXY_HTML" file="resources\md_user_manager\profile_browser_proxy.html" type="BINDATA" />
<include name="IDR_MD_PROFILE_BROWSER_PROXY_JS" file="resources\md_user_manager\profile_browser_proxy.js" type="BINDATA" />
- <include name="IDR_MD_SUPERVISED_USER_CREATE_CONFIRM_HTML" file="resources\md_user_manager\supervised_user_create_confirm.html" type="BINDATA" />
- <include name="IDR_MD_SUPERVISED_USER_CREATE_CONFIRM_JS" file="resources\md_user_manager\supervised_user_create_confirm.js" type="BINDATA" />
- <include name="IDR_MD_SUPERVISED_USER_LEARN_MORE_HTML" file="resources\md_user_manager\supervised_user_learn_more.html" type="BINDATA" />
- <include name="IDR_MD_SUPERVISED_USER_LEARN_MORE_JS" file="resources\md_user_manager\supervised_user_learn_more.js" type="BINDATA" />
<include name="IDR_MD_USER_MANAGER_HTML" file="resources\md_user_manager\user_manager.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_MD_USER_MANAGER_JS" file="resources\md_user_manager\user_manager.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_MD_USER_MANAGER_PAGES_HTML" file="resources\md_user_manager\user_manager_pages.html" type="BINDATA" />
@@ -564,6 +554,7 @@
<include name="IDR_SOUND_TOUCH_TYPE_WAV" file="resources\chromeos\sounds\touch_type.wav" type="BINDATA" />
<include name="IDR_SOUND_DICTATION_END_WAV" file="resources\chromeos\sounds\earcons\audio_end.wav" type="BINDATA" />
<include name="IDR_SOUND_DICTATION_START_WAV" file="resources\chromeos\sounds\earcons\audio_initiate.wav" type="BINDATA" />
+ <include name="IDR_SOUND_DICTATION_CANCEL_WAV" file="resources\chromeos\sounds\earcons\null_selection.wav" type="BINDATA" />
</if>
<if expr="chromeos">
<include name="IDR_ABOUT_POWER_HTML" file="resources\chromeos\power.html" type="BINDATA" />
@@ -657,6 +648,14 @@
<if expr="chromeos">
<include name="IDR_ASSISTANT_LOGO_PNG" file="resources\chromeos\assistant_optin\assistant_logo.png" type="BINDATA" />
</if>
+ <if expr="safe_browsing_mode == 1">
+ <include name="IDR_RESET_PASSWORD_HTML" file="resources\reset_password\reset_password.html" type="BINDATA" compress="gzip" />
+ <include name="IDR_RESET_PASSWORD_JS" file="resources\reset_password\reset_password.js" type="BINDATA" compress="gzip" />
+ <include name="IDR_RESET_PASSWORD_MOJO_JS" file="${root_gen_dir}\chrome\browser\ui\webui\reset_password\reset_password.mojom.js" use_base_dir="false" type="BINDATA" compress="gzip" />
+ </if>
+ <if expr="not is_android">
+ <include name="IDR_TAB_RANKER_EXAMPLE_PREPROCESSOR_CONFIG_PB" file="resource_coordinator\tab_ranker\example_preprocessor_config.pb" type="BINDATA" />
+ </if>
</includes>
</release>
</grit>
diff --git a/chromium/chrome/browser/chrome_content_browser_manifest_overlay.json b/chromium/chrome/browser/chrome_content_browser_manifest_overlay.json
index cd82cd63bff..3805676f7b8 100644
--- a/chromium/chrome/browser/chrome_content_browser_manifest_overlay.json
+++ b/chromium/chrome/browser/chrome_content_browser_manifest_overlay.json
@@ -5,23 +5,23 @@
"service_manager:connector": {
"provides": {
"renderer": [
- "autofill::mojom::AutofillDriver",
- "autofill::mojom::PasswordManagerDriver",
- "chrome::mojom::CacheStatsRecorder",
- "chrome::mojom::NetBenchmarking",
- "extensions::StashService",
- "metrics::mojom::CallStackProfileCollector",
- "mojom::ModuleEventSink",
- "rappor::mojom::RapporRecorder",
- "safe_browsing::mojom::SafeBrowsing",
- "translate::mojom::ContentTranslateDriver"
+ "autofill.mojom.AutofillDriver",
+ "autofill.mojom.PasswordManagerDriver",
+ "chrome.mojom.CacheStatsRecorder",
+ "chrome.mojom.NetBenchmarking",
+ "extensions.StashService",
+ "metrics.mojom.CallStackProfileCollector",
+ "mojom.ModuleEventSink",
+ "rappor.mojom.RapporRecorder",
+ "safe_browsing.mojom.SafeBrowsing",
+ "translate.mojom.ContentTranslateDriver"
],
"gpu": [
- "metrics::mojom::CallStackProfileCollector"
+ "metrics.mojom.CallStackProfileCollector"
],
"ime:ime_driver": [],
"profiling_client": [
- "heap_profiling::mojom::ProfilingClient"
+ "heap_profiling.mojom.ProfilingClient"
]
},
"requires": {
@@ -69,60 +69,63 @@
"navigation:frame": {
"provides": {
"renderer": [
- "autofill::mojom::AutofillDriver",
- "autofill::mojom::PasswordManagerDriver",
- "blink::mojom::BudgetService",
- "blink::mojom::InstalledAppProvider",
- "blink::mojom::MediaDownloadInProductHelp",
- "blink::mojom::ShareService",
- "blink::mojom::TextSuggestionHost",
- "chrome::mojom::OpenSearchDocumentDescriptionHandler",
- "chrome::mojom::PrerenderCanceler",
- "contextual_search::mojom::ContextualSearchJsApiService",
- "dom_distiller::mojom::DistillabilityService",
- "dom_distiller::mojom::DistillerJavaScriptService",
- "extensions::KeepAlive",
- "extensions::mime_handler::MimeHandlerService",
- "extensions::mojom::InlineInstall",
- "media_router::mojom::MediaRouter",
- "page_load_metrics::mojom::PageLoadMetrics",
- "password_manager::mojom::CredentialManager",
- "safe_browsing::mojom::PhishingDetectorClient",
- "translate::mojom::ContentTranslateDriver",
+ "autofill.mojom.AutofillDriver",
+ "autofill.mojom.PasswordManagerDriver",
+ "blink.mojom.BudgetService",
+ "blink.mojom.InstalledAppProvider",
+ "blink.mojom.MediaDownloadInProductHelp",
+ "blink.mojom.ShareService",
+ "blink.mojom.TextSuggestionHost",
+ "chrome.mojom.OpenSearchDocumentDescriptionHandler",
+ "chrome.mojom.PrerenderCanceler",
+ "contextual_search.mojom.ContextualSearchJsApiService",
+ "dom_distiller.mojom.DistillabilityService",
+ "dom_distiller.mojom.DistillerJavaScriptService",
+ "extensions.KeepAlive",
+ "extensions.mime_handler.MimeHandlerService",
+ "extensions.mojom.InlineInstall",
+ "media_router.mojom.MediaRouter",
+ "page_load_metrics.mojom.PageLoadMetrics",
+ "password_manager.mojom.CredentialManager",
+ "safe_browsing.mojom.PhishingDetectorClient",
+ "translate.mojom.ContentTranslateDriver",
// TODO(beng): These should be moved to a separate capability.
- "media::mojom::MediaEngagementScoreDetailsProvider",
- "mojom::BluetoothInternalsHandler",
- "mojom::DiscardsDetailsProvider",
- "mojom::InterventionsInternalsPageHandler",
- "mojom::OmniboxPageHandler",
- "mojom::PluginsPageHandler",
- "mojom::SiteEngagementDetailsProvider",
- "mojom::UsbInternalsPageHandler"
+ "media.mojom.MediaEngagementScoreDetailsProvider",
+ "mojom.BluetoothInternalsHandler",
+ "mojom.DiscardsDetailsProvider",
+ "mojom.InterventionsInternalsPageHandler",
+ "mojom.OmniboxPageHandler",
+ "mojom.PluginsPageHandler",
+ "mojom.ResetPasswordHandler",
+ "mojom.SiteEngagementDetailsProvider",
+ "mojom.UsbInternalsPageHandler",
+ "snippets_internals.mojom.PageHandlerFactory",
+ "web_ui_test.mojom.TestRunner"
],
"multidevice_setup" : [
- "chromeos::multidevice_setup::mojom::MultiDeviceSetup"
+ "chromeos.multidevice_setup.mojom.MultiDeviceSetup"
]
}
},
"navigation:dedicated_worker": {
"provides": {
"renderer": [
- "blink::mojom::BudgetService"
+ "blink.mojom.BudgetService"
]
}
},
"navigation:service_worker": {
"provides": {
"renderer": [
- "blink::mojom::BudgetService"
+ "blink.mojom.BudgetService"
]
}
},
"navigation:shared_worker": {
"provides": {
"renderer": [
- "blink::mojom::BudgetService"
+ "blink.mojom.BudgetService"
]
}
}
diff --git a/chromium/chrome/browser/chrome_content_gpu_manifest_overlay.json b/chromium/chrome/browser/chrome_content_gpu_manifest_overlay.json
index ad9a70f5c59..a590957557e 100644
--- a/chromium/chrome/browser/chrome_content_gpu_manifest_overlay.json
+++ b/chromium/chrome/browser/chrome_content_gpu_manifest_overlay.json
@@ -4,13 +4,13 @@
"service_manager:connector": {
"provides": {
"browser": [
- "arc::mojom::ProtectedBufferManager",
- "arc::mojom::VideoDecodeAccelerator",
- "arc::mojom::VideoDecodeClient",
- "arc::mojom::VideoEncodeAccelerator",
- "arc::mojom::VideoEncodeClient",
- "arc::mojom::VideoProtectedBufferAllocator",
- "heap_profiling::mojom::ProfilingClient"
+ "arc.mojom.ProtectedBufferManager",
+ "arc.mojom.VideoDecodeAccelerator",
+ "arc.mojom.VideoDecodeClient",
+ "arc.mojom.VideoEncodeAccelerator",
+ "arc.mojom.VideoEncodeClient",
+ "arc.mojom.VideoProtectedBufferAllocator",
+ "heap_profiling.mojom.ProfilingClient"
]
}
}
diff --git a/chromium/chrome/browser/chrome_content_renderer_manifest_overlay.json b/chromium/chrome/browser/chrome_content_renderer_manifest_overlay.json
index 48265a3bf53..beb16f2166f 100644
--- a/chromium/chrome/browser/chrome_content_renderer_manifest_overlay.json
+++ b/chromium/chrome/browser/chrome_content_renderer_manifest_overlay.json
@@ -5,27 +5,27 @@
"service_manager:connector": {
"provides": {
"browser": [
- "chrome::mojom::SearchBouncer",
- "heap_profiling::mojom::ProfilingClient"
+ "chrome.mojom.SearchBouncer",
+ "heap_profiling.mojom.ProfilingClient"
]
}
},
"navigation:frame": {
"provides": {
"browser": [
- "autofill::mojom::AutofillAgent",
- "autofill::mojom::PasswordAutofillAgent",
- "autofill::mojom::PasswordGenerationAgent",
- "blink::mojom::document_metadata::CopylessPaste",
- "chrome::mojom::ChromeRenderFrame",
- "chrome::mojom::ContentSettingsRenderer",
- "chrome::mojom::PrerenderDispatcher",
- "chrome::mojom::SandboxStatusExtension",
- "dom_distiller::mojom::DistillerPageNotifierService",
- "extensions::mojom::AppWindow",
- "safe_browsing::mojom::ThreatReporter",
- "safe_browsing::mojom::PhishingDetector",
- "spellcheck::mojom::SpellCheckPanel"
+ "autofill.mojom.AutofillAgent",
+ "autofill.mojom.PasswordAutofillAgent",
+ "autofill.mojom.PasswordGenerationAgent",
+ "blink.mojom.document_metadata.CopylessPaste",
+ "chrome.mojom.ChromeRenderFrame",
+ "chrome.mojom.ContentSettingsRenderer",
+ "chrome.mojom.PrerenderDispatcher",
+ "chrome.mojom.SandboxStatusExtension",
+ "dom_distiller.mojom.DistillerPageNotifierService",
+ "extensions.mojom.AppWindow",
+ "safe_browsing.mojom.ThreatReporter",
+ "safe_browsing.mojom.PhishingDetector",
+ "spellcheck.mojom.SpellCheckPanel"
]
},
"requires": {
diff --git a/chromium/chrome/browser/chrome_content_utility_manifest_overlay.json b/chromium/chrome/browser/chrome_content_utility_manifest_overlay.json
index 088f746e421..03d7cd6b486 100644
--- a/chromium/chrome/browser/chrome_content_utility_manifest_overlay.json
+++ b/chromium/chrome/browser/chrome_content_utility_manifest_overlay.json
@@ -4,13 +4,13 @@
"service_manager:connector": {
"provides": {
"browser": [
- "chrome::mojom::DialDeviceDescriptionParser",
- "chrome::mojom::ProfileImport",
- "chrome::mojom::ShellHandler",
- "payments::mojom::PaymentManifestParser",
- "heap_profiling::mojom::ProfilingClient",
- "proxy_resolver::mojom::ProxyResolverFactory",
- "safe_json::mojom::SafeJsonParser"
+ "chrome.mojom.DialDeviceDescriptionParser",
+ "chrome.mojom.ProfileImport",
+ "chrome.mojom.ShellHandler",
+ "payments.mojom.PaymentManifestParser",
+ "heap_profiling.mojom.ProfilingClient",
+ "proxy_resolver.mojom.ProxyResolverFactory",
+ "safe_json.mojom.SafeJsonParser"
]
}
}
diff --git a/chromium/chrome/browser/chromeos/BUILD.gn b/chromium/chrome/browser/chromeos/BUILD.gn
index 34b3744ddfa..fb5eb4dea62 100644
--- a/chromium/chrome/browser/chromeos/BUILD.gn
+++ b/chromium/chrome/browser/chromeos/BUILD.gn
@@ -4,7 +4,6 @@
import("//build/config/features.gni")
import("//build/config/ui.gni")
-import("//chromeos/assistant/assistant.gni")
import("//extensions/buildflags/buildflags.gni")
import("//media/media_options.gni")
import("//printing/buildflags/buildflags.gni")
@@ -21,7 +20,6 @@ source_set("chromeos") {
configs += [ "//build/config/compiler:wexit_time_destructors" ]
public_deps = [
- "//ash/resources",
"//ash/strings",
"//chrome:extra_resources",
"//chrome:resources",
@@ -33,6 +31,7 @@ source_set("chromeos") {
"//chromeos:vm_applications_apps_proto",
"//components/policy/proto",
"//content/app/resources",
+ "//ui/accessibility/mojom",
"//ui/chromeos/resources",
"//ui/chromeos/strings",
"//ui/resources",
@@ -50,6 +49,7 @@ source_set("chromeos") {
"//ash",
"//ash:ash_with_content",
"//ash/public/cpp",
+ "//ash/system/message_center/arc",
"//cc/paint",
"//chrome/app:command_ids",
"//chrome/app/vector_icons",
@@ -71,7 +71,8 @@ source_set("chromeos") {
"//chromeos:biod_proto",
"//chromeos:cryptohome_proto",
"//chromeos:cryptohome_signkey_proto",
- "//chromeos/assistant:buildflags",
+ "//chromeos:login_manager_proto",
+ "//chromeos/components/drivefs",
"//chromeos/components/proximity_auth",
"//chromeos/components/proximity_auth/logging",
"//chromeos/components/tether",
@@ -120,7 +121,6 @@ source_set("chromeos") {
"//components/safe_browsing/db:metadata_proto",
"//components/session_manager/core",
"//components/signin/core/browser",
- "//components/ssl_config",
"//components/startup_metric_utils/browser:lib",
"//components/storage_monitor",
"//components/sync_preferences",
@@ -152,7 +152,6 @@ source_set("chromeos") {
"//dbus",
"//device/base",
"//device/bluetooth",
- "//device/media_transfer_protocol",
"//device/usb/public/cpp",
"//device/usb/public/mojom",
"//extensions/browser",
@@ -163,7 +162,6 @@ source_set("chromeos") {
"//mash/public/mojom",
"//media",
"//media/mojo/interfaces",
- "//mojo/common",
"//net",
"//ppapi/proxy:ipc", # For PpapiMsg_LoadPlugin
"//services/data_decoder/public/cpp",
@@ -192,7 +190,6 @@ source_set("chromeos") {
"//third_party/webrtc_overrides",
"//third_party/zlib",
"//ui/app_list",
- "//ui/arc",
"//ui/aura",
"//ui/base",
"//ui/chromeos",
@@ -228,14 +225,6 @@ source_set("chromeos") {
allow_circular_includes_from = [ "//chrome/browser/extensions" ]
sources = [
- "../supervised_user/chromeos/manager_password_service.cc",
- "../supervised_user/chromeos/manager_password_service.h",
- "../supervised_user/chromeos/manager_password_service_factory.cc",
- "../supervised_user/chromeos/manager_password_service_factory.h",
- "../supervised_user/chromeos/supervised_user_password_service.cc",
- "../supervised_user/chromeos/supervised_user_password_service.h",
- "../supervised_user/chromeos/supervised_user_password_service_factory.cc",
- "../supervised_user/chromeos/supervised_user_password_service_factory.h",
"accessibility/accessibility_extension_loader.cc",
"accessibility/accessibility_extension_loader.h",
"accessibility/accessibility_manager.cc",
@@ -250,8 +239,8 @@ source_set("chromeos") {
"accessibility/magnification_manager.h",
"accessibility/select_to_speak_event_handler.cc",
"accessibility/select_to_speak_event_handler.h",
- "accessibility/spoken_feedback_event_rewriter.cc",
- "accessibility/spoken_feedback_event_rewriter.h",
+ "accessibility/spoken_feedback_event_rewriter_delegate.cc",
+ "accessibility/spoken_feedback_event_rewriter_delegate.h",
"accessibility/switch_access_event_handler.cc",
"accessibility/switch_access_event_handler.h",
"app_mode/app_launch_utils.cc",
@@ -315,6 +304,11 @@ source_set("chromeos") {
"arc/accessibility/arc_accessibility_util.h",
"arc/accessibility/ax_tree_source_arc.cc",
"arc/accessibility/ax_tree_source_arc.h",
+ "arc/app_shortcuts/arc_app_shortcut_item.h",
+ "arc/app_shortcuts/arc_app_shortcuts_menu_builder.cc",
+ "arc/app_shortcuts/arc_app_shortcuts_menu_builder.h",
+ "arc/app_shortcuts/arc_app_shortcuts_request.cc",
+ "arc/app_shortcuts/arc_app_shortcuts_request.h",
"arc/arc_migration_constants.h",
"arc/arc_migration_guide_notification.cc",
"arc/arc_migration_guide_notification.h",
@@ -330,6 +324,8 @@ source_set("chromeos") {
"arc/arc_support_host.h",
"arc/arc_util.cc",
"arc/arc_util.h",
+ "arc/arc_web_contents_data.cc",
+ "arc/arc_web_contents_data.h",
"arc/auth/arc_active_directory_enrollment_token_fetcher.cc",
"arc/auth/arc_active_directory_enrollment_token_fetcher.h",
"arc/auth/arc_auth_code_fetcher.h",
@@ -396,6 +392,10 @@ source_set("chromeos") {
"arc/fileapi/chrome_content_provider_url_util.h",
"arc/fileapi/file_stream_forwarder.cc",
"arc/fileapi/file_stream_forwarder.h",
+ "arc/icon_decode_request.cc",
+ "arc/icon_decode_request.h",
+ "arc/input_method_manager/arc_input_method_manager_bridge.cc",
+ "arc/input_method_manager/arc_input_method_manager_bridge.h",
"arc/intent_helper/arc_external_protocol_dialog.cc",
"arc/intent_helper/arc_external_protocol_dialog.h",
"arc/intent_helper/arc_navigation_throttle.cc",
@@ -496,6 +496,12 @@ source_set("chromeos") {
"certificate_provider/sign_requests.h",
"certificate_provider/thread_safe_certificate_map.cc",
"certificate_provider/thread_safe_certificate_map.h",
+ "child_accounts/screen_time_controller.cc",
+ "child_accounts/screen_time_controller.h",
+ "child_accounts/screen_time_controller_factory.cc",
+ "child_accounts/screen_time_controller_factory.h",
+ "child_accounts/usage_time_limit_processor.cc",
+ "child_accounts/usage_time_limit_processor.h",
"chrome_browser_main_chromeos.cc",
"chrome_browser_main_chromeos.h",
"chrome_content_browser_client_chromeos_part.cc",
@@ -504,10 +510,16 @@ source_set("chromeos") {
"chrome_service_name.h",
"crostini/crostini_manager.cc",
"crostini/crostini_manager.h",
+ "crostini/crostini_pref_names.cc",
+ "crostini/crostini_pref_names.h",
"crostini/crostini_registry_service.cc",
"crostini/crostini_registry_service.h",
"crostini/crostini_registry_service_factory.cc",
"crostini/crostini_registry_service_factory.h",
+ "crostini/crostini_remover.cc",
+ "crostini/crostini_remover.h",
+ "crostini/crostini_util.cc",
+ "crostini/crostini_util.h",
"cryptauth/chrome_cryptauth_service.cc",
"cryptauth/chrome_cryptauth_service.h",
"cryptauth/chrome_cryptauth_service_factory.cc",
@@ -522,16 +534,12 @@ source_set("chromeos") {
"customization/customization_wallpaper_downloader.h",
"customization/customization_wallpaper_util.cc",
"customization/customization_wallpaper_util.h",
- "dbus/chrome_component_updater_service_provider_delegate.cc",
- "dbus/chrome_component_updater_service_provider_delegate.h",
- "dbus/chrome_console_service_provider_delegate.cc",
- "dbus/chrome_console_service_provider_delegate.h",
- "dbus/chrome_display_power_service_provider_delegate.cc",
- "dbus/chrome_display_power_service_provider_delegate.h",
"dbus/chrome_proxy_resolution_service_provider_delegate.cc",
"dbus/chrome_proxy_resolution_service_provider_delegate.h",
"dbus/chrome_virtual_file_request_service_provider_delegate.cc",
"dbus/chrome_virtual_file_request_service_provider_delegate.h",
+ "dbus/component_updater_service_provider.cc",
+ "dbus/component_updater_service_provider.h",
"dbus/finch_features_service_provider_delegate.cc",
"dbus/finch_features_service_provider_delegate.h",
"dbus/kiosk_info_service_provider.cc",
@@ -540,10 +548,6 @@ source_set("chromeos") {
"dbus/screen_lock_service_provider.h",
"dbus/vm_applications_service_provider_delegate.cc",
"dbus/vm_applications_service_provider_delegate.h",
- "display/display_configuration_observer.cc",
- "display/display_configuration_observer.h",
- "display/display_prefs.cc",
- "display/display_prefs.h",
"display/output_protection_controller_ash.cc",
"display/output_protection_controller_ash.h",
"display/output_protection_controller_mus.cc",
@@ -552,8 +556,6 @@ source_set("chromeos") {
"display/output_protection_delegate.h",
"display/quirks_manager_delegate_impl.cc",
"display/quirks_manager_delegate_impl.h",
- "docked_magnifier/docked_magnifier_client.cc",
- "docked_magnifier/docked_magnifier_client.h",
"drive/debug_info_collector.cc",
"drive/debug_info_collector.h",
"drive/download_handler.cc",
@@ -580,12 +582,8 @@ source_set("chromeos") {
"drive/write_on_cache_file.h",
"eol_notification.cc",
"eol_notification.h",
- "events/event_rewriter_controller.cc",
- "events/event_rewriter_controller.h",
"events/event_rewriter_delegate_impl.cc",
"events/event_rewriter_delegate_impl.h",
- "events/keyboard_driven_event_rewriter.cc",
- "events/keyboard_driven_event_rewriter.h",
"extensions/active_tab_permission_granter_delegate_chromeos.cc",
"extensions/active_tab_permission_granter_delegate_chromeos.h",
"extensions/default_app_order.cc",
@@ -596,12 +594,8 @@ source_set("chromeos") {
"extensions/device_local_account_management_policy_provider.h",
"extensions/dictionary_event_router.cc",
"extensions/dictionary_event_router.h",
- "extensions/extension_system_event_observer.cc",
- "extensions/extension_system_event_observer.h",
"extensions/extension_tab_util_delegate_chromeos.cc",
"extensions/extension_tab_util_delegate_chromeos.h",
- "extensions/extension_volume_observer.cc",
- "extensions/extension_volume_observer.h",
"extensions/external_cache.cc",
"extensions/external_cache.h",
"extensions/external_cache_delegate.h",
@@ -977,6 +971,10 @@ source_set("chromeos") {
"login/quick_unlock/auth_token.h",
"login/quick_unlock/fingerprint_storage.cc",
"login/quick_unlock/fingerprint_storage.h",
+ "login/quick_unlock/pin_backend.cc",
+ "login/quick_unlock/pin_backend.h",
+ "login/quick_unlock/pin_storage_cryptohome.cc",
+ "login/quick_unlock/pin_storage_cryptohome.h",
"login/quick_unlock/pin_storage_prefs.cc",
"login/quick_unlock/pin_storage_prefs.h",
"login/quick_unlock/quick_unlock_factory.cc",
@@ -1052,6 +1050,9 @@ source_set("chromeos") {
"login/screens/network_screen.cc",
"login/screens/network_screen.h",
"login/screens/network_view.h",
+ "login/screens/recommend_apps_screen.cc",
+ "login/screens/recommend_apps_screen.h",
+ "login/screens/recommend_apps_screen_view.h",
"login/screens/reset_screen.cc",
"login/screens/reset_screen.h",
"login/screens/reset_view.h",
@@ -1150,12 +1151,12 @@ source_set("chromeos") {
"login/ui/login_display_host.h",
"login/ui/login_display_host_common.cc",
"login/ui/login_display_host_common.h",
- "login/ui/login_display_host_views.cc",
- "login/ui/login_display_host_views.h",
+ "login/ui/login_display_host_mojo.cc",
+ "login/ui/login_display_host_mojo.h",
"login/ui/login_display_host_webui.cc",
"login/ui/login_display_host_webui.h",
- "login/ui/login_display_views.cc",
- "login/ui/login_display_views.h",
+ "login/ui/login_display_mojo.cc",
+ "login/ui/login_display_mojo.h",
"login/ui/login_display_webui.cc",
"login/ui/login_display_webui.h",
"login/ui/login_feedback.cc",
@@ -1177,10 +1178,10 @@ source_set("chromeos") {
"login/ui/web_contents_forced_title.h",
"login/ui/webui_login_view.cc",
"login/ui/webui_login_view.h",
+ "login/user_board_view_mojo.cc",
+ "login/user_board_view_mojo.h",
"login/user_flow.cc",
"login/user_flow.h",
- "login/user_selection_screen_proxy.cc",
- "login/user_selection_screen_proxy.h",
"login/users/affiliation.cc",
"login/users/affiliation.h",
"login/users/avatar/user_image_loader.cc",
@@ -1228,8 +1229,6 @@ source_set("chromeos") {
"net/network_portal_detector_impl.h",
"net/network_portal_detector_test_impl.cc",
"net/network_portal_detector_test_impl.h",
- "net/network_portal_notification_controller.cc",
- "net/network_portal_notification_controller.h",
"net/network_portal_web_dialog.cc",
"net/network_portal_web_dialog.h",
"net/network_pref_state_observer.cc",
@@ -1248,6 +1247,8 @@ source_set("chromeos") {
"note_taking_controller_client.h",
"note_taking_helper.cc",
"note_taking_helper.h",
+ "oauth2_token_service_delegate.cc",
+ "oauth2_token_service_delegate.h",
"options/cert_library.cc",
"options/cert_library.h",
"options/network_config_view.cc",
@@ -1300,8 +1301,9 @@ source_set("chromeos") {
"policy/app_install_event_log_uploader.h",
"policy/app_install_event_logger.cc",
"policy/app_install_event_logger.h",
- "policy/auto_enrollment_client.cc",
"policy/auto_enrollment_client.h",
+ "policy/auto_enrollment_client_impl.cc",
+ "policy/auto_enrollment_client_impl.h",
"policy/bluetooth_policy_handler.cc",
"policy/bluetooth_policy_handler.h",
"policy/browser_policy_connector_chromeos.cc",
@@ -1314,6 +1316,10 @@ source_set("chromeos") {
"policy/cloud_external_data_policy_observer.h",
"policy/cloud_external_data_store.cc",
"policy/cloud_external_data_store.h",
+ "policy/component_active_directory_policy_retriever.cc",
+ "policy/component_active_directory_policy_retriever.h",
+ "policy/component_active_directory_policy_service.cc",
+ "policy/component_active_directory_policy_service.h",
"policy/configuration_policy_handler_chromeos.cc",
"policy/configuration_policy_handler_chromeos.h",
"policy/device_cloud_policy_initializer.cc",
@@ -1354,6 +1360,8 @@ source_set("chromeos") {
"policy/enrollment_handler_chromeos.h",
"policy/enrollment_status_chromeos.cc",
"policy/enrollment_status_chromeos.h",
+ "policy/fake_auto_enrollment_client.cc",
+ "policy/fake_auto_enrollment_client.h",
"policy/heartbeat_scheduler.cc",
"policy/heartbeat_scheduler.h",
"policy/hostname_handler.cc",
@@ -1386,10 +1394,6 @@ source_set("chromeos") {
"policy/policy_oauth2_token_fetcher.h",
"policy/pre_signin_policy_fetcher.cc",
"policy/pre_signin_policy_fetcher.h",
- "policy/recommendation_restorer.cc",
- "policy/recommendation_restorer.h",
- "policy/recommendation_restorer_factory.cc",
- "policy/recommendation_restorer_factory.h",
"policy/remote_commands/affiliated_remote_commands_invalidator.cc",
"policy/remote_commands/affiliated_remote_commands_invalidator.h",
"policy/remote_commands/device_command_fetch_status_job.cc",
@@ -1404,6 +1408,10 @@ source_set("chromeos") {
"policy/remote_commands/device_commands_factory_chromeos.h",
"policy/remote_commands/screenshot_delegate.cc",
"policy/remote_commands/screenshot_delegate.h",
+ "policy/remote_commands/user_command_arc_job.cc",
+ "policy/remote_commands/user_command_arc_job.h",
+ "policy/remote_commands/user_commands_factory_chromeos.cc",
+ "policy/remote_commands/user_commands_factory_chromeos.h",
"policy/secondary_google_account_signin_policy_handler.cc",
"policy/secondary_google_account_signin_policy_handler.h",
"policy/server_backed_device_state.cc",
@@ -1492,6 +1500,8 @@ source_set("chromeos") {
"printing/cups_print_job_notification_manager.h",
"printing/cups_printers_manager.cc",
"printing/cups_printers_manager.h",
+ "printing/cups_printers_manager_factory.cc",
+ "printing/cups_printers_manager_factory.h",
"printing/external_printers.cc",
"printing/external_printers.h",
"printing/external_printers_factory.cc",
@@ -1576,16 +1586,26 @@ source_set("chromeos") {
"smb_client/discovery/mdns_host_locator.h",
"smb_client/discovery/network_scanner.cc",
"smb_client/discovery/network_scanner.h",
+ "smb_client/smb_constants.cc",
+ "smb_client/smb_constants.h",
+ "smb_client/smb_errors.cc",
+ "smb_client/smb_errors.h",
"smb_client/smb_file_system.cc",
"smb_client/smb_file_system.h",
+ "smb_client/smb_file_system_id.cc",
+ "smb_client/smb_file_system_id.h",
"smb_client/smb_provider.cc",
"smb_client/smb_provider.h",
"smb_client/smb_service.cc",
"smb_client/smb_service.h",
"smb_client/smb_service_factory.cc",
"smb_client/smb_service_factory.h",
+ "smb_client/smb_service_helper.cc",
+ "smb_client/smb_service_helper.h",
"smb_client/smb_task_queue.cc",
"smb_client/smb_task_queue.h",
+ "smb_client/smb_url.cc",
+ "smb_client/smb_url.h",
"smb_client/temp_file_manager.cc",
"smb_client/temp_file_manager.h",
"status/network_menu.cc",
@@ -1720,20 +1740,6 @@ source_set("chromeos") {
"extensions/wallpaper_private_api.h",
]
- if (enable_cros_assistant) {
- deps += [
- "//chromeos/services/assistant:lib",
- "//chromeos/services/assistant/public/mojom",
- ]
-
- sources += [
- "assistant/assistant_client.cc",
- "assistant/assistant_client.h",
- "assistant/platform_audio_input_host.cc",
- "assistant/platform_audio_input_host.h",
- ]
- }
-
if (use_cups) {
sources += [
"printing/cups_print_job_manager_impl.cc",
@@ -1754,6 +1760,7 @@ source_set("chromeos") {
copy("dbus_service_files") {
sources = [
+ "dbus/org.chromium.ComponentUpdaterService.conf",
"dbus/org.chromium.ScreenLockService.conf",
]
outputs = [
@@ -1834,14 +1841,16 @@ source_set("unit_tests") {
"../metrics/perf/cpu_identity_unittest.cc",
"../metrics/perf/random_selector_unittest.cc",
"../policy/default_geolocation_policy_handler_unittest.cc",
+ "../resources/chromeos/zip_archiver/test/char_coding_test.cc",
"../ui/browser_finder_chromeos_unittest.cc",
- "accessibility/magnification_manager_unittest.cc",
"accessibility/select_to_speak_event_handler_unittest.cc",
- "accessibility/spoken_feedback_event_rewriter_unittest.cc",
"app_mode/startup_app_launcher_unittest.cc",
"apps/intent_helper/apps_navigation_throttle_unittest.cc",
"arc/accessibility/arc_accessibility_helper_bridge_unittest.cc",
"arc/accessibility/ax_tree_source_arc_unittest.cc",
+ "arc/app_shortcuts/arc_app_shortcuts_menu_builder_unittest.cc",
+ "arc/app_shortcuts/arc_app_shortcuts_request_unittest.cc",
+ "arc/arc_migration_guide_notification_unittest.cc",
"arc/arc_play_store_enabled_preference_handler_unittest.cc",
"arc/arc_session_manager_unittest.cc",
"arc/arc_support_host_unittest.cc",
@@ -1859,6 +1868,7 @@ source_set("unit_tests") {
"arc/fileapi/arc_file_system_operation_runner_unittest.cc",
"arc/fileapi/chrome_content_provider_url_util_unittest.cc",
"arc/fileapi/file_stream_forwarder_unittest.cc",
+ "arc/input_method_manager/arc_input_method_manager_bridge_unittest.cc",
"arc/intent_helper/arc_external_protocol_dialog_unittest.cc",
"arc/intent_helper/arc_navigation_throttle_unittest.cc",
"arc/intent_helper/arc_settings_service_unittest.cc",
@@ -1884,7 +1894,6 @@ source_set("unit_tests") {
"certificate_provider/certificate_provider_service_unittest.cc",
"crostini/crostini_manager_unittest.cc",
"customization/customization_document_unittest.cc",
- "display/display_prefs_unittest.cc",
"drive/download_handler_unittest.cc",
"drive/drive_file_stream_reader_unittest.cc",
"drive/drive_integration_service_unittest.cc",
@@ -1894,7 +1903,6 @@ source_set("unit_tests") {
"drive/fileapi/webkit_file_stream_reader_impl_unittest.cc",
"drive/write_on_cache_file_unittest.cc",
"events/event_rewriter_unittest.cc",
- "events/keyboard_driven_event_rewriter_unittest.cc",
"extensions/active_tab_permission_granter_delegate_chromeos_unittest.cc",
"extensions/default_app_order_unittest.cc",
"extensions/device_local_account_external_policy_loader_unittest.cc",
@@ -2003,12 +2011,12 @@ source_set("unit_tests") {
"net/cert_verify_proc_chromeos_unittest.cc",
"net/client_cert_store_chromeos_unittest.cc",
"net/network_portal_detector_impl_unittest.cc",
- "net/network_portal_notification_controller_unittest.cc",
"net/network_pref_state_observer_unittest.cc",
"net/network_throttling_observer_unittest.cc",
"net/wake_on_wifi_manager_unittest.cc",
"night_light/night_light_client_unittest.cc",
"note_taking_helper_unittest.cc",
+ "oauth2_token_service_delegate_unittest.cc",
"options/network_property_ui_data_unittest.cc",
"ownership/fake_owner_settings_service.cc",
"ownership/fake_owner_settings_service.h",
@@ -2023,12 +2031,14 @@ source_set("unit_tests") {
"policy/app_install_event_log_unittest.cc",
"policy/app_install_event_log_uploader_unittest.cc",
"policy/app_install_event_logger_unittest.cc",
- "policy/auto_enrollment_client_unittest.cc",
+ "policy/auto_enrollment_client_impl_unittest.cc",
"policy/bluetooth_policy_handler_unittest.cc",
"policy/cached_policy_key_loader_chromeos_unittest.cc",
"policy/cloud_external_data_manager_base_unittest.cc",
"policy/cloud_external_data_policy_observer_unittest.cc",
"policy/cloud_external_data_store_unittest.cc",
+ "policy/component_active_directory_policy_retriever_unittest.cc",
+ "policy/component_active_directory_policy_service_unittest.cc",
"policy/configuration_policy_handler_chromeos_unittest.cc",
"policy/device_cloud_policy_initializer_unittest.cc",
"policy/device_cloud_policy_manager_chromeos_unittest.cc",
@@ -2047,7 +2057,6 @@ source_set("unit_tests") {
"policy/off_hours/off_hours_proto_parser_unittest.cc",
"policy/off_hours/weekly_time_unittest.cc",
"policy/pre_signin_policy_fetcher_unittest.cc",
- "policy/recommendation_restorer_unittest.cc",
"policy/remote_commands/device_command_screenshot_job_unittest.cc",
"policy/remote_commands/device_command_set_volume_job_unittest.cc",
"policy/secondary_google_account_signin_policy_handler_unittest.cc",
@@ -2097,8 +2106,12 @@ source_set("unit_tests") {
"smb_client/discovery/in_memory_host_locator_unittest.cc",
"smb_client/discovery/mdns_host_locator_unittest.cc",
"smb_client/discovery/network_scanner_unittest.cc",
+ "smb_client/smb_errors_unittest.cc",
+ "smb_client/smb_file_system_id_test.cc",
+ "smb_client/smb_service_helper_unittest.cc",
"smb_client/smb_service_unittest.cc",
"smb_client/smb_task_queue_unittest.cc",
+ "smb_client/smb_url_unittest.cc",
"smb_client/temp_file_manager_unittest.cc",
"system/automatic_reboot_manager_unittest.cc",
"system/device_disabling_manager_unittest.cc",
@@ -2126,10 +2139,12 @@ source_set("unit_tests") {
"../ui/webui/settings/chromeos/device_keyboard_handler_unittest.cc",
"../ui/webui/settings/chromeos/easy_unlock_settings_handler_unittest.cc",
"../ui/webui/settings/chromeos/internet_handler_unittest.cc",
+ "//components/drive/about_resource_loader_unittest.cc",
"//components/drive/change_list_loader_unittest.cc",
"//components/drive/change_list_processor_unittest.cc",
"//components/drive/chromeos/file_cache_unittest.cc",
"//components/drive/directory_loader_unittest.cc",
+ "//components/drive/drive_file_util_unittest.cc",
"//components/drive/fake_file_system_unittest.cc",
"//components/drive/file_change_unittest.cc",
"//components/drive/file_system/copy_operation_unittest.cc",
@@ -2157,10 +2172,12 @@ source_set("unit_tests") {
"//components/drive/resource_metadata_storage_unittest.cc",
"//components/drive/resource_metadata_unittest.cc",
"//components/drive/search_metadata_unittest.cc",
+ "//components/drive/start_page_token_loader_unittest.cc",
"//components/drive/sync/entry_revert_performer_unittest.cc",
"//components/drive/sync/entry_update_performer_unittest.cc",
"//components/drive/sync/remove_performer_unittest.cc",
"//components/drive/sync_client_unittest.cc",
+ "//components/drive/team_drive_list_loader_unittest.cc",
]
public_deps = [
@@ -2171,9 +2188,11 @@ source_set("unit_tests") {
":attestation_proto",
":test_support",
"//ash",
- "//ash/resources",
+ "//ash/system/message_center/arc:test_support",
"//base",
+ "//chrome/browser/resources/chromeos/zip_archiver:char_coding",
"//chrome/common",
+ "//chromeos:login_manager_proto",
"//chromeos/components/tether:test_support",
"//chromeos/ime:gencode",
"//components/cryptauth:test_support",
@@ -2201,7 +2220,6 @@ source_set("unit_tests") {
"//third_party/blink/public:blink_headers",
"//third_party/icu",
"//third_party/leveldatabase",
- "//ui/arc:test_support",
"//ui/base/ime",
"//ui/chromeos/resources",
]
diff --git a/chromium/chrome/browser/chromeos/prefs/ash_pref_connector_manifest.json b/chromium/chrome/browser/chromeos/prefs/ash_pref_connector_manifest.json
index e1c86f75c12..5eb8177bf1f 100644
--- a/chromium/chrome/browser/chromeos/prefs/ash_pref_connector_manifest.json
+++ b/chromium/chrome/browser/chromeos/prefs/ash_pref_connector_manifest.json
@@ -5,7 +5,7 @@
"service_manager:connector": {
"provides": {
"pref_connector": [
- "ash::mojom::PrefConnector"
+ "ash.mojom.PrefConnector"
]
},
"requires": {
diff --git a/chromium/chrome/browser/custom_handlers/protocol_handler_registry.cc b/chromium/chrome/browser/custom_handlers/protocol_handler_registry.cc
index c691e70b8c3..571e5ae459d 100644
--- a/chromium/chrome/browser/custom_handlers/protocol_handler_registry.cc
+++ b/chromium/chrome/browser/custom_handlers/protocol_handler_registry.cc
@@ -454,6 +454,41 @@ ProtocolHandlerRegistry::GetHandlersFor(
}
ProtocolHandlerRegistry::ProtocolHandlerList
+ProtocolHandlerRegistry::GetUserDefinedHandlers(base::Time begin,
+ base::Time end) const {
+ ProtocolHandlerRegistry::ProtocolHandlerList result;
+ for (const auto& entry : user_protocol_handlers_) {
+ for (const ProtocolHandler& handler : entry.second) {
+ if (base::ContainsValue(predefined_protocol_handlers_, handler))
+ continue;
+ if (begin <= handler.last_modified() && handler.last_modified() < end)
+ result.push_back(handler);
+ }
+ }
+ return result;
+}
+
+ProtocolHandlerRegistry::ProtocolHandlerList
+ProtocolHandlerRegistry::GetUserIgnoredHandlers(base::Time begin,
+ base::Time end) const {
+ ProtocolHandlerRegistry::ProtocolHandlerList result;
+ for (const ProtocolHandler& handler : user_ignored_protocol_handlers_) {
+ if (begin <= handler.last_modified() && handler.last_modified() < end)
+ result.push_back(handler);
+ }
+ return result;
+}
+
+void ProtocolHandlerRegistry::ClearUserDefinedHandlers(base::Time begin,
+ base::Time end) {
+ for (const ProtocolHandler& handler : GetUserDefinedHandlers(begin, end))
+ RemoveHandler(handler);
+
+ for (const ProtocolHandler& handler : GetUserIgnoredHandlers(begin, end))
+ RemoveIgnoredHandler(handler);
+}
+
+ProtocolHandlerRegistry::ProtocolHandlerList
ProtocolHandlerRegistry::GetIgnoredHandlers() {
return ignored_protocol_handlers_;
}
@@ -906,6 +941,7 @@ void ProtocolHandlerRegistry::AddPredefinedHandler(
DCHECK(!is_loaded_); // Must be called prior InitProtocolSettings.
RegisterProtocolHandler(handler, USER);
SetDefault(handler);
+ predefined_protocol_handlers_.push_back(handler);
}
shell_integration::DefaultWebClientWorkerCallback
diff --git a/chromium/chrome/browser/custom_handlers/protocol_handler_registry.h b/chromium/chrome/browser/custom_handlers/protocol_handler_registry.h
index 92608305bab..378f092a820 100644
--- a/chromium/chrome/browser/custom_handlers/protocol_handler_registry.h
+++ b/chromium/chrome/browser/custom_handlers/protocol_handler_registry.h
@@ -159,6 +159,15 @@ class ProtocolHandlerRegistry : public KeyedService {
// Get the list of protocol handlers for the given scheme.
ProtocolHandlerList GetHandlersFor(const std::string& scheme) const;
+ // Get a list of protocol handlers registered in [begin, end).
+ // Does not include predefined or policy installed handlers.
+ ProtocolHandlerList GetUserDefinedHandlers(base::Time begin,
+ base::Time end) const;
+
+ // Clear all protocol handlers registered in [begin, end).
+ // Does not delete predefined or policy installed handlers.
+ void ClearUserDefinedHandlers(base::Time begin, base::Time end);
+
// Get the list of ignored protocol handlers.
ProtocolHandlerList GetIgnoredHandlers();
@@ -283,6 +292,16 @@ class ProtocolHandlerRegistry : public KeyedService {
void RegisterProtocolHandlersFromPref(const char* pref_name,
const HandlerSource source);
+ // Get all handlers with a timestamp in [begin,end) from |handlers|.
+ ProtocolHandlerList GetHandlersBetween(
+ const ProtocolHandlerMultiMap& handlers,
+ base::Time begin,
+ base::Time end) const;
+
+ // Get all ignored handlers with a timestamp in [begin,end).
+ ProtocolHandlerList GetUserIgnoredHandlers(base::Time begin,
+ base::Time end) const;
+
// Get the DictionaryValues stored under the given pref name that are valid
// ProtocolHandler values.
std::vector<const base::DictionaryValue*> GetHandlersFromPref(
@@ -337,6 +356,9 @@ class ProtocolHandlerRegistry : public KeyedService {
ProtocolHandlerList user_ignored_protocol_handlers_;
ProtocolHandlerList policy_ignored_protocol_handlers_;
+ // A list of handlers that were preinstalled.
+ ProtocolHandlerList predefined_protocol_handlers_;
+
// Protocol handlers that are the defaults for a given protocol.
ProtocolHandlerMap default_handlers_;
diff --git a/chromium/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc b/chromium/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc
index affce755595..500e7198f0a 100644
--- a/chromium/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc
+++ b/chromium/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc
@@ -391,6 +391,82 @@ TEST_F(ProtocolHandlerRegistryTest, SaveAndLoad) {
ASSERT_TRUE(registry()->IsIgnored(stuff_protocol_handler));
}
+TEST_F(ProtocolHandlerRegistryTest, Encode) {
+ base::Time now = base::Time::Now();
+ ProtocolHandler handler("test", GURL("http://example.com"), now);
+ auto value = handler.Encode();
+ ProtocolHandler recreated =
+ ProtocolHandler::CreateProtocolHandler(value.get());
+ EXPECT_EQ("test", recreated.protocol());
+ EXPECT_EQ(GURL("http://example.com"), recreated.url());
+ EXPECT_EQ(now, recreated.last_modified());
+}
+
+TEST_F(ProtocolHandlerRegistryTest, GetHandlersBetween) {
+ base::Time now = base::Time::Now();
+ base::Time one_hour_ago = now - base::TimeDelta::FromHours(1);
+ base::Time two_hours_ago = now - base::TimeDelta::FromHours(2);
+ ProtocolHandler handler1("test1", GURL("http://example.com"), two_hours_ago);
+ ProtocolHandler handler2("test2", GURL("http://example.com"), one_hour_ago);
+ ProtocolHandler handler3("test3", GURL("http://example.com"), now);
+ registry()->OnAcceptRegisterProtocolHandler(handler1);
+ registry()->OnAcceptRegisterProtocolHandler(handler2);
+ registry()->OnAcceptRegisterProtocolHandler(handler3);
+
+ EXPECT_EQ(
+ std::vector<ProtocolHandler>({handler1, handler2, handler3}),
+ registry()->GetUserDefinedHandlers(base::Time(), base::Time::Max()));
+ EXPECT_EQ(
+ std::vector<ProtocolHandler>({handler2, handler3}),
+ registry()->GetUserDefinedHandlers(one_hour_ago, base::Time::Max()));
+ EXPECT_EQ(std::vector<ProtocolHandler>({handler1, handler2}),
+ registry()->GetUserDefinedHandlers(base::Time(), now));
+}
+
+TEST_F(ProtocolHandlerRegistryTest, ClearHandlersBetween) {
+ base::Time now = base::Time::Now();
+ base::Time one_hour_ago = now - base::TimeDelta::FromHours(1);
+ base::Time two_hours_ago = now - base::TimeDelta::FromHours(2);
+ GURL url("http://example.com");
+ ProtocolHandler handler1("test1", url, two_hours_ago);
+ ProtocolHandler handler2("test2", url, one_hour_ago);
+ ProtocolHandler handler3("test3", url, now);
+ ProtocolHandler ignored1("ignored1", url, two_hours_ago);
+ ProtocolHandler ignored2("ignored2", url, one_hour_ago);
+ ProtocolHandler ignored3("ignored3", url, now);
+ registry()->OnAcceptRegisterProtocolHandler(handler1);
+ registry()->OnAcceptRegisterProtocolHandler(handler2);
+ registry()->OnAcceptRegisterProtocolHandler(handler3);
+ registry()->OnIgnoreRegisterProtocolHandler(ignored1);
+ registry()->OnIgnoreRegisterProtocolHandler(ignored2);
+ registry()->OnIgnoreRegisterProtocolHandler(ignored3);
+
+ EXPECT_TRUE(registry()->IsHandledProtocol("test1"));
+ EXPECT_TRUE(registry()->IsHandledProtocol("test2"));
+ EXPECT_TRUE(registry()->IsHandledProtocol("test3"));
+ EXPECT_TRUE(registry()->IsIgnored(ignored1));
+ EXPECT_TRUE(registry()->IsIgnored(ignored2));
+ EXPECT_TRUE(registry()->IsIgnored(ignored3));
+
+ // Delete handler2 and ignored2.
+ registry()->ClearUserDefinedHandlers(one_hour_ago, now);
+ EXPECT_TRUE(registry()->IsHandledProtocol("test1"));
+ EXPECT_FALSE(registry()->IsHandledProtocol("test2"));
+ EXPECT_TRUE(registry()->IsHandledProtocol("test3"));
+ EXPECT_TRUE(registry()->IsIgnored(ignored1));
+ EXPECT_FALSE(registry()->IsIgnored(ignored2));
+ EXPECT_TRUE(registry()->IsIgnored(ignored3));
+
+ // Delete all.
+ registry()->ClearUserDefinedHandlers(base::Time(), base::Time::Max());
+ EXPECT_FALSE(registry()->IsHandledProtocol("test1"));
+ EXPECT_FALSE(registry()->IsHandledProtocol("test2"));
+ EXPECT_FALSE(registry()->IsHandledProtocol("test3"));
+ EXPECT_FALSE(registry()->IsIgnored(ignored1));
+ EXPECT_FALSE(registry()->IsIgnored(ignored2));
+ EXPECT_FALSE(registry()->IsIgnored(ignored3));
+}
+
TEST_F(ProtocolHandlerRegistryTest, TestEnabledDisabled) {
registry()->Disable();
ASSERT_FALSE(registry()->enabled());
@@ -838,6 +914,12 @@ TEST_F(ProtocolHandlerRegistryTest, TestInstallDefaultHandler) {
std::vector<std::string> protocols;
registry()->GetRegisteredProtocols(&protocols);
ASSERT_EQ(static_cast<size_t>(1), protocols.size());
+ EXPECT_TRUE(registry()->IsHandledProtocol("test"));
+ auto handlers =
+ registry()->GetUserDefinedHandlers(base::Time(), base::Time::Max());
+ EXPECT_TRUE(handlers.empty());
+ registry()->ClearUserDefinedHandlers(base::Time(), base::Time::Max());
+ EXPECT_TRUE(registry()->IsHandledProtocol("test"));
}
#define URL_p1u1 "http://p1u1.com/%s"
diff --git a/chromium/chrome/browser/devtools/BUILD.gn b/chromium/chrome/browser/devtools/BUILD.gn
index 14382a2db81..b6297e80809 100644
--- a/chromium/chrome/browser/devtools/BUILD.gn
+++ b/chromium/chrome/browser/devtools/BUILD.gn
@@ -36,7 +36,7 @@ if (!is_android) {
_concatenated_protocol_path =
"$root_gen_dir/chrome/browser/devtools/protocol.json"
action("concatenate_protocols") {
- script = _inspector_protocol + "/ConcatenateProtocols.py"
+ script = _inspector_protocol + "/concatenate_protocols.py"
deps = [
"//third_party/blink/renderer/core/inspector:protocol_version",
@@ -54,8 +54,8 @@ if (!is_android) {
args = [ rebase_path(_blink_protocol_path, root_build_dir) ]
if (is_chromeos) {
- inputs += [ "cros_protocol.json" ]
- args += [ rebase_path("cros_protocol.json", root_build_dir) ]
+ inputs += [ "cros_protocol.pdl" ]
+ args += [ rebase_path("cros_protocol.pdl", root_build_dir) ]
}
args += [ rebase_path(output_file, root_build_dir) ]
@@ -108,6 +108,7 @@ static_library("devtools") {
"//chrome:strings",
"//chrome/app/theme:theme_resources",
"//chrome/common",
+ "//components/viz/host",
"//net:http_server",
"//skia",
"//third_party/icu",
diff --git a/chromium/chrome/browser/devtools/chrome_devtools_manager_delegate.cc b/chromium/chrome/browser/devtools/chrome_devtools_manager_delegate.cc
index ac2fee6c4e9..2f156c37783 100644
--- a/chromium/chrome/browser/devtools/chrome_devtools_manager_delegate.cc
+++ b/chromium/chrome/browser/devtools/chrome_devtools_manager_delegate.cc
@@ -141,9 +141,10 @@ ChromeDevToolsManagerDelegate::CreateNewTarget(const GURL& url) {
ui::PAGE_TRANSITION_AUTO_TOPLEVEL);
params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
Navigate(&params);
- if (!params.target_contents)
+ if (!params.navigated_or_inserted_contents)
return nullptr;
- return DevToolsAgentHost::GetOrCreateFor(params.target_contents);
+ return DevToolsAgentHost::GetOrCreateFor(
+ params.navigated_or_inserted_contents);
}
std::string ChromeDevToolsManagerDelegate::GetDiscoveryPageHTML() {
diff --git a/chromium/chrome/browser/devtools/chrome_devtools_session.cc b/chromium/chrome/browser/devtools/chrome_devtools_session.cc
index 7640f4ca5aa..93cf08d982f 100644
--- a/chromium/chrome/browser/devtools/chrome_devtools_session.cc
+++ b/chromium/chrome/browser/devtools/chrome_devtools_session.cc
@@ -25,9 +25,8 @@ ChromeDevToolsSession::ChromeDevToolsSession(
agent_host->GetType() == content::DevToolsAgentHost::kTypePage) {
page_handler_ = std::make_unique<PageHandler>(agent_host->GetWebContents(),
dispatcher_.get());
- target_handler_ = std::make_unique<TargetHandler>(
- agent_host->GetWebContents(), dispatcher_.get());
}
+ target_handler_ = std::make_unique<TargetHandler>(dispatcher_.get());
browser_handler_ = std::make_unique<BrowserHandler>(dispatcher_.get());
#if defined(OS_CHROMEOS)
window_manager_protocl_handler_ =
diff --git a/chromium/chrome/browser/devtools/cros_protocol.json b/chromium/chrome/browser/devtools/cros_protocol.json
deleted file mode 100644
index 69598245aeb..00000000000
--- a/chromium/chrome/browser/devtools/cros_protocol.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "domains": [
- {
- "domain": "WindowManager",
- "commands": [
- {
- "name": "enterOverviewMode",
- "description": "Enter the overview mode."
- },
- {
- "name": "exitOverviewMode",
- "description": "Exit the overview mode."
- }
- ]
- }
- ],
- "version": {
- "major": "1",
- "minor": "0"
- }
-}
diff --git a/chromium/chrome/browser/devtools/cros_protocol.pdl b/chromium/chrome/browser/devtools/cros_protocol.pdl
new file mode 100644
index 00000000000..c92ceffcd14
--- /dev/null
+++ b/chromium/chrome/browser/devtools/cros_protocol.pdl
@@ -0,0 +1,14 @@
+# 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.
+
+version
+ major 1
+ minor 0
+
+domain WindowManager
+ # Enter the overview mode.
+ command enterOverviewMode
+
+ # Exit the overview mode.
+ command exitOverviewMode
diff --git a/chromium/chrome/browser/devtools/device/adb/adb_client_socket.cc b/chromium/chrome/browser/devtools/device/adb/adb_client_socket.cc
index bd9f447b9cd..71b50ff3b9a 100644
--- a/chromium/chrome/browser/devtools/device/adb/adb_client_socket.cc
+++ b/chromium/chrome/browser/devtools/device/adb/adb_client_socket.cc
@@ -176,20 +176,26 @@ AdbClientSocket::AdbClientSocket(int port)
AdbClientSocket::~AdbClientSocket() {
}
-void AdbClientSocket::Connect(const net::CompletionCallback& callback) {
+void AdbClientSocket::RunConnectCallback(int result) {
+ std::move(connect_callback_).Run(result);
+}
+
+void AdbClientSocket::Connect(net::CompletionOnceCallback callback) {
net::IPAddress ip_address;
if (!ip_address.AssignFromIPLiteral(host_)) {
- callback.Run(net::ERR_FAILED);
+ std::move(callback).Run(net::ERR_FAILED);
return;
}
net::AddressList address_list =
net::AddressList::CreateFromIPAddress(ip_address, port_);
- socket_.reset(new net::TCPClientSocket(address_list, NULL, NULL,
- net::NetLogSource()));
- int result = socket_->Connect(callback);
+ socket_.reset(
+ new net::TCPClientSocket(address_list, NULL, NULL, net::NetLogSource()));
+ connect_callback_ = std::move(callback);
+ int result = socket_->Connect(base::BindOnce(
+ &AdbClientSocket::RunConnectCallback, base::Unretained(this)));
if (result != net::ERR_IO_PENDING)
- callback.Run(result);
+ AdbClientSocket::RunConnectCallback(result);
}
void AdbClientSocket::SendCommand(const std::string& command,
diff --git a/chromium/chrome/browser/devtools/device/adb/adb_client_socket.h b/chromium/chrome/browser/devtools/device/adb/adb_client_socket.h
index f7578e71957..5c0cdd2e167 100644
--- a/chromium/chrome/browser/devtools/device/adb/adb_client_socket.h
+++ b/chromium/chrome/browser/devtools/device/adb/adb_client_socket.h
@@ -32,7 +32,7 @@ class AdbClientSocket {
explicit AdbClientSocket(int port);
~AdbClientSocket();
- void Connect(const net::CompletionCallback& callback);
+ void Connect(net::CompletionOnceCallback callback);
void SendCommand(const std::string& command,
bool is_void,
@@ -54,6 +54,10 @@ class AdbClientSocket {
int bytes_left,
int result);
+ void RunConnectCallback(int result);
+
+ net::CompletionOnceCallback connect_callback_;
+
std::string host_;
int port_;
diff --git a/chromium/chrome/browser/devtools/device/adb/adb_client_socket_browsertest.cc b/chromium/chrome/browser/devtools/device/adb/adb_client_socket_browsertest.cc
index 44db9942b7b..1288d9c63dd 100644
--- a/chromium/chrome/browser/devtools/device/adb/adb_client_socket_browsertest.cc
+++ b/chromium/chrome/browser/devtools/device/adb/adb_client_socket_browsertest.cc
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "chrome/browser/devtools/device/adb/adb_device_provider.h"
#include "chrome/browser/devtools/device/adb/mock_adb_server.h"
diff --git a/chromium/chrome/browser/devtools/device/adb/mock_adb_server.cc b/chromium/chrome/browser/devtools/device/adb/mock_adb_server.cc
index b477ddfdedb..a840719dc23 100644
--- a/chromium/chrome/browser/devtools/device/adb/mock_adb_server.cc
+++ b/chromium/chrome/browser/devtools/device/adb/mock_adb_server.cc
@@ -11,6 +11,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
#include "base/sequence_checker.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
@@ -625,13 +626,14 @@ void StartMockAdbServer(FlushMode flush_mode) {
BrowserThread::PostTaskAndReply(
BrowserThread::IO, FROM_HERE,
base::BindOnce(&StartMockAdbServerOnIOThread, flush_mode),
- base::MessageLoop::QuitWhenIdleClosure());
+ base::RunLoop::QuitCurrentWhenIdleClosureDeprecated());
content::RunMessageLoop();
}
void StopMockAdbServer() {
- BrowserThread::PostTaskAndReply(BrowserThread::IO, FROM_HERE,
- base::BindOnce(&StopMockAdbServerOnIOThread),
- base::MessageLoop::QuitWhenIdleClosure());
+ BrowserThread::PostTaskAndReply(
+ BrowserThread::IO, FROM_HERE,
+ base::BindOnce(&StopMockAdbServerOnIOThread),
+ base::RunLoop::QuitCurrentWhenIdleClosureDeprecated());
content::RunMessageLoop();
}
diff --git a/chromium/chrome/browser/devtools/device/devtools_android_bridge.cc b/chromium/chrome/browser/devtools/device/devtools_android_bridge.cc
index 1e1356a60b1..9007e47005e 100644
--- a/chromium/chrome/browser/devtools/device/devtools_android_bridge.cc
+++ b/chromium/chrome/browser/devtools/device/devtools_android_bridge.cc
@@ -19,7 +19,6 @@
#include "base/lazy_instance.h"
#include "base/macros.h"
#include "base/memory/singleton.h"
-#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
diff --git a/chromium/chrome/browser/devtools/device/port_forwarding_browsertest.cc b/chromium/chrome/browser/devtools/device/port_forwarding_browsertest.cc
index 02b5e6c2b99..fece4645310 100644
--- a/chromium/chrome/browser/devtools/device/port_forwarding_browsertest.cc
+++ b/chromium/chrome/browser/devtools/device/port_forwarding_browsertest.cc
@@ -64,7 +64,7 @@ class PortForwardingTest: public InProcessBrowserTest {
if (status.empty() && skip_empty_devices_)
return;
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
+ FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated());
}
void set_skip_empty_devices(bool skip_empty_devices) {
diff --git a/chromium/chrome/browser/devtools/device/port_forwarding_controller.cc b/chromium/chrome/browser/devtools/device/port_forwarding_controller.cc
index 99ce43017d7..601373da41f 100644
--- a/chromium/chrome/browser/devtools/device/port_forwarding_controller.cc
+++ b/chromium/chrome/browser/devtools/device/port_forwarding_controller.cc
@@ -13,7 +13,6 @@
#include "base/json/json_writer.h"
#include "base/macros.h"
#include "base/memory/singleton.h"
-#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
diff --git a/chromium/chrome/browser/devtools/device/usb/android_usb_browsertest.cc b/chromium/chrome/browser/devtools/device/usb/android_usb_browsertest.cc
index 254f5c746d8..16b5c29922c 100644
--- a/chromium/chrome/browser/devtools/device/usb/android_usb_browsertest.cc
+++ b/chromium/chrome/browser/devtools/device/usb/android_usb_browsertest.cc
@@ -12,7 +12,7 @@
#include "base/containers/queue.h"
#include "base/location.h"
#include "base/memory/ref_counted_memory.h"
-#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_loop_current.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/utf_string_conversions.h"
@@ -746,7 +746,7 @@ IN_PROC_BROWSER_TEST_F(AndroidUsbCountTest,
runner_->Run();
EXPECT_EQ(1, listener.invoked_);
EXPECT_EQ(listener.invoked_ - 1, scheduler_invoked_);
- EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting());
+ EXPECT_TRUE(base::MessageLoopCurrent::Get()->IsIdleForTesting());
}
IN_PROC_BROWSER_TEST_F(AndroidUsbCountTest,
@@ -756,7 +756,7 @@ IN_PROC_BROWSER_TEST_F(AndroidUsbCountTest,
runner_->Run();
EXPECT_EQ(3, listener.invoked_);
EXPECT_EQ(listener.invoked_ - 1, scheduler_invoked_);
- EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting());
+ EXPECT_TRUE(base::MessageLoopCurrent::Get()->IsIdleForTesting());
}
IN_PROC_BROWSER_TEST_F(AndroidUsbCountTest,
@@ -768,7 +768,7 @@ IN_PROC_BROWSER_TEST_F(AndroidUsbCountTest,
runner_->Run();
EXPECT_EQ(1, listener.invoked_);
EXPECT_EQ(listener.invoked_ - 1, scheduler_invoked_);
- EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting());
+ EXPECT_TRUE(base::MessageLoopCurrent::Get()->IsIdleForTesting());
}
IN_PROC_BROWSER_TEST_F(AndroidUsbCountTest,
@@ -778,7 +778,7 @@ IN_PROC_BROWSER_TEST_F(AndroidUsbCountTest,
runner_->Run();
EXPECT_EQ(2, listener.invoked_);
EXPECT_EQ(listener.invoked_ - 1, scheduler_invoked_);
- EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting());
+ EXPECT_TRUE(base::MessageLoopCurrent::Get()->IsIdleForTesting());
}
IN_PROC_BROWSER_TEST_F(AndroidUsbTraitsTest, TestDeviceCounting) {
diff --git a/chromium/chrome/browser/devtools/device/usb/android_usb_socket.cc b/chromium/chrome/browser/devtools/device/usb/android_usb_socket.cc
index 27ef37f1ae7..d4ee11b1134 100644
--- a/chromium/chrome/browser/devtools/device/usb/android_usb_socket.cc
+++ b/chromium/chrome/browser/devtools/device/usb/android_usb_socket.cc
@@ -8,7 +8,6 @@
#include "base/callback_helpers.h"
#include "base/logging.h"
-#include "base/message_loop/message_loop.h"
#include "net/base/io_buffer.h"
#include "net/base/ip_address.h"
#include "net/base/net_errors.h"
@@ -51,7 +50,7 @@ void AndroidUsbSocket::HandleIncoming(std::unique_ptr<AdbMessage> message) {
remote_id_ = message->arg0;
is_connected_ = true;
if (!connect_callback_.is_null())
- base::ResetAndReturn(&connect_callback_).Run(net::OK);
+ std::move(connect_callback_).Run(net::OK);
// "this" can be deleted.
} else {
RespondToWriter(write_length_);
@@ -66,7 +65,7 @@ void AndroidUsbSocket::HandleIncoming(std::unique_ptr<AdbMessage> message) {
remote_id_ = message->arg0;
is_connected_ = true;
if (!connect_callback_.is_null())
- base::ResetAndReturn(&connect_callback_).Run(net::OK);
+ std::move(connect_callback_).Run(net::OK);
// "this" can be deleted.
} else {
RespondToReader(false);
@@ -89,14 +88,14 @@ void AndroidUsbSocket::Terminated(bool closed_by_device) {
// Break the socket -> device connection, release the device.
device_ = nullptr;
- base::ResetAndReturn(&delete_callback_).Run();
+ std::move(delete_callback_).Run();
if (!closed_by_device)
return;
// Respond to pending callbacks.
if (!connect_callback_.is_null()) {
- base::ResetAndReturn(&connect_callback_).Run(net::ERR_FAILED);
+ std::move(connect_callback_).Run(net::ERR_FAILED);
// "this" can be deleted.
return;
}
@@ -111,14 +110,14 @@ void AndroidUsbSocket::Terminated(bool closed_by_device) {
int AndroidUsbSocket::Read(net::IOBuffer* buffer,
int length,
- const net::CompletionCallback& callback) {
+ net::CompletionOnceCallback callback) {
DCHECK(!callback.is_null());
if (!is_connected_)
return device_.get() ? net::ERR_SOCKET_NOT_CONNECTED : 0;
DCHECK(read_callback_.is_null());
if (read_buffer_.empty()) {
- read_callback_ = callback;
+ read_callback_ = std::move(callback);
read_io_buffer_ = buffer;
read_length_ = length;
return net::ERR_IO_PENDING;
@@ -137,7 +136,7 @@ int AndroidUsbSocket::Read(net::IOBuffer* buffer,
int AndroidUsbSocket::Write(
net::IOBuffer* buffer,
int length,
- const net::CompletionCallback& callback,
+ net::CompletionOnceCallback callback,
const net::NetworkTrafficAnnotationTag& /*traffic_annotation*/) {
DCHECK(!callback.is_null());
if (!is_connected_)
@@ -147,7 +146,7 @@ int AndroidUsbSocket::Write(
length = kMaxPayload;
DCHECK(write_callback_.is_null());
- write_callback_ = callback;
+ write_callback_ = std::move(callback);
write_length_ = length;
device_->Send(AdbMessage::kCommandWRTE, local_id_, remote_id_,
std::string(buffer->data(), length));
@@ -164,7 +163,7 @@ int AndroidUsbSocket::SetSendBufferSize(int32_t size) {
return net::ERR_NOT_IMPLEMENTED;
}
-int AndroidUsbSocket::Connect(const net::CompletionCallback& callback) {
+int AndroidUsbSocket::Connect(net::CompletionOnceCallback callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!callback.is_null());
if (!device_.get())
@@ -172,7 +171,7 @@ int AndroidUsbSocket::Connect(const net::CompletionCallback& callback) {
DCHECK(!is_connected_);
DCHECK(connect_callback_.is_null());
- connect_callback_ = callback;
+ connect_callback_ = std::move(callback);
device_->Send(AdbMessage::kCommandOPEN, local_id_, 0, command_);
return net::ERR_IO_PENDING;
}
@@ -208,14 +207,6 @@ const net::NetLogWithSource& AndroidUsbSocket::NetLog() const {
return net_log_;
}
-void AndroidUsbSocket::SetSubresourceSpeculation() {
- NOTIMPLEMENTED();
-}
-
-void AndroidUsbSocket::SetOmniboxSpeculation() {
- NOTIMPLEMENTED();
-}
-
bool AndroidUsbSocket::WasEverUsed() const {
NOTIMPLEMENTED();
return true;
@@ -260,10 +251,10 @@ void AndroidUsbSocket::RespondToReader(bool disconnect) {
read_buffer_ = read_buffer_.substr(bytes_to_copy);
else
read_buffer_ = std::string();
- base::ResetAndReturn(&read_callback_).Run(bytes_to_copy);
+ std::move(read_callback_).Run(bytes_to_copy);
}
void AndroidUsbSocket::RespondToWriter(int result) {
if (!write_callback_.is_null())
- base::ResetAndReturn(&write_callback_).Run(result);
+ std::move(write_callback_).Run(result);
}
diff --git a/chromium/chrome/browser/devtools/device/usb/android_usb_socket.h b/chromium/chrome/browser/devtools/device/usb/android_usb_socket.h
index 799c1e856eb..50fcc685b41 100644
--- a/chromium/chrome/browser/devtools/device/usb/android_usb_socket.h
+++ b/chromium/chrome/browser/devtools/device/usb/android_usb_socket.h
@@ -34,23 +34,21 @@ class AndroidUsbSocket : public net::StreamSocket {
// net::StreamSocket implementation.
int Read(net::IOBuffer* buf,
int buf_len,
- const net::CompletionCallback& callback) override;
+ net::CompletionOnceCallback callback) override;
int Write(
net::IOBuffer* buf,
int buf_len,
- const net::CompletionCallback& callback,
+ net::CompletionOnceCallback callback,
const net::NetworkTrafficAnnotationTag& traffic_annotation) override;
int SetReceiveBufferSize(int32_t size) override;
int SetSendBufferSize(int32_t size) override;
- int Connect(const net::CompletionCallback& callback) override;
+ int Connect(net::CompletionOnceCallback callback) override;
void Disconnect() override;
bool IsConnected() const override;
bool IsConnectedAndIdle() const override;
int GetPeerAddress(net::IPEndPoint* address) const override;
int GetLocalAddress(net::IPEndPoint* address) const override;
const net::NetLogWithSource& NetLog() const override;
- void SetSubresourceSpeculation() override;
- void SetOmniboxSpeculation() override;
bool WasEverUsed() const override;
bool WasAlpnNegotiated() const override;
net::NextProto GetNegotiatedProtocol() const override;
@@ -76,9 +74,9 @@ class AndroidUsbSocket : public net::StreamSocket {
scoped_refptr<net::IOBuffer> read_io_buffer_;
int read_length_;
int write_length_;
- net::CompletionCallback connect_callback_;
- net::CompletionCallback read_callback_;
- net::CompletionCallback write_callback_;
+ net::CompletionOnceCallback connect_callback_;
+ net::CompletionOnceCallback read_callback_;
+ net::CompletionOnceCallback write_callback_;
base::Closure delete_callback_;
SEQUENCE_CHECKER(sequence_checker_);
diff --git a/chromium/chrome/browser/devtools/devtools_eye_dropper.cc b/chromium/chrome/browser/devtools/devtools_eye_dropper.cc
index 8b74d119b62..fe1ce9fbe8f 100644
--- a/chromium/chrome/browser/devtools/devtools_eye_dropper.cc
+++ b/chromium/chrome/browser/devtools/devtools_eye_dropper.cc
@@ -31,7 +31,6 @@ DevToolsEyeDropper::DevToolsEyeDropper(content::WebContents* web_contents,
last_cursor_x_(-1),
last_cursor_y_(-1),
host_(nullptr),
- video_consumer_binding_(this),
use_video_capture_api_(
base::FeatureList::IsEnabled(features::kVizDisplayCompositor) ||
base::FeatureList::IsEnabled(
@@ -57,6 +56,11 @@ void DevToolsEyeDropper::AttachToHost(content::RenderWidgetHost* host) {
if (!use_video_capture_api_)
return;
+ // The view can be null if the renderer process has crashed.
+ // (https://crbug.com/847363)
+ if (!host_->GetView())
+ return;
+
// Capturing a full-page screenshot can be costly so we shouldn't do it too
// often. We can capture at a lower frame rate without hurting the user
// experience.
@@ -73,11 +77,7 @@ void DevToolsEyeDropper::AttachToHost(content::RenderWidgetHost* host) {
media::COLOR_SPACE_UNSPECIFIED);
video_capturer_->SetMinCapturePeriod(base::TimeDelta::FromSeconds(1) /
kMaxFrameRate);
-
- // Start video capture.
- viz::mojom::FrameSinkVideoConsumerPtr consumer;
- video_consumer_binding_.Bind(mojo::MakeRequest(&consumer));
- video_capturer_->Start(std::move(consumer));
+ video_capturer_->Start(this);
}
void DevToolsEyeDropper::DetachFromHost() {
@@ -87,7 +87,6 @@ void DevToolsEyeDropper::DetachFromHost() {
content::CursorInfo cursor_info;
cursor_info.type = blink::WebCursorInfo::kTypePointer;
host_->SetCursor(cursor_info);
- video_consumer_binding_.Close();
video_capturer_.reset();
host_ = nullptr;
}
diff --git a/chromium/chrome/browser/devtools/devtools_eye_dropper.h b/chromium/chrome/browser/devtools/devtools_eye_dropper.h
index 7d5eaef7ce7..c120c989ac9 100644
--- a/chromium/chrome/browser/devtools/devtools_eye_dropper.h
+++ b/chromium/chrome/browser/devtools/devtools_eye_dropper.h
@@ -7,11 +7,11 @@
#include "base/callback.h"
#include "base/macros.h"
+#include "components/viz/host/client_frame_sink_video_capturer.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/web_contents_observer.h"
#include "media/renderers/paint_canvas_video_renderer.h"
#include "mojo/public/cpp/bindings/binding.h"
-#include "services/viz/privileged/interfaces/compositing/frame_sink_video_capture.mojom.h"
#include "third_party/skia/include/core/SkBitmap.h"
namespace blink {
@@ -68,8 +68,7 @@ class DevToolsEyeDropper : public content::WebContentsObserver,
int last_cursor_y_;
content::RenderWidgetHost::MouseEventCallback mouse_event_callback_;
content::RenderWidgetHost* host_;
- viz::mojom::FrameSinkVideoCapturerPtr video_capturer_;
- mojo::Binding<viz::mojom::FrameSinkVideoConsumer> video_consumer_binding_;
+ std::unique_ptr<viz::ClientFrameSinkVideoCapturer> video_capturer_;
const bool use_video_capture_api_;
media::PaintCanvasVideoRenderer video_renderer_;
base::WeakPtrFactory<DevToolsEyeDropper> weak_factory_;
diff --git a/chromium/chrome/browser/devtools/devtools_file_system_indexer.cc b/chromium/chrome/browser/devtools/devtools_file_system_indexer.cc
index db6f28720d2..24e0ba728f6 100644
--- a/chromium/chrome/browser/devtools/devtools_file_system_indexer.cc
+++ b/chromium/chrome/browser/devtools/devtools_file_system_indexer.cc
@@ -12,7 +12,6 @@
#include "base/callback.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_util.h"
-#include "base/files/file_util_proxy.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/macros.h"
diff --git a/chromium/chrome/browser/devtools/devtools_file_system_indexer_unittest.cc b/chromium/chrome/browser/devtools/devtools_file_system_indexer_unittest.cc
index f07114422de..c3be1b672be 100644
--- a/chromium/chrome/browser/devtools/devtools_file_system_indexer_unittest.cc
+++ b/chromium/chrome/browser/devtools/devtools_file_system_indexer_unittest.cc
@@ -44,7 +44,7 @@ class DevToolsFileSystemIndexerTest : public testing::Test {
TEST_F(DevToolsFileSystemIndexerTest, BasicUsage) {
base::FilePath base_test_path;
- PathService::Get(chrome::DIR_TEST_DATA, &base_test_path);
+ base::PathService::Get(chrome::DIR_TEST_DATA, &base_test_path);
base::FilePath index_path =
base_test_path.Append(FILE_PATH_LITERAL("devtools"))
.Append(FILE_PATH_LITERAL("indexer"));
diff --git a/chromium/chrome/browser/devtools/devtools_sanity_browsertest.cc b/chromium/chrome/browser/devtools/devtools_sanity_browsertest.cc
index 78457d9fc8f..4d76deddc16 100644
--- a/chromium/chrome/browser/devtools/devtools_sanity_browsertest.cc
+++ b/chromium/chrome/browser/devtools/devtools_sanity_browsertest.cc
@@ -16,7 +16,6 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
-#include "base/message_loop/message_loop.h"
#include "base/optional.h"
#include "base/path_service.h"
#include "base/run_loop.h"
@@ -24,6 +23,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/test/scoped_feature_list.h"
#include "base/test/test_timeouts.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -36,6 +36,7 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/unpacked_installer.h"
#include "chrome/browser/lifetime/application_lifetime.h"
+#include "chrome/browser/policy/developer_tools_policy_handler.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
@@ -51,6 +52,7 @@
#include "components/app_modal/native_app_modal_dialog.h"
#include "components/autofill/content/browser/content_autofill_driver.h"
#include "components/autofill/content/browser/content_autofill_driver_factory.h"
+#include "components/autofill/core/browser/autofill_experiments.h"
#include "components/autofill/core/browser/autofill_manager.h"
#include "components/autofill/core/browser/autofill_manager_test_delegate.h"
#include "components/prefs/pref_service.h"
@@ -72,6 +74,7 @@
#include "content/public/common/url_constants.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
+#include "content/public/test/url_loader_interceptor.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_registry_observer.h"
#include "extensions/browser/extension_system.h"
@@ -82,11 +85,8 @@
#include "extensions/test/test_extension_dir.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/spawned_test_server/spawned_test_server.h"
-#include "net/test/url_request/url_request_mock_http_job.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
-#include "net/url_request/url_request_filter.h"
-#include "net/url_request/url_request_http_job.h"
#include "services/network/public/cpp/features.h"
#include "third_party/blink/public/platform/web_input_event.h"
#include "ui/compositor/compositor_switches.h"
@@ -198,78 +198,6 @@ void SwitchToExtensionPanel(DevToolsWindow* window,
SwitchToPanel(window, (prefix + panel_name).c_str());
}
-class PushTimesMockURLRequestJob : public net::URLRequestMockHTTPJob {
- public:
- PushTimesMockURLRequestJob(net::URLRequest* request,
- net::NetworkDelegate* network_delegate,
- base::FilePath file_path)
- : net::URLRequestMockHTTPJob(request, network_delegate, file_path) {}
-
- void Start() override {
- load_timing_info_.socket_reused = true;
- load_timing_info_.request_start_time = base::Time::Now();
- load_timing_info_.request_start = base::TimeTicks::Now();
- load_timing_info_.send_start = base::TimeTicks::Now();
- load_timing_info_.send_end = base::TimeTicks::Now();
- load_timing_info_.receive_headers_end = base::TimeTicks::Now();
-
- net::URLRequestMockHTTPJob::Start();
- }
-
- void GetLoadTimingInfo(net::LoadTimingInfo* load_timing_info) const override {
- load_timing_info_.push_start = load_timing_info_.request_start -
- base::TimeDelta::FromMilliseconds(100);
- if (load_timing_info_.push_end.is_null() &&
- request()->url().query() != kPushUseNullEndTime) {
- load_timing_info_.push_end = base::TimeTicks::Now();
- }
- *load_timing_info = load_timing_info_;
- }
-
- private:
- mutable net::LoadTimingInfo load_timing_info_;
- DISALLOW_COPY_AND_ASSIGN(PushTimesMockURLRequestJob);
-};
-
-class TestInterceptor : public net::URLRequestInterceptor {
- public:
- // Creates TestInterceptor and registers it with the URLRequestFilter,
- // which takes ownership of it.
- static void Register(const GURL& url, const base::FilePath& file_path) {
- EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
- net::URLRequestFilter::GetInstance()->AddHostnameInterceptor(
- url.scheme(), url.host(),
- base::WrapUnique(new TestInterceptor(url, file_path)));
- }
-
- // Unregisters previously created TestInterceptor, which should delete it.
- static void Unregister(const GURL& url) {
- EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
- net::URLRequestFilter::GetInstance()->RemoveHostnameHandler(url.scheme(),
- url.host());
- }
-
- // net::URLRequestJobFactory::ProtocolHandler implementation:
- net::URLRequestJob* MaybeInterceptRequest(
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate) const override {
- EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
- if (request->url().path() != url_.path())
- return nullptr;
- return new PushTimesMockURLRequestJob(request, network_delegate,
- file_path_);
- }
-
- private:
- TestInterceptor(const GURL& url, const base::FilePath& file_path)
- : url_(url), file_path_(file_path) {}
-
- const GURL url_;
- const base::FilePath file_path_;
-
- DISALLOW_COPY_AND_ASSIGN(TestInterceptor);
-};
-
} // namespace
class DevToolsSanityTest : public InProcessBrowserTest {
@@ -485,7 +413,7 @@ class DevToolsExtensionTest : public DevToolsSanityTest,
public content::NotificationObserver {
public:
DevToolsExtensionTest() : DevToolsSanityTest() {
- PathService::Get(chrome::DIR_TEST_DATA, &test_extensions_dir_);
+ base::PathService::Get(chrome::DIR_TEST_DATA, &test_extensions_dir_);
test_extensions_dir_ = test_extensions_dir_.AppendASCII("devtools");
test_extensions_dir_ = test_extensions_dir_.AppendASCII("extensions");
}
@@ -1604,22 +1532,53 @@ IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestNetworkRawHeadersText) {
RunTest("testNetworkRawHeadersText", kChunkedTestPage);
}
+namespace {
+
+bool InterceptURLLoad(content::URLLoaderInterceptor::RequestParams* params) {
+ const GURL& url = params->url_request.url;
+ if (!base::EndsWith(url.path(), kPushTestResource,
+ base::CompareCase::SENSITIVE)) {
+ return false;
+ }
+
+ network::ResourceResponseHead response;
+
+ response.headers = new net::HttpResponseHeaders("200 OK\r\n\r\n");
+
+ auto start_time =
+ base::TimeTicks::Now() - base::TimeDelta::FromMilliseconds(10);
+ response.request_start = start_time;
+ response.response_start = base::TimeTicks::Now();
+ response.request_time =
+ base::Time::Now() - base::TimeDelta::FromMilliseconds(10);
+ response.response_time = base::Time::Now();
+
+ auto& load_timing = response.load_timing;
+ load_timing.request_start = start_time;
+ load_timing.request_start_time = response.request_time;
+ load_timing.send_start = start_time;
+ load_timing.send_end = base::TimeTicks::Now();
+ load_timing.receive_headers_end = base::TimeTicks::Now();
+ load_timing.push_start = start_time - base::TimeDelta::FromMilliseconds(100);
+ if (url.query() != kPushUseNullEndTime)
+ load_timing.push_end = base::TimeTicks::Now();
+
+ params->client->OnReceiveResponse(response, /*downloaded_file=*/nullptr);
+ params->client->OnComplete(network::URLLoaderCompletionStatus());
+ return true;
+}
+
+} // namespace
+
IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestNetworkPushTime) {
+ content::URLLoaderInterceptor interceptor(
+ base::BindRepeating(InterceptURLLoad));
+
OpenDevToolsWindow(kPushTestPage, false);
GURL push_url = spawned_test_server()->GetURL(kPushTestResource);
- base::FilePath file_path =
- spawned_test_server()->document_root().AppendASCII(kPushTestResource);
-
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::BindOnce(&TestInterceptor::Register, push_url, file_path));
DispatchOnTestSuite(window_, "testPushTimes", push_url.spec().c_str());
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::BindOnce(&TestInterceptor::Unregister, push_url));
-
CloseDevToolsWindow();
}
@@ -1671,7 +1630,34 @@ class AutofillManagerTestDelegateDevtoolsImpl
DISALLOW_COPY_AND_ASSIGN(AutofillManagerTestDelegateDevtoolsImpl);
};
-IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDispatchKeyEventShowsAutoFill) {
+// Test params:
+// - bool popup_views_enabled: whether feature AutofillExpandedPopupViews
+// is enabled for testing.
+//
+// This test is parametrized to ensure that it runs for the
+// AutofillExpandedPopupViews feature either enabled or disabled, while it's
+// rolled out.
+// TODO(crbug.com/831603): This can be merged into DevToolsSanityTest when
+// AutofillExpandedPopupViews becomes the default
+// behavior and is no longer used.
+class AutofillDevToolsSanityTest : public DevToolsSanityTest,
+ public ::testing::WithParamInterface<bool> {
+ public:
+ AutofillDevToolsSanityTest() = default;
+ ~AutofillDevToolsSanityTest() override = default;
+
+ void SetUpOnMainThread() override {
+ const bool popup_views_enabled = GetParam();
+ scoped_feature_list_.InitWithFeatureState(
+ autofill::kAutofillExpandedPopupViews, popup_views_enabled);
+ }
+
+ private:
+ base::test::ScopedFeatureList scoped_feature_list_;
+};
+
+IN_PROC_BROWSER_TEST_P(AutofillDevToolsSanityTest,
+ TestDispatchKeyEventShowsAutoFill) {
OpenDevToolsWindow(kDispatchKeyEventShowsAutoFill, false);
autofill::ContentAutofillDriver* autofill_driver =
@@ -1687,6 +1673,8 @@ IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDispatchKeyEventShowsAutoFill) {
CloseDevToolsWindow();
}
+INSTANTIATE_TEST_CASE_P(All, AutofillDevToolsSanityTest, ::testing::Bool());
+
// Tests that settings are stored in profile correctly.
IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestSettings) {
OpenDevToolsWindow("about:blank", true);
@@ -1897,13 +1885,13 @@ IN_PROC_BROWSER_TEST_F(DevToolsAgentHostTest, TestAgentHostReleased) {
<< "DevToolsAgentHost is not released when the tab is closed";
}
-class RemoteDebuggingTest : public ExtensionApiTest {
+class RemoteDebuggingTest : public extensions::ExtensionApiTest {
void SetUpCommandLine(base::CommandLine* command_line) override {
- ExtensionApiTest::SetUpCommandLine(command_line);
+ extensions::ExtensionApiTest::SetUpCommandLine(command_line);
command_line->AppendSwitchASCII(switches::kRemoteDebuggingPort, "9222");
// Override the extension root path.
- PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_);
+ base::PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_);
test_data_dir_ = test_data_dir_.AppendASCII("devtools");
}
};
@@ -1919,8 +1907,11 @@ IN_PROC_BROWSER_TEST_F(RemoteDebuggingTest, MAYBE_RemoteDebugger) {
}
using DevToolsPolicyTest = InProcessBrowserTest;
-IN_PROC_BROWSER_TEST_F(DevToolsPolicyTest, PolicyTrue) {
- browser()->profile()->GetPrefs()->SetBoolean(prefs::kDevToolsDisabled, true);
+IN_PROC_BROWSER_TEST_F(DevToolsPolicyTest, DevToolsAvailabilityPolicy) {
+ browser()->profile()->GetPrefs()->SetInteger(
+ prefs::kDevToolsAvailability,
+ static_cast<int>(
+ policy::DeveloperToolsPolicyHandler::Availability::kDisallowed));
ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
content::WebContents* web_contents =
browser()->tab_strip_model()->GetWebContentsAt(0);
@@ -2175,6 +2166,25 @@ IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, LoadNetworkResourceForFrontend) {
DevToolsWindowTesting::CloseDevToolsWindowSync(window_);
}
+IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, CreateBrowserContext) {
+ embedded_test_server()->ServeFilesFromSourceDirectory("chrome/test/data");
+ ASSERT_TRUE(embedded_test_server()->Start());
+
+ GURL url(embedded_test_server()->GetURL("/devtools/empty.html"));
+ ui_test_utils::NavigateToURL(browser(), url);
+ window_ =
+ DevToolsWindowTesting::OpenDevToolsWindowSync(GetInspectedTab(), false);
+ RunTestMethod("testCreateBrowserContext", url.spec().c_str());
+ DevToolsWindowTesting::CloseDevToolsWindowSync(window_);
+}
+
+IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, DisposeEmptyBrowserContext) {
+ window_ =
+ DevToolsWindowTesting::OpenDevToolsWindowSync(GetInspectedTab(), false);
+ RunTestMethod("testDisposeEmptyBrowserContext");
+ DevToolsWindowTesting::CloseDevToolsWindowSync(window_);
+}
+
IN_PROC_BROWSER_TEST_F(SitePerProcessDevToolsSanityTest, InspectElement) {
GURL url(embedded_test_server()->GetURL("a.com", "/devtools/oopif.html"));
GURL iframe_url(
diff --git a/chromium/chrome/browser/devtools/devtools_sanity_interactive_browsertest.cc b/chromium/chrome/browser/devtools/devtools_sanity_interactive_browsertest.cc
index 07c18ef3edd..f17114ec883 100644
--- a/chromium/chrome/browser/devtools/devtools_sanity_interactive_browsertest.cc
+++ b/chromium/chrome/browser/devtools/devtools_sanity_interactive_browsertest.cc
@@ -3,7 +3,7 @@
// found in the LICENSE file.
#include "base/macros.h"
-#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_loop_current.h"
#include "base/run_loop.h"
#include "build/build_config.h"
#include "chrome/browser/devtools/chrome_devtools_manager_delegate.h"
@@ -42,7 +42,7 @@ class CheckWaiter {
bool Check() {
if (callback_.Run() != expected_ &&
base::Time::NowFromSystemTime() < timeout_) {
- base::MessageLoop::current()->task_runner()->PostTask(
+ base::MessageLoopCurrent::Get()->task_runner()->PostTask(
FROM_HERE, base::BindOnce(base::IgnoreResult(&CheckWaiter::Check),
base::Unretained(this)));
return false;
@@ -128,7 +128,14 @@ IN_PROC_BROWSER_TEST_F(DevToolsManagerDelegateTest, NormalWindowChangeBounds) {
CheckWindowBounds(gfx::Rect(200, 100, 500, 400));
}
-IN_PROC_BROWSER_TEST_F(DevToolsManagerDelegateTest, NormalToMaximizedWindow) {
+#if defined(OS_MACOSX)
+// MacViews does not yet implement maximized windows: https://crbug.com/836327
+#define MAYBE_NormalToMaximizedWindow DISABLED_NormalToMaximizedWindow
+#else
+#define MAYBE_NormalToMaximizedWindow NormalToMaximizedWindow
+#endif
+IN_PROC_BROWSER_TEST_F(DevToolsManagerDelegateTest,
+ MAYBE_NormalToMaximizedWindow) {
CheckIsMaximized(false);
SendCommand("maximized");
CheckIsMaximized(true);
@@ -159,8 +166,14 @@ IN_PROC_BROWSER_TEST_F(DevToolsManagerDelegateTest,
CheckIsFullscreen(true);
}
+#if defined(OS_MACOSX)
+// MacViews does not yet implement maximized windows: https://crbug.com/836327
+#define MAYBE_MaximizedToMinimizedWindow DISABLED_MaximizedToMinimizedWindow
+#else
+#define MAYBE_MaximizedToMinimizedWindow MaximizedToMinimizedWindow
+#endif
IN_PROC_BROWSER_TEST_F(DevToolsManagerDelegateTest,
- MaximizedToMinimizedWindow) {
+ MAYBE_MaximizedToMinimizedWindow) {
browser()->window()->Maximize();
CheckIsMaximized(true);
@@ -198,7 +211,14 @@ IN_PROC_BROWSER_TEST_F(DevToolsManagerDelegateTest, ShowMinimizedWindow) {
CheckIsMinimized(false);
}
-IN_PROC_BROWSER_TEST_F(DevToolsManagerDelegateTest, RestoreMaximizedWindow) {
+#if defined(OS_MACOSX)
+// MacViews does not yet implement maximized windows: https://crbug.com/836327
+#define MAYBE_RestoreMaximizedWindow DISABLED_RestoreMaximizedWindow
+#else
+#define MAYBE_RestoreMaximizedWindow RestoreMaximizedWindow
+#endif
+IN_PROC_BROWSER_TEST_F(DevToolsManagerDelegateTest,
+ MAYBE_RestoreMaximizedWindow) {
browser()->window()->Maximize();
CheckIsMaximized(true);
SendCommand("normal");
diff --git a/chromium/chrome/browser/devtools/devtools_window.cc b/chromium/chrome/browser/devtools/devtools_window.cc
index ea750931ffb..2b93acddaea 100644
--- a/chromium/chrome/browser/devtools/devtools_window.cc
+++ b/chromium/chrome/browser/devtools/devtools_window.cc
@@ -20,6 +20,7 @@
#include "chrome/browser/devtools/devtools_eye_dropper.h"
#include "chrome/browser/file_select_helper.h"
#include "chrome/browser/infobars/infobar_service.h"
+#include "chrome/browser/policy/developer_tools_policy_handler.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/sessions/session_tab_helper.h"
@@ -418,8 +419,7 @@ DevToolsWindow::~DevToolsWindow() {
UpdateBrowserWindow();
UpdateBrowserToolbar();
- if (toolbox_web_contents_)
- delete toolbox_web_contents_;
+ owned_toolbox_web_contents_.reset();
DevToolsWindows* instances = g_devtools_window_instances.Pointer();
DevToolsWindows::iterator it(
@@ -912,17 +912,18 @@ void DevToolsWindow::OnPageCloseCanceled(WebContents* contents) {
DevToolsWindow::DevToolsWindow(FrontendType frontend_type,
Profile* profile,
- WebContents* main_web_contents,
+ std::unique_ptr<WebContents> main_web_contents,
DevToolsUIBindings* bindings,
WebContents* inspected_web_contents,
bool can_dock)
: frontend_type_(frontend_type),
profile_(profile),
- main_web_contents_(main_web_contents),
+ main_web_contents_(main_web_contents.get()),
toolbox_web_contents_(nullptr),
bindings_(bindings),
browser_(nullptr),
is_docked_(true),
+ owned_main_web_contents_(std::move(main_web_contents)),
can_dock_(can_dock),
close_on_detach_(true),
// This initialization allows external front-end to work without changes.
@@ -984,16 +985,24 @@ DevToolsWindow* DevToolsWindow::Create(
const std::string& settings,
const std::string& panel,
bool has_other_clients) {
- if (profile->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled) ||
- base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode))
+ using DTPH = policy::DeveloperToolsPolicyHandler;
+ // TODO(pfeldman): Implement handling for
+ // Availability::kDisallowedForForceInstalledExtensions
+ // (https://crbug.com/838146).
+ if (DTPH::GetDevToolsAvailability(profile->GetPrefs()) ==
+ DTPH::Availability::kDisallowed ||
+ base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) {
return nullptr;
+ }
#if defined(OS_CHROMEOS)
// Do not create DevTools if it's disabled for primary profile.
const Profile* primary_profile = ProfileManager::GetPrimaryUserProfile();
if (primary_profile &&
- primary_profile->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled))
+ DTPH::GetDevToolsAvailability(primary_profile->GetPrefs()) ==
+ DTPH::Availability::kDisallowed) {
return nullptr;
+ }
#endif
if (inspected_web_contents) {
@@ -1010,8 +1019,8 @@ DevToolsWindow* DevToolsWindow::Create(
// Create WebContents with devtools.
GURL url(GetDevToolsURL(profile, frontend_type, frontend_url, can_dock, panel,
has_other_clients));
- std::unique_ptr<WebContents> main_web_contents(
- WebContents::Create(WebContents::CreateParams(profile)));
+ std::unique_ptr<WebContents> main_web_contents =
+ WebContents::Create(WebContents::CreateParams(profile));
main_web_contents->GetController().LoadURL(
DecorateFrontendURL(url), content::Referrer(),
ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string());
@@ -1021,8 +1030,9 @@ DevToolsWindow* DevToolsWindow::Create(
return nullptr;
if (!settings.empty())
SetPreferencesFromJson(profile, settings);
- return new DevToolsWindow(frontend_type, profile, main_web_contents.release(),
- bindings, inspected_web_contents, can_dock);
+ return new DevToolsWindow(frontend_type, profile,
+ std::move(main_web_contents), bindings,
+ inspected_web_contents, can_dock);
}
// static
@@ -1136,12 +1146,14 @@ void DevToolsWindow::ActivateContents(WebContents* contents) {
}
void DevToolsWindow::AddNewContents(WebContents* source,
- WebContents* new_contents,
+ std::unique_ptr<WebContents> new_contents,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
bool* was_blocked) {
- if (new_contents == toolbox_web_contents_) {
+ if (new_contents.get() == toolbox_web_contents_) {
+ owned_toolbox_web_contents_ = std::move(new_contents);
+
toolbox_web_contents_->SetDelegate(
new DevToolsToolboxDelegate(toolbox_web_contents_,
inspected_contents_observer_.get()));
@@ -1158,8 +1170,8 @@ void DevToolsWindow::AddNewContents(WebContents* source,
WebContents* inspected_web_contents = GetInspectedWebContents();
if (inspected_web_contents) {
inspected_web_contents->GetDelegate()->AddNewContents(
- source, new_contents, disposition, initial_rect, user_gesture,
- was_blocked);
+ source, std::move(new_contents), disposition, initial_rect,
+ user_gesture, was_blocked);
}
}
@@ -1172,8 +1184,10 @@ void DevToolsWindow::WebContentsCreated(WebContents* source_contents,
if (target_url.SchemeIs(content::kChromeDevToolsScheme) &&
target_url.path().rfind("toolbox.html") != std::string::npos) {
CHECK(can_dock_);
- if (toolbox_web_contents_)
- delete toolbox_web_contents_;
+
+ // Ownership will be passed in DevToolsWindow::AddNewContents.
+ if (owned_toolbox_web_contents_)
+ owned_toolbox_web_contents_.reset();
toolbox_web_contents_ = new_contents;
// Tag the DevTools toolbox WebContents with its TaskManager specific
@@ -1199,7 +1213,8 @@ void DevToolsWindow::CloseContents(WebContents* source) {
// In case of docked main_web_contents_, we own it so delete here.
// Embedding DevTools window will be deleted as a result of
// DevToolsUIBindings destruction.
- delete main_web_contents_;
+ CHECK(owned_main_web_contents_);
+ owned_main_web_contents_.reset();
}
void DevToolsWindow::ContentsZoomChange(bool zoom_in) {
@@ -1339,9 +1354,15 @@ void DevToolsWindow::SetIsDocked(bool dock_requested) {
// Detach window from the external devtools browser. It will lead to
// the browser object's close and delete. Remove observer first.
TabStripModel* tab_strip_model = browser_->tab_strip_model();
- tab_strip_model->DetachWebContentsAt(
- tab_strip_model->GetIndexOfWebContents(main_web_contents_));
+ DCHECK(!owned_main_web_contents_);
+
+ // Removing the only WebContents from the tab strip of browser_ will
+ // eventually lead to the destruction of browser_ as well, which is why it's
+ // okay to just null the raw pointer here.
browser_ = NULL;
+
+ owned_main_web_contents_ = tab_strip_model->DetachWebContentsAt(
+ tab_strip_model->GetIndexOfWebContents(main_web_contents_));
} else if (!dock_requested && was_docked) {
UpdateBrowserWindow();
}
@@ -1536,8 +1557,8 @@ void DevToolsWindow::CreateDevToolsBrowser() {
browser_ = new Browser(Browser::CreateParams::CreateForDevTools(profile_));
browser_->tab_strip_model()->AddWebContents(
- main_web_contents_, -1, ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
- TabStripModel::ADD_ACTIVE);
+ std::move(owned_main_web_contents_), -1,
+ ui::PAGE_TRANSITION_AUTO_TOPLEVEL, TabStripModel::ADD_ACTIVE);
main_web_contents_->GetRenderViewHost()->SyncRendererPrefs();
}
diff --git a/chromium/chrome/browser/devtools/devtools_window.h b/chromium/chrome/browser/devtools/devtools_window.h
index 928fea3dfab..6fe1e2d1468 100644
--- a/chromium/chrome/browser/devtools/devtools_window.h
+++ b/chromium/chrome/browser/devtools/devtools_window.h
@@ -91,9 +91,10 @@ class DevToolsWindow : public DevToolsUIBindings::Delegate,
// Perform specified action for current WebContents inside a |browser|.
// This may close currently open DevTools window.
- // If DeveloperToolsDisabled policy is set, no DevTools window created.
- // In case if needed pointer to the created window one should use
- // DevToolsAgentHost and DevToolsWindow::FindDevToolsWindow(). E.g.:
+ // If DeveloperToolsAvailability policy disallows developer tools for the
+ // current WebContents, no DevTools window created. In case if needed pointer
+ // to the created window one should use DevToolsAgentHost and
+ // DevToolsWindow::FindDevToolsWindow(). E.g.:
//
// scoped_refptr<content::DevToolsAgentHost> agent(
// content::DevToolsAgentHost::GetOrCreateFor(inspected_web_contents));
@@ -254,7 +255,7 @@ class DevToolsWindow : public DevToolsUIBindings::Delegate,
DevToolsWindow(FrontendType frontend_type,
Profile* profile,
- content::WebContents* main_web_contents,
+ std::unique_ptr<content::WebContents> main_web_contents,
DevToolsUIBindings* bindings,
content::WebContents* inspected_web_contents,
bool can_dock);
@@ -293,7 +294,7 @@ class DevToolsWindow : public DevToolsUIBindings::Delegate,
// content::WebContentsDelegate:
void ActivateContents(content::WebContents* contents) override;
void AddNewContents(content::WebContents* source,
- content::WebContents* new_contents,
+ std::unique_ptr<content::WebContents> new_contents,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
@@ -348,6 +349,9 @@ class DevToolsWindow : public DevToolsUIBindings::Delegate,
void ShowCertificateViewer(const std::string& cert_viewer) override;
void ColorPickedInEyeDropper(int r, int g, int b, int a);
+
+ // This method create a new Browser object, and passes ownership of
+ // owned_main_web_contents_ to the tab strip of the Browser.
void CreateDevToolsBrowser();
BrowserWindow* GetInspectedBrowserWindow();
void ScheduleShow(const DevToolsToggleAction& action);
@@ -362,10 +366,25 @@ class DevToolsWindow : public DevToolsUIBindings::Delegate,
FrontendType frontend_type_;
Profile* profile_;
content::WebContents* main_web_contents_;
+
+ // DevToolsWindow is informed of the creation of the |toolbox_web_contents_|
+ // in WebContentsCreated right before ownership is passed to to DevToolsWindow
+ // in AddNewContents(). The former call has information not available in the
+ // latter, so it's easiest to record a raw pointer first in
+ // |toolbox_web_contents_|, and then update ownership immediately afterwards.
+ // TODO(erikchen): If we updated AddNewContents() to also pass back the
+ // target url, then we wouldn't need to listen to WebContentsCreated at all.
content::WebContents* toolbox_web_contents_;
+ std::unique_ptr<content::WebContents> owned_toolbox_web_contents_;
+
DevToolsUIBindings* bindings_;
Browser* browser_;
+
+ // When DevToolsWindow is docked, it owns main_web_contents_. When it isn't
+ // docked, the tab strip model owns the main_web_contents_.
bool is_docked_;
+ std::unique_ptr<content::WebContents> owned_main_web_contents_;
+
const bool can_dock_;
bool close_on_detach_;
LifeStage life_stage_;
diff --git a/chromium/chrome/browser/devtools/global_confirm_info_bar.cc b/chromium/chrome/browser/devtools/global_confirm_info_bar.cc
index ef435c0adc5..d283a99766a 100644
--- a/chromium/chrome/browser/devtools/global_confirm_info_bar.cc
+++ b/chromium/chrome/browser/devtools/global_confirm_info_bar.cc
@@ -28,6 +28,7 @@ class GlobalConfirmInfoBar::DelegateProxy : public ConfirmInfoBarDelegate {
// ConfirmInfoBarDelegate overrides
infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override;
base::string16 GetMessageText() const override;
+ gfx::ElideBehavior GetMessageElideBehavior() const override;
int GetButtons() const override;
base::string16 GetButtonLabel(InfoBarButton button) const override;
bool Accept() override;
@@ -63,6 +64,13 @@ base::string16 GlobalConfirmInfoBar::DelegateProxy::GetMessageText() const {
: base::string16();
}
+gfx::ElideBehavior
+GlobalConfirmInfoBar::DelegateProxy::GetMessageElideBehavior() const {
+ return global_info_bar_
+ ? global_info_bar_->delegate_->GetMessageElideBehavior()
+ : ConfirmInfoBarDelegate::GetMessageElideBehavior();
+}
+
int GlobalConfirmInfoBar::DelegateProxy::GetButtons() const {
return global_info_bar_ ? global_info_bar_->delegate_->GetButtons()
: 0;
diff --git a/chromium/chrome/browser/devtools/inspector_protocol_config.json b/chromium/chrome/browser/devtools/inspector_protocol_config.json
index 0a1c3ab0b93..38dfa64c028 100644
--- a/chromium/chrome/browser/devtools/inspector_protocol_config.json
+++ b/chromium/chrome/browser/devtools/inspector_protocol_config.json
@@ -18,7 +18,8 @@
},
{
"domain": "Target",
- "include": [ "setRemoteLocations" ],
+ "include": [ "setRemoteLocations", "createBrowserContext", "getBrowserContexts", "createTarget", "disposeBrowserContext" ],
+ "async": ["disposeBrowserContext"],
"include_events": []
},
{
diff --git a/chromium/chrome/browser/devtools/protocol/target_handler.cc b/chromium/chrome/browser/devtools/protocol/target_handler.cc
index 573b6acc0ab..f5c62726504 100644
--- a/chromium/chrome/browser/devtools/protocol/target_handler.cc
+++ b/chromium/chrome/browser/devtools/protocol/target_handler.cc
@@ -5,10 +5,152 @@
#include "chrome/browser/devtools/protocol/target_handler.h"
#include "chrome/browser/devtools/chrome_devtools_manager_delegate.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/browser_navigator.h"
+#include "content/public/browser/devtools_agent_host.h"
-TargetHandler::TargetHandler(content::WebContents* web_contents,
- protocol::UberDispatcher* dispatcher) {
- DCHECK(web_contents);
+namespace {
+
+class DevToolsBrowserContextManager : public BrowserListObserver {
+ public:
+ DevToolsBrowserContextManager();
+ protocol::Response CreateBrowserContext(std::string* out_context_id);
+ protocol::Response GetBrowserContexts(
+ std::unique_ptr<protocol::Array<protocol::String>>* browser_context_ids);
+ Profile* GetBrowserContext(const std::string& context_id);
+ void DisposeBrowserContext(
+ const std::string& context_id,
+ std::unique_ptr<TargetHandler::DisposeBrowserContextCallback> callback);
+
+ private:
+ void OnOriginalProfileDestroyed(Profile* profile);
+
+ void OnBrowserRemoved(Browser* browser) override;
+
+ base::flat_map<
+ std::string,
+ std::unique_ptr<IndependentOTRProfileManager::OTRProfileRegistration>>
+ registrations_;
+ base::flat_map<std::string,
+ std::unique_ptr<TargetHandler::DisposeBrowserContextCallback>>
+ pending_context_disposals_;
+
+ base::WeakPtrFactory<DevToolsBrowserContextManager> weak_factory_;
+ DISALLOW_COPY_AND_ASSIGN(DevToolsBrowserContextManager);
+};
+
+DevToolsBrowserContextManager::DevToolsBrowserContextManager()
+ : weak_factory_(this) {}
+
+Profile* DevToolsBrowserContextManager::GetBrowserContext(
+ const std::string& context_id) {
+ auto it = registrations_.find(context_id);
+ return it == registrations_.end() ? nullptr : it->second->profile();
+}
+
+protocol::Response DevToolsBrowserContextManager::CreateBrowserContext(
+ std::string* out_context_id) {
+ Profile* original_profile =
+ ProfileManager::GetActiveUserProfile()->GetOriginalProfile();
+
+ auto registration =
+ IndependentOTRProfileManager::GetInstance()->CreateFromOriginalProfile(
+ original_profile,
+ base::BindOnce(
+ &DevToolsBrowserContextManager::OnOriginalProfileDestroyed,
+ weak_factory_.GetWeakPtr()));
+ *out_context_id = registration->profile()->UniqueId();
+ registrations_[*out_context_id] = std::move(registration);
+ return protocol::Response::OK();
+}
+
+protocol::Response DevToolsBrowserContextManager::GetBrowserContexts(
+ std::unique_ptr<protocol::Array<protocol::String>>* browser_context_ids) {
+ *browser_context_ids = std::make_unique<protocol::Array<protocol::String>>();
+ for (const auto& registration_pair : registrations_) {
+ (*browser_context_ids)
+ ->addItem(registration_pair.second->profile()->UniqueId());
+ }
+ return protocol::Response::OK();
+}
+
+void DevToolsBrowserContextManager::DisposeBrowserContext(
+ const std::string& context_id,
+ std::unique_ptr<TargetHandler::DisposeBrowserContextCallback> callback) {
+ if (pending_context_disposals_.find(context_id) !=
+ pending_context_disposals_.end()) {
+ callback->sendFailure(protocol::Response::Error(
+ "Disposal of browser context " + context_id + " is already pending"));
+ return;
+ }
+ auto it = registrations_.find(context_id);
+ if (it == registrations_.end()) {
+ callback->sendFailure(protocol::Response::InvalidParams(
+ "Failed to find browser context with id " + context_id));
+ return;
+ }
+
+ Profile* profile = it->second->profile();
+ bool has_opened_browser = false;
+ for (auto* opened_browser : *BrowserList::GetInstance()) {
+ if (opened_browser->profile() == profile) {
+ has_opened_browser = true;
+ break;
+ }
+ }
+
+ // If no browsers are opened - dispose right away.
+ if (!has_opened_browser) {
+ registrations_.erase(it);
+ callback->sendSuccess();
+ return;
+ }
+
+ if (pending_context_disposals_.empty())
+ BrowserList::AddObserver(this);
+
+ pending_context_disposals_[context_id] = std::move(callback);
+ BrowserList::CloseAllBrowsersWithIncognitoProfile(
+ profile, base::DoNothing(), base::DoNothing(),
+ true /* skip_beforeunload */);
+}
+
+void DevToolsBrowserContextManager::OnOriginalProfileDestroyed(
+ Profile* profile) {
+ base::EraseIf(registrations_, [&profile](const auto& it) {
+ return it.second->profile()->GetOriginalProfile() == profile;
+ });
+}
+
+void DevToolsBrowserContextManager::OnBrowserRemoved(Browser* browser) {
+ std::string context_id = browser->profile()->UniqueId();
+ auto pending_disposal = pending_context_disposals_.find(context_id);
+ if (pending_disposal == pending_context_disposals_.end())
+ return;
+ for (auto* opened_browser : *BrowserList::GetInstance()) {
+ if (opened_browser->profile() == browser->profile())
+ return;
+ }
+ auto it = registrations_.find(context_id);
+ // We cannot delete immediately here: the profile might still be referenced
+ // during the browser tier-down process.
+ base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE,
+ it->second.release());
+ registrations_.erase(it);
+ pending_disposal->second->sendSuccess();
+ pending_context_disposals_.erase(pending_disposal);
+ if (pending_context_disposals_.empty())
+ BrowserList::RemoveObserver(this);
+}
+
+base::LazyInstance<DevToolsBrowserContextManager>::Leaky
+ g_devtools_browser_context_manager;
+
+} // namespace
+
+TargetHandler::TargetHandler(protocol::UberDispatcher* dispatcher) {
protocol::Target::Dispatcher::wire(dispatcher, this);
}
@@ -38,3 +180,69 @@ protocol::Response TargetHandler::SetRemoteLocations(
delegate->UpdateDeviceDiscovery();
return protocol::Response::OK();
}
+
+protocol::Response TargetHandler::CreateTarget(
+ const std::string& url,
+ protocol::Maybe<int> width,
+ protocol::Maybe<int> height,
+ protocol::Maybe<std::string> browser_context_id,
+ protocol::Maybe<bool> enable_begin_frame_control,
+ std::string* out_target_id) {
+ Profile* profile = ProfileManager::GetActiveUserProfile();
+ if (browser_context_id.isJust()) {
+ std::string profile_id = browser_context_id.fromJust();
+ profile =
+ g_devtools_browser_context_manager.Get().GetBrowserContext(profile_id);
+ if (!profile) {
+ return protocol::Response::Error(
+ "Failed to find browser context with id " + profile_id);
+ }
+ }
+
+ NavigateParams params(profile, GURL(url), ui::PAGE_TRANSITION_AUTO_TOPLEVEL);
+ Browser* target_browser = nullptr;
+ // Find a browser to open a new tab.
+ // We shouldn't use browser that is scheduled to close.
+ for (auto* browser : *BrowserList::GetInstance()) {
+ if (browser->profile() == profile &&
+ !browser->IsAttemptingToCloseBrowser()) {
+ target_browser = browser;
+ break;
+ }
+ }
+ if (target_browser) {
+ params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
+ params.browser = target_browser;
+ } else {
+ params.disposition = WindowOpenDisposition::NEW_WINDOW;
+ }
+
+ Navigate(&params);
+ if (!params.navigated_or_inserted_contents)
+ return protocol::Response::Error("Failed to open a new tab");
+
+ *out_target_id = content::DevToolsAgentHost::GetOrCreateFor(
+ params.navigated_or_inserted_contents)
+ ->GetId();
+ return protocol::Response::OK();
+}
+
+protocol::Response TargetHandler::CreateBrowserContext(
+ std::string* out_context_id) {
+ return g_devtools_browser_context_manager.Get().CreateBrowserContext(
+ out_context_id);
+}
+
+protocol::Response TargetHandler::GetBrowserContexts(
+ std::unique_ptr<protocol::Array<protocol::String>>* browser_context_ids) {
+ return g_devtools_browser_context_manager.Get().GetBrowserContexts(
+ browser_context_ids);
+}
+
+void TargetHandler::DisposeBrowserContext(
+ const std::string& context_id,
+ std::unique_ptr<DisposeBrowserContextCallback> callback) {
+ g_devtools_browser_context_manager.Get().DisposeBrowserContext(
+ context_id, std::move(callback));
+}
+
diff --git a/chromium/chrome/browser/devtools/protocol/target_handler.h b/chromium/chrome/browser/devtools/protocol/target_handler.h
index 6529337f22f..e9933b095b6 100644
--- a/chromium/chrome/browser/devtools/protocol/target_handler.h
+++ b/chromium/chrome/browser/devtools/protocol/target_handler.h
@@ -7,20 +7,19 @@
#include <set>
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/devtools/protocol/forward.h"
#include "chrome/browser/devtools/protocol/target.h"
+#include "chrome/browser/media/router/presentation/independent_otr_profile_manager.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_list_observer.h"
#include "net/base/host_port_pair.h"
-namespace content {
-class WebContents;
-}
-
using RemoteLocations = std::set<net::HostPortPair>;
class TargetHandler : public protocol::Target::Backend {
public:
- TargetHandler(content::WebContents* web_contents,
- protocol::UberDispatcher* dispatcher);
+ explicit TargetHandler(protocol::UberDispatcher* dispatcher);
~TargetHandler() override;
RemoteLocations& remote_locations() { return remote_locations_; }
@@ -29,6 +28,20 @@ class TargetHandler : public protocol::Target::Backend {
protocol::Response SetRemoteLocations(
std::unique_ptr<protocol::Array<protocol::Target::RemoteLocation>>
in_locations) override;
+ protocol::Response CreateBrowserContext(std::string* out_context_id) override;
+ protocol::Response CreateTarget(
+ const std::string& url,
+ protocol::Maybe<int> width,
+ protocol::Maybe<int> height,
+ protocol::Maybe<std::string> browser_context_id,
+ protocol::Maybe<bool> enable_begin_frame_control,
+ std::string* out_target_id) override;
+ protocol::Response GetBrowserContexts(
+ std::unique_ptr<protocol::Array<protocol::String>>* browser_context_ids)
+ override;
+ void DisposeBrowserContext(
+ const std::string& context_id,
+ std::unique_ptr<DisposeBrowserContextCallback> callback) override;
private:
RemoteLocations remote_locations_;
diff --git a/chromium/chrome/browser/devtools/remote_debugging_server.cc b/chromium/chrome/browser/devtools/remote_debugging_server.cc
index 7a6bf06184d..0f48441e968 100644
--- a/chromium/chrome/browser/devtools/remote_debugging_server.cc
+++ b/chromium/chrome/browser/devtools/remote_debugging_server.cc
@@ -103,13 +103,13 @@ RemoteDebuggingServer::RemoteDebuggingServer() {
// The client requested an ephemeral port. Must write the selected
// port to a well-known location in the profile directory to
// bootstrap the connection process.
- bool result = PathService::Get(chrome::DIR_USER_DATA, &output_dir);
+ bool result = base::PathService::Get(chrome::DIR_USER_DATA, &output_dir);
DCHECK(result);
}
base::FilePath debug_frontend_dir;
#if BUILDFLAG(DEBUG_DEVTOOLS)
- PathService::Get(chrome::DIR_INSPECTOR_DEBUG, &debug_frontend_dir);
+ base::PathService::Get(chrome::DIR_INSPECTOR_DEBUG, &debug_frontend_dir);
#endif
content::DevToolsAgentHost::StartRemoteDebuggingServer(
diff --git a/chromium/chrome/browser/engagement/BUILD.gn b/chromium/chrome/browser/engagement/BUILD.gn
index 9bd92b61df9..19652962467 100644
--- a/chromium/chrome/browser/engagement/BUILD.gn
+++ b/chromium/chrome/browser/engagement/BUILD.gn
@@ -12,7 +12,4 @@ mojom("mojo_bindings") {
public_deps = [
"//url/mojom:url_mojom_gurl",
]
-
- # TODO(crbug.com/714018): Convert the implementation to use OnceCallback.
- use_once_callback = false
}
diff --git a/chromium/chrome/browser/extensions/BUILD.gn b/chromium/chrome/browser/extensions/BUILD.gn
index 9733e2eebb9..fae6b2027bb 100644
--- a/chromium/chrome/browser/extensions/BUILD.gn
+++ b/chromium/chrome/browser/extensions/BUILD.gn
@@ -7,7 +7,6 @@ import("//build/config/ui.gni")
import("//chrome/common/features.gni")
import("//components/nacl/features.gni")
import("//extensions/buildflags/buildflags.gni")
-import("//media/media_options.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//rlz/buildflags/buildflags.gni")
@@ -247,8 +246,12 @@ static_library("extensions") {
"api/language_settings_private/language_settings_private_delegate_factory.h",
"api/management/chrome_management_api_delegate.cc",
"api/management/chrome_management_api_delegate.h",
+ "api/media_galleries/blob_data_source_factory.cc",
+ "api/media_galleries/blob_data_source_factory.h",
"api/media_galleries/media_galleries_api.cc",
"api/media_galleries/media_galleries_api.h",
+ "api/media_galleries/media_galleries_api_util.cc",
+ "api/media_galleries/media_galleries_api_util.h",
"api/messaging/chrome_messaging_delegate.cc",
"api/messaging/chrome_messaging_delegate.h",
"api/messaging/incognito_connectability.cc",
@@ -323,6 +326,10 @@ static_library("extensions") {
"api/resources_private/resources_private_api.h",
"api/runtime/chrome_runtime_api_delegate.cc",
"api/runtime/chrome_runtime_api_delegate.h",
+ "api/safe_browsing_private/safe_browsing_private_event_router.cc",
+ "api/safe_browsing_private/safe_browsing_private_event_router.h",
+ "api/safe_browsing_private/safe_browsing_private_event_router_factory.cc",
+ "api/safe_browsing_private/safe_browsing_private_event_router_factory.h",
"api/sessions/session_id.cc",
"api/sessions/session_id.h",
"api/sessions/sessions_api.cc",
@@ -427,6 +434,7 @@ static_library("extensions") {
"api/webrtc_audio_private/webrtc_audio_private_api.h",
"api/webrtc_desktop_capture_private/webrtc_desktop_capture_private_api.cc",
"api/webrtc_desktop_capture_private/webrtc_desktop_capture_private_api.h",
+ "api/webrtc_logging_private/webrtc_logging_private_api.cc",
"api/webrtc_logging_private/webrtc_logging_private_api.h",
"api/webstore_private/webstore_private_api.cc",
"api/webstore_private/webstore_private_api.h",
@@ -618,6 +626,8 @@ static_library("extensions") {
"external_component_loader.h",
"external_install_error.cc",
"external_install_error.h",
+ "external_install_error_constants.cc",
+ "external_install_error_constants.h",
"external_install_manager.cc",
"external_install_manager.h",
"external_loader.cc",
@@ -725,8 +735,12 @@ static_library("extensions") {
"updater/chrome_extension_downloader_factory.h",
"updater/chrome_update_client_config.cc",
"updater/chrome_update_client_config.h",
+ "updater/extension_update_client_command_line_config_policy.cc",
+ "updater/extension_update_client_command_line_config_policy.h",
"updater/extension_updater.cc",
"updater/extension_updater.h",
+ "updater/extension_updater_switches.cc",
+ "updater/extension_updater_switches.h",
"user_script_listener.cc",
"user_script_listener.h",
"warning_badge_service.cc",
@@ -826,6 +840,7 @@ static_library("extensions") {
"//components/omnibox/browser",
"//components/onc",
"//components/password_manager/core/browser",
+ "//components/payments/core",
"//components/pdf/browser",
"//components/policy:generated",
"//components/policy/core/browser",
@@ -916,9 +931,6 @@ static_library("extensions") {
"api/easy_unlock_private/easy_unlock_private_connection.h",
"api/easy_unlock_private/easy_unlock_private_connection_manager.cc",
"api/easy_unlock_private/easy_unlock_private_connection_manager.h",
- "api/easy_unlock_private/easy_unlock_private_crypto_delegate.h",
- "api/easy_unlock_private/easy_unlock_private_crypto_delegate_chromeos.cc",
- "api/easy_unlock_private/easy_unlock_private_crypto_delegate_stub.cc",
"api/enterprise_device_attributes/enterprise_device_attributes_api.cc",
"api/enterprise_device_attributes/enterprise_device_attributes_api.h",
"api/enterprise_platform_keys/enterprise_platform_keys_api.cc",
@@ -1017,12 +1029,14 @@ static_library("extensions") {
"api/messaging/native_message_process_host.h",
"api/messaging/native_process_launcher.cc",
"api/messaging/native_process_launcher.h",
- "api/messaging/native_process_launcher_posix.cc",
"api/messaging/native_process_launcher_win.cc",
"chrome_kiosk_delegate.cc",
"default_apps.cc",
"default_apps.h",
]
+ if (is_posix) {
+ sources += [ "api/messaging/native_process_launcher_posix.cc" ]
+ }
}
if (use_x11) {
@@ -1130,13 +1144,6 @@ static_library("extensions") {
deps += [ "//rlz:rlz_lib" ]
}
- if (enable_webrtc) {
- sources += [ "api/webrtc_logging_private/webrtc_logging_private_api.cc" ]
- } else {
- sources +=
- [ "api/webrtc_logging_private/webrtc_logging_private_api_stub.cc" ]
- }
-
if (toolkit_views) {
deps += [ "//ui/views" ]
}
diff --git a/chromium/chrome/browser/extensions/api/activity_log_private/activity_log_private_api.cc b/chromium/chrome/browser/extensions/api/activity_log_private/activity_log_private_api.cc
index ab0b80cca93..a2f3244e5a3 100644
--- a/chromium/chrome/browser/extensions/api/activity_log_private/activity_log_private_api.cc
+++ b/chromium/chrome/browser/extensions/api/activity_log_private/activity_log_private_api.cc
@@ -81,7 +81,7 @@ bool ActivityLogAPI::IsExtensionWhitelisted(const std::string& extension_id) {
// TODO(devlin): Pass in a HashedExtensionId to avoid this conversion.
return FeatureProvider::GetPermissionFeatures()
->GetFeature("activityLogPrivate")
- ->IsIdInWhitelist(HashedExtensionId(extension_id));
+ ->IsIdInAllowlist(HashedExtensionId(extension_id));
}
void ActivityLogAPI::OnListenerAdded(const EventListenerInfo& details) {
diff --git a/chromium/chrome/browser/extensions/api/automation/automation_apitest.cc b/chromium/chrome/browser/extensions/api/automation/automation_apitest.cc
index 965b7118cd1..3d50db2f6db 100644
--- a/chromium/chrome/browser/extensions/api/automation/automation_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/automation/automation_apitest.cc
@@ -61,7 +61,7 @@ class AutomationApiTest : public ExtensionApiTest {
void StartEmbeddedTestServer() {
base::FilePath test_data;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data));
+ ASSERT_TRUE(base::PathService::Get(chrome::DIR_TEST_DATA, &test_data));
embedded_test_server()->ServeFilesFromDirectory(
test_data.AppendASCII("extensions/api_test")
.AppendASCII(kSitesDir));
@@ -262,7 +262,8 @@ IN_PROC_BROWSER_TEST_F(AutomationApiTest, DesktopNotSupported) {
}
#endif // defined(USE_AURA)
-IN_PROC_BROWSER_TEST_F(AutomationApiTest, CloseTab) {
+// Flaky test on site_per_browser_tests: https://crbug.com/833318
+IN_PROC_BROWSER_TEST_F(AutomationApiTest, DISABLED_CloseTab) {
StartEmbeddedTestServer();
ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", "close_tab.html"))
<< message_;
diff --git a/chromium/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc b/chromium/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc
index 2a1b390978b..ef8e0dfa2d1 100644
--- a/chromium/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc
+++ b/chromium/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc
@@ -151,7 +151,7 @@ bool CanRequestAutomation(const Extension* extension,
int tab_id = ExtensionTabUtil::GetTabId(contents);
std::string unused_error;
- return extension->permissions_data()->CanAccessPage(extension, url, tab_id,
+ return extension->permissions_data()->CanAccessPage(url, tab_id,
&unused_error);
}
@@ -345,6 +345,9 @@ AutomationInternalPerformActionFunction::ConvertToAXActionData(
case api::automation::ACTION_TYPE_BLUR:
action->action = ax::mojom::Action::kBlur;
break;
+ case api::automation::ACTION_TYPE_CLEARACCESSIBILITYFOCUS:
+ action->action = ax::mojom::Action::kClearAccessibilityFocus;
+ break;
case api::automation::ACTION_TYPE_DECREMENT:
action->action = ax::mojom::Action::kDecrement;
break;
@@ -383,6 +386,9 @@ AutomationInternalPerformActionFunction::ConvertToAXActionData(
case api::automation::ACTION_TYPE_LOADINLINETEXTBOXES:
action->action = ax::mojom::Action::kLoadInlineTextBoxes;
break;
+ case api::automation::ACTION_TYPE_SETACCESSIBILITYFOCUS:
+ action->action = ax::mojom::Action::kSetAccessibilityFocus;
+ break;
case api::automation::ACTION_TYPE_SCROLLTOMAKEVISIBLE:
action->action = ax::mojom::Action::kScrollToMakeVisible;
break;
diff --git a/chromium/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc b/chromium/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
index a7d7901447f..27bf5a2193f 100644
--- a/chromium/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
+++ b/chromium/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
@@ -32,6 +32,7 @@
#include "base/feature_list.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/login/lock/screen_locker.h"
+#include "chrome/browser/chromeos/printing/cups_printers_manager.h"
#include "chrome/browser/chromeos/system/input_device_settings.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ash/login_screen_client.h"
@@ -42,6 +43,7 @@
#include "components/user_manager/user_manager.h"
#include "content/public/common/service_manager_connection.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
+#include "net/base/filename_util.h"
#include "services/service_manager/public/cpp/connector.h"
#include "ui/base/ui_base_features.h"
#include "ui/message_center/message_center.h"
@@ -494,6 +496,63 @@ ExtensionFunction::ResponseAction AutotestPrivateGetPrinterListFunction::Run() {
return RespondNow(OneArgument(std::move(values)));
}
+AutotestPrivateUpdatePrinterFunction::AutotestPrivateUpdatePrinterFunction() =
+ default;
+AutotestPrivateUpdatePrinterFunction::~AutotestPrivateUpdatePrinterFunction() =
+ default;
+
+ExtensionFunction::ResponseAction AutotestPrivateUpdatePrinterFunction::Run() {
+ std::unique_ptr<api::autotest_private::UpdatePrinter::Params> params(
+ api::autotest_private::UpdatePrinter::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params);
+ DVLOG(1) << "AutotestPrivateUpdatePrinterFunction";
+#if defined(OS_CHROMEOS)
+ const api::autotest_private::Printer& js_printer = params->printer;
+ chromeos::Printer printer(js_printer.printer_id ? *js_printer.printer_id
+ : "");
+ printer.set_display_name(js_printer.printer_name);
+ if (js_printer.printer_desc)
+ printer.set_description(*js_printer.printer_desc);
+
+ if (js_printer.printer_make_and_model)
+ printer.set_make_and_model(*js_printer.printer_make_and_model);
+
+ if (js_printer.printer_uri)
+ printer.set_uri(*js_printer.printer_uri);
+
+ if (js_printer.printer_ppd) {
+ const GURL ppd =
+ net::FilePathToFileURL(base::FilePath(*js_printer.printer_ppd));
+ if (ppd.is_valid())
+ printer.mutable_ppd_reference()->user_supplied_ppd_url = ppd.spec();
+ else
+ LOG(ERROR) << "Invalid ppd path: " << *js_printer.printer_ppd;
+ }
+ auto printers_manager = chromeos::CupsPrintersManager::Create(
+ ProfileManager::GetActiveUserProfile());
+ printers_manager->UpdateConfiguredPrinter(printer);
+#endif
+ return RespondNow(NoArguments());
+}
+
+AutotestPrivateRemovePrinterFunction::AutotestPrivateRemovePrinterFunction() =
+ default;
+AutotestPrivateRemovePrinterFunction::~AutotestPrivateRemovePrinterFunction() =
+ default;
+
+ExtensionFunction::ResponseAction AutotestPrivateRemovePrinterFunction::Run() {
+ std::unique_ptr<api::autotest_private::RemovePrinter::Params> params(
+ api::autotest_private::RemovePrinter::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params);
+ DVLOG(1) << "AutotestPrivateRemovePrinterFunction";
+#if defined(OS_CHROMEOS)
+ auto printers_manager = chromeos::CupsPrintersManager::Create(
+ ProfileManager::GetActiveUserProfile());
+ printers_manager->RemoveConfiguredPrinter(params->printer_id);
+#endif
+ return RespondNow(NoArguments());
+}
+
ExtensionFunction::ResponseAction
AutotestPrivateGetPlayStoreStateFunction::Run() {
DVLOG(1) << "AutotestPrivateGetPlayStoreStateFunction";
diff --git a/chromium/chrome/browser/extensions/api/autotest_private/autotest_private_api.h b/chromium/chrome/browser/extensions/api/autotest_private/autotest_private_api.h
index 63388ec5b8d..4575604fc44 100644
--- a/chromium/chrome/browser/extensions/api/autotest_private/autotest_private_api.h
+++ b/chromium/chrome/browser/extensions/api/autotest_private/autotest_private_api.h
@@ -242,6 +242,32 @@ class AutotestPrivateGetPrinterListFunction : public UIThreadExtensionFunction {
DISALLOW_COPY_AND_ASSIGN(AutotestPrivateGetPrinterListFunction);
};
+class AutotestPrivateUpdatePrinterFunction : public UIThreadExtensionFunction {
+ public:
+ AutotestPrivateUpdatePrinterFunction();
+ DECLARE_EXTENSION_FUNCTION("autotestPrivate.updatePrinter",
+ AUTOTESTPRIVATE_UPDATEPRINTER)
+
+ private:
+ ~AutotestPrivateUpdatePrinterFunction() override;
+ ResponseAction Run() override;
+
+ DISALLOW_COPY_AND_ASSIGN(AutotestPrivateUpdatePrinterFunction);
+};
+
+class AutotestPrivateRemovePrinterFunction : public UIThreadExtensionFunction {
+ public:
+ AutotestPrivateRemovePrinterFunction();
+ DECLARE_EXTENSION_FUNCTION("autotestPrivate.removePrinter",
+ AUTOTESTPRIVATE_REMOVEPRINTER)
+
+ private:
+ ~AutotestPrivateRemovePrinterFunction() override;
+ ResponseAction Run() override;
+
+ DISALLOW_COPY_AND_ASSIGN(AutotestPrivateRemovePrinterFunction);
+};
+
// Don't kill the browser when we're in a browser test.
void SetAutotestPrivateTest();
diff --git a/chromium/chrome/browser/extensions/api/autotest_private/autotest_private_apitest.cc b/chromium/chrome/browser/extensions/api/autotest_private/autotest_private_apitest.cc
index 3442d293c2c..e1bd15e7fba 100644
--- a/chromium/chrome/browser/extensions/api/autotest_private/autotest_private_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/autotest_private/autotest_private_apitest.cc
@@ -6,12 +6,16 @@
#include "chrome/browser/extensions/api/autotest_private/autotest_private_api.h"
#include "chrome/browser/extensions/extension_apitest.h"
+namespace extensions {
+
#if defined(OS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, AutotestPrivate) {
// Turn on testing mode so we don't kill the browser.
- extensions::AutotestPrivateAPI::GetFactoryInstance()
+ AutotestPrivateAPI::GetFactoryInstance()
->Get(browser()->profile())
->set_test_mode(true);
ASSERT_TRUE(RunComponentExtensionTest("autotest_private")) << message_;
}
#endif
+
+} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_apitest.cc b/chromium/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_apitest.cc
index 1b40c8253fb..7d50faf9277 100644
--- a/chromium/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_apitest.cc
@@ -98,14 +98,14 @@ const char kTestDescriptorId1[] = "desc_id1";
const char kTestDescriptorUuid1[] = "1222";
const uint8_t kTestDescriptorDefaultValue1[] = {0x04, 0x05};
-class BluetoothLowEnergyApiTest : public ExtensionApiTest {
+class BluetoothLowEnergyApiTest : public extensions::ExtensionApiTest {
public:
BluetoothLowEnergyApiTest() {}
~BluetoothLowEnergyApiTest() override {}
void SetUpOnMainThread() override {
- ExtensionApiTest::SetUpOnMainThread();
+ extensions::ExtensionApiTest::SetUpOnMainThread();
empty_extension_ = extensions::ExtensionBuilder("Test").Build();
SetUpMocks();
}
diff --git a/chromium/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_apitest_chromeos.cc b/chromium/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_apitest_chromeos.cc
index 9dc43888e84..7dca7b82ff6 100644
--- a/chromium/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_apitest_chromeos.cc
+++ b/chromium/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_apitest_chromeos.cc
@@ -11,7 +11,7 @@
#include "chrome/browser/chromeos/ownership/fake_owner_settings_service.h"
#include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h"
#include "chrome/browser/extensions/extension_apitest.h"
-#include "components/signin/core/account_id/account_id.h"
+#include "components/account_id/account_id.h"
#include "components/user_manager/scoped_user_manager.h"
#include "content/public/test/browser_test.h"
#include "extensions/common/switches.h"
diff --git a/chromium/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc b/chromium/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc
index bdc5848ab26..bbda385c078 100644
--- a/chromium/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc
+++ b/chromium/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc
@@ -552,7 +552,8 @@ bool BookmarkManagerPrivateStartDragFunction::RunOnReady() {
if (!EditBookmarksEnabled())
return false;
- if (GetViewType(GetSenderWebContents()) != VIEW_TYPE_TAB_CONTENTS) {
+ content::WebContents* web_contents = GetSenderWebContents();
+ if (GetViewType(web_contents) != VIEW_TYPE_TAB_CONTENTS) {
NOTREACHED();
return false;
}
@@ -566,9 +567,6 @@ bool BookmarkManagerPrivateStartDragFunction::RunOnReady() {
if (!GetNodesFromVector(model, params->id_list, &nodes))
return false;
- content::WebContents* web_contents = GetAssociatedWebContents();
- CHECK(web_contents);
-
ui::DragDropTypes::DragEventSource source =
ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE;
if (params->is_from_touch)
@@ -594,7 +592,8 @@ bool BookmarkManagerPrivateDropFunction::RunOnReady() {
if (!CanBeModified(drop_parent))
return false;
- if (GetViewType(GetSenderWebContents()) != VIEW_TYPE_TAB_CONTENTS) {
+ content::WebContents* web_contents = GetSenderWebContents();
+ if (GetViewType(web_contents) != VIEW_TYPE_TAB_CONTENTS) {
NOTREACHED();
return false;
}
@@ -605,8 +604,6 @@ bool BookmarkManagerPrivateDropFunction::RunOnReady() {
else
drop_index = drop_parent->child_count();
- WebContents* web_contents = GetAssociatedWebContents();
- CHECK(web_contents);
BookmarkManagerPrivateDragEventRouter* router =
BookmarkManagerPrivateDragEventRouter::FromWebContents(web_contents);
diff --git a/chromium/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_apitest.cc b/chromium/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_apitest.cc
index 35c4ad6bc47..ad4ac598a5b 100644
--- a/chromium/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_apitest.cc
@@ -26,6 +26,8 @@
using bookmarks::BookmarkModel;
using bookmarks::BookmarkNode;
+namespace extensions {
+
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BookmarkManager) {
// Add managed bookmarks.
Profile* profile = browser()->profile();
@@ -71,3 +73,5 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BookmarkManagerEditDisabled) {
ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/edit_disabled"))
<< message_;
}
+
+} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/bookmarks/bookmark_apitest.cc b/chromium/chrome/browser/extensions/api/bookmarks/bookmark_apitest.cc
index c4cdaf3aa3b..51335d49624 100644
--- a/chromium/chrome/browser/extensions/api/bookmarks/bookmark_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/bookmarks/bookmark_apitest.cc
@@ -21,6 +21,8 @@
using bookmarks::BookmarkModel;
+namespace extensions {
+
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Bookmarks) {
// Add test managed bookmarks to verify that the bookmarks API can read them
// and can't modify them.
@@ -44,3 +46,5 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Bookmarks) {
ASSERT_TRUE(RunExtensionTest("bookmarks")) << message_;
}
+
+} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/bookmarks/bookmarks_api.cc b/chromium/chrome/browser/extensions/api/bookmarks/bookmarks_api.cc
index d45e3c8e17f..f092d098467 100644
--- a/chromium/chrome/browser/extensions/api/bookmarks/bookmarks_api.cc
+++ b/chromium/chrome/browser/extensions/api/bookmarks/bookmarks_api.cc
@@ -90,7 +90,7 @@ base::FilePath GetDefaultFilepathForBookmarkExport() {
base::i18n::ReplaceIllegalCharactersInPath(&filename, '_');
base::FilePath default_path;
- PathService::Get(chrome::DIR_USER_DOCUMENTS, &default_path);
+ base::PathService::Get(chrome::DIR_USER_DOCUMENTS, &default_path);
return default_path.Append(filename);
}
@@ -733,7 +733,7 @@ void BookmarksIOFunction::ShowSelectFileDialog(
// either FileSelectionCanceled, MultiFilesSelected, or FileSelected
AddRef();
- WebContents* web_contents = GetAssociatedWebContents();
+ WebContents* web_contents = GetSenderWebContents();
select_file_dialog_ = ui::SelectFileDialog::Create(
this, std::make_unique<ChromeSelectFilePolicy>(web_contents));
diff --git a/chromium/chrome/browser/extensions/api/browsing_data/browsing_data_test.cc b/chromium/chrome/browser/extensions/api/browsing_data/browsing_data_test.cc
index f0e724e64a3..aeea3eef7bb 100644
--- a/chromium/chrome/browser/extensions/api/browsing_data/browsing_data_test.cc
+++ b/chromium/chrome/browser/extensions/api/browsing_data/browsing_data_test.cc
@@ -348,6 +348,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, RemoveBrowsingDataAll) {
content::BrowsingDataRemover::DATA_TYPE_COOKIES |
content::BrowsingDataRemover::DATA_TYPE_CHANNEL_IDS |
(content::BrowsingDataRemover::DATA_TYPE_DOM_STORAGE &
+ ~content::BrowsingDataRemover::DATA_TYPE_BACKGROUND_FETCH &
~content::BrowsingDataRemover::DATA_TYPE_EMBEDDER_DOM_STORAGE) |
content::BrowsingDataRemover::DATA_TYPE_CACHE |
content::BrowsingDataRemover::DATA_TYPE_DOWNLOADS |
@@ -548,6 +549,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, SettingsFunctionSiteData) {
(content::BrowsingDataRemover::DATA_TYPE_COOKIES |
content::BrowsingDataRemover::DATA_TYPE_CHANNEL_IDS |
content::BrowsingDataRemover::DATA_TYPE_DOM_STORAGE) &
+ ~content::BrowsingDataRemover::DATA_TYPE_BACKGROUND_FETCH &
~content::BrowsingDataRemover::DATA_TYPE_EMBEDDER_DOM_STORAGE;
int supported_site_data =
supported_site_data_except_plugins |
@@ -579,6 +581,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, SettingsFunctionAssorted) {
(content::BrowsingDataRemover::DATA_TYPE_COOKIES |
content::BrowsingDataRemover::DATA_TYPE_CHANNEL_IDS |
content::BrowsingDataRemover::DATA_TYPE_DOM_STORAGE) &
+ ~content::BrowsingDataRemover::DATA_TYPE_BACKGROUND_FETCH &
~content::BrowsingDataRemover::DATA_TYPE_EMBEDDER_DOM_STORAGE;
SetPrefsAndVerifySettings(
diff --git a/chromium/chrome/browser/extensions/api/cast_streaming/OWNERS b/chromium/chrome/browser/extensions/api/cast_streaming/OWNERS
index 41c70ee8aee..6234a6a3dc5 100644
--- a/chromium/chrome/browser/extensions/api/cast_streaming/OWNERS
+++ b/chromium/chrome/browser/extensions/api/cast_streaming/OWNERS
@@ -1,4 +1,4 @@
-hubbe@chromium.org
miu@chromium.org
+xjz@chromium.org
# COMPONENT: Internals>Cast>Streaming
diff --git a/chromium/chrome/browser/extensions/api/cast_streaming/cast_streaming_apitest.cc b/chromium/chrome/browser/extensions/api/cast_streaming/cast_streaming_apitest.cc
index 9c15fa49d72..2b5a2595bc0 100644
--- a/chromium/chrome/browser/extensions/api/cast_streaming/cast_streaming_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/cast_streaming/cast_streaming_apitest.cc
@@ -17,8 +17,10 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread_restrictions.h"
+#include "build/build_config.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_switches.h"
+#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "extensions/common/switches.h"
#include "media/base/bind_to_current_loop.h"
@@ -34,6 +36,7 @@
#include "net/base/rand_callback.h"
#include "net/log/net_log_source.h"
#include "net/socket/udp_server_socket.h"
+#include "testing/gtest/include/gtest/gtest-param-test.h"
#include "testing/gtest/include/gtest/gtest.h"
using media::cast::test::GetFreeLocalPort;
@@ -320,7 +323,23 @@ class TestPatternReceiver : public media::cast::InProcessReceiver {
} // namespace
-class CastStreamingApiTestWithPixelOutput : public CastStreamingApiTest {
+class CastStreamingApiTestWithPixelOutput
+ : public CastStreamingApiTest,
+ public testing::WithParamInterface<bool> {
+ public:
+ CastStreamingApiTestWithPixelOutput() {
+ std::vector<base::Feature> audio_service_oop_features = {
+ features::kAudioServiceAudioStreams,
+ features::kAudioServiceOutOfProcess};
+ if (GetParam()) {
+ // Force audio service out of process to enabled.
+ audio_service_features_.InitWithFeatures(audio_service_oop_features, {});
+ } else {
+ // Force audio service out of process to disabled.
+ audio_service_features_.InitWithFeatures({}, audio_service_oop_features);
+ }
+ }
+
void SetUp() override {
EnablePixelOutput();
CastStreamingApiTest::SetUp();
@@ -330,6 +349,9 @@ class CastStreamingApiTestWithPixelOutput : public CastStreamingApiTest {
command_line->AppendSwitchASCII(::switches::kWindowSize, "128,128");
CastStreamingApiTest::SetUpCommandLine(command_line);
}
+
+ private:
+ base::test::ScopedFeatureList audio_service_features_;
};
// Tests the Cast streaming API and its basic functionality end-to-end. An
@@ -337,12 +359,13 @@ class CastStreamingApiTestWithPixelOutput : public CastStreamingApiTest {
// use the API to send it out. At the same time, this test launches an
// in-process Cast receiver, listening on a localhost UDP socket, to receive the
// content and check whether it matches expectations.
-#if defined(NDEBUG)
+#if defined(NDEBUG) && !defined(OS_MACOSX)
#define MAYBE_EndToEnd EndToEnd
#else
+// Flaky on Mac: https://crbug.com/841387
#define MAYBE_EndToEnd DISABLED_EndToEnd // crbug.com/396413
#endif
-IN_PROC_BROWSER_TEST_F(CastStreamingApiTestWithPixelOutput, MAYBE_EndToEnd) {
+IN_PROC_BROWSER_TEST_P(CastStreamingApiTestWithPixelOutput, MAYBE_EndToEnd) {
std::unique_ptr<net::UDPServerSocket> receive_socket(
new net::UDPServerSocket(NULL, net::NetLogSource()));
receive_socket->AllowAddressReuse();
@@ -390,8 +413,33 @@ IN_PROC_BROWSER_TEST_F(CastStreamingApiTestWithPixelOutput, MAYBE_EndToEnd) {
cast_environment->Shutdown();
}
-IN_PROC_BROWSER_TEST_F(CastStreamingApiTestWithPixelOutput, RtpStreamError) {
+#if !defined(OS_MACOSX)
+#define MAYBE_RtpStreamError RtpStreamError
+#else
+// Flaky on Mac https://crbug.com/841986
+#define MAYBE_RtpStreamError DISABLED_RtpStreamError
+#endif
+IN_PROC_BROWSER_TEST_P(CastStreamingApiTestWithPixelOutput,
+ MAYBE_RtpStreamError) {
ASSERT_TRUE(RunExtensionSubtest("cast_streaming", "rtp_stream_error.html"));
}
+// We run these tests with the audio service both in and out of the the browser
+// process to have waterfall coverage while the feature rolls out. It should be
+// removed after launch. Note: CastStreamingApiTestWithPixelOutput.EndToEnd is
+// the only integration test exercising audio service loopback streams, so it's
+// a very important test to have.
+#if (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || defined(OS_MACOSX) || \
+ defined(OS_WIN)
+// Supported platforms.
+INSTANTIATE_TEST_CASE_P(,
+ CastStreamingApiTestWithPixelOutput,
+ ::testing::Bool());
+#else
+// Platforms where the out of process audio service isn't supported
+INSTANTIATE_TEST_CASE_P(,
+ CastStreamingApiTestWithPixelOutput,
+ ::testing::Values(false));
+#endif
+
} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/cast_streaming/performance_test.cc b/chromium/chrome/browser/extensions/api/cast_streaming/performance_test.cc
index 91d65b3d1f6..4f627788518 100644
--- a/chromium/chrome/browser/extensions/api/cast_streaming/performance_test.cc
+++ b/chromium/chrome/browser/extensions/api/cast_streaming/performance_test.cc
@@ -345,9 +345,8 @@ class TestPatternReceiver : public media::cast::InProcessReceiver {
DISALLOW_COPY_AND_ASSIGN(TestPatternReceiver);
};
-class CastV2PerformanceTest
- : public ExtensionApiTest,
- public testing::WithParamInterface<int> {
+class CastV2PerformanceTest : public extensions::ExtensionApiTest,
+ public testing::WithParamInterface<int> {
public:
CastV2PerformanceTest() {}
@@ -401,7 +400,7 @@ class CastV2PerformanceTest
EnablePixelOutput();
if (!HasFlag(kUseGpu))
UseSoftwareCompositing();
- ExtensionApiTest::SetUp();
+ extensions::ExtensionApiTest::SetUp();
}
void SetUpCommandLine(base::CommandLine* command_line) override {
@@ -424,7 +423,7 @@ class CastV2PerformanceTest
extensions::switches::kWhitelistedExtensionID,
kExtensionId);
- ExtensionApiTest::SetUpCommandLine(command_line);
+ extensions::ExtensionApiTest::SetUpCommandLine(command_line);
}
void GetTraceEvents(trace_analyzer::TraceAnalyzer* analyzer,
diff --git a/chromium/chrome/browser/extensions/api/certificate_provider/certificate_provider_apitest.cc b/chromium/chrome/browser/extensions/api/certificate_provider/certificate_provider_apitest.cc
index 01671bd64be..62ab1eae2b9 100644
--- a/chromium/chrome/browser/extensions/api/certificate_provider/certificate_provider_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/certificate_provider/certificate_provider_apitest.cc
@@ -143,7 +143,7 @@ void EnterWrongPin(chromeos::CertificateProviderService* service) {
EXPECT_EQ(SK_ColorRED, view->error_label_for_testing()->enabled_color());
}
-class CertificateProviderApiTest : public ExtensionApiTest {
+class CertificateProviderApiTest : public extensions::ExtensionApiTest {
public:
CertificateProviderApiTest() {}
@@ -152,11 +152,11 @@ class CertificateProviderApiTest : public ExtensionApiTest {
.WillRepeatedly(Return(true));
policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
- ExtensionApiTest::SetUpInProcessBrowserTestFixture();
+ extensions::ExtensionApiTest::SetUpInProcessBrowserTestFixture();
}
void SetUpOnMainThread() override {
- ExtensionApiTest::SetUpOnMainThread();
+ extensions::ExtensionApiTest::SetUpOnMainThread();
// Set up the AutoSelectCertificateForUrls policy to avoid the client
// certificate selection dialog.
const std::string autoselect_pattern =
diff --git a/chromium/chrome/browser/extensions/api/chrome_extensions_api_client.cc b/chromium/chrome/browser/extensions/api/chrome_extensions_api_client.cc
index bd9b3d8ba8e..c1a95cdfe0d 100644
--- a/chromium/chrome/browser/extensions/api/chrome_extensions_api_client.cc
+++ b/chromium/chrome/browser/extensions/api/chrome_extensions_api_client.cc
@@ -32,13 +32,16 @@
#include "chrome/browser/guest_view/mime_handler_view/chrome_mime_handler_view_guest_delegate.h"
#include "chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h"
#include "chrome/browser/guest_view/web_view/chrome_web_view_permission_helper_delegate.h"
+#include "chrome/browser/search/instant_io_context.h"
#include "chrome/browser/ui/pdf/chrome_pdf_web_contents_helper_client.h"
#include "chrome/browser/ui/webui/devtools_ui.h"
+#include "chrome/common/webui_url_constants.h"
#include "components/pdf/browser/pdf_web_contents_helper.h"
#include "components/signin/core/browser/signin_header_helper.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/api/virtual_keyboard_private/virtual_keyboard_delegate.h"
+#include "extensions/browser/api/web_request/web_request_info.h"
#include "extensions/browser/guest_view/web_view/web_view_guest.h"
#include "extensions/browser/guest_view/web_view/web_view_permission_helper.h"
#include "google_apis/gaia/gaia_urls.h"
@@ -105,8 +108,28 @@ bool ChromeExtensionsAPIClient::ShouldHideResponseHeader(
}
bool ChromeExtensionsAPIClient::ShouldHideBrowserNetworkRequest(
- const GURL& url) const {
- return DevToolsUI::IsFrontendResourceURL(url);
+ const WebRequestInfo& request) const {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+
+ // Exclude main frame navigation requests.
+ bool is_browser_request = request.render_process_id == -1 &&
+ request.type != content::RESOURCE_TYPE_MAIN_FRAME;
+
+ // Hide requests made by the Devtools frontend.
+ bool is_sensitive_request =
+ is_browser_request && DevToolsUI::IsFrontendResourceURL(request.url);
+
+ // Hide requests made by the browser on behalf of the NTP.
+ is_sensitive_request |=
+ (is_browser_request &&
+ request.initiator ==
+ url::Origin::Create(GURL(chrome::kChromeUINewTabURL)));
+
+ // Hide requests made by the NTP Instant renderer.
+ is_sensitive_request |= InstantIOContext::IsInstantProcess(
+ request.resource_context, request.render_process_id);
+
+ return is_sensitive_request;
}
AppViewGuestDelegate* ChromeExtensionsAPIClient::CreateAppViewGuestDelegate()
diff --git a/chromium/chrome/browser/extensions/api/chrome_extensions_api_client.h b/chromium/chrome/browser/extensions/api/chrome_extensions_api_client.h
index dbe7a3e7b35..a99acde774b 100644
--- a/chromium/chrome/browser/extensions/api/chrome_extensions_api_client.h
+++ b/chromium/chrome/browser/extensions/api/chrome_extensions_api_client.h
@@ -32,7 +32,8 @@ class ChromeExtensionsAPIClient : public ExtensionsAPIClient {
override;
bool ShouldHideResponseHeader(const GURL& url,
const std::string& header_name) const override;
- bool ShouldHideBrowserNetworkRequest(const GURL& url) const override;
+ bool ShouldHideBrowserNetworkRequest(
+ const WebRequestInfo& request) const override;
AppViewGuestDelegate* CreateAppViewGuestDelegate() const override;
ExtensionOptionsGuestDelegate* CreateExtensionOptionsGuestDelegate(
ExtensionOptionsGuest* guest) const override;
diff --git a/chromium/chrome/browser/extensions/api/chrome_extensions_api_client_unittest.cc b/chromium/chrome/browser/extensions/api/chrome_extensions_api_client_unittest.cc
index 8e2738c02a5..45762a579c3 100644
--- a/chromium/chrome/browser/extensions/api/chrome_extensions_api_client_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/chrome_extensions_api_client_unittest.cc
@@ -4,13 +4,26 @@
#include "chrome/browser/extensions/api/chrome_extensions_api_client.h"
+#include "base/macros.h"
+#include "chrome/common/webui_url_constants.h"
+#include "content/public/test/test_browser_thread_bundle.h"
+#include "extensions/browser/api/web_request/web_request_info.h"
#include "google_apis/gaia/gaia_urls.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
namespace extensions {
-TEST(TestChromeExtensionsAPIClient, ShouldHideResponseHeader) {
+class ChromeExtensionsAPIClientTest : public testing::Test {
+ public:
+ ChromeExtensionsAPIClientTest() = default;
+
+ private:
+ content::TestBrowserThreadBundle thread_bundle_;
+ DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsAPIClientTest);
+};
+
+TEST_F(ChromeExtensionsAPIClientTest, ShouldHideResponseHeader) {
ChromeExtensionsAPIClient client;
EXPECT_TRUE(client.ShouldHideResponseHeader(
GaiaUrls::GetInstance()->gaia_url(), "X-Chrome-ID-Consistency-Response"));
@@ -22,4 +35,26 @@ TEST(TestChromeExtensionsAPIClient, ShouldHideResponseHeader) {
GaiaUrls::GetInstance()->gaia_url(), "Google-Accounts-SignOut"));
}
+TEST_F(ChromeExtensionsAPIClientTest, ShouldHideBrowserNetworkRequest) {
+ ChromeExtensionsAPIClient client;
+
+ // Requests made by the browser with chrome://newtab as its initiator should
+ // not be visible to extensions.
+ WebRequestInfo request;
+ request.url = GURL("https://example.com/script.js");
+ request.initiator = url::Origin::Create(GURL(chrome::kChromeUINewTabURL));
+ request.render_process_id = -1;
+ request.type = content::ResourceType::RESOURCE_TYPE_SCRIPT;
+ EXPECT_TRUE(client.ShouldHideBrowserNetworkRequest(request));
+
+ // Main frame requests should always be visible to extensions.
+ request.type = content::ResourceType::RESOURCE_TYPE_MAIN_FRAME;
+ EXPECT_FALSE(client.ShouldHideBrowserNetworkRequest(request));
+
+ // Similar requests made by the renderer should be visible to extensions.
+ request.type = content::ResourceType::RESOURCE_TYPE_SCRIPT;
+ request.render_process_id = 2;
+ EXPECT_FALSE(client.ShouldHideBrowserNetworkRequest(request));
+}
+
} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_api.cc b/chromium/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_api.cc
index 3547cd4ce23..193801d9a5f 100644
--- a/chromium/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_api.cc
+++ b/chromium/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_api.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/cloud_print_private.h"
#include "google_apis/google_api_keys.h"
#include "net/base/network_interfaces.h"
@@ -44,31 +45,30 @@ CloudPrintPrivateSetupConnectorFunction::
~CloudPrintPrivateSetupConnectorFunction() {
}
-bool CloudPrintPrivateSetupConnectorFunction::RunAsync() {
+ExtensionFunction::ResponseAction
+CloudPrintPrivateSetupConnectorFunction::Run() {
using api::cloud_print_private::SetupConnector::Params;
std::unique_ptr<Params> params(Params::Create(*args_));
if (CloudPrintTestsDelegate::Get()) {
CloudPrintTestsDelegate::Get()->SetupConnector(
params->user_email, params->robot_email, params->credentials,
params->user_settings);
- SendResponse(true);
- return true;
+ return RespondNow(NoArguments());
}
base::Value user_settings_value =
base::Value::FromUniquePtrValue(params->user_settings.ToValue());
CloudPrintProxyService* service =
- CloudPrintProxyServiceFactory::GetForProfile(GetProfile());
+ CloudPrintProxyServiceFactory::GetForProfile(
+ Profile::FromBrowserContext(browser_context()));
if (!service) {
- error_ = kErrorIncognito;
- return false;
+ return RespondNow(Error(kErrorIncognito));
}
service->EnableForUserWithRobot(params->credentials, params->robot_email,
params->user_email,
std::move(user_settings_value));
- SendResponse(true);
- return true;
+ return RespondNow(NoArguments());
}
CloudPrintPrivateGetHostNameFunction::CloudPrintPrivateGetHostNameFunction() {
@@ -77,13 +77,11 @@ CloudPrintPrivateGetHostNameFunction::CloudPrintPrivateGetHostNameFunction() {
CloudPrintPrivateGetHostNameFunction::~CloudPrintPrivateGetHostNameFunction() {
}
-bool CloudPrintPrivateGetHostNameFunction::RunAsync() {
- SetResult(std::make_unique<base::Value>(
+ExtensionFunction::ResponseAction CloudPrintPrivateGetHostNameFunction::Run() {
+ return RespondNow(OneArgument(std::make_unique<base::Value>(
CloudPrintTestsDelegate::Get()
? CloudPrintTestsDelegate::Get()->GetHostName()
- : net::GetHostName()));
- SendResponse(true);
- return true;
+ : net::GetHostName())));
}
CloudPrintPrivateGetPrintersFunction::CloudPrintPrivateGetPrintersFunction() {
@@ -94,25 +92,28 @@ CloudPrintPrivateGetPrintersFunction::~CloudPrintPrivateGetPrintersFunction() {
void CloudPrintPrivateGetPrintersFunction::SendResults(
const std::vector<std::string>& printers) {
- results_ = api::cloud_print_private::GetPrinters::Results::Create(printers);
- SendResponse(true);
+ Respond(ArgumentList(
+ api::cloud_print_private::GetPrinters::Results::Create(printers)));
}
-bool CloudPrintPrivateGetPrintersFunction::RunAsync() {
+ExtensionFunction::ResponseAction CloudPrintPrivateGetPrintersFunction::Run() {
if (CloudPrintTestsDelegate::Get()) {
- SendResults(CloudPrintTestsDelegate::Get()->GetPrinters());
- return true;
+ return RespondNow(
+ ArgumentList(api::cloud_print_private::GetPrinters::Results::Create(
+ CloudPrintTestsDelegate::Get()->GetPrinters())));
}
CloudPrintProxyService* service =
- CloudPrintProxyServiceFactory::GetForProfile(GetProfile());
- if (!service) {
- error_ = kErrorIncognito;
- return false;
- }
+ CloudPrintProxyServiceFactory::GetForProfile(
+ Profile::FromBrowserContext(browser_context()));
+ if (!service)
+ return RespondNow(Error(kErrorIncognito));
+
+ // TODO(https://crbug.com/845250): CloudPrintProxyService::GetPrinters() may
+ // not invoke the callback, which means this function may never respond.
service->GetPrinters(
base::Bind(&CloudPrintPrivateGetPrintersFunction::SendResults, this));
- return true;
+ return RespondLater();
}
@@ -122,13 +123,11 @@ CloudPrintPrivateGetClientIdFunction::CloudPrintPrivateGetClientIdFunction() {
CloudPrintPrivateGetClientIdFunction::~CloudPrintPrivateGetClientIdFunction() {
}
-bool CloudPrintPrivateGetClientIdFunction::RunAsync() {
- SetResult(std::make_unique<base::Value>(
+ExtensionFunction::ResponseAction CloudPrintPrivateGetClientIdFunction::Run() {
+ return RespondNow(OneArgument(std::make_unique<base::Value>(
CloudPrintTestsDelegate::Get()
? CloudPrintTestsDelegate::Get()->GetClientId()
- : google_apis::GetOAuth2ClientID(google_apis::CLIENT_CLOUD_PRINT)));
- SendResponse(true);
- return true;
+ : google_apis::GetOAuth2ClientID(google_apis::CLIENT_CLOUD_PRINT))));
}
} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_api.h b/chromium/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_api.h
index 0c1e3b60ef6..4305893e576 100644
--- a/chromium/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_api.h
+++ b/chromium/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_api.h
@@ -9,7 +9,7 @@
#include <vector>
#include "build/build_config.h"
-#include "chrome/browser/extensions/chrome_extension_function.h"
+#include "extensions/browser/extension_function.h"
#include "printing/buildflags/buildflags.h"
#if !BUILDFLAG(ENABLE_PRINT_PREVIEW) || defined(OS_CHROMEOS)
@@ -49,7 +49,7 @@ class CloudPrintTestsDelegate {
};
class CloudPrintPrivateSetupConnectorFunction
- : public ChromeAsyncExtensionFunction {
+ : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("cloudPrintPrivate.setupConnector",
CLOUDPRINTPRIVATE_SETUPCONNECTOR)
@@ -60,11 +60,10 @@ class CloudPrintPrivateSetupConnectorFunction
~CloudPrintPrivateSetupConnectorFunction() override;
// ExtensionFunction:
- bool RunAsync() override;
+ ResponseAction Run() override;
};
-class CloudPrintPrivateGetHostNameFunction
- : public ChromeAsyncExtensionFunction {
+class CloudPrintPrivateGetHostNameFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("cloudPrintPrivate.getHostName",
CLOUDPRINTPRIVATE_GETHOSTNAME)
@@ -75,11 +74,10 @@ class CloudPrintPrivateGetHostNameFunction
~CloudPrintPrivateGetHostNameFunction() override;
// ExtensionFunction:
- bool RunAsync() override;
+ ResponseAction Run() override;
};
-class CloudPrintPrivateGetPrintersFunction
- : public ChromeAsyncExtensionFunction {
+class CloudPrintPrivateGetPrintersFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("cloudPrintPrivate.getPrinters",
CLOUDPRINTPRIVATE_GETPRINTERS)
@@ -93,11 +91,10 @@ class CloudPrintPrivateGetPrintersFunction
void SendResults(const std::vector<std::string>& printers);
// ExtensionFunction:
- bool RunAsync() override;
+ ResponseAction Run() override;
};
-class CloudPrintPrivateGetClientIdFunction
- : public ChromeAsyncExtensionFunction {
+class CloudPrintPrivateGetClientIdFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("cloudPrintPrivate.getClientId",
CLOUDPRINTPRIVATE_GETCLIENTID);
@@ -108,7 +105,7 @@ class CloudPrintPrivateGetClientIdFunction
~CloudPrintPrivateGetClientIdFunction() override;
// ExtensionFunction:
- bool RunAsync() override;
+ ResponseAction Run() override;
};
} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_apitest.cc b/chromium/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_apitest.cc
index 7145f7ca185..a00d71d51b3 100644
--- a/chromium/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/cloud_print_private/cloud_print_private_apitest.cc
@@ -22,10 +22,10 @@ using ::testing::Return;
using ::testing::_;
// A base class for tests below.
-class ExtensionCloudPrintPrivateApiTest : public ExtensionApiTest {
+class ExtensionCloudPrintPrivateApiTest : public extensions::ExtensionApiTest {
public:
void SetUpCommandLine(base::CommandLine* command_line) override {
- ExtensionApiTest::SetUpCommandLine(command_line);
+ extensions::ExtensionApiTest::SetUpCommandLine(command_line);
command_line->AppendSwitchASCII(
switches::kCloudPrintURL,
"http://www.cloudprintapp.com/extensions/api_test/"
@@ -33,7 +33,7 @@ class ExtensionCloudPrintPrivateApiTest : public ExtensionApiTest {
}
void SetUpOnMainThread() override {
- ExtensionApiTest::SetUpOnMainThread();
+ extensions::ExtensionApiTest::SetUpOnMainThread();
// Start up the test server and get us ready for calling the install
// API functions.
host_resolver()->AddRule("www.cloudprintapp.com", "127.0.0.1");
diff --git a/chromium/chrome/browser/extensions/api/command_line_private/command_line_private_apitest.cc b/chromium/chrome/browser/extensions/api/command_line_private/command_line_private_apitest.cc
index 36de0cea254..cdbd1f1bf16 100644
--- a/chromium/chrome/browser/extensions/api/command_line_private/command_line_private_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/command_line_private/command_line_private_apitest.cc
@@ -11,9 +11,9 @@ namespace {
const char kTestCommandLineSwitch[] = "command-line-private-api-test-foo";
} // namespace
-class CommandLinePrivateApiTest : public ExtensionApiTest {
+class CommandLinePrivateApiTest : public extensions::ExtensionApiTest {
void SetUpCommandLine(base::CommandLine* command_line) override {
- ExtensionApiTest::SetUpCommandLine(command_line);
+ extensions::ExtensionApiTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(kTestCommandLineSwitch);
}
};
diff --git a/chromium/chrome/browser/extensions/api/cookies/cookies_api.cc b/chromium/chrome/browser/extensions/api/cookies/cookies_api.cc
index 13790f2f9eb..639053961b0 100644
--- a/chromium/chrome/browser/extensions/api/cookies/cookies_api.cc
+++ b/chromium/chrome/browser/extensions/api/cookies/cookies_api.cc
@@ -82,18 +82,7 @@ network::mojom::CookieManager* ParseStoreCookieManager(
return nullptr;
}
} else {
- // The store ID was not specified; use the current execution context's
- // cookie store by default.
- // GetCurrentBrowser() already takes into account incognito settings.
- // TODO(rdevlin.cronin): Relying on the current execution context is
- // almost never the right answer; clean this up.
- Browser* current_browser =
- ChromeExtensionFunctionDetails(function).GetCurrentBrowser();
- if (!current_browser) {
- function->SetError(keys::kNoCookieStoreFoundError);
- return nullptr;
- }
- store_profile = current_browser->profile();
+ store_profile = function->GetProfile();
*store_id = cookies_helpers::GetStoreIdFromProfile(store_profile);
}
@@ -400,6 +389,16 @@ void CookiesSetFunction::GetCookieListCallback(
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK_EQ(SET_COMPLETED, state_);
state_ = GET_COMPLETED;
+
+ if (!success_) {
+ std::string name = parsed_args_->details.name.get()
+ ? *parsed_args_->details.name
+ : std::string();
+ error_ = ErrorUtils::FormatErrorMessage(keys::kCookieSetFailedError, name);
+ SendResponse(false);
+ return;
+ }
+
for (const net::CanonicalCookie& cookie : cookie_list) {
// Return the first matching cookie. Relies on the fact that the
// CookieMonster returns them in canonical order (longest path, then
@@ -415,15 +414,7 @@ void CookiesSetFunction::GetCookieListCallback(
}
}
- if (!success_) {
- std::string name =
- parsed_args_->details.name.get() ? *parsed_args_->details.name
- : std::string();
- // TODO(rdevlin.cronin): Avoid setting both error_ and results_ in the
- // same call.
- error_ = ErrorUtils::FormatErrorMessage(keys::kCookieSetFailedError, name);
- }
- SendResponse(success_);
+ SendResponse(true);
}
CookiesRemoveFunction::CookiesRemoveFunction() {
diff --git a/chromium/chrome/browser/extensions/api/dashboard_private/dashboard_private_api.cc b/chromium/chrome/browser/extensions/api/dashboard_private/dashboard_private_api.cc
index c2bb77b851e..662509209a3 100644
--- a/chromium/chrome/browser/extensions/api/dashboard_private/dashboard_private_api.cc
+++ b/chromium/chrome/browser/extensions/api/dashboard_private/dashboard_private_api.cc
@@ -124,7 +124,7 @@ void DashboardPrivateShowPermissionPromptForDelegatedInstallFunction::
return;
}
- content::WebContents* web_contents = GetAssociatedWebContents();
+ content::WebContents* web_contents = GetSenderWebContents();
if (!web_contents) {
// The browser window has gone away.
Respond(BuildResponse(api::dashboard_private::RESULT_USER_CANCELLED,
diff --git a/chromium/chrome/browser/extensions/api/data_reduction_proxy/data_reduction_proxy_api.cc b/chromium/chrome/browser/extensions/api/data_reduction_proxy/data_reduction_proxy_api.cc
index 56b6ad30049..0b33e5f5b76 100644
--- a/chromium/chrome/browser/extensions/api/data_reduction_proxy/data_reduction_proxy_api.cc
+++ b/chromium/chrome/browser/extensions/api/data_reduction_proxy/data_reduction_proxy_api.cc
@@ -22,8 +22,11 @@ DataReductionProxyClearDataSavingsFunction::Run() {
data_reduction_proxy::DataReductionProxySettings* settings =
DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
browser_context());
- settings->data_reduction_proxy_service()->compression_stats()->
- ClearDataSavingStatistics();
+ settings->data_reduction_proxy_service()
+ ->compression_stats()
+ ->ClearDataSavingStatistics(
+ data_reduction_proxy::DataReductionProxySavingsClearedReason::
+ USER_ACTION_EXTENSION);
return RespondNow(NoArguments());
}
diff --git a/chromium/chrome/browser/extensions/api/debugger/debugger_api.cc b/chromium/chrome/browser/extensions/api/debugger/debugger_api.cc
index 849602a866f..a163e7751bc 100644
--- a/chromium/chrome/browser/extensions/api/debugger/debugger_api.cc
+++ b/chromium/chrome/browser/extensions/api/debugger/debugger_api.cc
@@ -368,7 +368,7 @@ bool DebuggerFunction::InitAgentHost() {
if (result && web_contents) {
// TODO(rdevlin.cronin) This should definitely be GetLastCommittedURL().
GURL url = web_contents->GetVisibleURL();
- if (PermissionsData::IsRestrictedUrl(url, extension(), &error_))
+ if (extension()->permissions_data()->IsRestrictedUrl(url, &error_))
return false;
agent_host_ = DevToolsAgentHost::GetOrCreateFor(web_contents);
}
@@ -377,9 +377,8 @@ bool DebuggerFunction::InitAgentHost() {
ProcessManager::Get(GetProfile())
->GetBackgroundHostForExtension(*debuggee_.extension_id);
if (extension_host) {
- if (PermissionsData::IsRestrictedUrl(extension_host->GetURL(),
- extension(),
- &error_)) {
+ if (extension()->permissions_data()->IsRestrictedUrl(
+ extension_host->GetURL(), &error_)) {
return false;
}
agent_host_ =
@@ -388,9 +387,8 @@ bool DebuggerFunction::InitAgentHost() {
} else if (debuggee_.target_id) {
agent_host_ = DevToolsAgentHost::GetForId(*debuggee_.target_id);
if (agent_host_.get()) {
- if (PermissionsData::IsRestrictedUrl(agent_host_->GetURL(),
- extension(),
- &error_)) {
+ if (extension()->permissions_data()->IsRestrictedUrl(
+ agent_host_->GetURL(), &error_)) {
agent_host_ = nullptr;
return false;
}
diff --git a/chromium/chrome/browser/extensions/api/debugger/debugger_apitest.cc b/chromium/chrome/browser/extensions/api/debugger/debugger_apitest.cc
index 28f88e20e62..bdd6e19bf5e 100644
--- a/chromium/chrome/browser/extensions/api/debugger/debugger_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/debugger/debugger_apitest.cc
@@ -164,8 +164,8 @@ IN_PROC_BROWSER_TEST_F(DebuggerApiTest,
DebuggerNotAllowedOnOtherExtensionPages) {
// Load another arbitrary extension with an associated resource (popup.html).
base::FilePath path;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path));
- path = path.AppendASCII("extensions").AppendASCII("good_unpacked");
+ ASSERT_TRUE(base::PathService::Get(chrome::DIR_TEST_DATA, &path));
+ path = path.AppendASCII("extensions").AppendASCII("simple_with_popup");
const Extension* another_extension = LoadExtension(path);
ASSERT_TRUE(another_extension);
diff --git a/chromium/chrome/browser/extensions/api/debugger/debugger_extension_apitest.cc b/chromium/chrome/browser/extensions/api/debugger/debugger_extension_apitest.cc
index a8a3ef89437..efdbfbebade 100644
--- a/chromium/chrome/browser/extensions/api/debugger/debugger_extension_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/debugger/debugger_extension_apitest.cc
@@ -7,10 +7,10 @@
#include "chrome/common/chrome_switches.h"
#include "extensions/common/switches.h"
-class ExtensionApiTestWithSwitch : public ExtensionApiTest {
+class ExtensionApiTestWithSwitch : public extensions::ExtensionApiTest {
public:
void SetUpCommandLine(base::CommandLine* command_line) override {
- ExtensionApiTest::SetUpCommandLine(command_line);
+ extensions::ExtensionApiTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(switches::kSilentDebuggerExtensionAPI);
command_line->AppendSwitch(extensions::switches::kExtensionsOnChromeURLs);
}
diff --git a/chromium/chrome/browser/extensions/api/debugger/extension_dev_tools_infobar.cc b/chromium/chrome/browser/extensions/api/debugger/extension_dev_tools_infobar.cc
index 41b8582f234..fdc19ab8c55 100644
--- a/chromium/chrome/browser/extensions/api/debugger/extension_dev_tools_infobar.cc
+++ b/chromium/chrome/browser/extensions/api/debugger/extension_dev_tools_infobar.cc
@@ -30,6 +30,8 @@ class ExtensionDevToolsInfoBarDelegate : public ConfirmInfoBarDelegate {
bool ShouldExpire(const NavigationDetails& details) const override;
void InfoBarDismissed() override;
base::string16 GetMessageText() const override;
+ gfx::ElideBehavior GetMessageElideBehavior() const override;
+
int GetButtons() const override;
bool Cancel() override;
@@ -69,6 +71,14 @@ base::string16 ExtensionDevToolsInfoBarDelegate::GetMessageText() const {
return l10n_util::GetStringFUTF16(IDS_DEV_TOOLS_INFOBAR_LABEL, client_name_);
}
+gfx::ElideBehavior ExtensionDevToolsInfoBarDelegate::GetMessageElideBehavior()
+ const {
+ // The important part of the message text above is at the end:
+ // "... is debugging the browser". If the extension name is very long,
+ // we'd rather truncate it instead. See https://crbug.com/823194.
+ return gfx::ELIDE_HEAD;
+}
+
int ExtensionDevToolsInfoBarDelegate::GetButtons() const {
return BUTTON_CANCEL;
}
diff --git a/chromium/chrome/browser/extensions/api/declarative_content/declarative_content_apitest.cc b/chromium/chrome/browser/extensions/api/declarative_content/declarative_content_apitest.cc
index 4f2b43e14fd..a0660161c16 100644
--- a/chromium/chrome/browser/extensions/api/declarative_content/declarative_content_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/declarative_content/declarative_content_apitest.cc
@@ -841,9 +841,9 @@ IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest,
WebContentsWithoutTabAddedNotificationAtOnLoaded) {
// Add a web contents to the tab strip in a way that doesn't trigger
// NOTIFICATION_TAB_ADDED.
- content::WebContents* contents = content::WebContents::Create(
+ std::unique_ptr<content::WebContents> contents = content::WebContents::Create(
content::WebContents::CreateParams(profile()));
- browser()->tab_strip_model()->AppendWebContents(contents, false);
+ browser()->tab_strip_model()->AppendWebContents(std::move(contents), false);
// The actual extension contents don't matter here -- we're just looking to
// trigger OnExtensionLoaded.
@@ -868,8 +868,8 @@ IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest,
browser()->tab_strip_model()->GetWebContentsAt(0);
AddTabAtIndex(1, GURL("http://test2/"), ui::PAGE_TRANSITION_LINK);
- std::unique_ptr<content::WebContents> tab2(
- browser()->tab_strip_model()->GetWebContentsAt(1));
+ content::WebContents* tab2 =
+ browser()->tab_strip_model()->GetWebContentsAt(1);
// Add a rule matching the second tab.
const std::string kAddTestRules =
@@ -886,8 +886,7 @@ IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest,
"}], 'add_rules');\n";
EXPECT_EQ("add_rules",
ExecuteScriptInBackgroundPage(extension->id(), kAddTestRules));
- EXPECT_TRUE(page_action->GetIsVisible(
- ExtensionTabUtil::GetTabId(tab2.get())));
+ EXPECT_TRUE(page_action->GetIsVisible(ExtensionTabUtil::GetTabId(tab2)));
// Remove the rule.
const std::string kRemoveTestRule1 = "removeRule('2', 'remove_rule1');\n";
@@ -896,7 +895,8 @@ IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest,
// Remove the second tab, then trigger a rule evaluation for the remaining
// tab.
- tab2.reset();
+ browser()->tab_strip_model()->DetachWebContentsAt(
+ browser()->tab_strip_model()->GetIndexOfWebContents(tab2));
NavigateInRenderer(tab1, GURL("http://test1/"));
EXPECT_TRUE(page_action->GetIsVisible(ExtensionTabUtil::GetTabId(tab1)));
}
diff --git a/chromium/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_apitest.cc b/chromium/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_apitest.cc
index e46d400da4d..97ade6a7f58 100644
--- a/chromium/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_apitest.cc
@@ -12,14 +12,14 @@
namespace {
-class DeclarativeNetRequestAPItest : public ExtensionApiTest {
+class DeclarativeNetRequestAPItest : public extensions::ExtensionApiTest {
public:
DeclarativeNetRequestAPItest() {}
protected:
// ExtensionApiTest override.
void SetUpOnMainThread() override {
- ExtensionApiTest::SetUpOnMainThread();
+ extensions::ExtensionApiTest::SetUpOnMainThread();
base::FilePath test_data_dir =
test_data_dir_.AppendASCII("declarative_net_request");
diff --git a/chromium/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_browsertest.cc b/chromium/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_browsertest.cc
index 13840d16ecd..8f7580f1594 100644
--- a/chromium/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_browsertest.cc
+++ b/chromium/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_browsertest.cc
@@ -6,12 +6,16 @@
#include <algorithm>
#include <memory>
+#include <set>
+#include <vector>
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
+#include "base/json/json_string_value_serializer.h"
#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "base/path_service.h"
+#include "base/rand_util.h"
#include "base/test/histogram_tester.h"
#include "base/threading/thread_restrictions.h"
#include "base/values.h"
@@ -31,7 +35,7 @@
#include "components/proxy_config/proxy_config_pref_names.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_entry.h"
-#include "content/public/browser/notification_source.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
@@ -44,13 +48,12 @@
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/extension_util.h"
-#include "extensions/browser/notification_types.h"
-#include "extensions/browser/runtime_data.h"
#include "extensions/common/api/declarative_net_request/constants.h"
#include "extensions/common/api/declarative_net_request/test_utils.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/url_pattern.h"
+#include "extensions/test/extension_test_message_listener.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/spawned_test_server/spawned_test_server.h"
#include "net/test/test_data_directory.h"
@@ -90,8 +93,8 @@ class URLRequestMonitor : public RulesetManager::TestObserver {
private:
// RulesetManager::TestObserver implementation.
- void OnShouldBlockRequest(const WebRequestInfo& request,
- bool is_incognito_context) override {
+ void OnEvaluateRequest(const WebRequestInfo& request,
+ bool is_incognito_context) override {
if (request.url == url_)
GetAndResetRequestSeen(true);
}
@@ -115,12 +118,12 @@ class DeclarativeNetRequestBrowserTest
public:
DeclarativeNetRequestBrowserTest() {}
- // ExtensionBrowserTest override.
+ // ExtensionBrowserTest overrides:
void SetUpOnMainThread() override {
ExtensionBrowserTest::SetUpOnMainThread();
base::FilePath test_root_path;
- PathService::Get(chrome::DIR_TEST_DATA, &test_root_path);
+ base::PathService::Get(chrome::DIR_TEST_DATA, &test_root_path);
test_root_path = test_root_path.AppendASCII("extensions")
.AppendASCII("declarative_net_request");
embedded_test_server()->ServeFilesFromDirectory(test_root_path);
@@ -132,6 +135,19 @@ class DeclarativeNetRequestBrowserTest
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
}
+ void CreatedBrowserMainParts(
+ content::BrowserMainParts* browser_main_parts) override {
+ // At this point, the notification service is initialized but the profile
+ // and extensions have not. Initialize |background_page_ready_listener_| to
+ // listen for messages from extensions.
+ CHECK(content::NotificationService::current());
+
+ background_page_ready_listener_ =
+ std::make_unique<ExtensionTestMessageListener>("ready",
+ false /*will_reply*/);
+
+ ExtensionBrowserTest::CreatedBrowserMainParts(browser_main_parts);
+ }
protected:
content::WebContents* web_contents(Browser* browser) const {
@@ -184,6 +200,7 @@ class DeclarativeNetRequestBrowserTest
kJSONRulesFilename, rules, hosts,
has_background_script_);
+ background_page_ready_listener_->Reset();
const Extension* extension = nullptr;
switch (GetParam()) {
case ExtensionLoadType::PACKED:
@@ -201,6 +218,10 @@ class DeclarativeNetRequestBrowserTest
// Ensure the ruleset is also loaded on the IO thread.
content::RunAllTasksUntilIdle();
+ // Wait for the background page to load if needed.
+ if (has_background_script_)
+ WaitForBackgroundScriptToLoad(extension->id());
+
// Ensure no load errors were reported.
EXPECT_TRUE(LoadErrorReporter::GetInstance()->GetErrors()->empty());
@@ -220,9 +241,81 @@ class DeclarativeNetRequestBrowserTest
{URLPattern::kAllUrlsPattern});
}
+ void WaitForBackgroundScriptToLoad(const ExtensionId& extension_id) {
+ ASSERT_TRUE(background_page_ready_listener_->WaitUntilSatisfied());
+ ASSERT_EQ(extension_id,
+ background_page_ready_listener_->extension_id_for_message());
+ background_page_ready_listener_->Reset();
+ }
+
+ void AddWhitelistedPages(const ExtensionId& extension_id,
+ const std::vector<std::string>& patterns) {
+ UpdateWhitelistedPages(extension_id, patterns, "addWhitelistedPages");
+ }
+
+ void RemoveWhitelistedPages(const ExtensionId& extension_id,
+ const std::vector<std::string>& patterns) {
+ UpdateWhitelistedPages(extension_id, patterns, "removeWhitelistedPages");
+ }
+
+ // Verifies that the result of getWhitelistedPages call is the same as
+ // |expected_patterns|.
+ void VerifyGetWhitelistedPages(
+ const ExtensionId& extension_id,
+ const std::set<std::string>& expected_patterns) {
+ static constexpr char kScript[] = R"(
+ chrome.declarativeNetRequest.getWhitelistedPages(function(patterns) {
+ window.domAutomationController.send(chrome.runtime.lastError
+ ? 'error'
+ : JSON.stringify(patterns));
+ });
+ )";
+
+ const std::string result =
+ ExecuteScriptInBackgroundPage(extension_id, kScript);
+ ASSERT_NE("error", result);
+
+ // Parse |result| as a list and deserialize it to a set of strings.
+ std::unique_ptr<base::Value> value =
+ JSONStringValueDeserializer(result).Deserialize(
+ nullptr /*error_code*/, nullptr /*error_message*/);
+ ASSERT_TRUE(value);
+ ASSERT_TRUE(value->is_list());
+ std::set<std::string> patterns;
+ for (const auto& pattern_value : value->GetList()) {
+ ASSERT_TRUE(pattern_value.is_string());
+ patterns.insert(pattern_value.GetString());
+ }
+
+ EXPECT_EQ(expected_patterns, patterns);
+ }
+
private:
+ void UpdateWhitelistedPages(const ExtensionId& extension_id,
+ const std::vector<std::string>& patterns,
+ const std::string& function_name) {
+ static constexpr char kScript[] = R"(
+ chrome.declarativeNetRequest.%s(%s, function() {
+ window.domAutomationController.send(chrome.runtime.lastError
+ ? 'error'
+ : 'success');
+ });
+ )";
+
+ // Serialize |patterns| to JSON.
+ std::unique_ptr<base::ListValue> list = ToListValue(patterns);
+ std::string json_string;
+ ASSERT_TRUE(JSONStringValueSerializer(&json_string).Serialize(*list));
+
+ EXPECT_EQ("success", ExecuteScriptInBackgroundPage(
+ extension_id,
+ base::StringPrintf(kScript, function_name.c_str(),
+ json_string.c_str())));
+ }
+
base::ScopedTempDir temp_dir_;
bool has_background_script_ = false;
+ std::unique_ptr<ExtensionTestMessageListener> background_page_ready_listener_;
DISALLOW_COPY_AND_ASSIGN(DeclarativeNetRequestBrowserTest);
};
@@ -273,6 +366,7 @@ IN_PROC_BROWSER_TEST_P(DeclarativeNetRequestBrowserTest,
for (const auto& rule_data : rules_data) {
TestRule rule = CreateGenericRule();
rule.condition->url_filter = rule_data.url_filter;
+ rule.condition->resource_types = std::vector<std::string>({"main_frame"});
rule.id = rule_data.id;
rules.push_back(rule);
}
@@ -301,6 +395,7 @@ IN_PROC_BROWSER_TEST_P(DeclarativeNetRequestBrowserTest,
TestRule rule = CreateGenericRule();
rule.condition->url_filter =
std::string("pages_with_script/page2.html?q=bye^");
+ rule.condition->resource_types = std::vector<std::string>({"main_frame"});
ASSERT_NO_FATAL_FAILURE(LoadExtensionWithRules({rule}));
// '^' (Separator character) matches anything except a letter, a digit or
@@ -538,18 +633,21 @@ IN_PROC_BROWSER_TEST_P(DeclarativeNetRequestBrowserTest, Whitelist) {
TestRule rule = CreateGenericRule();
int id = kMinValidID;
- // Block all requests ending with numbers 1 to |kNumRequests|.
+ // Block all main-frame requests ending with numbers 1 to |kNumRequests|.
std::vector<TestRule> rules;
for (int i = 1; i <= kNumRequests; ++i) {
rule.id = id++;
rule.condition->url_filter = base::StringPrintf("num=%d|", i);
+ rule.condition->resource_types = std::vector<std::string>({"main_frame"});
rules.push_back(rule);
}
- // Whitelist all requests ending with even numbers from 1 to |kNumRequests|.
+ // Whitelist all main-frame requests ending with even numbers from 1 to
+ // |kNumRequests|.
for (int i = 2; i <= kNumRequests; i += 2) {
rule.id = id++;
rule.condition->url_filter = base::StringPrintf("num=%d|", i);
+ rule.condition->resource_types = std::vector<std::string>({"main_frame"});
rule.action->type = std::string("whitelist");
rules.push_back(rule);
}
@@ -577,9 +675,10 @@ IN_PROC_BROWSER_TEST_P(DeclarativeNetRequestBrowserTest, Whitelist) {
// enabled.
IN_PROC_BROWSER_TEST_P(DeclarativeNetRequestBrowserTest,
Enable_Disable_Reload_Uninstall) {
- // Block all requests to example.com
+ // Block all main frame requests to example.com
TestRule rule = CreateGenericRule();
rule.condition->url_filter = std::string("example.com");
+ rule.condition->resource_types = std::vector<std::string>({"main_frame"});
ASSERT_NO_FATAL_FAILURE(LoadExtensionWithRules({rule}));
const ExtensionId extension_id = last_loaded_extension_id();
@@ -650,6 +749,7 @@ IN_PROC_BROWSER_TEST_P(DeclarativeNetRequestBrowserTest,
for (const auto& rule_data : rules_data) {
TestRule rule = CreateGenericRule();
rule.condition->url_filter = rule_data.url_filter;
+ rule.condition->resource_types = std::vector<std::string>({"main_frame"});
rule.id = rule_data.id;
if (rule_data.add_to_first_extension)
rules_1.push_back(rule);
@@ -705,6 +805,7 @@ IN_PROC_BROWSER_TEST_P(DeclarativeNetRequestBrowserTest,
rule.priority = kMinValidPriority;
rule.action->type = std::string("redirect");
rule.condition->url_filter = std::string("example.com");
+ rule.condition->resource_types = std::vector<std::string>({"main_frame"});
base::Time last_extension_install_time = base::Time::Min();
@@ -762,6 +863,7 @@ IN_PROC_BROWSER_TEST_P(DeclarativeNetRequestBrowserTest, BlockAndRedirect) {
rule.condition->url_filter = rule_data.url_filter;
rule.id = rule_data.id;
rule.priority = kMinValidPriority;
+ rule.condition->resource_types = std::vector<std::string>({"main_frame"});
rule.action->type = rule_data.action_type;
rule.action->redirect_url = rule_data.redirect_url;
rules.push_back(rule);
@@ -844,13 +946,14 @@ IN_PROC_BROWSER_TEST_P(DeclarativeNetRequestBrowserTest, RedirectPriority) {
rule.action->type = std::string("redirect");
rule.action->redirect_url = redirect_url_for_priority(j);
rule.condition->url_filter = pattern;
+ rule.condition->resource_types = std::vector<std::string>({"main_frame"});
rules.push_back(rule);
}
}
// Shuffle the rules to ensure that the order in which rules are added has no
// effect on the test.
- std::random_shuffle(rules.begin(), rules.end());
+ base::RandomShuffle(rules.begin(), rules.end());
ASSERT_NO_FATAL_FAILURE(LoadExtensionWithRules(rules));
for (size_t i = 0; i <= kNumPatternTypes + 1; ++i) {
@@ -877,9 +980,10 @@ IN_PROC_BROWSER_TEST_P(DeclarativeNetRequestBrowserTest, RedirectPriority) {
// from an incognito context.
IN_PROC_BROWSER_TEST_P(DeclarativeNetRequestBrowserTest,
BlockRequests_Incognito) {
- // Block all requests to example.com
+ // Block all main-frame requests to example.com.
TestRule rule = CreateGenericRule();
rule.condition->url_filter = std::string("example.com");
+ rule.condition->resource_types = std::vector<std::string>({"main_frame"});
ASSERT_NO_FATAL_FAILURE(LoadExtensionWithRules({rule}));
ExtensionId extension_id = last_loaded_extension_id();
@@ -1106,7 +1210,7 @@ IN_PROC_BROWSER_TEST_P(DeclarativeNetRequestBrowserTest,
rules_2, "extension_2", {URLPattern::kAllUrlsPattern}));
const std::string extension_id_2 = last_loaded_extension_id();
- auto get_manifest_url = [](const std::string& extension_id) {
+ auto get_manifest_url = [](const ExtensionId& extension_id) {
return GURL(base::StringPrintf("%s://%s/manifest.json",
extensions::kExtensionScheme,
extension_id.c_str()));
@@ -1137,37 +1241,13 @@ IN_PROC_BROWSER_TEST_P(DeclarativeNetRequestBrowserTest_Packed,
ASSERT_TRUE(dnr_extension);
EXPECT_EQ("Test extension", dnr_extension->name());
- // Ensure the background page is ready before dispatching the script to it.
- if (!ExtensionSystem::Get(profile())->runtime_data()->IsBackgroundPageReady(
- dnr_extension)) {
- content::WindowedNotificationObserver(
- NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY,
- content::Source<Extension>(dnr_extension))
- .Wait();
- }
+ constexpr char kGoogleDotCom[] = "https://www.google.com/";
- // Whitelist "https://www.google.com/".
- const char* script1 = R"(
- chrome.declarativeNetRequest.addWhitelistedPages(
- ['https://www.google.com/'], function() {
- window.domAutomationController.send('success');
- });
- )";
- EXPECT_EQ("success",
- ExecuteScriptInBackgroundPage(last_loaded_extension_id(), script1));
+ // Whitelist |kGoogleDotCom|.
+ AddWhitelistedPages(dnr_extension->id(), {kGoogleDotCom});
// Ensure that the page was whitelisted.
- const char* script2 = R"(
- chrome.declarativeNetRequest.getWhitelistedPages(function(patterns) {
- if (patterns.length === 1 && patterns[0] === 'https://www.google.com/')
- window.domAutomationController.send('success');
- else
- window.domAutomationController.send('error');
- });
- )";
-
- EXPECT_EQ("success",
- ExecuteScriptInBackgroundPage(last_loaded_extension_id(), script2));
+ VerifyGetWhitelistedPages(dnr_extension->id(), {kGoogleDotCom});
}
// Tests that the pages whitelisted using the page whitelisting API are
@@ -1191,46 +1271,16 @@ IN_PROC_BROWSER_TEST_P(DeclarativeNetRequestBrowserTest_Packed,
ASSERT_TRUE(dnr_extension);
// Ensure the background page is ready before dispatching the script to it.
- if (!ExtensionSystem::Get(profile())->runtime_data()->IsBackgroundPageReady(
- dnr_extension)) {
- content::WindowedNotificationObserver(
- NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY,
- content::Source<Extension>(dnr_extension))
- .Wait();
- }
+ WaitForBackgroundScriptToLoad(dnr_extension->id());
+
+ constexpr char kGoogleDotCom[] = "https://www.google.com/";
+
+ VerifyGetWhitelistedPages(dnr_extension->id(), {kGoogleDotCom});
+
+ // Remove |kGoogleDotCom| from the whitelist.
+ RemoveWhitelistedPages(dnr_extension->id(), {kGoogleDotCom});
- const char* script1 = R"(
- chrome.declarativeNetRequest.getWhitelistedPages(function(patterns) {
- if (patterns.length === 1 && patterns[0] === "https://www.google.com/")
- window.domAutomationController.send("success");
- else
- window.domAutomationController.send("error");
- });
- )";
- ASSERT_EQ("success",
- ExecuteScriptInBackgroundPage(dnr_extension->id(), script1));
-
- // Remove "https://www.google.com/" from the whitelist.
- const char* script2 = R"(
- chrome.declarativeNetRequest.removeWhitelistedPages(
- ["https://www.google.com/"], function() {
- window.domAutomationController.send("success");
- });
- )";
- ASSERT_EQ("success",
- ExecuteScriptInBackgroundPage(dnr_extension->id(), script2));
-
- // Ensure that the page was removed from the whitelist.
- const char* script3 = R"(
- chrome.declarativeNetRequest.getWhitelistedPages(function(patterns) {
- if (patterns.length === 0)
- window.domAutomationController.send("success");
- else
- window.domAutomationController.send("error");
- });
- )";
- EXPECT_EQ("success",
- ExecuteScriptInBackgroundPage(dnr_extension->id(), script3));
+ VerifyGetWhitelistedPages(dnr_extension->id(), {});
}
// Test fixture to verify that host permissions for the request url and the
@@ -1357,7 +1407,8 @@ class DeclarativeNetRequestResourceTypeBrowserTest
DeclarativeNetRequestResourceTypeBrowserTest() {}
protected:
- // TODO(crbug.com/696822): Add tests for "object", "ping", "other", "font".
+ // TODO(crbug.com/696822): Add tests for "object", "ping", "other", "font",
+ // "csp_report".
enum ResourceTypeMask {
kNone = 0,
kSubframe = 1 << 0,
@@ -1453,17 +1504,11 @@ class DeclarativeNetRequestResourceTypeBrowserTest
{"block_websocket.com", 7, {"websocket"}, {}},
{"block_image_and_stylesheet.com", 8, {"image", "stylesheet"}, {}},
{"block_subframe_and_xhr.com", 11, {"sub_frame", "xmlhttprequest"}, {}},
- // With renderer side navigation, the main frame origin serves as the
- // initiator for main frame page loads. Hence to ensure that the main
- // frame page load is not blocked, also exclude the "other" resource
- // type, which is used for main frame requests currently.
- // TODO(crbug.com/696822): Change "other" to "main_frame" once it is
- // implemented.
- {"block_all.com", 9, {}, {"other"}},
+ {"block_all.com", 9, {}, {}},
{"block_all_but_xhr_and_script.com",
10,
{},
- {"xmlhttprequest", "script", "other"}},
+ {"xmlhttprequest", "script"}},
};
std::vector<TestRule> rules;
diff --git a/chromium/chrome/browser/extensions/api/declarative_net_request/rule_indexing_unittest.cc b/chromium/chrome/browser/extensions/api/declarative_net_request/rule_indexing_unittest.cc
index 0e5c1f20ae2..34bcef26e9f 100644
--- a/chromium/chrome/browser/extensions/api/declarative_net_request/rule_indexing_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/declarative_net_request/rule_indexing_unittest.cc
@@ -223,8 +223,9 @@ TEST_P(RuleIndexingTest, InvalidRedirectRulePriority) {
TEST_P(RuleIndexingTest, NoApplicableResourceTypes) {
TestRule rule = CreateGenericRule();
rule.condition->excluded_resource_types = std::vector<std::string>(
- {"sub_frame", "stylesheet", "script", "image", "font", "object",
- "xmlhttprequest", "ping", "media", "websocket", "other"});
+ {"main_frame", "sub_frame", "stylesheet", "script", "image", "font",
+ "object", "xmlhttprequest", "ping", "csp_report", "media", "websocket",
+ "other"});
AddRule(rule);
LoadAndExpectError(
ParseInfo(ParseResult::ERROR_NO_APPLICABLE_RESOURCE_TYPES, 0u)
diff --git a/chromium/chrome/browser/extensions/api/declarative_net_request/ruleset_manager_unittest.cc b/chromium/chrome/browser/extensions/api/declarative_net_request/ruleset_manager_unittest.cc
index 01b106a0d14..ff1ca03b826 100644
--- a/chromium/chrome/browser/extensions/api/declarative_net_request/ruleset_manager_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/declarative_net_request/ruleset_manager_unittest.cc
@@ -42,6 +42,8 @@ class RulesetManagerTest : public DNRTestBase {
RulesetManagerTest() {}
protected:
+ using Action = RulesetManager::Action;
+
// Helper to create a ruleset matcher instance for the given |rules|.
void CreateMatcherForRules(const std::vector<TestRule>& rules,
const std::string& extension_dirname,
@@ -140,8 +142,12 @@ TEST_P(RulesetManagerTest, MultipleRulesets) {
GetRequestForURL("http://three.com");
WebRequestInfo request_three_info(request_three.get());
- // Test all possible combinations with |rule_one| and |rule_two| enabled.
- const bool is_incognito_context = false;
+ auto should_block_request = [manager](const WebRequestInfo& request) {
+ GURL redirect_url;
+ return manager->EvaluateRequest(request, false /*is_incognito_context*/,
+ &redirect_url) == Action::BLOCK;
+ };
+
for (int mask = 0; mask < 4; mask++) {
SCOPED_TRACE(base::StringPrintf("Testing ruleset mask %d", mask));
@@ -170,14 +176,11 @@ TEST_P(RulesetManagerTest, MultipleRulesets) {
ASSERT_EQ(expected_matcher_count, manager->GetMatcherCountForTest());
- EXPECT_EQ(
- (mask & kEnableRulesetOne) != 0,
- manager->ShouldBlockRequest(request_one_info, is_incognito_context));
- EXPECT_EQ(
- (mask & kEnableRulesetTwo) != 0,
- manager->ShouldBlockRequest(request_two_info, is_incognito_context));
- EXPECT_FALSE(
- manager->ShouldBlockRequest(request_three_info, is_incognito_context));
+ EXPECT_EQ((mask & kEnableRulesetOne) != 0,
+ should_block_request(request_one_info));
+ EXPECT_EQ((mask & kEnableRulesetTwo) != 0,
+ should_block_request(request_two_info));
+ EXPECT_FALSE(should_block_request(request_three_info));
// Remove the rulesets.
if (mask & kEnableRulesetOne)
@@ -205,24 +208,30 @@ TEST_P(RulesetManagerTest, IncognitoRequests) {
GetRequestForURL("http://example.com");
WebRequestInfo request_info(request.get());
+ GURL redirect_url;
+
// By default, the extension is disabled in incognito mode. So requests from
// incognito contexts should not be evaluated.
EXPECT_FALSE(util::IsIncognitoEnabled(last_loaded_extension()->id(),
browser_context()));
- EXPECT_FALSE(
- manager->ShouldBlockRequest(request_info, true /*is_incognito_context*/));
- EXPECT_TRUE(manager->ShouldBlockRequest(request_info,
- false /*is_incognito_context*/));
+ EXPECT_EQ(Action::NONE,
+ manager->EvaluateRequest(
+ request_info, true /*is_incognito_context*/, &redirect_url));
+ EXPECT_EQ(Action::BLOCK,
+ manager->EvaluateRequest(
+ request_info, false /*is_incognito_context*/, &redirect_url));
// Enabling the extension in incognito mode, should cause requests from
// incognito contexts to also be evaluated.
SetIncognitoEnabled(last_loaded_extension(), true /*incognito_enabled*/);
EXPECT_TRUE(util::IsIncognitoEnabled(last_loaded_extension()->id(),
browser_context()));
- EXPECT_TRUE(
- manager->ShouldBlockRequest(request_info, true /*is_incognito_context*/));
- EXPECT_TRUE(manager->ShouldBlockRequest(request_info,
- false /*is_incognito_context*/));
+ EXPECT_EQ(Action::BLOCK,
+ manager->EvaluateRequest(
+ request_info, true /*is_incognito_context*/, &redirect_url));
+ EXPECT_EQ(Action::BLOCK,
+ manager->EvaluateRequest(
+ request_info, false /*is_incognito_context*/, &redirect_url));
}
// Test redirect rules.
@@ -250,8 +259,9 @@ TEST_P(RulesetManagerTest, Redirect) {
GetRequestForURL("http://example.com");
request->set_initiator(base::nullopt);
extensions::WebRequestInfo request_info1(request.get());
- EXPECT_TRUE(manager->ShouldRedirectRequest(
- request_info1, is_incognito_context, &redirect_url1));
+ EXPECT_EQ(Action::REDIRECT,
+ manager->EvaluateRequest(request_info1, is_incognito_context,
+ &redirect_url1));
EXPECT_EQ(GURL("http://google.com"), redirect_url1);
// Change the initiator to "xyz.com". It should not be redirected since we
@@ -259,16 +269,18 @@ TEST_P(RulesetManagerTest, Redirect) {
GURL redirect_url2;
request->set_initiator(url::Origin::Create(GURL("http://xyz.com")));
extensions::WebRequestInfo request_info2(request.get());
- EXPECT_FALSE(manager->ShouldRedirectRequest(
- request_info2, is_incognito_context, &redirect_url2));
+ EXPECT_EQ(Action::NONE,
+ manager->EvaluateRequest(request_info2, is_incognito_context,
+ &redirect_url2));
// Change the initiator to "abc.com". It should be redirected since we have
// the required host permissions.
GURL redirect_url3;
request->set_initiator(url::Origin::Create(GURL("http://abc.com")));
extensions::WebRequestInfo request_info3(request.get());
- EXPECT_TRUE(manager->ShouldRedirectRequest(
- request_info3, is_incognito_context, &redirect_url3));
+ EXPECT_EQ(Action::REDIRECT,
+ manager->EvaluateRequest(request_info3, is_incognito_context,
+ &redirect_url3));
EXPECT_EQ(GURL("http://google.com"), redirect_url3);
// Ensure web-socket requests are not redirected.
@@ -276,8 +288,9 @@ TEST_P(RulesetManagerTest, Redirect) {
request = GetRequestForURL("ws://example.com");
request->set_initiator(base::nullopt);
extensions::WebRequestInfo request_info4(request.get());
- EXPECT_FALSE(manager->ShouldRedirectRequest(
- request_info4, is_incognito_context, &redirect_url4));
+ EXPECT_EQ(Action::NONE,
+ manager->EvaluateRequest(request_info4, is_incognito_context,
+ &redirect_url4));
}
// Tests that an extension can't block or redirect resources on the chrome-
@@ -320,48 +333,40 @@ TEST_P(RulesetManagerTest, ExtensionScheme) {
EXPECT_EQ(2u, manager->GetMatcherCountForTest());
- // Ensure that "http://example.com" will be blocked and redirected.
+ // Ensure that "http://example.com" will be blocked (with blocking taking
+ // priority over redirection).
std::unique_ptr<net::URLRequest> request =
GetRequestForURL("http://example.com");
- EXPECT_TRUE(manager->ShouldBlockRequest(WebRequestInfo(request.get()),
- false /*is_incognito_context*/));
GURL redirect_url;
- EXPECT_TRUE(manager->ShouldRedirectRequest(WebRequestInfo(request.get()),
- false /*is_incognito_context*/,
- &redirect_url));
- EXPECT_EQ(GURL("http://google.com"), redirect_url);
+ EXPECT_EQ(Action::BLOCK, manager->EvaluateRequest(
+ WebRequestInfo(request.get()),
+ false /*is_incognito_context*/, &redirect_url));
// Ensure that the background page for |extension_1| won't be blocked or
// redirected.
GURL background_page_url_1 = BackgroundInfo::GetBackgroundURL(extension_1);
EXPECT_TRUE(!background_page_url_1.is_empty());
request = GetRequestForURL(background_page_url_1.spec());
- EXPECT_FALSE(manager->ShouldBlockRequest(WebRequestInfo(request.get()),
- false /*is_incognito_context*/));
- EXPECT_FALSE(manager->ShouldRedirectRequest(WebRequestInfo(request.get()),
- false /*is_incognito_context*/,
- &redirect_url));
+ EXPECT_EQ(Action::NONE, manager->EvaluateRequest(
+ WebRequestInfo(request.get()),
+ false /*is_incognito_context*/, &redirect_url));
// Ensure that the background page for |extension_2| won't be blocked or
// redirected.
GURL background_page_url_2 = BackgroundInfo::GetBackgroundURL(extension_2);
EXPECT_TRUE(!background_page_url_2.is_empty());
request = GetRequestForURL(background_page_url_2.spec());
- EXPECT_FALSE(manager->ShouldBlockRequest(WebRequestInfo(request.get()),
- false /*is_incognito_context*/));
- EXPECT_FALSE(manager->ShouldRedirectRequest(WebRequestInfo(request.get()),
- false /*is_incognito_context*/,
- &redirect_url));
+ EXPECT_EQ(Action::NONE, manager->EvaluateRequest(
+ WebRequestInfo(request.get()),
+ false /*is_incognito_context*/, &redirect_url));
// Also ensure that an arbitrary url on the chrome extension scheme is also
// not blocked or redirected.
request = GetRequestForURL(base::StringPrintf("%s://%s/%s", kExtensionScheme,
"extension_id", "path"));
- EXPECT_FALSE(manager->ShouldBlockRequest(WebRequestInfo(request.get()),
- false /*is_incognito_context*/));
- EXPECT_FALSE(manager->ShouldRedirectRequest(WebRequestInfo(request.get()),
- false /*is_incognito_context*/,
- &redirect_url));
+ EXPECT_EQ(Action::NONE, manager->EvaluateRequest(
+ WebRequestInfo(request.get()),
+ false /*is_incognito_context*/, &redirect_url));
}
INSTANTIATE_TEST_CASE_P(,
diff --git a/chromium/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc b/chromium/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc
index 4b88dec5ca5..c2cdf33f448 100644
--- a/chromium/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc
@@ -12,7 +12,6 @@
#include "base/json/json_file_value_serializer.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/message_loop/message_loop.h"
#include "base/test/values_test_util.h"
#include "base/time/time.h"
#include "base/values.h"
diff --git a/chromium/chrome/browser/extensions/api/desktop_capture/desktop_capture_apitest.cc b/chromium/chrome/browser/extensions/api/desktop_capture/desktop_capture_apitest.cc
index c6c75b48921..66e3efd2644 100644
--- a/chromium/chrome/browser/extensions/api/desktop_capture/desktop_capture_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/desktop_capture/desktop_capture_apitest.cc
@@ -254,7 +254,7 @@ IN_PROC_BROWSER_TEST_F(DesktopCaptureApiTest, MAYBE_ChooseDesktopMedia) {
IN_PROC_BROWSER_TEST_F(DesktopCaptureApiTest, DISABLED_Delegation) {
// Initialize test server.
base::FilePath test_data;
- EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data));
+ EXPECT_TRUE(base::PathService::Get(chrome::DIR_TEST_DATA, &test_data));
embedded_test_server()->ServeFilesFromDirectory(test_data.AppendASCII(
"extensions/api_test/desktop_capture_delegate"));
ASSERT_TRUE(embedded_test_server()->Start());
diff --git a/chromium/chrome/browser/extensions/api/developer_private/developer_private_api.cc b/chromium/chrome/browser/extensions/api/developer_private/developer_private_api.cc
index c7f44caf9f0..ce0daf6bb50 100644
--- a/chromium/chrome/browser/extensions/api/developer_private/developer_private_api.cc
+++ b/chromium/chrome/browser/extensions/api/developer_private/developer_private_api.cc
@@ -46,7 +46,6 @@
#include "chrome/browser/ui/extensions/app_launch_params.h"
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
-#include "chrome/browser/ui/webui/extensions/extension_loader_handler.h"
#include "chrome/common/extensions/api/developer_private.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "chrome/common/pref_names.h"
@@ -81,6 +80,7 @@
#include "extensions/common/feature_switch.h"
#include "extensions/common/install_warning.h"
#include "extensions/common/manifest.h"
+#include "extensions/common/manifest_constants.h"
#include "extensions/common/manifest_handlers/options_page_info.h"
#include "extensions/common/manifest_url_handlers.h"
#include "extensions/common/permissions/permissions_data.h"
@@ -91,6 +91,7 @@
#include "storage/browser/fileapi/file_system_operation.h"
#include "storage/browser/fileapi/file_system_operation_runner.h"
#include "storage/browser/fileapi/isolated_context.h"
+#include "third_party/re2/src/re2/re2.h"
#include "ui/base/l10n/l10n_util.h"
namespace extensions {
@@ -122,6 +123,9 @@ const char kCannotRepairHealthyExtension[] =
"Cannot repair a healthy extension.";
const char kCannotRepairPolicyExtension[] =
"Cannot repair a policy-installed extension.";
+const char kCannotChangeHostPermissions[] =
+ "Cannot change host permissions for the given extension.";
+const char kInvalidHost[] = "Invalid host.";
const char kUnpackedAppsFolder[] = "apps_target";
const char kManifestFile[] = "manifest.json";
@@ -134,10 +138,43 @@ ExtensionService* GetExtensionService(content::BrowserContext* context) {
std::string ReadFileToString(const base::FilePath& path) {
std::string data;
+ // This call can fail, but it doesn't matter for our purposes. If it fails,
+ // we simply return an empty string for the manifest, and ignore it.
ignore_result(base::ReadFileToString(path, &data));
return data;
}
+using GetManifestErrorCallback =
+ base::OnceCallback<void(const base::FilePath& file_path,
+ const std::string& error,
+ size_t line_number,
+ const std::string& manifest)>;
+// Takes in an |error| string and tries to parse it as a manifest error (with
+// line number), asynchronously calling |callback| with the results.
+void GetManifestError(const std::string& error,
+ const base::FilePath& extension_path,
+ GetManifestErrorCallback callback) {
+ size_t line = 0u;
+ size_t column = 0u;
+ std::string regex = base::StringPrintf("%s Line: (\\d+), column: (\\d+), .*",
+ manifest_errors::kManifestParseError);
+ // If this was a JSON parse error, we can highlight the exact line with the
+ // error. Otherwise, we should still display the manifest (for consistency,
+ // reference, and so that if we ever make this really fancy and add an editor,
+ // it's ready).
+ //
+ // This regex call can fail, but if it does, we just don't highlight anything.
+ re2::RE2::FullMatch(error, regex, &line, &column);
+
+ // This will read the manifest and call AddFailure with the read manifest
+ // contents.
+ base::PostTaskWithTraitsAndReplyWithResult(
+ FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_BLOCKING},
+ base::BindOnce(&ReadFileToString,
+ extension_path.Append(kManifestFilename)),
+ base::BindOnce(std::move(callback), extension_path, error, line));
+}
+
bool UserCanModifyExtensionConfiguration(
const Extension* extension,
content::BrowserContext* browser_context,
@@ -396,14 +433,13 @@ void DeveloperPrivateEventRouter::OnAppWindowRemoved(AppWindow* window) {
void DeveloperPrivateEventRouter::OnExtensionCommandAdded(
const std::string& extension_id,
const Command& added_command) {
- BroadcastItemStateChanged(developer::EVENT_TYPE_PREFS_CHANGED,
- extension_id);
+ BroadcastItemStateChanged(developer::EVENT_TYPE_COMMAND_ADDED, extension_id);
}
void DeveloperPrivateEventRouter::OnExtensionCommandRemoved(
const std::string& extension_id,
const Command& removed_command) {
- BroadcastItemStateChanged(developer::EVENT_TYPE_PREFS_CHANGED,
+ BroadcastItemStateChanged(developer::EVENT_TYPE_COMMAND_REMOVED,
extension_id);
}
@@ -610,11 +646,9 @@ ExtensionFunction::ResponseAction DeveloperPrivateAutoUpdateFunction::Run() {
ExtensionUpdater::CheckParams params;
params.fetch_priority = ManifestFetchData::FetchPriority::FOREGROUND;
params.install_immediately = true;
- // TODO(crbug.com/714018): Replace base::BindRepeating with base::BindOnce.
- params.callback =
- base::BindRepeating(&DeveloperPrivateAutoUpdateFunction::OnComplete,
- this /* ref counted */);
- updater->CheckNow(params);
+ params.callback = base::BindOnce(
+ &DeveloperPrivateAutoUpdateFunction::OnComplete, this /* refcounted */);
+ updater->CheckNow(std::move(params));
}
return RespondLater();
}
@@ -834,12 +868,8 @@ DeveloperPrivateUpdateExtensionConfigurationFunction::Run() {
}
if (update.run_on_all_urls) {
ScriptingPermissionsModifier modifier(browser_context(), extension);
- if (!modifier.CanAffectExtension(
- extension->permissions_data()->active_permissions()) &&
- !modifier.HasAffectedExtension()) {
- return RespondNow(
- Error("Cannot modify all urls of extension: " + extension->id()));
- }
+ if (!modifier.CanAffectExtension())
+ return RespondNow(Error(kCannotChangeHostPermissions));
modifier.SetAllowedOnAllUrls(*update.run_on_all_urls);
}
@@ -911,11 +941,10 @@ void DeveloperPrivateReloadFunction::OnLoadFailure(
const std::string& error) {
if (file_path == reloading_extension_path_) {
// Reload failed - create an error to pass back to the extension.
- ExtensionLoaderHandler::GetManifestError(
+ GetManifestError(
error, file_path,
- // TODO(devlin): Update GetManifestError to take a OnceCallback.
- base::BindRepeating(&DeveloperPrivateReloadFunction::OnGotManifestError,
- this)); // Creates a reference.
+ base::BindOnce(&DeveloperPrivateReloadFunction::OnGotManifestError,
+ this)); // Creates a reference.
ClearObservers();
}
}
@@ -1035,7 +1064,7 @@ ExtensionFunction::ResponseAction DeveloperPrivateLoadUnpackedFunction::Run() {
return RespondLater();
}
- if (!ShowPicker(ui::SelectFileDialog::SELECT_FOLDER,
+ if (!ShowPicker(ui::SelectFileDialog::SELECT_EXISTING_FOLDER,
l10n_util::GetStringUTF16(IDS_EXTENSION_LOAD_FROM_DIRECTORY),
ui::SelectFileDialog::FileTypeInfo(),
0 /* file_type_index */)) {
@@ -1077,7 +1106,7 @@ void DeveloperPrivateLoadUnpackedFunction::OnLoadComplete(
return;
}
- ExtensionLoaderHandler::GetManifestError(
+ GetManifestError(
error, file_path,
base::Bind(&DeveloperPrivateLoadUnpackedFunction::OnGotManifestError,
this));
@@ -1878,6 +1907,75 @@ DeveloperPrivateUpdateExtensionCommandFunction::Run() {
return RespondNow(NoArguments());
}
+DeveloperPrivateAddHostPermissionFunction::
+ DeveloperPrivateAddHostPermissionFunction() = default;
+DeveloperPrivateAddHostPermissionFunction::
+ ~DeveloperPrivateAddHostPermissionFunction() = default;
+
+ExtensionFunction::ResponseAction
+DeveloperPrivateAddHostPermissionFunction::Run() {
+ std::unique_ptr<developer::AddHostPermission::Params> params(
+ developer::AddHostPermission::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params);
+
+ GURL host(params->host);
+ if (!host.is_valid() || host.path_piece().length() > 1 || host.has_query() ||
+ host.has_ref()) {
+ return RespondNow(Error(kInvalidHost));
+ }
+
+ const Extension* extension = GetExtensionById(params->extension_id);
+ if (!extension)
+ return RespondNow(Error(kNoSuchExtensionError));
+
+ ScriptingPermissionsModifier scripting_modifier(browser_context(), extension);
+ if (!scripting_modifier.CanAffectExtension())
+ return RespondNow(Error(kCannotChangeHostPermissions));
+
+ // Only grant withheld permissions. This also ensures that we won't grant
+ // any permission for a host that shouldn't be accessible to the extension,
+ // like chrome:-scheme urls.
+ if (!extension->permissions_data()
+ ->withheld_permissions()
+ .HasEffectiveAccessToURL(host)) {
+ return RespondNow(Error("Cannot grant a permission that wasn't withheld."));
+ }
+
+ scripting_modifier.GrantHostPermission(host);
+ return RespondNow(NoArguments());
+}
+
+DeveloperPrivateRemoveHostPermissionFunction::
+ DeveloperPrivateRemoveHostPermissionFunction() = default;
+DeveloperPrivateRemoveHostPermissionFunction::
+ ~DeveloperPrivateRemoveHostPermissionFunction() = default;
+
+ExtensionFunction::ResponseAction
+DeveloperPrivateRemoveHostPermissionFunction::Run() {
+ std::unique_ptr<developer::RemoveHostPermission::Params> params(
+ developer::RemoveHostPermission::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params);
+
+ GURL host(params->host);
+ if (!host.is_valid() || host.path_piece().length() > 1 || host.has_query() ||
+ host.has_ref()) {
+ return RespondNow(Error(kInvalidHost));
+ }
+
+ const Extension* extension = GetExtensionById(params->extension_id);
+ if (!extension)
+ return RespondNow(Error(kNoSuchExtensionError));
+
+ ScriptingPermissionsModifier scripting_modifier(browser_context(), extension);
+ if (!scripting_modifier.CanAffectExtension())
+ return RespondNow(Error(kCannotChangeHostPermissions));
+
+ if (!scripting_modifier.HasGrantedHostPermission(host))
+ return RespondNow(Error("Cannot remove a host that hasn't been granted."));
+
+ scripting_modifier.RemoveGrantedHostPermission(host);
+ return RespondNow(NoArguments());
+}
} // namespace api
diff --git a/chromium/chrome/browser/extensions/api/developer_private/developer_private_api.h b/chromium/chrome/browser/extensions/api/developer_private/developer_private_api.h
index 11767ee4130..e1fb6581e13 100644
--- a/chromium/chrome/browser/extensions/api/developer_private/developer_private_api.h
+++ b/chromium/chrome/browser/extensions/api/developer_private/developer_private_api.h
@@ -753,6 +753,36 @@ class DeveloperPrivateUpdateExtensionCommandFunction
ResponseAction Run() override;
};
+class DeveloperPrivateAddHostPermissionFunction
+ : public DeveloperPrivateAPIFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("developerPrivate.addHostPermission",
+ DEVELOPERPRIVATE_ADDHOSTPERMISSION);
+ DeveloperPrivateAddHostPermissionFunction();
+
+ private:
+ ~DeveloperPrivateAddHostPermissionFunction() override;
+
+ ResponseAction Run() override;
+
+ DISALLOW_COPY_AND_ASSIGN(DeveloperPrivateAddHostPermissionFunction);
+};
+
+class DeveloperPrivateRemoveHostPermissionFunction
+ : public DeveloperPrivateAPIFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("developerPrivate.removeHostPermission",
+ DEVELOPERPRIVATE_REMOVEHOSTPERMISSION);
+ DeveloperPrivateRemoveHostPermissionFunction();
+
+ private:
+ ~DeveloperPrivateRemoveHostPermissionFunction() override;
+
+ ResponseAction Run() override;
+
+ DISALLOW_COPY_AND_ASSIGN(DeveloperPrivateRemoveHostPermissionFunction);
+};
+
} // namespace api
} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc b/chromium/chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc
index 5fcb562cce6..5f3a822df78 100644
--- a/chromium/chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc
@@ -11,6 +11,7 @@
#include "base/macros.h"
#include "base/scoped_observer.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/test/scoped_feature_list.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/chrome_test_extension_loader.h"
#include "chrome/browser/extensions/error_console/error_console.h"
@@ -53,8 +54,8 @@
#include "extensions/browser/test_extension_registry_observer.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
+#include "extensions/common/extension_features.h"
#include "extensions/common/extension_set.h"
-#include "extensions/common/feature_switch.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/value_builder.h"
#include "extensions/test/test_extension_dir.h"
@@ -70,6 +71,8 @@ namespace extensions {
namespace {
const char kGoodCrx[] = "ldnnhddmnhbkjipkidpdiheffobcpfmf";
+constexpr char kInvalidHost[] = "invalid host";
+constexpr char kInvalidHostError[] = "Invalid host.";
std::unique_ptr<KeyedService> BuildAPI(content::BrowserContext* context) {
return std::make_unique<DeveloperPrivateAPI>(context);
@@ -299,9 +302,7 @@ void DeveloperPrivateApiUnitTest::UpdateProfileConfigurationDevMode(
new api::DeveloperPrivateUpdateProfileConfigurationFunction());
std::unique_ptr<base::ListValue> args =
ListBuilder()
- .Append(DictionaryBuilder()
- .SetBoolean("inDeveloperMode", dev_mode)
- .Build())
+ .Append(DictionaryBuilder().Set("inDeveloperMode", dev_mode).Build())
.Build();
EXPECT_TRUE(RunFunction(function, *args)) << function->GetError();
}
@@ -360,13 +361,16 @@ void DeveloperPrivateApiUnitTest::TearDown() {
// Test developerPrivate.updateExtensionConfiguration.
TEST_F(DeveloperPrivateApiUnitTest,
DeveloperPrivateUpdateExtensionConfiguration) {
- FeatureSwitch::ScopedOverride scripts_require_action(
- FeatureSwitch::scripts_require_action(), true);
+ base::test::ScopedFeatureList scoped_feature_list;
+ scoped_feature_list.InitAndEnableFeature(features::kRuntimeHostPermissions);
// Sadly, we need a "real" directory here, because toggling prefs causes
// a reload (which needs a path).
const Extension* extension = LoadUnpackedExtension();
const std::string& id = extension->id();
+ ScriptingPermissionsModifier(profile(), base::WrapRefCounted(extension))
+ .SetAllowedOnAllUrls(false);
+
TestExtensionPrefSetting(
base::Bind(&HasPrefsPermission, &util::IsIncognitoEnabled, profile(), id),
"incognitoAccess", id);
@@ -402,13 +406,15 @@ TEST_F(DeveloperPrivateApiUnitTest, DeveloperPrivatePackFunction) {
// Use a temp dir isolating the extension dir and its generated files.
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- base::FilePath root_path = data_dir().AppendASCII("good_unpacked");
+ base::FilePath root_path = data_dir().AppendASCII("simple_with_popup");
ASSERT_TRUE(base::CopyDirectory(root_path, temp_dir.GetPath(), true));
base::FilePath temp_root_path =
temp_dir.GetPath().Append(root_path.BaseName());
- base::FilePath crx_path = temp_dir.GetPath().AppendASCII("good_unpacked.crx");
- base::FilePath pem_path = temp_dir.GetPath().AppendASCII("good_unpacked.pem");
+ base::FilePath crx_path =
+ temp_dir.GetPath().AppendASCII("simple_with_popup.crx");
+ base::FilePath pem_path =
+ temp_dir.GetPath().AppendASCII("simple_with_popup.pem");
EXPECT_FALSE(base::PathExists(crx_path))
<< "crx should not exist before the test is run!";
@@ -453,7 +459,8 @@ TEST_F(DeveloperPrivateApiUnitTest, DeveloperPrivateChoosePath) {
std::unique_ptr<content::WebContents> web_contents(
content::WebContentsTester::CreateTestWebContents(profile(), nullptr));
- base::FilePath expected_dir_path = data_dir().AppendASCII("good_unpacked");
+ base::FilePath expected_dir_path =
+ data_dir().AppendASCII("simple_with_popup");
api::EntryPicker::SkipPickerAndAlwaysSelectPathForTest(&expected_dir_path);
// Try selecting a directory.
@@ -471,7 +478,7 @@ TEST_F(DeveloperPrivateApiUnitTest, DeveloperPrivateChoosePath) {
// Try selecting a pem file.
base::FilePath expected_file_path =
- data_dir().AppendASCII("good_unpacked.pem");
+ data_dir().AppendASCII("simple_with_popup.pem");
api::EntryPicker::SkipPickerAndAlwaysSelectPathForTest(&expected_file_path);
choose_args.Clear();
choose_args.AppendString("FILE");
@@ -496,7 +503,7 @@ TEST_F(DeveloperPrivateApiUnitTest, DeveloperPrivateLoadUnpacked) {
std::unique_ptr<content::WebContents> web_contents(
content::WebContentsTester::CreateTestWebContents(profile(), nullptr));
- base::FilePath path = data_dir().AppendASCII("good_unpacked");
+ base::FilePath path = data_dir().AppendASCII("simple_with_popup");
api::EntryPicker::SkipPickerAndAlwaysSelectPathForTest(&path);
// Try loading a good extension (it should succeed, and the extension should
@@ -1144,7 +1151,7 @@ TEST_F(DeveloperPrivateApiUnitTest, RepairPolicyExtension) {
}
// Test developerPrivate.updateProfileConfiguration: Try to turn on devMode
-// when DeveloperToolsDisabled policy is active.
+// when DeveloperToolsAvailability policy disallows developer tools.
TEST_F(DeveloperPrivateApiUnitTest, DeveloperPrivateDevModeDisabledPolicy) {
testing_pref_service()->SetManagedPref(prefs::kExtensionsUIDeveloperMode,
std::make_unique<base::Value>(false));
@@ -1161,7 +1168,7 @@ TEST_F(DeveloperPrivateApiUnitTest, DeveloperPrivateDevModeDisabledPolicy) {
}
// Test developerPrivate.updateProfileConfiguration: Try to turn on devMode
-// (without DeveloperToolsDisabled policy).
+// (without DeveloperToolsAvailability policy).
TEST_F(DeveloperPrivateApiUnitTest, DeveloperPrivateDevMode) {
UpdateProfileConfigurationDevMode(false);
EXPECT_FALSE(
@@ -1188,7 +1195,7 @@ TEST_F(DeveloperPrivateApiUnitTest, LoadUnpackedFailsWithoutDevMode) {
std::unique_ptr<content::WebContents> web_contents(
content::WebContentsTester::CreateTestWebContents(profile(), nullptr));
- base::FilePath path = data_dir().AppendASCII("good_unpacked");
+ base::FilePath path = data_dir().AppendASCII("simple_with_popup");
api::EntryPicker::SkipPickerAndAlwaysSelectPathForTest(&path);
PrefService* prefs = profile()->GetPrefs();
@@ -1206,7 +1213,7 @@ TEST_F(DeveloperPrivateApiUnitTest, LoadUnpackedFailsWithBlacklistingPolicy) {
std::unique_ptr<content::WebContents> web_contents(
content::WebContentsTester::CreateTestWebContents(profile(), nullptr));
- base::FilePath path = data_dir().AppendASCII("good_unpacked");
+ base::FilePath path = data_dir().AppendASCII("simple_with_popup");
api::EntryPicker::SkipPickerAndAlwaysSelectPathForTest(&path);
{
@@ -1294,6 +1301,98 @@ TEST_F(DeveloperPrivateApiUnitTest, InstallDroppedFileUserScript) {
EXPECT_EQ("My user script", extension->name());
}
+TEST_F(DeveloperPrivateApiUnitTest, GrantHostPermission) {
+ base::test::ScopedFeatureList feature_list;
+ feature_list.InitAndEnableFeature(features::kRuntimeHostPermissions);
+
+ scoped_refptr<const Extension> extension =
+ ExtensionBuilder("test").AddPermission("<all_urls>").Build();
+ service()->AddExtension(extension.get());
+ ScriptingPermissionsModifier modifier(profile(), extension.get());
+ EXPECT_TRUE(modifier.IsAllowedOnAllUrls());
+ modifier.SetAllowedOnAllUrls(false);
+
+ auto run_add_host_permission = [this, extension](base::StringPiece host,
+ bool should_succeed,
+ const char* expected_error) {
+ SCOPED_TRACE(host);
+ scoped_refptr<UIThreadExtensionFunction> function =
+ base::MakeRefCounted<api::DeveloperPrivateAddHostPermissionFunction>();
+
+ std::string args = base::StringPrintf(R"(["%s", "%s"])",
+ extension->id().c_str(), host.data());
+ if (should_succeed) {
+ EXPECT_TRUE(api_test_utils::RunFunction(function.get(), args, profile()))
+ << function->GetError();
+ } else {
+ EXPECT_EQ(expected_error, api_test_utils::RunFunctionAndReturnError(
+ function.get(), args, profile()));
+ }
+ };
+
+ GURL host("https://example.com");
+ EXPECT_FALSE(modifier.HasGrantedHostPermission(host));
+ run_add_host_permission(host.spec(), true, nullptr);
+
+ run_add_host_permission(kInvalidHost, false, kInvalidHostError);
+ run_add_host_permission("https://example.com/foobar", false,
+ kInvalidHostError);
+ run_add_host_permission("https://example.com/#foobar", false,
+ kInvalidHostError);
+
+ GURL chrome_host("chrome://settings");
+ run_add_host_permission(chrome_host.spec(), false,
+ "Cannot grant a permission that wasn't withheld.");
+ EXPECT_FALSE(modifier.HasGrantedHostPermission(chrome_host));
+}
+
+TEST_F(DeveloperPrivateApiUnitTest, RemoveHostPermission) {
+ base::test::ScopedFeatureList feature_list;
+ feature_list.InitAndEnableFeature(features::kRuntimeHostPermissions);
+
+ scoped_refptr<const Extension> extension =
+ ExtensionBuilder("test").AddPermission("<all_urls>").Build();
+ service()->AddExtension(extension.get());
+ ScriptingPermissionsModifier modifier(profile(), extension.get());
+ EXPECT_TRUE(modifier.IsAllowedOnAllUrls());
+ modifier.SetAllowedOnAllUrls(false);
+
+ auto run_remove_host_permission = [this, extension](
+ base::StringPiece host,
+ bool should_succeed,
+ const char* expected_error) {
+ SCOPED_TRACE(host);
+ scoped_refptr<UIThreadExtensionFunction> function = base::MakeRefCounted<
+ api::DeveloperPrivateRemoveHostPermissionFunction>();
+ std::string args = base::StringPrintf(R"(["%s", "%s"])",
+ extension->id().c_str(), host.data());
+ if (should_succeed) {
+ EXPECT_TRUE(api_test_utils::RunFunction(function.get(), args, profile()))
+ << function->GetError();
+ } else {
+ EXPECT_EQ(expected_error, api_test_utils::RunFunctionAndReturnError(
+ function.get(), args, profile()));
+ }
+ };
+
+ GURL host("https://example.com");
+ run_remove_host_permission(host.spec(), false,
+ "Cannot remove a host that hasn't been granted.");
+
+ modifier.GrantHostPermission(host);
+ EXPECT_TRUE(modifier.HasGrantedHostPermission(host));
+
+ run_remove_host_permission("https://example.com/foobar", false,
+ kInvalidHostError);
+ run_remove_host_permission("https://example.com/#foobar", false,
+ kInvalidHostError);
+ run_remove_host_permission(kInvalidHost, false, kInvalidHostError);
+ EXPECT_TRUE(modifier.HasGrantedHostPermission(host));
+
+ run_remove_host_permission(host.spec(), true, nullptr);
+ EXPECT_FALSE(modifier.HasGrantedHostPermission(host));
+}
+
class DeveloperPrivateZipInstallerUnitTest
: public DeveloperPrivateApiUnitTest {
public:
@@ -1358,7 +1457,7 @@ TEST_F(DeveloperPrivateApiSupervisedUserUnitTest,
std::unique_ptr<content::WebContents> web_contents(
content::WebContentsTester::CreateTestWebContents(profile(), nullptr));
- base::FilePath path = data_dir().AppendASCII("good_unpacked");
+ base::FilePath path = data_dir().AppendASCII("simple_with_popup");
api::EntryPicker::SkipPickerAndAlwaysSelectPathForTest(&path);
ASSERT_TRUE(profile()->IsSupervised());
diff --git a/chromium/chrome/browser/extensions/api/developer_private/developer_private_apitest.cc b/chromium/chrome/browser/extensions/api/developer_private/developer_private_apitest.cc
index aaa7aced75d..570844d39d4 100644
--- a/chromium/chrome/browser/extensions/api/developer_private/developer_private_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/developer_private/developer_private_apitest.cc
@@ -34,7 +34,7 @@ IN_PROC_BROWSER_TEST_F(DeveloperPrivateApiTest, Basics) {
// Tests opening the developer tools for an app window.
IN_PROC_BROWSER_TEST_F(DeveloperPrivateApiTest, InspectAppWindowView) {
base::FilePath dir;
- PathService::Get(chrome::DIR_TEST_DATA, &dir);
+ base::PathService::Get(chrome::DIR_TEST_DATA, &dir);
dir = dir.AppendASCII("extensions")
.AppendASCII("platform_apps")
.AppendASCII("minimal");
@@ -85,7 +85,7 @@ IN_PROC_BROWSER_TEST_F(DeveloperPrivateApiTest, InspectAppWindowView) {
IN_PROC_BROWSER_TEST_F(DeveloperPrivateApiTest, InspectEmbeddedOptionsPage) {
base::FilePath dir;
- PathService::Get(chrome::DIR_TEST_DATA, &dir);
+ base::PathService::Get(chrome::DIR_TEST_DATA, &dir);
// Load an extension that only has an embedded options_ui page.
const Extension* extension = LoadExtension(dir.AppendASCII("extensions")
.AppendASCII("delayed_install")
diff --git a/chromium/chrome/browser/extensions/api/developer_private/extension_info_generator.cc b/chromium/chrome/browser/extensions/api/developer_private/extension_info_generator.cc
index 15b031d88d6..0b0d24d3096 100644
--- a/chromium/chrome/browser/extensions/api/developer_private/extension_info_generator.cc
+++ b/chromium/chrome/browser/extensions/api/developer_private/extension_info_generator.cc
@@ -25,7 +25,6 @@
#include "chrome/browser/extensions/shared_module_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
-#include "chrome/common/chrome_features.h"
#include "chrome/common/extensions/command.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "chrome/common/pref_names.h"
@@ -40,7 +39,6 @@
#include "extensions/browser/path_util.h"
#include "extensions/browser/warning_service.h"
#include "extensions/common/extension_set.h"
-#include "extensions/common/feature_switch.h"
#include "extensions/common/install_warning.h"
#include "extensions/common/manifest.h"
#include "extensions/common/manifest_handlers/background_info.h"
@@ -402,7 +400,8 @@ void ExtensionInfoGenerator::CreateExtensionInfoHelper(
// File access.
ManagementPolicy* management_policy = extension_system_->management_policy();
info->file_access.is_enabled =
- extension.wants_file_access() &&
+ (extension.wants_file_access() ||
+ Manifest::ShouldAlwaysAllowFileAccess(extension.location())) &&
management_policy->UserMayModifySettings(&extension, nullptr);
info->file_access.is_active =
util::AllowFileAccess(extension.id(), browser_context_);
@@ -534,12 +533,9 @@ void ExtensionInfoGenerator::CreateExtensionInfoHelper(
// Runs on all urls.
ScriptingPermissionsModifier permissions_modifier(
browser_context_, base::WrapRefCounted(&extension));
- info->run_on_all_urls.is_enabled =
- (FeatureSwitch::scripts_require_action()->IsEnabled() &&
- permissions_modifier.CanAffectExtension(
- extension.permissions_data()->active_permissions())) ||
- permissions_modifier.HasAffectedExtension();
- info->run_on_all_urls.is_active = permissions_modifier.IsAllowedOnAllUrls();
+ info->run_on_all_urls.is_enabled = permissions_modifier.CanAffectExtension();
+ info->run_on_all_urls.is_active = info->run_on_all_urls.is_enabled &&
+ permissions_modifier.IsAllowedOnAllUrls();
// Runtime warnings.
std::vector<std::string> warnings =
@@ -599,37 +595,16 @@ const std::string& ExtensionInfoGenerator::GetDefaultIconUrl(
if (str->empty()) {
*str = GetIconUrlFromImage(
ui::ResourceBundle::GetSharedInstance().GetImageNamed(
- is_app ? IDR_APP_DEFAULT_ICON : IDR_EXTENSION_DEFAULT_ICON),
- is_greyscale);
+ is_app ? IDR_APP_DEFAULT_ICON : IDR_EXTENSION_DEFAULT_ICON));
}
return *str;
}
std::string ExtensionInfoGenerator::GetIconUrlFromImage(
- const gfx::Image& image,
- bool should_greyscale) {
- // Ignore |should_greyscale| if MD Extensions are enabled.
- // TODO(dpapad): Remove should_greyscale logic once non-MD Extensions UI is
- // removed.
- should_greyscale =
- should_greyscale &&
- !base::FeatureList::IsEnabled(features::kMaterialDesignExtensions);
-
+ const gfx::Image& image) {
scoped_refptr<base::RefCountedMemory> data;
- if (should_greyscale) {
- color_utils::HSL shift = {-1, 0, 0.6};
- const SkBitmap* bitmap = image.ToSkBitmap();
- DCHECK(bitmap);
- SkBitmap grey = SkBitmapOperations::CreateHSLShiftedBitmap(*bitmap, shift);
- scoped_refptr<base::RefCountedBytes> image_bytes(
- new base::RefCountedBytes());
- gfx::PNGCodec::EncodeBGRASkBitmap(grey, false, &image_bytes->data());
- data = image_bytes;
- } else {
- data = image.As1xPNGBytes();
- }
-
+ data = image.As1xPNGBytes();
std::string base_64;
base::Base64Encode(base::StringPiece(data->front_as<char>(), data->size()),
&base_64);
@@ -641,8 +616,7 @@ void ExtensionInfoGenerator::OnImageLoaded(
std::unique_ptr<developer::ExtensionInfo> info,
const gfx::Image& icon) {
if (!icon.IsEmpty()) {
- info->icon_url = GetIconUrlFromImage(
- icon, info->state != developer::EXTENSION_STATE_ENABLED);
+ info->icon_url = GetIconUrlFromImage(icon);
} else {
bool is_app =
info->type == developer::EXTENSION_TYPE_HOSTED_APP ||
diff --git a/chromium/chrome/browser/extensions/api/developer_private/extension_info_generator.h b/chromium/chrome/browser/extensions/api/developer_private/extension_info_generator.h
index 8fb11cc4305..84628f86bd8 100644
--- a/chromium/chrome/browser/extensions/api/developer_private/extension_info_generator.h
+++ b/chromium/chrome/browser/extensions/api/developer_private/extension_info_generator.h
@@ -69,9 +69,8 @@ class ExtensionInfoGenerator {
// Returns the icon url for the default icon to use.
const std::string& GetDefaultIconUrl(bool is_app, bool is_disabled);
- // Returns an icon url from the given image, optionally applying a greyscale.
- std::string GetIconUrlFromImage(const gfx::Image& image,
- bool should_greyscale);
+ // Returns an icon url from the given image.
+ std::string GetIconUrlFromImage(const gfx::Image& image);
// Various systems, cached for convenience.
content::BrowserContext* browser_context_;
diff --git a/chromium/chrome/browser/extensions/api/developer_private/extension_info_generator_unittest.cc b/chromium/chrome/browser/extensions/api/developer_private/extension_info_generator_unittest.cc
index eac82c44d0b..7e371c03d6d 100644
--- a/chromium/chrome/browser/extensions/api/developer_private/extension_info_generator_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/developer_private/extension_info_generator_unittest.cc
@@ -15,6 +15,7 @@
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/api/developer_private/inspectable_views_finder.h"
#include "chrome/browser/extensions/chrome_test_extension_loader.h"
@@ -32,6 +33,7 @@
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
+#include "extensions/common/extension_features.h"
#include "extensions/common/feature_switch.h"
#include "extensions/common/permissions/permission_message.h"
#include "extensions/common/permissions/permissions_data.h"
@@ -253,7 +255,7 @@ TEST_F(ExtensionInfoGeneratorUnitTest, BasicInfoTest) {
base::UTF8ToUTF16("message"),
StackTrace(1, StackFrame(1, 1, base::UTF8ToUTF16("source"),
base::UTF8ToUTF16("function"))),
- kContextUrl, logging::LOG_VERBOSE, 1, 1));
+ kContextUrl, logging::LOG_WARNING, 1, 1));
// It's not feasible to validate every field here, because that would be
// a duplication of the logic in the method itself. Instead, test a handful
@@ -301,7 +303,7 @@ TEST_F(ExtensionInfoGeneratorUnitTest, BasicInfoTest) {
ASSERT_EQ(1u, info->manifest_errors.size());
const api::developer_private::RuntimeError& runtime_error_verbose =
info->runtime_errors[1];
- EXPECT_EQ(api::developer_private::ERROR_LEVEL_LOG,
+ EXPECT_EQ(api::developer_private::ERROR_LEVEL_WARN,
runtime_error_verbose.severity);
const api::developer_private::ManifestError& manifest_error =
info->manifest_errors[0];
@@ -390,9 +392,9 @@ TEST_F(ExtensionInfoGeneratorUnitTest, GenerateExtensionsJSONData) {
// urls, and only when the switch is on.
TEST_F(ExtensionInfoGeneratorUnitTest, ExtensionInfoRunOnAllUrls) {
// Start with the switch enabled.
- std::unique_ptr<FeatureSwitch::ScopedOverride> enable_scripts_switch(
- new FeatureSwitch::ScopedOverride(FeatureSwitch::scripts_require_action(),
- true));
+ auto scoped_feature_list = std::make_unique<base::test::ScopedFeatureList>();
+ scoped_feature_list->InitAndEnableFeature(features::kRuntimeHostPermissions);
+
// Two extensions - one with all urls, one without.
scoped_refptr<const Extension> all_urls_extension = CreateExtension(
"all_urls", ListBuilder().Append(kAllHostsPermission).Build(),
@@ -403,55 +405,31 @@ TEST_F(ExtensionInfoGeneratorUnitTest, ExtensionInfoRunOnAllUrls) {
std::unique_ptr<developer::ExtensionInfo> info =
GenerateExtensionInfo(all_urls_extension->id());
- // The extension should want all urls, but not currently have it.
+ // The extension should want all urls, and have it currently granted.
EXPECT_TRUE(info->run_on_all_urls.is_enabled);
- EXPECT_FALSE(info->run_on_all_urls.is_active);
+ EXPECT_TRUE(info->run_on_all_urls.is_active);
- // Give the extension all urls.
+ // Revoke the all urls permission.
ScriptingPermissionsModifier permissions_modifier(profile(),
all_urls_extension);
- permissions_modifier.SetAllowedOnAllUrls(true);
+ permissions_modifier.SetAllowedOnAllUrls(false);
- // Now the extension should both want and have all urls.
+ // Now the extension want all urls, but not have it granted.
info = GenerateExtensionInfo(all_urls_extension->id());
EXPECT_TRUE(info->run_on_all_urls.is_enabled);
- EXPECT_TRUE(info->run_on_all_urls.is_active);
+ EXPECT_FALSE(info->run_on_all_urls.is_active);
// The other extension should neither want nor have all urls.
info = GenerateExtensionInfo(no_urls_extension->id());
EXPECT_FALSE(info->run_on_all_urls.is_enabled);
EXPECT_FALSE(info->run_on_all_urls.is_active);
- // Revoke the first extension's permissions.
- permissions_modifier.SetAllowedOnAllUrls(false);
-
- // Turn off the switch and load another extension (so permissions are
- // re-initialized).
- enable_scripts_switch.reset();
-
- // Since the extension doesn't have access to all urls (but normally would),
- // the extension should have the "want" flag even with the switch off.
- info = GenerateExtensionInfo(all_urls_extension->id());
- EXPECT_TRUE(info->run_on_all_urls.is_enabled);
- EXPECT_FALSE(info->run_on_all_urls.is_active);
-
- // If we grant the extension all urls, then the checkbox should still be
- // there, since it has an explicitly-set user preference.
- permissions_modifier.SetAllowedOnAllUrls(true);
- info = GenerateExtensionInfo(all_urls_extension->id());
- EXPECT_TRUE(info->run_on_all_urls.is_enabled);
- EXPECT_TRUE(info->run_on_all_urls.is_active);
-
- // Load another extension with all urls (so permissions get re-init'd).
- all_urls_extension = CreateExtension(
- "all_urls_II", ListBuilder().Append(kAllHostsPermission).Build(),
- Manifest::INTERNAL);
-
- // Even though the extension has all_urls permission, the checkbox shouldn't
- // show up without the switch.
+ // Turn off the switch. With the switch off, the run_on_all_urls control
+ // should never be enabled.
+ scoped_feature_list.reset();
info = GenerateExtensionInfo(all_urls_extension->id());
EXPECT_FALSE(info->run_on_all_urls.is_enabled);
- EXPECT_TRUE(info->run_on_all_urls.is_active);
+ EXPECT_FALSE(info->run_on_all_urls.is_active);
}
// Test that file:// access checkbox does not show up when the user can't
@@ -472,6 +450,20 @@ TEST_F(ExtensionInfoGeneratorUnitTest, ExtensionInfoLockedAllUrls) {
EXPECT_FALSE(info->file_access.is_active);
}
+// Tests that file:// access checkbox shows up for extensions with activeTab
+// permission. See crbug.com/850643.
+TEST_F(ExtensionInfoGeneratorUnitTest, ActiveTabFileUrls) {
+ scoped_refptr<const Extension> extension =
+ CreateExtension("activeTab", ListBuilder().Append("activeTab").Build(),
+ Manifest::INTERNAL);
+ std::unique_ptr<developer::ExtensionInfo> info =
+ GenerateExtensionInfo(extension->id());
+
+ EXPECT_TRUE(extension->wants_file_access());
+ EXPECT_TRUE(info->file_access.is_enabled);
+ EXPECT_FALSE(info->file_access.is_active);
+}
+
// Tests that blacklisted extensions are returned by the ExtensionInfoGenerator.
TEST_F(ExtensionInfoGeneratorUnitTest, Blacklisted) {
const scoped_refptr<const Extension> extension1 = CreateExtension(
diff --git a/chromium/chrome/browser/extensions/api/downloads/downloads_api.cc b/chromium/chrome/browser/extensions/api/downloads/downloads_api.cc
index b09f914f0ca..7d33e085088 100644
--- a/chromium/chrome/browser/extensions/api/downloads/downloads_api.cc
+++ b/chromium/chrome/browser/extensions/api/downloads/downloads_api.cc
@@ -24,7 +24,7 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/memory/weak_ptr.h"
-#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_loop_current.h"
#include "base/metrics/histogram_macros.h"
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
@@ -41,6 +41,7 @@
#include "chrome/browser/download/download_core_service_factory.h"
#include "chrome/browser/download/download_danger_prompt.h"
#include "chrome/browser/download/download_file_icon_extractor.h"
+#include "chrome/browser/download/download_open_prompt.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/download/download_query.h"
#include "chrome/browser/download/download_shelf.h"
@@ -149,6 +150,7 @@ const char kDangerKey[] = "danger";
const char kDangerSafe[] = "safe";
const char kDangerUncommon[] = "uncommon";
const char kDangerUnwanted[] = "unwanted";
+const char kDangerWhitelistedByPolicy[] = "whitelistedByPolicy";
const char kDangerUrl[] = "url";
const char kEndTimeKey[] = "endTime";
const char kEndedAfterKey[] = "endedAfter";
@@ -183,16 +185,11 @@ const char kFinalUrlRegexKey[] = "finalUrlRegex";
// Note: Any change to the danger type strings, should be accompanied by a
// corresponding change to downloads.json.
const char* const kDangerStrings[] = {
- kDangerSafe,
- kDangerFile,
- kDangerUrl,
- kDangerContent,
- kDangerSafe,
- kDangerUncommon,
- kDangerAccepted,
- kDangerHost,
- kDangerUnwanted
-};
+ kDangerSafe, kDangerFile,
+ kDangerUrl, kDangerContent,
+ kDangerSafe, kDangerUncommon,
+ kDangerAccepted, kDangerHost,
+ kDangerUnwanted, kDangerWhitelistedByPolicy};
static_assert(arraysize(kDangerStrings) == download::DOWNLOAD_DANGER_TYPE_MAX,
"kDangerStrings should have DOWNLOAD_DANGER_TYPE_MAX elements");
@@ -636,7 +633,11 @@ class ExtensionDownloadsEventRouterData : public base::SupportsUserData::Data {
json_(std::move(json_item)),
creator_conflict_action_(downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY),
determined_conflict_action_(
- downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY) {
+ downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY),
+ is_download_completed_(download_item->GetState() ==
+ DownloadItem::COMPLETE),
+ is_completed_download_deleted_(
+ download_item->GetFileExternallyRemoved()) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
download_item->SetUserData(kKey, base::WrapUnique(this));
}
@@ -648,6 +649,16 @@ class ExtensionDownloadsEventRouterData : public base::SupportsUserData::Data {
}
}
+ void set_is_download_completed(bool is_download_completed) {
+ is_download_completed_ = is_download_completed;
+ }
+ void set_is_completed_download_deleted(bool is_completed_download_deleted) {
+ is_completed_download_deleted_ = is_completed_download_deleted;
+ }
+ bool is_download_completed() { return is_download_completed_; }
+ bool is_completed_download_deleted() {
+ return is_completed_download_deleted_;
+ }
const base::DictionaryValue& json() const { return *json_; }
void set_json(std::unique_ptr<base::DictionaryValue> json_item) {
json_ = std::move(json_item);
@@ -869,6 +880,8 @@ class ExtensionDownloadsEventRouterData : public base::SupportsUserData::Data {
int updated_;
int changed_fired_;
+ // Dictionary representing the current state of the download. It is cleared
+ // when download completes.
std::unique_ptr<base::DictionaryValue> json_;
base::Closure filename_no_change_;
@@ -884,6 +897,11 @@ class ExtensionDownloadsEventRouterData : public base::SupportsUserData::Data {
determined_conflict_action_;
DeterminerInfo determiner_;
+ // Whether a download is complete and whether the completed download is
+ // deleted.
+ bool is_download_completed_;
+ bool is_completed_download_deleted_;
+
std::unique_ptr<base::WeakPtrFactory<ExtensionDownloadsEventRouterData>>
weak_ptr_factory_;
@@ -1410,6 +1428,9 @@ ExtensionFunction::ResponseAction DownloadsShowDefaultFolderFunction::Run() {
return RespondNow(NoArguments());
}
+DownloadsOpenFunction::OnPromptCreatedCallback*
+ DownloadsOpenFunction::on_prompt_created_cb_ = nullptr;
+
DownloadsOpenFunction::DownloadsOpenFunction() {}
DownloadsOpenFunction::~DownloadsOpenFunction() {}
@@ -1430,9 +1451,48 @@ ExtensionFunction::ResponseAction DownloadsOpenFunction::Run() {
errors::kOpenPermission, &error)) {
return RespondNow(Error(error));
}
- download_item->OpenDownload();
+ Browser* browser = ChromeExtensionFunctionDetails(this).GetCurrentBrowser();
+ if (Fault(!browser, errors::kInvisibleContext, &error))
+ return RespondNow(Error(error));
+ content::WebContents* web_contents =
+ browser->tab_strip_model()->GetActiveWebContents();
+ if (Fault(!web_contents, errors::kInvisibleContext, &error))
+ return RespondNow(Error(error));
+ if (GetSenderWebContents() &&
+ GetSenderWebContents()->HasRecentInteractiveInputEvent()) {
+ download_item->OpenDownload();
+ return RespondNow(NoArguments());
+ }
+ // Prompt user for ack to open the download.
+ // TODO(qinmin): check if user prefers to open all download using the same
+ // extension, or check the recent user gesture on the originating webcontents
+ // to avoid showing the prompt.
+ DownloadOpenPrompt* download_open_prompt =
+ DownloadOpenPrompt::CreateDownloadOpenConfirmationDialog(
+ web_contents, extension()->name(), download_item->GetFullPath(),
+ base::BindOnce(&DownloadsOpenFunction::OpenPromptDone, this,
+ params->download_id));
+ if (on_prompt_created_cb_)
+ std::move(*on_prompt_created_cb_).Run(download_open_prompt);
RecordApiFunctions(DOWNLOADS_FUNCTION_OPEN);
- return RespondNow(NoArguments());
+ return RespondLater();
+}
+
+void DownloadsOpenFunction::OpenPromptDone(int download_id, bool accept) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ std::string error;
+ if (Fault(!accept, errors::kOpenPermission, &error)) {
+ Respond(Error(error));
+ return;
+ }
+ DownloadItem* download_item =
+ GetDownload(browser_context(), include_incognito(), download_id);
+ if (Fault(!download_item, errors::kFileAlreadyDeleted, &error)) {
+ Respond(Error(error));
+ return;
+ }
+ download_item->OpenDownload();
+ Respond(NoArguments());
}
DownloadsDragFunction::DownloadsDragFunction() {}
@@ -1458,8 +1518,7 @@ ExtensionFunction::ResponseAction DownloadsDragFunction::Run() {
gfx::NativeView view = web_contents->GetNativeView();
{
// Enable nested tasks during DnD, while |DragDownload()| blocks.
- base::MessageLoop::ScopedNestableTaskAllower allow(
- base::MessageLoop::current());
+ base::MessageLoopCurrent::ScopedNestableTaskAllower allow;
DragDownloadItem(download_item, icon, view);
}
return RespondNow(NoArguments());
@@ -1827,6 +1886,9 @@ void ExtensionDownloadsEventRouter::OnDownloadCreated(
downloads::OnDeterminingFilename::kEventName))) {
return;
}
+
+ // download_item->GetFileExternallyRemoved() should always return false for
+ // unfinished download.
std::unique_ptr<base::DictionaryValue> json_item(
DownloadItemToJSON(download_item, profile_));
DispatchEvent(events::DOWNLOADS_ON_CREATED, downloads::OnCreated::kEventName,
@@ -1836,7 +1898,10 @@ void ExtensionDownloadsEventRouter::OnDownloadCreated(
(router->HasEventListener(downloads::OnChanged::kEventName) ||
router->HasEventListener(
downloads::OnDeterminingFilename::kEventName))) {
- new ExtensionDownloadsEventRouterData(download_item, std::move(json_item));
+ new ExtensionDownloadsEventRouterData(
+ download_item, download_item->GetState() == DownloadItem::COMPLETE
+ ? nullptr
+ : std::move(json_item));
}
}
@@ -1857,44 +1922,65 @@ void ExtensionDownloadsEventRouter::OnDownloadUpdated(
download_item,
std::unique_ptr<base::DictionaryValue>(new base::DictionaryValue()));
}
- std::unique_ptr<base::DictionaryValue> new_json(
- DownloadItemToJSON(download_item, profile_));
+ std::unique_ptr<base::DictionaryValue> new_json;
std::unique_ptr<base::DictionaryValue> delta(new base::DictionaryValue());
delta->SetInteger(kIdKey, download_item->GetId());
- std::set<std::string> new_fields;
bool changed = false;
+ // For completed downloads, update can only happen when file is removed.
+ if (data->is_download_completed()) {
+ if (data->is_completed_download_deleted() !=
+ download_item->GetFileExternallyRemoved()) {
+ DCHECK(!data->is_completed_download_deleted());
+ DCHECK(download_item->GetFileExternallyRemoved());
+ std::string exists = kExistsKey;
+ delta->SetBoolean(exists + ".current", false);
+ delta->SetBoolean(exists + ".previous", true);
+ changed = true;
+ }
+ } else {
+ new_json = DownloadItemToJSON(download_item, profile_);
+ std::set<std::string> new_fields;
+ // For each field in the new json representation of the download_item except
+ // the bytesReceived field, if the field has changed from the previous old
+ // json, set the differences in the |delta| object and remember that
+ // something significant changed.
+ for (base::DictionaryValue::Iterator iter(*new_json); !iter.IsAtEnd();
+ iter.Advance()) {
+ new_fields.insert(iter.key());
+ if (IsDownloadDeltaField(iter.key())) {
+ const base::Value* old_value = NULL;
+ if (!data->json().HasKey(iter.key()) ||
+ (data->json().Get(iter.key(), &old_value) &&
+ !iter.value().Equals(old_value))) {
+ delta->Set(iter.key() + ".current", iter.value().CreateDeepCopy());
+ if (old_value)
+ delta->Set(iter.key() + ".previous", old_value->CreateDeepCopy());
+ changed = true;
+ }
+ }
+ }
- // For each field in the new json representation of the download_item except
- // the bytesReceived field, if the field has changed from the previous old
- // json, set the differences in the |delta| object and remember that something
- // significant changed.
- for (base::DictionaryValue::Iterator iter(*new_json); !iter.IsAtEnd();
- iter.Advance()) {
- new_fields.insert(iter.key());
- if (IsDownloadDeltaField(iter.key())) {
- const base::Value* old_value = NULL;
- if (!data->json().HasKey(iter.key()) ||
- (data->json().Get(iter.key(), &old_value) &&
- !iter.value().Equals(old_value))) {
- delta->Set(iter.key() + ".current", iter.value().CreateDeepCopy());
- if (old_value)
- delta->Set(iter.key() + ".previous", old_value->CreateDeepCopy());
+ // If a field was in the previous json but is not in the new json, set the
+ // difference in |delta|.
+ for (base::DictionaryValue::Iterator iter(data->json()); !iter.IsAtEnd();
+ iter.Advance()) {
+ if ((new_fields.find(iter.key()) == new_fields.end()) &&
+ IsDownloadDeltaField(iter.key())) {
+ // estimatedEndTime disappears after completion, but bytesReceived
+ // stays.
+ delta->Set(iter.key() + ".previous", iter.value().CreateDeepCopy());
changed = true;
}
}
}
- // If a field was in the previous json but is not in the new json, set the
- // difference in |delta|.
- for (base::DictionaryValue::Iterator iter(data->json());
- !iter.IsAtEnd(); iter.Advance()) {
- if ((new_fields.find(iter.key()) == new_fields.end()) &&
- IsDownloadDeltaField(iter.key())) {
- // estimatedEndTime disappears after completion, but bytesReceived stays.
- delta->Set(iter.key() + ".previous", iter.value().CreateDeepCopy());
- changed = true;
- }
- }
+ data->set_is_download_completed(download_item->GetState() ==
+ DownloadItem::COMPLETE);
+ // download_item->GetFileExternallyRemoved() should always return false for
+ // unfinished download.
+ data->set_is_completed_download_deleted(
+ download_item->GetFileExternallyRemoved());
+ data->set_json(std::move(new_json));
// Update the OnChangedStat and dispatch the event if something significant
// changed. Replace the stored json with the new json.
@@ -1905,7 +1991,6 @@ void ExtensionDownloadsEventRouter::OnDownloadUpdated(
Event::WillDispatchCallback(), std::move(delta));
data->OnChangedFired();
}
- data->set_json(std::move(new_json));
}
void ExtensionDownloadsEventRouter::OnDownloadRemoved(
diff --git a/chromium/chrome/browser/extensions/api/downloads/downloads_api.h b/chromium/chrome/browser/extensions/api/downloads/downloads_api.h
index cd6e5759ce8..77c386894fc 100644
--- a/chromium/chrome/browser/extensions/api/downloads/downloads_api.h
+++ b/chromium/chrome/browser/extensions/api/downloads/downloads_api.h
@@ -24,6 +24,7 @@
#include "extensions/browser/warning_set.h"
class DownloadFileIconExtractor;
+class DownloadOpenPrompt;
namespace extensions {
class ExtensionRegistry;
@@ -243,10 +244,20 @@ class DownloadsOpenFunction : public UIThreadExtensionFunction {
DownloadsOpenFunction();
ResponseAction Run() override;
+ typedef base::OnceCallback<void(DownloadOpenPrompt*)> OnPromptCreatedCallback;
+ static void set_on_prompt_created_cb_for_testing(
+ OnPromptCreatedCallback* on_prompt_created_cb) {
+ on_prompt_created_cb_ = on_prompt_created_cb;
+ }
+
protected:
~DownloadsOpenFunction() override;
private:
+ void OpenPromptDone(int download_id, bool accept);
+
+ static OnPromptCreatedCallback* on_prompt_created_cb_;
+
DISALLOW_COPY_AND_ASSIGN(DownloadsOpenFunction);
};
diff --git a/chromium/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc b/chromium/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc
index 97f0d633093..67974097916 100644
--- a/chromium/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc
+++ b/chromium/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc
@@ -14,7 +14,7 @@
#include "base/json/json_reader.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
-#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_loop_current.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/test/bind_test_util.h"
@@ -23,6 +23,7 @@
#include "chrome/browser/download/download_core_service.h"
#include "chrome/browser/download/download_core_service_factory.h"
#include "chrome/browser/download/download_file_icon_extractor.h"
+#include "chrome/browser/download/download_open_prompt.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/download/download_test_file_activity_observer.h"
#include "chrome/browser/extensions/api/downloads/downloads_api.h"
@@ -51,6 +52,7 @@
#include "content/public/common/content_features.h"
#include "content/public/test/download_test_observer.h"
#include "content/public/test/test_download_http_response.h"
+#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/notification_types.h"
@@ -85,6 +87,8 @@ const char kFirstDownloadUrl[] = "/download1";
const char kSecondDownloadUrl[] = "/download2";
const int kDownloadSize = 1024 * 10;
+void OnFileDeleted(bool success) {}
+
// Comparator that orders download items by their ID. Can be used with
// std::sort.
struct DownloadIdComparator {
@@ -97,6 +101,16 @@ bool IsDownloadExternallyRemoved(download::DownloadItem* item) {
return item->GetFileExternallyRemoved();
}
+void OnOpenPromptCreated(download::DownloadItem* item,
+ DownloadOpenPrompt* prompt) {
+ EXPECT_FALSE(item->GetOpened());
+ // Posts a task to accept the DownloadOpenPrompt.
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::BindOnce(&DownloadOpenPrompt::AcceptConfirmationDialogForTesting,
+ base::Unretained(prompt)));
+}
+
class DownloadsEventsListener : public content::NotificationObserver {
public:
DownloadsEventsListener()
@@ -245,6 +259,8 @@ class DownloadsEventsListener : public content::NotificationObserver {
return success;
}
+ base::circular_deque<std::unique_ptr<Event>>* events() { return &events_; }
+
private:
bool waiting_;
base::Time last_wait_;
@@ -255,6 +271,44 @@ class DownloadsEventsListener : public content::NotificationObserver {
DISALLOW_COPY_AND_ASSIGN(DownloadsEventsListener);
};
+// Object waiting for a download open event.
+class DownloadOpenObserver : public download::DownloadItem::Observer {
+ public:
+ explicit DownloadOpenObserver(download::DownloadItem* item)
+ : open_observer_(this), item_(item) {
+ open_observer_.Add(item);
+ }
+
+ ~DownloadOpenObserver() override = default;
+
+ void WaitForEvent() {
+ if (item_ && !item_->GetOpened()) {
+ base::RunLoop run_loop;
+ completion_closure_ = run_loop.QuitClosure();
+ run_loop.Run();
+ }
+ }
+
+ private:
+ // download::DownloadItem::Observer
+ void OnDownloadOpened(download::DownloadItem* item) override {
+ if (!completion_closure_.is_null())
+ std::move(completion_closure_).Run();
+ }
+
+ void OnDownloadDestroyed(download::DownloadItem* item) override {
+ open_observer_.Remove(item);
+ item_ = nullptr;
+ }
+
+ ScopedObserver<download::DownloadItem, download::DownloadItem::Observer>
+ open_observer_;
+ download::DownloadItem* item_;
+ base::OnceClosure completion_closure_;
+
+ DISALLOW_COPY_AND_ASSIGN(DownloadOpenObserver);
+};
+
class DownloadExtensionTest : public ExtensionApiTest {
public:
DownloadExtensionTest()
@@ -600,6 +654,8 @@ class DownloadExtensionTest : public ExtensionApiTest {
DownloadsEventsListener* events_listener() { return events_listener_.get(); }
+ const Extension* extension() { return extension_; }
+
private:
void SetUpExtensionFunction(UIThreadExtensionFunction* function) {
if (extension_) {
@@ -860,12 +916,34 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
RunFunctionAndReturnError(
open_function,
DownloadItemIdAsArgList(download_item)).c_str());
+ // RunFunctionAndReturnError() will trigger a navigation. Wait for it to
+ // finish before showing the prompt dialog. Otherwise the dialog will get
+ // automatically closed.
+ content::TestNavigationObserver navigation_observer(
+ browser()->tab_strip_model()->GetActiveWebContents());
+ navigation_observer.WaitForNavigationFinished();
EXPECT_FALSE(download_item->GetOpened());
- open_function = new DownloadsOpenFunction();
- open_function->set_user_gesture(true);
- EXPECT_TRUE(RunFunction(open_function,
- DownloadItemIdAsArgList(download_item)));
+ scoped_refptr<DownloadsOpenFunction> scoped_open(new DownloadsOpenFunction());
+ scoped_open->set_user_gesture(true);
+ base::ListValue list_value;
+ list_value.GetList().emplace_back(static_cast<int>(download_item->GetId()));
+ scoped_open->SetArgs(&list_value);
+ scoped_open->set_browser_context(browser()->profile());
+ scoped_open->set_extension(extension());
+ DownloadsOpenFunction::OnPromptCreatedCallback callback =
+ base::BindOnce(&OnOpenPromptCreated, base::Unretained(download_item));
+ DownloadsOpenFunction::set_on_prompt_created_cb_for_testing(&callback);
+ api_test_utils::SendResponseHelper response_helper(scoped_open.get());
+ std::unique_ptr<ExtensionFunctionDispatcher> dispatcher(
+ new ExtensionFunctionDispatcher(browser()->profile()));
+ scoped_open->set_dispatcher(dispatcher->AsWeakPtr());
+ scoped_open->RunWithValidation()->Execute();
+ response_helper.WaitForResponse();
+ EXPECT_TRUE(response_helper.has_response());
+ EXPECT_TRUE(response_helper.GetResponse());
+ DownloadOpenObserver observer(download_item);
+ observer.WaitForEvent();
EXPECT_TRUE(download_item->GetOpened());
}
@@ -1718,7 +1796,7 @@ class CustomResponse : public net::test_server::HttpResponse {
if (first_request_) {
*callback_ = std::move(done);
- *task_runner_ = base::MessageLoop::current()->task_runner().get();
+ *task_runner_ = base::MessageLoopCurrent::Get()->task_runner().get();
send.Run(response, base::BindRepeating([]() {}));
} else {
send.Run(response, std::move(done));
@@ -4345,6 +4423,52 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
observer->WaitForFinished();
}
+// Test that file deletion event is correctly generated after download
+// completion.
+IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
+ DownloadExtensionTest_DeleteFileAfterCompletion) {
+ ASSERT_TRUE(StartEmbeddedTestServer());
+ GoOnTheRecord();
+ LoadExtension("downloads_split");
+ std::string download_url = embedded_test_server()->GetURL("/slow?0").spec();
+
+ // Start downloading a file.
+ std::unique_ptr<base::Value> result(RunFunctionAndReturnResult(
+ new DownloadsDownloadFunction(),
+ base::StringPrintf("[{\"url\": \"%s\"}]", download_url.c_str())));
+ ASSERT_TRUE(result.get());
+ int result_id = -1;
+ ASSERT_TRUE(result->GetAsInteger(&result_id));
+ DownloadItem* item = GetCurrentManager()->GetDownload(result_id);
+ ASSERT_TRUE(item);
+ ScopedCancellingItem canceller(item);
+ ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
+
+ ASSERT_TRUE(WaitFor(downloads::OnCreated::kEventName,
+ base::StringPrintf(R"([{"danger": "safe",)"
+ R"( "incognito": false,)"
+ R"( "id": %d,)"
+ R"( "mime": "text/plain",)"
+ R"( "paused": false,)"
+ R"( "url": "%s"}])",
+ result_id, download_url.c_str())));
+ ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName,
+ base::StringPrintf(R"([{"id": %d,)"
+ R"( "state": {)"
+ R"( "previous": "in_progress",)"
+ R"( "current": "complete"}}])",
+ result_id)));
+
+ item->DeleteFile(base::BindRepeating(OnFileDeleted));
+
+ ASSERT_TRUE(WaitFor(downloads::OnChanged::kEventName,
+ base::StringPrintf(R"([{"id": %d,)"
+ R"( "exists": {)"
+ R"( "previous": true,)"
+ R"( "current": false}}])",
+ result_id)));
+}
+
class DownloadsApiTest : public ExtensionApiTest {
public:
DownloadsApiTest() {}
diff --git a/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc b/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc
index 6692d07a51f..0a705f95d3e 100644
--- a/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc
+++ b/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.cc
@@ -27,29 +27,28 @@
#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager.h"
#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_factory.h"
#include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_connection_manager.h"
-#include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_crypto_delegate.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/proximity_auth/proximity_auth_error_bubble.h"
#include "chrome/common/extensions/api/easy_unlock_private.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/components/proximity_auth/bluetooth_low_energy_setup_connection_finder.h"
-#include "chromeos/components/proximity_auth/bluetooth_util.h"
#include "chromeos/components/proximity_auth/logging/logging.h"
#include "chromeos/components/proximity_auth/proximity_auth_client.h"
#include "chromeos/components/proximity_auth/screenlock_bridge.h"
#include "chromeos/components/proximity_auth/screenlock_state.h"
#include "chromeos/components/proximity_auth/switches.h"
+#include "components/account_id/account_id.h"
#include "components/cryptauth/cryptauth_device_manager.h"
#include "components/cryptauth/cryptauth_enrollment_manager.h"
#include "components/cryptauth/cryptauth_enrollment_utils.h"
#include "components/cryptauth/proto/cryptauth_api.pb.h"
#include "components/cryptauth/remote_device.h"
#include "components/cryptauth/secure_message_delegate_impl.h"
-#include "components/signin/core/account_id/account_id.h"
#include "components/strings/grit/components_strings.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
+#include "extensions/browser/view_type_utils.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/chromeos/devicetype_utils.h"
#include "ui/gfx/geometry/rect.h"
@@ -67,13 +66,6 @@ static base::LazyInstance<BrowserContextKeyedAPIFactory<EasyUnlockPrivateAPI>>::
DestructorAtExit g_easy_unlock_private_api_factory =
LAZY_INSTANCE_INITIALIZER;
-// Utility method for getting the API's crypto delegate.
-EasyUnlockPrivateCryptoDelegate* GetCryptoDelegate(
- content::BrowserContext* context) {
- return BrowserContextKeyedAPIFactory<EasyUnlockPrivateAPI>::Get(context)
- ->GetCryptoDelegate();
-}
-
EasyUnlockPrivateConnectionManager* GetConnectionManager(
content::BrowserContext* context) {
return BrowserContextKeyedAPIFactory<EasyUnlockPrivateAPI>::Get(context)
@@ -93,12 +85,6 @@ EasyUnlockPrivateAPI::EasyUnlockPrivateAPI(content::BrowserContext* context)
EasyUnlockPrivateAPI::~EasyUnlockPrivateAPI() {}
-EasyUnlockPrivateCryptoDelegate* EasyUnlockPrivateAPI::GetCryptoDelegate() {
- if (!crypto_delegate_)
- crypto_delegate_ = EasyUnlockPrivateCryptoDelegate::Create();
- return crypto_delegate_.get();
-}
-
void EasyUnlockPrivateAPI::Shutdown() {
// Any dependency which references BrowserContext must be cleaned up here.
connection_manager_.reset();
@@ -318,369 +304,6 @@ ExtensionFunction::ResponseAction EasyUnlockPrivateGetStringsFunction::Run() {
return RespondNow(OneArgument(std::move(strings)));
}
-EasyUnlockPrivatePerformECDHKeyAgreementFunction::
-EasyUnlockPrivatePerformECDHKeyAgreementFunction() {}
-
-EasyUnlockPrivatePerformECDHKeyAgreementFunction::
-~EasyUnlockPrivatePerformECDHKeyAgreementFunction() {}
-
-ExtensionFunction::ResponseAction
-EasyUnlockPrivatePerformECDHKeyAgreementFunction::Run() {
- std::unique_ptr<easy_unlock_private::PerformECDHKeyAgreement::Params> params =
- easy_unlock_private::PerformECDHKeyAgreement::Params::Create(*args_);
- EXTENSION_FUNCTION_VALIDATE(params);
-
- GetCryptoDelegate(browser_context())->PerformECDHKeyAgreement(
- *params,
- base::Bind(&EasyUnlockPrivatePerformECDHKeyAgreementFunction::OnData,
- this));
- // TODO(https://crbug.com/829182): Resolve this.
- return did_respond() ? AlreadyResponded() : RespondLater();
-}
-
-void EasyUnlockPrivatePerformECDHKeyAgreementFunction::OnData(
- const std::string& secret_key) {
- // TODO(tbarzic): Improve error handling.
- if (!secret_key.empty()) {
- Respond(ArgumentList(
- easy_unlock_private::PerformECDHKeyAgreement::Results::Create(
- std::vector<char>(secret_key.begin(), secret_key.end()))));
- return;
- }
-
- Respond(NoArguments());
-}
-
-EasyUnlockPrivateGenerateEcP256KeyPairFunction::
-EasyUnlockPrivateGenerateEcP256KeyPairFunction() {}
-
-EasyUnlockPrivateGenerateEcP256KeyPairFunction::
-~EasyUnlockPrivateGenerateEcP256KeyPairFunction() {}
-
-ExtensionFunction::ResponseAction
-EasyUnlockPrivateGenerateEcP256KeyPairFunction::Run() {
- GetCryptoDelegate(browser_context())->GenerateEcP256KeyPair(
- base::Bind(&EasyUnlockPrivateGenerateEcP256KeyPairFunction::OnData,
- this));
- // TODO(https://crbug.com/829182): Resolve this.
- return did_respond() ? AlreadyResponded() : RespondLater();
-}
-
-void EasyUnlockPrivateGenerateEcP256KeyPairFunction::OnData(
- const std::string& private_key,
- const std::string& public_key) {
- // TODO(tbarzic): Improve error handling.
- if (!public_key.empty() && !private_key.empty()) {
- Respond(ArgumentList(
- easy_unlock_private::GenerateEcP256KeyPair::Results::Create(
- std::vector<char>(public_key.begin(), public_key.end()),
- std::vector<char>(private_key.begin(), private_key.end()))));
- return;
- }
-
- Respond(NoArguments());
-}
-
-EasyUnlockPrivateCreateSecureMessageFunction::
-EasyUnlockPrivateCreateSecureMessageFunction() {}
-
-EasyUnlockPrivateCreateSecureMessageFunction::
-~EasyUnlockPrivateCreateSecureMessageFunction() {}
-
-ExtensionFunction::ResponseAction
-EasyUnlockPrivateCreateSecureMessageFunction::Run() {
- std::unique_ptr<easy_unlock_private::CreateSecureMessage::Params> params =
- easy_unlock_private::CreateSecureMessage::Params::Create(*args_);
- EXTENSION_FUNCTION_VALIDATE(params);
-
- GetCryptoDelegate(browser_context())->CreateSecureMessage(
- *params,
- base::Bind(&EasyUnlockPrivateCreateSecureMessageFunction::OnData,
- this));
- // TODO(https://crbug.com/829182): Resolve this.
- return did_respond() ? AlreadyResponded() : RespondLater();
-}
-
-void EasyUnlockPrivateCreateSecureMessageFunction::OnData(
- const std::string& message) {
- // TODO(tbarzic): Improve error handling.
- if (!message.empty()) {
- Respond(
- ArgumentList(easy_unlock_private::CreateSecureMessage::Results::Create(
- std::vector<char>(message.begin(), message.end()))));
- return;
- }
-
- Respond(NoArguments());
-}
-
-EasyUnlockPrivateUnwrapSecureMessageFunction::
-EasyUnlockPrivateUnwrapSecureMessageFunction() {}
-
-EasyUnlockPrivateUnwrapSecureMessageFunction::
-~EasyUnlockPrivateUnwrapSecureMessageFunction() {}
-
-ExtensionFunction::ResponseAction
-EasyUnlockPrivateUnwrapSecureMessageFunction::Run() {
- std::unique_ptr<easy_unlock_private::UnwrapSecureMessage::Params> params =
- easy_unlock_private::UnwrapSecureMessage::Params::Create(*args_);
- EXTENSION_FUNCTION_VALIDATE(params);
-
- GetCryptoDelegate(browser_context())->UnwrapSecureMessage(
- *params,
- base::Bind(&EasyUnlockPrivateUnwrapSecureMessageFunction::OnData,
- this));
- // TODO(https://crbug.com/829182): Resolve this.
- return did_respond() ? AlreadyResponded() : RespondLater();
-}
-
-void EasyUnlockPrivateUnwrapSecureMessageFunction::OnData(
- const std::string& data) {
- // TODO(tbarzic): Improve error handling.
- if (!data.empty()) {
- Respond(
- ArgumentList(easy_unlock_private::UnwrapSecureMessage::Results::Create(
- std::vector<char>(data.begin(), data.end()))));
- return;
- }
-
- Respond(NoArguments());
-}
-
-EasyUnlockPrivateGetPermitAccessFunction::
- EasyUnlockPrivateGetPermitAccessFunction() {
-}
-
-EasyUnlockPrivateGetPermitAccessFunction::
- ~EasyUnlockPrivateGetPermitAccessFunction() {
-}
-
-ExtensionFunction::ResponseAction
-EasyUnlockPrivateGetPermitAccessFunction::Run() {
- // Check that we are inside a user session.
- Profile* profile = Profile::FromBrowserContext(browser_context());
- chromeos::EasyUnlockService* easy_unlock_service =
- chromeos::EasyUnlockService::Get(profile);
- if (easy_unlock_service->GetType() !=
- chromeos::EasyUnlockService::TYPE_REGULAR) {
- return RespondNow(
- Error("This function must be called inside a user session."));
- }
-
- std::string b64_public_key, b64_private_key;
- GetKeyPairForExperiment(&b64_public_key, &b64_private_key);
-
- // Fill in the permit access JSON dictionary.
- proximity_auth::ProximityAuthClient* client =
- easy_unlock_service->proximity_auth_client();
- std::unique_ptr<base::DictionaryValue> permit_access(
- new base::DictionaryValue());
- permit_access->SetString("permitId",
- "permit://google.com/" + client->GetAccountId());
- permit_access->SetString("id", b64_public_key);
- permit_access->SetString("type", "access");
- permit_access->SetString("data", b64_private_key);
-
- PA_LOG(INFO) << "Returning permit access for "
- << "chrome.easyUnlockPrivate.getPermitAccess:\n"
- << " id: " << b64_public_key;
-
- return RespondNow(OneArgument(std::move(permit_access)));
-}
-
-void EasyUnlockPrivateGetPermitAccessFunction::GetKeyPairForExperiment(
- std::string* user_public_key,
- std::string* user_private_key) {
- Profile* profile = Profile::FromBrowserContext(browser_context());
- cryptauth::CryptAuthEnrollmentManager* enrollment_manager =
- chromeos::EasyUnlockService::Get(profile)
- ->proximity_auth_client()
- ->GetCryptAuthEnrollmentManager();
- base::Base64UrlEncode(enrollment_manager->GetUserPublicKey(),
- base::Base64UrlEncodePolicy::INCLUDE_PADDING,
- user_public_key);
- base::Base64UrlEncode(enrollment_manager->GetUserPrivateKey(),
- base::Base64UrlEncodePolicy::INCLUDE_PADDING,
- user_private_key);
-}
-
-EasyUnlockPrivateClearPermitAccessFunction::
- EasyUnlockPrivateClearPermitAccessFunction() {
-}
-
-EasyUnlockPrivateClearPermitAccessFunction::
- ~EasyUnlockPrivateClearPermitAccessFunction() {
-}
-
-ExtensionFunction::ResponseAction
-EasyUnlockPrivateClearPermitAccessFunction::Run() {
- Profile* profile = Profile::FromBrowserContext(browser_context());
- chromeos::EasyUnlockService::Get(profile)->ClearPermitAccess();
- return RespondNow(NoArguments());
-}
-
-EasyUnlockPrivateSetRemoteDevicesFunction::
- EasyUnlockPrivateSetRemoteDevicesFunction() {
-}
-
-EasyUnlockPrivateSetRemoteDevicesFunction::
- ~EasyUnlockPrivateSetRemoteDevicesFunction() {
-}
-
-ExtensionFunction::ResponseAction
-EasyUnlockPrivateSetRemoteDevicesFunction::Run() {
- std::unique_ptr<easy_unlock_private::SetRemoteDevices::Params> params(
- easy_unlock_private::SetRemoteDevices::Params::Create(*args_));
- EXTENSION_FUNCTION_VALIDATE(params.get());
-
- Profile* profile = Profile::FromBrowserContext(browser_context());
- base::ListValue devices;
- for (const easy_unlock_private::Device& device : params->devices)
- devices.Append(device.ToValue());
-
- chromeos::EasyUnlockService::Get(profile)->SetRemoteBleDevices(devices);
-
- return RespondNow(NoArguments());
-}
-
-EasyUnlockPrivateGetRemoteDevicesFunction::
- EasyUnlockPrivateGetRemoteDevicesFunction() {
-}
-
-EasyUnlockPrivateGetRemoteDevicesFunction::
- ~EasyUnlockPrivateGetRemoteDevicesFunction() {
-}
-
-ExtensionFunction::ResponseAction
-EasyUnlockPrivateGetRemoteDevicesFunction::Run() {
- // Check that we are inside a user profile.
- Profile* profile = Profile::FromBrowserContext(browser_context());
- chromeos::EasyUnlockService* easy_unlock_service =
- chromeos::EasyUnlockService::Get(profile);
- if (easy_unlock_service->GetType() !=
- chromeos::EasyUnlockService::TYPE_REGULAR) {
- return RespondNow(
- Error("This function must be called inside a user session."));
- }
-
- // Get the synced unlock key data.
- proximity_auth::ProximityAuthClient* client =
- easy_unlock_service->proximity_auth_client();
-
- permit_id_ = "permit://google.com/easyunlock/v1/" + client->GetAccountId();
- secure_message_delegate_ =
- cryptauth::SecureMessageDelegateImpl::Factory::NewInstance();
- std::vector<cryptauth::ExternalDeviceInfo> unlock_keys = GetUnlockKeys();
- expected_devices_count_ = unlock_keys.size();
-
- remote_devices_.reset(new base::ListValue());
- if (expected_devices_count_ == 0)
- return RespondNow(OneArgument(std::move(remote_devices_)));
-
- // If there is a BLE unlock key, then don't return anything, so the app does
- // not try the classic Bluetooth protocol.
- for (const auto& unlock_key : unlock_keys) {
- if (unlock_key.bluetooth_address().empty())
- return RespondNow(OneArgument(std::move(remote_devices_)));
- }
-
- // Derive the PSKs for the user's unlock keys.
- PA_LOG(INFO) << "Deriving PSKs for "
- << "chrome.easyUnlockPrivate.getRemoteDevices.\n"
- << "Expecting " << expected_devices_count_ << " devices.";
- for (const auto& unlock_key : unlock_keys) {
- secure_message_delegate_->DeriveKey(
- GetUserPrivateKey(), unlock_key.public_key(),
- base::Bind(
- &EasyUnlockPrivateGetRemoteDevicesFunction::OnPSKDerivedForDevice,
- this, unlock_key));
- }
- return did_respond() ? AlreadyResponded() : RespondLater();
-}
-
-std::string EasyUnlockPrivateGetRemoteDevicesFunction::GetUserPrivateKey() {
- Profile* profile = Profile::FromBrowserContext(browser_context());
- proximity_auth::ProximityAuthClient* client =
- chromeos::EasyUnlockService::Get(profile)->proximity_auth_client();
- cryptauth::CryptAuthEnrollmentManager* enrollment_manager =
- client->GetCryptAuthEnrollmentManager();
- return enrollment_manager->GetUserPrivateKey();
-}
-
-std::vector<cryptauth::ExternalDeviceInfo>
-EasyUnlockPrivateGetRemoteDevicesFunction::GetUnlockKeys() {
- Profile* profile = Profile::FromBrowserContext(browser_context());
- proximity_auth::ProximityAuthClient* client =
- chromeos::EasyUnlockService::Get(profile)->proximity_auth_client();
- cryptauth::CryptAuthDeviceManager* device_manager =
- client->GetCryptAuthDeviceManager();
- return device_manager->GetUnlockKeys();
-}
-
-void EasyUnlockPrivateGetRemoteDevicesFunction::OnPSKDerivedForDevice(
- const cryptauth::ExternalDeviceInfo& device,
- const std::string& persistent_symmetric_key) {
- std::string b64_public_key, b64_psk;
- base::Base64UrlEncode(device.public_key(),
- base::Base64UrlEncodePolicy::INCLUDE_PADDING,
- &b64_public_key);
- base::Base64UrlEncode(persistent_symmetric_key,
- base::Base64UrlEncodePolicy::INCLUDE_PADDING,
- &b64_psk);
-
- // Fill in the JSON dictionary containing a single unlock key's data.
- std::unique_ptr<base::DictionaryValue> device_dictionary(
- new base::DictionaryValue());
- device_dictionary->SetString("name", device.friendly_device_name());
- device_dictionary->SetString("bluetoothAddress", device.bluetooth_address());
- device_dictionary->SetString("psk", b64_psk);
-
- // Fill in the permit license for the unlock key.
- std::unique_ptr<base::DictionaryValue> permit_license(
- new base::DictionaryValue());
- permit_license->SetString("permitId", permit_id_);
- permit_license->SetString("id", b64_public_key);
- permit_license->SetString("type", "license");
- permit_license->SetString("data", b64_public_key);
- device_dictionary->Set("permitRecord", std::move(permit_license));
-
- remote_devices_->Append(std::move(device_dictionary));
-
- // If all PSKs are derived, then return from the API call.
- PA_LOG(INFO) << "Derived PSK for " << b64_public_key << ": "
- << remote_devices_->GetSize() << "/" << expected_devices_count_;
- if (remote_devices_->GetSize() == expected_devices_count_)
- Respond(OneArgument(std::move(remote_devices_)));
-}
-
-EasyUnlockPrivateGetUserInfoFunction::EasyUnlockPrivateGetUserInfoFunction() {
-}
-
-EasyUnlockPrivateGetUserInfoFunction::~EasyUnlockPrivateGetUserInfoFunction() {
-}
-
-ExtensionFunction::ResponseAction EasyUnlockPrivateGetUserInfoFunction::Run() {
- chromeos::EasyUnlockService* service = chromeos::EasyUnlockService::Get(
- Profile::FromBrowserContext(browser_context()));
- std::vector<easy_unlock_private::UserInfo> users;
- const AccountId& account_id = service->GetAccountId();
- if (account_id.is_valid()) {
- easy_unlock_private::UserInfo user;
- user.user_id = account_id.GetUserEmail();
- user.logged_in =
- service->GetType() == chromeos::EasyUnlockService::TYPE_REGULAR;
- user.data_ready = user.logged_in || service->GetRemoteDevices() != NULL;
-
- user.device_user_id = cryptauth::CalculateDeviceUserId(
- cryptauth::CryptAuthDeviceIdProviderImpl::GetInstance()->GetDeviceId(),
- account_id.GetUserEmail());
-
- users.push_back(std::move(user));
- }
- return RespondNow(
- ArgumentList(easy_unlock_private::GetUserInfo::Results::Create(users)));
-}
-
EasyUnlockPrivateShowErrorBubbleFunction::
EasyUnlockPrivateShowErrorBubbleFunction() {
}
@@ -691,9 +314,10 @@ EasyUnlockPrivateShowErrorBubbleFunction::
ExtensionFunction::ResponseAction
EasyUnlockPrivateShowErrorBubbleFunction::Run() {
- content::WebContents* web_contents = GetAssociatedWebContents();
- if (!web_contents)
+ content::WebContents* web_contents = GetSenderWebContents();
+ if (!web_contents || GetViewType(web_contents) != VIEW_TYPE_APP_WINDOW) {
return RespondNow(Error("A foreground app window is required."));
+ }
std::unique_ptr<easy_unlock_private::ShowErrorBubble::Params> params(
easy_unlock_private::ShowErrorBubble::Params::Create(*args_));
@@ -757,14 +381,13 @@ void EasyUnlockPrivateFindSetupConnectionFunction::
void EasyUnlockPrivateFindSetupConnectionFunction::OnConnectionFound(
std::unique_ptr<cryptauth::Connection> connection) {
// Connection are not persistent by default.
- std::string device_address = connection->remote_device().bluetooth_address;
bool persistent = false;
int connection_id =
GetConnectionManager(browser_context())
->AddConnection(extension(), std::move(connection), persistent);
Respond(
ArgumentList(easy_unlock_private::FindSetupConnection::Results::Create(
- connection_id, device_address)));
+ connection_id)));
}
ExtensionFunction::ResponseAction
@@ -775,21 +398,20 @@ EasyUnlockPrivateFindSetupConnectionFunction::Run() {
// Creates a BLE connection finder to look for any device advertising
// |params->setup_service_uuid|.
- connection_finder_.reset(
- new proximity_auth::BluetoothLowEnergySetupConnectionFinder(
- params->setup_service_uuid));
+ connection_finder_ =
+ std::make_unique<proximity_auth::BluetoothLowEnergySetupConnectionFinder>(
+ params->setup_service_uuid);
connection_finder_->Find(base::Bind(
&EasyUnlockPrivateFindSetupConnectionFunction::OnConnectionFound, this));
- timer_.reset(new base::OneShotTimer());
+ timer_ = std::make_unique<base::OneShotTimer>();
timer_->Start(FROM_HERE, base::TimeDelta::FromSeconds(params->time_out),
base::Bind(&EasyUnlockPrivateFindSetupConnectionFunction::
OnConnectionFinderTimedOut,
this));
- // TODO(https://crbug.com/829182): Resolve this.
- return did_respond() ? AlreadyResponded() : RespondLater();
+ return RespondLater();
}
EasyUnlockPrivateSetupConnectionDisconnectFunction::
diff --git a/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.h b/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.h
index f0f04d2d74f..78046e5347e 100644
--- a/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.h
+++ b/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.h
@@ -27,8 +27,6 @@ class BrowserContext;
namespace cryptauth {
class Connection;
-class ExternalDeviceInfo;
-class SecureMessageDelegate;
}
namespace proximity_auth {
@@ -38,7 +36,6 @@ class BluetoothLowEnergyConnectionFinder;
namespace extensions {
class EasyUnlockPrivateConnectionManager;
-class EasyUnlockPrivateCryptoDelegate;
class EasyUnlockPrivateAPI : public BrowserContextKeyedAPI {
public:
@@ -50,8 +47,6 @@ class EasyUnlockPrivateAPI : public BrowserContextKeyedAPI {
explicit EasyUnlockPrivateAPI(content::BrowserContext* context);
~EasyUnlockPrivateAPI() override;
- EasyUnlockPrivateCryptoDelegate* GetCryptoDelegate();
-
EasyUnlockPrivateConnectionManager* get_connection_manager() {
return connection_manager_.get();
}
@@ -65,8 +60,6 @@ class EasyUnlockPrivateAPI : public BrowserContextKeyedAPI {
// KeyedService implementation.
void Shutdown() override;
- std::unique_ptr<EasyUnlockPrivateCryptoDelegate> crypto_delegate_;
-
std::unique_ptr<EasyUnlockPrivateConnectionManager> connection_manager_;
DISALLOW_COPY_AND_ASSIGN(EasyUnlockPrivateAPI);
@@ -89,198 +82,6 @@ class EasyUnlockPrivateGetStringsFunction : public UIThreadExtensionFunction {
DISALLOW_COPY_AND_ASSIGN(EasyUnlockPrivateGetStringsFunction);
};
-class EasyUnlockPrivatePerformECDHKeyAgreementFunction
- : public UIThreadExtensionFunction {
- public:
- EasyUnlockPrivatePerformECDHKeyAgreementFunction();
-
- protected:
- ~EasyUnlockPrivatePerformECDHKeyAgreementFunction() override;
-
- // ExtensionFunction:
- ResponseAction Run() override;
-
- private:
- void OnData(const std::string& secret_key);
-
- DECLARE_EXTENSION_FUNCTION("easyUnlockPrivate.performECDHKeyAgreement",
- EASYUNLOCKPRIVATE_PERFORMECDHKEYAGREEMENT)
-
- DISALLOW_COPY_AND_ASSIGN(EasyUnlockPrivatePerformECDHKeyAgreementFunction);
-};
-
-class EasyUnlockPrivateGenerateEcP256KeyPairFunction
- : public UIThreadExtensionFunction {
- public:
- EasyUnlockPrivateGenerateEcP256KeyPairFunction();
-
- protected:
- ~EasyUnlockPrivateGenerateEcP256KeyPairFunction() override;
-
- // ExtensionFunction:
- ResponseAction Run() override;
-
- private:
- void OnData(const std::string& public_key,
- const std::string& private_key);
-
- DECLARE_EXTENSION_FUNCTION("easyUnlockPrivate.generateEcP256KeyPair",
- EASYUNLOCKPRIVATE_GENERATEECP256KEYPAIR)
-
- DISALLOW_COPY_AND_ASSIGN(EasyUnlockPrivateGenerateEcP256KeyPairFunction);
-};
-
-class EasyUnlockPrivateCreateSecureMessageFunction
- : public UIThreadExtensionFunction {
- public:
- EasyUnlockPrivateCreateSecureMessageFunction();
-
- protected:
- ~EasyUnlockPrivateCreateSecureMessageFunction() override;
-
- // ExtensionFunction:
- ResponseAction Run() override;
-
- private:
- void OnData(const std::string& message);
-
- DECLARE_EXTENSION_FUNCTION("easyUnlockPrivate.createSecureMessage",
- EASYUNLOCKPRIVATE_CREATESECUREMESSAGE)
-
- DISALLOW_COPY_AND_ASSIGN(EasyUnlockPrivateCreateSecureMessageFunction);
-};
-
-class EasyUnlockPrivateUnwrapSecureMessageFunction
- : public UIThreadExtensionFunction {
- public:
- EasyUnlockPrivateUnwrapSecureMessageFunction();
-
- protected:
- ~EasyUnlockPrivateUnwrapSecureMessageFunction() override;
-
- // ExtensionFunction:
- ResponseAction Run() override;
-
- private:
- void OnData(const std::string& data);
-
- DECLARE_EXTENSION_FUNCTION("easyUnlockPrivate.unwrapSecureMessage",
- EASYUNLOCKPRIVATE_UNWRAPSECUREMESSAGE)
-
- DISALLOW_COPY_AND_ASSIGN(EasyUnlockPrivateUnwrapSecureMessageFunction);
-};
-
-class EasyUnlockPrivateGetPermitAccessFunction
- : public UIThreadExtensionFunction {
- public:
- DECLARE_EXTENSION_FUNCTION("easyUnlockPrivate.getPermitAccess",
- EASYUNLOCKPRIVATE_GETPERMITACCESS)
- EasyUnlockPrivateGetPermitAccessFunction();
-
- protected:
- ~EasyUnlockPrivateGetPermitAccessFunction() override;
-
- // Writes the user's public and private key in base64 form to the
- // |user_public_key| and |user_private_key| fields. Exposed for testing.
- virtual void GetKeyPairForExperiment(std::string* user_public_key,
- std::string* user_private_key);
-
- private:
- // ExtensionFunction:
- ResponseAction Run() override;
-
- DISALLOW_COPY_AND_ASSIGN(EasyUnlockPrivateGetPermitAccessFunction);
-};
-
-class EasyUnlockPrivateClearPermitAccessFunction
- : public UIThreadExtensionFunction {
- public:
- DECLARE_EXTENSION_FUNCTION("easyUnlockPrivate.clearPermitAccess",
- EASYUNLOCKPRIVATE_CLEARPERMITACCESS)
- EasyUnlockPrivateClearPermitAccessFunction();
-
- private:
- ~EasyUnlockPrivateClearPermitAccessFunction() override;
-
- // ExtensionFunction:
- ResponseAction Run() override;
-
- DISALLOW_COPY_AND_ASSIGN(EasyUnlockPrivateClearPermitAccessFunction);
-};
-
-class EasyUnlockPrivateSetRemoteDevicesFunction
- : public UIThreadExtensionFunction {
- public:
- DECLARE_EXTENSION_FUNCTION("easyUnlockPrivate.setRemoteDevices",
- EASYUNLOCKPRIVATE_SETREMOTEDEVICES)
- EasyUnlockPrivateSetRemoteDevicesFunction();
-
- private:
- ~EasyUnlockPrivateSetRemoteDevicesFunction() override;
-
- // ExtensionFunction:
- ResponseAction Run() override;
-
- DISALLOW_COPY_AND_ASSIGN(EasyUnlockPrivateSetRemoteDevicesFunction);
-};
-
-class EasyUnlockPrivateGetRemoteDevicesFunction
- : public UIThreadExtensionFunction {
- public:
- DECLARE_EXTENSION_FUNCTION("easyUnlockPrivate.getRemoteDevices",
- EASYUNLOCKPRIVATE_GETREMOTEDEVICES)
- EasyUnlockPrivateGetRemoteDevicesFunction();
-
- protected:
- ~EasyUnlockPrivateGetRemoteDevicesFunction() override;
-
- // Returns the user's private key used for the native experiment.
- // Exposed for testing.
- virtual std::string GetUserPrivateKey();
-
- // Returns the user's unlock keys used for the native experiment.
- // Exposed for testing.
- virtual std::vector<cryptauth::ExternalDeviceInfo> GetUnlockKeys();
-
- private:
- // ExtensionFunction:
- ResponseAction Run() override;
-
- // Callback when the PSK of a device is derived.
- void OnPSKDerivedForDevice(const cryptauth::ExternalDeviceInfo& device,
- const std::string& persistent_symmetric_key);
-
- // The permit id of the user. Used for the native experiment.
- std::string permit_id_;
-
- // The expected number of devices to return. Used for the native experiment.
- size_t expected_devices_count_;
-
- // Working list of the devices to return. Used for the native experiment.
- std::unique_ptr<base::ListValue> remote_devices_;
-
- // Used to derive devices' PSK. Used for the native experiment.
- std::unique_ptr<cryptauth::SecureMessageDelegate>
- secure_message_delegate_;
-
- DISALLOW_COPY_AND_ASSIGN(EasyUnlockPrivateGetRemoteDevicesFunction);
-};
-
-class EasyUnlockPrivateGetUserInfoFunction : public UIThreadExtensionFunction {
- public:
- DECLARE_EXTENSION_FUNCTION("easyUnlockPrivate.getUserInfo",
- EASYUNLOCKPRIVATE_GETUSERINFO)
- EasyUnlockPrivateGetUserInfoFunction();
-
- private:
- ~EasyUnlockPrivateGetUserInfoFunction() override;
-
- // ExtensionFunction:
- ResponseAction Run() override;
-
- DISALLOW_COPY_AND_ASSIGN(EasyUnlockPrivateGetUserInfoFunction);
-};
-
class EasyUnlockPrivateShowErrorBubbleFunction
: public UIThreadExtensionFunction {
public:
diff --git a/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api_chromeos_unittest.cc b/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api_chromeos_unittest.cc
index 009de5e36fd..e23780b47e8 100644
--- a/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api_chromeos_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api_chromeos_unittest.cc
@@ -5,142 +5,30 @@
#include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_api.h"
#include <memory>
-#include <string>
#include <utility>
-#include "base/bind.h"
-#include "base/command_line.h"
-#include "base/files/file_path.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
-#include "base/memory/scoped_refptr.h"
-#include "base/threading/thread_task_runner_handle.h"
-#include "base/values.h"
-#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_app_manager.h"
-#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_service_factory.h"
-#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_service_regular.h"
#include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_connection_manager.h"
#include "chrome/browser/extensions/extension_api_unittest.h"
-#include "chrome/browser/extensions/extension_function_test_utils.h"
-#include "chrome/browser/extensions/extension_system_factory.h"
-#include "chrome/browser/extensions/test_extension_system.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/extensions/api/easy_unlock_private.h"
-#include "chrome/common/extensions/extension_constants.h"
-#include "chrome/test/base/testing_profile.h"
-#include "chromeos/components/proximity_auth/switches.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/fake_easy_unlock_client.h"
-#include "components/cryptauth/cryptauth_test_util.h"
#include "components/cryptauth/fake_connection.h"
-#include "components/cryptauth/proto/cryptauth_api.pb.h"
-#include "device/bluetooth/dbus/bluez_dbus_manager.h"
-#include "extensions/browser/api_test_utils.h"
+#include "components/cryptauth/remote_device_test_util.h"
+#include "content/public/browser/browser_context.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
-#include "extensions/browser/test_event_router.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/value_builder.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/cros_system_api/dbus/service_constants.h"
-#include "ui/aura/env.h"
-// TODO(jhawkins): Wrap in extensions namespace.
+namespace extensions {
namespace {
-namespace api = extensions::api::easy_unlock_private;
-
using cryptauth::FakeConnection;
-using cryptauth::CreateLERemoteDeviceForTest;
+using cryptauth::CreateRemoteDeviceForTest;
using extensions::BrowserContextKeyedAPIFactory;
using extensions::DictionaryBuilder;
-using extensions::EasyUnlockPrivateAPI;
-using extensions::EasyUnlockPrivateCreateSecureMessageFunction;
-using extensions::EasyUnlockPrivateConnectionManager;
-using extensions::EasyUnlockPrivateGenerateEcP256KeyPairFunction;
-using extensions::EasyUnlockPrivatePerformECDHKeyAgreementFunction;
-using extensions::EasyUnlockPrivateUnwrapSecureMessageFunction;
using extensions::Extension;
using extensions::ExtensionBuilder;
using extensions::ListBuilder;
-class TestableGetRemoteDevicesFunction
- : public extensions::EasyUnlockPrivateGetRemoteDevicesFunction {
- public:
- TestableGetRemoteDevicesFunction() {}
-
- // EasyUnlockPrivateGetRemoteDevicesFunction:
- std::string GetUserPrivateKey() override { return "user private key"; }
-
- std::vector<cryptauth::ExternalDeviceInfo> GetUnlockKeys() override {
- cryptauth::ExternalDeviceInfo unlock_key1;
- unlock_key1.set_friendly_device_name("test phone 1");
- unlock_key1.set_public_key("public key 1");
- unlock_key1.set_bluetooth_address("AA:BB:CC:DD:EE:FF");
- unlock_key1.set_unlock_key(true);
-
- cryptauth::ExternalDeviceInfo unlock_key2;
- unlock_key2.set_friendly_device_name("test phone 2");
- unlock_key2.set_public_key("public key 2");
- unlock_key2.set_bluetooth_address("FF:EE:DD:CC:BB:AA");
- unlock_key2.set_unlock_key(true);
-
- std::vector<cryptauth::ExternalDeviceInfo> unlock_keys;
- unlock_keys.push_back(unlock_key1);
- unlock_keys.push_back(unlock_key2);
- return unlock_keys;
- }
-
- private:
- ~TestableGetRemoteDevicesFunction() override {}
-
- DISALLOW_COPY_AND_ASSIGN(TestableGetRemoteDevicesFunction);
-};
-
-class TestableGetPermitAccessFunction
- : public extensions::EasyUnlockPrivateGetPermitAccessFunction {
- public:
- TestableGetPermitAccessFunction() {}
-
- // EasyUnlockPrivateGetPermitAccessFunction:
- void GetKeyPairForExperiment(std::string* user_public_key,
- std::string* user_private_key) override {
- *user_public_key = "user public key";
- *user_private_key = "user private key";
- }
-
- private:
- ~TestableGetPermitAccessFunction() override {}
-
- DISALLOW_COPY_AND_ASSIGN(TestableGetPermitAccessFunction);
-};
-
-// Converts a string to a base::Value value whose buffer contains the
-// string data without the trailing '\0'.
-std::unique_ptr<base::Value> StringToBinaryValue(const std::string& value) {
- return base::Value::CreateWithCopiedBuffer(value.data(), value.length());
-}
-
-// Copies |private_key_source| and |public_key_source| to |private_key_target|
-// and |public_key_target|. It is used as a callback for
-// |EasyUnlockClient::GenerateEcP256KeyPair| to save the values returned by the
-// method.
-void CopyKeyPair(std::string* private_key_target,
- std::string* public_key_target,
- const std::string& private_key_source,
- const std::string& public_key_source) {
- *private_key_target = private_key_source;
- *public_key_target = public_key_source;
-}
-
-// Copies |data_source| to |data_target|. Used as a callback to EasyUnlockClient
-// methods to save the data returned by the method.
-void CopyData(std::string* data_target, const std::string& data_source) {
- *data_target = data_source;
-}
-
EasyUnlockPrivateConnectionManager* GetConnectionManager(
content::BrowserContext* context) {
return BrowserContextKeyedAPIFactory<EasyUnlockPrivateAPI>::Get(context)
@@ -164,357 +52,21 @@ class EasyUnlockPrivateApiTest : public extensions::ExtensionApiUnittest {
public:
EasyUnlockPrivateApiTest() {}
~EasyUnlockPrivateApiTest() override {}
-
- protected:
- void SetUp() override {
- chromeos::DBusThreadManager::Initialize();
- if (aura::Env::GetInstance()->mode() == aura::Env::Mode::LOCAL) {
- bluez::BluezDBusManager::Initialize(
- chromeos::DBusThreadManager::Get()->GetSystemBus(),
- chromeos::DBusThreadManager::Get()->IsUsingFakes());
- }
- client_ = chromeos::DBusThreadManager::Get()->GetEasyUnlockClient();
-
- extensions::ExtensionApiUnittest::SetUp();
- }
-
- void TearDown() override {
- extensions::ExtensionApiUnittest::TearDown();
-
- if (aura::Env::GetInstance()->mode() == aura::Env::Mode::LOCAL)
- bluez::BluezDBusManager::Shutdown();
- chromeos::DBusThreadManager::Shutdown();
- }
-
- // Extracts a single binary value result from a run extension function
- // |function| and converts it to string.
- // It will fail if the extension doesn't have exactly one binary value result.
- // On failure, an empty string is returned.
- std::string GetSingleBinaryResultAsString(
- UIThreadExtensionFunction* function) {
- const base::ListValue* result_list = function->GetResultList();
- if (!result_list) {
- LOG(ERROR) << "Function has no result list.";
- return std::string();
- }
-
- if (result_list->GetSize() != 1u) {
- LOG(ERROR) << "Invalid number of results.";
- return std::string();
- }
-
- const auto& result_binary_value = result_list->GetList()[0];
- if (!result_binary_value.is_blob()) {
- LOG(ERROR) << "Result not a binary value.";
- return std::string();
- }
-
- return std::string(result_binary_value.GetBlob().data(),
- result_binary_value.GetBlob().size());
- }
-
- chromeos::EasyUnlockClient* client_;
-};
-
-TEST_F(EasyUnlockPrivateApiTest, GenerateEcP256KeyPair) {
- scoped_refptr<EasyUnlockPrivateGenerateEcP256KeyPairFunction> function(
- new EasyUnlockPrivateGenerateEcP256KeyPairFunction());
- function->set_has_callback(true);
-
- ASSERT_TRUE(extension_function_test_utils::RunFunction(
- function.get(), "[]", browser(), extensions::api_test_utils::NONE));
-
- const base::ListValue* result_list = function->GetResultList();
- ASSERT_TRUE(result_list);
- ASSERT_EQ(2u, result_list->GetSize());
-
- const base::Value& public_key = result_list->GetList()[0];
- const base::Value& private_key = result_list->GetList()[1];
- ASSERT_TRUE(public_key.is_blob());
- ASSERT_TRUE(private_key.is_blob());
-
- EXPECT_TRUE(chromeos::FakeEasyUnlockClient::IsEcP256KeyPair(
- std::string(private_key.GetBlob().data(), private_key.GetBlob().size()),
- std::string(public_key.GetBlob().data(), public_key.GetBlob().size())));
-}
-
-TEST_F(EasyUnlockPrivateApiTest, PerformECDHKeyAgreement) {
- scoped_refptr<EasyUnlockPrivatePerformECDHKeyAgreementFunction> function(
- new EasyUnlockPrivatePerformECDHKeyAgreementFunction());
- function->set_has_callback(true);
-
- std::string private_key_1;
- std::string public_key_1_unused;
- client_->GenerateEcP256KeyPair(
- base::Bind(&CopyKeyPair, &private_key_1, &public_key_1_unused));
-
- std::string private_key_2_unused;
- std::string public_key_2;
- client_->GenerateEcP256KeyPair(
- base::Bind(&CopyKeyPair, &private_key_2_unused, &public_key_2));
-
- std::string expected_result;
- client_->PerformECDHKeyAgreement(
- private_key_1,
- public_key_2,
- base::Bind(&CopyData, &expected_result));
- ASSERT_GT(expected_result.length(), 0u);
-
- std::unique_ptr<base::ListValue> args(new base::ListValue);
- args->Append(StringToBinaryValue(private_key_1));
- args->Append(StringToBinaryValue(public_key_2));
-
- ASSERT_TRUE(extension_function_test_utils::RunFunction(
- function.get(), std::move(args), browser(),
- extensions::api_test_utils::NONE));
-
- EXPECT_EQ(expected_result, GetSingleBinaryResultAsString(function.get()));
-}
-
-TEST_F(EasyUnlockPrivateApiTest, CreateSecureMessage) {
- scoped_refptr<EasyUnlockPrivateCreateSecureMessageFunction> function(
- new EasyUnlockPrivateCreateSecureMessageFunction());
- function->set_has_callback(true);
-
- chromeos::EasyUnlockClient::CreateSecureMessageOptions create_options;
- create_options.key = "KEY";
- create_options.associated_data = "ASSOCIATED_DATA";
- create_options.public_metadata = "PUBLIC_METADATA";
- create_options.verification_key_id = "VERIFICATION_KEY_ID";
- create_options.decryption_key_id = "DECRYPTION_KEY_ID";
- create_options.encryption_type = easy_unlock::kEncryptionTypeAES256CBC;
- create_options.signature_type = easy_unlock::kSignatureTypeHMACSHA256;
-
- std::string expected_result;
- client_->CreateSecureMessage(
- "PAYLOAD",
- create_options,
- base::Bind(&CopyData, &expected_result));
- ASSERT_GT(expected_result.length(), 0u);
-
- std::unique_ptr<base::ListValue> args(new base::ListValue);
- args->Append(StringToBinaryValue("PAYLOAD"));
- args->Append(StringToBinaryValue("KEY"));
- auto options = std::make_unique<base::DictionaryValue>();
- options->Set("associatedData", StringToBinaryValue("ASSOCIATED_DATA"));
- options->Set("publicMetadata", StringToBinaryValue("PUBLIC_METADATA"));
- options->Set("verificationKeyId",
- StringToBinaryValue("VERIFICATION_KEY_ID"));
- options->Set("decryptionKeyId",
- StringToBinaryValue("DECRYPTION_KEY_ID"));
- options->SetString(
- "encryptType",
- api::ToString(api::ENCRYPTION_TYPE_AES_256_CBC));
- options->SetString(
- "signType",
- api::ToString(api::SIGNATURE_TYPE_HMAC_SHA256));
- args->Append(std::move(options));
-
- ASSERT_TRUE(extension_function_test_utils::RunFunction(
- function.get(), std::move(args), browser(),
- extensions::api_test_utils::NONE));
-
- EXPECT_EQ(expected_result, GetSingleBinaryResultAsString(function.get()));
-}
-
-TEST_F(EasyUnlockPrivateApiTest, CreateSecureMessage_EmptyOptions) {
- scoped_refptr<EasyUnlockPrivateCreateSecureMessageFunction> function(
- new EasyUnlockPrivateCreateSecureMessageFunction());
- function->set_has_callback(true);
-
- chromeos::EasyUnlockClient::CreateSecureMessageOptions create_options;
- create_options.key = "KEY";
- create_options.encryption_type = easy_unlock::kEncryptionTypeNone;
- create_options.signature_type = easy_unlock::kSignatureTypeHMACSHA256;
-
- std::string expected_result;
- client_->CreateSecureMessage(
- "PAYLOAD",
- create_options,
- base::Bind(&CopyData, &expected_result));
- ASSERT_GT(expected_result.length(), 0u);
-
- std::unique_ptr<base::ListValue> args(new base::ListValue);
- args->Append(StringToBinaryValue("PAYLOAD"));
- args->Append(StringToBinaryValue("KEY"));
- auto options = std::make_unique<base::DictionaryValue>();
- args->Append(std::move(options));
-
- ASSERT_TRUE(extension_function_test_utils::RunFunction(
- function.get(), std::move(args), browser(),
- extensions::api_test_utils::NONE));
-
- EXPECT_EQ(expected_result, GetSingleBinaryResultAsString(function.get()));
-}
-
-TEST_F(EasyUnlockPrivateApiTest, CreateSecureMessage_AsymmetricSign) {
- scoped_refptr<EasyUnlockPrivateCreateSecureMessageFunction> function(
- new EasyUnlockPrivateCreateSecureMessageFunction());
- function->set_has_callback(true);
-
- chromeos::EasyUnlockClient::CreateSecureMessageOptions create_options;
- create_options.key = "KEY";
- create_options.associated_data = "ASSOCIATED_DATA";
- create_options.verification_key_id = "VERIFICATION_KEY_ID";
- create_options.encryption_type = easy_unlock::kEncryptionTypeNone;
- create_options.signature_type = easy_unlock::kSignatureTypeECDSAP256SHA256;
-
- std::string expected_result;
- client_->CreateSecureMessage(
- "PAYLOAD",
- create_options,
- base::Bind(&CopyData, &expected_result));
- ASSERT_GT(expected_result.length(), 0u);
-
- std::unique_ptr<base::ListValue> args(new base::ListValue);
- args->Append(StringToBinaryValue("PAYLOAD"));
- args->Append(StringToBinaryValue("KEY"));
- auto options = std::make_unique<base::DictionaryValue>();
- options->Set("associatedData",
- StringToBinaryValue("ASSOCIATED_DATA"));
- options->Set("verificationKeyId",
- StringToBinaryValue("VERIFICATION_KEY_ID"));
- options->SetString(
- "signType",
- api::ToString(api::SIGNATURE_TYPE_ECDSA_P256_SHA256));
- args->Append(std::move(options));
-
- ASSERT_TRUE(extension_function_test_utils::RunFunction(
- function.get(), std::move(args), browser(),
- extensions::api_test_utils::NONE));
-
- EXPECT_EQ(expected_result, GetSingleBinaryResultAsString(function.get()));
-}
-
-TEST_F(EasyUnlockPrivateApiTest, UnwrapSecureMessage) {
- scoped_refptr<EasyUnlockPrivateUnwrapSecureMessageFunction> function(
- new EasyUnlockPrivateUnwrapSecureMessageFunction());
- function->set_has_callback(true);
-
- chromeos::EasyUnlockClient::UnwrapSecureMessageOptions unwrap_options;
- unwrap_options.key = "KEY";
- unwrap_options.associated_data = "ASSOCIATED_DATA";
- unwrap_options.encryption_type = easy_unlock::kEncryptionTypeAES256CBC;
- unwrap_options.signature_type = easy_unlock::kSignatureTypeHMACSHA256;
-
- std::string expected_result;
- client_->UnwrapSecureMessage(
- "MESSAGE",
- unwrap_options,
- base::Bind(&CopyData, &expected_result));
- ASSERT_GT(expected_result.length(), 0u);
-
- std::unique_ptr<base::ListValue> args(new base::ListValue);
- args->Append(StringToBinaryValue("MESSAGE"));
- args->Append(StringToBinaryValue("KEY"));
- auto options = std::make_unique<base::DictionaryValue>();
- options->Set("associatedData", StringToBinaryValue("ASSOCIATED_DATA"));
- options->SetString(
- "encryptType",
- api::ToString(api::ENCRYPTION_TYPE_AES_256_CBC));
- options->SetString(
- "signType",
- api::ToString(api::SIGNATURE_TYPE_HMAC_SHA256));
- args->Append(std::move(options));
-
- ASSERT_TRUE(extension_function_test_utils::RunFunction(
- function.get(), std::move(args), browser(),
- extensions::api_test_utils::NONE));
-
- EXPECT_EQ(expected_result, GetSingleBinaryResultAsString(function.get()));
-}
-
-TEST_F(EasyUnlockPrivateApiTest, UnwrapSecureMessage_EmptyOptions) {
- scoped_refptr<EasyUnlockPrivateUnwrapSecureMessageFunction> function(
- new EasyUnlockPrivateUnwrapSecureMessageFunction());
- function->set_has_callback(true);
-
- chromeos::EasyUnlockClient::UnwrapSecureMessageOptions unwrap_options;
- unwrap_options.key = "KEY";
- unwrap_options.encryption_type = easy_unlock::kEncryptionTypeNone;
- unwrap_options.signature_type = easy_unlock::kSignatureTypeHMACSHA256;
-
- std::string expected_result;
- client_->UnwrapSecureMessage(
- "MESSAGE",
- unwrap_options,
- base::Bind(&CopyData, &expected_result));
- ASSERT_GT(expected_result.length(), 0u);
-
- std::unique_ptr<base::ListValue> args(new base::ListValue);
- args->Append(StringToBinaryValue("MESSAGE"));
- args->Append(StringToBinaryValue("KEY"));
- auto options = std::make_unique<base::DictionaryValue>();
- args->Append(std::move(options));
-
- ASSERT_TRUE(extension_function_test_utils::RunFunction(
- function.get(), std::move(args), browser(),
- extensions::api_test_utils::NONE));
-
- EXPECT_EQ(expected_result, GetSingleBinaryResultAsString(function.get()));
-}
-
-TEST_F(EasyUnlockPrivateApiTest, UnwrapSecureMessage_AsymmetricSign) {
- scoped_refptr<EasyUnlockPrivateUnwrapSecureMessageFunction> function(
- new EasyUnlockPrivateUnwrapSecureMessageFunction());
- function->set_has_callback(true);
-
- chromeos::EasyUnlockClient::UnwrapSecureMessageOptions unwrap_options;
- unwrap_options.key = "KEY";
- unwrap_options.associated_data = "ASSOCIATED_DATA";
- unwrap_options.encryption_type = easy_unlock::kEncryptionTypeNone;
- unwrap_options.signature_type = easy_unlock::kSignatureTypeECDSAP256SHA256;
-
- std::string expected_result;
- client_->UnwrapSecureMessage(
- "MESSAGE",
- unwrap_options,
- base::Bind(&CopyData, &expected_result));
- ASSERT_GT(expected_result.length(), 0u);
-
- std::unique_ptr<base::ListValue> args(new base::ListValue);
- args->Append(StringToBinaryValue("MESSAGE"));
- args->Append(StringToBinaryValue("KEY"));
- auto options = std::make_unique<base::DictionaryValue>();
- options->Set("associatedData",
- StringToBinaryValue("ASSOCIATED_DATA"));
- options->SetString(
- "signType",
- api::ToString(api::SIGNATURE_TYPE_ECDSA_P256_SHA256));
- args->Append(std::move(options));
-
- ASSERT_TRUE(extension_function_test_utils::RunFunction(
- function.get(), std::move(args), browser(),
- extensions::api_test_utils::NONE));
-
- EXPECT_EQ(expected_result, GetSingleBinaryResultAsString(function.get()));
-}
-
-struct AutoPairingResult {
- AutoPairingResult() : success(false) {}
-
- void SetResult(bool success, const std::string& error) {
- this->success = success;
- this->error = error;
- }
-
- bool success;
- std::string error;
};
// Tests that no BrowserContext dependencies of EasyUnlockPrivateApi (and its
// dependencies) are referenced after the BrowserContext is torn down. The test
// fails with a crash if such a condition exists.
TEST_F(EasyUnlockPrivateApiTest, BrowserContextTearDown) {
- EasyUnlockPrivateConnectionManager* manager = GetConnectionManager(profile());
+ auto* manager = GetConnectionManager(profile());
ASSERT_TRUE(!!manager);
// Add a Connection. The shutdown path for EasyUnlockPrivateConnectionManager,
// a dependency of EasyUnlockPrivateApi, only references BrowserContext
// dependencies if it has a Connection to shutdown.
auto extension = CreateTestExtension();
- auto connection =
- std::make_unique<FakeConnection>(CreateLERemoteDeviceForTest());
+ auto connection = std::make_unique<FakeConnection>(
+ cryptauth::CreateRemoteDeviceRefForTest());
manager->AddConnection(extension.get(), std::move(connection), true);
// The Profile is cleaned up at the end of this scope, and BrowserContext
@@ -522,3 +74,4 @@ TEST_F(EasyUnlockPrivateApiTest, BrowserContextTearDown) {
}
} // namespace
+} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_connection_manager.cc b/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_connection_manager.cc
index 0ca60a93f09..646cadc7576 100644
--- a/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_connection_manager.cc
+++ b/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_connection_manager.cc
@@ -24,11 +24,11 @@ const char kEasyUnlockFeatureName[] = "easy_unlock";
api::easy_unlock_private::ConnectionStatus ToApiConnectionStatus(
Connection::Status status) {
switch (status) {
- case Connection::DISCONNECTED:
+ case Connection::Status::DISCONNECTED:
return api::easy_unlock_private::CONNECTION_STATUS_DISCONNECTED;
- case Connection::IN_PROGRESS:
+ case Connection::Status::IN_PROGRESS:
return api::easy_unlock_private::CONNECTION_STATUS_IN_PROGRESS;
- case Connection::CONNECTED:
+ case Connection::Status::CONNECTED:
return api::easy_unlock_private::CONNECTION_STATUS_CONNECTED;
}
return api::easy_unlock_private::CONNECTION_STATUS_NONE;
diff --git a/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_crypto_delegate.h b/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_crypto_delegate.h
deleted file mode 100644
index f03f47041d9..00000000000
--- a/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_crypto_delegate.h
+++ /dev/null
@@ -1,48 +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_EXTENSIONS_API_EASY_UNLOCK_PRIVATE_EASY_UNLOCK_PRIVATE_CRYPTO_DELEGATE_H_
-#define CHROME_BROWSER_EXTENSIONS_API_EASY_UNLOCK_PRIVATE_EASY_UNLOCK_PRIVATE_CRYPTO_DELEGATE_H_
-
-#include <memory>
-#include <string>
-
-#include "base/callback.h"
-#include "chrome/common/extensions/api/easy_unlock_private.h"
-
-namespace extensions {
-
-// Wrapper around EasyUnlock dbus client on Chrome OS. The methods read
-// extension function pearameters and invoke the associated EasyUnlock dbus
-// client methods. On non-Chrome OS platforms, the methods are stubbed out.
-class EasyUnlockPrivateCryptoDelegate {
- public:
- typedef base::Callback<void(const std::string& data)> DataCallback;
-
- typedef base::Callback<void(const std::string& public_key,
- const std::string& private_key)>
- KeyPairCallback;
-
- virtual ~EasyUnlockPrivateCryptoDelegate() {}
-
- // Creates platform specific delegate instance. Non Chrome OS implementations
- // currently do nothing but invoke callbacks with empty data.
- static std::unique_ptr<EasyUnlockPrivateCryptoDelegate> Create();
-
- // See chromeos/dbus/easy_unlock_client.h for info on these methods.
- virtual void GenerateEcP256KeyPair(const KeyPairCallback& callback) = 0;
- virtual void PerformECDHKeyAgreement(
- const api::easy_unlock_private::PerformECDHKeyAgreement::Params& params,
- const DataCallback& callback) = 0;
- virtual void CreateSecureMessage(
- const api::easy_unlock_private::CreateSecureMessage::Params& params,
- const DataCallback& callback) = 0;
- virtual void UnwrapSecureMessage(
- const api::easy_unlock_private::UnwrapSecureMessage::Params& params,
- const DataCallback& callback) = 0;
-};
-
-} // namespace extensions
-
-#endif // CHROME_BROWSER_EXTENSIONS_API_EASY_UNLOCK_PRIVATE_EASY_UNLOCK_PRIVATE_CRYPTO_DELEGATE_H_
diff --git a/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_crypto_delegate_chromeos.cc b/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_crypto_delegate_chromeos.cc
deleted file mode 100644
index 6d2a5b94691..00000000000
--- a/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_crypto_delegate_chromeos.cc
+++ /dev/null
@@ -1,133 +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/extensions/api/easy_unlock_private/easy_unlock_private_crypto_delegate.h"
-
-#include "base/macros.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/easy_unlock_client.h"
-#include "third_party/cros_system_api/dbus/service_constants.h"
-
-namespace extensions {
-
-namespace easy_unlock_private = api::easy_unlock_private;
-
-namespace {
-
-// Converts encryption type to a string representation used by EasyUnlock dbus
-// client.
-std::string EncryptionTypeToString(easy_unlock_private::EncryptionType type) {
- switch (type) {
- case easy_unlock_private::ENCRYPTION_TYPE_AES_256_CBC:
- return easy_unlock::kEncryptionTypeAES256CBC;
- default:
- return easy_unlock::kEncryptionTypeNone;
- }
-}
-
-// Converts signature type to a string representation used by EasyUnlock dbus
-// client.
-std::string SignatureTypeToString(easy_unlock_private::SignatureType type) {
- switch (type) {
- case easy_unlock_private::SIGNATURE_TYPE_ECDSA_P256_SHA256:
- return easy_unlock::kSignatureTypeECDSAP256SHA256;
- case easy_unlock_private::SIGNATURE_TYPE_HMAC_SHA256:
- // Fall through to default.
- default:
- return easy_unlock::kSignatureTypeHMACSHA256;
- }
-}
-
-// ChromeOS specific EasyUnlockPrivateCryptoDelegate implementation.
-class EasyUnlockPrivateCryptoDelegateChromeOS
- : public extensions::EasyUnlockPrivateCryptoDelegate {
- public:
- EasyUnlockPrivateCryptoDelegateChromeOS()
- : dbus_client_(
- chromeos::DBusThreadManager::Get()->GetEasyUnlockClient()) {
- }
-
- ~EasyUnlockPrivateCryptoDelegateChromeOS() override {}
-
- void GenerateEcP256KeyPair(const KeyPairCallback& callback) override {
- dbus_client_->GenerateEcP256KeyPair(callback);
- }
-
- void PerformECDHKeyAgreement(
- const easy_unlock_private::PerformECDHKeyAgreement::Params& params,
- const DataCallback& callback) override {
- dbus_client_->PerformECDHKeyAgreement(
- std::string(params.private_key.begin(), params.private_key.end()),
- std::string(params.public_key.begin(), params.public_key.end()),
- callback);
- }
-
- void CreateSecureMessage(
- const easy_unlock_private::CreateSecureMessage::Params& params,
- const DataCallback& callback) override {
- chromeos::EasyUnlockClient::CreateSecureMessageOptions options;
- options.key.assign(params.key.begin(), params.key.end());
- if (params.options.associated_data) {
- options.associated_data.assign(params.options.associated_data->begin(),
- params.options.associated_data->end());
- }
- if (params.options.public_metadata) {
- options.public_metadata.assign(params.options.public_metadata->begin(),
- params.options.public_metadata->end());
- }
- if (params.options.verification_key_id) {
- options.verification_key_id.assign(
- params.options.verification_key_id->begin(),
- params.options.verification_key_id->end());
- }
- if (params.options.decryption_key_id) {
- options.decryption_key_id.assign(
- params.options.decryption_key_id->begin(),
- params.options.decryption_key_id->end());
- }
- options.encryption_type =
- EncryptionTypeToString(params.options.encrypt_type);
- options.signature_type =
- SignatureTypeToString(params.options.sign_type);
-
- dbus_client_->CreateSecureMessage(
- std::string(params.payload.begin(), params.payload.end()), options,
- callback);
- }
-
- void UnwrapSecureMessage(
- const easy_unlock_private::UnwrapSecureMessage::Params& params,
- const DataCallback& callback) override {
- chromeos::EasyUnlockClient::UnwrapSecureMessageOptions options;
- options.key.assign(params.key.begin(), params.key.end());
- if (params.options.associated_data) {
- options.associated_data.assign(params.options.associated_data->begin(),
- params.options.associated_data->end());
- }
- options.encryption_type =
- EncryptionTypeToString(params.options.encrypt_type);
- options.signature_type =
- SignatureTypeToString(params.options.sign_type);
-
- dbus_client_->UnwrapSecureMessage(
- std::string(params.secure_message.begin(), params.secure_message.end()),
- options, callback);
- }
-
- private:
- chromeos::EasyUnlockClient* dbus_client_;
-
- DISALLOW_COPY_AND_ASSIGN(EasyUnlockPrivateCryptoDelegateChromeOS);
-};
-
-} // namespace
-
-// static
-std::unique_ptr<EasyUnlockPrivateCryptoDelegate>
-EasyUnlockPrivateCryptoDelegate::Create() {
- return std::unique_ptr<EasyUnlockPrivateCryptoDelegate>(
- new EasyUnlockPrivateCryptoDelegateChromeOS());
-}
-
-} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_crypto_delegate_stub.cc b/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_crypto_delegate_stub.cc
deleted file mode 100644
index 5a7161c90c2..00000000000
--- a/chromium/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_crypto_delegate_stub.cc
+++ /dev/null
@@ -1,57 +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 "base/macros.h"
-#include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_crypto_delegate.h"
-
-namespace extensions {
-
-namespace easy_unlock_private = api::easy_unlock_private;
-
-namespace {
-
-// Stub EasyUnlockPrivateCryptoDelegate implementation.
-class EasyUnlockPrivateCryptoDelegateStub
- : public extensions::EasyUnlockPrivateCryptoDelegate {
- public:
- EasyUnlockPrivateCryptoDelegateStub() {}
-
- ~EasyUnlockPrivateCryptoDelegateStub() override {}
-
- void GenerateEcP256KeyPair(const KeyPairCallback& callback) override {
- callback.Run("", "");
- }
-
- void PerformECDHKeyAgreement(
- const easy_unlock_private::PerformECDHKeyAgreement::Params& params,
- const DataCallback& callback) override {
- callback.Run("");
- }
-
- void CreateSecureMessage(
- const easy_unlock_private::CreateSecureMessage::Params& params,
- const DataCallback& callback) override {
- callback.Run("");
- }
-
- void UnwrapSecureMessage(
- const easy_unlock_private::UnwrapSecureMessage::Params& params,
- const DataCallback& callback) override {
- callback.Run("");
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(EasyUnlockPrivateCryptoDelegateStub);
-};
-
-} // namespace
-
-// static
-std::unique_ptr<EasyUnlockPrivateCryptoDelegate>
-EasyUnlockPrivateCryptoDelegate::Create() {
- return std::unique_ptr<EasyUnlockPrivateCryptoDelegate>(
- new EasyUnlockPrivateCryptoDelegateStub());
-}
-
-} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/enterprise_device_attributes/enterprise_device_attributes_apitest.cc b/chromium/chrome/browser/extensions/api/enterprise_device_attributes/enterprise_device_attributes_apitest.cc
index 8f2b5a933e6..c923b2d663b 100644
--- a/chromium/chrome/browser/extensions/api/enterprise_device_attributes/enterprise_device_attributes_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/enterprise_device_attributes/enterprise_device_attributes_apitest.cc
@@ -18,11 +18,11 @@
#include "chromeos/dbus/fake_session_manager_client.h"
#include "chromeos/system/fake_statistics_provider.h"
#include "chromeos/system/statistics_provider.h"
+#include "components/account_id/account_id.h"
#include "components/policy/core/common/cloud/device_management_service.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/policy/policy_constants.h"
#include "components/prefs/pref_service.h"
-#include "components/signin/core/account_id/account_id.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
@@ -84,7 +84,7 @@ class EnterpriseDeviceAttributesTest :
public:
EnterpriseDeviceAttributesTest() {
fake_statistics_provider_.SetMachineStatistic(
- chromeos::system::kSerialNumberKey, kSerialNumber);
+ chromeos::system::kSerialNumberKeyForTest, kSerialNumber);
set_exit_when_last_browser_closes(false);
set_chromeos_user_ = false;
}
diff --git a/chromium/chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_api_unittest.cc b/chromium/chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_api_unittest.cc
index d974bf51ac0..7fff815039e 100644
--- a/chromium/chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_api_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_api_unittest.cc
@@ -28,9 +28,9 @@
#include "chromeos/cryptohome/mock_async_method_caller.h"
#include "chromeos/dbus/dbus_method_call_status.h"
#include "chromeos/dbus/fake_cryptohome_client.h"
+#include "components/account_id/account_id.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/prefs/pref_service.h"
-#include "components/signin/core/account_id/account_id.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/user_manager/scoped_user_manager.h"
#include "extensions/common/extension_builder.h"
diff --git a/chromium/chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_apitest_nss.cc b/chromium/chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_apitest_nss.cc
index 5e20545888f..0566fd88cdc 100644
--- a/chromium/chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_apitest_nss.cc
+++ b/chromium/chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_apitest_nss.cc
@@ -26,6 +26,8 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace extensions {
+
namespace {
// The test extension has a certificate referencing this private key which will
@@ -191,8 +193,7 @@ class EnterprisePlatformKeysTest
policy::POLICY_SOURCE_CLOUD, std::move(forcelist), nullptr);
// Set the policy and wait until the extension is installed.
- extensions::TestExtensionRegistryObserver observer(
- extensions::ExtensionRegistry::Get(profile()));
+ TestExtensionRegistryObserver observer(ExtensionRegistry::Get(profile()));
mock_policy_provider()->UpdateChromePolicy(policy);
observer.WaitForExtensionWillBeInstalled();
}
@@ -269,9 +270,6 @@ INSTANTIATE_TEST_CASE_P(
PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
PlatformKeysTestBase::UserStatus::MANAGED_AFFILIATED_DOMAIN)));
-class EnterprisePlatformKeysTestNonPolicyInstalledExtension
- : public EnterprisePlatformKeysTest {};
-
// Ensure that extensions that are not pre-installed by policy throw an install
// warning if they request the enterprise.platformKeys permission in the
// manifest and that such extensions don't see the
@@ -284,9 +282,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest,
base::FilePath extension_path =
test_data_dir_.AppendASCII("enterprise_platform_keys");
- extensions::ExtensionRegistry* registry =
- extensions::ExtensionRegistry::Get(profile());
- const extensions::Extension* extension =
+ ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
+ const Extension* extension =
GetExtensionByPath(registry->enabled_extensions(), extension_path);
ASSERT_FALSE(extension->install_warnings().empty());
EXPECT_EQ(
@@ -294,3 +291,5 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest,
"location.",
extension->install_warnings()[0].message);
}
+
+} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.cc b/chromium/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.cc
index e42c29e6c6f..f609d252df9 100644
--- a/chromium/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.cc
+++ b/chromium/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.cc
@@ -9,7 +9,6 @@
#include "base/base64.h"
#include "base/callback.h"
-#include "base/message_loop/message_loop.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
@@ -31,9 +30,9 @@
#include "chromeos/dbus/dbus_method_call_status.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/settings/cros_settings_names.h"
+#include "components/account_id/account_id.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
-#include "components/signin/core/account_id/account_id.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/user_manager/known_user.h"
#include "components/user_manager/user.h"
@@ -148,6 +147,11 @@ bool EPKPChallengeKeyBase::IsExtensionWhitelisted() const {
// TODO(drcrash): Use a separate device-wide policy for the API.
return Manifest::IsPolicyLocation(extension_->location());
}
+ if (Manifest::IsComponentLocation(extension_->location())) {
+ // Note: For this to even be called, the component extension must also be
+ // whitelisted in chrome/common/extensions/api/_permission_features.json
+ return true;
+ }
const base::ListValue* list =
profile_->GetPrefs()->GetList(prefs::kAttestationExtensionWhitelist);
base::Value value(extension_->id());
diff --git a/chromium/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.h b/chromium/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.h
index a80e5d5930f..5409d5a735b 100644
--- a/chromium/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.h
+++ b/chromium/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.h
@@ -18,7 +18,7 @@
#include "chromeos/attestation/attestation_constants.h"
#include "chromeos/attestation/attestation_flow.h"
#include "chromeos/dbus/cryptohome_client.h"
-#include "components/signin/core/account_id/account_id.h"
+#include "components/account_id/account_id.h"
#include "extensions/browser/extension_function.h"
#include "extensions/common/extension.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
diff --git a/chromium/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api_unittest.cc b/chromium/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api_unittest.cc
index 03541c19880..93064bb1354 100644
--- a/chromium/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api_unittest.cc
@@ -30,9 +30,9 @@
#include "chromeos/cryptohome/cryptohome_parameters.h"
#include "chromeos/cryptohome/mock_async_method_caller.h"
#include "chromeos/dbus/fake_cryptohome_client.h"
+#include "components/account_id/account_id.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/prefs/pref_service.h"
-#include "components/signin/core/account_id/account_id.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/user_manager/scoped_user_manager.h"
#include "extensions/common/extension_builder.h"
diff --git a/chromium/chrome/browser/extensions/api/enterprise_reporting_private/chrome_desktop_report_request_helper.cc b/chromium/chrome/browser/extensions/api/enterprise_reporting_private/chrome_desktop_report_request_helper.cc
index 05c2b24bb68..4eae3e8ead7 100644
--- a/chromium/chrome/browser/extensions/api/enterprise_reporting_private/chrome_desktop_report_request_helper.cc
+++ b/chromium/chrome/browser/extensions/api/enterprise_reporting_private/chrome_desktop_report_request_helper.cc
@@ -11,11 +11,17 @@
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/browser/policy/policy_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/channel_info.h"
+#include "chrome/common/pref_names.h"
+#include "components/policy/core/common/cloud/cloud_policy_client.h"
#include "components/policy/core/common/cloud/cloud_policy_util.h"
+#include "components/policy/core/common/cloud/machine_level_user_cloud_policy_manager.h"
#include "components/policy/proto/device_management_backend.pb.h"
+#include "components/prefs/pref_service.h"
#include "components/version_info/channel.h"
#include "components/version_info/version_info.h"
@@ -24,18 +30,19 @@ namespace em = enterprise_management;
namespace extensions {
namespace {
-// JSON key in extension arguments.
-const char kMachineName[] = "machineName";
-const char kOSInfo[] = "osInfo";
-const char kOSUser[] = "osUser";
+// JSON keys in the extension arguments.
const char kBrowserReport[] = "browserReport";
const char kChromeUserProfileReport[] = "chromeUserProfileReport";
const char kChromeSignInUser[] = "chromeSignInUser";
const char kExtensionData[] = "extensionData";
const char kPlugins[] = "plugins";
+const char kSafeBrowsingWarnings[] = "safeBrowsingWarnings";
+const char kSafeBrowsingWarningsClickThrough[] =
+ "safeBrowsingWarningsClickThrough";
-// JSON key in the os_info field.
+// JSON keys in the os_info field.
const char kOS[] = "os";
+const char kOSArch[] = "arch";
const char kOSVersion[] = "os_version";
const char kDefaultDictionary[] = "{}";
@@ -56,6 +63,17 @@ std::string GetProfileId(const Profile* profile) {
return profile->GetOriginalProfile()->GetPath().AsUTF8Unsafe();
}
+// Returns last policy fetch timestamp of machine level user cloud policy if
+// it exists. Otherwise, returns zero.
+int64_t GetMachineLevelUserCloudPolicyFetchTimestamp() {
+ policy::MachineLevelUserCloudPolicyManager* manager =
+ g_browser_process->browser_policy_connector()
+ ->GetMachineLevelUserCloudPolicyManager();
+ if (!manager || !manager->IsClientRegistered())
+ return 0;
+ return manager->core()->client()->last_policy_timestamp().ToJavaTime();
+}
+
void AppendAdditionalBrowserInformation(em::ChromeDesktopReportRequest* request,
Profile* profile) {
// Set Chrome version number
@@ -76,11 +94,24 @@ void AppendAdditionalBrowserInformation(em::ChromeDesktopReportRequest* request,
request->mutable_browser_report()
->mutable_chrome_user_profile_reports(0)
->set_id(GetProfileId(profile));
+
// Set policy data of the first profile. Extension will report this data in
// the future.
request->mutable_browser_report()
->mutable_chrome_user_profile_reports(0)
->set_policy_data(policy::GetAllPolicyValuesAsJSON(profile, true));
+
+ int64_t timestamp = GetMachineLevelUserCloudPolicyFetchTimestamp();
+ if (timestamp > 0) {
+ request->mutable_browser_report()
+ ->mutable_chrome_user_profile_reports(0)
+ ->set_policy_fetched_timestamp(timestamp);
+ }
+
+ // Set the profile name
+ request->mutable_browser_report()
+ ->mutable_chrome_user_profile_reports(0)
+ ->set_name(profile->GetPrefs()->GetString(prefs::kProfileName));
}
bool UpdateJSONEncodedStringEntry(const base::Value& dict_value,
@@ -103,17 +134,23 @@ bool UpdateJSONEncodedStringEntry(const base::Value& dict_value,
return true;
}
-bool UpdateOSInfoEntry(const base::Value& report, std::string* os_info_string) {
- base::Value writable_os_info(base::Value::Type::DICTIONARY);
- if (const base::Value* os_info = report.FindKey(kOSInfo)) {
- if (!os_info->is_dict())
- return false;
- writable_os_info = os_info->Clone();
- }
- writable_os_info.SetKey(kOS, base::Value(policy::GetOSPlatform()));
- writable_os_info.SetKey(kOSVersion, base::Value(policy::GetOSVersion()));
- base::JSONWriter::Write(writable_os_info, os_info_string);
- return true;
+void AppendPlatformInformation(em::ChromeDesktopReportRequest* request) {
+ const char kComputerName[] = "computername";
+ const char kUsername[] = "username";
+
+ base::Value os_info = base::Value(base::Value::Type::DICTIONARY);
+ os_info.SetKey(kOS, base::Value(policy::GetOSPlatform()));
+ os_info.SetKey(kOSVersion, base::Value(policy::GetOSVersion()));
+ os_info.SetKey(kOSArch, base::Value(policy::GetOSArchitecture()));
+ base::JSONWriter::Write(os_info, request->mutable_os_info());
+
+ base::Value machine_name = base::Value(base::Value::Type::DICTIONARY);
+ machine_name.SetKey(kComputerName, base::Value(policy::GetMachineName()));
+ base::JSONWriter::Write(machine_name, request->mutable_machine_name());
+
+ base::Value os_user = base::Value(base::Value::Type::DICTIONARY);
+ os_user.SetKey(kUsername, base::Value(policy::GetOSUsername()));
+ base::JSONWriter::Write(os_user, request->mutable_os_user());
}
std::unique_ptr<em::ChromeUserProfileReport>
@@ -134,6 +171,20 @@ GenerateChromeUserProfileReportRequest(const base::Value& profile_report) {
return nullptr;
}
+ if (const base::Value* count =
+ profile_report.FindKey(kSafeBrowsingWarnings)) {
+ if (!count->is_int())
+ return nullptr;
+ request->set_safe_browsing_warnings(count->GetInt());
+ }
+
+ if (const base::Value* count =
+ profile_report.FindKey(kSafeBrowsingWarningsClickThrough)) {
+ if (!count->is_int())
+ return nullptr;
+ request->set_safe_browsing_warnings_click_through(count->GetInt());
+ }
+
return request;
}
@@ -145,13 +196,7 @@ GenerateChromeDesktopReportRequest(const base::DictionaryValue& report,
std::unique_ptr<em::ChromeDesktopReportRequest> request =
std::make_unique<em::ChromeDesktopReportRequest>();
- if (!UpdateJSONEncodedStringEntry(
- report, kMachineName, request->mutable_machine_name(), DICTIONARY) ||
- !UpdateJSONEncodedStringEntry(report, kOSUser, request->mutable_os_user(),
- DICTIONARY) ||
- !UpdateOSInfoEntry(report, request->mutable_os_info())) {
- return nullptr;
- }
+ AppendPlatformInformation(request.get());
if (const base::Value* browser_report =
report.FindKeyOfType(kBrowserReport, base::Value::Type::DICTIONARY)) {
diff --git a/chromium/chrome/browser/extensions/api/enterprise_reporting_private/chrome_desktop_report_request_helper_unittest.cc b/chromium/chrome/browser/extensions/api/enterprise_reporting_private/chrome_desktop_report_request_helper_unittest.cc
index fe6ef6e2b70..97d58f1c3ac 100644
--- a/chromium/chrome/browser/extensions/api/enterprise_reporting_private/chrome_desktop_report_request_helper_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/enterprise_reporting_private/chrome_desktop_report_request_helper_unittest.cc
@@ -5,10 +5,13 @@
#include "chrome/browser/extensions/api/enterprise_reporting_private/chrome_desktop_report_request_helper.h"
#include "base/json/json_reader.h"
+#include "base/json/string_escape.h"
#include "base/values.h"
+#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
#include "components/policy/core/common/cloud/cloud_policy_util.h"
#include "components/policy/proto/device_management_backend.pb.h"
+#include "components/prefs/pref_service.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -27,46 +30,57 @@ TEST_F(ChromeDesktopReportRequestGeneratorTest, OSInfo) {
std::unique_ptr<em::ChromeDesktopReportRequest> request;
std::string expected_os_info;
- // Platform and its version will be the |os_info| by default.
- expected_os_info = base::StringPrintf("{\"os\":\"%s\",\"os_version\":\"%s\"}",
- policy::GetOSPlatform().c_str(),
- policy::GetOSVersion().c_str());
+ expected_os_info = base::StringPrintf(
+ "{\"arch\":\"%s\",\"os\":\"%s\",\"os_version\":\"%s\"}",
+ policy::GetOSArchitecture().c_str(), policy::GetOSPlatform().c_str(),
+ policy::GetOSVersion().c_str());
request =
GenerateChromeDesktopReportRequest(base::DictionaryValue(), &profile_);
ASSERT_TRUE(request);
EXPECT_EQ(expected_os_info, request->os_info());
-
- // Platform and its version will be merged with other |os_info|.
- expected_os_info = base::StringPrintf(
- "{\"os\":\"%s\",\"os_version\":\"%s\",\"other_info\":\"info\"}",
- policy::GetOSPlatform().c_str(), policy::GetOSVersion().c_str());
- std::unique_ptr<base::DictionaryValue> report = base::DictionaryValue::From(
- base::JSONReader::Read("{\"osInfo\": {\"other_info\":\"info\"}}"));
- ASSERT_TRUE(report);
- request = GenerateChromeDesktopReportRequest(*report, &profile_);
- ASSERT_TRUE(request);
- EXPECT_EQ(expected_os_info, request->os_info());
}
TEST_F(ChromeDesktopReportRequestGeneratorTest, MachineName) {
std::unique_ptr<em::ChromeDesktopReportRequest> request;
std::string expected_machine_name;
- // Machine name will be a empty dict by default.
- expected_machine_name = "{}";
+ expected_machine_name = base::StringPrintf("{\"computername\":\"%s\"}",
+ policy::GetMachineName().c_str());
request =
GenerateChromeDesktopReportRequest(base::DictionaryValue(), &profile_);
ASSERT_TRUE(request);
EXPECT_EQ(expected_machine_name, request->machine_name());
+}
- // Machine name will be copied from the |report|.
- expected_machine_name = "{\"computername\":\"name\"}";
- std::unique_ptr<base::DictionaryValue> report = base::DictionaryValue::From(
- base::JSONReader::Read("{\"machineName\":{\"computername\":\"name\"}}"));
- ASSERT_TRUE(report);
- request = GenerateChromeDesktopReportRequest(*report, &profile_);
+TEST_F(ChromeDesktopReportRequestGeneratorTest, OSUsername) {
+ std::unique_ptr<em::ChromeDesktopReportRequest> request;
+ std::string expected_os_username, os_username_escaped;
+
+ // The username needs to be escaped as the name can contain slashes.
+ base::EscapeJSONString(policy::GetOSUsername(), false, &os_username_escaped);
+ expected_os_username =
+ base::StringPrintf("{\"username\":\"%s\"}", os_username_escaped.c_str());
+
+ request =
+ GenerateChromeDesktopReportRequest(base::DictionaryValue(), &profile_);
ASSERT_TRUE(request);
- EXPECT_EQ(expected_machine_name, request->machine_name());
+ EXPECT_EQ(expected_os_username, request->os_user());
+}
+
+TEST_F(ChromeDesktopReportRequestGeneratorTest, ProfileName) {
+ // Set the profile name to a known value to compare against.
+ const std::string test_name("TEST");
+ profile_.GetPrefs()->SetString(prefs::kProfileName, test_name);
+
+ // An empty report suffices for this test. The information of interest is
+ // sourced from the profile
+ std::unique_ptr<em::ChromeDesktopReportRequest> request =
+ GenerateChromeDesktopReportRequest(base::DictionaryValue(), &profile_);
+ ASSERT_TRUE(request);
+
+ // Make sure the user name was set in the proto.
+ EXPECT_EQ(test_name,
+ request->browser_report().chrome_user_profile_reports(0).name());
}
TEST_F(ChromeDesktopReportRequestGeneratorTest, ExtensionList) {
@@ -124,21 +138,49 @@ TEST_F(ChromeDesktopReportRequestGeneratorTest, ProfileID) {
TEST_F(ChromeDesktopReportRequestGeneratorTest, InvalidInput) {
// |request| will not be generated if the type of input is invalid.
std::unique_ptr<base::DictionaryValue> report;
- report = base::DictionaryValue::From(
- base::JSONReader::Read("{\"osInfo\": \"info\"}"));
+ report = base::DictionaryValue::From(base::JSONReader::Read(
+ "{\"browserReport\": "
+ "{\"chromeUserProfileReport\":[{\"extensionData\":{}}]}}"));
ASSERT_TRUE(report);
EXPECT_FALSE(GenerateChromeDesktopReportRequest(*report, &profile_));
+ report = base::DictionaryValue::From(base::JSONReader::Read(
+ "{\"browserReport\": "
+ "{\"chromeUserProfileReport\":[{\"chromeSignInUser\":\"\"}]}}"));
+ ASSERT_TRUE(report);
+ EXPECT_FALSE(GenerateChromeDesktopReportRequest(*report, &profile_));
+}
+
+TEST_F(ChromeDesktopReportRequestGeneratorTest, SafeBrowsing) {
+ std::unique_ptr<base::DictionaryValue> report;
report = base::DictionaryValue::From(
- base::JSONReader::Read("{\"machineName\": \"info\"}"));
+ base::JSONReader::Read("{\"browserReport\": "
+ "{\"chromeUserProfileReport\":[{"
+ "\"safeBrowsingWarnings\":\"invalid\"}]}}"));
ASSERT_TRUE(report);
EXPECT_FALSE(GenerateChromeDesktopReportRequest(*report, &profile_));
report = base::DictionaryValue::From(base::JSONReader::Read(
"{\"browserReport\": "
- "{\"chromeUserProfileReport\":[{\"extensionData\":{}}]}}"));
+ "{\"chromeUserProfileReport\":[{\"safeBrowsingWarningsClickThrough\":"
+ "\"invalid\"}]}}"));
ASSERT_TRUE(report);
EXPECT_FALSE(GenerateChromeDesktopReportRequest(*report, &profile_));
+
+ report = base::DictionaryValue::From(base::JSONReader::Read(
+ "{\"browserReport\": "
+ "{\"chromeUserProfileReport\":[{\"safeBrowsingWarnings\":3, "
+ "\"safeBrowsingWarningsClickThrough\":1}]}}"));
+ ASSERT_TRUE(report);
+ std::unique_ptr<em::ChromeDesktopReportRequest> request =
+ GenerateChromeDesktopReportRequest(*report, &profile_);
+ ASSERT_TRUE(request);
+ EXPECT_EQ(3u, request->browser_report()
+ .chrome_user_profile_reports(0)
+ .safe_browsing_warnings());
+ EXPECT_EQ(1u, request->browser_report()
+ .chrome_user_profile_reports(0)
+ .safe_browsing_warnings_click_through());
}
} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_api.cc b/chromium/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_api.cc
index de8a865ecb5..0ecdfca701f 100644
--- a/chromium/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_api.cc
+++ b/chromium/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_api.cc
@@ -40,7 +40,8 @@ EnterpriseReportingPrivateUploadChromeDesktopReportFunction::
if (device_management_service)
device_management_service->ScheduleInitialization(0);
cloud_policy_client_ = std::make_unique<policy::CloudPolicyClient>(
- std::string(), std::string(), device_management_service,
+ std::string() /* machine_id */, std::string() /* machine_model */,
+ std::string() /* brand_code */, device_management_service,
g_browser_process->system_request_context(), nullptr,
policy::CloudPolicyClient::DeviceDMTokenCallback());
dm_token_ = policy::BrowserDMTokenStorage::Get()->RetrieveDMToken();
diff --git a/chromium/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_unittest.cc b/chromium/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_unittest.cc
index 72f932d92a3..14c234c68d6 100644
--- a/chromium/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/enterprise_reporting_private/enterprise_reporting_private_unittest.cc
@@ -21,7 +21,6 @@ namespace {
const char kFakeDMToken[] = "fake-dm-token";
const char kFakeClientId[] = "fake-client-id";
const char kFakeMachineNameReport[] = "{\"computername\":\"name\"}";
-const char kFakeInvalidMachineNameReport[] = "\"invalid\"";
class MockCloudPolicyClient : public policy::MockCloudPolicyClient {
public:
@@ -30,7 +29,7 @@ class MockCloudPolicyClient : public policy::MockCloudPolicyClient {
void UploadChromeDesktopReport(
std::unique_ptr<enterprise_management::ChromeDesktopReportRequest>
request,
- const StatusCallback& callback) {
+ const StatusCallback& callback) override {
UploadChromeDesktopReportProxy(request.get(), callback);
}
MOCK_METHOD2(UploadChromeDesktopReportProxy,
@@ -73,6 +72,14 @@ class EnterpriseReportingPrivateTest : public ExtensionApiUnittest {
return base::StringPrintf("[{\"machineName\":%s}]", name);
}
+ std::string GenerateInvalidReport() {
+ // This report is invalid as the chromeSignInUser dictionary should not be
+ // wrapped in a list.
+ return std::string(
+ "[{\"browserReport\": "
+ "{\"chromeUserProfileReport\":[{\"chromeSignInUser\":\"Name\"}]}}]");
+ }
+
MockCloudPolicyClient* client_;
private:
@@ -90,7 +97,7 @@ TEST_F(EnterpriseReportingPrivateTest, ReportIsNotValid) {
ASSERT_EQ(enterprise_reporting::kInvalidInputErrorMessage,
RunFunctionAndReturnError(
CreateChromeDesktopReportingFunction(kFakeDMToken),
- GenerateArgs(kFakeInvalidMachineNameReport)));
+ GenerateInvalidReport()));
}
TEST_F(EnterpriseReportingPrivateTest, UploadFailed) {
diff --git a/chromium/chrome/browser/extensions/api/extension_action/browser_action_browsertest.cc b/chromium/chrome/browser/extensions/api/extension_action/browser_action_browsertest.cc
index d474eff3540..fdf5d3c0227 100644
--- a/chromium/chrome/browser/extensions/api/extension_action/browser_action_browsertest.cc
+++ b/chromium/chrome/browser/extensions/api/extension_action/browser_action_browsertest.cc
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "base/files/file_path.h"
-#include "base/message_loop/message_loop.h"
#include "chrome/browser/extensions/extension_action.h"
#include "chrome/browser/extensions/extension_action_manager.h"
#include "chrome/browser/extensions/extension_browsertest.h"
diff --git a/chromium/chrome/browser/extensions/api/extension_action/extension_action_api.cc b/chromium/chrome/browser/extensions/api/extension_action/extension_action_api.cc
index 3d48f3a8e6d..0b69a15ff2a 100644
--- a/chromium/chrome/browser/extensions/api/extension_action/extension_action_api.cc
+++ b/chromium/chrome/browser/extensions/api/extension_action/extension_action_api.cc
@@ -543,13 +543,11 @@ ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() {
return RespondNow(OneArgument(std::move(list)));
}
-BrowserActionOpenPopupFunction::BrowserActionOpenPopupFunction()
- : response_sent_(false) {
-}
+BrowserActionOpenPopupFunction::BrowserActionOpenPopupFunction() = default;
-bool BrowserActionOpenPopupFunction::RunAsync() {
+ExtensionFunction::ResponseAction BrowserActionOpenPopupFunction::Run() {
// We only allow the popup in the active window.
- Profile* profile = GetProfile();
+ Profile* profile = Profile::FromBrowserContext(browser_context());
Browser* browser = chrome::FindLastActiveWithProfile(profile);
// It's possible that the last active browser actually corresponds to the
// associated incognito profile, and this won't be returned by
@@ -566,13 +564,11 @@ bool BrowserActionOpenPopupFunction::RunAsync() {
// Otherwise, try to open a popup in the active browser.
// TODO(justinlin): Remove toolbar check when http://crbug.com/308645 is
// fixed.
- if (!browser ||
- !browser->window()->IsActive() ||
+ if (!browser || !browser->window()->IsActive() ||
!browser->window()->IsToolbarVisible() ||
- !ExtensionActionAPI::Get(GetProfile())->ShowExtensionActionPopup(
+ !ExtensionActionAPI::Get(profile)->ShowExtensionActionPopup(
extension_.get(), browser, false)) {
- error_ = kOpenPopupError;
- return false;
+ return RespondNow(Error(kOpenPopupError));
}
// Even if this is for an incognito window, we want to use the normal profile.
@@ -590,17 +586,15 @@ bool BrowserActionOpenPopupFunction::RunAsync() {
FROM_HERE,
base::BindOnce(&BrowserActionOpenPopupFunction::OpenPopupTimedOut, this),
base::TimeDelta::FromSeconds(10));
- return true;
+ return RespondLater();
}
void BrowserActionOpenPopupFunction::OpenPopupTimedOut() {
- if (response_sent_)
+ if (did_respond())
return;
DVLOG(1) << "chrome.browserAction.openPopup did not show a popup.";
- error_ = kOpenPopupError;
- SendResponse(false);
- response_sent_ = true;
+ Respond(Error(kOpenPopupError));
}
void BrowserActionOpenPopupFunction::Observe(
@@ -608,7 +602,7 @@ void BrowserActionOpenPopupFunction::Observe(
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD, type);
- if (response_sent_)
+ if (did_respond())
return;
ExtensionHost* host = content::Details<ExtensionHost>(details).ptr();
@@ -616,8 +610,7 @@ void BrowserActionOpenPopupFunction::Observe(
host->extension()->id() != extension_->id())
return;
- SendResponse(true);
- response_sent_ = true;
+ Respond(NoArguments());
registrar_.RemoveAll();
}
diff --git a/chromium/chrome/browser/extensions/api/extension_action/extension_action_api.h b/chromium/chrome/browser/extensions/api/extension_action/extension_action_api.h
index 6e003ace148..051518beed5 100644
--- a/chromium/chrome/browser/extensions/api/extension_action/extension_action_api.h
+++ b/chromium/chrome/browser/extensions/api/extension_action/extension_action_api.h
@@ -9,12 +9,12 @@
#include "base/macros.h"
#include "base/observer_list.h"
-#include "chrome/browser/extensions/chrome_extension_function.h"
#include "chrome/browser/extensions/extension_action.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
#include "extensions/browser/extension_event_histogram_value.h"
+#include "extensions/browser/extension_function.h"
#include "third_party/skia/include/core/SkColor.h"
namespace base {
@@ -26,6 +26,8 @@ class BrowserContext;
class WebContents;
}
+class Browser;
+
namespace extensions {
class ExtensionPrefs;
@@ -358,7 +360,7 @@ class BrowserActionDisableFunction : public ExtensionActionHideFunction {
~BrowserActionDisableFunction() override {}
};
-class BrowserActionOpenPopupFunction : public ChromeAsyncExtensionFunction,
+class BrowserActionOpenPopupFunction : public UIThreadExtensionFunction,
public content::NotificationObserver {
public:
DECLARE_EXTENSION_FUNCTION("browserAction.openPopup",
@@ -369,7 +371,7 @@ class BrowserActionOpenPopupFunction : public ChromeAsyncExtensionFunction,
~BrowserActionOpenPopupFunction() override {}
// ExtensionFunction:
- bool RunAsync() override;
+ ResponseAction Run() override;
void Observe(int type,
const content::NotificationSource& source,
@@ -377,7 +379,6 @@ class BrowserActionOpenPopupFunction : public ChromeAsyncExtensionFunction,
void OpenPopupTimedOut();
content::NotificationRegistrar registrar_;
- bool response_sent_;
DISALLOW_COPY_AND_ASSIGN(BrowserActionOpenPopupFunction);
};
diff --git a/chromium/chrome/browser/extensions/api/extension_action/extension_action_apitest.cc b/chromium/chrome/browser/extensions/api/extension_action/extension_action_apitest.cc
index fb57664c7ca..f12831ad5e7 100644
--- a/chromium/chrome/browser/extensions/api/extension_action/extension_action_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/extension_action/extension_action_apitest.cc
@@ -9,14 +9,20 @@
#include "base/run_loop.h"
#include "base/scoped_observer.h"
#include "base/strings/stringprintf.h"
+#include "chrome/browser/extensions/extension_action.h"
+#include "chrome/browser/extensions/extension_action_manager.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/sessions/session_tab_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/test/test_utils.h"
#include "extensions/browser/browsertest_util.h"
#include "extensions/browser/state_store.h"
#include "extensions/test/extension_test_message_listener.h"
#include "extensions/test/test_extension_dir.h"
+#include "ui/base/window_open_disposition.h"
namespace extensions {
namespace {
@@ -160,4 +166,59 @@ IN_PROC_BROWSER_TEST_F(ExtensionActionAPITest, TestNoUnnecessaryIO) {
}
}
+// Verify that tab-specific values are cleared on navigation and on tab
+// removal. Regression test for https://crbug.com/834033.
+IN_PROC_BROWSER_TEST_F(ExtensionActionAPITest,
+ ValuesAreClearedOnNavigationAndTabRemoval) {
+ ASSERT_TRUE(StartEmbeddedTestServer());
+
+ TestExtensionDir test_dir;
+ test_dir.WriteManifest(
+ R"({
+ "name": "Extension",
+ "description": "An extension",
+ "manifest_version": 2,
+ "version": "0.1",
+ "browser_action": {}
+ })");
+ const Extension* extension = LoadExtension(test_dir.UnpackedPath());
+ ASSERT_TRUE(extension);
+
+ auto* action_manager = ExtensionActionManager::Get(profile());
+ ExtensionAction* action = action_manager->GetExtensionAction(*extension);
+ ASSERT_TRUE(action);
+
+ GURL initial_url = embedded_test_server()->GetURL("/title1.html");
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(), initial_url, WindowOpenDisposition::NEW_FOREGROUND_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+
+ TabStripModel* tab_strip_model = browser()->tab_strip_model();
+ content::WebContents* web_contents = tab_strip_model->GetActiveWebContents();
+ int tab_id = SessionTabHelper::IdForTab(web_contents).id();
+
+ // There should be no explicit title to start, but should be one if we set
+ // one.
+ EXPECT_FALSE(action->HasTitle(tab_id));
+ action->SetTitle(tab_id, "alpha");
+ EXPECT_TRUE(action->HasTitle(tab_id));
+
+ // Navigating should clear the title.
+ GURL second_url = embedded_test_server()->GetURL("/title2.html");
+ ui_test_utils::NavigateToURL(browser(), second_url);
+
+ EXPECT_EQ(second_url, web_contents->GetLastCommittedURL());
+ EXPECT_FALSE(action->HasTitle(tab_id));
+
+ action->SetTitle(tab_id, "alpha");
+ {
+ content::WebContentsDestroyedWatcher destroyed_watcher(web_contents);
+ tab_strip_model->CloseWebContentsAt(tab_strip_model->active_index(),
+ TabStripModel::CLOSE_NONE);
+ destroyed_watcher.Wait();
+ }
+ // The title should have been cleared on tab removal as well.
+ EXPECT_FALSE(action->HasTitle(tab_id));
+}
+
} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/feedback_private/feedback_browsertest.cc b/chromium/chrome/browser/extensions/api/feedback_private/feedback_browsertest.cc
index 05be2e18013..2087659b39a 100644
--- a/chromium/chrome/browser/extensions/api/feedback_private/feedback_browsertest.cc
+++ b/chromium/chrome/browser/extensions/api/feedback_private/feedback_browsertest.cc
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "base/bind.h"
-#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "chrome/browser/apps/app_browsertest_util.h"
#include "chrome/browser/browser_process.h"
diff --git a/chromium/chrome/browser/extensions/api/file_system/chrome_file_system_delegate.cc b/chromium/chrome/browser/extensions/api/file_system/chrome_file_system_delegate.cc
index 57c2cf505ee..5d0ccc2fed6 100644
--- a/chromium/chrome/browser/extensions/api/file_system/chrome_file_system_delegate.cc
+++ b/chromium/chrome/browser/extensions/api/file_system/chrome_file_system_delegate.cc
@@ -230,7 +230,7 @@ ChromeFileSystemDelegate::~ChromeFileSystemDelegate() {}
base::FilePath ChromeFileSystemDelegate::GetDefaultDirectory() {
base::FilePath documents_dir;
- PathService::Get(chrome::DIR_USER_DOCUMENTS, &documents_dir);
+ base::PathService::Get(chrome::DIR_USER_DOCUMENTS, &documents_dir);
return documents_dir;
}
@@ -242,33 +242,28 @@ bool ChromeFileSystemDelegate::ShowSelectFileDialog(
FileSystemDelegate::FilesSelectedCallback files_selected_callback,
base::OnceClosure file_selection_canceled_callback) {
const Extension* extension = extension_function->extension();
- content::WebContents* web_contents = nullptr;
+ content::WebContents* web_contents =
+ extension_function->GetSenderWebContents();
+
+ if (!web_contents)
+ return false;
// TODO(asargent/benwells) - As a short term remediation for
// crbug.com/179010 we're adding the ability for a whitelisted extension to
// use this API since chrome.fileBrowserHandler.selectFile is ChromeOS-only.
// Eventually we'd like a better solution and likely this code will go back
// to being platform-app only.
- if (extension->is_platform_app()) {
- content::WebContents* candidate = content::WebContents::FromRenderFrameHost(
- extension_function->render_frame_host());
- // Make sure there is an app window associated with the web contents.
- if (AppWindowRegistry::Get(extension_function->browser_context())
- ->GetAppWindowForWebContents(candidate)) {
- web_contents = candidate;
- }
- } else {
- // TODO(michaelpg): As a workaround for crbug.com/736930, allow this to work
- // from a background page by using the the extended GetAssociatedWebContents
- // function provided by ChromeExtensionFunctionDetails. This is safe because
- // only whitelisted extensions can access the chrome.fileSystem API;
- // platform apps cannot open the file picker from a background page.
- web_contents = ChromeExtensionFunctionDetails(extension_function.get())
- .GetAssociatedWebContents();
- }
- if (!web_contents)
+ // Make sure there is an app window associated with the web contents, so that
+ // platform apps cannot open the file picker from a background page.
+ // TODO(michaelpg): As a workaround for https://crbug.com/736930, allow this
+ // to work from a background page for non-platform apps (which, in practice,
+ // is restricted to whitelisted extensions).
+ if (extension->is_platform_app() &&
+ !AppWindowRegistry::Get(extension_function->browser_context())
+ ->GetAppWindowForWebContents(web_contents)) {
return false;
+ }
// The file picker will hold a reference to the UIThreadExtensionFunction
// instance, preventing its destruction (and subsequent sending of the
diff --git a/chromium/chrome/browser/extensions/api/file_system/consent_provider_unittest.cc b/chromium/chrome/browser/extensions/api/file_system/consent_provider_unittest.cc
index cae7ed04cca..2289c0abd82 100644
--- a/chromium/chrome/browser/extensions/api/file_system/consent_provider_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/file_system/consent_provider_unittest.cc
@@ -181,10 +181,8 @@ TEST_F(FileSystemApiConsentProviderTest, ForKioskApps) {
{
scoped_refptr<Extension> auto_launch_kiosk_app(
ExtensionBuilder("Test", ExtensionBuilder::Type::PLATFORM_APP)
- .MergeManifest(DictionaryBuilder()
- .SetBoolean("kiosk_enabled", true)
- .SetBoolean("kiosk_only", true)
- .Build())
+ .SetManifestKey("kiosk_enabled", true)
+ .SetManifestKey("kiosk_only", true)
.Build());
user_manager_->AddKioskAppUser(
AccountId::FromUserEmail(auto_launch_kiosk_app->id()));
@@ -211,10 +209,8 @@ TEST_F(FileSystemApiConsentProviderTest, ForKioskApps) {
// receiving approval from the user.
scoped_refptr<Extension> manual_launch_kiosk_app(
ExtensionBuilder("Test", ExtensionBuilder::Type::PLATFORM_APP)
- .MergeManifest(DictionaryBuilder()
- .SetBoolean("kiosk_enabled", true)
- .SetBoolean("kiosk_only", true)
- .Build())
+ .SetManifestKey("kiosk_enabled", true)
+ .SetManifestKey("kiosk_only", true)
.Build());
user_manager::User* const manual_kiosk_app_user =
user_manager_->AddKioskAppUser(
diff --git a/chromium/chrome/browser/extensions/api/file_system/file_system_apitest.cc b/chromium/chrome/browser/extensions/api/file_system/file_system_apitest.cc
index 50a2b82e4eb..fe2b33bac09 100644
--- a/chromium/chrome/browser/extensions/api/file_system/file_system_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/file_system/file_system_apitest.cc
@@ -163,7 +163,7 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiGetDisplayPath) {
IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiGetDisplayPathPrettify) {
{
base::ScopedAllowBlockingForTesting allow_blocking;
- ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded(
+ ASSERT_TRUE(base::PathService::OverrideAndCreateIfNeeded(
base::DIR_HOME, test_root_folder_, false, false));
}
@@ -230,7 +230,7 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTest,
ASSERT_FALSE(test_file.empty());
{
base::ScopedAllowBlockingForTesting allow_blocking;
- ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded(
+ ASSERT_TRUE(base::PathService::OverrideAndCreateIfNeeded(
chrome::DIR_USER_DOCUMENTS, test_file.DirName(), false, false));
}
FileSystemChooseEntryFunction::
@@ -254,7 +254,7 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTest,
ASSERT_FALSE(test_file.empty());
{
base::ScopedAllowBlockingForTesting allow_blocking;
- ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded(
+ ASSERT_TRUE(base::PathService::OverrideAndCreateIfNeeded(
chrome::DIR_USER_DOCUMENTS, test_file.DirName(), false, false));
}
FileSystemChooseEntryFunction::
@@ -269,7 +269,7 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiOpenMultipleSuggested) {
ASSERT_FALSE(test_file.empty());
{
base::ScopedAllowBlockingForTesting allow_blocking;
- ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded(
+ ASSERT_TRUE(base::PathService::OverrideAndCreateIfNeeded(
chrome::DIR_USER_DOCUMENTS, test_file.DirName(), false, false));
}
FileSystemChooseEntryFunction::SkipPickerAndSelectSuggestedPathForTest();
@@ -351,7 +351,7 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTest,
base::FilePath test_directory = test_file.DirName();
{
base::ScopedAllowBlockingForTesting allow_blocking;
- ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded(
+ ASSERT_TRUE(base::PathService::OverrideAndCreateIfNeeded(
kGraylistedPath, test_directory, false, false));
}
FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
@@ -369,7 +369,7 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTest,
base::FilePath test_directory = test_file.DirName();
{
base::ScopedAllowBlockingForTesting allow_blocking;
- ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded(
+ ASSERT_TRUE(base::PathService::OverrideAndCreateIfNeeded(
kGraylistedPath, test_directory, false, false));
}
FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
@@ -388,7 +388,7 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTest,
base::FilePath parent_directory = test_directory.DirName();
{
base::ScopedAllowBlockingForTesting allow_blocking;
- ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded(
+ ASSERT_TRUE(base::PathService::OverrideAndCreateIfNeeded(
kGraylistedPath, test_directory, false, false));
}
FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
@@ -410,7 +410,7 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTest,
base::FilePath parent_directory = test_directory.DirName();
{
base::ScopedAllowBlockingForTesting allow_blocking;
- ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded(
+ ASSERT_TRUE(base::PathService::OverrideAndCreateIfNeeded(
kGraylistedPath, parent_directory, false, false));
}
FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
diff --git a/chromium/chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc b/chromium/chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc
index 9fa91d2ba67..183e3cad0cf 100644
--- a/chromium/chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc
+++ b/chromium/chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc
@@ -299,7 +299,7 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
FileSystemApiOpenMultipleSuggested) {
base::FilePath test_file = drive::util::GetDriveMountPointPath(
browser()->profile()).AppendASCII("root/open_existing.txt");
- ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded(
+ ASSERT_TRUE(base::PathService::OverrideAndCreateIfNeeded(
chrome::DIR_USER_DOCUMENTS, test_file.DirName(), true, false));
FileSystemChooseEntryFunction::SkipPickerAndSelectSuggestedPathForTest();
ASSERT_TRUE(RunPlatformAppTest(
diff --git a/chromium/chrome/browser/extensions/api/font_settings/font_settings_apitest.cc b/chromium/chrome/browser/extensions/api/font_settings/font_settings_apitest.cc
index 6e0fc6ff4db..603f84f1610 100644
--- a/chromium/chrome/browser/extensions/api/font_settings/font_settings_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/font_settings/font_settings_apitest.cc
@@ -11,6 +11,8 @@
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
+namespace extensions {
+
// Test of extension API on a standard profile.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, FontSettings) {
PrefService* prefs = browser()->profile()->GetPrefs();
@@ -36,3 +38,5 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, FontSettingsIncognito) {
"launch.html",
flags));
}
+
+} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/history/history_api.cc b/chromium/chrome/browser/extensions/api/history/history_api.cc
index c83fcd8c060..9e23c409306 100644
--- a/chromium/chrome/browser/extensions/api/history/history_api.cc
+++ b/chromium/chrome/browser/extensions/api/history/history_api.cc
@@ -149,16 +149,14 @@ void HistoryEventRouter::OnURLVisited(history::HistoryService* history_service,
api::history::OnVisited::kEventName, std::move(args));
}
-void HistoryEventRouter::OnURLsDeleted(history::HistoryService* history_service,
- bool all_history,
- bool expired,
- const history::URLRows& deleted_rows,
- const std::set<GURL>& favicon_urls) {
+void HistoryEventRouter::OnURLsDeleted(
+ history::HistoryService* history_service,
+ const history::DeletionInfo& deletion_info) {
OnVisitRemoved::Removed removed;
- removed.all_history = all_history;
+ removed.all_history = deletion_info.IsAllHistory();
std::vector<std::string>* urls = new std::vector<std::string>();
- for (const auto& row : deleted_rows)
+ for (const auto& row : deletion_info.deleted_rows())
urls->push_back(row.url().spec());
removed.urls.reset(urls);
diff --git a/chromium/chrome/browser/extensions/api/history/history_api.h b/chromium/chrome/browser/extensions/api/history/history_api.h
index f6b74f78d01..36d12ac0841 100644
--- a/chromium/chrome/browser/extensions/api/history/history_api.h
+++ b/chromium/chrome/browser/extensions/api/history/history_api.h
@@ -46,10 +46,7 @@ class HistoryEventRouter : public history::HistoryServiceObserver {
const history::RedirectList& redirects,
base::Time visit_time) override;
void OnURLsDeleted(history::HistoryService* history_service,
- bool all_history,
- bool expired,
- const history::URLRows& deleted_rows,
- const std::set<GURL>& favicon_urls) override;
+ const history::DeletionInfo& deletion_info) override;
void DispatchEvent(Profile* profile,
events::HistogramValue histogram_value,
diff --git a/chromium/chrome/browser/extensions/api/i18n/i18n_apitest.cc b/chromium/chrome/browser/extensions/api/i18n/i18n_apitest.cc
index 6eda3618fc2..b8d0b5b9e15 100644
--- a/chromium/chrome/browser/extensions/api/i18n/i18n_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/i18n/i18n_apitest.cc
@@ -14,6 +14,8 @@
#include "extensions/test/result_catcher.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
+namespace extensions {
+
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, I18N) {
ASSERT_TRUE(StartEmbeddedTestServer());
ASSERT_TRUE(RunExtensionTest("i18n")) << message_;
@@ -35,10 +37,9 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, I18NUpdate) {
test_data_dir_.AppendASCII("i18nUpdate").AppendASCII("_locales"),
extension_dir.GetPath().AppendASCII("_locales"), true);
- const extensions::Extension* extension =
- LoadExtension(extension_dir.GetPath());
+ const Extension* extension = LoadExtension(extension_dir.GetPath());
- extensions::ResultCatcher catcher;
+ ResultCatcher catcher;
// Test that the messages.json file is loaded and the i18n message is loaded.
ui_test_utils::NavigateToURL(
@@ -65,3 +66,5 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, I18NUpdate) {
ui_test_utils::GetCurrentTabTitle(browser(), &title);
EXPECT_EQ(std::string("SECONDMESSAGE"), base::UTF16ToUTF8(title));
}
+
+} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/identity/gaia_web_auth_flow_unittest.cc b/chromium/chrome/browser/extensions/api/identity/gaia_web_auth_flow_unittest.cc
index 57d3f43b709..79752bcfe86 100644
--- a/chromium/chrome/browser/extensions/api/identity/gaia_web_auth_flow_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/identity/gaia_web_auth_flow_unittest.cc
@@ -64,7 +64,7 @@ class IdentityGaiaWebAuthFlowTest : public testing::Test {
IdentityGaiaWebAuthFlowTest()
: ubertoken_error_state_(GoogleServiceAuthError::NONE) {}
- virtual void TearDown() {
+ void TearDown() override {
testing::Test::TearDown();
base::RunLoop loop;
loop.RunUntilIdle(); // Run tasks so FakeWebAuthFlows get deleted.
diff --git a/chromium/chrome/browser/extensions/api/identity/identity_apitest.cc b/chromium/chrome/browser/extensions/api/identity/identity_apitest.cc
index 2a6261ec2fe..3091e73d086 100644
--- a/chromium/chrome/browser/extensions/api/identity/identity_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/identity/identity_apitest.cc
@@ -14,16 +14,7 @@
#include "base/strings/string_util.h"
#include "base/values.h"
#include "build/build_config.h"
-#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
-#include "components/prefs/pref_service.h"
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/chromeos/login/users/mock_user_manager.h"
-#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
-#include "chrome/browser/chromeos/settings/stub_install_attributes.h"
-#include "components/user_manager/scoped_user_manager.h"
-#include "extensions/common/extension_builder.h"
-#endif
#include "chrome/browser/extensions/api/identity/identity_api.h"
#include "chrome/browser/extensions/api/identity/identity_constants.h"
#include "chrome/browser/extensions/api/identity/identity_get_accounts_function.h"
@@ -43,6 +34,7 @@
#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
#include "chrome/browser/signin/fake_signin_manager_builder.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
+#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/ui/browser.h"
@@ -52,6 +44,7 @@
#include "chrome/test/base/in_process_browser_test.h"
#include "components/crx_file/id_util.h"
#include "components/guest_view/browser/guest_view_base.h"
+#include "components/prefs/pref_service.h"
#include "components/signin/core/browser/account_fetcher_service.h"
#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/fake_gaia_cookie_manager_service.h"
@@ -70,14 +63,22 @@
#include "google_apis/gaia/oauth2_mint_token_flow.h"
#include "google_apis/gaia/oauth2_token_service.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
+#include "services/identity/public/cpp/identity_manager.h"
+#include "services/identity/public/cpp/identity_test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/login/users/mock_user_manager.h"
+#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
+#include "chrome/browser/chromeos/settings/stub_install_attributes.h"
+#include "components/user_manager/scoped_user_manager.h"
+#endif
+
using guest_view::GuestViewBase;
using testing::_;
using testing::Return;
-using testing::ReturnRef;
namespace extensions {
@@ -483,37 +484,26 @@ class IdentityTestWithSignin : public AsyncExtensionBrowserTest {
}
protected:
- void SignIn(const std::string& account_key) {
- SignIn(account_key, account_key);
- }
-
// Returns the account ID of the created account.
- std::string SignIn(const std::string& email, const std::string& gaia) {
- AccountTrackerService* account_tracker =
- AccountTrackerServiceFactory::GetForProfile(profile());
- std::string account_id = account_tracker->SeedAccountInfo(gaia, email);
-
-#if defined(OS_CHROMEOS)
- signin_manager_->SetAuthenticatedAccountInfo(gaia, email);
-#else
- signin_manager_->SignIn(gaia, email, "password");
-#endif
- token_service_->UpdateCredentials(account_id, "refresh_token");
-
- return account_id;
+ std::string SignIn(const std::string& email) {
+ identity::IdentityManager* identity_manager =
+ IdentityManagerFactory::GetForProfile(profile());
+ identity::MakePrimaryAccountAvailable(signin_manager_, token_service_,
+ identity_manager, email);
+ return identity_manager->GetPrimaryAccountInfo().account_id;
}
- void AddAccount(const std::string& email, const std::string& gaia) {
- AccountTrackerService* account_tracker =
- AccountTrackerServiceFactory::GetForProfile(profile());
- std::string account_id = account_tracker->SeedAccountInfo(gaia, email);
+ std::string AddAccount(const std::string& email) {
+ std::string account_id = SeedAccountInfo(email);
token_service_->UpdateCredentials(account_id, "refresh_token");
+ return account_id;
}
- void SeedAccountInfo(const std::string& account_key) {
+ std::string SeedAccountInfo(const std::string& email) {
+ std::string gaia = "gaia_id_for_" + email;
AccountTrackerService* account_tracker =
AccountTrackerServiceFactory::GetForProfile(profile());
- account_tracker->SeedAccountInfo(account_key, account_key);
+ return account_tracker->SeedAccountInfo(gaia, email);
}
FakeSigninManagerForTesting* signin_manager_;
@@ -532,59 +522,53 @@ class IdentityGetAccountsFunctionTest : public IdentityTestWithSignin {
protected:
testing::AssertionResult ExpectGetAccounts(
- const std::vector<std::string>& accounts) {
+ const std::vector<std::string>& gaia_ids) {
scoped_refptr<IdentityGetAccountsFunction> func(
new IdentityGetAccountsFunction);
func->set_extension(
ExtensionBuilder("Test").SetID(kExtensionId).Build().get());
if (!utils::RunFunction(func.get(), std::string("[]"), browser(),
api_test_utils::NONE)) {
- return GenerateFailureResult(accounts, NULL)
+ return GenerateFailureResult(gaia_ids, NULL)
<< "getAccounts did not return a result.";
}
const base::ListValue* callback_arguments = func->GetResultList();
if (!callback_arguments)
- return GenerateFailureResult(accounts, NULL) << "NULL result";
+ return GenerateFailureResult(gaia_ids, NULL) << "NULL result";
if (callback_arguments->GetSize() != 1) {
- return GenerateFailureResult(accounts, NULL)
+ return GenerateFailureResult(gaia_ids, NULL)
<< "Expected 1 argument but got " << callback_arguments->GetSize();
}
const base::ListValue* results;
if (!callback_arguments->GetList(0, &results))
- GenerateFailureResult(accounts, NULL) << "Result was not an array";
+ GenerateFailureResult(gaia_ids, NULL) << "Result was not an array";
std::set<std::string> result_ids;
- for (base::ListValue::const_iterator it = results->begin();
- it != results->end();
- ++it) {
+ for (const base::Value& item : *results) {
std::unique_ptr<api::identity::AccountInfo> info =
- api::identity::AccountInfo::FromValue(*it);
+ api::identity::AccountInfo::FromValue(item);
if (info.get())
result_ids.insert(info->id);
else
- return GenerateFailureResult(accounts, results);
+ return GenerateFailureResult(gaia_ids, results);
}
- for (std::vector<std::string>::const_iterator it = accounts.begin();
- it != accounts.end();
- ++it) {
- if (result_ids.find(*it) == result_ids.end())
- return GenerateFailureResult(accounts, results);
+ for (const std::string& gaia_id : gaia_ids) {
+ if (result_ids.find(gaia_id) == result_ids.end())
+ return GenerateFailureResult(gaia_ids, results);
}
return testing::AssertionResult(true);
}
testing::AssertionResult GenerateFailureResult(
- const ::std::vector<std::string>& accounts,
+ const ::std::vector<std::string>& gaia_ids,
const base::ListValue* results) {
testing::Message msg("Expected: ");
- for (std::vector<std::string>::const_iterator it = accounts.begin();
- it != accounts.end();
- ++it) {
- msg << *it << " ";
+ for (const std::string& gaia_id : gaia_ids) {
+ msg << gaia_id << " ";
}
msg << "Actual: ";
if (!results) {
@@ -609,36 +593,32 @@ IN_PROC_BROWSER_TEST_F(IdentityGetAccountsFunctionTest, MultiAccountOn) {
}
IN_PROC_BROWSER_TEST_F(IdentityGetAccountsFunctionTest, NoneSignedIn) {
- EXPECT_TRUE(ExpectGetAccounts(std::vector<std::string>()));
+ EXPECT_TRUE(ExpectGetAccounts({}));
}
IN_PROC_BROWSER_TEST_F(IdentityGetAccountsFunctionTest, NoPrimaryAccount) {
- AddAccount("secondary@example.com", "2");
- EXPECT_TRUE(ExpectGetAccounts(std::vector<std::string>()));
+ AddAccount("secondary@example.com");
+ EXPECT_TRUE(ExpectGetAccounts({}));
}
IN_PROC_BROWSER_TEST_F(IdentityGetAccountsFunctionTest,
PrimaryAccountHasNoRefreshToken) {
- std::string primary_account_id = SignIn("primary@example.com", "1");
+ std::string primary_account_id = SignIn("primary@example.com");
token_service_->RevokeCredentials(primary_account_id);
- EXPECT_TRUE(ExpectGetAccounts(std::vector<std::string>()));
+ EXPECT_TRUE(ExpectGetAccounts({}));
}
IN_PROC_BROWSER_TEST_F(IdentityGetAccountsFunctionTest,
PrimaryAccountSignedIn) {
- SignIn("primary@example.com", "1");
- std::vector<std::string> primary;
- primary.push_back("1");
- EXPECT_TRUE(ExpectGetAccounts(primary));
+ SignIn("primary@example.com");
+ EXPECT_TRUE(ExpectGetAccounts({"gaia_id_for_primary@example.com"}));
}
IN_PROC_BROWSER_TEST_F(IdentityGetAccountsFunctionTest, TwoAccountsSignedIn) {
- SignIn("primary@example.com", "1");
- AddAccount("secondary@example.com", "2");
- std::vector<std::string> two_accounts;
- two_accounts.push_back("1");
- two_accounts.push_back("2");
- EXPECT_TRUE(ExpectGetAccounts(two_accounts));
+ SignIn("primary@example.com");
+ AddAccount("secondary@example.com");
+ EXPECT_TRUE(ExpectGetAccounts({"gaia_id_for_primary@example.com",
+ "gaia_id_for_secondary@example.com"}));
}
class IdentityOldProfilesGetAccountsFunctionTest
@@ -656,11 +636,9 @@ IN_PROC_BROWSER_TEST_F(IdentityOldProfilesGetAccountsFunctionTest,
IN_PROC_BROWSER_TEST_F(IdentityOldProfilesGetAccountsFunctionTest,
TwoAccountsSignedIn) {
- SignIn("primary@example.com", "1");
- AddAccount("secondary@example.com", "2");
- std::vector<std::string> only_primary;
- only_primary.push_back("1");
- EXPECT_TRUE(ExpectGetAccounts(only_primary));
+ SignIn("primary@example.com");
+ AddAccount("secondary@example.com");
+ EXPECT_TRUE(ExpectGetAccounts({"gaia_id_for_primary@example.com"}));
}
class IdentityGetProfileUserInfoFunctionTest : public IdentityTestWithSignin {
@@ -687,11 +665,7 @@ class IdentityGetProfileUserInfoFunctionTest : public IdentityTestWithSignin {
private:
scoped_refptr<Extension> CreateExtensionWithEmailPermission() {
- std::unique_ptr<base::DictionaryValue> test_extension_value(
- api_test_utils::ParseDictionary(
- "{\"name\": \"Test\", \"version\": \"1.0\", "
- "\"permissions\": [\"identity.email\"]}"));
- return api_test_utils::CreateExtension(test_extension_value.get());
+ return ExtensionBuilder("Test").AddPermission("identity.email").Build();
}
};
@@ -703,11 +677,11 @@ IN_PROC_BROWSER_TEST_F(IdentityGetProfileUserInfoFunctionTest, NotSignedIn) {
}
IN_PROC_BROWSER_TEST_F(IdentityGetProfileUserInfoFunctionTest, SignedIn) {
- SignIn("president@example.com", "12345");
+ SignIn("president@example.com");
std::unique_ptr<api::identity::ProfileUserInfo> info =
RunGetProfileUserInfoWithEmail();
EXPECT_EQ("president@example.com", info->email);
- EXPECT_EQ("12345", info->id);
+ EXPECT_EQ("gaia_id_for_president@example.com", info->id);
}
IN_PROC_BROWSER_TEST_F(IdentityGetProfileUserInfoFunctionTest,
@@ -720,7 +694,7 @@ IN_PROC_BROWSER_TEST_F(IdentityGetProfileUserInfoFunctionTest,
IN_PROC_BROWSER_TEST_F(IdentityGetProfileUserInfoFunctionTest,
SignedInNoEmail) {
- SignIn("president@example.com", "12345");
+ SignIn("president@example.com");
std::unique_ptr<api::identity::ProfileUserInfo> info =
RunGetProfileUserInfo();
EXPECT_TRUE(info->email.empty());
@@ -736,11 +710,12 @@ class GetAuthTokenFunctionTest
command_line->AppendSwitch(switches::kExtensionsMultiAccount);
}
- void IssueLoginAccessTokenForAccount(const std::string& account_key) {
+ std::string IssueLoginAccessTokenForAccount(const std::string& account_id) {
+ std::string access_token = "access_token-" + account_id;
token_service_->IssueAllTokensForAccount(
- account_key,
- "access_token-" + account_key,
+ account_id, access_token,
base::Time::Now() + base::TimeDelta::FromSeconds(3600));
+ return access_token;
}
protected:
@@ -1675,7 +1650,7 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
}
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, ManuallyIssueToken) {
- SignIn("primary@example.com");
+ std::string primary_account_id = SignIn("primary@example.com");
scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction());
scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
@@ -1690,7 +1665,8 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, ManuallyIssueToken) {
RunFunctionAsync(func.get(), "[{}]");
run_loop.Run();
- IssueLoginAccessTokenForAccount("primary@example.com");
+ std::string primary_account_access_token =
+ IssueLoginAccessTokenForAccount(primary_account_id);
std::unique_ptr<base::Value> value(WaitForSingleResult(func.get()));
std::string access_token;
@@ -1698,11 +1674,11 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, ManuallyIssueToken) {
EXPECT_EQ(std::string(kAccessToken), access_token);
EXPECT_EQ(IdentityTokenCacheValue::CACHE_STATUS_TOKEN,
GetCachedToken(std::string()).status());
- EXPECT_EQ("access_token-primary@example.com", func->login_access_token());
+ EXPECT_EQ(primary_account_access_token, func->login_access_token());
}
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, ManuallyIssueTokenFailure) {
- SignIn("primary@example.com");
+ std::string primary_account_id = SignIn("primary@example.com");
scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction());
scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
@@ -1718,7 +1694,7 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, ManuallyIssueTokenFailure) {
run_loop.Run();
token_service_->IssueErrorForAllPendingRequestsForAccount(
- "primary@example.com",
+ primary_account_id,
GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE));
EXPECT_EQ(
@@ -1730,7 +1706,7 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, ManuallyIssueTokenFailure) {
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
MultiDefaultUserManuallyIssueToken) {
- SignIn("primary@example.com");
+ std::string primary_account_id = SignIn("primary@example.com");
SeedAccountInfo("secondary@example.com");
scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction());
@@ -1744,7 +1720,8 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
RunFunctionAsync(func.get(), "[{}]");
run_loop.Run();
- IssueLoginAccessTokenForAccount("primary@example.com");
+ std::string primary_account_access_token =
+ IssueLoginAccessTokenForAccount(primary_account_id);
std::unique_ptr<base::Value> value(WaitForSingleResult(func.get()));
std::string access_token;
@@ -1752,13 +1729,13 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
EXPECT_EQ(std::string(kAccessToken), access_token);
EXPECT_EQ(IdentityTokenCacheValue::CACHE_STATUS_TOKEN,
GetCachedToken(std::string()).status());
- EXPECT_EQ("access_token-primary@example.com", func->login_access_token());
+ EXPECT_EQ(primary_account_access_token, func->login_access_token());
}
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
MultiPrimaryUserManuallyIssueToken) {
- SignIn("primary@example.com");
- AddAccount("secondary@example.com", "secondary@example.com");
+ std::string primary_account_id = SignIn("primary@example.com");
+ AddAccount("secondary@example.com");
scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction());
scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
@@ -1768,11 +1745,13 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
base::RunLoop run_loop;
on_access_token_requested_ = run_loop.QuitClosure();
- RunFunctionAsync(func.get(),
- "[{\"account\": { \"id\": \"primary@example.com\" } }]");
+ RunFunctionAsync(
+ func.get(),
+ "[{\"account\": { \"id\": \"gaia_id_for_primary@example.com\" } }]");
run_loop.Run();
- IssueLoginAccessTokenForAccount("primary@example.com");
+ std::string primary_account_access_token =
+ IssueLoginAccessTokenForAccount(primary_account_id);
std::unique_ptr<base::Value> value(WaitForSingleResult(func.get()));
std::string access_token;
@@ -1780,13 +1759,13 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
EXPECT_EQ(std::string(kAccessToken), access_token);
EXPECT_EQ(IdentityTokenCacheValue::CACHE_STATUS_TOKEN,
GetCachedToken(std::string()).status());
- EXPECT_EQ("access_token-primary@example.com", func->login_access_token());
+ EXPECT_EQ(primary_account_access_token, func->login_access_token());
}
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
MultiSecondaryUserManuallyIssueToken) {
- SignIn("primary@example.com");
- AddAccount("secondary@example.com", "secondary@example.com");
+ std::string primary_account_id = SignIn("primary@example.com");
+ std::string secondary_account_id = AddAccount("secondary@example.com");
scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction());
scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
@@ -1796,25 +1775,27 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
base::RunLoop run_loop;
on_access_token_requested_ = run_loop.QuitClosure();
- RunFunctionAsync(func.get(),
- "[{\"account\": { \"id\": \"secondary@example.com\" } }]");
+ RunFunctionAsync(
+ func.get(),
+ "[{\"account\": { \"id\": \"gaia_id_for_secondary@example.com\" } }]");
run_loop.Run();
- IssueLoginAccessTokenForAccount("secondary@example.com");
+ std::string secondary_account_access_token =
+ IssueLoginAccessTokenForAccount(secondary_account_id);
std::unique_ptr<base::Value> value(WaitForSingleResult(func.get()));
std::string access_token;
EXPECT_TRUE(value->GetAsString(&access_token));
EXPECT_EQ(std::string(kAccessToken), access_token);
EXPECT_EQ(IdentityTokenCacheValue::CACHE_STATUS_TOKEN,
- GetCachedToken("secondary@example.com").status());
- EXPECT_EQ("access_token-secondary@example.com", func->login_access_token());
+ GetCachedToken(secondary_account_id).status());
+ EXPECT_EQ(secondary_account_access_token, func->login_access_token());
}
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
MultiUnknownUserGetTokenFromTokenServiceFailure) {
SignIn("primary@example.com");
- AddAccount("secondary@example.com", "secondary@example.com");
+ AddAccount("secondary@example.com");
scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction());
scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
@@ -1830,13 +1811,14 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
MultiSecondaryNonInteractiveMintFailure) {
SignIn("primary@example.com");
- AddAccount("secondary@example.com", "secondary@example.com");
+ AddAccount("secondary@example.com");
scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction());
func->set_extension(CreateExtension(CLIENT_ID | SCOPES));
func->set_mint_token_result(TestOAuth2MintTokenFlow::MINT_TOKEN_FAILURE);
std::string error = utils::RunFunctionAndReturnError(
- func.get(), "[{\"account\": { \"id\": \"secondary@example.com\" } }]",
+ func.get(),
+ "[{\"account\": { \"id\": \"gaia_id_for_secondary@example.com\" } }]",
browser());
EXPECT_TRUE(base::StartsWith(error, errors::kAuthFailure,
base::CompareCase::INSENSITIVE_ASCII));
@@ -1847,13 +1829,14 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
MultiSecondaryNonInteractiveLoginAccessTokenFailure) {
SignIn("primary@example.com");
- AddAccount("secondary@example.com", "secondary@example.com");
+ AddAccount("secondary@example.com");
scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction());
func->set_extension(CreateExtension(CLIENT_ID | SCOPES));
func->set_login_access_token_result(false);
std::string error = utils::RunFunctionAndReturnError(
- func.get(), "[{\"account\": { \"id\": \"secondary@example.com\" } }]",
+ func.get(),
+ "[{\"account\": { \"id\": \"gaia_id_for_secondary@example.com\" } }]",
browser());
EXPECT_TRUE(base::StartsWith(error, errors::kAuthFailure,
base::CompareCase::INSENSITIVE_ASCII));
@@ -1862,7 +1845,7 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
MultiSecondaryInteractiveApprovalAborted) {
SignIn("primary@example.com");
- AddAccount("secondary@example.com", "secondary@example.com");
+ AddAccount("secondary@example.com");
scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction());
func->set_extension(CreateExtension(CLIENT_ID | SCOPES));
@@ -1870,7 +1853,8 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
func->set_scope_ui_failure(GaiaWebAuthFlow::WINDOW_CLOSED);
std::string error = utils::RunFunctionAndReturnError(
func.get(),
- "[{\"account\": { \"id\": \"secondary@example.com\" }, \"interactive\": "
+ "[{\"account\": { \"id\": \"gaia_id_for_secondary@example.com\" }, "
+ "\"interactive\": "
"true}]",
browser());
EXPECT_EQ(std::string(errors::kUserRejected), error);
@@ -1970,18 +1954,12 @@ class GetAuthTokenFunctionPublicSessionTest : public GetAuthTokenFunctionTest {
}
scoped_refptr<Extension> CreateTestExtension(const std::string& id) {
- return ExtensionBuilder()
- .SetManifest(
- DictionaryBuilder()
- .Set("name", "Test")
- .Set("version", "1.0")
- .Set("oauth2",
- DictionaryBuilder()
- .Set("client_id", "clientId")
- .Set("scopes", ListBuilder().Append("scope1").Build())
- .Build())
- .Build())
- .SetLocation(Manifest::UNPACKED)
+ return ExtensionBuilder("Test")
+ .SetManifestKey(
+ "oauth2", DictionaryBuilder()
+ .Set("client_id", "clientId")
+ .Set("scopes", ListBuilder().Append("scope1").Build())
+ .Build())
.SetID(id)
.Build();
}
@@ -2302,11 +2280,11 @@ class OnSignInChangedEventTest : public IdentityTestWithSignin {
// Test that an event is fired when the primary account signs in.
IN_PROC_BROWSER_TEST_F(OnSignInChangedEventTest, FireOnPrimaryAccountSignIn) {
api::identity::AccountInfo account_info;
- account_info.id = "primary";
+ account_info.id = "gaia_id_for_primary@example.com";
AddExpectedEvent(api::identity::OnSignInChanged::Create(account_info, true));
// Sign in and verify that the callback fires.
- SignIn("primary", "primary");
+ SignIn("primary@example.com");
EXPECT_FALSE(HasExpectedEvent());
}
@@ -2315,10 +2293,10 @@ IN_PROC_BROWSER_TEST_F(OnSignInChangedEventTest, FireOnPrimaryAccountSignIn) {
// Test that an event is fired when the primary account signs out.
IN_PROC_BROWSER_TEST_F(OnSignInChangedEventTest, FireOnPrimaryAccountSignOut) {
api::identity::AccountInfo account_info;
- account_info.id = "primary";
+ account_info.id = "gaia_id_for_primary@example.com";
AddExpectedEvent(api::identity::OnSignInChanged::Create(account_info, true));
- SignIn("primary", "primary");
+ SignIn("primary@example.com");
AddExpectedEvent(api::identity::OnSignInChanged::Create(account_info, false));
@@ -2334,15 +2312,15 @@ IN_PROC_BROWSER_TEST_F(OnSignInChangedEventTest, FireOnPrimaryAccountSignOut) {
IN_PROC_BROWSER_TEST_F(OnSignInChangedEventTest,
FireOnPrimaryAccountRefreshTokenRevoked) {
api::identity::AccountInfo account_info;
- account_info.id = "primary";
+ account_info.id = "gaia_id_for_primary@example.com";
AddExpectedEvent(api::identity::OnSignInChanged::Create(account_info, true));
- SignIn("primary", "primary");
+ std::string primary_account_id = SignIn("primary@example.com");
AddExpectedEvent(api::identity::OnSignInChanged::Create(account_info, false));
// Revoke the refresh token and verify that the callback fires.
- token_service_->RevokeCredentials("primary");
+ token_service_->RevokeCredentials(primary_account_id);
EXPECT_FALSE(HasExpectedEvent());
}
@@ -2352,51 +2330,51 @@ IN_PROC_BROWSER_TEST_F(OnSignInChangedEventTest,
IN_PROC_BROWSER_TEST_F(OnSignInChangedEventTest,
FireOnPrimaryAccountRefreshTokenAvailable) {
api::identity::AccountInfo account_info;
- account_info.id = "primary";
+ account_info.id = "gaia_id_for_primary@example.com";
AddExpectedEvent(api::identity::OnSignInChanged::Create(account_info, true));
- SignIn("primary", "primary");
+ std::string primary_account_id = SignIn("primary@example.com");
AddExpectedEvent(api::identity::OnSignInChanged::Create(account_info, false));
- token_service_->RevokeCredentials("primary");
+ token_service_->RevokeCredentials(primary_account_id);
- account_info.id = "primary";
+ account_info.id = "gaia_id_for_primary@example.com";
AddExpectedEvent(api::identity::OnSignInChanged::Create(account_info, true));
// Make the primary account's refresh token available and check that the
// callback fires. Note that we must call AddAccount() here as the account's
// information must be present in the AccountTrackerService as well.
- AddAccount("primary", "primary");
+ AddAccount("primary@example.com");
EXPECT_FALSE(HasExpectedEvent());
}
// Test that an event is fired for changes to a secondary account.
IN_PROC_BROWSER_TEST_F(OnSignInChangedEventTest, FireForSecondaryAccount) {
api::identity::AccountInfo account_info;
- account_info.id = "primary";
+ account_info.id = "gaia_id_for_primary@example.com";
AddExpectedEvent(api::identity::OnSignInChanged::Create(account_info, true));
- SignIn("primary", "primary");
+ SignIn("primary@example.com");
- account_info.id = "secondary";
+ account_info.id = "gaia_id_for_secondary@example.com";
AddExpectedEvent(api::identity::OnSignInChanged::Create(account_info, true));
// Make a secondary account's refresh token available and check that the
// callback fires. Note that we must call AddAccount() here as the account's
// information must be present in the AccountTrackerService as well.
- AddAccount("secondary", "secondary");
+ std::string secondary_account_id = AddAccount("secondary@example.com");
EXPECT_FALSE(HasExpectedEvent());
// Revoke the secondary account's refresh token and check that the callback
// fires.
AddExpectedEvent(api::identity::OnSignInChanged::Create(account_info, false));
- token_service_->RevokeCredentials("secondary");
+ token_service_->RevokeCredentials(secondary_account_id);
EXPECT_FALSE(HasExpectedEvent());
}
-} // namespace extensions
-
// Tests the chrome.identity API implemented by custom JS bindings .
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) {
ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_;
}
+
+} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/idltest/idltest_apitest.cc b/chromium/chrome/browser/extensions/api/idltest/idltest_apitest.cc
index a81cb23da8f..2329c872cb7 100644
--- a/chromium/chrome/browser/extensions/api/idltest/idltest_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/idltest/idltest_apitest.cc
@@ -7,7 +7,7 @@
#include "extensions/common/features/feature_channel.h"
#include "extensions/common/switches.h"
-class ExtensionIdltestApiTest : public ExtensionApiTest {
+class ExtensionIdltestApiTest : public extensions::ExtensionApiTest {
public:
// Set the channel to "trunk" since idltest is restricted to trunk.
ExtensionIdltestApiTest() : trunk_(version_info::Channel::UNKNOWN) {}
diff --git a/chromium/chrome/browser/extensions/api/image_writer_private/image_writer_private_apitest.cc b/chromium/chrome/browser/extensions/api/image_writer_private/image_writer_private_apitest.cc
index ddcd1a3b317..ce0e8bbd6bc 100644
--- a/chromium/chrome/browser/extensions/api/image_writer_private/image_writer_private_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/image_writer_private/image_writer_private_apitest.cc
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/message_loop/message_loop.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/api/image_writer_private/operation.h"
#include "chrome/browser/extensions/api/image_writer_private/removable_storage_provider.h"
diff --git a/chromium/chrome/browser/extensions/api/image_writer_private/operation_unittest.cc b/chromium/chrome/browser/extensions/api/image_writer_private/operation_unittest.cc
index 3f0a8bceef5..2d3d0c32d99 100644
--- a/chromium/chrome/browser/extensions/api/image_writer_private/operation_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/image_writer_private/operation_unittest.cc
@@ -6,7 +6,6 @@
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/api/image_writer_private/error_messages.h"
diff --git a/chromium/chrome/browser/extensions/api/image_writer_private/test_utils.h b/chromium/chrome/browser/extensions/api/image_writer_private/test_utils.h
index 4e3ed443001..1031b57f7fa 100644
--- a/chromium/chrome/browser/extensions/api/image_writer_private/test_utils.h
+++ b/chromium/chrome/browser/extensions/api/image_writer_private/test_utils.h
@@ -11,7 +11,6 @@
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/test/scoped_task_environment.h"
#include "build/build_config.h"
@@ -46,7 +45,7 @@ const char kTestFileSystemType[] = "vfat";
class MockOperationManager : public OperationManager {
public:
explicit MockOperationManager(content::BrowserContext* context);
- virtual ~MockOperationManager();
+ ~MockOperationManager() override;
MOCK_METHOD3(OnProgress, void(const ExtensionId& extension_id,
image_writer_api::Stage stage,
diff --git a/chromium/chrome/browser/extensions/api/inline_install_private/inline_install_private_api.cc b/chromium/chrome/browser/extensions/api/inline_install_private/inline_install_private_api.cc
index 870613d80e3..66322d86a48 100644
--- a/chromium/chrome/browser/extensions/api/inline_install_private/inline_install_private_api.cc
+++ b/chromium/chrome/browser/extensions/api/inline_install_private/inline_install_private_api.cc
@@ -14,6 +14,7 @@
#include "components/crx_file/id_util.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/extension_registry.h"
+#include "extensions/browser/view_type_utils.h"
namespace extensions {
@@ -106,10 +107,11 @@ InlineInstallPrivateInstallFunction::Run() {
return RespondNow(CreateResponse("Must be called with a user gesture",
webstore_install::NOT_PERMITTED));
- content::WebContents* web_contents = GetAssociatedWebContents();
- if (!web_contents)
+ content::WebContents* web_contents = GetSenderWebContents();
+ if (!web_contents || GetViewType(web_contents) != VIEW_TYPE_APP_WINDOW) {
return RespondNow(CreateResponse("Must be called from a foreground page",
webstore_install::NOT_PERMITTED));
+ }
ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context());
if (registry->GetExtensionById(params->id, ExtensionRegistry::EVERYTHING))
diff --git a/chromium/chrome/browser/extensions/api/input_ime/input_ime_api.cc b/chromium/chrome/browser/extensions/api/input_ime/input_ime_api.cc
index fdf6dab9bdd..34b2a987294 100644
--- a/chromium/chrome/browser/extensions/api/input_ime/input_ime_api.cc
+++ b/chromium/chrome/browser/extensions/api/input_ime/input_ime_api.cc
@@ -59,6 +59,7 @@ void ImeObserver::OnFocus(
context_value.auto_correct = ConvertInputContextAutoCorrect(context);
context_value.auto_complete = ConvertInputContextAutoComplete(context);
context_value.spell_check = ConvertInputContextSpellCheck(context);
+ context_value.should_do_learning = context.should_do_learning;
std::unique_ptr<base::ListValue> args(
input_ime::OnFocus::Create(context_value));
diff --git a/chromium/chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.cc b/chromium/chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.cc
index 022c1f2d20b..85611abe334 100644
--- a/chromium/chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.cc
+++ b/chromium/chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.cc
@@ -25,8 +25,10 @@
#include "ui/base/ime/chromeos/input_method_manager.h"
#include "ui/base/ime/ime_engine_handler_interface.h"
#include "ui/keyboard/keyboard_controller.h"
+#include "ui/keyboard/keyboard_util.h"
namespace input_ime = extensions::api::input_ime;
+namespace input_method_private = extensions::api::input_method_private;
namespace DeleteSurroundingText =
extensions::api::input_ime::DeleteSurroundingText;
namespace UpdateMenuItems = extensions::api::input_ime::UpdateMenuItems;
@@ -188,6 +190,39 @@ class ImeObserverChromeOS : public ui::ImeObserver {
OnCompositionBoundsChanged::kEventName, std::move(args));
}
+ void OnFocus(
+ const IMEEngineHandlerInterface::InputContext& context) override {
+ if (extension_id_.empty())
+ return;
+
+ // There is both a public and private OnFocus event. The private OnFocus
+ // event is only for ChromeOS and contains additional information about pen
+ // inputs. We ensure that we only trigger one OnFocus event.
+ if (HasListener(input_method_private::OnFocus::kEventName) &&
+ keyboard::IsStylusVirtualKeyboardEnabled()) {
+ input_method_private::InputContext input_context;
+ input_context.context_id = context.id;
+ input_context.type = input_method_private::ParseInputContextType(
+ ConvertInputContextType(context));
+ input_context.auto_correct = ConvertInputContextAutoCorrect(context);
+ input_context.auto_complete = ConvertInputContextAutoComplete(context);
+ input_context.spell_check = ConvertInputContextSpellCheck(context);
+ input_context.should_do_learning = context.should_do_learning;
+ input_context.focus_reason = input_method_private::ParseFocusReason(
+ ConvertInputContextFocusReason(context));
+
+ std::unique_ptr<base::ListValue> args(
+ input_method_private::OnFocus::Create(input_context));
+
+ DispatchEventToExtension(
+ extensions::events::INPUT_METHOD_PRIVATE_ON_FOCUS,
+ input_method_private::OnFocus::kEventName, std::move(args));
+ return;
+ }
+
+ ImeObserver::OnFocus(context);
+ }
+
private:
// ui::ImeObserver overrides.
void DispatchEventToExtension(
@@ -251,6 +286,22 @@ class ImeObserverChromeOS : public ui::ImeObserver {
return "normal";
}
+ std::string ConvertInputContextFocusReason(
+ ui::IMEEngineHandlerInterface::InputContext input_context) {
+ switch (input_context.focus_reason) {
+ case ui::TextInputClient::FOCUS_REASON_NONE:
+ return "";
+ case ui::TextInputClient::FOCUS_REASON_MOUSE:
+ return "mouse";
+ case ui::TextInputClient::FOCUS_REASON_TOUCH:
+ return "touch";
+ case ui::TextInputClient::FOCUS_REASON_PEN:
+ return "pen";
+ case ui::TextInputClient::FOCUS_REASON_OTHER:
+ return "other";
+ }
+ }
+
DISALLOW_COPY_AND_ASSIGN(ImeObserverChromeOS);
};
@@ -619,6 +670,26 @@ InputMethodPrivateNotifyImeMenuItemActivatedFunction::Run() {
return RespondNow(NoArguments());
}
+ExtensionFunction::ResponseAction
+InputMethodPrivateGetCompositionBoundsFunction::Run() {
+ InputMethodEngine* engine = GetActiveEngine(
+ Profile::FromBrowserContext(browser_context()), extension_id());
+ if (!engine)
+ return RespondNow(Error(kErrorEngineNotAvailable));
+
+ auto bounds_list = std::make_unique<base::ListValue>();
+ for (const auto& bounds : engine->composition_bounds()) {
+ auto bounds_value = std::make_unique<base::DictionaryValue>();
+ bounds_value->SetInteger("x", bounds.x());
+ bounds_value->SetInteger("y", bounds.y());
+ bounds_value->SetInteger("w", bounds.width());
+ bounds_value->SetInteger("h", bounds.height());
+ bounds_list->Append(std::move(bounds_value));
+ }
+
+ return RespondNow(OneArgument(std::move(bounds_list)));
+}
+
void InputImeAPI::OnExtensionLoaded(content::BrowserContext* browser_context,
const Extension* extension) {
const std::vector<InputComponentInfo>* input_components =
diff --git a/chromium/chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.h b/chromium/chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.h
index c329b90cb88..7356db8c224 100644
--- a/chromium/chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.h
+++ b/chromium/chrome/browser/extensions/api/input_ime/input_ime_api_chromeos.h
@@ -133,6 +133,19 @@ class InputMethodPrivateNotifyImeMenuItemActivatedFunction
InputMethodPrivateNotifyImeMenuItemActivatedFunction);
};
+class InputMethodPrivateGetCompositionBoundsFunction
+ : public UIThreadExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.getCompositionBounds",
+ INPUTMETHODPRIVATE_GETCOMPOSITIONBOUNDS)
+
+ protected:
+ ~InputMethodPrivateGetCompositionBoundsFunction() override {}
+
+ // ExtensionFunction:
+ ResponseAction Run() override;
+};
+
class InputImeEventRouter : public InputImeEventRouterBase {
public:
explicit InputImeEventRouter(Profile* profile);
diff --git a/chromium/chrome/browser/extensions/api/input_ime/input_ime_apitest_chromeos.cc b/chromium/chrome/browser/extensions/api/input_ime/input_ime_apitest_chromeos.cc
index af200cec127..01b8c20f9d3 100644
--- a/chromium/chrome/browser/extensions/api/input_ime/input_ime_apitest_chromeos.cc
+++ b/chromium/chrome/browser/extensions/api/input_ime/input_ime_apitest_chromeos.cc
@@ -8,8 +8,12 @@
#include "extensions/browser/api/test/test_api.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace extensions {
+
#if defined(OS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, InputImeApiBasic) {
ASSERT_TRUE(RunExtensionTest("input_ime")) << message_;
}
#endif
+
+} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/instance_id/instance_id_api.cc b/chromium/chrome/browser/extensions/api/instance_id/instance_id_api.cc
index bb844a69c6c..4f1b565131a 100644
--- a/chromium/chrome/browser/extensions/api/instance_id/instance_id_api.cc
+++ b/chromium/chrome/browser/extensions/api/instance_id/instance_id_api.cc
@@ -8,11 +8,11 @@
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
-#include "chrome/browser/gcm/instance_id/instance_id_profile_service.h"
#include "chrome/browser/gcm/instance_id/instance_id_profile_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/instance_id.h"
#include "components/gcm_driver/instance_id/instance_id_driver.h"
+#include "components/gcm_driver/instance_id/instance_id_profile_service.h"
#include "extensions/common/extension.h"
namespace extensions {
@@ -76,7 +76,8 @@ ExtensionFunction::ResponseAction InstanceIDApiFunction::Run() {
bool InstanceIDApiFunction::IsEnabled() const {
Profile* profile = Profile::FromBrowserContext(browser_context());
- return instance_id::InstanceIDProfileService::IsInstanceIDEnabled(profile);
+ return instance_id::InstanceIDProfileService::IsInstanceIDEnabled(
+ profile->GetPrefs());
}
instance_id::InstanceID* InstanceIDApiFunction::GetInstanceID() const {
diff --git a/chromium/chrome/browser/extensions/api/management/chrome_management_api_delegate.cc b/chromium/chrome/browser/extensions/api/management/chrome_management_api_delegate.cc
index c1701dac388..5da7b5d1b97 100644
--- a/chromium/chrome/browser/extensions/api/management/chrome_management_api_delegate.cc
+++ b/chromium/chrome/browser/extensions/api/management/chrome_management_api_delegate.cc
@@ -316,11 +316,13 @@ void ChromeManagementAPIDelegate::EnableExtension(
void ChromeManagementAPIDelegate::DisableExtension(
content::BrowserContext* context,
+ const extensions::Extension* source_extension,
const std::string& extension_id,
extensions::disable_reason::DisableReason disable_reason) const {
extensions::ExtensionSystem::Get(context)
->extension_service()
- ->DisableExtension(extension_id, disable_reason);
+ ->DisableExtensionWithSource(source_extension, extension_id,
+ disable_reason);
}
bool ChromeManagementAPIDelegate::UninstallExtension(
diff --git a/chromium/chrome/browser/extensions/api/management/chrome_management_api_delegate.h b/chromium/chrome/browser/extensions/api/management/chrome_management_api_delegate.h
index fa8e88c5825..eb53b3d9d8a 100644
--- a/chromium/chrome/browser/extensions/api/management/chrome_management_api_delegate.h
+++ b/chromium/chrome/browser/extensions/api/management/chrome_management_api_delegate.h
@@ -52,6 +52,7 @@ class ChromeManagementAPIDelegate : public extensions::ManagementAPIDelegate {
const std::string& extension_id) const override;
void DisableExtension(
content::BrowserContext* context,
+ const extensions::Extension* source_extension,
const std::string& extension_id,
extensions::disable_reason::DisableReason disable_reason) const override;
bool UninstallExtension(content::BrowserContext* context,
diff --git a/chromium/chrome/browser/extensions/api/management/management_api_browsertest.cc b/chromium/chrome/browser/extensions/api/management/management_api_browsertest.cc
index e144c34a723..63f3124ab1a 100644
--- a/chromium/chrome/browser/extensions/api/management/management_api_browsertest.cc
+++ b/chromium/chrome/browser/extensions/api/management/management_api_browsertest.cc
@@ -4,6 +4,7 @@
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
+#include "base/memory/scoped_refptr.h"
#include "base/strings/pattern.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
@@ -26,6 +27,7 @@
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/notification_types.h"
+#include "extensions/common/extension_builder.h"
#include "extensions/test/extension_test_message_listener.h"
namespace keys = extension_management_api_constants;
@@ -206,10 +208,13 @@ class ExtensionManagementApiEscalationTest :
->DidExtensionEscalatePermissions(kId));
}
- void SetEnabled(bool enabled, bool user_gesture,
- const std::string& expected_error) {
+ void SetEnabled(bool enabled,
+ bool user_gesture,
+ const std::string& expected_error,
+ scoped_refptr<const Extension> extension) {
scoped_refptr<ManagementSetEnabledFunction> function(
new ManagementSetEnabledFunction);
+ function->set_extension(extension);
const char* const enabled_string = enabled ? "true" : "false";
if (user_gesture)
function->set_user_gesture(true);
@@ -251,14 +256,18 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiEscalationTest,
IN_PROC_BROWSER_TEST_F(ExtensionManagementApiEscalationTest,
SetEnabled) {
+ scoped_refptr<const Extension> source_extension =
+ ExtensionBuilder("test").Build();
+
// Expect an error about no gesture.
- SetEnabled(true, false, keys::kGestureNeededForEscalationError);
+ SetEnabled(true, false, keys::kGestureNeededForEscalationError,
+ source_extension);
{
// Expect an error that user cancelled the dialog.
ScopedTestDialogAutoConfirm auto_confirm(
ScopedTestDialogAutoConfirm::CANCEL);
- SetEnabled(true, true, keys::kUserDidNotReEnableError);
+ SetEnabled(true, true, keys::kUserDidNotReEnableError, source_extension);
}
{
@@ -271,7 +280,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiEscalationTest,
content::NotificationService::AllSources());
ScopedTestDialogAutoConfirm auto_confirm(
ScopedTestDialogAutoConfirm::ACCEPT);
- SetEnabled(true, true, std::string());
+ SetEnabled(true, true, std::string(), source_extension);
observer.Wait();
}
@@ -281,8 +290,14 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiEscalationTest,
ScopedTestDialogAutoConfirm auto_confirm(
ScopedTestDialogAutoConfirm::ACCEPT);
ASSERT_TRUE(CrashEnabledExtension(kId));
- SetEnabled(false, true, std::string());
- SetEnabled(true, true, std::string());
+ // Register the target extension with extension service.
+ scoped_refptr<const Extension> target_extension =
+ ExtensionBuilder("TargetExtension").SetID(kId).Build();
+ ExtensionService* const service =
+ ExtensionSystem::Get(browser()->profile())->extension_service();
+ service->AddExtension(target_extension.get());
+ SetEnabled(false, true, std::string(), source_extension);
+ SetEnabled(true, true, std::string(), source_extension);
const Extension* extension = ExtensionSystem::Get(browser()->profile())
->extension_service()
->GetExtensionById(kId, false);
diff --git a/chromium/chrome/browser/extensions/api/management/management_api_unittest.cc b/chromium/chrome/browser/extensions/api/management/management_api_unittest.cc
index d6e125dc86b..44ca34b11fa 100644
--- a/chromium/chrome/browser/extensions/api/management/management_api_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/management/management_api_unittest.cc
@@ -111,9 +111,13 @@ void ManagementApiUnitTest::TearDown() {
TEST_F(ManagementApiUnitTest, ManagementSetEnabled) {
scoped_refptr<const Extension> extension = ExtensionBuilder("Test").Build();
service()->AddExtension(extension.get());
+ scoped_refptr<const Extension> source_extension =
+ ExtensionBuilder("Test").Build();
+ service()->AddExtension(source_extension.get());
std::string extension_id = extension->id();
scoped_refptr<ManagementSetEnabledFunction> function(
new ManagementSetEnabledFunction());
+ function->set_extension(source_extension);
base::ListValue disable_args;
disable_args.AppendString(extension_id);
@@ -149,6 +153,107 @@ TEST_F(ManagementApiUnitTest, ManagementSetEnabled) {
policy->UnregisterProvider(&provider);
}
+// Test that component extensions cannot be disabled, and that policy extensions
+// can be disabled only by component/policy extensions.
+TEST_F(ManagementApiUnitTest, ComponentPolicyDisabling) {
+ auto component =
+ ExtensionBuilder("component").SetLocation(Manifest::COMPONENT).Build();
+ auto component2 =
+ ExtensionBuilder("component2").SetLocation(Manifest::COMPONENT).Build();
+ auto policy =
+ ExtensionBuilder("policy").SetLocation(Manifest::EXTERNAL_POLICY).Build();
+ auto policy2 = ExtensionBuilder("policy2")
+ .SetLocation(Manifest::EXTERNAL_POLICY)
+ .Build();
+ auto internal =
+ ExtensionBuilder("internal").SetLocation(Manifest::INTERNAL).Build();
+
+ service()->AddExtension(component.get());
+ service()->AddExtension(component2.get());
+ service()->AddExtension(policy.get());
+ service()->AddExtension(policy2.get());
+ service()->AddExtension(internal.get());
+
+ auto extension_can_disable_extension =
+ [this](scoped_refptr<const Extension> source_extension,
+ scoped_refptr<const Extension> target_extension) {
+ std::string id = target_extension->id();
+ base::ListValue args;
+ args.AppendString(id);
+ args.AppendBoolean(false /* disable the extension */);
+ auto function = base::MakeRefCounted<ManagementSetEnabledFunction>();
+ function->set_extension(source_extension);
+ bool did_disable = RunFunction(function, args);
+ // If the extension was disabled, re-enable it.
+ if (did_disable) {
+ EXPECT_TRUE(registry()->disabled_extensions().Contains(id));
+ service()->EnableExtension(id);
+ } else {
+ EXPECT_TRUE(registry()->enabled_extensions().Contains(id));
+ }
+ return did_disable;
+ };
+
+ // Component extension cannot be disabled.
+ EXPECT_FALSE(extension_can_disable_extension(component2, component));
+ EXPECT_FALSE(extension_can_disable_extension(policy, component));
+ EXPECT_FALSE(extension_can_disable_extension(internal, component));
+
+ // Policy extension can be disabled by component/policy extensions, but not
+ // others.
+ EXPECT_TRUE(extension_can_disable_extension(component, policy));
+ EXPECT_TRUE(extension_can_disable_extension(policy2, policy));
+ EXPECT_FALSE(extension_can_disable_extension(internal, policy));
+}
+
+// Test that policy extensions can be enabled only by component/policy
+// extensions.
+TEST_F(ManagementApiUnitTest, ComponentPolicyEnabling) {
+ auto component =
+ ExtensionBuilder("component").SetLocation(Manifest::COMPONENT).Build();
+ auto policy =
+ ExtensionBuilder("policy").SetLocation(Manifest::EXTERNAL_POLICY).Build();
+ auto policy2 = ExtensionBuilder("policy2")
+ .SetLocation(Manifest::EXTERNAL_POLICY)
+ .Build();
+ auto internal =
+ ExtensionBuilder("internal").SetLocation(Manifest::INTERNAL).Build();
+
+ service()->AddExtension(component.get());
+ service()->AddExtension(policy.get());
+ service()->AddExtension(policy2.get());
+ service()->AddExtension(internal.get());
+ service()->DisableExtensionWithSource(
+ component.get(), policy->id(), disable_reason::DISABLE_BLOCKED_BY_POLICY);
+
+ auto extension_can_enable_extension =
+ [this, component](scoped_refptr<const Extension> source_extension,
+ scoped_refptr<const Extension> target_extension) {
+ std::string id = target_extension->id();
+ base::ListValue args;
+ args.AppendString(id);
+ args.AppendBoolean(true /* enable the extension */);
+ auto function = base::MakeRefCounted<ManagementSetEnabledFunction>();
+ function->set_extension(source_extension);
+ bool did_enable = RunFunction(function, args);
+ // If the extension was enabled, disable it.
+ if (did_enable) {
+ EXPECT_TRUE(registry()->enabled_extensions().Contains(id));
+ service()->DisableExtensionWithSource(
+ component.get(), id, disable_reason::DISABLE_BLOCKED_BY_POLICY);
+ } else {
+ EXPECT_TRUE(registry()->disabled_extensions().Contains(id));
+ }
+ return did_enable;
+ };
+
+ // Policy extension can be enabled by component/policy extensions, but not
+ // others.
+ EXPECT_TRUE(extension_can_enable_extension(component, policy));
+ EXPECT_TRUE(extension_can_enable_extension(policy2, policy));
+ EXPECT_FALSE(extension_can_enable_extension(internal, policy));
+}
+
// Tests management.uninstall.
TEST_F(ManagementApiUnitTest, ManagementUninstall) {
scoped_refptr<const Extension> extension = ExtensionBuilder("Test").Build();
diff --git a/chromium/chrome/browser/extensions/api/management/management_apitest.cc b/chromium/chrome/browser/extensions/api/management/management_apitest.cc
index 3a914ec3552..2e470f69593 100644
--- a/chromium/chrome/browser/extensions/api/management/management_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/management/management_apitest.cc
@@ -42,7 +42,7 @@ Browser* FindOtherBrowser(Browser* browser) {
} // namespace
-class ExtensionManagementApiTest : public ExtensionApiTest {
+class ExtensionManagementApiTest : public extensions::ExtensionApiTest {
public:
virtual void LoadExtensions() {
base::FilePath basedir = test_data_dir_.AppendASCII("management");
diff --git a/chromium/chrome/browser/extensions/api/management/management_browsertest.cc b/chromium/chrome/browser/extensions/api/management/management_browsertest.cc
index 60ced21750e..adba1640c02 100644
--- a/chromium/chrome/browser/extensions/api/management/management_browsertest.cc
+++ b/chromium/chrome/browser/extensions/api/management/management_browsertest.cc
@@ -59,7 +59,7 @@ std::string BuildForceInstallPolicyValue(const char* extension_id,
} // namespace
-class ExtensionManagementTest : public ExtensionBrowserTest {
+class ExtensionManagementTest : public extensions::ExtensionBrowserTest {
public:
void SetUpInProcessBrowserTestFixture() override {
EXPECT_CALL(policy_provider_, IsInitializationComplete(_))
@@ -369,16 +369,14 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, MAYBE_AutoUpdate) {
ASSERT_EQ("ogjcoiohnmldgjemafoockdghcjciccf", extension->id());
ASSERT_EQ("1.0", extension->VersionString());
- extensions::ExtensionUpdater::CheckParams params;
- params.callback =
- base::Bind(&NotificationListener::OnFinished,
- base::Unretained(&notification_listener));
-
// Run autoupdate and make sure version 2 of the extension was installed.
ExtensionTestMessageListener listener2("v2 installed", false);
extensions::TestExtensionRegistryObserver install_observer(registry);
- service->updater()->CheckNow(params);
+ extensions::ExtensionUpdater::CheckParams params1;
+ params1.callback = base::BindOnce(&NotificationListener::OnFinished,
+ base::Unretained(&notification_listener));
+ service->updater()->CheckNow(std::move(params1));
install_observer.WaitForExtensionWillBeInstalled();
EXPECT_TRUE(listener2.WaitUntilSatisfied());
ASSERT_EQ(size_before + 1, registry->enabled_extensions().size());
@@ -400,7 +398,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, MAYBE_AutoUpdate) {
interceptor.SetResponseIgnoreQuery(GURL("http://localhost/autoupdate/v3.crx"),
basedir.AppendASCII("v3.crx"));
- service->updater()->CheckNow(params);
+ extensions::ExtensionUpdater::CheckParams params2;
+ params2.callback = base::BindOnce(&NotificationListener::OnFinished,
+ base::Unretained(&notification_listener));
+ service->updater()->CheckNow(std::move(params2));
ASSERT_TRUE(WaitForExtensionInstallError());
ASSERT_TRUE(notification_listener.started());
ASSERT_TRUE(notification_listener.finished());
@@ -473,16 +474,14 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest,
ASSERT_EQ("ogjcoiohnmldgjemafoockdghcjciccf", extension->id());
ASSERT_EQ("1.0", extension->VersionString());
- extensions::ExtensionUpdater::CheckParams params;
- params.callback =
- base::Bind(&NotificationListener::OnFinished,
- base::Unretained(&notification_listener));
-
ExtensionTestMessageListener listener2("v2 installed", false);
extensions::TestExtensionRegistryObserver install_observer(registry);
// Run autoupdate and make sure version 2 of the extension was installed but
// is still disabled.
- service->updater()->CheckNow(params);
+ extensions::ExtensionUpdater::CheckParams params;
+ params.callback = base::BindOnce(&NotificationListener::OnFinished,
+ base::Unretained(&notification_listener));
+ service->updater()->CheckNow(std::move(params));
install_observer.WaitForExtensionWillBeInstalled();
ASSERT_EQ(disabled_size_before + 1, registry->disabled_extensions().size());
ASSERT_EQ(enabled_size_before, registry->enabled_extensions().size());
@@ -509,7 +508,6 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalUrlUpdate) {
ExtensionService* service = extensions::ExtensionSystem::Get(
browser()->profile())->extension_service();
const char kExtensionId[] = "ogjcoiohnmldgjemafoockdghcjciccf";
- extensions::ExtensionUpdater::CheckParams params;
base::ScopedAllowBlockingForTesting allow_blocking;
base::ScopedTempDir temp_dir;
@@ -556,7 +554,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalUrlUpdate) {
extensions::TestExtensionRegistryObserver install_observer(registry);
// Run autoupdate and make sure version 2 of the extension was installed.
- service->updater()->CheckNow(params);
+ service->updater()->CheckNow(extensions::ExtensionUpdater::CheckParams());
install_observer.WaitForExtensionWillBeInstalled();
ASSERT_EQ(size_before + 1, registry->enabled_extensions().size());
const Extension* extension = service->GetExtensionById(kExtensionId, false);
diff --git a/chromium/chrome/browser/extensions/api/mdns/mdns_api_unittest.cc b/chromium/chrome/browser/extensions/api/mdns/mdns_api_unittest.cc
index a74ce67ef9f..2b97c24e75d 100644
--- a/chromium/chrome/browser/extensions/api/mdns/mdns_api_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/mdns/mdns_api_unittest.cc
@@ -98,9 +98,9 @@ class MockEventRouter : public EventRouter {
explicit MockEventRouter(content::BrowserContext* browser_context,
ExtensionPrefs* extension_prefs)
: EventRouter(browser_context, extension_prefs) {}
- virtual ~MockEventRouter() {}
+ ~MockEventRouter() override {}
- virtual void BroadcastEvent(std::unique_ptr<Event> event) {
+ void BroadcastEvent(std::unique_ptr<Event> event) override {
BroadcastEventPtr(event.get());
}
MOCK_METHOD1(BroadcastEventPtr, void(Event* event));
@@ -220,6 +220,7 @@ class MDnsAPITest : public extensions::ExtensionServiceTestBase {
base::DictionaryValue manifest;
manifest.SetString(extensions::manifest_keys::kVersion, "1.0.0.0");
manifest.SetString(extensions::manifest_keys::kName, name);
+ manifest.SetInteger(extensions::manifest_keys::kManifestVersion, 2);
if (is_platform_app) {
// Setting app.background.page = "background.html" is sufficient to make
// the extension type TYPE_PLATFORM_APP.
diff --git a/chromium/chrome/browser/extensions/api/mdns/mdns_apitest.cc b/chromium/chrome/browser/extensions/api/mdns/mdns_apitest.cc
index 48bcf21aab1..7751cefc276 100644
--- a/chromium/chrome/browser/extensions/api/mdns/mdns_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/mdns/mdns_apitest.cc
@@ -23,12 +23,12 @@ namespace api = extensions::api;
namespace {
-class MDnsAPITest : public ExtensionApiTest {
+class MDnsAPITest : public extensions::ExtensionApiTest {
public:
MDnsAPITest() {}
void SetUpCommandLine(base::CommandLine* command_line) override {
- ExtensionApiTest::SetUpCommandLine(command_line);
+ extensions::ExtensionApiTest::SetUpCommandLine(command_line);
command_line->AppendSwitchASCII(
extensions::switches::kWhitelistedExtensionID,
"ddchlicdkolnonkihahngkmmmjnjlkkf");
diff --git a/chromium/chrome/browser/extensions/api/media_galleries/blob_data_source_factory.cc b/chromium/chrome/browser/extensions/api/media_galleries/blob_data_source_factory.cc
new file mode 100644
index 00000000000..98271a7dd7b
--- /dev/null
+++ b/chromium/chrome/browser/extensions/api/media_galleries/blob_data_source_factory.cc
@@ -0,0 +1,83 @@
+// 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/extensions/api/media_galleries/blob_data_source_factory.h"
+#include "content/public/browser/browser_context.h"
+#include "extensions/browser/blob_reader.h"
+#include "mojo/public/cpp/bindings/binding.h"
+
+namespace extensions {
+namespace {
+
+// Media data source that reads data from a blob in browser process.
+class BlobMediaDataSource : public chrome::mojom::MediaDataSource {
+ public:
+ BlobMediaDataSource(chrome::mojom::MediaDataSourcePtr* interface,
+ content::BrowserContext* browser_context,
+ const std::string& blob_uuid,
+ BlobDataSourceFactory::MediaDataCallback callback)
+ : binding_(this, mojo::MakeRequest(interface)),
+ browser_context_(browser_context),
+ blob_uuid_(blob_uuid),
+ callback_(callback),
+ weak_factory_(this) {}
+
+ ~BlobMediaDataSource() override = default;
+
+ private:
+ // chrome::mojom::MediaDataSource implementation.
+ void Read(int64_t position,
+ int64_t length,
+ chrome::mojom::MediaDataSource::ReadCallback callback) override {
+ StartBlobRequest(std::move(callback), position, length);
+ }
+
+ void StartBlobRequest(chrome::mojom::MediaDataSource::ReadCallback callback,
+ int64_t position,
+ int64_t length) {
+ BlobReader* reader = new BlobReader( // BlobReader is self-deleting.
+ browser_context_, blob_uuid_,
+ base::BindRepeating(&BlobMediaDataSource::OnBlobReaderDone,
+ weak_factory_.GetWeakPtr(),
+ base::Passed(&callback)));
+ reader->SetByteRange(position, length);
+ reader->Start();
+ }
+
+ void OnBlobReaderDone(chrome::mojom::MediaDataSource::ReadCallback callback,
+ std::unique_ptr<std::string> data,
+ int64_t size) {
+ callback_.Run(std::move(callback), std::move(data));
+ }
+
+ mojo::Binding<chrome::mojom::MediaDataSource> binding_;
+
+ content::BrowserContext* const browser_context_;
+ std::string blob_uuid_;
+
+ BlobDataSourceFactory::MediaDataCallback callback_;
+
+ base::WeakPtrFactory<BlobMediaDataSource> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(BlobMediaDataSource);
+};
+
+} // namespace
+
+BlobDataSourceFactory::BlobDataSourceFactory(
+ content::BrowserContext* browser_context,
+ const std::string& blob_uuid)
+ : browser_context_(browser_context), blob_uuid_(blob_uuid) {}
+
+BlobDataSourceFactory::~BlobDataSourceFactory() = default;
+
+std::unique_ptr<chrome::mojom::MediaDataSource>
+BlobDataSourceFactory::CreateMediaDataSource(
+ chrome::mojom::MediaDataSourcePtr* request,
+ MediaDataCallback media_data_callback) {
+ return std::make_unique<BlobMediaDataSource>(request, browser_context_,
+ blob_uuid_, media_data_callback);
+}
+
+} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/media_galleries/blob_data_source_factory.h b/chromium/chrome/browser/extensions/api/media_galleries/blob_data_source_factory.h
new file mode 100644
index 00000000000..c2ed111caf6
--- /dev/null
+++ b/chromium/chrome/browser/extensions/api/media_galleries/blob_data_source_factory.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_EXTENSIONS_API_MEDIA_GALLERIES_BLOB_DATA_SOURCE_FACTORY_H_
+#define CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_BLOB_DATA_SOURCE_FACTORY_H_
+
+#include <memory>
+#include <string>
+
+#include "base/macros.h"
+#include "chrome/services/media_gallery_util/public/cpp/safe_media_metadata_parser.h"
+#include "chrome/services/media_gallery_util/public/mojom/media_parser.mojom.h"
+
+namespace content {
+class BrowserContext;
+} // namespace content
+
+namespace extensions {
+
+// Factory to provide media data source for extension media gallery API.
+// Internally it will read media data from a blob in browser process.
+class BlobDataSourceFactory
+ : public SafeMediaMetadataParser::MediaDataSourceFactory {
+ public:
+ BlobDataSourceFactory(content::BrowserContext* browser_context,
+ const std::string& blob_uuid);
+ ~BlobDataSourceFactory() override;
+
+ private:
+ // SafeMediaMetadataParser::MediaDataSourceFactory implementation.
+ std::unique_ptr<chrome::mojom::MediaDataSource> CreateMediaDataSource(
+ chrome::mojom::MediaDataSourcePtr* request,
+ MediaDataCallback media_data_callback) override;
+
+ content::BrowserContext* browser_context_;
+ std::string blob_uuid_;
+ MediaDataCallback callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(BlobDataSourceFactory);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_BLOB_DATA_SOURCE_FACTORY_H_
diff --git a/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc b/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc
index d958a3dc130..efe4a6313a2 100644
--- a/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc
+++ b/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc
@@ -24,6 +24,8 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/extensions/api/media_galleries/blob_data_source_factory.h"
+#include "chrome/browser/extensions/api/media_galleries/media_galleries_api_util.h"
#include "chrome/browser/extensions/chrome_extension_function_details.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/media_galleries/gallery_watch_manager.h"
@@ -674,9 +676,11 @@ void MediaGalleriesGetMetadataFunction::GetMetadata(
metadata_type == MediaGalleries::GET_METADATA_TYPE_ALL ||
metadata_type == MediaGalleries::GET_METADATA_TYPE_NONE;
+ auto media_data_source_factory =
+ std::make_unique<BlobDataSourceFactory>(GetProfile(), blob_uuid);
auto parser = std::make_unique<SafeMediaMetadataParser>(
- GetProfile(), blob_uuid, total_blob_length, mime_type,
- get_attached_images);
+ total_blob_length, mime_type, get_attached_images,
+ std::move(media_data_source_factory));
SafeMediaMetadataParser* parser_ptr = parser.get();
parser_ptr->Start(
content::ServiceManagerConnection::GetForProcess()->GetConnector(),
@@ -688,7 +692,7 @@ void MediaGalleriesGetMetadataFunction::GetMetadata(
void MediaGalleriesGetMetadataFunction::OnSafeMediaMetadataParserDone(
std::unique_ptr<SafeMediaMetadataParser> parser_keep_alive,
bool parse_success,
- std::unique_ptr<base::DictionaryValue> metadata_dictionary,
+ chrome::mojom::MediaMetadataPtr metadata,
std::unique_ptr<std::vector<metadata::AttachedImage>> attached_images) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
@@ -697,12 +701,13 @@ void MediaGalleriesGetMetadataFunction::OnSafeMediaMetadataParserDone(
return;
}
- DCHECK(metadata_dictionary.get());
- DCHECK(attached_images.get());
+ DCHECK(metadata);
+ DCHECK(attached_images);
std::unique_ptr<base::DictionaryValue> result_dictionary(
new base::DictionaryValue);
- result_dictionary->Set(kMetadataKey, std::move(metadata_dictionary));
+ result_dictionary->Set(kMetadataKey,
+ SerializeMediaMetadata(std::move(metadata)));
if (attached_images->empty()) {
SetResult(std::move(result_dictionary));
diff --git a/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_api.h b/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_api.h
index 003d60740f6..ebe708aba0f 100644
--- a/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_api.h
+++ b/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_api.h
@@ -22,6 +22,7 @@
#include "chrome/browser/media_galleries/media_file_system_registry.h"
#include "chrome/common/extensions/api/media_galleries.h"
#include "chrome/common/media_galleries/metadata_types.h"
+#include "chrome/services/media_gallery_util/public/mojom/media_parser.mojom.h"
#include "components/storage_monitor/media_storage_util.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
#include "extensions/browser/event_router.h"
@@ -181,7 +182,7 @@ class MediaGalleriesGetMetadataFunction : public ChromeAsyncExtensionFunction {
void OnSafeMediaMetadataParserDone(
std::unique_ptr<SafeMediaMetadataParser> parser_keep_alive,
bool parse_success,
- std::unique_ptr<base::DictionaryValue> result_dictionary,
+ chrome::mojom::MediaMetadataPtr metadata,
std::unique_ptr<std::vector<metadata::AttachedImage>> attached_images);
void ConstructNextBlob(
diff --git a/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_api_util.cc b/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_api_util.cc
new file mode 100644
index 00000000000..9a0eda75700
--- /dev/null
+++ b/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_api_util.cc
@@ -0,0 +1,63 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/api/media_galleries/media_galleries_api_util.h"
+
+#include "base/logging.h"
+#include "chrome/common/extensions/api/media_galleries.h"
+
+namespace extensions {
+
+template <class T>
+void SetValueScopedPtr(T value, std::unique_ptr<T>* destination) {
+ DCHECK(destination);
+ if (value >= 0)
+ destination->reset(new T(value));
+}
+
+template <>
+void SetValueScopedPtr(std::string value,
+ std::unique_ptr<std::string>* destination) {
+ DCHECK(destination);
+ if (!value.empty())
+ destination->reset(new std::string(std::move(value)));
+}
+
+std::unique_ptr<base::DictionaryValue> SerializeMediaMetadata(
+ chrome::mojom::MediaMetadataPtr metadata) {
+ DCHECK(metadata);
+ extensions::api::media_galleries::MediaMetadata extension_metadata;
+ extension_metadata.mime_type = std::move(metadata->mime_type);
+ if (metadata->height >= 0 && metadata->width >= 0) {
+ extension_metadata.height.reset(new int(metadata->height));
+ extension_metadata.width.reset(new int(metadata->width));
+ }
+
+ SetValueScopedPtr(metadata->duration, &extension_metadata.duration);
+ SetValueScopedPtr(std::move(metadata->artist), &extension_metadata.artist);
+ SetValueScopedPtr(std::move(metadata->album), &extension_metadata.album);
+ SetValueScopedPtr(std::move(metadata->comment), &extension_metadata.comment);
+ SetValueScopedPtr(std::move(metadata->copyright),
+ &extension_metadata.copyright);
+ SetValueScopedPtr(metadata->disc, &extension_metadata.disc);
+ SetValueScopedPtr(std::move(metadata->genre), &extension_metadata.genre);
+ SetValueScopedPtr(std::move(metadata->language),
+ &extension_metadata.language);
+ SetValueScopedPtr(metadata->rotation, &extension_metadata.rotation);
+ SetValueScopedPtr(std::move(metadata->title), &extension_metadata.title);
+ SetValueScopedPtr(metadata->track, &extension_metadata.track);
+
+ for (const chrome::mojom::MediaStreamInfoPtr& info : metadata->raw_tags) {
+ extensions::api::media_galleries::StreamInfo stream_info;
+ stream_info.type = std::move(info->type);
+ base::DictionaryValue* dict_value;
+ info->additional_properties.GetAsDictionary(&dict_value);
+ stream_info.tags.additional_properties.Swap(dict_value);
+ extension_metadata.raw_tags.push_back(std::move(stream_info));
+ }
+
+ return extension_metadata.ToValue();
+}
+
+} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_api_util.h b/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_api_util.h
new file mode 100644
index 00000000000..c768acde0ae
--- /dev/null
+++ b/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_api_util.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_EXTENSIONS_API_MEDIA_GALLERIES_MEDIA_GALLERIES_API_UTIL_H_
+#define CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_MEDIA_GALLERIES_API_UTIL_H_
+
+#include <memory>
+
+#include "chrome/services/media_gallery_util/public/mojom/media_parser.mojom.h"
+
+namespace base {
+class DictionaryValue;
+} // namespace base
+
+namespace extensions {
+
+// Converts a mojo media metadata struct into a dictionary. Internally uses
+// extension's auto generated serializer.
+std::unique_ptr<base::DictionaryValue> SerializeMediaMetadata(
+ chrome::mojom::MediaMetadataPtr metadata);
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_MEDIA_GALLERIES_API_UTIL_H_
diff --git a/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc b/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc
index 39bdf5e556f..95796a2c7fb 100644
--- a/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc
@@ -254,7 +254,7 @@ class MediaGalleriesPlatformAppPpapiTest
void SetUpOnMainThread() override {
MediaGalleriesPlatformAppBrowserTest::SetUpOnMainThread();
- ASSERT_TRUE(PathService::Get(chrome::DIR_GEN_TEST_DATA, &app_dir_));
+ ASSERT_TRUE(base::PathService::Get(chrome::DIR_GEN_TEST_DATA, &app_dir_));
app_dir_ = app_dir_.AppendASCII("ppapi")
.AppendASCII("tests")
.AppendASCII("extensions")
diff --git a/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_watch_apitest.cc b/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_watch_apitest.cc
index 0e662e59525..f3a7613fbec 100644
--- a/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_watch_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/media_galleries/media_galleries_watch_apitest.cc
@@ -69,7 +69,7 @@ const char kGalleryChangedEventReceived[] = "gallery_changed_event_received";
// MediaGalleriesGalleryWatchApiTest //
///////////////////////////////////////////////////////////////////////////////
-class MediaGalleriesGalleryWatchApiTest : public ExtensionApiTest {
+class MediaGalleriesGalleryWatchApiTest : public extensions::ExtensionApiTest {
public:
MediaGalleriesGalleryWatchApiTest()
: extension_(NULL), background_host_(NULL) {}
@@ -78,12 +78,12 @@ class MediaGalleriesGalleryWatchApiTest : public ExtensionApiTest {
protected:
// ExtensionApiTest overrides.
void SetUpCommandLine(base::CommandLine* command_line) override {
- ExtensionApiTest::SetUpCommandLine(command_line);
+ extensions::ExtensionApiTest::SetUpCommandLine(command_line);
command_line->AppendSwitchASCII(
extensions::switches::kWhitelistedExtensionID, kTestExtensionId);
}
void SetUpOnMainThread() override {
- ExtensionApiTest::SetUpOnMainThread();
+ extensions::ExtensionApiTest::SetUpOnMainThread();
ensure_media_directories_exists_.reset(new EnsureMediaDirectoriesExists);
extension_ = LoadExtension(test_data_dir_.AppendASCII(kTestExtensionPath));
GetBackgroundHostForTestExtension();
@@ -94,7 +94,7 @@ class MediaGalleriesGalleryWatchApiTest : public ExtensionApiTest {
extension_ = NULL;
background_host_ = NULL;
ensure_media_directories_exists_.reset();
- ExtensionApiTest::TearDownOnMainThread();
+ extensions::ExtensionApiTest::TearDownOnMainThread();
}
bool GalleryWatchesSupported() {
diff --git a/chromium/chrome/browser/extensions/api/media_perception_private/media_perception_api_delegate_chromeos.cc b/chromium/chrome/browser/extensions/api/media_perception_private/media_perception_api_delegate_chromeos.cc
index 4b96ce3fc8f..902cccf2825 100644
--- a/chromium/chrome/browser/extensions/api/media_perception_private/media_perception_api_delegate_chromeos.cc
+++ b/chromium/chrome/browser/extensions/api/media_perception_private/media_perception_api_delegate_chromeos.cc
@@ -4,9 +4,12 @@
#include "chrome/browser/extensions/api/media_perception_private/media_perception_api_delegate_chromeos.h"
+#include <string>
+#include <utility>
+
#include "base/bind.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/component_updater/cros_component_installer.h"
+#include "chrome/browser/component_updater/cros_component_installer_chromeos.h"
namespace media_perception = extensions::api::media_perception_private;
@@ -36,7 +39,9 @@ void OnLoadComponent(
MediaPerceptionAPIDelegate::LoadCrOSComponentCallback load_callback,
component_updater::CrOSComponentManager::Error error,
const base::FilePath& mount_point) {
- std::move(load_callback).Run(mount_point);
+ std::move(load_callback)
+ .Run(error == component_updater::CrOSComponentManager::Error::NONE,
+ mount_point);
}
} // namespace
diff --git a/chromium/chrome/browser/extensions/api/messaging/native_messaging_apitest.cc b/chromium/chrome/browser/extensions/api/messaging/native_messaging_apitest.cc
index eac88e83622..0983cc2ca74 100644
--- a/chromium/chrome/browser/extensions/api/messaging/native_messaging_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/messaging/native_messaging_apitest.cc
@@ -5,6 +5,8 @@
#include "chrome/browser/extensions/api/messaging/native_messaging_test_util.h"
#include "chrome/browser/extensions/extension_apitest.h"
+namespace extensions {
+
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NativeMessagingBasic) {
extensions::ScopedTestNativeMessagingHost test_host;
ASSERT_NO_FATAL_FAILURE(test_host.RegisterTestHost(false));
@@ -16,3 +18,5 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, UserLevelNativeMessaging) {
ASSERT_NO_FATAL_FAILURE(test_host.RegisterTestHost(true));
ASSERT_TRUE(RunExtensionTest("native_messaging")) << message_;
}
+
+} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/messaging/native_messaging_test_util.cc b/chromium/chrome/browser/extensions/api/messaging/native_messaging_test_util.cc
index 4067196dcaa..1acf4aec153 100644
--- a/chromium/chrome/browser/extensions/api/messaging/native_messaging_test_util.cc
+++ b/chromium/chrome/browser/extensions/api/messaging/native_messaging_test_util.cc
@@ -74,7 +74,8 @@ void ScopedTestNativeMessagingHost::RegisterTestHost(bool user_level) {
ScopedTestNativeMessagingHost test_host;
base::FilePath test_user_data_dir;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_user_data_dir));
+ ASSERT_TRUE(
+ base::PathService::Get(chrome::DIR_TEST_DATA, &test_user_data_dir));
test_user_data_dir = test_user_data_dir.AppendASCII("native_messaging")
.AppendASCII("native_hosts");
diff --git a/chromium/chrome/browser/extensions/api/messaging/native_process_launcher_posix.cc b/chromium/chrome/browser/extensions/api/messaging/native_process_launcher_posix.cc
index 0a5d0166333..c0843625742 100644
--- a/chromium/chrome/browser/extensions/api/messaging/native_process_launcher_posix.cc
+++ b/chromium/chrome/browser/extensions/api/messaging/native_process_launcher_posix.cc
@@ -22,7 +22,7 @@ namespace {
base::FilePath FindManifestInDir(int dir_key, const std::string& host_name) {
base::FilePath base_path;
- if (PathService::Get(dir_key, &base_path)) {
+ if (base::PathService::Get(dir_key, &base_path)) {
base::FilePath path = base_path.Append(host_name + ".json");
if (base::PathExists(path))
return path;
diff --git a/chromium/chrome/browser/extensions/api/metrics_private/metrics_apitest.cc b/chromium/chrome/browser/extensions/api/metrics_private/metrics_apitest.cc
index b41a3e14ee3..c9862e8fde7 100644
--- a/chromium/chrome/browser/extensions/api/metrics_private/metrics_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/metrics_private/metrics_apitest.cc
@@ -14,6 +14,8 @@
#include "chrome/browser/extensions/extension_apitest.h"
#include "components/variations/variations_associated_data.h"
+namespace extensions {
+
namespace {
// The tests that are run by this extension are expected to record the following
@@ -126,7 +128,7 @@ void ValidateHistograms(const RecordedHistogram* recorded,
}
}
-} // anonymous namespace
+} // namespace
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Metrics) {
base::UserActionTester user_action_tester;
@@ -145,3 +147,5 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Metrics) {
arraysize(g_user_actions));
ValidateHistograms(g_histograms, arraysize(g_histograms));
}
+
+} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/module/module_apitest.cc b/chromium/chrome/browser/extensions/api/module/module_apitest.cc
index 748b13275ea..ca037e4085b 100644
--- a/chromium/chrome/browser/extensions/api/module/module_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/module/module_apitest.cc
@@ -4,8 +4,7 @@
#include "chrome/browser/extensions/extension_apitest.h"
-class ExtensionModuleApiTest : public ExtensionApiTest {
-};
+using ExtensionModuleApiTest = extensions::ExtensionApiTest;
IN_PROC_BROWSER_TEST_F(ExtensionModuleApiTest, CognitoFile) {
ASSERT_TRUE(RunExtensionTest("extension_module/cognito_file")) << message_;
diff --git a/chromium/chrome/browser/extensions/api/networking_config_chromeos_apitest_chromeos.cc b/chromium/chrome/browser/extensions/api/networking_config_chromeos_apitest_chromeos.cc
index 2dea3a79ffc..4cfa0b91735 100644
--- a/chromium/chrome/browser/extensions/api/networking_config_chromeos_apitest_chromeos.cc
+++ b/chromium/chrome/browser/extensions/api/networking_config_chromeos_apitest_chromeos.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 <memory>
#include <string>
#include "base/location.h"
@@ -12,10 +13,10 @@
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/net/network_portal_detector_impl.h"
-#include "chrome/browser/chromeos/net/network_portal_notification_controller.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/notifications/notification_display_service_tester.h"
+#include "chrome/browser/ui/ash/network/network_portal_notification_controller.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/shill_device_client.h"
#include "chromeos/dbus/shill_profile_client.h"
@@ -45,11 +46,14 @@ const char kWifi1ServiceGUID[] = "wifi1_guid";
} // namespace
class NetworkingConfigTest
- : public ExtensionApiTest,
+ : public extensions::ExtensionApiTest,
public captive_portal::CaptivePortalDetectorTestBase {
public:
+ NetworkingConfigTest() : network_portal_detector_(nullptr) {}
+ ~NetworkingConfigTest() override = default;
+
void SetUpOnMainThread() override {
- ExtensionApiTest::SetUpOnMainThread();
+ extensions::ExtensionApiTest::SetUpOnMainThread();
content::RunAllPendingInMessageLoop();
display_service_ = std::make_unique<NotificationDisplayServiceTester>(
@@ -81,12 +85,20 @@ class NetworkingConfigTest
content::RunAllPendingInMessageLoop();
- network_portal_detector_ = new NetworkPortalDetectorImpl(
- test_loader_factory(), true /* create_notification_controller */);
+ network_portal_detector_ =
+ new NetworkPortalDetectorImpl(test_loader_factory());
+ // Takes ownership of |network_portal_detector_|:
chromeos::network_portal_detector::InitializeForTesting(
network_portal_detector_);
network_portal_detector_->Enable(false /* start_detection */);
set_detector(network_portal_detector_->captive_portal_detector_.get());
+ network_portal_notification_controller_ =
+ std::make_unique<NetworkPortalNotificationController>(
+ network_portal_detector_);
+ }
+
+ void TearDownOnMainThread() override {
+ network_portal_notification_controller_.reset();
}
void LoadTestExtension() {
@@ -118,7 +130,9 @@ class NetworkingConfigTest
}
protected:
- NetworkPortalDetectorImpl* network_portal_detector_ = nullptr;
+ NetworkPortalDetectorImpl* network_portal_detector_;
+ std::unique_ptr<NetworkPortalNotificationController>
+ network_portal_notification_controller_;
const extensions::Extension* extension_ = nullptr;
std::unique_ptr<NotificationDisplayServiceTester> display_service_;
};
diff --git a/chromium/chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc b/chromium/chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc
index 4abe0b8919d..475010dec10 100644
--- a/chromium/chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc
@@ -52,6 +52,7 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/test/test_utils.h"
+#include "dbus/object_path.h"
#include "extensions/browser/api/networking_private/networking_private_chromeos.h"
#include "extensions/browser/api/networking_private/networking_private_delegate_factory.h"
#include "extensions/browser/notification_types.h"
@@ -186,7 +187,7 @@ class TestListener : public content::NotificationObserver {
DISALLOW_COPY_AND_ASSIGN(TestListener);
};
-class NetworkingPrivateChromeOSApiTest : public ExtensionApiTest {
+class NetworkingPrivateChromeOSApiTest : public extensions::ExtensionApiTest {
public:
NetworkingPrivateChromeOSApiTest()
: detector_(nullptr),
@@ -207,11 +208,11 @@ class NetworkingPrivateChromeOSApiTest : public ExtensionApiTest {
.WillRepeatedly(Return(true));
policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
- ExtensionApiTest::SetUpInProcessBrowserTestFixture();
+ extensions::ExtensionApiTest::SetUpInProcessBrowserTestFixture();
}
void SetUpCommandLine(base::CommandLine* command_line) override {
- ExtensionApiTest::SetUpCommandLine(command_line);
+ extensions::ExtensionApiTest::SetUpCommandLine(command_line);
// Whitelist the extension ID of the test extension.
command_line->AppendSwitchASCII(
extensions::switches::kWhitelistedExtensionID,
@@ -252,33 +253,30 @@ class NetworkingPrivateChromeOSApiTest : public ExtensionApiTest {
// Add a Cellular GSM Device.
device_test_->AddDevice(kCellularDevicePath, shill::kTypeCellular,
"stub_cellular_device1");
- device_test_->SetDeviceProperty(kCellularDevicePath,
- shill::kCarrierProperty,
- base::Value("Cellular1_Carrier"));
+ SetDeviceProperty(kCellularDevicePath, shill::kCarrierProperty,
+ base::Value("Cellular1_Carrier"));
base::DictionaryValue home_provider;
home_provider.SetString("name", "Cellular1_Provider");
home_provider.SetString("code", "000000");
home_provider.SetString("country", "us");
- device_test_->SetDeviceProperty(
- kCellularDevicePath, shill::kHomeProviderProperty, home_provider);
- device_test_->SetDeviceProperty(kCellularDevicePath,
- shill::kTechnologyFamilyProperty,
- base::Value(shill::kNetworkTechnologyGsm));
- device_test_->SetDeviceProperty(kCellularDevicePath, shill::kMeidProperty,
- base::Value("test_meid"));
- device_test_->SetDeviceProperty(kCellularDevicePath, shill::kImeiProperty,
- base::Value("test_imei"));
- device_test_->SetDeviceProperty(kCellularDevicePath, shill::kIccidProperty,
- base::Value("test_iccid"));
- device_test_->SetDeviceProperty(kCellularDevicePath, shill::kEsnProperty,
- base::Value("test_esn"));
- device_test_->SetDeviceProperty(kCellularDevicePath, shill::kMdnProperty,
- base::Value("test_mdn"));
- device_test_->SetDeviceProperty(kCellularDevicePath, shill::kMinProperty,
- base::Value("test_min"));
- device_test_->SetDeviceProperty(kCellularDevicePath,
- shill::kModelIdProperty,
- base::Value("test_model_id"));
+ SetDeviceProperty(kCellularDevicePath, shill::kHomeProviderProperty,
+ home_provider);
+ SetDeviceProperty(kCellularDevicePath, shill::kTechnologyFamilyProperty,
+ base::Value(shill::kNetworkTechnologyGsm));
+ SetDeviceProperty(kCellularDevicePath, shill::kMeidProperty,
+ base::Value("test_meid"));
+ SetDeviceProperty(kCellularDevicePath, shill::kImeiProperty,
+ base::Value("test_imei"));
+ SetDeviceProperty(kCellularDevicePath, shill::kIccidProperty,
+ base::Value("test_iccid"));
+ SetDeviceProperty(kCellularDevicePath, shill::kEsnProperty,
+ base::Value("test_esn"));
+ SetDeviceProperty(kCellularDevicePath, shill::kMdnProperty,
+ base::Value("test_mdn"));
+ SetDeviceProperty(kCellularDevicePath, shill::kMinProperty,
+ base::Value("test_min"));
+ SetDeviceProperty(kCellularDevicePath, shill::kModelIdProperty,
+ base::Value("test_model_id"));
device_test_->SetSimLocked(kCellularDevicePath, false);
// Add the Cellular Service.
@@ -323,6 +321,13 @@ class NetworkingPrivateChromeOSApiTest : public ExtensionApiTest {
state, true /* add_to_visible */);
}
+ void SetDeviceProperty(const std::string& device_path,
+ const std::string& name,
+ const base::Value& value) {
+ device_test_->SetDeviceProperty(device_path, name, value,
+ /*notify_changed=*/true);
+ }
+
static std::unique_ptr<KeyedService> CreateNetworkingPrivateDelegate(
content::BrowserContext* context) {
std::unique_ptr<NetworkingPrivateDelegate> result(
@@ -340,14 +345,14 @@ class NetworkingPrivateChromeOSApiTest : public ExtensionApiTest {
ChromeNetworkingCastPrivateDelegate::SetFactoryCallbackForTest(
&networking_cast_delegate_factory_);
- ExtensionApiTest::SetUp();
+ extensions::ExtensionApiTest::SetUp();
}
void SetUpOnMainThread() override {
detector_ = new NetworkPortalDetectorTestImpl();
chromeos::network_portal_detector::InitializeForTesting(detector_);
- ExtensionApiTest::SetUpOnMainThread();
+ extensions::ExtensionApiTest::SetUpOnMainThread();
content::RunAllPendingInMessageLoop();
NetworkingPrivateDelegateFactory::GetInstance()->SetTestingFactory(
@@ -389,10 +394,10 @@ class NetworkingPrivateChromeOSApiTest : public ExtensionApiTest {
"stub_wifi_device1");
base::ListValue wifi_ip_configs;
wifi_ip_configs.AppendString(kIPConfigPath);
- device_test_->SetDeviceProperty(kWifiDevicePath, shill::kIPConfigsProperty,
- wifi_ip_configs);
- device_test_->SetDeviceProperty(kWifiDevicePath, shill::kAddressProperty,
- base::Value("001122aabbcc"));
+ SetDeviceProperty(kWifiDevicePath, shill::kIPConfigsProperty,
+ wifi_ip_configs);
+ SetDeviceProperty(kWifiDevicePath, shill::kAddressProperty,
+ base::Value("001122aabbcc"));
// Add Services
AddService("stub_ethernet", "eth0", shill::kTypeEthernet,
@@ -480,7 +485,7 @@ class NetworkingPrivateChromeOSApiTest : public ExtensionApiTest {
}
void TearDown() override {
- ExtensionApiTest::TearDown();
+ extensions::ExtensionApiTest::TearDown();
ChromeNetworkingCastPrivateDelegate::SetFactoryCallbackForTest(nullptr);
}
@@ -543,8 +548,10 @@ IN_PROC_BROWSER_TEST_F(NetworkingPrivateChromeOSApiTest, StartActivate) {
IN_PROC_BROWSER_TEST_F(NetworkingPrivateChromeOSApiTest, StartActivateSprint) {
SetupCellular();
// Set the carrier to Sprint.
- device_test_->SetDeviceProperty(kCellularDevicePath, shill::kCarrierProperty,
- base::Value(shill::kCarrierSprint));
+ DBusThreadManager::Get()->GetShillDeviceClient()->SetCarrier(
+ dbus::ObjectPath(kCellularDevicePath), shill::kCarrierSprint,
+ base::DoNothing(),
+ base::BindRepeating([](const std::string&, const std::string&) {}));
EXPECT_TRUE(RunNetworkingSubtest("startActivateSprint")) << message_;
EXPECT_EQ(0, UIDelegateStub::s_show_account_details_called_);
}
@@ -908,8 +915,8 @@ IN_PROC_BROWSER_TEST_F(NetworkingPrivateChromeOSApiTest,
.Set(shill::kStatusProperty, "available")
.Build())
.Build();
- device_test_->SetDeviceProperty(
- kCellularDevicePath, shill::kFoundNetworksProperty, *found_networks);
+ SetDeviceProperty(kCellularDevicePath, shill::kFoundNetworksProperty,
+ *found_networks);
EXPECT_TRUE(RunNetworkingSubtest("selectCellularMobileNetwork")) << message_;
}
diff --git a/chromium/chrome/browser/extensions/api/networking_private/networking_private_service_client_apitest.cc b/chromium/chrome/browser/extensions/api/networking_private/networking_private_service_client_apitest.cc
index 6b2b32bdea8..12ca21e5ca4 100644
--- a/chromium/chrome/browser/extensions/api/networking_private/networking_private_service_client_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/networking_private/networking_private_service_client_apitest.cc
@@ -91,7 +91,8 @@ class TestNetworkingCastPrivateDelegate
DISALLOW_COPY_AND_ASSIGN(TestNetworkingCastPrivateDelegate);
};
-class NetworkingPrivateServiceClientApiTest : public ExtensionApiTest {
+class NetworkingPrivateServiceClientApiTest
+ : public extensions::ExtensionApiTest {
public:
NetworkingPrivateServiceClientApiTest() {}
@@ -102,7 +103,7 @@ class NetworkingPrivateServiceClientApiTest : public ExtensionApiTest {
}
void SetUpCommandLine(base::CommandLine* command_line) override {
- ExtensionApiTest::SetUpCommandLine(command_line);
+ extensions::ExtensionApiTest::SetUpCommandLine(command_line);
// Whitelist the extension ID of the test extension.
command_line->AppendSwitchASCII(
extensions::switches::kWhitelistedExtensionID,
@@ -124,11 +125,11 @@ class NetworkingPrivateServiceClientApiTest : public ExtensionApiTest {
base::Unretained(this));
ChromeNetworkingCastPrivateDelegate::SetFactoryCallbackForTest(
&networking_cast_delegate_factory_);
- ExtensionApiTest::SetUp();
+ extensions::ExtensionApiTest::SetUp();
}
void SetUpOnMainThread() override {
- ExtensionApiTest::SetUpOnMainThread();
+ extensions::ExtensionApiTest::SetUpOnMainThread();
content::RunAllPendingInMessageLoop();
NetworkingPrivateDelegateFactory::GetInstance()->SetTestingFactory(
profile(), &CreateNetworkingPrivateServiceClient);
@@ -136,11 +137,11 @@ class NetworkingPrivateServiceClientApiTest : public ExtensionApiTest {
void TearDownOnMainThread() override {
content::RunAllPendingInMessageLoop();
- ExtensionApiTest::TearDownOnMainThread();
+ extensions::ExtensionApiTest::TearDownOnMainThread();
}
void TearDown() override {
- ExtensionApiTest::TearDown();
+ extensions::ExtensionApiTest::TearDown();
ChromeNetworkingCastPrivateDelegate::SetFactoryCallbackForTest(nullptr);
}
diff --git a/chromium/chrome/browser/extensions/api/notifications/notifications_apitest.cc b/chromium/chrome/browser/extensions/api/notifications/notifications_apitest.cc
index d999be59789..fbca69edf11 100644
--- a/chromium/chrome/browser/extensions/api/notifications/notifications_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/notifications/notifications_apitest.cc
@@ -5,7 +5,6 @@
#include <memory>
#include "base/containers/circular_deque.h"
-#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
@@ -112,7 +111,7 @@ enum class WindowState {
NORMAL
};
-class NotificationsApiTest : public ExtensionApiTest {
+class NotificationsApiTest : public extensions::ExtensionApiTest {
public:
const Extension* LoadExtensionAndWait(
const std::string& test_name) {
@@ -173,7 +172,7 @@ class NotificationsApiTest : public ExtensionApiTest {
protected:
void SetUpOnMainThread() override {
- ExtensionApiTest::SetUpOnMainThread();
+ extensions::ExtensionApiTest::SetUpOnMainThread();
DCHECK(profile());
display_service_tester_ =
@@ -182,7 +181,7 @@ class NotificationsApiTest : public ExtensionApiTest {
void TearDownOnMainThread() override {
display_service_tester_.reset();
- ExtensionApiTest::TearDownOnMainThread();
+ extensions::ExtensionApiTest::TearDownOnMainThread();
}
// Returns the notification that's being displayed for |extension|, or nullptr
diff --git a/chromium/chrome/browser/extensions/api/omnibox/omnibox_api_interactive_test.cc b/chromium/chrome/browser/extensions/api/omnibox/omnibox_api_interactive_test.cc
index 1e70b8a3011..c45a45ca66e 100644
--- a/chromium/chrome/browser/extensions/api/omnibox/omnibox_api_interactive_test.cc
+++ b/chromium/chrome/browser/extensions/api/omnibox/omnibox_api_interactive_test.cc
@@ -75,7 +75,14 @@ IN_PROC_BROWSER_TEST_F(OmniboxApiTest, PopupStaysClosed) {
}
// Tests deleting a deletable omnibox extension suggestion result.
-IN_PROC_BROWSER_TEST_F(OmniboxApiTest, DeleteOmniboxSuggestionResult) {
+// Flaky on Windows. https://crbug.com/801316
+#if defined(OS_WIN)
+#define MAYBE_DeleteOmniboxSuggestionResult \
+ DISABLED_DeleteOmniboxSuggestionResult
+#else
+#define MAYBE_DeleteOmniboxSuggestionResult DeleteOmniboxSuggestionResult
+#endif
+IN_PROC_BROWSER_TEST_F(OmniboxApiTest, MAYBE_DeleteOmniboxSuggestionResult) {
ASSERT_TRUE(RunExtensionTest("omnibox")) << message_;
// The results depend on the TemplateURLService being loaded. Make sure it is
diff --git a/chromium/chrome/browser/extensions/api/omnibox/omnibox_api_testbase.h b/chromium/chrome/browser/extensions/api/omnibox/omnibox_api_testbase.h
index 0013aa05f35..c95e2c48834 100644
--- a/chromium/chrome/browser/extensions/api/omnibox/omnibox_api_testbase.h
+++ b/chromium/chrome/browser/extensions/api/omnibox/omnibox_api_testbase.h
@@ -24,7 +24,7 @@
class AutocompleteController;
-class OmniboxApiTest : public ExtensionApiTest {
+class OmniboxApiTest : public extensions::ExtensionApiTest {
protected:
LocationBar* GetLocationBar(Browser* browser) const {
return browser->window()->GetLocationBar();
diff --git a/chromium/chrome/browser/extensions/api/page_capture/page_capture_apitest.cc b/chromium/chrome/browser/extensions/api/page_capture/page_capture_apitest.cc
index 3e7e9bd2934..96e50f1b94d 100644
--- a/chromium/chrome/browser/extensions/api/page_capture/page_capture_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/page_capture/page_capture_apitest.cc
@@ -22,14 +22,14 @@
using extensions::PageCaptureSaveAsMHTMLFunction;
using extensions::ScopedTestDialogAutoConfirm;
-class ExtensionPageCaptureApiTest : public ExtensionApiTest {
+class ExtensionPageCaptureApiTest : public extensions::ExtensionApiTest {
public:
void SetUpCommandLine(base::CommandLine* command_line) override {
- ExtensionApiTest::SetUpCommandLine(command_line);
+ extensions::ExtensionApiTest::SetUpCommandLine(command_line);
command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc");
}
void SetUpOnMainThread() override {
- ExtensionApiTest::SetUpOnMainThread();
+ extensions::ExtensionApiTest::SetUpOnMainThread();
host_resolver()->AddRule("*", "127.0.0.1");
}
};
diff --git a/chromium/chrome/browser/extensions/api/passwords_private/passwords_private_api.cc b/chromium/chrome/browser/extensions/api/passwords_private/passwords_private_api.cc
index f1b79559ce1..2ed573f89bb 100644
--- a/chromium/chrome/browser/extensions/api/passwords_private/passwords_private_api.cc
+++ b/chromium/chrome/browser/extensions/api/passwords_private/passwords_private_api.cc
@@ -177,7 +177,7 @@ PasswordsPrivateImportPasswordsFunction::Run() {
PasswordsPrivateDelegate* delegate =
PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context(),
true /* create */);
- delegate->ImportPasswords(GetAssociatedWebContents());
+ delegate->ImportPasswords(GetSenderWebContents());
return RespondNow(NoArguments());
}
@@ -196,7 +196,7 @@ PasswordsPrivateExportPasswordsFunction::Run() {
base::BindOnce(
&PasswordsPrivateExportPasswordsFunction::ExportRequestCompleted,
this),
- GetAssociatedWebContents());
+ GetSenderWebContents());
return RespondLater();
}
diff --git a/chromium/chrome/browser/extensions/api/permissions/permissions_api.cc b/chromium/chrome/browser/extensions/api/permissions/permissions_api.cc
index d78cf8f3d83..dcc9fd56b9b 100644
--- a/chromium/chrome/browser/extensions/api/permissions/permissions_api.cc
+++ b/chromium/chrome/browser/extensions/api/permissions/permissions_api.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/api/permissions/permissions_api_helpers.h"
+#include "chrome/browser/extensions/chrome_extension_function_details.h"
#include "chrome/browser/extensions/extension_management.h"
#include "chrome/browser/extensions/permissions_updater.h"
#include "chrome/browser/profiles/profile.h"
@@ -142,63 +143,61 @@ PermissionsRequestFunction::PermissionsRequestFunction() {}
PermissionsRequestFunction::~PermissionsRequestFunction() {}
-bool PermissionsRequestFunction::RunAsync() {
- results_ = Request::Results::Create(false);
-
+ExtensionFunction::ResponseAction PermissionsRequestFunction::Run() {
if (!user_gesture() &&
!ignore_user_gesture_for_tests &&
extension_->location() != Manifest::COMPONENT) {
- error_ = kUserGestureRequiredError;
- return false;
+ return RespondNow(Error(kUserGestureRequiredError));
}
+ gfx::NativeWindow native_window =
+ ChromeExtensionFunctionDetails(this).GetNativeWindowForUI();
+ if (!native_window)
+ return RespondNow(Error("Could not find an active window."));
+
std::unique_ptr<Request::Params> params(Request::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
+ std::string error;
requested_permissions_ = helpers::UnpackPermissionSet(
params->permissions,
- ExtensionPrefs::Get(GetProfile())->AllowFileAccess(extension_->id()),
- &error_);
+ ExtensionPrefs::Get(browser_context())->AllowFileAccess(extension_->id()),
+ &error);
if (!requested_permissions_.get())
- return false;
+ return RespondNow(Error(error));
// Make sure they're only requesting permissions supported by this API.
APIPermissionSet apis = requested_permissions_->apis();
for (APIPermissionSet::const_iterator i = apis.begin();
i != apis.end(); ++i) {
if (!i->info()->supports_optional()) {
- error_ = ErrorUtils::FormatErrorMessage(
- kNotWhitelistedError, i->name());
- return false;
+ return RespondNow(Error(
+ ErrorUtils::FormatErrorMessage(kNotWhitelistedError, i->name())));
}
}
// The requested permissions must be defined as optional in the manifest.
if (!PermissionsParser::GetOptionalPermissions(extension())
.Contains(*requested_permissions_)) {
- error_ = kNotInOptionalPermissionsError;
- return false;
+ return RespondNow(Error(kNotInOptionalPermissionsError));
}
// Automatically declines api permissions requests, which are blocked by
// enterprise policy.
- if (!ExtensionManagementFactory::GetForBrowserContext(GetProfile())
+ if (!ExtensionManagementFactory::GetForBrowserContext(browser_context())
->IsPermissionSetAllowed(extension(), *requested_permissions_)) {
- error_ = kBlockedByEnterprisePolicy;
- return false;
+ return RespondNow(Error(kBlockedByEnterprisePolicy));
}
// We don't need to prompt the user if the requested permissions are a subset
// of the granted permissions set.
std::unique_ptr<const PermissionSet> granted =
- ExtensionPrefs::Get(GetProfile())
+ ExtensionPrefs::Get(browser_context())
->GetGrantedPermissions(extension()->id());
if (granted.get() && granted->Contains(*requested_permissions_)) {
- PermissionsUpdater perms_updater(GetProfile());
+ PermissionsUpdater perms_updater(browser_context());
perms_updater.AddPermissions(extension(), *requested_permissions_);
- results_ = Request::Results::Create(true);
- SendResponse(true);
- return true;
+ return RespondNow(ArgumentList(Request::Results::Create(true)));
}
// Filter out the granted permissions so we only prompt for new ones.
@@ -225,35 +224,40 @@ bool PermissionsRequestFunction::RunAsync() {
if (auto_confirm_for_tests == PROCEED || has_no_warnings ||
extension_->location() == Manifest::COMPONENT) {
OnInstallPromptDone(ExtensionInstallPrompt::Result::ACCEPTED);
- } else if (auto_confirm_for_tests == ABORT) {
+ return AlreadyResponded();
+ }
+
+ if (auto_confirm_for_tests == ABORT) {
// Pretend the user clicked cancel.
OnInstallPromptDone(ExtensionInstallPrompt::Result::USER_CANCELED);
- } else {
- CHECK_EQ(DO_NOT_SKIP, auto_confirm_for_tests);
- install_ui_.reset(new ExtensionInstallPrompt(GetAssociatedWebContents()));
- install_ui_->ShowDialog(
- base::Bind(&PermissionsRequestFunction::OnInstallPromptDone, this),
- extension(), nullptr,
- std::make_unique<ExtensionInstallPrompt::Prompt>(
- ExtensionInstallPrompt::PERMISSIONS_PROMPT),
- requested_permissions_->Clone(),
- ExtensionInstallPrompt::GetDefaultShowDialogCallback());
+ return AlreadyResponded();
}
- return true;
+ CHECK_EQ(DO_NOT_SKIP, auto_confirm_for_tests);
+ install_ui_.reset(new ExtensionInstallPrompt(
+ Profile::FromBrowserContext(browser_context()), native_window));
+ install_ui_->ShowDialog(
+ base::Bind(&PermissionsRequestFunction::OnInstallPromptDone, this),
+ extension(), nullptr,
+ std::make_unique<ExtensionInstallPrompt::Prompt>(
+ ExtensionInstallPrompt::PERMISSIONS_PROMPT),
+ requested_permissions_->Clone(),
+ ExtensionInstallPrompt::GetDefaultShowDialogCallback());
+
+ // ExtensionInstallPrompt::ShowDialog() can call the response synchronously.
+ return did_respond() ? AlreadyResponded() : RespondLater();
}
void PermissionsRequestFunction::OnInstallPromptDone(
ExtensionInstallPrompt::Result result) {
- if (result == ExtensionInstallPrompt::Result::ACCEPTED) {
- PermissionsUpdater perms_updater(GetProfile());
+ bool granted = result == ExtensionInstallPrompt::Result::ACCEPTED;
+ if (granted) {
+ PermissionsUpdater perms_updater(browser_context());
perms_updater.AddPermissions(extension(), *requested_permissions_);
-
- results_ = Request::Results::Create(true);
}
- SendResponse(true);
- Release(); // Balanced in RunAsync().
+ Respond(ArgumentList(Request::Results::Create(granted)));
+ Release(); // Balanced in Run().
}
} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/permissions/permissions_api.h b/chromium/chrome/browser/extensions/api/permissions/permissions_api.h
index e780a45199d..63e516bf56a 100644
--- a/chromium/chrome/browser/extensions/api/permissions/permissions_api.h
+++ b/chromium/chrome/browser/extensions/api/permissions/permissions_api.h
@@ -9,8 +9,8 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "chrome/browser/extensions/chrome_extension_function.h"
#include "chrome/browser/extensions/extension_install_prompt.h"
+#include "extensions/browser/extension_function.h"
#include "extensions/common/permissions/permission_set.h"
namespace extensions {
@@ -52,7 +52,7 @@ class PermissionsRemoveFunction : public UIThreadExtensionFunction {
};
// chrome.permissions.request
-class PermissionsRequestFunction : public ChromeAsyncExtensionFunction {
+class PermissionsRequestFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("permissions.request", PERMISSIONS_REQUEST)
@@ -66,7 +66,7 @@ class PermissionsRequestFunction : public ChromeAsyncExtensionFunction {
~PermissionsRequestFunction() override;
// ExtensionFunction:
- bool RunAsync() override;
+ ResponseAction Run() override;
private:
void OnInstallPromptDone(ExtensionInstallPrompt::Result result);
diff --git a/chromium/chrome/browser/extensions/api/platform_keys/platform_keys_apitest_nss.cc b/chromium/chrome/browser/extensions/api/platform_keys/platform_keys_apitest_nss.cc
index 63971e9f50f..8df8111325f 100644
--- a/chromium/chrome/browser/extensions/api/platform_keys/platform_keys_apitest_nss.cc
+++ b/chromium/chrome/browser/extensions/api/platform_keys/platform_keys_apitest_nss.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <cryptohi.h>
+#include <pk11pub.h>
#include <memory>
#include <utility>
@@ -20,6 +21,8 @@
#include "chrome/browser/profiles/profile.h"
#include "components/policy/policy_constants.h"
#include "crypto/nss_util_internal.h"
+#include "crypto/scoped_nss_types.h"
+#include "crypto/scoped_test_nss_db.h"
#include "crypto/scoped_test_system_nss_key_slot.h"
#include "net/cert/nss_cert_database.h"
#include "net/cert/test_root_certs.h"
@@ -30,15 +33,34 @@ namespace {
class PlatformKeysTest : public PlatformKeysTestBase {
public:
+ enum class UserClientCertSlot { kPrivateSlot, kPublicSlot };
+
PlatformKeysTest(EnrollmentStatus enrollment_status,
UserStatus user_status,
- bool key_permission_policy)
+ bool key_permission_policy,
+ UserClientCertSlot user_client_cert_slot)
: PlatformKeysTestBase(SystemTokenStatus::EXISTS,
enrollment_status,
user_status),
- key_permission_policy_(key_permission_policy) {}
+ key_permission_policy_(key_permission_policy),
+ user_client_cert_slot_(user_client_cert_slot) {}
void SetUpOnMainThread() override {
+ if (!IsPreTest()) {
+ // Set up the private slot before
+ // |PlatformKeysTestBase::SetUpOnMainThread| triggers the user sign-in.
+ ASSERT_TRUE(user_private_slot_db_.is_open());
+ base::RunLoop loop;
+ content::BrowserThread::PostTaskAndReply(
+ content::BrowserThread::IO, FROM_HERE,
+ base::BindOnce(&PlatformKeysTest::SetPrivateSoftwareSlotOnIO,
+ base::Unretained(this),
+ crypto::ScopedPK11Slot(
+ PK11_ReferenceSlot(user_private_slot_db_.slot()))),
+ loop.QuitClosure());
+ loop.Run();
+ }
+
PlatformKeysTestBase::SetUpOnMainThread();
if (IsPreTest())
@@ -128,11 +150,18 @@ class PlatformKeysTest : public PlatformKeysTestBase {
}
protected:
+ // Imported into user's private or public slot, depending on the value of
+ // |user_client_cert_slot_|.
scoped_refptr<net::X509Certificate> client_cert1_;
+ // Imported into system slot.
scoped_refptr<net::X509Certificate> client_cert2_;
const extensions::Extension* extension_;
private:
+ void SetPrivateSoftwareSlotOnIO(crypto::ScopedPK11Slot slot) {
+ crypto::SetPrivateSoftwareSlotForChromeOSUserForTesting(std::move(slot));
+ }
+
void GotPermissionsForExtension(
const base::Closure& done_callback,
std::unique_ptr<chromeos::KeyPermissions::PermissionsForExtension>
@@ -152,9 +181,16 @@ class PlatformKeysTest : public PlatformKeysTestBase {
}
void SetupTestClientCerts(net::NSSCertDatabase* cert_db) {
+ // Sanity check to ensure that
+ // SetPrivateSoftwareSlotForChromeOSUserForTesting took effect.
+ EXPECT_EQ(user_private_slot_db_.slot(), cert_db->GetPrivateSlot().get());
+ EXPECT_NE(cert_db->GetPrivateSlot().get(), cert_db->GetPublicSlot().get());
+
+ auto* slot = user_client_cert_slot_ == UserClientCertSlot::kPrivateSlot
+ ? cert_db->GetPrivateSlot().get()
+ : cert_db->GetPublicSlot().get();
client_cert1_ = net::ImportClientCertAndKeyFromFile(
- net::GetTestCertsDirectory(), "client_1.pem", "client_1.pk8",
- cert_db->GetPrivateSlot().get());
+ net::GetTestCertsDirectory(), "client_1.pem", "client_1.pk8", slot);
ASSERT_TRUE(client_cert1_.get());
// Import a second client cert signed by another CA than client_1 into the
@@ -175,6 +211,8 @@ class PlatformKeysTest : public PlatformKeysTestBase {
}
const bool key_permission_policy_;
+ const UserClientCertSlot user_client_cert_slot_;
+ crypto::ScopedTestNSSDB user_private_slot_db_;
DISALLOW_COPY_AND_ASSIGN(PlatformKeysTest);
};
@@ -204,7 +242,7 @@ class TestSelectDelegate
scoped_refptr<net::X509Certificate> selection;
if (certs_to_select_.back()) {
for (scoped_refptr<net::X509Certificate> cert : certs) {
- if (cert->Equals(certs_to_select_.back().get())) {
+ if (cert->EqualsExcludingChain(certs_to_select_.back().get())) {
selection = cert;
break;
}
@@ -219,19 +257,32 @@ class TestSelectDelegate
net::CertificateList certs_to_select_;
};
-class UnmanagedPlatformKeysTest : public PlatformKeysTest,
- public ::testing::WithParamInterface<
- PlatformKeysTestBase::EnrollmentStatus> {
+struct UnmanagedPlatformKeysTestParams {
+ UnmanagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus enrollment_status,
+ PlatformKeysTest::UserClientCertSlot user_client_cert_slot)
+ : enrollment_status_(enrollment_status),
+ user_client_cert_slot_(user_client_cert_slot) {}
+
+ PlatformKeysTestBase::EnrollmentStatus enrollment_status_;
+ PlatformKeysTest::UserClientCertSlot user_client_cert_slot_;
+};
+
+class UnmanagedPlatformKeysTest
+ : public PlatformKeysTest,
+ public ::testing::WithParamInterface<UnmanagedPlatformKeysTestParams> {
public:
UnmanagedPlatformKeysTest()
- : PlatformKeysTest(GetParam(),
+ : PlatformKeysTest(GetParam().enrollment_status_,
UserStatus::UNMANAGED,
- false /* unused */) {}
+ false /* unused */,
+ GetParam().user_client_cert_slot_) {}
};
-struct Params {
- Params(PlatformKeysTestBase::EnrollmentStatus enrollment_status,
- PlatformKeysTestBase::UserStatus user_status)
+struct ManagedPlatformKeysTestParams {
+ ManagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus enrollment_status,
+ PlatformKeysTestBase::UserStatus user_status)
: enrollment_status_(enrollment_status), user_status_(user_status) {}
PlatformKeysTestBase::EnrollmentStatus enrollment_status_;
@@ -240,22 +291,24 @@ struct Params {
class ManagedWithPermissionPlatformKeysTest
: public PlatformKeysTest,
- public ::testing::WithParamInterface<Params> {
+ public ::testing::WithParamInterface<ManagedPlatformKeysTestParams> {
public:
ManagedWithPermissionPlatformKeysTest()
: PlatformKeysTest(GetParam().enrollment_status_,
GetParam().user_status_,
- true /* grant the extension key permission */) {}
+ true /* grant the extension key permission */,
+ UserClientCertSlot::kPrivateSlot) {}
};
class ManagedWithoutPermissionPlatformKeysTest
: public PlatformKeysTest,
- public ::testing::WithParamInterface<Params> {
+ public ::testing::WithParamInterface<ManagedPlatformKeysTestParams> {
public:
ManagedWithoutPermissionPlatformKeysTest()
: PlatformKeysTest(GetParam().enrollment_status_,
GetParam().user_status_,
- false /* do not grant key permission */) {}
+ false /* do not grant key permission */,
+ UserClientCertSlot::kPrivateSlot) {}
};
} // namespace
@@ -299,8 +352,18 @@ IN_PROC_BROWSER_TEST_P(UnmanagedPlatformKeysTest, Permissions) {
INSTANTIATE_TEST_CASE_P(
Unmanaged,
UnmanagedPlatformKeysTest,
- ::testing::Values(PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
- PlatformKeysTestBase::EnrollmentStatus::NOT_ENROLLED));
+ ::testing::Values(UnmanagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
+ PlatformKeysTest::UserClientCertSlot::kPrivateSlot),
+ UnmanagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus::NOT_ENROLLED,
+ PlatformKeysTest::UserClientCertSlot::kPrivateSlot),
+ UnmanagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
+ PlatformKeysTest::UserClientCertSlot::kPublicSlot),
+ UnmanagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus::NOT_ENROLLED,
+ PlatformKeysTest::UserClientCertSlot::kPublicSlot)));
IN_PROC_BROWSER_TEST_P(ManagedWithoutPermissionPlatformKeysTest,
PRE_UserPermissionsBlocked) {
@@ -340,12 +403,15 @@ INSTANTIATE_TEST_CASE_P(
ManagedWithoutPermission,
ManagedWithoutPermissionPlatformKeysTest,
::testing::Values(
- Params(PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
- PlatformKeysTestBase::UserStatus::MANAGED_AFFILIATED_DOMAIN),
- Params(PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
- PlatformKeysTestBase::UserStatus::MANAGED_OTHER_DOMAIN),
- Params(PlatformKeysTestBase::EnrollmentStatus::NOT_ENROLLED,
- PlatformKeysTestBase::UserStatus::MANAGED_OTHER_DOMAIN)));
+ ManagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
+ PlatformKeysTestBase::UserStatus::MANAGED_AFFILIATED_DOMAIN),
+ ManagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
+ PlatformKeysTestBase::UserStatus::MANAGED_OTHER_DOMAIN),
+ ManagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus::NOT_ENROLLED,
+ PlatformKeysTestBase::UserStatus::MANAGED_OTHER_DOMAIN)));
IN_PROC_BROWSER_TEST_P(ManagedWithPermissionPlatformKeysTest,
PRE_PolicyGrantsAccessToCorporateKey) {
@@ -396,9 +462,12 @@ INSTANTIATE_TEST_CASE_P(
ManagedWithPermission,
ManagedWithPermissionPlatformKeysTest,
::testing::Values(
- Params(PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
- PlatformKeysTestBase::UserStatus::MANAGED_AFFILIATED_DOMAIN),
- Params(PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
- PlatformKeysTestBase::UserStatus::MANAGED_OTHER_DOMAIN),
- Params(PlatformKeysTestBase::EnrollmentStatus::NOT_ENROLLED,
- PlatformKeysTestBase::UserStatus::MANAGED_OTHER_DOMAIN)));
+ ManagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
+ PlatformKeysTestBase::UserStatus::MANAGED_AFFILIATED_DOMAIN),
+ ManagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
+ PlatformKeysTestBase::UserStatus::MANAGED_OTHER_DOMAIN),
+ ManagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus::NOT_ENROLLED,
+ PlatformKeysTestBase::UserStatus::MANAGED_OTHER_DOMAIN)));
diff --git a/chromium/chrome/browser/extensions/api/platform_keys/platform_keys_test_base.cc b/chromium/chrome/browser/extensions/api/platform_keys/platform_keys_test_base.cc
index 74e8911e005..24934f6a747 100644
--- a/chromium/chrome/browser/extensions/api/platform_keys/platform_keys_test_base.cc
+++ b/chromium/chrome/browser/extensions/api/platform_keys/platform_keys_test_base.cc
@@ -56,7 +56,7 @@ PlatformKeysTestBase::~PlatformKeysTestBase() {}
void PlatformKeysTestBase::SetUp() {
base::FilePath test_data_dir;
- PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
+ base::PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
embedded_test_server()->ServeFilesFromDirectory(test_data_dir);
embedded_test_server()->RegisterRequestHandler(base::BindRepeating(
@@ -72,11 +72,11 @@ void PlatformKeysTestBase::SetUp() {
GaiaUrls::GetInstance()->gaia_url().host(),
embedded_test_server()->base_url()));
- ExtensionApiTest::SetUp();
+ extensions::ExtensionApiTest::SetUp();
}
void PlatformKeysTestBase::SetUpCommandLine(base::CommandLine* command_line) {
- ExtensionApiTest::SetUpCommandLine(command_line);
+ extensions::ExtensionApiTest::SetUpCommandLine(command_line);
policy::affiliation_test_helper::AppendCommandLineSwitchesForLoginManager(
command_line);
@@ -91,7 +91,7 @@ void PlatformKeysTestBase::SetUpCommandLine(base::CommandLine* command_line) {
}
void PlatformKeysTestBase::SetUpInProcessBrowserTestFixture() {
- ExtensionApiTest::SetUpInProcessBrowserTestFixture();
+ extensions::ExtensionApiTest::SetUpInProcessBrowserTestFixture();
chromeos::FakeSessionManagerClient* fake_session_manager_client =
new chromeos::FakeSessionManagerClient;
@@ -162,11 +162,11 @@ void PlatformKeysTestBase::SetUpOnMainThread() {
loop.Run();
}
- ExtensionApiTest::SetUpOnMainThread();
+ extensions::ExtensionApiTest::SetUpOnMainThread();
}
void PlatformKeysTestBase::TearDownOnMainThread() {
- ExtensionApiTest::TearDownOnMainThread();
+ extensions::ExtensionApiTest::TearDownOnMainThread();
if (system_token_status() == SystemTokenStatus::EXISTS) {
base::RunLoop loop;
diff --git a/chromium/chrome/browser/extensions/api/platform_keys/platform_keys_test_base.h b/chromium/chrome/browser/extensions/api/platform_keys/platform_keys_test_base.h
index 01f5ff06467..75f525973bd 100644
--- a/chromium/chrome/browser/extensions/api/platform_keys/platform_keys_test_base.h
+++ b/chromium/chrome/browser/extensions/api/platform_keys/platform_keys_test_base.h
@@ -11,8 +11,8 @@
#include "chrome/browser/chromeos/login/test/https_forwarder.h"
#include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h"
#include "chrome/browser/extensions/extension_apitest.h"
+#include "components/account_id/account_id.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
-#include "components/signin/core/account_id/account_id.h"
#include "google_apis/gaia/fake_gaia.h"
namespace crypto {
@@ -23,7 +23,7 @@ class ScopedTestSystemNSSKeySlot;
// availability, device enrollment status, user affiliation and user policy.
// Every test case is supposed to have a PRE_ test case which must call
// PlatformKeysTestBase::RunPreTest.
-class PlatformKeysTestBase : public ExtensionApiTest {
+class PlatformKeysTestBase : public extensions::ExtensionApiTest {
public:
enum class SystemTokenStatus { EXISTS, DOES_NOT_EXIST };
diff --git a/chromium/chrome/browser/extensions/api/preference/preference_api.cc b/chromium/chrome/browser/extensions/api/preference/preference_api.cc
index fe98bbb17a7..8eba4e71b44 100644
--- a/chromium/chrome/browser/extensions/api/preference/preference_api.cc
+++ b/chromium/chrome/browser/extensions/api/preference/preference_api.cc
@@ -127,7 +127,6 @@ const PrefMappingEntry kPrefMapping[] = {
APIPermission::kPrivacy, APIPermission::kPrivacy},
{"translationServiceEnabled", prefs::kOfferTranslateEnabled,
APIPermission::kPrivacy, APIPermission::kPrivacy},
-#if BUILDFLAG(ENABLE_WEBRTC)
// webRTCMultipleRoutesEnabled and webRTCNonProxiedUdpEnabled have been
// replaced by webRTCIPHandlingPolicy. Leaving it for backward
// compatibility. TODO(guoweis): Remove this in M50.
@@ -139,7 +138,6 @@ const PrefMappingEntry kPrefMapping[] = {
APIPermission::kPrivacy, APIPermission::kPrivacy},
{"webRTCUDPPortRange", prefs::kWebRTCUDPPortRange, APIPermission::kPrivacy,
APIPermission::kPrivacy},
-#endif
// accessibilityFeatures.animationPolicy is available for
// all platforms but the others from accessibilityFeatures
// is only available for OS_CHROMEOS.
diff --git a/chromium/chrome/browser/extensions/api/preference/preference_apitest.cc b/chromium/chrome/browser/extensions/api/preference/preference_apitest.cc
index 17b0bfde383..1c25420c612 100644
--- a/chromium/chrome/browser/extensions/api/preference/preference_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/preference/preference_apitest.cc
@@ -35,7 +35,7 @@
#include "extensions/test/result_catcher.h"
#include "media/media_buildflags.h"
-class ExtensionPreferenceApiTest : public ExtensionApiTest {
+class ExtensionPreferenceApiTest : public extensions::ExtensionApiTest {
protected:
ExtensionPreferenceApiTest() : profile_(NULL) {}
@@ -80,7 +80,7 @@ class ExtensionPreferenceApiTest : public ExtensionApiTest {
}
void SetUpOnMainThread() override {
- ExtensionApiTest::SetUpOnMainThread();
+ extensions::ExtensionApiTest::SetUpOnMainThread();
// The browser might get closed later (and therefore be destroyed), so we
// save the profile.
@@ -101,7 +101,7 @@ class ExtensionPreferenceApiTest : public ExtensionApiTest {
base::Unretained(&keep_alive_), nullptr));
content::RunAllPendingInMessageLoop();
- ExtensionApiTest::TearDownOnMainThread();
+ extensions::ExtensionApiTest::TearDownOnMainThread();
}
Profile* profile_;
@@ -127,12 +127,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionPreferenceApiTest, MAYBE_Standard) {
prefs->SetBoolean(password_manager::prefs::kCredentialsEnableService, false);
prefs->SetBoolean(prefs::kSafeBrowsingEnabled, false);
prefs->SetBoolean(prefs::kSearchSuggestEnabled, false);
-#if BUILDFLAG(ENABLE_WEBRTC)
prefs->SetBoolean(prefs::kWebRTCMultipleRoutesEnabled, false);
prefs->SetBoolean(prefs::kWebRTCNonProxiedUdpEnabled, false);
prefs->SetString(prefs::kWebRTCIPHandlingPolicy,
content::kWebRTCIPHandlingDefaultPublicInterfaceOnly);
-#endif
const char kExtensionPath[] = "preference/standard";
diff --git a/chromium/chrome/browser/extensions/api/processes/processes_api.cc b/chromium/chrome/browser/extensions/api/processes/processes_api.cc
index 6aa8242a882..84d72154ca7 100644
--- a/chromium/chrome/browser/extensions/api/processes/processes_api.cc
+++ b/chromium/chrome/browser/extensions/api/processes/processes_api.cc
@@ -500,7 +500,8 @@ ExtensionFunction::ResponseAction ProcessesTerminateFunction::Run() {
auto* render_process_host =
content::RenderProcessHost::FromID(child_process_host_id_);
if (render_process_host)
- return RespondNow(TerminateIfAllowed(render_process_host->GetHandle()));
+ return RespondNow(
+ TerminateIfAllowed(render_process_host->GetProcess().Handle()));
// This could be a non-renderer child process like a plugin or a nacl
// process. Try to get its handle from the BrowserChildProcessHost on the
diff --git a/chromium/chrome/browser/extensions/api/processes/processes_apitest.cc b/chromium/chrome/browser/extensions/api/processes/processes_apitest.cc
index da8e064fa21..c470ed46677 100644
--- a/chromium/chrome/browser/extensions/api/processes/processes_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/processes/processes_apitest.cc
@@ -13,7 +13,7 @@
#include "extensions/common/switches.h"
#include "extensions/test/extension_test_message_listener.h"
-class ProcessesApiTest : public ExtensionApiTest {
+class ProcessesApiTest : public extensions::ExtensionApiTest {
public:
ProcessesApiTest() {}
~ProcessesApiTest() override {}
diff --git a/chromium/chrome/browser/extensions/api/resources_private/resources_private_apitest.cc b/chromium/chrome/browser/extensions/api/resources_private/resources_private_apitest.cc
index 9b8b16c18f6..bddf8cd1419 100644
--- a/chromium/chrome/browser/extensions/api/resources_private/resources_private_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/resources_private/resources_private_apitest.cc
@@ -5,13 +5,7 @@
#include "base/macros.h"
#include "chrome/browser/extensions/extension_apitest.h"
-class ResourcesPrivateApiTest : public ExtensionApiTest {
- public:
- ResourcesPrivateApiTest() {}
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ResourcesPrivateApiTest);
-};
+using ResourcesPrivateApiTest = extensions::ExtensionApiTest;
IN_PROC_BROWSER_TEST_F(ResourcesPrivateApiTest, GetStrings) {
ASSERT_TRUE(RunComponentExtensionTest("resources_private/get_strings"));
diff --git a/chromium/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc b/chromium/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc
index 40364179f40..b30736cadbe 100644
--- a/chromium/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc
+++ b/chromium/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc
@@ -283,6 +283,10 @@ bool ChromeRuntimeAPIDelegate::GetPlatformInfo(PlatformInfo* info) {
info->arch = extensions::api::runtime::PLATFORM_ARCH_X86_32;
} else if (strcmp(arch, "x64") == 0) {
info->arch = extensions::api::runtime::PLATFORM_ARCH_X86_64;
+ } else if (strcmp(arch, "mipsel") == 0) {
+ info->arch = extensions::api::runtime::PLATFORM_ARCH_MIPS;
+ } else if (strcmp(arch, "mips64el") == 0) {
+ info->arch = extensions::api::runtime::PLATFORM_ARCH_MIPS64;
} else {
NOTREACHED();
return false;
@@ -295,6 +299,10 @@ bool ChromeRuntimeAPIDelegate::GetPlatformInfo(PlatformInfo* info) {
info->nacl_arch = extensions::api::runtime::PLATFORM_NACL_ARCH_X86_32;
} else if (strcmp(nacl_arch, "x86-64") == 0) {
info->nacl_arch = extensions::api::runtime::PLATFORM_NACL_ARCH_X86_64;
+ } else if (strcmp(nacl_arch, "mips32") == 0) {
+ info->nacl_arch = extensions::api::runtime::PLATFORM_NACL_ARCH_MIPS;
+ } else if (strcmp(nacl_arch, "mips64") == 0) {
+ info->nacl_arch = extensions::api::runtime::PLATFORM_NACL_ARCH_MIPS64;
} else {
NOTREACHED();
return false;
diff --git a/chromium/chrome/browser/extensions/api/runtime/runtime_apitest.cc b/chromium/chrome/browser/extensions/api/runtime/runtime_apitest.cc
index a1f7840198a..b26ef11c2df 100644
--- a/chromium/chrome/browser/extensions/api/runtime/runtime_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/runtime/runtime_apitest.cc
@@ -20,6 +20,8 @@
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "url/url_constants.h"
+namespace extensions {
+
// Tests the privileged components of chrome.runtime.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeRuntimePrivileged) {
ASSERT_TRUE(RunExtensionTest("runtime/privileged")) << message_;
@@ -48,8 +50,6 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeRuntimeUninstallURL) {
ASSERT_TRUE(RunExtensionTest("runtime/uninstall_url")) << message_;
}
-namespace extensions {
-
namespace {
const char kUninstallUrl[] = "http://www.google.com/";
diff --git a/chromium/chrome/browser/extensions/api/safe_browsing_private/OWNERS b/chromium/chrome/browser/extensions/api/safe_browsing_private/OWNERS
new file mode 100644
index 00000000000..50851251692
--- /dev/null
+++ b/chromium/chrome/browser/extensions/api/safe_browsing_private/OWNERS
@@ -0,0 +1,3 @@
+jialiul@chromium.org
+nparker@chromium.org
+vakh@chromium.org
diff --git a/chromium/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router.cc b/chromium/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router.cc
new file mode 100644
index 00000000000..6ffd453df0d
--- /dev/null
+++ b/chromium/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router.cc
@@ -0,0 +1,143 @@
+// 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/extensions/api/safe_browsing_private/safe_browsing_private_event_router.h"
+
+#include "base/strings/string_number_conversions.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/extensions/api/safe_browsing_private.h"
+#include "content/public/browser/browser_context.h"
+#include "extensions/browser/event_router.h"
+#include "url/gurl.h"
+
+namespace extensions {
+
+SafeBrowsingPrivateEventRouter::SafeBrowsingPrivateEventRouter(
+ content::BrowserContext* context)
+ : context_(context), event_router_(nullptr) {
+ event_router_ = EventRouter::Get(context_);
+}
+
+SafeBrowsingPrivateEventRouter::~SafeBrowsingPrivateEventRouter() {}
+
+void SafeBrowsingPrivateEventRouter::OnPolicySpecifiedPasswordReuseDetected(
+ const GURL& url,
+ const std::string& user_name,
+ bool is_phishing_url) {
+ // |event_router_| can be null in tests.
+ if (!event_router_)
+ return;
+
+ api::safe_browsing_private::PolicySpecifiedPasswordReuse params;
+ params.url = url.spec();
+ params.user_name = user_name;
+ params.is_phishing_url = is_phishing_url;
+
+ auto event_value = std::make_unique<base::ListValue>();
+ event_value->Append(params.ToValue());
+
+ auto extension_event = std::make_unique<Event>(
+ events::SAFE_BROWSING_PRIVATE_ON_POLICY_SPECIFIED_PASSWORD_REUSE_DETECTED,
+ api::safe_browsing_private::OnPolicySpecifiedPasswordReuseDetected::
+ kEventName,
+ std::move(event_value));
+ event_router_->BroadcastEvent(std::move(extension_event));
+}
+
+void SafeBrowsingPrivateEventRouter::OnPolicySpecifiedPasswordChanged(
+ const std::string& user_name) {
+ // |event_router_| can be null in tests.
+ if (!event_router_)
+ return;
+
+ auto event_value = std::make_unique<base::ListValue>();
+ event_value->Append(std::make_unique<base::Value>(user_name));
+ auto extension_event = std::make_unique<Event>(
+ events::SAFE_BROWSING_PRIVATE_ON_POLICY_SPECIFIED_PASSWORD_CHANGED,
+ api::safe_browsing_private::OnPolicySpecifiedPasswordChanged::kEventName,
+ std::move(event_value));
+ event_router_->BroadcastEvent(std::move(extension_event));
+}
+
+void SafeBrowsingPrivateEventRouter::OnDangerousDownloadOpened(
+ const GURL& url,
+ const std::string& file_name,
+ const std::string& download_digest_sha256,
+ const std::string& user_name) {
+ // |event_router_| can be null in tests.
+ if (!event_router_)
+ return;
+
+ api::safe_browsing_private::DangerousDownloadInfo params;
+ params.url = url.spec();
+ params.file_name = file_name;
+ params.download_digest_sha256 = download_digest_sha256;
+ params.user_name = user_name;
+ auto event_value = std::make_unique<base::ListValue>();
+ event_value->Append(params.ToValue());
+
+ auto extension_event = std::make_unique<Event>(
+ events::SAFE_BROWSING_PRIVATE_ON_DANGEROUS_DOWNLOAD_OPENED,
+ api::safe_browsing_private::OnDangerousDownloadOpened::kEventName,
+ std::move(event_value));
+ event_router_->BroadcastEvent(std::move(extension_event));
+}
+
+void SafeBrowsingPrivateEventRouter::OnSecurityInterstitialShown(
+ const GURL& url,
+ const std::string& reason,
+ int net_error_code,
+ const std::string& user_name) {
+ // |event_router_| can be null in tests.
+ if (!event_router_)
+ return;
+
+ api::safe_browsing_private::InterstitialInfo params;
+ params.url = url.spec();
+ params.reason = reason;
+ if (net_error_code < 0) {
+ params.net_error_code =
+ std::make_unique<std::string>(base::NumberToString(net_error_code));
+ }
+ params.user_name = user_name;
+
+ auto event_value = std::make_unique<base::ListValue>();
+ event_value->Append(params.ToValue());
+
+ auto extension_event = std::make_unique<Event>(
+ events::SAFE_BROWSING_PRIVATE_ON_SECURITY_INTERSTITIAL_SHOWN,
+ api::safe_browsing_private::OnSecurityInterstitialShown::kEventName,
+ std::move(event_value));
+ event_router_->BroadcastEvent(std::move(extension_event));
+}
+
+void SafeBrowsingPrivateEventRouter::OnSecurityInterstitialProceeded(
+ const GURL& url,
+ const std::string& reason,
+ int net_error_code,
+ const std::string& user_name) {
+ // |event_router_| can be null in tests.
+ if (!event_router_)
+ return;
+
+ api::safe_browsing_private::InterstitialInfo params;
+ params.url = url.spec();
+ params.reason = reason;
+ if (net_error_code < 0) {
+ params.net_error_code =
+ std::make_unique<std::string>(base::NumberToString(net_error_code));
+ }
+ params.user_name = user_name;
+
+ auto event_value = std::make_unique<base::ListValue>();
+ event_value->Append(params.ToValue());
+
+ auto extension_event = std::make_unique<Event>(
+ events::SAFE_BROWSING_PRIVATE_ON_SECURITY_INTERSTITIAL_PROCEEDED,
+ api::safe_browsing_private::OnSecurityInterstitialProceeded::kEventName,
+ std::move(event_value));
+ event_router_->BroadcastEvent(std::move(extension_event));
+}
+
+} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router.h b/chromium/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router.h
new file mode 100644
index 00000000000..e5267e9dce4
--- /dev/null
+++ b/chromium/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router.h
@@ -0,0 +1,68 @@
+// 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_EXTENSIONS_API_SAFE_BROWSING_PRIVATE_SAFE_BROWSING_PRIVATE_EVENT_ROUTER_H_
+#define CHROME_BROWSER_EXTENSIONS_API_SAFE_BROWSING_PRIVATE_SAFE_BROWSING_PRIVATE_EVENT_ROUTER_H_
+
+#include <string>
+
+#include "base/macros.h"
+#include "components/keyed_service/core/keyed_service.h"
+
+namespace content {
+class BrowserContext;
+}
+
+namespace extensions {
+class EventRouter;
+}
+
+class GURL;
+
+namespace extensions {
+
+// An event router that observes Safe Browsing events and notifies listeners.
+class SafeBrowsingPrivateEventRouter : public KeyedService {
+ public:
+ explicit SafeBrowsingPrivateEventRouter(content::BrowserContext* context);
+
+ ~SafeBrowsingPrivateEventRouter() override;
+
+ // Notifies listeners that the user reused a protected password.
+ void OnPolicySpecifiedPasswordReuseDetected(const GURL& url,
+ const std::string& user_name,
+ bool is_phishing_url);
+
+ // Notifies listeners that the user changed the password associated with
+ // |user_name|.
+ void OnPolicySpecifiedPasswordChanged(const std::string& user_name);
+
+ // Notifies listeners that the user just opened a dangerous download.
+ void OnDangerousDownloadOpened(const GURL& url,
+ const std::string& file_name,
+ const std::string& download_digest_sha256,
+ const std::string& user_name);
+
+ // Notifies listeners that the user saw a security interstitial.
+ void OnSecurityInterstitialShown(const GURL& url,
+ const std::string& reason,
+ int net_error_code,
+ const std::string& user_name);
+
+ // Notifies listeners that the user clicked-through a security interstitial.
+ void OnSecurityInterstitialProceeded(const GURL& url,
+ const std::string& reason,
+ int net_error_code,
+ const std::string& user_name);
+
+ private:
+ content::BrowserContext* context_;
+ EventRouter* event_router_;
+
+ DISALLOW_COPY_AND_ASSIGN(SafeBrowsingPrivateEventRouter);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_API_SAFE_BROWSING_PRIVATE_SAFE_BROWSING_PRIVATE_EVENT_ROUTER_H_
diff --git a/chromium/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router_factory.cc b/chromium/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router_factory.cc
new file mode 100644
index 00000000000..f9cc8435642
--- /dev/null
+++ b/chromium/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router_factory.cc
@@ -0,0 +1,59 @@
+// 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/extensions/api/safe_browsing_private/safe_browsing_private_event_router_factory.h"
+
+#include "chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router.h"
+#include "components/keyed_service/content/browser_context_dependency_manager.h"
+#include "content/public/browser/browser_context.h"
+#include "extensions/browser/extension_system_provider.h"
+#include "extensions/browser/extensions_browser_client.h"
+
+namespace extensions {
+
+// static
+SafeBrowsingPrivateEventRouter*
+SafeBrowsingPrivateEventRouterFactory::GetForProfile(
+ content::BrowserContext* context) {
+ return static_cast<SafeBrowsingPrivateEventRouter*>(
+ GetInstance()->GetServiceForBrowserContext(context, true));
+}
+
+// static
+SafeBrowsingPrivateEventRouterFactory*
+SafeBrowsingPrivateEventRouterFactory::GetInstance() {
+ return base::Singleton<SafeBrowsingPrivateEventRouterFactory>::get();
+}
+
+SafeBrowsingPrivateEventRouterFactory::SafeBrowsingPrivateEventRouterFactory()
+ : BrowserContextKeyedServiceFactory(
+ "SafeBrowsingPrivateEventRouter",
+ BrowserContextDependencyManager::GetInstance()) {
+ DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
+}
+
+SafeBrowsingPrivateEventRouterFactory::
+ ~SafeBrowsingPrivateEventRouterFactory() {}
+
+KeyedService* SafeBrowsingPrivateEventRouterFactory::BuildServiceInstanceFor(
+ content::BrowserContext* context) const {
+ return new SafeBrowsingPrivateEventRouter(context);
+}
+
+content::BrowserContext*
+SafeBrowsingPrivateEventRouterFactory::GetBrowserContextToUse(
+ content::BrowserContext* context) const {
+ return ExtensionsBrowserClient::Get()->GetOriginalContext(context);
+}
+
+bool SafeBrowsingPrivateEventRouterFactory::ServiceIsCreatedWithBrowserContext()
+ const {
+ return true;
+}
+
+bool SafeBrowsingPrivateEventRouterFactory::ServiceIsNULLWhileTesting() const {
+ return true;
+}
+
+} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router_factory.h b/chromium/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router_factory.h
new file mode 100644
index 00000000000..670735961dc
--- /dev/null
+++ b/chromium/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router_factory.h
@@ -0,0 +1,53 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_API_SAFE_BROWSING_PRIVATE_SAFE_BROWSING_PRIVATE_EVENT_ROUTER_FACTORY_H_
+#define CHROME_BROWSER_EXTENSIONS_API_SAFE_BROWSING_PRIVATE_SAFE_BROWSING_PRIVATE_EVENT_ROUTER_FACTORY_H_
+
+#include "base/macros.h"
+#include "base/memory/singleton.h"
+#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
+
+namespace extensions {
+
+class SafeBrowsingPrivateEventRouter;
+
+// This is a factory class used by the BrowserContextDependencyManager
+// to instantiate the safeBrowsingPrivate event router per profile (since the
+// extension event router is per profile).
+class SafeBrowsingPrivateEventRouterFactory
+ : public BrowserContextKeyedServiceFactory {
+ public:
+ // Returns the SafeBrowsingPrivateEventRouter for |profile|, creating it if
+ // it is not yet created.
+ static SafeBrowsingPrivateEventRouter* GetForProfile(
+ content::BrowserContext* context);
+
+ // Returns the SafeBrowsingPrivateEventRouterFactory instance.
+ static SafeBrowsingPrivateEventRouterFactory* GetInstance();
+
+ protected:
+ // BrowserContextKeyedBaseFactory overrides:
+ content::BrowserContext* GetBrowserContextToUse(
+ content::BrowserContext* context) const override;
+ bool ServiceIsCreatedWithBrowserContext() const override;
+ bool ServiceIsNULLWhileTesting() const override;
+
+ private:
+ friend struct base::DefaultSingletonTraits<
+ SafeBrowsingPrivateEventRouterFactory>;
+
+ SafeBrowsingPrivateEventRouterFactory();
+ ~SafeBrowsingPrivateEventRouterFactory() override;
+
+ // BrowserContextKeyedServiceFactory:
+ KeyedService* BuildServiceInstanceFor(
+ content::BrowserContext* profile) const override;
+
+ DISALLOW_COPY_AND_ASSIGN(SafeBrowsingPrivateEventRouterFactory);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_API_SAFE_BROWSING_PRIVATE_SAFE_BROWSING_PRIVATE_EVENT_ROUTER_FACTORY_H_
diff --git a/chromium/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router_unittest.cc b/chromium/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router_unittest.cc
new file mode 100644
index 00000000000..e8dff26b8fa
--- /dev/null
+++ b/chromium/chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router_unittest.cc
@@ -0,0 +1,182 @@
+// 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/extensions/api/safe_browsing_private/safe_browsing_private_event_router.h"
+
+#include "base/strings/utf_string_conversions.h"
+#include "base/test/mock_callback.h"
+#include "base/values.h"
+#include "chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router_factory.h"
+#include "chrome/common/extensions/api/safe_browsing_private.h"
+#include "chrome/test/base/testing_profile.h"
+#include "content/public/test/test_browser_thread_bundle.h"
+#include "extensions/browser/test_event_router.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace extensions {
+
+class SafeBrowsingEventObserver : public TestEventRouter::EventObserver {
+ public:
+ // The observer will only listen to events with the |event_name|.
+ explicit SafeBrowsingEventObserver(const std::string& event_name)
+ : event_name_(event_name) {}
+
+ ~SafeBrowsingEventObserver() override = default;
+
+ // Removes |event_args_| from |*this| and returns them.
+ base::Value PassEventArgs() { return std::move(event_args_); }
+
+ // extensions::TestEventRouter::EventObserver:
+ void OnBroadcastEvent(const extensions::Event& event) override {
+ if (event.event_name == event_name_) {
+ event_args_ = event.event_args->Clone();
+ }
+ }
+
+ private:
+ // The name of the observed event.
+ const std::string event_name_;
+
+ // The arguments passed for the last observed event.
+ base::Value event_args_;
+
+ DISALLOW_COPY_AND_ASSIGN(SafeBrowsingEventObserver);
+};
+
+std::unique_ptr<KeyedService> BuildSafeBrowsingPrivateEventRouter(
+ content::BrowserContext* context) {
+ return std::unique_ptr<KeyedService>(
+ new SafeBrowsingPrivateEventRouter(context));
+}
+
+class SafeBrowsingPrivateEventRouterTest : public testing::Test {
+ public:
+ SafeBrowsingPrivateEventRouterTest() = default;
+ ~SafeBrowsingPrivateEventRouterTest() override = default;
+
+ void TriggerOnPolicySpecifiedPasswordReuseDetectedEvent() {
+ SafeBrowsingPrivateEventRouterFactory::GetForProfile(&profile_)
+ ->OnPolicySpecifiedPasswordReuseDetected(GURL("https://phishing.com/"),
+ "user_name_1",
+ /*is_phishing_url*/ true);
+ }
+
+ void TriggerOnPolicySpecifiedPasswordChangedEvent() {
+ SafeBrowsingPrivateEventRouterFactory::GetForProfile(&profile_)
+ ->OnPolicySpecifiedPasswordChanged("user_name_2");
+ }
+
+ void TriggerOnDangerousDownloadOpenedEvent() {
+ SafeBrowsingPrivateEventRouterFactory::GetForProfile(&profile_)
+ ->OnDangerousDownloadOpened(GURL("https://evil.com/malware.exe"),
+ "/path/to/malware.exe",
+ "sha256_or_malware_exe", "user_name");
+ }
+
+ void TriggerOnSecurityInterstitialShownEvent() {
+ SafeBrowsingPrivateEventRouterFactory::GetForProfile(&profile_)
+ ->OnSecurityInterstitialShown(GURL("https://phishing.com/"), "PHISHING",
+ 0, "user_name");
+ }
+
+ void TriggerOnSecurityInterstitialProceededEvent() {
+ SafeBrowsingPrivateEventRouterFactory::GetForProfile(&profile_)
+ ->OnSecurityInterstitialProceeded(GURL("https://phishing.com/"),
+ "PHISHING", -201, "user_name");
+ }
+
+ void SetUpRouters() {
+ event_router_ = extensions::CreateAndUseTestEventRouter(&profile_);
+ SafeBrowsingPrivateEventRouterFactory::GetInstance()->SetTestingFactory(
+ &profile_, BuildSafeBrowsingPrivateEventRouter);
+ }
+
+ protected:
+ content::TestBrowserThreadBundle thread_bundle_;
+ TestingProfile profile_;
+ extensions::TestEventRouter* event_router_ = nullptr;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SafeBrowsingPrivateEventRouterTest);
+};
+
+TEST_F(SafeBrowsingPrivateEventRouterTest, TestOnReuseDetected) {
+ SetUpRouters();
+ SafeBrowsingEventObserver event_observer(
+ api::safe_browsing_private::OnPolicySpecifiedPasswordReuseDetected::
+ kEventName);
+ event_router_->AddEventObserver(&event_observer);
+
+ TriggerOnPolicySpecifiedPasswordReuseDetectedEvent();
+ base::RunLoop().RunUntilIdle();
+
+ auto captured_args = event_observer.PassEventArgs().GetList()[0].Clone();
+ EXPECT_EQ("https://phishing.com/", captured_args.FindKey("url")->GetString());
+ EXPECT_EQ("user_name_1", captured_args.FindKey("userName")->GetString());
+}
+
+TEST_F(SafeBrowsingPrivateEventRouterTest, TestOnPasswordChanged) {
+ SetUpRouters();
+ SafeBrowsingEventObserver event_observer(
+ api::safe_browsing_private::OnPolicySpecifiedPasswordChanged::kEventName);
+ event_router_->AddEventObserver(&event_observer);
+
+ TriggerOnPolicySpecifiedPasswordChangedEvent();
+ base::RunLoop().RunUntilIdle();
+
+ auto captured_args = event_observer.PassEventArgs().GetList()[0].Clone();
+ EXPECT_EQ("user_name_2", captured_args.GetString());
+}
+
+TEST_F(SafeBrowsingPrivateEventRouterTest, TestOnDangerousDownloadOpened) {
+ SetUpRouters();
+ SafeBrowsingEventObserver event_observer(
+ api::safe_browsing_private::OnDangerousDownloadOpened::kEventName);
+ event_router_->AddEventObserver(&event_observer);
+
+ TriggerOnDangerousDownloadOpenedEvent();
+ base::RunLoop().RunUntilIdle();
+
+ auto captured_args = event_observer.PassEventArgs().GetList()[0].Clone();
+ EXPECT_EQ("https://evil.com/malware.exe",
+ captured_args.FindKey("url")->GetString());
+ EXPECT_EQ("/path/to/malware.exe",
+ captured_args.FindKey("fileName")->GetString());
+ EXPECT_EQ("user_name", captured_args.FindKey("userName")->GetString());
+ EXPECT_EQ("sha256_or_malware_exe",
+ captured_args.FindKey("downloadDigestSha256")->GetString());
+}
+
+TEST_F(SafeBrowsingPrivateEventRouterTest,
+ TestOnSecurityInterstitialProceeded) {
+ SetUpRouters();
+ SafeBrowsingEventObserver event_observer(
+ api::safe_browsing_private::OnSecurityInterstitialProceeded::kEventName);
+ event_router_->AddEventObserver(&event_observer);
+
+ TriggerOnSecurityInterstitialProceededEvent();
+ base::RunLoop().RunUntilIdle();
+
+ auto captured_args = event_observer.PassEventArgs().GetList()[0].Clone();
+ EXPECT_EQ("https://phishing.com/", captured_args.FindKey("url")->GetString());
+ EXPECT_EQ("PHISHING", captured_args.FindKey("reason")->GetString());
+ EXPECT_EQ("-201", captured_args.FindKey("netErrorCode")->GetString());
+ EXPECT_EQ("user_name", captured_args.FindKey("userName")->GetString());
+}
+
+TEST_F(SafeBrowsingPrivateEventRouterTest, TestOnSecurityInterstitialShown) {
+ SetUpRouters();
+ SafeBrowsingEventObserver event_observer(
+ api::safe_browsing_private::OnSecurityInterstitialShown::kEventName);
+ event_router_->AddEventObserver(&event_observer);
+
+ TriggerOnSecurityInterstitialShownEvent();
+ base::RunLoop().RunUntilIdle();
+
+ auto captured_args = event_observer.PassEventArgs().GetList()[0].Clone();
+ EXPECT_EQ("https://phishing.com/", captured_args.FindKey("url")->GetString());
+ EXPECT_EQ("PHISHING", captured_args.FindKey("reason")->GetString());
+ EXPECT_FALSE(captured_args.FindKey("netErrorCode"));
+ EXPECT_EQ("user_name", captured_args.FindKey("userName")->GetString());
+}
+} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/screenlock_private/screenlock_private_apitest.cc b/chromium/chrome/browser/extensions/api/screenlock_private/screenlock_private_apitest.cc
index 01f98441b18..8b1f3765e78 100644
--- a/chromium/chrome/browser/extensions/api/screenlock_private/screenlock_private_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/screenlock_private/screenlock_private_apitest.cc
@@ -15,19 +15,21 @@
#include "chrome/browser/profiles/profile_attributes_entry.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/signin/identity_manager_factory.h"
+#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chromeos/components/proximity_auth/screenlock_bridge.h"
-#include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/notification_service.h"
#include "extensions/browser/api/test/test_api.h"
#include "extensions/browser/notification_types.h"
#include "extensions/common/switches.h"
+#include "services/identity/public/cpp/identity_manager.h"
+#include "services/identity/public/cpp/identity_test_utils.h"
namespace extensions {
namespace {
-const char kTestGaiaId[] = "gaia-id-testuser@gmail.com";
const char kAttemptClickAuthMessage[] = "attemptClickAuth";
const char kTestExtensionId[] = "lkegkdgachcnekllcdfkijonogckdnjo";
const char kTestUser[] = "testuser@gmail.com";
@@ -50,14 +52,14 @@ class ScreenlockPrivateApiTest : public ExtensionApiTest,
}
void SetUpOnMainThread() override {
- SigninManagerFactory::GetForProfile(profile())
- ->SetAuthenticatedAccountInfo(kTestGaiaId, kTestUser);
- ProfileAttributesEntry* entry;
- ASSERT_TRUE(g_browser_process->profile_manager()->
- GetProfileAttributesStorage().
- GetProfileAttributesWithPath(profile()->GetPath(), &entry));
- entry->SetAuthInfo(
- kTestGaiaId, base::UTF8ToUTF16(test_account_id_.GetUserEmail()));
+ identity::IdentityManager* identity_manager =
+ IdentityManagerFactory::GetForProfile(profile());
+ identity::MakePrimaryAccountAvailable(
+ SigninManagerFactory::GetForProfile(profile()),
+ ProfileOAuth2TokenServiceFactory::GetForProfile(profile()),
+ identity_manager, kTestUser);
+ test_account_id_ = AccountId::FromUserEmailGaiaId(
+ kTestUser, identity_manager->GetPrimaryAccountInfo().gaia);
registrar_.Add(this,
extensions::NOTIFICATION_EXTENSION_TEST_MESSAGE,
content::NotificationService::AllSources());
@@ -91,8 +93,7 @@ class ScreenlockPrivateApiTest : public ExtensionApiTest,
}
private:
- const AccountId test_account_id_ =
- AccountId::FromUserEmailGaiaId(kTestUser, kTestGaiaId);
+ AccountId test_account_id_;
content::NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateApiTest);
diff --git a/chromium/chrome/browser/extensions/api/sessions/sessions_apitest.cc b/chromium/chrome/browser/extensions/api/sessions/sessions_apitest.cc
index 1cc32e82a62..22bbf3acca1 100644
--- a/chromium/chrome/browser/extensions/api/sessions/sessions_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/sessions/sessions_apitest.cc
@@ -205,7 +205,7 @@ std::unique_ptr<KeyedService> ExtensionSessionsTest::BuildProfileSyncService(
void ExtensionSessionsTest::CreateTestProfileSyncService() {
ProfileManager* profile_manager = g_browser_process->profile_manager();
base::FilePath path;
- PathService::Get(chrome::DIR_USER_DATA, &path);
+ base::PathService::Get(chrome::DIR_USER_DATA, &path);
path = path.AppendASCII("test_profile");
if (!base::PathExists(path))
CHECK(base::CreateDirectory(path));
diff --git a/chromium/chrome/browser/extensions/api/settings_private/prefs_util.cc b/chromium/chrome/browser/extensions/api/settings_private/prefs_util.cc
index 47413054d45..70c8081978e 100644
--- a/chromium/chrome/browser/extensions/api/settings_private/prefs_util.cc
+++ b/chromium/chrome/browser/extensions/api/settings_private/prefs_util.cc
@@ -17,9 +17,11 @@
#include "components/autofill/core/common/autofill_pref_names.h"
#include "components/bookmarks/common/bookmark_pref_names.h"
#include "components/browsing_data/core/pref_names.h"
+#include "components/component_updater/pref_names.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/drive/drive_pref_names.h"
#include "components/password_manager/core/common/password_manager_pref_names.h"
+#include "components/payments/core/payment_prefs.h"
#include "components/prefs/pref_service.h"
#include "components/proxy_config/proxy_config_pref_names.h"
#include "components/safe_browsing/common/safe_browsing_prefs.h"
@@ -37,6 +39,7 @@
#if defined(OS_CHROMEOS)
#include "ash/public/cpp/ash_pref_names.h" // nogncheck
+#include "chrome/browser/chromeos/crostini/crostini_pref_names.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
@@ -80,6 +83,11 @@ bool IsSettingReadOnly(const std::string& pref_name) {
if (pref_name == ash::prefs::kEnableAutoScreenLock)
return true;
#endif
+#if defined(OS_WIN)
+ // Don't allow user to change sw_reporter preferences.
+ if (pref_name == prefs::kSwReporterEnabled)
+ return true;
+#endif
return false;
}
@@ -110,6 +118,8 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetWhitelistedKeys() {
settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_whitelist)[autofill::prefs::kAutofillCreditCardEnabled] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
+ (*s_whitelist)[payments::kCanMakePaymentEnabled] =
+ settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_whitelist)[bookmarks::prefs::kShowBookmarkBar] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
@@ -204,6 +214,8 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetWhitelistedKeys() {
#if defined(OS_CHROMEOS)
(*s_whitelist)[::prefs::kLanguageImeMenuActivated] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
+ (*s_whitelist)[::prefs::kAllowedLocales] =
+ settings_api::PrefType::PREF_TYPE_LIST;
#endif
// Search page.
@@ -285,6 +297,8 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetWhitelistedKeys() {
settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_whitelist)[ash::prefs::kShouldAlwaysShowAccessibilityMenu] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
+ (*s_whitelist)[ash::prefs::kAccessibilityDictationEnabled] =
+ settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_whitelist)[ash::prefs::kAccessibilityFocusHighlightEnabled] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_whitelist)[ash::prefs::kAccessibilityHighContrastEnabled] =
@@ -308,6 +322,20 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetWhitelistedKeys() {
(*s_whitelist)[ash::prefs::kAccessibilityMonoAudioEnabled] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
+ // Text to Speech.
+ (*s_whitelist)[::prefs::kTextToSpeechLangToVoiceName] =
+ settings_api::PrefType::PREF_TYPE_DICTIONARY;
+ (*s_whitelist)[::prefs::kTextToSpeechRate] =
+ settings_api::PrefType::PREF_TYPE_NUMBER;
+ (*s_whitelist)[::prefs::kTextToSpeechPitch] =
+ settings_api::PrefType::PREF_TYPE_NUMBER;
+ (*s_whitelist)[::prefs::kTextToSpeechVolume] =
+ settings_api::PrefType::PREF_TYPE_NUMBER;
+
+ // Crostini
+ (*s_whitelist)[crostini::prefs::kCrostiniEnabled] =
+ settings_api::PrefType::PREF_TYPE_BOOLEAN;
+
// Android Apps.
(*s_whitelist)[arc::prefs::kArcEnabled] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
@@ -428,6 +456,10 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetWhitelistedKeys() {
(*s_whitelist)[arc::prefs::kSmsConnectEnabled] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
+ // Native Printing settings.
+ (*s_whitelist)[::prefs::kUserNativePrintersAllowed] =
+ settings_api::PrefType::PREF_TYPE_BOOLEAN;
+
#else
(*s_whitelist)[::prefs::kAcceptLanguages] =
settings_api::PrefType::PREF_TYPE_STRING;
@@ -464,6 +496,12 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetWhitelistedKeys() {
(*s_whitelist)[::prefs::kMediaRouterMediaRemotingEnabled] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
+#if defined(OS_WIN)
+ // SwReporter settings.
+ (*s_whitelist)[::prefs::kSwReporterEnabled] =
+ settings_api::PrefType::PREF_TYPE_BOOLEAN;
+#endif
+
return *s_whitelist;
}
diff --git a/chromium/chrome/browser/extensions/api/settings_private/settings_private_apitest.cc b/chromium/chrome/browser/extensions/api/settings_private/settings_private_apitest.cc
index 8ebc9f6f06b..0f7d3c5e9f3 100644
--- a/chromium/chrome/browser/extensions/api/settings_private/settings_private_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/settings_private/settings_private_apitest.cc
@@ -6,7 +6,7 @@
#include "base/command_line.h"
#include "base/macros.h"
-#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_loop_current.h"
#include "base/run_loop.h"
#include "base/values.h"
#include "build/build_config.h"
@@ -69,7 +69,7 @@ class SettingsPrivateApiTest : public ExtensionApiTest {
policy::POLICY_SOURCE_CLOUD,
base::WrapUnique(new base::Value(true)), nullptr);
provider_.UpdateChromePolicy(policies);
- DCHECK(base::MessageLoop::current());
+ DCHECK(base::MessageLoopCurrent::Get());
base::RunLoop loop;
loop.RunUntilIdle();
}
diff --git a/chromium/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api_unittest.cc b/chromium/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api_unittest.cc
index 32d5acdee69..aaff0a6bbc8 100644
--- a/chromium/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api_unittest.cc
@@ -141,7 +141,7 @@ class ProfileSyncServiceMockForExtensionTests
public:
explicit ProfileSyncServiceMockForExtensionTests(Profile* p)
: ProfileSyncServiceMock(CreateProfileSyncServiceParamsForTest(p)) {}
- ~ProfileSyncServiceMockForExtensionTests() {}
+ ~ProfileSyncServiceMockForExtensionTests() override {}
MOCK_METHOD0(Shutdown, void());
MOCK_CONST_METHOD0(GetDeviceInfoTracker, DeviceInfoTracker*());
diff --git a/chromium/chrome/browser/extensions/api/socket/mock_tcp_client_socket.h b/chromium/chrome/browser/extensions/api/socket/mock_tcp_client_socket.h
index 9dd6af53b29..fddad102ac6 100644
--- a/chromium/chrome/browser/extensions/api/socket/mock_tcp_client_socket.h
+++ b/chromium/chrome/browser/extensions/api/socket/mock_tcp_client_socket.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_EXTENSIONS_API_SOCKET_MOCK_TCP_CLIENT_SOCKET_H_
#define CHROME_BROWSER_EXTENSIONS_API_SOCKET_MOCK_TCP_CLIENT_SOCKET_H_
+#include "base/callback_helpers.h"
#include "net/log/net_log_source.h"
#include "net/log/net_log_with_source.h"
#include "net/socket/tcp_client_socket.h"
@@ -12,11 +13,29 @@
#include "testing/gmock/include/gmock/gmock.h"
namespace extensions {
-
class MockTCPClientSocket : public net::TCPClientSocket {
public:
MockTCPClientSocket();
- virtual ~MockTCPClientSocket();
+ ~MockTCPClientSocket() override;
+
+ int Read(net::IOBuffer* buffer,
+ int bytes,
+ net::CompletionOnceCallback callback) override {
+ return Read(buffer, bytes,
+ base::AdaptCallbackForRepeating(std::move(callback)));
+ }
+
+ int Write(net::IOBuffer* buffer,
+ int bytes,
+ net::CompletionOnceCallback callback,
+ const net::NetworkTrafficAnnotationTag& tag) override {
+ return Write(buffer, bytes,
+ base::AdaptCallbackForRepeating(std::move(callback)), tag);
+ }
+
+ int Connect(net::CompletionOnceCallback callback) override {
+ return Connect(base::AdaptCallbackForRepeating(std::move(callback)));
+ }
MOCK_METHOD3(Read, int(net::IOBuffer*, int, const net::CompletionCallback&));
MOCK_METHOD4(Write,
@@ -33,8 +52,6 @@ class MockTCPClientSocket : public net::TCPClientSocket {
MOCK_CONST_METHOD1(GetPeerAddress, int(net::IPEndPoint*));
MOCK_CONST_METHOD1(GetLocalAddress, int(net::IPEndPoint*));
MOCK_CONST_METHOD0(NetLog, const net::NetLogWithSource&());
- MOCK_METHOD0(SetSubresourceSpeculation, void());
- MOCK_METHOD0(SetOmniboxSpeculation, void());
MOCK_CONST_METHOD0(WasEverUsed, bool());
MOCK_CONST_METHOD0(UsingTCPFastOpen, bool());
MOCK_CONST_METHOD0(NumBytesRead, int64_t());
diff --git a/chromium/chrome/browser/extensions/api/socket/socket_apitest.cc b/chromium/chrome/browser/extensions/api/socket/socket_apitest.cc
index b1710494d53..ae11686ed95 100644
--- a/chromium/chrome/browser/extensions/api/socket/socket_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/socket/socket_apitest.cc
@@ -25,7 +25,7 @@ namespace {
const char kHostname[] = "127.0.0.1";
const int kPort = 8888;
-class SocketApiTest : public ExtensionApiTest {
+class SocketApiTest : public extensions::ExtensionApiTest {
public:
SocketApiTest()
: resolver_event_(base::WaitableEvent::ResetPolicy::MANUAL,
@@ -33,7 +33,7 @@ class SocketApiTest : public ExtensionApiTest {
resolver_creator_(new extensions::MockHostResolverCreator()) {}
void SetUpOnMainThread() override {
- ExtensionApiTest::SetUpOnMainThread();
+ extensions::ExtensionApiTest::SetUpOnMainThread();
extensions::HostResolverWrapper::GetInstance()->SetHostResolverForTesting(
resolver_creator_->CreateMockHostResolver());
}
diff --git a/chromium/chrome/browser/extensions/api/socket/tcp_socket_unittest.cc b/chromium/chrome/browser/extensions/api/socket/tcp_socket_unittest.cc
index 902970df9ff..6351e3d6ca2 100644
--- a/chromium/chrome/browser/extensions/api/socket/tcp_socket_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/socket/tcp_socket_unittest.cc
@@ -4,6 +4,7 @@
#include <memory>
+#include "base/callback_helpers.h"
#include "base/macros.h"
#include "extensions/browser/api/socket/tcp_socket.h"
#include "net/base/address_list.h"
@@ -29,6 +30,21 @@ class MockTCPSocket : public net::TCPClientSocket {
explicit MockTCPSocket(const net::AddressList& address_list)
: net::TCPClientSocket(address_list, NULL, NULL, net::NetLogSource()) {}
+ int Read(net::IOBuffer* buffer,
+ int bytes,
+ net::CompletionOnceCallback callback) override {
+ return Read(buffer, bytes,
+ base::AdaptCallbackForRepeating(std::move(callback)));
+ }
+
+ int Write(net::IOBuffer* buffer,
+ int bytes,
+ net::CompletionOnceCallback callback,
+ const net::NetworkTrafficAnnotationTag& tag) override {
+ return Write(buffer, bytes,
+ base::AdaptCallbackForRepeating(std::move(callback)), tag);
+ }
+
MOCK_METHOD3(Read, int(net::IOBuffer* buf, int buf_len,
const net::CompletionCallback& callback));
MOCK_METHOD4(Write,
@@ -77,7 +93,7 @@ class CompleteHandler {
DISALLOW_COPY_AND_ASSIGN(CompleteHandler);
};
-const std::string FAKE_ID = "abcdefghijklmnopqrst";
+const char FAKE_ID[] = "abcdefghijklmnopqrst";
TEST(SocketTest, TestTCPSocketRead) {
net::AddressList address_list;
diff --git a/chromium/chrome/browser/extensions/api/socket/tls_socket_unittest.cc b/chromium/chrome/browser/extensions/api/socket/tls_socket_unittest.cc
index d89d7300d9b..678b630744e 100644
--- a/chromium/chrome/browser/extensions/api/socket/tls_socket_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/socket/tls_socket_unittest.cc
@@ -8,6 +8,7 @@
#include <memory>
#include <utility>
+#include "base/callback_helpers.h"
#include "base/containers/circular_deque.h"
#include "base/macros.h"
#include "base/strings/string_piece.h"
@@ -40,6 +41,25 @@ namespace extensions {
class MockSSLClientSocket : public net::SSLClientSocket {
public:
MockSSLClientSocket() {}
+ int Read(net::IOBuffer* buffer,
+ int bytes,
+ net::CompletionOnceCallback callback) override {
+ return Read(buffer, bytes,
+ base::AdaptCallbackForRepeating(std::move(callback)));
+ }
+
+ int Write(net::IOBuffer* buffer,
+ int bytes,
+ net::CompletionOnceCallback callback,
+ const net::NetworkTrafficAnnotationTag& tag) override {
+ return Write(buffer, bytes,
+ base::AdaptCallbackForRepeating(std::move(callback)), tag);
+ }
+
+ int Connect(net::CompletionOnceCallback callback) override {
+ return Connect(base::AdaptCallbackForRepeating(std::move(callback)));
+ }
+
MOCK_METHOD0(Disconnect, void());
MOCK_METHOD3(Read,
int(net::IOBuffer* buf,
@@ -57,8 +77,6 @@ class MockSSLClientSocket : public net::SSLClientSocket {
MOCK_CONST_METHOD1(GetPeerAddress, int(net::IPEndPoint*));
MOCK_CONST_METHOD1(GetLocalAddress, int(net::IPEndPoint*));
MOCK_CONST_METHOD0(NetLog, const net::NetLogWithSource&());
- MOCK_METHOD0(SetSubresourceSpeculation, void());
- MOCK_METHOD0(SetOmniboxSpeculation, void());
MOCK_CONST_METHOD0(WasEverUsed, bool());
MOCK_CONST_METHOD0(UsingTCPFastOpen, bool());
MOCK_CONST_METHOD0(WasAlpnNegotiated, bool());
@@ -75,7 +93,7 @@ class MockSSLClientSocket : public net::SSLClientSocket {
const StringPiece&,
unsigned char*,
unsigned int));
- MOCK_METHOD1(GetSSLCertRequestInfo, void(net::SSLCertRequestInfo*));
+ MOCK_CONST_METHOD1(GetSSLCertRequestInfo, void(net::SSLCertRequestInfo*));
MOCK_CONST_METHOD0(GetUnverifiedServerCertificateChain,
scoped_refptr<net::X509Certificate>());
MOCK_CONST_METHOD0(GetChannelIDService, net::ChannelIDService*());
@@ -95,6 +113,21 @@ class MockTCPSocket : public net::TCPClientSocket {
explicit MockTCPSocket(const net::AddressList& address_list)
: net::TCPClientSocket(address_list, NULL, NULL, net::NetLogSource()) {}
+ int Read(net::IOBuffer* buffer,
+ int bytes,
+ net::CompletionOnceCallback callback) override {
+ return Read(buffer, bytes,
+ base::AdaptCallbackForRepeating(std::move(callback)));
+ }
+
+ int Write(net::IOBuffer* buffer,
+ int bytes,
+ net::CompletionOnceCallback callback,
+ const net::NetworkTrafficAnnotationTag& tag) override {
+ return Write(buffer, bytes,
+ base::AdaptCallbackForRepeating(std::move(callback)), tag);
+ }
+
MOCK_METHOD3(Read,
int(net::IOBuffer* buf,
int buf_len,
diff --git a/chromium/chrome/browser/extensions/api/socket/udp_socket_unittest.cc b/chromium/chrome/browser/extensions/api/socket/udp_socket_unittest.cc
index 68b294cade7..033809d16f5 100644
--- a/chromium/chrome/browser/extensions/api/socket/udp_socket_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/socket/udp_socket_unittest.cc
@@ -10,7 +10,6 @@
#include "base/location.h"
#include "base/macros.h"
-#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/test/test_timeouts.h"
diff --git a/chromium/chrome/browser/extensions/api/storage/settings_apitest.cc b/chromium/chrome/browser/extensions/api/storage/settings_apitest.cc
index e0c56008abf..207804b001b 100644
--- a/chromium/chrome/browser/extensions/api/storage/settings_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/storage/settings_apitest.cc
@@ -64,7 +64,7 @@ const char kManagedStorageExtensionId[] = "kjmkgkdkpedkejedfhmfcenooemhbpbo";
class MockSchemaRegistryObserver : public policy::SchemaRegistry::Observer {
public:
MockSchemaRegistryObserver() {}
- virtual ~MockSchemaRegistryObserver() {}
+ ~MockSchemaRegistryObserver() override {}
MOCK_METHOD1(OnSchemaRegistryUpdated, void(bool));
};
@@ -482,7 +482,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionSettingsApiTest, ManagedStorage) {
.Set("string-policy", "value")
.Set("int-policy", -123)
.Set("double-policy", 456e7)
- .SetBoolean("boolean-policy", true)
+ .Set("boolean-policy", true)
.Set("list-policy", extensions::ListBuilder()
.Append("one")
.Append("two")
diff --git a/chromium/chrome/browser/extensions/api/streams_private/streams_private_apitest.cc b/chromium/chrome/browser/extensions/api/streams_private/streams_private_apitest.cc
index 3ab92a0545c..dc5725100f5 100644
--- a/chromium/chrome/browser/extensions/api/streams_private/streams_private_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/streams_private/streams_private_apitest.cc
@@ -32,6 +32,7 @@
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
+#include "services/network/public/cpp/features.h"
#include "testing/gmock/include/gmock/gmock.h"
using content::BrowserContext;
@@ -130,7 +131,7 @@ std::unique_ptr<HttpResponse> HandleRequest(const HttpRequest& request) {
// The test extension expects the resources that should be handed to the
// extension to have MIME type 'application/msword' and the resources that
// should be downloaded by the browser to have MIME type 'text/plain'.
-class StreamsPrivateApiTest : public ExtensionApiTest {
+class StreamsPrivateApiTest : public extensions::ExtensionApiTest {
public:
StreamsPrivateApiTest() {}
@@ -142,14 +143,14 @@ class StreamsPrivateApiTest : public ExtensionApiTest {
test_server_->RegisterRequestHandler(base::Bind(&HandleRequest));
ASSERT_TRUE(test_server_->Start());
host_resolver()->AddRule("*", "127.0.0.1");
- ExtensionApiTest::SetUpOnMainThread();
+ extensions::ExtensionApiTest::SetUpOnMainThread();
}
void TearDownOnMainThread() override {
// Tear down the test server.
EXPECT_TRUE(test_server_->ShutdownAndWaitUntilComplete());
test_server_.reset();
- ExtensionApiTest::TearDownOnMainThread();
+ extensions::ExtensionApiTest::TearDownOnMainThread();
}
void InitializeDownloadSettings() {
@@ -237,6 +238,9 @@ class StreamsPrivateApiTest : public ExtensionApiTest {
// installed, white-listed extension invokes the extension's
// onExecuteContentHandler event (and does not start a download).
IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, Navigate) {
+ if (base::FeatureList::IsEnabled(network::features::kNetworkService))
+ return; // Streams not used with network service.
+
ASSERT_TRUE(LoadTestExtension()) << message_;
ResultCatcher catcher;
@@ -261,6 +265,9 @@ IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, Navigate) {
// Tests that navigating to a file URL also intercepts despite there being no
// HTTP headers. This is a regression test for https://crbug.com/416433.
IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, FileURL) {
+ if (base::FeatureList::IsEnabled(network::features::kNetworkService))
+ return; // Streams not used with network service.
+
ASSERT_TRUE(LoadTestExtension()) << message_;
ResultCatcher catcher;
@@ -285,6 +292,9 @@ IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, FileURL) {
// onExecuteContentHandler event (and does not start a download).
// Regression test for http://crbug.com/342999.
IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, NavigateCrossSite) {
+ if (base::FeatureList::IsEnabled(network::features::kNetworkService))
+ return; // Streams not used with network service.
+
ASSERT_TRUE(LoadTestExtension()) << message_;
ResultCatcher catcher;
@@ -326,6 +336,9 @@ IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, NavigateCrossSite) {
// extension with a file browser handler that can handle the attachment's MIME
// type.
IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, MAYBE_NavigateToAnAttachment) {
+ if (base::FeatureList::IsEnabled(network::features::kNetworkService))
+ return; // Streams not used with network service.
+
InitializeDownloadSettings();
ASSERT_TRUE(LoadTestExtension()) << message_;
@@ -371,6 +384,9 @@ IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, MAYBE_NavigateToAnAttachment) {
// StreamsResourceThrottle, even if there is an extension with a file
// browser handler that can handle the download's MIME type.
IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, MAYBE_DirectDownload) {
+ if (base::FeatureList::IsEnabled(network::features::kNetworkService))
+ return; // Streams not used with network service.
+
InitializeDownloadSettings();
ASSERT_TRUE(LoadTestExtension()) << message_;
@@ -426,6 +442,9 @@ IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, MAYBE_DirectDownload) {
// Tests that response headers are correctly passed to the API and that multiple
// repsonse headers with the same name are merged correctly.
IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, Headers) {
+ if (base::FeatureList::IsEnabled(network::features::kNetworkService))
+ return; // Streams not used with network service.
+
ASSERT_TRUE(LoadTestExtension()) << message_;
ResultCatcher catcher;
@@ -449,6 +468,9 @@ IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, Headers) {
// Tests that chrome.streamsPrivate.abort() works correctly.
IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, Abort) {
+ if (base::FeatureList::IsEnabled(network::features::kNetworkService))
+ return; // Streams not used with network service.
+
ASSERT_TRUE(LoadTestExtension()) << message_;
ResultCatcher catcher;
diff --git a/chromium/chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc b/chromium/chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc
index b8f1c6b90c4..7117b068dfa 100644
--- a/chromium/chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc
@@ -37,14 +37,14 @@ using sync_file_system::SyncFileSystemServiceFactory;
namespace {
-class SyncFileSystemApiTest : public ExtensionApiTest {
+class SyncFileSystemApiTest : public extensions::ExtensionApiTest {
public:
SyncFileSystemApiTest()
: mock_remote_service_(NULL),
real_default_quota_(0) {}
void SetUpInProcessBrowserTestFixture() override {
- ExtensionApiTest::SetUpInProcessBrowserTestFixture();
+ extensions::ExtensionApiTest::SetUpInProcessBrowserTestFixture();
// TODO(calvinlo): Update test code after default quota is made const
// (http://crbug.com/155488).
@@ -56,7 +56,7 @@ class SyncFileSystemApiTest : public ExtensionApiTest {
void TearDownInProcessBrowserTestFixture() override {
storage::QuotaManager::kSyncableStorageDefaultHostQuota =
real_default_quota_;
- ExtensionApiTest::TearDownInProcessBrowserTestFixture();
+ extensions::ExtensionApiTest::TearDownInProcessBrowserTestFixture();
}
void SetUpOnMainThread() override {
@@ -66,7 +66,7 @@ class SyncFileSystemApiTest : public ExtensionApiTest {
mock_remote_service_ = new ::testing::NiceMock<MockRemoteFileSyncService>;
SyncFileSystemServiceFactory::GetInstance()->set_mock_remote_file_service(
std::unique_ptr<RemoteFileSyncService>(mock_remote_service_));
- ExtensionApiTest::SetUpOnMainThread();
+ extensions::ExtensionApiTest::SetUpOnMainThread();
}
::testing::NiceMock<MockRemoteFileSyncService>* mock_remote_service() {
diff --git a/chromium/chrome/browser/extensions/api/sync_file_system/sync_file_system_browsertest.cc b/chromium/chrome/browser/extensions/api/sync_file_system/sync_file_system_browsertest.cc
index 2ff9bc7e96f..1c8beebfe77 100644
--- a/chromium/chrome/browser/extensions/api/sync_file_system/sync_file_system_browsertest.cc
+++ b/chromium/chrome/browser/extensions/api/sync_file_system/sync_file_system_browsertest.cc
@@ -69,7 +69,7 @@ class SyncFileSystemTest : public extensions::PlatformAppBrowserTest,
}
void SetUpOnMainThread() override {
- in_memory_env_.reset(leveldb_chrome::NewMemEnv(leveldb::Env::Default()));
+ in_memory_env_ = leveldb_chrome::NewMemEnv("SyncFileSystemTest");
extensions::PlatformAppBrowserTest::SetUpOnMainThread();
ASSERT_TRUE(base_dir_.CreateUniqueTempDir());
diff --git a/chromium/chrome/browser/extensions/api/system_indicator/system_indicator_apitest.cc b/chromium/chrome/browser/extensions/api/system_indicator/system_indicator_apitest.cc
index a903caf6b17..2313974b371 100644
--- a/chromium/chrome/browser/extensions/api/system_indicator/system_indicator_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/system_indicator/system_indicator_apitest.cc
@@ -13,6 +13,8 @@
#include "extensions/common/extension.h"
#include "extensions/test/result_catcher.h"
+namespace extensions {
+
class SystemIndicatorApiTest : public ExtensionApiTest {
public:
void SetUpOnMainThread() override {
@@ -65,3 +67,5 @@ IN_PROC_BROWSER_TEST_F(SystemIndicatorApiTest, DISABLED_SystemIndicator) {
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
}
}
+
+} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/system_indicator/system_indicator_manager.h b/chromium/chrome/browser/extensions/api/system_indicator/system_indicator_manager.h
index 76045111189..a16d5f37f2d 100644
--- a/chromium/chrome/browser/extensions/api/system_indicator/system_indicator_manager.h
+++ b/chromium/chrome/browser/extensions/api/system_indicator/system_indicator_manager.h
@@ -21,9 +21,9 @@ class ExtensionAction;
class Profile;
class StatusTray;
+namespace extensions {
FORWARD_DECLARE_TEST(SystemIndicatorApiTest, SystemIndicator);
-namespace extensions {
class ExtensionIndicatorIcon;
class ExtensionRegistry;
@@ -41,7 +41,7 @@ class SystemIndicatorManager : public ExtensionRegistryObserver,
void Shutdown() override;
private:
- FRIEND_TEST_ALL_PREFIXES(::SystemIndicatorApiTest, SystemIndicator);
+ FRIEND_TEST_ALL_PREFIXES(SystemIndicatorApiTest, SystemIndicator);
// ExtensionRegistryObserver implementation.
void OnExtensionUnloaded(content::BrowserContext* browser_context,
diff --git a/chromium/chrome/browser/extensions/api/system_private/system_private_api.cc b/chromium/chrome/browser/extensions/api/system_private/system_private_api.cc
index e6f5f4d803b..132abe1537a 100644
--- a/chromium/chrome/browser/extensions/api/system_private/system_private_api.cc
+++ b/chromium/chrome/browser/extensions/api/system_private/system_private_api.cc
@@ -36,12 +36,8 @@ const char* const kIncognitoModeAvailabilityStrings[] = {
};
// Property keys.
-const char kBrightnessKey[] = "brightness";
const char kDownloadProgressKey[] = "downloadProgress";
-const char kIsVolumeMutedKey[] = "isVolumeMuted";
const char kStateKey[] = "state";
-const char kUserInitiatedKey[] = "userInitiated";
-const char kVolumeKey[] = "volume";
// System update states.
const char kNotAvailableState[] = "NotAvailable";
@@ -51,19 +47,6 @@ const char kNeedRestartState[] = "NeedRestart";
const char kUpdatingState[] = "Updating";
#endif // defined(OS_CHROMEOS)
-// Dispatches an extension event with |argument|
-void DispatchEvent(extensions::events::HistogramValue histogram_value,
- const std::string& event_name,
- std::unique_ptr<base::Value> argument) {
- std::unique_ptr<base::ListValue> list_args(new base::ListValue());
- if (argument) {
- list_args->Append(std::move(argument));
- }
- g_browser_process->extension_event_router_forwarder()
- ->BroadcastEventToRenderers(histogram_value, event_name,
- std::move(list_args), GURL());
-}
-
} // namespace
namespace extensions {
@@ -149,31 +132,4 @@ ExtensionFunction::ResponseAction SystemPrivateGetApiKeyFunction::Run() {
OneArgument(std::make_unique<base::Value>(google_apis::GetAPIKey())));
}
-void DispatchVolumeChangedEvent(double volume, bool is_volume_muted) {
- std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
- dict->SetDouble(kVolumeKey, volume);
- dict->SetBoolean(kIsVolumeMutedKey, is_volume_muted);
- DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_VOLUME_CHANGED,
- system_private::OnVolumeChanged::kEventName, std::move(dict));
-}
-
-void DispatchBrightnessChangedEvent(int brightness, bool user_initiated) {
- std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
- dict->SetInteger(kBrightnessKey, brightness);
- dict->SetBoolean(kUserInitiatedKey, user_initiated);
- DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_BRIGHTNESS_CHANGED,
- system_private::OnBrightnessChanged::kEventName,
- std::move(dict));
-}
-
-void DispatchScreenUnlockedEvent() {
- DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_SCREEN_UNLOCKED,
- system_private::OnScreenUnlocked::kEventName, nullptr);
-}
-
-void DispatchWokeUpEvent() {
- DispatchEvent(extensions::events::SYSTEM_PRIVATE_ON_WOKE_UP,
- system_private::OnWokeUp::kEventName, nullptr);
-}
-
} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/system_private/system_private_api.h b/chromium/chrome/browser/extensions/api/system_private/system_private_api.h
index 27e7265233a..5d6fb2bcc71 100644
--- a/chromium/chrome/browser/extensions/api/system_private/system_private_api.h
+++ b/chromium/chrome/browser/extensions/api/system_private/system_private_api.h
@@ -50,18 +50,6 @@ class SystemPrivateGetApiKeyFunction : public UIThreadExtensionFunction {
ResponseAction Run() override;
};
-// Dispatches systemPrivate.onBrightnessChanged event for extensions.
-void DispatchBrightnessChangedEvent(int brightness, bool user_initiated);
-
-// Dispatches systemPrivate.onVolumeChanged event for extensions.
-void DispatchVolumeChangedEvent(double volume, bool is_volume_muted);
-
-// Dispatches systemPrivate.onScreenChanged event for extensions.
-void DispatchScreenUnlockedEvent();
-
-// Dispatches systemPrivate.onWokeUp event for extensions.
-void DispatchWokeUpEvent();
-
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_API_SYSTEM_PRIVATE_SYSTEM_PRIVATE_API_H_
diff --git a/chromium/chrome/browser/extensions/api/system_private/system_private_apitest.cc b/chromium/chrome/browser/extensions/api/system_private/system_private_apitest.cc
index 6b47168db23..6f14af16ebc 100644
--- a/chromium/chrome/browser/extensions/api/system_private/system_private_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/system_private/system_private_apitest.cc
@@ -17,6 +17,8 @@
using chromeos::UpdateEngineClient;
#endif
+namespace extensions {
+
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, GetIncognitoModeAvailability) {
PrefService* pref_service = browser()->profile()->GetPrefs();
pref_service->SetInteger(prefs::kIncognitoModeAvailability, 1);
@@ -69,3 +71,5 @@ IN_PROC_BROWSER_TEST_F(GetUpdateStatusApiTest, Progress) {
}
#endif
+
+} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/tab_capture/OWNERS b/chromium/chrome/browser/extensions/api/tab_capture/OWNERS
index 100b4d0879a..ef6851eb466 100644
--- a/chromium/chrome/browser/extensions/api/tab_capture/OWNERS
+++ b/chromium/chrome/browser/extensions/api/tab_capture/OWNERS
@@ -1,5 +1,3 @@
-hubbe@chromium.org
-justinlin@chromium.org
miu@chromium.org
-# COMPONENT: UI>Browser>TabCapture
+# COMPONENT: Blink>GetUserMedia>Tab
diff --git a/chromium/chrome/browser/extensions/api/tab_capture/offscreen_tab.cc b/chromium/chrome/browser/extensions/api/tab_capture/offscreen_tab.cc
index 61a9d2ef326..12dc3bbd4e0 100644
--- a/chromium/chrome/browser/extensions/api/tab_capture/offscreen_tab.cc
+++ b/chromium/chrome/browser/extensions/api/tab_capture/offscreen_tab.cc
@@ -118,7 +118,7 @@ void OffscreenTab::Start(const GURL& start_url,
if (!optional_presentation_id.empty())
params.starting_sandbox_flags = blink::kPresentationReceiverSandboxFlags;
- offscreen_tab_web_contents_.reset(WebContents::Create(params));
+ offscreen_tab_web_contents_ = WebContents::Create(params);
offscreen_tab_web_contents_->SetDelegate(this);
WebContentsObserver::Observe(offscreen_tab_web_contents_.get());
@@ -262,8 +262,10 @@ bool OffscreenTab::EmbedsFullscreenWidget() const {
return true;
}
-void OffscreenTab::EnterFullscreenModeForTab(WebContents* contents,
- const GURL& origin) {
+void OffscreenTab::EnterFullscreenModeForTab(
+ WebContents* contents,
+ const GURL& origin,
+ const blink::WebFullscreenOptions& options) {
DCHECK_EQ(offscreen_tab_web_contents_.get(), contents);
if (in_fullscreen_mode())
diff --git a/chromium/chrome/browser/extensions/api/tab_capture/offscreen_tab.h b/chromium/chrome/browser/extensions/api/tab_capture/offscreen_tab.h
index 3f866f04566..71bd01da3fe 100644
--- a/chromium/chrome/browser/extensions/api/tab_capture/offscreen_tab.h
+++ b/chromium/chrome/browser/extensions/api/tab_capture/offscreen_tab.h
@@ -159,8 +159,10 @@ class OffscreenTab : protected content::WebContentsDelegate,
const std::string& partition_id,
content::SessionStorageNamespace* session_storage_namespace) final;
bool EmbedsFullscreenWidget() const final;
- void EnterFullscreenModeForTab(content::WebContents* contents,
- const GURL& origin) final;
+ void EnterFullscreenModeForTab(
+ content::WebContents* contents,
+ const GURL& origin,
+ const blink::WebFullscreenOptions& options) final;
void ExitFullscreenModeForTab(content::WebContents* contents) final;
bool IsFullscreenForTabOrPending(
const content::WebContents* contents) const final;
diff --git a/chromium/chrome/browser/extensions/api/tab_capture/tab_capture_apitest.cc b/chromium/chrome/browser/extensions/api/tab_capture/tab_capture_apitest.cc
index 520f0c136d0..ed7082bce77 100644
--- a/chromium/chrome/browser/extensions/api/tab_capture/tab_capture_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/tab_capture/tab_capture_apitest.cc
@@ -3,8 +3,10 @@
// found in the LICENSE file.
#include "base/command_line.h"
+#include "base/feature_list.h"
#include "base/location.h"
#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/stringprintf.h"
#include "base/test/test_timeouts.h"
@@ -21,6 +23,7 @@
#include "chrome/common/chrome_switches.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
+#include "content/public/common/content_features.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/extension_registry.h"
@@ -155,7 +158,13 @@ TEST(TabCaptureCaptureOffscreenTabTest, DetermineInitialSize) {
// Tests API behaviors, including info queries, and constraints violations.
IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_ApiTests) {
AddExtensionToCommandLineWhitelist();
- ASSERT_TRUE(RunExtensionSubtest("tab_capture", "api_tests.html")) << message_;
+ ASSERT_TRUE(RunExtensionSubtest(
+ "tab_capture", base::StringPrintf("api_tests.html%s",
+ base::FeatureList::IsEnabled(
+ features::kAudioServiceAudioStreams)
+ ? ""
+ : "?includeLegacyUnmuteTest=true")))
+ << message_;
}
#if defined(OS_MACOSX) && defined(ADDRESS_SANITIZER)
@@ -259,15 +268,10 @@ IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_GetUserMediaTest) {
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
}
-// http://crbug.com/177163
-#if defined(OS_WIN) && !defined(NDEBUG)
-#define MAYBE_ActiveTabPermission DISABLED_ActiveTabPermission
-#else
-#define MAYBE_ActiveTabPermission ActiveTabPermission
-#endif
+// http://crbug.com/177163, http://crbug.com/427730
// Make sure tabCapture.capture only works if the tab has been granted
// permission via an extension icon click or the extension is whitelisted.
-IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_ActiveTabPermission) {
+IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, DISABLED_ActiveTabPermission) {
ExtensionTestMessageListener before_open_tab("ready1", true);
ExtensionTestMessageListener before_grant_permission("ready2", true);
ExtensionTestMessageListener before_open_new_tab("ready3", true);
@@ -338,15 +342,11 @@ IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, DISABLED_FullscreenEvents) {
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
}
-// Times out on Win dbg bots: http://crbug.com/177163
-// Flaky on MSan bots: http://crbug.com/294431
-#if (defined(OS_WIN) && !defined(NDEBUG)) || defined(MEMORY_SANITIZER)
-#define MAYBE_GrantForChromePages DISABLED_GrantForChromePages
-#else
-#define MAYBE_GrantForChromePages GrantForChromePages
-#endif
+// Times out on Win dbg bots: https://crbug.com/177163
+// Flaky on MSan bots: https://crbug.com/294431
+// But really, just flaky everywhere. http://crbug.com/294431#c33
// Make sure tabCapture API can be granted for Chrome:// pages.
-IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_GrantForChromePages) {
+IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, DISABLED_GrantForChromePages) {
ExtensionTestMessageListener before_open_tab("ready1", true);
ASSERT_TRUE(RunExtensionSubtest("tab_capture",
"active_tab_chrome_pages.html"))
@@ -436,7 +436,7 @@ IN_PROC_BROWSER_TEST_F(TabCaptureApiTest, MAYBE_TabIndicator) {
if (alert_state != last_alert_state_) {
last_alert_state_ = alert_state;
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
+ FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated());
}
}
diff --git a/chromium/chrome/browser/extensions/api/tab_capture/tab_capture_performancetest.cc b/chromium/chrome/browser/extensions/api/tab_capture/tab_capture_performancetest.cc
index 38e56a88a20..9aadd4d918e 100644
--- a/chromium/chrome/browser/extensions/api/tab_capture/tab_capture_performancetest.cc
+++ b/chromium/chrome/browser/extensions/api/tab_capture/tab_capture_performancetest.cc
@@ -49,9 +49,8 @@ enum TestFlags {
kSmallWindow = 1 << 4, // Window size: 1 = 800x600, 0 = 2000x1000
};
-class TabCapturePerformanceTest
- : public ExtensionApiTest,
- public testing::WithParamInterface<int> {
+class TabCapturePerformanceTest : public extensions::ExtensionApiTest,
+ public testing::WithParamInterface<int> {
public:
TabCapturePerformanceTest() {}
@@ -78,7 +77,7 @@ class TabCapturePerformanceTest
EnablePixelOutput();
if (!HasFlag(kUseGpu))
UseSoftwareCompositing();
- ExtensionApiTest::SetUp();
+ extensions::ExtensionApiTest::SetUp();
}
void SetUpCommandLine(base::CommandLine* command_line) override {
@@ -101,7 +100,7 @@ class TabCapturePerformanceTest
extensions::switches::kWhitelistedExtensionID,
kExtensionId);
- ExtensionApiTest::SetUpCommandLine(command_line);
+ extensions::ExtensionApiTest::SetUpCommandLine(command_line);
}
void FindEvents(trace_analyzer::TraceAnalyzer* analyzer,
diff --git a/chromium/chrome/browser/extensions/api/tabs/tabs_api.cc b/chromium/chrome/browser/extensions/api/tabs/tabs_api.cc
index 9a275120a54..a753fd57760 100644
--- a/chromium/chrome/browser/extensions/api/tabs/tabs_api.cc
+++ b/chromium/chrome/browser/extensions/api/tabs/tabs_api.cc
@@ -640,12 +640,13 @@ ExtensionFunction::ResponseAction WindowsCreateFunction::Run() {
// a tabbed window.
if ((window_type == Browser::TYPE_POPUP && urls.empty()) ||
window_type == Browser::TYPE_TABBED) {
- if (source_tab_strip)
- contents = source_tab_strip->DetachWebContentsAt(tab_index);
- if (contents) {
+ if (source_tab_strip) {
+ std::unique_ptr<content::WebContents> detached_tab =
+ source_tab_strip->DetachWebContentsAt(tab_index);
+ contents = detached_tab.get();
TabStripModel* target_tab_strip = new_window->tab_strip_model();
- target_tab_strip->InsertWebContentsAt(urls.size(), contents,
- TabStripModel::ADD_NONE);
+ target_tab_strip->InsertWebContentsAt(
+ urls.size(), std::move(detached_tab), TabStripModel::ADD_NONE);
}
}
// Create a new tab if the created window is still empty. Don't create a new
@@ -655,20 +656,21 @@ ExtensionFunction::ResponseAction WindowsCreateFunction::Run() {
}
chrome::SelectNumberedTab(new_window, 0);
+ if (focused)
+ new_window->window()->Show();
+ else
+ new_window->window()->ShowInactive();
+
#if defined(OS_CHROMEOS)
// Lock the window fullscreen only after the new tab has been created
- // (otherwise the tabstrip is empty).
+ // (otherwise the tabstrip is empty), and window()->show() has been called
+ // (otherwise that resets the locked mode for devices in tablet mode).
if (create_data &&
create_data->state == windows::WINDOW_STATE_LOCKED_FULLSCREEN) {
SetLockedFullscreenState(new_window, true);
}
#endif
- if (focused)
- new_window->window()->Show();
- else
- new_window->window()->ShowInactive();
-
std::unique_ptr<base::Value> result;
if (new_window->profile()->IsOffTheRecord() &&
!browser_context()->IsOffTheRecord() && !include_incognito()) {
@@ -1366,8 +1368,9 @@ bool TabsUpdateFunction::RunAsync() {
if (params->update_properties.auto_discardable.get()) {
bool state = *params->update_properties.auto_discardable;
- g_browser_process->GetTabManager()->SetTabAutoDiscardableState(contents,
- state);
+ resource_coordinator::TabLifecycleUnitExternal::FromWebContents(
+ web_contents_)
+ ->SetAutoDiscardable(state);
}
if (!is_async) {
@@ -1395,11 +1398,13 @@ bool TabsUpdateFunction::UpdateURL(const std::string &url_string,
return false;
}
+ const bool is_javascript_scheme = url.SchemeIs(url::kJavaScriptScheme);
+ UMA_HISTOGRAM_BOOLEAN("Extensions.ApiTabUpdateJavascript",
+ is_javascript_scheme);
// JavaScript URLs can do the same kinds of things as cross-origin XHR, so
// we need to check host permissions before allowing them.
- if (url.SchemeIs(url::kJavaScriptScheme)) {
+ if (is_javascript_scheme) {
if (!extension()->permissions_data()->CanAccessPage(
- extension(),
web_contents_->GetURL(),
tab_id,
&error_)) {
@@ -1564,7 +1569,7 @@ bool TabsMoveFunction::MoveTab(int tab_id,
if (ExtensionTabUtil::GetWindowId(target_browser) !=
ExtensionTabUtil::GetWindowId(source_browser)) {
TabStripModel* target_tab_strip = target_browser->tab_strip_model();
- WebContents* web_contents =
+ std::unique_ptr<content::WebContents> web_contents =
source_tab_strip->DetachWebContentsAt(tab_index);
if (!web_contents) {
*error = ErrorUtils::FormatErrorMessage(keys::kTabNotFoundError,
@@ -1578,12 +1583,13 @@ bool TabsMoveFunction::MoveTab(int tab_id,
if (*new_index > target_tab_strip->count() || *new_index < 0)
*new_index = target_tab_strip->count();
- target_tab_strip->InsertWebContentsAt(
- *new_index, web_contents, TabStripModel::ADD_NONE);
+ content::WebContents* web_contents_raw = web_contents.get();
+ target_tab_strip->InsertWebContentsAt(*new_index, std::move(web_contents),
+ TabStripModel::ADD_NONE);
if (has_callback()) {
tab_values->Append(ExtensionTabUtil::CreateTabObject(
- web_contents, ExtensionTabUtil::kScrubTab,
+ web_contents_raw, ExtensionTabUtil::kScrubTab,
extension(), target_tab_strip, *new_index)
->ToValue());
}
@@ -1739,7 +1745,7 @@ WebContents* TabsCaptureVisibleTabFunction::GetWebContentsForID(
}
if (!extension()->permissions_data()->CanCaptureVisiblePage(
- contents->GetLastCommittedURL(), extension(),
+ contents->GetLastCommittedURL(),
SessionTabHelper::IdForTab(contents).id(), error)) {
return nullptr;
}
@@ -2007,8 +2013,8 @@ bool ExecuteCodeInTabFunction::CanExecuteScriptOnPage(std::string* error) {
// NOTE: This can give the wrong answer due to race conditions, but it is OK,
// we check again in the renderer.
- if (!extension()->permissions_data()->CanAccessPage(
- extension(), effective_document_url, execute_tab_id_, error)) {
+ if (!extension()->permissions_data()->CanAccessPage(effective_document_url,
+ execute_tab_id_, error)) {
if (is_about_url &&
extension()->permissions_data()->active_permissions().HasAPIPermission(
APIPermission::kTab)) {
@@ -2084,7 +2090,7 @@ bool TabsSetZoomFunction::RunAsync() {
return false;
GURL url(web_contents->GetVisibleURL());
- if (PermissionsData::IsRestrictedUrl(url, extension(), &error_))
+ if (extension()->permissions_data()->IsRestrictedUrl(url, &error_))
return false;
ZoomController* zoom_controller =
@@ -2136,7 +2142,7 @@ bool TabsSetZoomSettingsFunction::RunAsync() {
return false;
GURL url(web_contents->GetVisibleURL());
- if (PermissionsData::IsRestrictedUrl(url, extension(), &error_))
+ if (extension()->permissions_data()->IsRestrictedUrl(url, &error_))
return false;
// "per-origin" scope is only available in "automatic" mode.
diff --git a/chromium/chrome/browser/extensions/api/tabs/tabs_api_unittest.cc b/chromium/chrome/browser/extensions/api/tabs/tabs_api_unittest.cc
index 89c2d712616..90c6838376a 100644
--- a/chromium/chrome/browser/extensions/api/tabs/tabs_api_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/tabs/tabs_api_unittest.cc
@@ -94,18 +94,20 @@ TEST_F(TabsApiUnitTest, QueryWithoutTabsPermission) {
std::string tab_titles[] = {"", "Sample title", "Sample title"};
// Add 3 web contentses to the browser.
- std::unique_ptr<content::WebContents> web_contentses[arraysize(tab_urls)];
+ content::WebContents* web_contentses[arraysize(tab_urls)];
for (size_t i = 0; i < arraysize(tab_urls); ++i) {
- content::WebContents* web_contents =
+ std::unique_ptr<content::WebContents> web_contents =
content::WebContentsTester::CreateTestWebContents(profile(), nullptr);
- web_contentses[i].reset(web_contents);
- browser()->tab_strip_model()->AppendWebContents(web_contents, true);
+ content::WebContents* raw_web_contents = web_contents.get();
+ web_contentses[i] = raw_web_contents;
+ browser()->tab_strip_model()->AppendWebContents(std::move(web_contents),
+ true);
EXPECT_EQ(browser()->tab_strip_model()->GetActiveWebContents(),
- web_contents);
+ raw_web_contents);
content::WebContentsTester* web_contents_tester =
- content::WebContentsTester::For(web_contents);
+ content::WebContentsTester::For(raw_web_contents);
web_contents_tester->NavigateAndCommit(tab_urls[i]);
- web_contents->GetController().GetVisibleEntry()->SetTitle(
+ raw_web_contents->GetController().GetVisibleEntry()->SetTitle(
base::ASCIIToUTF16(tab_titles[i]));
}
@@ -140,7 +142,10 @@ TEST_F(TabsApiUnitTest, QueryWithoutTabsPermission) {
ASSERT_TRUE(tabs_list_with_permission->GetDictionary(0, &third_tab_info));
int third_tab_id = -1;
ASSERT_TRUE(third_tab_info->GetInteger("id", &third_tab_id));
- EXPECT_EQ(ExtensionTabUtil::GetTabId(web_contentses[2].get()), third_tab_id);
+ EXPECT_EQ(ExtensionTabUtil::GetTabId(web_contentses[2]), third_tab_id);
+
+ while (!browser()->tab_strip_model()->empty())
+ browser()->tab_strip_model()->DetachWebContentsAt(0);
}
TEST_F(TabsApiUnitTest, QueryWithHostPermission) {
@@ -150,18 +155,20 @@ TEST_F(TabsApiUnitTest, QueryWithHostPermission) {
std::string tab_titles[] = {"", "Sample title", "Sample title"};
// Add 3 web contentses to the browser.
- std::unique_ptr<content::WebContents> web_contentses[arraysize(tab_urls)];
+ content::WebContents* web_contentses[arraysize(tab_urls)];
for (size_t i = 0; i < arraysize(tab_urls); ++i) {
- content::WebContents* web_contents =
+ std::unique_ptr<content::WebContents> web_contents =
content::WebContentsTester::CreateTestWebContents(profile(), nullptr);
- web_contentses[i].reset(web_contents);
- browser()->tab_strip_model()->AppendWebContents(web_contents, true);
+ content::WebContents* raw_web_contents = web_contents.get();
+ web_contentses[i] = raw_web_contents;
+ browser()->tab_strip_model()->AppendWebContents(std::move(web_contents),
+ true);
EXPECT_EQ(browser()->tab_strip_model()->GetActiveWebContents(),
- web_contents);
+ raw_web_contents);
content::WebContentsTester* web_contents_tester =
- content::WebContentsTester::For(web_contents);
+ content::WebContentsTester::For(raw_web_contents);
web_contents_tester->NavigateAndCommit(tab_urls[i]);
- web_contents->GetController().GetVisibleEntry()->SetTitle(
+ raw_web_contents->GetController().GetVisibleEntry()->SetTitle(
base::ASCIIToUTF16(tab_titles[i]));
}
@@ -192,8 +199,7 @@ TEST_F(TabsApiUnitTest, QueryWithHostPermission) {
ASSERT_TRUE(tabs_list_with_permission->GetDictionary(0, &third_tab_info));
int third_tab_id = -1;
ASSERT_TRUE(third_tab_info->GetInteger("id", &third_tab_id));
- EXPECT_EQ(ExtensionTabUtil::GetTabId(web_contentses[2].get()),
- third_tab_id);
+ EXPECT_EQ(ExtensionTabUtil::GetTabId(web_contentses[2]), third_tab_id);
}
// Try the same without title, first and third tabs will match.
@@ -211,10 +217,8 @@ TEST_F(TabsApiUnitTest, QueryWithHostPermission) {
ASSERT_TRUE(tabs_list_with_permission->GetDictionary(1, &third_tab_info));
std::vector<int> expected_tabs_ids;
- expected_tabs_ids.push_back(
- ExtensionTabUtil::GetTabId(web_contentses[0].get()));
- expected_tabs_ids.push_back(
- ExtensionTabUtil::GetTabId(web_contentses[2].get()));
+ expected_tabs_ids.push_back(ExtensionTabUtil::GetTabId(web_contentses[0]));
+ expected_tabs_ids.push_back(ExtensionTabUtil::GetTabId(web_contentses[2]));
int first_tab_id = -1;
ASSERT_TRUE(first_tab_info->GetInteger("id", &first_tab_id));
@@ -224,6 +228,8 @@ TEST_F(TabsApiUnitTest, QueryWithHostPermission) {
ASSERT_TRUE(third_tab_info->GetInteger("id", &third_tab_id));
EXPECT_TRUE(base::ContainsValue(expected_tabs_ids, third_tab_id));
}
+ while (!browser()->tab_strip_model()->empty())
+ browser()->tab_strip_model()->DetachWebContentsAt(0);
}
// Test that using the PDF extension for tab updates is treated as a
@@ -242,19 +248,21 @@ TEST_F(TabsApiUnitTest, PDFExtensionNavigation) {
.Build();
ASSERT_TRUE(extension);
- content::WebContents* web_contents =
+ std::unique_ptr<content::WebContents> web_contents =
content::WebContentsTester::CreateTestWebContents(profile(), nullptr);
- ASSERT_TRUE(web_contents);
+ content::WebContents* raw_web_contents = web_contents.get();
+ ASSERT_TRUE(raw_web_contents);
content::WebContentsTester* web_contents_tester =
- content::WebContentsTester::For(web_contents);
+ content::WebContentsTester::For(raw_web_contents);
const GURL kGoogle("http://www.google.com");
web_contents_tester->NavigateAndCommit(kGoogle);
- EXPECT_EQ(kGoogle, web_contents->GetLastCommittedURL());
- EXPECT_EQ(kGoogle, web_contents->GetVisibleURL());
+ EXPECT_EQ(kGoogle, raw_web_contents->GetLastCommittedURL());
+ EXPECT_EQ(kGoogle, raw_web_contents->GetVisibleURL());
- SessionTabHelper::CreateForWebContents(web_contents);
- int tab_id = SessionTabHelper::IdForTab(web_contents).id();
- browser()->tab_strip_model()->AppendWebContents(web_contents, true);
+ SessionTabHelper::CreateForWebContents(raw_web_contents);
+ int tab_id = SessionTabHelper::IdForTab(raw_web_contents).id();
+ browser()->tab_strip_model()->AppendWebContents(std::move(web_contents),
+ true);
scoped_refptr<TabsUpdateFunction> function = new TabsUpdateFunction();
function->set_extension(extension.get());
@@ -266,8 +274,8 @@ TEST_F(TabsApiUnitTest, PDFExtensionNavigation) {
api_test_utils::SendResponseHelper response_helper(function.get());
function->RunWithValidation()->Execute();
- EXPECT_EQ(kGoogle, web_contents->GetLastCommittedURL());
- EXPECT_EQ(kGoogle, web_contents->GetVisibleURL());
+ EXPECT_EQ(kGoogle, raw_web_contents->GetLastCommittedURL());
+ EXPECT_EQ(kGoogle, raw_web_contents->GetVisibleURL());
// Clean up.
response_helper.WaitForResponse();
diff --git a/chromium/chrome/browser/extensions/api/tabs/tabs_event_router.cc b/chromium/chrome/browser/extensions/api/tabs/tabs_event_router.cc
index af63faf2661..05f4274c974 100644
--- a/chromium/chrome/browser/extensions/api/tabs/tabs_event_router.cc
+++ b/chromium/chrome/browser/extensions/api/tabs/tabs_event_router.cc
@@ -248,7 +248,9 @@ void TabsEventRouter::TabInsertedAt(TabStripModel* tab_strip_model,
std::move(args), EventRouter::USER_GESTURE_UNKNOWN);
}
-void TabsEventRouter::TabDetachedAt(WebContents* contents, int index) {
+void TabsEventRouter::TabDetachedAt(WebContents* contents,
+ int index,
+ bool was_active) {
if (!GetTabEntry(contents)) {
// The tab was removed. Don't send detach event.
return;
diff --git a/chromium/chrome/browser/extensions/api/tabs/tabs_event_router.h b/chromium/chrome/browser/extensions/api/tabs/tabs_event_router.h
index 7f0ac1eec90..d0b11d82c81 100644
--- a/chromium/chrome/browser/extensions/api/tabs/tabs_event_router.h
+++ b/chromium/chrome/browser/extensions/api/tabs/tabs_event_router.h
@@ -61,7 +61,9 @@ class TabsEventRouter : public TabStripModelObserver,
void TabClosingAt(TabStripModel* tab_strip_model,
content::WebContents* contents,
int index) override;
- void TabDetachedAt(content::WebContents* contents, int index) override;
+ void TabDetachedAt(content::WebContents* contents,
+ int index,
+ bool was_active) override;
void ActiveTabChanged(content::WebContents* old_contents,
content::WebContents* new_contents,
int index,
diff --git a/chromium/chrome/browser/extensions/api/tabs/tabs_test.cc b/chromium/chrome/browser/extensions/api/tabs/tabs_test.cc
index b711fb4d26e..0dc983f83c5 100644
--- a/chromium/chrome/browser/extensions/api/tabs/tabs_test.cc
+++ b/chromium/chrome/browser/extensions/api/tabs/tabs_test.cc
@@ -11,7 +11,6 @@
#include "apps/test/app_window_waiter.h"
#include "base/memory/ref_counted.h"
-#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/pattern.h"
#include "base/strings/string_split.h"
@@ -889,12 +888,8 @@ base::Value* ExtensionWindowLastFocusedTest::RunFunction(
IN_PROC_BROWSER_TEST_F(ExtensionWindowLastFocusedTest,
ExtensionAPICannotNavigateDevtools) {
- std::unique_ptr<base::DictionaryValue> test_extension_value(
- api_test_utils::ParseDictionary(
- "{\"name\": \"Test\", \"version\": \"1.0\", \"permissions\": "
- "[\"tabs\"]}"));
- scoped_refptr<Extension> extension(
- api_test_utils::CreateExtension(test_extension_value.get()));
+ scoped_refptr<const Extension> extension =
+ ExtensionBuilder("Test").AddPermission("tabs").Build();
DevToolsWindow* devtools = DevToolsWindowTesting::OpenDevToolsWindowSync(
browser()->tab_strip_model()->GetWebContentsAt(0), false /* is_docked */);
@@ -1033,7 +1028,13 @@ IN_PROC_BROWSER_TEST_F(ExtensionWindowLastFocusedTest,
}
#endif // !defined(OS_MACOSX)
-IN_PROC_BROWSER_TEST_F(ExtensionWindowCreateTest, AcceptState) {
+#if defined(OS_MACOSX)
+// https://crbug.com/836327
+#define MAYBE_AcceptState DISABLED_AcceptState
+#else
+#define MAYBE_AcceptState AcceptState
+#endif
+IN_PROC_BROWSER_TEST_F(ExtensionWindowCreateTest, MAYBE_AcceptState) {
#if defined(OS_MACOSX)
if (base::mac::IsOS10_10())
return; // Fails when swarmed. http://crbug.com/660582
@@ -1125,12 +1126,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTab) {
scoped_refptr<TabsDuplicateFunction> duplicate_tab_function(
new TabsDuplicateFunction());
- std::unique_ptr<base::DictionaryValue> test_extension_value(
- api_test_utils::ParseDictionary(
- "{\"name\": \"Test\", \"version\": \"1.0\", \"permissions\": "
- "[\"tabs\"]}"));
- scoped_refptr<Extension> empty_tab_extension(
- api_test_utils::CreateExtension(test_extension_value.get()));
+ scoped_refptr<const Extension> empty_tab_extension =
+ ExtensionBuilder("Test").AddPermission("tabs").Build();
duplicate_tab_function->set_extension(empty_tab_extension.get());
duplicate_tab_function->set_has_callback(true);
@@ -1273,12 +1270,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, MAYBE_FilteredEvents) {
}
IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, ExecuteScriptOnDevTools) {
- std::unique_ptr<base::DictionaryValue> test_extension_value(
- api_test_utils::ParseDictionary(
- "{\"name\": \"Test\", \"version\": \"1.0\", \"permissions\": "
- "[\"tabs\"]}"));
- scoped_refptr<Extension> extension(
- api_test_utils::CreateExtension(test_extension_value.get()));
+ scoped_refptr<const Extension> extension =
+ ExtensionBuilder("Test").AddPermission("tabs").Build();
DevToolsWindow* devtools = DevToolsWindowTesting::OpenDevToolsWindowSync(
browser()->tab_strip_model()->GetWebContentsAt(0), false /* is_docked */);
diff --git a/chromium/chrome/browser/extensions/api/terminal/terminal_private_apitest.cc b/chromium/chrome/browser/extensions/api/terminal/terminal_private_apitest.cc
index 7069e3d2a57..f14022f64a0 100644
--- a/chromium/chrome/browser/extensions/api/terminal/terminal_private_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/terminal/terminal_private_apitest.cc
@@ -6,9 +6,9 @@
#include "chrome/browser/extensions/extension_apitest.h"
#include "extensions/common/switches.h"
-class ExtensionTerminalPrivateApiTest : public ExtensionApiTest {
+class ExtensionTerminalPrivateApiTest : public extensions::ExtensionApiTest {
void SetUpCommandLine(base::CommandLine* command_line) override {
- ExtensionApiTest::SetUpCommandLine(command_line);
+ extensions::ExtensionApiTest::SetUpCommandLine(command_line);
command_line->AppendSwitchASCII(
extensions::switches::kWhitelistedExtensionID,
"kidcpjlbjdmcnmccjhjdckhbngnhnepk");
diff --git a/chromium/chrome/browser/extensions/api/top_sites/top_sites_api.cc b/chromium/chrome/browser/extensions/api/top_sites/top_sites_api.cc
index 0df2d28cbc4..3f9ef2b5060 100644
--- a/chromium/chrome/browser/extensions/api/top_sites/top_sites_api.cc
+++ b/chromium/chrome/browser/extensions/api/top_sites/top_sites_api.cc
@@ -18,21 +18,22 @@
namespace extensions {
-TopSitesGetFunction::TopSitesGetFunction()
- : weak_ptr_factory_(this) {}
+TopSitesGetFunction::TopSitesGetFunction() = default;
+TopSitesGetFunction::~TopSitesGetFunction() = default;
-TopSitesGetFunction::~TopSitesGetFunction() {}
-
-bool TopSitesGetFunction::RunAsync() {
- scoped_refptr<history::TopSites> ts =
- TopSitesFactory::GetForProfile(GetProfile());
+ExtensionFunction::ResponseAction TopSitesGetFunction::Run() {
+ scoped_refptr<history::TopSites> ts = TopSitesFactory::GetForProfile(
+ Profile::FromBrowserContext(browser_context()));
if (!ts)
- return false;
+ return RespondNow(Error(kUnknownErrorDoNotUse));
ts->GetMostVisitedURLs(
- base::Bind(&TopSitesGetFunction::OnMostVisitedURLsAvailable,
- weak_ptr_factory_.GetWeakPtr()), false);
- return true;
+ base::Bind(&TopSitesGetFunction::OnMostVisitedURLsAvailable, this),
+ false);
+
+ // GetMostVisitedURLs() will invoke the callback synchronously if the URLs are
+ // already populated.
+ return did_respond() ? AlreadyResponded() : RespondLater();
}
void TopSitesGetFunction::OnMostVisitedURLsAvailable(
@@ -52,8 +53,7 @@ void TopSitesGetFunction::OnMostVisitedURLsAvailable(
}
}
- SetResult(std::move(pages_value));
- SendResponse(true);
+ Respond(OneArgument(std::move(pages_value)));
}
} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/top_sites/top_sites_api.h b/chromium/chrome/browser/extensions/api/top_sites/top_sites_api.h
index 41b93efd86f..1b8689303ef 100644
--- a/chromium/chrome/browser/extensions/api/top_sites/top_sites_api.h
+++ b/chromium/chrome/browser/extensions/api/top_sites/top_sites_api.h
@@ -5,13 +5,12 @@
#ifndef CHROME_BROWSER_EXTENSIONS_API_TOP_SITES_TOP_SITES_API_H_
#define CHROME_BROWSER_EXTENSIONS_API_TOP_SITES_TOP_SITES_API_H_
-#include "base/memory/weak_ptr.h"
-#include "chrome/browser/extensions/chrome_extension_function.h"
#include "components/history/core/browser/history_types.h"
+#include "extensions/browser/extension_function.h"
namespace extensions {
-class TopSitesGetFunction : public ChromeAsyncExtensionFunction {
+class TopSitesGetFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("topSites.get", TOPSITES_GET)
@@ -21,13 +20,10 @@ class TopSitesGetFunction : public ChromeAsyncExtensionFunction {
~TopSitesGetFunction() override;
// ExtensionFunction:
- bool RunAsync() override;
+ ResponseAction Run() override;
private:
void OnMostVisitedURLsAvailable(const history::MostVisitedURLList& data);
-
- // For callbacks may be run after destruction.
- base::WeakPtrFactory<TopSitesGetFunction> weak_ptr_factory_;
};
} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/virtual_keyboard_private/chrome_virtual_keyboard_delegate.cc b/chromium/chrome/browser/extensions/api/virtual_keyboard_private/chrome_virtual_keyboard_delegate.cc
index bb04d9671bd..82ffe51c0ef 100644
--- a/chromium/chrome/browser/extensions/api/virtual_keyboard_private/chrome_virtual_keyboard_delegate.cc
+++ b/chromium/chrome/browser/extensions/api/virtual_keyboard_private/chrome_virtual_keyboard_delegate.cc
@@ -182,6 +182,8 @@ ChromeVirtualKeyboardDelegate::ConvertKeyboardModeToContainerType(
return keyboard::ContainerType::FULL_WIDTH;
case keyboard_api::KEYBOARD_MODE_FLOATING:
return keyboard::ContainerType::FLOATING;
+ case keyboard_api::KEYBOARD_MODE_FULLSCREEN:
+ return keyboard::ContainerType::FULLSCREEN;
}
NOTREACHED();
@@ -251,6 +253,9 @@ void ChromeVirtualKeyboardDelegate::OnHasInputDevices(
"gestureediting", keyboard::IsGestureEditingEnabled()));
features->AppendString(GenerateFeatureFlag(
"experimental", keyboard::IsExperimentalInputViewEnabled()));
+ features->AppendString(GenerateFeatureFlag(
+ "fullscreenhandwriting",
+ keyboard::IsFullscreenHandwritingVirtualKeyboardEnabled()));
const keyboard::KeyboardConfig config = keyboard::GetKeyboardConfig();
// TODO(oka): Change this to use config.voice_input.
diff --git a/chromium/chrome/browser/extensions/api/vpn_provider/vpn_provider_apitest.cc b/chromium/chrome/browser/extensions/api/vpn_provider/vpn_provider_apitest.cc
index cd090aab65c..000c2d54fee 100644
--- a/chromium/chrome/browser/extensions/api/vpn_provider/vpn_provider_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/vpn_provider/vpn_provider_apitest.cc
@@ -114,25 +114,25 @@ class TestShillThirdPartyVpnDriverClient
std::vector<char> ip_packet_;
};
-class VpnProviderApiTest : public ExtensionApiTest,
+class VpnProviderApiTest : public extensions::ExtensionApiTest,
public NetworkConfigurationObserver {
public:
VpnProviderApiTest() {}
~VpnProviderApiTest() override {}
void SetUpOnMainThread() override {
- ExtensionApiTest::SetUpOnMainThread();
+ extensions::ExtensionApiTest::SetUpOnMainThread();
NetworkHandler::Get()->network_configuration_handler()->AddObserver(this);
}
void TearDownOnMainThread() override {
- ExtensionApiTest::TearDownOnMainThread();
+ extensions::ExtensionApiTest::TearDownOnMainThread();
NetworkHandler::Get()->network_configuration_handler()->RemoveObserver(
this);
}
void SetUpInProcessBrowserTestFixture() override {
- ExtensionApiTest::SetUpInProcessBrowserTestFixture();
+ extensions::ExtensionApiTest::SetUpInProcessBrowserTestFixture();
test_client_ = new TestShillThirdPartyVpnDriverClient();
DBusThreadManager::GetSetterForTesting()->SetShillThirdPartyVpnDriverClient(
base::WrapUnique(test_client_));
diff --git a/chromium/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc b/chromium/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc
index e75618d49cb..56f264506ca 100644
--- a/chromium/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc
@@ -40,6 +40,7 @@
#include "content/public/common/resource_type.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/browser_test_utils.h"
+#include "content/public/test/download_test_observer.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/switches.h"
@@ -206,9 +207,6 @@ class WebNavigationApiTest : public ExtensionApiTest {
FrameNavigationState::set_allow_extension_scheme(true);
- base::CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kAllowLegacyExtensionManifests);
-
host_resolver()->AddRule("*", "127.0.0.1");
}
@@ -236,10 +234,17 @@ IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, DISABLED_ServerRedirect) {
<< message_;
}
-IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, Download) {
+// https://crbug.com/660288
+IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, DISABLED_Download) {
ASSERT_TRUE(StartEmbeddedTestServer());
- ASSERT_TRUE(RunExtensionTest("webnavigation/download"))
- << message_;
+ content::DownloadManager* download_manager =
+ content::BrowserContext::GetDownloadManager(browser()->profile());
+ content::DownloadTestObserverTerminal observer(
+ download_manager, 1,
+ content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL);
+ bool result = RunExtensionTest("webnavigation/download");
+ observer.WaitForFinished();
+ ASSERT_TRUE(result) << message_;
}
IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, ServerRedirectSingleProcess) {
diff --git a/chromium/chrome/browser/extensions/api/web_request/web_request_apitest.cc b/chromium/chrome/browser/extensions/api/web_request/web_request_apitest.cc
index 216f8755d93..28eaeffb94b 100644
--- a/chromium/chrome/browser/extensions/api/web_request/web_request_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/web_request/web_request_apitest.cc
@@ -3,13 +3,18 @@
// found in the LICENSE file.
#include <memory>
+#include <utility>
#include "base/command_line.h"
+#include "base/feature_list.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/optional.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
+#include "base/synchronization/lock.h"
+#include "base/test/bind_test_util.h"
+#include "base/test/scoped_feature_list.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
@@ -20,19 +25,29 @@
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_with_management_policy_apitest.h"
+#include "chrome/browser/extensions/scripting_permissions_modifier.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/net/profile_network_context_service.h"
#include "chrome/browser/net/profile_network_context_service_factory.h"
+#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/search/one_google_bar/one_google_bar_loader.h"
+#include "chrome/browser/search/one_google_bar/one_google_bar_service.h"
+#include "chrome/browser/search/one_google_bar/one_google_bar_service_factory.h"
+#include "chrome/browser/search/search.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/login/login_handler.h"
+#include "chrome/browser/ui/search/local_ntp_test_utils.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/url_constants.h"
#include "chrome/test/base/search_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "chromeos/login/scoped_test_public_session_login_state.h"
+#include "components/google/core/browser/google_switches.h"
#include "components/prefs/pref_service.h"
#include "components/proxy_config/proxy_config_dictionary.h"
#include "components/proxy_config/proxy_config_pref_names.h"
@@ -55,6 +70,7 @@
#include "extensions/browser/blocked_action_type.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension_builder.h"
+#include "extensions/common/extension_features.h"
#include "extensions/common/features/feature.h"
#include "extensions/test/extension_test_message_listener.h"
#include "extensions/test/result_catcher.h"
@@ -64,13 +80,10 @@
#include "net/http/http_util.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
+#include "net/test/embedded_test_server/http_response.h"
#include "net/test/test_data_directory.h"
#include "net/test/url_request/url_request_mock_http_job.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
-#include "net/url_request/test_url_fetcher_factory.h"
-#include "net/url_request/url_fetcher.h"
-#include "net/url_request/url_fetcher_delegate.h"
-#include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_request_filter.h"
#include "net/url_request/url_request_interceptor.h"
#include "services/network/public/cpp/features.h"
@@ -171,56 +184,6 @@ int GetWebRequestCountFromBackgroundPage(const Extension* extension,
"window.webRequestCount");
}
-// A test delegate to wait allow waiting for responses to complete with an
-// expected status and given content.
-// TODO(devlin): Other similar classes exist elsewhere. Pull this into a common
-// test class.
-class TestURLFetcherDelegate : public net::URLFetcherDelegate {
- public:
- // Creating the TestURLFetcherDelegate automatically creates and starts a
- // URLFetcher.
- TestURLFetcherDelegate(
- scoped_refptr<net::URLRequestContextGetter> context_getter,
- const GURL& url,
- net::URLRequestStatus expected_request_status)
- : expected_request_status_(expected_request_status),
- fetcher_(net::URLFetcher::Create(url,
- net::URLFetcher::GET,
- this,
- TRAFFIC_ANNOTATION_FOR_TESTS)) {
- fetcher_->SetRequestContext(context_getter.get());
- fetcher_->Start();
- }
- ~TestURLFetcherDelegate() override {}
-
- void SetExpectedResponse(const std::string& expected_response) {
- expected_response_ = expected_response;
- }
-
- void WaitForCompletion() { run_loop_.Run(); }
-
- // net::URLFetcherDelegate:
- void OnURLFetchComplete(const net::URLFetcher* source) override {
- EXPECT_EQ(expected_request_status_.status(), source->GetStatus().status());
- EXPECT_EQ(expected_request_status_.error(), source->GetStatus().error());
- if (expected_response_) {
- std::string response;
- ASSERT_TRUE(fetcher_->GetResponseAsString(&response));
- EXPECT_EQ(*expected_response_, response);
- }
-
- run_loop_.Quit();
- }
-
- private:
- const net::URLRequestStatus expected_request_status_;
- base::Optional<std::string> expected_response_;
- std::unique_ptr<net::URLFetcher> fetcher_;
- base::RunLoop run_loop_;
-
- DISALLOW_COPY_AND_ASSIGN(TestURLFetcherDelegate);
-};
-
// The DevTool's remote front-end is hardcoded to a URL with a fixed port.
// Redirect all responses to a URL with port.
class DevToolsFrontendInterceptor : public net::URLRequestInterceptor {
@@ -807,11 +770,11 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, HostedAppRequest) {
EXPECT_TRUE(listener2.WaitUntilSatisfied());
}
-// Tests that webRequest works with the --scripts-require-action feature.
+// Tests that webRequest works with features::kRuntimeHostPermissions.
IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest,
WebRequestWithWithheldPermissions) {
- FeatureSwitch::ScopedOverride enable_scripts_require_action(
- FeatureSwitch::scripts_require_action(), true);
+ base::test::ScopedFeatureList scoped_feature_list;
+ scoped_feature_list.InitAndEnableFeature(features::kRuntimeHostPermissions);
content::SetupCrossSiteRedirector(embedded_test_server());
ASSERT_TRUE(embedded_test_server()->Start());
@@ -822,6 +785,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest,
const Extension* extension =
LoadExtension(test_data_dir_.AppendASCII("webrequest_activetab"));
ASSERT_TRUE(extension) << message_;
+ ScriptingPermissionsModifier(profile(), base::WrapRefCounted(extension))
+ .SetAllowedOnAllUrls(false);
EXPECT_TRUE(listener.WaitUntilSatisfied());
// Navigate the browser to a page in a new tab.
@@ -926,14 +891,25 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest,
ASSERT_TRUE(extension) << message_;
EXPECT_TRUE(listener.WaitUntilSatisfied());
- EXPECT_EQ(0, GetWebRequestCountFromBackgroundPage(extension, profile()));
+ auto get_clients_google_request_count = [this, extension]() {
+ return GetCountFromBackgroundPage(extension, profile(),
+ "window.clientsGoogleWebRequestCount");
+ };
+ auto get_yahoo_request_count = [this, extension]() {
+ return GetCountFromBackgroundPage(extension, profile(),
+ "window.yahooWebRequestCount");
+ };
+
+ EXPECT_EQ(0, get_clients_google_request_count());
+ EXPECT_EQ(0, get_yahoo_request_count());
GURL main_frame_url =
embedded_test_server()->GetURL("www.example.com", "/simple.html");
NavigateParams params(browser(), main_frame_url, ui::PAGE_TRANSITION_TYPED);
ui_test_utils::NavigateToURL(&params);
- EXPECT_EQ(0, GetWebRequestCountFromBackgroundPage(extension, profile()));
+ EXPECT_EQ(0, get_clients_google_request_count());
+ EXPECT_EQ(0, get_yahoo_request_count());
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
@@ -953,33 +929,42 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest,
// Requests always fail due to cross origin nature.
EXPECT_FALSE(success);
- EXPECT_EQ(1, GetWebRequestCountFromBackgroundPage(extension, profile()));
-
- // Now perform a request to client1.google.com from the browser process. This
- // should *not* be visible to the WebRequest API.
-
- auto request = std::make_unique<network::ResourceRequest>();
- request->url =
- embedded_test_server()->GetURL("clients1.google.com", "/simple.html");
+ EXPECT_EQ(1, get_clients_google_request_count());
+ EXPECT_EQ(0, get_yahoo_request_count());
+
+ auto make_browser_request = [this](const GURL& url) {
+ auto request = std::make_unique<network::ResourceRequest>();
+ request->url = url;
+
+ auto* url_loader_factory =
+ content::BrowserContext::GetDefaultStoragePartition(profile())
+ ->GetURLLoaderFactoryForBrowserProcess()
+ .get();
+ content::SimpleURLLoaderTestHelper loader_helper;
+ auto loader = network::SimpleURLLoader::Create(
+ std::move(request), TRAFFIC_ANNOTATION_FOR_TESTS);
+ loader->DownloadToStringOfUnboundedSizeUntilCrashAndDie(
+ url_loader_factory, loader_helper.GetCallback());
+
+ // Wait for the response to complete.
+ loader_helper.WaitForCallback();
+ EXPECT_TRUE(loader_helper.response_body());
+ EXPECT_EQ(200, loader->ResponseInfo()->headers->response_code());
+ };
- auto* url_loader_factory =
- content::BrowserContext::GetDefaultStoragePartition(profile())
- ->GetURLLoaderFactoryForBrowserProcess()
- .get();
- content::SimpleURLLoaderTestHelper loader_helper;
- auto loader = network::SimpleURLLoader::Create(std::move(request),
- TRAFFIC_ANNOTATION_FOR_TESTS);
- loader->DownloadToStringOfUnboundedSizeUntilCrashAndDie(
- url_loader_factory, loader_helper.GetCallback());
-
- // Wait for the response to complete.
- loader_helper.WaitForCallback();
- EXPECT_TRUE(loader_helper.response_body());
- EXPECT_EQ(200, loader->ResponseInfo()->headers->response_code());
-
- // We should still have only seen the single render-initiated request from the
- // first half of the test.
- EXPECT_EQ(1, GetWebRequestCountFromBackgroundPage(extension, profile()));
+ // Now perform a request to "client1.google.com" from the browser process.
+ // This should *not* be visible to the WebRequest API. We should still have
+ // only seen the single render-initiated request from the first half of the
+ // test.
+ make_browser_request(
+ embedded_test_server()->GetURL("clients1.google.com", "/simple.html"));
+ EXPECT_EQ(1, get_clients_google_request_count());
+
+ // Sanity check that other requests made by the browser can still be
+ // intercepted by the extension.
+ make_browser_request(
+ embedded_test_server()->GetURL("yahoo.com", "/simple.html"));
+ EXPECT_EQ(1, get_yahoo_request_count());
}
// Verify that requests for PAC scripts are protected properly.
@@ -1156,7 +1141,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest,
// Test behavior when intercepting requests from a browser-initiated url fetch.
IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest,
- WebRequestURLFetcherInterception) {
+ WebRequestURLLoaderInterception) {
// Create an extension that intercepts (and blocks) requests to example.com.
TestExtensionDir test_dir;
test_dir.WriteManifest(
@@ -1177,7 +1162,6 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest,
["blocking"]);
chrome.test.sendMessage('ready');)");
- ASSERT_TRUE(StartEmbeddedTestServer());
const Extension* extension = nullptr;
{
ExtensionTestMessageListener listener("ready", false);
@@ -1186,12 +1170,36 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest,
EXPECT_TRUE(listener.WaitUntilSatisfied());
}
- GURL google_url =
- embedded_test_server()->GetURL("google.com", "/extensions/body1.html");
// Taken from test/data/extensions/body1.html.
const char kGoogleBodyContent[] = "dog";
const char kGoogleFullContent[] = "<html>\n<body>dog</body>\n</html>\n";
+ // Taken from test/data/extensions/body2.html.
+ const char kExampleBodyContent[] = "cat";
+ const char kExampleFullContent[] = "<html>\n<body>cat</body>\n</html>\n";
+
+ embedded_test_server()->RegisterRequestHandler(base::BindLambdaForTesting(
+ [&](const net::test_server::HttpRequest& request)
+ -> std::unique_ptr<net::test_server::HttpResponse> {
+ std::unique_ptr<net::test_server::BasicHttpResponse> response(
+ new net::test_server::BasicHttpResponse);
+ if (request.relative_url == "/extensions/body1.html") {
+ response->set_code(net::HTTP_OK);
+ response->set_content(kGoogleFullContent);
+ return std::move(response);
+ } else if (request.relative_url == "/extensions/body2.html") {
+ response->set_code(net::HTTP_OK);
+ response->set_content(kExampleFullContent);
+ return std::move(response);
+ }
+
+ return nullptr;
+ }));
+ ASSERT_TRUE(StartEmbeddedTestServer());
+
+ GURL google_url =
+ embedded_test_server()->GetURL("google.com", "/extensions/body1.html");
+
// First, check normal requets (e.g., navigations) to verify the extension
// is working correctly.
content::WebContents* web_contents =
@@ -1210,9 +1218,6 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest,
GURL example_url =
embedded_test_server()->GetURL("example.com", "/extensions/body2.html");
- // Taken from test/data/extensions/body2.html.
- const char kExampleBodyContent[] = "cat";
- const char kExampleFullContent[] = "<html>\n<body>cat</body>\n</html>\n";
ui_test_utils::NavigateToURL(browser(), example_url);
{
@@ -1229,47 +1234,74 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest,
EXPECT_NE(kExampleBodyContent, content);
}
+ // A callback allow waiting for responses to complete with an expected status
+ // and given content.
+ auto make_browser_request =
+ [this](network::mojom::URLLoaderFactory* url_loader_factory,
+ const GURL& url,
+ const base::Optional<std::string>& expected_response,
+ int expected_net_code) {
+ auto request = std::make_unique<network::ResourceRequest>();
+ request->url = url;
+
+ content::SimpleURLLoaderTestHelper simple_loader_helper;
+ auto simple_loader = network::SimpleURLLoader::Create(
+ std::move(request), TRAFFIC_ANNOTATION_FOR_TESTS);
+ simple_loader->DownloadToStringOfUnboundedSizeUntilCrashAndDie(
+ url_loader_factory, simple_loader_helper.GetCallback());
+
+ simple_loader_helper.WaitForCallback();
+
+ if (expected_response.has_value()) {
+ EXPECT_TRUE(!!simple_loader_helper.response_body());
+ EXPECT_EQ(*simple_loader_helper.response_body(), *expected_response);
+ EXPECT_EQ(200,
+ simple_loader->ResponseInfo()->headers->response_code());
+ } else {
+ EXPECT_FALSE(!!simple_loader_helper.response_body());
+ EXPECT_EQ(simple_loader->NetError(), expected_net_code);
+ }
+ };
+
// Next, try a series of requests through URLRequestFetchers (rather than a
// renderer).
- net::URLRequestContextGetter* profile_context =
- browser()->profile()->GetRequestContext();
+ auto* url_loader_factory =
+ content::BrowserContext::GetDefaultStoragePartition(profile())
+ ->GetURLLoaderFactoryForBrowserProcess()
+ .get();
+
{
// google.com should be unaffected by the extension and should succeed.
- SCOPED_TRACE("google.com with Profile's request context");
- TestURLFetcherDelegate url_fetcher(profile_context, google_url,
- net::URLRequestStatus());
- url_fetcher.SetExpectedResponse(kGoogleFullContent);
- url_fetcher.WaitForCompletion();
+ SCOPED_TRACE("google.com with Profile's url loader");
+ make_browser_request(url_loader_factory, google_url, kGoogleFullContent,
+ net::OK);
}
+
{
// example.com should fail.
- SCOPED_TRACE("example.com with Profile's request context");
- TestURLFetcherDelegate url_fetcher(
- profile_context, example_url,
- net::URLRequestStatus(net::URLRequestStatus::FAILED,
- net::ERR_BLOCKED_BY_CLIENT));
- url_fetcher.WaitForCompletion();
+ SCOPED_TRACE("example.com with Profile's url loader");
+ make_browser_request(url_loader_factory, example_url, base::nullopt,
+ net::ERR_BLOCKED_BY_CLIENT);
}
- // Requests going through the system request context should always succeed.
- net::URLRequestContextGetter* system_context =
- g_browser_process->system_request_context();
+ // Requests going through the system network context manager should always
+ // succeed.
+ SystemNetworkContextManager* system_network_context_manager =
+ g_browser_process->system_network_context_manager();
+ network::mojom::URLLoaderFactory* system_url_loader_factory =
+ system_network_context_manager->GetURLLoaderFactory();
{
// google.com should succeed (again).
- SCOPED_TRACE("google.com with System's request context");
- TestURLFetcherDelegate url_fetcher(system_context, google_url,
- net::URLRequestStatus());
- url_fetcher.SetExpectedResponse(kGoogleFullContent);
- url_fetcher.WaitForCompletion();
+ SCOPED_TRACE("google.com with System's network context manager");
+ make_browser_request(system_url_loader_factory, google_url,
+ kGoogleFullContent, net::OK);
}
{
// example.com should also succeed, since it's not through the profile's
// request context.
- SCOPED_TRACE("example.com with System's request context");
- TestURLFetcherDelegate url_fetcher(system_context, example_url,
- net::URLRequestStatus());
- url_fetcher.SetExpectedResponse(kExampleFullContent);
- url_fetcher.WaitForCompletion();
+ SCOPED_TRACE("example.com with System's network context manager");
+ make_browser_request(system_url_loader_factory, example_url,
+ kExampleFullContent, net::OK);
}
}
@@ -1318,6 +1350,222 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, MinimumAccessInitiator) {
}
}
+// Test fixture which sets a custom NTP Page.
+class NTPInterceptionWebRequestAPITest : public ExtensionApiTest {
+ public:
+ NTPInterceptionWebRequestAPITest()
+ : https_test_server_(net::EmbeddedTestServer::TYPE_HTTPS) {}
+
+ // ExtensionApiTest override:
+ void SetUpOnMainThread() override {
+ ExtensionApiTest::SetUpOnMainThread();
+ test_data_dir_ = test_data_dir_.AppendASCII("webrequest")
+ .AppendASCII("ntp_request_interception");
+ https_test_server_.ServeFilesFromDirectory(test_data_dir_);
+ ASSERT_TRUE(https_test_server_.Start());
+
+ GURL ntp_url = https_test_server_.GetURL("/fake_ntp.html");
+ local_ntp_test_utils::SetUserSelectedDefaultSearchProvider(
+ profile(), https_test_server_.base_url().spec(), ntp_url.spec());
+ }
+
+ const net::EmbeddedTestServer* https_test_server() const {
+ return &https_test_server_;
+ }
+
+ private:
+ net::EmbeddedTestServer https_test_server_;
+ DISALLOW_COPY_AND_ASSIGN(NTPInterceptionWebRequestAPITest);
+};
+
+// Ensures that requests made by the NTP Instant renderer are hidden from the
+// Web Request API. Regression test for crbug.com/797461.
+IN_PROC_BROWSER_TEST_F(NTPInterceptionWebRequestAPITest,
+ NTPRendererRequestsHidden) {
+ // Loads an extension which tries to intercept requests to
+ // "fake_ntp_script.js", which will be loaded as part of the NTP renderer.
+ ExtensionTestMessageListener listener("ready", true /*will_reply*/);
+ const Extension* extension =
+ LoadExtension(test_data_dir_.AppendASCII("extension"));
+ ASSERT_TRUE(extension);
+ EXPECT_TRUE(listener.WaitUntilSatisfied());
+
+ // Have the extension listen for requests to |fake_ntp_script.js|.
+ listener.Reply(https_test_server()->GetURL("/fake_ntp_script.js").spec());
+
+ // Returns true if the given extension was able to intercept the request to
+ // "fake_ntp_script.js".
+ auto was_script_request_intercepted =
+ [this](const std::string& extension_id) {
+ const std::string result = ExecuteScriptInBackgroundPage(
+ extension_id, "getAndResetRequestIntercepted();");
+ EXPECT_TRUE(result == "true" || result == "false")
+ << "Unexpected result " << result;
+ return result == "true";
+ };
+
+ // Returns true if the given |web_contents| has window.scriptExecuted set to
+ // true;
+ auto was_ntp_script_loaded = [](content::WebContents* web_contents) {
+ bool was_ntp_script_loaded = false;
+ EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
+ web_contents, "domAutomationController.send(!!window.scriptExecuted);",
+ &was_ntp_script_loaded));
+ return was_ntp_script_loaded;
+ };
+
+ WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+
+ // Navigate to the NTP. The request for "fake_ntp_script.js" should not have
+ // reached the extension, since it was made by the instant NTP renderer, which
+ // is semi-privileged.
+ ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
+ EXPECT_TRUE(was_ntp_script_loaded(web_contents));
+ ASSERT_TRUE(search::IsInstantNTP(web_contents));
+ EXPECT_FALSE(was_script_request_intercepted(extension->id()));
+
+ // However, when a normal webpage requests the same script, the request should
+ // be seen by the extension.
+ ui_test_utils::NavigateToURL(
+ browser(), https_test_server()->GetURL("/page_with_ntp_script.html"));
+ EXPECT_TRUE(was_ntp_script_loaded(web_contents));
+ ASSERT_FALSE(search::IsInstantNTP(web_contents));
+ EXPECT_TRUE(was_script_request_intercepted(extension->id()));
+}
+
+// Test fixture testing that requests made for the OneGoogleBar on behalf of
+// the local NTP can't be intercepted by extensions.
+class LocalNTPInterceptionWebRequestAPITest
+ : public ExtensionApiTest,
+ public OneGoogleBarServiceObserver {
+ public:
+ LocalNTPInterceptionWebRequestAPITest()
+ : https_test_server_(net::EmbeddedTestServer::TYPE_HTTPS) {}
+
+ // ExtensionApiTest override:
+ void SetUp() override {
+ https_test_server_.RegisterRequestMonitor(base::BindRepeating(
+ &LocalNTPInterceptionWebRequestAPITest::MonitorRequest,
+ base::Unretained(this)));
+ ASSERT_TRUE(https_test_server_.InitializeAndListen());
+ ExtensionApiTest::SetUp();
+ feature_list_.InitWithFeatures(
+ {::features::kUseGoogleLocalNtp, ::features::kOneGoogleBarOnLocalNtp},
+ {});
+ }
+ void SetUpCommandLine(base::CommandLine* command_line) override {
+ ExtensionApiTest::SetUpCommandLine(command_line);
+ command_line->AppendSwitchASCII(switches::kGoogleBaseURL,
+ https_test_server_.base_url().spec());
+ }
+ void SetUpOnMainThread() override {
+ ExtensionApiTest::SetUpOnMainThread();
+
+ https_test_server_.StartAcceptingConnections();
+
+ one_google_bar_url_ =
+ one_google_bar_service()->loader_for_testing()->GetLoadURLForTesting();
+
+ // Can't declare |runloop_| as a data member on the stack since it needs to
+ // be be constructed from a single-threaded context.
+ runloop_ = std::make_unique<base::RunLoop>();
+ one_google_bar_service()->AddObserver(this);
+ }
+
+ // OneGoogleBarServiceObserver overrides:
+ void OnOneGoogleBarDataUpdated() override { runloop_->Quit(); }
+ void OnOneGoogleBarServiceShuttingDown() override {
+ one_google_bar_service()->RemoveObserver(this);
+ }
+
+ GURL one_google_bar_url() const { return one_google_bar_url_; }
+
+ // Waits for OneGoogleBar data to be updated. Should only be used once.
+ void WaitForOneGoogleBarDataUpdate() { runloop_->Run(); }
+
+ bool GetAndResetOneGoogleBarRequestSeen() {
+ base::AutoLock lock(lock_);
+ bool result = one_google_bar_request_seen_;
+ one_google_bar_request_seen_ = false;
+ return result;
+ }
+
+ private:
+ OneGoogleBarService* one_google_bar_service() {
+ return OneGoogleBarServiceFactory::GetForProfile(profile());
+ }
+
+ void MonitorRequest(const net::test_server::HttpRequest& request) {
+ if (request.GetURL() == one_google_bar_url_) {
+ base::AutoLock lock(lock_);
+ one_google_bar_request_seen_ = true;
+ }
+ }
+
+ net::EmbeddedTestServer https_test_server_;
+ base::test::ScopedFeatureList feature_list_;
+ std::unique_ptr<base::RunLoop> runloop_;
+
+ // Initialized on the UI thread in SetUpOnMainThread. Read on UI and Embedded
+ // Test Server IO thread thereafter.
+ GURL one_google_bar_url_;
+
+ // Accessed on multiple threads- UI and Embedded Test Server IO thread. Access
+ // requires acquiring |lock_|.
+ bool one_google_bar_request_seen_ = false;
+
+ base::Lock lock_;
+
+ DISALLOW_COPY_AND_ASSIGN(LocalNTPInterceptionWebRequestAPITest);
+};
+
+IN_PROC_BROWSER_TEST_F(LocalNTPInterceptionWebRequestAPITest,
+ OneGoogleBarRequestsHidden) {
+ // Loads an extension which tries to intercept requests to the OneGoogleBar.
+ ExtensionTestMessageListener listener("ready", true /*will_reply*/);
+ const Extension* extension =
+ LoadExtension(test_data_dir_.AppendASCII("webrequest")
+ .AppendASCII("ntp_request_interception")
+ .AppendASCII("extension"));
+ ASSERT_TRUE(extension);
+ EXPECT_TRUE(listener.WaitUntilSatisfied());
+
+ // Have the extension listen for requests to |one_google_bar_url()|.
+ listener.Reply(one_google_bar_url().spec());
+
+ // Returns true if the given extension was able to intercept the request to
+ // |one_google_bar_url()|.
+ auto was_script_request_intercepted =
+ [this](const std::string& extension_id) {
+ const std::string result = ExecuteScriptInBackgroundPage(
+ extension_id, "getAndResetRequestIntercepted();");
+ EXPECT_TRUE(result == "true" || result == "false")
+ << "Unexpected result " << result;
+ return result == "true";
+ };
+
+ WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+
+ ASSERT_FALSE(GetAndResetOneGoogleBarRequestSeen());
+ ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
+ ASSERT_TRUE(search::IsInstantNTP(web_contents));
+ ASSERT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl),
+ web_contents->GetController().GetVisibleEntry()->GetURL());
+ WaitForOneGoogleBarDataUpdate();
+ ASSERT_TRUE(GetAndResetOneGoogleBarRequestSeen());
+
+ // Ensure that the extension wasn't able to intercept the request.
+ EXPECT_FALSE(was_script_request_intercepted(extension->id()));
+
+ // A normal request to |one_google_bar_url()| (i.e. not made by
+ // OneGoogleBarFetcher) should be intercepted by extensions.
+ ui_test_utils::NavigateToURL(browser(), one_google_bar_url());
+ EXPECT_TRUE(was_script_request_intercepted(extension->id()));
+ ASSERT_TRUE(GetAndResetOneGoogleBarRequestSeen());
+}
+
// Ensure that devtools frontend requests are hidden from the webRequest API.
IN_PROC_BROWSER_TEST_F(DevToolsFrontendInWebRequestApiTest, HiddenRequests) {
// Test expectations differ with the Network Service because of the way
@@ -1346,7 +1594,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTestWithManagementPolicy,
// means that the request to example.com will be seen by the extension.
{
ExtensionManagementPolicyUpdater pref(&policy_provider_);
- pref.AddRuntimeBlockedHost("*", "*://notexample.com");
+ pref.AddPolicyBlockedHost("*", "*://notexample.com");
}
ASSERT_TRUE(StartEmbeddedTestServer());
@@ -1401,7 +1649,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTestWithManagementPolicy,
// will not be seen by the extension.
{
ExtensionManagementPolicyUpdater pref(&policy_provider_);
- pref.AddRuntimeBlockedHost("*", "*://" + example_com);
+ pref.AddPolicyBlockedHost("*", "*://" + example_com);
}
// Wait until all remote Javascript files have been pulled down.
@@ -1419,14 +1667,15 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTestWithManagementPolicy,
// Tests that the webRequest events aren't dispatched when the URL of the
// request is protected by policy.
+// Disabled because it is flaky. See https://crbug.com/835155
IN_PROC_BROWSER_TEST_F(ExtensionApiTestWithManagementPolicy,
- UrlProtectedByPolicy) {
+ DISABLED_UrlProtectedByPolicy) {
// Host protected by policy.
const std::string protected_domain = "example.com";
{
ExtensionManagementPolicyUpdater pref(&policy_provider_);
- pref.AddRuntimeBlockedHost("*", "*://" + protected_domain);
+ pref.AddPolicyBlockedHost("*", "*://" + protected_domain);
}
ASSERT_TRUE(StartEmbeddedTestServer());
@@ -1474,15 +1723,15 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTestWithManagementPolicy,
// specific permission shouldn't bypass our policy.
IN_PROC_BROWSER_TEST_F(ExtensionApiTestWithManagementPolicy,
WebRequestProtectedByPolicy) {
- FeatureSwitch::ScopedOverride enable_scripts_require_action(
- FeatureSwitch::scripts_require_action(), true);
+ base::test::ScopedFeatureList scoped_feature_list;
+ scoped_feature_list.InitAndEnableFeature(features::kRuntimeHostPermissions);
// Host protected by policy.
const std::string protected_domain = "example.com";
{
ExtensionManagementPolicyUpdater pref(&policy_provider_);
- pref.AddRuntimeBlockedHost("*", "*://" + protected_domain);
+ pref.AddPolicyBlockedHost("*", "*://" + protected_domain);
}
ASSERT_TRUE(StartEmbeddedTestServer());
@@ -1491,6 +1740,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTestWithManagementPolicy,
const Extension* extension =
LoadExtension(test_data_dir_.AppendASCII("webrequest_activetab"));
ASSERT_TRUE(extension) << message_;
+ ScriptingPermissionsModifier(profile(), base::WrapRefCounted(extension))
+ .SetAllowedOnAllUrls(false);
EXPECT_TRUE(listener.WaitUntilSatisfied());
// Navigate the browser to a page in a new tab.
diff --git a/chromium/chrome/browser/extensions/api/web_request/web_request_permissions_unittest.cc b/chromium/chrome/browser/extensions/api/web_request/web_request_permissions_unittest.cc
index b2723a15ed6..ab284e6b1d8 100644
--- a/chromium/chrome/browser/extensions/api/web_request/web_request_permissions_unittest.cc
+++ b/chromium/chrome/browser/extensions/api/web_request/web_request_permissions_unittest.cc
@@ -7,7 +7,6 @@
#include <memory>
#include "base/macros.h"
-#include "base/message_loop/message_loop.h"
#include "chrome/common/extensions/extension_test_util.h"
#include "chromeos/login/scoped_test_public_session_login_state.h"
#include "content/public/browser/resource_request_info.h"
@@ -199,14 +198,14 @@ TEST_F(ExtensionWebRequestHelpersTestWithThreadsTest,
NULL, TRAFFIC_ANNOTATION_FOR_TESTS));
EXPECT_EQ(
- PermissionsData::ACCESS_ALLOWED,
+ PermissionsData::PageAccess::kAllowed,
WebRequestPermissions::CanExtensionAccessURL(
extension_info_map_.get(), permissionless_extension_->id(),
request->url(),
-1, // No tab id.
false, // crosses_incognito
WebRequestPermissions::DO_NOT_CHECK_HOST, request->initiator()));
- EXPECT_EQ(PermissionsData::ACCESS_DENIED,
+ EXPECT_EQ(PermissionsData::PageAccess::kDenied,
WebRequestPermissions::CanExtensionAccessURL(
extension_info_map_.get(), permissionless_extension_->id(),
request->url(),
@@ -214,7 +213,7 @@ TEST_F(ExtensionWebRequestHelpersTestWithThreadsTest,
false, // crosses_incognito
WebRequestPermissions::REQUIRE_HOST_PERMISSION_FOR_URL,
request->initiator()));
- EXPECT_EQ(PermissionsData::ACCESS_ALLOWED,
+ EXPECT_EQ(PermissionsData::PageAccess::kAllowed,
WebRequestPermissions::CanExtensionAccessURL(
extension_info_map_.get(), com_extension_->id(), request->url(),
-1, // No tab id.
@@ -222,14 +221,14 @@ TEST_F(ExtensionWebRequestHelpersTestWithThreadsTest,
WebRequestPermissions::REQUIRE_HOST_PERMISSION_FOR_URL,
request->initiator()));
EXPECT_EQ(
- PermissionsData::ACCESS_ALLOWED,
+ PermissionsData::PageAccess::kAllowed,
WebRequestPermissions::CanExtensionAccessURL(
extension_info_map_.get(), com_extension_->id(), request->url(),
-1, // No tab id.
false, // crosses_incognito
WebRequestPermissions::REQUIRE_HOST_PERMISSION_FOR_URL_AND_INITIATOR,
request->initiator()));
- EXPECT_EQ(PermissionsData::ACCESS_DENIED,
+ EXPECT_EQ(PermissionsData::PageAccess::kDenied,
WebRequestPermissions::CanExtensionAccessURL(
extension_info_map_.get(), com_extension_->id(), request->url(),
-1, // No tab id.
@@ -242,7 +241,7 @@ TEST_F(ExtensionWebRequestHelpersTestWithThreadsTest,
request_with_initiator->set_initiator(
url::Origin::Create(GURL("http://www.example.org")));
- EXPECT_EQ(PermissionsData::ACCESS_ALLOWED,
+ EXPECT_EQ(PermissionsData::PageAccess::kAllowed,
WebRequestPermissions::CanExtensionAccessURL(
extension_info_map_.get(), permissionless_extension_->id(),
request_with_initiator->url(),
@@ -250,7 +249,7 @@ TEST_F(ExtensionWebRequestHelpersTestWithThreadsTest,
false, // crosses_incognito
WebRequestPermissions::DO_NOT_CHECK_HOST,
request_with_initiator->initiator()));
- EXPECT_EQ(PermissionsData::ACCESS_DENIED,
+ EXPECT_EQ(PermissionsData::PageAccess::kDenied,
WebRequestPermissions::CanExtensionAccessURL(
extension_info_map_.get(), permissionless_extension_->id(),
request_with_initiator->url(),
@@ -258,7 +257,7 @@ TEST_F(ExtensionWebRequestHelpersTestWithThreadsTest,
false, // crosses_incognito
WebRequestPermissions::REQUIRE_HOST_PERMISSION_FOR_URL,
request_with_initiator->initiator()));
- EXPECT_EQ(PermissionsData::ACCESS_ALLOWED,
+ EXPECT_EQ(PermissionsData::PageAccess::kAllowed,
WebRequestPermissions::CanExtensionAccessURL(
extension_info_map_.get(), com_extension_->id(),
request_with_initiator->url(),
@@ -267,7 +266,7 @@ TEST_F(ExtensionWebRequestHelpersTestWithThreadsTest,
WebRequestPermissions::REQUIRE_HOST_PERMISSION_FOR_URL,
request_with_initiator->initiator()));
EXPECT_EQ(
- PermissionsData::ACCESS_DENIED,
+ PermissionsData::PageAccess::kDenied,
WebRequestPermissions::CanExtensionAccessURL(
extension_info_map_.get(), com_extension_->id(),
request_with_initiator->url(),
@@ -275,7 +274,7 @@ TEST_F(ExtensionWebRequestHelpersTestWithThreadsTest,
false, // crosses_incognito
WebRequestPermissions::REQUIRE_HOST_PERMISSION_FOR_URL_AND_INITIATOR,
request_with_initiator->initiator()));
- EXPECT_EQ(PermissionsData::ACCESS_DENIED,
+ EXPECT_EQ(PermissionsData::PageAccess::kDenied,
WebRequestPermissions::CanExtensionAccessURL(
extension_info_map_.get(), com_extension_->id(),
request_with_initiator->url(),
@@ -290,7 +289,7 @@ TEST_F(ExtensionWebRequestHelpersTestWithThreadsTest,
GURL("http://example.org"), net::DEFAULT_PRIORITY, nullptr));
// com_extension_ doesn't have host permission for .org URLs.
- EXPECT_EQ(PermissionsData::ACCESS_DENIED,
+ EXPECT_EQ(PermissionsData::PageAccess::kDenied,
WebRequestPermissions::CanExtensionAccessURL(
extension_info_map_.get(), com_policy_extension_->id(),
org_request->url(),
@@ -303,7 +302,7 @@ TEST_F(ExtensionWebRequestHelpersTestWithThreadsTest,
// Host permission checks are disabled in Public Sessions, instead all URLs
// are whitelisted.
- EXPECT_EQ(PermissionsData::ACCESS_ALLOWED,
+ EXPECT_EQ(PermissionsData::PageAccess::kAllowed,
WebRequestPermissions::CanExtensionAccessURL(
extension_info_map_.get(), com_policy_extension_->id(),
org_request->url(),
@@ -313,7 +312,7 @@ TEST_F(ExtensionWebRequestHelpersTestWithThreadsTest,
org_request->initiator()));
EXPECT_EQ(
- PermissionsData::ACCESS_ALLOWED,
+ PermissionsData::PageAccess::kAllowed,
WebRequestPermissions::CanExtensionAccessURL(
extension_info_map_.get(), com_policy_extension_->id(),
org_request->url(),
@@ -326,7 +325,7 @@ TEST_F(ExtensionWebRequestHelpersTestWithThreadsTest,
context.CreateRequest(GURL("chrome://version/"), net::DEFAULT_PRIORITY,
nullptr, TRAFFIC_ANNOTATION_FOR_TESTS));
- EXPECT_EQ(PermissionsData::ACCESS_DENIED,
+ EXPECT_EQ(PermissionsData::PageAccess::kDenied,
WebRequestPermissions::CanExtensionAccessURL(
extension_info_map_.get(), com_policy_extension_->id(),
chrome_request->url(),
diff --git a/chromium/chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.cc b/chromium/chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.cc
index 910c324ba2e..3f29daeb4db 100644
--- a/chromium/chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.cc
+++ b/chromium/chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.cc
@@ -284,7 +284,6 @@ WebrtcAudioPrivateSetAudioExperimentsFunction::
~WebrtcAudioPrivateSetAudioExperimentsFunction() {}
bool WebrtcAudioPrivateSetAudioExperimentsFunction::RunAsync() {
-#if BUILDFLAG(ENABLE_WEBRTC)
DCHECK_CURRENTLY_ON(BrowserThread::UI);
std::unique_ptr<wap::SetAudioExperiments::Params> params(
wap::SetAudioExperiments::Params::Create(*args_));
@@ -312,11 +311,6 @@ bool WebrtcAudioPrivateSetAudioExperimentsFunction::RunAsync() {
&WebrtcAudioPrivateSetAudioExperimentsFunction::FireCallback, this));
return true;
-#else
- SetError("Not supported");
- SendResponse(false);
- return false;
-#endif
}
void WebrtcAudioPrivateSetAudioExperimentsFunction::FireCallback(
diff --git a/chromium/chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_api.h b/chromium/chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_api.h
index 157ed003914..6ab73874ae1 100644
--- a/chromium/chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_api.h
+++ b/chromium/chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_api.h
@@ -8,13 +8,10 @@
#include <string>
#include "chrome/browser/extensions/chrome_extension_function.h"
-#include "chrome/common/extensions/api/webrtc_logging_private.h"
-#include "media/media_buildflags.h"
-
-#if BUILDFLAG(ENABLE_WEBRTC)
#include "chrome/browser/media/webrtc/audio_debug_recordings_handler.h"
#include "chrome/browser/media/webrtc/webrtc_logging_handler_host.h"
-#endif
+#include "chrome/common/extensions/api/webrtc_logging_private.h"
+#include "media/media_buildflags.h"
namespace content {
@@ -28,7 +25,6 @@ class WebrtcLoggingPrivateFunction : public ChromeAsyncExtensionFunction {
protected:
~WebrtcLoggingPrivateFunction() override {}
-#if BUILDFLAG(ENABLE_WEBRTC)
// Returns the RenderProcessHost associated with the given |request|
// authorized by the |security_origin|. Returns null if unauthorized or
// the RPH does not exist.
@@ -39,7 +35,6 @@ class WebrtcLoggingPrivateFunction : public ChromeAsyncExtensionFunction {
scoped_refptr<WebRtcLoggingHandlerHost> LoggingHandlerFromRequest(
const api::webrtc_logging_private::RequestInfo& request,
const std::string& security_origin);
-#endif
};
class WebrtcLoggingPrivateFunctionWithGenericCallback
@@ -47,7 +42,6 @@ class WebrtcLoggingPrivateFunctionWithGenericCallback
protected:
~WebrtcLoggingPrivateFunctionWithGenericCallback() override {}
-#if BUILDFLAG(ENABLE_WEBRTC)
// Finds the appropriate logging handler for performing the task and prepares
// a generic callback object for when the task is completed.
// If the logging handler can't be found for the given request+origin, the
@@ -59,7 +53,6 @@ class WebrtcLoggingPrivateFunctionWithGenericCallback
// Must be called on UI thread.
void FireCallback(bool success, const std::string& error_message);
-#endif
};
class WebrtcLoggingPrivateFunctionWithUploadCallback
@@ -67,11 +60,9 @@ class WebrtcLoggingPrivateFunctionWithUploadCallback
protected:
~WebrtcLoggingPrivateFunctionWithUploadCallback() override {}
-#if BUILDFLAG(ENABLE_WEBRTC)
// Must be called on UI thread.
void FireCallback(bool success, const std::string& report_id,
const std::string& error_message);
-#endif
};
class WebrtcLoggingPrivateFunctionWithRecordingDoneCallback
@@ -79,13 +70,11 @@ class WebrtcLoggingPrivateFunctionWithRecordingDoneCallback
protected:
~WebrtcLoggingPrivateFunctionWithRecordingDoneCallback() override {}
-#if BUILDFLAG(ENABLE_WEBRTC)
// Must be called on UI thread.
void FireErrorCallback(const std::string& error_message);
void FireCallback(const std::string& prefix_path,
bool did_stop,
bool did_manual_stop);
-#endif
};
class WebrtcLoggingPrivateSetMetaDataFunction
@@ -287,12 +276,10 @@ class WebrtcLoggingPrivateGetLogsDirectoryFunction
// ExtensionFunction overrides.
bool RunAsync() override;
-#if BUILDFLAG(ENABLE_WEBRTC)
// Must be called on UI thread.
void FireErrorCallback(const std::string& error_message);
void FireCallback(const std::string& filesystem_id,
const std::string& base_name);
-#endif
};
} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_api_stub.cc b/chromium/chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_api_stub.cc
deleted file mode 100644
index a47726a9a25..00000000000
--- a/chromium/chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_api_stub.cc
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// Stub implementation used when WebRTC is not enabled.
-
-#include "chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_api.h"
-
-namespace extensions {
-
-namespace {
-
-const char kErrorNotSupported[] = "Not supported";
-
-} // namespace
-
-bool WebrtcLoggingPrivateSetMetaDataFunction::RunAsync() {
- SetError(kErrorNotSupported);
- SendResponse(false);
- return false;
-}
-
-bool WebrtcLoggingPrivateStartFunction::RunAsync() {
- SetError(kErrorNotSupported);
- SendResponse(false);
- return false;
-}
-
-bool WebrtcLoggingPrivateSetUploadOnRenderCloseFunction::RunAsync() {
- SetError(kErrorNotSupported);
- SendResponse(false);
- return false;
-}
-
-bool WebrtcLoggingPrivateStopFunction::RunAsync() {
- SetError(kErrorNotSupported);
- SendResponse(false);
- return false;
-}
-
-bool WebrtcLoggingPrivateStoreFunction::RunAsync() {
- SetError(kErrorNotSupported);
- SendResponse(false);
- return false;
-}
-
-bool WebrtcLoggingPrivateUploadStoredFunction::RunAsync() {
- SetError(kErrorNotSupported);
- SendResponse(false);
- return false;
-}
-
-bool WebrtcLoggingPrivateUploadFunction::RunAsync() {
- SetError(kErrorNotSupported);
- SendResponse(false);
- return false;
-}
-
-bool WebrtcLoggingPrivateDiscardFunction::RunAsync() {
- SetError(kErrorNotSupported);
- SendResponse(false);
- return false;
-}
-
-bool WebrtcLoggingPrivateStartRtpDumpFunction::RunAsync() {
- SetError(kErrorNotSupported);
- SendResponse(false);
- return false;
-}
-
-bool WebrtcLoggingPrivateStopRtpDumpFunction::RunAsync() {
- SetError(kErrorNotSupported);
- SendResponse(false);
- return false;
-}
-
-bool WebrtcLoggingPrivateStartAudioDebugRecordingsFunction::RunAsync() {
- SetError(kErrorNotSupported);
- SendResponse(false);
- return false;
-}
-
-bool WebrtcLoggingPrivateStopAudioDebugRecordingsFunction::RunAsync() {
- SetError(kErrorNotSupported);
- SendResponse(false);
- return false;
-}
-
-bool WebrtcLoggingPrivateGetLogsDirectoryFunction::RunAsync() {
- SetError(kErrorNotSupported);
- SendResponse(false);
- return false;
-}
-
-} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_apitest.cc b/chromium/chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_apitest.cc
index 3eb34990543..c878060ff8f 100644
--- a/chromium/chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_apitest.cc
@@ -71,12 +71,12 @@ void InitializeTestMetaData(base::ListValue* parameters) {
parameters->Append(std::move(meta_data));
}
-class WebrtcLoggingPrivateApiTest : public ExtensionApiTest {
+class WebrtcLoggingPrivateApiTest : public extensions::ExtensionApiTest {
protected:
void SetUp() override {
auto* cl = scoped_command_line_.GetProcessCommandLine();
cl->AppendSwitchASCII(::switches::kWebRtcRemoteEventLog, "enabled");
- ExtensionApiTest::SetUp();
+ extensions::ExtensionApiTest::SetUp();
extension_ = extensions::ExtensionBuilder("Test").Build();
}
@@ -347,7 +347,7 @@ class WebrtcLoggingPrivateApiTestDisabledRemoteLogging
void SetUp() override {
auto* cl = scoped_command_line_.GetProcessCommandLine();
cl->AppendSwitchASCII(::switches::kWebRtcRemoteEventLog, "disabled");
- ExtensionApiTest::SetUp();
+ extensions::ExtensionApiTest::SetUp();
extension_ = extensions::ExtensionBuilder("Test").Build();
}
};
diff --git a/chromium/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc b/chromium/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
index 3a33fe8e797..6d06524c940 100644
--- a/chromium/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
+++ b/chromium/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
@@ -8,6 +8,7 @@
#include <utility>
#include <vector>
+#include "base/base64.h"
#include "base/bind.h"
#include "base/lazy_instance.h"
#include "base/macros.h"
@@ -17,11 +18,14 @@
#include "base/values.h"
#include "base/version.h"
#include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/crx_installer.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/install_tracker.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager.h"
+#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/ui/app_list/app_list_util.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -32,6 +36,7 @@
#include "content/public/browser/gpu_feature_checker.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
+#include "extensions/browser/extension_function_constants.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension.h"
@@ -44,6 +49,8 @@
#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#endif
+using safe_browsing::SafeBrowsingNavigationObserverManager;
+
namespace extensions {
namespace BeginInstallWithManifest3 =
@@ -60,6 +67,7 @@ namespace IsPendingCustodianApproval =
namespace IsInIncognitoMode = api::webstore_private::IsInIncognitoMode;
namespace LaunchEphemeralApp = api::webstore_private::LaunchEphemeralApp;
namespace SetStoreLogin = api::webstore_private::SetStoreLogin;
+namespace GetReferrerChain = api::webstore_private::GetReferrerChain;
namespace {
@@ -140,6 +148,9 @@ const char kIncognitoError[] =
const char kEphemeralAppLaunchingNotSupported[] =
"Ephemeral launching of apps is no longer supported.";
+// The number of user gestures to trace back for the referrer chain.
+const int kExtensionReferrerUserGestureLimit = 2;
+
WebstoreInstaller::Delegate* test_webstore_installer_delegate = nullptr;
// We allow the web store to set a string containing login information when a
@@ -299,7 +310,7 @@ void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseSuccess(
return;
}
- content::WebContents* web_contents = GetAssociatedWebContents();
+ content::WebContents* web_contents = GetSenderWebContents();
if (!web_contents) {
// The browser window has gone away.
Respond(BuildResponse(api::webstore_private::RESULT_USER_CANCELLED,
@@ -435,6 +446,12 @@ WebstorePrivateCompleteInstallFunction::Run() {
params->expected_id));
}
+ content::WebContents* web_contents = GetSenderWebContents();
+ if (!web_contents) {
+ return RespondNow(
+ Error(function_constants::kCouldNotFindSenderWebContents));
+ }
+
scoped_active_install_.reset(new ScopedActiveInstall(
InstallTracker::Get(browser_context()), params->expected_id));
@@ -444,8 +461,7 @@ WebstorePrivateCompleteInstallFunction::Run() {
// The extension will install through the normal extension install flow, but
// the whitelist entry will bypass the normal permissions install dialog.
scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller(
- chrome_details_.GetProfile(), this,
- chrome_details_.GetAssociatedWebContents(), params->expected_id,
+ chrome_details_.GetProfile(), this, web_contents, params->expected_id,
std::move(approval_), WebstoreInstaller::INSTALL_SOURCE_OTHER);
installer->Start();
@@ -657,4 +673,57 @@ WebstorePrivateIsPendingCustodianApprovalFunction::BuildResponse(bool result) {
return OneArgument(std::make_unique<base::Value>(result));
}
+WebstorePrivateGetReferrerChainFunction::
+ WebstorePrivateGetReferrerChainFunction()
+ : chrome_details_(this) {}
+
+WebstorePrivateGetReferrerChainFunction::
+ ~WebstorePrivateGetReferrerChainFunction() {}
+
+ExtensionFunction::ResponseAction
+WebstorePrivateGetReferrerChainFunction::Run() {
+ Profile* profile = chrome_details_.GetProfile();
+ if (!SafeBrowsingNavigationObserverManager::IsEnabledAndReady(profile))
+ return RespondNow(ArgumentList(GetReferrerChain::Results::Create("")));
+
+ content::WebContents* web_contents = GetSenderWebContents();
+ if (!web_contents) {
+ return RespondNow(ErrorWithArguments(GetReferrerChain::Results::Create(""),
+ kUserCancelledError));
+ }
+
+ scoped_refptr<SafeBrowsingNavigationObserverManager>
+ navigation_observer_manager = g_browser_process->safe_browsing_service()
+ ->navigation_observer_manager();
+
+ safe_browsing::ReferrerChain referrer_chain;
+ SafeBrowsingNavigationObserverManager::AttributionResult result =
+ navigation_observer_manager->IdentifyReferrerChainByWebContents(
+ web_contents, kExtensionReferrerUserGestureLimit, &referrer_chain);
+
+ // If the referrer chain is incomplete we'll append the most recent
+ // navigations to referrer chain for diagnostic purposes. This only happens if
+ // the user is not in incognito mode and has opted into extended reporting or
+ // Scout reporting. Otherwise, |CountOfRecentNavigationsToAppend| returns 0.
+ int recent_navigations_to_collect =
+ SafeBrowsingNavigationObserverManager::CountOfRecentNavigationsToAppend(
+ *profile, result);
+ if (recent_navigations_to_collect > 0) {
+ navigation_observer_manager->AppendRecentNavigations(
+ recent_navigations_to_collect, &referrer_chain);
+ }
+
+ safe_browsing::ExtensionWebStoreInstallRequest request;
+ request.mutable_referrer_chain()->Swap(&referrer_chain);
+ request.mutable_referrer_chain_options()->set_recent_navigations_to_collect(
+ recent_navigations_to_collect);
+
+ std::string serialized_referrer_proto = request.SerializeAsString();
+ // Base64 encode the proto to avoid issues with base::Value rejecting strings
+ // which are not valid UTF8.
+ base::Base64Encode(serialized_referrer_proto, &serialized_referrer_proto);
+ return RespondNow(ArgumentList(
+ GetReferrerChain::Results::Create(serialized_referrer_proto)));
+}
+
} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/webstore_private/webstore_private_api.h b/chromium/chrome/browser/extensions/api/webstore_private/webstore_private_api.h
index 8af8ccc53a6..c131838423e 100644
--- a/chromium/chrome/browser/extensions/api/webstore_private/webstore_private_api.h
+++ b/chromium/chrome/browser/extensions/api/webstore_private/webstore_private_api.h
@@ -304,6 +304,25 @@ class WebstorePrivateIsPendingCustodianApprovalFunction
ChromeExtensionFunctionDetails chrome_details_;
};
+class WebstorePrivateGetReferrerChainFunction
+ : public UIThreadExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("webstorePrivate.getReferrerChain",
+ WEBSTOREPRIVATE_GETREFERRERCHAIN)
+
+ WebstorePrivateGetReferrerChainFunction();
+
+ private:
+ ~WebstorePrivateGetReferrerChainFunction() override;
+
+ // ExtensionFunction:
+ ExtensionFunction::ResponseAction Run() override;
+
+ ChromeExtensionFunctionDetails chrome_details_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebstorePrivateGetReferrerChainFunction);
+};
+
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_API_WEBSTORE_PRIVATE_WEBSTORE_PRIVATE_API_H_
diff --git a/chromium/chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc b/chromium/chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc
index f33655acf2d..4819cef550e 100644
--- a/chromium/chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc
@@ -7,7 +7,6 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/macros.h"
-#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
@@ -432,4 +431,50 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebstoreGetWebGLStatusTest, Blocked) {
RunTest(webgl_allowed);
}
+class ExtensionWebstorePrivateGetReferrerChainApiTest
+ : public ExtensionWebstorePrivateApiTest {
+ public:
+ void SetUpOnMainThread() override {
+ host_resolver()->AddRule("redirect1.com", "127.0.0.1");
+ host_resolver()->AddRule("redirect2.com", "127.0.0.1");
+
+ ExtensionWebstorePrivateApiTest::SetUpOnMainThread();
+ }
+
+ GURL GetTestServerURLWithReferrers(const std::string& path) {
+ // Hand craft a url that will cause the test server to issue redirects.
+ const std::vector<std::string> redirects = {"redirect1.com",
+ "redirect2.com"};
+ net::HostPortPair host_port = embedded_test_server()->host_port_pair();
+ std::string redirect_chain;
+ for (const auto& redirect : redirects) {
+ std::string redirect_url = base::StringPrintf(
+ "http://%s:%d/server-redirect?", redirect.c_str(), host_port.port());
+ redirect_chain += redirect_url;
+ }
+
+ return GURL(redirect_chain + GetTestServerURL(path).spec());
+ }
+};
+
+// Tests that the GetReferrerChain API returns the redirect information.
+IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateGetReferrerChainApiTest,
+ GetReferrerChain) {
+ GURL page_url = GetTestServerURLWithReferrers("referrer_chain.html");
+ ASSERT_TRUE(RunPageTest(page_url.spec()));
+}
+
+// Tests that the GetReferrerChain API returns an empty string for profiles
+// opted out of SafeBrowsing.
+IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateGetReferrerChainApiTest,
+ GetReferrerChainForNonSafeBrowsingUser) {
+ PrefService* pref_service = browser()->profile()->GetPrefs();
+ EXPECT_TRUE(pref_service->GetBoolean(prefs::kSafeBrowsingEnabled));
+ // Disable SafeBrowsing.
+ pref_service->SetBoolean(prefs::kSafeBrowsingEnabled, false);
+
+ GURL page_url = GetTestServerURLWithReferrers("empty_referrer_chain.html");
+ ASSERT_TRUE(RunPageTest(page_url.spec()));
+}
+
} // namespace extensions
diff --git a/chromium/chrome/browser/extensions/api/webstore_widget_private/app_installer.cc b/chromium/chrome/browser/extensions/api/webstore_widget_private/app_installer.cc
index 3c1af8493f7..003dc82da45 100644
--- a/chromium/chrome/browser/extensions/api/webstore_widget_private/app_installer.cc
+++ b/chromium/chrome/browser/extensions/api/webstore_widget_private/app_installer.cc
@@ -42,6 +42,7 @@ AppInstaller::AppInstaller(content::WebContents* web_contents,
callback_(callback),
web_contents_(web_contents),
web_contents_observer_(new WebContentsObserver(web_contents, this)) {
+ DCHECK(web_contents_);
}
AppInstaller::~AppInstaller() {
diff --git a/chromium/chrome/browser/extensions/api/webstore_widget_private/webstore_widget_private_api.cc b/chromium/chrome/browser/extensions/api/webstore_widget_private/webstore_widget_private_api.cc
index 50ea3fc8820..f8f5aa30cb9 100644
--- a/chromium/chrome/browser/extensions/api/webstore_widget_private/webstore_widget_private_api.cc
+++ b/chromium/chrome/browser/extensions/api/webstore_widget_private/webstore_widget_private_api.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/webstore_widget_private.h"
#include "chrome/grit/generated_resources.h"
+#include "extensions/browser/extension_function_constants.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h"
@@ -90,9 +91,14 @@ WebstoreWidgetPrivateInstallWebstoreItemFunction::Run() {
&WebstoreWidgetPrivateInstallWebstoreItemFunction::OnInstallComplete,
this);
+ content::WebContents* web_contents = GetSenderWebContents();
+ if (!web_contents) {
+ return RespondNow(
+ Error(function_constants::kCouldNotFindSenderWebContents));
+ }
scoped_refptr<webstore_widget::AppInstaller> installer(
new webstore_widget::AppInstaller(
- GetAssociatedWebContents(), params->item_id,
+ web_contents, params->item_id,
Profile::FromBrowserContext(browser_context()),
params->silent_installation, callback));
// installer will be AddRef()'d in BeginInstall().
diff --git a/chromium/chrome/browser/media/BUILD.gn b/chromium/chrome/browser/media/BUILD.gn
index 00bd50db06a..d4aa4aa6274 100644
--- a/chromium/chrome/browser/media/BUILD.gn
+++ b/chromium/chrome/browser/media/BUILD.gn
@@ -11,7 +11,6 @@ mojom("mojo_bindings") {
]
public_deps = [
- "//mojo/common:common_custom_types",
"//url/mojom:url_mojom_gurl",
]
}
diff --git a/chromium/chrome/browser/media/media_engagement_score_details.mojom b/chromium/chrome/browser/media/media_engagement_score_details.mojom
index 6ee85659821..514b81fca4f 100644
--- a/chromium/chrome/browser/media/media_engagement_score_details.mojom
+++ b/chromium/chrome/browser/media/media_engagement_score_details.mojom
@@ -37,6 +37,15 @@ struct MediaEngagementConfig {
// to be high.
double high_score_lower_threshold;
double high_score_upper_threshold;
+
+ // The state of different internal autoplay features and flags.
+ bool feature_record_data;
+ bool feature_bypass_autoplay;
+ bool feature_preload_data;
+ string autoplay_policy;
+
+ // The current version of any preloaded component.
+ string preload_version;
};
interface MediaEngagementScoreDetailsProvider {
diff --git a/chromium/chrome/browser/media/router/BUILD.gn b/chromium/chrome/browser/media/router/BUILD.gn
index 3602ef3071f..ded1bb773da 100644
--- a/chromium/chrome/browser/media/router/BUILD.gn
+++ b/chromium/chrome/browser/media/router/BUILD.gn
@@ -99,6 +99,12 @@ static_library("router") {
"providers/cast/chrome_cast_message_handler.h",
"providers/cast/dual_media_sink_service.cc",
"providers/cast/dual_media_sink_service.h",
+ "providers/common/buffered_message_sender.cc",
+ "providers/common/buffered_message_sender.h",
+ "providers/dial/dial_activity_manager.cc",
+ "providers/dial/dial_activity_manager.h",
+ "providers/dial/dial_internal_message_util.cc",
+ "providers/dial/dial_internal_message_util.h",
"providers/dial/dial_media_route_provider.cc",
"providers/dial/dial_media_route_provider.h",
"providers/extension/extension_media_route_provider_proxy.cc",
diff --git a/chromium/chrome/browser/media/router/discovery/BUILD.gn b/chromium/chrome/browser/media/router/discovery/BUILD.gn
index 129a8221457..d4cb50ef8f4 100644
--- a/chromium/chrome/browser/media/router/discovery/BUILD.gn
+++ b/chromium/chrome/browser/media/router/discovery/BUILD.gn
@@ -55,6 +55,8 @@ static_library("discovery") {
"mdns/dns_sd_device_lister.h",
"mdns/dns_sd_registry.cc",
"mdns/dns_sd_registry.h",
+ "mdns/media_sink_util.cc",
+ "mdns/media_sink_util.h",
"media_sink_discovery_metrics.cc",
"media_sink_discovery_metrics.h",
]
@@ -64,7 +66,6 @@ static_library("discovery") {
"discovery_network_info.cc",
"discovery_network_info.h",
"discovery_network_list.h",
- "discovery_network_list_posix.cc",
"discovery_network_list_wifi.h",
"discovery_network_list_wifi_linux.cc",
"discovery_network_list_wifi_mac.mm",
@@ -76,6 +77,9 @@ static_library("discovery") {
"discovery_network_monitor_metrics.cc",
"discovery_network_monitor_metrics.h",
]
+ if (is_posix) {
+ sources += [ "discovery_network_list_posix.cc" ]
+ }
}
if (is_mac) {
diff --git a/chromium/chrome/browser/printing/background_printing_manager.cc b/chromium/chrome/browser/printing/background_printing_manager.cc
index 003944a0334..14fb359b034 100644
--- a/chromium/chrome/browser/printing/background_printing_manager.cc
+++ b/chromium/chrome/browser/printing/background_printing_manager.cc
@@ -31,7 +31,6 @@ class BackgroundPrintingManager::Observer
private:
void RenderProcessGone(base::TerminationStatus status) override;
- void WebContentsDestroyed() override;
BackgroundPrintingManager* manager_;
};
@@ -46,9 +45,6 @@ void BackgroundPrintingManager::Observer::RenderProcessGone(
base::TerminationStatus status) {
manager_->DeletePreviewContents(web_contents());
}
-void BackgroundPrintingManager::Observer::WebContentsDestroyed() {
- manager_->DeletePreviewContents(web_contents());
-}
BackgroundPrintingManager::BackgroundPrintingManager() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -64,27 +60,31 @@ BackgroundPrintingManager::~BackgroundPrintingManager() {
}
void BackgroundPrintingManager::OwnPrintPreviewDialog(
- WebContents* preview_dialog) {
+ std::unique_ptr<WebContents> preview_dialog) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(PrintPreviewDialogController::IsPrintPreviewURL(
preview_dialog->GetURL()));
- CHECK(!HasPrintPreviewDialog(preview_dialog));
+ CHECK(!HasPrintPreviewDialog(preview_dialog.get()));
- printing_contents_map_[preview_dialog] =
- std::make_unique<Observer>(this, preview_dialog);
+ WebContents* raw_preview_dialog = preview_dialog.get();
+ PrintingContents printing_contents;
+ printing_contents.observer =
+ std::make_unique<Observer>(this, raw_preview_dialog);
+ printing_contents.contents = std::move(preview_dialog);
+ printing_contents_map_[raw_preview_dialog] = std::move(printing_contents);
// Watch for print jobs finishing. Everything else is watched for by the
// Observer. TODO(avi, cait): finish the job of removing this last
// notification.
registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_RELEASED,
- content::Source<WebContents>(preview_dialog));
+ content::Source<WebContents>(raw_preview_dialog));
// Activate the initiator.
PrintPreviewDialogController* dialog_controller =
PrintPreviewDialogController::GetInstance();
if (!dialog_controller)
return;
- WebContents* initiator = dialog_controller->GetInitiator(preview_dialog);
+ WebContents* initiator = dialog_controller->GetInitiator(raw_preview_dialog);
if (!initiator)
return;
initiator->GetDelegate()->ActivateContents(initiator);
@@ -131,12 +131,15 @@ void BackgroundPrintingManager::DeletePreviewContents(
// Stop all observation ...
registrar_.Remove(this, chrome::NOTIFICATION_PRINT_JOB_RELEASED,
content::Source<WebContents>(preview_contents));
+ std::unique_ptr<WebContents> contents_to_delete =
+ std::move(i->second.contents);
printing_contents_map_.erase(i);
// ... and mortally wound the contents. Deletion immediately is not a good
// idea in case this was triggered by |preview_contents| far up the
// callstack. (Trace where the NOTIFICATION_PRINT_JOB_RELEASED comes from.)
- base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, preview_contents);
+ base::ThreadTaskRunnerHandle::Get()->DeleteSoon(
+ FROM_HERE, std::move(contents_to_delete));
}
std::set<content::WebContents*> BackgroundPrintingManager::CurrentContentSet() {
@@ -152,4 +155,12 @@ bool BackgroundPrintingManager::HasPrintPreviewDialog(
return base::ContainsKey(printing_contents_map_, preview_dialog);
}
+BackgroundPrintingManager::PrintingContents::PrintingContents() = default;
+BackgroundPrintingManager::PrintingContents::~PrintingContents() = default;
+BackgroundPrintingManager::PrintingContents::PrintingContents(
+ PrintingContents&&) = default;
+BackgroundPrintingManager::PrintingContents&
+BackgroundPrintingManager::PrintingContents::operator=(PrintingContents&&) =
+ default;
+
} // namespace printing
diff --git a/chromium/chrome/browser/printing/background_printing_manager.h b/chromium/chrome/browser/printing/background_printing_manager.h
index ea211ad0395..2042a234bc8 100644
--- a/chromium/chrome/browser/printing/background_printing_manager.h
+++ b/chromium/chrome/browser/printing/background_printing_manager.h
@@ -36,7 +36,8 @@ class BackgroundPrintingManager : public content::NotificationObserver {
// Takes ownership of |preview_dialog| and deletes it when |preview_dialog|
// finishes printing. This removes |preview_dialog| from its ConstrainedDialog
// and hides it from the user.
- void OwnPrintPreviewDialog(content::WebContents* preview_dialog);
+ void OwnPrintPreviewDialog(
+ std::unique_ptr<content::WebContents> preview_dialog);
// Returns true if |printing_contents_map_| contains |preview_dialog|.
bool HasPrintPreviewDialog(content::WebContents* preview_dialog);
@@ -60,9 +61,21 @@ class BackgroundPrintingManager : public content::NotificationObserver {
void DeletePreviewContents(content::WebContents* preview_contents);
// A map from print preview WebContentses (managed by
- // BackgroundPrintingManager) to the Observers that observe them.
- std::map<content::WebContents*, std::unique_ptr<Observer>>
- printing_contents_map_;
+ // BackgroundPrintingManager) to the Observers that observe them and the owned
+ // version of the WebContents.
+ struct PrintingContents {
+ PrintingContents();
+ ~PrintingContents();
+ PrintingContents(PrintingContents&&);
+ PrintingContents& operator=(PrintingContents&&);
+
+ std::unique_ptr<content::WebContents> contents;
+ std::unique_ptr<Observer> observer;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(PrintingContents);
+ };
+ std::map<content::WebContents*, PrintingContents> printing_contents_map_;
content::NotificationRegistrar registrar_;
diff --git a/chromium/chrome/browser/printing/cloud_print/cloud_print_proxy_service_unittest.cc b/chromium/chrome/browser/printing/cloud_print/cloud_print_proxy_service_unittest.cc
index e7ba86b31bc..f2828ee3fa3 100644
--- a/chromium/chrome/browser/printing/cloud_print/cloud_print_proxy_service_unittest.cc
+++ b/chromium/chrome/browser/printing/cloud_print/cloud_print_proxy_service_unittest.cc
@@ -149,7 +149,7 @@ class TestCloudPrintProxyService : public CloudPrintProxyService {
service_manager::InterfaceProvider::TestApi test_api(
&process_control_.remote_interfaces());
test_api.SetBinderForName(
- "cloud_print::mojom::CloudPrint",
+ "cloud_print.mojom.CloudPrint",
base::Bind(&TestCloudPrintProxyService::HandleCloudPrintProxyRequest,
base::Unretained(this)));
service_manager::mojom::InterfaceProviderPtr handle;
@@ -160,7 +160,7 @@ class TestCloudPrintProxyService : public CloudPrintProxyService {
~TestCloudPrintProxyService() override {
service_manager::InterfaceProvider::TestApi test_api(
&ServiceProcessControl::GetInstance()->remote_interfaces());
- test_api.ClearBinderForName("cloud_print::mojom::CloudPrint");
+ test_api.ClearBinderForName("cloud_print.mojom.CloudPrint");
}
void Initialize() {
diff --git a/chromium/chrome/browser/printing/cloud_print/privet_device_lister_unittest.cc b/chromium/chrome/browser/printing/cloud_print/privet_device_lister_unittest.cc
index 4533759a9d2..c71bf33a0b0 100644
--- a/chromium/chrome/browser/printing/cloud_print/privet_device_lister_unittest.cc
+++ b/chromium/chrome/browser/printing/cloud_print/privet_device_lister_unittest.cc
@@ -43,7 +43,7 @@ class MockServiceWatcher : public ServiceWatcher {
~MockServiceWatcher() override {}
- virtual void Start() {
+ void Start() override {
DCHECK(!started_);
started_ = true;
mock_delegate_->ServiceWatcherStarted(service_type_, this);
@@ -54,9 +54,7 @@ class MockServiceWatcher : public ServiceWatcher {
MOCK_METHOD1(SetActivelyRefreshServices, void(
bool actively_refresh_services));
- virtual std::string GetServiceType() const {
- return service_type_;
- }
+ std::string GetServiceType() const override { return service_type_; }
bool started() {
return started_;
@@ -156,7 +154,7 @@ class MockServiceDiscoveryMockDelegate : public ServiceDiscoveryMockDelegate {
class MockDeviceListerDelegate : public PrivetDeviceLister::Delegate {
public:
MockDeviceListerDelegate() {}
- virtual ~MockDeviceListerDelegate() {}
+ ~MockDeviceListerDelegate() override {}
MOCK_METHOD2(DeviceChanged,
void(const std::string& name,
diff --git a/chromium/chrome/browser/printing/cloud_print/privet_http_impl.cc b/chromium/chrome/browser/printing/cloud_print/privet_http_impl.cc
index 4b0befd36aa..caacea829aa 100644
--- a/chromium/chrome/browser/printing/cloud_print/privet_http_impl.cc
+++ b/chromium/chrome/browser/printing/cloud_print/privet_http_impl.cc
@@ -14,6 +14,7 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/location.h"
+#include "base/memory/ref_counted_memory.h"
#include "base/rand_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
@@ -480,16 +481,10 @@ void PrivetLocalPrintOperationImpl::DoSubmitdoc() {
url_fetcher_ =
privet_client_->CreateURLFetcher(url, net::URLFetcher::POST, this);
- if (use_pdf_) {
- // TODO(noamsml): Move to file-based upload data?
- std::string data_str(reinterpret_cast<const char*>(data_->front()),
- data_->size());
- url_fetcher_->SetUploadData(kPrivetContentTypePDF, data_str);
- } else {
- url_fetcher_->SetUploadFilePath(kPrivetContentTypePWGRaster,
- pwg_file_path_);
- }
-
+ std::string data_str(reinterpret_cast<const char*>(data_->front()),
+ data_->size());
+ url_fetcher_->SetUploadData(
+ use_pdf_ ? kPrivetContentTypePDF : kPrivetContentTypePWGRaster, data_str);
url_fetcher_->Start();
}
@@ -573,15 +568,15 @@ void PrivetLocalPrintOperationImpl::OnCreatejobResponse(
}
void PrivetLocalPrintOperationImpl::OnPWGRasterConverted(
- bool success,
- const base::FilePath& pwg_file_path) {
- if (!success) {
+ base::ReadOnlySharedMemoryRegion pwg_region) {
+ auto data =
+ base::RefCountedSharedMemoryMapping::CreateFromWholeRegion(pwg_region);
+ if (!data) {
delegate_->OnPrivetPrintingError(this, -1);
return;
}
- DCHECK(!pwg_file_path.empty());
- pwg_file_path_ = pwg_file_path;
+ data_ = data;
StartPrinting();
}
diff --git a/chromium/chrome/browser/printing/cloud_print/privet_http_impl.h b/chromium/chrome/browser/printing/cloud_print/privet_http_impl.h
index 3896350cc6d..432a94a8bc5 100644
--- a/chromium/chrome/browser/printing/cloud_print/privet_http_impl.h
+++ b/chromium/chrome/browser/printing/cloud_print/privet_http_impl.h
@@ -10,8 +10,8 @@
#include <vector>
#include "base/callback.h"
-#include "base/files/file_path.h"
#include "base/macros.h"
+#include "base/memory/read_only_shared_memory_region.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/printing/cloud_print/privet_http.h"
@@ -19,6 +19,10 @@
#include "printing/buildflags/buildflags.h"
#include "ui/gfx/geometry/size.h"
+namespace base {
+class RefCountedMemory;
+}
+
namespace cloud_print {
class PrivetHTTPClient;
@@ -189,7 +193,7 @@ class PrivetLocalPrintOperationImpl
const base::DictionaryValue* value);
void OnCreatejobResponse(bool has_error,
const base::DictionaryValue* value);
- void OnPWGRasterConverted(bool success, const base::FilePath& pwg_file_path);
+ void OnPWGRasterConverted(base::ReadOnlySharedMemoryRegion pwg_region);
PrivetHTTPClient* const privet_client_;
PrivetLocalPrintOperation::Delegate* const delegate_;
@@ -200,7 +204,6 @@ class PrivetLocalPrintOperationImpl
cloud_devices::CloudDeviceDescription capabilities_;
scoped_refptr<base::RefCountedMemory> data_;
- base::FilePath pwg_file_path_;
bool use_pdf_ = false;
bool has_extended_workflow_ = false;
diff --git a/chromium/chrome/browser/printing/cloud_print/privet_http_unittest.cc b/chromium/chrome/browser/printing/cloud_print/privet_http_unittest.cc
index 85bdf102855..71fc872ab85 100644
--- a/chromium/chrome/browser/printing/cloud_print/privet_http_unittest.cc
+++ b/chromium/chrome/browser/printing/cloud_print/privet_http_unittest.cc
@@ -358,8 +358,8 @@ class PrivetHTTPTest : public TestWithParam<const char*> {
return SuccessfulResponseToURL(url, response);
}
- bool SuccessfulResponseToURLAndFilePath(const GURL& url,
- const base::FilePath& file_path,
+ bool SuccessfulResponseToURLAndFileData(const GURL& url,
+ const std::string& file_data,
const std::string& response) {
net::TestURLFetcher* fetcher = fetcher_factory_.GetFetcherByID(0);
if (!fetcher) {
@@ -369,8 +369,8 @@ class PrivetHTTPTest : public TestWithParam<const char*> {
EXPECT_EQ(url, fetcher->GetOriginalURL());
- EXPECT_EQ(file_path, fetcher->upload_file_path());
- if (file_path != fetcher->upload_file_path())
+ EXPECT_EQ(file_data, fetcher->upload_data());
+ if (file_data != fetcher->upload_data())
return false;
return SuccessfulResponseToURL(url, response);
@@ -455,15 +455,15 @@ class MockRegisterDelegate : public PrivetRegisterOperation::Delegate {
class MockLocalPrintDelegate : public PrivetLocalPrintOperation::Delegate {
public:
- virtual void OnPrivetPrintingDone(
- const PrivetLocalPrintOperation* print_operation) {
+ void OnPrivetPrintingDone(
+ const PrivetLocalPrintOperation* print_operation) override {
OnPrivetPrintingDoneInternal();
}
MOCK_METHOD0(OnPrivetPrintingDoneInternal, void());
- virtual void OnPrivetPrintingError(
- const PrivetLocalPrintOperation* print_operation, int http_code) {
+ void OnPrivetPrintingError(const PrivetLocalPrintOperation* print_operation,
+ int http_code) override {
OnPrivetPrintingErrorInternal(http_code);
}
@@ -550,6 +550,8 @@ class PrivetRegisterTest : public PrivetHTTPTest {
StrictMock<MockRegisterDelegate> register_delegate_;
};
+INSTANTIATE_TEST_CASE_P(PrivetTests, PrivetRegisterTest, ValuesIn(kTestParams));
+
TEST_P(PrivetRegisterTest, RegisterSuccessSimple) {
register_operation_->Start();
@@ -767,20 +769,28 @@ TEST_P(PrivetCapabilitiesTest, BadToken) {
}
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
-// A note on PWG raster conversion: The PWG raster converter used simply
+// A note on PWG raster conversion: The fake PWG raster converter simply returns
+// the input as the converted data. The output isn't checked anyway.
// converts strings to file paths based on them by appending "test.pdf", since
// it's easier to test that way. Instead of using a mock, we simply check if the
// request is uploading a file that is based on this pattern.
class FakePwgRasterConverter : public printing::PwgRasterConverter {
public:
- void Start(base::RefCountedMemory* data,
+ void Start(const base::RefCountedMemory* data,
const printing::PdfRenderSettings& conversion_settings,
const printing::PwgRasterSettings& bitmap_settings,
ResultCallback callback) override {
+ base::MappedReadOnlyRegion memory =
+ base::ReadOnlySharedMemoryRegion::Create(data->size());
+ if (!memory.IsValid()) {
+ ADD_FAILURE() << "Failed to create pwg raster shared memory.";
+ std::move(callback).Run(base::ReadOnlySharedMemoryRegion());
+ return;
+ }
+
+ memcpy(memory.mapping.memory(), data->front(), data->size());
bitmap_settings_ = bitmap_settings;
- std::string data_str(data->front_as<char>(), data->size());
- std::move(callback).Run(
- true, base::FilePath().AppendASCII(data_str + "test.pdf"));
+ std::move(callback).Run(std::move(memory.region));
}
const printing::PwgRasterSettings& bitmap_settings() {
@@ -872,8 +882,7 @@ TEST_P(PrivetLocalPrintTest, SuccessfulLocalPrintWithAnyMimetype) {
TEST_P(PrivetLocalPrintTest, SuccessfulPWGLocalPrint) {
local_print_operation_->SetUsername("sample@gmail.com");
local_print_operation_->SetJobname("Sample job name");
- local_print_operation_->SetData(
- RefCountedBytesFromString("path/to/"));
+ local_print_operation_->SetData(RefCountedBytesFromString("foobar"));
local_print_operation_->SetCapabilities(kSampleCapabilitiesResponsePWGOnly);
local_print_operation_->Start();
@@ -885,12 +894,11 @@ TEST_P(PrivetLocalPrintTest, SuccessfulPWGLocalPrint) {
EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal());
- EXPECT_TRUE(SuccessfulResponseToURLAndFilePath(
+ EXPECT_TRUE(SuccessfulResponseToURLAndFileData(
GetUrl("/privet/printer/submitdoc?"
"client_name=Chrome&user_name=sample%40gmail.com"
"&job_name=Sample+job+name"),
- base::FilePath(FILE_PATH_LITERAL("path/to/test.pdf")),
- kSampleLocalPrintResponse));
+ "foobar", kSampleLocalPrintResponse));
EXPECT_EQ(printing::TRANSFORM_NORMAL,
pwg_converter_->bitmap_settings().odd_page_transform);
@@ -904,7 +912,7 @@ TEST_P(PrivetLocalPrintTest, SuccessfulPWGLocalPrint) {
TEST_P(PrivetLocalPrintTest, SuccessfulPWGLocalPrintDuplex) {
local_print_operation_->SetUsername("sample@gmail.com");
local_print_operation_->SetJobname("Sample job name");
- local_print_operation_->SetData(RefCountedBytesFromString("path/to/"));
+ local_print_operation_->SetData(RefCountedBytesFromString("foobar"));
local_print_operation_->SetTicket(kSampleCJTDuplex);
local_print_operation_->SetCapabilities(
kSampleCapabilitiesResponsePWGSettings);
@@ -922,12 +930,11 @@ TEST_P(PrivetLocalPrintTest, SuccessfulPWGLocalPrintDuplex) {
EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal());
- EXPECT_TRUE(SuccessfulResponseToURLAndFilePath(
+ EXPECT_TRUE(SuccessfulResponseToURLAndFileData(
GetUrl("/privet/printer/submitdoc?"
"client_name=Chrome&user_name=sample%40gmail.com"
"&job_name=Sample+job+name&job_id=1234"),
- base::FilePath(FILE_PATH_LITERAL("path/to/test.pdf")),
- kSampleLocalPrintResponse));
+ "foobar", kSampleLocalPrintResponse));
EXPECT_EQ(printing::TRANSFORM_ROTATE_180,
pwg_converter_->bitmap_settings().odd_page_transform);
@@ -941,7 +948,7 @@ TEST_P(PrivetLocalPrintTest, SuccessfulPWGLocalPrintDuplex) {
TEST_P(PrivetLocalPrintTest, SuccessfulPWGLocalPrintMono) {
local_print_operation_->SetUsername("sample@gmail.com");
local_print_operation_->SetJobname("Sample job name");
- local_print_operation_->SetData(RefCountedBytesFromString("path/to/"));
+ local_print_operation_->SetData(RefCountedBytesFromString("foobar"));
local_print_operation_->SetTicket(kSampleCJTMono);
local_print_operation_->SetCapabilities(
kSampleCapabilitiesResponsePWGSettings);
@@ -959,12 +966,11 @@ TEST_P(PrivetLocalPrintTest, SuccessfulPWGLocalPrintMono) {
EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal());
- EXPECT_TRUE(SuccessfulResponseToURLAndFilePath(
+ EXPECT_TRUE(SuccessfulResponseToURLAndFileData(
GetUrl("/privet/printer/submitdoc?"
"client_name=Chrome&user_name=sample%40gmail.com"
"&job_name=Sample+job+name&job_id=1234"),
- base::FilePath(FILE_PATH_LITERAL("path/to/test.pdf")),
- kSampleLocalPrintResponse));
+ "foobar", kSampleLocalPrintResponse));
EXPECT_EQ(printing::TRANSFORM_NORMAL,
pwg_converter_->bitmap_settings().odd_page_transform);
@@ -978,7 +984,7 @@ TEST_P(PrivetLocalPrintTest, SuccessfulPWGLocalPrintMono) {
TEST_P(PrivetLocalPrintTest, SuccessfulPWGLocalPrintMonoToGRAY8Printer) {
local_print_operation_->SetUsername("sample@gmail.com");
local_print_operation_->SetJobname("Sample job name");
- local_print_operation_->SetData(RefCountedBytesFromString("path/to/"));
+ local_print_operation_->SetData(RefCountedBytesFromString("foobar"));
local_print_operation_->SetTicket(kSampleCJTMono);
local_print_operation_->SetCapabilities(
kSampleCapabilitiesResponsePWGSettingsMono);
@@ -996,12 +1002,11 @@ TEST_P(PrivetLocalPrintTest, SuccessfulPWGLocalPrintMonoToGRAY8Printer) {
EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal());
- EXPECT_TRUE(SuccessfulResponseToURLAndFilePath(
+ EXPECT_TRUE(SuccessfulResponseToURLAndFileData(
GetUrl("/privet/printer/submitdoc?"
"client_name=Chrome&user_name=sample%40gmail.com"
"&job_name=Sample+job+name&job_id=1234"),
- base::FilePath(FILE_PATH_LITERAL("path/to/test.pdf")),
- kSampleLocalPrintResponse));
+ "foobar", kSampleLocalPrintResponse));
EXPECT_EQ(printing::TRANSFORM_NORMAL,
pwg_converter_->bitmap_settings().odd_page_transform);
@@ -1075,8 +1080,7 @@ TEST_P(PrivetLocalPrintTest, PDFPrintInvalidDocumentTypeRetry) {
local_print_operation_->SetJobname("Sample job name");
local_print_operation_->SetTicket(kSampleCJT);
local_print_operation_->SetCapabilities(kSampleCapabilitiesResponse);
- local_print_operation_->SetData(
- RefCountedBytesFromString("sample/path/"));
+ local_print_operation_->SetData(RefCountedBytesFromString("sample_data"));
local_print_operation_->Start();
EXPECT_TRUE(SuccessfulResponseToURL(GetUrl("/privet/info"),
@@ -1093,16 +1097,15 @@ TEST_P(PrivetLocalPrintTest, PDFPrintInvalidDocumentTypeRetry) {
GetUrl("/privet/printer/submitdoc?"
"client_name=Chrome&user_name=sample%40gmail.com&"
"job_name=Sample+job+name&job_id=1234"),
- "sample/path/", kSampleInvalidDocumentTypeResponse));
+ "sample_data", kSampleInvalidDocumentTypeResponse));
EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal());
- EXPECT_TRUE(SuccessfulResponseToURLAndFilePath(
+ EXPECT_TRUE(SuccessfulResponseToURLAndFileData(
GetUrl("/privet/printer/submitdoc?"
"client_name=Chrome&user_name=sample%40gmail.com&"
"job_name=Sample+job+name&job_id=1234"),
- base::FilePath(FILE_PATH_LITERAL("sample/path/test.pdf")),
- kSampleLocalPrintResponse));
+ "sample_data", kSampleLocalPrintResponse));
}
TEST_P(PrivetLocalPrintTest, LocalPrintRetryOnInvalidJobID) {
@@ -1151,7 +1154,7 @@ class PrivetHttpWithServerTest : public ::testing::Test,
std::make_unique<EmbeddedTestServer>(EmbeddedTestServer::TYPE_HTTP);
base::FilePath test_data_dir;
- ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir));
+ ASSERT_TRUE(base::PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir));
server_->ServeFilesFromDirectory(
test_data_dir.Append(FILE_PATH_LITERAL("chrome/test/data")));
ASSERT_TRUE(server_->Start());
diff --git a/chromium/chrome/browser/printing/cloud_print/privet_notifications_unittest.cc b/chromium/chrome/browser/printing/cloud_print/privet_notifications_unittest.cc
index f93be352751..f119313b146 100644
--- a/chromium/chrome/browser/printing/cloud_print/privet_notifications_unittest.cc
+++ b/chromium/chrome/browser/printing/cloud_print/privet_notifications_unittest.cc
@@ -100,7 +100,7 @@ class PrivetNotificationsListenerTest : public testing::Test {
description_.description = kExampleDeviceDescription;
}
- virtual ~PrivetNotificationsListenerTest() {}
+ ~PrivetNotificationsListenerTest() override {}
bool SuccessfulResponseToInfo(const std::string& response) {
net::TestURLFetcher* fetcher = fetcher_factory_.GetFetcherByID(0);
diff --git a/chromium/chrome/browser/printing/cloud_print/privet_url_fetcher.cc b/chromium/chrome/browser/printing/cloud_print/privet_url_fetcher.cc
index 44c854423e5..d8d3d0982c4 100644
--- a/chromium/chrome/browser/printing/cloud_print/privet_url_fetcher.cc
+++ b/chromium/chrome/browser/printing/cloud_print/privet_url_fetcher.cc
@@ -163,16 +163,8 @@ void PrivetURLFetcher::Try() {
url_fetcher_->SaveResponseToTemporaryFile(GetFileTaskRunner());
// URLFetcher requires us to set upload data for POST requests.
- if (request_type_ == net::URLFetcher::POST) {
- if (upload_file_path_.empty()) {
- url_fetcher_->SetUploadData(upload_content_type_, upload_data_);
- } else {
- url_fetcher_->SetUploadFilePath(
- upload_content_type_, upload_file_path_, 0 /*offset*/,
- std::numeric_limits<uint64_t>::max() /*length*/, GetFileTaskRunner());
- }
- }
-
+ if (request_type_ == net::URLFetcher::POST)
+ url_fetcher_->SetUploadData(upload_content_type_, upload_data_);
url_fetcher_->Start();
}
@@ -196,19 +188,10 @@ void PrivetURLFetcher::Start() {
void PrivetURLFetcher::SetUploadData(const std::string& upload_content_type,
const std::string& upload_data) {
- DCHECK(upload_file_path_.empty());
upload_content_type_ = upload_content_type;
upload_data_ = upload_data;
}
-void PrivetURLFetcher::SetUploadFilePath(
- const std::string& upload_content_type,
- const base::FilePath& upload_file_path) {
- DCHECK(upload_data_.empty());
- upload_content_type_ = upload_content_type;
- upload_file_path_ = upload_file_path;
-}
-
void PrivetURLFetcher::OnURLFetchComplete(const net::URLFetcher* source) {
DVLOG(1) << "Status: " << source->GetStatus().status()
<< ", ResponseCode: " << source->GetResponseCode();
diff --git a/chromium/chrome/browser/printing/cloud_print/privet_url_fetcher.h b/chromium/chrome/browser/printing/cloud_print/privet_url_fetcher.h
index 91e09bf338a..5be6c5f5f29 100644
--- a/chromium/chrome/browser/printing/cloud_print/privet_url_fetcher.h
+++ b/chromium/chrome/browser/printing/cloud_print/privet_url_fetcher.h
@@ -98,9 +98,6 @@ class PrivetURLFetcher : public net::URLFetcherDelegate {
void SetUploadData(const std::string& upload_content_type,
const std::string& upload_data);
- void SetUploadFilePath(const std::string& upload_content_type,
- const base::FilePath& upload_file_path);
-
const GURL& url() const {
return url_fetcher_ ? url_fetcher_->GetOriginalURL() : url_;
}
@@ -141,7 +138,6 @@ class PrivetURLFetcher : public net::URLFetcherDelegate {
int tries_ = 0;
std::string upload_data_;
std::string upload_content_type_;
- base::FilePath upload_file_path_;
std::unique_ptr<net::URLFetcher> url_fetcher_;
scoped_refptr<base::SequencedTaskRunner> file_task_runner_;
diff --git a/chromium/chrome/browser/printing/cloud_print/privet_url_fetcher_unittest.cc b/chromium/chrome/browser/printing/cloud_print/privet_url_fetcher_unittest.cc
index daff3e61f93..8e40a00df14 100644
--- a/chromium/chrome/browser/printing/cloud_print/privet_url_fetcher_unittest.cc
+++ b/chromium/chrome/browser/printing/cloud_print/privet_url_fetcher_unittest.cc
@@ -58,7 +58,7 @@ class MockPrivetURLFetcherDelegate : public PrivetURLFetcher::Delegate {
bool OnRawData(bool response_is_file,
const std::string& data,
- const base::FilePath& response_file) {
+ const base::FilePath& response_file) override {
if (!raw_mode_) return false;
if (response_is_file) {
diff --git a/chromium/chrome/browser/printing/pdf_to_emf_converter.cc b/chromium/chrome/browser/printing/pdf_to_emf_converter.cc
index 6760c09f15c..d435f7e1581 100644
--- a/chromium/chrome/browser/printing/pdf_to_emf_converter.cc
+++ b/chromium/chrome/browser/printing/pdf_to_emf_converter.cc
@@ -14,12 +14,10 @@
#include "base/callback.h"
#include "base/containers/queue.h"
-#include "base/files/file.h"
-#include "base/files/file_util.h"
-#include "base/files/scoped_temp_dir.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ref_counted_delete_on_sequence.h"
+#include "base/metrics/histogram_macros.h"
#include "base/sequenced_task_runner.h"
#include "base/task_scheduler/post_task.h"
#include "base/threading/sequenced_task_runner_handle.h"
@@ -31,7 +29,6 @@
#include "content/public/browser/child_process_data.h"
#include "content/public/common/service_manager_connection.h"
#include "mojo/public/cpp/bindings/binding.h"
-#include "mojo/public/cpp/system/platform_handle.h"
#include "printing/emf_win.h"
#include "printing/pdf_render_settings.h"
#include "services/service_manager/public/cpp/connector.h"
@@ -42,59 +39,6 @@ namespace printing {
namespace {
-void CloseFileOnBlockingTaskRunner(base::File temp_file) {
- base::AssertBlockingAllowed();
- temp_file.Close();
-}
-
-// Allows to delete temporary directory after all temporary files created inside
-// are closed. Windows cannot delete directory with opened files. Directory is
-// used to store PDF and metafiles. PDF should be gone by the time utility
-// process exits. Metafiles should be gone when all LazyEmf destroyed.
-class RefCountedTempDir
- : public base::RefCountedDeleteOnSequence<RefCountedTempDir> {
- public:
- RefCountedTempDir()
- : base::RefCountedDeleteOnSequence<RefCountedTempDir>(
- base::SequencedTaskRunnerHandle::Get()) {
- ignore_result(temp_dir_.CreateUniqueTempDir());
- }
-
- bool IsValid() const { return temp_dir_.IsValid(); }
- const base::FilePath& GetPath() const { return temp_dir_.GetPath(); }
-
- private:
- friend class base::RefCountedDeleteOnSequence<RefCountedTempDir>;
- friend class base::DeleteHelper<RefCountedTempDir>;
-
- ~RefCountedTempDir() {}
-
- base::ScopedTempDir temp_dir_;
- DISALLOW_COPY_AND_ASSIGN(RefCountedTempDir);
-};
-
-class TempFile {
- public:
- explicit TempFile(base::File file)
- : file_(std::move(file)),
- blocking_task_runner_(base::SequencedTaskRunnerHandle::Get()) {
- base::AssertBlockingAllowed();
- }
- ~TempFile() {
- blocking_task_runner_->PostTask(
- FROM_HERE, base::BindOnce(&CloseFileOnBlockingTaskRunner,
- base::Passed(std::move(file_))));
- }
-
- base::File& file() { return file_; }
-
- private:
- base::File file_;
- const scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
-
- DISALLOW_COPY_AND_ASSIGN(TempFile);
-};
-
class PdfToEmfConverterClientImpl : public mojom::PdfToEmfConverterClient {
public:
explicit PdfToEmfConverterClientImpl(
@@ -144,66 +88,30 @@ class PdfToEmfConverterClientImpl : public mojom::PdfToEmfConverterClient {
mojo::Binding<mojom::PdfToEmfConverterClient> binding_;
};
-using ScopedTempFile = std::unique_ptr<TempFile>;
-
-// Wrapper for Emf to keep only file handle in memory, and load actual data only
-// on playback. Emf::InitFromFile() can play metafile directly from disk, but it
-// can't open file handles. We need file handles to reliably delete temporary
-// files, and to efficiently interact with utility process.
-class LazyEmf : public MetafilePlayer {
- public:
- LazyEmf(const scoped_refptr<RefCountedTempDir>& temp_dir, ScopedTempFile file)
- : temp_dir_(temp_dir), file_(std::move(file)) {
- CHECK(file_);
- }
- ~LazyEmf() override { Close(); }
-
- protected:
- // MetafilePlayer:
- bool SafePlayback(HDC hdc) const override;
-
- void Close() const;
- bool LoadEmf(Emf* emf) const;
-
- private:
- mutable scoped_refptr<RefCountedTempDir> temp_dir_;
- mutable ScopedTempFile file_; // Mutable because of consts in base class.
-
- bool GetDataAsVector(std::vector<char>* buffer) const override;
- bool SaveTo(base::File* file) const override;
-
- DISALLOW_COPY_AND_ASSIGN(LazyEmf);
-};
-
-// Postscript metafile subclass to override SafePlayback.
-class PostScriptMetaFile : public LazyEmf {
+// Emf subclass that knows how to play back PostScript data embedded as EMF
+// comment records.
+class PostScriptMetaFile : public Emf {
public:
- PostScriptMetaFile(const scoped_refptr<RefCountedTempDir>& temp_dir,
- ScopedTempFile file)
- : LazyEmf(temp_dir, std::move(file)) {}
- ~PostScriptMetaFile() override;
+ PostScriptMetaFile() {}
+ ~PostScriptMetaFile() override {}
private:
- // MetafilePlayer:
+ // Emf:
bool SafePlayback(HDC hdc) const override;
DISALLOW_COPY_AND_ASSIGN(PostScriptMetaFile);
};
// Class for converting PDF to another format for printing (Emf, Postscript).
-// Class uses UI thread and |blocking_task_runner_|.
+// Class lives on the UI thread.
// Internal workflow is following:
-// 1. Create instance on the UI thread. (files_, settings_,)
-// 2. Create pdf file on |blocking_task_runner_|.
-// 3. Bind to printing service and start conversion on the UI thread (mojo
-// actually makes that happen transparently on the IO thread).
-// 4. Printing service returns page count.
-// 5. For each page:
-// 1. Clients requests page with file handle to a temp file.
-// 2. Utility converts the page, save it to the file and reply.
-//
-// All these steps work sequentially, so no data should be accessed
-// simultaneously by several threads.
+// 1. Create instance on the UI thread.
+// 2. Initialize() binds to printing service and start conversion on the UI
+// thread (Mojo actually makes that happen transparently on the IO thread).
+// 3. Printing service returns page count.
+// 4. For each page:
+// 1. Clients requests page.
+// 2. Utility converts the page, and sends back the data in a memory region.
class PdfConverterImpl : public PdfConverter {
public:
PdfConverterImpl(const scoped_refptr<base::RefCountedMemory>& data,
@@ -211,12 +119,12 @@ class PdfConverterImpl : public PdfConverter {
StartCallback start_callback);
~PdfConverterImpl() override;
- static void set_fail_when_creating_temp_file_for_tests(bool fail) {
- simulate_failure_creating_temp_file_ = fail;
+ static void set_fail_when_initializing_conversion_for_tests(bool fail) {
+ simulate_failure_initializing_conversion_ = fail;
}
- static bool fail_when_creating_temp_file_for_tests() {
- return simulate_failure_creating_temp_file_;
+ static bool fail_when_initializing_conversion_for_tests() {
+ return simulate_failure_initializing_conversion_;
}
private:
@@ -232,7 +140,6 @@ class PdfConverterImpl : public PdfConverter {
GetPageCallbackData& operator=(GetPageCallbackData&& rhs) {
page_number_ = rhs.page_number_;
callback_ = rhs.callback_;
- file_ = std::move(rhs.file_);
return *this;
}
@@ -240,37 +147,31 @@ class PdfConverterImpl : public PdfConverter {
const PdfConverter::GetPageCallback& callback() const { return callback_; }
- ScopedTempFile TakeFile() { return std::move(file_); }
-
- void set_file(ScopedTempFile file) { file_ = std::move(file); }
-
private:
int page_number_;
PdfConverter::GetPageCallback callback_;
- ScopedTempFile file_;
DISALLOW_COPY_AND_ASSIGN(GetPageCallbackData);
};
+ void Initialize(const scoped_refptr<base::RefCountedMemory>& data);
+
void GetPage(int page_number,
const PdfConverter::GetPageCallback& get_page_callback) override;
void Stop();
- // Helper functions: must be overridden by subclasses
- // Create a metafileplayer subclass file from a temporary file.
- std::unique_ptr<MetafilePlayer> GetFileFromTemp(ScopedTempFile temp_file);
+ std::unique_ptr<MetafilePlayer> GetMetaFileFromMapping(
+ base::ReadOnlySharedMemoryMapping mapping);
void OnPageCount(mojom::PdfToEmfConverterPtr converter, uint32_t page_count);
- void OnPageDone(bool success, float scale_factor);
+ void OnPageDone(base::ReadOnlySharedMemoryRegion emf_region,
+ float scale_factor);
void OnFailed(const std::string& error_message);
- void OnTempPdfReady(ScopedTempFile pdf);
- void OnTempFileReady(GetPageCallbackData* callback_data,
- ScopedTempFile temp_file);
- scoped_refptr<RefCountedTempDir> temp_dir_;
+ void RecordConversionMetrics();
PdfRenderSettings settings_;
@@ -283,7 +184,10 @@ class PdfConverterImpl : public PdfConverter {
using GetPageCallbacks = base::queue<GetPageCallbackData>;
GetPageCallbacks get_page_callbacks_;
- const scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
+ // Keep track of document size and page counts for metrics.
+ size_t bytes_generated_ = 0;
+ uint32_t pages_generated_ = 0;
+ uint32_t page_count_ = 0;
std::unique_ptr<PdfToEmfConverterClientImpl>
pdf_to_emf_converter_client_impl_;
@@ -294,133 +198,43 @@ class PdfConverterImpl : public PdfConverter {
base::WeakPtrFactory<PdfConverterImpl> weak_ptr_factory_;
- static bool simulate_failure_creating_temp_file_;
+ static bool simulate_failure_initializing_conversion_;
DISALLOW_COPY_AND_ASSIGN(PdfConverterImpl);
};
// static
-bool PdfConverterImpl::simulate_failure_creating_temp_file_ = false;
+bool PdfConverterImpl::simulate_failure_initializing_conversion_ = false;
-std::unique_ptr<MetafilePlayer> PdfConverterImpl::GetFileFromTemp(
- ScopedTempFile temp_file) {
+std::unique_ptr<MetafilePlayer> PdfConverterImpl::GetMetaFileFromMapping(
+ base::ReadOnlySharedMemoryMapping mapping) {
+ std::unique_ptr<Emf> metafile;
if (settings_.mode == PdfRenderSettings::Mode::POSTSCRIPT_LEVEL2 ||
settings_.mode == PdfRenderSettings::Mode::POSTSCRIPT_LEVEL3 ||
settings_.mode == PdfRenderSettings::Mode::TEXTONLY) {
- return std::make_unique<PostScriptMetaFile>(temp_dir_,
- std::move(temp_file));
+ metafile = std::make_unique<PostScriptMetaFile>();
+ } else {
+ metafile = std::make_unique<Emf>();
}
- return std::make_unique<LazyEmf>(temp_dir_, std::move(temp_file));
-}
-
-ScopedTempFile CreateTempFile(scoped_refptr<RefCountedTempDir>* temp_dir) {
- if (PdfConverterImpl::fail_when_creating_temp_file_for_tests())
- return ScopedTempFile();
-
- if (!temp_dir->get())
- *temp_dir = base::MakeRefCounted<RefCountedTempDir>();
- ScopedTempFile file;
- if (!(*temp_dir)->IsValid())
- return file;
- base::FilePath path;
- if (!base::CreateTemporaryFileInDir((*temp_dir)->GetPath(), &path)) {
- PLOG(ERROR) << "Failed to create file in "
- << (*temp_dir)->GetPath().value();
- return file;
- }
- file = std::make_unique<TempFile>(base::File(
- path, base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE |
- base::File::FLAG_READ | base::File::FLAG_DELETE_ON_CLOSE |
- base::File::FLAG_TEMPORARY));
- if (!file->file().IsValid()) {
- PLOG(ERROR) << "Failed to create " << path.value();
- file.reset();
- }
- return file;
-}
-
-ScopedTempFile CreateTempPdfFile(
- const scoped_refptr<base::RefCountedMemory>& data,
- scoped_refptr<RefCountedTempDir>* temp_dir) {
- ScopedTempFile pdf_file = CreateTempFile(temp_dir);
- if (!pdf_file || static_cast<int>(data->size()) !=
- pdf_file->file().WriteAtCurrentPos(
- data->front_as<char>(), data->size())) {
- pdf_file.reset();
- return pdf_file;
- }
- pdf_file->file().Seek(base::File::FROM_BEGIN, 0);
- return pdf_file;
-}
-
-bool LazyEmf::SafePlayback(HDC hdc) const {
- Emf emf;
- bool result = LoadEmf(&emf) && emf.SafePlayback(hdc);
- // TODO(thestig): Fix destruction of metafiles. For some reasons
- // instances of Emf are not deleted. https://crbug.com/260806
- // It's known that the Emf going to be played just once to a printer. So just
- // release |file_| here.
- Close();
- return result;
-}
-
-bool LazyEmf::GetDataAsVector(std::vector<char>* buffer) const {
- NOTREACHED();
- return false;
-}
-
-bool LazyEmf::SaveTo(base::File* file) const {
- Emf emf;
- return LoadEmf(&emf) && emf.SaveTo(file);
-}
-
-void LazyEmf::Close() const {
- file_.reset();
- temp_dir_ = nullptr;
-}
-
-bool LazyEmf::LoadEmf(Emf* emf) const {
- file_->file().Seek(base::File::FROM_BEGIN, 0);
- int64_t size = file_->file().GetLength();
- if (size <= 0)
- return false;
- std::vector<char> data(size);
- if (file_->file().ReadAtCurrentPos(data.data(), data.size()) != size)
- return false;
- return emf->InitFromData(data.data(), data.size());
-}
-
-PostScriptMetaFile::~PostScriptMetaFile() {
+ if (!metafile->InitFromData(mapping.memory(), mapping.size()))
+ metafile.reset();
+ return metafile;
}
bool PostScriptMetaFile::SafePlayback(HDC hdc) const {
- // TODO(thestig): Fix destruction of metafiles. For some reasons
- // instances of Emf are not deleted. https://crbug.com/260806
- // It's known that the Emf going to be played just once to a printer. So just
- // release |file_| before returning.
- Emf emf;
- if (!LoadEmf(&emf)) {
- Close();
- return false;
- }
-
- {
- // Ensure enumerator destruction before calling Close() below.
- Emf::Enumerator emf_enum(emf, nullptr, nullptr);
- for (const Emf::Record& record : emf_enum) {
- auto* emf_record = record.record();
- if (emf_record->iType != EMR_GDICOMMENT)
- continue;
-
- const EMRGDICOMMENT* comment =
- reinterpret_cast<const EMRGDICOMMENT*>(emf_record);
- const char* data = reinterpret_cast<const char*>(comment->Data);
- const uint16_t* ptr = reinterpret_cast<const uint16_t*>(data);
- int ret = ExtEscape(hdc, PASSTHROUGH, 2 + *ptr, data, 0, nullptr);
- DCHECK_EQ(*ptr, ret);
- }
+ Emf::Enumerator emf_enum(*this, nullptr, nullptr);
+ for (const Emf::Record& record : emf_enum) {
+ auto* emf_record = record.record();
+ if (emf_record->iType != EMR_GDICOMMENT)
+ continue;
+
+ const EMRGDICOMMENT* comment =
+ reinterpret_cast<const EMRGDICOMMENT*>(emf_record);
+ const char* data = reinterpret_cast<const char*>(comment->Data);
+ const uint16_t* ptr = reinterpret_cast<const uint16_t*>(data);
+ int ret = ExtEscape(hdc, PASSTHROUGH, 2 + *ptr, data, 0, nullptr);
+ DCHECK_EQ(*ptr, ret);
}
- Close();
return true;
}
@@ -430,28 +244,34 @@ PdfConverterImpl::PdfConverterImpl(
StartCallback start_callback)
: settings_(settings),
start_callback_(std::move(start_callback)),
- blocking_task_runner_(base::CreateSequencedTaskRunnerWithTraits(
- {base::MayBlock(), base::TaskPriority::USER_VISIBLE,
- base::TaskShutdownBehavior::BLOCK_SHUTDOWN})),
weak_ptr_factory_(this) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(start_callback_);
- base::PostTaskAndReplyWithResult(
- blocking_task_runner_.get(), FROM_HERE,
- base::BindOnce(&CreateTempPdfFile, data, &temp_dir_),
- base::BindOnce(&PdfConverterImpl::OnTempPdfReady,
- weak_ptr_factory_.GetWeakPtr()));
+ Initialize(data);
}
PdfConverterImpl::~PdfConverterImpl() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ RecordConversionMetrics();
}
-void PdfConverterImpl::OnTempPdfReady(ScopedTempFile pdf) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- if (!pdf)
- return OnFailed(std::string("Failed to create temporary PDF file."));
+void PdfConverterImpl::Initialize(
+ const scoped_refptr<base::RefCountedMemory>& data) {
+ if (simulate_failure_initializing_conversion_) {
+ OnFailed(std::string("Failed to create PDF data mapping."));
+ return;
+ }
+
+ base::MappedReadOnlyRegion memory =
+ base::ReadOnlySharedMemoryRegion::Create(data->size());
+ if (!memory.region.IsValid() || !memory.mapping.IsValid()) {
+ OnFailed(std::string("Failed to create PDF data mapping."));
+ return;
+ }
+
+ memcpy(memory.mapping.memory(), data->front(), data->size());
content::ServiceManagerConnection::GetForProcess()
->GetConnector()
@@ -467,7 +287,7 @@ void PdfConverterImpl::OnTempPdfReady(ScopedTempFile pdf) {
mojo::MakeRequest(&pdf_to_emf_converter_client_ptr));
pdf_to_emf_converter_factory_->CreateConverter(
- mojo::WrapPlatformFile(pdf->file().TakePlatformFile()), settings_,
+ std::move(memory.region), settings_,
std::move(pdf_to_emf_converter_client_ptr),
base::BindOnce(&PdfConverterImpl::OnPageCount,
weak_ptr_factory_.GetWeakPtr()));
@@ -482,61 +302,49 @@ void PdfConverterImpl::OnPageCount(mojom::PdfToEmfConverterPtr converter,
&PdfConverterImpl::OnFailed, weak_ptr_factory_.GetWeakPtr(),
std::string("Connection to PdfToEmfConverter error.")));
std::move(start_callback_).Run(page_count);
+ page_count_ = page_count;
}
void PdfConverterImpl::GetPage(
int page_number,
const PdfConverter::GetPageCallback& get_page_callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK(pdf_to_emf_converter_.is_bound());
+
// Store callback before any OnFailed() call to make it called on failure.
get_page_callbacks_.push(GetPageCallbackData(page_number, get_page_callback));
if (!pdf_to_emf_converter_)
return OnFailed(std::string("No PdfToEmfConverter."));
- base::PostTaskAndReplyWithResult(
- blocking_task_runner_.get(), FROM_HERE,
- base::BindOnce(&CreateTempFile, &temp_dir_),
- base::BindOnce(&PdfConverterImpl::OnTempFileReady,
- weak_ptr_factory_.GetWeakPtr(),
- &get_page_callbacks_.back()));
-}
-
-void PdfConverterImpl::OnTempFileReady(GetPageCallbackData* callback_data,
- ScopedTempFile temp_file) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- DCHECK(pdf_to_emf_converter_.is_bound());
-
- if (!pdf_to_emf_converter_ || !temp_file)
- return OnFailed(std::string("Error connecting to printing service."));
-
- // We need to dup the file as mojo::WrapPlatformFile takes ownership of the
- // passed file.
- base::File temp_file_copy = temp_file->file().Duplicate();
pdf_to_emf_converter_->ConvertPage(
- callback_data->page_number(),
- mojo::WrapPlatformFile(temp_file_copy.TakePlatformFile()),
- base::BindOnce(&PdfConverterImpl::OnPageDone,
- weak_ptr_factory_.GetWeakPtr()));
- callback_data->set_file(std::move(temp_file));
+ page_number, base::BindOnce(&PdfConverterImpl::OnPageDone,
+ weak_ptr_factory_.GetWeakPtr()));
}
-void PdfConverterImpl::OnPageDone(bool success, float scale_factor) {
+void PdfConverterImpl::OnPageDone(base::ReadOnlySharedMemoryRegion emf_region,
+ float scale_factor) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
if (get_page_callbacks_.empty())
return OnFailed(std::string("No get_page callbacks."));
- GetPageCallbackData& data = get_page_callbacks_.front();
- std::unique_ptr<MetafilePlayer> file;
- if (success) {
- ScopedTempFile temp_file = data.TakeFile();
- if (!temp_file) // Unexpected message from printing service.
- return OnFailed("No temp file.");
- file = GetFileFromTemp(std::move(temp_file));
+ GetPageCallbackData& data = get_page_callbacks_.front();
+ std::unique_ptr<MetafilePlayer> metafile;
+ if (emf_region.IsValid()) {
+ base::ReadOnlySharedMemoryMapping mapping = emf_region.Map();
+ if (mapping.IsValid()) {
+ size_t mapping_size = mapping.size();
+ metafile = GetMetaFileFromMapping(std::move(mapping));
+ if (metafile) {
+ ++pages_generated_;
+ bytes_generated_ += mapping_size;
+ }
+ }
}
base::WeakPtr<PdfConverterImpl> weak_this = weak_ptr_factory_.GetWeakPtr();
- data.callback().Run(data.page_number(), scale_factor, std::move(file));
+ data.callback().Run(data.page_number(), scale_factor, std::move(metafile));
// WARNING: the callback might have deleted |this|!
if (!weak_this)
return;
@@ -561,7 +369,7 @@ void PdfConverterImpl::OnFailed(const std::string& error_message) {
}
while (!get_page_callbacks_.empty()) {
- OnPageDone(false, 0.0f);
+ OnPageDone(base::ReadOnlySharedMemoryRegion(), 0.0f);
if (!weak_this) {
// OnPageDone invokes the GetPageCallback which might end up deleting
// this.
@@ -572,6 +380,41 @@ void PdfConverterImpl::OnFailed(const std::string& error_message) {
Stop();
}
+void PdfConverterImpl::RecordConversionMetrics() {
+ if (!page_count_ || page_count_ != pages_generated_) {
+ // TODO(thestig): Consider adding UMA to track failure rates.
+ return;
+ }
+
+ DCHECK(bytes_generated_);
+ size_t average_page_size_in_kb = bytes_generated_ / 1024;
+ average_page_size_in_kb /= page_count_;
+ switch (settings_.mode) {
+ case PdfRenderSettings::Mode::NORMAL:
+ UMA_HISTOGRAM_MEMORY_KB("Printing.ConversionSize.Emf",
+ average_page_size_in_kb);
+ return;
+ case PdfRenderSettings::Mode::TEXTONLY:
+ // Intentionally not logged.
+ return;
+ case PdfRenderSettings::Mode::GDI_TEXT:
+ UMA_HISTOGRAM_MEMORY_KB("Printing.ConversionSize.EmfWithGdiText",
+ average_page_size_in_kb);
+ return;
+ case PdfRenderSettings::Mode::POSTSCRIPT_LEVEL2:
+ UMA_HISTOGRAM_MEMORY_KB("Printing.ConversionSize.PostScript2",
+ average_page_size_in_kb);
+ return;
+ case PdfRenderSettings::Mode::POSTSCRIPT_LEVEL3:
+ UMA_HISTOGRAM_MEMORY_KB("Printing.ConversionSize.PostScript3",
+ average_page_size_in_kb);
+ return;
+ default:
+ NOTREACHED();
+ return;
+ }
+}
+
} // namespace
PdfConverter::~PdfConverter() = default;
@@ -587,12 +430,12 @@ std::unique_ptr<PdfConverter> PdfConverter::StartPdfConverter(
ScopedSimulateFailureCreatingTempFileForTests::
ScopedSimulateFailureCreatingTempFileForTests() {
- PdfConverterImpl::set_fail_when_creating_temp_file_for_tests(true);
+ PdfConverterImpl::set_fail_when_initializing_conversion_for_tests(true);
}
ScopedSimulateFailureCreatingTempFileForTests::
~ScopedSimulateFailureCreatingTempFileForTests() {
- PdfConverterImpl::set_fail_when_creating_temp_file_for_tests(false);
+ PdfConverterImpl::set_fail_when_initializing_conversion_for_tests(false);
}
} // namespace printing
diff --git a/chromium/chrome/browser/printing/pdf_to_emf_converter_browsertest.cc b/chromium/chrome/browser/printing/pdf_to_emf_converter_browsertest.cc
index f6b67d8198e..b804251b152 100644
--- a/chromium/chrome/browser/printing/pdf_to_emf_converter_browsertest.cc
+++ b/chromium/chrome/browser/printing/pdf_to_emf_converter_browsertest.cc
@@ -192,7 +192,7 @@ class PdfToEmfConverterBrowserTest : public InProcessBrowserTest {
private:
base::FilePath GetTestDataDir() const {
base::FilePath test_data_dir;
- if (PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir))
+ if (base::PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir))
test_data_dir = test_data_dir.AppendASCII("printing");
else
test_data_dir.clear();
@@ -202,20 +202,12 @@ class PdfToEmfConverterBrowserTest : public InProcessBrowserTest {
bool GetEmfData() {
base::ScopedAllowBlockingForTesting allow_blocking;
- // Need to save the EMF to a file as LazyEmf::GetDataAsVector() is not
- // implemented.
- base::FilePath emf_file_path;
- if (!base::CreateTemporaryFile(&emf_file_path))
+ std::vector<char> buffer;
+ if (!current_emf_file_->GetDataAsVector(&buffer))
return false;
- base::File emf_file(emf_file_path, base::File::Flags::FLAG_CREATE_ALWAYS |
- base::File::Flags::FLAG_WRITE);
- bool ret = current_emf_file_->SaveTo(&emf_file);
- emf_file.Close();
- if (ret)
- ret = base::ReadFileToString(emf_file_path, &actual_current_emf_data_);
- base::DeleteFile(emf_file_path, false);
- return ret && !actual_current_emf_data_.empty();
+ actual_current_emf_data_.assign(buffer.data(), buffer.size());
+ return !actual_current_emf_data_.empty();
}
const base::FilePath test_data_dir_;
diff --git a/chromium/chrome/browser/printing/print_browsertest.cc b/chromium/chrome/browser/printing/print_browsertest.cc
index 6947a5be505..d3ba95a02c4 100644
--- a/chromium/chrome/browser/printing/print_browsertest.cc
+++ b/chromium/chrome/browser/printing/print_browsertest.cc
@@ -243,7 +243,7 @@ class IsolateOriginsPrintBrowserTest : public PrintBrowserTest {
constexpr char IsolateOriginsPrintBrowserTest::kIsolatedSite[];
-class PrintExtensionBrowserTest : public ExtensionBrowserTest {
+class PrintExtensionBrowserTest : public extensions::ExtensionBrowserTest {
public:
PrintExtensionBrowserTest() {}
~PrintExtensionBrowserTest() override {}
@@ -263,7 +263,7 @@ class PrintExtensionBrowserTest : public ExtensionBrowserTest {
{
base::ScopedAllowBlockingForTesting allow_blocking;
base::FilePath test_data_dir;
- PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
+ base::PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
extension = LoadExtension(
test_data_dir.AppendASCII("printing").AppendASCII("test_extension"));
ASSERT_TRUE(extension);
diff --git a/chromium/chrome/browser/printing/print_job.cc b/chromium/chrome/browser/printing/print_job.cc
index 705d965c7b2..e76a3f12e36 100644
--- a/chromium/chrome/browser/printing/print_job.cc
+++ b/chromium/chrome/browser/printing/print_job.cc
@@ -23,7 +23,9 @@
#include "printing/printed_document.h"
#if defined(OS_WIN)
+#include "base/command_line.h"
#include "chrome/browser/printing/pdf_to_emf_converter.h"
+#include "chrome/common/chrome_features.h"
#include "printing/pdf_render_settings.h"
#include "printing/printed_page_win.h"
#endif
@@ -32,14 +34,16 @@ using base::TimeDelta;
namespace printing {
-// Helper function to ensure |owner| is valid until at least |callback| returns.
-void HoldRefCallback(scoped_refptr<PrintJobWorkerOwner> owner,
- base::OnceClosure callback) {
+// Helper function to ensure |job| is valid until at least |callback| returns.
+void HoldRefCallback(scoped_refptr<PrintJob> job, base::OnceClosure callback) {
std::move(callback).Run();
}
PrintJob::PrintJob()
- : is_job_pending_(false), is_canceling_(false), quit_factory_(this) {
+ : is_job_pending_(false),
+ is_canceling_(false),
+ task_runner_(base::ThreadTaskRunnerHandle::Get()),
+ quit_factory_(this) {
DCHECK(base::MessageLoopForUI::IsCurrent());
}
@@ -51,19 +55,19 @@ PrintJob::~PrintJob() {
DCHECK(RunsTasksInCurrentSequence());
}
-void PrintJob::Initialize(PrintJobWorkerOwner* job,
+void PrintJob::Initialize(PrinterQuery* query,
const base::string16& name,
int page_count) {
DCHECK(!worker_);
DCHECK(!is_job_pending_);
DCHECK(!is_canceling_);
- DCHECK(!document_.get());
- worker_ = job->DetachWorker(this);
- settings_ = job->settings();
-
- PrintedDocument* new_doc =
- new PrintedDocument(settings_, name, job->cookie());
+ DCHECK(!document_);
+ worker_ = query->DetachWorker();
+ worker_->SetPrintJob(this);
+ settings_ = query->settings();
+ auto new_doc =
+ base::MakeRefCounted<PrintedDocument>(settings_, name, query->cookie());
new_doc->set_page_count(page_count);
UpdatePrintedDocument(new_doc);
@@ -93,11 +97,37 @@ std::vector<int> PrintJob::GetFullPageMapping(const std::vector<int>& pages,
return mapping;
}
+void PrintJob::StartConversionToNativeFormat(
+ const scoped_refptr<base::RefCountedMemory>& print_data,
+ const gfx::Size& page_size,
+ const gfx::Rect& content_area,
+ const gfx::Point& physical_offsets) {
+ if (PrintedDocument::HasDebugDumpPath())
+ document()->DebugDumpData(print_data.get(), FILE_PATH_LITERAL(".pdf"));
+
+ if (settings_.printer_is_textonly()) {
+ StartPdfToTextConversion(print_data, page_size);
+ } else if ((settings_.printer_is_ps2() || settings_.printer_is_ps3()) &&
+ !base::FeatureList::IsEnabled(
+ features::kDisablePostScriptPrinting)) {
+ StartPdfToPostScriptConversion(print_data, content_area, physical_offsets,
+ settings_.printer_is_ps2());
+ } else {
+ StartPdfToEmfConversion(print_data, page_size, content_area);
+ }
+
+ // Indicate that the PDF is fully rendered and we no longer need the renderer
+ // and web contents, so the print job does not need to be cancelled if they
+ // die. This is needed on Windows because the PrintedDocument will not be
+ // considered complete until PDF conversion finishes.
+ document()->SetConvertingPdf();
+}
+
void PrintJob::ResetPageMapping() {
pdf_page_mapping_ =
GetFullPageMapping(pdf_page_mapping_, document_->page_count());
}
-#endif
+#endif // defined(OS_WIN)
void PrintJob::Observe(int type,
const content::NotificationSource& source,
@@ -108,28 +138,6 @@ void PrintJob::Observe(int type,
OnNotifyPrintJobEvent(*content::Details<JobEventDetails>(details).ptr());
}
-void PrintJob::GetSettingsDone(const PrintSettings& new_settings,
- PrintingContext::Result result) {
- NOTREACHED();
-}
-
-std::unique_ptr<PrintJobWorker> PrintJob::DetachWorker(
- PrintJobWorkerOwner* new_owner) {
- NOTREACHED();
- return nullptr;
-}
-
-const PrintSettings& PrintJob::settings() const {
- return settings_;
-}
-
-int PrintJob::cookie() const {
- // Always use an invalid cookie in this case.
- if (!document_.get())
- return 0;
- return document_->cookie();
-}
-
void PrintJob::StartPrinting() {
DCHECK(RunsTasksInCurrentSequence());
if (!worker_->IsRunning() || is_job_pending_) {
@@ -147,8 +155,8 @@ void PrintJob::StartPrinting() {
is_job_pending_ = true;
// Tell everyone!
- scoped_refptr<JobEventDetails> details(
- new JobEventDetails(JobEventDetails::NEW_DOC, 0, document_.get()));
+ auto details = base::MakeRefCounted<JobEventDetails>(JobEventDetails::NEW_DOC,
+ 0, document_.get());
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PRINT_JOB_EVENT,
content::Source<PrintJob>(this),
@@ -173,13 +181,14 @@ void PrintJob::Stop() {
} else {
// Flush the cached document.
is_job_pending_ = false;
- UpdatePrintedDocument(nullptr);
+ ClearPrintedDocument();
}
}
void PrintJob::Cancel() {
if (is_canceling_)
return;
+
is_canceling_ = true;
DCHECK(RunsTasksInCurrentSequence());
@@ -189,8 +198,8 @@ void PrintJob::Cancel() {
worker_->Cancel();
}
// Make sure a Cancel() is broadcast.
- scoped_refptr<JobEventDetails> details(
- new JobEventDetails(JobEventDetails::FAILED, 0, nullptr));
+ auto details = base::MakeRefCounted<JobEventDetails>(JobEventDetails::FAILED,
+ 0, nullptr);
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PRINT_JOB_EVENT,
content::Source<PrintJob>(this),
@@ -270,13 +279,21 @@ class PrintJob::PdfConversionState {
void PrintJob::StartPdfToEmfConversion(
const scoped_refptr<base::RefCountedMemory>& bytes,
const gfx::Size& page_size,
- const gfx::Rect& content_area,
- bool print_text_with_gdi) {
+ const gfx::Rect& content_area) {
DCHECK(!pdf_conversion_state_);
pdf_conversion_state_ =
std::make_unique<PdfConversionState>(page_size, content_area);
+
+ // TODO(thestig): Figure out why rendering text with GDI results in random
+ // missing characters for some users. https://crbug.com/658606
+ // Update : The missing letters seem to have been caused by the same
+ // problem as https://crbug.com/659604 which was resolved. GDI printing
+ // seems to work with the fix for this bug applied.
+ bool print_text_with_gdi =
+ settings_.print_text_with_gdi() && !settings_.printer_is_xps() &&
+ base::FeatureList::IsEnabled(features::kGdiTextPrinting);
PdfRenderSettings render_settings(
- content_area, gfx::Point(0, 0), settings().dpi_size(),
+ content_area, gfx::Point(0, 0), settings_.dpi_size(),
/*autorotate=*/true, settings_.color() == COLOR,
print_text_with_gdi ? PdfRenderSettings::Mode::GDI_TEXT
: PdfRenderSettings::Mode::NORMAL);
@@ -302,7 +319,7 @@ void PrintJob::OnPdfPageConverted(int page_number,
float scale_factor,
std::unique_ptr<MetafilePlayer> metafile) {
DCHECK(pdf_conversion_state_);
- if (!document_.get() || !metafile || page_number < 0 ||
+ if (!document_ || !metafile || page_number < 0 ||
static_cast<size_t>(page_number) >= pdf_page_mapping_.size()) {
// Be sure to live long enough.
scoped_refptr<PrintJob> handle(this);
@@ -332,7 +349,7 @@ void PrintJob::StartPdfToTextConversion(
std::make_unique<PdfConversionState>(gfx::Size(), gfx::Rect());
gfx::Rect page_area = gfx::Rect(0, 0, page_size.width(), page_size.height());
PdfRenderSettings render_settings(
- page_area, gfx::Point(0, 0), settings().dpi_size(),
+ page_area, gfx::Point(0, 0), settings_.dpi_size(),
/*autorotate=*/true,
/*use_color=*/true, PdfRenderSettings::Mode::TEXTONLY);
pdf_conversion_state_->Start(
@@ -349,7 +366,7 @@ void PrintJob::StartPdfToPostScriptConversion(
pdf_conversion_state_ = std::make_unique<PdfConversionState>(
gfx::Size(), gfx::Rect());
PdfRenderSettings render_settings(
- content_area, physical_offsets, settings().dpi_size(),
+ content_area, physical_offsets, settings_.dpi_size(),
/*autorotate=*/true, settings_.color() == COLOR,
ps_level2 ? PdfRenderSettings::Mode::POSTSCRIPT_LEVEL2
: PdfRenderSettings::Mode::POSTSCRIPT_LEVEL3);
@@ -359,25 +376,33 @@ void PrintJob::StartPdfToPostScriptConversion(
}
#endif // defined(OS_WIN)
-void PrintJob::UpdatePrintedDocument(PrintedDocument* new_document) {
- if (document_.get() == new_document)
- return;
+void PrintJob::UpdatePrintedDocument(
+ scoped_refptr<PrintedDocument> new_document) {
+ DCHECK(new_document);
document_ = new_document;
+ if (worker_)
+ SyncPrintedDocumentToWorker();
+}
- if (document_.get())
- settings_ = document_->settings();
-
- if (worker_) {
- DCHECK(!is_job_pending_);
- // Sync the document with the worker.
- worker_->PostTask(
- FROM_HERE,
- base::BindOnce(&HoldRefCallback, base::WrapRefCounted(this),
- base::BindOnce(&PrintJobWorker::OnDocumentChanged,
- base::Unretained(worker_.get()),
- base::RetainedRef(document_))));
- }
+void PrintJob::ClearPrintedDocument() {
+ if (!document_)
+ return;
+
+ document_ = nullptr;
+ if (worker_)
+ SyncPrintedDocumentToWorker();
+}
+
+void PrintJob::SyncPrintedDocumentToWorker() {
+ DCHECK(worker_);
+ DCHECK(!is_job_pending_);
+ worker_->PostTask(
+ FROM_HERE,
+ base::BindOnce(&HoldRefCallback, base::WrapRefCounted(this),
+ base::BindOnce(&PrintJobWorker::OnDocumentChanged,
+ base::Unretained(worker_.get()),
+ base::RetainedRef(document_))));
}
void PrintJob::OnNotifyPrintJobEvent(const JobEventDetails& event_details) {
@@ -429,8 +454,8 @@ void PrintJob::OnDocumentDone() {
// Stop the worker thread.
Stop();
- scoped_refptr<JobEventDetails> details(
- new JobEventDetails(JobEventDetails::JOB_DONE, 0, document_.get()));
+ auto details = base::MakeRefCounted<JobEventDetails>(
+ JobEventDetails::JOB_DONE, 0, document_.get());
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PRINT_JOB_EVENT,
content::Source<PrintJob>(this),
@@ -476,7 +501,16 @@ void PrintJob::ControlledWorkerShutdown() {
is_job_pending_ = false;
registrar_.RemoveAll();
- UpdatePrintedDocument(nullptr);
+ ClearPrintedDocument();
+}
+
+bool PrintJob::RunsTasksInCurrentSequence() const {
+ return task_runner_->RunsTasksInCurrentSequence();
+}
+
+bool PrintJob::PostTask(const base::Location& from_here,
+ base::OnceClosure task) {
+ return task_runner_->PostTask(from_here, std::move(task));
}
void PrintJob::HoldUntilStopIsCalled() {
diff --git a/chromium/chrome/browser/printing/print_job.h b/chromium/chrome/browser/printing/print_job.h
index 3a5ca0ae61b..a8fdec34ca6 100644
--- a/chromium/chrome/browser/printing/print_job.h
+++ b/chromium/chrome/browser/printing/print_job.h
@@ -10,14 +10,17 @@
#include "base/gtest_prod_util.h"
#include "base/macros.h"
+#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "build/build_config.h"
-#include "chrome/browser/printing/print_job_worker_owner.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
+#include "printing/print_settings.h"
namespace base {
+class Location;
class RefCountedMemory;
+class SequencedTaskRunner;
}
namespace printing {
@@ -25,15 +28,12 @@ namespace printing {
class JobEventDetails;
class MetafilePlayer;
class PrintJobWorker;
-class PrintJobWorkerOwner;
class PrintedDocument;
#if defined(OS_WIN)
class PrintedPage;
#endif
class PrinterQuery;
-
-void HoldRefCallback(scoped_refptr<PrintJobWorkerOwner> owner,
- base::OnceClosure callback);
+class PrintSettings;
// Manages the print work for a specific document. Talks to the printer through
// PrintingContext through PrintJobWorker. Hides access to PrintingContext in a
@@ -42,20 +42,27 @@ void HoldRefCallback(scoped_refptr<PrintJobWorkerOwner> owner,
// reference to the job to be sure it is kept alive. All the code in this class
// runs in the UI thread. All virtual functions are virtual only so that
// TestPrintJob can override them in tests.
-class PrintJob : public PrintJobWorkerOwner,
+class PrintJob : public base::RefCountedThreadSafe<PrintJob>,
public content::NotificationObserver {
public:
// Create a empty PrintJob. When initializing with this constructor,
// post-constructor initialization must be done with Initialize().
PrintJob();
- // Grabs the ownership of the PrintJobWorker from another job, which is
- // usually a PrinterQuery. Set the expected page count of the print job.
- virtual void Initialize(PrintJobWorkerOwner* job,
+ // Grabs the ownership of the PrintJobWorker from a PrinterQuery along with
+ // the print settings. Sets the expected page count of the print job based on
+ // the settings.
+ virtual void Initialize(PrinterQuery* query,
const base::string16& name,
int page_count);
#if defined(OS_WIN)
+ void StartConversionToNativeFormat(
+ const scoped_refptr<base::RefCountedMemory>& print_data,
+ const gfx::Size& page_size,
+ const gfx::Rect& content_area,
+ const gfx::Point& physical_offsets);
+
// Overwrites the PDF page mapping to fill in values of -1 for all indices
// that are not selected. This is needed when the user opens the system
// dialog from the link in Print Preview on Windows and then sets a selection
@@ -69,14 +76,6 @@ class PrintJob : public PrintJobWorkerOwner,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
- // PrintJobWorkerOwner implementation.
- void GetSettingsDone(const PrintSettings& new_settings,
- PrintingContext::Result result) override;
- std::unique_ptr<PrintJobWorker> DetachWorker(
- PrintJobWorkerOwner* new_owner) override;
- const PrintSettings& settings() const override;
- int cookie() const override;
-
// Starts the actual printing. Signals the worker that it should begin to
// spool as soon as data is available.
virtual void StartPrinting();
@@ -105,25 +104,17 @@ class PrintJob : public PrintJobWorkerOwner,
// Access the current printed document. Warning: may be NULL.
PrintedDocument* document() const;
-#if defined(OS_WIN)
- virtual void StartPdfToEmfConversion(
- const scoped_refptr<base::RefCountedMemory>& bytes,
- const gfx::Size& page_size,
- const gfx::Rect& content_area,
- bool print_text_with_gdi);
-
- virtual void StartPdfToPostScriptConversion(
- const scoped_refptr<base::RefCountedMemory>& bytes,
- const gfx::Rect& content_area,
- const gfx::Point& physical_offset,
- bool ps_level2);
+ // Returns true if tasks posted to this TaskRunner are sequenced
+ // with this call.
+ bool RunsTasksInCurrentSequence() const;
- virtual void StartPdfToTextConversion(
- const scoped_refptr<base::RefCountedMemory>& bytes,
- const gfx::Size& page_size);
-#endif // defined(OS_WIN)
+ // Posts the given task to be run.
+ bool PostTask(const base::Location& from_here, base::OnceClosure task);
protected:
+ // Refcounted class.
+ friend class base::RefCountedThreadSafe<PrintJob>;
+
~PrintJob() override;
// The functions below are used for tests only.
@@ -132,13 +123,20 @@ class PrintJob : public PrintJobWorkerOwner,
// Updates |document_| to a new instance. Protected so that tests can access
// it.
- void UpdatePrintedDocument(PrintedDocument* new_document);
+ void UpdatePrintedDocument(scoped_refptr<PrintedDocument> new_document);
private:
#if defined(OS_WIN)
FRIEND_TEST_ALL_PREFIXES(PrintJobTest, PageRangeMapping);
#endif
+ // Clears reference to |document_|.
+ void ClearPrintedDocument();
+
+ // Helper method for UpdatePrintedDocument() and ClearPrintedDocument() to
+ // sync |document_| updates with |worker_|.
+ void SyncPrintedDocumentToWorker();
+
// Processes a NOTIFY_PRINT_JOB_EVENT notification.
void OnNotifyPrintJobEvent(const JobEventDetails& event_details);
@@ -156,6 +154,21 @@ class PrintJob : public PrintJobWorkerOwner,
void HoldUntilStopIsCalled();
#if defined(OS_WIN)
+ virtual void StartPdfToEmfConversion(
+ const scoped_refptr<base::RefCountedMemory>& bytes,
+ const gfx::Size& page_size,
+ const gfx::Rect& content_area);
+
+ virtual void StartPdfToPostScriptConversion(
+ const scoped_refptr<base::RefCountedMemory>& bytes,
+ const gfx::Rect& content_area,
+ const gfx::Point& physical_offsets,
+ bool ps_level2);
+
+ virtual void StartPdfToTextConversion(
+ const scoped_refptr<base::RefCountedMemory>& bytes,
+ const gfx::Size& page_size);
+
void OnPdfConversionStarted(int page_count);
void OnPdfPageConverted(int page_number,
float scale_factor,
@@ -192,6 +205,10 @@ class PrintJob : public PrintJobWorkerOwner,
std::vector<int> pdf_page_mapping_;
#endif // defined(OS_WIN)
+ // Task runner reference. Used to send notifications in the right
+ // thread.
+ scoped_refptr<base::SequencedTaskRunner> task_runner_;
+
// Used at shutdown so that we can quit a nested run loop.
base::WeakPtrFactory<PrintJob> quit_factory_;
diff --git a/chromium/chrome/browser/printing/print_job_manager.cc b/chromium/chrome/browser/printing/print_job_manager.cc
index 4488eb6ae10..218ce2b82ec 100644
--- a/chromium/chrome/browser/printing/print_job_manager.cc
+++ b/chromium/chrome/browser/printing/print_job_manager.cc
@@ -22,11 +22,11 @@ PrintQueriesQueue::~PrintQueriesQueue() {
queued_queries_.clear();
}
-void PrintQueriesQueue::QueuePrinterQuery(PrinterQuery* job) {
+void PrintQueriesQueue::QueuePrinterQuery(PrinterQuery* query) {
base::AutoLock lock(lock_);
- DCHECK(job);
- queued_queries_.push_back(base::WrapRefCounted(job));
- DCHECK(job->is_valid());
+ DCHECK(query);
+ queued_queries_.push_back(base::WrapRefCounted(query));
+ DCHECK(query->is_valid());
}
scoped_refptr<PrinterQuery> PrintQueriesQueue::PopPrinterQuery(
diff --git a/chromium/chrome/browser/printing/print_job_manager.h b/chromium/chrome/browser/printing/print_job_manager.h
index b22022b2cf5..285accbb8d0 100644
--- a/chromium/chrome/browser/printing/print_job_manager.h
+++ b/chromium/chrome/browser/printing/print_job_manager.h
@@ -29,10 +29,10 @@ class PrintQueriesQueue : public base::RefCountedThreadSafe<PrintQueriesQueue> {
// Queues a semi-initialized worker thread. Can be called from any thread.
// Current use case is queuing from the I/O thread.
// TODO(maruel): Have them vanish after a timeout (~5 minutes?)
- void QueuePrinterQuery(PrinterQuery* job);
+ void QueuePrinterQuery(PrinterQuery* query);
- // Pops a queued PrintJobWorkerOwner object that was previously queued or
- // create new one. Can be called from any thread.
+ // Pops a queued PrinterQuery object that was previously queued or creates
+ // a new one. Can be called from any thread.
scoped_refptr<PrinterQuery> PopPrinterQuery(int document_cookie);
// Creates new query. Virtual so that tests can override it.
diff --git a/chromium/chrome/browser/printing/print_job_unittest.cc b/chromium/chrome/browser/printing/print_job_unittest.cc
index 1a47aa3acab..34222c6db16 100644
--- a/chromium/chrome/browser/printing/print_job_unittest.cc
+++ b/chromium/chrome/browser/printing/print_job_unittest.cc
@@ -13,6 +13,7 @@
#include "build/build_config.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/printing/print_job_worker.h"
+#include "chrome/browser/printing/printer_query.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_service.h"
#include "content/public/common/child_process_host.h"
@@ -25,43 +26,48 @@ namespace {
class TestPrintJobWorker : public PrintJobWorker {
public:
- explicit TestPrintJobWorker(PrintJobWorkerOwner* owner)
+ explicit TestPrintJobWorker(PrinterQuery* query)
: PrintJobWorker(content::ChildProcessHost::kInvalidUniqueID,
content::ChildProcessHost::kInvalidUniqueID,
- owner) {}
- friend class TestOwner;
+ query) {}
+ friend class TestQuery;
};
-class TestOwner : public PrintJobWorkerOwner {
+class TestQuery : public PrinterQuery {
public:
- TestOwner() {}
+ TestQuery()
+ : PrinterQuery(content::ChildProcessHost::kInvalidUniqueID,
+ content::ChildProcessHost::kInvalidUniqueID) {}
void GetSettingsDone(const PrintSettings& new_settings,
PrintingContext::Result result) override {
- EXPECT_FALSE(true);
+ FAIL();
}
- std::unique_ptr<PrintJobWorker> DetachWorker(
- PrintJobWorkerOwner* new_owner) override {
+ std::unique_ptr<PrintJobWorker> DetachWorker() override {
+ {
+ // Do an actual detach to keep the parent class happy.
+ auto real_worker = PrinterQuery::DetachWorker();
+ }
+
// We're screwing up here since we're calling worker from the main thread.
// That's fine for testing. It is actually simulating PrinterQuery behavior.
- auto worker = std::make_unique<TestPrintJobWorker>(new_owner);
+ auto worker = std::make_unique<TestPrintJobWorker>(this);
EXPECT_TRUE(worker->Start());
worker->printing_context()->UseDefaultSettings();
settings_ = worker->printing_context()->settings();
+
return std::move(worker);
}
const PrintSettings& settings() const override { return settings_; }
- int cookie() const override { return 42; }
-
private:
- ~TestOwner() override {}
+ ~TestQuery() override {}
PrintSettings settings_;
- DISALLOW_COPY_AND_ASSIGN(TestOwner);
+ DISALLOW_COPY_AND_ASSIGN(TestQuery);
};
class TestPrintJob : public PrintJob {
@@ -97,8 +103,8 @@ TEST(PrintJobTest, SimplePrint) {
volatile bool check = false;
scoped_refptr<PrintJob> job(new TestPrintJob(&check));
EXPECT_TRUE(job->RunsTasksInCurrentSequence());
- scoped_refptr<TestOwner> owner(new TestOwner);
- job->Initialize(owner.get(), base::string16(), 1);
+ scoped_refptr<TestQuery> query = base::MakeRefCounted<TestQuery>();
+ job->Initialize(query.get(), base::string16(), 1);
job->Stop();
while (job->document()) {
base::RunLoop().RunUntilIdle();
diff --git a/chromium/chrome/browser/printing/print_job_worker.cc b/chromium/chrome/browser/printing/print_job_worker.cc
index da87d60520c..1065e808e62 100644
--- a/chromium/chrome/browser/printing/print_job_worker.cc
+++ b/chromium/chrome/browser/printing/print_job_worker.cc
@@ -13,7 +13,6 @@
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/location.h"
-#include "base/message_loop/message_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
@@ -90,7 +89,7 @@ std::string PrintingContextDelegate::GetAppLocale() {
return g_browser_process->GetApplicationLocale();
}
-void NotificationCallback(PrintJobWorkerOwner* print_job,
+void NotificationCallback(PrintJob* print_job,
JobEventDetails::Type detail_type,
int job_id,
PrintedDocument* document) {
@@ -98,21 +97,26 @@ void NotificationCallback(PrintJobWorkerOwner* print_job,
base::MakeRefCounted<JobEventDetails>(detail_type, job_id, document);
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PRINT_JOB_EVENT,
- // We know that is is a PrintJob object in this circumstance.
- content::Source<PrintJob>(static_cast<PrintJob*>(print_job)),
+ content::Source<PrintJob>(print_job),
content::Details<JobEventDetails>(details.get()));
}
-void PostOnOwnerThread(scoped_refptr<PrintJobWorkerOwner> owner,
+// Helper function to ensure |query| is valid until at least |callback| returns.
+void WorkerHoldRefCallback(scoped_refptr<PrinterQuery> query,
+ base::OnceClosure callback) {
+ std::move(callback).Run();
+}
+
+void PostOnQueryThread(scoped_refptr<PrinterQuery> query,
PrintingContext::PrintSettingsCallback callback,
PrintingContext::Result result) {
- owner->PostTask(FROM_HERE,
- base::BindOnce(&HoldRefCallback, owner,
+ query->PostTask(FROM_HERE,
+ base::BindOnce(&WorkerHoldRefCallback, query,
base::BindOnce(std::move(callback), result)));
}
#if defined(OS_WIN)
-void PageNotificationCallback(PrintJobWorkerOwner* print_job,
+void PageNotificationCallback(PrintJob* print_job,
JobEventDetails::Type detail_type,
int job_id,
PrintedDocument* document,
@@ -121,8 +125,7 @@ void PageNotificationCallback(PrintJobWorkerOwner* print_job,
document, page);
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PRINT_JOB_EVENT,
- // We know that is is a PrintJob object in this circumstance.
- content::Source<PrintJob>(static_cast<PrintJob*>(print_job)),
+ content::Source<PrintJob>(print_job),
content::Details<JobEventDetails>(details.get()));
}
#endif
@@ -131,30 +134,39 @@ void PageNotificationCallback(PrintJobWorkerOwner* print_job,
PrintJobWorker::PrintJobWorker(int render_process_id,
int render_frame_id,
- PrintJobWorkerOwner* owner)
+ PrinterQuery* query)
: printing_context_delegate_(
std::make_unique<PrintingContextDelegate>(render_process_id,
render_frame_id)),
printing_context_(
PrintingContext::Create(printing_context_delegate_.get())),
- owner_(owner),
+ query_(query),
thread_("Printing_Worker"),
weak_factory_(this) {
// The object is created in the IO thread.
- DCHECK(owner_->RunsTasksInCurrentSequence());
+ DCHECK(query_->RunsTasksInCurrentSequence());
}
PrintJobWorker::~PrintJobWorker() {
- // The object is normally deleted in the UI thread, but when the user
- // cancels printing or in the case of print preview, the worker is destroyed
- // on the I/O thread.
- DCHECK(owner_->RunsTasksInCurrentSequence());
+ // The object is normally deleted by PrintJob in the UI thread, but when the
+ // user cancels printing or in the case of print preview, the worker is
+ // destroyed with the PrinterQuery, which is on the I/O thread.
+ if (query_) {
+ DCHECK(!print_job_);
+ DCHECK(query_->RunsTasksInCurrentSequence());
+ } else {
+ DCHECK(print_job_);
+ DCHECK(print_job_->RunsTasksInCurrentSequence());
+ }
Stop();
}
-void PrintJobWorker::SetNewOwner(PrintJobWorkerOwner* new_owner) {
- DCHECK(page_number_ == PageNumber::npos());
- owner_ = new_owner;
+void PrintJobWorker::SetPrintJob(PrintJob* print_job) {
+ DCHECK_EQ(page_number_, PageNumber::npos());
+ print_job_ = print_job;
+
+ // Release the Printer Query reference. It is no longer needed.
+ query_ = nullptr;
}
void PrintJobWorker::GetSettings(bool ask_user_for_settings,
@@ -166,12 +178,15 @@ void PrintJobWorker::GetSettings(bool ask_user_for_settings,
DCHECK(task_runner_->RunsTasksInCurrentSequence());
DCHECK_EQ(page_number_, PageNumber::npos());
+ // This function is only called by the PrinterQuery.
+ DCHECK(query_);
+
// Recursive task processing is needed for the dialog in case it needs to be
// destroyed by a task.
// TODO(thestig): This code is wrong. SetNestableTasksAllowed(true) is needed
// on the thread where the PrintDlgEx is called, and definitely both calls
// should happen on the same thread. See http://crbug.com/73466
- // MessageLoop::current()->SetNestableTasksAllowed(true);
+ // MessageLoopCurrent::Get()->SetNestableTasksAllowed(true);
printing_context_->set_margin_type(margin_type);
printing_context_->set_is_modifiable(is_modifiable);
@@ -181,14 +196,14 @@ void PrintJobWorker::GetSettings(bool ask_user_for_settings,
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::BindOnce(
- &HoldRefCallback, base::WrapRefCounted(owner_),
+ &WorkerHoldRefCallback, base::WrapRefCounted(query_),
base::BindOnce(&PrintJobWorker::GetSettingsWithUI,
base::Unretained(this), document_page_count,
has_selection, is_scripted)));
} else {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- base::BindOnce(&HoldRefCallback, base::WrapRefCounted(owner_),
+ base::BindOnce(&WorkerHoldRefCallback, base::WrapRefCounted(query_),
base::BindOnce(&PrintJobWorker::UseDefaultSettings,
base::Unretained(this))));
}
@@ -197,11 +212,12 @@ void PrintJobWorker::GetSettings(bool ask_user_for_settings,
void PrintJobWorker::SetSettings(
std::unique_ptr<base::DictionaryValue> new_settings) {
DCHECK(task_runner_->RunsTasksInCurrentSequence());
+ DCHECK(query_);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::BindOnce(
- &HoldRefCallback, base::WrapRefCounted(owner_),
+ &WorkerHoldRefCallback, base::WrapRefCounted(query_),
base::BindOnce(&PrintJobWorker::UpdatePrintSettings,
base::Unretained(this), std::move(new_settings))));
}
@@ -210,11 +226,12 @@ void PrintJobWorker::SetSettings(
void PrintJobWorker::SetSettingsFromPOD(
std::unique_ptr<printing::PrintSettings> new_settings) {
DCHECK(task_runner_->RunsTasksInCurrentSequence());
+ DCHECK(query_);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::BindOnce(
- &HoldRefCallback, base::WrapRefCounted(owner_),
+ &WorkerHoldRefCallback, base::WrapRefCounted(query_),
base::BindOnce(&PrintJobWorker::UpdatePrintSettingsFromPOD,
base::Unretained(this), std::move(new_settings))));
}
@@ -244,14 +261,14 @@ void PrintJobWorker::GetSettingsDone(PrintingContext::Result result) {
// TODO(thestig): See above comment. SetNestableTasksAllowed(false) needs to
// be called on the same thread as the previous call. See
// http://crbug.com/73466
- // MessageLoop::current()->SetNestableTasksAllowed(false);
+ // MessageLoopCurrent::Get()->SetNestableTasksAllowed(false);
- // We can't use OnFailure() here since owner_ may not support notifications.
+ // We can't use OnFailure() here since query_ does not support notifications.
- // PrintJob will create the new PrintedDocument.
- owner_->PostTask(FROM_HERE,
- base::BindOnce(&PrintJobWorkerOwner::GetSettingsDone,
- base::WrapRefCounted(owner_),
+ DCHECK(query_);
+ query_->PostTask(FROM_HERE,
+ base::BindOnce(&PrinterQuery::GetSettingsDone,
+ base::WrapRefCounted(query_),
printing_context_->settings(), result));
}
@@ -286,10 +303,10 @@ void PrintJobWorker::GetSettingsWithUI(
if (web_contents && web_contents->IsFullscreenForCurrentTab())
web_contents->ExitFullscreen(true);
- // weak_factory_ creates pointers valid only on owner_ thread.
+ // weak_factory_ creates pointers valid only on query_ thread.
printing_context_->AskUserForSettings(
document_page_count, has_selection, is_scripted,
- base::BindOnce(&PostOnOwnerThread, base::WrapRefCounted(owner_),
+ base::BindOnce(&PostOnQueryThread, base::WrapRefCounted(query_),
base::BindOnce(&PrintJobWorker::GetSettingsDone,
weak_factory_.GetWeakPtr())));
}
@@ -301,12 +318,19 @@ void PrintJobWorker::UseDefaultSettings() {
void PrintJobWorker::StartPrinting(PrintedDocument* new_document) {
DCHECK(task_runner_->RunsTasksInCurrentSequence());
- DCHECK_EQ(page_number_, PageNumber::npos());
- DCHECK_EQ(document_.get(), new_document);
- DCHECK(document_.get());
- if (!document_.get() || page_number_ != PageNumber::npos() ||
- document_.get() != new_document) {
+ if (page_number_ != PageNumber::npos()) {
+ NOTREACHED();
+ return;
+ }
+
+ if (!document_) {
+ NOTREACHED();
+ return;
+ }
+
+ if (document_.get() != new_document) {
+ NOTREACHED();
return;
}
@@ -332,10 +356,11 @@ void PrintJobWorker::StartPrinting(PrintedDocument* new_document) {
void PrintJobWorker::OnDocumentChanged(PrintedDocument* new_document) {
DCHECK(task_runner_->RunsTasksInCurrentSequence());
- DCHECK_EQ(page_number_, PageNumber::npos());
- if (page_number_ != PageNumber::npos())
+ if (page_number_ != PageNumber::npos()) {
+ NOTREACHED();
return;
+ }
document_ = new_document;
}
@@ -348,62 +373,47 @@ void PrintJobWorker::PostWaitForPage() {
base::TimeDelta::FromMilliseconds(500));
}
-#if defined(OS_WIN)
void PrintJobWorker::OnNewPage() {
- if (!document_.get()) // Spurious message.
- return;
-
- // message_loop() could return NULL when the print job is cancelled.
DCHECK(task_runner_->RunsTasksInCurrentSequence());
+ if (!document_)
+ return;
+
+#if defined(OS_WIN)
if (page_number_ == PageNumber::npos()) {
// Find first page to print.
int page_count = document_->page_count();
if (!page_count) {
- // We still don't know how many pages the document contains. We can't
- // start to print the document yet since the header/footer may refer to
- // the document's page count.
+ // We still don't know how many pages the document contains.
return;
}
- // We have enough information to initialize page_number_.
+ // We have enough information to initialize |page_number_|.
page_number_.Init(document_->settings(), page_count);
}
- DCHECK_NE(page_number_, PageNumber::npos());
while (true) {
scoped_refptr<PrintedPage> page = document_->GetPage(page_number_.ToInt());
- if (!page.get()) {
+ if (!page) {
PostWaitForPage();
- break;
+ return;
}
// The page is there, print it.
SpoolPage(page.get());
++page_number_;
- if (page_number_ == PageNumber::npos()) {
- OnDocumentDone();
- // Don't touch this anymore since the instance could be destroyed.
+ if (page_number_ == PageNumber::npos())
break;
- }
}
-}
#else
-void PrintJobWorker::OnNewPage() {
- if (!document_.get()) // Spurious message.
- return;
-
- // message_loop() could return NULL when the print job is cancelled.
- DCHECK(task_runner_->RunsTasksInCurrentSequence());
-
- const MetafilePlayer* metafile = document_->GetMetafile();
- if (!metafile) {
+ if (!document_->GetMetafile()) {
PostWaitForPage();
return;
}
SpoolJob();
- // Don't touch this anymore since the instance could be destroyed.
+#endif // defined(OS_WIN)
+
OnDocumentDone();
+ // Don't touch |this| anymore since the instance could be destroyed.
}
-#endif // defined(OS_WIN)
void PrintJobWorker::Cancel() {
// This is the only function that can be called from any thread.
@@ -418,9 +428,7 @@ bool PrintJobWorker::IsRunning() const {
bool PrintJobWorker::PostTask(const base::Location& from_here,
base::OnceClosure task) {
- if (task_runner_.get())
- return task_runner_->PostTask(from_here, std::move(task));
- return false;
+ return task_runner_ && task_runner_->PostTask(from_here, std::move(task));
}
void PrintJobWorker::StopSoon() {
@@ -440,7 +448,9 @@ bool PrintJobWorker::Start() {
void PrintJobWorker::OnDocumentDone() {
DCHECK(task_runner_->RunsTasksInCurrentSequence());
DCHECK_EQ(page_number_, PageNumber::npos());
- DCHECK(document_.get());
+ DCHECK(document_);
+ // PrintJob must own this, because only PrintJob can send notifications.
+ DCHECK(print_job_);
int job_id = printing_context_->job_id();
if (printing_context_->DocumentDone() != PrintingContext::OK) {
@@ -448,13 +458,14 @@ void PrintJobWorker::OnDocumentDone() {
return;
}
- owner_->PostTask(FROM_HERE, base::BindOnce(&NotificationCallback,
- base::RetainedRef(owner_),
- JobEventDetails::DOC_DONE, job_id,
- base::RetainedRef(document_)));
+ print_job_->PostTask(
+ FROM_HERE,
+ base::BindOnce(&NotificationCallback, base::RetainedRef(print_job_),
+ JobEventDetails::DOC_DONE, job_id,
+ base::RetainedRef(document_)));
// Makes sure the variables are reinitialized.
- document_ = NULL;
+ document_ = nullptr;
}
#if defined(OS_WIN)
@@ -478,11 +489,12 @@ void PrintJobWorker::SpoolPage(PrintedPage* page) {
}
// Signal everyone that the page is printed.
- owner_->PostTask(FROM_HERE,
- base::BindRepeating(
- &PageNotificationCallback, base::RetainedRef(owner_),
- JobEventDetails::PAGE_DONE, printing_context_->job_id(),
- base::RetainedRef(document_), base::RetainedRef(page)));
+ DCHECK(print_job_);
+ print_job_->PostTask(
+ FROM_HERE, base::BindRepeating(
+ &PageNotificationCallback, base::RetainedRef(print_job_),
+ JobEventDetails::PAGE_DONE, printing_context_->job_id(),
+ base::RetainedRef(document_), base::RetainedRef(page)));
}
#else
void PrintJobWorker::SpoolJob() {
@@ -494,18 +506,19 @@ void PrintJobWorker::SpoolJob() {
void PrintJobWorker::OnFailure() {
DCHECK(task_runner_->RunsTasksInCurrentSequence());
+ DCHECK(print_job_);
// We may loose our last reference by broadcasting the FAILED event.
- scoped_refptr<PrintJobWorkerOwner> handle(owner_);
+ scoped_refptr<PrintJob> handle(print_job_);
- owner_->PostTask(
+ print_job_->PostTask(
FROM_HERE,
- base::BindOnce(&NotificationCallback, base::RetainedRef(owner_),
+ base::BindOnce(&NotificationCallback, base::RetainedRef(print_job_),
JobEventDetails::FAILED, 0, base::RetainedRef(document_)));
Cancel();
// Makes sure the variables are reinitialized.
- document_ = NULL;
+ document_ = nullptr;
page_number_ = PageNumber::npos();
}
diff --git a/chromium/chrome/browser/printing/print_job_worker.h b/chromium/chrome/browser/printing/print_job_worker.h
index 4ad10b420a8..182f7563e0c 100644
--- a/chromium/chrome/browser/printing/print_job_worker.h
+++ b/chromium/chrome/browser/printing/print_job_worker.h
@@ -25,9 +25,9 @@ class DictionaryValue;
namespace printing {
class PrintJob;
-class PrintJobWorkerOwner;
class PrintedDocument;
class PrintedPage;
+class PrinterQuery;
// Worker thread code. It manages the PrintingContext, which can be blocking
// and/or run a message loop. This is the object that generates most
@@ -38,10 +38,12 @@ class PrintJobWorker {
public:
PrintJobWorker(int render_process_id,
int render_frame_id,
- PrintJobWorkerOwner* owner);
+ PrinterQuery* query);
virtual ~PrintJobWorker();
- void SetNewOwner(PrintJobWorkerOwner* new_owner);
+ void SetPrintJob(PrintJob* print_job);
+
+ /* The following functions may only be called before calling SetPrintJob(). */
// Initializes the print settings. If |ask_user_for_settings| is true, a
// Print... dialog box will be shown to ask the user their preference.
@@ -63,6 +65,8 @@ class PrintJobWorker {
std::unique_ptr<printing::PrintSettings> new_settings);
#endif
+ /* The following functions may only be called after calling SetPrintJob(). */
+
// Starts the printing loop. Every pages are printed as soon as the data is
// available. Makes sure the new_document is the right one.
void StartPrinting(PrintedDocument* new_document);
@@ -75,7 +79,9 @@ class PrintJobWorker {
// the next page can be printed.
void OnNewPage();
- // This is the only function that can be called in a thread.
+ /* The following functions may be called before or after SetPrintJob(). */
+
+ // Cancels the job.
void Cancel();
// Returns true if the thread has been started, and not yet stopped.
@@ -141,7 +147,7 @@ class PrintJobWorker {
std::unique_ptr<printing::PrintSettings> new_settings);
#endif
- // Reports settings back to owner_.
+ // Reports settings back to |query_|.
void GetSettingsDone(PrintingContext::Result result);
// Use the default settings. When using GTK+ or Mac, this can still end up
@@ -158,9 +164,13 @@ class PrintJobWorker {
// The printed document. Only has read-only access.
scoped_refptr<PrintedDocument> document_;
+ // The printer query that owns this worker thread at creation. It will own
+ // the object until DetachWorker() is called.
+ PrinterQuery* query_ = nullptr;
+
// The print job owning this worker thread. It is guaranteed to outlive this
- // object.
- PrintJobWorkerOwner* owner_;
+ // object and should be set with SetPrintJob().
+ PrintJob* print_job_ = nullptr;
// Current page number to print.
PageNumber page_number_;
diff --git a/chromium/chrome/browser/printing/print_job_worker_owner.cc b/chromium/chrome/browser/printing/print_job_worker_owner.cc
deleted file mode 100644
index decac596362..00000000000
--- a/chromium/chrome/browser/printing/print_job_worker_owner.cc
+++ /dev/null
@@ -1,28 +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/printing/print_job_worker_owner.h"
-
-#include "base/location.h"
-#include "base/single_thread_task_runner.h"
-#include "base/threading/thread_task_runner_handle.h"
-
-namespace printing {
-
-PrintJobWorkerOwner::PrintJobWorkerOwner()
- : task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
-
-PrintJobWorkerOwner::~PrintJobWorkerOwner() {
-}
-
-bool PrintJobWorkerOwner::RunsTasksInCurrentSequence() const {
- return task_runner_->RunsTasksInCurrentSequence();
-}
-
-bool PrintJobWorkerOwner::PostTask(const base::Location& from_here,
- base::OnceClosure task) {
- return task_runner_->PostTask(from_here, std::move(task));
-}
-
-} // namespace printing
diff --git a/chromium/chrome/browser/printing/print_job_worker_owner.h b/chromium/chrome/browser/printing/print_job_worker_owner.h
deleted file mode 100644
index 8625ac71be3..00000000000
--- a/chromium/chrome/browser/printing/print_job_worker_owner.h
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (c) 2011 The Chromium 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_PRINTING_PRINT_JOB_WORKER_OWNER_H__
-#define CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_OWNER_H__
-
-#include <memory>
-
-#include "base/memory/ref_counted.h"
-#include "printing/printing_context.h"
-
-namespace base {
-class Location;
-class SequencedTaskRunner;
-}
-
-namespace printing {
-
-class PrintJobWorker;
-class PrintSettings;
-
-class PrintJobWorkerOwner
- : public base::RefCountedThreadSafe<PrintJobWorkerOwner> {
- public:
- // Can only be called in single-threaded context.
- PrintJobWorkerOwner();
-
- // Finishes the initialization began by PrintJobWorker::GetSettings().
- // Creates a new PrintedDocument if necessary. Solely meant to be called by
- // PrintJobWorker.
- virtual void GetSettingsDone(const PrintSettings& new_settings,
- PrintingContext::Result result) = 0;
-
- // Detach the PrintJobWorker associated to this object.
- virtual std::unique_ptr<PrintJobWorker> DetachWorker(
- PrintJobWorkerOwner* new_owner) = 0;
-
- // Access the current settings.
- virtual const PrintSettings& settings() const = 0;
-
- // Cookie uniquely identifying the PrintedDocument and/or loaded settings.
- virtual int cookie() const = 0;
-
- // Returns true if tasks posted to this TaskRunner are sequenced
- // with this call.
- bool RunsTasksInCurrentSequence() const;
-
- // Posts the given task to be run.
- bool PostTask(const base::Location& from_here, base::OnceClosure task);
-
- protected:
- friend class base::RefCountedThreadSafe<PrintJobWorkerOwner>;
-
- virtual ~PrintJobWorkerOwner();
-
- // Task runner reference. Used to send notifications in the right
- // thread.
- scoped_refptr<base::SequencedTaskRunner> task_runner_;
-};
-
-} // namespace printing
-
-#endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_OWNER_H__
diff --git a/chromium/chrome/browser/printing/print_preview_data_service.cc b/chromium/chrome/browser/printing/print_preview_data_service.cc
index 98b3266c27c..7c4605b2b92 100644
--- a/chromium/chrome/browser/printing/print_preview_data_service.cc
+++ b/chromium/chrome/browser/printing/print_preview_data_service.cc
@@ -53,15 +53,6 @@ class PrintPreviewDataStore {
page_data_map_[index] = std::move(data);
}
- // Returns the available draft page count.
- int GetAvailableDraftPageCount() const {
- int page_data_map_size = page_data_map_.size();
- if (base::ContainsKey(page_data_map_,
- printing::COMPLETE_PREVIEW_DOCUMENT_INDEX))
- page_data_map_size--;
- return page_data_map_size;
- }
-
private:
// 1:1 relationship between page index and its associated preview data.
// Key: Page index is zero-based and can be
@@ -115,10 +106,3 @@ void PrintPreviewDataService::SetDataEntry(
void PrintPreviewDataService::RemoveEntry(int32_t preview_ui_id) {
data_store_map_.erase(preview_ui_id);
}
-
-int PrintPreviewDataService::GetAvailableDraftPageCount(
- int32_t preview_ui_id) const {
- PreviewDataStoreMap::const_iterator it = data_store_map_.find(preview_ui_id);
- return (it == data_store_map_.end()) ?
- 0 : it->second->GetAvailableDraftPageCount();
-}
diff --git a/chromium/chrome/browser/printing/print_preview_data_service.h b/chromium/chrome/browser/printing/print_preview_data_service.h
index d1339276912..d55251aef02 100644
--- a/chromium/chrome/browser/printing/print_preview_data_service.h
+++ b/chromium/chrome/browser/printing/print_preview_data_service.h
@@ -48,9 +48,6 @@ class PrintPreviewDataService {
// Remove the corresponding PrintPreviewUI entry from the map.
void RemoveEntry(int32_t preview_ui_id);
- // Returns the available draft page count.
- int GetAvailableDraftPageCount(int32_t preview_ui_id) const;
-
private:
friend struct base::DefaultSingletonTraits<PrintPreviewDataService>;
diff --git a/chromium/chrome/browser/printing/print_preview_message_handler.cc b/chromium/chrome/browser/printing/print_preview_message_handler.cc
index 3e88490b371..e891e2733ff 100644
--- a/chromium/chrome/browser/printing/print_preview_message_handler.cc
+++ b/chromium/chrome/browser/printing/print_preview_message_handler.cc
@@ -24,8 +24,8 @@
#include "components/printing/browser/print_composite_client.h"
#include "components/printing/browser/print_manager_utils.h"
#include "components/printing/common/print_messages.h"
-#include "components/printing/service/public/cpp/pdf_service_mojo_types.h"
-#include "components/printing/service/public/cpp/pdf_service_mojo_utils.h"
+#include "components/services/pdf_compositor/public/cpp/pdf_service_mojo_types.h"
+#include "components/services/pdf_compositor/public/cpp/pdf_service_mojo_utils.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
@@ -268,28 +268,30 @@ void PrintPreviewMessageHandler::OnCompositePdfPageDone(
int page_number,
int request_id,
mojom::PdfCompositor::Status status,
- mojo::ScopedSharedBufferHandle handle) {
+ base::ReadOnlySharedMemoryRegion region) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (status != mojom::PdfCompositor::Status::SUCCESS) {
DLOG(ERROR) << "Compositing pdf failed with error " << status;
return;
}
- NotifyUIPreviewPageReady(page_number, request_id,
- GetDataFromMojoHandle(std::move(handle)));
+ NotifyUIPreviewPageReady(
+ page_number, request_id,
+ base::RefCountedSharedMemoryMapping::CreateFromWholeRegion(region));
}
void PrintPreviewMessageHandler::OnCompositePdfDocumentDone(
int page_count,
int request_id,
mojom::PdfCompositor::Status status,
- mojo::ScopedSharedBufferHandle handle) {
+ base::ReadOnlySharedMemoryRegion region) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (status != mojom::PdfCompositor::Status::SUCCESS) {
DLOG(ERROR) << "Compositing pdf failed with error " << status;
return;
}
- NotifyUIPreviewDocumentReady(page_count, request_id,
- GetDataFromMojoHandle(std::move(handle)));
+ NotifyUIPreviewDocumentReady(
+ page_count, request_id,
+ base::RefCountedSharedMemoryMapping::CreateFromWholeRegion(region));
}
bool PrintPreviewMessageHandler::OnMessageReceived(
diff --git a/chromium/chrome/browser/printing/print_preview_message_handler.h b/chromium/chrome/browser/printing/print_preview_message_handler.h
index 695cb7f5ebd..0c3938acc89 100644
--- a/chromium/chrome/browser/printing/print_preview_message_handler.h
+++ b/chromium/chrome/browser/printing/print_preview_message_handler.h
@@ -7,9 +7,10 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
+#include "base/memory/read_only_shared_memory_region.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/weak_ptr.h"
-#include "components/printing/service/public/interfaces/pdf_compositor.mojom.h"
+#include "components/services/pdf_compositor/public/interfaces/pdf_compositor.mojom.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
@@ -88,11 +89,11 @@ class PrintPreviewMessageHandler
void OnCompositePdfPageDone(int page_number,
int request_id,
mojom::PdfCompositor::Status status,
- mojo::ScopedSharedBufferHandle handle);
+ base::ReadOnlySharedMemoryRegion region);
void OnCompositePdfDocumentDone(int page_count,
int request_id,
mojom::PdfCompositor::Status status,
- mojo::ScopedSharedBufferHandle handle);
+ base::ReadOnlySharedMemoryRegion region);
base::WeakPtrFactory<PrintPreviewMessageHandler> weak_ptr_factory_;
diff --git a/chromium/chrome/browser/printing/print_test_utils.cc b/chromium/chrome/browser/printing/print_test_utils.cc
index e1670db877b..75826787db9 100644
--- a/chromium/chrome/browser/printing/print_test_utils.cc
+++ b/chromium/chrome/browser/printing/print_test_utils.cc
@@ -45,6 +45,7 @@ base::Value GetPrintTicket(PrinterType type, bool cloud) {
ticket.SetKey(kSettingPrintWithExtension, base::Value(is_extension_printer));
ticket.SetKey(kSettingRasterizePdf, base::Value(false));
ticket.SetKey(kSettingScaleFactor, base::Value(100));
+ ticket.SetKey(kSettingPagesPerSheet, base::Value(1));
ticket.SetKey(kSettingDpiHorizontal, base::Value(kTestPrinterDpi));
ticket.SetKey(kSettingDpiVertical, base::Value(kTestPrinterDpi));
ticket.SetKey(kSettingDeviceName, base::Value(kDummyPrinterName));
diff --git a/chromium/chrome/browser/printing/print_view_manager.cc b/chromium/chrome/browser/printing/print_view_manager.cc
index 916e9e54c13..482546828df 100644
--- a/chromium/chrome/browser/printing/print_view_manager.cc
+++ b/chromium/chrome/browser/printing/print_view_manager.cc
@@ -84,7 +84,6 @@ PrintViewManager::~PrintViewManager() {
DCHECK_EQ(NOT_PREVIEWING, print_preview_state_);
}
-#if BUILDFLAG(ENABLE_BASIC_PRINTING)
bool PrintViewManager::PrintForSystemDialogNow(
const base::Closure& dialog_shown_callback) {
DCHECK(!dialog_shown_callback.is_null());
@@ -111,7 +110,6 @@ bool PrintViewManager::BasicPrint(content::RenderFrameHost* rfh) {
return !!print_preview_dialog->GetWebUI();
}
-#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
bool PrintViewManager::PrintPreviewNow(content::RenderFrameHost* rfh,
bool has_selection) {
diff --git a/chromium/chrome/browser/printing/print_view_manager.h b/chromium/chrome/browser/printing/print_view_manager.h
index cee2e7b6550..51807693fce 100644
--- a/chromium/chrome/browser/printing/print_view_manager.h
+++ b/chromium/chrome/browser/printing/print_view_manager.h
@@ -23,7 +23,6 @@ class PrintViewManager : public PrintViewManagerBase,
public:
~PrintViewManager() override;
-#if BUILDFLAG(ENABLE_BASIC_PRINTING)
// Same as PrintNow(), but for the case where a user prints with the system
// dialog from print preview.
// |dialog_shown_callback| is called when the print dialog is shown.
@@ -33,7 +32,6 @@ class PrintViewManager : public PrintViewManagerBase,
// show the native system dialog. This can happen from both initiator and
// preview dialog.
bool BasicPrint(content::RenderFrameHost* rfh);
-#endif // ENABLE_BASIC_PRINTING
// Initiate print preview of the current document by first notifying the
// renderer. Since this happens asynchronous, the print preview dialog
diff --git a/chromium/chrome/browser/printing/print_view_manager_base.cc b/chromium/chrome/browser/printing/print_view_manager_base.cc
index 9f0672828c1..9b0c15b3c50 100644
--- a/chromium/chrome/browser/printing/print_view_manager_base.cc
+++ b/chromium/chrome/browser/printing/print_view_manager_base.cc
@@ -12,7 +12,7 @@
#include "base/location.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/shared_memory.h"
-#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_loop_current.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/utf_string_conversions.h"
@@ -35,8 +35,8 @@
#include "components/printing/browser/print_composite_client.h"
#include "components/printing/browser/print_manager_utils.h"
#include "components/printing/common/print_messages.h"
-#include "components/printing/service/public/cpp/pdf_service_mojo_types.h"
-#include "components/printing/service/public/cpp/pdf_service_mojo_utils.h"
+#include "components/services/pdf_compositor/public/cpp/pdf_service_mojo_types.h"
+#include "components/services/pdf_compositor/public/cpp/pdf_service_mojo_utils.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
@@ -56,11 +56,6 @@
#include "chrome/browser/printing/print_error_dialog.h"
#endif
-#if defined(OS_WIN)
-#include "base/command_line.h"
-#include "chrome/common/chrome_features.h"
-#endif
-
using base::TimeDelta;
using content::BrowserThread;
@@ -116,7 +111,7 @@ PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents)
inside_inner_message_loop_(false),
queue_(g_browser_process->print_job_manager()->queue()),
weak_ptr_factory_(this) {
- DCHECK(queue_.get());
+ DCHECK(queue_);
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
printing_enabled_.Init(
@@ -130,7 +125,6 @@ PrintViewManagerBase::~PrintViewManagerBase() {
DisconnectFromCurrentPrintJob();
}
-#if BUILDFLAG(ENABLE_BASIC_PRINTING)
bool PrintViewManagerBase::PrintNow(content::RenderFrameHost* rfh) {
DisconnectFromCurrentPrintJob();
@@ -138,7 +132,6 @@ bool PrintViewManagerBase::PrintNow(content::RenderFrameHost* rfh) {
int32_t id = rfh->GetRoutingID();
return PrintNowInternal(rfh, std::make_unique<PrintMsg_PrintPages>(id));
}
-#endif
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void PrintViewManagerBase::PrintForPrintPreview(
@@ -163,46 +156,20 @@ void PrintViewManagerBase::PrintForPrintPreview(
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
void PrintViewManagerBase::PrintDocument(
- PrintedDocument* document,
const scoped_refptr<base::RefCountedMemory>& print_data,
const gfx::Size& page_size,
const gfx::Rect& content_area,
const gfx::Point& offsets) {
#if defined(OS_WIN)
- if (PrintedDocument::HasDebugDumpPath())
- document->DebugDumpData(print_data.get(), FILE_PATH_LITERAL(".pdf"));
-
- const auto& settings = document->settings();
- if (settings.printer_is_textonly()) {
- print_job_->StartPdfToTextConversion(print_data, page_size);
- } else if ((settings.printer_is_ps2() || settings.printer_is_ps3()) &&
- !base::FeatureList::IsEnabled(
- features::kDisablePostScriptPrinting)) {
- print_job_->StartPdfToPostScriptConversion(
- print_data, content_area, offsets, settings.printer_is_ps2());
- } else {
- // TODO(thestig): Figure out why rendering text with GDI results in random
- // missing characters for some users. https://crbug.com/658606
- // Update : The missing letters seem to have been caused by the same
- // problem as https://crbug.com/659604 which was resolved. GDI printing
- // seems to work with the fix for this bug applied.
- bool print_text_with_gdi =
- settings.print_text_with_gdi() && !settings.printer_is_xps() &&
- base::FeatureList::IsEnabled(features::kGdiTextPrinting);
- print_job_->StartPdfToEmfConversion(print_data, page_size, content_area,
- print_text_with_gdi);
- }
- // Indicate that the PDF is fully rendered and we no longer need the renderer
- // and web contents, so the print job does not need to be cancelled if they
- // die. This is needed on Windows because the PrintedDocument will not be
- // considered complete until PDF conversion finishes.
- document->SetConvertingPdf();
+ print_job_->StartConversionToNativeFormat(print_data, page_size, content_area,
+ offsets);
#else
std::unique_ptr<PdfMetafileSkia> metafile =
std::make_unique<PdfMetafileSkia>();
CHECK(metafile->InitFromData(print_data->front(), print_data->size()));
// Update the rendered document. It will send notifications to the listener.
+ PrintedDocument* document = print_job_->document();
document->SetDocument(std::move(metafile), page_size, content_area);
ShouldQuitFromInnerMessageLoop();
#endif
@@ -257,8 +224,7 @@ void PrintViewManagerBase::StartLocalPrintJob(
OnDidGetPrintedPagesCount(printer_query->cookie(), page_count);
- PrintedDocument* document = GetDocument(printer_query->cookie());
- if (!document) {
+ if (!PrintJobHasDocument(printer_query->cookie())) {
std::move(callback).Run(base::Value("Failed to print"));
return;
}
@@ -272,7 +238,7 @@ void PrintViewManagerBase::StartLocalPrintJob(
gfx::Rect content_area =
gfx::Rect(0, 0, page_size.width(), page_size.height());
- PrintDocument(document, print_data, page_size, content_area,
+ PrintDocument(print_data, page_size, content_area,
settings.page_setup_device_units().printable_area().origin());
std::move(callback).Run(base::Value());
}
@@ -304,50 +270,42 @@ void PrintViewManagerBase::OnDidGetPrintedPagesCount(int cookie,
OpportunisticallyCreatePrintJob(cookie);
}
-PrintedDocument* PrintViewManagerBase::GetDocument(int cookie) {
+bool PrintViewManagerBase::PrintJobHasDocument(int cookie) {
if (!OpportunisticallyCreatePrintJob(cookie))
- return nullptr;
+ return false;
+ // These checks may fail since we are completely asynchronous. Old spurious
+ // messages can be received if one of the processes is overloaded.
PrintedDocument* document = print_job_->document();
- if (!document || cookie != document->cookie()) {
- // Out of sync. It may happen since we are completely asynchronous. Old
- // spurious messages can be received if one of the processes is overloaded.
- return nullptr;
- }
- return document;
+ return document && document->cookie() == cookie;
}
void PrintViewManagerBase::OnComposePdfDone(
const PrintHostMsg_DidPrintDocument_Params& params,
mojom::PdfCompositor::Status status,
- mojo::ScopedSharedBufferHandle handle) {
+ base::ReadOnlySharedMemoryRegion region) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (status != mojom::PdfCompositor::Status::SUCCESS) {
DLOG(ERROR) << "Compositing pdf failed with error " << status;
return;
}
- PrintedDocument* document = print_job_->document();
- if (!document)
+ if (!print_job_->document())
return;
- std::unique_ptr<base::SharedMemory> shared_buf =
- GetShmFromMojoHandle(std::move(handle));
- if (!shared_buf)
+ scoped_refptr<base::RefCountedSharedMemoryMapping> data =
+ base::RefCountedSharedMemoryMapping::CreateFromWholeRegion(region);
+ if (!data)
return;
- size_t size = shared_buf->mapped_size();
- auto data = base::MakeRefCounted<base::RefCountedSharedMemory>(
- std::move(shared_buf), size);
- PrintDocument(document, data, params.page_size, params.content_area,
+ PrintDocument(data, params.page_size, params.content_area,
params.physical_offsets);
}
void PrintViewManagerBase::OnDidPrintDocument(
content::RenderFrameHost* render_frame_host,
const PrintHostMsg_DidPrintDocument_Params& params) {
- PrintedDocument* document = GetDocument(params.document_cookie);
- if (!document)
+ if (!PrintJobHasDocument(params.document_cookie))
return;
const PrintHostMsg_DidPrintContent_Params& content = params.content;
@@ -376,7 +334,7 @@ void PrintViewManagerBase::OnDidPrintDocument(
auto data = base::MakeRefCounted<base::RefCountedSharedMemory>(
std::move(shared_buf), content.data_size);
- PrintDocument(document, data, params.page_size, params.content_area,
+ PrintDocument(data, params.page_size, params.content_area,
params.physical_offsets);
}
@@ -417,11 +375,11 @@ void PrintViewManagerBase::RenderFrameDeleted(
PrintManager::PrintingRenderFrameDeleted();
ReleasePrinterQuery();
- if (!print_job_.get())
+ if (!print_job_)
return;
scoped_refptr<PrintedDocument> document(print_job_->document());
- if (document.get()) {
+ if (document) {
// If IsComplete() returns false, the document isn't completely rendered.
// Since our renderer is gone, there's nothing to do, cancel it. Otherwise,
// the print job may finish without problem.
@@ -523,7 +481,7 @@ void PrintViewManagerBase::OnNotifyPrintJobEvent(
}
bool PrintViewManagerBase::RenderAllMissingPagesNow() {
- if (!print_job_.get() || !print_job_->is_job_pending())
+ if (!print_job_ || !print_job_->is_job_pending())
return false;
// Is the document already complete?
@@ -571,8 +529,9 @@ void PrintViewManagerBase::ShouldQuitFromInnerMessageLoop() {
}
}
-bool PrintViewManagerBase::CreateNewPrintJob(PrintJobWorkerOwner* job) {
+bool PrintViewManagerBase::CreateNewPrintJob(PrinterQuery* query) {
DCHECK(!inside_inner_message_loop_);
+ DCHECK(query);
// Disconnect the current |print_job_|.
DisconnectFromCurrentPrintJob();
@@ -583,13 +542,9 @@ bool PrintViewManagerBase::CreateNewPrintJob(PrintJobWorkerOwner* job) {
return false;
}
- DCHECK(!print_job_.get());
- DCHECK(job);
- if (!job)
- return false;
-
+ DCHECK(!print_job_);
print_job_ = base::MakeRefCounted<PrintJob>();
- print_job_->Initialize(job, RenderSourceName(), number_pages_);
+ print_job_->Initialize(query, RenderSourceName(), number_pages_);
registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT,
content::Source<PrintJob>(print_job_.get()));
printing_succeeded_ = false;
@@ -602,8 +557,7 @@ void PrintViewManagerBase::DisconnectFromCurrentPrintJob() {
bool result = RenderAllMissingPagesNow();
// Verify that assertion.
- if (print_job_.get() &&
- print_job_->document() &&
+ if (print_job_ && print_job_->document() &&
!print_job_->document()->IsComplete()) {
DCHECK(!result);
// That failed.
@@ -615,7 +569,7 @@ void PrintViewManagerBase::DisconnectFromCurrentPrintJob() {
}
void PrintViewManagerBase::TerminatePrintJob(bool cancel) {
- if (!print_job_.get())
+ if (!print_job_)
return;
if (cancel) {
@@ -638,7 +592,7 @@ void PrintViewManagerBase::ReleasePrintJob() {
content::RenderFrameHost* rfh = printing_rfh_;
printing_rfh_ = nullptr;
- if (!print_job_.get())
+ if (!print_job_)
return;
if (rfh) {
@@ -676,8 +630,7 @@ bool PrintViewManagerBase::RunInnerMessageLoop() {
// Need to enable recursive task.
{
- base::MessageLoop::ScopedNestableTaskAllower allow(
- base::MessageLoop::current());
+ base::MessageLoopCurrent::ScopedNestableTaskAllower allow;
run_loop.Run();
}
@@ -692,7 +645,7 @@ bool PrintViewManagerBase::RunInnerMessageLoop() {
}
bool PrintViewManagerBase::OpportunisticallyCreatePrintJob(int cookie) {
- if (print_job_.get())
+ if (print_job_)
return true;
if (!cookie) {
@@ -704,7 +657,7 @@ bool PrintViewManagerBase::OpportunisticallyCreatePrintJob(int cookie) {
// The job was initiated by a script. Time to get the corresponding worker
// thread.
scoped_refptr<PrinterQuery> queued_query = queue_->PopPrinterQuery(cookie);
- if (!queued_query.get()) {
+ if (!queued_query) {
NOTREACHED();
return false;
}
@@ -748,7 +701,7 @@ void PrintViewManagerBase::ReleasePrinterQuery() {
scoped_refptr<PrinterQuery> printer_query;
printer_query = queue_->PopPrinterQuery(cookie);
- if (!printer_query.get())
+ if (!printer_query)
return;
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
diff --git a/chromium/chrome/browser/printing/print_view_manager_base.h b/chromium/chrome/browser/printing/print_view_manager_base.h
index bd1b912c6e9..fe0e0b5b065 100644
--- a/chromium/chrome/browser/printing/print_view_manager_base.h
+++ b/chromium/chrome/browser/printing/print_view_manager_base.h
@@ -8,6 +8,7 @@
#include <memory>
#include "base/macros.h"
+#include "base/memory/read_only_shared_memory_region.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
@@ -15,10 +16,9 @@
#include "chrome/browser/ui/webui/print_preview/printer_handler.h"
#include "components/prefs/pref_member.h"
#include "components/printing/browser/print_manager.h"
-#include "components/printing/service/public/interfaces/pdf_compositor.mojom.h"
+#include "components/services/pdf_compositor/public/interfaces/pdf_compositor.mojom.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
-#include "mojo/public/cpp/system/platform_handle.h"
#include "printing/buildflags/buildflags.h"
struct PrintHostMsg_DidPrintDocument_Params;
@@ -35,9 +35,7 @@ namespace printing {
class JobEventDetails;
class PrintJob;
-class PrintJobWorkerOwner;
class PrintQueriesQueue;
-class PrintedDocument;
class PrinterQuery;
// Base class for managing the print commands for a WebContents.
@@ -46,12 +44,10 @@ class PrintViewManagerBase : public content::NotificationObserver,
public:
~PrintViewManagerBase() override;
-#if BUILDFLAG(ENABLE_BASIC_PRINTING)
// Prints the current document immediately. Since the rendering is
// asynchronous, the actual printing will not be completed on the return of
// this function. Returns false if printing is impossible at the moment.
virtual bool PrintNow(content::RenderFrameHost* rfh);
-#endif // ENABLE_BASIC_PRINTING
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Prints the document in |print_data| with settings specified in
@@ -94,7 +90,7 @@ class PrintViewManagerBase : public content::NotificationObserver,
// currently a print job, safely disconnect from it. Returns false if it is
// impossible to safely disconnect from the current print job or it is
// impossible to create a new print job.
- virtual bool CreateNewPrintJob(PrintJobWorkerOwner* job);
+ virtual bool CreateNewPrintJob(PrinterQuery* query);
// Manages the low-level talk to the printer.
scoped_refptr<PrintJob> print_job_;
@@ -121,7 +117,7 @@ class PrintViewManagerBase : public content::NotificationObserver,
// IPC message handlers for service.
void OnComposePdfDone(const PrintHostMsg_DidPrintDocument_Params& params,
mojom::PdfCompositor::Status status,
- mojo::ScopedSharedBufferHandle handle);
+ base::ReadOnlySharedMemoryRegion region);
// Helpers for PrintForPrintPreview();
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
@@ -129,12 +125,12 @@ class PrintViewManagerBase : public content::NotificationObserver,
const scoped_refptr<base::RefCountedMemory>& print_data,
int page_count,
PrinterHandler::PrintCallback callback,
- scoped_refptr<printing::PrinterQuery> printer_query);
+ scoped_refptr<PrinterQuery> printer_query);
void StartLocalPrintJob(
const scoped_refptr<base::RefCountedMemory>& print_data,
int page_count,
- scoped_refptr<printing::PrinterQuery> printer_query,
+ scoped_refptr<PrinterQuery> printer_query,
PrinterHandler::PrintCallback callback);
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
@@ -146,14 +142,13 @@ class PrintViewManagerBase : public content::NotificationObserver,
// been requested to the renderer.
bool RenderAllMissingPagesNow();
- // Checks that synchronization is correct and a print query exists for
- // |cookie|. If so, returns the document associated with the cookie.
- PrintedDocument* GetDocument(int cookie);
+ // Checks that synchronization is correct with |print_job_| based on |cookie|.
+ bool PrintJobHasDocument(int cookie);
- // Starts printing |document| with the given |print_data|. This method assumes
- // |print_data| contains valid data.
- void PrintDocument(PrintedDocument* document,
- const scoped_refptr<base::RefCountedMemory>& print_data,
+ // Starts printing the |document| in |print_job_| with the given |print_data|.
+ // This method assumes PrintJobHasDocument() has been called, and |print_data|
+ // contains valid data.
+ void PrintDocument(const scoped_refptr<base::RefCountedMemory>& print_data,
const gfx::Size& page_size,
const gfx::Rect& content_area,
const gfx::Point& offsets);
@@ -211,7 +206,7 @@ class PrintViewManagerBase : public content::NotificationObserver,
// Whether printing is enabled.
BooleanPrefMember printing_enabled_;
- scoped_refptr<printing::PrintQueriesQueue> queue_;
+ scoped_refptr<PrintQueriesQueue> queue_;
base::WeakPtrFactory<PrintViewManagerBase> weak_ptr_factory_;
diff --git a/chromium/chrome/browser/printing/print_view_manager_common.cc b/chromium/chrome/browser/printing/print_view_manager_common.cc
index 1dac59c4e0b..3d36b0b972b 100644
--- a/chromium/chrome/browser/printing/print_view_manager_common.cc
+++ b/chromium/chrome/browser/printing/print_view_manager_common.cc
@@ -93,12 +93,9 @@ void StartPrint(content::WebContents* contents,
}
#endif // ENABLE_PRINT_PREVIEW
-#if BUILDFLAG(ENABLE_BASIC_PRINTING)
print_view_manager->PrintNow(rfh_to_use);
-#endif // ENABLE_BASIC_PRINTING
}
-#if BUILDFLAG(ENABLE_BASIC_PRINTING)
void StartBasicPrint(content::WebContents* contents) {
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
content::WebContents* contents_to_use = GetWebContentsToUse(contents);
@@ -115,7 +112,6 @@ void StartBasicPrint(content::WebContents* contents) {
print_view_manager->BasicPrint(rfh_to_use);
#endif // ENABLE_PRINT_PREVIEW
}
-#endif // ENABLE_BASIC_PRINTING
content::RenderFrameHost* GetFrameToPrint(content::WebContents* contents) {
auto* focused_frame = contents->GetFocusedFrame();
diff --git a/chromium/chrome/browser/printing/print_view_manager_common.h b/chromium/chrome/browser/printing/print_view_manager_common.h
index 92d912a4003..96556eb0a96 100644
--- a/chromium/chrome/browser/printing/print_view_manager_common.h
+++ b/chromium/chrome/browser/printing/print_view_manager_common.h
@@ -19,10 +19,8 @@ void StartPrint(content::WebContents* web_contents,
bool print_preview_disabled,
bool has_selection);
-#if BUILDFLAG(ENABLE_BASIC_PRINTING)
// Start printing using the system print dialog.
void StartBasicPrint(content::WebContents* contents);
-#endif
// If the user has selected text in the currently focused frame, print only that
// frame (this makes print selection work for multiple frames).
diff --git a/chromium/chrome/browser/printing/print_view_manager_unittest.cc b/chromium/chrome/browser/printing/print_view_manager_unittest.cc
index d2274f58b44..4db373efbb1 100644
--- a/chromium/chrome/browser/printing/print_view_manager_unittest.cc
+++ b/chromium/chrome/browser/printing/print_view_manager_unittest.cc
@@ -49,7 +49,9 @@ class TestPrintViewManager : public PrintViewManagerBase {
const gfx::Rect& content_area() { return test_job()->content_area(); }
- const gfx::Point& offsets() { return test_job()->offsets(); }
+ const gfx::Point& physical_offsets() {
+ return test_job()->physical_offsets();
+ }
#if defined(OS_WIN)
PrintSettings::PrinterType type() { return test_job()->type(); }
@@ -71,9 +73,9 @@ class TestPrintViewManager : public PrintViewManagerBase {
protected:
// Override to create a TestPrintJob instead of a real one.
- bool CreateNewPrintJob(PrintJobWorkerOwner* job) override {
+ bool CreateNewPrintJob(PrinterQuery* query) override {
print_job_ = base::MakeRefCounted<TestPrintJob>();
- print_job_->Initialize(job, RenderSourceName(), number_pages_);
+ print_job_->Initialize(query, RenderSourceName(), number_pages_);
return true;
}
@@ -118,8 +120,8 @@ TEST_F(PrintViewManagerTest, PostScriptHasCorrectOffsets) {
// Setup PostScript printer with printable area offsets of 0.1in.
queue->SetupPrinterType(PrintSettings::PrinterType::TYPE_POSTSCRIPT_LEVEL2);
- int offset_in_px = static_cast<int>(kTestPrinterDpi * 0.1f);
- queue->SetupPrinterOffsets(offset_in_px, offset_in_px);
+ int offset_in_pixels = static_cast<int>(kTestPrinterDpi * 0.1f);
+ queue->SetupPrinterOffsets(offset_in_pixels, offset_in_pixels);
g_browser_process->print_job_manager()->SetQueueForTest(queue);
chrome::NewTab(browser());
@@ -148,7 +150,7 @@ TEST_F(PrintViewManagerTest, PostScriptHasCorrectOffsets) {
std::move(callback));
print_view_manager->WaitForCallback();
- EXPECT_EQ(gfx::Point(60, 60), print_view_manager->offsets());
+ EXPECT_EQ(gfx::Point(60, 60), print_view_manager->physical_offsets());
EXPECT_EQ(gfx::Rect(0, 0, 5100, 6600), print_view_manager->content_area());
EXPECT_EQ(PrintSettings::PrinterType::TYPE_POSTSCRIPT_LEVEL2,
print_view_manager->type());
diff --git a/chromium/chrome/browser/printing/printer_manager_dialog_win.cc b/chromium/chrome/browser/printing/printer_manager_dialog_win.cc
index 983dea7ba64..ab3c2452932 100644
--- a/chromium/chrome/browser/printing/printer_manager_dialog_win.cc
+++ b/chromium/chrome/browser/printing/printer_manager_dialog_win.cc
@@ -18,7 +18,7 @@ namespace {
// A helper callback that opens the printer management dialog.
void OpenPrintersDialogCallback() {
base::FilePath sys_dir;
- PathService::Get(base::DIR_SYSTEM, &sys_dir);
+ base::PathService::Get(base::DIR_SYSTEM, &sys_dir);
base::FilePath rundll32 = sys_dir.Append(L"rundll32.exe");
base::FilePath shell32dll = sys_dir.Append(L"shell32.dll");
diff --git a/chromium/chrome/browser/printing/printer_query.cc b/chromium/chrome/browser/printing/printer_query.cc
index 58c8baad7ae..cc236873136 100644
--- a/chromium/chrome/browser/printing/printer_query.cc
+++ b/chromium/chrome/browser/printing/printer_query.cc
@@ -9,18 +9,24 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/location.h"
+#include "base/single_thread_task_runner.h"
#include "base/threading/thread_restrictions.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
#include "chrome/browser/printing/print_job_worker.h"
#include "content/public/browser/browser_thread.h"
+#include "printing/print_job_constants.h"
+#include "printing/print_settings.h"
namespace printing {
PrinterQuery::PrinterQuery(int render_process_id, int render_frame_id)
- : worker_(std::make_unique<PrintJobWorker>(render_process_id,
+ : cookie_(PrintSettings::NewCookie()),
+ task_runner_(base::ThreadTaskRunnerHandle::Get()),
+ worker_(std::make_unique<PrintJobWorker>(render_process_id,
render_frame_id,
- this)),
- cookie_(PrintSettings::NewCookie()) {
+ this)) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
}
@@ -49,12 +55,10 @@ void PrinterQuery::GetSettingsDone(const PrintSettings& new_settings,
}
}
-std::unique_ptr<PrintJobWorker> PrinterQuery::DetachWorker(
- PrintJobWorkerOwner* new_owner) {
+std::unique_ptr<PrintJobWorker> PrinterQuery::DetachWorker() {
DCHECK(!callback_);
DCHECK(worker_);
- worker_->SetNewOwner(new_owner);
return std::move(worker_);
}
@@ -138,6 +142,15 @@ void PrinterQuery::StopWorker() {
}
}
+bool PrinterQuery::RunsTasksInCurrentSequence() const {
+ return task_runner_->RunsTasksInCurrentSequence();
+}
+
+bool PrinterQuery::PostTask(const base::Location& from_here,
+ base::OnceClosure task) {
+ return task_runner_->PostTask(from_here, std::move(task));
+}
+
bool PrinterQuery::is_callback_pending() const {
return !callback_.is_null();
}
diff --git a/chromium/chrome/browser/printing/printer_query.h b/chromium/chrome/browser/printing/printer_query.h
index 35b42578489..64db84f9f85 100644
--- a/chromium/chrome/browser/printing/printer_query.h
+++ b/chromium/chrome/browser/printing/printer_query.h
@@ -9,10 +9,15 @@
#include "base/callback.h"
#include "base/macros.h"
-#include "chrome/browser/printing/print_job_worker_owner.h"
+#include "base/memory/ref_counted.h"
+#include "printing/print_job_constants.h"
+#include "printing/print_settings.h"
+#include "printing/printing_context.h"
namespace base {
class DictionaryValue;
+class Location;
+class SequencedTaskRunner;
}
namespace printing {
@@ -20,7 +25,7 @@ namespace printing {
class PrintJobWorker;
// Query the printer for settings.
-class PrinterQuery : public PrintJobWorkerOwner {
+class PrinterQuery : public base::RefCountedThreadSafe<PrinterQuery> {
public:
// GetSettings() UI parameter.
enum class GetSettingsAskParam {
@@ -31,13 +36,16 @@ class PrinterQuery : public PrintJobWorkerOwner {
// Can only be called on the IO thread.
PrinterQuery(int render_process_id, int render_frame_id);
- // PrintJobWorkerOwner implementation.
- void GetSettingsDone(const PrintSettings& new_settings,
- PrintingContext::Result result) override;
- std::unique_ptr<PrintJobWorker> DetachWorker(
- PrintJobWorkerOwner* new_owner) override;
- const PrintSettings& settings() const override;
- int cookie() const override;
+ // Virtual so that tests can override.
+ virtual void GetSettingsDone(const PrintSettings& new_settings,
+ PrintingContext::Result result);
+
+ // Detach the PrintJobWorker associated to this object. Virtual so that tests
+ // can override.
+ virtual std::unique_ptr<PrintJobWorker> DetachWorker();
+
+ // Virtual so that tests can override.
+ virtual const PrintSettings& settings() const;
// Initializes the printing context. It is fine to call this function multiple
// times to reinitialize the settings. |web_contents_observer| can be queried
@@ -67,22 +75,27 @@ class PrinterQuery : public PrintJobWorkerOwner {
// Returns true if a GetSettings() call is pending completion.
bool is_callback_pending() const;
+ int cookie() const;
PrintingContext::Result last_status() const { return last_status_; }
// Returns if a worker thread is still associated to this instance.
bool is_valid() const;
- protected:
- // For unit tests to manually set the print callback.
- void set_callback(base::OnceClosure callback);
+ // Returns true if tasks posted to this TaskRunner are sequenced
+ // with this call.
+ bool RunsTasksInCurrentSequence() const;
- // All the UI is done in a worker thread because many Win32 print functions
- // are blocking and enters a message loop without your consent. There is one
- // worker thread per print job.
- std::unique_ptr<PrintJobWorker> worker_;
+ // Posts the given task to be run.
+ bool PostTask(const base::Location& from_here, base::OnceClosure task);
+ protected:
// Refcounted class.
- ~PrinterQuery() override;
+ friend class base::RefCountedThreadSafe<PrinterQuery>;
+
+ virtual ~PrinterQuery();
+
+ // For unit tests to manually set the print callback.
+ void set_callback(base::OnceClosure callback);
private:
// Lazy create the worker thread. There is one worker thread per print job.
@@ -103,6 +116,15 @@ class PrinterQuery : public PrintJobWorkerOwner {
// Callback waiting to be run.
base::OnceClosure callback_;
+ // Task runner reference. Used to send notifications in the right
+ // thread.
+ scoped_refptr<base::SequencedTaskRunner> task_runner_;
+
+ // All the UI is done in a worker thread because many Win32 print functions
+ // are blocking and enters a message loop without your consent. There is one
+ // worker thread per print job.
+ std::unique_ptr<PrintJobWorker> worker_;
+
DISALLOW_COPY_AND_ASSIGN(PrinterQuery);
};
diff --git a/chromium/chrome/browser/printing/printing_layout_browsertest.cc b/chromium/chrome/browser/printing/printing_layout_browsertest.cc
index a6daff02a7c..1177a94d1a3 100644
--- a/chromium/chrome/browser/printing/printing_layout_browsertest.cc
+++ b/chromium/chrome/browser/printing/printing_layout_browsertest.cc
@@ -11,6 +11,7 @@
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/process/process_handle.h"
+#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -46,7 +47,7 @@ class PrintingLayoutTest : public PrintingTest<InProcessBrowserTest>,
public:
PrintingLayoutTest() {
base::FilePath browser_directory;
- PathService::Get(chrome::DIR_APP, &browser_directory);
+ base::PathService::Get(chrome::DIR_APP, &browser_directory);
emf_path_ = browser_directory.AppendASCII("metafile_dumps");
}
@@ -85,7 +86,7 @@ class PrintingLayoutTest : public PrintingTest<InProcessBrowserTest>,
case printing::JobEventDetails::JOB_DONE: {
// Succeeded.
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
+ FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated());
break;
}
case printing::JobEventDetails::USER_INIT_CANCELED:
@@ -93,7 +94,7 @@ class PrintingLayoutTest : public PrintingTest<InProcessBrowserTest>,
// Failed.
ASSERT_TRUE(false);
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
+ FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated());
break;
}
case printing::JobEventDetails::NEW_DOC:
diff --git a/chromium/chrome/browser/printing/pwg_raster_converter.cc b/chromium/chrome/browser/printing/pwg_raster_converter.cc
index 1e9d3f93087..bc982c6c853 100644
--- a/chromium/chrome/browser/printing/pwg_raster_converter.cc
+++ b/chromium/chrome/browser/printing/pwg_raster_converter.cc
@@ -10,16 +10,9 @@
#include "base/bind_helpers.h"
#include "base/cancelable_callback.h"
-#include "base/files/file.h"
-#include "base/files/file_util.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/location.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/sequenced_task_runner.h"
-#include "base/task_scheduler/post_task.h"
-#include "base/threading/thread_restrictions.h"
-#include "base/threading/thread_task_runner_handle.h"
+#include "base/metrics/histogram_macros.h"
#include "chrome/services/printing/public/mojom/constants.mojom.h"
#include "chrome/services/printing/public/mojom/pdf_to_pwg_raster_converter.mojom.h"
#include "components/cloud_devices/common/cloud_device_description.h"
@@ -41,100 +34,29 @@ namespace {
using content::BrowserThread;
-class FileHandlers {
- public:
- FileHandlers() {}
-
- ~FileHandlers() { base::AssertBlockingAllowed(); }
-
- void Init(base::RefCountedMemory* data);
- bool IsValid();
-
- base::FilePath GetPwgPath() const {
- return temp_dir_.GetPath().AppendASCII("output.pwg");
- }
-
- base::FilePath GetPdfPath() const {
- return temp_dir_.GetPath().AppendASCII("input.pdf");
- }
-
- base::PlatformFile GetPdfForProcess() {
- DCHECK(pdf_file_.IsValid());
- return pdf_file_.TakePlatformFile();
- }
-
- base::PlatformFile GetPwgForProcess() {
- DCHECK(pwg_file_.IsValid());
- return pwg_file_.TakePlatformFile();
- }
-
- private:
- base::ScopedTempDir temp_dir_;
- base::File pdf_file_;
- base::File pwg_file_;
-
- DISALLOW_COPY_AND_ASSIGN(FileHandlers);
-};
-
-void FileHandlers::Init(base::RefCountedMemory* data) {
- base::AssertBlockingAllowed();
-
- if (!temp_dir_.CreateUniqueTempDir())
- return;
-
- if (static_cast<int>(data->size()) !=
- base::WriteFile(GetPdfPath(), data->front_as<char>(), data->size())) {
- return;
- }
-
- // Reopen in read only mode.
- pdf_file_.Initialize(GetPdfPath(),
- base::File::FLAG_OPEN | base::File::FLAG_READ);
- pwg_file_.Initialize(GetPwgPath(),
- base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE);
-}
-
-bool FileHandlers::IsValid() {
- return pdf_file_.IsValid() && pwg_file_.IsValid();
-}
-
-// Converts PDF into PWG raster.
-// Class uses UI thread and |blocking_task_runner_|.
-// Internal workflow is following:
-// 1. Create instance on the UI thread. (files_, settings_,)
-// 2. Create file on |blocking_task_runner_|.
-// 3. Connect to the printing utility service and start the conversion.
-// 4. Run result callback on the UI thread.
-// 5. Instance is destroyed from any thread that has the last reference.
-// 6. FileHandlers destroyed on |blocking_task_runner_|.
-// This step posts |FileHandlers| to be destroyed on |blocking_task_runner_|.
-// All these steps work sequentially, so no data should be accessed
-// simultaneously by several threads.
+// Converts PDF into PWG raster. Class lives on the UI thread.
class PwgRasterConverterHelper
- : public base::RefCountedThreadSafe<PwgRasterConverterHelper> {
+ : public base::RefCounted<PwgRasterConverterHelper> {
public:
PwgRasterConverterHelper(const PdfRenderSettings& settings,
const PwgRasterSettings& bitmap_settings);
- void Convert(base::RefCountedMemory* data,
+ void Convert(const base::RefCountedMemory* data,
PwgRasterConverter::ResultCallback callback);
private:
- friend class base::RefCountedThreadSafe<PwgRasterConverterHelper>;
+ friend class base::RefCounted<PwgRasterConverterHelper>;
~PwgRasterConverterHelper();
- void RunCallback(bool success);
-
- void OnFilesReadyOnUIThread();
+ void RunCallback(base::ReadOnlySharedMemoryRegion region,
+ uint32_t page_count);
PdfRenderSettings settings_;
PwgRasterSettings bitmap_settings_;
mojo::InterfacePtr<printing::mojom::PdfToPwgRasterConverter>
pdf_to_pwg_raster_converter_ptr_;
PwgRasterConverter::ResultCallback callback_;
- const scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
- std::unique_ptr<FileHandlers, base::OnTaskRunnerDeleter> files_;
DISALLOW_COPY_AND_ASSIGN(PwgRasterConverterHelper);
};
@@ -142,38 +64,20 @@ class PwgRasterConverterHelper
PwgRasterConverterHelper::PwgRasterConverterHelper(
const PdfRenderSettings& settings,
const PwgRasterSettings& bitmap_settings)
- : settings_(settings),
- bitmap_settings_(bitmap_settings),
- blocking_task_runner_(base::CreateSequencedTaskRunnerWithTraits(
- {base::MayBlock(), base::TaskPriority::USER_VISIBLE,
- base::TaskShutdownBehavior::BLOCK_SHUTDOWN})),
- files_(nullptr, base::OnTaskRunnerDeleter(blocking_task_runner_)) {}
+ : settings_(settings), bitmap_settings_(bitmap_settings) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+}
-PwgRasterConverterHelper::~PwgRasterConverterHelper() {}
+PwgRasterConverterHelper::~PwgRasterConverterHelper() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+}
void PwgRasterConverterHelper::Convert(
- base::RefCountedMemory* data,
+ const base::RefCountedMemory* data,
PwgRasterConverter::ResultCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
callback_ = std::move(callback);
- CHECK(!files_);
- files_.reset(new FileHandlers());
-
- blocking_task_runner_->PostTaskAndReply(
- FROM_HERE,
- base::BindOnce(&FileHandlers::Init, base::Unretained(files_.get()),
- base::RetainedRef(data)),
- base::BindOnce(&PwgRasterConverterHelper::OnFilesReadyOnUIThread, this));
-}
-
-void PwgRasterConverterHelper::OnFilesReadyOnUIThread() {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
-
- if (!files_->IsValid()) {
- RunCallback(false);
- return;
- }
content::ServiceManagerConnection::GetForProcess()
->GetConnector()
@@ -181,18 +85,40 @@ void PwgRasterConverterHelper::OnFilesReadyOnUIThread() {
&pdf_to_pwg_raster_converter_ptr_);
pdf_to_pwg_raster_converter_ptr_.set_connection_error_handler(
- base::Bind(&PwgRasterConverterHelper::RunCallback, this, false));
+ base::BindOnce(&PwgRasterConverterHelper::RunCallback, this,
+ base::ReadOnlySharedMemoryRegion(), /*page_count=*/0));
+ base::MappedReadOnlyRegion memory =
+ base::ReadOnlySharedMemoryRegion::Create(data->size());
+ if (!memory.IsValid()) {
+ RunCallback(base::ReadOnlySharedMemoryRegion(), /*page_count=*/0);
+ return;
+ }
+
+ // TODO(thestig): Write |data| into shared memory in the first place, to avoid
+ // this memcpy().
+ memcpy(memory.mapping.memory(), data->front(), data->size());
pdf_to_pwg_raster_converter_ptr_->Convert(
- mojo::WrapPlatformFile(files_->GetPdfForProcess()), settings_,
- bitmap_settings_, mojo::WrapPlatformFile(files_->GetPwgForProcess()),
+ std::move(memory.region), settings_, bitmap_settings_,
base::Bind(&PwgRasterConverterHelper::RunCallback, this));
}
-void PwgRasterConverterHelper::RunCallback(bool success) {
+void PwgRasterConverterHelper::RunCallback(
+ base::ReadOnlySharedMemoryRegion region,
+ uint32_t page_count) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- if (callback_)
- std::move(callback_).Run(success, files_->GetPwgPath());
+ if (callback_) {
+ if (region.IsValid() && page_count > 0) {
+ size_t average_page_size_in_kb = region.GetSize() / 1024;
+ average_page_size_in_kb /= page_count;
+ UMA_HISTOGRAM_MEMORY_KB("Printing.ConversionSize.Pwg",
+ average_page_size_in_kb);
+ std::move(callback_).Run(std::move(region));
+ } else {
+ // TODO(thestig): Consider adding UMA to track failure rates.
+ std::move(callback_).Run(base::ReadOnlySharedMemoryRegion());
+ }
+ }
pdf_to_pwg_raster_converter_ptr_.reset();
}
@@ -201,7 +127,7 @@ class PwgRasterConverterImpl : public PwgRasterConverter {
PwgRasterConverterImpl();
~PwgRasterConverterImpl() override;
- void Start(base::RefCountedMemory* data,
+ void Start(const base::RefCountedMemory* data,
const PdfRenderSettings& conversion_settings,
const PwgRasterSettings& bitmap_settings,
ResultCallback callback) override;
@@ -209,8 +135,9 @@ class PwgRasterConverterImpl : public PwgRasterConverter {
private:
scoped_refptr<PwgRasterConverterHelper> utility_client_;
- // Cancelable version of ResultCallback.
- base::CancelableOnceCallback<void(bool, const base::FilePath&)> callback_;
+ // Cancelable version of PwgRasterConverter::ResultCallback.
+ base::CancelableOnceCallback<void(base::ReadOnlySharedMemoryRegion)>
+ cancelable_callback_;
DISALLOW_COPY_AND_ASSIGN(PwgRasterConverterImpl);
};
@@ -219,14 +146,14 @@ PwgRasterConverterImpl::PwgRasterConverterImpl() = default;
PwgRasterConverterImpl::~PwgRasterConverterImpl() = default;
-void PwgRasterConverterImpl::Start(base::RefCountedMemory* data,
+void PwgRasterConverterImpl::Start(const base::RefCountedMemory* data,
const PdfRenderSettings& conversion_settings,
const PwgRasterSettings& bitmap_settings,
ResultCallback callback) {
- callback_.Reset(std::move(callback));
+ cancelable_callback_.Reset(std::move(callback));
utility_client_ = base::MakeRefCounted<PwgRasterConverterHelper>(
conversion_settings, bitmap_settings);
- utility_client_->Convert(data, callback_.callback());
+ utility_client_->Convert(data, cancelable_callback_.callback());
}
} // namespace
diff --git a/chromium/chrome/browser/printing/pwg_raster_converter.h b/chromium/chrome/browser/printing/pwg_raster_converter.h
index 866f62441fc..712a2546639 100644
--- a/chromium/chrome/browser/printing/pwg_raster_converter.h
+++ b/chromium/chrome/browser/printing/pwg_raster_converter.h
@@ -8,13 +8,10 @@
#include <memory>
#include "base/callback.h"
+#include "base/memory/read_only_shared_memory_region.h"
#include "base/memory/ref_counted_memory.h"
#include "printing/pdf_render_settings.h"
-namespace base {
-class FilePath;
-}
-
namespace cloud_devices {
class CloudDeviceDescription;
}
@@ -30,12 +27,9 @@ struct PwgRasterSettings;
class PwgRasterConverter {
public:
// Callback for when the PDF is converted to a PWG raster.
- // |success| denotes whether the conversion succeeded.
- // |temp_file| is the path to the temp file (owned by the converter) that
- // contains the PWG raster data.
+ // |region| contains the PWG raster data.
using ResultCallback =
- base::OnceCallback<void(bool /*success*/,
- const base::FilePath& /*temp_file*/)>;
+ base::OnceCallback<void(base::ReadOnlySharedMemoryRegion /*region*/)>;
virtual ~PwgRasterConverter() {}
@@ -55,7 +49,7 @@ class PwgRasterConverter {
const cloud_devices::CloudDeviceDescription& printer_capabilities,
const cloud_devices::CloudDeviceDescription& ticket);
- virtual void Start(base::RefCountedMemory* data,
+ virtual void Start(const base::RefCountedMemory* data,
const PdfRenderSettings& conversion_settings,
const PwgRasterSettings& bitmap_settings,
ResultCallback callback) = 0;
diff --git a/chromium/chrome/browser/printing/pwg_raster_converter_browsertest.cc b/chromium/chrome/browser/printing/pwg_raster_converter_browsertest.cc
index d4638897719..826c5469fa6 100644
--- a/chromium/chrome/browser/printing/pwg_raster_converter_browsertest.cc
+++ b/chromium/chrome/browser/printing/pwg_raster_converter_browsertest.cc
@@ -34,21 +34,18 @@ constexpr char kPdfToPwgRasterMonoTestFile[] =
#endif
void ResultCallbackImpl(bool* called,
- bool* success_out,
- base::FilePath* temp_file_out,
+ base::ReadOnlySharedMemoryRegion* pwg_region_out,
base::Closure quit_closure,
- bool success_in,
- const base::FilePath& temp_file_in) {
+ base::ReadOnlySharedMemoryRegion pwg_region_in) {
*called = true;
- *success_out = success_in;
- *temp_file_out = temp_file_in;
+ *pwg_region_out = std::move(pwg_region_in);
quit_closure.Run();
}
void GetPdfData(const char* file_name,
base::FilePath* test_data_dir,
scoped_refptr<base::RefCountedString>* pdf_data) {
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, test_data_dir));
+ ASSERT_TRUE(base::PathService::Get(chrome::DIR_TEST_DATA, test_data_dir));
*test_data_dir = test_data_dir->AppendASCII("printing");
base::FilePath pdf_file = test_data_dir->AppendASCII(file_name);
std::string pdf_data_str;
@@ -57,19 +54,24 @@ void GetPdfData(const char* file_name,
*pdf_data = base::RefCountedString::TakeString(&pdf_data_str);
}
-std::string HashFile(const std::string& file_data) {
- std::string sha1 = base::SHA1HashString(file_data);
- return base::HexEncode(sha1.c_str(), sha1.length());
+std::string HashData(const char* data, size_t len) {
+ char hash[base::kSHA1Length];
+ base::SHA1HashBytes(reinterpret_cast<const unsigned char*>(data), len,
+ reinterpret_cast<unsigned char*>(hash));
+ return base::HexEncode(hash, base::kSHA1Length);
}
-void ComparePwgFiles(const base::FilePath& expected,
- const base::FilePath& actual) {
+void ComparePwgOutput(const base::FilePath& expected_file,
+ base::ReadOnlySharedMemoryRegion pwg_region) {
std::string pwg_expected_data_str;
- ASSERT_TRUE(base::ReadFileToString(expected, &pwg_expected_data_str));
- std::string pwg_actual_data_str;
- ASSERT_TRUE(base::ReadFileToString(actual, &pwg_actual_data_str));
- EXPECT_EQ(pwg_expected_data_str.length(), pwg_actual_data_str.length());
- EXPECT_EQ(HashFile(pwg_expected_data_str), HashFile(pwg_actual_data_str));
+ ASSERT_TRUE(base::ReadFileToString(expected_file, &pwg_expected_data_str));
+
+ base::ReadOnlySharedMemoryMapping pwg_mapping = pwg_region.Map();
+ ASSERT_TRUE(pwg_mapping.IsValid());
+ size_t size = pwg_mapping.size();
+ ASSERT_EQ(pwg_expected_data_str.length(), size);
+ EXPECT_EQ(HashData(pwg_expected_data_str.c_str(), size),
+ HashData(static_cast<const char*>(pwg_mapping.memory()), size));
}
class PdfToPwgRasterBrowserTest : public InProcessBrowserTest {
@@ -78,20 +80,19 @@ class PdfToPwgRasterBrowserTest : public InProcessBrowserTest {
: converter_(PwgRasterConverter::CreateDefault()) {}
~PdfToPwgRasterBrowserTest() override {}
- void Convert(base::RefCountedMemory* pdf_data,
+ void Convert(const base::RefCountedMemory* pdf_data,
const PdfRenderSettings& conversion_settings,
const PwgRasterSettings& bitmap_settings,
bool expect_success,
- base::FilePath* temp_file) {
+ base::ReadOnlySharedMemoryRegion* pwg_region) {
bool called = false;
- bool success = false;
base::RunLoop run_loop;
converter_->Start(pdf_data, conversion_settings, bitmap_settings,
- base::BindOnce(&ResultCallbackImpl, &called, &success,
- temp_file, run_loop.QuitClosure()));
+ base::BindOnce(&ResultCallbackImpl, &called, pwg_region,
+ run_loop.QuitClosure()));
run_loop.Run();
ASSERT_TRUE(called);
- EXPECT_EQ(success, expect_success);
+ EXPECT_EQ(expect_success, pwg_region->IsValid());
}
private:
@@ -103,9 +104,9 @@ class PdfToPwgRasterBrowserTest : public InProcessBrowserTest {
IN_PROC_BROWSER_TEST_F(PdfToPwgRasterBrowserTest, TestFailure) {
scoped_refptr<base::RefCountedStaticMemory> bad_pdf_data =
base::MakeRefCounted<base::RefCountedStaticMemory>("0123456789", 10);
- base::FilePath temp_file;
+ base::ReadOnlySharedMemoryRegion pwg_region;
Convert(bad_pdf_data.get(), PdfRenderSettings(), PwgRasterSettings(),
- /*expect_success=*/false, &temp_file);
+ /*expect_success=*/false, &pwg_region);
}
IN_PROC_BROWSER_TEST_F(PdfToPwgRasterBrowserTest, TestSuccessColor) {
@@ -126,14 +127,13 @@ IN_PROC_BROWSER_TEST_F(PdfToPwgRasterBrowserTest, TestSuccessColor) {
pwg_settings.reverse_page_order = false;
pwg_settings.use_color = true;
- base::FilePath temp_file;
+ base::ReadOnlySharedMemoryRegion pwg_region;
Convert(pdf_data.get(), pdf_settings, pwg_settings,
- /*expect_success=*/true, &temp_file);
- ASSERT_FALSE(temp_file.empty());
+ /*expect_success=*/true, &pwg_region);
- base::FilePath pwg_file =
+ base::FilePath expected_pwg_file =
test_data_dir.AppendASCII(kPdfToPwgRasterColorTestFile);
- ComparePwgFiles(pwg_file, temp_file);
+ ComparePwgOutput(expected_pwg_file, std::move(pwg_region));
}
IN_PROC_BROWSER_TEST_F(PdfToPwgRasterBrowserTest, TestSuccessMono) {
@@ -154,14 +154,13 @@ IN_PROC_BROWSER_TEST_F(PdfToPwgRasterBrowserTest, TestSuccessMono) {
pwg_settings.reverse_page_order = false;
pwg_settings.use_color = false;
- base::FilePath temp_file;
+ base::ReadOnlySharedMemoryRegion pwg_region;
Convert(pdf_data.get(), pdf_settings, pwg_settings,
- /*expect_success=*/true, &temp_file);
- ASSERT_FALSE(temp_file.empty());
+ /*expect_success=*/true, &pwg_region);
- base::FilePath pwg_file =
+ base::FilePath expected_pwg_file =
test_data_dir.AppendASCII(kPdfToPwgRasterMonoTestFile);
- ComparePwgFiles(pwg_file, temp_file);
+ ComparePwgOutput(expected_pwg_file, std::move(pwg_region));
}
} // namespace printing
diff --git a/chromium/chrome/browser/printing/test_print_job.cc b/chromium/chrome/browser/printing/test_print_job.cc
index f1d4511ce59..6e929b6feee 100644
--- a/chromium/chrome/browser/printing/test_print_job.cc
+++ b/chromium/chrome/browser/printing/test_print_job.cc
@@ -9,23 +9,25 @@
#include "base/memory/ref_counted_memory.h"
#include "build/build_config.h"
#include "chrome/browser/printing/print_job_worker.h"
-#include "chrome/browser/printing/print_job_worker_owner.h"
+#include "chrome/browser/printing/printer_query.h"
#include "chrome/browser/printing/test_print_job.h"
#include "printing/printed_document.h"
#include "ui/gfx/geometry/size.h"
namespace printing {
-void TestPrintJob::Initialize(PrintJobWorkerOwner* job,
+void TestPrintJob::Initialize(PrinterQuery* query,
const base::string16& name,
int page_count) {
// Since we do not actually print in these tests, just let this get destroyed
// when this function exits.
- std::unique_ptr<PrintJobWorker> worker = job->DetachWorker(this);
- set_settings(job->settings());
+ std::unique_ptr<PrintJobWorker> worker = query->DetachWorker();
+
+ set_settings(query->settings());
scoped_refptr<PrintedDocument> new_doc =
- base::MakeRefCounted<PrintedDocument>(settings(), name, job->cookie());
+ base::MakeRefCounted<PrintedDocument>(query->settings(), name,
+ query->cookie());
new_doc->set_page_count(page_count);
UpdatePrintedDocument(new_doc.get());
@@ -51,8 +53,7 @@ bool TestPrintJob::FlushJob(base::TimeDelta timeout) {
void TestPrintJob::StartPdfToEmfConversion(
const scoped_refptr<base::RefCountedMemory>& bytes,
const gfx::Size& page_size,
- const gfx::Rect& content_area,
- bool print_text_with_gdi) {
+ const gfx::Rect& content_area) {
page_size_ = page_size;
content_area_ = content_area;
type_ = PrintSettings::PrinterType::TYPE_NONE;
@@ -61,10 +62,10 @@ void TestPrintJob::StartPdfToEmfConversion(
void TestPrintJob::StartPdfToPostScriptConversion(
const scoped_refptr<base::RefCountedMemory>& bytes,
const gfx::Rect& content_area,
- const gfx::Point& physical_offset,
+ const gfx::Point& physical_offsets,
bool ps_level2) {
content_area_ = content_area;
- offsets_ = physical_offset;
+ physical_offsets_ = physical_offsets;
type_ = ps_level2 ? PrintSettings::PrinterType::TYPE_POSTSCRIPT_LEVEL2
: PrintSettings::PrinterType::TYPE_POSTSCRIPT_LEVEL3;
}
diff --git a/chromium/chrome/browser/printing/test_print_job.h b/chromium/chrome/browser/printing/test_print_job.h
index f381dc048db..0c779de19df 100644
--- a/chromium/chrome/browser/printing/test_print_job.h
+++ b/chromium/chrome/browser/printing/test_print_job.h
@@ -11,11 +11,12 @@
#include "base/macros.h"
#include "build/build_config.h"
#include "chrome/browser/printing/print_job.h"
-#include "chrome/browser/printing/print_job_worker_owner.h"
#include "printing/print_settings.h"
namespace printing {
+class PrinterQuery;
+
class TestPrintJob : public PrintJob {
public:
// Create a empty PrintJob. When initializing with this constructor,
@@ -25,7 +26,7 @@ class TestPrintJob : public PrintJob {
// Getters for values stored by TestPrintJob in Start...Converter functions.
const gfx::Size& page_size() const { return page_size_; }
const gfx::Rect& content_area() const { return content_area_; }
- const gfx::Point& offsets() const { return offsets_; }
+ const gfx::Point& physical_offsets() const { return physical_offsets_; }
#if defined(OS_WIN)
PrintSettings::PrinterType type() const { return type_; }
#endif
@@ -36,7 +37,7 @@ class TestPrintJob : public PrintJob {
const content::NotificationDetails& details) override {}
// All remaining functions are PrintJob implementation.
- void Initialize(PrintJobWorkerOwner* job,
+ void Initialize(PrinterQuery* query,
const base::string16& name,
int page_count) override;
@@ -53,19 +54,17 @@ class TestPrintJob : public PrintJob {
bool FlushJob(base::TimeDelta timeout) override;
#if defined(OS_WIN)
- // These functions fill in the values pointed to by |page_size_|,
- // |content_area_|, |offsets_| and |type_| based on the arguments passed
- // to them.
+ // These functions fill in the corresponding member variables based on the
+ // arguments passed in.
void StartPdfToEmfConversion(
const scoped_refptr<base::RefCountedMemory>& bytes,
const gfx::Size& page_size,
- const gfx::Rect& content_area,
- bool print_text_with_gdi) override;
+ const gfx::Rect& content_area) override;
void StartPdfToPostScriptConversion(
const scoped_refptr<base::RefCountedMemory>& bytes,
const gfx::Rect& content_area,
- const gfx::Point& physical_offset,
+ const gfx::Point& physical_offsets,
bool ps_level2) override;
void StartPdfToTextConversion(
@@ -73,13 +72,12 @@ class TestPrintJob : public PrintJob {
const gfx::Size& page_size) override;
#endif // defined(OS_WIN)
- protected:
+ private:
~TestPrintJob() override;
- private:
gfx::Size page_size_;
gfx::Rect content_area_;
- gfx::Point offsets_;
+ gfx::Point physical_offsets_;
#if defined(OS_WIN)
PrintSettings::PrinterType type_;
#endif
diff --git a/chromium/chrome/browser/printing/test_printer_query.h b/chromium/chrome/browser/printing/test_printer_query.h
index 4432b62ceac..934fc99d68d 100644
--- a/chromium/chrome/browser/printing/test_printer_query.h
+++ b/chromium/chrome/browser/printing/test_printer_query.h
@@ -11,7 +11,6 @@
#include "base/macros.h"
#include "build/build_config.h"
#include "chrome/browser/printing/print_job_manager.h"
-#include "chrome/browser/printing/print_job_worker_owner.h"
#include "chrome/browser/printing/printer_query.h"
namespace base {
diff --git a/chromium/chrome/browser/profiling_host/BUILD.gn b/chromium/chrome/browser/profiling_host/BUILD.gn
index aa354dc925e..853b995581d 100644
--- a/chromium/chrome/browser/profiling_host/BUILD.gn
+++ b/chromium/chrome/browser/profiling_host/BUILD.gn
@@ -29,8 +29,6 @@ if (!is_android) {
sources = [
"memlog_browsertest.cc",
- "profiling_test_driver.cc",
- "profiling_test_driver.h",
]
defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
@@ -39,6 +37,7 @@ if (!is_android) {
"//base",
"//base/allocator:buildflags",
"//chrome/test:test_support_ui",
+ "//components/heap_profiling:test_support",
"//components/services/heap_profiling/public/cpp",
"//testing/gmock",
"//testing/gtest",
@@ -47,27 +46,11 @@ if (!is_android) {
} else {
import("//build/config/android/rules.gni")
- # In-process browser tests aren't supported on Android.
+ # In-process browser tests aren't supported on Android. The tests are run as
+ # instrumentation tests.
group("profiling_browsertests") {
}
- generate_jni("jni_headers") {
- sources = [
- "../../android/javatests/src/org/chromium/chrome/browser/profiling_host/TestAndroidShim.java",
- ]
- jni_package = "chrome_profiling_host"
- }
-
- # This library must be included by the apk_under_test in order for the JNI
- # shim to function correctly.
- android_library("profiling_host_java_test_support") {
- testonly = true
- java_files = [ "../../android/javatests/src/org/chromium/chrome/browser/profiling_host/TestAndroidShim.java" ]
- deps = [
- "//base:base_java",
- ]
- }
-
# This library must be included by the instrumentation_test. It must not be
# included by the apk_under_test, since in debug builds, java classes that
# appear in the apk_under_test are stripped from the instrumentation_test.
@@ -77,11 +60,11 @@ if (!is_android) {
testonly = true
java_files = [ "../../android/javatests/src/org/chromium/chrome/browser/profiling_host/ProfilingProcessHostAndroidTest.java" ]
deps = [
- ":profiling_host_java_test_support",
"//base:base_java",
"//base:base_java_test_support",
"//chrome/android:chrome_java",
"//chrome/test/android:chrome_java_test_support",
+ "//components/heap_profiling:heap_profiling_java_test_support",
"//third_party/android_support_test_runner:rules_java",
"//third_party/android_support_test_runner:runner_java",
"//third_party/junit",
diff --git a/chromium/chrome/browser/resource_coordinator/tab_ranker/BUILD.gn b/chromium/chrome/browser/resource_coordinator/tab_ranker/BUILD.gn
new file mode 100644
index 00000000000..9ca357b5e2b
--- /dev/null
+++ b/chromium/chrome/browser/resource_coordinator/tab_ranker/BUILD.gn
@@ -0,0 +1,31 @@
+# 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.
+
+source_set("tab_ranker") {
+ # Dependent targets should not include native_inference.h directly.
+ public = [
+ "mru_features.h",
+ "tab_features.h",
+ "tab_score_predictor.h",
+ "window_features.h",
+ ]
+
+ sources = [
+ "native_inference.cc",
+ "native_inference.h",
+ "tab_features.cc",
+ "tab_score_predictor.cc",
+ "window_features.cc",
+ ]
+
+ deps = [
+ "//base",
+ "//chrome/browser:resources",
+ "//chrome/browser/resource_coordinator:tab_metrics_event_proto",
+ "//components/assist_ranker",
+ "//components/assist_ranker/proto",
+ "//components/sessions",
+ "//ui/base",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/BUILD.gn b/chromium/chrome/browser/resources/BUILD.gn
index 8f492140686..94569586b3b 100644
--- a/chromium/chrome/browser/resources/BUILD.gn
+++ b/chromium/chrome/browser/resources/BUILD.gn
@@ -10,9 +10,38 @@ assert(!is_ios, "Chromium/iOS shouldn't use anything in //chrome")
if (closure_compile) {
group("closure_compile") {
deps = [
+ "cryptotoken:closure_compile",
"engagement:closure_compile",
- "md_bookmarks:closure_compile",
]
+ if (is_linux || is_win || is_mac) {
+ deps += [
+ "md_bookmarks:closure_compile",
+ "md_downloads:closure_compile",
+ "md_history:closure_compile",
+ "media_router:closure_compile",
+ "ntp4:closure_compile",
+ "pdf:closure_compile",
+ "print_preview:closure_compile",
+ "settings:closure_compile",
+ ]
+ }
+ if (is_chromeos) {
+ deps += [
+ "md_user_manager:closure_compile",
+ "signin/dice_sync_confirmation:closure_compile",
+ "welcome/dice_welcome:closure_compile",
+ ]
+ }
+ if (enable_extensions) {
+ deps += [ "md_extensions:closure_compile" ]
+ }
+ if (is_android) {
+ deps += [
+ "offline_pages:closure_compile",
+ "snippets_internals:closure_compile",
+ "webapks:closure_compile",
+ ]
+ }
}
}
diff --git a/chromium/chrome/browser/resources/PRESUBMIT.py b/chromium/chrome/browser/resources/PRESUBMIT.py
index 67679981a0f..a8156d44925 100644
--- a/chromium/chrome/browser/resources/PRESUBMIT.py
+++ b/chromium/chrome/browser/resources/PRESUBMIT.py
@@ -8,8 +8,6 @@ See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details about the presubmit API built into depot_tools.
"""
-import os
-
ACTION_XML_PATH = '../../../tools/metrics/actions/actions.xml'
@@ -125,8 +123,8 @@ def _CheckChangeOnUploadOrCommit(input_api, output_api):
results += CheckHtml(input_api, output_api)
webui_sources = set(['optimize_webui.py', 'unpack_pak.py'])
- affected_filenames = set([os.path.basename(f.LocalPath()) for f in affected])
- if webui_sources.intersection(affected_filenames):
+ affected_files = [input_api.os_path.basename(f.LocalPath()) for f in affected]
+ if webui_sources.intersection(set(affected_files)):
results += RunOptimizeWebUiTests(input_api, output_api)
results += _CheckWebDevStyle(input_api, output_api)
results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api,
diff --git a/chromium/chrome/browser/resources/about_conflicts.html b/chromium/chrome/browser/resources/about_conflicts.html
index 59602eae8d8..5eadf36f14b 100644
--- a/chromium/chrome/browser/resources/about_conflicts.html
+++ b/chromium/chrome/browser/resources/about_conflicts.html
@@ -1,5 +1,5 @@
<!doctype html>
-<html i18n-values="dir:textdirection;lang:language">
+<html dir="$i18n{textdirection}" lang="$i18n{language}">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="chrome://resources/css/text_defaults.css">
@@ -139,14 +139,14 @@ html[dir=rtl] .clearing {
</style>
</head>
<body>
-<div id="loading-message" i18n-content="loadingMessage"></div>
+<div id="loading-message">$i18n{loadingMessage}</div>
<div id="body-container" style="visibility:hidden">
- <div id="header"><h1 i18n-content="modulesLongTitle">TITLE</h1></div>
+ <div id="header"><h1>$i18n{modulesLongTitle}</h1></div>
<div id="blurb-container">
- <span i18n-content="modulesBlurb">MODULES BLURB</span>
+ <span>$i18n{modulesBlurb}</span>
</div>
<div id="modulesTemplate">
@@ -169,7 +169,7 @@ html[dir=rtl] .clearing {
<div class="content">
<div class="module-name no-modules"
jsdisplay="moduleList.length === 0">
- <div i18n-content="modulesNoneLoaded">NO_MODULES_ARE_AVAILABLE</div>
+ <div>$i18n{modulesNoneLoaded}</div>
</div>
<div jsdisplay="moduleList.length &gt; 0">
@@ -178,14 +178,18 @@ html[dir=rtl] .clearing {
<td valign="top">
<table cellpadding="2" cellspacing="0" border="0">
<tr>
- <td class="datacell"><span dir="ltr" i18n-content="headerSoftware"
- >SOFTWARE</span></td>
- <td class="datacell"><span dir="ltr" i18n-content="headerSignedBy"
- >SIGNER</span></td>
- <td class="datacell"><span dir="ltr" i18n-content="headerVersion"
- >VERSION</span></td>
- <td class="datacell"><span dir="ltr" i18n-content="headerLocation"
- >LOCATION</span></td>
+ <td class="datacell">
+ <span dir="ltr">$i18n{headerSoftware}</span>
+ </td>
+ <td class="datacell">
+ <span dir="ltr">$i18n{headerSignedBy}</span>
+ </td>
+ <td class="datacell">
+ <span dir="ltr">$i18n{headerVersion}</span>
+ </td>
+ <td class="datacell">
+ <span dir="ltr">$i18n{headerLocation}</span>
+ </td>
</tr>
<tr jsselect="moduleList">
<td valign="top" class="datacell">
@@ -196,11 +200,9 @@ html[dir=rtl] .clearing {
class="extra-info-text">
<span class="clearing">
<span jsdisplay="status == 2"
- i18n-content="moduleSuspectedBad"
- class="suspected-bad">SUSPECTED_BAD</span>
+ class="suspected-bad">$i18n{moduleSuspectedBad}</span>
<span jsdisplay="status == 3"
- i18n-content="moduleConfirmedBad"
- class="confirmed-bad">CONFIRMED_BAD</span>
+ class="confirmed-bad">$i18n{moduleConfirmedBad}</span>
</span>
<span class="clearing">
<span jsdisplay="possibleResolution.length &gt; 0">
@@ -208,8 +210,7 @@ html[dir=rtl] .clearing {
>POSSIBLE_RESOLUTION</span>
</span>
<a jsdisplay="help_url.length &gt; 0"
- jsvalues=".href:help_url"
- i18n-content="helpCenterLink">HELP_CENTER</a>
+ jsvalues=".href:help_url">$i18n{helpCenterLink}</a>
</span>
</div>
</td>
diff --git a/chromium/chrome/browser/resources/bookmark_manager/css/bmm.css b/chromium/chrome/browser/resources/bookmark_manager/css/bmm.css
deleted file mode 100644
index a550ec56d1f..00000000000
--- a/chromium/chrome/browser/resources/bookmark_manager/css/bmm.css
+++ /dev/null
@@ -1,392 +0,0 @@
-/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file. */
-
-<include src="../search_header.css">
-
-html,
-body {
- cursor: default;
- height: 100%;
- margin: 0;
- overflow: hidden;
- width: 100%;
-}
-
-body {
- display: flex;
- flex-direction: column;
-}
-
-list {
- display: block;
- overflow-x: hidden;
- overflow-y: visible; /* let the container do the scrolling */
-}
-
-list > * {
- -webkit-padding-end: 20px;
- -webkit-padding-start: 3px;
- color: hsl(0, 0%, 70%);
- display: flex;
- line-height: 20px;
- margin: 0;
- overflow: visible;
- padding-bottom: 0;
- padding-top: 0;
- text-decoration: none;
- white-space: nowrap;
-}
-
-list > * > * {
- -webkit-padding-start: 20px;
- background: 0 50% no-repeat;
- box-sizing: border-box;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: pre;
-}
-
-list .label {
- -webkit-padding-start: 0;
- align-items: center;
- display: flex;
-}
-
-list .label-img-wrapper {
- display: inline-block; /* Makes the image start-align in RTL. */
- width: 20px;
- z-index: -1;
-}
-
-<if expr="not is_macosx">
-html[dir=rtl] list > .folder .label-img-wrapper > * {
- transform: scaleX(-1);
-}
-</if>
-
-list .label-text {
- color: black;
- flex: 1;
- overflow: hidden;
- text-overflow: ellipsis;
-}
-
-/* We need to ensure that even empty labels take up space, or the row could be
- * the wrong height. */
-list .label-text:empty::after {
- content: ' ';
- white-space: pre;
-}
-
-list .url {
- direction: ltr;
- display: none;
- flex: 1;
-}
-
-list > :hover > .url,
-list > [selected] > .url {
- display: block;
-}
-
-/* Handle proper padding for URL field in an RTL context, where field order is
- * |div.url||div.label| - so we need padding at the right of URL, not at the
- * left. And since url is always LTR, that is padding at the end, not the start.
- */
-html[dir=rtl] list .url {
- -webkit-padding-end: 20px;
- -webkit-padding-start: 0;
- text-align: right;
-}
-
-list > * > button {
- background: #fff no-repeat center center;
- border: 1px solid hsl(214, 91%, 85%);
- border-radius: 3px;
- bottom: 1px;
- display: none;
- overflow: hidden;
- padding: 0;
- position: absolute;
- right: 3px;
- top: 1px;
- transition: opacity 150ms;
- width: 15px;
-}
-
-list > [selected]:hover > button,
-list > * > button[menu-shown] {
- border-color: hsl(214, 91%, 65%);
-}
-
-list > :hover > button {
- display: block;
-}
-
-list > * > button:hover,
-list > * > button[menu-shown] {
- display: block;
-}
-
-html[dir=rtl] list > * > button {
- left: 3px;
- right: auto;
-}
-
-/* Edit mode */
-
-list [editing] .label-text input,
-list [editing] .url input {
- -webkit-margin-end: 4px;
- -webkit-margin-start: -4px;
- -webkit-padding-end: 3px;
- -webkit-padding-start: 3px;
- box-sizing: content-box;
- font-family: inherit;
- font-size: inherit;
- font-weight: inherit;
- /* Do not inherit the line-height. */
- line-height: normal;
- margin-bottom: 0;
- margin-top: 0;
- min-height: 0;
- text-decoration: none;
- vertical-align: baseline;
-}
-
-.tree-item [editing] input {
- line-height: normal;
- margin: 0;
- min-height: 0;
- padding: 1px 0;
-}
-
-<if expr="is_macosx">
-list .label-text input,
-list .url input {
- outline: none;
-}
-</if>
-
-list > [editing] {
- overflow: visible;
-}
-
-list [editing] .label-text,
-list [editing] .url,
-list [editing] > * {
- overflow: visible;
-}
-
-list [editing] .url {
- -webkit-padding-start: 5px;
-}
-
-list [editing] input {
- padding: 1px 0;
-}
-
-/* end editing */
-
-.main {
- border-top: 1px solid rgb(156, 194, 239);
- display: flex;
- flex: 1;
- min-height: 0;
-}
-
-.pane,
-.splitter {
- display: flex;
- flex-direction: column;
-}
-
-.pane > :first-child,
-.splitter > :first-child {
- background-color: rgb(235, 239, 249);
- flex: none;
- padding: 5px 10px;
- white-space: nowrap;
-}
-
-.splitter > :first-child {
- overflow: hidden;
- padding-left: 0;
- padding-right: 0;
- width: 15px;
-}
-
-.splitter button {
- visibility: hidden; /* This button is only used for height matching. */
-}
-
-#tree-pane {
- /* min-width and max-width are used by the split pane. */
- max-width: 50%;
- min-width: 150px;
- width: 200px;
-}
-
-#list-pane {
- flex: 1;
- min-width: 0;
-}
-
-#list-pane > :first-child {
- -webkit-padding-start: 0; /* Accounts for extra splitter resize width. */
-}
-
-#tree-container {
- overflow: auto;
-}
-
-#list,
-#tree-container {
- flex: 1;
-}
-
-#tree,
-#list {
- -webkit-padding-end: 5px;
- box-sizing: border-box;
- display: inline-block;
- min-width: 100%;
- padding-bottom: 5px;
- padding-top: 5px;
-}
-
-#tree {
- /* Only pad the tree as the splitter adds a lot of whitespace for the list. */
- -webkit-padding-start: 10px;
-}
-
-.tree-item > .tree-row {
- line-height: 20px;
-}
-
-.tree-row .expand-icon {
- top: 2px;
-}
-
-/* TODO(pkasting): Convert the tree widget to use the same resources as the
- * list, and remove this block. */
-<if expr="is_macosx">
-.tree-label,
-.tree-row[may-have-children] > .tree-label,
-.tree-item[expanded] > .tree-row > .tree-label {
- background-image: -webkit-image-set(
- url(../../../../app/theme/default_100_percent/mac/bookmark_bar_folder.png) 1x,
- url(../../../../app/theme/default_200_percent/mac/bookmark_bar_folder.png) 2x);
-}
-</if>
-
-.splitter {
- border-left: 5px solid rgb(235, 239, 249);
- cursor: e-resize;
-<if expr="is_macosx">
- cursor: col-resize;
-</if>
- overflow-x: hidden;
-}
-
-.tree-row.drag-on,
-.drag-on {
- background-color: hsla(214, 91%, 85%, .5);
- border: 1px solid hsl(214, 91%, 85%);
- border-radius: 3px;
- box-sizing: border-box;
-}
-
-.drag-above::before,
-.drag-below::after {
- background-clip: padding-box;
- background-color: black;
- border: 3px solid black;
- border-bottom-color: transparent;
- border-radius: 0;
- border-top-color: transparent;
- box-sizing: border-box;
- content: '';
- display: block;
- height: 8px;
- left: 0;
- position: absolute;
- right: 0;
- z-index: 10;
-}
-
-.drag-above::before {
- top: calc((8px/2 + 1px) * -1)
-}
-
-.drag-below::after {
- bottom: calc((8px/2 + 1px) * -1)
-}
-
-list.drag-above::before {
- top: 0
-}
-
-list > .drag-below,
-list > .drag-above {
- overflow: visible;
-}
-
-.summary > * {
- font-size: 100%;
- margin: 0;
-}
-
-#folders-button,
-#organize-button,
-.splitter button {
- -webkit-appearance: none;
- -webkit-padding-end: 11px;
- -webkit-padding-start: 0;
- background: transparent no-repeat right center;
- border: 0;
- font: inherit;
- font-weight: bold;
- padding-bottom: 0;
- padding-top: 0;
-}
-
-list > * > button,
-[i18n-processed] #folders-button,
-[i18n-processed] #organize-button,
-[i18n-processed] .splitter button {
- background-image:
- url(../../../../../ui/webui/resources/images/drop_down_arrow_black.svg);
- background-size: 9px 4px;
-}
-
-#folders-button {
- -webkit-margin-start: 16px;
-}
-
-#organize-button {
- -webkit-margin-start: 4px;
-}
-
-html[dir=rtl] #folders-button,
-html[dir=rtl] #organize-button {
- background-position: left center;
-}
-
-@media (pointer:coarse) {
- list > *,
- cr-menu > button,
- .tree-item > .tree-row {
- line-height: 28px;
- }
-
- list [editing] input,
- .tree-item [editing] input {
- padding: 3px 0;
- }
-
- .tree-row .expand-icon {
- top: 6px;
- }
-}
diff --git a/chromium/chrome/browser/resources/bookmark_manager/images/2x/bookmark_manager_search.png b/chromium/chrome/browser/resources/bookmark_manager/images/2x/bookmark_manager_search.png
deleted file mode 100644
index 438c6782b6b..00000000000
--- a/chromium/chrome/browser/resources/bookmark_manager/images/2x/bookmark_manager_search.png
+++ /dev/null
Binary files differ
diff --git a/chromium/chrome/browser/resources/bookmark_manager/images/2x/bookmark_manager_search_rtl.png b/chromium/chrome/browser/resources/bookmark_manager/images/2x/bookmark_manager_search_rtl.png
deleted file mode 100644
index 439055ba71c..00000000000
--- a/chromium/chrome/browser/resources/bookmark_manager/images/2x/bookmark_manager_search_rtl.png
+++ /dev/null
Binary files differ
diff --git a/chromium/chrome/browser/resources/bookmark_manager/images/2x/bookmarks_section_32.png b/chromium/chrome/browser/resources/bookmark_manager/images/2x/bookmarks_section_32.png
deleted file mode 100644
index 5455818ae66..00000000000
--- a/chromium/chrome/browser/resources/bookmark_manager/images/2x/bookmarks_section_32.png
+++ /dev/null
Binary files differ
diff --git a/chromium/chrome/browser/resources/bookmark_manager/images/bookmark_manager_search.png b/chromium/chrome/browser/resources/bookmark_manager/images/bookmark_manager_search.png
deleted file mode 100644
index 46b88a769e1..00000000000
--- a/chromium/chrome/browser/resources/bookmark_manager/images/bookmark_manager_search.png
+++ /dev/null
Binary files differ
diff --git a/chromium/chrome/browser/resources/bookmark_manager/images/bookmark_manager_search_rtl.png b/chromium/chrome/browser/resources/bookmark_manager/images/bookmark_manager_search_rtl.png
deleted file mode 100644
index 2ad79680ab5..00000000000
--- a/chromium/chrome/browser/resources/bookmark_manager/images/bookmark_manager_search_rtl.png
+++ /dev/null
Binary files differ
diff --git a/chromium/chrome/browser/resources/bookmark_manager/images/bookmarks_section_32.png b/chromium/chrome/browser/resources/bookmark_manager/images/bookmarks_section_32.png
deleted file mode 100644
index 555d3400db6..00000000000
--- a/chromium/chrome/browser/resources/bookmark_manager/images/bookmarks_section_32.png
+++ /dev/null
Binary files differ
diff --git a/chromium/chrome/browser/resources/bookmark_manager/js/bmm.js b/chromium/chrome/browser/resources/bookmark_manager/js/bmm.js
deleted file mode 100644
index a981cb9975c..00000000000
--- a/chromium/chrome/browser/resources/bookmark_manager/js/bmm.js
+++ /dev/null
@@ -1,261 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('bmm', function() {
- 'use strict';
-
- /**
- * Whether a node contains another node.
- * TODO(yosin): Once JavaScript style guide is updated and linter follows
- * that, we'll remove useless documentations for |parent| and |descendant|.
- * TODO(yosin): bmm.contains() should be method of BookmarkTreeNode.
- * @param {!BookmarkTreeNode} parent .
- * @param {!BookmarkTreeNode} descendant .
- * @return {boolean} Whether the parent contains the descendant.
- */
- function contains(parent, descendant) {
- if (descendant.parentId == parent.id)
- return true;
- // the bmm.treeLookup contains all folders
- var parentTreeItem = bmm.treeLookup[descendant.parentId];
- if (!parentTreeItem || !parentTreeItem.bookmarkNode)
- return false;
- return this.contains(parent, parentTreeItem.bookmarkNode);
- }
-
- /**
- * @param {!BookmarkTreeNode} node The node to test.
- * @return {boolean} Whether a bookmark node is a folder.
- */
- function isFolder(node) {
- return !('url' in node);
- }
-
- var loadingPromises = {};
-
- /**
- * Promise version of chrome.bookmarkManagerPrivate.getSubtree.
- * @param {string} id .
- * @param {boolean} foldersOnly .
- * @return {!Promise<!Array<!BookmarkTreeNode>>} .
- */
- function getSubtreePromise(id, foldersOnly) {
- return new Promise(function(resolve, reject) {
- chrome.bookmarkManagerPrivate.getSubtree(id, foldersOnly, function(node) {
- if (chrome.runtime.lastError) {
- reject(new Error(chrome.runtime.lastError.message));
- return;
- }
- resolve(node);
- });
- });
- }
-
- /**
- * Loads a subtree of the bookmark tree and returns a {@code Promise} that
- * will be fulfilled when done. This reuses multiple loads so that we do not
- * load the same subtree more than once at the same time.
- * @return {!Promise<!BookmarkTreeNode>} The future promise for the load.
- */
- function loadSubtree(id) {
- if (!loadingPromises[id]) {
- loadingPromises[id] = getSubtreePromise(id, false).then(function(nodes) {
- return nodes && nodes[0];
- }, function(error) {
- console.error(error.message);
- });
- loadingPromises[id].then(function() {
- delete loadingPromises[id];
- });
- }
- return loadingPromises[id];
- }
-
- /**
- * Loads the entire bookmark tree and returns a {@code Promise} that will
- * be fulfilled when done. This reuses multiple loads so that we do not load
- * the same tree more than once at the same time.
- * @return {!Promise<!BookmarkTreeNode>} The future promise for the load.
- */
- function loadTree() {
- return loadSubtree('');
- }
-
- var bookmarkCache = {
- /**
- * Removes the cached item from both the list and tree lookups.
- */
- remove: function(id) {
- var treeItem = bmm.treeLookup[id];
- if (treeItem) {
- var items = treeItem.items; // is an HTMLCollection
- for (var i = 0; i < items.length; ++i) {
- var item = items[i];
- var bookmarkNode = item.bookmarkNode;
- delete bmm.treeLookup[bookmarkNode.id];
- }
- delete bmm.treeLookup[id];
- }
- },
-
- /**
- * Updates the underlying bookmark node for the tree items and list items by
- * querying the bookmark backend.
- * @param {string} id The id of the node to update the children for.
- * @param {Function=} opt_f A funciton to call when done.
- */
- updateChildren: function(id, opt_f) {
- function updateItem(bookmarkNode) {
- var treeItem = bmm.treeLookup[bookmarkNode.id];
- if (treeItem) {
- treeItem.bookmarkNode = bookmarkNode;
- }
- }
-
- chrome.bookmarks.getChildren(id, function(children) {
- if (children)
- children.forEach(updateItem);
-
- if (opt_f)
- opt_f(children);
- });
- }
- };
-
- /**
- * Called when the title of a bookmark changes.
- * @param {string} id The id of changed bookmark node.
- * @param {!Object} changeInfo The information about how the node changed.
- */
- function handleBookmarkChanged(id, changeInfo) {
- if (bmm.tree)
- bmm.tree.handleBookmarkChanged(id, changeInfo);
- if (bmm.list)
- bmm.list.handleBookmarkChanged(id, changeInfo);
- }
-
- /**
- * Callback for when the user reorders by title.
- * @param {string} id The id of the bookmark folder that was reordered.
- * @param {!Object} reorderInfo The information about how the items where
- * reordered.
- */
- function handleChildrenReordered(id, reorderInfo) {
- if (bmm.tree)
- bmm.tree.handleChildrenReordered(id, reorderInfo);
- if (bmm.list)
- bmm.list.handleChildrenReordered(id, reorderInfo);
- bookmarkCache.updateChildren(id);
- }
-
- /**
- * Callback for when a bookmark node is created.
- * @param {string} id The id of the newly created bookmark node.
- * @param {!Object} bookmarkNode The new bookmark node.
- */
- function handleCreated(id, bookmarkNode) {
- if (bmm.list)
- bmm.list.handleCreated(id, bookmarkNode);
- if (bmm.tree)
- bmm.tree.handleCreated(id, bookmarkNode);
- bookmarkCache.updateChildren(bookmarkNode.parentId);
- }
-
- /**
- * Callback for when a bookmark node is moved.
- * @param {string} id The id of the moved bookmark node.
- * @param {!Object} moveInfo The information about move.
- */
- function handleMoved(id, moveInfo) {
- if (bmm.list)
- bmm.list.handleMoved(id, moveInfo);
- if (bmm.tree)
- bmm.tree.handleMoved(id, moveInfo);
-
- bookmarkCache.updateChildren(moveInfo.parentId);
- if (moveInfo.parentId != moveInfo.oldParentId)
- bookmarkCache.updateChildren(moveInfo.oldParentId);
- }
-
- /**
- * Callback for when a bookmark node is removed.
- * @param {string} id The id of the removed bookmark node.
- * @param {!Object} removeInfo The information about removed.
- */
- function handleRemoved(id, removeInfo) {
- if (bmm.list)
- bmm.list.handleRemoved(id, removeInfo);
- if (bmm.tree)
- bmm.tree.handleRemoved(id, removeInfo);
-
- bookmarkCache.updateChildren(removeInfo.parentId);
- bookmarkCache.remove(id);
- }
-
- /**
- * Callback for when all bookmark nodes have been deleted.
- */
- function handleRemoveAll() {
- // Reload the list and the tree.
- if (bmm.list)
- bmm.list.reload();
- if (bmm.tree)
- bmm.tree.reload();
- }
-
- /**
- * Callback for when importing bookmark is started.
- */
- function handleImportBegan() {
- chrome.bookmarks.onCreated.removeListener(handleCreated);
- chrome.bookmarks.onChanged.removeListener(handleBookmarkChanged);
- }
-
- /**
- * Callback for when importing bookmark node is finished.
- */
- function handleImportEnded() {
- // When importing is done we reload the tree and the list.
-
- function f() {
- bmm.tree.removeEventListener('load', f);
-
- chrome.bookmarks.onCreated.addListener(handleCreated);
- chrome.bookmarks.onChanged.addListener(handleBookmarkChanged);
-
- if (!bmm.list)
- return;
-
- // TODO(estade): this should navigate to the newly imported folder, which
- // may be the bookmark bar if there were no previous bookmarks.
- bmm.list.reload();
- }
-
- if (bmm.tree) {
- bmm.tree.addEventListener('load', f);
- bmm.tree.reload();
- }
- }
-
- /**
- * Adds the listeners for the bookmark model change events.
- */
- function addBookmarkModelListeners() {
- chrome.bookmarks.onChanged.addListener(handleBookmarkChanged);
- chrome.bookmarks.onChildrenReordered.addListener(handleChildrenReordered);
- chrome.bookmarks.onCreated.addListener(handleCreated);
- chrome.bookmarks.onMoved.addListener(handleMoved);
- chrome.bookmarks.onRemoved.addListener(handleRemoved);
- chrome.bookmarks.onImportBegan.addListener(handleImportBegan);
- chrome.bookmarks.onImportEnded.addListener(handleImportEnded);
- }
-
- return {
- contains: contains,
- isFolder: isFolder,
- loadSubtree: loadSubtree,
- loadTree: loadTree,
- addBookmarkModelListeners: addBookmarkModelListeners
- };
-});
diff --git a/chromium/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js b/chromium/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js
deleted file mode 100644
index 089b77a7044..00000000000
--- a/chromium/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js
+++ /dev/null
@@ -1,658 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// TODO(arv): Now that this is driven by a data model, implement a data model
-// that handles the loading and the events from the bookmark backend.
-
-/**
- * @typedef {{childIds: Array<string>}}
- *
- * @see chrome/common/extensions/api/bookmarks.json
- */
-var ReorderInfo;
-
-/**
- * @typedef {{parentId: string,
- * index: number,
- * oldParentId: string,
- * oldIndex: number}}
- *
- * @see chrome/common/extensions/api/bookmarks.json
- */
-var MoveInfo;
-
-cr.define('bmm', function() {
- 'use strict';
-
- var List = cr.ui.List;
- var ListItem = cr.ui.ListItem;
- var ArrayDataModel = cr.ui.ArrayDataModel;
- var ContextMenuButton = cr.ui.ContextMenuButton;
-
- /**
- * Basic array data model for use with bookmarks.
- * @param {!Array<!BookmarkTreeNode>} items The bookmark items.
- * @constructor
- * @extends {ArrayDataModel}
- */
- function BookmarksArrayDataModel(items) {
- ArrayDataModel.call(this, items);
- }
-
- BookmarksArrayDataModel.prototype = {
- __proto__: ArrayDataModel.prototype,
-
- /**
- * Finds the index of the bookmark with the given ID.
- * @param {string} id The ID of the bookmark node to find.
- * @return {number} The index of the found node or -1 if not found.
- */
- findIndexById: function(id) {
- for (var i = 0; i < this.length; i++) {
- if (this.item(i).id == id)
- return i;
- }
- return -1;
- }
- };
-
- /**
- * Removes all children and appends a new child.
- * @param {!Node} parent The node to remove all children from.
- * @param {!Node} newChild The new child to append.
- */
- function replaceAllChildren(parent, newChild) {
- var n;
- while ((n = parent.lastChild)) {
- parent.removeChild(n);
- }
- parent.appendChild(newChild);
- }
-
- /**
- * Creates a new bookmark list.
- * @param {Object=} opt_propertyBag Optional properties.
- * @constructor
- * @extends {cr.ui.List}
- */
- var BookmarkList = cr.ui.define('list');
-
- BookmarkList.prototype = {
- __proto__: List.prototype,
-
- /** @override */
- decorate: function() {
- List.prototype.decorate.call(this);
- this.addEventListener('mousedown', this.handleMouseDown_);
-
- // HACK(arv): http://crbug.com/40902
- window.addEventListener('resize', this.redraw.bind(this));
-
- // We could add the ContextMenuButton in the BookmarkListItem but it slows
- // down redraws a lot so we do this on mouseovers instead.
- this.addEventListener('mouseover', this.handleMouseOver_.bind(this));
-
- bmm.list = this;
- },
-
- /**
- * @param {!BookmarkTreeNode} bookmarkNode
- * @override
- */
- createItem: function(bookmarkNode) {
- return new BookmarkListItem(bookmarkNode);
- },
-
- /** @private {string} */
- parentId_: '',
-
- /** @private {number} */
- loadCount_: 0,
-
- /**
- * Reloads the list from the bookmarks backend.
- */
- reload: function() {
- var parentId = this.parentId;
-
- var callback = this.handleBookmarkCallback_.bind(this);
-
- this.loadCount_++;
-
- if (!parentId)
- callback([]);
- else if (/^q=/.test(parentId))
- chrome.bookmarks.search(parentId.slice(2), callback);
- else
- chrome.bookmarks.getChildren(parentId, callback);
- },
-
- /**
- * Callback function for loading items.
- * @param {Array<!BookmarkTreeNode>} items The loaded items.
- * @private
- */
- handleBookmarkCallback_: function(items) {
- this.loadCount_--;
- if (this.loadCount_)
- return;
-
- if (!items) {
- // Failed to load bookmarks. Most likely due to the bookmark being
- // removed.
- cr.dispatchSimpleEvent(this, 'invalidId');
- return;
- }
-
- this.dataModel = new BookmarksArrayDataModel(items);
-
- this.fixWidth_();
- cr.dispatchSimpleEvent(this, 'load');
-
- // Use the same histogram configuration as UMA_HISTOGRAM_COUNTS_1000().
- chrome.metricsPrivate.recordValue({
- 'metricName': 'Bookmarks.BookmarksInFolder',
- 'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LOG,
- 'min': 1,
- 'max': 1000,
- 'buckets': 50
- }, this.dataModel.length);
- },
-
- /**
- * The bookmark node that the list is currently displaying. If we are
- * currently displaying search this returns null.
- * @type {BookmarkTreeNode}
- */
- get bookmarkNode() {
- if (this.isSearch())
- return null;
- var treeItem = bmm.treeLookup[this.parentId];
- return treeItem && treeItem.bookmarkNode;
- },
-
- /**
- * @return {boolean} Whether we are currently showing search results.
- */
- isSearch: function() {
- return this.parentId_[0] == 'q';
- },
-
- /**
- * @return {boolean} Whether we are editing an ephemeral item.
- */
- hasEphemeral: function() {
- var dataModel = this.dataModel;
- for (var i = 0; i < dataModel.array_.length; i++) {
- if (dataModel.array_[i].id == 'new')
- return true;
- }
- return false;
- },
-
- /**
- * Handles mouseover on the list so that we can add the context menu button
- * lazily.
- * @private
- * @param {!Event} e The mouseover event object.
- */
- handleMouseOver_: function(e) {
- var el = e.target;
- while (el && el.parentNode != this) {
- el = el.parentNode;
- }
-
- if (el && el.parentNode == this &&
- !el.editing &&
- !(el.lastChild instanceof ContextMenuButton)) {
- el.appendChild(new ContextMenuButton);
- }
- },
-
- /**
- * Dispatches an urlClicked event which is used to open URLs in new
- * tabs etc.
- * @private
- * @param {string} url The URL that was clicked.
- * @param {!Event} originalEvent The original click event object.
- */
- dispatchUrlClickedEvent_: function(url, originalEvent) {
- var event = new Event('urlClicked', {bubbles: true});
- event.url = url;
- event.originalEvent = originalEvent;
- this.dispatchEvent(event);
- },
-
- /**
- * Handles mousedown events so that we can prevent the auto scroll as
- * necessary.
- * @private
- * @param {!Event} e The mousedown event object.
- */
- handleMouseDown_: function(e) {
- e = /** @type {!MouseEvent} */(e);
- if (e.button == 1) {
- // WebKit no longer fires click events for middle clicks so we manually
- // listen to mouse up to dispatch a click event.
- this.addEventListener('mouseup', this.handleMiddleMouseUp_);
-
- // When the user does a middle click we need to prevent the auto scroll
- // in case the user is trying to middle click to open a bookmark in a
- // background tab.
- // We do not do this in case the target is an input since middle click
- // is also paste on Linux and we don't want to break that.
- if (e.target.tagName != 'INPUT')
- e.preventDefault();
- }
- },
-
- /**
- * WebKit no longer dispatches click events for middle clicks so we need
- * to emulate it.
- * @private
- * @param {!Event} e The mouse up event object.
- */
- handleMiddleMouseUp_: function(e) {
- e = /** @type {!MouseEvent} */(e);
- this.removeEventListener('mouseup', this.handleMiddleMouseUp_);
- if (e.button == 1) {
- var el = e.target;
- while (el.parentNode != this) {
- el = el.parentNode;
- }
- var node = el.bookmarkNode;
- if (node && !bmm.isFolder(node))
- this.dispatchUrlClickedEvent_(node.url, e);
- }
- e.preventDefault();
- },
-
- // Bookmark model update callbacks
- handleBookmarkChanged: function(id, changeInfo) {
- var dataModel = this.dataModel;
- var index = dataModel.findIndexById(id);
- if (index != -1) {
- var bookmarkNode = this.dataModel.item(index);
- bookmarkNode.title = changeInfo.title;
- if ('url' in changeInfo)
- bookmarkNode.url = changeInfo['url'];
-
- dataModel.updateIndex(index);
- }
- },
-
- /**
- * @param {string} id
- * @param {ReorderInfo} reorderInfo
- */
- handleChildrenReordered: function(id, reorderInfo) {
- if (this.parentId == id) {
- // We create a new data model with updated items in the right order.
- var dataModel = this.dataModel;
- var items = {};
- for (var i = this.dataModel.length - 1; i >= 0; i--) {
- var bookmarkNode = dataModel.item(i);
- items[bookmarkNode.id] = bookmarkNode;
- }
- var newArray = [];
- for (var i = 0; i < reorderInfo.childIds.length; i++) {
- newArray[i] = items[reorderInfo.childIds[i]];
- newArray[i].index = i;
- }
-
- this.dataModel = new BookmarksArrayDataModel(newArray);
- }
- },
-
- handleCreated: function(id, bookmarkNode) {
- if (this.parentId == bookmarkNode.parentId)
- this.dataModel.splice(bookmarkNode.index, 0, bookmarkNode);
- },
-
- /**
- * @param {string} id
- * @param {MoveInfo} moveInfo
- */
- handleMoved: function(id, moveInfo) {
- if (moveInfo.parentId == this.parentId ||
- moveInfo.oldParentId == this.parentId) {
-
- var dataModel = this.dataModel;
-
- if (moveInfo.oldParentId == moveInfo.parentId) {
- // Reorder within this folder
-
- this.startBatchUpdates();
-
- var bookmarkNode = this.dataModel.item(moveInfo.oldIndex);
- this.dataModel.splice(moveInfo.oldIndex, 1);
- this.dataModel.splice(moveInfo.index, 0, bookmarkNode);
-
- this.endBatchUpdates();
- } else {
- if (moveInfo.oldParentId == this.parentId) {
- // Move out of this folder
-
- var index = dataModel.findIndexById(id);
- if (index != -1)
- dataModel.splice(index, 1);
- }
-
- if (moveInfo.parentId == this.parentId) {
- // Move to this folder
- var self = this;
- chrome.bookmarks.get(id, function(bookmarkNodes) {
- var bookmarkNode = bookmarkNodes[0];
- dataModel.splice(bookmarkNode.index, 0, bookmarkNode);
- });
- }
- }
- }
- },
-
- handleRemoved: function(id, removeInfo) {
- var dataModel = this.dataModel;
- var index = dataModel.findIndexById(id);
- if (index != -1)
- dataModel.splice(index, 1);
- },
-
- /**
- * Workaround for http://crbug.com/40902
- * @private
- */
- fixWidth_: function() {
- var list = bmm.list;
- if (this.loadCount_ || !list)
- return;
-
- // The width of the list is wrong after its content has changed.
- // Fortunately the reported offsetWidth is correct so we can detect the
- //incorrect width.
- if (list.offsetWidth != list.parentNode.clientWidth - list.offsetLeft) {
- // Set the width to the correct size. This causes the relayout.
- list.style.width = list.parentNode.clientWidth - list.offsetLeft + 'px';
- // Remove the temporary style.width in a timeout. Once the timer fires
- // the size should not change since we already fixed the width.
- window.setTimeout(function() {
- list.style.width = '';
- }, 0);
- }
- }
- };
-
- /**
- * The ID of the bookmark folder we are displaying.
- */
- cr.defineProperty(BookmarkList, 'parentId', cr.PropertyKind.JS,
- function() {
- this.reload();
- });
-
- /**
- * The contextMenu property.
- */
- cr.ui.contextMenuHandler.addContextMenuProperty(BookmarkList);
- /** @type {cr.ui.Menu} */
- BookmarkList.prototype.contextMenu;
-
- /**
- * Creates a new bookmark list item.
- * @param {!BookmarkTreeNode} bookmarkNode The bookmark node this represents.
- * @constructor
- * @extends {cr.ui.ListItem}
- */
- function BookmarkListItem(bookmarkNode) {
- var el = cr.doc.createElement('div');
- el.bookmarkNode = bookmarkNode;
- BookmarkListItem.decorate(el);
- return el;
- }
-
- /**
- * Decorates an element as a bookmark list item.
- * @param {!HTMLElement} el The element to decorate.
- */
- BookmarkListItem.decorate = function(el) {
- el.__proto__ = BookmarkListItem.prototype;
- el.decorate();
- };
-
- BookmarkListItem.prototype = {
- __proto__: ListItem.prototype,
-
- /** @override */
- decorate: function() {
- ListItem.prototype.decorate.call(this);
-
- var bookmarkNode = this.bookmarkNode;
-
- this.draggable = true;
-
- var labelEl = this.ownerDocument.createElement('div');
- labelEl.className = 'label';
- var labelImgWrapper = this.ownerDocument.createElement('div');
- labelImgWrapper.className = 'label-img-wrapper';
- var labelImg = this.ownerDocument.createElement('div');
- var labelText = this.ownerDocument.createElement('div');
- labelText.className = 'label-text';
- labelText.textContent = bookmarkNode.title;
-
- var urlEl = this.ownerDocument.createElement('div');
- urlEl.className = 'url';
-
- if (bmm.isFolder(bookmarkNode)) {
- this.className = 'folder';
- // TODO(pkasting): Condense folder icon resources together.
- labelImg.style.content = cr.icon.getImage(
- cr.isMac ?
- 'chrome://theme/IDR_BOOKMARK_BAR_FOLDER' :
- 'chrome://theme/IDR_FOLDER_CLOSED');
- } else {
- labelImg.style.content = cr.icon.getFavicon(bookmarkNode.url);
- urlEl.textContent = bookmarkNode.url;
- }
-
- labelImgWrapper.appendChild(labelImg);
- labelEl.appendChild(labelImgWrapper);
- labelEl.appendChild(labelText);
- this.appendChild(labelEl);
- this.appendChild(urlEl);
-
- // Initially the ContextMenuButton was added here but it slowed down
- // rendering a lot so it is now added using mouseover.
- },
-
- /**
- * The ID of the bookmark folder we are currently showing or loading.
- * @type {string}
- */
- get bookmarkId() {
- return this.bookmarkNode.id;
- },
-
- /**
- * Whether the user is currently able to edit the list item.
- * @type {boolean}
- */
- get editing() {
- return this.hasAttribute('editing');
- },
- set editing(editing) {
- var oldEditing = this.editing;
- if (oldEditing == editing)
- return;
-
- var url = this.bookmarkNode.url;
- var title = this.bookmarkNode.title;
- var isFolder = bmm.isFolder(this.bookmarkNode);
- var listItem = this;
- var labelInput, urlInput;
-
- // Handles enter and escape which trigger reset and commit respectively.
- function handleKeydown(e) {
- // Make sure that the tree does not handle the key.
- e.stopPropagation();
-
- // Calling list.focus blurs the input which will stop editing the list
- // item.
- switch (e.key) {
- case 'Escape': // Esc
- labelInput.value = title;
- if (!isFolder)
- urlInput.value = url;
- // fall through
- cr.dispatchSimpleEvent(listItem, 'canceledit', true);
- case 'Enter':
- if (listItem.parentNode)
- listItem.parentNode.focus();
- break;
- case 'Tab': // Tab
- // urlInput is the last focusable element in the page. If we
- // allowed Tab focus navigation and the page loses focus, we
- // couldn't give focus on urlInput programatically. So, we prevent
- // Tab focus navigation.
- if (document.activeElement == urlInput && !e.ctrlKey &&
- !e.metaKey && !e.shiftKey && !getValidURL(urlInput)) {
- e.preventDefault();
- urlInput.blur();
- }
- break;
- }
- }
-
- function getValidURL(input) {
- var originalValue = input.value;
- if (!originalValue)
- return null;
- if (input.validity.valid)
- return originalValue;
- // Blink does not do URL fix up so we manually test if prepending
- // 'http://' would make the URL valid.
- // https://bugs.webkit.org/show_bug.cgi?id=29235
- input.value = 'http://' + originalValue;
- if (input.validity.valid)
- return input.value;
- // still invalid
- input.value = originalValue;
- return null;
- }
-
- function handleBlur(e) {
- // When the blur event happens we do not know who is getting focus so we
- // delay this a bit since we want to know if the other input got focus
- // before deciding if we should exit edit mode.
- var doc = e.target.ownerDocument;
- window.setTimeout(function() {
- var activeElement = doc.hasFocus() && doc.activeElement;
- if (activeElement != urlInput && activeElement != labelInput) {
- listItem.editing = false;
- }
- }, 50);
- }
-
- var doc = this.ownerDocument;
- var labelTextEl = queryRequiredElement('.label-text', this);
- var urlEl = queryRequiredElement('.url', this);
- if (editing) {
- this.setAttribute('editing', '');
- this.draggable = false;
-
- labelInput = /** @type {HTMLElement} */(doc.createElement('input'));
- labelInput.placeholder =
- loadTimeData.getString('name_input_placeholder');
- replaceAllChildren(labelTextEl, labelInput);
- labelInput.value = title;
-
- if (!isFolder) {
- urlInput = /** @type {HTMLElement} */(doc.createElement('input'));
- urlInput.type = 'url';
- urlInput.required = true;
- urlInput.placeholder =
- loadTimeData.getString('url_input_placeholder');
-
- // We also need a name for the input for the CSS to work.
- urlInput.name = '-url-input-' + cr.createUid();
- replaceAllChildren(assert(urlEl), urlInput);
- urlInput.value = url;
- }
-
- var stopPropagation = function(e) {
- e.stopPropagation();
- };
-
- var eventsToStop =
- ['mousedown', 'mouseup', 'contextmenu', 'dblclick', 'paste'];
- eventsToStop.forEach(function(type) {
- labelInput.addEventListener(type, stopPropagation);
- });
- labelInput.addEventListener('keydown', handleKeydown);
- labelInput.addEventListener('blur', handleBlur);
- cr.ui.limitInputWidth(labelInput, this, 100, 0.5);
- labelInput.focus();
- labelInput.select();
-
- if (!isFolder) {
- eventsToStop.forEach(function(type) {
- urlInput.addEventListener(type, stopPropagation);
- });
- urlInput.addEventListener('keydown', handleKeydown);
- urlInput.addEventListener('blur', handleBlur);
- cr.ui.limitInputWidth(urlInput, this, 200, 0.5);
- }
-
- } else {
- // Check that we have a valid URL and if not we do not change the
- // editing mode.
- if (!isFolder) {
- var urlInput = this.querySelector('.url input');
- var newUrl = urlInput.value;
- if (!newUrl) {
- cr.dispatchSimpleEvent(this, 'canceledit', true);
- return;
- }
-
- newUrl = getValidURL(urlInput);
- if (!newUrl) {
- // In case the item was removed before getting here we should
- // not alert.
- if (listItem.parentNode) {
- // Select the item again.
- var dataModel = this.parentNode.dataModel;
- var index = dataModel.indexOf(this.bookmarkNode);
- var sm = this.parentNode.selectionModel;
- sm.selectedIndex = sm.leadIndex = sm.anchorIndex = index;
-
- alert(loadTimeData.getString('invalid_url'));
- }
- urlInput.focus();
- urlInput.select();
- return;
- }
- urlEl.textContent = this.bookmarkNode.url = newUrl;
- }
-
- this.removeAttribute('editing');
- this.draggable = true;
-
- labelInput = this.querySelector('.label input');
- var newLabel = labelInput.value;
- labelTextEl.textContent = this.bookmarkNode.title = newLabel;
-
- if (isFolder) {
- if (newLabel != title) {
- cr.dispatchSimpleEvent(this, 'rename', true);
- }
- } else if (newLabel != title || newUrl != url) {
- cr.dispatchSimpleEvent(this, 'edit', true);
- }
- }
- }
- };
-
- return {
- BookmarkList: BookmarkList,
- list: /** @type {Element} */(null), // Set when decorated.
- };
-});
diff --git a/chromium/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_tree.js b/chromium/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_tree.js
deleted file mode 100644
index fbd74c5b923..00000000000
--- a/chromium/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_tree.js
+++ /dev/null
@@ -1,323 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-
-cr.define('bmm', function() {
- 'use strict';
-
- /**
- * The id of the bookmark root.
- * @type {string}
- * @const
- */
- var ROOT_ID = '0';
-
- /** @const */ var Tree = cr.ui.Tree;
- /** @const */ var TreeItem = cr.ui.TreeItem;
- /** @const */ var localStorage = window.localStorage;
-
- var treeLookup = {};
-
- // Manager for persisting the expanded state.
- var expandedManager = /** @type {EventListener} */({
- /**
- * A map of the collapsed IDs.
- * @type {Object}
- */
- map: 'bookmarkTreeState' in localStorage ?
- /** @type {Object} */(JSON.parse(localStorage['bookmarkTreeState'])) :
- {},
-
- /**
- * Set the collapsed state for an ID.
- * @param {string} id The bookmark ID of the tree item that was expanded or
- * collapsed.
- * @param {boolean} expanded Whether the tree item was expanded.
- */
- set: function(id, expanded) {
- if (expanded)
- delete this.map[id];
- else
- this.map[id] = 1;
-
- this.save();
- },
-
- /**
- * @param {string} id The bookmark ID.
- * @return {boolean} Whether the tree item should be expanded.
- */
- get: function(id) {
- return !(id in this.map);
- },
-
- /**
- * Callback for the expand and collapse events from the tree.
- * @param {!Event} e The collapse or expand event.
- */
- handleEvent: function(e) {
- this.set(e.target.bookmarkId, e.type == 'expand');
- },
-
- /**
- * Cleans up old bookmark IDs.
- */
- cleanUp: function() {
- for (var id in this.map) {
- // If the id is no longer in the treeLookup the bookmark no longer
- // exists.
- if (!(id in treeLookup))
- delete this.map[id];
- }
- this.save();
- },
-
- timer: null,
-
- /**
- * Saves the expanded state to the localStorage.
- */
- save: function() {
- clearTimeout(this.timer);
- var map = this.map;
- // Save in a timeout so that we can coalesce multiple changes.
- this.timer = setTimeout(function() {
- localStorage['bookmarkTreeState'] = JSON.stringify(map);
- }, 100);
- }
- });
-
- // Clean up once per session but wait until things settle down a bit.
- setTimeout(expandedManager.cleanUp.bind(expandedManager), 1e4);
-
- /**
- * Creates a new tree item for a bookmark node.
- * @param {!Object} bookmarkNode The bookmark node.
- * @constructor
- * @extends {TreeItem}
- */
- function BookmarkTreeItem(bookmarkNode) {
- var ti = new TreeItem({
- label: bookmarkNode.title,
- bookmarkNode: bookmarkNode,
- // Bookmark toolbar and Other bookmarks are not draggable.
- draggable: bookmarkNode.parentId != ROOT_ID
- });
- ti.__proto__ = BookmarkTreeItem.prototype;
- treeLookup[bookmarkNode.id] = ti;
- return ti;
- }
-
- BookmarkTreeItem.prototype = {
- __proto__: TreeItem.prototype,
-
- /**
- * The ID of the bookmark this tree item represents.
- * @type {string}
- */
- get bookmarkId() {
- return this.bookmarkNode.id;
- }
- };
-
- /**
- * Asynchronousy adds a tree item at the correct index based on the bookmark
- * backend.
- *
- * Since the bookmark tree only contains folders the index we get from certain
- * callbacks is not very useful so we therefore have this async call which
- * gets the children of the parent and adds the tree item at the desired
- * index.
- *
- * This also exoands the parent so that newly added children are revealed.
- *
- * @param {!cr.ui.TreeItem} parent The parent tree item.
- * @param {!cr.ui.TreeItem} treeItem The tree item to add.
- * @param {Function=} opt_f A function which gets called after the item has
- * been added at the right index.
- */
- function addTreeItem(parent, treeItem, opt_f) {
- chrome.bookmarks.getChildren(parent.bookmarkNode.id, function(children) {
- var isFolder = /**
- * @type {function (BookmarkTreeNode, number,
- * Array<(BookmarkTreeNode)>)}
- */(bmm.isFolder);
- var index = children.filter(isFolder).map(function(item) {
- return item.id;
- }).indexOf(treeItem.bookmarkNode.id);
- parent.addAt(treeItem, index);
- parent.expanded = true;
- if (opt_f)
- opt_f();
- });
- }
-
-
- /**
- * Creates a new bookmark list.
- * @param {Object=} opt_propertyBag Optional properties.
- * @constructor
- * @extends {cr.ui.Tree}
- */
- var BookmarkTree = cr.ui.define('tree');
-
- BookmarkTree.prototype = {
- __proto__: Tree.prototype,
-
- decorate: function() {
- Tree.prototype.decorate.call(this);
- this.addEventListener('expand', expandedManager);
- this.addEventListener('collapse', expandedManager);
-
- bmm.tree = this;
- },
-
- handleBookmarkChanged: function(id, changeInfo) {
- var treeItem = treeLookup[id];
- if (treeItem)
- treeItem.label = treeItem.bookmarkNode.title = changeInfo.title;
- },
-
- /**
- * @param {string} id
- * @param {ReorderInfo} reorderInfo
- */
- handleChildrenReordered: function(id, reorderInfo) {
- var parentItem = treeLookup[id];
- // The tree only contains folders.
- var dirIds = reorderInfo.childIds.filter(function(id) {
- return id in treeLookup;
- }).forEach(function(id, i) {
- parentItem.addAt(treeLookup[id], i);
- });
- },
-
- handleCreated: function(id, bookmarkNode) {
- if (bmm.isFolder(bookmarkNode)) {
- var parentItem = treeLookup[bookmarkNode.parentId];
- var newItem = new BookmarkTreeItem(bookmarkNode);
- addTreeItem(parentItem, newItem);
- }
- },
-
- /**
- * @param {string} id
- * @param {MoveInfo} moveInfo
- */
- handleMoved: function(id, moveInfo) {
- var treeItem = treeLookup[id];
- if (treeItem) {
- var oldParentItem = treeLookup[moveInfo.oldParentId];
- oldParentItem.remove(treeItem);
- var newParentItem = treeLookup[moveInfo.parentId];
- // The tree only shows folders so the index is not the index we want. We
- // therefore get the children need to adjust the index.
- addTreeItem(newParentItem, treeItem);
- }
- },
-
- handleRemoved: function(id, removeInfo) {
- var parentItem = treeLookup[removeInfo.parentId];
- var itemToRemove = treeLookup[id];
- if (parentItem && itemToRemove)
- parentItem.remove(itemToRemove);
- },
-
- insertSubtree: function(folder) {
- if (!bmm.isFolder(folder))
- return;
- var children = folder.children;
- this.handleCreated(folder.id, folder);
- for (var i = 0; i < children.length; i++) {
- var child = children[i];
- this.insertSubtree(child);
- }
- },
-
- /**
- * Returns the bookmark node with the given ID. The tree only maintains
- * folder nodes.
- * @param {string} id The ID of the node to find.
- * @return {BookmarkTreeNode} The bookmark tree node or null if not found.
- */
- getBookmarkNodeById: function(id) {
- var treeItem = treeLookup[id];
- if (treeItem)
- return treeItem.bookmarkNode;
- return null;
- },
-
- /**
- * Returns the selected bookmark folder node as an array.
- * @type {!Array} Array of bookmark nodes.
- */
- get selectedFolders() {
- return this.selectedItem && this.selectedItem.bookmarkNode ?
- [this.selectedItem.bookmarkNode] : [];
- },
-
- /**
- * Fetches the bookmark items and builds the tree control.
- */
- reload: function() {
- /**
- * Recursive helper function that adds all the directories to the
- * parentTreeItem.
- * @param {!cr.ui.Tree|!cr.ui.TreeItem} parentTreeItem The parent tree
- * element to append to.
- * @param {!Array<BookmarkTreeNode>} bookmarkNodes A list of bookmark
- * nodes to be added.
- * @return {boolean} Whether any directories where added.
- */
- function buildTreeItems(parentTreeItem, bookmarkNodes) {
- var hasDirectories = false;
- for (var i = 0, bookmarkNode; bookmarkNode = bookmarkNodes[i]; i++) {
- if (bmm.isFolder(bookmarkNode)) {
- hasDirectories = true;
- var item = new BookmarkTreeItem(bookmarkNode);
- parentTreeItem.add(item);
- var children = assert(bookmarkNode.children);
- var anyChildren = buildTreeItems(item, children);
- item.expanded = anyChildren && expandedManager.get(bookmarkNode.id);
- }
- }
- return hasDirectories;
- }
-
- var self = this;
- chrome.bookmarkManagerPrivate.getSubtree('', true, function(root) {
- self.clear();
- buildTreeItems(self, root[0].children);
- cr.dispatchSimpleEvent(self, 'load');
- });
- },
-
- /**
- * Clears the tree.
- */
- clear: function() {
- // Remove all fields without recreating the object since other code
- // references it.
- for (var id in treeLookup) {
- delete treeLookup[id];
- }
- this.textContent = '';
- },
-
- /** @override */
- remove: function(child) {
- Tree.prototype.remove.call(this, child);
- if (child.bookmarkNode)
- delete treeLookup[child.bookmarkNode.id];
- }
- };
-
- return {
- BookmarkTree: BookmarkTree,
- BookmarkTreeItem: BookmarkTreeItem,
- treeLookup: treeLookup,
- tree: /** @type {Element} */(null), // Set when decorated.
- ROOT_ID: ROOT_ID
- };
-});
diff --git a/chromium/chrome/browser/resources/bookmark_manager/js/bmm_test.html b/chromium/chrome/browser/resources/bookmark_manager/js/bmm_test.html
deleted file mode 100644
index 00d410867d9..00000000000
--- a/chromium/chrome/browser/resources/bookmark_manager/js/bmm_test.html
+++ /dev/null
@@ -1,113 +0,0 @@
-<!doctype html>
-<html>
-<head>
-<!-- TODO(arv): Check in Closure unit tests and make this run as part of the
- tests -->
-<link rel="stylesheet" href="chrome://resources/css/text_defaults.css">
-<script src="https://cdn.rawgit.com/google/closure-library/master/closure/goog/base.js"></script>
-<script src="../../../../../ui/webui/resources/js/cr.js"></script>
-<script src="bmm.js"></script>
-<title>Bookmark Manager Loading Test</title>
-<script>
-
-goog.require('goog.testing.jsunit');
-goog.require('goog.testing.AsyncTestCase');
-
-</script>
-</head>
-<body>
-<script>
-
-var asyncTestCase = goog.testing.AsyncTestCase.createAndInstall(document.title);
-
-var tree = {
- id: 0,
- children: [
- {
- id: 1,
- children: [
- {id: 2},
- {id: 3, children: []}
- ]
- },
- {id: 4},
- {id: 5}
- ]
-};
-
-// Mock chrome.bookmarkManagerPrivate.getSubtree
-chrome = chrome || {};
-chrome.bookmarkManagerPrivate = chrome.bookmarkManagerPrivate || {};
-
-var callbacks = {};
-
-chrome.bookmarkManagerPrivate.getSubtree = function(id, foldersOnly, callback) {
- callbacks[id] = callbacks[id] || [];
- callbacks[id].push(callback);
- callbacks[id].$calls = callbacks[id].$calls ? callbacks[id].$calls++ : 1;
-};
-
-chrome.bookmarkManagerPrivate.getSubtree.load = function(node) {
- // getSubtree gets the root tree when id is ''.
- var id = node.id;
- if (id == tree.id)
- id = '';
- for (var i = 0; i < callbacks[id].length; i++) {
- callbacks[id][i].call(null, [node]);
- }
-};
-
-function continueTesting() {
- asyncTestCase.continueTesting();
-}
-
-function testLoad() {
- var calls1 = 0;
- var calls2 = 0;
- function f1(node) {
- calls1++;
- assertEquals(tree, node);
- }
- function f2(node) {
- calls2++;
- assertEquals(tree, node);
- }
-
- var p = bmm.loadTree();
- var p2 = bmm.loadTree();
- var r = [
- p.then(f1),
- p2.then(f2),
- ];
-
- chrome.bookmarkManagerPrivate.getSubtree.load(tree);
-
- var root = Promise.all(r).then(function() {
- assertEquals(1, calls1);
- assertEquals(1, calls2);
- assertEquals(1, callbacks[''].$calls);
- });
-
-
- var calls3 = 0;
- function f3(node) {
- calls3++;
- assertEquals(tree.children[0], node);
- }
-
- var p3 = bmm.loadSubtree(1);
- var s = p3.then(f3);
-
- chrome.bookmarkManagerPrivate.getSubtree.load(tree.children[0]);
-
- var subtree = s.then(function() {
- assertEquals(1, calls3);
- assertEquals(1, callbacks[1].$calls);
- });
-
- Promise.all([root, subtree]).then(continueTesting);
-}
-
-</script>
-</body>
-</html>
diff --git a/chromium/chrome/browser/resources/bookmark_manager/js/compiled_resources2.gyp b/chromium/chrome/browser/resources/bookmark_manager/js/compiled_resources2.gyp
deleted file mode 100644
index 388e1d1bf7d..00000000000
--- a/chromium/chrome/browser/resources/bookmark_manager/js/compiled_resources2.gyp
+++ /dev/null
@@ -1,58 +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.
-{
- 'targets': [
- {
- 'target_name': 'bookmark_manager',
- 'variables': {
- 'script_args': ['--custom_sources'],
- 'source_files': [
- '<(DEPTH)/third_party/jstemplate/util.js',
- '<(DEPTH)/ui/webui/resources/js/assert.js',
- '<(DEPTH)/third_party/jstemplate/jsevalcontext.js',
- '<(DEPTH)/third_party/jstemplate/jstemplate.js',
- '<(DEPTH)/ui/webui/resources/js/cr.js',
- '<(DEPTH)/ui/webui/resources/js/cr/event_target.js',
- '<(DEPTH)/ui/webui/resources/js/cr/link_controller.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/array_data_model.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/command.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/context_menu_button.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/context_menu_handler.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/focus_outline_manager.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/list.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/list_item.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/list_selection_controller.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/list_selection_model.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/menu.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/menu_button.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/menu_item.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/position_util.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/splitter.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/touch_handler.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/tree.js',
- '<(DEPTH)/ui/webui/resources/js/event_tracker.js',
- '<(DEPTH)/ui/webui/resources/js/i18n_template_no_process.js',
- '<(DEPTH)/ui/webui/resources/js/load_time_data.js',
- '<(DEPTH)/ui/webui/resources/js/parse_html_subset.js',
- '<(DEPTH)/ui/webui/resources/js/promise_resolver.js',
- '<(DEPTH)/ui/webui/resources/js/util.js',
- '<(DEPTH)/ui/webui/resources/js/icon.js',
- '<(DEPTH)/chrome/browser/resources/bookmark_manager/js/bmm.js',
- '<(DEPTH)/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js',
- '<(DEPTH)/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_tree.js',
- '<(DEPTH)/chrome/browser/resources/bookmark_manager/js/dnd.js',
- '<(DEPTH)/chrome/browser/resources/bookmark_manager/js/main.js',
- '<(DEPTH)/third_party/closure_compiler/externs/bookmark_manager_private.js',
- '<(DEPTH)/third_party/closure_compiler/externs//chrome_send.js',
- '<(DEPTH)/third_party/closure_compiler/externs//chrome_extensions.js',
- '<(DEPTH)/third_party/closure_compiler/externs//metrics_private.js',
- '<(DEPTH)/third_party/closure_compiler/externs//system_private.js',
- '<(DEPTH)/ui/webui/resources/js/template_data_externs.js',
- ],
- },
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- }
- ],
-}
diff --git a/chromium/chrome/browser/resources/bookmark_manager/js/dnd.js b/chromium/chrome/browser/resources/bookmark_manager/js/dnd.js
deleted file mode 100644
index 9a97faf0f38..00000000000
--- a/chromium/chrome/browser/resources/bookmark_manager/js/dnd.js
+++ /dev/null
@@ -1,562 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('dnd', function() {
- 'use strict';
-
- /** @const */ var BookmarkList = bmm.BookmarkList;
- /** @const */ var ListItem = cr.ui.ListItem;
- /** @const */ var TreeItem = cr.ui.TreeItem;
-
- /**
- * Enumeration of valid drop locations relative to an element. These are
- * bit masks to allow combining multiple locations in a single value.
- * @enum {number}
- * @const
- */
- var DropPosition = {
- NONE: 0,
- ABOVE: 1,
- ON: 2,
- BELOW: 4
- };
-
- /**
- * @type {Object} Drop information calculated in |handleDragOver|.
- */
- var dropDestination = null;
-
- /**
- * @type {number} Timer id used to help minimize flicker.
- */
- var removeDropIndicatorTimer;
-
- /**
- * The element currently targeted by a touch.
- * @type {Element}
- */
- var currentTouchTarget;
-
- /**
- * The element that had a style applied it to indicate the drop location.
- * This is used to easily remove the style when necessary.
- * @type {Element}
- */
- var lastIndicatorElement;
-
- /**
- * The style that was applied to indicate the drop location.
- * @type {?string}
- */
- var lastIndicatorClassName;
-
- var dropIndicator = {
- /**
- * Applies the drop indicator style on the target element and stores that
- * information to easily remove the style in the future.
- */
- addDropIndicatorStyle: function(indicatorElement, position) {
- var indicatorStyleName = position == DropPosition.ABOVE ? 'drag-above' :
- position == DropPosition.BELOW ? 'drag-below' :
- 'drag-on';
-
- lastIndicatorElement = indicatorElement;
- lastIndicatorClassName = indicatorStyleName;
-
- indicatorElement.classList.add(indicatorStyleName);
- },
-
- /**
- * Clears the drop indicator style from the last element was the drop target
- * so the drop indicator is no longer for that element.
- */
- removeDropIndicatorStyle: function() {
- if (!lastIndicatorElement || !lastIndicatorClassName)
- return;
- lastIndicatorElement.classList.remove(lastIndicatorClassName);
- lastIndicatorElement = null;
- lastIndicatorClassName = null;
- },
-
- /**
- * Displays the drop indicator on the current drop target to give the
- * user feedback on where the drop will occur.
- */
- update: function(dropDest) {
- window.clearTimeout(removeDropIndicatorTimer);
-
- var indicatorElement = dropDest.element;
- var position = dropDest.position;
- if (dropDest.element instanceof BookmarkList) {
- // For an empty bookmark list use 'drop-above' style.
- position = DropPosition.ABOVE;
- } else if (dropDest.element instanceof TreeItem) {
- indicatorElement = indicatorElement.querySelector('.tree-row');
- }
- dropIndicator.removeDropIndicatorStyle();
- dropIndicator.addDropIndicatorStyle(indicatorElement, position);
- },
-
- /**
- * Stop displaying the drop indicator.
- */
- finish: function() {
- // The use of a timeout is in order to reduce flickering as we move
- // between valid drop targets.
- window.clearTimeout(removeDropIndicatorTimer);
- removeDropIndicatorTimer = window.setTimeout(function() {
- dropIndicator.removeDropIndicatorStyle();
- }, 100);
- }
- };
-
- /**
- * Delay for expanding folder when pointer hovers on folder in tree view in
- * milliseconds.
- * @type {number}
- * @const
- */
- // TODO(yosin): EXPAND_FOLDER_DELAY should follow system settings. 400ms is
- // taken from Windows default settings.
- var EXPAND_FOLDER_DELAY = 400;
-
- /**
- * The timestamp when the mouse was over a folder during a drag operation.
- * Used to open the hovered folder after a certain time.
- * @type {number}
- */
- var lastHoverOnFolderTimeStamp = 0;
-
- /**
- * Expand a folder if the user has hovered for longer than the specified
- * time during a drag action.
- */
- function updateAutoExpander(eventTimeStamp, overElement) {
- // Expands a folder in tree view when pointer hovers on it longer than
- // EXPAND_FOLDER_DELAY.
- var hoverOnFolderTimeStamp = lastHoverOnFolderTimeStamp;
- lastHoverOnFolderTimeStamp = 0;
- if (hoverOnFolderTimeStamp) {
- if (eventTimeStamp - hoverOnFolderTimeStamp >= EXPAND_FOLDER_DELAY)
- overElement.expanded = true;
- else
- lastHoverOnFolderTimeStamp = hoverOnFolderTimeStamp;
- } else if (overElement instanceof TreeItem &&
- bmm.isFolder(overElement.bookmarkNode) &&
- overElement.hasChildren &&
- !overElement.expanded) {
- lastHoverOnFolderTimeStamp = eventTimeStamp;
- }
- }
-
- /**
- * Stores the information about the bookmark and folders being dragged.
- * @type {Object}
- */
- var dragData = null;
- var dragInfo = {
- handleChromeDragEnter: function(newDragData) {
- dragData = newDragData;
- },
- clearDragData: function() {
- dragData = null;
- },
- isDragValid: function() {
- return !!dragData;
- },
- isSameProfile: function() {
- return dragData && dragData.sameProfile;
- },
- isDraggingFolders: function() {
- return dragData && dragData.elements.some(function(node) {
- return !node.url;
- });
- },
- isDraggingBookmark: function(bookmarkId) {
- return dragData && dragData.elements.some(function(node) {
- return node.id == bookmarkId;
- });
- },
- isDraggingChildBookmark: function(folderId) {
- return dragData && dragData.elements.some(function(node) {
- return node.parentId == folderId;
- });
- },
- isDraggingFolderToDescendant: function(bookmarkNode) {
- return dragData && dragData.elements.some(function(node) {
- var dragFolder = bmm.treeLookup[node.id];
- var dragFolderNode = dragFolder && dragFolder.bookmarkNode;
- return dragFolderNode && bmm.contains(dragFolderNode, bookmarkNode);
- });
- }
- };
-
- /**
- * External function to select folders or bookmarks after a drop action.
- * @type {?Function}
- */
- var selectItemsAfterUserAction = null;
-
- function getBookmarkElement(el) {
- while (el && !el.bookmarkNode) {
- el = el.parentNode;
- }
- return el;
- }
-
- // If we are over the list and the list is showing search result, we cannot
- // drop.
- function isOverSearch(overElement) {
- return bmm.list.isSearch() && bmm.list.contains(overElement);
- }
-
- /**
- * Determines the valid drop positions for the given target element.
- * @param {!HTMLElement} overElement The element that we are currently
- * dragging over.
- * @return {DropPosition} An bit field enumeration of valid drop locations.
- */
- function calculateValidDropTargets(overElement) {
- // Don't allow dropping if there is an ephemeral item being edited.
- if (bmm.list.hasEphemeral())
- return DropPosition.NONE;
-
- if (!dragInfo.isDragValid() || isOverSearch(overElement))
- return DropPosition.NONE;
-
- if (dragInfo.isSameProfile() &&
- (dragInfo.isDraggingBookmark(overElement.bookmarkNode.id) ||
- dragInfo.isDraggingFolderToDescendant(overElement.bookmarkNode))) {
- return DropPosition.NONE;
- }
-
- var canDropInfo = calculateDropAboveBelow(overElement);
- if (canDropOn(overElement))
- canDropInfo |= DropPosition.ON;
-
- return canDropInfo;
- }
-
- function calculateDropAboveBelow(overElement) {
- if (overElement instanceof BookmarkList)
- return DropPosition.NONE;
-
- // We cannot drop between Bookmarks bar and Other bookmarks.
- if (overElement.bookmarkNode.parentId == bmm.ROOT_ID)
- return DropPosition.NONE;
-
- var isOverTreeItem = overElement instanceof TreeItem;
- var isOverExpandedTree = isOverTreeItem && overElement.expanded;
- var isDraggingFolders = dragInfo.isDraggingFolders();
-
- // We can only drop between items in the tree if we have any folders.
- if (isOverTreeItem && !isDraggingFolders)
- return DropPosition.NONE;
-
- // When dragging from a different profile we do not need to consider
- // conflicts between the dragged items and the drop target.
- if (!dragInfo.isSameProfile()) {
- // Don't allow dropping below an expanded tree item since it is confusing
- // to the user anyway.
- return isOverExpandedTree ? DropPosition.ABOVE :
- (DropPosition.ABOVE | DropPosition.BELOW);
- }
-
- var resultPositions = DropPosition.NONE;
-
- // Cannot drop above if the item above is already in the drag source.
- var previousElem = overElement.previousElementSibling;
- if (!previousElem || !dragInfo.isDraggingBookmark(previousElem.bookmarkId))
- resultPositions |= DropPosition.ABOVE;
-
- // Don't allow dropping below an expanded tree item since it is confusing
- // to the user anyway.
- if (isOverExpandedTree)
- return resultPositions;
-
- // Cannot drop below if the item below is already in the drag source.
- var nextElement = overElement.nextElementSibling;
- if (!nextElement || !dragInfo.isDraggingBookmark(nextElement.bookmarkId))
- resultPositions |= DropPosition.BELOW;
-
- return resultPositions;
- }
-
- /**
- * Determine whether we can drop the dragged items on the drop target.
- * @param {!HTMLElement} overElement The element that we are currently
- * dragging over.
- * @return {boolean} Whether we can drop the dragged items on the drop
- * target.
- */
- function canDropOn(overElement) {
- // We can only drop on a folder.
- if (!bmm.isFolder(overElement.bookmarkNode))
- return false;
-
- if (!dragInfo.isSameProfile())
- return true;
-
- if (overElement instanceof BookmarkList) {
- // We are trying to drop an item past the last item. This is
- // only allowed if dragged item is different from the last item
- // in the list.
- var listItems = bmm.list.items;
- var len = listItems.length;
- if (!len || !dragInfo.isDraggingBookmark(listItems[len - 1].bookmarkId))
- return true;
- }
-
- return !dragInfo.isDraggingChildBookmark(overElement.bookmarkNode.id);
- }
-
- /**
- * Callback for the dragstart event.
- * @param {Event} e The dragstart event.
- */
- function handleDragStart(e) {
- // Determine the selected bookmarks.
- var target = e.target;
- var draggedNodes = [];
- var isFromTouch = target == currentTouchTarget;
-
- if (target instanceof ListItem) {
- // Use selected items.
- draggedNodes =
- /** @type {cr.ui.List} */ (target.parentNode).selectedItems;
- } else if (target instanceof TreeItem) {
- draggedNodes.push(target.bookmarkNode);
- }
-
- // We manage starting the drag by using the extension API.
- e.preventDefault();
-
- // Do not allow dragging if there is an ephemeral item being edited at the
- // moment.
- if (bmm.list.hasEphemeral())
- return;
-
- if (draggedNodes.length) {
- // If we are dragging a single link, we can do the *Link* effect.
- // Otherwise, we only allow copy and move.
- e.dataTransfer.effectAllowed = draggedNodes.length == 1 &&
- !bmm.isFolder(draggedNodes[0]) ? 'copyMoveLink' : 'copyMove';
-
- chrome.bookmarkManagerPrivate.startDrag(draggedNodes.map(function(node) {
- return node.id;
- }), isFromTouch);
- var dragTarget = getBookmarkElement(e.target);
- if (dragTarget instanceof ListItem ||
- dragTarget instanceof BookmarkList) {
- chrome.metricsPrivate.recordUserAction(
- 'BookmarkManager_StartDragFromList');
- } else if (dragTarget instanceof TreeItem) {
- chrome.metricsPrivate.recordUserAction(
- 'BookmarkManager_StartDragFromTree');
- }
-
- chrome.metricsPrivate.recordSmallCount(
- 'BookmarkManager.NumDragged', draggedNodes.length);
- }
- }
-
- function handleDragEnter(e) {
- e.preventDefault();
- }
-
- /**
- * Calback for the dragover event.
- * @param {Event} e The dragover event.
- */
- function handleDragOver(e) {
- // Allow DND on text inputs.
- if (e.target.tagName != 'INPUT') {
- // The default operation is to allow dropping links etc to do navigation.
- // We never want to do that for the bookmark manager.
- e.preventDefault();
-
- // Set to none. This will get set to something if we can do the drop.
- e.dataTransfer.dropEffect = 'none';
- }
-
- if (!dragInfo.isDragValid())
- return;
-
- var overElement = getBookmarkElement(e.target) ||
- (e.target == bmm.list ? bmm.list : null);
- if (!overElement)
- return;
-
- updateAutoExpander(e.timeStamp, overElement);
-
- var canDropInfo = calculateValidDropTargets(overElement);
- if (canDropInfo == DropPosition.NONE)
- return;
-
- // Now we know that we can drop. Determine if we will drop above, on or
- // below based on mouse position etc.
-
- dropDestination = calcDropPosition(e.clientY, overElement, canDropInfo);
- if (!dropDestination) {
- e.dataTransfer.dropEffect = 'none';
- return;
- }
-
- e.dataTransfer.dropEffect = dragInfo.isSameProfile() ? 'move' : 'copy';
- dropIndicator.update(dropDestination);
- }
-
- /**
- * This function determines where the drop will occur relative to the element.
- * @return {?Object} If no valid drop position is found, null, otherwise
- * an object containing the following parameters:
- * element - The target element that will receive the drop.
- * position - A |DropPosition| relative to the |element|.
- */
- function calcDropPosition(elementClientY, overElement, canDropInfo) {
- if (overElement instanceof BookmarkList) {
- // Dropping on the BookmarkList either means dropping below the last
- // bookmark element or on the list itself if it is empty.
- var length = overElement.items.length;
- if (length)
- return {
- element: overElement.getListItemByIndex(length - 1),
- position: DropPosition.BELOW
- };
- return {element: overElement, position: DropPosition.ON};
- }
-
- var above = canDropInfo & DropPosition.ABOVE;
- var below = canDropInfo & DropPosition.BELOW;
- var on = canDropInfo & DropPosition.ON;
- var rect = overElement.getBoundingClientRect();
- var yRatio = (elementClientY - rect.top) / rect.height;
-
- if (above && (yRatio <= .25 || yRatio <= .5 && (!below || !on)))
- return {element: overElement, position: DropPosition.ABOVE};
- if (below && (yRatio > .75 || yRatio > .5 && (!above || !on)))
- return {element: overElement, position: DropPosition.BELOW};
- if (on)
- return {element: overElement, position: DropPosition.ON};
- return null;
- }
-
- function calculateDropInfo(eventTarget, dropDestination) {
- if (!dropDestination || !dragInfo.isDragValid())
- return null;
-
- var dropPos = dropDestination.position;
- var relatedNode = dropDestination.element.bookmarkNode;
- var dropInfoResult = {
- selectTarget: null,
- selectedTreeId: -1,
- parentId: dropPos == DropPosition.ON ? relatedNode.id :
- relatedNode.parentId,
- index: -1,
- relatedIndex: -1
- };
-
- // Try to find the index in the dataModel so we don't have to always keep
- // the index for the list items up to date.
- var overElement = getBookmarkElement(eventTarget);
- if (overElement instanceof ListItem) {
- dropInfoResult.relatedIndex =
- overElement.parentNode.dataModel.indexOf(relatedNode);
- dropInfoResult.selectTarget = bmm.list;
- } else if (overElement instanceof BookmarkList) {
- dropInfoResult.relatedIndex = overElement.dataModel.length - 1;
- dropInfoResult.selectTarget = bmm.list;
- } else {
- // Tree
- dropInfoResult.relatedIndex = relatedNode.index;
- dropInfoResult.selectTarget = bmm.tree;
- dropInfoResult.selectedTreeId =
- bmm.tree.selectedItem ? bmm.tree.selectedItem.bookmarkId : null;
- }
-
- if (dropPos == DropPosition.ABOVE)
- dropInfoResult.index = dropInfoResult.relatedIndex;
- else if (dropPos == DropPosition.BELOW)
- dropInfoResult.index = dropInfoResult.relatedIndex + 1;
-
- return dropInfoResult;
- }
-
- function handleDragLeave(e) {
- dropIndicator.finish();
- }
-
- function handleDrop(e) {
- var dropInfo = calculateDropInfo(e.target, dropDestination);
- if (dropInfo) {
- selectItemsAfterUserAction(dropInfo.selectTarget,
- dropInfo.selectedTreeId);
- if (dropInfo.index != -1)
- chrome.bookmarkManagerPrivate.drop(dropInfo.parentId, dropInfo.index);
- else
- chrome.bookmarkManagerPrivate.drop(dropInfo.parentId);
-
- e.preventDefault();
-
- var dragTarget = getBookmarkElement(e.target);
- var action;
- if (dragTarget instanceof ListItem ||
- dragTarget instanceof BookmarkList) {
- action = 'BookmarkManager_DropToList';
- if (dropDestination.position == DropPosition.ON)
- action = 'BookmarkManager_DropToListItem';
- } else if (dragTarget instanceof TreeItem) {
- action = 'BookmarkManager_DropToTree';
- if (dropDestination.position == DropPosition.ON)
- action = 'BookmarkManager_DropToTreeItem';
- }
- if (action)
- chrome.metricsPrivate.recordUserAction(action);
- }
- dropDestination = null;
- dropIndicator.finish();
- }
-
- function setCurrentTouchTarget(e) {
- // Only set a new target for a single touch point.
- if (e.touches.length == 1)
- currentTouchTarget = getBookmarkElement(e.target);
- }
-
- function clearCurrentTouchTarget(e) {
- if (getBookmarkElement(e.target) == currentTouchTarget)
- currentTouchTarget = null;
- }
-
- function clearDragData() {
- dragInfo.clearDragData();
- dropDestination = null;
- }
-
- function init(selectItemsAfterUserActionFunction) {
- function deferredClearData() {
- setTimeout(clearDragData, 0);
- }
-
- selectItemsAfterUserAction = selectItemsAfterUserActionFunction;
-
- document.addEventListener('dragstart', handleDragStart);
- document.addEventListener('dragenter', handleDragEnter);
- document.addEventListener('dragover', handleDragOver);
- document.addEventListener('dragleave', handleDragLeave);
- document.addEventListener('drop', handleDrop);
- document.addEventListener('dragend', deferredClearData);
- document.addEventListener('mouseup', deferredClearData);
- document.addEventListener('mousedown', clearCurrentTouchTarget);
- document.addEventListener('touchcancel', clearCurrentTouchTarget);
- document.addEventListener('touchend', clearCurrentTouchTarget);
- document.addEventListener('touchstart', setCurrentTouchTarget);
-
- chrome.bookmarkManagerPrivate.onDragEnter.addListener(
- dragInfo.handleChromeDragEnter);
- chrome.bookmarkManagerPrivate.onDragLeave.addListener(deferredClearData);
- chrome.bookmarkManagerPrivate.onDrop.addListener(deferredClearData);
- }
- return {init: init};
-});
diff --git a/chromium/chrome/browser/resources/bookmark_manager/js/main.js b/chromium/chrome/browser/resources/bookmark_manager/js/main.js
deleted file mode 100644
index 9da605af8bf..00000000000
--- a/chromium/chrome/browser/resources/bookmark_manager/js/main.js
+++ /dev/null
@@ -1,1547 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-(function() {
-'use strict';
-
-/** @const */ var BookmarkList = bmm.BookmarkList;
-/** @const */ var BookmarkTree = bmm.BookmarkTree;
-/** @const */ var Command = cr.ui.Command;
-/** @const */ var LinkKind = cr.LinkKind;
-/** @const */ var ListItem = cr.ui.ListItem;
-/** @const */ var Menu = cr.ui.Menu;
-/** @const */ var MenuButton = cr.ui.MenuButton;
-/** @const */ var Splitter = cr.ui.Splitter;
-/** @const */ var TreeItem = cr.ui.TreeItem;
-
-/**
- * An array containing the BookmarkTreeNodes that were deleted in the last
- * deletion action. This is used for implementing undo.
- * @type {?{nodes: Array<Array<BookmarkTreeNode>>, target: EventTarget}}
- */
-var lastDeleted;
-
-/**
- *
- * Holds the last DOMTimeStamp when mouse pointer hovers on folder in tree
- * view. Zero means pointer doesn't hover on folder.
- * @type {number}
- */
-var lastHoverOnFolderTimeStamp = 0;
-
-/**
- * Holds a function that will undo that last action, if global undo is enabled.
- * @type {Function}
- */
-var performGlobalUndo;
-
-/**
- * Holds a link controller singleton. Use getLinkController() rarther than
- * accessing this variabie.
- * @type {cr.LinkController}
- */
-var linkController;
-
-/**
- * Incognito mode availability can take the following values: ,
- * - 'enabled' for when both normal and incognito modes are available;
- * - 'disabled' for when incognito mode is disabled;
- * - 'forced' for when incognito mode is forced (normal mode is unavailable).
- */
-var incognitoModeAvailability = 'enabled';
-
-/**
- * Whether bookmarks can be modified.
- * @type {boolean}
- */
-var canEdit = true;
-
-/**
- * @type {TreeItem}
- * @const
- */
-var searchTreeItem = new TreeItem({
- bookmarkId: 'q='
-});
-
-/**
- * @type {boolean}
- */
-var firstLoad = true;
-
-/**
- * Command shortcut mapping.
- * @const
- */
-var commandShortcutMap = cr.isMac ? {
- 'edit': 'Enter',
- // On Mac we also allow Meta+Backspace.
- 'delete': 'Delete Backspace Meta|Backspace',
- 'open-in-background-tab': 'Meta|Enter',
- 'open-in-new-tab': 'Shift|Meta|Enter',
- 'open-in-same-window': 'Meta|Down',
- 'open-in-new-window': 'Shift|Enter',
- 'rename-folder': 'Enter',
- // Global undo is Command-Z. It is not in any menu.
- 'undo': 'Meta|z',
-} : {
- 'edit': 'F2',
- 'delete': 'Delete',
- 'open-in-background-tab': 'Ctrl|Enter',
- 'open-in-new-tab': 'Shift|Ctrl|Enter',
- 'open-in-same-window': 'Enter',
- 'open-in-new-window': 'Shift|Enter',
- 'rename-folder': 'F2',
- // Global undo is Ctrl-Z. It is not in any menu.
- 'undo': 'Ctrl|z',
-};
-
-/**
- * Mapping for folder id to suffix of UMA. These names will be appeared
- * after "BookmarkManager_NavigateTo_" in UMA dashboard.
- * @const
- */
-var folderMetricsNameMap = {
- '1': 'BookmarkBar',
- '2': 'Other',
- '3': 'Mobile',
- 'q=': 'Search',
- 'subfolder': 'SubFolder',
-};
-
-/**
- * Adds an event listener to a node that will remove itself after firing once.
- * @param {!Element} node The DOM node to add the listener to.
- * @param {string} name The name of the event listener to add to.
- * @param {function(Event)} handler Function called when the event fires.
- */
-function addOneShotEventListener(node, name, handler) {
- var f = function(e) {
- handler(e);
- node.removeEventListener(name, f);
- };
- node.addEventListener(name, f);
-}
-
-// Get the localized strings from the backend via bookmakrManagerPrivate API.
-function loadLocalizedStrings(data) {
- // The strings may contain & which we need to strip.
- for (var key in data) {
- data[key] = data[key].replace(/&/, '');
- }
-
- loadTimeData.data = data;
- i18nTemplate.process(document, loadTimeData);
-
- searchTreeItem.label = loadTimeData.getString('search');
- searchTreeItem.icon = isRTL() ? 'images/bookmark_manager_search_rtl.png' :
- 'images/bookmark_manager_search.png';
-}
-
-/**
- * Updates the location hash to reflect the current state of the application.
- */
-function updateHash() {
- window.location.hash = bmm.tree.selectedItem.bookmarkId;
- updateAllCommands();
-}
-
-/**
- * Navigates to a bookmark ID.
- * @param {string} id The ID to navigate to.
- * @param {function()=} opt_callback Function called when list view loaded or
- * displayed specified folder.
- */
-function navigateTo(id, opt_callback) {
- window.location.hash = id;
-
- var sameParent = bmm.list.parentId == id;
- if (!sameParent)
- updateParentId(id);
-
- updateAllCommands();
-
- var metricsId = folderMetricsNameMap[id.replace(/^q=.*/, 'q=')] ||
- folderMetricsNameMap['subfolder'];
- chrome.metricsPrivate.recordUserAction(
- 'BookmarkManager_NavigateTo_' + metricsId);
-
- if (opt_callback) {
- if (sameParent)
- opt_callback();
- else
- addOneShotEventListener(bmm.list, 'load', opt_callback);
- }
-}
-
-/**
- * Updates the parent ID of the bookmark list and selects the correct tree item.
- * @param {string} id The id.
- */
-function updateParentId(id) {
- // Setting list.parentId fires 'load' event.
- bmm.list.parentId = id;
-
- // When tree.selectedItem changed, tree view calls navigatTo() then it
- // calls updateHash() when list view displayed specified folder.
- bmm.tree.selectedItem = bmm.treeLookup[id] || bmm.tree.selectedItem;
-}
-
-// Process the location hash. This is called by onhashchange and when the page
-// is first loaded.
-function processHash() {
- var wasFirstLoad = firstLoad;
- firstLoad = false;
- var id = window.location.hash.slice(1);
- if (!id) {
- // If we do not have a hash, select first item in the tree.
- id = bmm.tree.items[0].bookmarkId;
- }
-
- var valid = false;
- if (/^e=/.test(id)) {
- id = id.slice(2);
-
- // If hash contains e=, edit the item specified.
- chrome.bookmarks.get(id, function(bookmarkNodes) {
- // Verify the node to edit is a valid node.
- if (!bookmarkNodes || bookmarkNodes.length != 1)
- return;
- var bookmarkNode = bookmarkNodes[0];
-
- // After the list reloads, edit the desired bookmark.
- var editBookmark = function() {
- var index = bmm.list.dataModel.findIndexById(bookmarkNode.id);
- if (index != -1) {
- var sm = bmm.list.selectionModel;
- sm.anchorIndex = sm.leadIndex = sm.selectedIndex = index;
- scrollIntoViewAndMakeEditable(index);
- }
- };
-
- var parentId = assert(bookmarkNode.parentId);
- navigateTo(parentId, editBookmark);
- });
-
- // We handle the two cases of navigating to the bookmark to be edited
- // above. Don't run the standard navigation code below.
- return;
- } else if (/^q=/.test(id)) {
- // In case we got a search hash, update the text input and the
- // bmm.treeLookup to use the new id.
- setSearch(id.slice(2));
- valid = true;
- }
-
- // Navigate to bookmark 'id' (which may be a query of the form q=query).
- if (valid) {
- updateParentId(id);
- } else {
- // We need to verify that this is a correct ID.
- chrome.bookmarks.get(id, function(items) {
- if (items && items.length == 1)
- updateParentId(id);
-
- if (wasFirstLoad) {
- setTimeout(function() {
- chrome.metricsPrivate.recordTime(
- 'BookmarkManager.ResultsRenderedTime',
- Math.floor(window.performance.now()));
- });
- }
- });
- }
-}
-
-// Activate is handled by the open-in-same-window-command.
-function handleDoubleClickForList(e) {
- if (e.button == 0)
- /** @type {Command} */ ($('open-in-same-window-command')).execute();
-}
-
-// The list dispatches an event when the user clicks on the URL or the Show in
-// folder part.
-function handleUrlClickedForList(e) {
- getLinkController().openUrlFromEvent(e.url, e.originalEvent);
- chrome.bookmarkManagerPrivate.recordLaunch();
-}
-
-function handleSearch(e) {
- setSearch(this.value);
-}
-
-/**
- * Navigates to the search results for the search text.
- * @param {string} searchText The text to search for.
- */
-function setSearch(searchText) {
- if (searchText) {
- // Only update search item if we have a search term. We never want the
- // search item to be for an empty search.
- delete bmm.treeLookup[searchTreeItem.bookmarkId];
- var id = searchTreeItem.bookmarkId = 'q=' + searchText;
- bmm.treeLookup[searchTreeItem.bookmarkId] = searchTreeItem;
- }
-
- var input = $('term');
- // Do not update the input if the user is actively using the text input.
- if (document.activeElement != input)
- input.value = searchText;
-
- if (searchText) {
- bmm.tree.add(searchTreeItem);
- bmm.tree.selectedItem = searchTreeItem;
- } else {
- // Go "home".
- bmm.tree.selectedItem = bmm.tree.items[0];
- id = bmm.tree.selectedItem.bookmarkId;
- }
-
- navigateTo(id);
-}
-
-/**
- * This returns the user visible path to the folder where the bookmark is
- * located.
- * @param {number} parentId The ID of the parent folder.
- * @return {string|undefined} The path to the the bookmark,
- */
-function getFolder(parentId) {
- var parentNode = bmm.tree.getBookmarkNodeById(parentId);
- if (parentNode) {
- var s = parentNode.title;
- if (parentNode.parentId != bmm.ROOT_ID) {
- return getFolder(parentNode.parentId) + '/' + s;
- }
- return s;
- }
-}
-
-function handleLoadForTree(e) {
- processHash();
-}
-
-/**
- * Returns a promise for all the URLs in the {@code nodes} and the direct
- * children of {@code nodes}.
- * @param {!Array<BookmarkTreeNode>} nodes .
- * @return {!Promise<Array<string>>} .
- */
-function getAllUrls(nodes) {
- var urls = [];
-
- // Adds the node and all its direct children.
- // TODO(deepak.m1): Here node should exist. When we delete the nodes then
- // datamodel gets updated but still it shows deleted items as selected items
- // and accessing those nodes throws chrome.runtime.lastError. This cause
- // undefined value for node. Please refer https://crbug.com/480935.
- function addNodes(node) {
- if (!node || node.id == 'new')
- return;
-
- if (node.children) {
- node.children.forEach(function(child) {
- if (!bmm.isFolder(child))
- urls.push(child.url);
- });
- } else {
- urls.push(node.url);
- }
- }
-
- // Get a future promise for the nodes.
- var promises = nodes.map(function(node) {
- if (bmm.isFolder(assert(node)))
- return bmm.loadSubtree(node.id);
- // Not a folder so we already have all the data we need.
- return Promise.resolve(node);
- });
-
- return Promise.all(promises).then(function(nodes) {
- nodes.forEach(addNodes);
- return urls;
- });
-}
-
-/**
- * Returns the nodes (non recursive) to use for the open commands.
- * @param {HTMLElement} target
- * @return {!Array<BookmarkTreeNode>}
- */
-function getNodesForOpen(target) {
- if (target == bmm.tree) {
- if (bmm.tree.selectedItem != searchTreeItem)
- return bmm.tree.selectedFolders;
- // Fall through to use all nodes in the list.
- } else {
- var items = bmm.list.selectedItems;
- if (items.length)
- return items;
- }
-
- // The list starts off with a null dataModel. We can get here during startup.
- if (!bmm.list.dataModel)
- return [];
-
- // Return an array based on the dataModel.
- return bmm.list.dataModel.slice();
-}
-
-/**
- * Returns a promise that will contain all URLs of all the selected bookmarks
- * and the nested bookmarks for use with the open commands.
- * @param {HTMLElement} target The target list or tree.
- * @return {Promise<Array<string>>} .
- */
-function getUrlsForOpenCommands(target) {
- return getAllUrls(getNodesForOpen(target));
-}
-
-function notNewNode(node) {
- return node.id != 'new';
-}
-
-/**
- * Helper function that updates the canExecute and labels for the open-like
- * commands.
- * @param {!cr.ui.CanExecuteEvent} e The event fired by the command system.
- * @param {!cr.ui.Command} command The command we are currently processing.
- * @param {string} singularId The string id of singular form of the menu label.
- * @param {string} pluralId The string id of menu label if the singular form is
- not used.
- * @param {boolean} commandDisabled Whether the menu item should be disabled
- no matter what bookmarks are selected.
- */
-function updateOpenCommand(e, command, singularId, pluralId, commandDisabled) {
- if (singularId) {
- // The command label reflects the selection which might not reflect
- // how many bookmarks will be opened. For example if you right click an
- // empty area in a folder with 1 bookmark the text should still say "all".
- var selectedNodes = getSelectedBookmarkNodes(e.target).filter(notNewNode);
- var singular = selectedNodes.length == 1 && !bmm.isFolder(selectedNodes[0]);
- command.label = loadTimeData.getString(singular ? singularId : pluralId);
- }
-
- if (commandDisabled) {
- command.disabled = true;
- e.canExecute = false;
- return;
- }
-
- getUrlsForOpenCommands(assertInstanceof(e.target, HTMLElement)).then(
- function(urls) {
- var disabled = !urls.length;
- command.disabled = disabled;
- e.canExecute = !disabled;
- });
-}
-
-/**
- * Calls the backend to figure out if we can paste the clipboard into the active
- * folder.
- * @param {Function=} opt_f Function to call after the state has been updated.
- */
-function updatePasteCommand(opt_f) {
- function update(commandId, canPaste) {
- $(commandId).disabled = !canPaste;
- }
-
- var promises = [];
-
- // The folders menu.
- // We can not paste into search item in tree.
- if (bmm.tree.selectedItem && bmm.tree.selectedItem != searchTreeItem) {
- promises.push(new Promise(function(resolve) {
- var id = bmm.tree.selectedItem.bookmarkId;
- chrome.bookmarkManagerPrivate.canPaste(id, function(canPaste) {
- update('paste-from-folders-menu-command', canPaste);
- resolve(canPaste);
- });
- }));
- } else {
- // Tree's not loaded yet.
- update('paste-from-folders-menu-command', false);
- }
-
- // The organize menu.
- var listId = bmm.list.parentId;
- if (bmm.list.isSearch() || !listId) {
- // We cannot paste into search view or the list isn't ready.
- update('paste-from-organize-menu-command', false);
- } else {
- promises.push(new Promise(function(resolve) {
- chrome.bookmarkManagerPrivate.canPaste(listId, function(canPaste) {
- update('paste-from-organize-menu-command', canPaste);
- resolve(canPaste);
- });
- }));
- }
-
- Promise.all(promises).then(function() {
- var cmd;
- if (document.activeElement == bmm.list)
- cmd = 'paste-from-organize-menu-command';
- else if (document.activeElement == bmm.tree)
- cmd = 'paste-from-folders-menu-command';
-
- if (cmd)
- update('paste-from-context-menu-command', !$(cmd).disabled);
-
- if (opt_f) opt_f();
- });
-}
-
-function handleCanExecuteForSearchBox(e) {
- var command = e.command;
- switch (command.id) {
- case 'delete-command':
- case 'undo-command':
- // Pass the delete and undo commands through
- // (fixes http://crbug.com/278112).
- e.canExecute = false;
- break;
- }
-}
-
-function handleCanExecuteForDocument(e) {
- var command = e.command;
- switch (command.id) {
- case 'import-menu-command':
- e.canExecute = canEdit;
- break;
-
- case 'export-menu-command':
- // We can always execute the export-menu command.
- e.canExecute = true;
- break;
-
- case 'sort-command':
- e.canExecute = !bmm.list.isSearch() &&
- bmm.list.dataModel && bmm.list.dataModel.length > 1 &&
- !isUnmodifiable(bmm.tree.getBookmarkNodeById(bmm.list.parentId));
- break;
-
- case 'undo-command':
- // Because the global undo command has no visible UI, always enable it,
- // and just make it a no-op if undo is not possible.
- e.canExecute = true;
- break;
-
- default:
- canExecuteForList(e);
- if (!e.defaultPrevented)
- canExecuteForTree(e);
- break;
- }
-}
-
-/**
- * Helper function for handling canExecute for the list and the tree.
- * @param {!cr.ui.CanExecuteEvent} e Can execute event object.
- * @param {boolean} isSearch Whether the user is trying to do a command on
- * search.
- */
-function canExecuteShared(e, isSearch) {
- var command = e.command;
- switch (command.id) {
- case 'paste-from-folders-menu-command':
- case 'paste-from-organize-menu-command':
- case 'paste-from-context-menu-command':
- updatePasteCommand();
- break;
-
- case 'add-new-bookmark-command':
- case 'new-folder-command':
- case 'new-folder-from-folders-menu-command':
- var parentId = computeParentFolderForNewItem();
- var unmodifiable = isUnmodifiable(
- bmm.tree.getBookmarkNodeById(parentId));
- e.canExecute = !isSearch && canEdit && !unmodifiable;
- break;
-
- case 'open-in-new-tab-command':
- updateOpenCommand(e, command, 'open_in_new_tab', 'open_all', false);
- break;
-
- case 'open-in-background-tab-command':
- updateOpenCommand(e, command, '', '', false);
- break;
-
- case 'open-in-new-window-command':
- updateOpenCommand(e, command,
- 'open_in_new_window', 'open_all_new_window',
- // Disabled when incognito is forced.
- incognitoModeAvailability == 'forced');
- break;
-
- case 'open-incognito-window-command':
- updateOpenCommand(e, command,
- 'open_incognito', 'open_all_incognito',
- // Not available when incognito is disabled.
- incognitoModeAvailability == 'disabled');
- break;
-
- case 'undo-delete-command':
- e.canExecute = !!lastDeleted;
- break;
- }
-}
-
-/**
- * Helper function for handling canExecute for the list and document.
- * @param {!cr.ui.CanExecuteEvent} e Can execute event object.
- */
-function canExecuteForList(e) {
- function hasSelected() {
- return !!bmm.list.selectedItem;
- }
-
- function hasSingleSelected() {
- return bmm.list.selectedItems.length == 1;
- }
-
- function canCopyItem(item) {
- return item.id != 'new';
- }
-
- function canCopyItems() {
- var selectedItems = bmm.list.selectedItems;
- return selectedItems && selectedItems.some(canCopyItem);
- }
-
- function isSearch() {
- return bmm.list.isSearch();
- }
-
- var command = e.command;
- switch (command.id) {
- case 'rename-folder-command':
- // Show rename if a single folder is selected.
- var items = bmm.list.selectedItems;
- if (items.length != 1) {
- e.canExecute = false;
- command.hidden = true;
- } else {
- var isFolder = bmm.isFolder(items[0]);
- e.canExecute = isFolder && canEdit && !hasUnmodifiable(items);
- command.hidden = !isFolder;
- }
- break;
-
- case 'edit-command':
- // Show the edit command if not a folder.
- var items = bmm.list.selectedItems;
- if (items.length != 1) {
- e.canExecute = false;
- command.hidden = false;
- } else {
- var isFolder = bmm.isFolder(items[0]);
- e.canExecute = !isFolder && canEdit && !hasUnmodifiable(items);
- command.hidden = isFolder;
- }
- break;
-
- case 'show-in-folder-command':
- e.canExecute = isSearch() && hasSingleSelected();
- break;
-
- case 'delete-command':
- case 'cut-command':
- e.canExecute = canCopyItems() && canEdit &&
- !hasUnmodifiable(bmm.list.selectedItems);
- break;
-
- case 'copy-command':
- e.canExecute = canCopyItems();
- break;
-
- case 'open-in-same-window-command':
- e.canExecute = (e.target == bmm.list) && hasSelected();
- break;
-
- default:
- canExecuteShared(e, isSearch());
- }
-}
-
-// Update canExecute for the commands when the list is the active element.
-function handleCanExecuteForList(e) {
- if (e.target != bmm.list) return;
- canExecuteForList(e);
-}
-
-// Update canExecute for the commands when the tree is the active element.
-function handleCanExecuteForTree(e) {
- if (e.target != bmm.tree) return;
- canExecuteForTree(e);
-}
-
-function canExecuteForTree(e) {
- function hasSelected() {
- return !!bmm.tree.selectedItem;
- }
-
- function isSearch() {
- return bmm.tree.selectedItem == searchTreeItem;
- }
-
- function isTopLevelItem() {
- return bmm.tree.selectedItem &&
- bmm.tree.selectedItem.parentNode == bmm.tree;
- }
-
- var command = e.command;
- switch (command.id) {
- case 'rename-folder-command':
- case 'rename-folder-from-folders-menu-command':
- command.hidden = false;
- e.canExecute = hasSelected() && !isTopLevelItem() && canEdit &&
- !hasUnmodifiable(bmm.tree.selectedFolders);
- break;
-
- case 'edit-command':
- command.hidden = true;
- e.canExecute = false;
- break;
-
- case 'delete-command':
- case 'delete-from-folders-menu-command':
- case 'cut-command':
- case 'cut-from-folders-menu-command':
- e.canExecute = hasSelected() && !isTopLevelItem() && canEdit &&
- !hasUnmodifiable(bmm.tree.selectedFolders);
- break;
-
- case 'copy-command':
- case 'copy-from-folders-menu-command':
- e.canExecute = hasSelected() && !isTopLevelItem();
- break;
-
- case 'undo-delete-from-folders-menu-command':
- e.canExecute = lastDeleted && lastDeleted.target == bmm.tree;
- break;
-
- default:
- canExecuteShared(e, isSearch());
- }
-}
-
-/**
- * Update the canExecute state of all the commands.
- */
-function updateAllCommands() {
- var commands =
- /** @type {NodeList<Command>} */ (document.querySelectorAll('command'));
- for (var i = 0; i < commands.length; i++) {
- commands[i].canExecuteChange();
- }
-}
-
-function updateEditingCommands() {
- var editingCommands = [
- 'add-new-bookmark',
- 'cut',
- 'cut-from-folders-menu',
- 'delete',
- 'edit',
- 'new-folder',
- 'paste-from-context-menu',
- 'paste-from-folders-menu',
- 'paste-from-organize-menu',
- 'rename-folder',
- 'sort',
- ];
-
- chrome.bookmarkManagerPrivate.canEdit(function(result) {
- if (result != canEdit) {
- canEdit = result;
- editingCommands.forEach(function(baseId) {
- /** @type {Command} */ ($(baseId + '-command')).canExecuteChange();
- });
- }
- });
-}
-
-function handleChangeForTree(e) {
- navigateTo(bmm.tree.selectedItem.bookmarkId);
-}
-
-function handleMenuButtonClicked(e) {
- updateEditingCommands();
-
- if (e.currentTarget.id == 'folders-menu') {
- /** @type {Command} */ ($('copy-from-folders-menu-command'))
- .canExecuteChange();
- /** @type {Command} */ ($('undo-delete-from-folders-menu-command'))
- .canExecuteChange();
- } else {
- /** @type {Command} */ ($('copy-command')).canExecuteChange();
- }
-}
-
-function handleRename(e) {
- var item = e.target;
- var bookmarkNode = item.bookmarkNode;
- chrome.bookmarks.update(bookmarkNode.id, {title: item.label});
- performGlobalUndo = null; // This can't be undone, so disable global undo.
-}
-
-function handleEdit(e) {
- var item = e.target;
- var bookmarkNode = item.bookmarkNode;
- var context = {
- title: bookmarkNode.title
- };
- if (!bmm.isFolder(bookmarkNode))
- context.url = bookmarkNode.url;
-
- if (bookmarkNode.id == 'new') {
- selectItemsAfterUserAction(/** @type {BookmarkList} */(bmm.list));
-
- // New page
- context.parentId = bookmarkNode.parentId;
- chrome.bookmarks.create(context, function(node) {
- // A new node was created and will get added to the list due to the
- // handler.
- var dataModel = bmm.list.dataModel;
- var index = dataModel.indexOf(bookmarkNode);
- dataModel.splice(index, 1);
-
- // Select new item.
- var newIndex = dataModel.findIndexById(node.id);
- if (newIndex != -1) {
- var sm = bmm.list.selectionModel;
- bmm.list.scrollIndexIntoView(newIndex);
- sm.leadIndex = sm.anchorIndex = sm.selectedIndex = newIndex;
- }
- });
- } else {
- // Edit
- chrome.bookmarks.update(bookmarkNode.id, context);
- }
- performGlobalUndo = null; // This can't be undone, so disable global undo.
-}
-
-function handleCancelEdit(e) {
- var item = e.target;
- var bookmarkNode = item.bookmarkNode;
- if (bookmarkNode.id == 'new') {
- var dataModel = bmm.list.dataModel;
- var index = dataModel.findIndexById('new');
- dataModel.splice(index, 1);
- }
-}
-
-/**
- * Navigates to the folder that the selected item is in and selects it. This is
- * used for the show-in-folder command.
- */
-function showInFolder() {
- var bookmarkNode = bmm.list.selectedItem;
- if (!bookmarkNode)
- return;
- var parentId = bookmarkNode.parentId;
-
- // After the list is loaded we should select the revealed item.
- function selectItem() {
- var index = bmm.list.dataModel.findIndexById(bookmarkNode.id);
- if (index == -1)
- return;
- var sm = bmm.list.selectionModel;
- sm.anchorIndex = sm.leadIndex = sm.selectedIndex = index;
- bmm.list.scrollIndexIntoView(index);
- }
-
- var treeItem = bmm.treeLookup[parentId];
- treeItem.reveal();
-
- navigateTo(parentId, selectItem);
-}
-
-/**
- * @return {!cr.LinkController} The link controller used to open links based on
- * user clicks and keyboard actions.
- */
-function getLinkController() {
- return linkController ||
- (linkController = new cr.LinkController(loadTimeData));
-}
-
-/**
- * Returns the selected bookmark nodes of the provided tree or list.
- * If |opt_target| is not provided or null the active element is used.
- * Only call this if the list or the tree is focused.
- * @param {EventTarget=} opt_target The target list or tree.
- * @return {!Array} Array of bookmark nodes.
- */
-function getSelectedBookmarkNodes(opt_target) {
- return (opt_target || document.activeElement) == bmm.tree ?
- bmm.tree.selectedFolders : bmm.list.selectedItems;
-}
-
-/**
- * @param {EventTarget=} opt_target The target list or tree.
- * @return {!Array<string>} An array of the selected bookmark IDs.
- */
-function getSelectedBookmarkIds(opt_target) {
- var selectedNodes = getSelectedBookmarkNodes(opt_target);
- selectedNodes.sort(function(a, b) { return a.index - b.index; });
- return selectedNodes.map(function(node) {
- return node.id;
- });
-}
-
-/**
- * @param {BookmarkTreeNode} node The node to test.
- * @return {boolean} Whether the given node is unmodifiable.
- */
-function isUnmodifiable(node) {
- return !!(node && node.unmodifiable);
-}
-
-/**
- * @param {Array<BookmarkTreeNode>} nodes A list of BookmarkTreeNodes.
- * @return {boolean} Whether any of the nodes is managed.
- */
-function hasUnmodifiable(nodes) {
- return nodes.some(isUnmodifiable);
-}
-
-/**
- * Opens the selected bookmarks.
- * @param {cr.LinkKind} kind The kind of link we want to open.
- * @param {HTMLElement=} opt_eventTarget The target of the user initiated event.
- */
-function openBookmarks(kind, opt_eventTarget) {
- // If we have selected any folders, we need to find all the bookmarks one
- // level down. We use multiple async calls to getSubtree instead of getting
- // the whole tree since we would like to minimize the amount of data sent.
-
- var urlsP = getUrlsForOpenCommands(opt_eventTarget ? opt_eventTarget : null);
- urlsP.then(function(urls) {
- getLinkController().openUrls(assert(urls), kind);
- chrome.bookmarkManagerPrivate.recordLaunch();
- });
-}
-
-/**
- * Opens an item in the list.
- */
-function openItem() {
- var bookmarkNodes = getSelectedBookmarkNodes();
- // If we double clicked or pressed enter on a single folder, navigate to it.
- if (bookmarkNodes.length == 1 && bmm.isFolder(bookmarkNodes[0]))
- navigateTo(bookmarkNodes[0].id);
- else
- openBookmarks(LinkKind.FOREGROUND_TAB);
-}
-
-/**
- * Refreshes search results after delete or undo-delete.
- * This ensures children of deleted folders do not remain in results
- */
-function updateSearchResults() {
- if (bmm.list.isSearch())
- bmm.list.reload();
-}
-
-/**
- * Deletes the selected bookmarks. The bookmarks are saved in memory in case
- * the user needs to undo the deletion.
- * @param {EventTarget=} opt_target The deleter of bookmarks.
- */
-function deleteBookmarks(opt_target) {
- var selectedIds = getSelectedBookmarkIds(opt_target);
- if (!selectedIds.length)
- return;
-
- var filteredIds = getFilteredSelectedBookmarkIds(opt_target);
- lastDeleted = {nodes: [], target: opt_target || document.activeElement};
-
- function performDelete() {
- // Only remove filtered ids.
- chrome.bookmarkManagerPrivate.removeTrees(filteredIds);
- /** @type {Command} */ ($('undo-delete-command')).canExecuteChange();
- /** @type {Command} */ ($('undo-delete-from-folders-menu-command'))
- .canExecuteChange();
- performGlobalUndo = undoDelete;
- }
-
- // First, store information about the bookmarks being deleted.
- // Store all selected ids.
- selectedIds.forEach(function(id) {
- chrome.bookmarks.getSubTree(id, function(results) {
- lastDeleted.nodes.push(results);
-
- // When all nodes have been saved, perform the deletion.
- if (lastDeleted.nodes.length === selectedIds.length) {
- performDelete();
- updateSearchResults();
- }
- });
- });
-}
-
-/**
- * Restores a tree of bookmarks under a specified folder.
- * @param {BookmarkTreeNode} node The node to restore.
- * @param {(string|number)=} opt_parentId If a string is passed, it's the ID of
- * the folder to restore under. If not specified or a number is passed, the
- * original parentId of the node will be used.
- */
-function restoreTree(node, opt_parentId) {
- var bookmarkInfo = {
- parentId: typeof opt_parentId == 'string' ? opt_parentId : node.parentId,
- title: node.title,
- index: node.index,
- url: node.url
- };
-
- chrome.bookmarks.create(bookmarkInfo, function(result) {
- if (!result) {
- console.error('Failed to restore bookmark.');
- return;
- }
-
- if (node.children) {
- // Restore the children using the new ID for this node.
- node.children.forEach(function(child) {
- restoreTree(child, result.id);
- });
- }
-
- updateSearchResults();
- });
-}
-
-/**
- * Restores the last set of bookmarks that was deleted.
- */
-function undoDelete() {
- lastDeleted.nodes.forEach(function(arr) {
- arr.forEach(restoreTree);
- });
- lastDeleted = null;
- /** @type {Command} */ ($('undo-delete-command')).canExecuteChange();
- /** @type {Command} */ ($('undo-delete-from-folders-menu-command'))
- .canExecuteChange();
-
- // Only a single level of undo is supported, so disable global undo now.
- performGlobalUndo = null;
-}
-
-/**
- * Computes folder for "Add Page" and "Add Folder".
- * @return {string} The id of folder node where we'll create new page/folder.
- */
-function computeParentFolderForNewItem() {
- if (document.activeElement == bmm.tree)
- return bmm.list.parentId;
- var selectedItem = bmm.list.selectedItem;
- return selectedItem && bmm.isFolder(selectedItem) ?
- selectedItem.id : bmm.list.parentId;
-}
-
-/**
- * Callback for rename folder and edit command. This starts editing for
- * the passed in target, or the selected item.
- * @param {EventTarget=} opt_target The target to start editing. If absent or
- * null, the selected item will be edited instead.
- */
-function editItem(opt_target) {
- if ((opt_target || document.activeElement) == bmm.tree) {
- bmm.tree.selectedItem.editing = true;
- } else {
- var li = bmm.list.getListItem(bmm.list.selectedItem);
- if (li)
- li.editing = true;
- }
-}
-
-/**
- * Callback for the new folder command. This creates a new folder and starts
- * a rename of it.
- * @param {EventTarget=} opt_target The target to create a new folder in.
- */
-function newFolder(opt_target) {
- performGlobalUndo = null; // This can't be undone, so disable global undo.
-
- var parentId = computeParentFolderForNewItem();
- var selectedItems = bmm.list.selectedItems;
- var newIndex;
- // Callback is called after tree and list data model updated.
- function createFolder(callback) {
- if (selectedItems.length == 1 && document.activeElement != bmm.tree &&
- !bmm.isFolder(selectedItems[0]) && selectedItems[0].id != 'new') {
- newIndex = bmm.list.dataModel.indexOf(selectedItems[0]) + 1;
- }
- chrome.bookmarks.create({
- title: loadTimeData.getString('new_folder_name'),
- parentId: parentId,
- index: newIndex
- }, callback);
- }
-
- if ((opt_target || document.activeElement) == bmm.tree) {
- createFolder(function(newNode) {
- navigateTo(newNode.id, function() {
- bmm.treeLookup[newNode.id].editing = true;
- });
- });
- return;
- }
-
- function editNewFolderInList() {
- createFolder(function(newNode) {
- var index = newNode.index;
- var sm = bmm.list.selectionModel;
- sm.anchorIndex = sm.leadIndex = sm.selectedIndex = index;
- scrollIntoViewAndMakeEditable(index);
- });
- }
-
- navigateTo(parentId, editNewFolderInList);
-}
-
-/**
- * Scrolls the list item into view and makes it editable.
- * @param {number} index The index of the item to make editable.
- */
-function scrollIntoViewAndMakeEditable(index) {
- bmm.list.scrollIndexIntoView(index);
- // onscroll is now dispatched asynchronously so we have to postpone
- // the rest.
- setTimeout(function() {
- var item = bmm.list.getListItemByIndex(index);
- if (item)
- item.editing = true;
- }, 0);
-}
-
-/**
- * Adds a page to the current folder. This is called by the
- * add-new-bookmark-command handler.
- */
-function addPage() {
- var parentId = computeParentFolderForNewItem();
- var selectedItems = bmm.list.selectedItems;
- var newIndex;
- function editNewBookmark() {
- if (selectedItems.length == 1 && document.activeElement != bmm.tree &&
- !bmm.isFolder(selectedItems[0])) {
- newIndex = bmm.list.dataModel.indexOf(selectedItems[0]) + 1;
- }
-
- var fakeNode = {
- title: '',
- url: '',
- parentId: parentId,
- index: newIndex,
- id: 'new'
- };
- var dataModel = bmm.list.dataModel;
- var index = dataModel.length;
- if (newIndex != undefined)
- index = newIndex;
- dataModel.splice(index, 0, fakeNode);
- var sm = bmm.list.selectionModel;
- sm.anchorIndex = sm.leadIndex = sm.selectedIndex = index;
- scrollIntoViewAndMakeEditable(index);
- }
-
- navigateTo(parentId, editNewBookmark);
-}
-
-/**
- * This function is used to select items after a user action such as paste, drop
- * add page etc.
- * @param {BookmarkList|BookmarkTree} target The target of the user action.
- * @param {string=} opt_selectedTreeId If provided, then select that tree id.
- */
-function selectItemsAfterUserAction(target, opt_selectedTreeId) {
- // We get one onCreated event per item so we delay the handling until we get
- // no more events coming.
-
- var ids = [];
- var timer;
-
- function handle(id, bookmarkNode) {
- clearTimeout(timer);
- if (opt_selectedTreeId || bmm.list.parentId == bookmarkNode.parentId)
- ids.push(id);
- timer = setTimeout(handleTimeout, 50);
- }
-
- function handleTimeout() {
- chrome.bookmarks.onCreated.removeListener(handle);
- chrome.bookmarks.onMoved.removeListener(handle);
-
- if (opt_selectedTreeId && ids.indexOf(opt_selectedTreeId) != -1) {
- var index = ids.indexOf(opt_selectedTreeId);
- if (index != -1 && opt_selectedTreeId in bmm.treeLookup) {
- bmm.tree.selectedItem = bmm.treeLookup[opt_selectedTreeId];
- }
- } else if (target == bmm.list) {
- var dataModel = bmm.list.dataModel;
- var firstIndex = dataModel.findIndexById(ids[0]);
- var lastIndex = dataModel.findIndexById(ids[ids.length - 1]);
- if (firstIndex != -1 && lastIndex != -1) {
- var selectionModel = bmm.list.selectionModel;
- selectionModel.selectedIndex = -1;
- selectionModel.selectRange(firstIndex, lastIndex);
- selectionModel.anchorIndex = selectionModel.leadIndex = lastIndex;
- bmm.list.focus();
- }
- }
-
- bmm.list.endBatchUpdates();
- }
-
- bmm.list.startBatchUpdates();
-
- chrome.bookmarks.onCreated.addListener(handle);
- chrome.bookmarks.onMoved.addListener(handle);
- timer = setTimeout(handleTimeout, 300);
-}
-
-/**
- * Record user action.
- * @param {string} name An user action name.
- */
-function recordUserAction(name) {
- chrome.metricsPrivate.recordUserAction('BookmarkManager_Command_' + name);
-}
-
-/**
- * The currently selected bookmark, based on where the user is clicking.
- * @return {string} The ID of the currently selected bookmark (could be from
- * tree view or list view).
- */
-function getSelectedId() {
- if (document.activeElement == bmm.tree)
- return bmm.tree.selectedItem.bookmarkId;
- var selectedItem = bmm.list.selectedItem;
- return selectedItem && bmm.isFolder(selectedItem) ?
- selectedItem.id : bmm.tree.selectedItem.bookmarkId;
-}
-
-/**
- * Pastes the copied/cutted bookmark into the right location depending whether
- * if it was called from Organize Menu or from Context Menu.
- * @param {string} id The id of the element being pasted from.
- */
-function pasteBookmark(id) {
- recordUserAction('Paste');
- selectItemsAfterUserAction(/** @type {BookmarkList} */(bmm.list));
- chrome.bookmarkManagerPrivate.paste(id, getSelectedBookmarkIds());
-}
-
-/**
- * Returns true if child is contained in another selected folder.
- * Traces parent nodes up the tree until a selected ancestor or root is found.
- */
-function hasSelectedAncestor(parentNode) {
- function contains(arr, item) {
- for (var i = 0; i < arr.length; i++)
- if (arr[i] === item)
- return true;
- return false;
- }
-
- // Don't search top level, cannot select permanent nodes in search.
- if (parentNode == null || parentNode.id <= 2)
- return false;
-
- // Found selected ancestor.
- if (contains(getSelectedBookmarkNodes(), parentNode))
- return true;
-
- // Keep digging.
- return hasSelectedAncestor(
- bmm.tree.getBookmarkNodeById(parentNode.parentId));
-}
-
-/**
- * @param {EventTarget=} opt_target A target to get bookmark IDs from.
- * @return {Array<string>} An array of bookmarks IDs.
- */
-function getFilteredSelectedBookmarkIds(opt_target) {
- // Remove duplicates from filteredIds and return.
- var filteredIds = [];
- // Selected nodes to iterate through for matches.
- var nodes = getSelectedBookmarkNodes(opt_target);
-
- for (var i = 0; i < nodes.length; i++)
- if (!hasSelectedAncestor(bmm.tree.getBookmarkNodeById(nodes[i].parentId)))
- filteredIds.splice(0, 0, nodes[i].id);
-
- return filteredIds;
-}
-
-/**
- * Handler for the command event. This is used for context menu of list/tree
- * and organized menu.
- * @param {!Event} e The event object.
- */
-function handleCommand(e) {
- var command = e.command;
- var target = assertInstanceof(e.target, HTMLElement);
- switch (command.id) {
- case 'import-menu-command':
- recordUserAction('Import');
- chrome.bookmarks.import();
- break;
-
- case 'export-menu-command':
- recordUserAction('Export');
- chrome.bookmarks.export();
- break;
-
- case 'undo-command':
- if (performGlobalUndo) {
- recordUserAction('UndoGlobal');
- performGlobalUndo();
- } else {
- recordUserAction('UndoNone');
- }
- break;
-
- case 'show-in-folder-command':
- recordUserAction('ShowInFolder');
- showInFolder();
- break;
-
- case 'open-in-new-tab-command':
- case 'open-in-background-tab-command':
- recordUserAction('OpenInNewTab');
- openBookmarks(LinkKind.BACKGROUND_TAB, target);
- break;
-
- case 'open-in-new-window-command':
- recordUserAction('OpenInNewWindow');
- openBookmarks(LinkKind.WINDOW, target);
- break;
-
- case 'open-incognito-window-command':
- recordUserAction('OpenIncognito');
- openBookmarks(LinkKind.INCOGNITO, target);
- break;
-
- case 'delete-from-folders-menu-command':
- target = bmm.tree;
- case 'delete-command':
- recordUserAction('Delete');
- deleteBookmarks(target);
- break;
-
- case 'copy-from-folders-menu-command':
- target = bmm.tree;
- case 'copy-command':
- recordUserAction('Copy');
- chrome.bookmarkManagerPrivate.copy(getSelectedBookmarkIds(target),
- updatePasteCommand);
- break;
-
- case 'cut-from-folders-menu-command':
- target = bmm.tree;
- case 'cut-command':
- recordUserAction('Cut');
- chrome.bookmarkManagerPrivate.cut(getSelectedBookmarkIds(target),
- function() {
- updatePasteCommand();
- updateSearchResults();
- });
- break;
-
- case 'paste-from-organize-menu-command':
- pasteBookmark(bmm.list.parentId);
- break;
-
- case 'paste-from-folders-menu-command':
- pasteBookmark(bmm.tree.selectedItem.bookmarkId);
- break;
-
- case 'paste-from-context-menu-command':
- pasteBookmark(getSelectedId());
- break;
-
- case 'sort-command':
- recordUserAction('Sort');
- chrome.bookmarkManagerPrivate.sortChildren(bmm.list.parentId);
- break;
-
-
- case 'rename-folder-from-folders-menu-command':
- target = bmm.tree;
- case 'rename-folder-command':
- editItem(target);
- break;
-
- case 'edit-command':
- recordUserAction('Edit');
- editItem();
- break;
-
- case 'new-folder-from-folders-menu-command':
- target = bmm.tree;
- case 'new-folder-command':
- recordUserAction('NewFolder');
- newFolder(target);
- break;
-
- case 'add-new-bookmark-command':
- recordUserAction('AddPage');
- addPage();
- break;
-
- case 'open-in-same-window-command':
- recordUserAction('OpenInSame');
- openItem();
- break;
-
- case 'undo-delete-command':
- case 'undo-delete-from-folders-menu-command':
- recordUserAction('UndoDelete');
- undoDelete();
- break;
- }
-}
-
-// Execute the copy, cut and paste commands when those events are dispatched by
-// the browser. This allows us to rely on the browser to handle the keyboard
-// shortcuts for these commands.
-function installEventHandlerForCommand(eventName, commandId) {
- function handle(e) {
- if (document.activeElement != bmm.list &&
- document.activeElement != bmm.tree)
- return;
- var command = /** @type {Command} */ ($(commandId));
- if (!command.disabled) {
- command.execute();
- if (e)
- e.preventDefault(); // Prevent the system beep.
- }
- }
- if (eventName == 'paste') {
- // Paste is a bit special since we need to do an async call to see if we
- // can paste because the paste command might not be up to date.
- document.addEventListener(eventName, function(e) {
- updatePasteCommand(handle);
- });
- } else {
- document.addEventListener(eventName, handle);
- }
-}
-
-function initializeSplitter() {
- var splitter = document.querySelector('.main > .splitter');
- Splitter.decorate(splitter);
-
- var splitterStyle = splitter.previousElementSibling.style;
-
- // The splitter persists the size of the left component in the local store.
- if ('treeWidth' in window.localStorage)
- splitterStyle.width = window.localStorage['treeWidth'];
-
- splitter.addEventListener('resize', function(e) {
- window.localStorage['treeWidth'] = splitterStyle.width;
- });
-}
-
-function initializeBookmarkManager() {
- // Sometimes the extension API is not initialized.
- if (!chrome.bookmarks)
- console.error('Bookmarks extension API is not available');
-
- chrome.bookmarkManagerPrivate.getStrings(continueInitializeBookmarkManager);
-}
-
-function continueInitializeBookmarkManager(localizedStrings) {
- loadLocalizedStrings(localizedStrings);
-
- bmm.treeLookup[searchTreeItem.bookmarkId] = searchTreeItem;
-
- cr.ui.decorate('cr-menu', Menu);
- cr.ui.decorate('button[menu]', MenuButton);
- cr.ui.decorate('command', Command);
- BookmarkList.decorate($('list'));
- BookmarkTree.decorate($('tree'));
-
- bmm.list.addEventListener('canceledit', handleCancelEdit);
- bmm.list.addEventListener('canExecute', handleCanExecuteForList);
- bmm.list.addEventListener('change', updateAllCommands);
- bmm.list.addEventListener('contextmenu', updateEditingCommands);
- bmm.list.addEventListener('dblclick', handleDoubleClickForList);
- bmm.list.addEventListener('edit', handleEdit);
- bmm.list.addEventListener('rename', handleRename);
- bmm.list.addEventListener('urlClicked', handleUrlClickedForList);
-
- bmm.tree.addEventListener('canExecute', handleCanExecuteForTree);
- bmm.tree.addEventListener('change', handleChangeForTree);
- bmm.tree.addEventListener('contextmenu', updateEditingCommands);
- bmm.tree.addEventListener('rename', handleRename);
- bmm.tree.addEventListener('load', handleLoadForTree);
-
- cr.ui.contextMenuHandler.addContextMenuProperty(
- /** @type {!Element} */(bmm.tree));
- bmm.list.contextMenu = $('context-menu');
- bmm.tree.contextMenu = $('context-menu');
-
- // We listen to hashchange so that we can update the currently shown folder
- // when // the user goes back and forward in the history.
- window.addEventListener('hashchange', processHash);
-
- document.querySelector('header form').onsubmit =
- /** @type {function(Event=)} */(function(e) {
- setSearch($('term').value);
- e.preventDefault();
- });
-
- $('term').addEventListener('search', handleSearch);
- $('term').addEventListener('canExecute', handleCanExecuteForSearchBox);
-
- $('folders-button').addEventListener('click', handleMenuButtonClicked);
- $('organize-button').addEventListener('click', handleMenuButtonClicked);
-
- document.addEventListener('canExecute', handleCanExecuteForDocument);
- document.addEventListener('command', handleCommand);
-
- // Listen to copy, cut and paste events and execute the associated commands.
- installEventHandlerForCommand('copy', 'copy-command');
- installEventHandlerForCommand('cut', 'cut-command');
- installEventHandlerForCommand('paste', 'paste-from-organize-menu-command');
-
- // Install shortcuts
- for (var name in commandShortcutMap) {
- $(name + '-command').shortcut = commandShortcutMap[name];
- }
-
- // Disable almost all commands at startup.
- var commands = document.querySelectorAll('command');
- for (var i = 0, command; command = commands[i]; ++i) {
- if (command.id != 'import-menu-command' &&
- command.id != 'export-menu-command') {
- command.disabled = true;
- }
- }
-
- chrome.bookmarkManagerPrivate.canEdit(function(result) {
- canEdit = result;
- });
-
- chrome.systemPrivate.getIncognitoModeAvailability(function(result) {
- // TODO(rustema): propagate policy value to the bookmark manager when it
- // changes.
- incognitoModeAvailability = result;
- });
-
- cr.ui.FocusOutlineManager.forDocument(document);
- initializeSplitter();
- bmm.addBookmarkModelListeners();
- dnd.init(selectItemsAfterUserAction);
- bmm.tree.reload();
-}
-
-initializeBookmarkManager();
-})();
diff --git a/chromium/chrome/browser/resources/bookmark_manager/main.html b/chromium/chrome/browser/resources/bookmark_manager/main.html
deleted file mode 100644
index 8a5e831309d..00000000000
--- a/chromium/chrome/browser/resources/bookmark_manager/main.html
+++ /dev/null
@@ -1,207 +0,0 @@
-<!doctype html>
-<html i18n-values="dir:textdirection;lang:language">
-<!--
-
-Copyright (c) 2012 The Chromium Authors. All rights reserved.
-Use of this source code is governed by a BSD-style license that can be
-found in the LICENSE file.
-
--->
-<head>
-<meta name="google" value="notranslate">
-<meta charset="utf-8">
-<title i18n-content="title"></title>
-
-<link rel="stylesheet" href="chrome://resources/css/text_defaults.css">
-<link rel="stylesheet" href="chrome://resources/css/i18n_process.css">
-<link rel="stylesheet" href="chrome://resources/css/list.css">
-<link rel="stylesheet" href="chrome://resources/css/tree.css">
-<link rel="stylesheet" href="chrome://resources/css/menu.css">
-<link rel="stylesheet" href="chrome://resources/css/menu_button.css">
-<link rel="stylesheet" href="chrome://resources/css/widgets.css">
-<link rel="stylesheet" href="css/bmm.css">
-
-<script src="chrome://resources/js/event_tracker.js"></script>
-
-<script src="chrome://resources/js/cr.js"></script>
-<script src="chrome://resources/js/cr/event_target.js"></script>
-<script src="chrome://resources/js/cr/link_controller.js"></script>
-<script src="chrome://resources/js/cr/ui.js"></script>
-<script src="chrome://resources/js/cr/ui/touch_handler.js"></script>
-<script src="chrome://resources/js/cr/ui/array_data_model.js"></script>
-<script src="chrome://resources/js/cr/ui/command.js"></script>
-<script src="chrome://resources/js/cr/ui/focus_outline_manager.js"></script>
-<script src="chrome://resources/js/cr/ui/menu_item.js"></script>
-<script src="chrome://resources/js/cr/ui/menu.js"></script>
-<script src="chrome://resources/js/cr/ui/position_util.js"></script>
-<script src="chrome://resources/js/cr/ui/menu_button.js"></script>
-<script src="chrome://resources/js/cr/ui/context_menu_button.js"></script>
-<script src="chrome://resources/js/cr/ui/context_menu_handler.js"></script>
-<script src="chrome://resources/js/cr/ui/list_selection_model.js"></script>
-<script src="chrome://resources/js/cr/ui/list_selection_controller.js"></script>
-<script src="chrome://resources/js/cr/ui/list_item.js"></script>
-<script src="chrome://resources/js/cr/ui/list.js"></script>
-<script src="chrome://resources/js/cr/ui/tree.js"></script>
-<script src="chrome://resources/js/cr/ui/splitter.js"></script>
-
-<script src="chrome://resources/js/i18n_template_no_process.js"></script>
-<script src="chrome://resources/js/icon.js"></script>
-<script src="chrome://resources/js/load_time_data.js"></script>
-<script src="chrome://resources/js/util.js"></script>
-
-<script src="js/bmm.js"></script>
-<script src="js/bmm/bookmark_list.js"></script>
-<script src="js/bmm/bookmark_tree.js"></script>
-<script src="js/dnd.js"></script>
-</head>
-<body>
-
-<header>
- <h1 i18n-content="title"></h1>
- <form>
- <input type="search" id="term" i18n-values="placeholder:search_button"
- autofocus incremental>
- </form>
-</header>
-
-<div class="main">
- <div id="tree-pane" class="pane">
- <div>
- <button menu="#folders-menu" i18n-content="folders_menu"
- id="folders-button" class="custom-appearance"></button>
- </div>
- <div id="tree-container">
- <tree id="tree" role="tree"></tree>
- </div>
- </div>
- <div class="splitter">
- <div>
- <!-- Used to occupy the correct amount of vertical space. -->
- <button menu="#no-menu" i18n-content="folders_menu"
- class="custom-appearance"></button>
- </div>
- </div>
- <div id="list-pane" class="pane">
- <div>
- <button menu="#organize-menu" i18n-content="organize_menu"
- id="organize-button" class="custom-appearance"></button>
- </div>
- <!-- The list doesn't use a scroll container as it truncates horizontally
- and handles its own vertical overflow. -->
- <list id="list"></list>
- </div>
-</div>
-
-<!-- Organize menu -->
-<command i18n-values=".label:rename_folder" id="rename-folder-command">
-</command>
-<command i18n-values=".label:edit" id="edit-command"></command>
-<command i18n-values=".label:show_in_folder" id="show-in-folder-command">
-</command>
-<command i18n-values=".label:cut" id="cut-command"></command>
-<command i18n-values=".label:copy" id="copy-command"></command>
-<command i18n-values=".label:paste" id="paste-from-organize-menu-command">
-</command>
-<command i18n-values=".label:delete" id="delete-command"></command>
-<command i18n-values=".label:undo_delete" id="undo-delete-command"></command>
-<command i18n-values=".label:sort" id="sort-command"></command>
-<command i18n-values=".label:add_new_bookmark" id="add-new-bookmark-command">
-</command>
-<command i18n-values=".label:new_folder" id="new-folder-command"></command>
-
-<!-- Folders menu -->
-<command i18n-values=".label:cut" id="cut-from-folders-menu-command"></command>
-<command i18n-values=".label:copy" id="copy-from-folders-menu-command">
-</command>
-<command i18n-values=".label:paste" id="paste-from-folders-menu-command">
-</command>
-<command i18n-values=".label:new_folder"
- id="new-folder-from-folders-menu-command"></command>
-<command i18n-values=".label:delete" id="delete-from-folders-menu-command">
-</command>
-<command i18n-values=".label:undo_delete"
- id="undo-delete-from-folders-menu-command"></command>
-
-<!-- Tools menu -->
-<command i18n-values=".label:import_menu" id="import-menu-command"></command>
-<command i18n-values=".label:export_menu" id="export-menu-command"></command>
-
-<!-- Context menu -->
-<command i18n-values=".label:paste" id="paste-from-context-menu-command">
-</command>
-
-<!-- open * are handled in canExecute handler -->
-<command id="open-in-new-tab-command"></command>
-<command id="open-in-background-tab-command"></command>
-<command id="open-in-new-window-command"></command>
-<command id="open-incognito-window-command"></command>
-<command id="open-in-same-window-command"></command>
-
-<command id="undo-command"></command>
-
-<command i18n-values=".label:rename_folder"
- id="rename-folder-from-folders-menu-command"></command>
-<command i18n-values=".label:paste" id="paste-from-folders-menu-command">
-</command>
-
-<!-- TODO(arv): I think the commands might be better created in code? -->
-
-<cr-menu id="folders-menu">
- <button command="#new-folder-from-folders-menu-command"></button>
- <hr>
- <button command="#rename-folder-from-folders-menu-command"></button>
- <hr>
- <button command="#cut-from-folders-menu-command"></button>
- <button command="#copy-from-folders-menu-command"></button>
- <button command="#paste-from-folders-menu-command"></button>
- <hr>
- <button command="#delete-from-folders-menu-command"></button>
- <button command="#undo-delete-from-folders-menu-command"></button>
-</cr-menu>
-
-<cr-menu id="no-menu"></cr-menu>
-
-<cr-menu id="organize-menu">
- <button command="#add-new-bookmark-command"></button>
- <button command="#new-folder-command"></button>
- <hr>
- <button command="#rename-folder-command"></button>
- <button command="#edit-command"></button>
- <button command="#show-in-folder-command"></button>
- <hr>
- <button command="#cut-command"></button>
- <button command="#copy-command"></button>
- <button command="#paste-from-organize-menu-command"></button>
- <hr>
- <button command="#delete-command"></button>
- <button command="#undo-delete-command"></button>
- <hr>
- <button command="#sort-command"></button>
- <hr>
- <button command="#import-menu-command"></button>
- <button command="#export-menu-command"></button>
-</cr-menu>
-
-<cr-menu id="context-menu">
- <button command="#open-in-new-tab-command"></button>
- <button command="#open-in-new-window-command"></button>
- <button command="#open-incognito-window-command"></button>
- <hr>
- <button command="#rename-folder-command"></button>
- <button command="#edit-command"></button>
- <button command="#show-in-folder-command"></button>
- <hr>
- <button command="#cut-command"></button>
- <button command="#copy-command"></button>
- <button command="#paste-from-context-menu-command"></button>
- <hr>
- <button command="#delete-command"></button>
- <button command="#undo-delete-command"></button>
- <hr>
- <button command="#add-new-bookmark-command"></button>
- <button command="#new-folder-command"></button>
-</cr-menu>
-
-<script src="js/main.js"></script>
-</body>
-</html>
diff --git a/chromium/chrome/browser/resources/bookmark_manager/manifest.json b/chromium/chrome/browser/resources/bookmark_manager/manifest.json
deleted file mode 100644
index 23222d04747..00000000000
--- a/chromium/chrome/browser/resources/bookmark_manager/manifest.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDQcByy+eN9jzazWF/DPn7NW47sW7lgmpk6eKc0BQM18q8hvEM3zNm2n7HkJv/R6fU+X5mtqkDuKvq5skF6qqUF4oEyaleWDFhd1xFwV7JV+/DU7bZ00w2+6gzqsabkerFpoP33ZRIw7OviJenP0c0uWqDWF8EGSyMhB3txqhOtiQIDAQAB",
- "name": "Bookmark Manager",
- "version": "0.1",
- "manifest_version": 2,
- "description": "Bookmark Manager",
- "icons": {
- // The favicon is loaded directly from resources.pak.
- },
- "incognito" : "split",
- "permissions": [
- "bookmarks",
- "bookmarkManagerPrivate",
- "metricsPrivate",
- "systemPrivate",
- "tabs",
- "chrome://favicon/",
- "chrome://resources/"
- ],
- "chrome_url_overrides": {
- "bookmarks": "main.html"
- },
- "content_security_policy":
- "object-src 'none'; script-src chrome://resources 'self' blob: filesystem:"
-}
diff --git a/chromium/chrome/browser/resources/chromeos/chromevox/BUILD.gn b/chromium/chrome/browser/resources/chromeos/chromevox/BUILD.gn
index 329a2f37113..c20da9a29c2 100644
--- a/chromium/chrome/browser/resources/chromeos/chromevox/BUILD.gn
+++ b/chromium/chrome/browser/resources/chromeos/chromevox/BUILD.gn
@@ -136,7 +136,10 @@ chromevox_modules = [
"cvox2/background/desktop_automation_handler.js",
"cvox2/background/earcon_engine.js",
"cvox2/background/editing.js",
+ "cvox2/background/event_source.js",
"cvox2/background/find_handler.js",
+ "cvox2/background/gesture_command_data.js",
+ "cvox2/background/gesture_command_handler.js",
"cvox2/background/i_search.js",
"cvox2/background/keyboard_handler.js",
"cvox2/background/live_regions.js",
diff --git a/chromium/chrome/browser/resources/chromeos/chromevox/strings/chromevox_strings.grd b/chromium/chrome/browser/resources/chromeos/chromevox/strings/chromevox_strings.grd
index 317b9552267..1b4fb0d5702 100644
--- a/chromium/chrome/browser/resources/chromeos/chromevox/strings/chromevox_strings.grd
+++ b/chromium/chrome/browser/resources/chromeos/chromevox/strings/chromevox_strings.grd
@@ -180,7 +180,7 @@
<message desc="The description of the readFromHere key. Displayed in the Options page." name="IDS_CHROMEVOX_READ_FROM_HERE">
Start reading from current location
</message>
- <message desc="The description of the showPowerKey key. Displayed in the Options page." name="IDS_CHROMEVOX_SHOW_POWER_KEY">
+ <message desc="The description of the command to show the ChromeVox menu. This menu is the application menu for ChromeVox and contains commands, as well as other useful menu items such as help." name="IDS_CHROMEVOX_SHOW_PANEL_MENU">
Open ChromeVox menus
</message>
<message desc="The description of the hidePowerKey key. Displayed in the Options page." name="IDS_CHROMEVOX_HIDE_POWER_KEY">
@@ -1054,6 +1054,132 @@
<message desc="This is an abbreviated ARIA widget role name shown on a braille display. When translating, try to find a contracted form of the translation for 'dialog' (as in dialog box on a computer screen) according to local conventions. If reasonable, use all lowercase and avoid punctuation to keep the number of characters as low as possible." name="IDS_CHROMEVOX_ROLE_DIALOG_BRL">
dlg
</message>
+ <message desc="Accessibility role description for abstract" name="IDS_CHROMEVOX_ROLE_DOC_ABSTRACT">
+ Abstract
+ </message>
+ <message desc="Accessibility role description for acknowledgments" name="IDS_CHROMEVOX_ROLE_DOC_ACKNOWLEDGMENTS">
+ Acknowledgments
+ </message>
+ <message desc="Accessibility role description for afterword" name="IDS_CHROMEVOX_ROLE_DOC_AFTERWORD">
+ Afterword
+ </message>
+ <message desc="Accessibility role description for appendix" name="IDS_CHROMEVOX_ROLE_DOC_APPENDIX">
+ Appendix
+ </message>
+ <message desc="Accessibility role description for back link" name="IDS_CHROMEVOX_ROLE_DOC_BACK_LINK">
+ Back link
+ </message>
+ <message desc="Accessibility role description for bibliography entry" name="IDS_CHROMEVOX_ROLE_DOC_BIBLIO_ENTRY">
+ Bibliography entry
+ </message>
+ <message desc="Accessibility role description for bibliography" name="IDS_CHROMEVOX_ROLE_DOC_BIBLIOGRAPHY">
+ Bibliography
+ </message>
+ <message desc="Accessibility role description for bibliography reference" name="IDS_CHROMEVOX_ROLE_DOC_BIBLIO_REF">
+ Bibliography reference
+ </message>
+ <message desc="Accessibility role description for chapter" name="IDS_CHROMEVOX_ROLE_DOC_CHAPTER">
+ Chapter
+ </message>
+ <message desc="Accessibility role description for colophon" name="IDS_CHROMEVOX_ROLE_DOC_COLOPHON">
+ Colophon
+ </message>
+ <message desc="Accessibility role description for conclusion" name="IDS_CHROMEVOX_ROLE_DOC_CONCLUSION">
+ Conclusion
+ </message>
+ <message desc="Accessibility role description for cover" name="IDS_CHROMEVOX_ROLE_DOC_COVER">
+ Cover
+ </message>
+ <message desc="Accessibility role description for credit" name="IDS_CHROMEVOX_ROLE_DOC_CREDIT">
+ Credit
+ </message>
+ <message desc="Accessibility role description for credits" name="IDS_CHROMEVOX_ROLE_DOC_CREDITS">
+ Credits
+ </message>
+ <message desc="Accessibility role description for dedication" name="IDS_CHROMEVOX_ROLE_DOC_DEDICATION">
+ Dedication
+ </message>
+ <message desc="Accessibility role description for endnote" name="IDS_CHROMEVOX_ROLE_DOC_ENDNOTE">
+ Endnote
+ </message>
+ <message desc="Accessibility role description for endnotes" name="IDS_CHROMEVOX_ROLE_DOC_ENDNOTES">
+ Endnotes
+ </message>
+ <message desc="Accessibility role description for epigraph" name="IDS_CHROMEVOX_ROLE_DOC_EPIGRAPH">
+ Epigraph
+ </message>
+ <message desc="Accessibility role description for epilogue" name="IDS_CHROMEVOX_ROLE_DOC_EPILOGUE">
+ Epilogue
+ </message>
+ <message desc="Accessibility role description for errata" name="IDS_CHROMEVOX_ROLE_DOC_ERRATA">
+ Errata
+ </message>
+ <message desc="Accessibility role description for example" name="IDS_CHROMEVOX_ROLE_DOC_EXAMPLE">
+ Example
+ </message>
+ <message desc="Accessibility role description for footnote" name="IDS_CHROMEVOX_ROLE_DOC_FOOTNOTE">
+ Footnote
+ </message>
+ <message desc="Accessibility role description for foreword" name="IDS_CHROMEVOX_ROLE_DOC_FOREWORD">
+ Foreword
+ </message>
+ <message desc="Accessibility role description for glossary" name="IDS_CHROMEVOX_ROLE_DOC_GLOSSARY">
+ Glossary
+ </message>
+ <message desc="Accessibility role description for glossary reference" name="IDS_CHROMEVOX_ROLE_DOC_GLOSS_REF">
+ Glossary reference
+ </message>
+ <message desc="Accessibility role description for index" name="IDS_CHROMEVOX_ROLE_DOC_INDEX">
+ Index
+ </message>
+ <message desc="Accessibility role description for introduction" name="IDS_CHROMEVOX_ROLE_DOC_INTRODUCTION">
+ Introduction
+ </message>
+ <message desc="Accessibility role description for note reference" name="IDS_CHROMEVOX_ROLE_DOC_NOTE_REF">
+ Note reference
+ </message>
+ <message desc="Accessibility role description for notice" name="IDS_CHROMEVOX_ROLE_DOC_NOTICE">
+ Notice
+ </message>
+ <message desc="Accessibility role description for page break" name="IDS_CHROMEVOX_ROLE_DOC_PAGE_BREAK">
+ Page break
+ </message>
+ <message desc="Accessibility role description for page list" name="IDS_CHROMEVOX_ROLE_DOC_PAGE_LIST">
+ Page list
+ </message>
+ <message desc="Accessibility role description for part" name="IDS_CHROMEVOX_ROLE_DOC_PART">
+ Part
+ </message>
+ <message desc="Accessibility role description for preface" name="IDS_CHROMEVOX_ROLE_DOC_PREFACE">
+ Preface
+ </message>
+ <message desc="Accessibility role description for prologue" name="IDS_CHROMEVOX_ROLE_DOC_PROLOGUE">
+ Prologue
+ </message>
+ <message desc="Accessibility role description for pullquote" name="IDS_CHROMEVOX_ROLE_DOC_PULLQUOTE">
+ Pullquote
+ </message>
+ <message desc="Accessibility role description for Q+A (questions and answers)" name="IDS_CHROMEVOX_ROLE_DOC_QNA">
+ Q&amp;A
+ </message>
+ <message desc="Accessibility role description for subtitle" name="IDS_CHROMEVOX_ROLE_DOC_SUBTITLE">
+ subti
+ </message>
+ <message desc="Accessibility role description for tip" name="IDS_CHROMEVOX_ROLE_DOC_TIP">
+ tip
+ </message>
+ <message desc="Accessibility role description for table of contents" name="IDS_CHROMEVOX_ROLE_DOC_TOC">
+ toc
+ </message>
+ <message desc="Accessibility role description for graphics document" name="IDS_CHROMEVOX_ROLE_GRAPHICS_DOCUMENT">
+ Graphics document
+ </message>
+ <message desc="Accessibility role description for graphics object" name="IDS_CHROMEVOX_ROLE_GRAPHICS_OBJECT">
+ Graphics object
+ </message>
+ <message desc="Accessibility role description for graphics symbol" name="IDS_CHROMEVOX_ROLE_GRAPHICS_SYMBOL">
+ Graphics symbol
+ </message>
<message desc="Describes an element with the ARIA role grid." name="IDS_CHROMEVOX_ROLE_GRID">
Grid
</message>
@@ -2622,11 +2748,11 @@
</message>
<message desc="Part of the ChromeVox tutorial, explains some common Chrome keyboard shortcuts" name="IDS_CHROMEVOX_TUTORIAL_CHROME_SHORTCUTS">
The next few shortcuts aren’t ChromeVox commands, but they’re still very useful for getting the most out of Chrome.
-To navigate forward through actionable items like buttons and links, press the Tab key. To navigate backwards, press Shift+Tab.
-To enter the Chrome browser address box, also called the omnibox, press Control + L.
-To open and go to a new tab automatically, press Control+T. Your cursor will be in the omnibox.
-To close a tab, press Control+W.
-To move forward between open tabs, use Control+Tab.
+To navigate forward through actionable items like buttons and links, press the Tab key. To navigate backwards, press Shift+Tab.
+To enter the Chrome browser address box, also called the omnibox, press Control + L.
+To open and go to a new tab automatically, press Control+T. Your cursor will be in the omnibox.
+To close a tab, press Control+W.
+To move forward between open tabs, use Control+Tab.
To open the Chrome browser menu, press Alt+F.
</message>
<message desc="Part of the ChromeVox tutorial, explains a keyboard shortcut to press on Chromebook keyboards" name="IDS_CHROMEVOX_TUTORIAL_CHROMEBOOK_CTRL_FORWARD">
@@ -2759,6 +2885,18 @@ If you're done with the tutorial, use ChromeVox to navigate to the Close button
<message desc="Spoken when a user navigates to the end of a text match from a find in page." name="IDS_CHROMEVOX_TEXT_MATCH_END">
Text match end
</message>
+ <message desc="Spoken when a user navigates to the beginning of subscript text." name="IDS_CHROMEVOX_SUBSCRIPT_START">
+ Subscript start
+ </message>
+ <message desc="Spoken when a user navigates to the end of subscript text." name="IDS_CHROMEVOX_SUBSCRIPT_END">
+ Subscript end
+ </message>
+ <message desc="Spoken when a user navigates to the beginning of superscript text." name="IDS_CHROMEVOX_SUPERSCRIPT_START">
+ Superscript start
+ </message>
+ <message desc="Spoken when a user navigates to the end of superscript text." name="IDS_CHROMEVOX_SUPERSCRIPT_END">
+ Superscript end
+ </message>
<message desc="Spoken when a user navigates to the beginning of bolded text." name="IDS_CHROMEVOX_BOLD_START">
Bold start
</message>
@@ -2816,6 +2954,27 @@ If you're done with the tutorial, use ChromeVox to navigate to the Close button
<message desc="A hint to the user for interacting with the menu control." name="IDS_CHROMEVOX_HINT_MENU">
Press up or down arrow to navigate; enter to activate.
</message>
+ <message desc="Describes the action of decrementing a control." name="IDS_CHROMEVOX_ACTION_DECREMENT_DESCRIPTION">
+ Decrease value
+ </message>
+ <message desc="Describes the action of incrementing a control." name="IDS_CHROMEVOX_ACTION_INCREMENT_DESCRIPTION">
+ Increase value
+ </message>
+ <message desc="Describes the action of scrolling backward." name="IDS_CHROMEVOX_ACTION_SCROLL_BACKWARD_DESCRIPTION">
+ Scroll back
+ </message>
+ <message desc="Describes the action of scrolling forward." name="IDS_CHROMEVOX_ACTION_SCROLL_FORWARD_DESCRIPTION">
+ Scroll forward
+ </message>
+ <message desc="A hint to the user that they are editing text within a text field. This text will be spoken using text to speech along with a description of the text field's name and value" name="IDS_CHROMEVOX_HINT_IS_EDITING">
+ is editing
+ </message>
+ <message desc="A hint to the user about the special behavior of the Search key with arrows within a text field. This text will be spoken using text to speech along with a description of the text field's name and value. The text is intentionally in fragments to reduce the time needed to convey this information via text to speech. Keys are capitalized and do not contain plus separators because it adds to the spoken announcement's duration. As a general guide, try to read the string aloud." name="IDS_CHROMEVOX_HINT_SEARCH_WITHIN_TEXT_FIELD">
+ Use Search Left or Right for Home or End, Search Control Left or Right for Control Home or End, Search Up or Down for Page Up or Down.
+ </message>
+ <message desc="A hint to the user controls that can be double tapped." name="IDS_CHROMEVOX_HINT_DOUBLE_TAP">
+ Double tap to activate
+ </message>
</messages>
</release>
</grit>
diff --git a/chromium/chrome/browser/resources/chromeos/crosh_builtin/manifest.json b/chromium/chrome/browser/resources/chromeos/crosh_builtin/manifest.json
index 9938484de90..759bd77b8ee 100644
--- a/chromium/chrome/browser/resources/chromeos/crosh_builtin/manifest.json
+++ b/chromium/chrome/browser/resources/chromeos/crosh_builtin/manifest.json
@@ -1,18 +1,24 @@
{
"key": "AAAAB3NzaC1yc2EAAAADAQABAAAAgQDtKfIKWzC4HnQbyAeddk5h78K7LSyrIEnLKDsQCNxhfsavJ+otV9JprDSz3nF7EHZokXiC72SHxdMndt2IlId/aRfhbU4UGidrmFBKg6v1Fs2zey6niB+xLOhJQMe9XtwVNWDpiGXHLmwNhG/FLhj0bBBf1HZDBV18Xp47ymLiuQ==",
- "name": "Chrome OS developer shell",
+ "name": "Terminal",
"manifest_version": 2,
+ "icons": {
+ "192": "images/dev/crostini-192.png"
+ },
"content_security_policy": "script-src 'self' blob: filesystem:; object-src 'self' blob: filesystem:",
"version": "0.8.36",
"default_locale": "en",
"description": "Built-in terminal for crosh.",
"offline_enabled": true,
+ "options_page": "html/nassh_preferences_editor.html",
"incognito": "split",
"permissions": [
"clipboardRead",
"clipboardWrite",
- "unlimitedStorage",
+ "notifications",
"storage",
- "terminalPrivate"
+ "terminalPrivate",
+ "unlimitedStorage",
+ "accessibilityFeatures.read"
]
}
diff --git a/chromium/chrome/browser/resources/chromeos/multidevice_setup/compiled_resources2.gyp b/chromium/chrome/browser/resources/chromeos/multidevice_setup/compiled_resources2.gyp
index 5c69afb8a05..48d4f2bb1b0 100644
--- a/chromium/chrome/browser/resources/chromeos/multidevice_setup/compiled_resources2.gyp
+++ b/chromium/chrome/browser/resources/chromeos/multidevice_setup/compiled_resources2.gyp
@@ -1,14 +1,73 @@
-# 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.
+#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.
{
- 'targets': [
+ 'targets' : [
{
- 'target_name': 'multidevice_setup',
- 'dependencies': [
+ 'target_name' : 'button_bar',
+ 'dependencies' : [],
+ 'includes' :
+ ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
+ },
+
+ {
+ 'target_name' : 'fake_mojo_service',
+ 'dependencies' : [
+ '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
+ ],
+ 'includes' :
+ ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
+ },
+
+ {
+ 'target_name' : 'multidevice_setup',
+ 'dependencies' : [
+ '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
+ 'button_bar',
+ 'fake_mojo_service',
+ 'start_setup_page',
+ 'setup_succeeded_page',
+ 'setup_failed_page',
+ ],
+ 'includes' :
+ ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
+ },
+
+ {
+ 'target_name' : 'setup_failed_page',
+ 'dependencies' : [
+ 'ui_page_container_behavior',
+ ],
+ 'includes' :
+ ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
+ },
+
+ {
+ 'target_name' : 'setup_succeeded_page',
+ 'dependencies' : [
+ 'ui_page_container_behavior',
+ ],
+ 'includes' :
+ ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
+ },
+
+ {
+ 'target_name' : 'start_setup_page',
+ 'dependencies' : [
+ 'ui_page_container_behavior',
+ ],
+ 'includes' :
+ ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
+ },
+
+ {
+ 'target_name' : 'ui_page_container_behavior',
+ 'dependencies' : [
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
+ '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
+ 'includes' :
+ ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
},
],
}
diff --git a/chromium/chrome/browser/resources/chromeos/multidevice_setup/multidevice_setup_resources.grd b/chromium/chrome/browser/resources/chromeos/multidevice_setup/multidevice_setup_resources.grd
index e700208ec63..21c9f8b4a1b 100644
--- a/chromium/chrome/browser/resources/chromeos/multidevice_setup/multidevice_setup_resources.grd
+++ b/chromium/chrome/browser/resources/chromeos/multidevice_setup/multidevice_setup_resources.grd
@@ -12,17 +12,68 @@
</outputs>
<release seq="1">
<structures>
- <structure name="IDR_MULTIDEVICE_SETUP_MULTIDEVICE_SETUP_HTML"
- file="multidevice_setup.html"
+ <structure name="IDR_MULTIDEVICE_SETUP_BUTTON_BAR_HTML"
+ file="button_bar.html"
type="chrome_html" />
- <structure name="IDR_MULTIDEVICE_SETUP_MULTIDEVICE_SETUP_JS"
- file="multidevice_setup.js"
+ <structure name="IDR_MULTIDEVICE_SETUP_BUTTON_BAR_JS"
+ file="button_bar.js"
+ type="chrome_html" />
+ <structure name="IDR_MULTIDEVICE_SETUP_FAKE_MOJO_SERVICE_HTML"
+ file="fake_mojo_service.html"
+ type="chrome_html" />
+ <structure name="IDR_MULTIDEVICE_SETUP_FAKE_MOJO_SERVICE_JS"
+ file="fake_mojo_service.js"
+ type="chrome_html" />
+ <structure name="IDR_MULTIDEVICE_SETUP_I18N_SETUP_HTML"
+ file="i18n_setup.html"
+ type="chrome_html" />
+ <structure name="IDR_MULTIDEVICE_SETUP_ICONS_HTML"
+ file="icons.html"
type="chrome_html" />
<structure name="IDR_MULTIDEVICE_SETUP_MULTIDEVICE_SETUP_DIALOG_HTML"
file="multidevice_setup_dialog.html"
flattenhtml="true"
allowexternalscript="true"
type="chrome_html" />
+ <structure name="IDR_MULTIDEVICE_SETUP_MULTIDEVICE_SETUP_HTML"
+ file="multidevice_setup.html"
+ type="chrome_html" />
+ <structure name="IDR_MULTIDEVICE_SETUP_MULTIDEVICE_SETUP_JS"
+ file="multidevice_setup.js"
+ type="chrome_html" />
+ <structure name="IDR_MULTIDEVICE_SETUP_MULTIDEVICE_SETUP_SHARED_CSS_HTML"
+ file="multidevice_setup_shared_css.html"
+ type="chrome_html" />
+ <structure name="IDR_MULTIDEVICE_SETUP_SETUP_FAILED_PAGE_HTML"
+ file="setup_failed_page.html"
+ type="chrome_html" />
+ <structure name="IDR_MULTIDEVICE_SETUP_SETUP_FAILED_PAGE_JS"
+ file="setup_failed_page.js"
+ type="chrome_html" />
+ <structure name="IDR_MULTIDEVICE_SETUP_SETUP_SUCCEEDED_PAGE_HTML"
+ file="setup_succeeded_page.html"
+ type="chrome_html" />
+ <structure name="IDR_MULTIDEVICE_SETUP_SETUP_SUCCEEDED_PAGE_JS"
+ file="setup_succeeded_page.js"
+ type="chrome_html" />
+ <structure name="IDR_MULTIDEVICE_SETUP_START_SETUP_PAGE_HTML"
+ file="start_setup_page.html"
+ type="chrome_html" />
+ <structure name="IDR_MULTIDEVICE_SETUP_START_SETUP_PAGE_JS"
+ file="start_setup_page.js"
+ type="chrome_html" />
+ <structure name="IDR_MULTIDEVICE_SETUP_UI_PAGE_CONTAINER_BEHAVIOR_HTML"
+ file="ui_page_container_behavior.html"
+ type="chrome_html" />
+ <structure name="IDR_MULTIDEVICE_SETUP_UI_PAGE_CONTAINER_BEHAVIOR_JS"
+ file="ui_page_container_behavior.js"
+ type="chrome_html" />
+ <structure name="IDR_MULTIDEVICE_SETUP_UI_PAGE_HTML"
+ file="ui_page.html"
+ type="chrome_html" />
+ <structure name="IDR_MULTIDEVICE_SETUP_UI_PAGE_JS"
+ file="ui_page.js"
+ type="chrome_html" />
</structures>
</release>
</grit>
diff --git a/chromium/chrome/browser/resources/chromeos/wallpaper_manager/manifest.json b/chromium/chrome/browser/resources/chromeos/wallpaper_manager/manifest.json
index d4c6c37d202..988f78ecf08 100644
--- a/chromium/chrome/browser/resources/chromeos/wallpaper_manager/manifest.json
+++ b/chromium/chrome/browser/resources/chromeos/wallpaper_manager/manifest.json
@@ -8,13 +8,7 @@
"manifest_version": 2,
"description": "An experimental wallpaper picker UI",
"icons": {
- "16": "images/icon16.png",
- "32": "images/icon32.png",
- "48": "images/icon48.png",
- "64": "images/icon64.png",
- "96": "images/icon96.png",
- "128": "images/icon128.png",
- "256": "images/icon256.png"
+ "192": "images/icon192.png"
},
"permissions": [
"alarms",
diff --git a/chromium/chrome/browser/resources/chromeos/zip_archiver/BUILD.gn b/chromium/chrome/browser/resources/chromeos/zip_archiver/BUILD.gn
index 94edb33f30c..b0a1ef82960 100644
--- a/chromium/chrome/browser/resources/chromeos/zip_archiver/BUILD.gn
+++ b/chromium/chrome/browser/resources/chromeos/zip_archiver/BUILD.gn
@@ -91,3 +91,10 @@ copy("zip_archiver_root") {
"$zip_archiver_dir/{{source_file_part}}",
]
}
+
+static_library("char_coding") {
+ sources = [
+ "cpp/char_coding.cc",
+ "cpp/char_coding.h",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/chromeos/zip_archiver/cpp/BUILD.gn b/chromium/chrome/browser/resources/chromeos/zip_archiver/cpp/BUILD.gn
index c7294e3ca84..34d48c6fcea 100644
--- a/chromium/chrome/browser/resources/chromeos/zip_archiver/cpp/BUILD.gn
+++ b/chromium/chrome/browser/resources/chromeos/zip_archiver/cpp/BUILD.gn
@@ -33,6 +33,7 @@ executable("zip_archiver_pnacl") {
deps = [
"//base:base",
"//build/config:exe_and_shlib_deps",
+ "//chrome/browser/resources/chromeos/zip_archiver:char_coding",
"//ppapi/cpp",
"//ppapi/native_client:ppapi_lib",
"//third_party/minizip:minizip",
diff --git a/chromium/chrome/browser/resources/component_extension_resources.grd b/chromium/chrome/browser/resources/component_extension_resources.grd
index fccd3d74bf1..0ba36ef347b 100644
--- a/chromium/chrome/browser/resources/component_extension_resources.grd
+++ b/chromium/chrome/browser/resources/component_extension_resources.grd
@@ -12,7 +12,6 @@
</outputs>
<release seq="1">
<structures>
- <structure name="IDR_BOOKMARK_MANAGER_MAIN" file="bookmark_manager/main.html" flattenhtml="true" allowexternalscript="true" type="chrome_html" />
<if expr="chromeos">
<structure name="IDR_WALLPAPER_MANAGER_MAIN" file="chromeos/wallpaper_manager/main.html" flattenhtml="true" allowexternalscript="true" type="chrome_html" />
<if expr="not _google_chrome">
@@ -31,13 +30,6 @@
<include name="IDR_BRAILLE_IME_MAIN_JS" file="chromeos/braille_ime/main.js" type="BINDATA" />
</if>
- <include name="IDR_BOOKMARK_MANAGER_BOOKMARK_MANAGER_SEARCH" file="bookmark_manager/images/bookmark_manager_search.png" type="BINDATA" />
- <include name="IDR_BOOKMARK_MANAGER_BOOKMARK_MANAGER_SEARCH_RTL" file="bookmark_manager/images/bookmark_manager_search_rtl.png" type="BINDATA" />
- <include name="IDR_BOOKMARK_MANAGER_BOOKMARK_MAIN_JS" file="bookmark_manager/js/main.js" type="BINDATA" />
- <include name="IDR_BOOKMARK_MANAGER_BOOKMARK_BMM_LIST_JS" file="bookmark_manager/js/bmm/bookmark_list.js" type="BINDATA" />
- <include name="IDR_BOOKMARK_MANAGER_BOOKMARK_BMM_TREE_JS" file="bookmark_manager/js/bmm/bookmark_tree.js" type="BINDATA" />
- <include name="IDR_BOOKMARK_MANAGER_BOOKMARK_DND_JS" file="bookmark_manager/js/dnd.js" type="BINDATA" />
- <include name="IDR_BOOKMARK_MANAGER_BOOKMARK_BMM_JS" file="bookmark_manager/js/bmm.js" type="BINDATA" />
<!-- Material Design Bookmarks -->
<include name="IDR_COMPONENT_MD_BOOKMARKS_BOOKMARKS_HTML" file="md_bookmarks/bookmarks.html" type="BINDATA" />
<!-- Gaia auth extension -->
@@ -68,13 +60,7 @@
<if expr="chromeos">
<include name="IDR_WALLPAPER_MANAGER_CONSTANTS_JS" file="chromeos/wallpaper_manager/js/constants.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_WALLPAPER_MANAGER_EVENT_JS" file="chromeos/wallpaper_manager/js/event_page.js" flattenhtml="true" type="BINDATA" />
- <include name="IDR_WALLPAPER_MANAGER_ICON_16" file="chromeos/wallpaper_manager/images/icon16.png" type="BINDATA" />
- <include name="IDR_WALLPAPER_MANAGER_ICON_32" file="chromeos/wallpaper_manager/images/icon32.png" type="BINDATA" />
- <include name="IDR_WALLPAPER_MANAGER_ICON_48" file="chromeos/wallpaper_manager/images/icon48.png" type="BINDATA" />
- <include name="IDR_WALLPAPER_MANAGER_ICON_64" file="chromeos/wallpaper_manager/images/icon64.png" type="BINDATA" />
- <include name="IDR_WALLPAPER_MANAGER_ICON_96" file="chromeos/wallpaper_manager/images/icon96.png" type="BINDATA" />
- <include name="IDR_WALLPAPER_MANAGER_ICON_128" file="chromeos/wallpaper_manager/images/icon128.png" type="BINDATA" />
- <include name="IDR_WALLPAPER_MANAGER_ICON_256" file="chromeos/wallpaper_manager/images/icon256.png" type="BINDATA" />
+ <include name="IDR_WALLPAPER_MANAGER_ICON_192" file="chromeos/wallpaper_manager/images/icon192.png" type="BINDATA" />
<include name="IDR_WALLPAPER_MANAGER_MAIN_JS" file="chromeos/wallpaper_manager/js/main_scripts.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_WALLPAPER_MANAGER_UTIL_JS" file="chromeos/wallpaper_manager/js/util.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_FIRST_RUN_DIALOG_BACKGROUND_JS" file="chromeos/first_run/app/background.js" flattenhtml="true" type="BINDATA" />
@@ -88,6 +74,7 @@
<include name="IDR_FIRST_RUN_DIALOG_ICON_256" file="chromeos/first_run/app/icon/256.png" type="BINDATA" />
<include name="IDR_ARC_SUPPORT_BACKGROUND_JS" file="chromeos/arc_support/background.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_ARC_SUPPORT_MAIN_CSS" file="chromeos/arc_support/main.css" type="BINDATA" />
+ <include name="IDR_ARC_SUPPORT_OVERLAY_CSS" file="chromeos/arc_support/overlay.css" type="BINDATA" />
<include name="IDR_ARC_SUPPORT_PLAYSTORE_CSS" file="chromeos/arc_support/playstore.css" type="BINDATA" />
<include name="IDR_ARC_SUPPORT_PLAYSTORE_JS" file="chromeos/arc_support/playstore.js" type="BINDATA" />
<include name="IDR_ARC_SUPPORT_PLAYSTORE_LOGO" file="chromeos/arc_support/icon/playstore.svg" type="BINDATA" />
diff --git a/chromium/chrome/browser/resources/cryptotoken/BUILD.gn b/chromium/chrome/browser/resources/cryptotoken/BUILD.gn
new file mode 100644
index 00000000000..ca7165140f1
--- /dev/null
+++ b/chromium/chrome/browser/resources/cryptotoken/BUILD.gn
@@ -0,0 +1,50 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":approvedorigins",
+ ":b64",
+ ":closeable",
+ ":countdown",
+ ":errorcodes",
+ ":inherits",
+ ":origincheck",
+ ":sha256",
+ ":textfetcher",
+ ":timer",
+ ]
+}
+
+js_library("errorcodes") {
+}
+
+js_library("b64") {
+}
+
+js_library("approvedorigins") {
+}
+
+js_library("closeable") {
+}
+
+js_library("countdown") {
+}
+
+js_library("inherits") {
+}
+
+js_library("origincheck") {
+}
+
+js_library("sha256") {
+}
+
+js_library("textfetcher") {
+}
+
+js_library("timer") {
+}
diff --git a/chromium/chrome/browser/resources/cryptotoken/compiled_resources2.gyp b/chromium/chrome/browser/resources/cryptotoken/compiled_resources2.gyp
deleted file mode 100644
index a84a888dcca..00000000000
--- a/chromium/chrome/browser/resources/cryptotoken/compiled_resources2.gyp
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'errorcodes',
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'b64',
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'approvedorigins',
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'closeable',
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'countdown',
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'inherits',
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'origincheck',
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'sha256',
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'textfetcher',
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'timer',
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ]
-}
diff --git a/chromium/chrome/browser/resources/device_log_ui/device_log_ui.html b/chromium/chrome/browser/resources/device_log_ui/device_log_ui.html
index 50963fe6472..52bf9f6dc91 100644
--- a/chromium/chrome/browser/resources/device_log_ui/device_log_ui.html
+++ b/chromium/chrome/browser/resources/device_log_ui/device_log_ui.html
@@ -57,6 +57,10 @@
<span>$i18n{logTypeHidText}</span>
</label>
<label>
+ <input id="log-type-printer" type="checkbox">
+ <span>$i18n{logTypePrinterText}</span>
+ </label>
+ <label>
<input id="log-fileinfo" type="checkbox">
<span>$i18n{logLevelFileinfoText}</span>
</label>
diff --git a/chromium/chrome/browser/resources/discards/discards.css b/chromium/chrome/browser/resources/discards/discards.css
index b5a965016cc..b9d06337f6c 100644
--- a/chromium/chrome/browser/resources/discards/discards.css
+++ b/chromium/chrome/browser/resources/discards/discards.css
@@ -37,19 +37,11 @@ table td div.title-cell-container {
table td div.favicon-div {
height: 16px;
margin: 3px;
- padding: 0;
- width: 16px;
-}
-
-table td div.favicon-div img {
- height: 16px;
- width: 16px;
+ min-width: 16px;
}
table td div.title-div {
- margin: 0;
overflow: hidden;
- padding: 0;
white-space: nowrap;
}
diff --git a/chromium/chrome/browser/resources/discards/discards.html b/chromium/chrome/browser/resources/discards/discards.html
index 8fbb143a60d..8742ff9257c 100644
--- a/chromium/chrome/browser/resources/discards/discards.html
+++ b/chromium/chrome/browser/resources/discards/discards.html
@@ -14,6 +14,7 @@ general use and is not localized.
<link rel="stylesheet" href="chrome://resources/css/action_link.css">
<link rel="stylesheet" href="chrome://resources/css/text_defaults.css">
<script src="chrome://resources/js/cr.js"></script>
+ <script src="chrome://resources/js/icon.js"></script>
<script src="chrome://resources/js/mojo_bindings.js"></script>
<script src="chrome://resources/js/util.js"></script>
<script src="chrome/browser/ui/webui/discards/discards.mojom.js"></script>
@@ -32,10 +33,12 @@ general use and is not localized.
<thead>
<tr id="tab-discards-info-table-header">
<th data-sort-key="utilityRank" class="sort-column">Utility Rank</th>
+ <th data-sort-key="reactivationScore">Reactivation Score</th>
<th data-sort-key="title">Tab Title</th>
<th data-sort-key="tabUrl">Tab URL</th>
<th data-sort-key="visibility">Visibility</th>
<th data-sort-key="isMedia">Media</th>
+ <th data-sort-key="isFrozen">Frozen</th>
<th data-sort-key="isDiscarded">Discarded</th>
<th data-sort-key="discardCount">Discard Count</th>
<th data-sort-key="isAutoDiscardable">Auto Discardable</th>
@@ -48,17 +51,17 @@ general use and is not localized.
<template id="tab-discard-info-row">
<tr>
<td class="utility-rank-cell"></td>
+ <td class="reactivation-score-cell"></td>
<td class="title-cell">
<div class="title-cell-container">
- <div class="favicon-div">
- <img class="favicon" alt="FavIcon">
- </div>
+ <div class="favicon-div"></div>
<div class="title-div"></div>
</div>
</td>
<td class="tab-url-cell"></td>
<td class="visibility-cell"></td>
<td class="is-media-cell boolean-cell"></td>
+ <td class="is-frozen-cell boolean-cell"></td>
<td class="is-discarded-cell boolean-cell"></td>
<td class="discard-count-cell"></td>
<td class="is-auto-discardable-cell boolean-cell">
diff --git a/chromium/chrome/browser/resources/discards/discards.js b/chromium/chrome/browser/resources/discards/discards.js
index d28205475f0..b04312e2256 100644
--- a/chromium/chrome/browser/resources/discards/discards.js
+++ b/chromium/chrome/browser/resources/discards/discards.js
@@ -64,7 +64,8 @@ cr.define('discards', function() {
}
// Compares boolean fields.
- if (['isMedia', 'isDiscarded', 'isAutoDiscardable'].includes(sortKey)) {
+ if (['isMedia', 'isFrozen', 'isDiscarded', 'isAutoDiscardable'].includes(
+ sortKey)) {
if (val1 == val2)
return 0;
return val1 ? 1 : -1;
@@ -73,7 +74,11 @@ cr.define('discards', function() {
// Compares numeric fields.
// Note: Visibility is represented as a numeric value.
if ([
- 'visibility', 'discardCount', 'utilityRank', 'lastActiveSeconds'
+ 'visibility',
+ 'discardCount',
+ 'utilityRank',
+ 'reactivationScore',
+ 'lastActiveSeconds',
].includes(sortKey)) {
return val1 - val2;
}
@@ -254,8 +259,6 @@ cr.define('discards', function() {
let lifecycleListener = function(e) {
// Get the info backing this row.
let info = infos[getRowIndex(e.target)];
- // TODO(fmeawad): Disable the action, and let the update function
- // re-enable it. Blocked on acquiring freeze status.
// Perform the action.
uiHandler.freezeById(info.id);
};
@@ -274,14 +277,18 @@ cr.define('discards', function() {
// Update the content.
row.querySelector('.utility-rank-cell').textContent =
info.utilityRank.toString();
- row.querySelector('.favicon').src =
- info.faviconUrl ? info.faviconUrl : 'chrome://favicon';
+ row.querySelector('.reactivation-score-cell').textContent =
+ info.hasReactivationScore ? info.reactivationScore.toFixed(4) : 'N/A';
+ row.querySelector('.favicon-div').style.backgroundImage =
+ cr.icon.getFavicon(info.tabUrl);
row.querySelector('.title-div').textContent = info.title;
row.querySelector('.tab-url-cell').textContent = info.tabUrl;
row.querySelector('.visibility-cell').textContent =
visibilityToString(info.visibility);
row.querySelector('.is-media-cell').textContent =
boolToString(info.isMedia);
+ row.querySelector('.is-frozen-cell').textContent =
+ boolToString(info.isFrozen);
row.querySelector('.is-discarded-cell').textContent =
boolToString(info.isDiscarded);
row.querySelector('.discard-count-cell').textContent =
@@ -302,6 +309,12 @@ cr.define('discards', function() {
discardLink.removeAttribute('disabled');
discardUrgentLink.removeAttribute('disabled');
}
+
+ let freezeLink = row.querySelector('.freeze-link');
+ if (info.isFrozen)
+ freezeLink.setAttribute('disabled', '');
+ else
+ freezeLink.removeAttribute('disabled', '');
}
/**
diff --git a/chromium/chrome/browser/resources/download_internals/BUILD.gn b/chromium/chrome/browser/resources/download_internals/BUILD.gn
new file mode 100644
index 00000000000..53a4def4ffe
--- /dev/null
+++ b/chromium/chrome/browser/resources/download_internals/BUILD.gn
@@ -0,0 +1,36 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":download_internals",
+ ":download_internals_browser_proxy",
+ ":download_internals_visuals",
+ ]
+}
+
+js_library("download_internals") {
+ deps = [
+ ":download_internals_browser_proxy",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:util",
+ ]
+}
+
+js_library("download_internals_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("download_internals_visuals") {
+ deps = [
+ ":download_internals_browser_proxy",
+ "//ui/webui/resources/js:cr",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/download_internals/compiled_resources2.gyp b/chromium/chrome/browser/resources/download_internals/compiled_resources2.gyp
deleted file mode 100644
index 13baad13e0e..00000000000
--- a/chromium/chrome/browser/resources/download_internals/compiled_resources2.gyp
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'download_internals',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- 'download_internals_browser_proxy',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'download_internals_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'download_internals_visuals',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- 'download_internals_browser_proxy',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/extensions/OWNERS b/chromium/chrome/browser/resources/extensions/OWNERS
deleted file mode 100644
index 9f96570c5ab..00000000000
--- a/chromium/chrome/browser/resources/extensions/OWNERS
+++ /dev/null
@@ -1,5 +0,0 @@
-finnur@chromium.org
-rdevlin.cronin@chromium.org
-
-# TEAM: extensions-dev@chromium.org
-# COMPONENT: Platform>Extensions
diff --git a/chromium/chrome/browser/resources/extensions/apps_developer_tools_promo_48.png b/chromium/chrome/browser/resources/extensions/apps_developer_tools_promo_48.png
deleted file mode 100644
index 462bc9a5450..00000000000
--- a/chromium/chrome/browser/resources/extensions/apps_developer_tools_promo_48.png
+++ /dev/null
Binary files differ
diff --git a/chromium/chrome/browser/resources/extensions/compiled_resources2.gyp b/chromium/chrome/browser/resources/extensions/compiled_resources2.gyp
deleted file mode 100644
index 060505cf447..00000000000
--- a/chromium/chrome/browser/resources/extensions/compiled_resources2.gyp
+++ /dev/null
@@ -1,66 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'extensions',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:webui_listener_tracker',
- ],
- 'variables': {
- 'script_args': ['--custom_sources'],
- 'source_files': [
- '<(DEPTH)/ui/webui/resources/js/promise_resolver.js',
- '<(DEPTH)/ui/webui/resources/js/load_time_data.js',
- '<(DEPTH)/ui/webui/resources/js/parse_html_subset.js',
- '<(DEPTH)/ui/webui/resources/js/cr.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/array_data_model.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/list.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/focus_outline_manager.js',
- 'extension_loader.js',
- '<(DEPTH)/ui/webui/resources/js/util.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/focus_manager.js',
- 'extension_focus_manager.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/list_item.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/focus_row.js',
- 'extension_options_overlay.js',
- '<(DEPTH)/third_party/closure_compiler/externs/management.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/list_selection_controller.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/alert_overlay.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/bubble.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/focus_grid.js',
- 'chromeos/kiosk_apps.js',
- '<(DEPTH)/ui/webui/resources/js/assert.js',
- 'extension_commands_overlay.js',
- 'extensions.js',
- 'extension_list.js',
- 'chromeos/kiosk_app_disable_bailout_confirm.js',
- 'focus_row.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/bubble_button.js',
- '<(DEPTH)/third_party/closure_compiler/externs/chrome_send.js',
- '<(DEPTH)/third_party/jstemplate/util.js',
- 'extension_error.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui.js',
- '<(DEPTH)/ui/webui/resources/js/event_tracker.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/overlay.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/drag_wrapper.js',
- 'extension_code.js',
- '<(DEPTH)/ui/webui/resources/js/cr/event_target.js',
- '<(DEPTH)/third_party/jstemplate/jsevalcontext.js',
- 'extension_command_list.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/controlled_indicator.js',
- 'extension_error_overlay.js',
- '../md_extensions/drag_and_drop_handler.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/list_selection_model.js',
- '<(DEPTH)/third_party/jstemplate/jstemplate.js',
- 'chromeos/kiosk_app_list.js',
- '<(DEPTH)/third_party/closure_compiler/externs/developer_private.js',
- '../md_extensions/shortcut_util.js',
- 'pack_extension_overlay.js',
- ],
- },
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- }
- ]
-}
diff --git a/chromium/chrome/browser/resources/extensions/extension_code.js b/chromium/chrome/browser/resources/extensions/extension_code.js
deleted file mode 100644
index fd99783d901..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_code.js
+++ /dev/null
@@ -1,119 +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.
-
-/**
- * @typedef {{afterHighlight: string,
- * beforeHighlight: string,
- * highlight: string,
- * message: string}}
- */
-var ExtensionHighlight;
-
-cr.define('extensions', function() {
- 'use strict';
-
- /**
- * ExtensionCode is an element which displays code in a styled div, and is
- * designed to highlight errors.
- * @constructor
- * @extends {HTMLDivElement}
- */
- function ExtensionCode(div) {
- div.__proto__ = ExtensionCode.prototype;
- return div;
- }
-
- ExtensionCode.prototype = {
- __proto__: HTMLDivElement.prototype,
-
- /**
- * Populate the content area of the code div with the given code. This will
- * highlight the erroneous section (if any).
- * @param {?ExtensionHighlight} code The 'highlight' strings represent the
- * three portions of the file's content to display - the portion which
- * is most relevant and should be emphasized (highlight), and the parts
- * both before and after this portion. The title is the error message,
- * which will be the mouseover hint for the highlighted region. These
- * may be empty.
- * @param {string} emptyMessage The message to display if the code
- * object is empty (e.g., 'could not load code').
- */
- populate: function(code, emptyMessage) {
- // Clear any remnant content, so we don't have multiple code listed.
- this.clear();
-
- // If there's no code, then display an appropriate message.
- if (!code ||
- (!code.highlight && !code.beforeHighlight && !code.afterHighlight)) {
- var span = document.createElement('span');
- span.classList.add('extension-code-empty');
- span.textContent = emptyMessage;
- this.appendChild(span);
- return;
- }
-
- var sourceDiv = document.createElement('div');
- sourceDiv.classList.add('extension-code-source');
- this.appendChild(sourceDiv);
-
- var lineCount = 0;
- var createSpan = function(source, isHighlighted) {
- lineCount += source.split('\n').length - 1;
- var span = document.createElement('span');
- span.className = isHighlighted ? 'extension-code-highlighted-source' :
- 'extension-code-normal-source';
- span.textContent = source;
- return span;
- };
-
- if (code.beforeHighlight)
- sourceDiv.appendChild(createSpan(code.beforeHighlight, false));
-
- if (code.highlight) {
- var highlightSpan = createSpan(code.highlight, true);
- highlightSpan.title = code.message;
- sourceDiv.appendChild(highlightSpan);
- }
-
- if (code.afterHighlight)
- sourceDiv.appendChild(createSpan(code.afterHighlight, false));
-
- // Make the line numbers. This should be the number of line breaks + 1
- // (the last line doesn't break, but should still be numbered).
- var content = '';
- for (var i = 1; i < lineCount + 1; ++i)
- content += i + '\n';
- var span = document.createElement('span');
- span.textContent = content;
-
- var linesDiv = document.createElement('div');
- linesDiv.classList.add('extension-code-line-numbers');
- linesDiv.appendChild(span);
- this.insertBefore(linesDiv, this.firstChild);
- },
-
- /**
- * Clears the content of the element.
- */
- clear: function() {
- while (this.firstChild)
- this.removeChild(this.firstChild);
- },
-
- /**
- * Scrolls to the error, if there is one. This cannot be called when the
- * div is hidden.
- */
- scrollToError: function() {
- var errorSpan = this.querySelector('.extension-code-highlighted-source');
- if (errorSpan)
- this.scrollTop = errorSpan.offsetTop - this.clientHeight / 2;
- }
- };
-
- // Export
- return {
- ExtensionCode: ExtensionCode
- };
-});
diff --git a/chromium/chrome/browser/resources/extensions/extension_command_list.js b/chromium/chrome/browser/resources/extensions/extension_command_list.js
deleted file mode 100644
index 1aa48e3052f..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_command_list.js
+++ /dev/null
@@ -1,425 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// <include src="../md_extensions/shortcut_util.js">
-
-cr.define('extensions', function() {
- 'use strict';
-
- /**
- * Creates a new list of extension commands.
- * @param {HTMLDivElement} div
- * @constructor
- * @extends {HTMLDivElement}
- */
- function ExtensionCommandList(div) {
- div.__proto__ = ExtensionCommandList.prototype;
- return div;
- }
-
- ExtensionCommandList.prototype = {
- __proto__: HTMLDivElement.prototype,
-
- /**
- * While capturing, this records the current (last) keyboard event generated
- * by the user. Will be |null| after capture and during capture when no
- * keyboard event has been generated.
- * @type {KeyboardEvent}.
- * @private
- */
- currentKeyEvent_: null,
-
- /**
- * While capturing, this keeps track of the previous selection so we can
- * revert back to if no valid assignment is made during capture.
- * @type {string}.
- * @private
- */
- oldValue_: '',
-
- /**
- * While capturing, this keeps track of which element the user asked to
- * change.
- * @type {HTMLElement}.
- * @private
- */
- capturingElement_: null,
-
- /**
- * Updates the extensions data for the overlay.
- * @param {!Array<chrome.developerPrivate.ExtensionInfo>} data The extension
- * data.
- */
- setData: function(data) {
- /** @private {!Array<chrome.developerPrivate.ExtensionInfo>} */
- this.data_ = data;
-
- this.textContent = '';
-
- // Iterate over the extension data and add each item to the list.
- this.data_.forEach(this.createNodeForExtension_.bind(this));
- },
-
- /**
- * Synthesizes and initializes an HTML element for the extension command
- * metadata given in |extension|.
- * @param {chrome.developerPrivate.ExtensionInfo} extension A dictionary of
- * extension metadata.
- * @private
- */
- createNodeForExtension_: function(extension) {
- if (extension.commands.length == 0 ||
- extension.state == chrome.developerPrivate.ExtensionState.DISABLED)
- return;
-
- var template = $('template-collection-extension-commands').querySelector(
- '.extension-command-list-extension-item-wrapper');
- var node = template.cloneNode(true);
-
- var title = node.querySelector('.extension-title');
- title.textContent = extension.name;
-
- this.appendChild(node);
-
- // Iterate over the commands data within the extension and add each item
- // to the list.
- extension.commands.forEach(
- this.createNodeForCommand_.bind(this, extension.id));
- },
-
- /**
- * Synthesizes and initializes an HTML element for the extension command
- * metadata given in |command|.
- * @param {string} extensionId The associated extension's id.
- * @param {chrome.developerPrivate.Command} command A dictionary of
- * extension command metadata.
- * @private
- */
- createNodeForCommand_: function(extensionId, command) {
- var template = $('template-collection-extension-commands').querySelector(
- '.extension-command-list-command-item-wrapper');
- var node = template.cloneNode(true);
- node.id = this.createElementId_('command', extensionId, command.name);
-
- var description = node.querySelector('.command-description');
- description.textContent = command.description;
-
- var shortcutNode = node.querySelector('.command-shortcut-text');
- shortcutNode.addEventListener('mouseup',
- this.startCapture_.bind(this));
- shortcutNode.addEventListener('focus', this.handleFocus_.bind(this));
- shortcutNode.addEventListener('blur', this.handleBlur_.bind(this));
- shortcutNode.addEventListener('keydown', this.handleKeyDown_.bind(this));
- shortcutNode.addEventListener('keyup', this.handleKeyUp_.bind(this));
- if (!command.isActive) {
- shortcutNode.textContent =
- loadTimeData.getString('extensionCommandsInactive');
-
- var commandShortcut = node.querySelector('.command-shortcut');
- commandShortcut.classList.add('inactive-keybinding');
- } else {
- shortcutNode.textContent = command.keybinding;
- }
-
- var commandClear = node.querySelector('.command-clear');
- commandClear.id = this.createElementId_(
- 'clear', extensionId, command.name);
- commandClear.title = loadTimeData.getString('extensionCommandsDelete');
- commandClear.addEventListener('click', this.handleClear_.bind(this));
-
- var select = node.querySelector('.command-scope');
- select.id = this.createElementId_(
- 'setCommandScope', extensionId, command.name);
- select.hidden = false;
- // Add the 'In Chrome' option.
- var option = document.createElement('option');
- option.textContent = loadTimeData.getString('extensionCommandsRegular');
- select.appendChild(option);
- if (command.isExtensionAction || !command.isActive) {
- // Extension actions cannot be global, so we might as well disable the
- // combo box, to signify that, and if the command is inactive, it
- // doesn't make sense to allow the user to adjust the scope.
- select.disabled = true;
- } else {
- // Add the 'Global' option.
- option = document.createElement('option');
- option.textContent = loadTimeData.getString('extensionCommandsGlobal');
- select.appendChild(option);
- select.selectedIndex =
- command.scope == chrome.developerPrivate.CommandScope.GLOBAL ?
- 1 : 0;
-
- select.addEventListener(
- 'change', this.handleSetCommandScope_.bind(this));
- }
-
- this.appendChild(node);
- },
-
- /**
- * Starts keystroke capture to determine which key to use for a particular
- * extension command.
- * @param {Event} event The keyboard event to consider.
- * @private
- */
- startCapture_: function(event) {
- if (this.capturingElement_)
- return; // Already capturing.
-
- chrome.developerPrivate.setShortcutHandlingSuspended(true);
-
- var shortcutNode = event.target;
- this.oldValue_ = shortcutNode.textContent;
- shortcutNode.textContent =
- loadTimeData.getString('extensionCommandsStartTyping');
- shortcutNode.parentElement.classList.add('capturing');
-
- var commandClear =
- shortcutNode.parentElement.querySelector('.command-clear');
- commandClear.hidden = true;
-
- this.capturingElement_ = /** @type {HTMLElement} */(event.target);
- },
-
- /**
- * Ends keystroke capture and either restores the old value or (if valid
- * value) sets the new value as active..
- * @param {Event} event The keyboard event to consider.
- * @private
- */
- endCapture_: function(event) {
- if (!this.capturingElement_)
- return; // Not capturing.
-
- chrome.developerPrivate.setShortcutHandlingSuspended(false);
-
- var shortcutNode = this.capturingElement_;
- var commandShortcut = shortcutNode.parentElement;
-
- commandShortcut.classList.remove('capturing');
- commandShortcut.classList.remove('contains-chars');
-
- // When the capture ends, the user may have not given a complete and valid
- // input (or even no input at all). Only a valid key event followed by a
- // valid key combination will cause a shortcut selection to be activated.
- // If no valid selection was made, however, revert back to what the
- // textbox had before to indicate that the shortcut registration was
- // canceled.
- if (!this.currentKeyEvent_ ||
- !extensions.isValidKeyCode(this.currentKeyEvent_.keyCode))
- shortcutNode.textContent = this.oldValue_;
-
- var commandClear = commandShortcut.querySelector('.command-clear');
- if (this.oldValue_ == '') {
- commandShortcut.classList.remove('clearable');
- commandClear.hidden = true;
- } else {
- commandShortcut.classList.add('clearable');
- commandClear.hidden = false;
- }
-
- this.oldValue_ = '';
- this.capturingElement_ = null;
- this.currentKeyEvent_ = null;
- },
-
- /**
- * Handles focus event and adds visual indication for active shortcut.
- * @param {Event} event to consider.
- * @private
- */
- handleFocus_: function(event) {
- var commandShortcut = event.target.parentElement;
- commandShortcut.classList.add('focused');
- },
-
- /**
- * Handles lost focus event and removes visual indication of active shortcut
- * also stops capturing on focus lost.
- * @param {Event} event to consider.
- * @private
- */
- handleBlur_: function(event) {
- this.endCapture_(event);
- var commandShortcut = event.target.parentElement;
- commandShortcut.classList.remove('focused');
- },
-
- /**
- * The KeyDown handler.
- * @param {Event} event The keyboard event to consider.
- * @private
- */
- handleKeyDown_: function(event) {
- event = /** @type {KeyboardEvent} */(event);
- if (event.keyCode == extensions.Key.Escape) {
- if (!this.capturingElement_) {
- // If we're not currently capturing, allow escape to propagate (so it
- // can close the overflow).
- return;
- }
- // Otherwise, escape cancels capturing.
- this.endCapture_(event);
- var parsed = this.parseElementId_('clear',
- event.target.parentElement.querySelector('.command-clear').id);
- chrome.developerPrivate.updateExtensionCommand({
- extensionId: parsed.extensionId,
- commandName: parsed.commandName,
- keybinding: ''
- });
- event.preventDefault();
- event.stopPropagation();
- return;
- }
- if (event.keyCode == extensions.Key.Tab) {
- // Allow tab propagation for keyboard navigation.
- return;
- }
-
- if (!this.capturingElement_)
- this.startCapture_(event);
-
- this.handleKey_(event);
- },
-
- /**
- * The KeyUp handler.
- * @param {Event} event The keyboard event to consider.
- * @private
- */
- handleKeyUp_: function(event) {
- event = /** @type {KeyboardEvent} */(event);
- if (event.keyCode == extensions.Key.Tab ||
- event.keyCode == extensions.Key.Escape) {
- // We need to allow tab propagation for keyboard navigation, and escapes
- // are fully handled in handleKeyDown.
- return;
- }
-
- // We want to make it easy to change from Ctrl+Shift+ to just Ctrl+ by
- // releasing Shift, but we also don't want it to be easy to lose for
- // example Ctrl+Shift+F to Ctrl+ just because you didn't release Ctrl
- // as fast as the other two keys. Therefore, we process KeyUp until you
- // have a valid combination and then stop processing it (meaning that once
- // you have a valid combination, we won't change it until the next
- // KeyDown message arrives).
- if (!this.currentKeyEvent_ ||
- !extensions.isValidKeyCode(this.currentKeyEvent_.keyCode)) {
- if (!event.ctrlKey && !event.altKey ||
- ((cr.isMac || cr.isChromeOS) && !event.metaKey)) {
- // If neither Ctrl nor Alt is pressed then it is not a valid shortcut.
- // That means we're back at the starting point so we should restart
- // capture.
- this.endCapture_(event);
- this.startCapture_(event);
- } else {
- this.handleKey_(event);
- }
- }
- },
-
- /**
- * A general key handler (used for both KeyDown and KeyUp).
- * @param {KeyboardEvent} event The keyboard event to consider.
- * @private
- */
- handleKey_: function(event) {
- // While capturing, we prevent all events from bubbling, to prevent
- // shortcuts lacking the right modifier (F3 for example) from activating
- // and ending capture prematurely.
- event.preventDefault();
- event.stopPropagation();
-
- if (!extensions.hasValidModifiers(event))
- return;
-
- var shortcutNode = this.capturingElement_;
- var keystroke = extensions.keystrokeToString(event);
- shortcutNode.textContent = keystroke;
- event.target.classList.add('contains-chars');
- this.currentKeyEvent_ = event;
-
- if (extensions.isValidKeyCode(event.keyCode)) {
- var node = event.target;
- while (node && !node.id)
- node = node.parentElement;
-
- this.oldValue_ = keystroke; // Forget what the old value was.
- var parsed = this.parseElementId_('command', node.id);
-
- // Ending the capture must occur before calling
- // setExtensionCommandShortcut to ensure the shortcut is set.
- this.endCapture_(event);
- chrome.developerPrivate.updateExtensionCommand(
- {extensionId: parsed.extensionId,
- commandName: parsed.commandName,
- keybinding: keystroke});
- }
- },
-
- /**
- * A handler for the delete command button.
- * @param {Event} event The mouse event to consider.
- * @private
- */
- handleClear_: function(event) {
- var parsed = this.parseElementId_('clear', event.target.id);
- chrome.developerPrivate.updateExtensionCommand(
- {extensionId: parsed.extensionId,
- commandName: parsed.commandName,
- keybinding: ''});
- },
-
- /**
- * A handler for the setting the scope of the command.
- * @param {Event} event The mouse event to consider.
- * @private
- */
- handleSetCommandScope_: function(event) {
- var parsed = this.parseElementId_('setCommandScope', event.target.id);
- var element =
- $('setCommandScope-' + parsed.extensionId + '-' + parsed.commandName);
- var scope = element.selectedIndex == 1 ?
- chrome.developerPrivate.CommandScope.GLOBAL :
- chrome.developerPrivate.CommandScope.CHROME;
- chrome.developerPrivate.updateExtensionCommand(
- {extensionId: parsed.extensionId,
- commandName: parsed.commandName,
- scope: scope});
- },
-
- /**
- * A utility function to create a unique element id based on a namespace,
- * extension id and a command name.
- * @param {string} namespace The namespace to prepend the id with.
- * @param {string} extensionId The extension ID to use in the id.
- * @param {string} commandName The command name to append the id with.
- * @private
- */
- createElementId_: function(namespace, extensionId, commandName) {
- return namespace + '-' + extensionId + '-' + commandName;
- },
-
- /**
- * A utility function to parse a unique element id based on a namespace,
- * extension id and a command name.
- * @param {string} namespace The namespace to prepend the id with.
- * @param {string} id The id to parse.
- * @return {{extensionId: string, commandName: string}} The parsed id.
- * @private
- */
- parseElementId_: function(namespace, id) {
- var kExtensionIdLength = 32;
- return {
- extensionId: id.substring(namespace.length + 1,
- namespace.length + 1 + kExtensionIdLength),
- commandName: id.substring(namespace.length + 1 + kExtensionIdLength + 1)
- };
- },
- };
-
- return {
- ExtensionCommandList: ExtensionCommandList
- };
-});
diff --git a/chromium/chrome/browser/resources/extensions/extension_commands_overlay.css b/chromium/chrome/browser/resources/extensions/extension_commands_overlay.css
deleted file mode 100644
index 407a256ad34..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_commands_overlay.css
+++ /dev/null
@@ -1,80 +0,0 @@
-/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file. */
-
-.extension-command-list-command-item-wrapper {
- margin-left: 12px;
-}
-
-.command-title {
- display: inline-block;
- margin-top: 1em;
-}
-
-.command-container {
- -webkit-box-orient: horizontal;
- display: -webkit-box;
- width: 450px;
-}
-
-.command-description {
- -webkit-box-flex: 1;
- display: -webkit-box;
- margin-top: 0.5em;
- min-height: 2em;
-}
-
-.command-shortcut-container {
- display: -webkit-box;
- margin-top: 0.25em;
- min-height: 2em;
-}
-
-.command-shortcut {
- border: solid 1px #BFBFBF;
- border-radius: 2px;
- color: rgb(48, 57, 66);
- display: inline-block;
- height: 1.4em;
- min-width: 12.5em;
- padding: 3px 0 1px 4px;
-}
-
-.command-shortcut-text {
- display: inline-block;
- height: 1.4em;
- min-width: 11em;
- outline: none;
-}
-
-.focused {
- border: solid 1px rgb(140, 147, 255);
-}
-
-.clearable {
- background: white;
-}
-
-.command-clear {
- float: right;
- margin-top: 1px;
-}
-
-.command-scope {
- margin-left: 0.25em;
- margin-top: 0.24em;
-}
-
-.capturing {
- background: rgb(243, 244, 255);
- border: solid 1px rgb(140, 147, 255);
- color: #999;
-}
-
-.contains-chars {
- color: rgb(48, 57, 66);
-}
-
-.inactive-keybinding {
- color: #999;
-}
diff --git a/chromium/chrome/browser/resources/extensions/extension_commands_overlay.html b/chromium/chrome/browser/resources/extensions/extension_commands_overlay.html
deleted file mode 100644
index ad6c24839fe..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_commands_overlay.html
+++ /dev/null
@@ -1,55 +0,0 @@
-<!--
- * Copyright (c) 2012 The Chromium Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be found
- * in the LICENSE file.
--->
-<div id="extension-commands-overlay" class="page">
- <div class="close-button"></div>
- <h1>$i18n{extensionCommandsOverlay}</h1>
- <div class="content-area">
- <div id="extension-command-list"
- class="empty-extension-commands-list"></div>
- <div id="no-commands" hidden>
- <span id="no-extensions-commands-message">
- $i18n{extensionCommandsEmpty}
- </span>
- </div>
- </div>
- <div class="action-area">
- <div class="action-area-right">
- <div class="button-strip">
- <button id="extension-commands-dismiss">$i18n{ok}</button>
- </div>
- </div>
- </div>
-</div>
-
-<div id="template-collection-extension-commands" hidden>
- <div class="extension-command-list-extension-item-wrapper">
- <div class="extension-command-list-extension-item">
- <div class="extension-command-extension-details">
- <div>
- <span class="extension-title command-title"></span>
- <div class="command-details"></div>
- </div>
- </div>
- </div>
- </div>
-
- <div class="extension-command-list-command-item-wrapper">
- <div class="extension-command-list-command-item">
- <div class="extension-command-details">
- <div class="command-container">
- <span class="command-description"></span>
- <span class="command-shortcut-container"
- ><span class="command-shortcut clearable"
- ><img class="command-clear"
- src="chrome://theme/IDR_EXTENSION_COMMAND_CLOSE"
- ><span class="command-shortcut-text" tabindex="0"
- ></span></span></span>
- <select class="command-scope" hidden></select>
- </div>
- </div>
- </div>
- </div>
-</div>
diff --git a/chromium/chrome/browser/resources/extensions/extension_commands_overlay.js b/chromium/chrome/browser/resources/extensions/extension_commands_overlay.js
deleted file mode 100644
index 443440b2856..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_commands_overlay.js
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// <include src="extension_command_list.js">
-
-cr.define('extensions', function() {
- 'use strict';
-
- // The Extension Commands list object that will be used to show the commands
- // on the page.
- var ExtensionCommandList = extensions.ExtensionCommandList;
-
- /**
- * ExtensionCommandsOverlay class
- * Encapsulated handling of the 'Extension Commands' overlay page.
- * @constructor
- */
- function ExtensionCommandsOverlay() {
- }
-
- cr.addSingletonGetter(ExtensionCommandsOverlay);
-
- ExtensionCommandsOverlay.prototype = {
- /**
- * Initialize the page.
- */
- initializePage: function() {
- var overlay = $('overlay');
- cr.ui.overlay.setupOverlay(overlay);
- cr.ui.overlay.globalInitialization();
- overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this));
-
- this.extensionCommandList_ = new ExtensionCommandList(
- /**@type {HTMLDivElement} */($('extension-command-list')));
-
- $('extension-commands-dismiss').addEventListener('click', function() {
- cr.dispatchSimpleEvent(overlay, 'cancelOverlay');
- });
-
- // The ExtensionList will update us with its data, so we don't need to
- // handle that here.
- },
-
- /**
- * Handles a click on the dismiss button.
- * @param {Event} e The click event.
- */
- handleDismiss_: function(e) {
- extensions.ExtensionSettings.showOverlay(null);
- },
- };
-
- /**
- * Called by the dom_ui_ to re-populate the page with data representing
- * the current state of extension commands.
- * @param {!Array<chrome.developerPrivate.ExtensionInfo>} extensionsData
- */
- ExtensionCommandsOverlay.updateExtensionsData = function(extensionsData) {
- var overlay = ExtensionCommandsOverlay.getInstance();
- overlay.extensionCommandList_.setData(extensionsData);
-
- var hasAnyCommands = false;
- for (var i = 0; i < extensionsData.length; ++i) {
- if (extensionsData[i].commands.length > 0) {
- hasAnyCommands = true;
- break;
- }
- }
-
- // Make sure the config link is visible, since there are commands to show
- // and potentially configure.
- document.querySelector('.extension-commands-config').hidden =
- !hasAnyCommands;
-
- $('no-commands').hidden = hasAnyCommands;
- overlay.extensionCommandList_.classList.toggle(
- 'empty-extension-commands-list', !hasAnyCommands);
- };
-
- // Export
- return {
- ExtensionCommandsOverlay: ExtensionCommandsOverlay
- };
-});
diff --git a/chromium/chrome/browser/resources/extensions/extension_error.css b/chromium/chrome/browser/resources/extensions/extension_error.css
deleted file mode 100644
index 79ee0ab3adf..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_error.css
+++ /dev/null
@@ -1,111 +0,0 @@
-/* Copyright 2013 The Chromium Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file. */
-
-.extension-error-list-heading {
- align-content: flex-start;
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- padding: 3px;
-}
-
-.extension-error-list-heading span {
- font-weight: bold;
-}
-
-.extension-error-list a {
- cursor: pointer;
-}
-
-.extension-error-list-contents {
- -webkit-padding-start: 0;
- cursor: pointer;
- list-style-type: none;
- margin-bottom: 0;
- margin-top: 0;
-}
-
-#no-errors-span {
- -webkit-margin-start: 10px;
-}
-
-.extension-error-list-contents.scrollable {
- overflow-y: auto;
-}
-
-.extension-error-list-contents .extension-error-metadata:hover {
- background-color: #eee;
-}
-
-.extension-error-list-contents
- .extension-error-metadata.extension-error-active {
- background-color: rgba(0, 100, 255, 0.1);
-}
-
-.extension-error-metadata {
- -webkit-padding-end: 1px;
- -webkit-padding-start: 3px;
- display: flex;
- flex-direction: row;
-}
-
-.extension-error-icon {
- -webkit-margin-end: 3px;
- height: 15px;
- width: 15px;
-}
-
-.extension-error-message {
- -webkit-margin-end: 15px;
- flex: 1;
- margin-bottom: 0;
- margin-top: 0;
- overflow: hidden;
-}
-
-.extension-error-metadata {
- align-items: center;
- display: flex;
-}
-
-.extension-error-metadata > .error-delete-button {
- -webkit-appearance: none;
- background: url(chrome://theme/IDR_CLOSE_DIALOG) center no-repeat;
- border: none;
- height: 14px;
- opacity: 0.6;
- width: 14px;
-}
-
-.extension-error-metadata > .error-delete-button:hover {
- opacity: 0.8;
-}
-
-.extension-error-metadata > .error-delete-button:active {
- opacity: 1.0;
-}
-
-.extension-error-severity-info .extension-error-message {
- color: #333;
-}
-.extension-error-severity-info .extension-error-icon,
-.extension-error-info-icon {
- content: url(extension_error_severity_info.png);
-}
-
-.extension-error-severity-warning .extension-error-message {
- color: rgba(250, 145, 0, 255);
-}
-.extension-error-severity-warning .extension-error-icon,
-.extension-error-warning-icon {
- content: url(extension_error_severity_warning.png);
-}
-
-.extension-error-severity-fatal .extension-error-message {
- color: rgba(200, 50, 50, 255);
-}
-.extension-error-severity-fatal .extension-error-icon,
-.extension-error-fatal-icon {
- content: url(extension_error_severity_fatal.png);
-}
diff --git a/chromium/chrome/browser/resources/extensions/extension_error.html b/chromium/chrome/browser/resources/extensions/extension_error.html
deleted file mode 100644
index ad294bb4854..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_error.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<!--
-Copyright 2013 The Chromium Authors. All rights reserved.
-Use of this source code is governed by a BSD-style license that can be found
-in the LICENSE file.
--->
-<div id="template-collection-extension-error" hidden>
- <div class="extension-error-list">
- <div class="extension-error-list-heading">
- <span>$i18n{extensionErrorHeading}</span>
- <a id="extension-error-list-clear" is="action-link">
- $i18n{extensionErrorClearAll}
- </a>
- </div>
- <ul class="extension-error-list-contents"></ul>
- <span id="no-errors-span" hidden>$i18n{extensionErrorNoErrors}</span>
- </div>
- <li class="extension-error-metadata">
- <p class="extension-error-message" tabindex="0"></p>
- <button class="custom-appearance error-delete-button"></button>
- </li>
-</div>
diff --git a/chromium/chrome/browser/resources/extensions/extension_error.js b/chromium/chrome/browser/resources/extensions/extension_error.js
deleted file mode 100644
index 6d619c29b3b..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_error.js
+++ /dev/null
@@ -1,376 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('extensions', function() {
- 'use strict';
-
- /**
- * Clone a template within the extension error template collection.
- * @param {string} templateName The class name of the template to clone.
- * @return {HTMLElement} The clone of the template.
- */
- function cloneTemplate(templateName) {
- return /** @type {HTMLElement} */($('template-collection-extension-error').
- querySelector('.' + templateName).cloneNode(true));
- }
-
- /**
- * Checks that an Extension ID follows the proper format (i.e., is 32
- * characters long, is lowercase, and contains letters in the range [a, p]).
- * @param {string} id The Extension ID to test.
- * @return {boolean} Whether or not the ID is valid.
- */
- function idIsValid(id) {
- return /^[a-p]{32}$/.test(id);
- }
-
- /**
- * @param {!Array<(ManifestError|RuntimeError)>} errors
- * @param {number} id
- * @return {number} The index of the error with |id|, or -1 if not found.
- */
- function findErrorById(errors, id) {
- for (var i = 0; i < errors.length; ++i) {
- if (errors[i].id == id)
- return i;
- }
- return -1;
- }
-
- /**
- * Creates a new ExtensionError HTMLElement; this is used to show a
- * notification to the user when an error is caused by an extension.
- * @param {(RuntimeError|ManifestError)} error The error the element should
- * represent.
- * @constructor
- * @extends {HTMLElement}
- */
- function ExtensionError(error) {
- var div = cloneTemplate('extension-error-metadata');
- div.__proto__ = ExtensionError.prototype;
- div.decorate(error);
- return div;
- }
-
- ExtensionError.prototype = {
- __proto__: HTMLElement.prototype,
-
- /**
- * @param {(RuntimeError|ManifestError)} error The error the element should
- * represent.
- * @private
- */
- decorate: function(error) {
- /**
- * The backing error.
- * @type {(ManifestError|RuntimeError)}
- */
- this.error = error;
- var iconAltTextKey = 'extensionLogLevelWarn';
-
- // Add an additional class for the severity level.
- if (error.type == chrome.developerPrivate.ErrorType.RUNTIME) {
- switch (error.severity) {
- case chrome.developerPrivate.ErrorLevel.LOG:
- this.classList.add('extension-error-severity-info');
- iconAltTextKey = 'extensionLogLevelInfo';
- break;
- case chrome.developerPrivate.ErrorLevel.WARN:
- this.classList.add('extension-error-severity-warning');
- break;
- case chrome.developerPrivate.ErrorLevel.ERROR:
- this.classList.add('extension-error-severity-fatal');
- iconAltTextKey = 'extensionLogLevelError';
- break;
- default:
- assertNotReached();
- }
- } else {
- // We classify manifest errors as "warnings".
- this.classList.add('extension-error-severity-warning');
- }
-
- var iconNode = document.createElement('img');
- iconNode.className = 'extension-error-icon';
- iconNode.alt = loadTimeData.getString(iconAltTextKey);
- this.insertBefore(iconNode, this.firstChild);
-
- var messageSpan = this.querySelector('.extension-error-message');
- messageSpan.textContent = error.message;
-
- var deleteButton = this.querySelector('.error-delete-button');
- deleteButton.addEventListener('click', function(e) {
- this.dispatchEvent(
- new CustomEvent('deleteExtensionError',
- {bubbles: true, detail: this.error}));
- }.bind(this));
-
- this.addEventListener('click', function(e) {
- if (e.target != deleteButton)
- this.requestActive_();
- }.bind(this));
-
- this.addEventListener('keydown', function(e) {
- if (e.key == 'Enter' && e.target != deleteButton)
- this.requestActive_();
- });
- },
-
- /**
- * Bubble up an event to request to become active.
- * @private
- */
- requestActive_: function() {
- this.dispatchEvent(
- new CustomEvent('highlightExtensionError',
- {bubbles: true, detail: this.error}));
- },
- };
-
- /**
- * A variable length list of runtime or manifest errors for a given extension.
- * @param {Array<(RuntimeError|ManifestError)>} errors The list of extension
- * errors with which to populate the list.
- * @param {string} extensionId The id of the extension.
- * @constructor
- * @extends {HTMLDivElement}
- */
- function ExtensionErrorList(errors, extensionId) {
- var div = cloneTemplate('extension-error-list');
- div.__proto__ = ExtensionErrorList.prototype;
- div.extensionId_ = extensionId;
- div.decorate(errors);
- return div;
- }
-
- /**
- * @param {!Element} root
- * @param {?Element} boundary
- * @constructor
- * @extends {cr.ui.FocusRow}
- */
- ExtensionErrorList.FocusRow = function(root, boundary) {
- cr.ui.FocusRow.call(this, root, boundary);
-
- this.addItem('message', '.extension-error-message');
- this.addItem('delete', '.error-delete-button');
- };
-
- ExtensionErrorList.FocusRow.prototype = {
- __proto__: cr.ui.FocusRow.prototype,
- };
-
- ExtensionErrorList.prototype = {
- __proto__: HTMLDivElement.prototype,
-
- /**
- * Initializes the extension error list.
- * @param {Array<(RuntimeError|ManifestError)>} errors The list of errors.
- */
- decorate: function(errors) {
- /** @private {!Array<(ManifestError|RuntimeError)>} */
- this.errors_ = [];
-
- /** @private {!cr.ui.FocusGrid} */
- this.focusGrid_ = new cr.ui.FocusGrid();
-
- /** @private {Element} */
- this.listContents_ = this.querySelector('.extension-error-list-contents');
-
- errors.forEach(this.addError_, this);
-
- this.focusGrid_.ensureRowActive();
-
- this.addEventListener('highlightExtensionError', function(e) {
- this.setActiveErrorNode_(e.target);
- });
- this.addEventListener('deleteExtensionError', function(e) {
- this.removeError_(e.detail);
- });
-
- this.querySelector('#extension-error-list-clear').addEventListener(
- 'click', function(e) {
- this.clear(true);
- }.bind(this));
-
- /**
- * The callback for the extension changed event.
- * @private {function(chrome.developerPrivate.EventData):void}
- */
- this.onItemStateChangedListener_ = function(data) {
- var type = chrome.developerPrivate.EventType;
- if ((data.event_type == type.ERRORS_REMOVED ||
- data.event_type == type.ERROR_ADDED) &&
- data.extensionInfo.id == this.extensionId_) {
- var newErrors = data.extensionInfo.runtimeErrors.concat(
- data.extensionInfo.manifestErrors);
- this.updateErrors_(newErrors);
- }
- }.bind(this);
-
- chrome.developerPrivate.onItemStateChanged.addListener(
- this.onItemStateChangedListener_);
-
- /**
- * The active error element in the list.
- * @private {?}
- */
- this.activeError_ = null;
-
- this.setActiveError(0);
- },
-
- /**
- * Adds an error to the list.
- * @param {(RuntimeError|ManifestError)} error The error to add.
- * @private
- */
- addError_: function(error) {
- this.querySelector('#no-errors-span').hidden = true;
- this.errors_.push(error);
-
- var extensionError = new ExtensionError(error);
- this.listContents_.appendChild(extensionError);
-
- this.focusGrid_.addRow(
- new ExtensionErrorList.FocusRow(extensionError, this.listContents_));
- },
-
- /**
- * Removes an error from the list.
- * @param {(RuntimeError|ManifestError)} error The error to remove.
- * @private
- */
- removeError_: function(error) {
- var index = 0;
- for (; index < this.errors_.length; ++index) {
- if (this.errors_[index].id == error.id)
- break;
- }
- assert(index != this.errors_.length);
- var errorList = this.querySelector('.extension-error-list-contents');
-
- var wasActive =
- this.activeError_ && this.activeError_.error.id == error.id;
-
- this.errors_.splice(index, 1);
- var listElement = errorList.children[index];
-
- var focusRow = this.focusGrid_.getRowForRoot(listElement);
- this.focusGrid_.removeRow(focusRow);
- this.focusGrid_.ensureRowActive();
- focusRow.destroy();
-
- // TODO(dbeam): in a world where this UI is actually used, we should
- // probably move the focus before removing |listElement|.
- listElement.parentNode.removeChild(listElement);
-
- if (wasActive) {
- index = Math.min(index, this.errors_.length - 1);
- this.setActiveError(index); // Gracefully handles the -1 case.
- }
-
- chrome.developerPrivate.deleteExtensionErrors({
- extensionId: error.extensionId,
- errorIds: [error.id]
- });
-
- if (this.errors_.length == 0)
- this.querySelector('#no-errors-span').hidden = false;
- },
-
- /**
- * Updates the list of errors.
- * @param {!Array<(ManifestError|RuntimeError)>} newErrors The new list of
- * errors.
- * @private
- */
- updateErrors_: function(newErrors) {
- this.errors_.forEach(function(error) {
- if (findErrorById(newErrors, error.id) == -1)
- this.removeError_(error);
- }, this);
- newErrors.forEach(function(error) {
- var index = findErrorById(this.errors_, error.id);
- if (index == -1)
- this.addError_(error);
- else
- this.errors_[index] = error; // Update the existing reference.
- }, this);
- },
-
- /**
- * Called when the list is being removed.
- */
- onRemoved: function() {
- chrome.developerPrivate.onItemStateChanged.removeListener(
- this.onItemStateChangedListener_);
- this.clear(false);
- },
-
- /**
- * Sets the active error in the list.
- * @param {number} index The index to set to be active.
- */
- setActiveError: function(index) {
- var errorList = this.querySelector('.extension-error-list-contents');
- var item = errorList.children[index];
- this.setActiveErrorNode_(
- item ? item.querySelector('.extension-error-metadata') : null);
- var node = null;
- if (index >= 0 && index < errorList.children.length) {
- node = errorList.children[index].querySelector(
- '.extension-error-metadata');
- }
- this.setActiveErrorNode_(node);
- },
-
- /**
- * Clears the list of all errors.
- * @param {boolean} deleteErrors Whether or not the errors should be deleted
- * on the backend.
- */
- clear: function(deleteErrors) {
- if (this.errors_.length == 0)
- return;
-
- if (deleteErrors) {
- var ids = this.errors_.map(function(error) { return error.id; });
- chrome.developerPrivate.deleteExtensionErrors({
- extensionId: this.extensionId_,
- errorIds: ids
- });
- }
-
- this.setActiveErrorNode_(null);
- this.errors_.length = 0;
- var errorList = this.querySelector('.extension-error-list-contents');
- while (errorList.firstChild)
- errorList.removeChild(errorList.firstChild);
- },
-
- /**
- * Sets the active error in the list.
- * @param {?} node The error to make active.
- * @private
- */
- setActiveErrorNode_: function(node) {
- if (this.activeError_)
- this.activeError_.classList.remove('extension-error-active');
-
- if (node)
- node.classList.add('extension-error-active');
-
- this.activeError_ = node;
-
- this.dispatchEvent(
- new CustomEvent('activeExtensionErrorChanged',
- {bubbles: true, detail: node ? node.error : null}));
- },
- };
-
- return {
- ExtensionErrorList: ExtensionErrorList
- };
-});
diff --git a/chromium/chrome/browser/resources/extensions/extension_error_overlay.css b/chromium/chrome/browser/resources/extensions/extension_error_overlay.css
deleted file mode 100644
index 91007073925..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_error_overlay.css
+++ /dev/null
@@ -1,72 +0,0 @@
-/* Copyright 2013 The Chromium Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file. */
-
-#extension-error-overlay {
- max-width: 100%;
-}
-
-#extension-error-overlay .content-area {
- display: flex;
- flex-direction: column;
-}
-
-#extension-error-overlay .extension-error-list {
- border: 1px solid #ccc;
- margin-bottom: 3px;
- min-height: 48px;
- overflow-y: auto;
-}
-
-.extension-error-overlay-runtime-content {
- flex: none;
-}
-
-#extension-error-overlay .extension-code-highlighted-source {
- background-color: rgba(255, 195, 200, 255);
-}
-
-#extension-error-overlay-code {
- font-size: 1.2em;
- margin-bottom: 10px;
-}
-
-#extension-error-overlay .extension-code-source {
- color: #555;
-}
-
-.extension-error-overlay-context {
- font-size: 1.1em;
- margin-bottom: 10px;
-}
-
-.extension-error-overlay-stack-trace-list {
- list-style-type: none;
- padding: 0;
-}
-
-.extension-error-overlay-stack-trace summary {
- cursor: pointer;
- font-size: 1.1em;
- outline: none;
-}
-
-.extension-error-overlay-stack-trace summary::-webkit-details-marker {
- font-size: 1em;
-}
-
-.extension-error-overlay-stack-trace-list li {
- -webkit-padding-start: 10px;
- background-color: white;
- cursor: pointer;
- padding-bottom: 6px;
- padding-top: 6px;
-}
-
-.extension-error-overlay-stack-trace-list li:hover {
- background-color: #eee;
-}
-
-.extension-error-overlay-stack-trace-list li.extension-error-active {
- background-color: rgba(0, 100, 255, 0.1);
-}
diff --git a/chromium/chrome/browser/resources/extensions/extension_error_overlay.html b/chromium/chrome/browser/resources/extensions/extension_error_overlay.html
deleted file mode 100644
index 2becd7ce9dd..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_error_overlay.html
+++ /dev/null
@@ -1,39 +0,0 @@
-<!--
-Copyright 2013 The Chromium Authors. All rights reserved.
-Use of this source code is governed by a BSD-style license that can be found
-in the LICENSE file.
--->
-
-<div id="template-collection-extension-error-overlay" hidden>
- <div class="extension-error-overlay-runtime-content">
- <div class="extension-error-overlay-context">
- <span>$i18n{extensionErrorOverlayContextUrl}</span>
- <span class="extension-error-overlay-context-url"></span>
- </div>
- <details class="extension-error-overlay-stack-trace">
- <summary>$i18n{extensionErrorOverlayStackTrace}</summary>
- <ul class="extension-error-overlay-stack-trace-list"></ul>
- </details>
- </div>
-</div>
-
-<div id="extension-error-overlay" class="page">
- <div class="close-button"></div>
- <h1 class="extension-error-overlay-title"></h1>
- <div class="content-area">
- <div class="extension-error-list"></div>
- <div id="extension-error-overlay-code" class="extension-code"></div>
- </div>
- <div class="action-area">
- <div class="action-area-right">
- <div class="button-strip">
- <button id="extension-error-overlay-dismiss">
- $i18n{extensionErrorOverlayDone}
- </button>
- <button id="extension-error-overlay-devtools-button" hidden>
- $i18n{extensionErrorOverlayLaunchDevtools}
- </button>
- </div>
- </div>
- </div>
-</div>
diff --git a/chromium/chrome/browser/resources/extensions/extension_error_overlay.js b/chromium/chrome/browser/resources/extensions/extension_error_overlay.js
deleted file mode 100644
index c8d6948ba24..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_error_overlay.js
+++ /dev/null
@@ -1,502 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-
-/** @typedef {chrome.developerPrivate.RuntimeError} */
-var RuntimeError;
-/** @typedef {chrome.developerPrivate.ManifestError} */
-var ManifestError;
-
-cr.define('extensions', function() {
- 'use strict';
-
- /**
- * Clear all the content of a given element.
- * @param {HTMLElement} element The element to be cleared.
- */
- function clearElement(element) {
- while (element.firstChild)
- element.removeChild(element.firstChild);
- }
-
- /**
- * Get the url relative to the main extension url. If the url is
- * unassociated with the extension, this will be the full url.
- * @param {string} url The url to make relative.
- * @param {string} extensionUrl The url for the extension resources, in the
- * form "chrome-etxension://<extension_id>/".
- * @return {string} The url relative to the host.
- */
- function getRelativeUrl(url, extensionUrl) {
- return url.substring(0, extensionUrl.length) == extensionUrl ?
- url.substring(extensionUrl.length) : url;
- }
-
- /**
- * The RuntimeErrorContent manages all content specifically associated with
- * runtime errors; this includes stack frames and the context url.
- * @constructor
- * @extends {HTMLDivElement}
- */
- function RuntimeErrorContent() {
- var contentArea = $('template-collection-extension-error-overlay').
- querySelector('.extension-error-overlay-runtime-content').
- cloneNode(true);
- contentArea.__proto__ = RuntimeErrorContent.prototype;
- /** @type {RuntimeErrorContent} */ (contentArea).init();
- return contentArea;
- }
-
- /**
- * The name of the "active" class specific to extension errors (so as to
- * not conflict with other rules).
- * @type {string}
- * @const
- */
- RuntimeErrorContent.ACTIVE_CLASS_NAME = 'extension-error-active';
-
- /**
- * Determine whether or not we should display the url to the user. We don't
- * want to include any of our own code in stack traces.
- * @param {string} url The url in question.
- * @return {boolean} True if the url should be displayed, and false
- * otherwise (i.e., if it is an internal script).
- */
- RuntimeErrorContent.shouldDisplayForUrl = function(url) {
- // All our internal scripts are in the 'extensions::' namespace.
- return !/^extensions::/.test(url);
- };
-
- RuntimeErrorContent.prototype = {
- __proto__: HTMLDivElement.prototype,
-
- /**
- * The underlying error whose details are being displayed.
- * @type {?(RuntimeError|ManifestError)}
- * @private
- */
- error_: null,
-
- /**
- * The URL associated with this extension, i.e. chrome-extension://<id>/.
- * @type {?string}
- * @private
- */
- extensionUrl_: null,
-
- /**
- * The node of the stack trace which is currently active.
- * @type {?HTMLElement}
- * @private
- */
- currentFrameNode_: null,
-
- /**
- * Initialize the RuntimeErrorContent for the first time.
- */
- init: function() {
- /**
- * The stack trace element in the overlay.
- * @type {HTMLElement}
- * @private
- */
- this.stackTrace_ = /** @type {HTMLElement} */(
- this.querySelector('.extension-error-overlay-stack-trace-list'));
- assert(this.stackTrace_);
-
- /**
- * The context URL element in the overlay.
- * @type {HTMLElement}
- * @private
- */
- this.contextUrl_ = /** @type {HTMLElement} */(
- this.querySelector('.extension-error-overlay-context-url'));
- assert(this.contextUrl_);
- },
-
- /**
- * Sets the error for the content.
- * @param {(RuntimeError|ManifestError)} error The error whose content
- * should be displayed.
- * @param {string} extensionUrl The URL associated with this extension.
- */
- setError: function(error, extensionUrl) {
- this.clearError();
-
- this.error_ = error;
- this.extensionUrl_ = extensionUrl;
- this.contextUrl_.textContent = error.contextUrl ?
- getRelativeUrl(error.contextUrl, this.extensionUrl_) :
- loadTimeData.getString('extensionErrorOverlayContextUnknown');
- this.initStackTrace_();
- },
-
- /**
- * Wipe content associated with a specific error.
- */
- clearError: function() {
- this.error_ = null;
- this.extensionUrl_ = null;
- this.currentFrameNode_ = null;
- clearElement(this.stackTrace_);
- this.stackTrace_.hidden = true;
- },
-
- /**
- * Makes |frame| active and deactivates the previously active frame (if
- * there was one).
- * @param {HTMLElement} frameNode The frame to activate.
- * @private
- */
- setActiveFrame_: function(frameNode) {
- if (this.currentFrameNode_) {
- this.currentFrameNode_.classList.remove(
- RuntimeErrorContent.ACTIVE_CLASS_NAME);
- }
-
- this.currentFrameNode_ = frameNode;
- this.currentFrameNode_.classList.add(
- RuntimeErrorContent.ACTIVE_CLASS_NAME);
- },
-
- /**
- * Initialize the stack trace element of the overlay.
- * @private
- */
- initStackTrace_: function() {
- for (var i = 0; i < this.error_.stackTrace.length; ++i) {
- var frame = this.error_.stackTrace[i];
- // Don't include any internal calls (e.g., schemaBindings) in the
- // stack trace.
- if (!RuntimeErrorContent.shouldDisplayForUrl(frame.url))
- continue;
-
- var frameNode = document.createElement('li');
- // Attach the index of the frame to which this node refers (since we
- // may skip some, this isn't a 1-to-1 match).
- frameNode.indexIntoTrace = i;
-
- // The description is a human-readable summation of the frame, in the
- // form "<relative_url>:<line_number> (function)", e.g.
- // "myfile.js:25 (myFunction)".
- var description = getRelativeUrl(frame.url,
- assert(this.extensionUrl_)) + ':' + frame.lineNumber;
- if (frame.functionName) {
- var functionName = frame.functionName == '(anonymous function)' ?
- loadTimeData.getString('extensionErrorOverlayAnonymousFunction') :
- frame.functionName;
- description += ' (' + functionName + ')';
- }
- frameNode.textContent = description;
-
- // When the user clicks on a frame in the stack trace, we should
- // highlight that overlay in the list, display the appropriate source
- // code with the line highlighted, and link the "Open DevTools" button
- // with that frame.
- frameNode.addEventListener('click', function(frame, frameNode, e) {
- this.setActiveFrame_(frameNode);
-
- // Request the file source with the section highlighted.
- extensions.ExtensionErrorOverlay.getInstance().requestFileSource(
- {extensionId: this.error_.extensionId,
- message: this.error_.message,
- pathSuffix: getRelativeUrl(frame.url,
- assert(this.extensionUrl_)),
- lineNumber: frame.lineNumber});
- }.bind(this, frame, frameNode));
-
- this.stackTrace_.appendChild(frameNode);
- }
-
- // Set the current stack frame to the first stack frame and show the
- // trace, if one exists. (We can't just check error.stackTrace, because
- // it's possible the trace was purely internal, and we don't show
- // internal frames.)
- if (this.stackTrace_.children.length > 0) {
- this.stackTrace_.hidden = false;
- this.setActiveFrame_(assertInstanceof(this.stackTrace_.firstChild,
- HTMLElement));
- }
- },
-
- /**
- * Open the developer tools for the active stack frame.
- */
- openDevtools: function() {
- var stackFrame =
- this.error_.stackTrace[this.currentFrameNode_.indexIntoTrace];
-
- chrome.developerPrivate.openDevTools(
- {renderProcessId: this.error_.renderProcessId || -1,
- renderViewId: this.error_.renderViewId || -1,
- url: stackFrame.url,
- lineNumber: stackFrame.lineNumber || 0,
- columnNumber: stackFrame.columnNumber || 0});
- }
- };
-
- /**
- * The ExtensionErrorOverlay will show the contents of a file which pertains
- * to the ExtensionError; this is either the manifest file (for manifest
- * errors) or a source file (for runtime errors). If possible, the portion
- * of the file which caused the error will be highlighted.
- * @constructor
- */
- function ExtensionErrorOverlay() {
- /**
- * The content section for runtime errors; this is re-used for all
- * runtime errors and attached/detached from the overlay as needed.
- * @type {RuntimeErrorContent}
- * @private
- */
- this.runtimeErrorContent_ = new RuntimeErrorContent();
- }
-
- /**
- * The manifest filename.
- * @type {string}
- * @const
- * @private
- */
- ExtensionErrorOverlay.MANIFEST_FILENAME_ = 'manifest.json';
-
- /**
- * Determine whether or not chrome can load the source for a given file; this
- * can only be done if the file belongs to the extension.
- * @param {string} file The file to load.
- * @param {string} extensionUrl The url for the extension, in the form
- * chrome-extension://<extension-id>/.
- * @return {boolean} True if the file can be loaded, false otherwise.
- * @private
- */
- ExtensionErrorOverlay.canLoadFileSource = function(file, extensionUrl) {
- return file.substr(0, extensionUrl.length) == extensionUrl ||
- file.toLowerCase() == ExtensionErrorOverlay.MANIFEST_FILENAME_;
- };
-
- cr.addSingletonGetter(ExtensionErrorOverlay);
-
- ExtensionErrorOverlay.prototype = {
- /**
- * The underlying error whose details are being displayed.
- * @type {?(RuntimeError|ManifestError)}
- * @private
- */
- selectedError_: null,
-
- /**
- * Initialize the page.
- * @param {function(HTMLDivElement)} showOverlay The function to show or
- * hide the ExtensionErrorOverlay; this should take a single parameter
- * which is either the overlay Div if the overlay should be displayed,
- * or null if the overlay should be hidden.
- */
- initializePage: function(showOverlay) {
- var overlay = $('overlay');
- cr.ui.overlay.setupOverlay(overlay);
- cr.ui.overlay.globalInitialization();
- overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this));
-
- $('extension-error-overlay-dismiss').addEventListener('click',
- function() {
- cr.dispatchSimpleEvent(overlay, 'cancelOverlay');
- });
-
- /**
- * The element of the full overlay.
- * @type {HTMLDivElement}
- * @private
- */
- this.overlayDiv_ = /** @type {HTMLDivElement} */(
- $('extension-error-overlay'));
-
- /**
- * The portion of the overlay which shows the code relating to the error
- * and the corresponding line numbers.
- * @type {extensions.ExtensionCode}
- * @private
- */
- this.codeDiv_ =
- new extensions.ExtensionCode($('extension-error-overlay-code'));
-
- /**
- * The function to show or hide the ExtensionErrorOverlay.
- * @param {boolean} isVisible Whether the overlay should be visible.
- */
- this.setVisible = function(isVisible) {
- showOverlay(isVisible ? this.overlayDiv_ : null);
- if (isVisible)
- this.codeDiv_.scrollToError();
- };
-
- /**
- * The button to open the developer tools (only available for runtime
- * errors).
- * @type {HTMLButtonElement}
- * @private
- */
- this.openDevtoolsButton_ = /** @type {HTMLButtonElement} */(
- $('extension-error-overlay-devtools-button'));
- this.openDevtoolsButton_.addEventListener('click', function() {
- this.runtimeErrorContent_.openDevtools();
- }.bind(this));
- },
-
- /**
- * Handles a click on the dismiss ("OK" or close) buttons.
- * @param {Event} e The click event.
- * @private
- */
- handleDismiss_: function(e) {
- this.setVisible(false);
-
- // There's a chance that the overlay receives multiple dismiss events; in
- // this case, handle it gracefully and return (since all necessary work
- // will already have been done).
- if (!this.selectedError_)
- return;
-
- // Remove all previous content.
- this.codeDiv_.clear();
-
- /** @type {extensions.ExtensionErrorList} */ (
- this.overlayDiv_.querySelector('.extension-error-list'))
- .onRemoved();
-
- this.clearRuntimeContent_();
-
- this.selectedError_ = null;
- },
-
- /**
- * Clears the current content.
- * @private
- */
- clearRuntimeContent_: function() {
- if (this.runtimeErrorContent_.parentNode) {
- this.runtimeErrorContent_.parentNode.removeChild(
- this.runtimeErrorContent_);
- this.runtimeErrorContent_.clearError();
- }
- this.openDevtoolsButton_.hidden = true;
- },
-
- /**
- * Sets the active error for the overlay.
- * @param {?(ManifestError|RuntimeError)} error The error to make active.
- * @private
- */
- setActiveError_: function(error) {
- this.selectedError_ = error;
-
- // If there is no error (this can happen if, e.g., the user deleted all
- // the errors), then clear the content.
- if (!error) {
- this.codeDiv_.populate(
- null, loadTimeData.getString('extensionErrorNoErrorsCodeMessage'));
- this.clearRuntimeContent_();
- return;
- }
-
- var extensionUrl = 'chrome-extension://' + error.extensionId + '/';
- // Set or hide runtime content.
- if (error.type == chrome.developerPrivate.ErrorType.RUNTIME) {
- this.runtimeErrorContent_.setError(error, extensionUrl);
- this.overlayDiv_.querySelector('.content-area').insertBefore(
- this.runtimeErrorContent_,
- this.codeDiv_.nextSibling);
- this.openDevtoolsButton_.hidden = false;
- this.openDevtoolsButton_.disabled = !error.canInspect;
- } else {
- this.clearRuntimeContent_();
- }
-
- // Read the file source to populate the code section, or set it to null if
- // the file is unreadable.
- if (ExtensionErrorOverlay.canLoadFileSource(error.source, extensionUrl)) {
- // Use pathname instead of relativeUrl.
- var requestFileSourceArgs = {extensionId: error.extensionId,
- message: error.message};
- switch (error.type) {
- case chrome.developerPrivate.ErrorType.MANIFEST:
- requestFileSourceArgs.pathSuffix = error.source;
- requestFileSourceArgs.manifestKey = error.manifestKey;
- requestFileSourceArgs.manifestSpecific = error.manifestSpecific;
- break;
- case chrome.developerPrivate.ErrorType.RUNTIME:
- // slice(1) because pathname starts with a /.
- var pathname = new URL(error.source).pathname.slice(1);
- requestFileSourceArgs.pathSuffix = pathname;
- requestFileSourceArgs.lineNumber =
- error.stackTrace && error.stackTrace[0] ?
- error.stackTrace[0].lineNumber : 0;
- break;
- default:
- assertNotReached();
- }
- this.requestFileSource(requestFileSourceArgs);
- } else {
- this.onFileSourceResponse_(null);
- }
- },
-
- /**
- * Associate an error with the overlay. This will set the error for the
- * overlay, and, if possible, will populate the code section of the overlay
- * with the relevant file, load the stack trace, and generate links for
- * opening devtools (the latter two only happen for runtime errors).
- * @param {Array<(RuntimeError|ManifestError)>} errors The error to show in
- * the overlay.
- * @param {string} extensionId The id of the extension.
- * @param {string} extensionName The name of the extension.
- */
- setErrorsAndShowOverlay: function(errors, extensionId, extensionName) {
- document.querySelector(
- '#extension-error-overlay .extension-error-overlay-title').
- textContent = extensionName;
- var errorsDiv = this.overlayDiv_.querySelector('.extension-error-list');
- var extensionErrors =
- new extensions.ExtensionErrorList(errors, extensionId);
- errorsDiv.parentNode.replaceChild(extensionErrors, errorsDiv);
- extensionErrors.addEventListener('activeExtensionErrorChanged',
- function(e) {
- this.setActiveError_(e.detail);
- }.bind(this));
-
- if (errors.length > 0)
- this.setActiveError_(errors[0]);
- this.setVisible(true);
- },
-
- /**
- * Requests a file's source.
- * @param {chrome.developerPrivate.RequestFileSourceProperties} args The
- * arguments for the call.
- */
- requestFileSource: function(args) {
- chrome.developerPrivate.requestFileSource(
- args, this.onFileSourceResponse_.bind(this));
- },
-
- /**
- * Set the code to be displayed in the code portion of the overlay.
- * @see ExtensionErrorOverlay.requestFileSourceResponse().
- * @param {?chrome.developerPrivate.RequestFileSourceResponse} response The
- * response from the request file source call, which will be shown as
- * code. If |response| is null, then a "Could not display code" message
- * will be displayed instead.
- */
- onFileSourceResponse_: function(response) {
- this.codeDiv_.populate(
- response, // ExtensionCode can handle a null response.
- loadTimeData.getString('extensionErrorOverlayNoCodeToDisplay'));
- this.setVisible(true);
- },
- };
-
- // Export
- return {
- ExtensionErrorOverlay: ExtensionErrorOverlay
- };
-});
diff --git a/chromium/chrome/browser/resources/extensions/extension_error_severity_fatal.png b/chromium/chrome/browser/resources/extensions/extension_error_severity_fatal.png
deleted file mode 100644
index b53dc2cf74b..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_error_severity_fatal.png
+++ /dev/null
Binary files differ
diff --git a/chromium/chrome/browser/resources/extensions/extension_error_severity_info.png b/chromium/chrome/browser/resources/extensions/extension_error_severity_info.png
deleted file mode 100644
index 1c32c6eb83f..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_error_severity_info.png
+++ /dev/null
Binary files differ
diff --git a/chromium/chrome/browser/resources/extensions/extension_error_severity_warning.png b/chromium/chrome/browser/resources/extensions/extension_error_severity_warning.png
deleted file mode 100644
index d2e3434a595..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_error_severity_warning.png
+++ /dev/null
Binary files differ
diff --git a/chromium/chrome/browser/resources/extensions/extension_focus_manager.js b/chromium/chrome/browser/resources/extensions/extension_focus_manager.js
deleted file mode 100644
index 377744caaeb..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_focus_manager.js
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('extensions', function() {
- /**
- * @constructor
- * @extends {cr.ui.FocusManager}
- */
- function ExtensionFocusManager() {}
-
- cr.addSingletonGetter(ExtensionFocusManager);
-
- ExtensionFocusManager.prototype = {
- __proto__: cr.ui.FocusManager.prototype,
-
- /** @override */
- getFocusParent: function() {
- var overlay = extensions.ExtensionSettings.getCurrentOverlay();
- return overlay || $('extension-settings');
- },
- };
-
- return {
- ExtensionFocusManager: ExtensionFocusManager,
- };
-});
diff --git a/chromium/chrome/browser/resources/extensions/extension_list.js b/chromium/chrome/browser/resources/extensions/extension_list.js
deleted file mode 100644
index 5a2e396ee59..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_list.js
+++ /dev/null
@@ -1,1066 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// <include src="extension_error.js">
-
-cr.define('extensions', function() {
- 'use strict';
-
- var ExtensionType = chrome.developerPrivate.ExtensionType;
-
- /**
- * @param {string} name The name of the template to clone.
- * @return {!Element} The freshly cloned template.
- */
- function cloneTemplate(name) {
- var node = $('templates').querySelector('.' + name).cloneNode(true);
- return assertInstanceof(node, Element);
- }
-
- /**
- * @extends {HTMLElement}
- * @constructor
- */
- function ExtensionWrapper() {
- var wrapper = cloneTemplate('extension-list-item-wrapper');
- wrapper.__proto__ = ExtensionWrapper.prototype;
- wrapper.initialize();
- return wrapper;
- }
-
- ExtensionWrapper.prototype = {
- __proto__: HTMLElement.prototype,
-
- initialize: function() {
- var boundary = $('extension-settings-list');
- /** @private {!extensions.FocusRow} */
- this.focusRow_ = new extensions.FocusRow(this, boundary);
- },
-
- /** @return {!cr.ui.FocusRow} */
- getFocusRow: function() {
- return this.focusRow_;
- },
-
- /**
- * Add an item to the focus row and listen for |eventType| events.
- * @param {string} focusType A tag used to identify equivalent elements when
- * changing focus between rows.
- * @param {string} query A query to select the element to set up.
- * @param {string=} opt_eventType The type of event to listen to.
- * @param {function(Event)=} opt_handler The function that should be called
- * by the event.
- * @private
- */
- setupColumn: function(focusType, query, opt_eventType, opt_handler) {
- assert(this.focusRow_.addItem(focusType, query));
- if (opt_eventType) {
- assert(opt_handler);
- this.querySelector(query).addEventListener(opt_eventType, opt_handler);
- }
- },
- };
-
- var ExtensionCommandsOverlay = extensions.ExtensionCommandsOverlay;
-
- /**
- * Compares two extensions for the order they should appear in the list.
- * @param {chrome.developerPrivate.ExtensionInfo} a The first extension.
- * @param {chrome.developerPrivate.ExtensionInfo} b The second extension.
- * returns {number} -1 if A comes before B, 1 if A comes after B, 0 if equal.
- */
- function compareExtensions(a, b) {
- function compare(x, y) {
- return x < y ? -1 : (x > y ? 1 : 0);
- }
- function compareLocation(x, y) {
- if (x.location == y.location)
- return 0;
- if (x.location == chrome.developerPrivate.Location.UNPACKED)
- return -1;
- if (y.location == chrome.developerPrivate.Location.UNPACKED)
- return 1;
- return 0;
- }
- return compareLocation(a, b) ||
- compare(a.name.toLowerCase(), b.name.toLowerCase()) ||
- compare(a.id, b.id);
- }
-
- /** @interface */
- function ExtensionListDelegate() {}
-
- ExtensionListDelegate.prototype = {
- /**
- * Called when the number of extensions in the list has changed.
- */
- onExtensionCountChanged: assertNotReached,
- };
-
- /**
- * Creates a new list of extensions.
- * @param {extensions.ExtensionListDelegate} delegate
- * @constructor
- * @extends {HTMLDivElement}
- */
- function ExtensionList(delegate) {
- var div = document.createElement('div');
- div.__proto__ = ExtensionList.prototype;
- div.initialize(delegate);
- return div;
- }
-
- ExtensionList.prototype = {
- __proto__: HTMLDivElement.prototype,
-
- /**
- * Indicates whether an embedded options page that was navigated to through
- * the '?options=' URL query has been shown to the user. This is necessary
- * to prevent showExtensionNodes_ from opening the options more than once.
- * @type {boolean}
- * @private
- */
- optionsShown_: false,
-
- /** @private {!cr.ui.FocusGrid} */
- focusGrid_: new cr.ui.FocusGrid(),
-
- /**
- * Indicates whether an uninstall dialog is being shown to prevent multiple
- * dialogs from being displayed.
- * @private {boolean}
- */
- uninstallIsShowing_: false,
-
- /**
- * Indicates whether a permissions prompt is showing.
- * @private {boolean}
- */
- permissionsPromptIsShowing_: false,
-
- /**
- * Whether or not any initial navigation (like scrolling to an extension,
- * or opening an options page) has occurred.
- * @private {boolean}
- */
- didInitialNavigation_: false,
-
- /**
- * Whether or not incognito mode is available.
- * @private {boolean}
- */
- incognitoAvailable_: false,
-
- /**
- * Whether or not the app info dialog is enabled.
- * @private {boolean}
- */
- enableAppInfoDialog_: false,
-
- /**
- * Initializes the list.
- * @param {!extensions.ExtensionListDelegate} delegate
- */
- initialize: function(delegate) {
- /** @private {!Array<chrome.developerPrivate.ExtensionInfo>} */
- this.extensions_ = [];
-
- /** @private {!extensions.ExtensionListDelegate} */
- this.delegate_ = delegate;
-
- this.resetLoadFinished();
-
- chrome.developerPrivate.onItemStateChanged.addListener(
- function(eventData) {
- var EventType = chrome.developerPrivate.EventType;
- switch (eventData.event_type) {
- case EventType.VIEW_REGISTERED:
- case EventType.VIEW_UNREGISTERED:
- case EventType.INSTALLED:
- case EventType.LOADED:
- case EventType.UNLOADED:
- case EventType.ERROR_ADDED:
- case EventType.ERRORS_REMOVED:
- case EventType.PREFS_CHANGED:
- if (eventData.extensionInfo) {
- this.updateOrCreateWrapper_(eventData.extensionInfo);
- this.focusGrid_.ensureRowActive();
- }
- break;
- case EventType.UNINSTALLED:
- var index = this.getIndexOfExtension_(eventData.item_id);
- this.extensions_.splice(index, 1);
- this.removeWrapper_(/**@type {!ExtensionWrapper} */ (
- getRequiredElement(eventData.item_id)));
- break;
- default:
- assertNotReached();
- }
-
- if (eventData.event_type == EventType.UNLOADED)
- this.hideEmbeddedExtensionOptions_(eventData.item_id);
-
- if (eventData.event_type == EventType.INSTALLED ||
- eventData.event_type == EventType.UNINSTALLED) {
- this.delegate_.onExtensionCountChanged();
- }
-
- if (eventData.event_type == EventType.LOADED ||
- eventData.event_type == EventType.UNLOADED ||
- eventData.event_type == EventType.PREFS_CHANGED ||
- eventData.event_type == EventType.UNINSTALLED) {
- // We update the commands overlay whenever an extension is added or
- // removed (other updates wouldn't affect command-ly things). We
- // need both UNLOADED and UNINSTALLED since the UNLOADED event results
- // in an extension losing active keybindings, and UNINSTALLED can
- // result in the "Keyboard shortcuts" link being removed.
- ExtensionCommandsOverlay.updateExtensionsData(this.extensions_);
- }
- }.bind(this));
- },
-
- /**
- * Resets the |loadFinished| promise so that it can be used again; this
- * is useful if the page updates and tests need to wait for it to finish.
- */
- resetLoadFinished: function() {
- /**
- * |loadFinished| should be used for testing purposes and will be
- * fulfilled when this list has finished loading the first time.
- * @type {Promise}
- * */
- this.loadFinished = new Promise(function(resolve, reject) {
- /** @private {function(?)} */
- this.resolveLoadFinished_ = resolve;
- }.bind(this));
- },
-
- /**
- * Updates the extensions on the page.
- * @param {boolean} incognitoAvailable Whether or not incognito is allowed.
- * @param {boolean} enableAppInfoDialog Whether or not the app info dialog
- * is enabled.
- * @return {Promise} A promise that is resolved once the extensions data is
- * fully updated.
- */
- updateExtensionsData: function(incognitoAvailable, enableAppInfoDialog) {
- // If we start to need more information about the extension configuration,
- // consider passing in the full object from the ExtensionSettings.
- this.incognitoAvailable_ = incognitoAvailable;
- this.enableAppInfoDialog_ = enableAppInfoDialog;
- /** @private {Promise} */
- this.extensionsUpdated_ = new Promise(function(resolve, reject) {
- chrome.developerPrivate.getExtensionsInfo(
- {includeDisabled: true, includeTerminated: true},
- function(extensions) {
- // Sort in order of unpacked vs. packed, followed by name, followed by
- // id.
- extensions.sort(compareExtensions);
- this.extensions_ = extensions;
- this.showExtensionNodes_();
-
- // We keep the commands overlay's extension info in sync, so that we
- // don't duplicate the same querying logic there.
- ExtensionCommandsOverlay.updateExtensionsData(this.extensions_);
-
- resolve();
-
- // |resolve| is async so it's necessary to use |then| here in order to
- // do work after other |then|s have finished. This is important so
- // elements are visible when these updates happen.
- this.extensionsUpdated_.then(function() {
- this.onUpdateFinished_();
- this.resolveLoadFinished_();
- }.bind(this));
- }.bind(this));
- }.bind(this));
- return this.extensionsUpdated_;
- },
-
- /**
- * Updates elements that need to be visible in order to update properly.
- * @private
- */
- onUpdateFinished_: function() {
- // Cannot focus or highlight a extension if there are none, and we should
- // only scroll to a particular extension or open the options page once.
- if (this.extensions_.length == 0 || this.didInitialNavigation_)
- return;
-
- this.didInitialNavigation_ = true;
- assert(!this.hidden);
- assert(!this.parentElement.hidden);
-
- var idToHighlight = this.getIdQueryParam_();
- if (idToHighlight) {
- var wrapper = /** @type {ExtensionWrapper} */ ($(idToHighlight));
- if (wrapper) {
- this.scrollToWrapper_(idToHighlight);
-
- var focusRow = wrapper.getFocusRow();
- (focusRow.getFirstFocusable('enabled') ||
- focusRow.getFirstFocusable('remove-enterprise') ||
- focusRow.getFirstFocusable('website') ||
- focusRow.getFirstFocusable('details')).focus();
- }
- }
-
- var idToOpenOptions = this.getOptionsQueryParam_();
- if (idToOpenOptions && $(idToOpenOptions))
- this.showEmbeddedExtensionOptions_(idToOpenOptions, true);
- },
-
- /** @return {number} The number of extensions being displayed. */
- getNumExtensions: function() {
- return this.extensions_.length;
- },
-
- /**
- * @param {string} id The id of the extension.
- * @return {number} The index of the extension with the given id.
- * @private
- */
- getIndexOfExtension_: function(id) {
- for (var i = 0; i < this.extensions_.length; ++i) {
- if (this.extensions_[i].id == id)
- return i;
- }
- return -1;
- },
-
- getIdQueryParam_: function() {
- return parseQueryParams(document.location)['id'];
- },
-
- getOptionsQueryParam_: function() {
- return parseQueryParams(document.location)['options'];
- },
-
- /**
- * Creates or updates all extension items from scratch.
- * @private
- */
- showExtensionNodes_: function() {
- // Any node that is not updated will be removed.
- var seenIds = [];
-
- // Iterate over the extension data and add each item to the list.
- this.extensions_.forEach(function(extension) {
- seenIds.push(extension.id);
- this.updateOrCreateWrapper_(extension);
- }, this);
- this.focusGrid_.ensureRowActive();
-
- // Remove extensions that are no longer installed.
- var wrappers = document.querySelectorAll(
- '.extension-list-item-wrapper[id]');
- Array.prototype.forEach.call(wrappers, function(wrapper) {
- if (seenIds.indexOf(wrapper.id) < 0)
- this.removeWrapper_(wrapper);
- }, this);
- },
-
- /**
- * Removes the wrapper from the DOM and updates the focused element if
- * needed.
- * @param {!ExtensionWrapper} wrapper
- * @private
- */
- removeWrapper_: function(wrapper) {
- // If focus is in the wrapper about to be removed, move it first. This
- // happens when clicking the trash can to remove an extension.
- if (wrapper.contains(document.activeElement)) {
- var wrappers = /** @type {NodeList<ExtensionWrapper>}*/ (
- document.querySelectorAll('.extension-list-item-wrapper[id]'));
- var index = Array.prototype.indexOf.call(wrappers, wrapper);
- assert(index != -1);
- var focusableWrapper = wrappers[index + 1] || wrappers[index - 1];
- if (focusableWrapper) {
- var newFocusRow = focusableWrapper.getFocusRow();
- newFocusRow.getEquivalentElement(document.activeElement).focus();
- }
- }
-
- var focusRow = wrapper.getFocusRow();
- this.focusGrid_.removeRow(focusRow);
- this.focusGrid_.ensureRowActive();
- focusRow.destroy();
-
- wrapper.parentNode.removeChild(wrapper);
- },
-
- /**
- * Scrolls the page down to the extension node with the given id.
- * @param {string} extensionId The id of the extension to scroll to.
- * @private
- */
- scrollToWrapper_: function(extensionId) {
- // Scroll offset should be calculated slightly higher than the actual
- // offset of the element being scrolled to, so that it ends up not all
- // the way at the top. That way it is clear that there are more elements
- // above the element being scrolled to.
- var wrapper = $(extensionId);
- var scrollFudge = 1.2;
- var scrollTop = wrapper.offsetTop - scrollFudge * wrapper.clientHeight;
- setScrollTopForDocument(document, scrollTop);
- },
-
- /**
- * Synthesizes and initializes an HTML element for the extension metadata
- * given in |extension|.
- * @param {!chrome.developerPrivate.ExtensionInfo} extension A dictionary
- * of extension metadata.
- * @param {?Element} nextWrapper The newly created wrapper will be inserted
- * before |nextWrapper| if non-null (else it will be appended to the
- * wrapper list).
- * @private
- */
- createWrapper_: function(extension, nextWrapper) {
- var wrapper = new ExtensionWrapper;
- wrapper.id = extension.id;
-
- // The 'Permissions' link.
- wrapper.setupColumn('details', '.permissions-link', 'click', function(e) {
- if (!this.permissionsPromptIsShowing_) {
- chrome.developerPrivate.showPermissionsDialog(extension.id,
- function() {
- this.permissionsPromptIsShowing_ = false;
- }.bind(this));
- this.permissionsPromptIsShowing_ = true;
- }
- e.preventDefault();
- });
-
- wrapper.setupColumn('options', '.options-button', 'click', function(e) {
- this.showEmbeddedExtensionOptions_(extension.id, false);
- e.preventDefault();
- }.bind(this));
-
- // The 'Options' button or link, depending on its behaviour.
- // Set an href to get the correct mouse-over appearance (link,
- // footer) - but the actual link opening is done through developerPrivate
- // API with a preventDefault().
- wrapper.querySelector('.options-link').href =
- extension.optionsPage ? extension.optionsPage.url : '';
- wrapper.setupColumn('options', '.options-link', 'click', function(e) {
- chrome.developerPrivate.showOptions(extension.id);
- e.preventDefault();
- });
-
- // The 'View in Web Store/View Web Site' link.
- wrapper.setupColumn('website', '.site-link');
-
- // The 'Launch' link.
- wrapper.setupColumn('launch', '.launch-link', 'click', function(e) {
- chrome.management.launchApp(extension.id);
- });
-
- // The 'Reload' link.
- wrapper.setupColumn('localReload', '.reload-link', 'click', function(e) {
- chrome.developerPrivate.reload(extension.id, {failQuietly: true});
- });
-
- wrapper.setupColumn('errors', '.errors-link', 'click', function(e) {
- var extensionId = extension.id;
- assert(this.extensions_.length > 0);
- var newEx = this.extensions_.filter(function(e) {
- return e.id == extensionId;
- })[0];
- var errors = newEx.manifestErrors.concat(newEx.runtimeErrors);
- extensions.ExtensionErrorOverlay.getInstance().setErrorsAndShowOverlay(
- errors, extensionId, newEx.name);
- }.bind(this));
-
- wrapper.setupColumn('suspiciousLearnMore',
- '.suspicious-install-message .learn-more-link');
-
- // The path, if provided by unpacked extension.
- wrapper.setupColumn('loadPath', '.load-path a:first-of-type', 'click',
- function(e) {
- chrome.developerPrivate.showPath(extension.id);
- e.preventDefault();
- });
-
- // The 'allow in incognito' checkbox.
- wrapper.setupColumn('incognito', '.incognito-control input', 'change',
- function(e) {
- var butterBar = wrapper.querySelector('.butter-bar');
- var checked = e.target.checked;
- butterBar.hidden = !checked ||
- extension.type == ExtensionType.HOSTED_APP;
- chrome.developerPrivate.updateExtensionConfiguration({
- extensionId: extension.id,
- incognitoAccess: e.target.checked
- });
- }.bind(this));
-
- // The 'collect errors' checkbox. This should only be visible if the
- // error console is enabled - we can detect this by the existence of the
- // |errorCollectionEnabled| property.
- wrapper.setupColumn('collectErrors', '.error-collection-control input',
- 'change', function(e) {
- chrome.developerPrivate.updateExtensionConfiguration({
- extensionId: extension.id,
- errorCollection: e.target.checked
- });
- });
-
- // The 'allow on all urls' checkbox. This should only be visible if
- // active script restrictions are enabled. If they are not enabled, no
- // extensions should want all urls.
- wrapper.setupColumn('allUrls', '.all-urls-control input', 'click',
- function(e) {
- chrome.developerPrivate.updateExtensionConfiguration({
- extensionId: extension.id,
- runOnAllUrls: e.target.checked
- });
- });
-
- // The 'allow file:// access' checkbox.
- wrapper.setupColumn('localUrls', '.file-access-control input', 'click',
- function(e) {
- chrome.developerPrivate.updateExtensionConfiguration({
- extensionId: extension.id,
- fileAccess: e.target.checked
- });
- });
-
- // The 'Reload' terminated link.
- wrapper.setupColumn('terminatedReload', '.terminated-reload-link',
- 'click', function(e) {
- chrome.developerPrivate.reload(extension.id, {failQuietly: true});
- });
-
- // The 'Repair' corrupted link.
- wrapper.setupColumn('repair', '.corrupted-repair-button', 'click',
- function(e) {
- chrome.developerPrivate.repairExtension(extension.id);
- });
-
- // The 'Enabled' checkbox.
- wrapper.setupColumn('enabled', '.enable-checkbox input', 'click',
- function(e) {
- var checked = e.target.checked;
- // TODO(devlin): What should we do if this fails? Ideally we want to
- // show some kind of error or feedback to the user if this fails.
- chrome.management.setEnabled(extension.id, checked);
-
- // This may seem counter-intuitive (to not set/clear the checkmark)
- // but this page will be updated asynchronously if the extension
- // becomes enabled/disabled. It also might not become enabled or
- // disabled, because the user might e.g. get prompted when enabling
- // and choose not to.
- e.preventDefault();
- });
-
- // 'Remove' button.
- var trash = cloneTemplate('trash');
- trash.title = loadTimeData.getString('extensionUninstall');
-
- wrapper.querySelector('.enable-controls').appendChild(trash);
-
- wrapper.setupColumn('remove-enterprise', '.trash', 'click', function(e) {
- trash.classList.add('open');
- trash.classList.toggle('mouse-clicked', e.detail > 0);
- if (this.uninstallIsShowing_)
- return;
- this.uninstallIsShowing_ = true;
- chrome.management.uninstall(extension.id,
- {showConfirmDialog: true},
- function() {
- // TODO(devlin): What should we do if the uninstall fails?
- this.uninstallIsShowing_ = false;
-
- if (trash.classList.contains('mouse-clicked'))
- trash.blur();
-
- if (chrome.runtime.lastError) {
- // The uninstall failed (e.g. a cancel). Allow the trash to close.
- trash.classList.remove('open');
- } else {
- // Leave the trash open if the uninstall succeded. Otherwise it can
- // half-close right before it's removed when the DOM is modified.
- }
- }.bind(this));
- }.bind(this));
-
- // Maintain the order that nodes should be in when creating as well as
- // when adding only one new wrapper.
- this.insertBefore(wrapper, nextWrapper);
- this.updateWrapper_(extension, wrapper);
-
- var nextRow = this.focusGrid_.getRowForRoot(nextWrapper); // May be null.
- this.focusGrid_.addRowBefore(wrapper.getFocusRow(), nextRow);
- },
-
- /**
- * Updates an HTML element for the extension metadata given in |extension|.
- * @param {!chrome.developerPrivate.ExtensionInfo} extension A dictionary of
- * extension metadata.
- * @param {!ExtensionWrapper} wrapper The extension wrapper element to
- * update.
- * @private
- */
- updateWrapper_: function(extension, wrapper) {
- var isActive =
- extension.state == chrome.developerPrivate.ExtensionState.ENABLED;
- wrapper.classList.toggle('inactive-extension', !isActive);
- wrapper.classList.remove('controlled', 'may-not-remove');
-
- if (extension.controlledInfo) {
- wrapper.classList.add('controlled');
- } else if (!extension.userMayModify ||
- extension.mustRemainInstalled ||
- extension.dependentExtensions.length > 0) {
- wrapper.classList.add('may-not-remove');
- }
-
- var item = wrapper.querySelector('.extension-list-item');
- item.style.backgroundImage = 'url(' + extension.iconUrl + ')';
-
- this.setText_(wrapper, '.extension-title', extension.name);
- this.setText_(wrapper, '.extension-version', extension.version);
- this.setText_(wrapper, '.location-text', extension.locationText || '');
- this.setText_(wrapper, '.blacklist-text', extension.blacklistText || '');
- this.setText_(wrapper, '.extension-description', extension.description);
-
- // The 'allow in incognito' checkbox.
- this.updateVisibility_(wrapper, '.incognito-control',
- isActive && this.incognitoAvailable_,
- function(item) {
- var incognito = item.querySelector('input');
- incognito.disabled = !extension.incognitoAccess.isEnabled;
- incognito.checked = extension.incognitoAccess.isActive;
- });
- var showButterBar = isActive &&
- extension.incognitoAccess.isActive &&
- extension.type != ExtensionType.HOSTED_APP;
- // The 'allow in incognito' butter bar.
- this.updateVisibility_(wrapper, '.butter-bar', showButterBar);
-
- // The 'collect errors' checkbox. This should only be visible if the
- // error console is enabled - we can detect this by the existence of the
- // |errorCollectionEnabled| property.
- this.updateVisibility_(
- wrapper, '.error-collection-control',
- isActive && extension.errorCollection.isEnabled,
- function(item) {
- item.querySelector('input').checked =
- extension.errorCollection.isActive;
- });
-
- // The 'allow on all urls' checkbox. This should only be visible if
- // active script restrictions are enabled. If they are not enabled, no
- // extensions should want all urls.
- this.updateVisibility_(
- wrapper, '.all-urls-control',
- isActive && extension.runOnAllUrls.isEnabled,
- function(item) {
- item.querySelector('input').checked = extension.runOnAllUrls.isActive;
- });
-
- // The 'allow file:// access' checkbox.
- this.updateVisibility_(wrapper, '.file-access-control',
- isActive && extension.fileAccess.isEnabled,
- function(item) {
- item.querySelector('input').checked = extension.fileAccess.isActive;
- });
-
- // The 'Options' button or link, depending on its behaviour.
- var optionsEnabled = isActive && !!extension.optionsPage;
- this.updateVisibility_(wrapper, '.options-link', optionsEnabled &&
- extension.optionsPage.openInTab);
- this.updateVisibility_(wrapper, '.options-button', optionsEnabled &&
- !extension.optionsPage.openInTab);
-
- // The 'View in Web Store/View Web Site' link.
- var siteLinkEnabled = !!extension.homePage.url &&
- !this.enableAppInfoDialog_;
- this.updateVisibility_(wrapper, '.site-link', siteLinkEnabled,
- function(item) {
- item.href = extension.homePage.url;
- item.textContent = loadTimeData.getString(
- extension.homePage.specified ? 'extensionSettingsVisitWebsite' :
- 'extensionSettingsVisitWebStore');
- });
-
- var isUnpacked =
- extension.location == chrome.developerPrivate.Location.UNPACKED;
- // The 'Reload' link.
- this.updateVisibility_(wrapper, '.reload-link', isActive && isUnpacked);
-
- // The 'Launch' link.
- this.updateVisibility_(
- wrapper, '.launch-link',
- isUnpacked && extension.type == ExtensionType.PLATFORM_APP &&
- isActive);
-
- // The 'Errors' link.
- var hasErrors = extension.runtimeErrors.length > 0 ||
- extension.manifestErrors.length > 0;
- this.updateVisibility_(wrapper, '.errors-link', hasErrors,
- function(item) {
- var Level = chrome.developerPrivate.ErrorLevel;
-
- var map = {};
- map[Level.LOG] = {weight: 0, name: 'extension-error-info-icon'};
- map[Level.WARN] = {weight: 1, name: 'extension-error-warning-icon'};
- map[Level.ERROR] = {weight: 2, name: 'extension-error-fatal-icon'};
-
- // Find the highest severity of all the errors; manifest errors all have
- // a 'warning' level severity.
- var highestSeverity = extension.runtimeErrors.reduce(
- function(prev, error) {
- return map[error.severity].weight > map[prev].weight ?
- error.severity : prev;
- }, extension.manifestErrors.length ? Level.WARN : Level.LOG);
-
- // Adjust the class on the icon.
- var icon = item.querySelector('.extension-error-icon');
- // TODO(hcarmona): Populate alt text with a proper description since
- // this icon conveys the severity of the error. (info, warning, fatal).
- icon.alt = '';
- icon.className = 'extension-error-icon'; // Remove other classes.
- icon.classList.add(map[highestSeverity].name);
- });
-
- // The 'Reload' terminated link.
- var isTerminated =
- extension.state == chrome.developerPrivate.ExtensionState.TERMINATED;
- this.updateVisibility_(wrapper, '.terminated-reload-link', isTerminated);
-
- // The 'Repair' corrupted link.
- var canRepair = !isTerminated &&
- extension.disableReasons.corruptInstall &&
- extension.location ==
- chrome.developerPrivate.Location.FROM_STORE;
- this.updateVisibility_(wrapper, '.corrupted-repair-button', canRepair);
-
- // The 'Enabled' checkbox.
- var isOK = !isTerminated && !canRepair;
- this.updateVisibility_(wrapper, '.enable-checkbox', isOK, function(item) {
- var enableCheckboxDisabled =
- !extension.userMayModify ||
- extension.disableReasons.suspiciousInstall ||
- extension.disableReasons.corruptInstall ||
- extension.disableReasons.updateRequired ||
- extension.dependentExtensions.length > 0 ||
- extension.state ==
- chrome.developerPrivate.ExtensionState.BLACKLISTED;
- item.querySelector('input').disabled = enableCheckboxDisabled;
- item.querySelector('input').checked = isActive;
- });
-
- // Indicator for extensions controlled by policy.
- var controlNode = wrapper.querySelector('.enable-controls');
- var indicator =
- controlNode.querySelector('.controlled-extension-indicator');
- var needsIndicator = isOK && extension.controlledInfo;
-
- if (needsIndicator && !indicator) {
- indicator = new cr.ui.ControlledIndicator();
- indicator.classList.add('controlled-extension-indicator');
- var ControllerType = chrome.developerPrivate.ControllerType;
- var controlledByStr = '';
- switch (extension.controlledInfo.type) {
- case ControllerType.POLICY:
- controlledByStr = 'policy';
- break;
- case ControllerType.CHILD_CUSTODIAN:
- controlledByStr = 'child-custodian';
- break;
- case ControllerType.SUPERVISED_USER_CUSTODIAN:
- controlledByStr = 'supervised-user-custodian';
- break;
- }
- indicator.setAttribute('controlled-by', controlledByStr);
- var text = extension.controlledInfo.text;
- indicator.setAttribute('text' + controlledByStr, text);
- indicator.image.setAttribute('aria-label', text);
- controlNode.appendChild(indicator);
- wrapper.setupColumn('remove-enterprise', '[controlled-by] div');
- } else if (!needsIndicator && indicator) {
- controlNode.removeChild(indicator);
- }
-
- // Developer mode ////////////////////////////////////////////////////////
-
- // First we have the id.
- var idLabel = wrapper.querySelector('.extension-id');
- idLabel.textContent = ' ' + extension.id;
-
- // Then the path, if provided by unpacked extension.
- this.updateVisibility_(wrapper, '.load-path', isUnpacked,
- function(item) {
- item.querySelector('a:first-of-type').textContent =
- ' ' + extension.prettifiedPath;
- });
-
- // Then the 'managed, cannot uninstall/disable' message.
- // We would like to hide managed installed message since this
- // extension is disabled.
- var isRequired =
- !extension.userMayModify || extension.mustRemainInstalled;
- this.updateVisibility_(wrapper, '.managed-message', isRequired &&
- !extension.disableReasons.updateRequired);
-
- // Then the 'This isn't from the webstore, looks suspicious' message.
- var isSuspicious = extension.disableReasons.suspiciousInstall;
- this.updateVisibility_(wrapper, '.suspicious-install-message',
- !isRequired && isSuspicious);
-
- // Then the 'This is a corrupt extension' message.
- this.updateVisibility_(wrapper, '.corrupt-install-message', !isRequired &&
- extension.disableReasons.corruptInstall);
-
- // Then the 'An update required by enterprise policy' message. Note that
- // a force-installed extension might be disabled due to being outdated
- // as well.
- this.updateVisibility_(wrapper, '.update-required-message',
- extension.disableReasons.updateRequired);
-
- // The 'following extensions depend on this extension' list.
- var hasDependents = extension.dependentExtensions.length > 0;
- wrapper.classList.toggle('developer-extras', hasDependents);
- this.updateVisibility_(wrapper, '.dependent-extensions-message',
- hasDependents, function(item) {
- var dependentList = item.querySelector('ul');
- dependentList.textContent = '';
- extension.dependentExtensions.forEach(function(dependentExtension) {
- var depNode = cloneTemplate('dependent-list-item');
- depNode.querySelector('.dep-extension-title').textContent =
- dependentExtension.name;
- depNode.querySelector('.dep-extension-id').textContent =
- dependentExtension.id;
- dependentList.appendChild(depNode);
- }, this);
- }.bind(this));
-
- // The active views.
- this.updateVisibility_(wrapper, '.active-views',
- extension.views.length > 0, function(item) {
- var link = item.querySelector('a');
-
- // Link needs to be an only child before the list is updated.
- while (link.nextElementSibling)
- item.removeChild(link.nextElementSibling);
-
- // Link needs to be cleaned up if it was used before.
- link.textContent = '';
- if (link.clickHandler)
- link.removeEventListener('click', link.clickHandler);
-
- extension.views.forEach(function(view, i) {
- if (view.type == chrome.developerPrivate.ViewType.EXTENSION_DIALOG ||
- view.type == chrome.developerPrivate.ViewType.EXTENSION_POPUP) {
- return;
- }
- var displayName;
- if (view.url.startsWith('chrome-extension://')) {
- var pathOffset = 'chrome-extension://'.length + 32 + 1;
- displayName = view.url.substring(pathOffset);
- if (displayName == '_generated_background_page.html')
- displayName = loadTimeData.getString('backgroundPage');
- } else {
- displayName = view.url;
- }
- var label = displayName +
- (view.incognito ?
- ' ' + loadTimeData.getString('viewIncognito') : '') +
- (view.renderProcessId == -1 ?
- ' ' + loadTimeData.getString('viewInactive') : '') +
- (view.isIframe ?
- ' ' + loadTimeData.getString('viewIframe') : '');
- link.textContent = label;
- link.clickHandler = function(e) {
- chrome.developerPrivate.openDevTools({
- extensionId: extension.id,
- renderProcessId: view.renderProcessId,
- renderViewId: view.renderViewId,
- incognito: view.incognito
- });
- };
- link.addEventListener('click', link.clickHandler);
-
- if (i < extension.views.length - 1) {
- link = link.cloneNode(true);
- item.appendChild(link);
- }
-
- wrapper.setupColumn('activeView', '.active-views a:last-of-type');
- });
- });
-
- // The extension warnings (describing runtime issues).
- this.updateVisibility_(wrapper, '.extension-warnings',
- extension.runtimeWarnings.length > 0,
- function(item) {
- var warningList = item.querySelector('ul');
- warningList.textContent = '';
- extension.runtimeWarnings.forEach(function(warning) {
- var li = document.createElement('li');
- warningList.appendChild(li).innerText = warning;
- });
- });
-
- // Install warnings.
- this.updateVisibility_(wrapper, '.install-warnings',
- extension.installWarnings.length > 0,
- function(item) {
- var installWarningList = item.querySelector('ul');
- installWarningList.textContent = '';
- if (extension.installWarnings) {
- extension.installWarnings.forEach(function(warning) {
- var li = document.createElement('li');
- li.innerText = warning;
- installWarningList.appendChild(li);
- });
- }
- });
-
- if (location.hash.substr(1) == extension.id) {
- // Scroll beneath the fixed header so that the extension is not
- // obscured.
- var topScroll = wrapper.offsetTop - $('page-header').offsetHeight;
- var pad = parseInt(window.getComputedStyle(wrapper).marginTop, 10);
- if (!isNaN(pad))
- topScroll -= pad / 2;
- setScrollTopForDocument(document, topScroll);
- }
- },
-
- /**
- * Updates an element's textContent.
- * @param {Node} node Ancestor of the element specified by |query|.
- * @param {string} query A query to select an element in |node|.
- * @param {string} textContent
- * @private
- */
- setText_: function(node, query, textContent) {
- node.querySelector(query).textContent = textContent;
- },
-
- /**
- * Updates an element's visibility and calls |shownCallback| if it is
- * visible.
- * @param {Node} node Ancestor of the element specified by |query|.
- * @param {string} query A query to select an element in |node|.
- * @param {boolean} visible Whether the element should be visible or not.
- * @param {function(Element)=} opt_shownCallback Callback if the element is
- * visible. The element passed in will be the element specified by
- * |query|.
- * @private
- */
- updateVisibility_: function(node, query, visible, opt_shownCallback) {
- var element = assertInstanceof(node.querySelector(query), Element);
- element.hidden = !visible;
- if (visible && opt_shownCallback)
- opt_shownCallback(element);
- },
-
- /**
- * Opens the extension options overlay for the extension with the given id.
- * @param {string} extensionId The id of extension whose options page should
- * be displayed.
- * @param {boolean} scroll Whether the page should scroll to the extension
- * @private
- */
- showEmbeddedExtensionOptions_: function(extensionId, scroll) {
- if (this.optionsShown_)
- return;
-
- // Get the extension from the given id.
- var extension = this.extensions_.filter(function(extension) {
- return extension.state ==
- chrome.developerPrivate.ExtensionState.ENABLED &&
- extension.id == extensionId;
- })[0];
-
- if (!extension)
- return;
-
- if (scroll)
- this.scrollToWrapper_(extensionId);
-
- // Add the options query string. Corner case: the 'options' query string
- // will clobber the 'id' query string if the options link is clicked when
- // 'id' is in the URL, or if both query strings are in the URL.
- window.history.replaceState({}, '', '/?options=' + extensionId);
-
- var overlay = extensions.ExtensionOptionsOverlay.getInstance();
- var shownCallback = function() {
- // This overlay doesn't get focused automatically as <extensionoptions>
- // is created after the overlay is shown.
- if (cr.ui.FocusOutlineManager.forDocument(document).visible)
- overlay.setInitialFocus();
- };
- overlay.setExtensionAndShow(extensionId, extension.name,
- extension.iconUrl, shownCallback);
- this.optionsShown_ = true;
-
- var self = this;
- $('overlay').addEventListener('cancelOverlay', function f() {
- self.optionsShown_ = false;
- $('overlay').removeEventListener('cancelOverlay', f);
-
- // Remove the options query string.
- window.history.replaceState({}, '', '/');
- });
-
- // TODO(dbeam): why do we need to focus <extensionoptions> before and
- // after its showing animation? Makes very little sense to me.
- overlay.setInitialFocus();
- },
-
- /**
- * Hides the extension options overlay for the extension with id
- * |extensionId|. If there is an overlay showing for a different extension,
- * nothing happens.
- * @param {string} extensionId ID of the extension to hide.
- * @private
- */
- hideEmbeddedExtensionOptions_: function(extensionId) {
- if (!this.optionsShown_)
- return;
-
- var overlay = extensions.ExtensionOptionsOverlay.getInstance();
- if (overlay.getExtensionId() == extensionId)
- overlay.close();
- },
-
- /**
- * Updates or creates a wrapper for |extension|.
- * @param {!chrome.developerPrivate.ExtensionInfo} extension The information
- * about the extension to update.
- * @private
- */
- updateOrCreateWrapper_: function(extension) {
- var currIndex = this.getIndexOfExtension_(extension.id);
- if (currIndex != -1) {
- // If there is a current version of the extension, update it with the
- // new version.
- this.extensions_[currIndex] = extension;
- } else {
- // If the extension isn't found, push it back and sort. Technically, we
- // could optimize by inserting it at the right location, but since this
- // only happens on extension install, it's not worth it.
- this.extensions_.push(extension);
- this.extensions_.sort(compareExtensions);
- }
-
- var wrapper = /**@type {ExtensionWrapper} */ ($(extension.id));
- if (wrapper) {
- this.updateWrapper_(extension, wrapper);
- } else {
- var nextExt = this.extensions_[this.extensions_.indexOf(extension) + 1];
- this.createWrapper_(extension, nextExt ? $(nextExt.id) : null);
- }
- }
- };
-
- return {
- ExtensionList: ExtensionList,
- ExtensionListDelegate: ExtensionListDelegate
- };
-});
diff --git a/chromium/chrome/browser/resources/extensions/extension_load_error.css b/chromium/chrome/browser/resources/extensions/extension_load_error.css
deleted file mode 100644
index 620eed10936..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_load_error.css
+++ /dev/null
@@ -1,50 +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. */
-
-#extension-load-error {
- -webkit-margin-end: 20px;
- -webkit-padding-end: 3px;
- -webkit-padding-start: 10px;
- background-color: rgba(255, 249, 221, 1);
- border-radius: 7px;
- display: flex;
- flex-direction: column;
- font-size: 1.1em;
- margin-top: 10px;
- padding-bottom: 10px;
-}
-
-#extension-load-error h2 {
- font-size: 14px;
- font-weight: bold;
-}
-
-#extension-load-error-message {
- margin-top: 5px;
-}
-
-#extension-load-error-manifest {
- background-color: rgba(255, 250, 240, 1);
- margin-bottom: 10px;
- margin-top: 10px;
- max-height: 100px;
-}
-
-#extension-load-error-manifest .extension-code-highlighted-source {
- background-color: pink;
-}
-
-#extension-load-error-controls {
- align-self: flex-end;
-}
-
-#extension-load-error-additional > span {
- font-size: 12px;
- font-weight: bold;
-}
-
-#extension-load-error-additional > li {
- margin-bottom: 0;
- margin-top: 3px;
-}
diff --git a/chromium/chrome/browser/resources/extensions/extension_load_error.html b/chromium/chrome/browser/resources/extensions/extension_load_error.html
deleted file mode 100644
index 8823bfbfea7..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_load_error.html
+++ /dev/null
@@ -1,27 +0,0 @@
-<!doctype html>
-<!--
-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.
--->
-<div id="extension-load-error" hidden>
- <h2>$i18n{extensionLoadErrorHeading}</h2>
- <div id="extension-load-error-message">
- <span>$i18n{extensionLoadErrorMessage}</span>
- <span id="extension-load-error-path"></span>
- </div>
- <span id="extension-load-error-reason"></span>
- <div id="extension-load-error-manifest" class="extension-code"></div>
- <div id="extension-load-error-controls">
- <button id="extension-load-error-retry-button">
- $i18n{extensionLoadErrorRetry}
- </button>
- <button id="extension-load-error-give-up-button">
- $i18n{extensionLoadErrorGiveUp}
- </button>
- </div>
- <div id="extension-load-error-additional" hidden>
- <span>$i18n{extensionLoadAdditionalFailures}</span>
- <ul></ul>
- </div>
-</div>
diff --git a/chromium/chrome/browser/resources/extensions/extension_loader.js b/chromium/chrome/browser/resources/extensions/extension_loader.js
deleted file mode 100644
index 5c03d50e3c5..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_loader.js
+++ /dev/null
@@ -1,234 +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.
-
-cr.define('extensions', function() {
- 'use strict';
-
- /**
- * Construct an ExtensionLoadError around the given |div|.
- * @param {HTMLDivElement} div The HTML div for the extension load error.
- * @constructor
- * @extends {HTMLDivElement}
- */
- function ExtensionLoadError(div) {
- div.__proto__ = ExtensionLoadError.prototype;
- /** @type {ExtensionLoadError} */ (div).init();
- return div;
- }
-
- /**
- * Construct a Failure.
- * @param {string} filePath The path to the unpacked extension.
- * @param {string} error The reason the extension failed to load.
- * @param {ExtensionHighlight} manifest Three 'highlight' strings in
- * |manifest| represent three portions of the file's content to display -
- * the portion which is most relevant and should be emphasized
- * (highlight), and the parts both before and after this portion. These
- * may be empty.
- * @param {HTMLLIElement} listElement The HTML element used for displaying the
- * failure path for the additional failures UI.
- * @constructor
- * @extends {HTMLDivElement}
- */
- function Failure(filePath, error, manifest, listElement) {
- this.path = filePath;
- this.error = error;
- this.manifest = manifest;
- this.listElement = listElement;
- }
-
- ExtensionLoadError.prototype = {
- __proto__: HTMLDivElement.prototype,
-
- /**
- * Initialize the ExtensionLoadError div.
- */
- init: function() {
- /**
- * The element which displays the path of the extension.
- * @type {HTMLElement}
- * @private
- */
- this.path_ = /** @type {HTMLElement} */(
- this.querySelector('#extension-load-error-path'));
-
- /**
- * The element which displays the reason the extension failed to load.
- * @type {HTMLElement}
- * @private
- */
- this.reason_ = /** @type {HTMLElement} */(
- this.querySelector('#extension-load-error-reason'));
-
- /**
- * The element which displays the manifest code.
- * @type {extensions.ExtensionCode}
- * @private
- */
- this.manifest_ = new extensions.ExtensionCode(
- this.querySelector('#extension-load-error-manifest'));
-
- /**
- * The element which displays information about additional errors.
- * @type {HTMLElement}
- * @private
- */
- this.additional_ = /** @type {HTMLUListElement} */(
- this.querySelector('#extension-load-error-additional'));
- this.additional_.list = this.additional_.getElementsByTagName('ul')[0];
-
- /**
- * An array of Failures for keeping track of multiple active failures.
- * @type {Array<Failure>}
- * @private
- */
- this.failures_ = [];
-
- this.querySelector('#extension-load-error-retry-button').addEventListener(
- 'click', function(e) {
- chrome.send('extensionLoaderRetry');
- this.remove_();
- }.bind(this));
-
- this.querySelector('#extension-load-error-give-up-button').
- addEventListener('click', function(e) {
- chrome.send('extensionLoaderIgnoreFailure');
- this.remove_();
- }.bind(this));
-
- chrome.send('extensionLoaderDisplayFailures');
- },
-
- /**
- * Add a failure to failures_ array. If there is already a displayed
- * failure, display the additional failures element.
- * @param {Array<Object>} failures Array of failures containing paths,
- * errors, and manifests.
- * @private
- */
- add_: function(failures) {
- // If a failure is already being displayed, unhide the last item.
- if (this.failures_.length > 0)
- this.failures_[this.failures_.length - 1].listElement.hidden = false;
- failures.forEach(function(failure) {
- var listItem = /** @type {HTMLLIElement} */(
- document.createElement('li'));
- listItem.textContent = failure.path;
- this.additional_.list.appendChild(listItem);
- this.failures_.push(new Failure(failure.path,
- failure.error,
- failure.manifest,
- listItem));
- }.bind(this));
- // Hide the last item because the UI is displaying its information.
- this.failures_[this.failures_.length - 1].listElement.hidden = true;
- this.show_();
- },
-
- /**
- * Remove a failure from |failures_| array. If this was the last failure,
- * hide the error UI. If this was the last additional failure, hide
- * the additional failures UI.
- * @private
- */
- remove_: function() {
- this.additional_.list.removeChild(
- this.failures_[this.failures_.length - 1].listElement);
- this.failures_.pop();
- if (this.failures_.length > 0) {
- this.failures_[this.failures_.length - 1].listElement.hidden = true;
- this.show_();
- } else {
- this.hidden = true;
- }
- },
-
- /**
- * Display the load error to the user. The last failure gets its manifest
- * and error displayed, while additional failures have their path names
- * displayed in the additional failures element.
- * @private
- */
- show_: function() {
- assert(this.failures_.length >= 1);
- var failure = this.failures_[this.failures_.length - 1];
- this.path_.textContent = failure.path;
- this.reason_.textContent = failure.error;
-
- failure.manifest.message = failure.error;
- this.manifest_.populate(
- failure.manifest,
- loadTimeData.getString('extensionLoadCouldNotLoadManifest'));
- this.hidden = false;
- this.manifest_.scrollToError();
-
- this.additional_.hidden = this.failures_.length == 1;
- }
- };
-
- /**
- * The ExtensionLoader is the class in charge of loading unpacked extensions.
- * @constructor
- */
- function ExtensionLoader() {
- /**
- * The ExtensionLoadError to show any errors from loading an unpacked
- * extension.
- * @type {ExtensionLoadError}
- * @private
- */
- this.loadError_ = new ExtensionLoadError(
- /** @type {HTMLDivElement} */($('extension-load-error')));
- }
-
- cr.addSingletonGetter(ExtensionLoader);
-
- ExtensionLoader.prototype = {
- /**
- * Whether or not we are currently loading an unpacked extension.
- * @private {boolean}
- */
- isLoading_: false,
-
- /**
- * Begin the sequence of loading an unpacked extension. If an error is
- * encountered, this object will get notified via notifyFailed().
- */
- loadUnpacked: function() {
- if (this.isLoading_) // Only one running load at a time.
- return;
- this.isLoading_ = true;
- chrome.developerPrivate.loadUnpacked({failQuietly: true}, function() {
- // Check lastError to avoid the log, but don't do anything with it -
- // error-handling is done on the C++ side.
- var lastError = chrome.runtime.lastError;
- this.isLoading_ = false;
- }.bind(this));
- },
-
- /**
- * Notify the ExtensionLoader that loading an unpacked extension failed.
- * Add the failure to failures_ and show the ExtensionLoadError.
- * @param {Array<Object>} failures Array of failures containing paths,
- * errors, and manifests.
- */
- notifyFailed: function(failures) {
- this.loadError_.add_(failures);
- },
- };
-
- /**
- * A static forwarding function for ExtensionLoader.notifyFailed.
- * @param {Array<Object>} failures Array of failures containing paths,
- * errors, and manifests.
- * @see ExtensionLoader.notifyFailed
- */
- ExtensionLoader.notifyLoadFailed = function(failures) {
- ExtensionLoader.getInstance().notifyFailed(failures);
- };
-
- return {
- ExtensionLoader: ExtensionLoader
- };
-});
diff --git a/chromium/chrome/browser/resources/extensions/extension_options_overlay.css b/chromium/chrome/browser/resources/extensions/extension_options_overlay.css
deleted file mode 100644
index 5492611a000..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_options_overlay.css
+++ /dev/null
@@ -1,28 +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. */
-
-#extension-options-overlay {
- overflow: hidden;
-}
-
-#extension-options-overlay-header {
- align-items: center;
- border-bottom: solid lightgray 1px;
- display: flex;
- position: relative;
-}
-
-#extension-options-overlay-icon {
- padding: 8px;
-}
-
-#extension-options-overlay-icon {
- height: 32px;
- width: 32px;
-}
-
-#extension-options-overlay-title {
- /* Cancel left padding to line up with the icon. */
- padding-left: 0;
-}
diff --git a/chromium/chrome/browser/resources/extensions/extension_options_overlay.html b/chromium/chrome/browser/resources/extensions/extension_options_overlay.html
deleted file mode 100644
index e5ee0b97885..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_options_overlay.html
+++ /dev/null
@@ -1,13 +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.
--->
-<div id="extension-options-overlay" class="page">
- <div class="close-button"></div>
- <div id="extension-options-overlay-header">
- <img id="extension-options-overlay-icon" aria-hidden="true">
- <h1 id="extension-options-overlay-title"></h1>
- </div>
- <div id="extension-options-overlay-guest"></div>
-</div>
diff --git a/chromium/chrome/browser/resources/extensions/extension_options_overlay.js b/chromium/chrome/browser/resources/extensions/extension_options_overlay.js
deleted file mode 100644
index 73aac3ed618..00000000000
--- a/chromium/chrome/browser/resources/extensions/extension_options_overlay.js
+++ /dev/null
@@ -1,257 +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.
-
-// Returns the width of a scrollbar in logical pixels.
-function getScrollbarWidth() {
- // Create nested divs with scrollbars.
- var outer = document.createElement('div');
- outer.style.width = '100px';
- outer.style.overflow = 'scroll';
- outer.style.visibility = 'hidden';
- document.body.appendChild(outer);
- var inner = document.createElement('div');
- inner.style.width = '101px';
- outer.appendChild(inner);
-
- // The outer div's |clientWidth| and |offsetWidth| differ only by the width of
- // the vertical scrollbar.
- var scrollbarWidth = outer.offsetWidth - outer.clientWidth;
- outer.parentNode.removeChild(outer);
- return scrollbarWidth;
-}
-
-cr.define('extensions', function() {
- 'use strict';
-
- /**
- * The ExtensionOptionsOverlay will show an extension's options page using
- * an <extensionoptions> element.
- * @constructor
- */
- function ExtensionOptionsOverlay() {}
-
- cr.addSingletonGetter(ExtensionOptionsOverlay);
-
- ExtensionOptionsOverlay.prototype = {
- /**
- * The function that shows the given element in the overlay.
- * @type {?function(HTMLDivElement)} Function that receives the element to
- * show in the overlay.
- * @private
- */
- showOverlay_: null,
-
- /**
- * The id of the extension that this options page display.
- * @type {string}
- * @private
- */
- extensionId_: '',
-
- /**
- * Initialize the page.
- * @param {function(HTMLDivElement)} showOverlay The function to show or
- * hide the ExtensionOptionsOverlay; this should take a single parameter
- * which is either the overlay Div if the overlay should be displayed,
- * or null if the overlay should be hidden.
- */
- initializePage: function(showOverlay) {
- var overlay = $('overlay');
-
- cr.ui.overlay.setupOverlay(overlay);
- cr.ui.overlay.globalInitialization();
- overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this));
-
- this.showOverlay_ = showOverlay;
- },
-
- setInitialFocus: function() {
- this.getExtensionOptions_().focus();
- },
-
- /**
- * @return {?Element}
- * @private
- */
- getExtensionOptions_: function() {
- return $('extension-options-overlay-guest').querySelector(
- 'extensionoptions');
- },
-
- /**
- * Handles a click on the close button.
- * @param {Event} event The click event.
- * @private
- */
- handleDismiss_: function(event) {
- this.setVisible_(false);
- var extensionoptions = this.getExtensionOptions_();
- if (extensionoptions)
- $('extension-options-overlay-guest').removeChild(extensionoptions);
-
- $('extension-options-overlay-icon').removeAttribute('src');
- },
-
- /**
- * Associate an extension with the overlay and display it.
- * @param {string} extensionId The id of the extension whose options page
- * should be displayed in the overlay.
- * @param {string} extensionName The name of the extension, which is used
- * as the header of the overlay.
- * @param {string} extensionIcon The URL of the extension's icon.
- * @param {function():void} shownCallback A function called when
- * showing completes.
- * @suppress {checkTypes}
- * TODO(vitalyp): remove the suppression after adding
- * chrome/renderer/resources/extensions/extension_options.js
- * to dependencies.
- */
- setExtensionAndShow: function(extensionId,
- extensionName,
- extensionIcon,
- shownCallback) {
- var overlay = $('extension-options-overlay');
- var overlayHeader = $('extension-options-overlay-header');
- var overlayGuest = $('extension-options-overlay-guest');
- var overlayStyle = window.getComputedStyle(overlay);
-
- $('extension-options-overlay-title').textContent = extensionName;
- $('extension-options-overlay-icon').src = extensionIcon;
-
- this.setVisible_(true);
-
- var extensionoptions = new window.ExtensionOptions();
- extensionoptions.extension = extensionId;
- this.extensionId_ = extensionId;
-
- // The <extensionoptions> content's size needs to be restricted to the
- // bounds of the overlay window. The overlay gives a minWidth and
- // maxHeight, but the maxHeight does not include our header height (title
- // and close button), so we need to subtract that to get the maxHeight
- // for the extension options.
- var maxHeight = parseInt(overlayStyle.maxHeight, 10) -
- overlayHeader.offsetHeight;
- var minWidth = parseInt(overlayStyle.minWidth, 10);
-
- extensionoptions.onclose = function() {
- cr.dispatchSimpleEvent($('overlay'), 'cancelOverlay');
- }.bind(this);
-
- // Track the current animation (used to grow/shrink the overlay content),
- // if any. Preferred size changes can fire more rapidly than the
- // animation speed, and multiple animations running at the same time has
- // undesirable effects.
- var animation = null;
-
- /**
- * Resize the overlay if the <extensionoptions> changes preferred size.
- * @param {{width: number, height: number}} evt
- */
- extensionoptions.onpreferredsizechanged = function(evt) {
- var oldOverlayWidth = parseInt(overlayStyle.width, 10);
- var oldOverlayHeight = parseInt(overlayStyle.height, 10);
- var newOverlayWidth = evt.width;
- // |evt.height| is just the new overlay guest height, and does not
- // include the overlay header height, so it needs to be added.
- var newOverlayHeight = evt.height + overlayHeader.offsetHeight;
-
- // Make room for the vertical scrollbar, if there is one.
- if (newOverlayHeight > maxHeight) {
- newOverlayWidth += getScrollbarWidth();
- }
-
- // Enforce |minWidth| and |maxHeight|.
- newOverlayWidth = Math.max(newOverlayWidth, minWidth);
- newOverlayHeight = Math.min(newOverlayHeight, maxHeight);
-
- // animationTime is the amount of time in ms that will be used to resize
- // the overlay. It is calculated by multiplying the pythagorean distance
- // between old and the new size (in px) with a constant speed of
- // 0.25 ms/px.
- var loading = document.documentElement.classList.contains('loading');
- var animationTime = loading ? 0 :
- 0.25 * Math.sqrt(Math.pow(newOverlayWidth - oldOverlayWidth, 2) +
- Math.pow(newOverlayHeight - oldOverlayHeight, 2));
-
- if (animation)
- animation.cancel();
-
- // The header height must be added to the (old and new) preferred
- // heights to get the full overlay heights.
- animation = overlay.animate([
- {width: oldOverlayWidth + 'px', height: oldOverlayHeight + 'px'},
- {width: newOverlayWidth + 'px', height: newOverlayHeight + 'px'}
- ], {
- duration: animationTime,
- delay: 0
- });
-
- animation.onfinish = function(e) {
- animation = null;
-
- // The <extensionoptions> element is ready to place back in the
- // overlay. Make sure that it's sized to take up the full width/height
- // of the overlay.
- overlayGuest.style.position = '';
- overlayGuest.style.left = '';
- overlayGuest.style.width = newOverlayWidth + 'px';
- // |newOverlayHeight| includes the header height, so it needs to be
- // subtracted to get the new guest height.
- overlayGuest.style.height =
- (newOverlayHeight - overlayHeader.offsetHeight) + 'px';
-
- if (shownCallback) {
- shownCallback();
- shownCallback = null;
- }
- };
- }.bind(this);
-
- // Move the <extensionoptions> off screen until the overlay is ready.
- overlayGuest.style.position = 'fixed';
- overlayGuest.style.left = window.outerWidth + 'px';
- // Begin rendering at the default dimensions. This is also necessary to
- // cancel any width/height set on a previous render.
- // TODO(kalman): This causes a visual jag where the overlay guest shows
- // up briefly. It would be better to render this off-screen first, then
- // swap it in place. See crbug.com/408274.
- // This may also solve crbug.com/431001 (width is 0 on initial render).
- overlayGuest.style.width = '';
- overlayGuest.style.height = '';
-
- overlayGuest.appendChild(extensionoptions);
- },
-
- /**
- * Dispatches a 'cancelOverlay' event on the $('overlay') element.
- */
- close: function() {
- cr.dispatchSimpleEvent($('overlay'), 'cancelOverlay');
- },
-
- /**
- * Returns extension id that this options page set.
- * @return {string}
- */
- getExtensionId: function() {
- return this.extensionId_;
- },
-
- /**
- * Toggles the visibility of the ExtensionOptionsOverlay.
- * @param {boolean} isVisible Whether the overlay should be visible.
- * @private
- */
- setVisible_: function(isVisible) {
- this.showOverlay_(isVisible ?
- /** @type {HTMLDivElement} */($('extension-options-overlay')) :
- null);
- }
- };
-
- // Export
- return {
- ExtensionOptionsOverlay: ExtensionOptionsOverlay
- };
-});
diff --git a/chromium/chrome/browser/resources/extensions/extensions.css b/chromium/chrome/browser/resources/extensions/extensions.css
deleted file mode 100644
index fd9e469922b..00000000000
--- a/chromium/chrome/browser/resources/extensions/extensions.css
+++ /dev/null
@@ -1,443 +0,0 @@
-/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file. */
-
-html.loading * {
- transition-duration: 0ms !important;
-}
-
-html:not(.focus-outline-visible)
-:enabled:focus:-webkit-any(input[type='checkbox'], input[type='radio']) {
- /* Cancel border-color for :focus specified in widgets.css. */
- border-color: rgba(0, 0, 0, 0.25);
-}
-
-.no-scroll {
- overflow-y: hidden;
-}
-
-#extension-settings.showing-banner {
- margin-top: 45px;
-}
-
-/* Developer mode */
-
-#dev-controls {
- -webkit-margin-end: 0;
- height: 0;
- overflow: hidden;
-}
-
-#dev-controls.animated {
- transition: height 150ms;
-}
-
-.dev-mode #dev-controls {
- border-bottom: 1px solid #eee;
-}
-
-#dev-controls > * {
- padding: 8px 3px;
-}
-
-#dev-controls .button-container {
- -webkit-padding-end: 12px;
- -webkit-padding-start: 12px;
- display: flex;
- flex-wrap: wrap;
-}
-
-#dev-controls button {
- white-space: nowrap;
-}
-
-#dev-controls .button-container button:not(:last-of-type) {
- -webkit-margin-end: 5px;
-}
-
-#dev-controls-spacer {
- flex: 1;
-}
-
-.extension-code {
- border: 1px solid #ccc;
- display: flex;
- font-family: monospace;
- overflow: auto;
- white-space: pre;
-}
-
-.extension-code > * {
- padding: 3px;
-}
-
-.extension-code-line-numbers {
- align-self: flex-start;
- background-color: rgba(240, 240, 240, 1);
- border-right: 1px solid #ccc;
- color: rgba(128, 128, 128, 1);
- flex-shrink: 0;
- text-align: right;
-}
-
-.extension-code-empty {
- background-color: #eee;
- display: inline-block;
- line-height: 100px; /* Vertically centers text and serves as min-height. */
- text-align: center;
- width: 100%;
-}
-
-.extension-details > .developer-extras > div,
-.extension-details > .permanent-warnings > div {
- margin: 5px 0;
-}
-
-.dependent-extensions-message,
-.suspicious-install-message {
- line-height: 150%;
-}
-
-#page-header {
- -webkit-padding-start: 23px;
- left: 0;
-}
-
-[dir='rtl'] #page-header {
- right: 0;
-}
-
-#page-header > .page-banner > .page-banner-gradient {
- -webkit-margin-end: 0;
-}
-
-#header-controls {
- /* Reserve enough space to match .location-text + .trash */
- min-width: 130px;
- right: 16px;
-}
-
-html[dir='rtl'] #header-controls {
- left: 16px;
- right: auto;
-}
-
-#page-header > h1::after {
- -webkit-margin-end: 0;
-}
-
-#extension-settings #page-header {
- /* These values match the .page values. */
- -webkit-margin-end: 24px;
- min-width: 576px;
-}
-
-/* Contents */
-
-#extension-settings {
- max-width: 738px;
-}
-
-#no-extensions-message {
- font-weight: bold;
-}
-
-#no-extensions {
- margin-top: 3em;
-}
-
-#suggest-gallery {
- -webkit-padding-start: 10px;
-}
-
-#footer-section {
- background: url(chrome://theme/IDR_WEBSTORE_ICON_32) no-repeat left center;
- background-size: 32px 32px;
- font-size: 1.25em;
- margin: 24px 12px 12px 12px;
-}
-
-html[dir=rtl] #footer-section {
- background: url(chrome://theme/IDR_WEBSTORE_ICON_32) no-repeat right center;
-}
-
-#footer-section > a {
- -webkit-margin-start: 42px;
- line-height: 32px;
-}
-
-.extension-list-item-wrapper {
- margin: 12px 0;
- padding: 12px;
-}
-
-.extension-list-item {
- background-repeat: no-repeat;
- background-size: 48px 48px;
- display: -webkit-box;
- min-height: 48px;
-}
-
-.extension-list-item a {
- -webkit-margin-start: 0.5em;
- display: inline-block;
-}
-
-html[dir='rtl'] .extension-list-item {
- background-position-x: 100%;
-}
-
-.extension-title {
- -webkit-padding-end: 20px;
- color: rgb(48, 57, 66);
- display: inline;
- font-size: 14px;
- font-weight: 500;
- user-select: text;
-}
-
-.inactive-extension .extension-title {
- color: inherit;
-}
-
-.extension-version {
- -webkit-padding-end: 7px;
- font-size: 13px;
- font-weight: 400;
-}
-
-.extension-description,
-.corrupt-install-message {
- -webkit-padding-end: 5px;
- font-size: 13px;
- margin: 5px 0;
- white-space: normal;
-}
-
-.corrupt-install-message {
- color: rgb(196, 42, 23);
-}
-
-.action-links {
- margin-bottom: 0.5em;
-}
-
-.action-links a {
- -webkit-margin-end: 1em;
- -webkit-margin-start: 0;
-}
-
-.action-links .errors-link {
- align-items: center;
- display: inline-flex;
- vertical-align: bottom;
-}
-
-.extension-details {
- -webkit-box-flex: 1;
- -webkit-padding-end: 7px;
- -webkit-padding-start: 60px;
- padding-top: 6px;
-}
-
-.extension-description,
-.extension-version,
-.extension-list-item-wrapper.inactive-extension .extension-details,
-.location-text,
-.blacklist-text,
-.enable-checkbox input:disabled + .enable-checkbox-text {
- color: rgb(115, 119, 122);
-}
-
-.enable-controls {
- /* Matches right: position of dev controls toggle. */
- -webkit-margin-end: 0;
- position: relative;
-}
-
-.enable-controls > .controlled-setting-indicator {
- width: 23px;
-}
-
-.enable-controls > .controlled-setting-indicator > div {
- left: 11px;
- right: 11px;
-}
-
-/* We use x[is='action-link'] here so that we get higher specifity than the
- * action link rules without resorting to the Dark Side (!IMPORTANT). */
-.terminated-reload-link[is='action-link'],
-.corrupted-repair-button[is='action-link'] {
- /* Matches width of trash. */
- -webkit-margin-end: 30px;
-}
-
-.checkbox {
- display: inline-block;
-}
-
-.enabled-text {
- font-weight: bold;
-}
-
-.extension-list-item-wrapper.inactive-extension .enabled-text,
-.extension-list-item-wrapper:not(.inactive-extension) .enable-text,
-.extension-list-item-wrapper.inactive-extension .optional-controls,
-.extension-list-item-wrapper.inactive-extension .butter-bar {
- display: none;
-}
-
-.optional-controls .checkbox {
- -webkit-margin-end: 12px;
-}
-
-.load-path > span {
- word-wrap: break-word;
-}
-
-.terminated-reload-link,
-.corrupted-repair-button {
- display: inline-block;
- padding-top: 7px;
-}
-
-.install-warnings a {
- -webkit-margin-start: 0;
-}
-
-.butter-bar,
-.install-warnings,
-.extension-warnings {
- border-radius: 3px;
- line-height: 150%;
- margin: 8px 0;
- padding: 8px 12px;
-}
-
-.butter-bar {
- background: rgb(255, 242, 153);
-}
-
-.install-warnings,
-.extension-warnings {
- background: pink;
-}
-
-.install-warnings ul,
-.extension-warnings ul {
- margin: 0;
-}
-
-.error-collection-control {
- -webkit-margin-start: 5px;
-}
-
-#extension-settings:not(.dev-mode) .developer-extras,
-#extension-settings:not(.dev-mode) .error-collection-control {
- display: none;
-}
-
-#font-measuring-div {
- /* Remove from the flow and hide. */
- position: absolute;
- visibility: hidden;
-}
-
-.extension-commands-config {
- float: right;
-}
-
-html[dir=rtl] .extension-commands-config {
- float: left;
-}
-
-/* Overlays */
-
-#overlay {
- z-index: 5;
-}
-
-#overlay .page:not(.showing) {
- display: none;
-}
-
-#drop-target-overlay {
- color: rgb(48, 57, 66);
- font-size: 18px;
- text-align: center;
-}
-
-#drop-target-overlay div {
- margin: 1em;
-}
-
-.location-text,
-.blacklist-text {
- display: block;
- width: 100px;
-}
-
-.enable-checkbox {
- /* Reserve enough space to match .location-text */
- min-width: 100px;
-}
-
-/* Trash */
-
-#extension-settings .trash {
- height: 22px;
- opacity: 0.8;
- position: relative;
- right: -8px;
- top: 6px;
- transition: opacity 200ms;
- vertical-align: top;
-}
-
-html[dir='rtl'] #extension-settings .trash {
- left: -8px;
- right: auto;
-}
-
-.extension-list-item:not(:hover) .trash:not(:focus) {
- opacity: 0;
-}
-
-.extension-list-item-wrapper.may-not-remove .trash {
- visibility: hidden;
-}
-
-/* In case the extension is policy controlled the trash icon must be hidden by
- * setting display:none rather than only setting visibility:hidden to completely
- * remove it from the layout and make space for the controlled indicator.
- * TODO(cschuet): rather than hide always replace it with something meaningful.
- */
-.extension-list-item-wrapper.controlled .trash {
- display: none;
-}
-
-/* Supervised users */
-
-.page:not(.profile-is-supervised) .profile-is-supervised-banner,
-.profile-is-supervised .more-extensions-link {
- display: none;
-}
-
-.profile-is-supervised-banner .page-banner-text {
- background-image: url(../../../../ui/webui/resources/images/warning.svg);
-}
-
-/* Sideload Wipeout */
-
-.sideload-wipeout-learn-more {
- text-decoration: none;
-}
-
-.sideload-wipeout-banner .page-banner-text {
- -webkit-padding-start: 8px;
- background-image: none;
-}
-
-.extension-highlight {
- background-color: rgba(0, 0, 0, .05);
-}
diff --git a/chromium/chrome/browser/resources/extensions/extensions.html b/chromium/chrome/browser/resources/extensions/extensions.html
deleted file mode 100644
index 40d6ce3f016..00000000000
--- a/chromium/chrome/browser/resources/extensions/extensions.html
+++ /dev/null
@@ -1,283 +0,0 @@
-<!doctype html>
-<html dir="$i18n{textdirection}" lang="$i18n{language}">
-<head>
-<meta charset="utf-8">
-<title>$i18n{extensionSettings}</title>
-
-<link rel="stylesheet" href="extensions.css">
-<link rel="stylesheet" href="extension_commands_overlay.css">
-<link rel="stylesheet" href="extension_error.css">
-<link rel="stylesheet" href="extension_error_overlay.css">
-<link rel="stylesheet" href="extension_load_error.css">
-<link rel="stylesheet" href="extension_options_overlay.css">
-<link rel="stylesheet" href="pack_extension_overlay.css">
-<link rel="stylesheet" href="chrome://resources/css/alert_overlay.css">
-<link rel="stylesheet" href="chrome://resources/css/bubble.css">
-<link rel="stylesheet" href="chrome://resources/css/bubble_button.css">
-<link rel="stylesheet" href="chrome://resources/css/controlled_indicator.css">
-<link rel="stylesheet" href="chrome://resources/css/chrome_shared.css">
-<link rel="stylesheet" href="chrome://resources/css/overlay.css">
-<link rel="stylesheet" href="chrome://resources/css/spinner.css">
-<link rel="stylesheet" href="chrome://resources/css/trash.css">
-<link rel="stylesheet" href="../uber_shared.css">
-
-<script src="chrome://resources/js/action_link.js"></script>
-<script src="chrome://resources/js/cr.js"></script>
-<script src="chrome://resources/js/event_tracker.js"></script>
-<script src="chrome://resources/js/load_time_data.js"></script>
-<script src="chrome://resources/js/util.js"></script>
-<script src="chrome://resources/js/cr/ui.js"></script>
-<script src="chrome://resources/js/cr/ui/alert_overlay.js"></script>
-<script src="chrome://resources/js/cr/ui/bubble.js"></script>
-<script src="chrome://resources/js/cr/ui/bubble_button.js"></script>
-<script src="chrome://resources/js/cr/ui/controlled_indicator.js"></script>
-<script src="chrome://resources/js/cr/ui/drag_wrapper.js"></script>
-<script src="chrome://resources/js/cr/ui/focus_manager.js"></script>
-<script src="chrome://resources/js/cr/ui/focus_outline_manager.js"></script>
-<script src="chrome://resources/js/cr/ui/node_utils.js"></script>
-<script src="chrome://resources/js/cr/ui/overlay.js"></script>
-
-<if expr="chromeos">
-<link rel="stylesheet" href="chrome://resources/css/list.css">
-<link rel="stylesheet" href="chromeos/kiosk_apps.css">
-<script src="chrome://resources/js/cr/event_target.js"></script>
-<script src="chrome://resources/js/cr/ui/array_data_model.js"></script>
-<script src="chrome://resources/js/cr/ui/list_selection_model.js"></script>
-<script src="chrome://resources/js/cr/ui/list_selection_controller.js"></script>
-<script src="chrome://resources/js/cr/ui/list_single_selection_model.js">
-</script>
-<script src="chrome://resources/js/cr/ui/list_item.js"></script>
-<script src="chrome://resources/js/cr/ui/list.js"></script>
-<script src="chrome://resources/js/promise_resolver.js"></script>
-<script src="chrome://resources/js/webui_listener_tracker.js"></script>
-</if>
-
-<script src="chrome://extensions/extensions.js"></script>
-</head>
-
-<body>
-
-<div id="overlay" class="overlay" hidden>
- <include src="extension_commands_overlay.html">
- <include src="extension_error_overlay.html">
- <include src="extension_options_overlay.html">
- <include src="pack_extension_overlay.html">
- <include src="../../../../ui/webui/resources/html/alert_overlay.html">
-<if expr="chromeos">
- <include src="chromeos/kiosk_apps.html">
- <include src="chromeos/kiosk_app_disable_bailout_confirm.html">
-</if>
- <div id="drop-target-overlay" class="page">
- <div>$i18n{extensionSettingsInstallDropTarget}</div>
- </div>
-</div>
-
-<div class="page" id="extension-settings">
- <header id="page-header">
- <h1>$i18n{extensionSettings}</h1>
- <div id="header-controls" class="header-extras">
- <div id="dev-toggle" class="checkbox">
- <label>
- <input id="toggle-dev-on" type="checkbox">
- <span>$i18n{extensionSettingsDeveloperMode}</span>
- <span id="dev-toggle-disabled-by-policy-indicator"
- class="controlled-setting-indicator"></span>
- </label>
- </div>
- </div>
- <div class="page-banner profile-is-supervised-banner">
- <div class="page-banner-gradient">
- <span class="page-banner-text">
- $i18n{extensionSettingsSupervisedUser}
- </span>
- </div>
- </div>
- </header>
- <div id="loading-spinner">
- <div class="inline-spinner"></div>
- <span>$i18n{loading}</span>
- </div>
- <div id="dev-controls" hidden>
- <div class="button-container">
- <button id="load-unpacked">
- $i18n{extensionSettingsLoadUnpackedButton}
- </button>
- <button id="pack-extension">
- $i18n{extensionSettingsPackButton}
- </button>
-<if expr="chromeos">
- <button id="add-kiosk-app" hidden>$i18n{addKioskAppButton}</button>
-</if>
- <div id="dev-controls-spacer"></div>
- <button id="update-extensions-now">
- $i18n{extensionSettingsUpdateButton}
- </button>
- </div>
- </div>
- <include src="extension_load_error.html">
- <div id="extension-list-wrapper" hidden>
- <div id="footer-section">
- <a target="_blank" class="more-extensions-link"
- i18n-values="href:extensionSettingsGetMoreExtensionsUrl">
- $i18n{extensionSettingsGetMoreExtensions}
- </a>
- <a is="action-link" class="extension-commands-config" hidden>
- $i18n{extensionSettingsCommandsLink}
- </a>
- </div>
- </div>
- <div id="no-extensions" hidden>
- <span id="no-extensions-message">$i18n{extensionSettingsNoExtensions}</span>
- <span id="suggest-gallery" class="more-extensions-link"
- i18n-values=".innerHTML:extensionSettingsSuggestGallery">
- </span>
- </div>
-</div>
-
-<span id="font-measuring-div"></span>
-
-<div id="templates" hidden>
-
- <div class="extension-list-item-wrapper">
- <div class="extension-list-item">
- <div class="extension-details">
- <div>
- <h2 class="extension-title"></h2>
- <span class="extension-version"></span>
- </div>
- <p class="corrupt-install-message"
- hidden>$i18n{extensionSettingsCorruptInstall}</p>
- <p class="extension-description"></p>
- <div class="action-links">
- <a is="action-link" class="permissions-link">
- $i18n{extensionSettingsPermissions}
- </a>
- <a is="action-link" class="options-button" hidden>
- $i18n{extensionSettingsOptions}
- </a>
- <a class="options-link" hidden>$i18n{extensionSettingsOptions}</a>
- <a class="site-link" target="_parent" hidden></a>
- <a is="action-link" class="launch-link" hidden>
- $i18n{extensionSettingsLaunch}
- </a>
- <a is="action-link" role="button" class="reload-link" hidden>
- $i18n{extensionSettingsReloadUnpacked}
- </a>
- <a is="action-link" role="button" class="errors-link">
- <img class="extension-error-icon">
- <span>$i18n{extensionErrorHeading}</span>
- </a>
- </div>
- <div class="permanent-warnings">
- <div class="extension-warnings" hidden>
- <span>$i18n{extensionSettingsWarningsTitle}</span>
- <ul></ul>
- </div>
- <div class="suspicious-install-message" hidden>
- <span>$i18n{extensionSettingsSuspiciousInstall}</span>
- <a target="_blank" class="learn-more-link" href="#"
- i18n-values="href:extensionSettingsSuspiciousInstallHelpUrl">
- $i18n{extensionSettingsLearnMore}
- </a>
- </div>
- </div>
- <div class="dependent-extensions-message" hidden>
- <span>$i18n{extensionSettingsDependentExtensions}</span>
- <ul></ul>
- </div>
- <div class="developer-extras">
- <div>
- <span>$i18n{extensionSettingsExtensionId}</span>
- <span class="extension-id"></span>
- </div>
- <div class="load-path" hidden>
- <span>$i18n{extensionSettingsExtensionPath}</span>
- <a is="action-link"></a>
- </div>
- <div class="managed-message" hidden>
- $i18n{extensionSettingsPolicyControlled}
- </div>
- <div class="update-required-message" hidden>
- $i18n{extensionSettingsUpdateRequiredBePolicy}
- </div>
- <div class="active-views" hidden>
- <span>$i18n{extensionSettingsInspectViews}</span>
- <a is="action-link"></a>
- </div>
- <div class="install-warnings" hidden>
- <span>$i18n{extensionSettingsInstallWarnings}</span>
- <ul></ul>
- </div>
- </div>
- <div class="optional-controls">
- <div class="checkbox">
- <label class="incognito-control">
- <input type="checkbox">
- <span>$i18n{extensionSettingsEnableIncognito}</span>
- </label>
- </div>
- <div class="checkbox error-collection-control" hidden>
- <label>
- <input type="checkbox">
- <span>$i18n{extensionSettingsEnableErrorCollection}</span>
- </label>
- </div>
- <div class="checkbox all-urls-control" hidden>
- <label>
- <input type="checkbox">
- <span>$i18n{extensionSettingsAllowOnAllUrls}</span>
- </label>
- </div>
- <div class="checkbox file-access-control" hidden>
- <label>
- <input type="checkbox">
- <span>$i18n{extensionSettingsAllowFileAccess}</span>
- </label>
- </div>
- </div>
- <div class="butter-bar"
- i18n-values=".innerHTML:extensionSettingsIncognitoWarning" hidden>
- </div>
- </div>
- <div class="enable-controls">
- <a is="action-link" role="button" class="terminated-reload-link" hidden>
- $i18n{extensionSettingsReloadTerminated}
- </a>
- <a is="action-link" role="button" class="corrupted-repair-button"
- hidden>
- $i18n{extensionSettingsRepairCorrupted}
- </a>
- <div class="checkbox enable-checkbox" hidden><label>
- <input type="checkbox">
- <span class="enable-checkbox-text">
- <span class="enabled-text">$i18n{extensionSettingsEnabled}</span>
- <span class="enable-text">$i18n{extensionSettingsEnable}</span>
- </span>
- </label>
- <span class="location-text"></span>
- <span class="blacklist-text"></span>
- </div>
- </div>
- </div>
- </div>
- <li class="dependent-list-item">
- <span class="dep-extension-title"></span>
- <ul>
- <li>
- <span>$i18n{extensionSettingsExtensionId}</span>
- <span class="dep-extension-id"></span>
- </li>
- </ul>
- </li>
-
-
- <include src="../../../../ui/webui/resources/html/trash.html">
- <include src="extension_error.html">
-
-</div>
-
-<script src="chrome://extensions/strings.js"></script>
-<script src="chrome://resources/js/i18n_template.js"></script>
-
-</body>
-</html>
diff --git a/chromium/chrome/browser/resources/extensions/extensions.js b/chromium/chrome/browser/resources/extensions/extensions.js
deleted file mode 100644
index b3be0624d18..00000000000
--- a/chromium/chrome/browser/resources/extensions/extensions.js
+++ /dev/null
@@ -1,461 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// <include src="../../../../ui/webui/resources/js/cr/ui/focus_row.js">
-// <include src="../../../../ui/webui/resources/js/cr/ui/focus_grid.js">
-// <include src="../md_extensions/drag_and_drop_handler.js">
-// <include src="extension_code.js">
-// <include src="extension_commands_overlay.js">
-// <include src="extension_error_overlay.js">
-// <include src="extension_focus_manager.js">
-// <include src="focus_row.js">
-// <include src="extension_list.js">
-// <include src="pack_extension_overlay.js">
-// <include src="extension_loader.js">
-// <include src="extension_options_overlay.js">
-
-// <if expr="chromeos">
-// <include src="chromeos/kiosk_apps.js">
-// </if>
-
-cr.define('extensions', function() {
- var ExtensionList = extensions.ExtensionList;
-
- /**
- * ExtensionSettings class
- * @class
- * @constructor
- * @implements {extensions.ExtensionListDelegate}
- */
- function ExtensionSettings() {}
-
- cr.addSingletonGetter(ExtensionSettings);
-
- ExtensionSettings.prototype = {
- /**
- * The drag-drop wrapper for installing external Extensions, if available.
- * null if external Extension installation is not available.
- * @type {cr.ui.DragWrapper}
- * @private
- */
- dragWrapper_: null,
-
- /**
- * True if drag-drop is both available and currently enabled - it can be
- * temporarily disabled while overlays are showing.
- * @type {boolean}
- * @private
- */
- dragEnabled_: false,
-
- /**
- * True if the page has finished the initial load.
- * @private {boolean}
- */
- hasLoaded_: false,
-
- /**
- * Perform initial setup.
- */
- initialize: function() {
- this.setLoading_(true);
- cr.ui.FocusOutlineManager.forDocument(document);
- measureCheckboxStrings();
-
- var extensionList = new ExtensionList(this);
- extensionList.id = 'extension-settings-list';
- var wrapper = $('extension-list-wrapper');
- wrapper.insertBefore(extensionList, wrapper.firstChild);
-
- // Get the initial profile state, and register to be notified of any
- // future changes.
- chrome.developerPrivate.getProfileConfiguration(
- this.update_.bind(this));
- chrome.developerPrivate.onProfileStateChanged.addListener(
- this.update_.bind(this));
-
- var extensionLoader = extensions.ExtensionLoader.getInstance();
-
- $('toggle-dev-on').addEventListener('change', function(e) {
- this.updateDevControlsVisibility_(true);
- chrome.developerPrivate.updateProfileConfiguration(
- {inDeveloperMode: e.target.checked});
- var suffix = $('toggle-dev-on').checked ? 'Enabled' : 'Disabled';
- chrome.send('metricsHandler:recordAction',
- ['Options_ToggleDeveloperMode_' + suffix]);
- }.bind(this));
-
- window.addEventListener('resize', function() {
- this.updateDevControlsVisibility_(false);
- }.bind(this));
-
- // Set up the three dev mode buttons (load unpacked, pack and update).
- $('load-unpacked').addEventListener('click', function(e) {
- chrome.send('metricsHandler:recordAction',
- ['Options_LoadUnpackedExtension']);
- extensionLoader.loadUnpacked();
- });
- $('pack-extension').addEventListener('click',
- this.handlePackExtension_.bind(this));
- $('update-extensions-now').addEventListener('click',
- this.handleUpdateExtensionNow_.bind(this));
-
- var dragTarget = document.documentElement;
- /** @private {extensions.DragAndDropHandler} */
- this.dragWrapperHandler_ =
- new extensions.DragAndDropHandler(true, false, dragTarget);
- dragTarget.addEventListener('extension-drag-started', function() {
- ExtensionSettings.showOverlay($('drop-target-overlay'));
- });
- dragTarget.addEventListener('extension-drag-ended', function() {
- var overlay = ExtensionSettings.getCurrentOverlay();
- if (overlay && overlay.id === 'drop-target-overlay')
- ExtensionSettings.showOverlay(null);
- });
- this.dragWrapper_ =
- new cr.ui.DragWrapper(dragTarget, this.dragWrapperHandler_);
-
- extensions.PackExtensionOverlay.getInstance().initializePage();
-
- // Hook up the configure commands link to the overlay.
- var link = document.querySelector('.extension-commands-config');
- link.addEventListener('click',
- this.handleExtensionCommandsConfig_.bind(this));
-
- // Initialize the Commands overlay.
- extensions.ExtensionCommandsOverlay.getInstance().initializePage();
-
- extensions.ExtensionErrorOverlay.getInstance().initializePage(
- extensions.ExtensionSettings.showOverlay);
-
- extensions.ExtensionOptionsOverlay.getInstance().initializePage(
- extensions.ExtensionSettings.showOverlay);
-
- // Add user action logging for bottom links.
- var moreExtensionLink =
- document.getElementsByClassName('more-extensions-link');
- for (var i = 0; i < moreExtensionLink.length; i++) {
- moreExtensionLink[i].addEventListener('click', function(e) {
- chrome.send('metricsHandler:recordAction',
- ['Options_GetMoreExtensions']);
- });
- }
-
- // Initialize the kiosk overlay.
- if (cr.isChromeOS) {
- var kioskOverlay = extensions.KioskAppsOverlay.getInstance();
- kioskOverlay.initialize();
-
- $('add-kiosk-app').addEventListener('click', function() {
- ExtensionSettings.showOverlay($('kiosk-apps-page'));
- kioskOverlay.didShowPage();
- });
-
- extensions.KioskDisableBailoutConfirm.getInstance().initialize();
- }
-
- cr.ui.overlay.setupOverlay($('drop-target-overlay'));
- cr.ui.overlay.globalInitialization();
-
- extensions.ExtensionFocusManager.getInstance().initialize();
-
- var path = document.location.pathname;
- if (path.length > 1) {
- // Skip starting slash and remove trailing slash (if any).
- var overlayName = path.slice(1).replace(/\/$/, '');
- if (overlayName == 'configureCommands')
- this.showExtensionCommandsConfigUi_();
- }
- },
-
- /**
- * [Re]-Populates the page with data representing the current state of
- * installed extensions.
- * @param {chrome.developerPrivate.ProfileInfo} profileInfo
- * @private
- */
- update_: function(profileInfo) {
- // We only set the page to be loading if we haven't already finished an
- // initial load, because otherwise the updates are all incremental and
- // don't need to display the interstitial spinner.
- if (!this.hasLoaded_)
- this.setLoading_(true);
-
- /** @const */
- var supervised = profileInfo.isSupervised;
- var developerModeControlledByPolicy =
- profileInfo.isDeveloperModeControlledByPolicy;
-
- var pageDiv = $('extension-settings');
- pageDiv.classList.toggle('profile-is-supervised', supervised);
- pageDiv.classList.toggle('showing-banner', supervised);
-
- var devControlsCheckbox = $('toggle-dev-on');
- devControlsCheckbox.checked = profileInfo.inDeveloperMode;
- devControlsCheckbox.disabled =
- supervised || developerModeControlledByPolicy;
-
- // This is necessary e.g. if developer mode is now disabled by policy
- // but extension developer tools were visible.
- this.updateDevControlsVisibility_(false);
- this.updateDevToggleControlledIndicator_(developerModeControlledByPolicy);
-
- $('load-unpacked').disabled = !profileInfo.canLoadUnpacked;
- var extensionList = /** @type {extensions.ExtensionList} */ (
- $('extension-settings-list'));
- extensionList.updateExtensionsData(
- profileInfo.isIncognitoAvailable,
- profileInfo.appInfoDialogEnabled).then(function() {
- if (!this.hasLoaded_) {
- this.hasLoaded_ = true;
- this.setLoading_(false);
- }
- this.onExtensionCountChanged();
- }.bind(this));
- },
-
- /**
- * Shows or hides the 'controlled by policy' indicator on the dev-toggle
- * checkbox.
- * @param {boolean} devModeControlledByPolicy true if the indicator
- * should be showing.
- * @private
- */
- updateDevToggleControlledIndicator_: function(devModeControlledByPolicy) {
- var controlledIndicator = document.querySelector(
- '#dev-toggle .controlled-setting-indicator');
-
- if (!(controlledIndicator instanceof cr.ui.ControlledIndicator))
- cr.ui.ControlledIndicator.decorate(controlledIndicator);
-
- // We control the visibility of the ControlledIndicator by setting or
- // removing the 'controlled-by' attribute (see controlled_indicator.css).
- var isVisible = controlledIndicator.getAttribute('controlled-by');
- if (devModeControlledByPolicy && !isVisible) {
- var controlledBy = 'policy';
- controlledIndicator.setAttribute(
- 'controlled-by', controlledBy);
- controlledIndicator.setAttribute(
- 'text' + controlledBy,
- loadTimeData.getString('extensionControlledSettingPolicy'));
- } else if (!devModeControlledByPolicy && isVisible) {
- // This hides the element - see above.
- controlledIndicator.removeAttribute('controlled-by');
- }
- },
-
- /**
- * Shows the loading spinner and hides elements that shouldn't be visible
- * while loading.
- * @param {boolean} isLoading
- * @private
- */
- setLoading_: function(isLoading) {
- document.documentElement.classList.toggle('loading', isLoading);
- $('loading-spinner').hidden = !isLoading;
- $('dev-controls').hidden = isLoading;
- this.updateDevControlsVisibility_(false);
-
- // The extension list is already hidden/shown elsewhere and shouldn't be
- // updated here because it can be hidden if there are no extensions.
- },
-
- /**
- * Handles the Pack Extension button.
- * @param {Event} e Change event.
- * @private
- */
- handlePackExtension_: function(e) {
- ExtensionSettings.showOverlay($('pack-extension-overlay'));
- chrome.send('metricsHandler:recordAction', ['Options_PackExtension']);
- },
-
- /**
- * Shows the Extension Commands configuration UI.
- * @private
- */
- showExtensionCommandsConfigUi_: function() {
- ExtensionSettings.showOverlay($('extension-commands-overlay'));
- chrome.send('metricsHandler:recordAction',
- ['Options_ExtensionCommands']);
- },
-
- /**
- * Handles the Configure (Extension) Commands link.
- * @param {Event} e Change event.
- * @private
- */
- handleExtensionCommandsConfig_: function(e) {
- this.showExtensionCommandsConfigUi_();
- },
-
- /**
- * Handles the Update Extension Now button.
- * @param {Event} e Change event.
- * @private
- */
- handleUpdateExtensionNow_: function(e) {
- chrome.developerPrivate.autoUpdate();
- chrome.send('metricsHandler:recordAction',
- ['Options_UpdateExtensions']);
- },
-
- /**
- * Updates the visibility of the developer controls based on whether the
- * [x] Developer mode checkbox is checked.
- * @param {boolean} animated Whether to animate any updates.
- * @private
- */
- updateDevControlsVisibility_: function(animated) {
- var showDevControls = $('toggle-dev-on').checked;
- $('extension-settings').classList.toggle('dev-mode', showDevControls);
-
- var devControls = $('dev-controls');
- devControls.classList.toggle('animated', animated);
-
- var buttons = devControls.querySelector('.button-container');
- Array.prototype.forEach.call(buttons.querySelectorAll('a, button'),
- function(control) {
- control.tabIndex = showDevControls ? 0 : -1;
- });
- buttons.setAttribute('aria-hidden', !showDevControls);
-
- window.requestAnimationFrame(function() {
- devControls.style.height = !showDevControls ? '' :
- buttons.offsetHeight + 'px';
-
- document.dispatchEvent(new Event('devControlsVisibilityUpdated'));
- }.bind(this));
- },
-
- /** @override */
- onExtensionCountChanged: function() {
- /** @const */
- var hasExtensions =
- /** @type {extensions.ExtensionList} */ ($('extension-settings-list'))
- .getNumExtensions() != 0;
- $('no-extensions').hidden = hasExtensions;
- $('extension-list-wrapper').hidden = !hasExtensions;
- },
- };
-
- /**
- * Returns the current overlay or null if one does not exist.
- * @return {Element} The overlay element.
- */
- ExtensionSettings.getCurrentOverlay = function() {
- return document.querySelector('#overlay .page.showing');
- };
-
- /**
- * Sets the given overlay to show. If the overlay is already showing, this is
- * a no-op; otherwise, hides any currently-showing overlay.
- * @param {HTMLElement} node The overlay page to show. If null, all overlays
- * are hidden.
- */
- ExtensionSettings.showOverlay = function(node) {
- var pageDiv = $('extension-settings');
- pageDiv.style.width = node ? window.getComputedStyle(pageDiv).width : '';
- document.body.classList.toggle('no-scroll', !!node);
-
- var currentlyShowingOverlay = ExtensionSettings.getCurrentOverlay();
- if (currentlyShowingOverlay) {
- if (currentlyShowingOverlay == node) // Already displayed.
- return;
- currentlyShowingOverlay.classList.remove('showing');
- }
-
- if (node) {
- var lastFocused;
-
- var focusOutlineManager = cr.ui.FocusOutlineManager.forDocument(document);
- if (focusOutlineManager.visible)
- lastFocused = document.activeElement;
-
- $('overlay').addEventListener('cancelOverlay', function f() {
- if (lastFocused && focusOutlineManager.visible)
- lastFocused.focus();
-
- $('overlay').removeEventListener('cancelOverlay', f);
- window.history.replaceState({}, '', '/');
- });
- node.classList.add('showing');
- }
-
- var pages = document.querySelectorAll('.page');
- for (var i = 0; i < pages.length; i++) {
- var hidden = (node != pages[i]) ? 'true' : 'false';
- pages[i].setAttribute('aria-hidden', hidden);
- }
-
- $('overlay').hidden = !node;
-
- if (node)
- ExtensionSettings.focusOverlay();
-
- // If drag-drop for external Extension installation is available, enable
- // drag-drop when there is any overlay showing other than the usual overlay
- // shown when drag-drop is started.
- var settings = ExtensionSettings.getInstance();
- if (settings.dragWrapper_) {
- assert(settings.dragWrapperHandler_).dragEnabled =
- !node || node == $('drop-target-overlay');
- }
- };
-
- ExtensionSettings.focusOverlay = function() {
- var currentlyShowingOverlay = ExtensionSettings.getCurrentOverlay();
- assert(currentlyShowingOverlay);
-
- if (cr.ui.FocusOutlineManager.forDocument(document).visible)
- cr.ui.setInitialFocus(currentlyShowingOverlay);
-
- if (!currentlyShowingOverlay.contains(document.activeElement)) {
- // Make sure focus isn't stuck behind the overlay.
- document.activeElement.blur();
- }
- };
-
- /**
- * Utility function to find the width of various UI strings and synchronize
- * the width of relevant spans. This is crucial for making sure the
- * Enable/Enabled checkboxes align, as well as the Developer Mode checkbox.
- */
- function measureCheckboxStrings() {
- var trashWidth = 30;
- var measuringDiv = $('font-measuring-div');
- measuringDiv.textContent =
- loadTimeData.getString('extensionSettingsEnabled');
- measuringDiv.className = 'enabled-text';
- var pxWidth = measuringDiv.clientWidth + trashWidth;
- measuringDiv.textContent =
- loadTimeData.getString('extensionSettingsEnable');
- measuringDiv.className = 'enable-text';
- pxWidth = Math.max(measuringDiv.clientWidth + trashWidth, pxWidth);
- measuringDiv.textContent =
- loadTimeData.getString('extensionSettingsDeveloperMode');
- measuringDiv.className = '';
- pxWidth = Math.max(measuringDiv.clientWidth, pxWidth);
-
- var style = document.createElement('style');
- style.type = 'text/css';
- style.textContent =
- '.enable-checkbox-text {' +
- ' min-width: ' + (pxWidth - trashWidth) + 'px;' +
- '}' +
- '#dev-toggle span {' +
- ' min-width: ' + pxWidth + 'px;' +
- '}';
- document.querySelector('head').appendChild(style);
- }
-
- // Export
- return {
- ExtensionSettings: ExtensionSettings
- };
-});
-
-window.addEventListener('load', function(e) {
- extensions.ExtensionSettings.getInstance().initialize();
-});
diff --git a/chromium/chrome/browser/resources/extensions/focus_row.js b/chromium/chrome/browser/resources/extensions/focus_row.js
deleted file mode 100644
index 6022f3993d9..00000000000
--- a/chromium/chrome/browser/resources/extensions/focus_row.js
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('extensions', function() {
- /**
- * @param {!Element} root
- * @param {?Element} boundary
- * @constructor
- * @extends {cr.ui.FocusRow}
- */
- function FocusRow(root, boundary) {
- cr.ui.FocusRow.call(this, root, boundary);
- }
-
- FocusRow.prototype = {
- __proto__: cr.ui.FocusRow.prototype,
-
- /** @override */
- makeActive: function(active) {
- cr.ui.FocusRow.prototype.makeActive.call(this, active);
-
- // Only highlight if the row has focus.
- this.root.classList.toggle('extension-highlight',
- active && this.root.contains(document.activeElement));
- },
- };
-
- return {FocusRow: FocusRow};
-});
diff --git a/chromium/chrome/browser/resources/extensions/pack_extension_overlay.css b/chromium/chrome/browser/resources/extensions/pack_extension_overlay.css
deleted file mode 100644
index 74a4b19d546..00000000000
--- a/chromium/chrome/browser/resources/extensions/pack_extension_overlay.css
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file. */
-
-.pack-extension-heading {
- padding-bottom: 5px;
- width: 520px;
-}
-
-.pack-extension-text-boxes {
- text-align: right;
-}
-
-.pack-extension-text-area {
- width: 260px;
-}
-
-<if expr="toolkit_views">
-/* TODO(estade): apply this everywhere. */
-.button-strip {
- -webkit-box-direction: reverse;
-}
-</if>
diff --git a/chromium/chrome/browser/resources/extensions/pack_extension_overlay.html b/chromium/chrome/browser/resources/extensions/pack_extension_overlay.html
deleted file mode 100644
index 65572b515d7..00000000000
--- a/chromium/chrome/browser/resources/extensions/pack_extension_overlay.html
+++ /dev/null
@@ -1,33 +0,0 @@
-<div id="pack-extension-overlay" class="page">
- <div class="close-button"></div>
- <h1>$i18n{packExtensionOverlay}</h1>
- <div id="cbd-content-area" class="content-area">
- <div class="pack-extension-heading">$i18n{packExtensionHeading}</div>
- <div class="pack-extension-text-boxes">
- <label for="extension-root-dir">$i18n{packExtensionRootDir}</label>
- <input class="pack-extension-text-area" id="extension-root-dir"
- type="text">
- <button id="browse-extension-dir">
- $i18n{packExtensionBrowseButton}
- </button>
- </div>
- <div class="pack-extension-text-boxes">
- <label for="extension-private-key">$i18n{packExtensionPrivateKey}</label>
- <input class="pack-extension-text-area" id="extension-private-key"
- type="text">
- <button id="browse-private-key">
- $i18n{packExtensionBrowseButton}
- </button>
- </div>
- </div>
- <div class="action-area">
- <div class="action-area-right">
- <div class="button-strip">
- <button id="pack-extension-dismiss">$i18n{cancel}</button>
- <button id="pack-extension-commit">
- $i18n{packExtensionCommit}
- </button>
- </div>
- </div>
- </div>
-</div>
diff --git a/chromium/chrome/browser/resources/extensions/pack_extension_overlay.js b/chromium/chrome/browser/resources/extensions/pack_extension_overlay.js
deleted file mode 100644
index 63b20a4d2de..00000000000
--- a/chromium/chrome/browser/resources/extensions/pack_extension_overlay.js
+++ /dev/null
@@ -1,169 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('extensions', function() {
- /**
- * PackExtensionOverlay class
- * Encapsulated handling of the 'Pack Extension' overlay page.
- * @constructor
- */
- function PackExtensionOverlay() {
- }
-
- cr.addSingletonGetter(PackExtensionOverlay);
-
- PackExtensionOverlay.prototype = {
- /**
- * Initialize the page.
- */
- initializePage: function() {
- var overlay = $('overlay');
- cr.ui.overlay.setupOverlay(overlay);
- cr.ui.overlay.globalInitialization();
- overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this));
-
- $('pack-extension-dismiss').addEventListener('click', function() {
- cr.dispatchSimpleEvent(overlay, 'cancelOverlay');
- });
- $('pack-extension-commit').addEventListener('click',
- this.handleCommit_.bind(this));
- $('browse-extension-dir').addEventListener('click',
- this.handleBrowseExtensionDir_.bind(this));
- $('browse-private-key').addEventListener('click',
- this.handleBrowsePrivateKey_.bind(this));
- },
-
- /**
- * Handles a click on the dismiss button.
- * @param {Event} e The click event.
- */
- handleDismiss_: function(e) {
- extensions.ExtensionSettings.showOverlay(null);
- },
-
- /**
- * Handles a click on the pack button.
- * @param {Event} e The click event.
- */
- handleCommit_: function(e) {
- var extensionPath = $('extension-root-dir').value;
- var privateKeyPath = $('extension-private-key').value;
- chrome.developerPrivate.packDirectory(
- extensionPath, privateKeyPath, 0, this.onPackResponse_.bind(this));
- },
-
- /**
- * Utility function which asks the C++ to show a platform-specific file
- * select dialog, and set the value property of |node| to the selected path.
- * @param {chrome.developerPrivate.SelectType} selectType
- * The type of selection to use.
- * @param {chrome.developerPrivate.FileType} fileType
- * The type of file to select.
- * @param {HTMLInputElement} node The node to set the value of.
- * @private
- */
- showFileDialog_: function(selectType, fileType, node) {
- chrome.developerPrivate.choosePath(selectType, fileType, function(path) {
- // Last error is set if the user canceled the dialog.
- if (!chrome.runtime.lastError && path)
- node.value = path;
- });
- },
-
- /**
- * Handles the showing of the extension directory browser.
- * @param {Event} e Change event.
- * @private
- */
- handleBrowseExtensionDir_: function(e) {
- this.showFileDialog_(
- chrome.developerPrivate.SelectType.FOLDER,
- chrome.developerPrivate.FileType.LOAD,
- /** @type {HTMLInputElement} */ ($('extension-root-dir')));
- },
-
- /**
- * Handles the showing of the extension private key file.
- * @param {Event} e Change event.
- * @private
- */
- handleBrowsePrivateKey_: function(e) {
- this.showFileDialog_(
- chrome.developerPrivate.SelectType.FILE,
- chrome.developerPrivate.FileType.PEM,
- /** @type {HTMLInputElement} */ ($('extension-private-key')));
- },
-
- /**
- * Handles a response from a packDirectory call.
- * @param {chrome.developerPrivate.PackDirectoryResponse} response The
- * response of the pack call.
- * @private
- */
- onPackResponse_: function(response) {
- /** @type {string} */
- var alertTitle;
- /** @type {string} */
- var alertOk;
- /** @type {string} */
- var alertCancel;
- /** @type {function()} */
- var alertOkCallback;
- /** @type {function()} */
- var alertCancelCallback;
-
- var closeAlert = function() {
- extensions.ExtensionSettings.showOverlay(null);
- };
-
- switch (response.status) {
- case chrome.developerPrivate.PackStatus.SUCCESS:
- alertTitle = loadTimeData.getString('packExtensionOverlay');
- alertOk = loadTimeData.getString('ok');
- alertOkCallback = closeAlert;
- // No 'Cancel' option.
- break;
- case chrome.developerPrivate.PackStatus.WARNING:
- alertTitle = loadTimeData.getString('packExtensionWarningTitle');
- alertOk = loadTimeData.getString('packExtensionProceedAnyway');
- alertCancel = loadTimeData.getString('cancel');
- alertOkCallback = function() {
- chrome.developerPrivate.packDirectory(
- response.item_path,
- response.pem_path,
- response.override_flags,
- this.onPackResponse_.bind(this));
- closeAlert();
- }.bind(this);
- alertCancelCallback = closeAlert;
- break;
- case chrome.developerPrivate.PackStatus.ERROR:
- alertTitle = loadTimeData.getString('packExtensionErrorTitle');
- alertOk = loadTimeData.getString('ok');
- alertOkCallback = function() {
- extensions.ExtensionSettings.showOverlay(
- $('pack-extension-overlay'));
- };
- // No 'Cancel' option.
- break;
- default:
- assertNotReached();
- return;
- }
-
- alertOverlay.setValues(alertTitle,
- response.message,
- alertOk,
- alertCancel,
- alertOkCallback,
- alertCancelCallback);
- extensions.ExtensionSettings.showOverlay($('alertOverlay'));
- },
- };
-
- // Export
- return {
- PackExtensionOverlay: PackExtensionOverlay
- };
-});
diff --git a/chromium/chrome/browser/resources/feedback/css/sys_info.css b/chromium/chrome/browser/resources/feedback/css/sys_info.css
index 7f55d86aaff..baea3ef76d8 100644
--- a/chromium/chrome/browser/resources/feedback/css/sys_info.css
+++ b/chromium/chrome/browser/resources/feedback/css/sys_info.css
@@ -5,6 +5,7 @@
html,
body {
overflow: visible;
+ user-select: auto;
}
#detailsTable {
diff --git a/chromium/chrome/browser/resources/feedback/js/take_screenshot.js b/chromium/chrome/browser/resources/feedback/js/take_screenshot.js
index 830fd726004..91792317c9e 100644
--- a/chromium/chrome/browser/resources/feedback/js/take_screenshot.js
+++ b/chromium/chrome/browser/resources/feedback/js/take_screenshot.js
@@ -20,7 +20,7 @@ function takeScreenshot(callback) {
video, 0, 0, video.videoWidth, video.videoHeight);
video.pause();
- video.src = '';
+ video.srcObject = null;
screenshotStream.getVideoTracks()[0].stop();
screenshotStream = null;
@@ -39,7 +39,7 @@ function takeScreenshot(callback) {
function(stream) {
if (stream) {
screenshotStream = stream;
- video.src = window.URL.createObjectURL(screenshotStream);
+ video.srcObject = screenshotStream;
video.play();
}
},
diff --git a/chromium/chrome/browser/resources/gaia_auth_host/authenticator.js b/chromium/chrome/browser/resources/gaia_auth_host/authenticator.js
index ddae045145d..f289d2fb29a 100644
--- a/chromium/chrome/browser/resources/gaia_auth_host/authenticator.js
+++ b/chromium/chrome/browser/resources/gaia_auth_host/authenticator.js
@@ -79,6 +79,7 @@ cr.define('cr.login', function() {
// not called before dispatching |authCopleted|.
// Default is |true|.
'flow', // One of 'default', 'enterprise', or 'theftprotection'.
+ 'enterpriseDisplayDomain', // Current domain name to be displayed.
'enterpriseEnrollmentDomain', // Domain in which hosting device is (or
// should be) enrolled.
'emailDomain', // Value used to prefill domain for email.
@@ -95,6 +96,7 @@ cr.define('cr.login', function() {
'lsbReleaseBoard', // Chrome OS Release board name
'isFirstUser', // True if this is non-enterprise device,
// and there are no users yet.
+ 'obfuscatedOwnerId', // Obfuscated device owner ID, if neeed.
// The email fields allow for the following possibilities:
//
@@ -153,6 +155,7 @@ cr.define('cr.login', function() {
this.samlApiUsedCallback = null;
this.missingGaiaInfoCallback = null;
this.needPassword = true;
+ this.services_ = null;
this.bindToWebview_(webview);
@@ -185,6 +188,7 @@ cr.define('cr.login', function() {
this.authFlow = AuthFlow.DEFAULT;
this.samlHandler_.reset();
this.videoEnabled = false;
+ this.services_ = null;
};
/**
@@ -357,9 +361,8 @@ cr.define('cr.login', function() {
url = appendParam(url, 'chrometype', data.chromeType);
if (data.clientId)
url = appendParam(url, 'client_id', data.clientId);
- if (data.enterpriseEnrollmentDomain)
- url =
- appendParam(url, 'manageddomain', data.enterpriseEnrollmentDomain);
+ if (data.enterpriseDisplayDomain)
+ url = appendParam(url, 'manageddomain', data.enterpriseDisplayDomain);
if (data.clientVersion)
url = appendParam(url, 'client_version', data.clientVersion);
if (data.platformVersion)
@@ -383,6 +386,8 @@ cr.define('cr.login', function() {
url = appendParam(url, 'chromeos_board', data.lsbReleaseBoard);
if (data.isFirstUser)
url = appendParam(url, 'is_first_user', true);
+ if (data.obfuscatedOwnerId)
+ url = appendParam(url, 'obfuscated_owner_id', data.obfuscatedOwnerId);
}
} else {
url = appendParam(url, 'continue', this.continueUrl_);
@@ -655,6 +660,10 @@ cr.define('cr.login', function() {
this.dispatchEvent(new CustomEvent(
'identifierEntered',
{detail: {accountIdentifier: msg.accountIdentifier}}));
+ } else if (msg.method == 'userInfo') {
+ this.services_ = msg.services;
+ if (this.email_ && this.gaiaId_ && this.sessionIndex_)
+ this.maybeCompleteAuth_();
} else {
console.warn('Unrecognized message from GAIA: ' + msg.method);
}
@@ -697,6 +706,15 @@ cr.define('cr.login', function() {
this.webview_.src = this.initialFrameUrl_;
return;
}
+ // TODO(https://crbug.com/837107): remove this once API is fully stabilized.
+ // @example.com is used in tests.
+ if (!this.services_ && !this.email_.endsWith('@gmail.com') &&
+ !this.email_.endsWith('@example.com')) {
+ console.warn('Forcing empty services.');
+ this.services_ = [];
+ }
+ if (!this.services_)
+ return;
if (this.samlHandler_.samlApiUsed) {
if (this.samlApiUsedCallback) {
@@ -756,6 +774,21 @@ cr.define('cr.login', function() {
assert(
this.skipForNow_ ||
(this.email_ && this.gaiaId_ && this.sessionIndex_));
+ // Chrome will crash on incorrect data type, so log some error message here.
+ if (this.services_) {
+ if (!Array.isArray(this.services_)) {
+ console.error('FATAL: Bad services type:' + typeof this.services_);
+ } else {
+ for (var i = 0; i < this.services_.length; ++i) {
+ if (typeof this.services_[i] == 'string')
+ continue;
+
+ console.error(
+ 'FATAL: Bad services[' + i +
+ '] type:' + typeof this.services_[i]);
+ }
+ }
+ }
this.dispatchEvent(new CustomEvent(
'authCompleted',
// TODO(rsorokin): get rid of the stub values.
@@ -771,6 +804,7 @@ cr.define('cr.login', function() {
sessionIndex: this.sessionIndex_ || '',
trusted: this.trusted_,
gapsCookie: this.newGapsCookie_ || this.gapsCookie_ || '',
+ services: this.services_ || [],
}
}));
this.resetStates();
@@ -804,6 +838,7 @@ cr.define('cr.login', function() {
this.authDomain = this.samlHandler_.authDomain;
this.authFlow = AuthFlow.SAML;
+ this.webview_.focus();
this.fireReadyEvent_();
};
diff --git a/chromium/chrome/browser/resources/inspect/inspect.js b/chromium/chrome/browser/resources/inspect/inspect.js
index 1901d601dd6..f3b2629825f 100644
--- a/chromium/chrome/browser/resources/inspect/inspect.js
+++ b/chromium/chrome/browser/resources/inspect/inspect.js
@@ -641,7 +641,7 @@ function addTargetToList(data, list, properties) {
row, 'inspect', sendCommand.bind(null, 'inspect-additional', data.url),
false);
row.classList.add('additional');
- } else if (!data.hasCustomInspectAction) {
+ } else if (!data.hasCustomInspectAction && data.type !== 'iframe') {
addActionLink(
row, 'inspect', sendTargetCommand.bind(null, 'inspect', data),
data.hasNoUniqueId || data.adbAttachedForeign);
diff --git a/chromium/chrome/browser/resources/interventions_internals/index.html b/chromium/chrome/browser/resources/interventions_internals/index.html
index 91dbe087ce6..f8d0ad49b16 100644
--- a/chromium/chrome/browser/resources/interventions_internals/index.html
+++ b/chromium/chrome/browser/resources/interventions_internals/index.html
@@ -27,7 +27,7 @@
<label class="inactive-tab">
<input type="radio" id="blacklist-tab" name="tabs"
value="blacklist-status">
- <span>Blacklist Status</span>
+ <span>Blocklist Status</span>
</label>
<label class="inactive-tab">
<input type="radio" id="nqe-tab" name="tabs" value="nqe-info">
@@ -76,19 +76,19 @@
<div class="tab-content" id="blacklist-status">
<div id="blacklist-ignored-status"></div>
<button id="ignore-blacklist-button" type="button">
- Ignore Blacklist
+ Ignore Blocklist
</button>
<div id="user-blacklisted-status">
- User blacklisted status:
+ User blocklisted status:
<span id="user-blacklisted-status-value">N/A</span>
</div>
<div id="blacklist-cleared-status">
- Last blacklist cleared:
+ Last blocklist cleared:
<span id="blacklist-last-cleared-time">N/A</span>
</div>
<div id="blacklisted-hosts">
- <div class="table-name">Blacklisted hosts</div>
+ <div class="table-name">Blocklisted hosts</div>
<table id="blacklisted-hosts-table">
<tr>
<th id="blacklisted-host-header">Host</th>
diff --git a/chromium/chrome/browser/resources/local_ntp/custom_backgrounds.css b/chromium/chrome/browser/resources/local_ntp/custom_backgrounds.css
new file mode 100644
index 00000000000..9315d88c87a
--- /dev/null
+++ b/chromium/chrome/browser/resources/local_ntp/custom_backgrounds.css
@@ -0,0 +1,281 @@
+/* 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. */
+
+#edit-bg {
+ border-radius: 8px;
+ bottom: 16px;
+ height: 28px;
+ position: fixed;
+ right: 16px;
+ width: 28px;
+}
+
+#edit-bg:hover {
+ background-color: rgb(241, 243, 244);
+}
+
+#edit-bg-gear:focus {
+ outline: 0;
+}
+
+#edit-bg-gear {
+ background: url(../../../../ui/webui/resources/images/icon_settings.svg) no-repeat center;
+ background-size: 16px 16px;
+ height: 100%;
+ width: 100%;
+}
+
+.non-white-bg #edit-bg-gear {
+ background: url(../../../../ui/webui/resources/images/icon_settings_white.svg) no-repeat center;
+ background-size: 16px 16px;
+}
+
+#edit-bg-overlay {
+ display: none;
+ height: 100%;
+ left: 0;
+ position: fixed;
+ top: 0;
+ width: 100%;
+ z-index: 10000;
+}
+
+#edit-bg-dialog {
+ background: #fff;
+ border-radius: 8px;
+ border-style: outset;
+ border-width: thin;
+ bottom: 44px;
+ box-shadow: 0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15);
+ padding-bottom: 16px;
+ position: fixed;
+ right: 16px;
+ width: 325px;
+}
+
+#edit-bg-title {
+ color: rgb(32, 33, 36);
+ font-family: 'Roboto', arial, sans-serif;
+ font-size: 15px;
+ height: 30px;
+ padding: 16px 0 0 16px;
+}
+
+.bg-option {
+ color: rgb(60, 64, 67);
+ font-family: 'Roboto', arial, sans-serif;
+ font-size: 13px;
+ height: 40px;
+ line-height: 40px;
+}
+
+.bg-option:hover {
+ background-color: rgb(241, 243, 244);
+}
+
+.bg-option-img {
+ background: url(../../../../ui/webui/resources/images/settings.svg) no-repeat center;
+ background-size: 24px 24px;
+ display: inline-block;
+ height: 24px;
+ line-height: normal;
+ margin: 0 0 0 16px;
+ text-align: center;
+ vertical-align: middle;
+ width: 24px;
+}
+
+.bg-option-text {
+ display: inline-block;
+ line-height: normal;
+ padding-left: 16px;
+ text-align: center;
+ vertical-align: middle;
+}
+
+#bg-sel-menu-overlay {
+ background-color: rgba(255, 255, 255, .75);
+ border: none;
+ height: 100%;
+ left: 0;
+ position: fixed;
+ top: 0;
+ width: 100%;
+ z-index: 1000;
+}
+
+#bg-sel-menu {
+ background-color: #fff;
+ border-radius: 4px;
+ bottom: 0;
+ box-shadow: 0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15);
+ font-family: 'Roboto', arial, sans-serif;
+ height: 400px;
+ left: 0;
+ margin: auto;
+ position: absolute;
+ right: 0;
+ top: 0;
+ width: 516px;
+ z-index: 10000;
+}
+
+@media (max-width: 520px) {
+ #bg-sel-menu {
+ width: 352px;
+ }
+}
+
+#bg-sel-tiles {
+ height: 284px;
+ overflow-y: scroll;
+ padding-left: 8px;
+ width: 100%;
+}
+
+#bg-sel-tiles::-webkit-scrollbar {
+ display: none;
+}
+
+#bg-sel-title-bar {
+ font-size: 15px;
+ height: 52px;
+ line-height: 52px;
+ text-align: center;
+}
+
+#bg-sel-back {
+ background: url(../../../../ui/webui/resources/images/icon_arrow_back.svg) no-repeat center;
+ background-size: 16px 16px;
+ display: none;
+ height: 16px;
+ margin: 0 0 0 16px;
+ vertical-align: middle;
+ width: 16px;
+}
+
+.is-col-sel #bg-sel-back {
+ display: none;
+ text-align: left;
+}
+
+.is-img-sel #bg-sel-back {
+ display: inline-block;
+ float: left;
+ margin-top: 18px;
+}
+
+#bg-sel-title {
+ color: rgb(32, 33, 36);
+ display: inline-block;
+ line-height: normal;
+ padding-left: 16px;
+ text-align: center;
+ vertical-align: middle;
+}
+
+.is-col-sel #bg-sel-title {
+ padding-left: 0;
+ text-align: center;
+}
+
+.is-img-sel #bg-sel-title {
+ float: left;
+ padding: 18px 0 0 16px;
+ text-align: left;
+}
+
+#bg-sel-footer {
+ bottom: 0;
+ box-shadow: 0 -8px 6px -6px rgba(60, 64, 67, 0.3);
+ color: rgb(60, 64, 67);
+ height: 64px;
+ padding-left: 0;
+ position: absolute;
+ width: 100%;
+}
+
+#bg-sel-footer-done {
+ background-color: rgb(241, 243, 244);
+ border-radius: 4px;
+ bottom: 16px;
+ height: 24px;
+ line-height: normal;
+ padding-top: 8px;
+ position: absolute;
+ right: 16px;
+ text-align: center;
+ vertical-align: middle;
+ width: 52px;
+}
+
+.done-available {
+ background-color: rgb(66, 133, 244) !important;
+ color: #FFF;
+}
+
+#bg-sel-footer-toggle-text {
+ padding: 24px 0 0 16px;
+}
+
+.bg-sel-tile {
+ background-color: rgb(32, 33, 36);
+ background-size: cover;
+ display: inline-block;
+ height: 117px;
+ margin: 6px 0 0 8px;
+ position: relative;
+ width: 156px;
+}
+
+.bg-selected {
+ border: 3px solid rgb(172, 206, 247);
+ border-radius: 3px;
+ height: 111px;
+ width: 150px;
+}
+
+.bg-sel-tile-title {
+ background-color: rgba(32, 33, 36, 0.71);
+ bottom: 0;
+ color: #FFF;
+ display: inline-block;
+ font-size: 13px;
+ height: 24px;
+ padding: 8px 16px 0 16px;
+ position: absolute;
+ text-overflow: ellipsis;
+ vertical-align: middle;
+ white-space: nowrap;
+ width: 124px;
+}
+
+.bg-selected .bg-sel-tile-title {
+ width: 118px;
+}
+
+#bg-daily-refresh {
+ margin: 23px 0 0 16px;
+}
+
+.is-img-sel #bg-daily-refresh {
+ display: none;
+}
+
+.is-col-sel #bg-daily-refresh {
+ display: none;
+}
+
+.is-img-sel #bg-sel-refresh-text {
+ display: none;
+ margin: 24px 0 0 64px;
+}
+
+.is-col-sel #bg-sel-refresh-text {
+ display: none;
+}
+
+.show-overlay {
+ display: block !important;
+}
diff --git a/chromium/chrome/browser/resources/local_ntp/custom_backgrounds.js b/chromium/chrome/browser/resources/local_ntp/custom_backgrounds.js
new file mode 100644
index 00000000000..34ca4f46a11
--- /dev/null
+++ b/chromium/chrome/browser/resources/local_ntp/custom_backgrounds.js
@@ -0,0 +1,402 @@
+// 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.
+
+
+'use strict';
+
+let customBackgrounds = {};
+
+/**
+ * Enum for key codes.
+ * @enum {int}
+ * @const
+ */
+customBackgrounds.KEYCODES = {
+ BACKSPACE: 8,
+ ENTER: 13,
+ ESC: 27,
+ TAB: 9,
+};
+
+/**
+ * Enum for HTML element ids.
+ * @enum {string}
+ * @const
+ */
+customBackgrounds.IDS = {
+ BACK: 'bg-sel-back',
+ CONNECT_GOOGLE_PHOTOS: 'edit-bg-google-photos',
+ CONNECT_GOOGLE_PHOTOS_TEXT: 'edit-bg-google-photos-text',
+ DEFAULT_WALLPAPERS: 'edit-bg-default-wallpapers',
+ DEFAULT_WALLPAPERS_TEXT: 'edit-bg-default-wallpapers-text',
+ DONE: 'bg-sel-footer-done',
+ EDIT_BG: 'edit-bg',
+ EDIT_BG_DIALOG: 'edit-bg-dialog',
+ EDIT_BG_GEAR: 'edit-bg-gear',
+ EDIT_BG_OVERLAY: 'edit-bg-overlay',
+ MENU: 'bg-sel-menu',
+ OPTIONS_TITLE: 'edit-bg-title',
+ OVERLAY: 'bg-sel-menu-overlay',
+ RESTORE_DEFAULT: 'edit-bg-restore-default',
+ RESTORE_DEFAULT_TEXT: 'edit-bg-restore-default-text',
+ REFRESH_TEXT: 'bg-sel-refresh-text',
+ REFRESH_TOGGLE: 'bg-daily-refresh',
+ UPLOAD_IMAGE: 'edit-bg-upload-image',
+ UPLOAD_IMAGE_TEXT: 'edit-bg-upload-image-text',
+ TILES: 'bg-sel-tiles',
+ TITLE: 'bg-sel-title',
+};
+
+/**
+ * Enum for classnames.
+ * @enum {string}
+ * @const
+ */
+customBackgrounds.CLASSES = {
+ COLLECTION_DIALOG: 'is-col-sel',
+ COLLECTION_SELECTED: 'bg-selected', // Highlight selected tile
+ COLLECTION_TILE: 'bg-sel-tile', // Preview tile for background customization
+ COLLECTION_TITLE: 'bg-sel-tile-title', // Title of a background image
+ DONE_AVAILABLE: 'done-available',
+ IMAGE_DIALOG: 'is-img-sel',
+ SHOW_OVERLAY: 'show-overlay',
+};
+
+/**
+ * Alias for document.getElementById.
+ * @param {string} id The ID of the element to find.
+ * @return {HTMLElement} The found element or null if not found.
+ */
+function $(id) {
+ // eslint-disable-next-line no-restricted-properties
+ return document.getElementById(id);
+}
+
+/**
+ * Remove all collection tiles from the container when the dialog
+ * is closed.
+ */
+customBackgrounds.resetSelectionDialog = function() {
+ $(customBackgrounds.IDS.TILES).scrollTop = 0;
+ var tileContainer = $(customBackgrounds.IDS.TILES);
+ while (tileContainer.firstChild) {
+ tileContainer.removeChild(tileContainer.firstChild);
+ }
+ $(customBackgrounds.IDS.DONE)
+ .classList.remove(customBackgrounds.CLASSES.DONE_AVAILABLE);
+};
+
+/**
+ * Show dialog for selecting a collection. Populates the dialog
+ * with data from |coll|.
+ * @param {string} dialogTitle The title to be displayed at the top of the
+ * dialog.
+ */
+customBackgrounds.showCollectionSelectionDialog = function() {
+ var tileContainer = $(customBackgrounds.IDS.TILES);
+ var overlay = $(customBackgrounds.IDS.OVERLAY);
+
+ if (!overlay.open)
+ overlay.showModal();
+
+ // Create dialog header
+ $(customBackgrounds.IDS.TITLE).textContent =
+ configData.translatedStrings.selectChromeWallpaper;
+ $(customBackgrounds.IDS.MENU)
+ .classList.add(customBackgrounds.CLASSES.COLLECTION_DIALOG);
+ $(customBackgrounds.IDS.MENU)
+ .classList.remove(customBackgrounds.CLASSES.IMAGE_DIALOG);
+
+ // Create dialog tiles
+ for (var i = 0; i < coll.length; ++i) {
+ var tile = document.createElement('div');
+ tile.classList.add(customBackgrounds.CLASSES.COLLECTION_TILE);
+ tile.style.backgroundImage = 'url(' + coll[i].previewImageUrl + ')';
+ tile.id = 'coll_tile_' + i;
+ tile.dataset.id = coll[i].collectionId;
+ tile.dataset.name = coll[i].collectionName;
+ tile.tabIndex = 0;
+
+ var title = document.createElement('div');
+ title.classList.add(customBackgrounds.CLASSES.COLLECTION_TITLE);
+ title.textContent = tile.dataset.name;
+
+ var tileInteraction = function(event) {
+ var tile = event.target;
+ if (tile.classList.contains(customBackgrounds.CLASSES.COLLECTION_TITLE))
+ tile = tile.parentNode;
+
+ // Load images for selected collection
+ var imgElement = $('ntp-images-loader');
+ if (imgElement) {
+ imgElement.parentNode.removeChild(imgElement);
+ }
+ var imgScript = document.createElement('script');
+ imgScript.id = 'ntp-images-loader';
+ imgScript.src = 'chrome-search://local-ntp/ntp-background-images.js?' +
+ 'collection_id=' + tile.dataset.id;
+ document.body.appendChild(imgScript);
+
+ imgScript.onload = function() {
+ customBackgrounds.resetSelectionDialog();
+ if (coll_img.length > 0 &&
+ coll_img[0].collectionId == tile.dataset.id) {
+ customBackgrounds.showImageSelectionDialog(tile.dataset.name);
+ } else {
+ overlay.close();
+ customBackgrounds.resetSelectionDialog();
+ }
+ };
+ };
+
+ tile.onclick = tileInteraction;
+ tile.onkeyup = function(event) {
+ if (event.keyCode === customBackgrounds.KEYCODES.ENTER) {
+ tileInteraction(event);
+ }
+ };
+
+ tile.appendChild(title);
+ tileContainer.appendChild(tile);
+ }
+
+ $(customBackgrounds.IDS.DONE).tabIndex = -1;
+
+ // Create dialog footer
+ $(customBackgrounds.IDS.DONE).textContent =
+ configData.translatedStrings.selectionDone;
+
+ overlay.onclick = function(event) {
+ if (event.target == overlay) {
+ overlay.close();
+ customBackgrounds.resetSelectionDialog();
+ }
+ };
+};
+
+
+/**
+ * Show dialog for selecting an image or toggling on daily refresh. Image
+ * data should previous have been loaded into coll_img via
+ * chrome-search://local-ntp/ntp-background-images.js?collection_id=<collection_id>
+ * @param {string} dialogTitle The title to be displayed at the top of the
+ */
+customBackgrounds.showImageSelectionDialog = function(dialogTitle) {
+ var backButton = $(customBackgrounds.IDS.BACK);
+ var dailyRefresh = $(customBackgrounds.IDS.REFRESH_TOGGLE);
+ var doneButton = $(customBackgrounds.IDS.DONE);
+ var overlay = $(customBackgrounds.IDS.OVERLAY);
+ var selectedTile = null;
+ var tileContainer = $(customBackgrounds.IDS.TILES);
+
+ $(customBackgrounds.IDS.TITLE).textContent = dialogTitle;
+ $(customBackgrounds.IDS.MENU)
+ .classList.remove(customBackgrounds.CLASSES.COLLECTION_DIALOG);
+ $(customBackgrounds.IDS.MENU)
+ .classList.add(customBackgrounds.CLASSES.IMAGE_DIALOG);
+
+ for (var i = 0; i < coll_img.length; ++i) {
+ var tile = document.createElement('div');
+ tile.classList.add(customBackgrounds.CLASSES.COLLECTION_TILE);
+ tile.style.backgroundImage = 'url(' + coll_img[i].thumbnailImageUrl + ')';
+ tile.id = 'img_tile_' + i;
+ tile.dataset.url = coll_img[i].imageUrl;
+ tile.tabIndex = 0;
+
+ var tileInteraction = function(event) {
+ var tile = event.target;
+ if (selectedTile) {
+ selectedTile.classList.remove(
+ customBackgrounds.CLASSES.COLLECTION_SELECTED);
+ }
+ tile.classList.add(customBackgrounds.CLASSES.COLLECTION_SELECTED);
+ selectedTile = tile;
+
+ // Turn toggle off when an image is selected.
+ $(customBackgrounds.IDS.REFRESH_TOGGLE).children[0].checked = false;
+ $(customBackgrounds.IDS.DONE)
+ .classList.add(customBackgrounds.CLASSES.DONE_AVAILABLE);
+ };
+
+ tile.onclick = tileInteraction;
+ tile.onkeyup = function(event) {
+ if (event.keyCode === customBackgrounds.KEYCODES.ENTER) {
+ tileInteraction(event);
+ doneButton.focus();
+ }
+ };
+
+ tileContainer.appendChild(tile);
+ }
+
+ $('img_tile_0').focus();
+ doneButton.tabIndex = 0;
+
+ dailyRefresh.onclick = function(event) {
+ if (selectedTile) {
+ selectedTile.classList.remove(
+ customBackgrounds.CLASSES.COLLECTION_SELECTED);
+ selectedTile = null;
+ }
+ $(customBackgrounds.IDS.DONE)
+ .classList.add(customBackgrounds.CLASSES.DONE_AVAILABLE);
+ };
+
+ var setBackground = function(event) {
+ if (!selectedTile)
+ return;
+
+ overlay.close();
+ window.chrome.embeddedSearch.newTabPage.setBackgroundURL(
+ selectedTile.dataset.url);
+ customBackgrounds.resetSelectionDialog();
+ };
+
+ doneButton.onclick = setBackground;
+ doneButton.onkeyup = function(event) {
+ if (event.keyCode === customBackgrounds.KEYCODES.ENTER) {
+ setBackground(event);
+ $(customBackgrounds.IDS.EDIT_BG).focus();
+ }
+ };
+
+ backButton.onclick = function(event) {
+ customBackgrounds.resetSelectionDialog();
+ customBackgrounds.showCollectionSelectionDialog();
+ };
+};
+
+/**
+ * Load the NTPBackgroundCollections script. It'll create a global
+ * variable name "coll" which is a dict of background collections data.
+ * TODO(kmilka): add error UI as part of crbug.com/848981.
+ * @private
+ */
+customBackgrounds.loadCollections = function() {
+ var collElement = $('ntp-collection-loader');
+ if (collElement) {
+ collElement.parentNode.removeChild(collElement);
+ }
+ var collScript = document.createElement('script');
+ collScript.id = 'ntp-collection-loader';
+ collScript.src = 'chrome-search://local-ntp/ntp-background-collections.js';
+ document.body.appendChild(collScript);
+};
+
+/**
+ * Display dialog with various options for custom background source.
+ */
+customBackgrounds.initCustomBackgrounds = function() {
+ var editDialogOverlay = $(customBackgrounds.IDS.EDIT_BG_OVERLAY);
+ var editDialog = $(customBackgrounds.IDS.EDIT_BG_DIALOG);
+
+ $(customBackgrounds.IDS.CONNECT_GOOGLE_PHOTOS_TEXT).textContent =
+ configData.translatedStrings.connectGooglePhotos;
+ $(customBackgrounds.IDS.DEFAULT_WALLPAPERS_TEXT).textContent =
+ configData.translatedStrings.defaultWallpapers;
+ $(customBackgrounds.IDS.UPLOAD_IMAGE_TEXT).textContent =
+ configData.translatedStrings.uploadImage;
+ $(customBackgrounds.IDS.RESTORE_DEFAULT_TEXT).textContent =
+ configData.translatedStrings.restoreDefaultBackground;
+ $(customBackgrounds.IDS.OPTIONS_TITLE).textContent =
+ configData.translatedStrings.customizeBackground;
+ $(customBackgrounds.IDS.REFRESH_TEXT).textContent =
+ configData.translatedStrings.dailyRefresh;
+
+ // Control tab cycling through background options.
+ $(customBackgrounds.IDS.DEFAULT_WALLPAPERS).onkeydown = function(event) {
+ if (event.keyCode == customBackgrounds.KEYCODES.TAB) {
+ event.preventDefault();
+ $(customBackgrounds.IDS.RESTORE_DEFAULT).focus();
+ }
+ };
+
+ $(customBackgrounds.IDS.RESTORE_DEFAULT).onkeydown = function(event) {
+ if (event.keyCode == customBackgrounds.KEYCODES.TAB) {
+ event.preventDefault();
+ $(customBackgrounds.IDS.DEFAULT_WALLPAPERS).focus();
+ }
+ };
+
+ $(customBackgrounds.IDS.RESTORE_DEFAULT).onfocus = function() {
+ if (this.hidden) {
+ $(customBackgrounds.IDS.DEFAULT_WALLPAPERS).focus();
+ }
+ };
+
+ var editBackgroundInteraction = function(event) {
+ customBackgrounds.loadCollections();
+ $(customBackgrounds.IDS.EDIT_BG_OVERLAY)
+ .classList.add(customBackgrounds.CLASSES.SHOW_OVERLAY);
+ $(customBackgrounds.IDS.DEFAULT_WALLPAPERS).focus();
+ };
+
+ $(customBackgrounds.IDS.EDIT_BG).onclick = editBackgroundInteraction;
+ $(customBackgrounds.IDS.EDIT_BG).onkeyup = function(event) {
+ if (event.keyCode === customBackgrounds.KEYCODES.ENTER) {
+ editBackgroundInteraction(event);
+ }
+ };
+
+ var editDialogOverlayInteraction = function(event) {
+ editDialogOverlay.classList.remove(customBackgrounds.CLASSES.SHOW_OVERLAY);
+ $(customBackgrounds.IDS.EDIT_BG).focus();
+ };
+
+ editDialogOverlay.onclick = function(event) {
+ if (event.target == editDialogOverlay)
+ editDialogOverlayInteraction(event);
+ };
+ editDialogOverlay.onkeyup = function(event) {
+ if (event.keyCode === customBackgrounds.KEYCODES.ESC ||
+ event.keyCode === customBackgrounds.KEYCODES.BACKSPACE) {
+ editDialogOverlayInteraction(event);
+ }
+ };
+
+ var restoreDefaultInteraction = function(event) {
+ $(customBackgrounds.IDS.EDIT_BG_OVERLAY)
+ .classList.remove(customBackgrounds.CLASSES.SHOW_OVERLAY);
+ window.chrome.embeddedSearch.newTabPage.setBackgroundURL('');
+ $(customBackgrounds.IDS.EDIT_BG).focus();
+ };
+ $(customBackgrounds.IDS.RESTORE_DEFAULT).onclick = restoreDefaultInteraction;
+ $(customBackgrounds.IDS.RESTORE_DEFAULT).onkeyup = function(event) {
+ if (event.keyCode === customBackgrounds.KEYCODES.ENTER) {
+ restoreDefaultInteraction(event);
+ }
+ };
+
+ var defaultWallpapersInteraction = function(event) {
+ $(customBackgrounds.IDS.EDIT_BG_OVERLAY)
+ .classList.remove(customBackgrounds.CLASSES.SHOW_OVERLAY);
+ if (typeof coll != 'undefined') {
+ customBackgrounds.showCollectionSelectionDialog();
+ $('coll_tile_0').focus();
+ }
+ };
+ $(customBackgrounds.IDS.DEFAULT_WALLPAPERS).onclick =
+ defaultWallpapersInteraction;
+ $(customBackgrounds.IDS.DEFAULT_WALLPAPERS).onkeyup = function(event) {
+ if (event.keyCode === customBackgrounds.KEYCODES.ENTER) {
+ defaultWallpapersInteraction(event);
+ }
+ };
+
+ $(customBackgrounds.IDS.MENU).onkeyup = function(event) {
+ if (event.keyCode === customBackgrounds.KEYCODES.ESC ||
+ event.keyCode === customBackgrounds.KEYCODES.BACKSPACE) {
+ if ($(customBackgrounds.IDS.MENU)
+ .classList.contains(
+ customBackgrounds.CLASSES.COLLECTION_DIALOG)) {
+ $(customBackgrounds.IDS.OVERLAY).close();
+ $(customBackgrounds.IDS.EDIT_BG).focus();
+ } else {
+ customBackgrounds.resetSelectionDialog();
+ customBackgrounds.showCollectionSelectionDialog();
+ $('coll_tile_0').focus();
+ }
+ }
+ };
+};
diff --git a/chromium/chrome/browser/resources/local_ntp/local_ntp.css b/chromium/chrome/browser/resources/local_ntp/local_ntp.css
index e2ad0dd9167..251b0f236e8 100644
--- a/chromium/chrome/browser/resources/local_ntp/local_ntp.css
+++ b/chromium/chrome/browser/resources/local_ntp/local_ntp.css
@@ -3,6 +3,10 @@
* found in the LICENSE file. */
html {
+ /* Material Design constants */
+ --md-tile-height: 104px;
+ --md-tile-margin: 8px;
+
/* This will be overridden based on the viewport width, see below. */
--column-count: 2;
@@ -288,6 +292,14 @@ body.alternate-logo #logo-non-white {
transition: box-shadow 200ms cubic-bezier(0.4, 0, 0.2, 1);
}
+.md #fakebox {
+ background-color: rgb(241, 243, 244);
+ border-radius: 22px;
+ box-shadow: none;
+ margin: 0 auto;
+ max-width: 560px;
+}
+
.non-google-page #fakebox-container {
display: none;
}
@@ -297,6 +309,11 @@ body.fakebox-focused #fakebox {
box-shadow: 0 3px 8px 0 rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.08);
}
+.md #fakebox:hover,
+body.md.fakebox-focused #fakebox {
+ box-shadow: none;
+}
+
#fakebox > input {
bottom: 0;
box-sizing: border-box;
@@ -309,12 +326,20 @@ body.fakebox-focused #fakebox {
width: 100%;
}
+.md #fakebox > input {
+ padding-left: 20px;
+}
+
html[dir=rtl] #fakebox > input {
padding-left: 0;
padding-right: 8px;
right: 0;
}
+.md html[dir=rtl] #fakebox > input {
+ padding-right: 20px;
+}
+
#fakebox-text {
bottom: 4px;
color: rgba(0, 0, 0, 0.42);
@@ -333,6 +358,14 @@ html[dir=rtl] #fakebox > input {
white-space: nowrap;
}
+.md #fakebox-text {
+ color: rgb(128, 134, 139);
+ font-family: 'Roboto', arial, sans-serif;
+ font-size: 14px;
+ left: 0;
+ padding-left: 20px;
+}
+
html[dir=rtl] #fakebox-text {
left: auto;
right: 13px;
@@ -348,11 +381,19 @@ html[dir=rtl] #fakebox-text {
width: 1px;
}
+.md #fakebox-cursor {
+ left: 20px;
+}
+
html[dir=rtl] #fakebox-cursor {
left: auto;
right: 13px;
}
+.md html[dir=rtl] #fakebox-cursor {
+ right: 20px;
+}
+
#fakebox-microphone {
background: url(googlemic_clr_24px.svg) no-repeat center;
background-size: 24px 24px;
@@ -365,6 +406,12 @@ html[dir=rtl] #fakebox-cursor {
width: 41px;
}
+.md #fakebox-microphone {
+ background-size: 16px 16px;
+ margin-right: 12px;
+ width: 28px;
+}
+
html[dir=rtl] #fakebox-microphone {
left: 0;
right: auto;
@@ -399,6 +446,10 @@ body.fakebox-focused #fakebox-cursor {
user-select: none;
}
+.md-icons #most-visited {
+ margin-top: 30px;
+}
+
/* Non-Google pages have no Fakebox, so don't need top margin. */
.non-google-page #most-visited {
margin-top: 0;
@@ -415,6 +466,13 @@ body.fakebox-focused #fakebox-cursor {
width: var(--content-width);
}
+.md-icons #mv-tiles {
+ /* Two rows of tiles of 104px each, 8px of spacing after each row, and 10px of
+ * margin on top and bottom. If you change this, also change the corresponding
+ * values in most_visited_single.css. */
+ height: calc(2*(var(--md-tile-height) + var(--md-tile-margin)) + 2*10px);
+}
+
#mv-notice-x {
-webkit-mask-image: -webkit-image-set(
url(chrome-search://local-ntp/images/close_3_mask.png) 1x,
@@ -446,6 +504,29 @@ html[dir=rtl] #mv-notice-x {
background-color: rgb(66,133,244);
}
+.md-icons #mv-notice-x {
+ display: none;
+}
+
+#mv-notice-container {
+ width: 100%;
+}
+
+.md-icons #mv-notice-container {
+ bottom: -50px;
+ margin-bottom: 16px;
+ position: fixed;
+ transition: bottom 400ms;
+}
+
+.md-icons #mv-notice-container.float-up {
+ bottom: 0;
+}
+
+.md-icons #mv-notice-container.mv-notice-hide {
+ display: none;
+}
+
/* The notification shown when a tile is blacklisted. */
#mv-notice {
font-size: 12px;
@@ -454,6 +535,19 @@ html[dir=rtl] #mv-notice-x {
padding: 10px 0;
}
+.md-icons #mv-notice {
+ background-color: white;
+ border: 1px solid rgb(218, 220, 224);
+ /* Necessary for a "pill" shape. Using 50% creates an oval. */
+ border-radius: 500px;
+ font-family: 'Roboto';
+ font-weight: normal;
+ height: 32px;
+ margin: 0 auto;
+ padding: 0;
+ width: fit-content;
+}
+
#mv-notice span {
cursor: default;
display: inline-block;
@@ -462,6 +556,13 @@ html[dir=rtl] #mv-notice-x {
vertical-align: top;
}
+.md-icons #mv-notice span {
+ color: rgb(95,99,104);
+ height: auto;
+ line-height: 32px;
+ vertical-align: unset;
+}
+
/* Links in the notification. */
#mv-notice-links span {
-webkit-margin-start: 6px;
@@ -471,15 +572,34 @@ html[dir=rtl] #mv-notice-x {
padding: 0 4px;
}
+.md-icons #mv-notice-links span {
+ -webkit-margin-start: 0;
+ /* Necessary for a "pill" shape. Using 50% creates an oval. */
+ border-radius: 500px;
+ color: rgb(26,115,232);
+ padding: 0 16px;
+}
+
#mv-notice-links span:hover,
#mv-notice-links span:focus {
text-decoration: underline;
}
+.md-icons #mv-notice-links span:hover,
+.md-icons #mv-notice-links span:active {
+ background-color: rgba(26,115,232, 0.1);
+ text-decoration: none;
+ transition: background-color 200ms;
+}
+
#mv-msg {
color: var(--text-color);
}
+.md-icons #mv-msg {
+ padding: 0 16px;
+}
+
.default-theme.dark #mv-msg {
color: #fff;
}
@@ -535,3 +655,88 @@ html[dir=rtl] #attribution,
#one-google.hidden {
opacity: 0;
}
+
+.ripple-container {
+ height: 0;
+ left: 0;
+ overflow: hidden;
+ pointer-events: none;
+ position: absolute;
+ top: 0;
+ width: 0;
+ z-index: 100;
+}
+
+.ripple-effect {
+ background-color: rgba(26, 115, 232, 0.1);
+ border-radius: 50%;
+ height: 1px;
+ pointer-events: none;
+ transition: width, height, margin, background-color 400ms 250ms;
+ transition-duration: 400ms;
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
+ width: 1px;
+}
+
+/* The box containing the slider */
+.switch {
+ background-color: #fff;
+ border-radius: 8px;
+ display: inline-block;
+ height: 12px;
+ left: 3px;
+ position: absolute;
+ top: 2px;
+ transition: background-color linear 80ms;
+ width: 28px;
+ z-index: 0;
+}
+
+/* Hide default checkbox */
+.switch input {
+ display: none;
+}
+
+/* Rounded background element for the toggle */
+.toggle {
+ background-color: #ccc;
+ border-radius: 34px;
+ bottom: 0;
+ cursor: pointer;
+ display: block;
+ left: 0;
+ position: absolute;
+ right: 0;
+ top: 0;
+ transition: transform linear 80ms, background-color linear 80ms;
+}
+
+.toggle::before {
+ background-color: #fff;
+ border-radius: 50%;
+ bottom: -2px;
+ box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
+ content: '';
+ display: block;
+ height: 16px;
+ left: -6px;
+ position: absolute;
+ transition: transform linear 80ms, background-color linear 80ms;
+ width: 16px;
+}
+
+input:checked + .toggle {
+ background-color: rgba(26, 115, 232, .5);
+ box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
+}
+
+input:focus + .toggle {
+ box-shadow: 0 0 1px rgb(33, 150, 243);
+}
+
+input:checked + .toggle::before {
+ -webkit-transform: translateX(26px);
+ background-color: rgb(26, 115, 232);
+ transform: translateX(26px);
+}
+
diff --git a/chromium/chrome/browser/resources/local_ntp/local_ntp.html b/chromium/chrome/browser/resources/local_ntp/local_ntp.html
index d8ed2e62814..5aa76bd3f98 100644
--- a/chromium/chrome/browser/resources/local_ntp/local_ntp.html
+++ b/chromium/chrome/browser/resources/local_ntp/local_ntp.html
@@ -7,10 +7,13 @@
<link rel="stylesheet" href="chrome-search://local-ntp/theme.css"></link>
<link rel="stylesheet" href="chrome-search://local-ntp/local-ntp.css"></link>
<link rel="stylesheet" href="chrome-search://local-ntp/voice.css"></link>
+ <link rel="stylesheet" href="chrome-search://local-ntp/custom-backgrounds.css"></link>
<script src="chrome-search://local-ntp/local-ntp.js"
{{LOCAL_NTP_INTEGRITY}}></script>
<script src="chrome-search://local-ntp/voice.js"
{{LOCAL_NTP_VOICE_INTEGRITY}}></script>
+ <script src="chrome-search://local-ntp/custom-backgrounds.js"
+ {{LOCAL_NTP_CUSTOM_BG_INTEGRITY}}></script>
<meta charset="utf-8">
<meta name="google" value="notranslate">
</head>
@@ -56,19 +59,68 @@
<!-- The container for the tiles. The MV iframe goes in here. -->
<div id="mv-tiles"></div>
<!-- Notification shown when a tile is blacklisted. -->
- <div id="mv-notice" class="mv-notice-hide" role="alert">
- <span id="mv-msg"></span>
- <!-- Links in the notification. -->
- <span id="mv-notice-links">
- <span id="mv-undo" tabindex="0" role="button"></span>
- <span id="mv-restore" tabindex="0" role="button"></span>
- <div id="mv-notice-x" tabindex="0" role="button"></div>
- </span>
+ <div id="mv-notice-container">
+ <div id="mv-notice" class="mv-notice-hide" role="alert">
+ <span id="mv-msg"></span>
+ <!-- Links in the notification. -->
+ <span id="mv-notice-links">
+ <span id="mv-undo" class="ripple" tabindex="0" role="button"></span>
+ <span id="mv-restore" class="ripple" tabindex="0" role="button">
+ </span>
+ <div id="mv-notice-x" tabindex="0" role="button"></div>
+ </span>
+ </div>
</div>
</div>
<div id="attribution"><div id="attribution-text"></div></div>
+
+ <div id="edit-bg" tabindex="0" hidden>
+ <button id="edit-bg-gear"></button>
+ </div>
+
+ <div id="edit-bg-overlay">
+ <div id="edit-bg-dialog">
+ <div id="edit-bg-title"></div>
+ <div id="edit-bg-google-photos" class="bg-option" tabindex="0" hidden>
+ <div class="bg-option-img"></div>
+ <div id="edit-bg-google-photos-text" class="bg-option-text"></div>
+ </div>
+ <div id="edit-bg-default-wallpapers" class="bg-option" tabindex="0">
+ <div class="bg-option-img"></div>
+ <div id="edit-bg-default-wallpapers-text" class="bg-option-text">
+ </div>
+ </div>
+ <div id="edit-bg-upload-image" class="bg-option" tabindex="0" hidden>
+ <div class="bg-option-img"></div>
+ <div id="edit-bg-upload-image-text" class="bg-option-text"></div>
+ </div>
+ <div id="edit-bg-restore-default" class="bg-option" tabindex="0">
+ <div class="bg-option-img"></div>
+ <div id="edit-bg-restore-default-text" class="bg-option-text"></div>
+ </div>
+ </div>
+ </div>
+
</div>
+ <dialog id="bg-sel-menu-overlay">
+ <div id="bg-sel-menu">
+ <div id="bg-sel-title-bar">
+ <div id="bg-sel-back"></div>
+ <div id="bg-sel-title"></div>
+ </div>
+ <div id="bg-sel-tiles"></div>
+ <div id="bg-sel-footer">
+ <label id="bg-daily-refresh" class="switch">
+ <input type="checkbox">
+ <span class="toggle"></span>
+ </label>
+ <div id="bg-sel-refresh-text"></div>
+ <div id="bg-sel-footer-done"></div>
+ </div>
+ </div>
+ </dialog>
+
<dialog id="voice-overlay-dialog" class="overlay-dialog">
<div id="voice-overlay" class="overlay-hidden">
<button id="voice-close-button" class="close-button">&times;</button>
diff --git a/chromium/chrome/browser/resources/local_ntp/local_ntp.js b/chromium/chrome/browser/resources/local_ntp/local_ntp.js
index 516f1392774..dfe83409d8d 100644
--- a/chromium/chrome/browser/resources/local_ntp/local_ntp.js
+++ b/chromium/chrome/browser/resources/local_ntp/local_ntp.js
@@ -75,12 +75,21 @@ var CLASSES = {
DELAYED_HIDE_NOTIFICATION: 'mv-notice-delayed-hide',
FADE: 'fade', // Enables opacity transition on logo and doodle.
FAKEBOX_FOCUS: 'fakebox-focused', // Applies focus styles to the fakebox
+ // Applies float animations to the Most Visited notification
+ FLOAT_UP: 'float-up',
+ // Applies ripple animation to the element on click
+ RIPPLE: 'ripple',
+ RIPPLE_CONTAINER: 'ripple-container',
+ RIPPLE_EFFECT: 'ripple-effect',
// Applies drag focus style to the fakebox
FAKEBOX_DRAG_FOCUS: 'fakebox-drag-focused',
HIDE_FAKEBOX_AND_LOGO: 'hide-fakebox-logo',
HIDE_NOTIFICATION: 'mv-notice-hide',
INITED: 'inited', // Reveals the <body> once init() is done.
LEFT_ALIGN_ATTRIBUTION: 'left-align-attribution',
+ MATERIAL_DESIGN: 'md', // Applies Material Design styles to the page
+ MATERIAL_DESIGN_ICONS:
+ 'md-icons', // Applies Material Design styles to Most Visited.
// Vertically centers the most visited section for a non-Google provided page.
NON_GOOGLE_PAGE: 'non-google-page',
NON_WHITE_BG: 'non-white-bg',
@@ -108,14 +117,16 @@ var IDS = {
LOGO_DOODLE_IFRAME: 'logo-doodle-iframe',
LOGO_DOODLE_BUTTON: 'logo-doodle-button',
LOGO_DOODLE_NOTIFIER: 'logo-doodle-notifier',
+ MOST_VISITED: 'most-visited',
NOTIFICATION: 'mv-notice',
+ NOTIFICATION_CONTAINER: 'mv-notice-container',
NOTIFICATION_CLOSE_BUTTON: 'mv-notice-x',
NOTIFICATION_MESSAGE: 'mv-msg',
NTP_CONTENTS: 'ntp-contents',
RESTORE_ALL_LINK: 'mv-restore',
TILES: 'mv-tiles',
TILES_IFRAME: 'mv-single',
- UNDO_LINK: 'mv-undo'
+ UNDO_LINK: 'mv-undo',
};
@@ -169,6 +180,8 @@ var LOG_TYPE = {
*/
var WHITE_BACKGROUND_COLORS = ['rgba(255,255,255,1)', 'rgba(0,0,0,0)'];
+const CUSTOM_BACKGROUND_OVERLAY =
+ 'linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2))';
/**
* Enum for keycodes.
@@ -179,6 +192,27 @@ var KEYCODE = {ENTER: 13, SPACE: 32};
/**
+ * The period of time (ms) before the Most Visited notification is hidden.
+ * @type {number}
+ */
+const NOTIFICATION_TIMEOUT = 10000;
+
+
+/**
+ * The duration of the ripple animation.
+ * @type {number}
+ */
+const RIPPLE_DURATION_MS = 800;
+
+
+/**
+ * The max size of the ripple animation.
+ * @type {number}
+ */
+const RIPPLE_MAX_RADIUS_PX = 300;
+
+
+/**
* The last blacklisted tile rid if any, which by definition should not be
* filler.
* @type {?number}
@@ -187,6 +221,14 @@ var lastBlacklistedTile = null;
/**
+ * The timeout id for automatically hiding the Most Visited notification.
+ * Invalid ids will silently do nothing.
+ * @type {number}
+ */
+let delayedHideNotification = -1;
+
+
+/**
* The browser embeddedSearch.newTabPage object.
* @type {Object}
*/
@@ -236,7 +278,6 @@ function getIsThemeDark() {
return luminance >= 128;
}
-
/**
* Updates the NTP based on the current theme.
* @private
@@ -260,6 +301,19 @@ function renderTheme() {
document.body.classList.toggle(CLASSES.NON_WHITE_BG, isNonWhiteBackground);
updateThemeAttribution(info.attributionUrl, info.imageHorizontalAlignment);
setCustomThemeStyle(info);
+
+ if (info.customBackgroundConfigured) {
+ var imageWithOverlay =
+ [CUSTOM_BACKGROUND_OVERLAY, info.imageUrl].join(',').trim();
+ document.body.style.setProperty('background-image', imageWithOverlay);
+ }
+ $(customBackgrounds.IDS.RESTORE_DEFAULT).hidden =
+ !info.customBackgroundConfigured;
+
+ if (configData.isGooglePage) {
+ $('edit-bg').hidden =
+ !configData.isCustomBackgroundsEnabled || !info.usingDefaultTheme;
+ }
}
/**
@@ -437,11 +491,25 @@ function reloadTiles() {
* Shows the blacklist notification and triggers a delay to hide it.
*/
function showNotification() {
- var notification = $(IDS.NOTIFICATION);
- notification.classList.remove(CLASSES.HIDE_NOTIFICATION);
- notification.classList.remove(CLASSES.DELAYED_HIDE_NOTIFICATION);
- notification.scrollTop;
- notification.classList.add(CLASSES.DELAYED_HIDE_NOTIFICATION);
+ if (configData.isMDIconsEnabled || configData.isMDUIEnabled) {
+ $(IDS.NOTIFICATION).classList.remove(CLASSES.HIDE_NOTIFICATION);
+ // Timeout is required for the "float up" transition to work. Modifying the
+ // "display" property prevents transitions from activating.
+ window.setTimeout(() => {
+ $(IDS.NOTIFICATION_CONTAINER).classList.add(CLASSES.FLOAT_UP);
+ }, 20);
+
+ // Automatically hide the notification after a period of time.
+ delayedHideNotification = window.setTimeout(() => {
+ hideNotification();
+ }, NOTIFICATION_TIMEOUT);
+ } else {
+ var notification = $(IDS.NOTIFICATION);
+ notification.classList.remove(CLASSES.HIDE_NOTIFICATION);
+ notification.classList.remove(CLASSES.DELAYED_HIDE_NOTIFICATION);
+ notification.scrollTop;
+ notification.classList.add(CLASSES.DELAYED_HIDE_NOTIFICATION);
+ }
}
@@ -449,9 +517,26 @@ function showNotification() {
* Hides the blacklist notification.
*/
function hideNotification() {
- var notification = $(IDS.NOTIFICATION);
- notification.classList.add(CLASSES.HIDE_NOTIFICATION);
- notification.classList.remove(CLASSES.DELAYED_HIDE_NOTIFICATION);
+ if (configData.isMDIconsEnabled || configData.isMDUIEnabled) {
+ let notification = $(IDS.NOTIFICATION_CONTAINER);
+ if (!notification.classList.contains(CLASSES.FLOAT_UP)) {
+ return;
+ }
+ window.clearTimeout(delayedHideNotification);
+ notification.classList.remove(CLASSES.FLOAT_UP);
+
+ let afterHide = (event) => {
+ if (event.propertyName == 'bottom') {
+ $(IDS.NOTIFICATION).classList.add(CLASSES.HIDE_NOTIFICATION);
+ notification.removeEventListener('transitionend', afterHide);
+ }
+ };
+ notification.addEventListener('transitionend', afterHide);
+ } else {
+ var notification = $(IDS.NOTIFICATION);
+ notification.classList.add(CLASSES.HIDE_NOTIFICATION);
+ notification.classList.remove(CLASSES.DELAYED_HIDE_NOTIFICATION);
+ }
}
@@ -593,6 +678,89 @@ function handlePostMessage(event) {
/**
+ * Enables Material Design styles for all of NTP.
+ */
+function enableMD() {
+ document.body.classList.add(CLASSES.MATERIAL_DESIGN);
+ enableMDIcons();
+}
+
+
+/**
+ * Enables Material Design styles for the Most Visited section.
+ */
+function enableMDIcons() {
+ $(IDS.MOST_VISITED).classList.add(CLASSES.MATERIAL_DESIGN_ICONS);
+ $(IDS.TILES).classList.add(CLASSES.MATERIAL_DESIGN_ICONS);
+ addRippleAnimations();
+}
+
+
+/**
+ * Enables ripple animations for elements with CLASSES.RIPPLE.
+ * TODO(kristipark): Remove after migrating to WebUI.
+ */
+function addRippleAnimations() {
+ let ripple = (event) => {
+ let target = event.target;
+ const rect = target.getBoundingClientRect();
+ const x = Math.round(event.clientX - rect.left);
+ const y = Math.round(event.clientY - rect.top);
+
+ // Calculate radius
+ const corners = [
+ {x: 0, y: 0},
+ {x: rect.width, y: 0},
+ {x: 0, y: rect.height},
+ {x: rect.width, y: rect.height},
+ ];
+ let distance = (x1, y1, x2, y2) => {
+ var xDelta = x1 - x2;
+ var yDelta = y1 - y2;
+ return Math.sqrt(xDelta * xDelta + yDelta * yDelta);
+ };
+ let cornerDistances = corners.map(function(corner) {
+ return Math.round(distance(x, y, corner.x, corner.y));
+ });
+ const radius =
+ Math.min(RIPPLE_MAX_RADIUS_PX, Math.max.apply(Math, cornerDistances));
+
+ let ripple = document.createElement('div');
+ let rippleContainer = document.createElement('div');
+ ripple.classList.add(CLASSES.RIPPLE_EFFECT);
+ rippleContainer.classList.add(CLASSES.RIPPLE_CONTAINER);
+ rippleContainer.appendChild(ripple);
+ target.appendChild(rippleContainer);
+ // Ripple start location
+ ripple.style.marginLeft = x + 'px';
+ ripple.style.marginTop = y + 'px';
+
+ rippleContainer.style.left = rect.left + 'px';
+ rippleContainer.style.width = target.offsetWidth + 'px';
+ rippleContainer.style.height = target.offsetHeight + 'px';
+ rippleContainer.style.borderRadius =
+ window.getComputedStyle(target).borderRadius;
+
+ // Start transition/ripple
+ ripple.style.width = radius * 2 + 'px';
+ ripple.style.height = radius * 2 + 'px';
+ ripple.style.marginLeft = x - radius + 'px';
+ ripple.style.marginTop = y - radius + 'px';
+ ripple.style.backgroundColor = 'rgba(0, 0, 0, 0)';
+
+ window.setTimeout(function() {
+ ripple.remove();
+ rippleContainer.remove();
+ }, RIPPLE_DURATION_MS);
+ };
+
+ let rippleElements = document.querySelectorAll('.' + CLASSES.RIPPLE);
+ for (let i = 0; i < rippleElements.length; i++) {
+ rippleElements[i].addEventListener('mousedown', ripple);
+ }
+}
+
+/**
* Prepares the New Tab Page by adding listeners, the most visited pages
* section, and Google-specific elements for a Google-provided page.
*/
@@ -604,7 +772,11 @@ function init() {
}
// Hide notifications after fade out, so we can't focus on links via keyboard.
- $(IDS.NOTIFICATION).addEventListener('transitionend', hideNotification);
+ $(IDS.NOTIFICATION).addEventListener('transitionend', (event) => {
+ if (event.properyName === 'opacity') {
+ hideNotification();
+ }
+ });
$(IDS.NOTIFICATION_MESSAGE).textContent =
configData.translatedStrings.thumbnailRemovedNotification;
@@ -638,6 +810,15 @@ function init() {
var searchboxApiHandle = embeddedSearchApiHandle.searchBox;
if (configData.isGooglePage) {
+ if (configData.isMDUIEnabled) {
+ enableMD();
+ } else if (configData.isMDIconsEnabled) {
+ enableMDIcons();
+ }
+
+ if (configData.isCustomBackgroundsEnabled)
+ customBackgrounds.initCustomBackgrounds();
+
// Set up the fakebox (which only exists on the Google NTP).
ntpApiHandle.oninputstart = onInputStart;
ntpApiHandle.oninputcancel = onInputCancel;
@@ -762,6 +943,10 @@ function init() {
args.push('removeTooltip=' +
encodeURIComponent(configData.translatedStrings.removeThumbnailTooltip));
+ if (configData.isMDIconsEnabled || configData.isMDUIEnabled) {
+ args.push('enableMD=1');
+ }
+
// Create the most visited iframe.
var iframe = document.createElement('iframe');
iframe.id = IDS.TILES_IFRAME;
diff --git a/chromium/chrome/browser/resources/local_ntp/most_visited_single.css b/chromium/chrome/browser/resources/local_ntp/most_visited_single.css
index e64af31bc38..733d3f93aef 100644
--- a/chromium/chrome/browser/resources/local_ntp/most_visited_single.css
+++ b/chromium/chrome/browser/resources/local_ntp/most_visited_single.css
@@ -3,6 +3,21 @@
* found in the LICENSE file. */
html {
+ /* Material Design constants */
+ --md-favicon-size: 16px;
+ --md-icon-margin-bottom: 16px;
+ --md-icon-size: 40px;
+ --md-max-tiles-row: 5;
+ --md-menu-margin-side: 2px;
+ --md-menu-margin-top: 4px;
+ --md-menu-size: 12px;
+ --md-tile-height: 104px;
+ --md-tile-margin: 8px;
+ --md-tile-padding: 8px;
+ --md-tile-width: 88px;
+ --md-title-font-size: 12px;
+ --md-title-height: 32px;
+
/* Constants. */
--tile-height: 128px;
--tile-margin: 16px;
@@ -40,6 +55,11 @@ a:visited {
user-select: none;
}
+.md #most-visited {
+ margin: 10px 0;
+ width: 100%
+}
+
#mv-tiles,
.mv-tiles-old {
font-size: 0;
@@ -57,6 +77,23 @@ a:visited {
user-select: none;
}
+.md #mv-tiles {
+ display: flex;
+ flex-wrap: wrap;
+ height: auto;
+ justify-content: center;
+ line-height: normal;
+ margin: 0;
+ /* 5 88px tiles per row. If you change this, also change the corresponding
+ * values in local_ntp.css. */
+ max-width: calc(var(--md-tile-width) * var(--md-max-tiles-row));
+ position: static;
+}
+
+.md .mv-tiles-old {
+ display: none;
+}
+
.mv-tile,
.mv-empty-tile {
border-radius: 2px;
@@ -201,7 +238,7 @@ body.dark-theme .mv-thumb.failed-img {
background-color: #555;
}
-/* We use ::after without content to provide an aditional element on top of the
+/* We use ::after without content to provide an additional element on top of the
* thumbnail. */
.mv-thumb.failed-img::after {
border: 8px solid rgb(215,215,215);
@@ -334,3 +371,188 @@ html[dir=rtl] .mv-favicon {
.mv-favicon.failed-favicon img {
display: none;
}
+
+.md-tile {
+ border-radius: 4px;
+ box-sizing: border-box;
+ cursor: pointer;
+ height: var(--md-tile-height);
+ margin-bottom: var(--md-tile-margin);
+ opacity: 1;
+ padding: var(--md-tile-padding);
+ position: relative;
+ transition-property: background, border-color, box-shadow, opacity;
+ width: var(--md-tile-width);
+}
+
+.md-empty-tile {
+ display: none;
+}
+
+.md-tile:hover {
+ background-color: rgba(33, 32, 36, 0.06);
+}
+
+body.dark-theme .md-tile:hover {
+ background-color: rgba(255, 255, 255, 0.1);
+}
+
+.md-tile:hover > .md-menu {
+ opacity: 1;
+}
+
+.md-tile:active,
+body.dark-theme .md-tile:active {
+ background-color: white;
+ box-shadow: 0 1px 3px 0 rgba(60, 64, 67, 0.3),
+ 0 4px 8px 3px rgba(60, 64, 67, 0.15);
+ transition-duration: 200ms;
+ z-index: 10;
+}
+
+body.dark-theme .md-tile:active .md-title {
+ color: rgba(33, 32, 36, 0.86);
+}
+
+body.dark-theme .md-tile:active .md-menu::after {
+ background-color: rgba(33, 32, 36, 0.71);
+}
+
+.md-tile.blacklisted {
+ margin: 0;
+ padding: 0;
+ transform: scale(0, 0);
+ transition-duration: 200ms;
+ transition-property: transform, box-shadow, margin, opacity, padding, width;
+ width: 0;
+}
+
+.md-tile-inner {
+ align-items: center;
+ display: flex;
+ flex-flow: column nowrap;
+ height: 100%;
+ position: relative;
+ width: 100%;
+ z-index: -1;
+}
+
+.md-link {
+ height: 100%;
+ left: 0;
+ position: absolute;
+ right: 0;
+ top: 0;
+ width: 100%;
+}
+
+.md-icon {
+ margin-bottom: var(--md-icon-margin-bottom);
+}
+
+.md-icon-background {
+ align-items: center;
+ background-color: rgb(241, 243, 244);
+ border-radius: 50%;
+ display: flex;
+ height: var(--md-icon-size);
+ justify-content: center;
+ width: var(--md-icon-size);
+}
+
+.md-favicon {
+ height: var(--md-favicon-size);
+ pointer-events: none;
+ width: var(--md-favicon-size);
+}
+
+.md-favicon img {
+ height: 100%;
+ width: 100%;
+}
+
+.md-favicon.failed-favicon {
+ background-image: -webkit-image-set(
+ url(chrome-search://local-ntp/images/ntp_default_favicon.png) 1x,
+ url(chrome-search://local-ntp/images/ntp_default_favicon.png@2x) 2x);
+ background-repeat: no-repeat;
+ background-size: var(--md-favicon-size) var(--md-favicon-size);
+}
+
+.md-favicon.failed-favicon img {
+ display: none;
+}
+
+.md-title-container {
+ overflow: hidden;
+}
+
+.md-title {
+ color: rgba(33, 32, 36, 0.86);
+ font-family: 'Roboto';
+ font-size: var(--md-title-font-size);
+ height: var(--md-title-height);
+ line-height: 1.4em;
+ text-align: center;
+ width: 100%;
+ word-break: break-word;
+ word-wrap: break-word;
+}
+
+body.dark-theme .md-title {
+ color: rgb(248, 249, 250);
+}
+
+.md-menu {
+ background-color: transparent;
+ border: none;
+ cursor: pointer;
+ height: var(--md-menu-size);
+ margin: var(--md-menu-margin-top) var(--md-menu-margin-side);
+ opacity: 0;
+ position: absolute;
+ right: 0;
+ top: 0;
+ width: var(--md-menu-size);
+}
+
+.md-menu:focus {
+ opacity: 1;
+}
+
+/* We use ::after without content to provide the masked X element. */
+.md-menu::after {
+ --mask-width: calc(var(--md-menu-size) - 2);
+ -webkit-mask-image: -webkit-image-set(
+ url(chrome-search://local-ntp/images/close_3_mask.png) 1x,
+ url(chrome-search://local-ntp/images/close_3_mask.png@2x) 2x);
+ -webkit-mask-repeat: no-repeat;
+ -webkit-mask-size: var(--mask-width);
+ background-color: rgba(33, 32, 36, 0.55);
+ content: '';
+ display: block;
+ height: var(--md-menu-size);
+ left: 0;
+ position: absolute;
+ top: 0;
+ width: var(--md-menu-size);
+}
+
+body.dark-theme .md-menu::after {
+ background-color: white;
+}
+
+html[dir=rtl] .md-menu {
+ left: 0;
+ right: auto;
+}
+
+.md-menu:hover::after,
+.md-menu:focus::after {
+ background-color: rgba(33, 32, 36, 0.71);
+}
+
+body.dark-theme .md-menu:hover::after,
+body.dark-theme .md-menu:focus::after {
+ background-color: rgb(218, 220, 224);
+}
diff --git a/chromium/chrome/browser/resources/local_ntp/most_visited_single.js b/chromium/chrome/browser/resources/local_ntp/most_visited_single.js
index 9bdd106296f..cad4e9030e3 100644
--- a/chromium/chrome/browser/resources/local_ntp/most_visited_single.js
+++ b/chromium/chrome/browser/resources/local_ntp/most_visited_single.js
@@ -8,6 +8,28 @@
/**
+ * Enum for classnames.
+ * @enum {string}
+ * @const
+ */
+const CLASSES = {
+ FAILED_FAVICON: 'failed-favicon', // Applied when the favicon fails to load.
+ MATERIAL_DESIGN: 'md', // Applies Material Design styles to the page.
+ // Material Design classes.
+ MD_EMPTY_TILE: 'md-empty-tile',
+ MD_FAVICON: 'md-favicon',
+ MD_LINK: 'md-link',
+ MD_ICON: 'md-icon',
+ MD_ICON_BACKGROUND: 'md-icon-background',
+ MD_MENU: 'md-menu',
+ MD_TILE: 'md-tile',
+ MD_TILE_INNER: 'md-tile-inner',
+ MD_TITLE: 'md-title',
+ MD_TITLE_CONTAINER: 'md-title-container',
+};
+
+
+/**
* The different types of events that are logged from the NTP. This enum is
* used to transfer information from the NTP JavaScript to the renderer and is
* not used as a UMA enum histogram's logged value.
@@ -89,6 +111,13 @@ var queryArgs = {};
/**
+ * True if Material Design styles should be applied.
+ * @type {boolean}
+ */
+let isMDEnabled = false;
+
+
+/**
* Log an event on the NTP.
* @param {number} eventType Event from LOG_TYPE.
*/
@@ -252,6 +281,11 @@ var swapInNewTiles = function() {
// Add new tileset.
cur.id = 'mv-tiles';
parent.appendChild(cur);
+ if (isMDEnabled) {
+ // Called after appending to document so that css styles are active.
+ truncateTitleText(
+ parent.lastChild.querySelectorAll('.' + CLASSES.MD_TITLE));
+ }
// getComputedStyle causes the initial style (opacity 0) to be applied, so
// that when we then set it to 1, that triggers the CSS transition.
if (fadeIn) {
@@ -266,6 +300,25 @@ var swapInNewTiles = function() {
/**
+ * Truncates titles that are longer than two lines and appends an ellipsis. Text
+ * overflow in CSS ("text-overflow: ellipsis") cannot handle multiple lines.
+ */
+function truncateTitleText(titles) {
+ for (let i = 0; i < titles.length; i++) {
+ let el = titles[i];
+ const originalTitle = el.innerText;
+ let truncatedTitle = el.innerText;
+ while (el.scrollHeight > el.offsetHeight && truncatedTitle.length > 0) {
+ el.innerText = (truncatedTitle = truncatedTitle.slice(0, -1)) + '...';
+ }
+ if (truncatedTitle.length == 0) {
+ console.error('Title truncation failed: ' + originalTitle);
+ }
+ }
+}
+
+
+/**
* Handler for the 'show' message from the host page, called when it wants to
* add a suggestion tile.
* It's also used to fill up our tiles to NUMBER_OF_TILES if necessary.
@@ -326,6 +379,19 @@ var isSchemeAllowed = function(url) {
* data is null if you want to construct an empty tile.
*/
var renderTile = function(data) {
+ if (isMDEnabled) {
+ return renderMaterialDesignTile(data);
+ }
+ return renderMostVisitedTile(data);
+};
+
+
+/**
+ * @param {object} data Object containing rid, url, title, favicon, thumbnail.
+ * data is null if you want to construct an empty tile.
+ * @return {Element}
+ */
+var renderMostVisitedTile = function(data) {
var tile = document.createElement('a');
if (data == null) {
@@ -407,7 +473,7 @@ var renderTile = function(data) {
fi.addEventListener('load', countLoad);
fi.addEventListener('error', countLoad);
fi.addEventListener('error', function(ev) {
- favicon.classList.add('failed-favicon');
+ favicon.classList.add(CLASSES.FAILED_FAVICON);
});
favicon.appendChild(fi);
tile.appendChild(favicon);
@@ -473,6 +539,132 @@ var renderTile = function(data) {
/**
+ * Renders a MostVisited tile with Material Design styles.
+ * @param {object} data Object containing rid, url, title, favicon. data is null
+ * if you want to construct an empty tile.
+ * @return {Element}
+ */
+function renderMaterialDesignTile(data) {
+ let mdTile = document.createElement('a');
+
+ if (data == null) {
+ mdTile.className = CLASSES.MD_EMPTY_TILE;
+ return mdTile;
+ }
+
+ // The tile will be appended to tiles.
+ const position = tiles.children.length;
+ // This is set in the load/error event for the favicon image.
+ let tileType = TileVisualType.NONE;
+
+ mdTile.className = CLASSES.MD_TILE;
+ mdTile.setAttribute('data-tid', data.tid);
+ mdTile.setAttribute('data-pos', position);
+ if (isSchemeAllowed(data.url)) {
+ mdTile.href = data.url;
+ }
+ mdTile.setAttribute('aria-label', data.title);
+ mdTile.title = data.title;
+
+ mdTile.addEventListener('click', function(ev) {
+ logMostVisitedNavigation(
+ position, data.tileTitleSource, data.tileSource, tileType,
+ data.dataGenerationTime);
+ });
+ mdTile.addEventListener('keydown', function(event) {
+ if (event.keyCode == 46 /* DELETE */ ||
+ event.keyCode == 8 /* BACKSPACE */) {
+ event.preventDefault();
+ event.stopPropagation();
+ blacklistTile(this);
+ } else if (
+ event.keyCode == 13 /* ENTER */ || event.keyCode == 32 /* SPACE */) {
+ event.preventDefault();
+ this.click();
+ } else if (event.keyCode == 37 /* LEFT */) {
+ const tiles = document.querySelectorAll('#mv-tiles .' + CLASSES.MD_TILE);
+ tiles[Math.max(this.getAttribute('data-pos') - 1, 0)].focus();
+ } else if (event.keyCode == 39 /* RIGHT */) {
+ const tiles = document.querySelectorAll('#mv-tiles .' + CLASSES.MD_TILE);
+ tiles[Math.min(this.getAttribute('data-pos') + 1, tiles.length - 1)]
+ .focus();
+ }
+ });
+
+ let mdTileInner = document.createElement('div');
+ mdTileInner.className = CLASSES.MD_TILE_INNER;
+
+ let mdIcon = document.createElement('div');
+ mdIcon.className = CLASSES.MD_ICON;
+ let mdIconBackground = document.createElement('div');
+ mdIconBackground.className = CLASSES.MD_ICON_BACKGROUND;
+
+ let mdFavicon = document.createElement('div');
+ mdFavicon.className = CLASSES.MD_FAVICON;
+ let fi = document.createElement('img');
+ fi.src = data.faviconUrl;
+ // Set title and alt to empty so screen readers won't say the image name.
+ fi.title = '';
+ fi.alt = '';
+ loadedCounter += 1;
+ fi.addEventListener('load', function(ev) {
+ // Store the type for a potential later navigation.
+ tileType = TileVisualType.ICON_REAL;
+ logMostVisitedImpression(
+ position, data.tileTitleSource, data.tileSource, tileType,
+ data.dataGenerationTime);
+ // Note: It's important to call countLoad last, because that might emit the
+ // NTP_ALL_TILES_LOADED event, which must happen after the impression log.
+ countLoad();
+ });
+ fi.addEventListener('error', function(ev) {
+ mdFavicon.classList.add(CLASSES.FAILED_FAVICON);
+ thumb.removeChild(img);
+ // Store the type for a potential later navigation.
+ tileType = TileVisualType.ICON_DEFAULT;
+ logMostVisitedImpression(
+ position, data.tileTitleSource, data.tileSource, tileType,
+ data.dataGenerationTime);
+ // Note: It's important to call countLoad last, because that might emit the
+ // NTP_ALL_TILES_LOADED event, which must happen after the impression log.
+ countLoad();
+ });
+ mdFavicon.appendChild(fi);
+ mdIconBackground.appendChild(mdFavicon);
+ mdIcon.appendChild(mdIconBackground);
+ mdTileInner.appendChild(mdIcon);
+
+ let mdTitleContainer = document.createElement('div');
+ mdTitleContainer.className = CLASSES.MD_TITLE_CONTAINER;
+ let mdTitle = document.createElement('div');
+ mdTitle.className = CLASSES.MD_TITLE;
+ mdTitle.innerText = data.title;
+ mdTitle.style.direction = data.direction || 'ltr';
+ mdTitleContainer.appendChild(mdTitle);
+ mdTileInner.appendChild(mdTitleContainer);
+
+ let mdMenu = document.createElement('button');
+ mdMenu.className = CLASSES.MD_MENU;
+ mdMenu.title = queryArgs['removeTooltip'] || '';
+ mdMenu.addEventListener('click', function(ev) {
+ removeAllOldTiles();
+ blacklistTile(mdTile);
+ ev.preventDefault();
+ ev.stopPropagation();
+ });
+ // Don't allow the event to bubble out to the containing tile, as that would
+ // trigger navigation to the tile URL.
+ mdMenu.addEventListener('keydown', function(event) {
+ event.stopPropagation();
+ });
+
+ mdTile.appendChild(mdTileInner);
+ mdTile.appendChild(mdMenu);
+ return mdTile;
+}
+
+
+/**
* Does some initialization and parses the query arguments passed to the iframe.
*/
var init = function() {
@@ -504,6 +696,12 @@ var init = function() {
html.dir = 'rtl';
}
+ // Enable Material Design.
+ if (queryArgs['enableMD'] == '1') {
+ isMDEnabled = true;
+ document.body.classList.add(CLASSES.MATERIAL_DESIGN);
+ }
+
window.addEventListener('message', handlePostMessage);
};
diff --git a/chromium/chrome/browser/resources/md_bookmarks/BUILD.gn b/chromium/chrome/browser/resources/md_bookmarks/BUILD.gn
index 166396b95e3..400eacb490a 100644
--- a/chromium/chrome/browser/resources/md_bookmarks/BUILD.gn
+++ b/chromium/chrome/browser/resources/md_bookmarks/BUILD.gn
@@ -174,6 +174,7 @@ js_library("list") {
":item",
":store_client",
"//third_party/polymer/v1_0/components-chromium/iron-list:iron-list-extracted",
+ "//ui/webui/resources/js:list_property_update_behavior",
"//ui/webui/resources/js:load_time_data",
]
}
diff --git a/chromium/chrome/browser/resources/md_bookmarks/command_manager.js b/chromium/chrome/browser/resources/md_bookmarks/command_manager.js
index 28ba9b4c02d..f91cfb161a3 100644
--- a/chromium/chrome/browser/resources/md_bookmarks/command_manager.js
+++ b/chromium/chrome/browser/resources/md_bookmarks/command_manager.js
@@ -795,7 +795,7 @@ cr.define('bookmarks', function() {
* @private
*/
onMenuMousedown_: function(e) {
- if (e.path[0] != this.$.dropdown.getIfExists())
+ if (e.path[0].tagName != 'DIALOG')
return;
this.closeCommandMenu();
diff --git a/chromium/chrome/browser/resources/md_bookmarks/list.html b/chromium/chrome/browser/resources/md_bookmarks/list.html
index 23a8d332748..bd56c510a0b 100644
--- a/chromium/chrome/browser/resources/md_bookmarks/list.html
+++ b/chromium/chrome/browser/resources/md_bookmarks/list.html
@@ -1,5 +1,6 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-a11y-announcer/iron-a11y-announcer.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-list/iron-list.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/shadow.html">
@@ -8,6 +9,7 @@
<link rel="import" href="chrome://bookmarks/shared_style.html">
<link rel="import" href="chrome://bookmarks/store_client.html">
<link rel="import" href="chrome://bookmarks/util.html">
+<link rel="import" href="chrome://resources/html/list_property_update_behavior.html">
<dom-module id="bookmarks-list">
<template>
@@ -22,6 +24,7 @@
#list {
@apply --shadow-elevation-2dp;
background-color: #fff;
+ border-radius: var(--cr-card-border-radius);
margin: 0 auto;
max-width: var(--card-max-width);
padding: 8px 0;
diff --git a/chromium/chrome/browser/resources/md_bookmarks/list.js b/chromium/chrome/browser/resources/md_bookmarks/list.js
index 11b1580b221..ba5fbcb993b 100644
--- a/chromium/chrome/browser/resources/md_bookmarks/list.js
+++ b/chromium/chrome/browser/resources/md_bookmarks/list.js
@@ -7,6 +7,7 @@ Polymer({
behaviors: [
bookmarks.StoreClient,
+ ListPropertyUpdateBehavior,
],
properties: {
@@ -95,30 +96,11 @@ Polymer({
* @param {Array<string>} oldValue
*/
onDisplayedIdsChanged_: function(newValue, oldValue) {
- if (!oldValue) {
- this.displayedList_ = this.displayedIds_.map(function(id) {
- return {id: id};
- });
- } else {
- const splices = Polymer.ArraySplice.calculateSplices(
- /** @type {!Array<string>} */ (newValue),
- /** @type {!Array<string>} */ (oldValue));
- splices.forEach((splice) => {
- // TODO(calamity): Could use notifySplices to improve performance here.
- const additions =
- newValue.slice(splice.index, splice.index + splice.addedCount)
- .map(function(id) {
- return {id: id};
- });
- this.splice.apply(this, [
- 'displayedList_', splice.index, splice.removed.length
- ].concat(additions));
- });
-
- cr.sendWithPromise(
- 'getPluralString', 'listChanged', this.displayedList_.length)
- .then((label) => this.fire('iron-announce', {text: label}));
- }
+ const updatedList = newValue.map(id => ({id: id}));
+ this.updateList('displayedList_', item => item.id, updatedList);
+ cr.sendWithPromise(
+ 'getPluralString', 'listChanged', this.displayedList_.length)
+ .then(label => this.fire('iron-announce', {text: label}));
},
/** @private */
diff --git a/chromium/chrome/browser/resources/md_bookmarks/reducers.js b/chromium/chrome/browser/resources/md_bookmarks/reducers.js
index a307e5551e2..17ca9e18c8f 100644
--- a/chromium/chrome/browser/resources/md_bookmarks/reducers.js
+++ b/chromium/chrome/browser/resources/md_bookmarks/reducers.js
@@ -14,7 +14,7 @@ cr.define('bookmarks', function() {
/**
* @param {SelectionState} selectionState
- * @param {Action} action
+ * @param {Object} action
* @return {SelectionState}
*/
SelectionState.selectItems = function(selectionState, action) {
@@ -66,7 +66,7 @@ cr.define('bookmarks', function() {
/**
* @param {SelectionState} selectionState
- * @param {Action} action
+ * @param {Object} action
* @return {SelectionState}
*/
SelectionState.updateAnchor = function(selectionState, action) {
@@ -77,7 +77,7 @@ cr.define('bookmarks', function() {
/**
* @param {SelectionState} selection
- * @param {Action} action
+ * @param {Object} action
* @return {SelectionState}
*/
SelectionState.updateSelection = function(selection, action) {
@@ -111,7 +111,7 @@ cr.define('bookmarks', function() {
/**
* @param {SearchState} search
- * @param {Action} action
+ * @param {Object} action
* @return {SearchState}
*/
SearchState.startSearch = function(search, action) {
@@ -124,7 +124,7 @@ cr.define('bookmarks', function() {
/**
* @param {SearchState} search
- * @param {Action} action
+ * @param {Object} action
* @return {SearchState}
*/
SearchState.finishSearch = function(search, action) {
@@ -164,7 +164,7 @@ cr.define('bookmarks', function() {
/**
* @param {SearchState} search
- * @param {Action} action
+ * @param {Object} action
* @return {SearchState}
*/
SearchState.updateSearch = function(search, action) {
@@ -199,7 +199,7 @@ cr.define('bookmarks', function() {
/**
* @param {NodeMap} nodes
- * @param {Action} action
+ * @param {Object} action
* @return {NodeMap}
*/
NodeState.createBookmark = function(nodes, action) {
@@ -218,7 +218,7 @@ cr.define('bookmarks', function() {
/**
* @param {NodeMap} nodes
- * @param {Action} action
+ * @param {Object} action
* @return {NodeMap}
*/
NodeState.editBookmark = function(nodes, action) {
@@ -234,7 +234,7 @@ cr.define('bookmarks', function() {
/**
* @param {NodeMap} nodes
- * @param {Action} action
+ * @param {Object} action
* @return {NodeMap}
*/
NodeState.moveBookmark = function(nodes, action) {
@@ -266,7 +266,7 @@ cr.define('bookmarks', function() {
/**
* @param {NodeMap} nodes
- * @param {Action} action
+ * @param {Object} action
* @return {NodeMap}
*/
NodeState.removeBookmark = function(nodes, action) {
@@ -283,7 +283,7 @@ cr.define('bookmarks', function() {
/**
* @param {NodeMap} nodes
- * @param {Action} action
+ * @param {Object} action
* @return {NodeMap}
*/
NodeState.reorderChildren = function(nodes, action) {
@@ -295,7 +295,7 @@ cr.define('bookmarks', function() {
/**
* @param {NodeMap} nodes
- * @param {Action} action
+ * @param {Object} action
* @return {NodeMap}
*/
NodeState.updateNodes = function(nodes, action) {
@@ -338,7 +338,7 @@ cr.define('bookmarks', function() {
/**
* @param {string} selectedFolder
- * @param {Action} action
+ * @param {Object} action
* @param {NodeMap} nodes
* @return {string}
*/
@@ -388,7 +388,7 @@ cr.define('bookmarks', function() {
/**
* @param {FolderOpenState} folderOpenState
- * @param {Action} action
+ * @param {Object} action
* @return {FolderOpenState}
*/
FolderOpenState.changeFolderOpen = function(folderOpenState, action) {
@@ -401,7 +401,7 @@ cr.define('bookmarks', function() {
/**
* @param {FolderOpenState} folderOpenState
- * @param {Action} action
+ * @param {Object} action
* @param {NodeMap} nodes
* @return {FolderOpenState}
*/
@@ -431,7 +431,7 @@ cr.define('bookmarks', function() {
/**
* @param {PreferencesState} prefs
- * @param {Action} action
+ * @param {Object} action
* @return {PreferencesState}
*/
PreferencesState.updatePrefs = function(prefs, action) {
@@ -453,7 +453,7 @@ cr.define('bookmarks', function() {
* Root reducer for the Bookmarks page. This is called by the store in
* response to an action, and the return value is used to update the UI.
* @param {!BookmarksPageState} state
- * @param {Action} action
+ * @param {Object} action
* @return {!BookmarksPageState}
*/
function reduceAction(state, action) {
diff --git a/chromium/chrome/browser/resources/md_bookmarks/toast_manager.html b/chromium/chrome/browser/resources/md_bookmarks/toast_manager.html
index 454d1f1ab70..87b07d0e319 100644
--- a/chromium/chrome/browser/resources/md_bookmarks/toast_manager.html
+++ b/chromium/chrome/browser/resources/md_bookmarks/toast_manager.html
@@ -14,14 +14,6 @@
flex: 1;
}
- paper-button {
- -webkit-margin-end: 0;
- -webkit-margin-start: 32px;
- color: var(--google-blue-300);
- height: 32px;
- padding: 8px;
- }
-
.collapsible {
overflow: hidden;
text-overflow: ellipsis;
diff --git a/chromium/chrome/browser/resources/md_downloads/BUILD.gn b/chromium/chrome/browser/resources/md_downloads/BUILD.gn
index f741fce8c0b..f4aaa1324cf 100644
--- a/chromium/chrome/browser/resources/md_downloads/BUILD.gn
+++ b/chromium/chrome/browser/resources/md_downloads/BUILD.gn
@@ -1,3 +1,8 @@
+# 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/closure_compiler/compile_js.gni")
import("../optimize_webui.gni")
optimize_webui("build") {
@@ -9,3 +14,87 @@ optimize_webui("build") {
insert_in_head = "<base href=chrome://downloads>"
js_out_files = [ "crisper.js" ]
}
+
+js_type_check("closure_compile") {
+ deps = [
+ ":browser_proxy",
+ ":constants",
+ ":downloads",
+ ":externs",
+ ":item",
+ ":manager",
+ ":search_service",
+ ":toolbar",
+ ]
+}
+
+js_library("browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("constants") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("downloads") {
+ deps = [
+ ":manager",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("externs") {
+}
+
+js_library("item") {
+ deps = [
+ ":browser_proxy",
+ ":constants",
+ ":externs",
+ "//third_party/polymer/v1_0/components-chromium/paper-behaviors:paper-inky-focus-behavior-extracted",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:util",
+ ]
+}
+
+js_library("manager") {
+ deps = [
+ ":browser_proxy",
+ ":externs",
+ ":item",
+ ":search_service",
+ ":toolbar",
+ "//third_party/polymer/v1_0/components-chromium/iron-list:iron-list-extracted",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:util",
+ "//ui/webui/resources/js/cr:ui",
+ "//ui/webui/resources/js/cr/ui:command",
+ ]
+ externs_list = [ "$externs_path/chrome_send.js" ]
+}
+
+js_library("search_service") {
+ deps = [
+ ":browser_proxy",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
+
+js_library("toolbar") {
+ deps = [
+ ":browser_proxy",
+ ":search_service",
+ "//third_party/polymer/v1_0/components-chromium/iron-a11y-announcer:iron-a11y-announcer-extracted",
+ "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
+ "//ui/webui/resources/cr_elements/cr_toolbar:cr_toolbar",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:util",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/md_downloads/compiled_resources2.gyp b/chromium/chrome/browser/resources/md_downloads/compiled_resources2.gyp
deleted file mode 100644
index 4adfce2fe86..00000000000
--- a/chromium/chrome/browser/resources/md_downloads/compiled_resources2.gyp
+++ /dev/null
@@ -1,84 +0,0 @@
-# Copyright 2015 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'constants',
- 'dependencies': ['<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr'],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'downloads',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- 'manager',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'externs',
- 'includes': ['../../../../third_party/closure_compiler/include_js.gypi'],
- },
- {
- 'target_name': 'item',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/paper-behaviors/compiled_resources2.gyp:paper-inky-focus-behavior-extracted',
- 'constants',
- 'browser_proxy',
- 'externs',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'manager',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- '<(DEPTH)/ui/webui/resources/js/cr/compiled_resources2.gyp:ui',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:command',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-list/compiled_resources2.gyp:iron-list-extracted',
- 'browser_proxy',
- 'item',
- 'search_service',
- 'toolbar',
- '<(EXTERNS_GYP):chrome_send',
- 'externs',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'search_service',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- 'browser_proxy',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'toolbar',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_action_menu/compiled_resources2.gyp:cr_action_menu',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_toolbar/compiled_resources2.gyp:cr_toolbar',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-a11y-announcer/compiled_resources2.gyp:iron-a11y-announcer-extracted',
- 'browser_proxy',
- 'search_service',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/md_downloads/downloads.html b/chromium/chrome/browser/resources/md_downloads/downloads.html
index 07eaf62e051..a3a71bbed4c 100644
--- a/chromium/chrome/browser/resources/md_downloads/downloads.html
+++ b/chromium/chrome/browser/resources/md_downloads/downloads.html
@@ -8,7 +8,7 @@
html {
--downloads-card-margin: 24px;
--downloads-card-width: 680px;
- background: #f1f1f1;
+ background: rgb(248, 249, 250);
/* Remove 300ms delay for 'click' event, when using touch interface. */
touch-action: manipulation;
diff --git a/chromium/chrome/browser/resources/md_downloads/item.html b/chromium/chrome/browser/resources/md_downloads/item.html
index f24d0bd91bd..10ad0662ad5 100644
--- a/chromium/chrome/browser/resources/md_downloads/item.html
+++ b/chromium/chrome/browser/resources/md_downloads/item.html
@@ -3,6 +3,7 @@
<link rel="import" href="chrome://resources/cr_elements/cr_icons_css.html">
<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html">
+<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html">
<link rel="import" href="chrome://resources/html/action_link.html">
<link rel="import" href="chrome://resources/html/action_link_css.html">
<link rel="import" href="chrome://resources/html/cr.html">
@@ -45,7 +46,7 @@
#content {
background: white;
- border-radius: 2px;
+ border-radius: var(--cr-card-border-radius);
display: flex;
flex: none;
margin: 6px auto;
@@ -220,15 +221,6 @@
width: 32px;
}
- /* TODO(hcarmona): Move this to its parent after updating
- paper-icon-button-light to have:
- :host ::slotted(button) {
- font-size: inherit;
- } */
- #remove-wrapper > paper-icon-button-light > button {
- font-size: 16px;
- }
-
#incognito {
bottom: 20px;
content: -webkit-image-set(
@@ -315,12 +307,12 @@
</div>
<div id="remove-wrapper" class="icon-wrapper ">
- <paper-icon-button-light
+ <paper-icon-button-light class="icon-clear"
style$="[[computeRemoveStyle_(isDangerous_, showCancel_)]]">
<button id="remove"
title="$i18n{controlRemoveFromList}"
aria-label="$i18n{controlRemoveFromList}"
- on-click="onRemoveTap_">&#x2715;</button>
+ on-click="onRemoveTap_"></button>
</paper-icon-button-light>
</div>
diff --git a/chromium/chrome/browser/resources/md_downloads/manager.js b/chromium/chrome/browser/resources/md_downloads/manager.js
index 3716f45b567..0971027df40 100644
--- a/chromium/chrome/browser/resources/md_downloads/manager.js
+++ b/chromium/chrome/browser/resources/md_downloads/manager.js
@@ -248,8 +248,10 @@ cr.define('downloads', function() {
type: 'splice',
removed: [],
}]);
- const list = /** @type {!IronListElement} */ (this.$['downloads-list']);
- list.updateSizeForItem(index);
+ this.async(() => {
+ const list = /** @type {!IronListElement} */ (this.$['downloads-list']);
+ list.updateSizeForIndex(index);
+ });
},
});
diff --git a/chromium/chrome/browser/resources/md_extensions/BUILD.gn b/chromium/chrome/browser/resources/md_extensions/BUILD.gn
index 898ea8d2e30..4edc9f45309 100644
--- a/chromium/chrome/browser/resources/md_extensions/BUILD.gn
+++ b/chromium/chrome/browser/resources/md_extensions/BUILD.gn
@@ -1,3 +1,8 @@
+# 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/closure_compiler/compile_js.gni")
import("../optimize_webui.gni")
import("//tools/grit/grit_rule.gni")
import("//chrome/common/features.gni")
@@ -42,3 +47,297 @@ grit("flattened_resources") {
]
output_dir = "$root_gen_dir/chrome/browser/resources/md_extensions"
}
+js_type_check("closure_compile") {
+ deps = [
+ ":code_section",
+ ":detail_view",
+ ":drag_and_drop_handler",
+ ":drop_overlay",
+ ":error_page",
+ ":install_warnings_dialog",
+ ":item",
+ ":item_behavior",
+ ":item_list",
+ ":item_util",
+ ":keyboard_shortcuts",
+ ":kiosk_browser_proxy",
+ ":kiosk_dialog",
+ ":load_error",
+ ":manager",
+ ":navigation_helper",
+ ":options_dialog",
+ ":pack_dialog",
+ ":pack_dialog_alert",
+ ":service",
+ ":shortcut_input",
+ ":shortcut_util",
+ ":sidebar",
+ ":toolbar",
+ ":view_manager",
+ ]
+}
+
+js_library("code_section") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+ externs_list = [ "$externs_path/developer_private.js" ]
+}
+
+js_library("detail_view") {
+ deps = [
+ ":item",
+ ":item_behavior",
+ ":item_util",
+ ":navigation_helper",
+ "//ui/webui/resources/cr_elements:cr_container_shadow_behavior",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+ externs_list = [ "$externs_path/developer_private.js" ]
+}
+
+js_library("drag_and_drop_handler") {
+ deps = [
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js/cr/ui:drag_wrapper",
+ ]
+ externs_list = [ "$externs_path/developer_private.js" ]
+}
+
+js_library("drop_overlay") {
+ deps = [
+ ":drag_and_drop_handler",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js/cr/ui:drag_wrapper",
+ ]
+}
+
+js_library("error_page") {
+ deps = [
+ ":code_section",
+ ":item_util",
+ ":navigation_helper",
+ "//ui/webui/resources/cr_elements:cr_container_shadow_behavior",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js/cr/ui:focus_outline_manager",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+ externs_list = [
+ "$externs_path/developer_private.js",
+ "$externs_path/metrics_private.js",
+ ]
+}
+
+js_library("install_warnings_dialog") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("item") {
+ deps = [
+ ":item_behavior",
+ ":item_util",
+ ":navigation_helper",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+ externs_list = [ "$externs_path/developer_private.js" ]
+}
+
+js_library("item_behavior") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/developer_private.js" ]
+}
+
+js_library("item_list") {
+ deps = [
+ ":item",
+ "//third_party/polymer/v1_0/components-chromium/iron-a11y-announcer:iron-a11y-announcer-extracted",
+ "//ui/webui/resources/cr_elements:cr_container_shadow_behavior",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+ externs_list = [
+ "$externs_path/developer_private.js",
+ "$externs_path/metrics_private.js",
+ ]
+}
+
+js_library("item_util") {
+ deps = [
+ ":navigation_helper",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+ externs_list = [ "$externs_path/developer_private.js" ]
+}
+
+js_library("keyboard_shortcuts") {
+ deps = [
+ ":item_behavior",
+ "//ui/webui/resources/cr_elements:cr_container_shadow_behavior",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [
+ "$externs_path/developer_private.js",
+ "$externs_path/metrics_private.js",
+ ]
+}
+
+js_library("kiosk_browser_proxy") {
+ deps = [
+ ":item_behavior",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("kiosk_dialog") {
+ deps = [
+ ":kiosk_browser_proxy",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("load_error") {
+ deps = [
+ "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/developer_private.js" ]
+}
+
+js_library("manager") {
+ deps = [
+ ":detail_view",
+ ":item",
+ ":item_list",
+ ":item_util",
+ ":keyboard_shortcuts",
+ ":kiosk_browser_proxy",
+ ":load_error",
+ ":navigation_helper",
+ ":service",
+ ":sidebar",
+ ":toolbar",
+ ":view_manager",
+ "//ui/webui/resources/cr_elements/cr_drawer:cr_drawer",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/developer_private.js" ]
+}
+
+js_library("navigation_helper") {
+ deps = [
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
+
+js_library("options_dialog") {
+ deps = [
+ ":item_behavior",
+ ":navigation_helper",
+ "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/developer_private.js" ]
+}
+
+js_library("pack_dialog") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/developer_private.js" ]
+}
+
+js_library("pack_dialog_alert") {
+ deps = [
+ "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+ externs_list = [ "$externs_path/developer_private.js" ]
+}
+
+js_library("service") {
+ deps = [
+ ":error_page",
+ ":item",
+ ":load_error",
+ ":navigation_helper",
+ ":pack_dialog",
+ ":toolbar",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+ externs_list = [
+ "$externs_path/developer_private.js",
+ "$externs_path/management.js",
+ "$externs_path/metrics_private.js",
+ ]
+}
+
+js_library("shortcut_input") {
+ deps = [
+ ":shortcut_util",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/developer_private.js" ]
+}
+
+js_library("shortcut_util") {
+ deps = [
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("sidebar") {
+ deps = [
+ ":navigation_helper",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/metrics_private.js" ]
+}
+
+js_library("toolbar") {
+ deps = [
+ "//third_party/polymer/v1_0/components-chromium/iron-a11y-announcer:iron-a11y-announcer-extracted",
+ "//ui/webui/resources/cr_elements/cr_toast:cr_toast",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:util",
+ ]
+ externs_list = [ "$externs_path/metrics_private.js" ]
+}
+
+js_library("view_manager") {
+ deps = [
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/web_animations.js" ]
+}
diff --git a/chromium/chrome/browser/resources/md_extensions/compiled_resources2.gyp b/chromium/chrome/browser/resources/md_extensions/compiled_resources2.gyp
deleted file mode 100644
index dec283f2234..00000000000
--- a/chromium/chrome/browser/resources/md_extensions/compiled_resources2.gyp
+++ /dev/null
@@ -1,286 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'code_section',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(EXTERNS_GYP):developer_private',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'detail_view',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/compiled_resources2.gyp:cr_container_shadow_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(EXTERNS_GYP):developer_private',
- 'item',
- 'item_behavior',
- 'item_util',
- 'navigation_helper',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'drag_and_drop_handler',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:drag_wrapper',
- '<(EXTERNS_GYP):developer_private',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'drop_overlay',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:drag_wrapper',
- 'drag_and_drop_handler',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'error_page',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/compiled_resources2.gyp:cr_container_shadow_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_outline_manager',
- '<(EXTERNS_GYP):developer_private',
- 'code_section',
- 'item_util',
- 'navigation_helper',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'install_warnings_dialog',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'item',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(EXTERNS_GYP):developer_private',
- 'item_behavior',
- 'item_util',
- 'navigation_helper',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'item_behavior',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):developer_private',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'item_list',
- 'dependencies': [
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-a11y-announcer/compiled_resources2.gyp:iron-a11y-announcer-extracted',
- '<(DEPTH)/ui/webui/resources/cr_elements/compiled_resources2.gyp:cr_container_shadow_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(EXTERNS_GYP):developer_private',
- '<(EXTERNS_GYP):metrics_private',
- 'item',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'item_util',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(EXTERNS_GYP):developer_private',
- 'navigation_helper',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'keyboard_shortcuts',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/compiled_resources2.gyp:cr_container_shadow_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):developer_private',
- '<(EXTERNS_GYP):metrics_private',
- 'item_behavior',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'kiosk_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- 'item_behavior',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'kiosk_dialog',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- 'kiosk_browser_proxy',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'load_error',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_dialog/compiled_resources2.gyp:cr_dialog',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):developer_private',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'manager',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_drawer/compiled_resources2.gyp:cr_drawer',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):developer_private',
- 'detail_view',
- 'item',
- 'item_list',
- 'item_util',
- 'load_error',
- 'keyboard_shortcuts',
- 'kiosk_browser_proxy',
- 'navigation_helper',
- 'service',
- 'sidebar',
- 'toolbar',
- 'view_manager',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'navigation_helper',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'options_dialog',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_dialog/compiled_resources2.gyp:cr_dialog',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):developer_private',
- 'item_behavior',
- 'navigation_helper',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'pack_dialog',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):developer_private',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'pack_dialog_alert',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_dialog/compiled_resources2.gyp:cr_dialog',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(EXTERNS_GYP):developer_private',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'service',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(EXTERNS_GYP):developer_private',
- '<(EXTERNS_GYP):management',
- '<(EXTERNS_GYP):metrics_private',
- 'error_page',
- 'item',
- 'load_error',
- 'navigation_helper',
- 'pack_dialog',
- 'toolbar',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'shortcut_input',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):developer_private',
- 'shortcut_util',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'shortcut_util',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'sidebar',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):metrics_private',
- 'navigation_helper',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'toolbar',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_toast/compiled_resources2.gyp:cr_toast',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-a11y-announcer/compiled_resources2.gyp:iron-a11y-announcer-extracted',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- '<(EXTERNS_GYP):metrics_private',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'view_manager',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):web_animations',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ]
-}
diff --git a/chromium/chrome/browser/resources/md_extensions/detail_view.html b/chromium/chrome/browser/resources/md_extensions/detail_view.html
index 07cb5f81845..faa8d0570fd 100644
--- a/chromium/chrome/browser/resources/md_extensions/detail_view.html
+++ b/chromium/chrome/browser/resources/md_extensions/detail_view.html
@@ -4,12 +4,13 @@
<link rel="import" href="chrome://resources/cr_elements/cr_icons_css.html">
<link rel="import" href="chrome://resources/cr_elements/cr_link_row/cr_link_row.html">
<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html">
-<link rel="import" href="chrome://resources/cr_elements/shared_style_css.html">
<link rel="import" href="chrome://resources/cr_elements/paper_button_style_css.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_tooltip_icon.html">
+<link rel="import" href="chrome://resources/cr_elements/shared_style_css.html">
<link rel="import" href="chrome://resources/html/action_link.html">
<link rel="import" href="chrome://resources/html/action_link_css.html">
<link rel="import" href="chrome://resources/html/cr.html">
+<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icons/iron-icons.html">
@@ -184,7 +185,7 @@
<div id="main">
<div id="top-bar">
<paper-icon-button-light class="icon-arrow-back no-overlap">
- <button id="close-button" aria-label="$i18n{back}"
+ <button id="closeButton" aria-label="$i18n{back}"
on-click="onCloseButtonTap_"></button>
</paper-icon-button-light>
<img id="icon" src="[[data.iconUrl]]"
diff --git a/chromium/chrome/browser/resources/md_extensions/detail_view.js b/chromium/chrome/browser/resources/md_extensions/detail_view.js
index 364eb45cf4a..1988b9f1043 100644
--- a/chromium/chrome/browser/resources/md_extensions/detail_view.js
+++ b/chromium/chrome/browser/resources/md_extensions/detail_view.js
@@ -37,6 +37,19 @@ cr.define('extensions', function() {
'onItemIdChanged_(data.id, delegate)',
],
+ listeners: {
+ 'view-enter-start': 'onViewEnterStart_',
+ },
+
+ /**
+ * Focuses the back button when page is loaded.
+ * @private
+ */
+ onViewEnterStart_: function() {
+ Polymer.RenderStatus.afterNextRender(
+ this, () => cr.ui.focusWithoutInk(this.$.closeButton));
+ },
+
/** @private */
onItemIdChanged_: function() {
// Clear the size, since this view is reused, such that no obsolete size
diff --git a/chromium/chrome/browser/resources/md_extensions/drag_and_drop_handler.js b/chromium/chrome/browser/resources/md_extensions/drag_and_drop_handler.js
index 862c3a436b5..d1472760949 100644
--- a/chromium/chrome/browser/resources/md_extensions/drag_and_drop_handler.js
+++ b/chromium/chrome/browser/resources/md_extensions/drag_and_drop_handler.js
@@ -7,26 +7,18 @@ cr.define('extensions', function() {
/**
* @param {boolean} dragEnabled
- * @param {boolean} isMdExtensions
* @param {!EventTarget} target
* @constructor
* @implements cr.ui.DragWrapperDelegate
*/
- function DragAndDropHandler(dragEnabled, isMdExtensions, target) {
+ function DragAndDropHandler(dragEnabled, target) {
this.dragEnabled = dragEnabled;
- // Behavior is different for dropped directories between MD and non-MD
- // extensions pages.
- // TODO(devlin): Delete the non-MD codepath and remove this variable when
- // MD extensions launches.
- /** @private {boolean} */
- this.isMdExtensions_ = isMdExtensions;
-
/** @private {!EventTarget} */
this.eventTarget_ = target;
}
- // TODO(devlin): Finish un-chrome.send-ifying this implementation.
+ // TODO(devlin): Convert this to an ES6 class.
DragAndDropHandler.prototype = {
/** @override */
shouldAcceptDrag: function(e) {
@@ -45,10 +37,7 @@ cr.define('extensions', function() {
/** @override */
doDragEnter: function() {
- chrome.send('startDrag');
- if (this.isMdExtensions_)
- chrome.developerPrivate.notifyDragInstallInProgress();
-
+ chrome.developerPrivate.notifyDragInstallInProgress();
this.eventTarget_.dispatchEvent(
new CustomEvent('extension-drag-started'));
},
@@ -56,7 +45,6 @@ cr.define('extensions', function() {
/** @override */
doDragLeave: function() {
this.fireDragEnded_();
- chrome.send('stopDrag');
},
/** @override */
@@ -94,8 +82,7 @@ cr.define('extensions', function() {
* @private
*/
handleFileDrop_: function() {
- // Packaged files always go through chrome.send (for now).
- chrome.send('installDroppedFile');
+ chrome.developerPrivate.installDroppedFile();
},
/**
@@ -103,13 +90,6 @@ cr.define('extensions', function() {
* @private
*/
handleDirectoryDrop_: function() {
- // Dropped directories either go through developerPrivate or chrome.send
- // depending on if this is the MD page.
- if (!this.isMdExtensions_) {
- chrome.send('installDroppedDirectory');
- return;
- }
-
// TODO(devlin): Update this to use extensions.Service when it's not
// shared between the MD and non-MD pages.
chrome.developerPrivate.loadUnpacked(
diff --git a/chromium/chrome/browser/resources/md_extensions/drop_overlay.js b/chromium/chrome/browser/resources/md_extensions/drop_overlay.js
index ededf3b24f5..913d7186a84 100644
--- a/chromium/chrome/browser/resources/md_extensions/drop_overlay.js
+++ b/chromium/chrome/browser/resources/md_extensions/drop_overlay.js
@@ -21,7 +21,7 @@ Polymer({
this.hidden = true;
const dragTarget = document.documentElement;
this.dragWrapperHandler_ =
- new extensions.DragAndDropHandler(true, true, dragTarget);
+ new extensions.DragAndDropHandler(true, dragTarget);
// TODO(devlin): All these dragTarget listeners leak (they aren't removed
// when the element is). This only matters in tests at the moment, but would
// be good to fix.
diff --git a/chromium/chrome/browser/resources/md_extensions/error_page.html b/chromium/chrome/browser/resources/md_extensions/error_page.html
index 1e683ef3cc8..89ab2b466b8 100644
--- a/chromium/chrome/browser/resources/md_extensions/error_page.html
+++ b/chromium/chrome/browser/resources/md_extensions/error_page.html
@@ -6,6 +6,7 @@
<link rel="import" href="chrome://resources/cr_elements/paper_button_style_css.html">
<link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="chrome://resources/html/cr/ui/focus_outline_manager.html">
+<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-collapse/iron-collapse.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icons/iron-icons.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
@@ -100,7 +101,7 @@
.error-message {
-webkit-margin-start: 10px;
flex-grow: 1;
- word-break: break-all;
+ word-break: break-word;
}
.devtools-controls {
@@ -131,11 +132,6 @@
background: var(--google-blue-100);
}
- .devtool-button {
- margin-bottom: 20px;
- max-width: 300px;
- }
-
extensions-code-section {
background: white;
height: 200px;
@@ -176,7 +172,7 @@
<div id="main">
<div id="heading">
<paper-icon-button-light class="icon-arrow-back no-overlap">
- <button id="close-button" aria-label="$i18n{back}"
+ <button id="closeButton" aria-label="$i18n{back}"
on-click="onCloseButtonTap_">
</button>
</paper-icon-button-light>
@@ -191,9 +187,10 @@
<div class="item-container">
<div class$="error-item
[[computeErrorClass_(item, selectedEntry_)]]">
- <div actionable class=" start" on-click="onErrorItemAction_"
+ <div actionable class="start" on-click="onErrorItemAction_"
on-keydown="onErrorItemAction_" tabindex="0"
- role="button">
+ role="button" aria-expanded$="[[isAriaExpanded_(
+ index, selectedEntry_)]]">
<iron-icon icon$="[[computeErrorIcon_(item)]]"
title$="[[computeErrorTypeLabel_(item)]]">
</iron-icon>
@@ -246,12 +243,6 @@
could-not-display-code="$i18n{noErrorsToShow}">
</extensions-code-section>
</template>
- <paper-button class="devtool-button action-button"
- hidden$="[[!computeIsRuntimeError_(item)]]"
- disabled="[[!item.canInspect]]"
- on-click="onDevToolButtonTap_">
- $i18n{openInDevtool}
- </paper-button>
</div>
</iron-collapse>
</div>
diff --git a/chromium/chrome/browser/resources/md_extensions/error_page.js b/chromium/chrome/browser/resources/md_extensions/error_page.js
index 4df213ce594..360b01a9087 100644
--- a/chromium/chrome/browser/resources/md_extensions/error_page.js
+++ b/chromium/chrome/browser/resources/md_extensions/error_page.js
@@ -24,11 +24,6 @@ cr.define('extensions', function() {
* @return {!Promise<!chrome.developerPrivate.RequestFileSourceResponse>}
*/
requestFileSource(args) {}
-
- /**
- * @param {!chrome.developerPrivate.OpenDevToolsProperties} args
- */
- openDevTools(args) {}
}
/**
@@ -109,6 +104,10 @@ cr.define('extensions', function() {
'observeDataChanges_(data.*)',
],
+ listeners: {
+ 'view-enter-start': 'onViewEnterStart_',
+ },
+
/** @override */
ready: function() {
cr.ui.FocusOutlineManager.forDocument(document);
@@ -120,6 +119,16 @@ cr.define('extensions', function() {
},
/**
+ * Focuses the back button when page is loaded.
+ * @private
+ */
+ onViewEnterStart_: function() {
+ Polymer.RenderStatus.afterNextRender(
+ this, () => cr.ui.focusWithoutInk(this.$.closeButton));
+ chrome.metricsPrivate.recordUserAction('Options_ViewExtensionErrors');
+ },
+
+ /**
* @param {!ManifestError|!RuntimeError} error
* @param {string} unknown
* @return {string}
@@ -254,11 +263,6 @@ cr.define('extensions', function() {
return description;
},
- /** @private */
- getExpandedClass_: function() {
- return this.stackTraceExpanded_ ? 'expanded' : '';
- },
-
/**
* @param {chrome.developerPrivate.StackFrame} frame
* @return {string}
@@ -347,22 +351,6 @@ cr.define('extensions', function() {
}
},
- /** @private */
- onDevToolButtonTap_: function() {
- const selectedError = this.getSelectedError();
- // This guarantees renderProcessId and renderViewId.
- assert(selectedError.type == chrome.developerPrivate.ErrorType.RUNTIME);
- assert(this.selectedStackFrame_);
-
- this.delegate.openDevTools({
- renderProcessId: selectedError.renderProcessId,
- renderViewId: selectedError.renderViewId,
- url: this.selectedStackFrame_.url,
- lineNumber: this.selectedStackFrame_.lineNumber || 0,
- columnNumber: this.selectedStackFrame_.columnNumber || 0,
- });
- },
-
/**
* Computes the class name for the error item depending on whether its
* the currently selected error.
@@ -390,6 +378,16 @@ cr.define('extensions', function() {
return index == this.selectedEntry_;
},
+
+ /**
+ * @param {number} index
+ * @return {string} The aria-expanded value as a string.
+ * @private
+ */
+ isAriaExpanded_: function(index) {
+ return this.isOpened_(index).toString();
+ },
+
/**
* @param {!{type: string, code: string, model: !{index: number}}} e
* @private
diff --git a/chromium/chrome/browser/resources/md_extensions/extensions.html b/chromium/chrome/browser/resources/md_extensions/extensions.html
index 5b851ed3990..ec0e59c5c6a 100644
--- a/chromium/chrome/browser/resources/md_extensions/extensions.html
+++ b/chromium/chrome/browser/resources/md_extensions/extensions.html
@@ -11,7 +11,7 @@
html {
/* --md-background-color in disguise. Not using the var for increased
* performance. */
- background-color: #f1f1f1;
+ background-color: rgb(248, 249, 250);
/* Remove 300ms delay for 'click' event, when using touch interface. */
touch-action: manipulation;
@@ -41,6 +41,6 @@
<extensions-manager></extensions-manager>
<link rel="stylesheet" href="chrome://resources/css/md_colors.css">
<link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css">
- <link rel="import" href="manager.html">
+ <link rel="import" href="chrome://extensions/manager.html">
</body>
</html>
diff --git a/chromium/chrome/browser/resources/md_extensions/item.html b/chromium/chrome/browser/resources/md_extensions/item.html
index 40497c8a00d..746514ff2a4 100644
--- a/chromium/chrome/browser/resources/md_extensions/item.html
+++ b/chromium/chrome/browser/resources/md_extensions/item.html
@@ -62,7 +62,7 @@
#card {
@apply --shadow-elevation-2dp;
background: white;
- border-radius: 2px;
+ border-radius: var(--cr-card-border-radius);
display: flex;
flex-direction: column;
height: 160px;
@@ -78,7 +78,7 @@
#main {
display: flex;
flex: 1;
- padding: 16px 20px 17px;
+ padding: 16px 20px;
}
#content {
@@ -139,9 +139,7 @@
}
#button-strip {
- /* Avoid ripple from overlapping container. */
- -webkit-margin-end: 20px;
- border-top: var(--cr-separator-line);
+ -webkit-padding-end: 20px;
box-sizing: border-box;
flex-shrink: 0;
height: var(--cr-section-min-height);
diff --git a/chromium/chrome/browser/resources/md_extensions/item_list.html b/chromium/chrome/browser/resources/md_extensions/item_list.html
index 3431fecab79..7b829f814da 100644
--- a/chromium/chrome/browser/resources/md_extensions/item_list.html
+++ b/chromium/chrome/browser/resources/md_extensions/item_list.html
@@ -59,9 +59,6 @@
</style>
<div id="container">
<div id="content-wrapper">
- <div class="empty-list-message" hidden="[[!isGuest]]">
- $i18n{guestModeMessage}
- </div>
<div id="no-items" class="empty-list-message"
hidden$="[[!shouldShowEmptyItemsMessage_(
apps.length, extensions.length)]]">
diff --git a/chromium/chrome/browser/resources/md_extensions/item_list.js b/chromium/chrome/browser/resources/md_extensions/item_list.js
index 834f0cb4f4b..82851e402eb 100644
--- a/chromium/chrome/browser/resources/md_extensions/item_list.js
+++ b/chromium/chrome/browser/resources/md_extensions/item_list.js
@@ -23,8 +23,6 @@ cr.define('extensions', function() {
value: false,
},
- isGuest: Boolean,
-
filter: {
type: String,
},
@@ -81,13 +79,12 @@ cr.define('extensions', function() {
/** @private */
shouldShowEmptyItemsMessage_: function() {
- return !this.isGuest && this.apps.length === 0 &&
- this.extensions.length === 0;
+ return this.apps.length === 0 && this.extensions.length === 0;
},
/** @private */
shouldShowEmptySearchMessage_: function() {
- return !this.isGuest && !this.shouldShowEmptyItemsMessage_() &&
+ return !this.shouldShowEmptyItemsMessage_() &&
this.shownAppsCount_ === 0 && this.shownExtensionsCount_ === 0;
},
diff --git a/chromium/chrome/browser/resources/md_extensions/keyboard_shortcuts.html b/chromium/chrome/browser/resources/md_extensions/keyboard_shortcuts.html
index 5bdefc60481..d5860ab7569 100644
--- a/chromium/chrome/browser/resources/md_extensions/keyboard_shortcuts.html
+++ b/chromium/chrome/browser/resources/md_extensions/keyboard_shortcuts.html
@@ -21,7 +21,7 @@
@apply --cr-primary-text;
@apply --shadow-elevation-2dp;
background-color: white;
- border-radius: 2px;
+ border-radius: var(--cr-card-border-radius);
margin: 0 auto 16px auto;
padding-bottom: 8px;
width: var(--cr-toolbar-field-width);
diff --git a/chromium/chrome/browser/resources/md_extensions/keyboard_shortcuts.js b/chromium/chrome/browser/resources/md_extensions/keyboard_shortcuts.js
index 1baad321ca1..c740d566ea3 100644
--- a/chromium/chrome/browser/resources/md_extensions/keyboard_shortcuts.js
+++ b/chromium/chrome/browser/resources/md_extensions/keyboard_shortcuts.js
@@ -5,6 +5,36 @@
cr.define('extensions', function() {
'use strict';
+ /** @interface */
+ class KeyboardShortcutDelegate {
+ /**
+ * Called when shortcut capturing changes in order to suspend or re-enable
+ * global shortcut handling. This is important so that the shortcuts aren't
+ * processed normally as the user types them.
+ * TODO(devlin): From very brief experimentation, it looks like preventing
+ * the default handling on the event also does this. Investigate more in the
+ * future.
+ * @param {boolean} isCapturing
+ */
+ setShortcutHandlingSuspended(isCapturing) {}
+
+ /**
+ * Updates an extension command's keybinding.
+ * @param {string} extensionId
+ * @param {string} commandName
+ * @param {string} keybinding
+ */
+ updateExtensionCommandKeybinding(extensionId, commandName, keybinding) {}
+
+ /**
+ * Updates an extension command's scope.
+ * @param {string} extensionId
+ * @param {string} commandName
+ * @param {chrome.developerPrivate.CommandScope} scope
+ */
+ updateExtensionCommandScope(extensionId, commandName, scope) {}
+ }
+
// The UI to display and manage keyboard shortcuts set for extension commands.
const KeyboardShortcuts = Polymer({
is: 'extensions-keyboard-shortcuts',
@@ -12,6 +42,9 @@ cr.define('extensions', function() {
behaviors: [CrContainerShadowBehavior, extensions.ItemBehavior],
properties: {
+ /** @type {!extensions.KeyboardShortcutDelegate} */
+ delegate: Object,
+
/** @type {Array<!chrome.developerPrivate.ExtensionInfo>} */
items: Array,
@@ -86,9 +119,15 @@ cr.define('extensions', function() {
* @private
*/
onScopeChanged_: function(event) {
- event.model.set('command.scope', event.target.value);
+ this.delegate.updateExtensionCommandScope(
+ event.model.get('item.id'), event.model.get('command.name'),
+ /** @type {chrome.developerPrivate.CommandScope} */
+ (event.target.value));
},
});
- return {KeyboardShortcuts: KeyboardShortcuts};
+ return {
+ KeyboardShortcutDelegate: KeyboardShortcutDelegate,
+ KeyboardShortcuts: KeyboardShortcuts,
+ };
});
diff --git a/chromium/chrome/browser/resources/md_extensions/kiosk_dialog.html b/chromium/chrome/browser/resources/md_extensions/kiosk_dialog.html
index 5fe53138c7a..0a7a4c89471 100644
--- a/chromium/chrome/browser/resources/md_extensions/kiosk_dialog.html
+++ b/chromium/chrome/browser/resources/md_extensions/kiosk_dialog.html
@@ -1,5 +1,6 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html">
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
<link rel="import" href="chrome://resources/cr_elements/cr_icons_css.html">
<link rel="import" href="chrome://resources/cr_elements/paper_button_style_css.html">
@@ -9,7 +10,6 @@
<link rel="import" href="chrome://resources/html/util.html">
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-checkbox/paper-checkbox.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-input/paper-input.html">
<link rel="import" href="item_behavior.html">
@@ -120,11 +120,11 @@
$i18n{add}
</paper-button>
</div>
- <paper-checkbox disabled="[[!canEditBailout_]]"
- on-pointerdown="onBailoutTap_" checked="[[bailoutDisabled_]]"
+ <cr-checkbox disabled="[[!canEditBailout_]]" id="bailout"
+ on-change="onBailoutChanged_" checked="[[bailoutDisabled_]]"
hidden="[[!canEditAutoLaunch_]]">
$i18n{kioskDisableBailout}
- </paper-checkbox>
+ </cr-checkbox>
</div>
<div slot="button-container">
<paper-button class="action-button" on-click="onDoneTap_">
diff --git a/chromium/chrome/browser/resources/md_extensions/kiosk_dialog.js b/chromium/chrome/browser/resources/md_extensions/kiosk_dialog.js
index 66ada3fbebc..49e5056c0c1 100644
--- a/chromium/chrome/browser/resources/md_extensions/kiosk_dialog.js
+++ b/chromium/chrome/browser/resources/md_extensions/kiosk_dialog.js
@@ -123,26 +123,25 @@ cr.define('extensions', function() {
* @param {!Event} event
* @private
*/
- onBailoutTap_: function(event) {
+ onBailoutChanged_: function(event) {
event.preventDefault();
- if (this.bailoutDisabled_) {
+ if (this.$.bailout.checked) {
+ this.$['confirm-dialog'].showModal();
+ } else {
this.kioskBrowserProxy_.setDisableBailoutShortcut(false);
- this.bailoutDisabled_ = false;
this.$['confirm-dialog'].close();
- } else {
- this.$['confirm-dialog'].showModal();
}
},
/** @private */
onBailoutDialogCancelTap_: function() {
+ this.$.bailout.checked = false;
this.$['confirm-dialog'].cancel();
},
/** @private */
onBailoutDialogConfirmTap_: function() {
this.kioskBrowserProxy_.setDisableBailoutShortcut(true);
- this.bailoutDisabled_ = true;
this.$['confirm-dialog'].close();
},
diff --git a/chromium/chrome/browser/resources/md_extensions/manager.html b/chromium/chrome/browser/resources/md_extensions/manager.html
index 716f70f0655..c746b63aab7 100644
--- a/chromium/chrome/browser/resources/md_extensions/manager.html
+++ b/chromium/chrome/browser/resources/md_extensions/manager.html
@@ -56,8 +56,7 @@
</style>
<extensions-drop-overlay drag-enabled="[[inDevMode]]">
</extensions-drop-overlay>
- <extensions-toolbar is-guest="[[isGuest_]]"
- in-dev-mode="[[inDevMode]]"
+ <extensions-toolbar in-dev-mode="[[inDevMode]]"
can-load-unpacked="[[canLoadUnpacked]]"
is-supervised="[[isSupervised_]]"
dev-mode-controlled-by-policy="[[devModeControlledByPolicy]]"
@@ -81,10 +80,10 @@
</cr-drawer>
</template>
<extensions-view-manager id="viewManager" role="main">
- <extensions-item-list id="items-list" is-guest="[[isGuest_]]"
- delegate="[[delegate]]" in-dev-mode="[[inDevMode]]"
- filter="[[filter]]" hidden$="[[!didInitPage_]]" slot="view"
- apps="[[apps_]]" extensions="[[extensions_]]"
+ <extensions-item-list id="items-list" delegate="[[delegate]]"
+ in-dev-mode="[[inDevMode]]" filter="[[filter]]"
+ hidden$="[[!didInitPage_]]" slot="view" apps="[[apps_]]"
+ extensions="[[extensions_]]"
on-show-install-warnings="onShowInstallWarnings_">
</extensions-item-list>
<cr-lazy-render id="details-view">
diff --git a/chromium/chrome/browser/resources/md_extensions/manager.js b/chromium/chrome/browser/resources/md_extensions/manager.js
index f120fac9efb..615f1389a23 100644
--- a/chromium/chrome/browser/resources/md_extensions/manager.js
+++ b/chromium/chrome/browser/resources/md_extensions/manager.js
@@ -38,8 +38,7 @@ cr.define('extensions', function() {
value: false,
},
- // This is not typed because it implements multiple interfaces, and is
- // passed to different elements as different types.
+ /** @type {!extensions.Service} */
delegate: {
type: Object,
value: function() {
@@ -47,13 +46,6 @@ cr.define('extensions', function() {
},
},
- isGuest_: {
- type: Boolean,
- value: function() {
- return loadTimeData.getBoolean('isGuest');
- },
- },
-
inDevMode: {
type: Boolean,
value: () => loadTimeData.getBoolean('inDevMode'),
@@ -166,11 +158,6 @@ cr.define('extensions', function() {
/** @override */
ready: function() {
- if (loadTimeData.getBoolean('isGuest')) {
- this.initPage_();
- return;
- }
-
let service = extensions.Service.getInstance();
let onProfileStateChanged = profileInfo => {
@@ -243,12 +230,19 @@ cr.define('extensions', function() {
case EventType.ERRORS_REMOVED:
case EventType.PREFS_CHANGED:
case EventType.WARNINGS_CHANGED:
+ case EventType.COMMAND_ADDED:
+ case EventType.COMMAND_REMOVED:
// |extensionInfo| can be undefined in the case of an extension
// being unloaded right before uninstallation. There's nothing to do
// here.
if (!eventData.extensionInfo)
break;
+ if (this.delegate.shouldIgnoreUpdate(
+ eventData.extensionInfo.id, eventData.event_type)) {
+ break;
+ }
+
const listId = this.getListId_(eventData.extensionInfo);
const currentIndex = this[listId].findIndex(
item => item.id == eventData.extensionInfo.id);
diff --git a/chromium/chrome/browser/resources/md_extensions/navigation_helper.js b/chromium/chrome/browser/resources/md_extensions/navigation_helper.js
index e4efc690d4b..f58d72157e3 100644
--- a/chromium/chrome/browser/resources/md_extensions/navigation_helper.js
+++ b/chromium/chrome/browser/resources/md_extensions/navigation_helper.js
@@ -75,16 +75,14 @@ cr.define('extensions', function() {
}
/**
- * If you're not a guest, going to /configureCommands and /shortcuts should
- * land you on /shortcuts. These are the only two supported routes, so all
- * other cases (guest or not) will redirect you to root path if not already
- * on it.
+ * Going to /configureCommands and /shortcuts should land you on /shortcuts.
+ * These are the only two supported routes, so all other cases will redirect
+ * you to root path if not already on it.
* @private
*/
processRoute_() {
- if (!loadTimeData.getBoolean('isGuest') &&
- (this.currentPath_ == '/configureCommands' ||
- this.currentPath_ == '/shortcuts')) {
+ if (this.currentPath_ == '/configureCommands' ||
+ this.currentPath_ == '/shortcuts') {
window.history.replaceState(
undefined /* stateObject */, '', '/shortcuts');
} else if (this.currentPath_ !== '/') {
diff --git a/chromium/chrome/browser/resources/md_extensions/options_dialog.html b/chromium/chrome/browser/resources/md_extensions/options_dialog.html
index 76b427a1530..ab4bd4da479 100644
--- a/chromium/chrome/browser/resources/md_extensions/options_dialog.html
+++ b/chromium/chrome/browser/resources/md_extensions/options_dialog.html
@@ -29,8 +29,11 @@
cr-dialog {
--scroll-border: 0;
--cr-dialog-body: {
+ -webkit-padding-end: 0;
+ -webkit-padding-start: 0;
height: 100%;
- padding: 0;
+ padding-bottom: 0;
+ padding-top: 0;
};
--cr-dialog-wrapper: {
@@ -48,7 +51,7 @@
</style>
<cr-dialog id="dialog" close-text="$i18n{close}"
- on-close="onClose_">
+ on-close="onClose_" show-close-button>
<div slot="title">
<div id="icon-and-name-wrapper">
<img id="icon" src="[[data_.iconUrl]]"
diff --git a/chromium/chrome/browser/resources/md_extensions/service.js b/chromium/chrome/browser/resources/md_extensions/service.js
index 2d1e7a766ee..31a7a30d789 100644
--- a/chromium/chrome/browser/resources/md_extensions/service.js
+++ b/chromium/chrome/browser/resources/md_extensions/service.js
@@ -8,6 +8,7 @@ cr.define('extensions', function() {
/**
* @implements {extensions.ErrorPageDelegate}
* @implements {extensions.ItemDelegate}
+ * @implements {extensions.KeyboardShortcutDelegate}
* @implements {extensions.LoadErrorDelegate}
* @implements {extensions.PackDialogDelegate}
* @implements {extensions.ToolbarDelegate}
@@ -16,6 +17,9 @@ cr.define('extensions', function() {
constructor() {
/** @private {boolean} */
this.isDeleting_ = false;
+
+ /** @private {!Set<string>} */
+ this.eventsToIgnoreOnce_ = new Set();
}
getProfileConfiguration() {
@@ -28,6 +32,23 @@ cr.define('extensions', function() {
return chrome.developerPrivate.onItemStateChanged;
}
+ /**
+ * @param {string} extensionId
+ * @param {!chrome.developerPrivate.EventType} eventType
+ * @return {boolean}
+ */
+ shouldIgnoreUpdate(extensionId, eventType) {
+ return this.eventsToIgnoreOnce_.delete(`${extensionId}_${eventType}`);
+ }
+
+ /**
+ * @param {string} extensionId
+ * @param {!chrome.developerPrivate.EventType} eventType
+ */
+ ignoreNextEvent(extensionId, eventType) {
+ this.eventsToIgnoreOnce_.add(`${extensionId}_${eventType}`);
+ }
+
getProfileStateChangedTarget() {
return chrome.developerPrivate.onProfileStateChanged;
}
@@ -67,13 +88,8 @@ cr.define('extensions', function() {
});
}
- /**
- * Updates an extension command.
- * @param {string} extensionId
- * @param {string} commandName
- * @param {string} keybinding
- */
- updateExtensionCommand(extensionId, commandName, keybinding) {
+ /** @override */
+ updateExtensionCommandKeybinding(extensionId, commandName, keybinding) {
chrome.developerPrivate.updateExtensionCommand({
extensionId: extensionId,
commandName: commandName,
@@ -81,15 +97,22 @@ cr.define('extensions', function() {
});
}
- /**
- * Called when shortcut capturing changes in order to suspend or re-enable
- * global shortcut handling. This is important so that the shortcuts aren't
- * processed normally as the user types them.
- * TODO(devlin): From very brief experimentation, it looks like preventing
- * the default handling on the event also does this. Investigate more in the
- * future.
- * @param {boolean} isCapturing
- */
+ /** @override */
+ updateExtensionCommandScope(extensionId, commandName, scope) {
+ // The COMMAND_REMOVED event needs to be ignored since it is sent before
+ // the command is added back with the updated scope but can be handled
+ // after the COMMAND_ADDED event.
+ this.ignoreNextEvent(
+ extensionId, chrome.developerPrivate.EventType.COMMAND_REMOVED);
+ chrome.developerPrivate.updateExtensionCommand({
+ extensionId: extensionId,
+ commandName: commandName,
+ scope: scope,
+ });
+ }
+
+
+ /** @override */
setShortcutHandlingSuspended(isCapturing) {
chrome.developerPrivate.setShortcutHandlingSuspended(isCapturing);
}
@@ -286,11 +309,6 @@ cr.define('extensions', function() {
}
/** @override */
- openDevTools(args) {
- chrome.developerPrivate.openDevTools(args);
- }
-
- /** @override */
showInFolder(id) {
chrome.developerPrivate.showPath(id);
}
diff --git a/chromium/chrome/browser/resources/md_extensions/shortcut_input.html b/chromium/chrome/browser/resources/md_extensions/shortcut_input.html
index d2ac3b3cf6b..513ffd4e305 100644
--- a/chromium/chrome/browser/resources/md_extensions/shortcut_input.html
+++ b/chromium/chrome/browser/resources/md_extensions/shortcut_input.html
@@ -35,6 +35,10 @@
right: -8px;
}
+ :host-context([dir='rtl']) #clearContainer {
+ left: -8px;
+ right: inherit;
+ }
</style>
<div id="main">
<paper-input id="input" placeholder="$i18n{shortcutTypeAShortcut}"
diff --git a/chromium/chrome/browser/resources/md_extensions/shortcut_input.js b/chromium/chrome/browser/resources/md_extensions/shortcut_input.js
index f2a0b2cfb64..48629000d66 100644
--- a/chromium/chrome/browser/resources/md_extensions/shortcut_input.js
+++ b/chromium/chrome/browser/resources/md_extensions/shortcut_input.js
@@ -2,23 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+/** @enum {number} */
+const ShortcutError = {
+ NO_ERROR: 0,
+ INCLUDE_START_MODIFIER: 1,
+ TOO_MANY_MODIFIERS: 2,
+ NEED_CHARACTER: 3,
+};
+
cr.define('extensions', function() {
'use strict';
- /** @enum {number} */
- const ShortcutError = {
- NO_ERROR: 0,
- INCLUDE_START_MODIFIER: 1,
- TOO_MANY_MODIFIERS: 2,
- NEED_CHARACTER: 3,
- };
-
// The UI to display and manage keyboard shortcuts set for extension commands.
const ShortcutInput = Polymer({
is: 'extensions-shortcut-input',
properties: {
- /** @type {!Object} */
+ /** @type {!extensions.KeyboardShortcutDelegate} */
delegate: Object,
item: {
@@ -180,7 +180,7 @@ cr.define('extensions', function() {
/** @private */
commitPending_: function() {
this.shortcut = this.pendingShortcut_;
- this.delegate.updateExtensionCommand(
+ this.delegate.updateExtensionCommandKeybinding(
this.item, this.commandName, this.shortcut);
},
diff --git a/chromium/chrome/browser/resources/md_extensions/toggle_row.html b/chromium/chrome/browser/resources/md_extensions/toggle_row.html
index b326dc8ca00..b71803d44ca 100644
--- a/chromium/chrome/browser/resources/md_extensions/toggle_row.html
+++ b/chromium/chrome/browser/resources/md_extensions/toggle_row.html
@@ -37,7 +37,7 @@
flex: 1;
}
</style>
- <label id="label" on-click="onLabelTap_">
+ <label id="label">
<input id="native" type="checkbox" checked="[[checked]]"
on-change="onNativeChange_" on-click="onNativeClick_">
<slot></slot>
diff --git a/chromium/chrome/browser/resources/md_extensions/toggle_row.js b/chromium/chrome/browser/resources/md_extensions/toggle_row.js
index 8667db24ce4..1b5de89d990 100644
--- a/chromium/chrome/browser/resources/md_extensions/toggle_row.js
+++ b/chromium/chrome/browser/resources/md_extensions/toggle_row.js
@@ -30,18 +30,6 @@ cr.define('extensions', function() {
* @param {!Event}
* @private
*/
- onLabelTap_: function(e) {
- // If the interaction sequence (pointerdown+pointerup) began within the
- // cr-toggle itself, then prevent this event from changing the state of
- // the toggle.
- if (this.$.crToggle.shouldIgnoreHostTap(e))
- e.preventDefault();
- },
-
- /**
- * @param {!Event}
- * @private
- */
onNativeClick_: function(e) {
// Even though the native checkbox is hidden and can't be actually
// cilcked/tapped by the user, because it resides within the <label> the
diff --git a/chromium/chrome/browser/resources/md_extensions/toolbar.html b/chromium/chrome/browser/resources/md_extensions/toolbar.html
index 67ab5ed89e8..14c8b33ce20 100644
--- a/chromium/chrome/browser/resources/md_extensions/toolbar.html
+++ b/chromium/chrome/browser/resources/md_extensions/toolbar.html
@@ -19,9 +19,9 @@
<style include="cr-hidden-style paper-button-style">
:host {
/* The constant is the height of the tallest control. */
- --button-row-height: calc(var(--margin-bottom) + 36px);
+ --button-row-height: calc(2 * var(--padding-top-bottom) + 36px);
--drawer-transition: 0.3s cubic-bezier(.25, .1, .25, 1);
- --margin-bottom: 4px;
+ --padding-top-bottom: 8px;
--toolbar-color: var(--md-toolbar-color);
}
@@ -46,6 +46,8 @@
}
#devDrawer {
+ background: white;
+ border-bottom: 1px solid var(--google-grey-300);
height: 0;
overflow: hidden;
position: relative;
@@ -58,11 +60,9 @@
#buttonStrip {
-webkit-margin-end: auto;
- -webkit-margin-start: auto;
- background: var(--toolbar-color);
- margin-bottom: var(--margin-bottom);
+ -webkit-margin-start: 24px;
+ padding: var(--padding-top-bottom) 0;
position: absolute;
- text-align: center;
top: calc(var(--button-row-height) * -1);
transition: top var(--drawer-transition);
/* Prevent selection of the blank space between buttons. */
@@ -72,11 +72,6 @@
#buttonStrip paper-button {
-webkit-margin-end: 16px;
- color: white;
- /* Increase contrast compared to default values. */
- --paper-button-flat-keyboard-focus: {
- background: rgba(0, 0, 0, .3);
- };
}
.more-actions {
@@ -98,13 +93,10 @@
white-space: nowrap;
}
</style>
- <cr-toolbar page-name="$i18n{toolbarTitle}"
- search-prompt="$i18n{search}"
- clear-label="$i18n{clearSearch}"
- menu-label="$i18n{mainMenu}"
- show-menu="[[!isGuest]]" show-search="[[!isGuest]]"
+ <cr-toolbar page-name="$i18n{toolbarTitle}" search-prompt="$i18n{search}"
+ clear-label="$i18n{clearSearch}" menu-label="$i18n{mainMenu}" show-menu
narrow-threshold="1000">
- <div class="more-actions" hidden$="[[isGuest]]">
+ <div class="more-actions">
<span id="devModeLabel">$i18n{toolbarDevMode}</span>
<cr-tooltip-icon hidden$="[[!devModeControlledByPolicy]]"
tooltip-text="$i18n{controlledSettingPolicy}"
@@ -131,9 +123,6 @@
title="$i18n{toolbarUpdateNowTooltip}">
$i18n{toolbarUpdateNow}
</paper-button>
- <cr-toast>
- <div>[[toastLabel_]]</div>
- </cr-toast>
<if expr="chromeos">
<paper-button id="kioskExtensions" on-click="onKioskTap_"
hidden$="[[!kioskEnabled]]">
@@ -142,6 +131,9 @@
</if>
</div>
</div>
+ <cr-toast>
+ <div>[[toastLabel_]]</div>
+ </cr-toast>
</template>
<script src="toolbar.js"></script>
</dom-module>
diff --git a/chromium/chrome/browser/resources/md_extensions/toolbar.js b/chromium/chrome/browser/resources/md_extensions/toolbar.js
index 00ddbf2cc5a..0df6f40ec05 100644
--- a/chromium/chrome/browser/resources/md_extensions/toolbar.js
+++ b/chromium/chrome/browser/resources/md_extensions/toolbar.js
@@ -43,8 +43,6 @@ cr.define('extensions', function() {
isSupervised: Boolean,
- isGuest: Boolean,
-
// <if expr="chromeos">
kioskEnabled: Boolean,
// </if>
diff --git a/chromium/chrome/browser/resources/md_history/BUILD.gn b/chromium/chrome/browser/resources/md_history/BUILD.gn
index 4930d084a37..7b647e03ee3 100644
--- a/chromium/chrome/browser/resources/md_history/BUILD.gn
+++ b/chromium/chrome/browser/resources/md_history/BUILD.gn
@@ -1,3 +1,8 @@
+# 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/closure_compiler/compile_js.gni")
import("../optimize_webui.gni")
optimize_webui("build") {
@@ -24,3 +29,148 @@ optimize_webui("build") {
deps = []
}
+
+js_type_check("closure_compile") {
+ deps = [
+ ":app",
+ ":browser_service",
+ ":constants",
+ ":externs",
+ ":history",
+ ":history_item",
+ ":history_list",
+ ":history_toolbar",
+ ":query_manager",
+ ":router",
+ ":side_bar",
+ ":synced_device_card",
+ ":synced_device_manager",
+ ]
+}
+
+js_library("constants") {
+}
+
+js_library("browser_service") {
+ deps = [
+ ":externs",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("externs") {
+ deps = [
+ ":constants",
+ ]
+}
+
+js_library("history_item") {
+ deps = [
+ ":browser_service",
+ ":constants",
+ ":externs",
+ "//ui/webui/resources/js:icon",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:util",
+ "//ui/webui/resources/js/cr/ui:focus_row",
+ ]
+}
+
+js_library("history_list") {
+ deps = [
+ ":browser_service",
+ ":constants",
+ ":externs",
+ ":history_item",
+ "//third_party/polymer/v1_0/components-chromium/iron-a11y-announcer:iron-a11y-announcer-extracted",
+ "//third_party/polymer/v1_0/components-chromium/iron-list:iron-list-extracted",
+ "//third_party/polymer/v1_0/components-chromium/iron-scroll-threshold:iron-scroll-threshold-extracted",
+ "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
+ "//ui/webui/resources/cr_elements/cr_lazy_render:cr_lazy_render",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:util",
+ ]
+}
+
+js_library("history_toolbar") {
+ deps = [
+ ":constants",
+ ":externs",
+ "//ui/webui/resources/cr_elements/cr_toolbar:cr_toolbar",
+ "//ui/webui/resources/cr_elements/cr_toolbar:cr_toolbar_selection_overlay",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:util",
+ ]
+}
+
+js_library("history") {
+ deps = [
+ ":app",
+ ":constants",
+ ":externs",
+ "//ui/webui/resources/js:icon",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+ externs_list = [ "$externs_path/chrome_send.js" ]
+}
+
+js_library("app") {
+ deps = [
+ ":constants",
+ ":externs",
+ ":history_list",
+ ":history_toolbar",
+ ":side_bar",
+ ":synced_device_card",
+ ":synced_device_manager",
+ "//ui/webui/resources/cr_elements/cr_drawer:cr_drawer",
+ "//ui/webui/resources/js:util",
+ "//ui/webui/resources/js/cr/ui:command",
+ ]
+}
+
+js_library("query_manager") {
+ deps = [
+ ":browser_service",
+ ":externs",
+ ":router",
+ ]
+}
+
+js_library("router") {
+ deps = [
+ ":constants",
+ ":externs",
+ ]
+}
+
+js_library("side_bar") {
+ deps = [
+ ":browser_service",
+ "//third_party/polymer/v1_0/components-chromium/iron-a11y-keys-behavior:iron-a11y-keys-behavior-extracted",
+ "//third_party/polymer/v1_0/components-chromium/iron-selector:iron-selector-extracted",
+ "//third_party/polymer/v1_0/components-chromium/paper-ripple:paper-ripple-extracted",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
+
+js_library("synced_device_card") {
+ deps = [
+ ":browser_service",
+ ":constants",
+ ":externs",
+ "//ui/webui/resources/js:icon",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js/cr/ui:focus_row",
+ ]
+}
+
+js_library("synced_device_manager") {
+ deps = [
+ ":browser_service",
+ ":synced_device_card",
+ "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
+ "//ui/webui/resources/cr_elements/cr_lazy_render:cr_lazy_render",
+ "//ui/webui/resources/js/cr/ui:focus_grid",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/md_history/compiled_resources2.gyp b/chromium/chrome/browser/resources/md_history/compiled_resources2.gyp
deleted file mode 100644
index 8ffa9354c1a..00000000000
--- a/chromium/chrome/browser/resources/md_history/compiled_resources2.gyp
+++ /dev/null
@@ -1,147 +0,0 @@
-# Copyright 2015 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'constants',
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'browser_service',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- 'externs',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'externs',
- 'dependencies': [
- 'constants',
- ],
- 'includes': ['../../../../third_party/closure_compiler/include_js.gypi'],
- },
- {
- 'target_name': 'history_item',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:icon',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_row',
- 'constants',
- 'browser_service',
- 'externs',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'history_list',
- 'dependencies': [
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-a11y-announcer/compiled_resources2.gyp:iron-a11y-announcer-extracted',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-list/compiled_resources2.gyp:iron-list-extracted',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-scroll-threshold/compiled_resources2.gyp:iron-scroll-threshold-extracted',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_action_menu/compiled_resources2.gyp:cr_action_menu',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_lazy_render/compiled_resources2.gyp:cr_lazy_render',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- 'browser_service',
- 'constants',
- 'externs',
- 'history_item',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'history_toolbar',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_toolbar/compiled_resources2.gyp:cr_toolbar',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_toolbar/compiled_resources2.gyp:cr_toolbar_selection_overlay',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- 'constants',
- 'externs',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'history',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:icon',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- 'app',
- 'constants',
- 'externs',
- '<(EXTERNS_GYP):chrome_send',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'app',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_drawer/compiled_resources2.gyp:cr_drawer',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:command',
- 'constants',
- 'externs',
- 'history_toolbar',
- 'history_list',
- 'side_bar',
- 'synced_device_card',
- 'synced_device_manager',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'query_manager',
- 'dependencies': [
- 'browser_service',
- 'externs',
- 'router',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'router',
- 'dependencies': [
- 'constants',
- 'externs',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'side_bar',
- 'dependencies': [
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-a11y-keys-behavior/compiled_resources2.gyp:iron-a11y-keys-behavior-extracted',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-selector/compiled_resources2.gyp:iron-selector-extracted',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/paper-ripple/compiled_resources2.gyp:paper-ripple-extracted',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- 'browser_service',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'synced_device_card',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:icon',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_row',
- 'browser_service',
- 'constants',
- 'externs',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'synced_device_manager',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_lazy_render/compiled_resources2.gyp:cr_lazy_render',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_action_menu/compiled_resources2.gyp:cr_action_menu',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_grid',
- 'browser_service',
- 'synced_device_card',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/md_history/history_item.html b/chromium/chrome/browser/resources/md_history/history_item.html
index 7c69c15390a..21c4142bbd1 100644
--- a/chromium/chrome/browser/resources/md_history/history_item.html
+++ b/chromium/chrome/browser/resources/md_history/history_item.html
@@ -6,6 +6,7 @@
<link rel="import" href="chrome://history/shared_style.html">
<link rel="import" href="chrome://resources/cr_elements/cr_icons_css.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html">
+<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html">
<link rel="import" href="chrome://resources/html/cr/ui/focus_row.html">
<link rel="import" href="chrome://resources/html/icon.html">
<link rel="import" href="chrome://resources/html/util.html">
@@ -32,7 +33,7 @@
}
:host([is-card-start][is-card-end]) #main-container {
- border-radius: 2px;
+ border-radius: var(--cr-card-border-radius);
}
#date-accessed {
@@ -67,52 +68,19 @@
overflow: hidden;
}
- #checkbox-container {
- height: 40px;
- margin: 0;
- padding: 0;
- transform: none; /* Checkboxes shouldn't flip even in RTL. */
- width: 40px;
- }
-
- :host([selected]) #checkbox {
- color: var(--interactive-color);
+ #checkbox {
+ margin: 12px;
}
- #checkmark {
+ /* #checkbox[unresolved] styling is necessary since cr-checkbox is being
+ lazy-loaded. */
+ #checkbox[unresolved] {
border: 2px solid var(--secondary-text-color);
border-radius: 2px;
- height: 12px;
- margin: 12px;
- width: 12px;
- }
-
- #checkmark::after {
- border-color: inherit;
- border-style: solid;
- border-width: 0 2px 2px 0;
content: '';
display: block;
- height: 70%;
- transform: scale(0) rotate(45deg);
- transform-origin: 97% 86%;
- width: 36%;
- }
-
- :host-context([dir='rtl']) #checkmark::after {
- transform-origin: 50% 14%;
- }
-
- :host([selected]) #checkmark {
- background: var(--interactive-color);
- border-color: var(--interactive-color);
- }
-
- :host([selected]) #checkmark::after {
- border-color: white;
- transform: scale(1) rotate(45deg);
- /* Only animate when showing checkmark. */
- transition: transform 140ms ease-out;
+ height: 12px;
+ width: 12px;
}
#time-accessed {
@@ -185,15 +153,15 @@
}
:host([is-card-start]) #background {
- border-radius: 2px 2px 0 0;
+ border-radius: var(--cr-card-border-radius) var(--cr-card-border-radius) 0 0;
}
:host([is-card-end]) #background {
- border-radius: 0 0 2px 2px;
+ border-radius: 0 0 var(--cr-card-border-radius) var(--cr-card-border-radius);
}
:host([is-card-start][is-card-end]) #background {
- border-radius: 2px;
+ border-radius: var(--cr-card-border-radius);
}
</style>
@@ -207,15 +175,12 @@
<div id="item-container"
on-mousedown="onItemMousedown_"
on-click="onItemClick_">
- <paper-icon-button-light id="checkbox-container"
- hidden="[[selectionNotAllowed_]]">
- <button id="checkbox"
- role="checkbox"
- aria-checked$="[[getAriaChecked_(selected)]]"
- aria-label$="[[getEntrySummary_(item)]]">
- <div id="checkmark"></div>
- </button>
- </paper-icon-button-light>
+ <cr-checkbox id="checkbox" checked="[[selected]]" unresolved
+ on-mousedown="onCheckboxClick_" on-keydown="onCheckboxClick_"
+ on-change="onCheckboxChange_" class="no-label"
+ hidden="[[selectionNotAllowed_]]"
+ disabled="[[selectionNotAllowed_]]"
+ aria-label$="[[getEntrySummary_(item)]]"></cr-checkbox>
<span id="time-accessed">
[[item.readableTimestamp]]
</span>
diff --git a/chromium/chrome/browser/resources/md_history/history_item.js b/chromium/chrome/browser/resources/md_history/history_item.js
index 3329aa189f7..d059f011514 100644
--- a/chromium/chrome/browser/resources/md_history/history_item.js
+++ b/chromium/chrome/browser/resources/md_history/history_item.js
@@ -136,6 +136,9 @@ cr.define('md_history', function() {
/** @private {boolean} */
mouseDown_: false,
+ /** @private {boolean} */
+ isShiftKeyDown_: false,
+
/** @override */
attached: function() {
Polymer.RenderStatus.afterNextRender(this, function() {
@@ -215,6 +218,33 @@ cr.define('md_history', function() {
},
/**
+ * This is bound to mouse/keydown instead of click/press because this
+ * has to fire before onCheckboxChange_. If we bind it to click/press,
+ * it might trigger out of disired order.
+ *
+ * @param {!Event} e
+ * @private
+ */
+ onCheckboxClick_: function(e) {
+ this.isShiftKeyDown_ = e.shiftKey;
+ },
+
+ /**
+ * @param {!Event} e
+ * @private
+ */
+ onCheckboxChange_: function(e) {
+ this.fire('history-checkbox-select', {
+ index: this.index,
+ // If the user clicks or press enter/space key, oncheckboxClick_ will
+ // trigger before this function, so a shift-key might be recorded.
+ shiftKey: this.isShiftKeyDown_,
+ });
+
+ this.isShiftKeyDown_ = false;
+ },
+
+ /**
* @param {MouseEvent} e
* @private
*/
diff --git a/chromium/chrome/browser/resources/md_history/lazy_load.html b/chromium/chrome/browser/resources/md_history/lazy_load.html
index 011a4357ef2..3298b3aa427 100644
--- a/chromium/chrome/browser/resources/md_history/lazy_load.html
+++ b/chromium/chrome/browser/resources/md_history/lazy_load.html
@@ -3,6 +3,7 @@
<body>
<link rel="import" href="chrome://history/synced_device_manager.html">
<link rel="import" href="chrome://resources/cr_elements/cr_action_menu/cr_action_menu.html">
+ <link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html">
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
<link rel="import" href="chrome://resources/cr_elements/cr_drawer/cr_drawer.html">
<link rel="import" href="chrome://resources/cr_elements/cr_toolbar/cr_toolbar_selection_overlay.html">
diff --git a/chromium/chrome/browser/resources/md_history/shared_style.html b/chromium/chrome/browser/resources/md_history/shared_style.html
index ea503791985..37273cbd2ad 100644
--- a/chromium/chrome/browser/resources/md_history/shared_style.html
+++ b/chromium/chrome/browser/resources/md_history/shared_style.html
@@ -12,7 +12,6 @@
.card-title {
align-items: center;
border-bottom: 1px solid var(--card-border-color);
- border-radius: 2px 2px 0 0;
display: flex;
font-size: 108%;
font-weight: 500;
diff --git a/chromium/chrome/browser/resources/md_history/synced_device_card.html b/chromium/chrome/browser/resources/md_history/synced_device_card.html
index 0f4f6a2f53c..fe572961913 100644
--- a/chromium/chrome/browser/resources/md_history/synced_device_card.html
+++ b/chromium/chrome/browser/resources/md_history/synced_device_card.html
@@ -1,6 +1,7 @@
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html">
+<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html">
<link rel="import" href="chrome://resources/html/cr/ui/focus_row.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-collapse/iron-collapse.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
@@ -59,7 +60,7 @@
#history-item-container {
@apply --shadow-elevation-2dp;
background: #fff;
- border-radius: 2px;
+ border-radius: var(--cr-card-border-radius);
}
.item-container {
diff --git a/chromium/chrome/browser/resources/md_user_manager/BUILD.gn b/chromium/chrome/browser/resources/md_user_manager/BUILD.gn
new file mode 100644
index 00000000000..41e5786b71c
--- /dev/null
+++ b/chromium/chrome/browser/resources/md_user_manager/BUILD.gn
@@ -0,0 +1,54 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":control_bar",
+ ":create_profile",
+ ":error_dialog",
+ ":profile_browser_proxy",
+ ":user_manager_pages",
+ ":user_manager_tutorial",
+ ]
+}
+
+js_library("control_bar") {
+ deps = [
+ ":profile_browser_proxy",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+}
+
+js_library("create_profile") {
+ deps = [
+ ":profile_browser_proxy",
+ "//ui/webui/resources/cr_elements/cr_profile_avatar_selector:cr_profile_avatar_selector",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:util",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("error_dialog") {
+}
+
+js_library("profile_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("user_manager_pages") {
+}
+
+js_library("user_manager_tutorial") {
+ deps = [
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:util",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/md_user_manager/compiled_resources2.gyp b/chromium/chrome/browser/resources/md_user_manager/compiled_resources2.gyp
deleted file mode 100644
index 63270db9c99..00000000000
--- a/chromium/chrome/browser/resources/md_user_manager/compiled_resources2.gyp
+++ /dev/null
@@ -1,75 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'control_bar',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- 'profile_browser_proxy',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'create_profile',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_profile_avatar_selector/compiled_resources2.gyp:cr_profile_avatar_selector',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- 'profile_browser_proxy',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'error_dialog',
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'import_supervised_user',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- 'profile_browser_proxy',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'profile_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'supervised_user_create_confirm',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- 'profile_browser_proxy',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'supervised_user_learn_more',
- 'dependencies': [
- 'profile_browser_proxy',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'user_manager_pages',
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'user_manager_tutorial',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/md_user_manager/create_profile.html b/chromium/chrome/browser/resources/md_user_manager/create_profile.html
index 46ce56619e0..c2ad589fa0a 100644
--- a/chromium/chrome/browser/resources/md_user_manager/create_profile.html
+++ b/chromium/chrome/browser/resources/md_user_manager/create_profile.html
@@ -1,11 +1,10 @@
<link rel="import" href="chrome://resources/html/polymer.html">
-<link rel="import" href="/import_supervised_user.html">
<link rel="import" href="/profile_browser_proxy.html">
<link rel="import" href="/shared_styles.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html">
<link rel="import" href="chrome://resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html">
-<link rel="import" href="chrome://resources/cr_elements/paper_checkbox_style_css.html">
<link rel="import" href="chrome://resources/html/action_link.html">
<link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
@@ -14,14 +13,13 @@
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-checkbox/paper-checkbox.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-input/paper-input.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-spinner/paper-spinner-lite.html">
<dom-module id="create-profile">
<template>
<style
- include="shared-styles iron-positioning md-select paper-checkbox-style">
+ include="shared-styles iron-positioning md-select">
:host {
align-self: center;
}
@@ -91,39 +89,10 @@
width: 300px;
}
- paper-checkbox {
- --paper-checkbox-checked-color: var(--google-blue-500);
- --paper-checkbox-label-spacing: 16px;
- --paper-checkbox-size: 16px;
- --paper-checkbox-unchecked-color: var(--paper-grey-600);
+ cr-checkbox {
margin-top: 24px;
}
- paper-checkbox + paper-checkbox {
- margin-top: 16px;
- }
-
- #supervised-user-container {
- -webkit-padding-start: 32px;
- }
-
- #supervised-user-container #learn-more {
- line-height: 20px;
- }
-
- #supervised-user-container .md-select-wrapper {
- -webkit-margin-start: calc(-1 * var(--md-select-side-padding));
- margin-top: 4px;
- }
-
- #supervised-user-container #import-user {
- -webkit-margin-start: 16px;
- }
-
- #supervised-user-container #sign-in-howto-message {
- margin-top: 12px;
- }
-
#actions {
bottom: 16px;
display: flex;
@@ -155,61 +124,22 @@
<cr-profile-avatar-selector avatars="[[availableIcons_]]"
selected-avatar="{{selectedAvatar_}}">
</cr-profile-avatar-selector>
- <paper-checkbox id="createShortcutCheckbox" checked="{{createShortcut_}}"
+ <cr-checkbox id="createShortcutCheckbox" checked="{{createShortcut_}}"
hidden="[[!isProfileShortcutsEnabled_]]">
$i18n{createDesktopShortcutLabel}
- </paper-checkbox>
- <template is="dom-if" if="[[isSupervisedUserCreationEnabled_]]">
- <paper-checkbox id="makeSupervisedCheckbox" checked="{{isSupervised_}}">
- $i18n{manageProfilesSupervisedSignedInLabel}
- </paper-checkbox>
- <div id="supervised-user-container">
- <div id="learn-more" >
- <a is="action-link" on-tap="onLearnMoreTap_">$i18n{learnMore}</a>
- </div>
- <template is="dom-if" if="[[isSupervised_]]">
- <template is="dom-if" if="[[isSignedIn_(signedInUsers_)]]">
- <div class="md-select-wrapper">
- <select class="md-select" on-change="onAccountChanged_">
- <option disabled selected>$i18n{selectAnAccount}</option>
- <template is="dom-repeat" items="[[signedInUsers_]]">
- <option value="[[index]]">
- [[item.username]]
- </option>
- </template>
- </select>
- <span class="md-select-underline"></span>
- </div>
- <a id="import-user" is="action-link" on-tap="onImportUserTap_"
- hidden="[[isImportUserLinkHidden_(createInProgress_,
- loadingSupervisedUsers_,
- signedInUserIndex_)]]">
- $i18n{importExistingSupervisedUserLink}
- </a>
- </template>
- <div id="sign-in-howto-message"
- hidden="[[isSignedIn_(signedInUsers_)]]"
- inner-h-t-m-l="[[i18nAllowIDAttr_('noSignedInUserMessage')]]">
- </div>
- </template>
- </div>
- </template>
+ </cr-checkbox>
<div id="actions">
- <paper-spinner-lite active="[[isSpinnerActive_(
- createInProgress_, loadingSupervisedUsers_)]]">
+ <paper-spinner-lite active="[[isSpinnerActive_(createInProgress_)]]">
</paper-spinner-lite>
<paper-button id="cancel" class="action secondary"
on-tap="onCancelTap_">
$i18n{cancel}
</paper-button>
<paper-button id="save" class="action primary" on-tap="onSaveTap_"
- disabled="[[isSaveDisabled_(createInProgress_,
- loadingSupervisedUsers_,
- profileName_)]]">
+ disabled="[[isSaveDisabled_(createInProgress_, profileName_)]]">
$i18n{createProfileConfirm}
</paper-button>
</div>
- <import-supervised-user id="importUserPopup"></import-supervised-user>
</div>
</template>
<script src="create_profile.js"></script>
diff --git a/chromium/chrome/browser/resources/md_user_manager/create_profile.js b/chromium/chrome/browser/resources/md_user_manager/create_profile.js
index 4f17bccf264..daabfba68e2 100644
--- a/chromium/chrome/browser/resources/md_user_manager/create_profile.js
+++ b/chromium/chrome/browser/resources/md_user_manager/create_profile.js
@@ -4,16 +4,10 @@
/**
* @fileoverview 'create-profile' is a page that contains controls for creating
- * a (optionally supervised) profile, including choosing a name, and an avatar.
+ * a profile, including choosing a name, and an avatar.
*/
(function() {
-/**
- * Sentinel signed-in user's index value.
- * @type {number}
- */
-const NO_USER_SELECTED = -1;
-
Polymer({
is: 'create-profile',
@@ -44,12 +38,6 @@ Polymer({
selectedAvatar_: Object,
/**
- * True if the existing supervised users are being loaded.
- * @private {boolean}
- */
- loadingSupervisedUsers_: {type: Boolean, value: false},
-
- /**
* True if a profile is being created or imported.
* @private {boolean}
*/
@@ -73,29 +61,6 @@ Polymer({
*/
createShortcut_: {type: Boolean, value: true},
- /**
- * True if the new profile is a supervised profile.
- * @private {boolean}
- */
- isSupervised_: {type: Boolean, value: false},
-
- /**
- * The list of usernames and profile paths for currently signed-in users.
- * @private {!Array<!SignedInUser>}
- */
- signedInUsers_: {
- type: Array,
- value: function() {
- return [];
- }
- },
-
- /**
- * Index of the selected signed-in user.
- * @private {number}
- */
- signedInUserIndex_: {type: Number, value: NO_USER_SELECTED},
-
/** @private {!signin.ProfileBrowserProxy} */
browserProxy_: Object,
@@ -121,23 +86,8 @@ Polymer({
return loadTimeData.getBoolean('isForceSigninEnabled');
},
},
-
- /**
- * True if Supervised User creation is enabled.
- * @private {boolean}
- */
- isSupervisedUserCreationEnabled_: {
- type: Boolean,
- value: function() {
- return loadTimeData.getBoolean('isSupervisedUserCreationEnabled') &&
- !loadTimeData.getBoolean('isForceSigninEnabled');
- },
- }
},
- listeners:
- {'tap': 'onTap_', 'importUserPopup.import': 'onImportUserPopupImport_'},
-
/** @override */
created: function() {
this.browserProxy_ = signin.ProfileBrowserProxyImpl.getInstance();
@@ -156,32 +106,26 @@ Polymer({
});
this.addWebUIListener(
'profile-defaults-received', this.handleProfileDefaults_.bind(this));
- this.addWebUIListener(
- 'signedin-users-received', this.handleSignedInUsers_.bind(this));
this.browserProxy_.getAvailableIcons();
- this.browserProxy_.getSignedInUsers();
},
/** @override */
attached: function() {
- this.$.nameInput.focus();
+ // paper-input's focusable element isn't defined until after it's attached.
+ Polymer.RenderStatus.afterNextRender(this, () => this.$.nameInput.focus());
},
/**
* Handles tap events from:
* - links within dynamic warning/error messages pushed from the browser.
- * - the 'noSignedInUserMessage' i18n string.
* @param {!Event} event
* @private
*/
onTap_: function(event) {
const element = Polymer.dom(event).rootTarget;
- if (element.id == 'supervised-user-import-existing') {
- this.onImportUserTap_(event);
- event.preventDefault();
- } else if (element.id == 'sign-in-to-chrome') {
+ if (element.id == 'sign-in-to-chrome') {
this.browserProxy_.openUrlInLastActiveProfileBrowser(element.href);
event.preventDefault();
} else if (element.id == 'reauth') {
@@ -202,153 +146,12 @@ Polymer({
},
/**
- * Handler for when signed-in users are pushed from the browser.
- * @param {!Array<!SignedInUser>} signedInUsers
- * @private
- */
- handleSignedInUsers_: function(signedInUsers) {
- this.signedInUsers_ = signedInUsers;
- },
-
- /**
- * Returns the currently selected signed-in user.
- * @return {(!SignedInUser|undefined)}
- * @private
- */
- signedInUser_: function(signedInUserIndex) {
- return this.signedInUsers_[signedInUserIndex];
- },
-
- /**
- * Handler for the 'Learn More' link tap event.
- * @param {!Event} event
- * @private
- */
- onLearnMoreTap_: function(event) {
- this.fire('change-page', {page: 'supervised-learn-more-page'});
- },
-
- /**
- * Handler for the 'Import Supervised User' link tap event.
- * @param {!Event} event
- * @private
- */
- onImportUserTap_: function(event) {
- if (this.signedInUserIndex_ == NO_USER_SELECTED) {
- // A custodian must be selected.
- this.handleMessage_(
- this.i18nAdvanced('custodianAccountNotSelectedError'));
- } else {
- const signedInUser = this.signedInUser_(this.signedInUserIndex_);
- this.hideMessage_();
- this.loadingSupervisedUsers_ = true;
- this.browserProxy_.getExistingSupervisedUsers(signedInUser.profilePath)
- .then(
- this.showImportSupervisedUserPopup_.bind(this),
- this.handleMessage_.bind(this));
- }
- },
-
- /**
* Handler for the 'Save' button tap event.
* @param {!Event} event
* @private
*/
onSaveTap_: function(event) {
- if (!this.isSupervised_) {
- // The new profile is not supervised. Go ahead and create it.
- this.createProfile_();
- } else if (this.signedInUserIndex_ == NO_USER_SELECTED) {
- // If the new profile is supervised, a custodian must be selected.
- this.handleMessage_(
- this.i18nAdvanced('custodianAccountNotSelectedError'));
- } else {
- const signedInUser = this.signedInUser_(this.signedInUserIndex_);
- this.hideMessage_();
- this.loadingSupervisedUsers_ = true;
- this.browserProxy_.getExistingSupervisedUsers(signedInUser.profilePath)
- .then(
- this.createProfileIfValidSupervisedUser_.bind(this),
- this.handleMessage_.bind(this));
- }
- },
-
- /**
- * Displays the import supervised user popup or an error message if there are
- * no existing supervised users.
- * @param {!Array<!SupervisedUser>} supervisedUsers The list of existing
- * supervised users.
- * @private
- */
- showImportSupervisedUserPopup_: function(supervisedUsers) {
- this.loadingSupervisedUsers_ = false;
- if (supervisedUsers.length > 0) {
- this.$.importUserPopup.show(
- this.signedInUser_(this.signedInUserIndex_), supervisedUsers);
- } else {
- this.handleMessage_(this.i18nAdvanced('noSupervisedUserImportText'));
- }
- },
-
- /**
- * Checks if the entered name matches name of an existing supervised user.
- * If yes, the user is prompted to import the existing supervised user.
- * If no, the new supervised profile gets created.
- * @param {!Array<!SupervisedUser>} supervisedUsers The list of existing
- * supervised users.
- * @private
- */
- createProfileIfValidSupervisedUser_: function(supervisedUsers) {
- for (let i = 0; i < supervisedUsers.length; ++i) {
- if (supervisedUsers[i].name != this.profileName_)
- continue;
- // Check if another supervised user also exists with that name.
- let nameIsUnique = true;
- // Handling the case when multiple supervised users with the same
- // name exist, but not all of them are on the device.
- // If at least one is not imported, we want to offer that
- // option to the user. This could happen due to a bug that allowed
- // creating SUs with the same name (https://crbug.com/557445).
- let allOnCurrentDevice = supervisedUsers[i].onCurrentDevice;
- for (let j = i + 1; j < supervisedUsers.length; ++j) {
- if (supervisedUsers[j].name == this.profileName_) {
- nameIsUnique = false;
- allOnCurrentDevice =
- allOnCurrentDevice && supervisedUsers[j].onCurrentDevice;
- }
- }
-
- const opts = {
- 'substitutions':
- [HTMLEscape(elide(this.profileName_, /* maxLength */ 50))],
- 'attrs': {
- 'id': function(node, value) {
- return node.tagName == 'A';
- },
- 'is': function(node, value) {
- return node.tagName == 'A' && value == 'action-link';
- },
- 'role': function(node, value) {
- return node.tagName == 'A' && value == 'link';
- },
- 'tabindex': function(node, value) {
- return node.tagName == 'A';
- }
- }
- };
-
- this.handleMessage_(
- allOnCurrentDevice ?
- this.i18nAdvanced('managedProfilesExistingLocalSupervisedUser') :
- this.i18nAdvanced('manageProfilesExistingSupervisedUser', opts));
- return;
- }
- // No existing supervised user's name matches the entered profile name.
- // Continue with creating the new supervised profile.
this.createProfile_();
- // Set this to false after createInProgress_ has been set to true in
- // order for the 'Save' button to remain disabled.
- this.loadingSupervisedUsers_ = false;
},
/**
@@ -356,11 +159,6 @@ Polymer({
* @private
*/
createProfile_: function() {
- let custodianProfilePath = '';
- if (this.signedInUserIndex_ != NO_USER_SELECTED) {
- custodianProfilePath =
- this.signedInUser_(this.signedInUserIndex_).profilePath;
- }
this.hideMessage_();
this.createInProgress_ = true;
const createShortcut =
@@ -368,35 +166,7 @@ Polymer({
// Select the 1st avatar if none selected.
const selectedAvatar = this.selectedAvatar_ || this.availableIcons_[0];
this.browserProxy_.createProfile(
- this.profileName_, selectedAvatar.url, createShortcut,
- this.isSupervised_, '', custodianProfilePath);
- },
-
- /**
- * Handler for a change in the supervised account dropdown.
- * @param {!{target: HTMLSelectElement}} event
- * @private
- */
- onAccountChanged_: function(event) {
- this.signedInUserIndex_ = parseInt(event.target.value, 10);
- },
-
- /**
- * Handler for the 'import' event fired by #importUserPopup once a supervised
- * user is selected to be imported and the popup closes.
- * @param {!{detail: {supervisedUser: !SupervisedUser,
- * signedInUser: !SignedInUser}}} event
- * @private
- */
- onImportUserPopupImport_: function(event) {
- const supervisedUser = event.detail.supervisedUser;
- const signedInUser = event.detail.signedInUser;
- this.hideMessage_();
- this.createInProgress_ = true;
- const createShortcut = this.isProfileShortcutsEnabled_;
- this.browserProxy_.createProfile(
- supervisedUser.name, supervisedUser.iconURL, createShortcut,
- true /* isSupervised */, supervisedUser.id, signedInUser.profilePath);
+ this.profileName_, selectedAvatar.url, createShortcut);
},
/**
@@ -405,15 +175,7 @@ Polymer({
* @private
*/
onCancelTap_: function(event) {
- if (this.createInProgress_) {
- this.createInProgress_ = false;
- this.browserProxy_.cancelCreateProfile();
- } else if (this.loadingSupervisedUsers_) {
- this.loadingSupervisedUsers_ = false;
- this.browserProxy_.cancelLoadingSupervisedUsers();
- } else {
- this.fire('change-page', {page: 'user-pods-page'});
- }
+ this.fire('change-page', {page: 'user-pods-page'});
},
/**
@@ -423,13 +185,7 @@ Polymer({
*/
handleSuccess_: function(profileInfo) {
this.createInProgress_ = false;
- if (profileInfo.showConfirmation) {
- this.fire(
- 'change-page',
- {page: 'supervised-create-confirm-page', data: profileInfo});
- } else {
- this.fire('change-page', {page: 'user-pods-page'});
- }
+ this.fire('change-page', {page: 'user-pods-page'});
},
/**
@@ -441,14 +197,12 @@ Polymer({
},
/**
- * Handles warning/error messages when a profile is being created/imported
- * or the existing supervised users are being loaded.
+ * Handles warning/error messages when a profile is being created/imported.
* @param {*} message An HTML warning/error message.
* @private
*/
handleMessage_: function(message) {
this.createInProgress_ = false;
- this.loadingSupervisedUsers_ = false;
this.message_ = '' + message;
this.isMessageVisble_ = true;
},
@@ -474,55 +228,26 @@ Polymer({
/**
* Computed binding determining whether the paper-spinner is active.
* @param {boolean} createInProgress Is create in progress?
- * @param {boolean} loadingSupervisedUsers Are supervised users being loaded?
* @return {boolean}
* @private
*/
- isSpinnerActive_: function(createInProgress, loadingSupervisedUsers) {
- return createInProgress || loadingSupervisedUsers;
+ isSpinnerActive_: function(createInProgress) {
+ return createInProgress;
},
/**
* Computed binding determining whether 'Save' button is disabled.
* @param {boolean} createInProgress Is create in progress?
- * @param {boolean} loadingSupervisedUsers Are supervised users being loaded?
* @param {string} profileName Profile Name.
* @return {boolean}
* @private
*/
- isSaveDisabled_: function(
- createInProgress, loadingSupervisedUsers, profileName) {
+ isSaveDisabled_: function(createInProgress, profileName) {
// TODO(mahmadi): Figure out a way to add 'paper-input-extracted' as a
// dependency and cast to PaperInputElement instead.
/** @type {{validate: function():boolean}} */
const nameInput = this.$.nameInput;
- return createInProgress || loadingSupervisedUsers || !profileName ||
- !nameInput.validate();
- },
-
- /**
- * Returns True if the import existing supervised user link should be hidden.
- * @param {boolean} createInProgress True if create/import is in progress.
- * @param {boolean} loadingSupervisedUsers True if supervised users are being
- * loaded.
- * @param {number} signedInUserIndex Index of the selected signed-in user.
- * @return {boolean}
- * @private
- */
- isImportUserLinkHidden_: function(
- createInProgress, loadingSupervisedUsers, signedInUserIndex) {
- return createInProgress || loadingSupervisedUsers ||
- !this.signedInUser_(signedInUserIndex);
+ return createInProgress || !profileName || !nameInput.validate();
},
-
- /**
- * Computed binding that returns True if there are any signed-in users.
- * @param {!Array<!SignedInUser>} signedInUsers signed-in users.
- * @return {boolean}
- * @private
- */
- isSignedIn_: function(signedInUsers) {
- return signedInUsers.length > 0;
- }
});
}());
diff --git a/chromium/chrome/browser/resources/md_user_manager/error_dialog.html b/chromium/chrome/browser/resources/md_user_manager/error_dialog.html
index 9cae3a5cd40..cd2feba9eb7 100644
--- a/chromium/chrome/browser/resources/md_user_manager/error_dialog.html
+++ b/chromium/chrome/browser/resources/md_user_manager/error_dialog.html
@@ -16,7 +16,7 @@
word-wrap: break-word;
}
</style>
- <cr-dialog id="dialog">
+ <cr-dialog id="dialog" show-close-button>
<div slot="body">
<div id="message">[[message_]]</div>
</div>
diff --git a/chromium/chrome/browser/resources/md_user_manager/import_supervised_user.html b/chromium/chrome/browser/resources/md_user_manager/import_supervised_user.html
deleted file mode 100644
index 73b108cff3f..00000000000
--- a/chromium/chrome/browser/resources/md_user_manager/import_supervised_user.html
+++ /dev/null
@@ -1,94 +0,0 @@
-<link rel="import" href="chrome://resources/html/polymer.html">
-
-<link rel="import" href="/shared_styles.html">
-<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
-<link rel="import" href="chrome://resources/cr_elements/shared_style_css.html">
-<link rel="import" href="chrome://resources/html/i18n_behavior.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-item/paper-item.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-listbox/paper-listbox.html">
-
-<dom-module id="import-supervised-user">
- <template>
- <style include="shared-styles cr-shared-style iron-flex iron-flex-alignment iron-positioning">
- :host {
- --item-height: 52px;
- --items-container-max-height: calc(var(--item-height) * 4);
- }
-
- #message {
- margin-bottom: 16px;
- margin-top: 20px;
- white-space: pre-wrap;
- word-wrap: break-word;
- }
-
- paper-listbox {
- max-height: var(--items-container-max-height);
- overflow: auto;
- }
-
- paper-listbox paper-item {
- --paper-item: {
- font-size: inherit;
- height: var(--item-height);
- line-height: inherit;
- };
- --paper-item-disabled: {
- color: inherit;
- };
- --paper-item-focused: {
- background: rgba(0, 0, 0, .04);
- };
- --paper-item-focused-before: {
- background: none;
- };
- }
-
- paper-listbox paper-item .profile-img {
- flex-shrink: 0;
- }
-
- paper-listbox paper-item .profile-name {
- -webkit-margin-start: 10px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-
- paper-listbox paper-item .on-device {
- -webkit-margin-start: 10px;
- flex-shrink: 0;
- }
- </style>
- <cr-dialog id="dialog">
- <div slot="title">$i18n{supervisedUserImportTitle}</div>
- <div slot="body">
- <div id="message">$i18n{supervisedUserImportText}</div>
- <paper-listbox class="no-padding" selected="{{supervisedUserIndex_}}">
- <template is="dom-repeat" items="[[supervisedUsers_]]">
- <paper-item disabled="[[item.onCurrentDevice]]">
- <img class="profile-img" src="[[item.iconURL]]">
- <div class="profile-name">[[item.name]]</div>
- <div class="on-device" hidden="[[!item.onCurrentDevice]]">
- $i18n{supervisedUserAlreadyOnThisDevice}
- </div>
- </paper-item>
- </template>
- </paper-listbox>
- </div>
- <div slot="button-container">
- <paper-button id="cancel" class="cancel-button" on-tap="onCancelTap_">
- $i18n{cancel}
- </paper-button>
- <paper-button id="import" class="action-button"
- on-tap="onImportTap_"
- disabled="[[isImportDisabled_(supervisedUserIndex_)]]">
- $i18n{supervisedUserImportOk}
- </paper-button>
- </div>
- </cr-dialog>
- </template>
- <script src="import_supervised_user.js"></script>
-</dom-module>
diff --git a/chromium/chrome/browser/resources/md_user_manager/import_supervised_user.js b/chromium/chrome/browser/resources/md_user_manager/import_supervised_user.js
deleted file mode 100644
index 11ca765969b..00000000000
--- a/chromium/chrome/browser/resources/md_user_manager/import_supervised_user.js
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/**
- * @fileoverview 'import-supervised-user' is a dialog that allows user to select
- * a supervised profile from a list of profiles to import on the current device.
- */
-(function() {
-/**
- * It means no supervised user is selected.
- * @type {number}
- */
-const NO_USER_SELECTED = -1;
-
-Polymer({
- is: 'import-supervised-user',
-
- behaviors: [
- I18nBehavior,
- ],
-
- properties: {
- /**
- * The currently signed in user and the custodian.
- * @private {?SignedInUser}
- */
- signedInUser_: {
- type: Object,
- value: function() {
- return null;
- }
- },
-
- /**
- * The list of supervised users managed by signedInUser_.
- * @private {!Array<!SupervisedUser>}
- */
- supervisedUsers_: {
- type: Array,
- value: function() {
- return [];
- }
- },
-
- /**
- * Index of the selected supervised user.
- * @private {number}
- */
- supervisedUserIndex_: {type: Number, value: NO_USER_SELECTED}
- },
-
- /**
- * Displays the dialog.
- * @param {(!SignedInUser|undefined)} signedInUser
- * @param {!Array<!SupervisedUser>} supervisedUsers
- */
- show: function(signedInUser, supervisedUsers) {
- this.supervisedUsers_ = supervisedUsers;
- this.supervisedUsers_.sort(function(a, b) {
- if (a.onCurrentDevice != b.onCurrentDevice)
- return a.onCurrentDevice ? 1 : -1;
- return a.name.localeCompare(b.name);
- });
-
- this.supervisedUserIndex_ = NO_USER_SELECTED;
-
- this.signedInUser_ = signedInUser || null;
- if (this.signedInUser_)
- this.$.dialog.showModal();
- },
-
- /**
- * @param {number} supervisedUserIndex Index of the selected supervised user.
- * @return {boolean} Whether the 'Import' button should be disabled.
- * @private
- */
- isImportDisabled_: function(supervisedUserIndex) {
- return supervisedUserIndex == NO_USER_SELECTED;
- },
-
- /**
- * Called when the user clicks the 'Import' button. it proceeds with importing
- * the supervised user.
- * @private
- */
- onImportTap_: function() {
- const supervisedUser = this.supervisedUsers_[this.supervisedUserIndex_];
- if (this.signedInUser_ && supervisedUser) {
- this.$.dialog.close();
- // Event is caught by create-profile.
- this.fire(
- 'import',
- {supervisedUser: supervisedUser, signedInUser: this.signedInUser_});
- }
- },
-
- /** @private */
- onCancelTap_: function() {
- this.$.dialog.close();
- },
-});
-})();
diff --git a/chromium/chrome/browser/resources/md_user_manager/profile_browser_proxy.js b/chromium/chrome/browser/resources/md_user_manager/profile_browser_proxy.js
index 8d766878e19..da35f050863 100644
--- a/chromium/chrome/browser/resources/md_user_manager/profile_browser_proxy.js
+++ b/chromium/chrome/browser/resources/md_user_manager/profile_browser_proxy.js
@@ -7,26 +7,12 @@
* between JS and C++ for creating/importing profiles in the user-manager page.
*/
-/** @typedef {{username: string, profilePath: string}} */
-let SignedInUser;
-
/**
* @typedef {{name: string,
- * filePath: string,
- * isSupervised: boolean,
- * custodianUsername: string,
- * showConfirmation: boolean}}
+ * filePath: string}}
*/
let ProfileInfo;
-/**
- * @typedef {{id: string,
- * name: string,
- * iconURL: string,
- * onCurrentDevice: boolean}}
- */
-let SupervisedUser;
-
cr.define('signin', function() {
/** @interface */
function ProfileBrowserProxy() {}
@@ -40,13 +26,6 @@ cr.define('signin', function() {
},
/**
- * Gets the current signed-in users.
- */
- getSignedInUsers: function() {
- assertNotReached();
- },
-
- /**
* Launches the guest user.
*/
launchGuestUser: function() {
@@ -54,44 +33,14 @@ cr.define('signin', function() {
},
/**
- * @param {string} profilePath Profile Path of the custodian.
- * @return {!Promise<!Array<!SupervisedUser>>} The list of existing
- * supervised users.
- */
- getExistingSupervisedUsers: function(profilePath) {
- assertNotReached();
- },
-
- /**
* Creates a profile.
* @param {string} profileName Name of the new profile.
* @param {string} profileIconUrl URL of the selected icon of the new
* profile.
* @param {boolean} createShortcut if true a desktop shortcut will be
* created.
- * @param {boolean} isSupervised True if the new profile is supervised.
- * @param {string} supervisedUserId ID of the supervised user to be
- * imported.
- * @param {string} custodianProfilePath Profile path of the custodian if
- * the new profile is supervised.
- */
- createProfile: function(
- profileName, profileIconUrl, createShortcut, isSupervised,
- supervisedUserId, custodianProfilePath) {
- assertNotReached();
- },
-
- /**
- * Cancels creation of the new profile.
*/
- cancelCreateProfile: function() {
- assertNotReached();
- },
-
- /**
- * Cancels loading supervised users.
- */
- cancelLoadingSupervisedUsers: function() {
+ createProfile: function(profileName, profileIconUrl, createShortcut) {
assertNotReached();
},
@@ -163,38 +112,14 @@ cr.define('signin', function() {
},
/** @override */
- getSignedInUsers: function() {
- chrome.send('requestSignedInProfiles');
- },
-
- /** @override */
launchGuestUser: function() {
chrome.send('launchGuest');
},
/** @override */
- getExistingSupervisedUsers: function(profilePath) {
- return cr.sendWithPromise('getExistingSupervisedUsers', profilePath);
- },
-
- /** @override */
- createProfile: function(
- profileName, profileIconUrl, createShortcut, isSupervised,
- supervisedUserId, custodianProfilePath) {
- chrome.send('createProfile', [
- profileName, profileIconUrl, createShortcut, isSupervised,
- supervisedUserId, custodianProfilePath
- ]);
- },
-
- /** @override */
- cancelCreateProfile: function() {
- chrome.send('cancelCreateProfile');
- },
-
- /** @override */
- cancelLoadingSupervisedUsers: function() {
- chrome.send('cancelLoadingSupervisedUsers');
+ createProfile: function(profileName, profileIconUrl, createShortcut) {
+ chrome.send(
+ 'createProfile', [profileName, profileIconUrl, createShortcut]);
},
/** @override */
diff --git a/chromium/chrome/browser/resources/md_user_manager/supervised_user_create_confirm.html b/chromium/chrome/browser/resources/md_user_manager/supervised_user_create_confirm.html
deleted file mode 100644
index f87044917b8..00000000000
--- a/chromium/chrome/browser/resources/md_user_manager/supervised_user_create_confirm.html
+++ /dev/null
@@ -1,63 +0,0 @@
-<link rel="import" href="chrome://resources/html/polymer.html">
-
-<link rel="import" href="/profile_browser_proxy.html">
-<link rel="import" href="/shared_styles.html">
-<link rel="import" href="chrome://resources/html/util.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
-
-<dom-module id="supervised-user-create-confirm">
- <template>
- <style include="shared-styles iron-flex iron-flex-alignment iron-positioning">
- :host {
- align-self: center;
- }
-
- #container {
- color: var(--primary-text-color);
- line-height: 20px;
- width: var(--page-width);
- }
-
- #title-area {
- font-size: 16px;
- font-weight: 500;
- }
-
- .content-area {
- padding-top: 32px;
- white-space: pre-wrap;
- word-wrap: break-word;
- }
-
- #actions {
- bottom: 16px;
- position: absolute;
- right: 16px;
- }
-
- :host-context([dir='rtl']) #actions {
- left: 16px;
- right: auto;
- }
- </style>
- <div id="container">
- <div id="title-area" class="horizontal justified layout">
- <span id="title">[[titleText_(profileInfo)]]</span>
- </div>
- <div class="content-area"
- inner-h-t-m-l="[[confirmationMessage_(profileInfo)]]">
- </div>
- <div id="actions">
- <paper-button id="ok" class="action secondary" on-tap="onOkTap_">
- $i18n{supervisedUserCreatedDone}
- </paper-button>
- <paper-button id="switchUser" class="action primary"
- on-tap="onSwitchUserTap_">
- [[switchUserText_(profileInfo)]]
- </paper-button>
- </div>
- </div>
- </template>
- <script src="supervised_user_create_confirm.js"></script>
-</dom-module>
diff --git a/chromium/chrome/browser/resources/md_user_manager/supervised_user_create_confirm.js b/chromium/chrome/browser/resources/md_user_manager/supervised_user_create_confirm.js
deleted file mode 100644
index 11acbbed620..00000000000
--- a/chromium/chrome/browser/resources/md_user_manager/supervised_user_create_confirm.js
+++ /dev/null
@@ -1,145 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/**
- * @fileoverview 'supervised-user-create-confirm' is a page that is displayed
- * upon successful creation of a supervised user. It contains information for
- * the custodian on where to configure browsing restrictions as well as how to
- * exit and childlock their profile.
- */
-(function() {
-/**
- * Maximum length of the supervised user profile name or custodian's username.
- * @type {number}
- */
-const MAX_NAME_LENGTH = 50;
-
-Polymer({
- is: 'supervised-user-create-confirm',
-
- behaviors: [I18nBehavior],
-
- properties: {
- /**
- * Profile Info of the supervised user that is passed to the page.
- * @type {?ProfileInfo}
- */
- profileInfo: {
- type: Object,
- value: function() {
- return null;
- }
- },
-
- /** @private {!signin.ProfileBrowserProxy} */
- browserProxy_: Object
- },
-
- listeners: {'tap': 'onTap_'},
-
- /** @override */
- created: function() {
- this.browserProxy_ = signin.ProfileBrowserProxyImpl.getInstance();
- },
-
- /**
- * Handles tap events from dynamically created links in the
- * supervisedUserCreatedText i18n string.
- * @param {!Event} event
- * @private
- */
- onTap_: function(event) {
- const element = Polymer.dom(event).rootTarget;
-
- // Handle the tap event only if the target is a '<a>' element.
- if (element.nodeName == 'A') {
- this.browserProxy_.openUrlInLastActiveProfileBrowser(element.href);
- event.preventDefault();
- }
- },
-
- /**
- * Returns the shortened profile name or empty string if |profileInfo| is
- * null.
- * @param {?ProfileInfo} profileInfo
- * @return {string}
- * @private
- */
- elideProfileName_: function(profileInfo) {
- const name = profileInfo ? profileInfo.name : '';
- return elide(name, MAX_NAME_LENGTH);
- },
-
- /**
- * Returns the shortened custodian username or empty string if |profileInfo|
- * is null.
- * @param {?ProfileInfo} profileInfo
- * @return {string}
- * @private
- */
- elideCustodianUsername_: function(profileInfo) {
- const name = profileInfo ? profileInfo.custodianUsername : '';
- return elide(name, MAX_NAME_LENGTH);
- },
-
- /**
- * Computed binding returning the text of the title section.
- * @param {?ProfileInfo} profileInfo
- * @return {string}
- * @private
- */
- titleText_: function(profileInfo) {
- return this.i18n(
- 'supervisedUserCreatedTitle', this.elideProfileName_(profileInfo));
- },
-
- /**
- * Computed binding returning the sanitized confirmation HTML message that is
- * safe to set as innerHTML.
- * @param {?ProfileInfo} profileInfo
- * @return {string}
- * @private
- */
- confirmationMessage_: function(profileInfo) {
- return this.i18nAdvanced('supervisedUserCreatedText', {
- substitutions: [
- this.elideProfileName_(profileInfo),
- this.elideCustodianUsername_(profileInfo)
- ],
- });
- },
-
- /**
- * Computed binding returning the text of the 'Switch To User' button.
- * @param {?ProfileInfo} profileInfo
- * @return {string}
- * @private
- */
- switchUserText_: function(profileInfo) {
- return this.i18n(
- 'supervisedUserCreatedSwitch', this.elideProfileName_(profileInfo));
- },
-
- /**
- * Handler for the 'Ok' button tap event.
- * @param {!Event} event
- * @private
- */
- onOkTap_: function(event) {
- // Event is caught by user-manager-pages.
- this.fire('change-page', {page: 'user-pods-page'});
- },
-
- /**
- * Handler for the 'Switch To User' button tap event.
- * @param {!Event} event
- * @private
- */
- onSwitchUserTap_: function(event) {
- this.browserProxy_.switchToProfile(this.profileInfo.filePath);
- // Event is caught by user-manager-pages.
- this.fire('change-page', {page: 'user-pods-page'});
- }
-});
-})();
diff --git a/chromium/chrome/browser/resources/md_user_manager/supervised_user_learn_more.html b/chromium/chrome/browser/resources/md_user_manager/supervised_user_learn_more.html
deleted file mode 100644
index 5ada724a33f..00000000000
--- a/chromium/chrome/browser/resources/md_user_manager/supervised_user_learn_more.html
+++ /dev/null
@@ -1,55 +0,0 @@
-<link rel="import" href="chrome://resources/html/polymer.html">
-
-<link rel="import" href="/shared_styles.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
-
-<dom-module id="supervised-user-learn-more">
- <template>
- <style include="shared-styles iron-flex iron-flex-alignment iron-positioning">
- :host {
- align-self: center;
- }
-
- #container {
- color: var(--primary-text-color);
- line-height: 20px;
- width: var(--page-width);
- }
-
- #title-area {
- font-size: 16px;
- font-weight: 500;
- }
-
- .content-area {
- padding-top: 32px;
- white-space: pre-wrap;
- word-wrap: break-word;
- }
-
- #actions {
- bottom: 16px;
- position: absolute;
- right: 16px;
- }
-
- :host-context([dir='rtl']) #actions {
- left: 16px;
- right: auto;
- }
- </style>
- <div id="container">
- <div id="title-area" class="horizontal justified layout">
- <span id="title">$i18n{supervisedUserLearnMoreTitle}</span>
- </div>
- <div class="content-area">$i18nRaw{supervisedUserLearnMoreText}</div>
- <div id="actions">
- <paper-button id="done" class="action primary" on-tap="onDoneTap_">
- $i18n{supervisedUserLearnMoreDone}
- </paper-button>
- </div>
- </div>
- </template>
- <script src="supervised_user_learn_more.js"></script>
-</dom-module>
diff --git a/chromium/chrome/browser/resources/md_user_manager/supervised_user_learn_more.js b/chromium/chrome/browser/resources/md_user_manager/supervised_user_learn_more.js
deleted file mode 100644
index 42a7b301448..00000000000
--- a/chromium/chrome/browser/resources/md_user_manager/supervised_user_learn_more.js
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/**
- * @fileoverview 'supervised-user-learn-more' is a page that contains
- * information about what a supervised user is, what happens when a supervised
- * user is created, and a link to the help center for more information.
- */
-Polymer({
- is: 'supervised-user-learn-more',
-
- properties: {
- /** @private {!signin.ProfileBrowserProxy} */
- browserProxy_: Object
- },
-
- listeners: {'tap': 'onTap_'},
-
- /** @override */
- created: function() {
- this.browserProxy_ = signin.ProfileBrowserProxyImpl.getInstance();
- },
-
- /**
- * Handles tap events from dynamically created links in the
- * supervisedUserLearnMoreText i18n string.
- * @param {!Event} event
- * @private
- */
- onTap_: function(event) {
- const element = Polymer.dom(event).rootTarget;
-
- // Handle the tap event only if the target is a '<a>' element.
- if (element.nodeName == 'A') {
- this.browserProxy_.openUrlInLastActiveProfileBrowser(element.href);
- event.preventDefault();
- }
- },
-
- /**
- * Handler for the 'Done' button tap event.
- * @param {!Event} event
- * @private
- */
- onDoneTap_: function(event) {
- // Event is caught by user-manager-pages.
- this.fire('change-page', {page: 'create-user-page'});
- }
-});
diff --git a/chromium/chrome/browser/resources/md_user_manager/user_manager_pages.html b/chromium/chrome/browser/resources/md_user_manager/user_manager_pages.html
index c2f8945b653..8df85d3f7c0 100644
--- a/chromium/chrome/browser/resources/md_user_manager/user_manager_pages.html
+++ b/chromium/chrome/browser/resources/md_user_manager/user_manager_pages.html
@@ -1,8 +1,6 @@
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="/create_profile.html">
-<link rel="import" href="/supervised_user_create_confirm.html">
-<link rel="import" href="/supervised_user_learn_more.html">
<link rel="import" href="chrome://resources/polymer/v1_0/neon-animation/animations/fade-in-animation.html">
<link rel="import" href="chrome://resources/polymer/v1_0/neon-animation/animations/fade-out-animation.html">
<link rel="import" href="chrome://resources/polymer/v1_0/neon-animation/neon-animatable.html">
diff --git a/chromium/chrome/browser/resources/md_user_manager/user_manager_tutorial.js b/chromium/chrome/browser/resources/md_user_manager/user_manager_tutorial.js
index f6134f20489..d365ca5b925 100644
--- a/chromium/chrome/browser/resources/md_user_manager/user_manager_tutorial.js
+++ b/chromium/chrome/browser/resources/md_user_manager/user_manager_tutorial.js
@@ -2,12 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-/**
- * @fileoverview 'user-manager-tutorial' is the element that controls the
- * tutorial steps for the user manager page.
- */
-(function() {
-
/** @enum {string} */
const TutorialSteps = {
YOUR_CHROME: 'yourChrome',
@@ -17,6 +11,11 @@ const TutorialSteps = {
NOT_YOU: 'notYou'
};
+/**
+ * @fileoverview 'user-manager-tutorial' is the element that controls the
+ * tutorial steps for the user manager page.
+ */
+(function() {
Polymer({
is: 'user-manager-tutorial',
diff --git a/chromium/chrome/browser/resources/media/media_engagement.js b/chromium/chrome/browser/resources/media/media_engagement.js
index 6f685cb590d..a1619c26b6a 100644
--- a/chromium/chrome/browser/resources/media/media_engagement.js
+++ b/chromium/chrome/browser/resources/media/media_engagement.js
@@ -116,6 +116,28 @@ function renderConfigTable(config) {
createConfigRow('Lower Threshold', config.highScoreLowerThreshold));
configTableBody.appendChild(
createConfigRow('Upper Threshold', config.highScoreUpperThreshold));
+
+ configTableBody.appendChild(createConfigRow(
+ 'Record MEI data', formatFeatureFlag(config.featureRecordData)));
+ configTableBody.appendChild(createConfigRow(
+ 'Bypass autoplay based on MEI',
+ formatFeatureFlag(config.featureBypassAutoplay)));
+ configTableBody.appendChild(createConfigRow(
+ 'Preload MEI data', formatFeatureFlag(config.featurePreloadData)));
+ configTableBody.appendChild(
+ createConfigRow('Autoplay Policy', config.autoplayPolicy));
+ configTableBody.appendChild(createConfigRow(
+ 'Preload version',
+ config.preloadVersion ? config.preloadVersion : 'Not Available'));
+}
+
+/**
+ * Converts a boolean into a string value.
+ * @param {bool} value The value of the config setting.
+ * @return {string}
+ */
+function formatFeatureFlag(value) {
+ return value ? 'Enabled' : 'Disabled';
}
/**
diff --git a/chromium/chrome/browser/resources/media_router/BUILD.gn b/chromium/chrome/browser/resources/media_router/BUILD.gn
new file mode 100644
index 00000000000..ad4aebea658
--- /dev/null
+++ b/chromium/chrome/browser/resources/media_router/BUILD.gn
@@ -0,0 +1,58 @@
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+group("closure_compile") {
+ deps = [
+ ":media_router_resources",
+ "elements/issue_banner:closure_compile",
+ "elements/media_router_container:closure_compile",
+ "elements/media_router_header:closure_compile",
+ "elements/media_router_search_highlighter:closure_compile",
+ "elements/route_controls:closure_compile",
+ "elements/route_details:closure_compile",
+ ]
+}
+
+js_type_check("media_router_resources") {
+ deps = [
+ ":media_router",
+ ":media_router_browser_api",
+ ":media_router_data",
+ ":media_router_ui_interface",
+ ]
+}
+
+js_library("media_router") {
+ deps = [
+ ":media_router_ui_interface",
+ "elements/media_router_container:media_router_container_interface",
+ "elements/media_router_header:media_router_header",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("media_router_browser_api") {
+ deps = [
+ ":media_router_data",
+ ]
+ externs_list = [ "$externs_path/chrome_send.js" ]
+}
+
+js_library("media_router_data") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
+
+js_library("media_router_ui_interface") {
+ deps = [
+ ":media_router_browser_api",
+ "elements/media_router_container:media_router_container_interface",
+ "elements/media_router_header:media_router_header",
+ "elements/route_controls:route_controls_interface",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/media_router/OWNERS b/chromium/chrome/browser/resources/media_router/OWNERS
index c2e26607570..2d837dee815 100644
--- a/chromium/chrome/browser/resources/media_router/OWNERS
+++ b/chromium/chrome/browser/resources/media_router/OWNERS
@@ -1,5 +1,4 @@
amp@chromium.org
-apacible@chromium.org
imcheng@chromium.org
mfoltz@chromium.org
diff --git a/chromium/chrome/browser/resources/media_router/compiled_resources2.gyp b/chromium/chrome/browser/resources/media_router/compiled_resources2.gyp
deleted file mode 100644
index ff0af0525f8..00000000000
--- a/chromium/chrome/browser/resources/media_router/compiled_resources2.gyp
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'externs',
- 'includes': ['../../../../third_party/closure_compiler/include_js.gypi'],
- },
- {
- 'target_name': 'media_router',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- 'media_router_ui_interface',
- 'elements/media_router_header/compiled_resources2.gyp:media_router_header',
- 'elements/media_router_container/compiled_resources2.gyp:media_router_container_interface',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'media_router_browser_api',
- 'dependencies': [
- 'media_router_data',
- '<(EXTERNS_GYP):chrome_send',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'media_router_data',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'media_router_ui_interface',
- 'dependencies': [
- 'media_router_browser_api',
- 'elements/media_router_header/compiled_resources2.gyp:media_router_header',
- 'elements/media_router_container/compiled_resources2.gyp:media_router_container_interface',
- 'elements/route_controls/compiled_resources2.gyp:route_controls_interface',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/media_router/elements/issue_banner/BUILD.gn b/chromium/chrome/browser/resources/media_router/elements/issue_banner/BUILD.gn
new file mode 100644
index 00000000000..0994f8c3196
--- /dev/null
+++ b/chromium/chrome/browser/resources/media_router/elements/issue_banner/BUILD.gn
@@ -0,0 +1,18 @@
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":issue_banner",
+ ]
+}
+
+js_library("issue_banner") {
+ deps = [
+ "../..:media_router_data",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/media_router/elements/issue_banner/compiled_resources2.gyp b/chromium/chrome/browser/resources/media_router/elements/issue_banner/compiled_resources2.gyp
deleted file mode 100644
index 621a1d48a21..00000000000
--- a/chromium/chrome/browser/resources/media_router/elements/issue_banner/compiled_resources2.gyp
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'issue_banner',
- 'dependencies': [
- '../../compiled_resources2.gyp:media_router_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- ],
- 'includes': ['../../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/media_router/elements/media_router_container/BUILD.gn b/chromium/chrome/browser/resources/media_router/elements/media_router_container/BUILD.gn
new file mode 100644
index 00000000000..be701f7ec4a
--- /dev/null
+++ b/chromium/chrome/browser/resources/media_router/elements/media_router_container/BUILD.gn
@@ -0,0 +1,39 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":media_router_container",
+ ":media_router_container_interface",
+ ":pseudo_sink_search_state",
+ ]
+}
+
+js_library("media_router_container") {
+ deps = [
+ ":pseudo_sink_search_state",
+ "../..:media_router_browser_api",
+ "../..:media_router_data",
+ "../../elements/issue_banner:issue_banner",
+ "../../elements/media_router_header:media_router_header",
+ "../../elements/media_router_search_highlighter:media_router_search_highlighter",
+ "../../elements/route_details:route_details",
+ ]
+ externs_list = [ "../../externs.js" ]
+}
+
+js_library("media_router_container_interface") {
+ deps = [
+ "../..:media_router_data",
+ "../../elements/media_router_header:media_router_header",
+ ]
+}
+
+js_library("pseudo_sink_search_state") {
+ deps = [
+ "../..:media_router_data",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/media_router/elements/media_router_container/compiled_resources2.gyp b/chromium/chrome/browser/resources/media_router/elements/media_router_container/compiled_resources2.gyp
deleted file mode 100644
index dc5aa26cfb3..00000000000
--- a/chromium/chrome/browser/resources/media_router/elements/media_router_container/compiled_resources2.gyp
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'media_router_container',
- 'dependencies': [
- 'pseudo_sink_search_state',
- '../../compiled_resources2.gyp:externs',
- '../../compiled_resources2.gyp:media_router_browser_api',
- '../../compiled_resources2.gyp:media_router_data',
- '../../elements/issue_banner/compiled_resources2.gyp:issue_banner',
- '../../elements/media_router_header/compiled_resources2.gyp:media_router_header',
- '../../elements/media_router_search_highlighter/compiled_resources2.gyp:media_router_search_highlighter',
- '../../elements/route_details/compiled_resources2.gyp:route_details',
- ],
- 'includes': ['../../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'media_router_container_interface',
- 'dependencies': [
- '../../compiled_resources2.gyp:media_router_data',
- '../../elements/media_router_header/compiled_resources2.gyp:media_router_header',
- ],
- 'includes': ['../../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'pseudo_sink_search_state',
- 'dependencies': [
- '../../compiled_resources2.gyp:media_router_data',
- ],
- 'includes': ['../../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.css b/chromium/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.css
index 9cc54236cca..2ea2acebcde 100644
--- a/chromium/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.css
+++ b/chromium/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.css
@@ -117,11 +117,13 @@
text-align: center;
}
-paper-checkbox {
- --paper-checkbox-checked-color: white;
- --paper-checkbox-checkmark-color: var(--paper-blue-700);
- --paper-checkbox-ink-size: 35px;
- --paper-checkbox-unchecked-color: white;
+cr-checkbox {
+ --cr-checkbox-checked-box-color: white;
+ --cr-checkbox-mark-color: var(--paper-blue-700);
+ --cr-checkbox-ripple-checked-color: white;
+ --cr-checkbox-ripple-unchecked-color: white;
+ --cr-checkbox-unchecked-box-color: white;
+ --cr-checkbox-ripple-opacity: 0.25;
}
paper-item {
diff --git a/chromium/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.html b/chromium/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.html
index 6b606df8ece..4e446513411 100644
--- a/chromium/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.html
+++ b/chromium/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.html
@@ -1,6 +1,7 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+
+<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-checkbox/paper-checkbox.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-input/paper-input.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-item/paper-item.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-listbox/paper-listbox.html">
@@ -19,26 +20,20 @@
<div id="first-run-title">[[i18n('firstRunFlowTitle')]]</div>
<div id="first-run-text">
<span>[[i18n('firstRunFlowText')]]</span>
- <a href="[[firstRunFlowLearnMoreUrl]]" target="_blank">
- <span class="first-run-learn-more">
- [[i18n('learnMoreText')]]
- </span>
+ <a href="[[firstRunFlowLearnMoreUrl]]" class="first-run-learn-more"
+ target="_blank">
+ [[i18n('learnMoreText')]]
</a>
</div>
<div id="first-run-flow-cloud-pref"
hidden$="[[!showFirstRunFlowCloudPref]]">
- <div>
- <paper-checkbox checked id="first-run-cloud-checkbox">
- </paper-checkbox>
- </div>
- <div>
+ <cr-checkbox checked id="first-run-cloud-checkbox">
<span>[[getFirstRunFlowCloudPrefText_()]]</span>
- <a href="[[firstRunFlowCloudPrefLearnMoreUrl]]" target="_blank">
- <span class="first-run-learn-more">
- [[i18n('learnMoreText')]]
- </span>
+ <a href="[[firstRunFlowCloudPrefLearnMoreUrl]]"
+ class="first-run-learn-more" target="_blank">
+ [[i18n('learnMoreText')]]
</a>
- </div>
+ </cr-checkbox>
</div>
<div id="first-run-button-container">
<paper-button id="first-run-button" class="button"
diff --git a/chromium/chrome/browser/resources/media_router/elements/media_router_header/BUILD.gn b/chromium/chrome/browser/resources/media_router/elements/media_router_header/BUILD.gn
new file mode 100644
index 00000000000..20336476804
--- /dev/null
+++ b/chromium/chrome/browser/resources/media_router/elements/media_router_header/BUILD.gn
@@ -0,0 +1,19 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":media_router_header",
+ ]
+}
+
+js_library("media_router_header") {
+ deps = [
+ "../..:media_router_data",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:util",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/media_router/elements/media_router_header/compiled_resources2.gyp b/chromium/chrome/browser/resources/media_router/elements/media_router_header/compiled_resources2.gyp
deleted file mode 100644
index 40cfdea2b9f..00000000000
--- a/chromium/chrome/browser/resources/media_router/elements/media_router_header/compiled_resources2.gyp
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'media_router_header',
- 'dependencies': [
- '../../compiled_resources2.gyp:media_router_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- ],
- 'includes': ['../../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/media_router/elements/media_router_search_highlighter/BUILD.gn b/chromium/chrome/browser/resources/media_router/elements/media_router_search_highlighter/BUILD.gn
new file mode 100644
index 00000000000..7881aba419e
--- /dev/null
+++ b/chromium/chrome/browser/resources/media_router/elements/media_router_search_highlighter/BUILD.gn
@@ -0,0 +1,17 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":media_router_search_highlighter",
+ ]
+}
+
+js_library("media_router_search_highlighter") {
+ deps = [
+ "//ui/webui/resources/js:util",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/media_router/elements/media_router_search_highlighter/compiled_resources2.gyp b/chromium/chrome/browser/resources/media_router/elements/media_router_search_highlighter/compiled_resources2.gyp
deleted file mode 100644
index 18e64ac7790..00000000000
--- a/chromium/chrome/browser/resources/media_router/elements/media_router_search_highlighter/compiled_resources2.gyp
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'media_router_search_highlighter',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- ],
- 'includes': ['../../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/media_router/elements/route_controls/BUILD.gn b/chromium/chrome/browser/resources/media_router/elements/route_controls/BUILD.gn
new file mode 100644
index 00000000000..0b21078a54b
--- /dev/null
+++ b/chromium/chrome/browser/resources/media_router/elements/route_controls/BUILD.gn
@@ -0,0 +1,28 @@
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":route_controls",
+ ":route_controls_interface",
+ ]
+}
+
+js_library("route_controls") {
+ deps = [
+ "../..:media_router_browser_api",
+ "../..:media_router_data",
+ "../..:media_router_ui_interface",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
+
+js_library("route_controls_interface") {
+ deps = [
+ "../..:media_router_data",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/media_router/elements/route_controls/compiled_resources2.gyp b/chromium/chrome/browser/resources/media_router/elements/route_controls/compiled_resources2.gyp
deleted file mode 100644
index cb312aec660..00000000000
--- a/chromium/chrome/browser/resources/media_router/elements/route_controls/compiled_resources2.gyp
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'route_controls',
- 'dependencies': [
- '../../compiled_resources2.gyp:media_router_browser_api',
- '../../compiled_resources2.gyp:media_router_data',
- '../../compiled_resources2.gyp:media_router_ui_interface',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- ],
- 'includes': ['../../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'route_controls_interface',
- 'dependencies': [
- '../../compiled_resources2.gyp:media_router_data',
- ],
- 'includes': ['../../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/media_router/elements/route_controls/route_controls.css b/chromium/chrome/browser/resources/media_router/elements/route_controls/route_controls.css
index 322ee273e68..8de71a9bd47 100644
--- a/chromium/chrome/browser/resources/media_router/elements/route_controls/route_controls.css
+++ b/chromium/chrome/browser/resources/media_router/elements/route_controls/route_controls.css
@@ -79,10 +79,6 @@
padding: 0.3em 0;
}
-paper-checkbox {
- --paper-checkbox-checked-color: #1976D2;
-}
-
#hangouts-local-present-controls {
cursor: pointer;
display: inline-block;
@@ -92,8 +88,11 @@ paper-checkbox {
}
#hangouts-local-present-checkbox {
- --paper-checkbox-vertical-align: top;
-};
+ --cr-checkbox-label-container: {
+ -webkit-padding-start: 14px;
+ }
+ align-items: start;
+}
#hangouts-local-present-checkbox-subtitle {
display: block;
diff --git a/chromium/chrome/browser/resources/media_router/elements/route_controls/route_controls.html b/chromium/chrome/browser/resources/media_router/elements/route_controls/route_controls.html
index 65a26cf7946..788339f115d 100644
--- a/chromium/chrome/browser/resources/media_router/elements/route_controls/route_controls.html
+++ b/chromium/chrome/browser/resources/media_router/elements/route_controls/route_controls.html
@@ -1,8 +1,9 @@
-<link rel="import" href="chrome://resources/html/md_select_css.html">
<link rel="import" href="chrome://resources/html/polymer.html">
+
+<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html">
+<link rel="import" href="chrome://resources/html/md_select_css.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icons/av-icons.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-checkbox/paper-checkbox.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-slider/paper-slider.html">
<dom-module id="route-controls">
<link rel="import" type="css" href="../../media_router_common.css">
@@ -70,7 +71,7 @@
</span>
<div id="hangouts-local-present-controls"
hidden="[[!routeStatus.hangoutsExtraData]]">
- <paper-checkbox
+ <cr-checkbox
checked="[[hangoutsLocalPresent_]]"
id="hangouts-local-present-checkbox"
on-change="onHangoutsLocalPresentChange_"
@@ -81,7 +82,7 @@
<span id="hangouts-local-present-checkbox-subtitle">
[[i18n('hangoutsLocalPresentSubtitle')]]
</span>
- </paper-checkbox>
+ </cr-checkbox>
</div>
</div>
<div id="mirroring-fullscreen-video-controls"
diff --git a/chromium/chrome/browser/resources/media_router/elements/route_controls/route_controls.js b/chromium/chrome/browser/resources/media_router/elements/route_controls/route_controls.js
index f2cc3e360ce..98f15e0b868 100644
--- a/chromium/chrome/browser/resources/media_router/elements/route_controls/route_controls.js
+++ b/chromium/chrome/browser/resources/media_router/elements/route_controls/route_controls.js
@@ -75,7 +75,7 @@ Polymer({
/**
* Set to true when the user is dragging the volume bar. Volume updates from
* the browser will be ignored when set to true.
- * @private {boolean}
+ * @private
*/
isVolumeChanging_: {
type: Boolean,
@@ -84,7 +84,7 @@ Polymer({
/**
* The timestamp for when the controller last submitted a seek request.
- * @private {number}
+ * @private
*/
lastSeekByUser_: {
type: Number,
@@ -93,7 +93,7 @@ Polymer({
/**
* The timestamp for when |routeStatus| was last updated.
- * @private {number}
+ * @private
*/
lastStatusUpdate_: {
type: Number,
@@ -103,7 +103,7 @@ Polymer({
/**
* The timestamp for when the controller last submitted a volume change
* request.
- * @private {boolean}
+ * @private
*/
lastVolumeChangeByUser_: {
type: Number,
@@ -112,7 +112,7 @@ Polymer({
/**
* Keep in sync with media remoting individual user setting.
- * @private {boolean}
+ * @private
*/
mediaRemotingEnabled_: {
type: Boolean,
@@ -336,7 +336,7 @@ Polymer({
/**
* Called when the "smooth motion" box for Hangouts is changed by the user.
- * @param {!{target: !PaperCheckboxElement}} e
+ * @param {!{target: !HTMLElement}} e
* @private
*/
onHangoutsLocalPresentChange_: function(e) {
@@ -401,7 +401,7 @@ Polymer({
this.FullscreenVideoOption_.REMOTE_SCREEN :
this.FullscreenVideoOption_.BOTH_SCREENS;
}
- this.shouldShowRouteStatusTitle_ = newRouteStatus.title &&
+ this.shouldShowRouteStatusTitle_ = !!newRouteStatus.title &&
newRouteStatus.title != '' &&
newRouteStatus.title != this.routeDescription_;
},
diff --git a/chromium/chrome/browser/resources/media_router/elements/route_details/BUILD.gn b/chromium/chrome/browser/resources/media_router/elements/route_details/BUILD.gn
new file mode 100644
index 00000000000..b7559add3ca
--- /dev/null
+++ b/chromium/chrome/browser/resources/media_router/elements/route_details/BUILD.gn
@@ -0,0 +1,21 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":route_details",
+ ]
+}
+
+js_library("route_details") {
+ deps = [
+ "../..:media_router_data",
+ "../..:media_router_ui_interface",
+ "../route_controls:route_controls",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/media_router/elements/route_details/compiled_resources2.gyp b/chromium/chrome/browser/resources/media_router/elements/route_details/compiled_resources2.gyp
deleted file mode 100644
index d8eb22868be..00000000000
--- a/chromium/chrome/browser/resources/media_router/elements/route_details/compiled_resources2.gyp
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'route_details',
- 'dependencies': [
- '../../compiled_resources2.gyp:media_router_data',
- '../../compiled_resources2.gyp:media_router_ui_interface',
- '../route_controls/compiled_resources2.gyp:route_controls',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- ],
- 'includes': ['../../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/media_router/elements/route_details/route_details.js b/chromium/chrome/browser/resources/media_router/elements/route_details/route_details.js
index a91b5897ea1..71526863464 100644
--- a/chromium/chrome/browser/resources/media_router/elements/route_details/route_details.js
+++ b/chromium/chrome/browser/resources/media_router/elements/route_details/route_details.js
@@ -191,7 +191,7 @@ Polymer({
* @private
*/
shouldShowWebUiControls_: function(route) {
- return route && route.supportsWebUiController;
+ return !!route && !!route.supportsWebUiController;
},
/**
diff --git a/chromium/chrome/browser/resources/net_internals/browser_bridge.js b/chromium/chrome/browser/resources/net_internals/browser_bridge.js
index 9a9c1c9e284..b7fb13f67c4 100644
--- a/chromium/chrome/browser/resources/net_internals/browser_bridge.js
+++ b/chromium/chrome/browser/resources/net_internals/browser_bridge.js
@@ -54,6 +54,8 @@ var BrowserBridge = (function() {
'altSvcMappings', 'onAltSvcMappingsChanged');
this.addNetInfoPollableDataHelper('quicInfo', 'onQuicInfoChanged');
this.addNetInfoPollableDataHelper(
+ 'reportingInfo', 'onReportingInfoChanged');
+ this.addNetInfoPollableDataHelper(
'httpCacheInfo', 'onHttpCacheInfoChanged');
// Add other PollableDataHelpers.
@@ -482,6 +484,17 @@ var BrowserBridge = (function() {
},
/**
+ * Adds a listener of the Reporting info. |observer| will be called back
+ * when data is received, through:
+ *
+ * observer.onReportingInfoChanged(reportingInfo)
+ */
+ addReportingInfoObserver: function(observer, ignoreWhenUnchanged) {
+ this.pollableDataHelpers_.reportingInfo.addObserver(
+ observer, ignoreWhenUnchanged);
+ },
+
+ /**
* Adds a listener of the SPDY info. |observer| will be called back
* when data is received, through:
*
diff --git a/chromium/chrome/browser/resources/net_internals/index.html b/chromium/chrome/browser/resources/net_internals/index.html
index fec412dbf6e..5451405783b 100644
--- a/chromium/chrome/browser/resources/net_internals/index.html
+++ b/chromium/chrome/browser/resources/net_internals/index.html
@@ -35,6 +35,7 @@ found in the LICENSE file.
<include src="alt_svc_view.html">
<include src="spdy_view.html">
<include src="quic_view.html">
+ <include src="reporting_view.html">
<include src="http_cache_view.html">
<include src="bandwidth_view.html">
<include src="prerender_view.html">
diff --git a/chromium/chrome/browser/resources/net_internals/index.js b/chromium/chrome/browser/resources/net_internals/index.js
index fdb47b9c72e..e8fefcef711 100644
--- a/chromium/chrome/browser/resources/net_internals/index.js
+++ b/chromium/chrome/browser/resources/net_internals/index.js
@@ -37,6 +37,7 @@
// <include src="log_grouper.js">
// <include src="proxy_view.js">
// <include src="quic_view.js">
+// <include src="reporting_view.js">
// <include src="socket_pool_wrapper.js">
// <include src="sockets_view.js">
// <include src="alt_svc_view.js">
diff --git a/chromium/chrome/browser/resources/net_internals/main.js b/chromium/chrome/browser/resources/net_internals/main.js
index 875a93381e3..0c6e59d6613 100644
--- a/chromium/chrome/browser/resources/net_internals/main.js
+++ b/chromium/chrome/browser/resources/net_internals/main.js
@@ -189,6 +189,7 @@ var MainView = (function() {
addTab(AltSvcView);
addTab(SpdyView);
addTab(QuicView);
+ addTab(ReportingView);
addTab(HttpCacheView);
addTab(ModulesView);
addTab(DomainSecurityPolicyView);
diff --git a/chromium/chrome/browser/resources/net_internals/reporting_view.html b/chromium/chrome/browser/resources/net_internals/reporting_view.html
new file mode 100644
index 00000000000..fa30020e087
--- /dev/null
+++ b/chromium/chrome/browser/resources/net_internals/reporting_view.html
@@ -0,0 +1,86 @@
+<style>
+td.reporting-centered {
+ text-align: center;
+}
+td.reporting-right-justified {
+ text-align: right;
+}
+td .reporting-content-summary {
+}
+td .reporting-content-expand-button {
+ color: rgb(0, 0, 255);
+ cursor: pointer;
+ float: right;
+ font-size: 80%;
+ margin-left: 1em;
+ text-decoration: underline;
+}
+td .reporting-content-detail {
+}
+</style>
+
+<div id=reporting-view-tab-content class=content-box>
+ <!-- Only one of these two are shown -->
+ <div id=reporting-view-disabled-content><h4>Reporting is disabled</h4></div>
+ <div id=reporting-view-enabled-content>
+ <h4 style='margin-top:0'>Queued reports</h4>
+ <table id=reporting-view-reports-table class="styled-table">
+ <thead>
+ <tr>
+ <th>Queued</th>
+ <th>URL</th>
+ <th>Status</th>
+ <th>Type</th>
+ <th>Content</th>
+ </tr>
+ </thead>
+ <tbody id=reporting-view-reports-tbody>
+ </tbody>
+ </table>
+ <div id=reporting-view-reports-empty>There are no queued reports</div>
+
+ <h4>Per-origin config</h4>
+ <table id=reporting-view-clients-table class="styled-table">
+ <thead>
+ <tr>
+ <th>Origin</th>
+ <th>Group</th>
+ <th>Subdomains?</th>
+ <th>Expires</th>
+ <th>Endpoint</th>
+ <th>Priority</th>
+ <th>Weight</th>
+ <th>Uploads</th>
+ <th>Failed uploads</th>
+ </tr>
+ </thead>
+ <tbody id=reporting-view-clients-tbody>
+ </tbody>
+ </table>
+ <div id=reporting-view-clients-empty>
+ No origins have provided Reporting headers
+ </div>
+
+ <h4>Network Error Logging policies</h4>
+ <table id=reporting-view-nel-policies-table class="styled-table">
+ <thead>
+ <tr>
+ <th>Origin</th>
+ <th>Subdomains?</th>
+ <th>Expires</th>
+ <th>Group</th>
+ <th>Success %</th>
+ <th>Failure %</th>
+ </tr>
+ </thead>
+ <tbody id=reporting-view-nel-policies-tbody>
+ </tbody>
+ </table>
+ <div id=reporting-view-nel-policies-disabled>
+ NEL is disabled
+ </div>
+ <div id=reporting-view-nel-policies-empty>
+ No origins have provided NEL headers
+ </div>
+ </div>
+</div>
diff --git a/chromium/chrome/browser/resources/net_internals/reporting_view.js b/chromium/chrome/browser/resources/net_internals/reporting_view.js
new file mode 100644
index 00000000000..b43a1876aeb
--- /dev/null
+++ b/chromium/chrome/browser/resources/net_internals/reporting_view.js
@@ -0,0 +1,397 @@
+// Copyright (c) 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.
+
+/**
+ * This view displays a summary of the current Reporting cache, including the
+ * configuration headers received for Reporting-enabled origins, and any queued
+ * reports that are waiting to be uploaded.
+ */
+var ReportingView = (function() {
+ 'use strict';
+
+ // We inherit from DivView.
+ var superClass = DivView;
+
+ /**
+ * @constructor
+ */
+ function ReportingView() {
+ assertFirstConstructorCall(ReportingView);
+
+ // Call superclass's constructor.
+ superClass.call(this, ReportingView.MAIN_BOX_ID);
+
+ g_browser.addReportingInfoObserver(this, true);
+ }
+
+ ReportingView.TAB_ID = 'tab-handle-reporting';
+ ReportingView.TAB_NAME = 'Reporting';
+ ReportingView.TAB_HASH = '#reporting';
+
+ // IDs for special HTML elements in reporting_view.html
+ ReportingView.MAIN_BOX_ID = 'reporting-view-tab-content';
+
+ ReportingView.DISABLED_BOX_ID = 'reporting-view-disabled-content';
+ ReportingView.ENABLED_BOX_ID = 'reporting-view-enabled-content';
+
+ ReportingView.CLIENTS_EMPTY_ID = 'reporting-view-clients-empty';
+ ReportingView.CLIENTS_TABLE_ID = 'reporting-view-clients-table';
+ ReportingView.CLIENTS_TBODY_ID = 'reporting-view-clients-tbody';
+ ReportingView.REPORTS_EMPTY_ID = 'reporting-view-reports-empty';
+ ReportingView.REPORTS_TABLE_ID = 'reporting-view-reports-table';
+ ReportingView.REPORTS_TBODY_ID = 'reporting-view-reports-tbody';
+
+ ReportingView.NEL_POLICIES_DISABLED_ID =
+ 'reporting-view-nel-policies-disabled';
+ ReportingView.NEL_POLICIES_EMPTY_ID = 'reporting-view-nel-policies-empty';
+ ReportingView.NEL_POLICIES_TABLE_ID = 'reporting-view-nel-policies-table';
+ ReportingView.NEL_POLICIES_TBODY_ID = 'reporting-view-nel-policies-tbody';
+
+ cr.addSingletonGetter(ReportingView);
+
+ ReportingView.prototype = {
+ // Inherit the superclass's methods.
+ __proto__: superClass.prototype,
+
+ onLoadLogFinish: function(data) {
+ return this.onReportingInfoChanged(data.reportingInfo);
+ },
+
+ onReportingInfoChanged: function(reportingInfo) {
+ if (!isObject_(reportingInfo))
+ return false;
+
+ var enabled = !!reportingInfo.reportingEnabled;
+ setNodeDisplay($(ReportingView.DISABLED_BOX_ID), !enabled);
+ setNodeDisplay($(ReportingView.ENABLED_BOX_ID), enabled);
+ if (!enabled)
+ return true;
+
+ displayReportDetail_(ensureArray_(reportingInfo.reports));
+ displayClientDetail_(ensureArray_(reportingInfo.clients));
+ displayNELPolicyDetail_(reportingInfo.networkErrorLogging);
+ return true;
+ },
+ };
+
+ /**
+ * Displays information about each queued report in the Reporting cache.
+ * REQUIRES: |reportList| must be an array
+ */
+ function displayReportDetail_(reportList) {
+ // Clear the existing content.
+ $(ReportingView.REPORTS_TBODY_ID).innerHTML = '';
+
+ var empty = reportList.length == 0;
+ setNodeDisplay($(ReportingView.REPORTS_EMPTY_ID), empty);
+ setNodeDisplay($(ReportingView.REPORTS_TABLE_ID), !empty);
+ if (empty)
+ return;
+
+ for (var i = 0; i < reportList.length; ++i) {
+ var report = ensureObject_(reportList[i]);
+ var tr = addNode($(ReportingView.REPORTS_TBODY_ID), 'tr');
+
+ var queuedNode = addNode(tr, 'td');
+ if (report.queued != undefined) {
+ var queuedDate = timeutil.convertTimeTicksToDate(report.queued);
+ timeutil.addNodeWithDate(queuedNode, queuedDate);
+ }
+
+ addNodeWithText(tr, 'td', report.url);
+
+ var statusNode = addNode(tr, 'td');
+ addTextNode(statusNode, report.status);
+ addTextNode(statusNode, ' (' + report.group);
+ if (report.depth !== undefined && report.depth > 0)
+ addTextNode(statusNode, ', depth: ' + report.depth);
+ if (report.attempts !== undefined && report.attempts > 0)
+ addTextNode(statusNode, ', attempts: ' + report.attempts);
+ addTextNode(statusNode, ')');
+
+ addNodeWithText(tr, 'td', report.type);
+
+ var contentNode = addNode(tr, 'td');
+ if (report.type == 'network-error')
+ displayNetworkErrorContent_(contentNode, report);
+ else
+ displayGenericReportContent_(contentNode, report);
+ }
+ }
+
+ /**
+ * Adds nodes to the "content" cell for a report that allow you to show a
+ * summary as well as collapsable detail. We will add a clickable button that
+ * toggles between showing and hiding the detail; its label will be `showText`
+ * when the detail is hidden, and `hideText` when it's visible.
+ *
+ * The result is an object containing `summary` and `detail` nodes. You can
+ * add whatever content you want to each of these nodes. The summary should
+ * be a one-liner, and will be a <span>. The detail can be as large as you
+ * want, and will be a <div>.
+ */
+ function addContentSections_(contentNode, showText, hideText) {
+ var sections = {};
+
+ sections.summary = addNode(contentNode, 'span');
+ sections.summary.classList.add('reporting-content-summary');
+
+ var button = addNode(contentNode, 'span');
+ button.classList.add('reporting-content-expand-button');
+ addTextNode(button, showText);
+ button.onclick = function() {
+ toggleNodeDisplay(sections.detail);
+ button.textContent =
+ getNodeDisplay(sections.detail) ? hideText : showText;
+ };
+
+ sections.detail = addNode(contentNode, 'div');
+ sections.detail.classList.add('reporting-content-detail');
+ setNodeDisplay(sections.detail, false);
+
+ return sections;
+ }
+
+ /**
+ * Displays format-specific detail for Network Error Logging reports.
+ * REQUIRES: |report| must be an object
+ */
+ function displayNetworkErrorContent_(contentNode, report) {
+ var contentSections =
+ addContentSections_(contentNode, 'Show raw report', 'Hide raw report');
+
+ var body = ensureObject_(report.body);
+ addTextNode(contentSections.summary, body.type);
+ // Only show the status code if it's present and not 0.
+ if (body['status-code'])
+ addTextNode(
+ contentSections.summary, ' (' + report.body['status-code'] + ')');
+
+ addNodeWithText(
+ contentSections.detail, 'pre', JSON.stringify(report, null, ' '));
+ }
+
+ /**
+ * Displays a generic content cell for reports whose type we don't know how to
+ * render something specific for.
+ * REQUIRES: |report| must be an object
+ */
+ function displayGenericReportContent_(contentNode, report) {
+ var contentSections =
+ addContentSections_(contentNode, 'Show raw report', 'Hide raw report');
+ addNodeWithText(
+ contentSections.detail, 'pre', JSON.stringify(report, null, ' '));
+ }
+
+ /**
+ * Displays information about each origin that has provided Reporting headers.
+ * REQUIRES: |clientList| must be an array
+ */
+ function displayClientDetail_(clientList) {
+ // Clear the existing content.
+ $(ReportingView.CLIENTS_TBODY_ID).innerHTML = '';
+
+ var empty = clientList.length == 0;
+ setNodeDisplay($(ReportingView.CLIENTS_EMPTY_ID), empty);
+ setNodeDisplay($(ReportingView.CLIENTS_TABLE_ID), !empty);
+ if (empty)
+ return;
+
+ for (var i = 0; i < clientList.length; ++i) {
+ var client = ensureObject_(clientList[i]);
+ var groups = ensureArray_(client.groups);
+ if (groups.length == 0)
+ continue;
+
+ // Calculate the total number of endpoints for this origin, so that we can
+ // rowspan its origin cell.
+ var originHeight = 0;
+ for (var j = 0; j < groups.length; ++j) {
+ var group = ensureObject_(groups[j]);
+ var endpoints = ensureArray_(group.endpoints);
+ originHeight += group.endpoints.length;
+ }
+ if (originHeight == 0)
+ continue;
+
+ for (var j = 0; j < groups.length; ++j) {
+ var group = ensureObject_(groups[j]);
+ var endpoints = ensureArray_(group.endpoints);
+ for (var k = 0; k < endpoints.length; ++k) {
+ var endpoint = ensureObject_(endpoints[k]);
+ var tr = addNode($(ReportingView.CLIENTS_TBODY_ID), 'tr');
+
+ if (j == 0 && k == 0) {
+ var originNode = addNode(tr, 'td');
+ originNode.setAttribute('rowspan', originHeight);
+ addTextNode(originNode, client.origin);
+ }
+
+ if (k == 0) {
+ var groupNode = addNode(tr, 'td');
+ groupNode.setAttribute('rowspan', group.endpoints.length);
+ addTextNode(groupNode, group.name);
+
+ var subdomainsNode = addNode(tr, 'td');
+ subdomainsNode.classList.add('reporting-centered');
+ subdomainsNode.setAttribute('rowspan', group.endpoints.length);
+ addTextNode(
+ subdomainsNode, !!group.includeSubdomains ? 'yes' : 'no');
+
+ var expiresNode = addNode(tr, 'td');
+ expiresNode.setAttribute('rowspan', group.endpoints.length);
+ if (group.expires !== undefined) {
+ var expiresDate = timeutil.convertTimeTicksToDate(group.expires);
+ timeutil.addNodeWithDate(expiresNode, expiresDate);
+ if (expired_(expiresDate)) {
+ var expiredSpan = addNode(expiresNode, 'span');
+ expiredSpan.classList.add('warning-text');
+ addTextNode(expiredSpan, ' [expired]');
+ }
+ }
+ }
+
+ var endpointNode = addNode(tr, 'td');
+ addTextNode(endpointNode, endpoint.url);
+
+ var priorityNode = addNode(tr, 'td');
+ priorityNode.classList.add('reporting-centered');
+ addTextNode(priorityNode, valueOrDefault_(endpoint.priority, 0));
+
+ var weightNode = addNode(tr, 'td');
+ weightNode.classList.add('reporting-centered');
+ addTextNode(weightNode, valueOrDefault_(endpoint.weight, 1));
+
+ addUploadCount_(tr, ensureObject_(endpoint.successful));
+ addUploadCount_(tr, ensureObject_(endpoint.failed));
+ }
+ }
+ }
+ }
+
+ /**
+ * Adds an upload count cell to the client details table.
+ * REQUIRES: |counts| must be an object
+ */
+ function addUploadCount_(tr, counts) {
+ var node = addNode(tr, 'td');
+ node.classList.add('reporting-centered');
+ var uploads = valueOrDefault_(counts.uploads, 0);
+ var reports = valueOrDefault_(counts.reports, 0);
+ if (uploads == 0 && reports == 0) {
+ addTextNode(node, '-');
+ } else {
+ addTextNode(node, uploads + ' (' + reports + ')');
+ }
+ }
+
+ /**
+ * Displays information about each origin that has provided NEL headers.
+ */
+ function displayNELPolicyDetail_(nelInfo) {
+ // Clear the existing content.
+ $(ReportingView.NEL_POLICIES_TBODY_ID).innerHTML = '';
+
+ var disabled = (nelInfo === undefined);
+ setNodeDisplay($(ReportingView.NEL_POLICIES_DISABLED_ID), disabled);
+ if (disabled) {
+ setNodeDisplay($(ReportingView.NEL_POLICIES_EMPTY_ID), false);
+ setNodeDisplay($(ReportingView.NEL_POLICIES_TABLE_ID), false);
+ return;
+ }
+
+ nelInfo = ensureObject_(nelInfo);
+ var policies = ensureArray_(nelInfo.originPolicies);
+ var empty = policies.length == 0;
+ setNodeDisplay($(ReportingView.NEL_POLICIES_EMPTY_ID), empty);
+ setNodeDisplay($(ReportingView.NEL_POLICIES_TABLE_ID), !empty);
+ if (empty)
+ return;
+
+ for (var i = 0; i < policies.length; ++i) {
+ var policy = ensureObject_(policies[i]);
+ var tr = addNode($(ReportingView.NEL_POLICIES_TBODY_ID), 'tr');
+
+ addNodeWithText(tr, 'td', policy.origin);
+
+ var subdomainsNode = addNode(tr, 'td');
+ subdomainsNode.classList.add('reporting-centered');
+ addTextNode(subdomainsNode, !!policy.includeSubdomains ? 'yes' : 'no');
+
+ var expiresNode = addNode(tr, 'td');
+ if (policy.expires !== undefined) {
+ var expiresDate = timeutil.convertTimeTicksToDate(policy.expires);
+ timeutil.addNodeWithDate(expiresNode, expiresDate);
+ if (expired_(expiresDate)) {
+ var expiredSpan = addNode(expiresNode, 'span');
+ expiredSpan.classList.add('warning-text');
+ addTextNode(expiredSpan, ' [expired]');
+ }
+ }
+
+ addNodeWithText(tr, 'td', policy.reportTo);
+
+ var successFractionNode = addNode(tr, 'td');
+ successFractionNode.classList.add('reporting-right-justified');
+ addTextNode(successFractionNode, percent_(policy.successFraction));
+
+ var failureFractionNode = addNode(tr, 'td');
+ failureFractionNode.classList.add('reporting-right-justified');
+ addTextNode(failureFractionNode, percent_(policy.failureFraction));
+ }
+ }
+
+ /**
+ * Returns whether an expiry timestamp has expired. If we're viewing live
+ * data, uses the actual current time to determine whether it's expired. If
+ * we're viewing data from a saved log file, uses the timestamp when the file
+ * was recorded.
+ *
+ * @param {Date} expiry An expiry time
+ */
+ function expired_(expiry) {
+ var now;
+ if (MainView.isViewingLoadedLog()) {
+ now = new Date(ClientInfo.numericDate);
+ } else {
+ now = new Date();
+ }
+ return expiry < now;
+ }
+
+ /**
+ * Formats a float fraction as a percentage.
+ */
+ function percent_(fraction) {
+ return (valueOrDefault_(fraction, 0) * 100).toFixed(2) + '%';
+ }
+
+ function isObject_(value) {
+ return value && typeof(value) === 'object';
+ }
+
+ function isArray_(value) {
+ return value !== undefined && value instanceof Array;
+ }
+
+ function ensureObject_(value) {
+ if (isObject_(value))
+ return value;
+ return {};
+ }
+
+ function ensureArray_(value) {
+ if (isArray_(value))
+ return value;
+ return [];
+ }
+
+ function valueOrDefault_(value, defaultValue) {
+ if (value != undefined)
+ return value;
+ return defaultValue;
+ }
+
+ return ReportingView;
+})();
diff --git a/chromium/chrome/browser/resources/net_internals/util.js b/chromium/chrome/browser/resources/net_internals/util.js
index fa92b3c794b..47662456e8b 100644
--- a/chromium/chrome/browser/resources/net_internals/util.js
+++ b/chromium/chrome/browser/resources/net_internals/util.js
@@ -45,6 +45,22 @@ function setNodeDisplay(node, isVisible) {
}
/**
+ * Toggles the visibility of a DOM node.
+ * @param {!HtmlNode} node The node to show or hide.
+ */
+function toggleNodeDisplay(node) {
+ setNodeDisplay(node, !getNodeDisplay(node));
+}
+
+/**
+ * Returns the visibility of a DOM node.
+ * @param {!HtmlNode} node The node to query.
+ */
+function getNodeDisplay(node) {
+ return node.style.display != 'none';
+}
+
+/**
* Adds a node to |parentNode|, of type |tagName|.
* @param {!HtmlNode} parentNode The node that will be the parent of the new
* element.
diff --git a/chromium/chrome/browser/resources/ntp4/BUILD.gn b/chromium/chrome/browser/resources/ntp4/BUILD.gn
new file mode 100644
index 00000000000..7bd99669526
--- /dev/null
+++ b/chromium/chrome/browser/resources/ntp4/BUILD.gn
@@ -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.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":apps_page",
+ ]
+}
+
+js_library("apps_page") {
+ sources = [
+ "//third_party/jstemplate/jsevalcontext.js",
+ "//third_party/jstemplate/jstemplate.js",
+ "//third_party/jstemplate/util.js",
+ "//ui/webui/resources/js/action_link.js",
+ "//ui/webui/resources/js/assert.js",
+ "//ui/webui/resources/js/cr.js",
+ "//ui/webui/resources/js/cr/event_target.js",
+ "//ui/webui/resources/js/cr/ui.js",
+ "//ui/webui/resources/js/cr/ui/bubble.js",
+ "//ui/webui/resources/js/cr/ui/card_slider.js",
+ "//ui/webui/resources/js/cr/ui/command.js",
+ "//ui/webui/resources/js/cr/ui/context_menu_button.js",
+ "//ui/webui/resources/js/cr/ui/context_menu_handler.js",
+ "//ui/webui/resources/js/cr/ui/drag_wrapper.js",
+ "//ui/webui/resources/js/cr/ui/expandable_bubble.js",
+ "//ui/webui/resources/js/cr/ui/focus_manager.js",
+ "//ui/webui/resources/js/cr/ui/menu.js",
+ "//ui/webui/resources/js/cr/ui/menu_button.js",
+ "//ui/webui/resources/js/cr/ui/menu_item.js",
+ "//ui/webui/resources/js/cr/ui/position_util.js",
+ "//ui/webui/resources/js/cr/ui/touch_handler.js",
+ "//ui/webui/resources/js/event_tracker.js",
+ "//ui/webui/resources/js/load_time_data.js",
+ "//ui/webui/resources/js/parse_html_subset.js",
+ "//ui/webui/resources/js/promise_resolver.js",
+ "//ui/webui/resources/js/util.js",
+ "apps_page.js",
+ "dot_list.js",
+ "logging.js",
+ "nav_dot.js",
+ "new_tab.js",
+ "page_list_view.js",
+ "page_switcher.js",
+ "tile_page.js",
+ "trash.js",
+ ]
+
+ externs_list = [
+ "$externs_path/chrome.js",
+ "$externs_path/chrome_send.js",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/ntp4/apps_page.js b/chromium/chrome/browser/resources/ntp4/apps_page.js
index 713c4f37bb2..0cfe93869b9 100644
--- a/chromium/chrome/browser/resources/ntp4/apps_page.js
+++ b/chromium/chrome/browser/resources/ntp4/apps_page.js
@@ -569,7 +569,7 @@ cr.define('ntp', function() {
/**
* Creates a new AppsPage object.
* @constructor
- * @extends {TilePage}
+ * @extends {ntp.TilePage}
*/
function AppsPage() {
var el = new TilePage(appsPageGridValues);
diff --git a/chromium/chrome/browser/resources/ntp4/compiled_resources2.gyp b/chromium/chrome/browser/resources/ntp4/compiled_resources2.gyp
deleted file mode 100644
index 4f1f721b8fb..00000000000
--- a/chromium/chrome/browser/resources/ntp4/compiled_resources2.gyp
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'apps_page',
- 'variables': {
- 'script_args': ['--custom_sources'],
- 'source_files': [
- '<(DEPTH)/third_party/closure_compiler/externs/chrome_send.js',
- '<(DEPTH)/third_party/jstemplate/util.js',
- '<(DEPTH)/third_party/jstemplate/jsevalcontext.js',
- '<(DEPTH)/third_party/jstemplate/jstemplate.js',
- '<(DEPTH)/ui/webui/resources/js/action_link.js',
- '<(DEPTH)/ui/webui/resources/js/assert.js',
- '<(DEPTH)/ui/webui/resources/js/cr.js',
- '<(DEPTH)/ui/webui/resources/js/event_tracker.js',
- '<(DEPTH)/ui/webui/resources/js/load_time_data.js',
- '<(DEPTH)/ui/webui/resources/js/parse_html_subset.js',
- '<(DEPTH)/ui/webui/resources/js/promise_resolver.js',
- '<(DEPTH)/ui/webui/resources/js/util.js',
- '<(DEPTH)/ui/webui/resources/js/cr/event_target.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/bubble.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/card_slider.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/command.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/context_menu_handler.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/drag_wrapper.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/expandable_bubble.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/focus_manager.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/menu.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/menu_item.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/position_util.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/menu_button.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/context_menu_button.js',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/touch_handler.js',
- 'logging.js',
- 'tile_page.js',
- 'dot_list.js',
- 'trash.js',
- 'page_switcher.js',
- 'page_list_view.js',
- 'nav_dot.js',
- 'new_tab.js',
- 'apps_page.js',
- ],
- },
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/offline_pages/BUILD.gn b/chromium/chrome/browser/resources/offline_pages/BUILD.gn
new file mode 100644
index 00000000000..83c60714a90
--- /dev/null
+++ b/chromium/chrome/browser/resources/offline_pages/BUILD.gn
@@ -0,0 +1,28 @@
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":offline_internals",
+ ":offline_internals_browser_proxy",
+ ]
+}
+
+js_library("offline_internals") {
+ deps = [
+ ":offline_internals_browser_proxy",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:util",
+ ]
+}
+
+js_library("offline_internals_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/offline_pages/compiled_resources2.gyp b/chromium/chrome/browser/resources/offline_pages/compiled_resources2.gyp
deleted file mode 100644
index 559ed1a4953..00000000000
--- a/chromium/chrome/browser/resources/offline_pages/compiled_resources2.gyp
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'offline_internals',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- 'offline_internals_browser_proxy',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'offline_internals_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/offline_pages/offline_internals.html b/chromium/chrome/browser/resources/offline_pages/offline_internals.html
index f7ab768f209..df91dab4e7c 100644
--- a/chromium/chrome/browser/resources/offline_pages/offline_internals.html
+++ b/chromium/chrome/browser/resources/offline_pages/offline_internals.html
@@ -52,14 +52,13 @@
<h2>Stored Pages</h2>
<div>
- <button id="delete-all-pages">Delete all</button>
<button id="delete-selected-pages">Delete selected</button>
</div>
<table class="stored-pages-table">
<thead>
<tr>
<th>#</th>
- <th></th>
+ <th><input type="checkbox" id="toggle-all-stored"></th>
<th>URL</th>
<th>Namespace</th>
<th>Size (Kb)</th>
@@ -80,13 +79,12 @@
<h2>Request Queue</h2>
<div>
- <button id="delete-all-requests">Delete all</button>
<button id="delete-selected-requests">Delete selected</button>
</div>
<table class="request-queue-table">
<thead>
<tr>
- <th>&nbsp;</th>
+ <th><input type="checkbox" id="toggle-all-requests"></th>
<th>URL</th>
<th>Created Timestamp</th>
<th>Status</th>
diff --git a/chromium/chrome/browser/resources/offline_pages/offline_internals.js b/chromium/chrome/browser/resources/offline_pages/offline_internals.js
index f184c8c005b..b63962f2470 100644
--- a/chromium/chrome/browser/resources/offline_pages/offline_internals.js
+++ b/chromium/chrome/browser/resources/offline_pages/offline_internals.js
@@ -37,7 +37,7 @@ cr.define('offlineInternals', function() {
var td = template.content.querySelectorAll('td');
for (let pageIndex = 0; pageIndex < pages.length; pageIndex++) {
var page = pages[pageIndex];
- td[0].textContent = pageIndex;
+ td[0].textContent = pageIndex + 1;
var checkbox = td[1].querySelector('input');
checkbox.setAttribute('value', page.id);
@@ -116,34 +116,6 @@ cr.define('offlineInternals', function() {
}
/**
- * Delete all pages in the offline store.
- */
- function deleteAllPages() {
- var checkboxes = document.getElementsByName('stored');
- var selectedIds = [];
-
- for (var i = 0; i < checkboxes.length; i++) {
- selectedIds.push(checkboxes[i].value);
- }
-
- browserProxy.deleteSelectedPages(selectedIds).then(pagesDeleted);
- }
-
- /**
- * Delete all pending SavePageRequest items in the request queue.
- */
- function deleteAllRequests() {
- var checkboxes = document.getElementsByName('requests');
- var selectedIds = [];
-
- for (var i = 0; i < checkboxes.length; i++) {
- selectedIds.push(checkboxes[i].value);
- }
-
- browserProxy.deleteSelectedRequests(selectedIds).then(requestsDeleted);
- }
-
- /**
* Callback when pages are deleted.
* @param {string} status The status of the request.
*/
@@ -221,33 +193,29 @@ cr.define('offlineInternals', function() {
}
/**
- * Delete selected pages from the offline store.
+ * Sets all checkboxes with a specific name to the same checked status as the
+ * provided source checkbox.
+ * @param {HTMLElement} source The checkbox controlling the checked
+ * status.
+ * @param {string} checkboxesName The name identifying the checkboxes to set.
*/
- function deleteSelectedPages() {
- var checkboxes = document.getElementsByName('stored');
- var selectedIds = [];
-
- for (var i = 0; i < checkboxes.length; i++) {
- if (checkboxes[i].checked)
- selectedIds.push(checkboxes[i].value);
+ function toggleAllCheckboxes(source, checkboxesName) {
+ var checkboxes = document.getElementsByName(checkboxesName);
+ for (let checkbox of checkboxes) {
+ checkbox.checked = source.checked;
}
-
- browserProxy.deleteSelectedPages(selectedIds).then(pagesDeleted);
}
/**
- * Delete selected SavePageRequest items from the request queue.
+ * Return the item ids for the selected checkboxes with a given name.
+ * @param {string} checkboxesName The name identifying the checkboxes to
+ * query.
+ * @return {!Array<string>} An array of selected ids.
*/
- function deleteSelectedRequests() {
- var checkboxes = document.getElementsByName('requests');
- var selectedIds = [];
-
- for (var i = 0; i < checkboxes.length; i++) {
- if (checkboxes[i].checked)
- selectedIds.push(checkboxes[i].value);
- }
-
- browserProxy.deleteSelectedRequests(selectedIds).then(requestsDeleted);
+ function getSelectedIdsFor(checkboxesName) {
+ var checkboxes = document.querySelectorAll(
+ `input[type="checkbox"][name="${checkboxesName}"]:checked`);
+ return Array.from(checkboxes).map(c => c.value);
}
/**
@@ -287,15 +255,19 @@ cr.define('offlineInternals', function() {
}
var incognito = loadTimeData.getBoolean('isIncognito');
- ['delete-all-pages', 'delete-selected-pages', 'delete-all-requests',
- 'delete-selected-requests', 'log-model-on', 'log-model-off',
- 'log-request-on', 'log-request-off', 'refresh']
+ ['delete-selected-pages', 'delete-selected-requests', 'log-model-on',
+ 'log-model-off', 'log-request-on', 'log-request-off', 'refresh']
.forEach(el => $(el).disabled = incognito);
- $('delete-all-pages').onclick = deleteAllPages;
- $('delete-selected-pages').onclick = deleteSelectedPages;
- $('delete-all-requests').onclick = deleteAllRequests;
- $('delete-selected-requests').onclick = deleteSelectedRequests;
+ $('delete-selected-pages').onclick = function() {
+ let pageIds = getSelectedIdsFor('stored');
+ browserProxy.deleteSelectedPages(pageIds).then(pagesDeleted);
+
+ };
+ $('delete-selected-requests').onclick = function() {
+ let requestIds = getSelectedIdsFor('requests');
+ browserProxy.deleteSelectedRequests(requestIds).then(requestsDeleted);
+ };
$('refresh').onclick = refreshAll;
$('dump').onclick = dumpAsJson;
$('close-dump').onclick = closeDump;
@@ -354,6 +326,12 @@ cr.define('offlineInternals', function() {
$('download-archive').onclick = function() {
browserProxy.downloadArchive($('download-name').value);
};
+ $('toggle-all-stored').onclick = function() {
+ toggleAllCheckboxes($('toggle-all-stored'), 'stored');
+ };
+ $('toggle-all-requests').onclick = function() {
+ toggleAllCheckboxes($('toggle-all-requests'), 'requests');
+ };
if (!incognito)
refreshAll();
}
diff --git a/chromium/chrome/browser/resources/omnibox/omnibox.js b/chromium/chrome/browser/resources/omnibox/omnibox.js
index f97d788bf64..cee6d94e6be 100644
--- a/chromium/chrome/browser/resources/omnibox/omnibox.js
+++ b/chromium/chrome/browser/resources/omnibox/omnibox.js
@@ -80,7 +80,7 @@ function startOmniboxQuery(event) {
* @param {string} propertyName the name of the property in the autocomplete
* result record that we lookup.
* @param {boolean} displayAlways whether the property should be displayed
- * regardless of whether we're in detailed more.
+ * regardless of whether we're in detailed mode.
* @param {string} tooltip a description of the property that will be
* presented as a tooltip when the mouse is hovered over the column title.
* @constructor
@@ -123,6 +123,9 @@ var PROPERTY_OUTPUT_ORDER = [
'Starred', '', 'starred', false,
'A green checkmark indicates that the result has been bookmarked.'),
new PresentationInfoRecord(
+ 'Has tab match', '', 'hasTabMatch', false,
+ 'A green checkmark indicates that the result URL matches an open tab.'),
+ new PresentationInfoRecord(
'Description', '', 'description', false, 'The page title of the result.'),
new PresentationInfoRecord(
'URL', '', 'destinationUrl', true, 'The URL for the result.'),
diff --git a/chromium/chrome/browser/resources/page_not_available_for_guest/app.html b/chromium/chrome/browser/resources/page_not_available_for_guest/app.html
new file mode 100644
index 00000000000..3313ee43dc0
--- /dev/null
+++ b/chromium/chrome/browser/resources/page_not_available_for_guest/app.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<html dir="$i18n{textdirection}" lang="$i18n{language}">
+ <head>
+ <meta charset="utf-8">
+ <title>$i18n{pageTitle}</title>
+ <link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css">
+ <style>
+ h1 {
+ color: #6e6e6e;
+ font-weight: 500;
+ margin-top: 80px;
+ text-align: center;
+ }
+ </style>
+ </head>
+ <body>
+ <h1>$i18n{pageHeading}</h1>
+ </body>
+</html>
diff --git a/chromium/chrome/browser/resources/pdf/BUILD.gn b/chromium/chrome/browser/resources/pdf/BUILD.gn
new file mode 100644
index 00000000000..5a3ce142671
--- /dev/null
+++ b/chromium/chrome/browser/resources/pdf/BUILD.gn
@@ -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.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+# TODO(dpapad): Add compile targets for all files, crbug.com/721073.
+group("closure_compile") {
+ deps = [
+ ":pdf_resources",
+ "elements/viewer-bookmark:closure_compile",
+ "elements/viewer-error-screen:closure_compile",
+ "elements/viewer-page-indicator:closure_compile",
+ "elements/viewer-page-selector:closure_compile",
+ "elements/viewer-password-screen:closure_compile",
+ ]
+}
+
+js_library("browser_api") {
+ externs_list = [
+ "$externs_path/chrome_extensions.js",
+ "$externs_path/mime_handler_private.js",
+ ]
+}
+
+js_library("pdf_fitting_type") {
+}
+
+js_library("coords_transformer") {
+}
+
+js_library("gesture_detector") {
+}
+
+js_library("open_pdf_params_parser") {
+ deps = [
+ ":pdf_fitting_type",
+ ]
+}
+
+js_library("pdf_scripting_api") {
+ deps = [
+ "//ui/webui/resources/js:assert",
+ ]
+}
+
+js_library("viewport_scroller") {
+}
+
+js_type_check("pdf_resources") {
+ deps = [
+ ":browser_api",
+ ":coords_transformer",
+ ":gesture_detector",
+ ":open_pdf_params_parser",
+ ":pdf_fitting_type",
+ ":pdf_scripting_api",
+ ":viewport_scroller",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/pdf/browser_api.js b/chromium/chrome/browser/resources/pdf/browser_api.js
index 34da975c46c..fcab1f81cda 100644
--- a/chromium/chrome/browser/resources/pdf/browser_api.js
+++ b/chromium/chrome/browser/resources/pdf/browser_api.js
@@ -5,7 +5,6 @@
'use strict';
/**
- * Returns a promise that will resolve to the default zoom factor.
* @param {!Object} streamInfo The stream object pointing to the data contained
* in the PDF.
* @return {Promise<number>} A promise that will resolve to the default zoom
@@ -28,6 +27,7 @@ function lookupDefaultZoom(streamInfo) {
* Returns a promise that will resolve to the initial zoom factor
* upon starting the plugin. This may differ from the default zoom
* if, for example, the page is zoomed before the plugin is run.
+ *
* @param {!Object} streamInfo The stream object pointing to the data contained
* in the PDF.
* @return {Promise<number>} A promise that will resolve to the initial zoom
@@ -64,10 +64,10 @@ class BrowserApi {
}
/**
- * Returns a promise to a BrowserApi.
* @param {!Object} streamInfo The stream object pointing to the data
* contained in the PDF.
* @param {BrowserApi.ZoomBehavior} zoomBehavior How to manage zoom.
+ * @return {Promise<BrowserApi>} A promise to a BrowserApi.
*/
static create(streamInfo, zoomBehavior) {
return Promise
@@ -79,8 +79,8 @@ class BrowserApi {
}
/**
- * Returns the stream info pointing to the data contained in the PDF.
- * @return {Object} The stream info object.
+ * @return {Object} The stream info object pointing to the data contained in
+ * the PDF.
*/
getStreamInfo() {
return this.streamInfo_;
@@ -96,6 +96,7 @@ class BrowserApi {
/**
* Sets the browser zoom.
+ *
* @param {number} zoom The zoom factor to send to the browser.
* @return {Promise} A promise that will be resolved when the browser zoom
* has been updated.
@@ -109,7 +110,6 @@ class BrowserApi {
}
/**
- * Returns the default browser zoom factor.
* @return {number} The default browser zoom factor.
*/
getDefaultZoom() {
@@ -117,7 +117,6 @@ class BrowserApi {
}
/**
- * Returns the initial browser zoom factor.
* @return {number} The initial browser zoom factor.
*/
getInitialZoom() {
@@ -125,7 +124,6 @@ class BrowserApi {
}
/**
- * Returns how to manage the zoom.
* @return {BrowserApi.ZoomBehavior} How to manage zoom.
*/
getZoomBehavior() {
@@ -134,6 +132,7 @@ class BrowserApi {
/**
* Adds an event listener to be notified when the browser zoom changes.
+ *
* @param {!Function} listener The listener to be called with the new zoom
* factor.
*/
@@ -164,6 +163,7 @@ BrowserApi.ZoomBehavior = {
/**
* Creates a BrowserApi for an extension running as a mime handler.
+ *
* @return {Promise<BrowserApi>} A promise to a BrowserApi instance constructed
* using the mimeHandlerPrivate API.
*/
@@ -199,6 +199,7 @@ function createBrowserApiForMimeHandlerView() {
/**
* Creates a BrowserApi instance for an extension not running as a mime handler.
+ *
* @return {Promise<BrowserApi>} A promise to a BrowserApi instance constructed
* from the URL.
*/
@@ -228,7 +229,6 @@ function createBrowserApiForPrintPreview() {
}
/**
- * Returns a promise that will resolve to a BrowserApi instance.
* @return {Promise<BrowserApi>} A promise to a BrowserApi instance for the
* current environment.
*/
diff --git a/chromium/chrome/browser/resources/pdf/compiled_resources2.gyp b/chromium/chrome/browser/resources/pdf/compiled_resources2.gyp
deleted file mode 100644
index eae4c571a9e..00000000000
--- a/chromium/chrome/browser/resources/pdf/compiled_resources2.gyp
+++ /dev/null
@@ -1,58 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# TODO(dpapad): Add compile targets for all files, crbug.com/721073.
-{
- 'targets': [
- {
- 'target_name': 'browser_api',
- 'dependencies': [
- '<(EXTERNS_GYP):chrome_extensions',
- '<(EXTERNS_GYP):mime_handler_private',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'pdf_fitting_type',
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'coords_transformer',
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'gesture_detector',
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'open_pdf_params_parser',
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- 'dependencies': [
- 'pdf_fitting_type',
- ],
- },
- {
- 'target_name': 'pdf_scripting_api',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'viewport_scroller',
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'pdf_resources',
- 'type': 'none',
- 'dependencies': [
- 'elements/viewer-bookmark/compiled_resources2.gyp:*',
- 'elements/viewer-error-screen/compiled_resources2.gyp:*',
- 'elements/viewer-page-indicator/compiled_resources2.gyp:*',
- 'elements/viewer-page-selector/compiled_resources2.gyp:*',
- 'elements/viewer-password-screen/compiled_resources2.gyp:*',
- ],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/pdf/coords_transformer.js b/chromium/chrome/browser/resources/pdf/coords_transformer.js
index 43a073f736d..1f440147882 100644
--- a/chromium/chrome/browser/resources/pdf/coords_transformer.js
+++ b/chromium/chrome/browser/resources/pdf/coords_transformer.js
@@ -42,6 +42,7 @@ window.PDFCoordsTransformer = class {
/**
* Send a 'transformPagePoint' message to the plugin.
+ *
* @param {function(Object, Object):void} callback Function to call when the
* response is received.
* @param {Object} params User parameters to be used in |callback|.
@@ -59,6 +60,7 @@ window.PDFCoordsTransformer = class {
/**
* Call when 'transformPagePointReply' is received from the plugin.
+ *
* @param {Object} message The message received from the plugin.
*/
onReplyReceived(message) {
diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-bookmark/BUILD.gn b/chromium/chrome/browser/resources/pdf/elements/viewer-bookmark/BUILD.gn
new file mode 100644
index 00000000000..fa2b15b86f7
--- /dev/null
+++ b/chromium/chrome/browser/resources/pdf/elements/viewer-bookmark/BUILD.gn
@@ -0,0 +1,17 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":viewer-bookmark",
+ ]
+}
+
+js_library("viewer-bookmark") {
+ deps = [
+ "//third_party/polymer/v1_0/components-chromium/iron-a11y-keys-behavior:iron-a11y-keys-behavior-extracted",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-bookmark/compiled_resources2.gyp b/chromium/chrome/browser/resources/pdf/elements/viewer-bookmark/compiled_resources2.gyp
deleted file mode 100644
index 5df4148b621..00000000000
--- a/chromium/chrome/browser/resources/pdf/elements/viewer-bookmark/compiled_resources2.gyp
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-{
- 'targets': [
- {
- 'target_name': 'viewer-bookmark',
- 'dependencies': [
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-a11y-keys-behavior/compiled_resources2.gyp:iron-a11y-keys-behavior-extracted',
- ],
- 'includes': ['../../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-error-screen/BUILD.gn b/chromium/chrome/browser/resources/pdf/elements/viewer-error-screen/BUILD.gn
new file mode 100644
index 00000000000..3beeb5d21b0
--- /dev/null
+++ b/chromium/chrome/browser/resources/pdf/elements/viewer-error-screen/BUILD.gn
@@ -0,0 +1,17 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":viewer-error-screen",
+ ]
+}
+
+js_library("viewer-error-screen") {
+ deps = [
+ "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-error-screen/compiled_resources2.gyp b/chromium/chrome/browser/resources/pdf/elements/viewer-error-screen/compiled_resources2.gyp
deleted file mode 100644
index 061a2d27a67..00000000000
--- a/chromium/chrome/browser/resources/pdf/elements/viewer-error-screen/compiled_resources2.gyp
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-{
- 'targets': [
- {
- 'target_name': 'viewer-error-screen',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_dialog/compiled_resources2.gyp:cr_dialog',
- ],
- 'includes': ['../../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-error-screen/viewer-error-screen.html b/chromium/chrome/browser/resources/pdf/elements/viewer-error-screen/viewer-error-screen.html
index b5032dbb7a2..97ddcc14898 100644
--- a/chromium/chrome/browser/resources/pdf/elements/viewer-error-screen/viewer-error-screen.html
+++ b/chromium/chrome/browser/resources/pdf/elements/viewer-error-screen/viewer-error-screen.html
@@ -1,18 +1,16 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
-<link rel="import" href="chrome://resources/cr_elements/shared_style_css.html">
+<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html">
+<link rel="import" href="chrome://resources/cr_elements/paper_button_style_css.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<dom-module id="viewer-error-screen">
<template>
- <style include="cr-shared-style"></style>
+ <style include="paper-button-style cr-hidden-style"></style>
<cr-dialog id="dialog" no-cancel>
- <div slot="title">
- [[strings.errorDialogTitle]]
- </div>
- <div slot="body">
- [[strings.pageLoadFailed]]
- </div>
+ <div slot="title">[[strings.errorDialogTitle]]</div>
+ <div slot="body">[[strings.pageLoadFailed]]</div>
<div slot="button-container" hidden$="[[!reloadFn]]">
<paper-button class="action-button" on-click="reload">
[[strings.pageReload]]
diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-page-indicator/BUILD.gn b/chromium/chrome/browser/resources/pdf/elements/viewer-page-indicator/BUILD.gn
new file mode 100644
index 00000000000..8da20c8f3cf
--- /dev/null
+++ b/chromium/chrome/browser/resources/pdf/elements/viewer-page-indicator/BUILD.gn
@@ -0,0 +1,14 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":viewer-page-indicator",
+ ]
+}
+
+js_library("viewer-page-indicator") {
+}
diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-page-indicator/compiled_resources2.gyp b/chromium/chrome/browser/resources/pdf/elements/viewer-page-indicator/compiled_resources2.gyp
deleted file mode 100644
index f4c56ed7f9b..00000000000
--- a/chromium/chrome/browser/resources/pdf/elements/viewer-page-indicator/compiled_resources2.gyp
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-{
- 'targets': [
- {
- 'target_name': 'viewer-page-indicator',
- 'includes': ['../../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-page-selector/BUILD.gn b/chromium/chrome/browser/resources/pdf/elements/viewer-page-selector/BUILD.gn
new file mode 100644
index 00000000000..1c3443312ee
--- /dev/null
+++ b/chromium/chrome/browser/resources/pdf/elements/viewer-page-selector/BUILD.gn
@@ -0,0 +1,14 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":viewer-page-selector",
+ ]
+}
+
+js_library("viewer-page-selector") {
+}
diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-page-selector/compiled_resources2.gyp b/chromium/chrome/browser/resources/pdf/elements/viewer-page-selector/compiled_resources2.gyp
deleted file mode 100644
index 00dd3695705..00000000000
--- a/chromium/chrome/browser/resources/pdf/elements/viewer-page-selector/compiled_resources2.gyp
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-{
- 'targets': [
- {
- 'target_name': 'viewer-page-selector',
- 'includes': ['../../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-page-selector/viewer-page-selector.html b/chromium/chrome/browser/resources/pdf/elements/viewer-page-selector/viewer-page-selector.html
index a2c53b9ee6d..3d55cbd8083 100644
--- a/chromium/chrome/browser/resources/pdf/elements/viewer-page-selector/viewer-page-selector.html
+++ b/chromium/chrome/browser/resources/pdf/elements/viewer-page-selector/viewer-page-selector.html
@@ -61,11 +61,17 @@
#pagelength {
font-size: 0.81rem;
}
+
+ iron-input input {
+ @apply --paper-input-container-shared-input-style;
+ }
</style>
<paper-input-container id="pageselector" no-label-float>
- <input id="input" is="iron-input" value="{{pageNo}}" slot="input"
- prevent-invalid-input allowed-pattern="\d" on-mouseup="select"
- on-change="pageNoCommitted" aria-label$="{{strings.labelPageNumber}}">
+ <iron-input slot="input" bind-value="[[pageNo]]" allowed-pattern="\d">
+ <input id="input" prevent-invalid-input value="{{value::input}}"
+ on-mouseup="select" on-change="pageNoCommitted"
+ aria-label$="{{strings.labelPageNumber}}">
+ </iron-input>
</paper-input-container>
<span id="slash"> / </span>
<span id="pagelength-spacer">
diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-password-screen/BUILD.gn b/chromium/chrome/browser/resources/pdf/elements/viewer-password-screen/BUILD.gn
new file mode 100644
index 00000000000..607e745fa5a
--- /dev/null
+++ b/chromium/chrome/browser/resources/pdf/elements/viewer-password-screen/BUILD.gn
@@ -0,0 +1,17 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":viewer-password-screen",
+ ]
+}
+
+js_library("viewer-password-screen") {
+ deps = [
+ "//third_party/polymer/v1_0/components-chromium/paper-input:paper-input-extracted",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-password-screen/compiled_resources2.gyp b/chromium/chrome/browser/resources/pdf/elements/viewer-password-screen/compiled_resources2.gyp
deleted file mode 100644
index a26f57364b1..00000000000
--- a/chromium/chrome/browser/resources/pdf/elements/viewer-password-screen/compiled_resources2.gyp
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-{
- 'targets': [
- {
- 'target_name': 'viewer-password-screen',
- 'dependencies': [
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/paper-input/compiled_resources2.gyp:paper-input-extracted'
- ],
- 'includes': ['../../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-pdf-toolbar/viewer-pdf-toolbar.html b/chromium/chrome/browser/resources/pdf/elements/viewer-pdf-toolbar/viewer-pdf-toolbar.html
index b7e067c3b89..00b23ce44cb 100644
--- a/chromium/chrome/browser/resources/pdf/elements/viewer-pdf-toolbar/viewer-pdf-toolbar.html
+++ b/chromium/chrome/browser/resources/pdf/elements/viewer-pdf-toolbar/viewer-pdf-toolbar.html
@@ -1,5 +1,4 @@
<link rel="import" href="chrome://resources/html/polymer.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="chrome://resources/polymer/v1_0/neon-animation/animations/slide-up-animation.html">
<link rel="import" href="chrome://resources/polymer/v1_0/neon-animation/animations/transform-animation.html">
<link rel="import" href="chrome://resources/polymer/v1_0/neon-animation/neon-animation-runner-behavior.html">
@@ -29,7 +28,7 @@
}
#title {
- @apply --layout-flex-5;
+ flex: 5;
font-size: 0.87rem;
font-weight: 500;
overflow: hidden;
@@ -38,7 +37,6 @@
}
#pageselector-container {
- @apply --layout-flex-1;
text-align: center;
/* The container resizes according to the width of the toolbar. On small
* screens with large numbers of pages, overflow page numbers without
@@ -47,7 +45,7 @@
}
#buttons {
- @apply --layout-flex-5;
+ flex: 5;
text-align: end;
user-select: none;
}
diff --git a/chromium/chrome/browser/resources/pdf/gesture_detector.js b/chromium/chrome/browser/resources/pdf/gesture_detector.js
index 2af88ee0349..59e9bc419ff 100644
--- a/chromium/chrome/browser/resources/pdf/gesture_detector.js
+++ b/chromium/chrome/browser/resources/pdf/gesture_detector.js
@@ -10,7 +10,6 @@
*/
class GestureDetector {
/**
- * Constructs a GestureDetector.
* @param {!Element} element The element to monitor for touch gestures.
*/
constructor(element) {
@@ -37,18 +36,20 @@ class GestureDetector {
this.pinchStartEvent_ = null;
this.lastTouchTouchesCount_ = 0;
- /** @private {?TouchEvent} */
+ /** @private {TouchEvent} */
this.lastEvent_ = null;
/**
* The scale relative to the start of the pinch when handling ctrl-wheels.
* null when there is no ongoing pinch.
+ *
* @private {?number}
*/
this.accumulatedWheelScale_ = null;
/**
* A timeout ID from setTimeout used for sending the pinchend event when
* handling ctrl-wheels.
+ *
* @private {?number}
*/
this.wheelEndTimeout_ = null;
@@ -60,6 +61,7 @@ class GestureDetector {
/**
* Add a |listener| to be notified of |type| events.
+ *
* @param {string} type The event type to be notified for.
* @param {!Function} listener The callback.
*/
@@ -70,7 +72,6 @@ class GestureDetector {
}
/**
- * Returns true if the last touch start was a two finger touch.
* @return {boolean} True if the last touch start was a two finger touch.
*/
wasTwoFingerTouch() {
@@ -79,8 +80,9 @@ class GestureDetector {
/**
* Call the relevant listeners with the given |pinchEvent|.
- * @private
+ *
* @param {!Object} pinchEvent The event to notify the listeners of.
+ * @private
*/
notify_(pinchEvent) {
let listeners = this.listeners_.get(pinchEvent.type);
@@ -91,8 +93,9 @@ class GestureDetector {
/**
* The callback for touchstart events on the element.
- * @private
+ *
* @param {!TouchEvent} event Touch event on the element.
+ * @private
*/
onTouchStart_(event) {
this.lastTouchTouchesCount_ = event.touches.length;
@@ -106,8 +109,9 @@ class GestureDetector {
/**
* The callback for touch move, end, and cancel events on the element.
- * @private
+ *
* @param {!TouchEvent} event Touch event on the element.
+ * @private
*/
onTouch_(event) {
if (!this.pinchStartEvent_)
@@ -153,8 +157,9 @@ class GestureDetector {
/**
* The callback for wheel events on the element.
- * @private
+ *
* @param {!WheelEvent} event Wheel event on the element.
+ * @private
*/
onWheel_(event) {
// We handle ctrl-wheels to invoke our own pinch zoom. On Mac, synthetic
@@ -211,11 +216,12 @@ class GestureDetector {
/**
* Computes the change in scale between this touch event
* and a previous one.
- * @private
+ *
* @param {!TouchEvent} event Latest touch event on the element.
* @param {!TouchEvent} prevEvent A previous touch event on the element.
* @return {?number} The ratio of the scale of this event and the
* scale of the previous one.
+ * @private
*/
static pinchScaleRatio_(event, prevEvent) {
let distance1 = GestureDetector.distance_(prevEvent);
@@ -225,9 +231,10 @@ class GestureDetector {
/**
* Computes the distance between fingers.
- * @private
+ *
* @param {!TouchEvent} event Touch event with at least 2 touch points.
* @return {number} Distance between touch[0] and touch[1].
+ * @private
*/
static distance_(event) {
let touch1 = event.touches[0];
@@ -239,9 +246,10 @@ class GestureDetector {
/**
* Computes the midpoint between fingers.
- * @private
+ *
* @param {!TouchEvent} event Touch event with at least 2 touch points.
* @return {!Object} Midpoint between touch[0] and touch[1].
+ * @private
*/
static center_(event) {
let touch1 = event.touches[0];
diff --git a/chromium/chrome/browser/resources/pdf/main.js b/chromium/chrome/browser/resources/pdf/main.js
index 6a1061c6535..5acb612fe35 100644
--- a/chromium/chrome/browser/resources/pdf/main.js
+++ b/chromium/chrome/browser/resources/pdf/main.js
@@ -6,6 +6,7 @@
/**
* Global PDFViewer object, accessible for testing.
+ *
* @type Object
*/
var viewer;
@@ -15,12 +16,14 @@ var viewer;
/**
* Stores any pending messages received which should be passed to the
* PDFViewer when it is created.
+ *
* @type Array
*/
var pendingMessages = [];
/**
* Handles events that are received prior to the PDFViewer being created.
+ *
* @param {Object} message A message event received.
*/
function handleScriptingMessage(message) {
@@ -29,6 +32,7 @@ function handleScriptingMessage(message) {
/**
* Initialize the global PDFViewer and pass any outstanding messages to it.
+ *
* @param {Object} browserApi An object providing an API to the browser.
*/
function initViewer(browserApi) {
diff --git a/chromium/chrome/browser/resources/pdf/metrics.js b/chromium/chrome/browser/resources/pdf/metrics.js
index 61091cd4dc1..d0cb77c8d97 100644
--- a/chromium/chrome/browser/resources/pdf/metrics.js
+++ b/chromium/chrome/browser/resources/pdf/metrics.js
@@ -48,6 +48,7 @@ window.PDFMetrics = class {
/**
* Call when the zoom mode is changed to fit a FittingType.
+ *
* @param {FittingType} fittingType the new FittingType.
*/
onFitTo(fittingType) {}
@@ -73,6 +74,7 @@ window.PDFMetrics = class {
* This is used in print preview mode to avoid bundling the actions in the PDF
* viewer and the print preview in the same histogram. Also, metricsPrivate is
* not available in print preview.
+ *
* @implements {PDFMetrics}
*/
window.PDFMetricsDummy = class {
@@ -100,6 +102,7 @@ window.PDFMetricsDummy = class {
/**
* Implementation of PDFMetrics that logs the corresponding metrics to UMA
* through chrome.metricsPrivate.
+ *
* @implements {PDFMetrics}
*/
window.PDFMetricsImpl = class {
@@ -164,14 +167,15 @@ window.PDFMetricsImpl = class {
}
/**
- * @private
* Logs the "first" event code if it hasn't been logged by this instance yet
* and also log the "total" event code. This distinction allows analyzing
* both:
* - in what percentage of documents each action was taken;
* - how many times, on average, each action is taken on a document;
+ *
* @param {number} firstEventCode event code for the "first" metric.
* @return {number} totalEventCode event code for the "total" metric.
+ * @private
*/
logFirstAndTotal_(firstEventCode, totalEventCode) {
this.log_(totalEventCode);
@@ -179,19 +183,21 @@ window.PDFMetricsImpl = class {
}
/**
- * @private
* Logs the given event code to chrome.metricsPrivate.
+ *
* @param {number} eventCode event code to log.
+ * @private
*/
log_(eventCode) {
chrome.metricsPrivate.recordValue(this.actionsMetric_, eventCode);
}
/**
- * @private
* Logs the given event code. Subsequent calls of this method with the same
* event code have no effect on the this PDFMetrics instance.
+ *
* @param {number} eventCode event code to log.
+ * @private
*/
logOnlyFirstTime_(eventCode) {
if (!this.firstEventLogged_.has(eventCode)) {
diff --git a/chromium/chrome/browser/resources/pdf/navigator.js b/chromium/chrome/browser/resources/pdf/navigator.js
index ebc18db186e..00c31b960fa 100644
--- a/chromium/chrome/browser/resources/pdf/navigator.js
+++ b/chromium/chrome/browser/resources/pdf/navigator.js
@@ -7,6 +7,7 @@
/**
* Creates a new NavigatorDelegate for calling browser-specific functions to
* do the actual navigating.
+ *
* @param {number} tabId The tab ID of the PDF viewer or -1 if the viewer is
* not displayed in a tab.
* @constructor
@@ -17,6 +18,7 @@ function NavigatorDelegate(tabId) {
/**
* Creates a new Navigator for navigating to links inside or outside the PDF.
+ *
* @param {string} originalUrl The original page URL.
* @param {Object} viewport The viewport info of the page.
* @param {Object} paramsParser The object for URL parsing.
@@ -34,8 +36,8 @@ function Navigator(originalUrl, viewport, paramsParser, navigatorDelegate) {
NavigatorDelegate.prototype = {
/**
- * @public
* Called when navigation should happen in the current tab.
+ *
* @param {string} url The url to be opened in the current tab.
*/
navigateInCurrentTab: function(url) {
@@ -48,8 +50,8 @@ NavigatorDelegate.prototype = {
},
/**
- * @public
* Called when navigation should happen in the new tab.
+ *
* @param {string} url The url to be opened in the new tab.
* @param {boolean} active Indicates if the new tab should be the active tab.
*/
@@ -63,8 +65,8 @@ NavigatorDelegate.prototype = {
},
/**
- * @public
* Called when navigation should happen in the new window.
+ *
* @param {string} url The url to be opened in the new window.
*/
navigateInNewWindow: function(url) {
@@ -95,6 +97,7 @@ Navigator.prototype = {
/**
* Function to navigate to the given URL. This might involve navigating
* within the PDF page or opening a new url (in the same tab or a new tab).
+ *
* @param {string} url The URL to navigate to.
* @param {number} disposition The window open disposition when
* navigating to the new URL.
@@ -148,10 +151,11 @@ Navigator.prototype = {
},
/**
- * @private
* Called when the viewport position is received.
+ *
* @param {Object} viewportPosition Dictionary containing the viewport
* position.
+ * @private
*/
onViewportReceived_: function(viewportPosition) {
var originalUrl = this.originalUrl_;
@@ -172,10 +176,11 @@ Navigator.prototype = {
},
/**
- * @private
* Checks if the URL starts with a scheme and is not just a scheme.
+ *
* @param {string} url The input URL
* @return {boolean} Whether the url is valid.
+ * @private
*/
isValidUrl_: function(url) {
// Make sure |url| starts with a valid scheme.
@@ -200,11 +205,12 @@ Navigator.prototype = {
},
/**
- * @private
* Attempt to figure out what a URL is when there is no scheme.
+ *
* @param {string} url The input URL
* @return {string} The URL with a scheme or the original URL if it is not
* possible to determine the scheme.
+ * @private
*/
guessUrlWithoutScheme_: function(url) {
// If the original URL is mailto:, that does not make sense to start with,
diff --git a/chromium/chrome/browser/resources/pdf/open_pdf_params_parser.js b/chromium/chrome/browser/resources/pdf/open_pdf_params_parser.js
index 5903e403366..a125b7c3478 100644
--- a/chromium/chrome/browser/resources/pdf/open_pdf_params_parser.js
+++ b/chromium/chrome/browser/resources/pdf/open_pdf_params_parser.js
@@ -12,7 +12,6 @@
*/
window.OpenPDFParamsParser = class {
/**
- * Constructor.
* @param {function(Object)} postMessageCallback
* Function called to fetch information for a named destination.
*/
@@ -25,11 +24,12 @@ window.OpenPDFParamsParser = class {
}
/**
- * @private
* Parse zoom parameter of open PDF parameters. The PDF should be opened at
* the specified zoom level.
+ *
* @param {string} paramValue zoom value.
* @return {Object} Map with zoom parameters (zoom and position).
+ * @private
*/
parseZoomParam_(paramValue) {
const paramValueSplit = paramValue.split(',');
@@ -55,11 +55,12 @@ window.OpenPDFParamsParser = class {
}
/**
- * @private
* Parse view parameter of open PDF parameters. The PDF should be opened at
* the specified fitting type mode and position.
+ *
* @param {string} paramValue view value.
* @return {Object} Map with view parameters (view and viewPosition).
+ * @private
*/
parseViewParam_(paramValue) {
const viewModeComponents = paramValue.toLowerCase().split(',');
@@ -92,9 +93,10 @@ window.OpenPDFParamsParser = class {
/**
* Parse the parameters encoded in the fragment of a URL into a dictionary.
- * @private
+ *
* @param {string} url to parse
* @return {Object} Key-value pairs of URL parameters
+ * @private
*/
parseUrlParams_(url) {
const params = {};
@@ -126,6 +128,7 @@ window.OpenPDFParamsParser = class {
* Parse PDF url parameters used for controlling the state of UI. These need
* to be available when the UI is being initialized, rather than when the PDF
* is finished loading.
+ *
* @param {string} url that needs to be parsed.
* @return {Object} parsed url parameters.
*/
@@ -144,6 +147,7 @@ window.OpenPDFParamsParser = class {
* and specify actions to be performed when opening pdf files.
* See http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/
* pdfs/pdf_open_parameters.pdf for details.
+ *
* @param {string} url that needs to be parsed.
* @param {Function} callback function to be called with viewport info.
*/
@@ -180,6 +184,7 @@ window.OpenPDFParamsParser = class {
/**
* This is called when a named destination is received and the page number
* corresponding to the request for which a named destination is passed.
+ *
* @param {number} pageNumber The page corresponding to the named destination
* requested.
*/
diff --git a/chromium/chrome/browser/resources/pdf/pdf.js b/chromium/chrome/browser/resources/pdf/pdf.js
index 0f032245af0..6ed1cb3cb12 100644
--- a/chromium/chrome/browser/resources/pdf/pdf.js
+++ b/chromium/chrome/browser/resources/pdf/pdf.js
@@ -22,6 +22,7 @@ function getScrollbarWidth() {
/**
* Return the filename component of a URL, percent decoded if possible.
+ *
* @param {string} url The URL to get the filename from.
* @return {string} The filename component.
*/
@@ -42,6 +43,7 @@ function getFilenameFromURL(url) {
/**
* Whether keydown events should currently be ignored. Events are ignored when
* an editable element has focus, to allow for proper editing controls.
+ *
* @param {HTMLElement} activeElement The currently selected DOM node.
* @return {boolean} True if keydown events should be ignored.
*/
@@ -88,8 +90,9 @@ PDFViewer.DARK_BACKGROUND_COLOR = '0xFF525659';
/**
* Creates a new PDFViewer. There should only be one of these objects per
* document.
- * @constructor
+ *
* @param {!BrowserApi} browserApi An object providing an API to the browser.
+ * @constructor
*/
function PDFViewer(browserApi) {
this.browserApi_ = browserApi;
@@ -98,7 +101,7 @@ function PDFViewer(browserApi) {
this.parentWindow_ = null;
this.parentOrigin_ = null;
this.isFormFieldFocused_ = false;
-
+ this.beepCount_ = 0;
this.delayedScriptingMessages_ = [];
this.isPrintPreview_ = location.origin === 'chrome://print';
@@ -289,10 +292,11 @@ function PDFViewer(browserApi) {
PDFViewer.prototype = {
/**
- * @private
* Handle key events. These may come from the user directly or via the
* scripting API.
+ *
* @param {KeyboardEvent} e the event to handle.
+ * @private
*/
handleKeyEvent_: function(e) {
var position = this.viewport_.position;
@@ -448,8 +452,9 @@ PDFViewer.prototype = {
},
/**
- * @private
* Rotate the plugin clockwise.
+ *
+ * @private
*/
rotateClockwise_: function() {
this.metrics.onRotation();
@@ -457,8 +462,9 @@ PDFViewer.prototype = {
},
/**
- * @private
* Rotate the plugin counter-clockwise.
+ *
+ * @private
*/
rotateCounterClockwise_: function() {
this.metrics.onRotation();
@@ -466,9 +472,10 @@ PDFViewer.prototype = {
},
/**
- * @private
* Request to change the viewport fitting type.
+ *
* @param {CustomEvent} e Event received with the new FittingType as detail.
+ * @private
*/
fitToChanged_: function(e) {
if (e.detail.fittingType == FittingType.FIT_TO_PAGE) {
@@ -486,25 +493,28 @@ PDFViewer.prototype = {
},
/**
- * @private
* Notify the plugin to print.
+ *
+ * @private
*/
print_: function() {
this.postMessage_({type: 'print'});
},
/**
- * @private
* Notify the plugin to save.
+ *
+ * @private
*/
save_: function() {
this.postMessage_({type: 'save'});
},
/**
- * @private
* Sends a 'documentLoaded' message to the PDFScriptingAPI if the document has
* finished loading.
+ *
+ * @private
*/
sendDocumentLoadedMessage_: function() {
if (this.loadState_ == LoadState.LOADING)
@@ -516,11 +526,12 @@ PDFViewer.prototype = {
},
/**
- * @private
* Handle open pdf parameters. This function updates the viewport as per
* the parameters mentioned in the url while opening pdf. The order is
* important as later actions can override the effects of previous actions.
+ *
* @param {Object} params The open params passed in the URL.
+ * @private
*/
handleURLParams_: function(params) {
if (params.zoom)
@@ -550,13 +561,14 @@ PDFViewer.prototype = {
},
/**
- * @private
* Moves the viewport to a point in a page. Called back after a
* 'transformPagePointReply' is returned from the plugin.
+ *
* @param {string} origin Identifier for the caller for logging purposes.
* @param {number} page The index of the page to go to. zero-based.
* @param {Object} message Message received from the plugin containing the
* x and y to navigate to in screen coordinates.
+ * @private
*/
goToPageAndXY_: function(origin, page, message) {
this.viewport_.goToPageAndXY(page, message.x, message.y);
@@ -565,10 +577,11 @@ PDFViewer.prototype = {
},
/**
- * @private
* Update the loading progress of the document in response to a progress
* message being received from the plugin.
+ *
* @param {number} progress the progress as a percentage.
+ * @private
*/
updateProgress_: function(progress) {
if (this.toolbar_)
@@ -600,10 +613,11 @@ PDFViewer.prototype = {
},
/**
- * @private
* Load a dictionary of translated strings into the UI. Used as a callback for
* chrome.resourcesPrivate.
+ *
* @param {Object} strings Dictionary of translated strings
+ * @private
*/
handleStrings_: function(strings) {
document.documentElement.dir = strings.textdirection;
@@ -616,10 +630,11 @@ PDFViewer.prototype = {
},
/**
- * @private
* An event handler for handling password-submitted events. These are fired
* when an event is entered into the password screen.
+ *
* @param {Object} event a password-submitted event.
+ * @private
*/
onPasswordSubmitted_: function(event) {
this.postMessage_(
@@ -627,22 +642,28 @@ PDFViewer.prototype = {
},
/**
- * @private
* Post a message to the PPAPI plugin. Some messages will cause an async reply
* to be received through handlePluginMessage_().
+ *
* @param {Object} message Message to post.
+ * @private
*/
postMessage_: function(message) {
this.plugin_.postMessage(message);
},
/**
- * @private
* An event handler for handling message events received from the plugin.
+ *
* @param {MessageObject} message a message event.
+ * @private
*/
handlePluginMessage_: function(message) {
switch (message.data.type.toString()) {
+ case 'beep':
+ // Beeps are annoying, so just track count for now.
+ this.beepCount_ += 1;
+ break;
case 'documentDimensions':
this.documentDimensions_ = message.data;
this.isUserInitiatedEvent_ = false;
@@ -742,9 +763,10 @@ PDFViewer.prototype = {
},
/**
- * @private
* A callback that's called before the zoom changes. Notify the plugin to stop
* reacting to scroll events while zoom is taking place to avoid flickering.
+ *
+ * @private
*/
beforeZoom_: function() {
this.postMessage_({type: 'stopScrolling'});
@@ -765,9 +787,10 @@ PDFViewer.prototype = {
},
/**
- * @private
* A callback that's called after the zoom changes. Notify the plugin of the
* zoom change and to continue reacting to scroll events.
+ *
+ * @private
*/
afterZoom_: function() {
var position = this.viewport_.position;
@@ -792,10 +815,10 @@ PDFViewer.prototype = {
},
/**
- * @param {boolean} userInitiated The value to set |isUserInitiatedEvent_|
- * to.
- * @private
* A callback that sets |isUserInitiatedEvent_| to |userInitiated|.
+ *
+ * @param {boolean} userInitiated The value to set |isUserInitiatedEvent_| to.
+ * @private
*/
setUserInitiated_: function(userInitiated) {
if (this.isUserInitiatedEvent_ == userInitiated) {
@@ -805,9 +828,10 @@ PDFViewer.prototype = {
},
/**
- * @private
* A callback that's called when an update to a pinch zoom is detected.
+ *
* @param {!Object} e the pinch event.
+ * @private
*/
onPinchUpdate_: function(e) {
// Throttle number of pinch events to one per frame.
@@ -821,9 +845,10 @@ PDFViewer.prototype = {
},
/**
- * @private
* A callback that's called when the end of a pinch zoom is detected.
+ *
* @param {!Object} e the pinch event.
+ * @private
*/
onPinchEnd_: function(e) {
// Using rAF for pinch end prevents pinch updates scheduled by rAF getting
@@ -834,9 +859,10 @@ PDFViewer.prototype = {
},
/**
- * @private
* A callback that's called when the start of a pinch zoom is detected.
+ *
* @param {!Object} e the pinch event.
+ * @private
*/
onPinchStart_: function(e) {
// We also use rAF for pinch start, so that if there is a pinch end event
@@ -847,8 +873,9 @@ PDFViewer.prototype = {
},
/**
- * @private
* A callback that's called after the viewport changes.
+ *
+ * @private
*/
viewportChanged_: function() {
if (!this.documentDimensions_)
@@ -910,6 +937,7 @@ PDFViewer.prototype = {
* Handle a scripting message from outside the extension (typically sent by
* PDFScriptingAPI in a page containing the extension) to interact with the
* plugin.
+ *
* @param {MessageObject} message the message to handle.
*/
handleScriptingMessage: function(message) {
@@ -941,10 +969,11 @@ PDFViewer.prototype = {
},
/**
- * @private
* Handle scripting messages specific to print preview.
+ *
* @param {MessageObject} message the message to handle.
* @return {boolean} true if the message was handled, false otherwise.
+ * @private
*/
handlePrintPreviewScriptingMessage_: function(message) {
if (!this.isPrintPreview_)
@@ -996,10 +1025,11 @@ PDFViewer.prototype = {
},
/**
- * @private
* Send a scripting message outside the extension (typically to
* PDFScriptingAPI in a page containing the extension).
+ *
* @param {Object} message the message to send.
+ * @private
*/
sendScriptingMessage_: function(message) {
if (this.parentWindow_ && this.parentOrigin_) {
@@ -1030,6 +1060,7 @@ PDFViewer.prototype = {
* - title
* - page (optional)
* - array of children (themselves bookmarks)
+ *
* @type {Array} the top-level bookmarks of the PDF.
*/
get bookmarks() {
diff --git a/chromium/chrome/browser/resources/pdf/pdf_scripting_api.js b/chromium/chrome/browser/resources/pdf/pdf_scripting_api.js
index b4ed5b9b944..6ade6be31d0 100644
--- a/chromium/chrome/browser/resources/pdf/pdf_scripting_api.js
+++ b/chromium/chrome/browser/resources/pdf/pdf_scripting_api.js
@@ -4,6 +4,7 @@
/**
* Turn a dictionary received from postMessage into a key event.
+ *
* @param {Object} dict A dictionary representing the key event.
* @return {Event} A key event.
*/
@@ -21,6 +22,7 @@ function DeserializeKeyEvent(dict) {
/**
* Turn a key event into a dictionary which can be sent over postMessage.
+ *
* @param {Event} event A key event.
* @return {Object} A dictionary representing the key event.
*/
@@ -44,6 +46,7 @@ var LoadState = {LOADING: 'loading', SUCCESS: 'success', FAILED: 'failed'};
/**
* Create a new PDFScriptingAPI. This provides a scripting interface to
* the PDF viewer so that it can be customized by things like print preview.
+ *
* @param {Window} window the window of the page containing the pdf viewer.
* @param {Object} plugin the plugin element containing the pdf viewer.
* @constructor
@@ -100,11 +103,12 @@ function PDFScriptingAPI(window, plugin) {
PDFScriptingAPI.prototype = {
/**
- * @private
* Send a message to the extension. If messages try to get sent before there
* is a plugin element set, then we queue them up and send them later (this
* can happen in print preview).
+ *
* @param {Object} message The message to send.
+ * @private
*/
sendMessage_: function(message) {
if (this.plugin_)
@@ -116,6 +120,7 @@ PDFScriptingAPI.prototype = {
/**
* Sets the plugin element containing the PDF viewer. The element will usually
* be passed into the PDFScriptingAPI constructor but may also be set later.
+ *
* @param {Object} plugin the plugin element containing the PDF viewer.
*/
setPlugin: function(plugin) {
@@ -133,6 +138,7 @@ PDFScriptingAPI.prototype = {
/**
* Sets the callback which will be run when the PDF viewport changes.
+ *
* @param {Function} callback the callback to be called.
*/
setViewportChangedCallback: function(callback) {
@@ -142,6 +148,7 @@ PDFScriptingAPI.prototype = {
/**
* Sets the callback which will be run when the PDF document has finished
* loading. If the document is already loaded, it will be run immediately.
+ *
* @param {Function} callback the callback to be called.
*/
setLoadCallback: function(callback) {
@@ -160,6 +167,7 @@ PDFScriptingAPI.prototype = {
/**
* Resets the PDF viewer into print preview mode.
+ *
* @param {string} url the url of the PDF to load.
* @param {boolean} grayscale whether or not to display the PDF in grayscale.
* @param {Array<number>} pageNumbers an array of the page numbers.
@@ -178,6 +186,7 @@ PDFScriptingAPI.prototype = {
/**
* Load a page into the document while in print preview mode.
+ *
* @param {string} url the url of the pdf page to load.
* @param {number} index the index of the page to load.
*/
@@ -196,6 +205,7 @@ PDFScriptingAPI.prototype = {
/**
* Get the selected text in the document. The callback will be called with the
* text that is selected. May only be called after document load.
+ *
* @param {Function} callback a callback to be called with the selected text.
* @return {boolean} true if the function is successful, false if there is an
* outstanding request for selected text that has not been answered.
@@ -217,6 +227,7 @@ PDFScriptingAPI.prototype = {
/**
* Send a key event to the extension.
+ *
* @param {Event} keyEvent the key event to send to the extension.
*/
sendKeyEvent: function(keyEvent) {
@@ -230,6 +241,7 @@ PDFScriptingAPI.prototype = {
* iframe which is navigated to the PDF viewer extension and 2) a scripting
* interface which provides access to various features of the viewer for use
* by print preview and accessibility.
+ *
* @param {string} src the source URL of the PDF to load initially.
* @param {string} baseUrl the base URL of the PDF viewer
* @return {HTMLIFrameElement} the iframe element containing the PDF viewer.
diff --git a/chromium/chrome/browser/resources/pdf/toolbar_manager.js b/chromium/chrome/browser/resources/pdf/toolbar_manager.js
index 6fa82bf92d9..471f6b10e38 100644
--- a/chromium/chrome/browser/resources/pdf/toolbar_manager.js
+++ b/chromium/chrome/browser/resources/pdf/toolbar_manager.js
@@ -47,10 +47,11 @@ function isMouseNearSideToolbar(e, window) {
/**
* Constructs a Toolbar Manager, responsible for co-ordinating between multiple
* toolbar elements.
- * @constructor
+ *
* @param {Object} window The window containing the UI.
* @param {Object} toolbar The top toolbar element.
* @param {Object} zoomToolbar The zoom toolbar element.
+ * @constructor
*/
function ToolbarManager(window, toolbar, zoomToolbar) {
this.window_ = window;
@@ -111,6 +112,7 @@ ToolbarManager.prototype = {
/**
* Whether a mousemove event is high enough velocity to reveal the toolbars.
+ *
* @param {MouseEvent} e Event to test.
* @return {boolean} true if the event is a high velocity mousemove, false
* otherwise.
@@ -136,6 +138,7 @@ ToolbarManager.prototype = {
/**
* Wrapper around Date.now() to make it easily replaceable for testing.
+ *
* @return {number}
* @private
*/
@@ -241,6 +244,7 @@ ToolbarManager.prototype = {
/**
* Updates the size of toolbar dropdowns based on the positions of the rest of
* the UI.
+ *
* @private
*/
resizeDropdowns_: function() {
diff --git a/chromium/chrome/browser/resources/pdf/viewport.js b/chromium/chrome/browser/resources/pdf/viewport.js
index ddf9312491d..bc396e1440f 100644
--- a/chromium/chrome/browser/resources/pdf/viewport.js
+++ b/chromium/chrome/browser/resources/pdf/viewport.js
@@ -20,6 +20,7 @@ let PartialPoint;
/**
* Returns the height of the intersection of two rectangles.
+ *
* @param {Object} rect1 the first rect
* @param {Object} rect2 the second rect
* @return {number} the height of the intersection of the rects
@@ -33,6 +34,7 @@ function getIntersectionHeight(rect1, rect2) {
/**
* Computes vector between two points.
+ *
* @param {!Object} p1 The first point.
* @param {!Object} p2 The second point.
* @return {!Object} The vector.
@@ -51,7 +53,7 @@ function frameToPluginCoordinate(coordinateInFrame) {
/**
* Create a new viewport.
- * @constructor
+ *
* @param {Window} window the window
* @param {Object} sizer is the element which represents the size of the
* document in the viewport
@@ -64,6 +66,7 @@ function frameToPluginCoordinate(coordinateInFrame) {
* @param {number} defaultZoom The default zoom level.
* @param {number} topToolbarHeight The number of pixels that should initially
* be left blank above the document for the toolbar.
+ * @constructor
*/
function Viewport(
window, sizer, viewportChangedCallback, beforeZoomCallback,
@@ -136,6 +139,7 @@ Viewport.ZOOM_FACTOR_RANGE = {
/**
* Clamps the zoom factor (or page scale factor) to be within the limits.
+ *
* @param {number} factor The zoom/scale factor.
* @return {number} The factor clamped within the limits.
*/
@@ -161,6 +165,7 @@ Viewport.prototype = {
* Rounding is necessary when interacting with the renderer which tends to
* operate in integral values (for example for determining if scrollbars
* should be shown).
+ *
* @param {number} zoom The zoom to use to compute the scaled dimensions.
* @return {Object} A dictionary with scaled 'width'/'height' of the document.
* @private
@@ -175,12 +180,13 @@ Viewport.prototype = {
},
/**
- * @private
* Returns true if the document needs scrollbars at the given zoom level.
+ *
* @param {number} zoom compute whether scrollbars are needed at this zoom
* @return {Object} with 'horizontal' and 'vertical' keys which map to bool
* values indicating if the horizontal and vertical scrollbars are needed
* respectively.
+ * @private
*/
documentNeedsScrollbars_: function(zoom) {
var zoomedDimensions = this.getZoomedDocumentDimensions_(zoom);
@@ -204,6 +210,7 @@ Viewport.prototype = {
/**
* Returns true if the document needs scrollbars at the current zoom level.
+ *
* @return {Object} with 'x' and 'y' keys which map to bool values
* indicating if the horizontal and vertical scrollbars are needed
* respectively.
@@ -213,8 +220,9 @@ Viewport.prototype = {
},
/**
- * @private
* Helper function called when the zoomed document size changes.
+ *
+ * @private
*/
contentSizeChanged_: function() {
var zoomedDimensions = this.getZoomedDocumentDimensions_(this.zoom);
@@ -226,16 +234,18 @@ Viewport.prototype = {
},
/**
- * @private
* Called when the viewport should be updated.
+ *
+ * @private
*/
updateViewport_: function() {
this.viewportChangedCallback_();
},
/**
- * @private
* Called when the browser window size changes.
+ *
+ * @private
*/
resizeWrapper_: function() {
this.setUserInitiatedCallback_(false);
@@ -244,8 +254,9 @@ Viewport.prototype = {
},
/**
- * @private
* Called when the viewport size changes.
+ *
+ * @private
*/
resize_: function() {
if (this.fittingType_ == FittingType.FIT_TO_PAGE)
@@ -270,6 +281,7 @@ Viewport.prototype = {
/**
* Scroll the viewport to the specified position.
+ *
* @type {Object} position The position to scroll to.
*/
set position(position) {
@@ -298,6 +310,7 @@ Viewport.prototype = {
/**
* Set the zoom manager.
+ *
* @type {ZoomManager} manager the zoom manager to set.
*/
set zoomManager(manager) {
@@ -328,12 +341,13 @@ Viewport.prototype = {
},
/**
- * @private
- * @param {function} f Function to wrap
* Used to wrap a function that might perform zooming on the viewport. This is
* required so that we can notify the plugin that zooming is in progress
* so that while zooming is taking place it can stop reacting to scroll events
* from the viewport. This is to avoid flickering.
+ *
+ * @param {function} f Function to wrap
+ * @private
*/
mightZoom_: function(f) {
this.beforeZoomCallback_();
@@ -344,9 +358,10 @@ Viewport.prototype = {
},
/**
- * @private
* Sets the zoom of the viewport.
+ *
* @param {number} newZoom the zoom level to zoom to.
+ * @private
*/
setZoomInternal_: function(newZoom) {
if (!this.allowedToChangeZoom_) {
@@ -368,11 +383,12 @@ Viewport.prototype = {
},
/**
- * @private
* Sets the zoom of the viewport.
* Same as setZoomInternal_ but for pinch zoom we have some more operations.
+ *
* @param {number} scaleDelta The zoom delta.
* @param {!Object} center The pinch center in content coordinates.
+ * @private
*/
setPinchZoomInternal_: function(scaleDelta, center) {
assert(
@@ -399,10 +415,11 @@ Viewport.prototype = {
},
/**
- * @private
* Converts a point from frame to content coordinates.
+ *
* @param {!Object} framePoint The frame coordinates.
* @return {!Object} The content coordinates.
+ * @private
*/
frameToContent: function(framePoint) {
// TODO(mcnee) Add a helper Point class to avoid duplicating operations
@@ -415,6 +432,7 @@ Viewport.prototype = {
/**
* Sets the zoom to the given zoom level.
+ *
* @param {number} newZoom the zoom level to zoom to.
*/
setZoom: function(newZoom) {
@@ -428,6 +446,7 @@ Viewport.prototype = {
/**
* Gets notified of the browser zoom changing seperately from the
* internal zoom.
+ *
* @param {number} oldBrowserZoom the previous value of the browser zoom.
*/
updateZoomFromBrowserChange: function(oldBrowserZoom) {
@@ -463,9 +482,11 @@ Viewport.prototype = {
},
/**
- * @private
+ * Get the which page is at a given y position.
+ *
* @param {number} y the y-coordinate to get the page at.
* @return {number} the index of a page overlapping the given y-coordinate.
+ * @private
*/
getPageAtY_: function(y) {
var min = 0;
@@ -496,6 +517,7 @@ Viewport.prototype = {
/**
* Returns the page with the greatest proportion of its height in the current
* viewport.
+ *
* @return {number} the index of the most visible page.
*/
getMostVisiblePage: function() {
@@ -523,7 +545,6 @@ Viewport.prototype = {
},
/**
- * @private
* Compute the zoom level for fit-to-page, fit-to-width or fit-to-height.
*
* At least one of {fitWidth, fitHeight} must be true.
@@ -534,6 +555,7 @@ Viewport.prototype = {
* @param {boolean} fitHeight a bool indicating whether the whole height of
* the page needs to be in the viewport.
* @return {number} the internal zoom to set
+ * @private
*/
computeFittingZoom_: function(pageDimensions, fitWidth, fitHeight) {
assert(
@@ -586,7 +608,6 @@ Viewport.prototype = {
},
/**
- * @private
* Compute a zoom level given the dimensions to fit and the actual numbers
* in those dimensions.
*
@@ -599,6 +620,7 @@ Viewport.prototype = {
* @param {number} pageWidth the width of the page in px.
* @param {number} pageHeight the height of the page in px.
* @return {number} the internal zoom to set
+ * @private
*/
computeFittingZoomGivenDimensions_: function(
fitWidth, fitHeight, windowWidth, windowHeight, pageWidth, pageHeight) {
@@ -638,11 +660,12 @@ Viewport.prototype = {
},
/**
- * @private
* Zoom the viewport so that the page height consumes the entire viewport.
+ *
* @param {boolean} scrollToTopOfPage Set to true if the viewport should be
* scrolled to the top of the current page. Set to false if the viewport
* should remain at the current scroll position.
+ * @private
*/
fitToHeightInternal_: function(scrollToTopOfPage) {
this.mightZoom_(() => {
@@ -672,11 +695,12 @@ Viewport.prototype = {
},
/**
- * @private
* Zoom the viewport so that a page consumes as much as possible of the it.
+ *
* @param {boolean} scrollToTopOfPage Set to true if the viewport should be
* scrolled to the top of the current page. Set to false if the viewport
* should remain at the current scroll position.
+ * @private
*/
fitToPageInternal_: function(scrollToTopOfPage) {
this.mightZoom_(() => {
@@ -739,6 +763,7 @@ Viewport.prototype = {
/**
* Pinch zoom event handler.
+ *
* @param {!Object} e The pinch event.
*/
pinchZoom: function(e) {
@@ -811,6 +836,7 @@ Viewport.prototype = {
/**
* Go to the given page index.
+ *
* @param {number} page the index of the page to go to. zero-based.
*/
goToPage: function(page) {
@@ -819,6 +845,7 @@ Viewport.prototype = {
/**
* Go to the given y position in the given page index.
+ *
* @param {number} page the index of the page to go to. zero-based.
* @param {number} x the x position in the page to go to.
* @param {number} y the y position in the page to go to.
@@ -848,6 +875,7 @@ Viewport.prototype = {
/**
* Set the dimensions of the document.
+ *
* @param {Object} documentDimensions the dimensions of the document
*/
setDocumentDimensions: function(documentDimensions) {
@@ -869,6 +897,7 @@ Viewport.prototype = {
/**
* Get the coordinates of the page contents (excluding the page shadow)
* relative to the screen.
+ *
* @param {number} page the index of the page to get the rect for.
* @return {Object} a rect representing the page in screen coordinates.
*/
diff --git a/chromium/chrome/browser/resources/pdf/viewport_scroller.js b/chromium/chrome/browser/resources/pdf/viewport_scroller.js
index 8246e54e98c..c92d1af3405 100644
--- a/chromium/chrome/browser/resources/pdf/viewport_scroller.js
+++ b/chromium/chrome/browser/resources/pdf/viewport_scroller.js
@@ -5,15 +5,17 @@
'use strict';
/**
- * @private
* The period of time in milliseconds to wait between updating the viewport
* position by the scroll velocity.
+ *
+ * @private
*/
ViewportScroller.DRAG_TIMER_INTERVAL_MS_ = 100;
/**
- * @private
* The maximum drag scroll distance per DRAG_TIMER_INTERVAL in pixels.
+ *
+ * @private
*/
ViewportScroller.MAX_DRAG_SCROLL_DISTANCE_ = 100;
@@ -21,6 +23,7 @@ ViewportScroller.MAX_DRAG_SCROLL_DISTANCE_ = 100;
* Creates a new ViewportScroller.
* A ViewportScroller scrolls the page in response to drag selection with the
* mouse.
+ *
* @param {Object} viewport The viewport info of the page.
* @param {Object} plugin The PDF plugin element.
* @param {Object} window The window containing the viewer.
@@ -38,9 +41,10 @@ function ViewportScroller(viewport, plugin, window) {
ViewportScroller.prototype = {
/**
- * @private
* Start scrolling the page by |scrollVelocity_| every
* |DRAG_TIMER_INTERVAL_MS_|.
+ *
+ * @private
*/
startDragScrollTimer_: function() {
if (this.timerId_ === null) {
@@ -52,8 +56,9 @@ ViewportScroller.prototype = {
},
/**
- * @private
* Stops the drag scroll timer if it is active.
+ *
+ * @private
*/
stopDragScrollTimer_: function() {
if (this.timerId_ !== null) {
@@ -64,8 +69,9 @@ ViewportScroller.prototype = {
},
/**
- * @private
* Scrolls the viewport by the current scroll velocity.
+ *
+ * @private
*/
dragScrollPage_: function() {
var position = this.viewport_.position;
@@ -79,11 +85,12 @@ ViewportScroller.prototype = {
},
/**
- * @private
* Calculate the velocity to scroll while dragging using the distance of the
* cursor outside the viewport.
+ *
* @param {Object} event The mousemove event.
* @return {Object} Object with x and y direction scroll velocity.
+ * @private
*/
calculateVelocity_: function(event) {
var x =
@@ -102,10 +109,11 @@ ViewportScroller.prototype = {
},
/**
- * @private
* Handles mousemove events. It updates the scroll velocity and starts and
* stops timer based on scroll velocity.
+ *
* @param {Object} event The mousemove event.
+ * @private
*/
onMousemove_: function(event) {
this.scrollVelocity_ = this.calculateVelocity_(event);
@@ -118,6 +126,7 @@ ViewportScroller.prototype = {
/**
* Sets whether to scroll the viewport when the mouse is outside the
* viewport.
+ *
* @param {boolean} isSelecting Represents selection status.
*/
setEnableScrolling: function(isSelecting) {
diff --git a/chromium/chrome/browser/resources/pdf/zoom_manager.js b/chromium/chrome/browser/resources/pdf/zoom_manager.js
index 3ca81814d94..0b75da27ea2 100644
--- a/chromium/chrome/browser/resources/pdf/zoom_manager.js
+++ b/chromium/chrome/browser/resources/pdf/zoom_manager.js
@@ -11,7 +11,6 @@
*/
class ZoomManager {
/**
- * Constructs a ZoomManager.
* @param {!Viewport} viewport A Viewport for which to manage zoom.
* @param {number} initialZoom The initial browser zoom level.
*/
@@ -25,6 +24,7 @@ class ZoomManager {
/**
* Creates the appropriate kind of zoom manager given the zoom behavior.
+ *
* @param {BrowserApi.ZoomBehavior} zoomBehavior How to manage zoom.
* @param {!Viewport} viewport A Viewport for which to manage zoom.
* @param {Function} setBrowserZoomFunction A function that sets the browser
@@ -45,6 +45,7 @@ class ZoomManager {
/**
* Invoked when a browser-initiated zoom-level change occurs.
+ *
* @param {number} newZoom the zoom level to zoom to.
*/
onBrowserZoomChange(newZoom) {}
@@ -57,6 +58,7 @@ class ZoomManager {
/**
* Combines the internal pdf zoom and the browser zoom to
* produce the total zoom level for the viewer.
+ *
* @param {number} internalZoom the zoom level internal to the viewer.
* @return {number} the total zoom level.
*/
@@ -67,6 +69,7 @@ class ZoomManager {
/**
* Given a zoom level, return the internal zoom level needed to
* produce that zoom level.
+ *
* @param {number} totalZoom the total zoom level.
* @return {number} the zoom level internal to the viewer.
*/
@@ -76,6 +79,7 @@ class ZoomManager {
/**
* Returns whether two numbers are approximately equal.
+ *
* @param {number} a The first number.
* @param {number} b The second number.
*/
@@ -100,6 +104,7 @@ class InactiveZoomManager extends ZoomManager {}
class ActiveZoomManager extends ZoomManager {
/**
* Constructs a ActiveZoomManager.
+ *
* @param {!Viewport} viewport A Viewport for which to manage zoom.
* @param {Function} setBrowserZoomFunction A function that sets the browser
* zoom to the provided value.
@@ -113,6 +118,7 @@ class ActiveZoomManager extends ZoomManager {
/**
* Invoked when a browser-initiated zoom-level change occurs.
+ *
* @param {number} newZoom the zoom level to zoom to.
*/
onBrowserZoomChange(newZoom) {
@@ -159,6 +165,7 @@ class ActiveZoomManager extends ZoomManager {
/**
* Combines the internal pdf zoom and the browser zoom to
* produce the total zoom level for the viewer.
+ *
* @param {number} internalZoom the zoom level internal to the viewer.
* @return {number} the total zoom level.
*/
@@ -171,6 +178,7 @@ class ActiveZoomManager extends ZoomManager {
/**
* Given a zoom level, return the internal zoom level needed to
* produce that zoom level.
+ *
* @param {number} totalZoom the total zoom level.
* @return {number} the zoom level internal to the viewer.
*/
@@ -188,6 +196,7 @@ class ActiveZoomManager extends ZoomManager {
class EmbeddedZoomManager extends ZoomManager {
/**
* Invoked when a browser-initiated zoom-level change occurs.
+ *
* @param {number} newZoom the new browser zoom level.
*/
onBrowserZoomChange(newZoom) {
diff --git a/chromium/chrome/browser/resources/plugin_metadata/plugins_linux.json b/chromium/chrome/browser/resources/plugin_metadata/plugins_linux.json
index 6b59385b7ae..37ce4bf3bef 100644
--- a/chromium/chrome/browser/resources/plugin_metadata/plugins_linux.json
+++ b/chromium/chrome/browser/resources/plugin_metadata/plugins_linux.json
@@ -1,5 +1,5 @@
{
- "x-version": 30,
+ "x-version": 31,
"google-talk": {
"mime_types": [
],
@@ -80,9 +80,9 @@
],
"versions": [
{
- "version": "29.0.0.171",
+ "version": "30.0.0.134",
"status": "up_to_date",
- "reference": "https://helpx.adobe.com/security/products/flash-player/apsb18-16.html"
+ "reference": "https://helpx.adobe.com/security/products/flash-player/apsb18-24.html"
}
],
"lang": "en-US",
diff --git a/chromium/chrome/browser/resources/plugin_metadata/plugins_mac.json b/chromium/chrome/browser/resources/plugin_metadata/plugins_mac.json
index f305b16a88d..e40b501ee46 100644
--- a/chromium/chrome/browser/resources/plugin_metadata/plugins_mac.json
+++ b/chromium/chrome/browser/resources/plugin_metadata/plugins_mac.json
@@ -1,5 +1,5 @@
{
- "x-version": 36,
+ "x-version": 37,
"google-talk": {
"mime_types": [
],
@@ -115,9 +115,9 @@
],
"versions": [
{
- "version": "29.0.0.171",
+ "version": "30.0.0.134",
"status": "requires_authorization",
- "reference": "https://helpx.adobe.com/security/products/flash-player/apsb18-16.html"
+ "reference": "https://helpx.adobe.com/security/products/flash-player/apsb18-24.html"
}
],
"lang": "en-US",
diff --git a/chromium/chrome/browser/resources/plugin_metadata/plugins_win.json b/chromium/chrome/browser/resources/plugin_metadata/plugins_win.json
index aaea0f38b2b..21a20edb31d 100644
--- a/chromium/chrome/browser/resources/plugin_metadata/plugins_win.json
+++ b/chromium/chrome/browser/resources/plugin_metadata/plugins_win.json
@@ -1,5 +1,5 @@
{
- "x-version": 45,
+ "x-version": 46,
"google-talk": {
"mime_types": [
],
@@ -137,9 +137,9 @@
],
"versions": [
{
- "version": "29.0.0.171",
+ "version": "30.0.0.134",
"status": "requires_authorization",
- "reference": "https://helpx.adobe.com/security/products/flash-player/apsb18-16.html"
+ "reference": "https://helpx.adobe.com/security/products/flash-player/apsb18-24.html"
}
],
"lang": "en-US",
diff --git a/chromium/chrome/browser/resources/policy.html b/chromium/chrome/browser/resources/policy.html
index 93a74fdf41d..b4dd54ccd4f 100644
--- a/chromium/chrome/browser/resources/policy.html
+++ b/chromium/chrome/browser/resources/policy.html
@@ -66,6 +66,10 @@
<div class="label">$i18n{labelUsername}</div>
<div class="username"></div>
</div>
+ <div class="status-entry" hidden>
+ <div class="label">$i18n{labelGaiaId}</div>
+ <div class="gaia-id"></div>
+ </div>
<div class="status-entry">
<div class="label">$i18n{labelClientId}</div>
<div class="client-id"></div>
diff --git a/chromium/chrome/browser/resources/policy_base.js b/chromium/chrome/browser/resources/policy_base.js
index 8ab679951be..f3baef42b7d 100644
--- a/chromium/chrome/browser/resources/policy_base.js
+++ b/chromium/chrome/browser/resources/policy_base.js
@@ -81,6 +81,11 @@ cr.define('policy', function() {
var username = this.querySelector('.username');
username.textContent = status.username;
username.parentElement.hidden = false;
+ // Populate the user gaia id.
+ var gaiaId = this.querySelector('.gaia-id');
+ gaiaId.textContent =
+ status.gaiaId || loadTimeData.getString('notSpecified');
+ gaiaId.parentElement.hidden = false;
}
// Populate all remaining items.
this.querySelector('.client-id').textContent = status.clientId || '';
diff --git a/chromium/chrome/browser/resources/policy_tool.html b/chromium/chrome/browser/resources/policy_tool.html
index 073e87122b6..75f7e688c8e 100644
--- a/chromium/chrome/browser/resources/policy_tool.html
+++ b/chromium/chrome/browser/resources/policy_tool.html
@@ -63,6 +63,7 @@
<button id="delete-session-button">$i18n{removeSession}</button>
<button id="rename-session-button">$i18n{renameSession}</button>
<button id="export-policies-linux">$i18n{exportLinux}</button>
+ <button id="export-policies-mac">$i18n{exportMac}</button>
</div>
<select size="4" id="session-list">
</select>
diff --git a/chromium/chrome/browser/resources/policy_tool.js b/chromium/chrome/browser/resources/policy_tool.js
index b80796d76dd..04c2ab2de66 100644
--- a/chromium/chrome/browser/resources/policy_tool.js
+++ b/chromium/chrome/browser/resources/policy_tool.js
@@ -173,6 +173,10 @@ policy.Page.prototype.initialize = function() {
chrome.send('exportLinux', [policy.Page.getInstance().getDictionary()]);
};
+ $('export-policies-mac').onclick = (event) => {
+ chrome.send('exportMac', [policy.Page.getInstance().getDictionary()]);
+ };
+
// Notify the browser that the page has loaded, causing it to send the
// list of all known policies and the values from the default session.
chrome.send('initialized');
@@ -243,6 +247,8 @@ policy.Policy.prototype.setStatus_ = function(value) {
status = loadTimeData.getString('unset');
} else if (value.error) {
status = value.error;
+ } else if (!value.valid) {
+ status = loadTimeData.getString('errorInvalidType');
} else {
status = loadTimeData.getString('ok');
}
@@ -256,7 +262,7 @@ policy.Policy.prototype.setStatus_ = function(value) {
*/
policy.Policy.prototype.setValue_ = function(value) {
this.value = value;
- if (!value) {
+ if (value === undefined) {
value = '';
} else if (typeof value != 'string') {
value = JSON.stringify(value);
diff --git a/chromium/chrome/browser/resources/print_preview/BUILD.gn b/chromium/chrome/browser/resources/print_preview/BUILD.gn
index 0454c79bae6..e36e45667c0 100644
--- a/chromium/chrome/browser/resources/print_preview/BUILD.gn
+++ b/chromium/chrome/browser/resources/print_preview/BUILD.gn
@@ -1,46 +1,206 @@
+# 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/closure_compiler/compile_js.gni")
import("../optimize_webui.gni")
import("//tools/grit/grit_rule.gni")
import("//chrome/common/features.gni")
-print_preview_pak_file = "print_preview_resources.pak"
-unpak_folder = "print_preview_resources.unpak"
+if (optimize_webui) {
+ print_preview_pak_file = "print_preview_resources.pak"
+ unpak_folder = "print_preview_resources.unpak"
+
+ optimize_webui("build") {
+ host = "print"
+ html_in_files = [ "print_preview_new.html" ]
+ html_out_files = [ "vulcanized.html" ]
+ insert_in_head = "<base href=\"chrome://print\">"
+ input = rebase_path("$target_gen_dir/$unpak_folder", root_build_dir)
+ js_out_files = [ "crisper.js" ]
+
+ excludes = [ "pdf/pdf_scripting_api.js" ]
+
+ deps = [
+ ":unpak",
+ ]
+ }
+
+ unpak("unpak") {
+ pak_file = print_preview_pak_file
+ out_folder = unpak_folder
+
+ deps = [
+ ":flattened_resources",
+ ]
+ }
+
+ grit("flattened_resources") {
+ source = "print_preview_resources.grd"
-optimize_webui("build") {
- host = "print"
- html_in_files = [ "print_preview_new.html" ]
- html_out_files = [ "vulcanized.html" ]
- insert_in_head = "<base href=\"chrome://print\">"
- input = rebase_path("$target_gen_dir/$unpak_folder", root_build_dir)
- js_out_files = [ "crisper.js" ]
+ # The .grd contains references to generated files.
+ source_is_generated = true
- excludes = [ "pdf/pdf_scripting_api.js" ]
+ defines = chrome_grit_defines
+ outputs = [
+ "grit/print_preview_resources.h",
+ "grit/print_preview_resources_map.cc",
+ "grit/print_preview_resources_map.h",
+ print_preview_pak_file,
+ ]
+ output_dir = "$root_gen_dir/chrome/browser/resources/print_preview"
+ }
+}
+
+group("closure_compile") {
+ deps = [
+ ":print_preview_resources",
+ "data:closure_compile",
+ "new:closure_compile",
+ ]
+}
+
+js_type_check("print_preview_resources") {
+ deps = [
+ ":cloud_print_interface",
+ ":metrics",
+ ":native_layer",
+ ":print_preview",
+ ":print_preview_utils",
+ ]
+}
+js_library("print_preview") {
deps = [
- ":unpak",
+ "../pdf:pdf_scripting_api",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:event_tracker",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:promise_resolver",
+ "//ui/webui/resources/js:util",
+ "//ui/webui/resources/js:webui_listener_tracker",
+ "//ui/webui/resources/js/cr:event_target",
+ "//ui/webui/resources/js/cr:ui",
+ "//ui/webui/resources/js/cr/ui:focus_manager",
+ "//ui/webui/resources/js/cr/ui:focus_outline_manager",
+ "//ui/webui/resources/js/cr/ui:node_utils",
+ ]
+
+ sources = [
+ "cloud_print_interface.js",
+ "common/overlay.js",
+ "common/search_box.js",
+ "common/search_bubble.js",
+ "component.js",
+ "data/app_state.js",
+ "data/capabilities_holder.js",
+ "data/cloud_parsers.js",
+ "data/coordinate2d.js",
+ "data/destination.js",
+ "data/destination_match.js",
+ "data/destination_store.js",
+ "data/document_info.js",
+ "data/invitation.js",
+ "data/invitation_store.js",
+ "data/local_parsers.js",
+ "data/margins.js",
+ "data/measurement_system.js",
+ "data/page_number_set.js",
+ "data/print_ticket_store.js",
+ "data/printable_area.js",
+ "data/size.js",
+ "data/ticket_items/collate.js",
+ "data/ticket_items/color.js",
+ "data/ticket_items/copies.js",
+ "data/ticket_items/css_background.js",
+ "data/ticket_items/custom_margins.js",
+ "data/ticket_items/dpi.js",
+ "data/ticket_items/duplex.js",
+ "data/ticket_items/fit_to_page.js",
+ "data/ticket_items/header_footer.js",
+ "data/ticket_items/landscape.js",
+ "data/ticket_items/margins_type.js",
+ "data/ticket_items/media_size.js",
+ "data/ticket_items/page_range.js",
+ "data/ticket_items/rasterize.js",
+ "data/ticket_items/scaling.js",
+ "data/ticket_items/selection_only.js",
+ "data/ticket_items/ticket_item.js",
+ "data/ticket_items/vendor_items.js",
+ "data/user_info.js",
+ "metrics.js",
+ "native_layer.js",
+ "preview_generator.js",
+ "previewarea/margin_control.js",
+ "previewarea/margin_control_container.js",
+ "previewarea/preview_area.js",
+ "print_header.js",
+ "print_preview.js",
+ "print_preview_animations.js",
+ "print_preview_focus_manager.js",
+ "print_preview_utils.js",
+ "search/destination_list.js",
+ "search/destination_list_item.js",
+ "search/destination_search.js",
+ "search/provisional_destination_resolver.js",
+ "search/recent_destination_list.js",
+ "settings/advanced_options_settings.js",
+ "settings/advanced_settings/advanced_settings.js",
+ "settings/advanced_settings/advanced_settings_item.js",
+ "settings/color_settings.js",
+ "settings/copies_settings.js",
+ "settings/destination_settings.js",
+ "settings/dpi_settings.js",
+ "settings/layout_settings.js",
+ "settings/margin_settings.js",
+ "settings/media_size_settings.js",
+ "settings/more_settings.js",
+ "settings/other_options_settings.js",
+ "settings/page_settings.js",
+ "settings/scaling_settings.js",
+ "settings/settings_section.js",
+ "settings/settings_section_select.js",
]
+
+ externs_list = [ "$externs_path/chrome_send.js" ]
}
-unpak("unpak") {
- pak_file = print_preview_pak_file
- out_folder = unpak_folder
+js_library("print_preview_utils") {
+ deps = [
+ "data:coordinate2d",
+ "data:size",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+js_library("metrics") {
deps = [
- ":flattened_resources",
+ ":native_layer",
+ "//ui/webui/resources/js:cr",
]
}
-grit("flattened_resources") {
- source = "print_preview_resources.grd"
+js_library("component") {
+}
+js_library("print_preview_focus_manager") {
+}
- # The .grd contains references to generated files.
- source_is_generated = true
+js_library("cloud_print_interface") {
+ deps = [
+ ":native_layer",
+ "data:cloud_parsers",
+ "data:destination",
+ "data:document_info",
+ "data:invitation",
+ "data:user_info",
+ "//ui/webui/resources/js:cr",
+ ]
+}
- defines = chrome_grit_defines
- outputs = [
- "grit/print_preview_resources.h",
- "grit/print_preview_resources_map.cc",
- "grit/print_preview_resources_map.h",
- print_preview_pak_file,
+js_library("native_layer") {
+ deps = [
+ "data:destination",
+ "data:measurement_system",
+ "//ui/webui/resources/js:cr",
]
- output_dir = "$root_gen_dir/chrome/browser/resources/print_preview"
}
diff --git a/chromium/chrome/browser/resources/print_preview/compiled_resources2.gyp b/chromium/chrome/browser/resources/print_preview/compiled_resources2.gyp
deleted file mode 100644
index 311e09e0400..00000000000
--- a/chromium/chrome/browser/resources/print_preview/compiled_resources2.gyp
+++ /dev/null
@@ -1,69 +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.
-{
- 'targets': [
- {
- 'target_name': 'print_preview',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:event_tracker',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:webui_listener_tracker',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:promise_resolver',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- '<(DEPTH)/ui/webui/resources/js/cr/compiled_resources2.gyp:event_target',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_manager',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_outline_manager',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:node_utils',
- '<(DEPTH)/ui/webui/resources/js/cr/compiled_resources2.gyp:ui',
- '<(EXTERNS_GYP):chrome_send',
- ],
- 'variables': {
- 'extra_inputs': [
- '<!@(python <(CLOSURE_DIR)/build/get_includes.py print_preview.js)',
- ],
- },
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'print_preview_utils',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- 'data/compiled_resources2.gyp:size',
- 'data/compiled_resources2.gyp:coordinate2d'
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'metrics',
- 'dependencies': [
- 'native_layer',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'cloud_print_interface',
- 'dependencies': [
- 'native_layer',
- 'data/compiled_resources2.gyp:cloud_parsers',
- 'data/compiled_resources2.gyp:destination',
- 'data/compiled_resources2.gyp:document_info',
- 'data/compiled_resources2.gyp:invitation',
- 'data/compiled_resources2.gyp:user_info',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'native_layer',
- 'dependencies': [
- 'data/compiled_resources2.gyp:destination',
- 'data/compiled_resources2.gyp:measurement_system',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/print_preview/component.js b/chromium/chrome/browser/resources/print_preview/component.js
index 00227848188..1f69a934a52 100644
--- a/chromium/chrome/browser/resources/print_preview/component.js
+++ b/chromium/chrome/browser/resources/print_preview/component.js
@@ -15,7 +15,7 @@ cr.define('print_preview', function() {
/**
* Component's HTML element.
- * @private {Element}
+ * @protected {Element}
*/
this.element_ = null;
@@ -23,7 +23,7 @@ cr.define('print_preview', function() {
/**
* Component's event tracker.
- * @private {!EventTracker}
+ * @protected {!EventTracker}
*/
this.tracker_ = new EventTracker();
diff --git a/chromium/chrome/browser/resources/print_preview/data/BUILD.gn b/chromium/chrome/browser/resources/print_preview/data/BUILD.gn
new file mode 100644
index 00000000000..a93e13c5113
--- /dev/null
+++ b/chromium/chrome/browser/resources/print_preview/data/BUILD.gn
@@ -0,0 +1,139 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":cloud_parsers",
+ ":coordinate2d",
+ ":destination",
+ ":destination_match",
+ ":destination_store",
+ ":document_info",
+ ":invitation",
+ ":invitation_store",
+ ":local_parsers",
+ ":margins",
+ ":measurement_system",
+ ":printable_area",
+ ":size",
+ ":user_info",
+ ]
+}
+
+js_library("destination_store") {
+ deps = [
+ ":destination",
+ ":destination_match",
+ ":local_parsers",
+ ":user_info",
+ "..:cloud_print_interface",
+ "..:metrics",
+ "..:native_layer",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:event_tracker",
+ "//ui/webui/resources/js:webui_listener_tracker",
+ "//ui/webui/resources/js/cr:event_target",
+ ]
+}
+
+js_library("invitation_store") {
+ deps = [
+ ":invitation",
+ ":user_info",
+ "..:cloud_print_interface",
+ "//ui/webui/resources/js:event_tracker",
+ "//ui/webui/resources/js/cr:event_target",
+ ]
+}
+
+js_library("local_parsers") {
+ deps = [
+ ":destination",
+ "..:native_layer",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("destination_match") {
+ deps = [
+ ":destination",
+ "..:native_layer",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("cloud_parsers") {
+ deps = [
+ ":destination",
+ ":invitation",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("invitation") {
+ deps = [
+ ":destination",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("destination") {
+ deps = [
+ "..:print_preview_utils",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
+
+js_library("document_info") {
+ deps = [
+ ":coordinate2d",
+ ":margins",
+ ":printable_area",
+ ":size",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js/cr:event_target",
+ ]
+}
+
+js_library("margins") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("measurement_system") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("printable_area") {
+ deps = [
+ ":coordinate2d",
+ ":size",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("size") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("coordinate2d") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("user_info") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js/cr:event_target",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/print_preview/data/compiled_resources2.gyp b/chromium/chrome/browser/resources/print_preview/data/compiled_resources2.gyp
deleted file mode 100644
index db082079ecc..00000000000
--- a/chromium/chrome/browser/resources/print_preview/data/compiled_resources2.gyp
+++ /dev/null
@@ -1,136 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'destination_store',
- 'dependencies': [
- 'destination',
- 'destination_match',
- 'local_parsers',
- 'user_info',
- '../compiled_resources2.gyp:cloud_print_interface',
- '../compiled_resources2.gyp:metrics',
- '../compiled_resources2.gyp:native_layer',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:event_tracker',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:webui_listener_tracker',
- '<(DEPTH)/ui/webui/resources/js/cr/compiled_resources2.gyp:event_target',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'invitation_store',
- 'dependencies': [
- 'invitation',
- 'user_info',
- '../compiled_resources2.gyp:cloud_print_interface',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:event_tracker',
- '<(DEPTH)/ui/webui/resources/js/cr/compiled_resources2.gyp:event_target',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'local_parsers',
- 'dependencies': [
- 'destination',
- '../compiled_resources2.gyp:native_layer',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'destination_match',
- 'dependencies': [
- 'destination',
- '../compiled_resources2.gyp:native_layer',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'cloud_parsers',
- 'dependencies': [
- 'destination',
- 'invitation',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'invitation',
- 'dependencies': [
- 'destination',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'destination',
- 'dependencies': [
- '../compiled_resources2.gyp:print_preview_utils',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'document_info',
- 'dependencies': [
- 'margins',
- 'size',
- 'coordinate2d',
- 'printable_area',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/cr/compiled_resources2.gyp:event_target',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'margins',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'measurement_system',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'printable_area',
- 'dependencies': [
- 'size',
- 'coordinate2d',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'size',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'coordinate2d',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'user_info',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/cr/compiled_resources2.gyp:event_target',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ]
-}
diff --git a/chromium/chrome/browser/resources/print_preview/data/destination.html b/chromium/chrome/browser/resources/print_preview/data/destination.html
index cdaabd9beb7..7690ac8b807 100644
--- a/chromium/chrome/browser/resources/print_preview/data/destination.html
+++ b/chromium/chrome/browser/resources/print_preview/data/destination.html
@@ -1,5 +1,6 @@
<link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="chrome://resources/html/load_time_data.html">
<link rel="import" href="../print_preview_utils.html">
+<link rel="import" href="../new/strings.html">
<script src="destination.js"></script>
diff --git a/chromium/chrome/browser/resources/print_preview/data/destination.js b/chromium/chrome/browser/resources/print_preview/data/destination.js
index a3b1e5627d0..a51790037dc 100644
--- a/chromium/chrome/browser/resources/print_preview/data/destination.js
+++ b/chromium/chrome/browser/resources/print_preview/data/destination.js
@@ -574,6 +574,14 @@ cr.define('print_preview', function() {
return this.isOffline || this.shouldShowInvalidCertificateError;
}
+ /** @return {boolean} Whether the destination is ready to be selected. */
+ get readyForSelection() {
+ return (!cr.isChromeOS ||
+ this.origin_ != print_preview.DestinationOrigin.CROS ||
+ this.capabilities_ != null) &&
+ !this.isProvisional;
+ }
+
/**
* @return {string} Human readable status for a destination that is offline
* or has a bad certificate. */
diff --git a/chromium/chrome/browser/resources/print_preview/data/destination_store.js b/chromium/chrome/browser/resources/print_preview/data/destination_store.js
index 638e1f951a1..b7a3a5148e3 100644
--- a/chromium/chrome/browser/resources/print_preview/data/destination_store.js
+++ b/chromium/chrome/browser/resources/print_preview/data/destination_store.js
@@ -748,13 +748,14 @@ cr.define('print_preview', function() {
* Attempts to resolve a provisional destination.
* @param {!print_preview.Destination} destination Provisional destination
* that should be resolved.
+ * @return {!Promise<?print_preview.Destination>}
*/
resolveProvisionalDestination(destination) {
assert(
destination.provisionalType ==
print_preview.DestinationProvisionalType.NEEDS_USB_PERMISSION,
'Provisional type cannot be resolved.');
- this.nativeLayer_.grantExtensionPrinterAccess(destination.id)
+ return this.nativeLayer_.grantExtensionPrinterAccess(destination.id)
.then(
destinationInfo => {
/**
@@ -769,6 +770,7 @@ cr.define('print_preview', function() {
this.insertIntoStore_(parsedDestination);
this.dispatchProvisionalDestinationResolvedEvent_(
destination.id, parsedDestination);
+ return parsedDestination;
},
() => {
/**
@@ -779,6 +781,7 @@ cr.define('print_preview', function() {
this.removeProvisionalDestination_(destination.id);
this.dispatchProvisionalDestinationResolvedEvent_(
destination.id, null);
+ return null;
});
}
@@ -1005,11 +1008,11 @@ cr.define('print_preview', function() {
*/
updateDestination_(destination) {
assert(destination.constructor !== Array, 'Single printer expected');
- destination.capabilities_ =
- localizeCapabilities(assert(destination.capabilities_));
+ destination.capabilities =
+ localizeCapabilities(assert(destination.capabilities));
if (print_preview.originToType(destination.origin) !==
print_preview.PrinterType.LOCAL_PRINTER) {
- destination.capabilities_ = sortMediaSizes(destination.capabilities_);
+ destination.capabilities = sortMediaSizes(destination.capabilities);
}
const existingDestination =
this.destinationMap_[this.getKey_(destination)];
@@ -1053,7 +1056,7 @@ cr.define('print_preview', function() {
const key = this.getKey_(destination);
const existingDestination = this.destinationMap_[key];
if (existingDestination == null) {
- destination.isRecent |=
+ destination.isRecent = destination.isRecent ||
this.recentDestinations_.some(function(recent) {
return (
destination.id == recent.id &&
diff --git a/chromium/chrome/browser/resources/print_preview/data/ticket_items/dpi.js b/chromium/chrome/browser/resources/print_preview/data/ticket_items/dpi.js
index 60c401ac920..0e71b329684 100644
--- a/chromium/chrome/browser/resources/print_preview/data/ticket_items/dpi.js
+++ b/chromium/chrome/browser/resources/print_preview/data/ticket_items/dpi.js
@@ -21,7 +21,7 @@ cr.define('print_preview.ticket_items', function() {
wouldValueBeValid(value) {
if (!this.isCapabilityAvailable())
return false;
- return this.capability.option.some(function(option) {
+ return this.capability().option.some(function(option) {
return option.horizontal_dpi == value.horizontal_dpi &&
option.vertical_dpi == value.vertical_dpi &&
option.vendor_id == value.vendor_id;
@@ -30,8 +30,8 @@ cr.define('print_preview.ticket_items', function() {
/** @override */
isCapabilityAvailable() {
- return !!this.capability && !!this.capability.option &&
- this.capability.option.length > 1;
+ return !!this.capability() && !!this.capability().option &&
+ this.capability().option.length > 1;
}
/** @override */
@@ -43,7 +43,7 @@ cr.define('print_preview.ticket_items', function() {
}
/** @return {Object} DPI capability of the selected destination. */
- get capability() {
+ capability() {
const destination = this.getSelectedDestInternal();
return (destination && destination.capabilities &&
destination.capabilities.printer &&
@@ -53,7 +53,7 @@ cr.define('print_preview.ticket_items', function() {
/** @override */
getDefaultValueInternal() {
- const defaultOptions = this.capability.option.filter(function(option) {
+ const defaultOptions = this.capability().option.filter(function(option) {
return option.is_default;
});
return defaultOptions.length > 0 ? defaultOptions[0] : null;
diff --git a/chromium/chrome/browser/resources/print_preview/data/ticket_items/media_size.js b/chromium/chrome/browser/resources/print_preview/data/ticket_items/media_size.js
index 6302e0b418d..e8e794a80f3 100644
--- a/chromium/chrome/browser/resources/print_preview/data/ticket_items/media_size.js
+++ b/chromium/chrome/browser/resources/print_preview/data/ticket_items/media_size.js
@@ -44,7 +44,7 @@ cr.define('print_preview.ticket_items', function() {
if (!this.isCapabilityAvailable()) {
return false;
}
- return this.capability.option.some(function(option) {
+ return this.capability().option.some(function(option) {
return option.width_microns == value.width_microns &&
option.height_microns == value.height_microns &&
option.is_continuous_feed == value.is_continuous_feed &&
@@ -60,7 +60,7 @@ cr.define('print_preview.ticket_items', function() {
this.getSelectedDestInternal() &&
this.getSelectedDestInternal().id ==
print_preview.Destination.GooglePromotedId.SAVE_AS_PDF;
- return !knownSizeToSaveAsPdf && !!this.capability;
+ return !knownSizeToSaveAsPdf && !!this.capability();
}
/** @override */
@@ -73,7 +73,7 @@ cr.define('print_preview.ticket_items', function() {
}
/** @return {Object} Media size capability of the selected destination. */
- get capability() {
+ capability() {
const destination = this.getSelectedDestInternal();
return (destination && destination.capabilities &&
destination.capabilities.printer &&
@@ -83,7 +83,7 @@ cr.define('print_preview.ticket_items', function() {
/** @override */
getDefaultValueInternal() {
- const defaultOptions = this.capability.option.filter(function(option) {
+ const defaultOptions = this.capability().option.filter(function(option) {
return option.is_default;
});
return defaultOptions.length > 0 ? defaultOptions[0] : null;
diff --git a/chromium/chrome/browser/resources/print_preview/native_layer.js b/chromium/chrome/browser/resources/print_preview/native_layer.js
index d2227130df1..2975eadf152 100644
--- a/chromium/chrome/browser/resources/print_preview/native_layer.js
+++ b/chromium/chrome/browser/resources/print_preview/native_layer.js
@@ -71,7 +71,7 @@ print_preview.CapabilitiesResponse;
* @typedef {{
* printerId: string,
* success: boolean,
- * capabilities: Object,
+ * capabilities: !print_preview.Cdd,
* }}
*/
print_preview.PrinterSetupResponse;
@@ -197,13 +197,11 @@ cr.define('print_preview', function() {
* 'page-layout-ready',
* 'page-preview-ready'
* @param {string} printTicket JSON print ticket for the request.
- * @param {number} pageCount Page count for the preview request, or -1 if
- * unknown (first request).
* @return {!Promise<number>} Promise that resolves with the unique ID of
* the preview UI when the preview has been generated.
*/
- getPreview(printTicket, pageCount) {
- return cr.sendWithPromise('getPreview', printTicket, pageCount);
+ getPreview(printTicket) {
+ return cr.sendWithPromise('getPreview', printTicket);
}
/**
diff --git a/chromium/chrome/browser/resources/print_preview/new/BUILD.gn b/chromium/chrome/browser/resources/print_preview/new/BUILD.gn
new file mode 100644
index 00000000000..c239b1ea5ac
--- /dev/null
+++ b/chromium/chrome/browser/resources/print_preview/new/BUILD.gn
@@ -0,0 +1,370 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":advanced_options_settings",
+ ":advanced_settings_dialog",
+ ":advanced_settings_item",
+ ":app",
+ ":color_settings",
+ ":copies_settings",
+ ":destination_dialog",
+ ":destination_list",
+ ":destination_list_item",
+ ":destination_settings",
+ ":dpi_settings",
+ ":header",
+ ":highlight_utils",
+ ":input_behavior",
+ ":layout_settings",
+ ":link_container",
+ ":margin_control",
+ ":margin_control_container",
+ ":margins_settings",
+ ":media_size_settings",
+ ":model",
+ ":more_settings",
+ ":number_settings_section",
+ ":other_options_settings",
+ ":pages_per_sheet_settings",
+ ":pages_settings",
+ ":preview_area",
+ ":print_preview_search_box",
+ ":provisional_destination_resolver",
+ ":scaling_settings",
+ ":select_behavior",
+ ":settings_behavior",
+ ":settings_select",
+ ":state",
+ ]
+}
+
+js_library("app") {
+ deps = [
+ ":advanced_options_settings",
+ ":color_settings",
+ ":copies_settings",
+ ":destination_settings",
+ ":dpi_settings",
+ ":header",
+ ":layout_settings",
+ ":link_container",
+ ":margins_settings",
+ ":media_size_settings",
+ ":model",
+ ":more_settings",
+ ":other_options_settings",
+ ":pages_per_sheet_settings",
+ ":pages_settings",
+ ":preview_area",
+ ":scaling_settings",
+ ":state",
+ "..:cloud_print_interface",
+ "..:metrics",
+ "..:native_layer",
+ "../data:destination",
+ "../data:destination_store",
+ "../data:document_info",
+ "../data:invitation_store",
+ "../data:measurement_system",
+ "../data:user_info",
+ "//ui/webui/resources/js:event_tracker",
+ "//ui/webui/resources/js:util",
+ "//ui/webui/resources/js:webui_listener_tracker",
+ ]
+}
+
+js_library("header") {
+ deps = [
+ ":model",
+ ":settings_behavior",
+ ":state",
+ "../data:destination",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
+
+js_library("destination_settings") {
+ deps = [
+ ":destination_dialog",
+ ":state",
+ "../data:destination",
+ "../data:destination_store",
+ "../data:invitation_store",
+ "../data:user_info",
+ "//ui/webui/resources/cr_elements/cr_lazy_render:cr_lazy_render",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+}
+
+js_library("pages_settings") {
+ deps = [
+ ":input_behavior",
+ ":settings_behavior",
+ "../data:document_info",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
+
+js_library("copies_settings") {
+ deps = [
+ ":number_settings_section",
+ ":settings_behavior",
+ ]
+}
+
+js_library("layout_settings") {
+ deps = [
+ ":select_behavior",
+ ":settings_behavior",
+ ]
+}
+
+js_library("color_settings") {
+ deps = [
+ ":select_behavior",
+ ":settings_behavior",
+ ]
+}
+
+js_library("media_size_settings") {
+ deps = [
+ ":settings_behavior",
+ ":settings_select",
+ ]
+}
+
+js_library("margins_settings") {
+ deps = [
+ ":select_behavior",
+ ":settings_behavior",
+ ]
+}
+
+js_library("dpi_settings") {
+ deps = [
+ ":settings_behavior",
+ ":settings_select",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
+
+js_library("pages_per_sheet_settings") {
+ deps = [
+ ":select_behavior",
+ ":settings_behavior",
+ ]
+}
+
+js_library("scaling_settings") {
+ deps = [
+ ":number_settings_section",
+ ":settings_behavior",
+ "../data:document_info",
+ ]
+}
+
+js_library("other_options_settings") {
+ deps = [
+ ":settings_behavior",
+ ]
+}
+
+js_library("advanced_options_settings") {
+ deps = [
+ ":advanced_settings_dialog",
+ ":settings_behavior",
+ "../data:destination",
+ ]
+}
+
+js_library("more_settings") {
+ deps = [
+ "..:metrics",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+}
+
+js_library("number_settings_section") {
+ deps = [
+ ":input_behavior",
+ ]
+}
+
+js_library("settings_select") {
+ deps = [
+ ":select_behavior",
+ ":settings_behavior",
+ "..:print_preview_utils",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("settings_behavior") {
+ deps = [
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("input_behavior") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("select_behavior") {
+ deps = []
+}
+
+js_library("link_container") {
+ deps = [
+ "../data:destination",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("preview_area") {
+ deps = [
+ ":margin_control_container",
+ ":model",
+ ":settings_behavior",
+ ":state",
+ "..:native_layer",
+ "..:print_preview_utils",
+ "../../pdf:pdf_scripting_api",
+ "../data:coordinate2d",
+ "../data:destination",
+ "../data:document_info",
+ "../data:margins",
+ "../data:printable_area",
+ "../data:size",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:util",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("margin_control_container") {
+ deps = [
+ ":margin_control",
+ ":settings_behavior",
+ "../data:coordinate2d",
+ "../data:margins",
+ "../data:measurement_system",
+ "../data:size",
+ "//ui/webui/resources/js:event_tracker",
+ ]
+ externs_list = [ "$externs_path/pending.js" ]
+}
+
+js_library("margin_control") {
+ deps = [
+ ":input_behavior",
+ "../data:coordinate2d",
+ "../data:margins",
+ "../data:size",
+ ]
+}
+
+js_library("destination_dialog") {
+ deps = [
+ ":destination_list",
+ ":print_preview_search_box",
+ ":provisional_destination_resolver",
+ "..:metrics",
+ "../data:destination",
+ "../data:destination_store",
+ "../data:invitation",
+ "../data:invitation_store",
+ "../data:user_info",
+ "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
+ "//ui/webui/resources/js:event_tracker",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+}
+
+js_library("destination_list") {
+ deps = [
+ ":destination_list_item",
+ "..:native_layer",
+ "../data:destination",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+}
+
+js_library("destination_list_item") {
+ deps = [
+ ":highlight_utils",
+ "..:native_layer",
+ "../data:destination",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
+
+js_library("advanced_settings_dialog") {
+ deps = [
+ ":advanced_settings_item",
+ ":print_preview_search_box",
+ ":settings_behavior",
+ "..:metrics",
+ "../data:destination",
+ "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+}
+
+js_library("advanced_settings_item") {
+ deps = [
+ ":highlight_utils",
+ ":settings_behavior",
+ "..:print_preview_utils",
+ "../data:destination",
+ ]
+}
+
+js_library("print_preview_search_box") {
+ deps = [
+ "//ui/webui/resources/cr_elements/cr_search_field:cr_search_field_behavior",
+ ]
+}
+
+js_library("provisional_destination_resolver") {
+ deps = [
+ "../data:destination",
+ "../data:destination_store",
+ "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+}
+
+js_library("highlight_utils") {
+ deps = [
+ "//ui/webui/resources/js:search_highlight_utils",
+ ]
+}
+
+js_library("model") {
+ deps = [
+ ":settings_behavior",
+ "../data:destination",
+ "../data:document_info",
+ "../data:margins",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("state") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/print_preview/new/advanced_settings_dialog.html b/chromium/chrome/browser/resources/print_preview/new/advanced_settings_dialog.html
index bc4b58562d8..6ad13d0f8d9 100644
--- a/chromium/chrome/browser/resources/print_preview/new/advanced_settings_dialog.html
+++ b/chromium/chrome/browser/resources/print_preview/new/advanced_settings_dialog.html
@@ -3,22 +3,26 @@
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
+<link rel="import" href="../metrics.html">
<link rel="import" href="../data/destination.html">
<link rel="import" href="advanced_settings_item.html">
<link rel="import" href="settings_behavior.html">
<link rel="import" href="button_css.html">
<link rel="import" href="print_preview_shared_css.html">
<link rel="import" href="search_dialog_css.html">
+<link rel="import" href="strings.html">
<dom-module id="print-preview-advanced-dialog">
<style include="print-preview-shared search-dialog button cr-hidden-style">
</style>
<template>
- <cr-dialog id="dialog" on-close="onCloseOrCancel_">
+ <cr-dialog id="dialog" on-close="onCloseOrCancel_" show-close-button>
<div slot="title">
<div>[[i18n('advancedSettingsDialogTitle', destination.displayName)]]
</div>
<print-preview-search-box id="searchBox"
+ hidden$="[[!hasMultipleItems_(
+ destination.capabilities.printer.vendor_capability)]]"
label="$i18n{advancedSettingsSearchBoxPlaceholder}"
search-query="{{searchQuery_}}">
</print-preview-search-box>
diff --git a/chromium/chrome/browser/resources/print_preview/new/advanced_settings_dialog.js b/chromium/chrome/browser/resources/print_preview/new/advanced_settings_dialog.js
index 989de5b0285..6bec184bead 100644
--- a/chromium/chrome/browser/resources/print_preview/new/advanced_settings_dialog.js
+++ b/chromium/chrome/browser/resources/print_preview/new/advanced_settings_dialog.js
@@ -25,6 +25,17 @@ Polymer({
},
},
+ /** @private {!print_preview.PrintSettingsUiMetricsContext} */
+ metrics_: new print_preview.PrintSettingsUiMetricsContext(),
+
+ /**
+ * @return {boolean} Whether there is more than one vendor item to display.
+ * @private
+ */
+ hasMultipleItems_: function() {
+ return this.destination.capabilities.printer.vendor_capability.length > 1;
+ },
+
/**
* @return {boolean} Whether there is a setting matching the query.
* @private
@@ -54,6 +65,10 @@ Polymer({
onCloseOrCancel_: function() {
if (this.searchQuery_)
this.$.searchBox.setValue('');
+ if (this.$.dialog.getNative().returnValue == 'success') {
+ this.metrics_.record(print_preview.Metrics.PrintSettingsUiBucket
+ .ADVANCED_SETTINGS_DIALOG_CANCELED);
+ }
},
/** @private */
@@ -73,6 +88,8 @@ Polymer({
},
show: function() {
+ this.metrics_.record(print_preview.Metrics.PrintSettingsUiBucket
+ .ADVANCED_SETTINGS_DIALOG_SHOWN);
this.$.dialog.showModal();
},
diff --git a/chromium/chrome/browser/resources/print_preview/new/app.html b/chromium/chrome/browser/resources/print_preview/new/app.html
index 71931d347f0..1209ecb4b4b 100644
--- a/chromium/chrome/browser/resources/print_preview/new/app.html
+++ b/chromium/chrome/browser/resources/print_preview/new/app.html
@@ -3,7 +3,9 @@
<link rel="import" href="chrome://resources/html/event_tracker.html">
<link rel="import" href="chrome://resources/html/util.html">
<link rel="import" href="chrome://resources/html/webui_listener_tracker.html">
+<link rel="import" href="chrome://resources/polymer/v1_0/iron-collapse/iron-collapse.html">
<link rel="import" href="../cloud_print_interface.html">
+<link rel="import" href="../metrics.html">
<link rel="import" href="../native_layer.html">
<link rel="import" href="../data/destination.html">
<link rel="import" href="../data/destination_store.html">
@@ -24,9 +26,11 @@
<link rel="import" href="media_size_settings.html">
<link rel="import" href="margins_settings.html">
<link rel="import" href="dpi_settings.html">
+<link rel="import" href="pages_per_sheet_settings.html">
<link rel="import" href="scaling_settings.html">
<link rel="import" href="other_options_settings.html">
<link rel="import" href="advanced_options_settings.html">
+<link rel="import" href="more_settings.html">
<if expr="not chromeos">
<link rel="import" href="link_container.html">
</if>
@@ -47,7 +51,7 @@
min-width: 310px;
}
- #settings-sections {
+ #settingsSections {
background: #fbfbfb;
border-top: 1px solid #f3f3f3;
flex: 1;
@@ -73,17 +77,18 @@
on-print-requested="onPrintRequested_"
on-cancel-requested="onCancelRequested_">
</print-preview-header>
- <div id="settings-sections">
+ <div id="settingsSections">
<print-preview-destination-settings id="destinationSettings"
destination="[[destination_]]"
destination-store="[[destinationStore_]]"
invitation-store="[[invitationStore_]]"
disabled="[[controlsDisabled_]]" state="[[state]]"
recent-destinations="[[recentDestinations_]]"
- user-info="{{userInfo_}}">
+ user-info="{{userInfo_}}" available>
</print-preview-destination-settings>
<print-preview-pages-settings settings="{{settings}}"
- document-info="[[documentInfo_]]" disabled="[[controlsDisabled_]]"
+ document-info="[[documentInfo_]]"
+ disabled="[[controlsDisabled_]]"
hidden$="[[!settings.pages.available]]">
</print-preview-pages-settings>
<print-preview-copies-settings settings="{{settings}}"
@@ -98,32 +103,47 @@
disabled="[[controlsDisabled_]]"
hidden$="[[!settings.color.available]]">
</print-preview-color-settings>
- <print-preview-media-size-settings settings="{{settings}}"
- capability="[[destination_.capabilities.printer.media_size]]"
- disabled="[[controlsDisabled_]]"
- hidden$="[[!settings.mediaSize.available]]">
- </print-preview-media-size-settings>
- <print-preview-margins-settings settings="{{settings}}"
- disabled="[[controlsDisabled_]]"
- hidden$="[[!settings.margins.available]]">
- </print-preview-margins-settings>
- <print-preview-dpi-settings settings="{{settings}}"
- capability="[[destination_.capabilities.printer.dpi]]"
- disabled="[[controlsDisabled_]]"
- hidden$="[[!settings.dpi.available]]">
- </print-preview-dpi-settings>
- <print-preview-scaling-settings settings="{{settings}}"
- document-info="[[documentInfo_]]" disabled="[[controlsDisabled_]]"
- hidden$="[[!settings.scaling.available]]">
- </print-preview-scaling-settings>
- <print-preview-other-options-settings settings="{{settings}}"
+ <print-preview-more-settings
+ settings-expanded-by-user="{{settingsExpandedByUser_}}"
disabled="[[controlsDisabled_]]"
- hidden$="[[!settings.otherOptions.available]]">
- </print-preview-other-options-settings>
- <print-preview-advanced-options-settings settings="{{settings}}"
- destination="[[destination_]]" disabled="[[controlsDisabled_]]"
- hidden$="[[!settings.vendorItems.available]]">
- </print-preview-advanced-options-settings>
+ hidden$="[[!shouldShowMoreSettings_]]">
+ </print-preview-more-settings>
+ <iron-collapse id="moreSettings"
+ opened="[[shouldExpandSettings_(
+ settingsExpandedByUser_, shouldShowMoreSettings_)]]">
+ <print-preview-media-size-settings settings="{{settings}}"
+ capability="[[destination_.capabilities.printer.media_size]]"
+ disabled="[[controlsDisabled_]]"
+ hidden$="[[!settings.mediaSize.available]]">
+ </print-preview-media-size-settings>
+ <print-preview-margins-settings settings="{{settings}}"
+ disabled="[[controlsDisabled_]]"
+ hidden$="[[!settings.margins.available]]">
+ </print-preview-margins-settings>
+ <print-preview-dpi-settings settings="{{settings}}"
+ capability="[[destination_.capabilities.printer.dpi]]"
+ disabled="[[controlsDisabled_]]"
+ hidden$="[[!settings.dpi.available]]">
+ </print-preview-dpi-settings>
+ <template is="dom-if" if="[[showPagesPerSheet_]]">
+ <print-preview-pages-per-sheet-settings settings="{{settings}}"
+ disabled="[[controlsDisabled_]]"
+ hidden$="[[!settings.pagesPerSheet.available]]">
+ </print-preview-pages-per-sheet-settings>
+ </template>
+ <print-preview-scaling-settings settings="{{settings}}"
+ document-info="[[documentInfo_]]" disabled="[[controlsDisabled_]]"
+ hidden$="[[!settings.scaling.available]]">
+ </print-preview-scaling-settings>
+ <print-preview-other-options-settings settings="{{settings}}"
+ disabled="[[controlsDisabled_]]"
+ hidden$="[[!settings.otherOptions.available]]">
+ </print-preview-other-options-settings>
+ <print-preview-advanced-options-settings settings="{{settings}}"
+ destination="[[destination_]]" disabled="[[controlsDisabled_]]"
+ hidden$="[[!settings.vendorItems.available]]">
+ </print-preview-advanced-options-settings>
+ </iron-collapse>
<if expr="not chromeos">
<print-preview-link-container destination="[[destination_]]"
app-kiosk-mode="[[isInAppKioskMode_]]"
@@ -140,9 +160,7 @@
<print-preview-preview-area id="previewArea" settings="{{settings}}"
destination="[[destination_]]" document-info="{{documentInfo_}}"
state="[[state]]" measurement-system="[[measurementSystem_]]"
- on-invalid-printer="onInvalidPrinter_"
- on-preview-failed="onPreviewFailed_"
- on-preview-loaded="onPreviewLoaded_">
+ preview-state="{{previewState_}}">
</print-preview-preview-area>
</div>
</template>
diff --git a/chromium/chrome/browser/resources/print_preview/new/app.js b/chromium/chrome/browser/resources/print_preview/new/app.js
index 6698b22ce01..83ccdadd72e 100644
--- a/chromium/chrome/browser/resources/print_preview/new/app.js
+++ b/chromium/chrome/browser/resources/print_preview/new/app.js
@@ -2,10 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+(function() {
+'use strict';
+
+/**
+ * Number of settings sections to show when "More settings" is collapsed.
+ * @type {number}
+ */
+const MAX_SECTIONS_TO_SHOW = 6;
+
Polymer({
is: 'print-preview-app',
behaviors: [SettingsBehavior],
+
properties: {
/**
* Object containing current settings of Print Preview, for use by Polymer
@@ -89,6 +99,42 @@ Polymer({
notify: true,
value: false,
},
+
+ /** @private {!print_preview_new.PreviewAreaState} */
+ previewState_: {
+ type: String,
+ observer: 'onPreviewAreaStateChanged_',
+ },
+
+ /** @private {boolean} */
+ settingsExpandedByUser_: {
+ type: Boolean,
+ notify: true,
+ value: false,
+ },
+
+ /** @private {boolean} */
+ shouldShowMoreSettings_: {
+ type: Boolean,
+ notify: true,
+ computed: 'computeShouldShowMoreSettings_(settings.pages.available, ' +
+ 'settings.copies.available, settings.layout.available, ' +
+ 'settings.color.available, settings.mediaSize.available, ' +
+ 'settings.dpi.available, settings.margins.available, ' +
+ 'settings.pagesPerSheet.available, settings.scaling.available, ' +
+ 'settings.otherOptions.available, settings.vendorItems.available)',
+ },
+
+ /**
+ * Whether to show pages per sheet feature or not.
+ * @private {boolean}
+ */
+ showPagesPerSheet_: {
+ type: Boolean,
+ value: function() {
+ return loadTimeData.getBoolean('pagesPerSheetEnabled');
+ },
+ },
},
/** @private {?WebUIListenerTracker} */
@@ -112,6 +158,9 @@ Polymer({
/** @private {boolean} */
openPdfInPreview_: false,
+ /** @private {boolean} */
+ isInKioskAutoPrintMode_: false,
+
/** @override */
attached: function() {
this.nativeLayer_ = print_preview.NativeLayer.getInstance();
@@ -120,6 +169,9 @@ Polymer({
this.listenerTracker_ = new WebUIListenerTracker();
this.listenerTracker_.add(
'use-cloud-print', this.onCloudPrintEnable_.bind(this));
+ this.listenerTracker_.add('print-failed', this.onPrintFailed_.bind(this));
+ this.listenerTracker_.add(
+ 'print-preset-options', this.onPrintPresetOptions_.bind(this));
this.destinationStore_ = new print_preview.DestinationStore(
this.userInfo_, this.listenerTracker_);
this.invitationStore_ = new print_preview.InvitationStore(this.userInfo_);
@@ -232,6 +284,7 @@ Polymer({
settings.serializedDefaultDestinationSelectionRulesStr,
this.recentDestinations_);
this.isInAppKioskMode_ = settings.isInAppKioskMode;
+ this.isInKioskAutoPrintMode_ = settings.isInKioskAutoPrintMode;
},
/**
@@ -271,6 +324,10 @@ Polymer({
/** @private */
onDestinationSelect_: function() {
+ // If the plugin does not exist do not attempt to load the preview.
+ if (this.state == print_preview_new.State.FATAL_ERROR)
+ return;
+
this.$.state.transitTo(print_preview_new.State.NOT_READY);
this.destination_ = this.destinationStore_.selectedDestination;
},
@@ -280,10 +337,16 @@ Polymer({
this.set(
'destination_.capabilities',
this.destinationStore_.selectedDestination.capabilities);
- if (this.state != print_preview_new.State.READY)
- this.$.state.transitTo(print_preview_new.State.READY);
+
if (!this.$.model.initialized())
this.$.model.applyStickySettings();
+
+ if (this.state == print_preview_new.State.NOT_READY ||
+ this.state == print_preview_new.State.INVALID_PRINTER) {
+ this.$.state.transitTo(print_preview_new.State.READY);
+ if (this.isInKioskAutoPrintMode_)
+ this.onPrintRequested_();
+ }
},
/**
@@ -302,6 +365,14 @@ Polymer({
} else if (this.state == print_preview_new.State.HIDDEN) {
this.nativeLayer_.hidePreview();
} else if (this.state == print_preview_new.State.PRINTING) {
+ if (this.shouldShowMoreSettings_) {
+ new print_preview.PrintSettingsUiMetricsContext().record(
+ this.settingsExpandedByUser_ ?
+ print_preview.Metrics.PrintSettingsUiBucket
+ .PRINT_WITH_SETTINGS_EXPANDED :
+ print_preview.Metrics.PrintSettingsUiBucket
+ .PRINT_WITH_SETTINGS_COLLAPSED);
+ }
const destination = assert(this.destinationStore_.selectedDestination);
const whenPrintDone =
this.nativeLayer_.print(this.$.model.createPrintTicket(
@@ -324,12 +395,6 @@ Polymer({
},
/** @private */
- onPreviewLoaded_: function() {
- if (this.state == print_preview_new.State.HIDDEN)
- this.$.state.transitTo(print_preview_new.State.PRINTING);
- },
-
- /** @private */
onPrintRequested_: function() {
this.$.state.transitTo(
this.$.previewArea.previewLoaded() ? print_preview_new.State.PRINTING :
@@ -409,13 +474,31 @@ Polymer({
},
/** @private */
- onPreviewFailed_: function() {
- this.$.state.transitTo(print_preview_new.State.FATAL_ERROR);
+ onInvalidPrinter_: function() {
+ this.previewState_ =
+ print_preview_new.PreviewAreaState.UNSUPPORTED_CLOUD_PRINTER;
},
/** @private */
- onInvalidPrinter_: function() {
- this.$.state.transitTo(print_preview_new.State.INVALID_PRINTER);
+ onPreviewAreaStateChanged_: function() {
+ switch (this.previewState_) {
+ case print_preview_new.PreviewAreaState.PREVIEW_FAILED:
+ case print_preview_new.PreviewAreaState.NO_PLUGIN:
+ this.$.state.transitTo(print_preview_new.State.FATAL_ERROR);
+ break;
+ case print_preview_new.PreviewAreaState.INVALID_SETTINGS:
+ case print_preview_new.PreviewAreaState.UNSUPPORTED_CLOUD_PRINTER:
+ if (this.state != print_preview_new.State.INVALID_PRINTER)
+ this.$.state.transitTo(print_preview_new.State.INVALID_PRINTER);
+ break;
+ case print_preview_new.PreviewAreaState.DISPLAY_PREVIEW:
+ case print_preview_new.PreviewAreaState.OPEN_IN_PREVIEW_LOADED:
+ if (this.state == print_preview_new.State.HIDDEN)
+ this.$.state.transitTo(print_preview_new.State.PRINTING);
+ break;
+ default:
+ break;
+ }
},
/**
@@ -443,8 +526,52 @@ Polymer({
}
},
+ /**
+ * Updates printing options according to source document presets.
+ * @param {boolean} disableScaling Whether the document disables scaling.
+ * @param {number} copies The default number of copies from the document.
+ * @param {number} duplex The default duplex setting from the document.
+ * @private
+ */
+ onPrintPresetOptions_: function(disableScaling, copies, duplex) {
+ if (disableScaling)
+ this.documentInfo_.updateIsScalingDisabled(true);
+
+ if (copies > 0 && this.getSetting('copies').available)
+ this.setSetting('copies', copies);
+
+ if (duplex >= 0 && this.getSetting('duplex').available)
+ this.setSetting('duplex', duplex);
+ },
+
+ /**
+ * @return {boolean} Whether to show the "More settings" link.
+ * @private
+ */
+ computeShouldShowMoreSettings_: function() {
+ // Destination settings is always available. See if the total number of
+ // available sections exceeds the maximum number to show.
+ return [
+ 'pages', 'copies', 'layout', 'color', 'mediaSize', 'margins', 'color',
+ 'pagesPerSheet', 'scaling', 'otherOptions', 'vendorItems'
+ ].reduce((count, setting) => {
+ return this.getSetting(setting).available ? count + 1 : count;
+ }, 1) > MAX_SECTIONS_TO_SHOW;
+ },
+
+ /**
+ * @return {boolean} Whether the "more settings" collapse should be expanded.
+ * @private
+ */
+ shouldExpandSettings_: function() {
+ // Expand the settings if the user has requested them expanded or if more
+ // settings is not displayed (i.e. less than 6 total settings available).
+ return this.settingsExpandedByUser_ || !this.shouldShowMoreSettings_;
+ },
+
/** @private */
close_: function() {
this.$.state.transitTo(print_preview_new.State.CLOSING);
},
});
+})();
diff --git a/chromium/chrome/browser/resources/print_preview/new/button_css.html b/chromium/chrome/browser/resources/print_preview/new/button_css.html
index 77481fa255a..b7dff75c563 100644
--- a/chromium/chrome/browser/resources/print_preview/new/button_css.html
+++ b/chromium/chrome/browser/resources/print_preview/new/button_css.html
@@ -21,6 +21,15 @@
background-image: linear-gradient(#e7e7e7, #e7e7e7 38%, #d7d7d7);
@apply --print-preview-active;
}
+
+ button.default:not(:focus):not(:disabled) {
+ border-color: #808080;
+ }
+
+ button.default {
+ font-kerning: none;
+ font-weight: bold;
+ }
</style>
</template>
</dom-module>
diff --git a/chromium/chrome/browser/resources/print_preview/new/color_settings.html b/chromium/chrome/browser/resources/print_preview/new/color_settings.html
index 88adf84c90c..242cf8789c8 100644
--- a/chromium/chrome/browser/resources/print_preview/new/color_settings.html
+++ b/chromium/chrome/browser/resources/print_preview/new/color_settings.html
@@ -2,6 +2,7 @@
<link rel="import" href="print_preview_shared_css.html">
<link rel="import" href="select_css.html">
+<link rel="import" href="select_behavior.html">
<link rel="import" href="settings_section.html">
<dom-module id="print-preview-color-settings">
@@ -11,8 +12,7 @@
<print-preview-settings-section>
<span id="color-label" slot="title">$i18n{optionColor}</span>
<div slot="controls">
- <select aria-labelledby="color-label" on-change="onChange_"
- disabled$="[[disabled]]">
+ <select aria-labelledby="color-label" disabled$="[[disabled]]">
<option value="bw" selected>$i18n{optionBw}</option>
<option value="color">$i18n{optionColor}</option>
</select>
diff --git a/chromium/chrome/browser/resources/print_preview/new/color_settings.js b/chromium/chrome/browser/resources/print_preview/new/color_settings.js
index 4c8631aa5ec..40e2e6b547e 100644
--- a/chromium/chrome/browser/resources/print_preview/new/color_settings.js
+++ b/chromium/chrome/browser/resources/print_preview/new/color_settings.js
@@ -5,7 +5,7 @@
Polymer({
is: 'print-preview-color-settings',
- behaviors: [SettingsBehavior],
+ behaviors: [SettingsBehavior, print_preview_new.SelectBehavior],
properties: {
disabled: Boolean,
@@ -21,8 +21,8 @@ Polymer({
this.$$('select').value = /** @type {boolean} */ (value) ? 'color' : 'bw';
},
- /** @private */
- onChange_: function() {
- this.setSetting('color', this.$$('select').value == 'color');
+ /** @param {string} value The new select value. */
+ onProcessSelectChange: function(value) {
+ this.setSetting('color', value == 'color');
},
});
diff --git a/chromium/chrome/browser/resources/print_preview/new/compiled_resources2.gyp b/chromium/chrome/browser/resources/print_preview/new/compiled_resources2.gyp
deleted file mode 100644
index fee39181adc..00000000000
--- a/chromium/chrome/browser/resources/print_preview/new/compiled_resources2.gyp
+++ /dev/null
@@ -1,324 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'app',
- 'dependencies': [
- 'header',
- 'destination_settings',
- 'pages_settings',
- 'copies_settings',
- 'layout_settings',
- 'color_settings',
- 'media_size_settings',
- 'margins_settings',
- 'dpi_settings',
- 'scaling_settings',
- 'other_options_settings',
- 'advanced_options_settings',
- 'link_container',
- 'preview_area',
- 'model',
- 'state',
- '../compiled_resources2.gyp:cloud_print_interface',
- '../compiled_resources2.gyp:native_layer',
- '../data/compiled_resources2.gyp:destination',
- '../data/compiled_resources2.gyp:destination_store',
- '../data/compiled_resources2.gyp:invitation_store',
- '../data/compiled_resources2.gyp:document_info',
- '../data/compiled_resources2.gyp:measurement_system',
- '../data/compiled_resources2.gyp:user_info',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:event_tracker',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:webui_listener_tracker',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'header',
- 'dependencies': [
- '../data/compiled_resources2.gyp:destination',
- 'model',
- 'settings_behavior',
- 'state',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'destination_settings',
- 'dependencies': [
- '../data/compiled_resources2.gyp:destination',
- '../data/compiled_resources2.gyp:destination_store',
- '../data/compiled_resources2.gyp:invitation_store',
- '../data/compiled_resources2.gyp:user_info',
- 'destination_dialog',
- 'state',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_lazy_render/compiled_resources2.gyp:cr_lazy_render',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'pages_settings',
- 'dependencies': [
- 'input_behavior',
- 'settings_behavior',
- '../data/compiled_resources2.gyp:document_info',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'copies_settings',
- 'dependencies': [
- 'number_settings_section',
- 'settings_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'layout_settings',
- 'dependencies': [
- 'settings_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'color_settings',
- 'dependencies': [
- 'settings_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'media_size_settings',
- 'dependencies': [
- 'settings_behavior',
- 'settings_select',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'margins_settings',
- 'dependencies': [
- 'settings_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'dpi_settings',
- 'dependencies': [
- 'settings_behavior',
- 'settings_select',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'scaling_settings',
- 'dependencies': [
- '../data/compiled_resources2.gyp:document_info',
- 'number_settings_section',
- 'settings_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'other_options_settings',
- 'dependencies': [
- 'settings_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'advanced_options_settings',
- 'dependencies': [
- '../data/compiled_resources2.gyp:destination',
- 'advanced_settings_dialog',
- 'settings_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'number_settings_section',
- 'dependencies': [
- 'input_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'settings_select',
- 'dependencies': [
- 'settings_behavior',
- '../compiled_resources2.gyp:print_preview_utils',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'settings_behavior',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'input_behavior',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'link_container',
- 'dependencies': [
- '../data/compiled_resources2.gyp:destination',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'preview_area',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '../../pdf/compiled_resources2.gyp:pdf_scripting_api',
- '../compiled_resources2.gyp:native_layer',
- '../compiled_resources2.gyp:print_preview_utils',
- '../data/compiled_resources2.gyp:destination',
- '../data/compiled_resources2.gyp:document_info',
- '../data/compiled_resources2.gyp:coordinate2d',
- '../data/compiled_resources2.gyp:size',
- '../data/compiled_resources2.gyp:margins',
- '../data/compiled_resources2.gyp:printable_area',
- 'margin_control_container',
- 'model',
- 'settings_behavior',
- 'state',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'margin_control_container',
- 'dependencies': [
- '../data/compiled_resources2.gyp:coordinate2d',
- '../data/compiled_resources2.gyp:margins',
- '../data/compiled_resources2.gyp:measurement_system',
- '../data/compiled_resources2.gyp:size',
- 'margin_control',
- 'settings_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:event_tracker',
- '<(EXTERNS_GYP):pending',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'margin_control',
- 'dependencies': [
- '../data/compiled_resources2.gyp:coordinate2d',
- '../data/compiled_resources2.gyp:margins',
- '../data/compiled_resources2.gyp:size',
- 'input_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'destination_dialog',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_dialog/compiled_resources2.gyp:cr_dialog',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '../data/compiled_resources2.gyp:destination',
- '../data/compiled_resources2.gyp:destination_store',
- '../data/compiled_resources2.gyp:invitation',
- '../data/compiled_resources2.gyp:invitation_store',
- '../data/compiled_resources2.gyp:user_info',
- 'destination_list',
- 'print_preview_search_box',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'destination_list',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '../compiled_resources2.gyp:native_layer',
- '../data/compiled_resources2.gyp:destination',
- 'destination_list_item',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'destination_list_item',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- 'highlight_utils',
- '../compiled_resources2.gyp:native_layer',
- '../data/compiled_resources2.gyp:destination',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'advanced_settings_dialog',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_dialog/compiled_resources2.gyp:cr_dialog',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '../data/compiled_resources2.gyp:destination',
- 'advanced_settings_item',
- 'print_preview_search_box',
- 'settings_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'advanced_settings_item',
- 'dependencies': [
- 'highlight_utils',
- '../compiled_resources2.gyp:print_preview_utils',
- '../data/compiled_resources2.gyp:destination',
- 'settings_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'print_preview_search_box',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_search_field/compiled_resources2.gyp:cr_search_field_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'highlight_utils',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:search_highlight_utils',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'model',
- 'dependencies': [
- 'settings_behavior',
- '../data/compiled_resources2.gyp:destination',
- '../data/compiled_resources2.gyp:document_info',
- '../data/compiled_resources2.gyp:margins',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'state',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- }
- ],
-}
diff --git a/chromium/chrome/browser/resources/print_preview/new/copies_settings.js b/chromium/chrome/browser/resources/print_preview/new/copies_settings.js
index 1115ac4c99f..aeaa23f0545 100644
--- a/chromium/chrome/browser/resources/print_preview/new/copies_settings.js
+++ b/chromium/chrome/browser/resources/print_preview/new/copies_settings.js
@@ -17,22 +17,16 @@ Polymer({
disabled: Boolean,
},
- /** @private {boolean} */
- isInitialized_: false,
-
observers: [
'onInputChanged_(currentValue_, inputValid_)',
- 'onInitialized_(settings.copies.value, settings.collate.value)'
+ 'onSettingsChanged_(settings.copies.value, settings.collate.value)'
],
/**
* Updates the input string when the setting has been initialized.
* @private
*/
- onInitialized_: function() {
- if (this.isInitialized_)
- return;
- this.isInitialized_ = true;
+ onSettingsChanged_: function() {
const copies = this.getSetting('copies');
this.currentValue_ = /** @type {string} */ (copies.value.toString());
const collate = this.getSetting('collate');
diff --git a/chromium/chrome/browser/resources/print_preview/new/destination_dialog.html b/chromium/chrome/browser/resources/print_preview/new/destination_dialog.html
index e740071ef93..182e131217b 100644
--- a/chromium/chrome/browser/resources/print_preview/new/destination_dialog.html
+++ b/chromium/chrome/browser/resources/print_preview/new/destination_dialog.html
@@ -3,7 +3,9 @@
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html">
<link rel="import" href="chrome://resources/html/action_link_css.html">
+<link rel="import" href="chrome://resources/html/event_tracker.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
+<link rel="import" href="../metrics.html">
<link rel="import" href="../data/destination.html">
<link rel="import" href="../data/destination_store.html">
<link rel="import" href="../data/invitation.html">
@@ -12,8 +14,10 @@
<link rel="import" href="destination_list.html">
<link rel="import" href="print_preview_search_box.html">
<link rel="import" href="print_preview_shared_css.html">
+<link rel="import" href="provisional_destination_resolver.html">
<link rel="import" href="search_dialog_css.html">
<link rel="import" href="select_css.html">
+<link rel="import" href="strings.html">
<link rel="import" href="throbber_css.html">
<dom-module id="print-preview-destination-dialog">
@@ -21,10 +25,24 @@
<style include="print-preview-shared button action-link select cr-hidden-style search-dialog throbber">
:host #dialog {
--cr-dialog-native: {
+ border-radius: 2px;
box-shadow: 0 4px 23px 5px rgba(0, 0, 0, 0.2),
0 2px 6px rgba(0, 0, 0, 0.15);
+ min-height: calc(100vh - 40px);
width: 640px;
- }
+ };
+ --cr-dialog-wrapper: {
+ height: 100%;
+ };
+ --cr-dialog-body: {
+ -webkit-padding-end: 16px;
+ -webkit-padding-start: 16px;
+ padding-bottom: 0;
+ padding-top: 0;
+ };
+ --cr-dialog-body-container: {
+ flex: 1;
+ };
}
:host .user-info {
@@ -91,15 +109,19 @@
flex-direction: column;
}
- :host #invitationPromo .invitation-text {
- padding-bottom: 12px;
+ :host #invitationPromo .invitation-buttons {
+ padding: 12px 0;
}
- :host #invitationPromo .invitation-reject-button {
- -webkit-margin-start: 10px;
+ print-preview-destination-list {
+ padding-bottom: 18px;
+ }
+
+ print-preview-destination-list:last-child {
+ padding-bottom: 0;
}
</style>
- <cr-dialog id="dialog" on-close="onCloseOrCancel_">
+ <cr-dialog id="dialog" on-close="onCloseOrCancel_" show-close-button>
<div slot="title">
<div>$i18n{destinationSearchTitle}</div>
<div class="user-info" hidden$="[[!userInfo.loggedIn]]">
@@ -122,18 +144,23 @@
</print-preview-search-box>
</div>
<div slot="body" scrollable>
- <print-preview-destination-list
- destinations="[[recentDestinationList_]]"
- search-query="[[searchQuery_]]"
- title="$i18n{recentDestinationsTitle}"
- on-destination-selected="onDestinationSelected_">
- </print-preview-destination-list>
- <print-preview-destination-list destinations="[[destinations_]]"
- has-action-link loading-destinations="[[loadingDestinations_]]"
- search-query="[[searchQuery_]]"
- title="$i18n{printDestinationsTitle}"
- on-destination-selected="onDestinationSelected_">
- </print-preview-destination-list>
+ <div>
+ <print-preview-destination-list
+ destinations="[[recentDestinationList_]]"
+ search-query="[[searchQuery_]]"
+ title="$i18n{recentDestinationsTitle}"
+ on-destination-selected="onDestinationSelected_">
+ </print-preview-destination-list>
+ <print-preview-destination-list destinations="[[destinations_]]"
+ has-action-link loading-destinations="[[loadingDestinations_]]"
+ search-query="[[searchQuery_]]"
+ title="$i18n{printDestinationsTitle}"
+ on-destination-selected="onDestinationSelected_">
+ </print-preview-destination-list>
+ </div>
+ <print-preview-provisional-destination-resolver id="provisionalResolver"
+ destination-store="[[destinationStore]]">
+ </print-preview-provisional-destination-resolver>
</div>
<div slot="button-container">
<button class="cancel-button" on-click="onCancelButtonClick_">
@@ -148,20 +175,15 @@
<div class="close-button"></div>
</div>
<div class="promo" id="invitationPromo" hidden="[[!invitation_]]">
- <div class="invitation-text"
- inner-h-t-m-l="[[getInvitationText_(invitation_)]]">
- </div>
+ <div inner-h-t-m-l="[[getInvitationText_(invitation_)]]"></div>
<div class="invitation-buttons">
- <button class="invitation-accept-button"
- on-click="onInvitationAcceptClick_">
+ <button on-click="onInvitationAcceptClick_">
[[getAcceptButtonText_(invitation_)]]
</button>
- <button class="invitation-reject-button"
- on-click="onInvitationRejectClick_">
- $i18n{reject}
- </button>
+ <button on-click="onInvitationRejectClick_">$i18n{reject}</button>
<div id="invitation-process-throbber" class="throbber" hidden></div>
</div>
+ <div>$i18nRaw{registerPrinterInformationMessage}</div>
</div>
</div>
</cr-dialog>
diff --git a/chromium/chrome/browser/resources/print_preview/new/destination_dialog.js b/chromium/chrome/browser/resources/print_preview/new/destination_dialog.js
index ad5fc91a47d..8500c9fd721 100644
--- a/chromium/chrome/browser/resources/print_preview/new/destination_dialog.js
+++ b/chromium/chrome/browser/resources/print_preview/new/destination_dialog.js
@@ -36,6 +36,7 @@ Polymer({
showCloudPrintPromo: {
type: Boolean,
notify: true,
+ observer: 'onShowCloudPrintPromoChanged_',
},
/** @private {!Array<!print_preview.Destination>} */
@@ -73,6 +74,14 @@ Polymer({
/** @private {!EventTracker} */
tracker_: new EventTracker(),
+ /** @private {!print_preview.DestinationSearchMetricsContext} */
+ metrics_: new print_preview.DestinationSearchMetricsContext(),
+
+ // <if expr="chromeos">
+ /** @private {?print_preview.Destination} */
+ destinationInConfiguring_: null,
+ // </if>
+
/** @override */
ready: function() {
this.$$('.promo-text').innerHTML =
@@ -81,6 +90,8 @@ Polymer({
attrs: {
'is': (node, v) => v == 'action-link',
'class': (node, v) => v == 'sign-in',
+ 'tabindex': (node, v) => v == '0',
+ 'role': (node, v) => v == 'link',
},
});
},
@@ -165,6 +176,13 @@ Polymer({
onCloseOrCancel_: function() {
if (this.searchQuery_)
this.$.searchBox.setValue('');
+ if (this.$.dialog.getNative().returnValue == 'success') {
+ this.metrics_.record(print_preview.Metrics.DestinationSearchBucket
+ .DESTINATION_CLOSED_CHANGED);
+ } else {
+ this.metrics_.record(print_preview.Metrics.DestinationSearchBucket
+ .DESTINATION_CLOSED_UNCHANGED);
+ }
},
/** @private */
@@ -173,12 +191,71 @@ Polymer({
},
/**
- * @param {!CustomEvent} e Event containing the selected destination.
+ * @param {!CustomEvent} e Event containing the selected destination list item
+ * element.
* @private
*/
onDestinationSelected_: function(e) {
- this.destinationStore.selectDestination(
- /** @type {!print_preview.Destination} */ (e.detail));
+ const listItem =
+ /** @type {!PrintPreviewDestinationListItemElement} */ (e.detail);
+ const destination = listItem.destination;
+
+ // ChromeOS local destinations that don't have capabilities need to be
+ // configured before selecting, and provisional destinations need to be
+ // resolved. Other destinations can be selected.
+ if (destination.readyForSelection) {
+ this.selectDestination_(destination);
+ return;
+ }
+
+ // Provisional destinations
+ if (destination.isProvisional) {
+ this.$.provisionalResolver.resolveDestination(destination)
+ .then(this.selectDestination_.bind(this))
+ .catch(function() {
+ console.error(
+ 'Failed to resolve provisional destination: ' + destination.id);
+ })
+ .then(() => {
+ if (this.$.dialog.open && !!listItem && !listItem.hidden) {
+ listItem.focus();
+ }
+ });
+ return;
+ }
+
+ // <if expr="chromeos">
+ // Destination must be a CrOS local destination that needs to be set up.
+ // The user is only allowed to set up printer at one time.
+ if (this.destinationInConfiguring_)
+ return;
+
+ // Show the configuring status to the user and resolve the destination.
+ listItem.onConfigureRequestAccepted();
+ this.destinationInConfiguring_ = destination;
+ this.destinationStore.resolveCrosDestination(destination)
+ .then(
+ response => {
+ this.destinationInConfiguring_ = null;
+ listItem.onConfigureComplete(response.success);
+ if (response.success) {
+ destination.capabilities = response.capabilities;
+ this.selectDestination_(destination);
+ }
+ },
+ () => {
+ this.destinationInConfiguring_ = null;
+ listItem.onConfigureComplete(false);
+ });
+ // </if>
+ },
+
+ /**
+ * @param {!print_preview.Destination} destination The destination to select.
+ * @private
+ */
+ selectDestination_: function(destination) {
+ this.destinationStore.selectDestination(destination);
this.$.dialog.close();
},
@@ -186,6 +263,8 @@ Polymer({
this.loadingDestinations_ =
this.destinationStore.isPrintDestinationSearchInProgress;
this.$.dialog.showModal();
+ this.metrics_.record(
+ print_preview.Metrics.DestinationSearchBucket.DESTINATION_SHOWN);
},
/** @return {boolean} Whether the dialog is open. */
@@ -200,6 +279,8 @@ Polymer({
/** @private */
onSignInClick_: function() {
+ this.metrics_.record(
+ print_preview.Metrics.DestinationSearchBucket.SIGNIN_TRIGGERED);
print_preview.NativeLayer.getInstance().signIn(false).then(() => {
this.destinationStore.onDestinationsReload();
});
@@ -218,6 +299,10 @@ Polymer({
const invitations = this.userInfo.activeUser ?
this.invitationStore.invitations(this.userInfo.activeUser) :
[];
+ if (this.invitation_ != invitations[0]) {
+ this.metrics_.record(
+ print_preview.Metrics.DestinationSearchBucket.INVITATION_AVAILABLE);
+ }
this.invitation_ = invitations.length > 0 ? invitations[0] : null;
},
@@ -260,12 +345,16 @@ Polymer({
/** @private */
onInvitationAcceptClick_: function() {
+ this.metrics_.record(
+ print_preview.Metrics.DestinationSearchBucket.INVITATION_ACCEPTED);
this.invitationStore.processInvitation(assert(this.invitation_), true);
this.updateInvitations_();
},
/** @private */
onInvitationRejectClick_: function() {
+ this.metrics_.record(
+ print_preview.Metrics.DestinationSearchBucket.INVITATION_REJECTED);
this.invitationStore.processInvitation(assert(this.invitation_), false);
this.updateInvitations_();
},
@@ -281,6 +370,8 @@ Polymer({
this.notifyPath('userInfo.loggedIn');
this.destinationStore.reloadUserCookieBasedDestinations();
this.invitationStore.startLoadingInvitations();
+ this.metrics_.record(
+ print_preview.Metrics.DestinationSearchBucket.ACCOUNT_CHANGED);
} else {
print_preview.NativeLayer.getInstance().signIn(true).then(
this.destinationStore.onDestinationsReload.bind(
@@ -292,6 +383,16 @@ Polymer({
break;
}
}
+ this.metrics_.record(
+ print_preview.Metrics.DestinationSearchBucket.ADD_ACCOUNT_SELECTED);
+ }
+ },
+
+ /** @private */
+ onShowCloudPrintPromoChanged_: function() {
+ if (this.showCloudPrintPromo) {
+ this.metrics_.record(
+ print_preview.Metrics.DestinationSearchBucket.SIGNIN_PROMPT);
}
},
});
diff --git a/chromium/chrome/browser/resources/print_preview/new/destination_list.html b/chromium/chrome/browser/resources/print_preview/new/destination_list.html
index 3a008a5df4d..69416e0e6d4 100644
--- a/chromium/chrome/browser/resources/print_preview/new/destination_list.html
+++ b/chromium/chrome/browser/resources/print_preview/new/destination_list.html
@@ -7,13 +7,14 @@
<link rel="import" href="../data/destination.html">
<link rel="import" href="destination_list_item.html">
<link rel="import" href="print_preview_shared_css.html">
+<link rel="import" href="strings.html">
<link rel="import" href="throbber_css.html">
<dom-module id="print-preview-destination-list">
<template>
<style include="print-preview-shared action-link cr-hidden-style throbber">
:host {
- padding: 0 14px 18px;
+ display: block;
user-select: none;
}
diff --git a/chromium/chrome/browser/resources/print_preview/new/destination_list.js b/chromium/chrome/browser/resources/print_preview/new/destination_list.js
index b83f9309149..3f8cd873cbe 100644
--- a/chromium/chrome/browser/resources/print_preview/new/destination_list.js
+++ b/chromium/chrome/browser/resources/print_preview/new/destination_list.js
@@ -129,10 +129,7 @@ Polymer({
* @private
*/
onDestinationSelected_: function(e) {
- this.fire(
- 'destination-selected',
- /** @type {PrintPreviewDestinationListItemElement} */
- (e.target).destination);
+ this.fire('destination-selected', e.target);
},
});
})();
diff --git a/chromium/chrome/browser/resources/print_preview/new/destination_list_item.html b/chromium/chrome/browser/resources/print_preview/new/destination_list_item.html
index 7fe1155fbc8..702662e9541 100644
--- a/chromium/chrome/browser/resources/print_preview/new/destination_list_item.html
+++ b/chromium/chrome/browser/resources/print_preview/new/destination_list_item.html
@@ -1,11 +1,13 @@
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html">
+<link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="chrome://resources/html/load_time_data.html">
<link rel="import" href="../native_layer.html">
<link rel="import" href="../data/destination.html">
<link rel="import" href="highlight_utils.html">
<link rel="import" href="print_preview_shared_css.html">
+<link rel="import" href="strings.html">
<dom-module id="print-preview-destination-list-item">
<template>
@@ -49,11 +51,6 @@
color: rgb(51, 103, 214);
}
- :host .register-promo {
- -webkit-margin-start: 1em;
- flex: 0 0 auto;
- }
-
:host .extension-controlled-indicator {
display: flex;
flex: 1;
@@ -110,11 +107,6 @@
on-click="onLearnMoreLinkClick_">
$i18n{learnMore}
</a>
- <span class="register-promo" hidden$="[[!destination.isUnregistered]]">
- <button class="register-promo-button">
- $i18n{registerPromoButtonText}
- </button>
- </span>
<span class="extension-controlled-indicator"
hidden$="[[!destination.isExtension]]">
<span class="extension-name searchable">
@@ -123,13 +115,17 @@
<span class="extension-icon" role="button" tabindex="0"></span>
</span>
<if expr="chromeos">
- <span class="configuring-in-progress-text" hidden>
+ <span class="configuring-in-progress-text"
+ hidden$="[[!checkConfigurationStatus_(statusEnum_.IN_PROGRESS,
+ configurationStatus_)]]">
$i18n{configuringInProgressText}
<span class="configuring-text-jumping-dots">
<span>.</span><span>.</span><span>.</span>
</span>
</span>
- <span class="configuring-failed-text" hidden>
+ <span class="configuring-failed-text"
+ hidden$="[[!checkConfigurationStatus_(statusEnum_.FAILED,
+ configurationStatus_)]]">
$i18n{configuringFailedText}
</span>
</if>
diff --git a/chromium/chrome/browser/resources/print_preview/new/destination_list_item.js b/chromium/chrome/browser/resources/print_preview/new/destination_list_item.js
index b68a211d14d..3c3df29119f 100644
--- a/chromium/chrome/browser/resources/print_preview/new/destination_list_item.js
+++ b/chromium/chrome/browser/resources/print_preview/new/destination_list_item.js
@@ -2,6 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+cr.exportPath('print_preview_new');
+
+// <if expr="chromeos">
+/** @enum {number} */
+print_preview_new.DestinationConfigStatus = {
+ IDLE: 0,
+ IN_PROGRESS: 1,
+ FAILED: 2,
+};
+// </if>
+
Polymer({
is: 'print-preview-destination-list-item',
@@ -20,11 +31,29 @@ Polymer({
/** @private {string} */
searchHint_: String,
+
+ // <if expr="chromeos">
+ /** @private {!print_preview_new.DestinationConfigStatus} */
+ configurationStatus_: {
+ type: Number,
+ value: print_preview_new.DestinationConfigStatus.IDLE,
+ },
+
+ /**
+ * Mirroring the enum so that it can be used from HTML bindings.
+ * @private
+ */
+ statusEnum_: {
+ type: Object,
+ value: print_preview_new.DestinationConfigStatus,
+ },
+ // </if>
},
observers: [
'onDestinationPropertiesChange_(' +
- 'destination.displayName, destination.isOfflineOrInvalid)',
+ 'destination.displayName, destination.isOfflineOrInvalid, ' +
+ 'destination.isExtension)',
],
/** @private {boolean} */
@@ -34,6 +63,14 @@ Polymer({
onDestinationPropertiesChange_: function() {
this.title = this.destination.displayName;
this.stale_ = this.destination.isOfflineOrInvalid;
+ if (this.destination.isExtension) {
+ const icon = this.$$('.extension-icon');
+ icon.style.backgroundImage = '-webkit-image-set(' +
+ 'url(chrome://extension-icon/' + this.destination.extensionId +
+ '/24/1) 1x,' +
+ 'url(chrome://extension-icon/' + this.destination.extensionId +
+ '/48/1) 2x)';
+ }
},
/** @private */
@@ -42,6 +79,40 @@ Polymer({
loadTimeData.getString('gcpCertificateErrorLearnMoreURL'));
},
+ // <if expr="chromeos">
+ /**
+ * Called if the printer configuration request is accepted. Show the waiting
+ * message to the user as the configuration might take longer than expected.
+ */
+ onConfigureRequestAccepted: function() {
+ // It must be a Chrome OS CUPS printer which hasn't been set up before.
+ assert(
+ this.destination.origin == print_preview.DestinationOrigin.CROS &&
+ !this.destination.capabilities);
+ this.configurationStatus_ =
+ print_preview_new.DestinationConfigStatus.IN_PROGRESS;
+ },
+
+ /**
+ * Called when the printer configuration request completes.
+ * @param {boolean} success Whether configuration was successful.
+ */
+ onConfigureComplete: function(success) {
+ this.configurationStatus_ = success ?
+ print_preview_new.DestinationConfigStatus.IDLE :
+ print_preview_new.DestinationConfigStatus.FAILED;
+ },
+
+ /**
+ * @param {!print_preview_new.DestinationConfigStatus} status
+ * @return {boolean} Whether the current configuration status is |status|.
+ * @private
+ */
+ checkConfigurationStatus_: function(status) {
+ return this.configurationStatus_ == status;
+ },
+ // </if>
+
update: function() {
this.updateSearchHint_();
this.updateHighlighting_();
diff --git a/chromium/chrome/browser/resources/print_preview/new/destination_settings.html b/chromium/chrome/browser/resources/print_preview/new/destination_settings.html
index a5edebb475f..f5cf7145087 100644
--- a/chromium/chrome/browser/resources/print_preview/new/destination_settings.html
+++ b/chromium/chrome/browser/resources/print_preview/new/destination_settings.html
@@ -13,6 +13,7 @@
<link rel="import" href="print_preview_shared_css.html">
<link rel="import" href="throbber_css.html">
<link rel="import" href="settings_section.html">
+<link rel="import" href="strings.html">
<dom-module id="print-preview-destination-settings">
<template>
diff --git a/chromium/chrome/browser/resources/print_preview/new/dpi_settings.html b/chromium/chrome/browser/resources/print_preview/new/dpi_settings.html
index 1714dc87c91..3511643588a 100644
--- a/chromium/chrome/browser/resources/print_preview/new/dpi_settings.html
+++ b/chromium/chrome/browser/resources/print_preview/new/dpi_settings.html
@@ -5,6 +5,7 @@
<link rel="import" href="settings_behavior.html">
<link rel="import" href="settings_section.html">
<link rel="import" href="settings_select.html">
+<link rel="import" href="strings.html">
<dom-module id="print-preview-dpi-settings">
<template>
diff --git a/chromium/chrome/browser/resources/print_preview/new/header.html b/chromium/chrome/browser/resources/print_preview/new/header.html
index 70468e7670d..957e1802e57 100644
--- a/chromium/chrome/browser/resources/print_preview/new/header.html
+++ b/chromium/chrome/browser/resources/print_preview/new/header.html
@@ -1,5 +1,6 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="button_css.html">
<link rel="import" href="../data/destination.html">
diff --git a/chromium/chrome/browser/resources/print_preview/new/header.js b/chromium/chrome/browser/resources/print_preview/new/header.js
index 4c5e0240e79..2801f38b453 100644
--- a/chromium/chrome/browser/resources/print_preview/new/header.js
+++ b/chromium/chrome/browser/resources/print_preview/new/header.js
@@ -49,7 +49,8 @@ Polymer({
observers:
['update_(settings.copies.value, settings.duplex.value, ' +
- 'settings.pages.value, state)'],
+ 'settings.pages.value, settings.pagesPerSheet.value, state, ' +
+ 'destination.id)'],
/** @private */
onPrintClick_: function() {
@@ -94,6 +95,14 @@ Polymer({
numSheets = Math.ceil(numPages / 2);
}
+ const pagesPerSheet = parseInt(this.getSettingValue('pagesPerSheet'), 10);
+
+ if (!Number.isNaN(pagesPerSheet)) {
+ assert(pagesPerSheet > 0);
+ numSheets = Math.ceil(numSheets / pagesPerSheet);
+ numPages = Math.ceil(numPages / pagesPerSheet);
+ }
+
const copies = parseInt(this.getSettingValue('copies'), 10);
numSheets *= copies;
numPages *= copies;
@@ -151,19 +160,10 @@ Polymer({
* @private
*/
getSummary_: function(labelInfo) {
- let html = null;
- if (labelInfo.numPages != labelInfo.numSheets) {
- html = loadTimeData.getStringF(
- 'printPreviewSummaryFormatLong',
- '<b>' + labelInfo.numSheets.toLocaleString() + '</b>',
- '<b>' + labelInfo.summaryLabel + '</b>',
- labelInfo.numPages.toLocaleString(), labelInfo.pagesLabel);
- } else {
- html = loadTimeData.getStringF(
- 'printPreviewSummaryFormatShort',
- '<b>' + labelInfo.numSheets.toLocaleString() + '</b>',
- '<b>' + labelInfo.summaryLabel + '</b>');
- }
+ let html = loadTimeData.getStringF(
+ 'printPreviewSummaryFormatShort',
+ '<b>' + labelInfo.numSheets.toLocaleString() + '</b>',
+ '<b>' + labelInfo.summaryLabel + '</b>');
// Removing extra spaces from within the string.
html = html.replace(/\s{2,}/g, ' ');
@@ -176,12 +176,6 @@ Polymer({
* @private
*/
getSummaryLabel_: function(labelInfo) {
- if (labelInfo.numPages != labelInfo.numSheets) {
- return loadTimeData.getStringF(
- 'printPreviewSummaryFormatLong', labelInfo.numSheets.toLocaleString(),
- labelInfo.summaryLabel, labelInfo.numPages.toLocaleString(),
- labelInfo.pagesLabel);
- }
return loadTimeData.getStringF(
'printPreviewSummaryFormatShort', labelInfo.numSheets.toLocaleString(),
labelInfo.summaryLabel);
diff --git a/chromium/chrome/browser/resources/print_preview/new/input_behavior.js b/chromium/chrome/browser/resources/print_preview/new/input_behavior.js
index bd63ce05c44..e2aec6d9928 100644
--- a/chromium/chrome/browser/resources/print_preview/new/input_behavior.js
+++ b/chromium/chrome/browser/resources/print_preview/new/input_behavior.js
@@ -84,7 +84,12 @@ cr.define('print_preview_new', function() {
}
},
- /** Called to clear the timeout and update the value. */
+ // Resets the lastValue_ so that future inputs trigger a change event.
+ resetString: function() {
+ this.lastValue_ = null;
+ },
+
+ // Called to clear the timeout and update the value.
resetAndUpdate: function() {
if (this.timeout_) {
clearTimeout(this.timeout_);
diff --git a/chromium/chrome/browser/resources/print_preview/new/layout_settings.html b/chromium/chrome/browser/resources/print_preview/new/layout_settings.html
index 0b0e7ae3098..dc7b9710046 100644
--- a/chromium/chrome/browser/resources/print_preview/new/layout_settings.html
+++ b/chromium/chrome/browser/resources/print_preview/new/layout_settings.html
@@ -2,6 +2,7 @@
<link rel="import" href="print_preview_shared_css.html">
<link rel="import" href="select_css.html">
+<link rel="import" href="select_behavior.html">
<link rel="import" href="settings_behavior.html">
<link rel="import" href="settings_section.html">
@@ -11,8 +12,7 @@
<print-preview-settings-section>
<span id="layout-label" slot="title">$i18n{layoutLabel}</span>
<div slot="controls">
- <select aria-labelledby="layout-label" on-change="onChange_"
- disabled$="[[disabled]]">
+ <select aria-labelledby="layout-label" disabled$="[[disabled]]">
<option value="portrait" selected>$i18n{optionPortrait}</option>
<option value="landscape">$i18n{optionLandscape}</option>
</select>
diff --git a/chromium/chrome/browser/resources/print_preview/new/layout_settings.js b/chromium/chrome/browser/resources/print_preview/new/layout_settings.js
index b84fbe2bd00..c5cb3e5fc10 100644
--- a/chromium/chrome/browser/resources/print_preview/new/layout_settings.js
+++ b/chromium/chrome/browser/resources/print_preview/new/layout_settings.js
@@ -5,7 +5,7 @@
Polymer({
is: 'print-preview-layout-settings',
- behaviors: [SettingsBehavior],
+ behaviors: [SettingsBehavior, print_preview_new.SelectBehavior],
properties: {
disabled: Boolean,
@@ -22,8 +22,8 @@ Polymer({
/** @type {boolean} */ (value) ? 'landscape' : 'portrait';
},
- /** @private */
- onChange_: function() {
- this.setSetting('layout', this.$$('select').value == 'landscape');
+ /** @param {string} value The new select value. */
+ onProcessSelectChange: function(value) {
+ this.setSetting('layout', value == 'landscape');
},
});
diff --git a/chromium/chrome/browser/resources/print_preview/new/link_container.html b/chromium/chrome/browser/resources/print_preview/new/link_container.html
index 2fa93003579..5fca9837360 100644
--- a/chromium/chrome/browser/resources/print_preview/new/link_container.html
+++ b/chromium/chrome/browser/resources/print_preview/new/link_container.html
@@ -1,6 +1,7 @@
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html">
+<link rel="import" href="chrome://resources/html/action_link.html">
<link rel="import" href="chrome://resources/html/action_link_css.html">
<link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="../data/destination.html">
@@ -27,6 +28,10 @@
:host > div > a {
margin: 8px 20px;
}
+
+ :host #systemDialogLink {
+ margin-top: 14px;
+ }
</style>
<div>
<a is="action-link" id="systemDialogLink" disabled="[[disabled]]"
diff --git a/chromium/chrome/browser/resources/print_preview/new/margins_settings.html b/chromium/chrome/browser/resources/print_preview/new/margins_settings.html
index 7bf74d1b5a3..87121b453d7 100644
--- a/chromium/chrome/browser/resources/print_preview/new/margins_settings.html
+++ b/chromium/chrome/browser/resources/print_preview/new/margins_settings.html
@@ -2,6 +2,7 @@
<link rel="import" href="print_preview_shared_css.html">
<link rel="import" href="select_css.html">
+<link rel="import" href="select_behavior.html">
<link rel="import" href="settings_behavior.html">
<link rel="import" href="settings_section.html">
@@ -12,8 +13,7 @@
<print-preview-settings-section>
<span id="margins-label" slot="title">$i18n{marginsLabel}</span>
<div slot="controls">
- <select aria-labelledby="margins-label" on-change="onChange_"
- disabled$="[[disabled]]">
+ <select aria-labelledby="margins-label" disabled$="[[disabled]]">
<!-- The order of these options must match the natural order of their
values, which come from
print_preview.ticket_items.MarginsTypeValue. -->
diff --git a/chromium/chrome/browser/resources/print_preview/new/margins_settings.js b/chromium/chrome/browser/resources/print_preview/new/margins_settings.js
index c641b40c73b..9145663aab0 100644
--- a/chromium/chrome/browser/resources/print_preview/new/margins_settings.js
+++ b/chromium/chrome/browser/resources/print_preview/new/margins_settings.js
@@ -5,7 +5,7 @@
Polymer({
is: 'print-preview-margins-settings',
- behaviors: [SettingsBehavior],
+ behaviors: [SettingsBehavior, print_preview_new.SelectBehavior],
properties: {
disabled: Boolean,
@@ -21,8 +21,8 @@ Polymer({
this.$$('select').value = /** @type {string} */ (value).toString();
},
- /** @private */
- onChange_: function() {
- this.setSetting('margins', parseInt(this.$$('select').value, 10));
+ /** @param {string} value The new select value. */
+ onProcessSelectChange: function(value) {
+ this.setSetting('margins', parseInt(value, 10));
},
});
diff --git a/chromium/chrome/browser/resources/print_preview/new/model.js b/chromium/chrome/browser/resources/print_preview/new/model.js
index c4c71e6e2ae..a7ffc573dc7 100644
--- a/chromium/chrome/browser/resources/print_preview/new/model.js
+++ b/chromium/chrome/browser/resources/print_preview/new/model.js
@@ -219,6 +219,13 @@ Polymer({
available: true,
key: 'vendorOptions',
},
+ pagesPerSheet: {
+ value: 1,
+ unavailableValue: 1,
+ valid: true,
+ available: true,
+ key: '',
+ },
// This does not represent a real setting value, and is used only to
// expose the availability of the other options settings section.
otherOptions: {
@@ -264,14 +271,13 @@ Polymer({
},
observers: [
- 'updateSettings_(' +
- 'destination.id, destination.capabilities, ' +
+ 'updateSettingsFromDestination_(destination.capabilities)',
+ 'updateSettingsAvailabilityFromDocumentInfo_(' +
'documentInfo.isModifiable, documentInfo.hasCssMediaStyles,' +
'documentInfo.hasSelection)',
'updateHeaderFooterAvailable_(' +
- 'documentInfo.isModifiable, documentInfo.margins, ' +
- 'settings.margins.value, settings.customMargins.value, ' +
- 'settings.mediaSize.value)',
+ 'documentInfo.margins, settings.margins.value, ' +
+ 'settings.customMargins.value, settings.mediaSize.value)',
'updateRecentDestinations_(destination, destination.capabilities)',
'stickySettingsChanged_(' +
'settings.collate.value, settings.layout.value, settings.color.value,' +
@@ -293,22 +299,26 @@ Polymer({
/**
* Updates the availability of the settings sections and values of dpi and
- * media size settings.
+ * media size settings based on the destination capabilities.
* @private
*/
- updateSettings_: function() {
- const caps = (!!this.destination && !!this.destination.capabilities) ?
- this.destination.capabilities.printer :
- null;
- this.updateSettingsAvailability_(caps);
-
- if (!caps)
+ updateSettingsFromDestination_: function() {
+ if (!this.destination)
return;
if (this.destination.capabilities == this.lastDestinationCapabilities_)
return;
this.lastDestinationCapabilities_ = this.destination.capabilities;
+
+ const caps = !!this.destination.capabilities ?
+ this.destination.capabilities.printer :
+ null;
+ this.updateSettingsAvailabilityFromDestination_(caps);
+
+ if (!caps)
+ return;
+
this.updateSettingsValues_(caps);
},
@@ -316,31 +326,54 @@ Polymer({
* @param {?print_preview.CddCapabilities} caps The printer capabilities.
* @private
*/
- updateSettingsAvailability_: function(caps) {
- const isSaveToPdf = this.destination.id ==
- print_preview.Destination.GooglePromotedId.SAVE_AS_PDF;
- const knownSizeToSaveAsPdf = isSaveToPdf &&
- (!this.documentInfo.isModifiable ||
- this.documentInfo.hasCssMediaStyles);
+ updateSettingsAvailabilityFromDestination_: function(caps) {
this.set('settings.copies.available', !!caps && !!(caps.copies));
this.set('settings.collate.available', !!caps && !!(caps.collate));
this.set('settings.layout.available', this.isLayoutAvailable_(caps));
this.set('settings.color.available', this.destination.hasColorCapability);
- this.set('settings.margins.available', this.documentInfo.isModifiable);
- this.set(
- 'settings.customMargins.available', this.documentInfo.isModifiable);
- this.set(
- 'settings.mediaSize.available',
- !!caps && !!caps.media_size && !knownSizeToSaveAsPdf);
this.set(
'settings.dpi.available',
!!caps && !!caps.dpi && !!caps.dpi.option &&
caps.dpi.option.length > 1);
+ this.set('settings.duplex.available', !!caps && !!caps.duplex);
+ this.set(
+ 'settings.vendorItems.available', !!caps && !!caps.vendor_capability);
+
+ if (this.documentInfo)
+ this.updateSettingsAvailabilityFromDestinationAndDocumentInfo_();
+ },
+
+ /** @private */
+ updateSettingsAvailabilityFromDestinationAndDocumentInfo_: function() {
+ const knownSizeToSaveAsPdf = this.destination.id ==
+ print_preview.Destination.GooglePromotedId.SAVE_AS_PDF &&
+ (!this.documentInfo.isModifiable ||
+ this.documentInfo.hasCssMediaStyles);
this.set(
'settings.fitToPage.available',
- !this.documentInfo.isModifiable && !isSaveToPdf);
+ !knownSizeToSaveAsPdf && !this.documentInfo.isModifiable);
this.set('settings.scaling.available', !knownSizeToSaveAsPdf);
- this.set('settings.duplex.available', !!caps && !!caps.duplex);
+ const caps = (!!this.destination && !!this.destination.capabilities) ?
+ this.destination.capabilities.printer :
+ null;
+ this.set(
+ 'settings.mediaSize.available',
+ !!caps && !!caps.media_size && !knownSizeToSaveAsPdf);
+ this.set('settings.layout.available', this.isLayoutAvailable_(caps));
+ this.set(
+ 'settings.otherOptions.available',
+ this.settings.duplex.available ||
+ this.settings.cssBackground.available ||
+ this.settings.selectionOnly.available ||
+ this.settings.headerFooter.available ||
+ this.settings.rasterize.available);
+ },
+
+ /** @private */
+ updateSettingsAvailabilityFromDocumentInfo_: function() {
+ this.set('settings.margins.available', this.documentInfo.isModifiable);
+ this.set(
+ 'settings.customMargins.available', this.documentInfo.isModifiable);
this.set(
'settings.cssBackground.available', this.documentInfo.isModifiable);
this.set(
@@ -351,15 +384,9 @@ Polymer({
this.set(
'settings.rasterize.available',
!this.documentInfo.isModifiable && !cr.isWindows && !cr.isMac);
- this.set(
- 'settings.otherOptions.available',
- this.settings.duplex.available ||
- this.settings.cssBackground.available ||
- this.settings.selectionOnly.available ||
- this.settings.headerFooter.available ||
- this.settings.rasterize.available);
- this.set(
- 'settings.vendorItems.available', !!caps && !!caps.vendor_capability);
+
+ if (this.destination)
+ this.updateSettingsAvailabilityFromDestinationAndDocumentInfo_();
},
/** @private */
@@ -441,6 +468,7 @@ Polymer({
const defaultOption = caps.media_size.option.find(o => !!o.is_default);
this.set('settings.mediaSize.value', defaultOption);
}
+
if (this.settings.dpi.available) {
const defaultOption = caps.dpi.option.find(o => !!o.is_default);
this.set('settings.dpi.value', defaultOption);
@@ -449,6 +477,25 @@ Polymer({
this.set('settings.dpi.unavailableValue', caps.dpi.option[0]);
}
+ if (this.settings.color.available) {
+ const defaultOption = this.destination.defaultColorOption;
+ if (defaultOption) {
+ this.set(
+ 'settings.color.value',
+ !['STANDARD_MONOCHROME', 'CUSTOM_MONOCHROME'].includes(
+ defaultOption.type));
+ }
+ } else if (
+ caps && caps.color && caps.color.option &&
+ caps.color.option.length > 0) {
+ this.set(
+ 'settings.color.unavailableValue',
+ !['STANDARD_MONOCHROME', 'CUSTOM_MONOCHROME'].includes(
+ caps.color.option[0].type));
+ } else { // if no color capability is reported, assume black and white.
+ this.set('settings.color.unavailableValue', false);
+ }
+
if (this.settings.vendorItems.available) {
const vendorSettings = {};
for (const item of caps.vendor_capability) {
@@ -615,6 +662,7 @@ Polymer({
printWithExtension: destination.isExtension,
rasterizePDF: this.getSettingValue('rasterize'),
scaleFactor: parseInt(this.getSettingValue('scaling'), 10),
+ pagesPerSheet: this.getSettingValue('pagesPerSheet'),
dpiHorizontal: (dpi && 'horizontal_dpi' in dpi) ? dpi.horizontal_dpi : 0,
dpiVertical: (dpi && 'vertical_dpi' in dpi) ? dpi.vertical_dpi : 0,
deviceName: destination.id,
diff --git a/chromium/chrome/browser/resources/print_preview/new/more_settings.html b/chromium/chrome/browser/resources/print_preview/new/more_settings.html
new file mode 100644
index 00000000000..527973849f0
--- /dev/null
+++ b/chromium/chrome/browser/resources/print_preview/new/more_settings.html
@@ -0,0 +1,53 @@
+<link rel="import" href="chrome://resources/html/polymer.html">
+
+<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html">
+<link rel="import" href="chrome://resources/html/action_link.html">
+<link rel="import" href="chrome://resources/html/action_link_css.html">
+<link rel="import" href="chrome://resources/html/i18n_behavior.html">
+<link rel="import" href="../metrics.html">
+<link rel="import" href="strings.html">
+
+<dom-module id="print-preview-more-settings">
+ <template>
+ <style include="action-link cr-hidden-style">
+ :host {
+ align-items: center;
+ background-color: #f6f6f6;
+ --border: 1px solid #e1e1e1;
+ border-bottom: var(--border);
+ border-top: var(--border);
+ cursor: pointer;
+ display: flex;
+ margin-top: 4px;
+ min-height: 38px;
+ padding: 5px 20px;
+ }
+
+ :host([hidden]) {
+ display: none;
+ }
+
+ :host #label {
+ flex: 1;
+ }
+
+ :host #icon {
+ height: 25px;
+ width: 25px;
+ }
+
+ :host .minus-icon {
+ background-image: url(chrome://resources/images/icon_expand_less.svg);
+ }
+
+ :host .plus-icon {
+ background-image: url(chrome://resources/images/icon_expand_more.svg);
+ }
+ </style>
+ <a id="label" is="action-link" disabled="[[disabled]]">
+ [[getLabelText_(settingsExpandedByUser)]]
+ </a>
+ <div id="icon" class$="[[getIconClass_(settingsExpandedByUser)]]"></div>
+ </template>
+ <script src="more_settings.js"></script>
+</dom-module>
diff --git a/chromium/chrome/browser/resources/print_preview/new/more_settings.js b/chromium/chrome/browser/resources/print_preview/new/more_settings.js
new file mode 100644
index 00000000000..431625fbea2
--- /dev/null
+++ b/chromium/chrome/browser/resources/print_preview/new/more_settings.js
@@ -0,0 +1,52 @@
+// 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.
+
+Polymer({
+ is: 'print-preview-more-settings',
+
+ behaviors: [I18nBehavior],
+
+ properties: {
+ settingsExpandedByUser: {
+ type: Boolean,
+ notify: true,
+ },
+
+ disabled: Boolean,
+ },
+
+ listeners: {
+ 'click': 'onMoreSettingsClick_',
+ },
+
+ /** @private {!print_preview.PrintSettingsUiMetricsContext} */
+ metrics_: new print_preview.PrintSettingsUiMetricsContext(),
+
+ /**
+ * @return {string} 'plus-icon' if settings are collapsed, 'minus-icon' if
+ * they are expanded.
+ * @private
+ */
+ getIconClass_: function() {
+ return this.settingsExpandedByUser ? 'minus-icon' : 'plus-icon';
+ },
+
+ /**
+ * @return {string} The text to display on the label.
+ * @private
+ */
+ getLabelText_: function() {
+ return this.i18n(
+ this.settingsExpandedByUser ? 'lessOptionsLabel' : 'moreOptionsLabel');
+ },
+
+ /** @private */
+ onMoreSettingsClick_: function() {
+ this.settingsExpandedByUser = !this.settingsExpandedByUser;
+ this.metrics_.record(
+ this.settingsExpandedByUser ?
+ print_preview.Metrics.PrintSettingsUiBucket.MORE_SETTINGS_CLICKED :
+ print_preview.Metrics.PrintSettingsUiBucket.LESS_SETTINGS_CLICKED);
+ },
+});
diff --git a/chromium/chrome/browser/resources/print_preview/new/number_settings_section.js b/chromium/chrome/browser/resources/print_preview/new/number_settings_section.js
index 1e52be5f263..2615d7c82d1 100644
--- a/chromium/chrome/browser/resources/print_preview/new/number_settings_section.js
+++ b/chromium/chrome/browser/resources/print_preview/new/number_settings_section.js
@@ -86,13 +86,13 @@ Polymer({
/** @private */
onInputChanged_: function() {
this.inputValid = this.computeValid_();
- if (this.inputValid)
- this.currentValue = this.inputString_;
+ this.currentValue = this.inputString_;
},
/** @private */
onCurrentValueChanged_: function() {
this.inputString_ = this.currentValue;
+ this.resetString();
},
/**
diff --git a/chromium/chrome/browser/resources/print_preview/new/other_options_settings.html b/chromium/chrome/browser/resources/print_preview/new/other_options_settings.html
index afd187b856d..d5ee2d569ef 100644
--- a/chromium/chrome/browser/resources/print_preview/new/other_options_settings.html
+++ b/chromium/chrome/browser/resources/print_preview/new/other_options_settings.html
@@ -16,37 +16,39 @@
<print-preview-settings-section class="multirow-controls">
<span slot="title" id="options-label">$i18n{optionsLabel}</span>
<div slot="controls" class="checkbox">
- <label aria-live="polite"
- hidden$="[[!settings.headerFooter.available]]">
- <input type="checkbox" id="header-footer"
+ <label hidden$="[[!settings.headerFooter.available]]"
+ aria-live="polite">
+ <input type="checkbox" id="headerFooter"
disabled$="[[disabled]]"
on-change="onHeaderFooterChange_"
checked$="[[settings.headerFooter.value]]">
<span>$i18n{optionHeaderFooter}</span>
</label>
- <label aria-live="polite" hidden$="[[!settings.duplex.available]]">
+ <label hidden$="[[!settings.duplex.available]]"
+ aria-live="polite">
<input type="checkbox" id="duplex" on-change="onDuplexChange_"
disabled$="[[disabled]]"
checked$="[[settings.duplex.value]]">
<span>$i18n{optionTwoSided}</span>
</label>
- <label aria-live="polite"
- hidden$="[[!settings.cssBackground.available]]">
- <input type="checkbox" id="css-background"
+ <label hidden$="[[!settings.cssBackground.available]]"
+ aria-live="polite">
+ <input type="checkbox" id="cssBackground"
on-change="onCssBackgroundChange_"
disabled$="[[disabled]]"
checked$="[[settings.cssBackground.value]]">
<span>$i18n{optionBackgroundColorsAndImages}</span>
</label>
- <label aria-live="polite" hidden$="[[!settings.rasterize.available]]">
+ <label hidden$="[[!settings.rasterize.available]]"
+ aria-live="polite">
<input type="checkbox" id="rasterize"
disabled$="[[disabled]]" on-change="onRasterizeChange_"
checked$="[[settings.rasterize.value]]">
<span>$i18n{optionRasterize}</span>
</label>
- <label aria-live="polite"
- hidden$="[[!settings.selectionOnly.available]]">
- <input type="checkbox" id="selection-only"
+ <label hidden$="[[!settings.selectionOnly.available]]"
+ aria-live="polite">
+ <input type="checkbox" id="selectionOnly"
disabled$="[[disabled]]"
on-change="onSelectionOnlyChange_"
checked$="[[settings.selectionOnly.value]]">
diff --git a/chromium/chrome/browser/resources/print_preview/new/other_options_settings.js b/chromium/chrome/browser/resources/print_preview/new/other_options_settings.js
index 07d9f82eb58..783dde11e6f 100644
--- a/chromium/chrome/browser/resources/print_preview/new/other_options_settings.js
+++ b/chromium/chrome/browser/resources/print_preview/new/other_options_settings.js
@@ -19,12 +19,39 @@ Polymer({
'onSelectionOnlySettingChange_(settings.selectionOnly.value)',
],
+ /** @private {!Map<string, ?number>} */
+ timeouts_: new Map(),
+
+ /** @private {!Map<string, boolean>} */
+ previousValues_: new Map(),
+
+ /**
+ * @param {string} settingName The name of the setting to updated.
+ * @param {boolean} newValue The new value for the setting.
+ */
+ updateSettingWithTimeout_: function(settingName, newValue) {
+ const timeout = this.timeouts_.get(settingName);
+ if (timeout != null)
+ clearTimeout(timeout);
+
+ this.timeouts_.set(settingName, setTimeout(() => {
+ this.timeouts_.delete(settingName);
+ if (this.previousValues_.get(settingName) == newValue)
+ return;
+ this.previousValues_.set(settingName, newValue);
+ this.setSetting(settingName, newValue);
+
+ // For tests only
+ this.fire('update-checkbox-setting', settingName);
+ }, 100));
+ },
+
/**
* @param {boolean} value The new value of the header footer setting.
* @private
*/
onHeaderFooterSettingChange_: function(value) {
- this.$$('#header-footer').checked = value;
+ this.$.headerFooter.checked = value;
},
/**
@@ -32,7 +59,7 @@ Polymer({
* @private
*/
onDuplexSettingChange_: function(value) {
- this.$$('#duplex').checked = value;
+ this.$.duplex.checked = value;
},
/**
@@ -40,7 +67,7 @@ Polymer({
* @private
*/
onCssBackgroundSettingChange_: function(value) {
- this.$$('#css-background').checked = value;
+ this.$.cssBackground.checked = value;
},
/**
@@ -48,7 +75,7 @@ Polymer({
* @private
*/
onRasterizeSettingChange_: function(value) {
- this.$$('#rasterize').checked = value;
+ this.$.rasterize.checked = value;
},
/**
@@ -56,31 +83,33 @@ Polymer({
* @private
*/
onSelectionOnlySettingChange_: function(value) {
- this.$$('#selection-only').checked = value;
+ this.$.selectionOnly.checked = value;
},
/** @private */
onHeaderFooterChange_: function() {
- this.setSetting('headerFooter', this.$$('#header-footer').checked);
+ this.updateSettingWithTimeout_('headerFooter', this.$.headerFooter.checked);
},
/** @private */
onDuplexChange_: function() {
- this.setSetting('duplex', this.$$('#duplex').checked);
+ this.updateSettingWithTimeout_('duplex', this.$.duplex.checked);
},
/** @private */
onCssBackgroundChange_: function() {
- this.setSetting('cssBackground', this.$$('#css-background').checked);
+ this.updateSettingWithTimeout_(
+ 'cssBackground', this.$.cssBackground.checked);
},
/** @private */
onRasterizeChange_: function() {
- this.setSetting('rasterize', this.$$('#rasterize').checked);
+ this.updateSettingWithTimeout_('rasterize', this.$.rasterize.checked);
},
/** @private */
onSelectionOnlyChange_: function() {
- this.setSetting('selectionOnly', this.$$('#selection-only').checked);
+ this.updateSettingWithTimeout_(
+ 'selectionOnly', this.$.selectionOnly.checked);
},
});
diff --git a/chromium/chrome/browser/resources/print_preview/new/pages_per_sheet_settings.html b/chromium/chrome/browser/resources/print_preview/new/pages_per_sheet_settings.html
new file mode 100644
index 00000000000..09a4a68b846
--- /dev/null
+++ b/chromium/chrome/browser/resources/print_preview/new/pages_per_sheet_settings.html
@@ -0,0 +1,30 @@
+<link rel="import" href="chrome://resources/html/polymer.html">
+
+<link rel="import" href="print_preview_shared_css.html">
+<link rel="import" href="select_css.html">
+<link rel="import" href="select_behavior.html">
+<link rel="import" href="settings_behavior.html">
+<link rel="import" href="settings_section.html">
+
+<dom-module id="print-preview-pages-per-sheet-settings">
+ <template>
+ <style include="print-preview-shared select">
+ </style>
+ <print-preview-settings-section>
+ <span id="pages-per-sheet-label" slot="title">$i18n{pagesPerSheetLabel}
+ </span>
+ <div slot="controls">
+ <select aria-labelledby="pages-per-sheet-label"
+ disabled$="[[disabled]]">
+ <option value="1" selected>1</option>
+ <option value="2">2</option>
+ <option value="4">4</option>
+ <option value="6">6</option>
+ <option value="9">9</option>
+ <option value="16">16</option>
+ </select>
+ </div>
+ </print-preview-settings-section>
+ </template>
+ <script src="pages_per_sheet_settings.js"></script>
+</dom-module>
diff --git a/chromium/chrome/browser/resources/print_preview/new/pages_per_sheet_settings.js b/chromium/chrome/browser/resources/print_preview/new/pages_per_sheet_settings.js
new file mode 100644
index 00000000000..0b23bbcda2f
--- /dev/null
+++ b/chromium/chrome/browser/resources/print_preview/new/pages_per_sheet_settings.js
@@ -0,0 +1,28 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+Polymer({
+ is: 'print-preview-pages-per-sheet-settings',
+
+ behaviors: [SettingsBehavior, print_preview_new.SelectBehavior],
+
+ properties: {
+ disabled: Boolean,
+ },
+
+ observers: ['onPagesPerSheetSettingChange_(settings.pagesPerSheet.value)'],
+
+ /**
+ * @param {*} value The new value of the pages per sheet setting.
+ * @private
+ */
+ onPagesPerSheetSettingChange_: function(value) {
+ this.$$('select').value = /** @type {number} */ (value).toString();
+ },
+
+ /** @param {string} value The new select value. */
+ onProcessSelectChange: function(value) {
+ this.setSetting('pagesPerSheet', parseInt(value, 10));
+ },
+});
diff --git a/chromium/chrome/browser/resources/print_preview/new/pages_settings.html b/chromium/chrome/browser/resources/print_preview/new/pages_settings.html
index d9781a4b421..2cd551e07fd 100644
--- a/chromium/chrome/browser/resources/print_preview/new/pages_settings.html
+++ b/chromium/chrome/browser/resources/print_preview/new/pages_settings.html
@@ -7,6 +7,7 @@
<link rel="import" href="print_preview_shared_css.html">
<link rel="import" href="settings_behavior.html">
<link rel="import" href="settings_section.html">
+<link rel="import" href="strings.html">
<dom-module id="print-preview-pages-settings">
<template>
@@ -42,7 +43,7 @@
<input id="pageSettingsCustomInput" class="user-value" type="text"
checked="{{customSelected_::change}}" data-timeout-delay="500"
disabled$="[[getDisabled_(disabled, settings.pages.valid)]]"
- pattern="([0-9]*(-)?[0-9]*(,)( )?)*([0-9]*(-)?[0-9]*(,)?( )?)?"
+ pattern="[[inputPattern_]]"
on-focus="onCustomInputFocus_" on-blur="onCustomInputBlur_"
placeholder="$i18n{examplePageRangeText}"
aria-label="$i18n{examplePageRangeText}">
diff --git a/chromium/chrome/browser/resources/print_preview/new/pages_settings.js b/chromium/chrome/browser/resources/print_preview/new/pages_settings.js
index 0734e387451..6b4a692c886 100644
--- a/chromium/chrome/browser/resources/print_preview/new/pages_settings.js
+++ b/chromium/chrome/browser/resources/print_preview/new/pages_settings.js
@@ -65,6 +65,14 @@ Polymer({
type: Array,
computed: 'computeRangesToPrint_(pagesToPrint_, allPagesArray_)',
},
+
+ /** @private {string} */
+ inputPattern_: {
+ type: String,
+ notify: true,
+ value:
+ '([0-9]*(-)?[0-9]*(,|\u3001)( )?)*([0-9]*(-)?[0-9]*(,|\u3001)?( )?)?',
+ },
},
observers: [
@@ -126,16 +134,18 @@ Polymer({
const pages = [];
const added = {};
- const ranges = this.inputString_.split(',');
+ const ranges = this.inputString_.split(/,|\u3001/);
const maxPage = this.allPagesArray_.length;
for (let range of ranges) {
range = range.trim();
- if (range == '')
- continue;
+ if (range == '') {
+ this.errorState_ = PagesInputErrorState.INVALID_SYNTAX;
+ return this.pagesToPrint_;
+ }
const limits = range.split('-');
let min = parseInt(limits[0], 10);
if (min < 1) {
- this.errorState_ = PagesInputErrorState.OUT_OF_BOUNDS;
+ this.errorState_ = PagesInputErrorState.INVALID_SYNTAX;
return this.pagesToPrint_;
}
if (limits.length == 1) {
diff --git a/chromium/chrome/browser/resources/print_preview/new/preview_area.html b/chromium/chrome/browser/resources/print_preview/new/preview_area.html
index fa38e388017..b57d5dff0e9 100644
--- a/chromium/chrome/browser/resources/print_preview/new/preview_area.html
+++ b/chromium/chrome/browser/resources/print_preview/new/preview_area.html
@@ -18,6 +18,7 @@
<link rel="import" href="model.html">
<link rel="import" href="state.html">
<link rel="import" href="settings_behavior.html">
+<link rel="import" href="strings.html">
<dom-module id="print-preview-preview-area">
<template>
@@ -115,25 +116,25 @@
}
</style>
- <div class$="preview-area-overlay-layer [[getInvisible_(previewState_)]]"
- aria-hidden$="[[previewLoaded_]]">
+ <div class$="preview-area-overlay-layer [[getInvisible_(previewState)]]"
+ aria-hidden$="[[getAriaHidden_(previewState)]]">
<div class="preview-area-messages">
<div class="preview-area-message">
<div>
- <span>[[currentMessage_(previewState_)]]</span>
+ <span>[[currentMessage_(previewState)]]</span>
<span class$="preview-area-loading-message-jumping-dots
- [[getJumpingDots_(previewState_)]]"
- hidden$="[[!isPreviewLoading_(previewState_)]]">
+ [[getJumpingDots_(previewState)]]"
+ hidden$="[[!isPreviewLoading_(previewState)]]">
<span>.</span><span>.</span><span>.</span>
</span>
<a is="action-link" class="learn-more-link"
- hidden$="[[!shouldShowLearnMoreLink_(previewState_)]]"
+ hidden$="[[!shouldShowLearnMoreLink_(previewState)]]"
on-click="onGcpErrorLearnMoreClick_">
$i18n{learnMore}
</a>
</div>
<div class="preview-area-action-area"
- hidden$="[[!displaySystemDialogButton_(previewState_)]]">
+ hidden$="[[!displaySystemDialogButton_(previewState)]]">
<button class="preview-area-open-system-dialog-button">
$i18n{launchNativeDialog}
</button>
diff --git a/chromium/chrome/browser/resources/print_preview/new/preview_area.js b/chromium/chrome/browser/resources/print_preview/new/preview_area.js
index a95bb5065ab..28de03e54bc 100644
--- a/chromium/chrome/browser/resources/print_preview/new/preview_area.js
+++ b/chromium/chrome/browser/resources/print_preview/new/preview_area.js
@@ -34,14 +34,21 @@ cr.exportPath('print_preview_new');
*/
print_preview_new.PDFPlugin;
-(function() {
-'use strict';
+/**
+ * @typedef {{
+ * width_microns: number,
+ * height_microns: number,
+ * }}
+ */
+print_preview_new.MediaSizeValue;
/** @enum {string} */
-const PreviewAreaState_ = {
+print_preview_new.PreviewAreaState = {
+ NO_PLUGIN: 'no-plugin',
LOADING: 'loading',
DISPLAY_PREVIEW: 'display-preview',
- OPEN_IN_PREVIEW: 'open-in-preview',
+ OPEN_IN_PREVIEW_LOADING: 'open-in-preview-loading',
+ OPEN_IN_PREVIEW_LOADED: 'open-in-preview-loaded',
INVALID_SETTINGS: 'invalid-settings',
PREVIEW_FAILED: 'preview-failed',
UNSUPPORTED_CLOUD_PRINTER: 'unsupported-cloud-printer',
@@ -80,19 +87,18 @@ Polymer({
value: false,
},
- /** @private {string} */
- previewState_: {
+ /** @type {!print_preview_new.PreviewAreaState} */
+ previewState: {
type: String,
notify: true,
- value: PreviewAreaState_.LOADING,
+ value: print_preview_new.PreviewAreaState.LOADING,
},
/** @private {boolean} */
previewLoaded_: {
type: Boolean,
notify: true,
- computed: 'computePreviewLoaded_(' +
- 'previewState_, pluginLoaded_, documentReady_)',
+ computed: 'computePreviewLoaded_(documentReady_, pluginLoaded_)',
},
},
@@ -104,16 +110,28 @@ Polymer({
observers: [
'onSettingsChanged_(settings.color.value, settings.cssBackground.value, ' +
'settings.fitToPage.value, settings.headerFooter.value, ' +
- 'settings.layout.value, settings.margins.value, ' +
- 'settings.customMargins.value, settings.mediaSize.value, ' +
- 'settings.ranges.value, settings.selectionOnly.value, ' +
- 'settings.scaling.value, settings.rasterize.value, destination.id, ' +
- 'destination.capabilities)',
+ 'settings.layout.value, settings.ranges.value, ' +
+ 'settings.selectionOnly.value, settings.scaling.value, ' +
+ 'settings.pagesPerSheet.value, settings.rasterize.value, destination)',
+ 'onMarginsChanged_(settings.margins.value)',
+ 'onCustomMarginsChanged_(settings.customMargins.value)',
+ 'onMediaSizeChanged_(settings.mediaSize.value)',
+ 'pluginOrDocumentStatusChanged_(pluginLoaded_, documentReady_)',
],
- /** @private {print_preview.NativeLayer} */
+ /** @private {?print_preview.NativeLayer} */
nativeLayer_: null,
+ /**
+ * @private {?print_preview.MarginsSetting}
+ */
+ lastCustomMargins_: null,
+
+ /**
+ * @private {?print_preview_new.MediaSizeValue}
+ */
+ lastMediaSize_: null,
+
/** @private {number} */
inFlightRequestId_: -1,
@@ -136,14 +154,21 @@ Polymer({
this.addWebUIListener(
'page-preview-ready', this.onPagePreviewReady_.bind(this));
+ if (!this.checkPluginCompatibility())
+ this.previewState = print_preview_new.PreviewAreaState.NO_PLUGIN;
+ },
+
+ /**
+ * @return {boolean} Whether the plugin exists and is compatible. Overridden
+ * in tests.
+ */
+ checkPluginCompatibility: function() {
const oopCompatObj =
this.$$('.preview-area-compatibility-object-out-of-process');
const isOOPCompatible = oopCompatObj.postMessage;
oopCompatObj.parentElement.removeChild(oopCompatObj);
- if (!isOOPCompatible) {
- this.previewState_ = PreviewAreaState_.PREVIEW_FAILED;
- this.fire('preview-failed');
- }
+
+ return isOOPCompatible;
},
/**
@@ -151,9 +176,7 @@ Polymer({
* @private
*/
computePreviewLoaded_: function() {
- return this.previewState_ == PreviewAreaState_.DISPLAY_PREVIEW ||
- (this.documentReady_ && this.pluginLoaded_ &&
- this.previewState_ == PreviewAreaState_.OPEN_IN_PREVIEW);
+ return this.documentReady_ && this.pluginLoaded_;
},
/** @return {boolean} Whether the preview is loaded. */
@@ -206,12 +229,40 @@ Polymer({
this.requestPreviewWhenReady_ = true;
},
+ /** @private */
+ pluginOrDocumentStatusChanged_: function() {
+ if (!this.pluginLoaded_ || !this.documentReady_)
+ return;
+
+ this.previewState = this.previewState ==
+ print_preview_new.PreviewAreaState.OPEN_IN_PREVIEW_LOADING ?
+ print_preview_new.PreviewAreaState.OPEN_IN_PREVIEW_LOADED :
+ print_preview_new.PreviewAreaState.DISPLAY_PREVIEW;
+ },
+
/**
* @return {string} 'invisible' if overlay is invisible, '' otherwise.
* @private
*/
getInvisible_: function() {
- return this.previewLoaded() ? 'invisible' : '';
+ return this.isInDisplayPreviewState_() ? 'invisible' : '';
+ },
+
+ /**
+ * @return {string} 'true' if overlay is aria-hidden, 'false' otherwise.
+ * @private
+ */
+ getAriaHidden_: function() {
+ return this.isInDisplayPreviewState_().toString();
+ },
+
+ /**
+ * @return {boolean} Whether the preview area is in DISPLAY_PREVIEW state.
+ * @private
+ */
+ isInDisplayPreviewState_: function() {
+ return this.previewState ==
+ print_preview_new.PreviewAreaState.DISPLAY_PREVIEW;
},
/**
@@ -219,7 +270,7 @@ Polymer({
* @private
*/
isPreviewLoading_: function() {
- return this.previewState_ == PreviewAreaState_.LOADING;
+ return this.previewState == print_preview_new.PreviewAreaState.LOADING;
},
/**
@@ -235,8 +286,12 @@ Polymer({
* @private
*/
displaySystemDialogButton_: function() {
- return this.previewState_ == PreviewAreaState_.INVALID_SETTINGS ||
- this.previewState_ == PreviewAreaState_.OPEN_IN_PREVIEW;
+ return this.previewState ==
+ print_preview_new.PreviewAreaState.INVALID_SETTINGS ||
+ this.previewState ==
+ print_preview_new.PreviewAreaState.OPEN_IN_PREVIEW_LOADING ||
+ this.previewState ==
+ print_preview_new.PreviewAreaState.OPEN_IN_PREVIEW_LOADED;
},
/**
@@ -245,7 +300,8 @@ Polymer({
* @private
*/
shouldShowLearnMoreLink_: function() {
- return this.previewState_ == PreviewAreaState_.UNSUPPORTED_CLOUD_PRINTER;
+ return this.previewState ==
+ print_preview_new.PreviewAreaState.UNSUPPORTED_CLOUD_PRINTER;
},
/**
@@ -253,65 +309,56 @@ Polymer({
* @private
*/
currentMessage_: function() {
- if (this.previewState_ == PreviewAreaState_.LOADING)
- return this.i18n('loading');
- if (this.previewState_ == PreviewAreaState_.OPEN_IN_PREVIEW)
- return this.i18n('openingPDFInPreview');
- if (this.previewState_ == PreviewAreaState_.INVALID_SETTINGS)
- return this.i18n('invalidPrinterSettings');
- if (this.previewState_ == PreviewAreaState_.PREVIEW_FAILED)
- return this.i18n('previewFailed');
- if (this.previewState_ == PreviewAreaState_.UNSUPPORTED_CLOUD_PRINTER)
- return this.i18n('unsupportedCloudPrinter');
- return '';
+ switch (this.previewState) {
+ case print_preview_new.PreviewAreaState.NO_PLUGIN:
+ return this.i18n('noPlugin');
+ case print_preview_new.PreviewAreaState.LOADING:
+ return this.i18n('loading');
+ case print_preview_new.PreviewAreaState.DISPLAY_PREVIEW:
+ return '';
+ // <if expr="is_macosx">
+ case print_preview_new.PreviewAreaState.OPEN_IN_PREVIEW_LOADING:
+ case print_preview_new.PreviewAreaState.OPEN_IN_PREVIEW_LOADED:
+ return this.i18n('openingPDFInPreview');
+ // </if>
+ case print_preview_new.PreviewAreaState.INVALID_SETTINGS:
+ return this.i18n('invalidPrinterSettings');
+ case print_preview_new.PreviewAreaState.PREVIEW_FAILED:
+ return this.i18n('previewFailed');
+ case print_preview_new.PreviewAreaState.UNSUPPORTED_CLOUD_PRINTER:
+ return this.i18n('unsupportedCloudPrinter');
+ default:
+ return '';
+ }
},
/** @private */
startPreview_: function() {
- this.previewState_ = PreviewAreaState_.LOADING;
+ this.previewState = print_preview_new.PreviewAreaState.LOADING;
this.documentReady_ = false;
this.getPreview_().then(
previewUid => {
if (!this.documentInfo.isModifiable)
this.onPreviewStart_(previewUid, -1);
this.documentReady_ = true;
- if (this.pluginLoaded_) {
- if (this.previewState_ != PreviewAreaState_.OPEN_IN_PREVIEW)
- this.previewState_ = PreviewAreaState_.DISPLAY_PREVIEW;
- this.fire('preview-loaded');
- }
},
type => {
if (/** @type{string} */ (type) == 'SETTINGS_INVALID') {
- this.previewState_ = PreviewAreaState_.INVALID_SETTINGS;
- this.fire('invalid-printer');
+ this.previewState =
+ print_preview_new.PreviewAreaState.INVALID_SETTINGS;
} else if (/** @type{string} */ (type) != 'CANCELLED') {
- this.previewState_ = PreviewAreaState_.PREVIEW_FAILED;
- this.fire('preview-failed');
+ this.previewState =
+ print_preview_new.PreviewAreaState.PREVIEW_FAILED;
}
});
},
/** @private */
onStateChanged_: function() {
- switch (this.state) {
- case (print_preview_new.State.NOT_READY):
- // Resetting the destination clears the invalid settings error.
- this.previewState_ = PreviewAreaState_.LOADING;
- break;
- case (print_preview_new.State.READY):
- // Request a new preview.
- if (this.requestPreviewWhenReady_) {
- this.startPreview_();
- this.requestPreviewWhenReady_ = false;
- }
- break;
- case (print_preview_new.State.INVALID_PRINTER):
- if (this.previewState_ != PreviewAreaState_.INVALID_SETTINGS)
- this.previewState_ = PreviewAreaState_.UNSUPPORTED_CLOUD_PRINTER;
- break;
- default:
- break;
+ if (this.state == print_preview_new.State.READY &&
+ this.requestPreviewWhenReady_) {
+ this.startPreview_();
+ this.requestPreviewWhenReady_ = false;
}
},
@@ -319,7 +366,10 @@ Polymer({
/** Set the preview state to display the "opening in preview" message. */
setOpeningPdfInPreview: function() {
assert(cr.isMac);
- this.previewState_ = PreviewAreaState_.OPEN_IN_PREVIEW;
+ this.previewState =
+ this.previewState == print_preview_new.PreviewAreaState.LOADING ?
+ print_preview_new.PreviewAreaState.OPEN_IN_PREVIEW_LOADING :
+ print_preview_new.PreviewAreaState.OPEN_IN_PREVIEW_LOADED;
},
// </if>
@@ -405,11 +455,6 @@ Polymer({
*/
onPluginLoad_: function() {
this.pluginLoaded_ = true;
- if (this.documentReady_) {
- if (this.previewState_ != PreviewAreaState_.OPEN_IN_PREVIEW)
- this.previewState_ = PreviewAreaState_.DISPLAY_PREVIEW;
- this.fire('preview-loaded');
- }
},
/**
@@ -574,6 +619,49 @@ Polymer({
this.i18n('gcpCertificateErrorLearnMoreURL'));
},
+ /** @private */
+ onMarginsChanged_: function() {
+ if (this.getSettingValue('margins') !=
+ print_preview.ticket_items.MarginsTypeValue.CUSTOM) {
+ this.lastCustomMargins_ = null;
+ this.onSettingsChanged_();
+ } else {
+ this.lastCustomMargins_ =
+ /** @type {!print_preview.MarginsSetting} */ (
+ this.getSettingValue('customMargins'));
+ }
+ },
+
+ /** @private */
+ onCustomMarginsChanged_: function() {
+ const newValue =
+ /** @type {!print_preview.MarginsSetting} */ (
+ this.getSettingValue('customMargins'));
+ if (!!this.lastCustomMargins_ &&
+ this.getSettingValue('margins') ==
+ print_preview.ticket_items.MarginsTypeValue.CUSTOM &&
+ (this.lastCustomMargins_.marginTop != newValue.marginTop ||
+ this.lastCustomMargins_.marginLeft != newValue.marginLeft ||
+ this.lastCustomMargins_.marginRight != newValue.marginRight ||
+ this.lastCustomMargins_.marginBottom != newValue.marginBottom)) {
+ this.onSettingsChanged_();
+ }
+ this.lastCustomMargins_ = newValue;
+ },
+
+ /** @private */
+ onMediaSizeChanged_: function() {
+ const newValue =
+ /** @type {!print_preview_new.MediaSizeValue} */ (
+ this.getSettingValue('mediaSize'));
+ if (!!this.lastMediaSize_ &&
+ (newValue.height_microns != this.lastMediaSize_.height_microns ||
+ newValue.width_microns != this.lastMediaSize_.width_microns)) {
+ this.onSettingsChanged_();
+ }
+ this.lastMediaSize_ = newValue;
+ },
+
/**
* Requests a preview from the native layer.
* @return {!Promise} Promise that resolves when the preview has been
@@ -593,10 +681,10 @@ Polymer({
/** @type {boolean} */ (this.getSettingValue('color'))),
headerFooterEnabled: this.getSettingValue('headerFooter'),
marginsType: this.getSettingValue('margins'),
+ pagesPerSheet: this.getSettingValue('pagesPerSheet'),
isFirstRequest: this.inFlightRequestId_ == 0,
requestID: this.inFlightRequestId_,
previewModifiable: this.documentInfo.isModifiable,
- generateDraftData: this.documentInfo.isModifiable,
fitToPageEnabled: this.getSettingValue('fitToPage'),
scaleFactor: parseInt(this.getSettingValue('scaling'), 10),
shouldPrintBackgrounds: this.getSettingValue('cssBackground'),
@@ -629,12 +717,6 @@ Polymer({
print_preview.ticket_items.MarginsTypeValue.CUSTOM) {
ticket.marginsCustom = this.getSettingValue('customMargins');
}
- let pageCount = -1;
- if (this.inFlightRequestId_ > 0) {
- pageCount = this.documentInfo.isModifiable ?
- this.documentInfo.pageCount : 0;
- }
- return this.nativeLayer_.getPreview(JSON.stringify(ticket), pageCount);
+ return this.nativeLayer_.getPreview(JSON.stringify(ticket));
},
});
-})();
diff --git a/chromium/chrome/browser/resources/print_preview/new/provisional_destination_resolver.html b/chromium/chrome/browser/resources/print_preview/new/provisional_destination_resolver.html
new file mode 100644
index 00000000000..df3927214aa
--- /dev/null
+++ b/chromium/chrome/browser/resources/print_preview/new/provisional_destination_resolver.html
@@ -0,0 +1,86 @@
+<link rel="import" href="chrome://resources/html/polymer.html">
+
+<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
+<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html">
+<link rel="import" href="chrome://resources/html/cr.html">
+<link rel="import" href="chrome://resources/html/i18n_behavior.html">
+<link rel="import" href="../data/destination.html">
+<link rel="import" href="../data/destination_store.html">
+<link rel="import" href="button_css.html">
+<link rel="import" href="print_preview_shared_css.html">
+<link rel="import" href="search_dialog_css.html">
+<link rel="import" href="strings.html">
+<link rel="import" href="throbber_css.html">
+
+<dom-module id="print-preview-provisional-destination-resolver">
+ <template>
+ <style include="print-preview-shared search-dialog button cr-hidden-style throbber">
+ :host #dialog {
+ --cr-dialog-native: {
+ border-radius: 2px;
+ box-shadow: 0 4px 23px 5px rgba(0, 0, 0, 0.2),
+ 0 2px 6px rgba(0, 0, 0, 0.15);
+ width: 360px;
+ };
+ --cr-dialog-top-container-min-height: 35px;
+ }
+
+ :host .throbber-placeholder {
+ height: 16px;
+ margin: 4px;
+ width: 16px;
+ }
+
+ .message {
+ line-height: 1.4rem;
+ margin: 0;
+ padding-bottom: 35px;
+ }
+
+ .extension-desc {
+ display: flex;
+ }
+
+ .extension-icon {
+ background-position: center;
+ background-repeat: none;
+ height: 24px;
+ width: 24px;
+ }
+
+ .extension-name {
+ flex: 1;
+ line-height: 24px;
+ overflow-wrap: break-word;
+ }
+
+ div[slot='button-container'] {
+ margin: 0 3px 10px;
+ }
+ </style>
+ <cr-dialog id="dialog" on-close="onCancel_" show-close-button>
+ <div slot="body">
+ <p class="message">
+ [[getPermissionMessage_(state_, destination_.extensionName)]]
+ </p>
+ <div class="extension-desc" hidden="[[isInErrorState_(state_)]]">
+ <div class$="throbber-placeholder [[getThrobberClass_(state_)]]"
+ role="img" alt=""></div>
+ <div class="extension-icon" role="img" alt=""></div>
+ <div class="extension-name">
+ [[destination_.extensionName]]
+ </div>
+ </div>
+ </div>
+ <div slot="button-container">
+ <button class="cancel" on-click="onCancel_">$i18n{goBackButton}</button>
+ <button class="default" hidden="[[isInErrorState_(state_)]]"
+ disabled="[[!isInActiveState_(state_)]]"
+ on-click="startResolveDestination_">
+ $i18n{selectButton}
+ </button>
+ </div>
+ </cr-dialog>
+ </template>
+ <script src="provisional_destination_resolver.js"></script>
+</dom-module>
diff --git a/chromium/chrome/browser/resources/print_preview/new/provisional_destination_resolver.js b/chromium/chrome/browser/resources/print_preview/new/provisional_destination_resolver.js
new file mode 100644
index 00000000000..16f5f9c0e51
--- /dev/null
+++ b/chromium/chrome/browser/resources/print_preview/new/provisional_destination_resolver.js
@@ -0,0 +1,157 @@
+// 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.
+
+/**
+ * @fileoverview PrintPreviewProvisionalDestinationResolver
+ * This class is a dialog for resolving provisional destinations. Provisional
+ * destinations are extension controlled destinations that need access to a USB
+ * device and have not yet been granted access by the user. Destinations are
+ * resolved when the user confirms they wish to grant access and the handler
+ * has successfully granted access.
+ */
+
+cr.exportPath('print_preview_new');
+
+/**
+ * States that the provisional destination resolver can be in.
+ * @enum {string}
+ */
+print_preview_new.ResolverState = {
+ INITIAL: 'INITIAL',
+ ACTIVE: 'ACTIVE',
+ GRANTING_PERMISSION: 'GRANTING_PERMISSION',
+ ERROR: 'ERROR',
+ DONE: 'DONE'
+};
+
+Polymer({
+ is: 'print-preview-provisional-destination-resolver',
+
+ behaviors: [I18nBehavior],
+
+ properties: {
+ /** @type {?print_preview.DestinationStore} */
+ destinationStore: Object,
+
+ /** @private {?print_preview.Destination} */
+ destination_: {
+ type: Object,
+ value: null,
+ },
+
+ /** @private {!print_preview_new.ResolverState} */
+ state_: {
+ type: String,
+ value: print_preview_new.ResolverState.INITIAL,
+ },
+ },
+
+ /**
+ * Promise resolver for promise returned by {@code this.resolveDestination}.
+ * @private {?PromiseResolver<!print_preview.Destination>}
+ */
+ promiseResolver_: null,
+
+ /**
+ * @param {!print_preview.Destination} destination The destination this
+ * dialog is needed to resolve.
+ * @return {!Promise} Promise that is resolved when the destination has been
+ * resolved.
+ */
+ resolveDestination: function(destination) {
+ this.state_ = print_preview_new.ResolverState.ACTIVE;
+ this.destination_ = destination;
+ this.$.dialog.showModal();
+ const icon = this.$$('.extension-icon');
+ icon.style.backgroundImage = '-webkit-image-set(' +
+ 'url(chrome://extension-icon/' + this.destination_.extensionId +
+ '/24/1) 1x,' +
+ 'url(chrome://extension-icon/' + this.destination_.extensionId +
+ '/48/1) 2x)';
+ this.promiseResolver_ = new PromiseResolver();
+ return this.promiseResolver_.promise;
+ },
+
+ /**
+ * Handler for click on OK button. It attempts to resolve the destination.
+ * If successful, promiseResolver_.promise is resolved with the
+ * resolved destination and the dialog closes.
+ * @private
+ */
+ startResolveDestination_: function() {
+ assert(
+ this.state_ == print_preview_new.ResolverState.ACTIVE,
+ 'Invalid state in request grant permission');
+
+ this.state_ = print_preview_new.ResolverState.GRANTING_PERMISSION;
+ const destination =
+ /** @type {!print_preview.Destination} */ (this.destination_);
+ this.destinationStore.resolveProvisionalDestination(destination)
+ .then(
+ /** @param {?print_preview.Destination} resolvedDestination */
+ (resolvedDestination) => {
+ if (this.state_ !=
+ print_preview_new.ResolverState.GRANTING_PERMISSION) {
+ return;
+ }
+
+ if (destination.id != this.destination_.id)
+ return;
+
+ if (resolvedDestination) {
+ this.state_ = print_preview_new.ResolverState.DONE;
+ this.promiseResolver_.resolve(resolvedDestination);
+ this.promiseResolver_ = null;
+ this.$.dialog.close();
+ } else {
+ this.state_ = print_preview_new.ResolverState.ERROR;
+ }
+ });
+ },
+
+ /** @private */
+ onCancel_: function() {
+ this.promiseResolver_.reject();
+ this.$.dialog.close();
+ this.state_ = print_preview_new.ResolverState.INITIAL;
+ },
+
+ /**
+ * @return {string} The USB permission message to display.
+ * @private
+ */
+ getPermissionMessage_: function() {
+ return this.state_ == print_preview_new.ResolverState.ERROR ?
+ this.i18n(
+ 'resolveExtensionUSBErrorMessage',
+ this.destination_.extensionName) :
+ this.i18n('resolveExtensionUSBPermissionMessage');
+ },
+
+ /**
+ * @return {boolean} Whether the resolver is in the ERROR state.
+ * @private
+ */
+ isInErrorState_: function() {
+ return this.state_ == print_preview_new.ResolverState.ERROR;
+ },
+
+ /**
+ * @return {boolean} Whether the resolver is in the ACTIVE state.
+ * @private
+ */
+ isInActiveState_: function() {
+ return this.state_ == print_preview_new.ResolverState.ACTIVE;
+ },
+
+ /**
+ * @return {string} 'throbber' if the resolver is in the GRANTING_PERMISSION
+ * state, empty otherwise.
+ */
+ getThrobberClass_: function() {
+ return this.state_ == print_preview_new.ResolverState.GRANTING_PERMISSION ?
+ 'throbber' :
+ '';
+ },
+});
diff --git a/chromium/chrome/browser/resources/print_preview/new/scaling_settings.js b/chromium/chrome/browser/resources/print_preview/new/scaling_settings.js
index 977389d25f2..9bbd9ffc089 100644
--- a/chromium/chrome/browser/resources/print_preview/new/scaling_settings.js
+++ b/chromium/chrome/browser/resources/print_preview/new/scaling_settings.js
@@ -2,6 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+cr.exportPath('print_preview_new');
+
+/** @enum {number} */
+print_preview_new.ScalingState = {
+ INIT: 0,
+ VALID: 1,
+ INVALID: 2,
+ FIT_TO_PAGE: 3,
+};
+
+/*
+ * When fit to page is available, the checkbox and input interact as follows:
+ * 1. When checkbox is checked, the fit to page scaling value is displayed in
+ * the input. The error message is cleared if it was present.
+ * 2. When checkbox is unchecked, the most recent valid scale value is restored.
+ * 3. If the input is modified while the checkbox is checked, the checkbox will
+ * be unchecked automatically, regardless of the validity of the new value.
+ */
Polymer({
is: 'print-preview-scaling-settings',
@@ -17,38 +35,73 @@ Polymer({
/** @private {boolean} */
inputValid_: Boolean,
- disabled: Boolean,
- },
+ /** @private {boolean} */
+ hideInput_: Boolean,
- /** @private {string} */
- lastValidScaling_: '100',
+ disabled: Boolean,
- /** @private {number} */
- fitToPageFlag_: 0,
+ /** @private {!print_preview_new.ScalingState} */
+ currentState_: {
+ type: Number,
+ value: print_preview_new.ScalingState.INIT,
+ observer: 'onStateChange_',
+ },
+ },
observers: [
- 'onFitToPageSettingChange_(settings.fitToPage.value, ' +
- 'settings.fitToPage.available, documentInfo.fitToPageScaling)',
+ 'onFitToPageSettingChange_(settings.fitToPage.value)',
+ 'onFitToPageScalingSet_(documentInfo.fitToPageScaling)',
'onInputChanged_(currentValue_, inputValid_)',
'onScalingSettingChanged_(settings.scaling.value)',
+ 'onScalingValidChanged_(settings.scaling.valid)',
],
+ /**
+ * Timeout used to delay processing of the checkbox input.
+ * @private {?number}
+ */
+ fitToPageTimeout_: null,
+
+ /** @private {boolean} */
+ ignoreFtp_: false,
+
+ /** @private {boolean} */
+ ignoreValid_: false,
+
+ /** @private {boolean} */
+ ignoreValue_: false,
+
+ /** @private {string} */
+ lastValidScaling_: '100',
+
+ /** @private {?boolean} */
+ lastFitToPageValue_: null,
+
/** @private */
onFitToPageSettingChange_: function() {
- const fitToPage = this.getSetting('fitToPage');
- if (!fitToPage.available)
+ if (this.ignoreFtp_ || !this.getSetting('fitToPage').available)
+ return;
+
+ const fitToPage = this.getSetting('fitToPage').value;
+
+ if (fitToPage) {
+ this.currentState_ = print_preview_new.ScalingState.FIT_TO_PAGE;
return;
- this.$$('#fit-to-page-checkbox').checked = fitToPage.value;
- if (!fitToPage.value) {
- // Fit to page is no longer checked. Update the display.
- this.currentValue_ = this.lastValidScaling_;
- } else if (fitToPage.value) {
- // Set flag to number of expected calls to onInputChanged_. If scaling
- // is valid, 1 call will occur due to the change to |currentValue_|. If
- // not, 2 calls will occur, since |inputValid_| will also change.
- this.fitToPageFlag_ = this.inputValid_ ? 1 : 2;
- this.currentValue_ = this.documentInfo.fitToPageScaling.toString();
}
+
+ this.currentState_ = this.getSetting('scaling').valid ?
+ print_preview_new.ScalingState.VALID :
+ print_preview_new.ScalingState.INVALID;
+ },
+
+ /** @private */
+ onFitToPageScalingSet_: function() {
+ if (this.currentState_ != print_preview_new.ScalingState.FIT_TO_PAGE)
+ return;
+
+ this.ignoreValue_ = true;
+ this.currentValue_ = this.documentInfo.fitToPageScaling.toString();
+ this.ignoreValue_ = false;
},
/**
@@ -60,6 +113,20 @@ Polymer({
this.lastValidScaling_ =
/** @type {string} */ (this.getSetting('scaling').value);
this.currentValue_ = this.lastValidScaling_;
+ this.currentState_ = print_preview_new.ScalingState.VALID;
+ },
+
+ /**
+ * Updates the state of the UI when scaling validity is set.
+ * @private
+ */
+ onScalingValidChanged_: function() {
+ if (this.ignoreValid_)
+ return;
+
+ this.currentState_ = this.getSetting('scaling').valid ?
+ print_preview_new.ScalingState.VALID :
+ print_preview_new.ScalingState.INVALID;
},
/**
@@ -68,34 +135,36 @@ Polymer({
* @private
*/
onInputChanged_: function() {
- const fitToPage = this.$$('#fit-to-page-checkbox').checked;
- if (fitToPage && this.fitToPageFlag_ == 0) {
- // User modified scaling while fit to page was checked. Uncheck fit to
- // page.
- const wasValid = this.getSetting('scaling').valid;
- if (this.inputValid_ && wasValid)
- this.setSetting('scaling', this.currentValue_);
- else
- this.setSettingValid('scaling', false);
- this.$$('#fit-to-page-checkbox').checked = false;
- this.setSetting('fitToPage', false);
- } else if (fitToPage) {
- // Fit to page was checked and scaling changed as a result.
- this.fitToPageFlag_--;
- this.setSettingValid('scaling', true);
- } else {
- // User modified scaling while fit to page was not checked or
- // scaling setting was set.
- const wasValid = this.getSetting('scaling').valid;
- this.setSettingValid('scaling', this.inputValid_);
- if (this.inputValid_ && wasValid)
- this.setSetting('scaling', this.currentValue_);
- }
+ if (this.ignoreValue_)
+ return;
+
+ this.setSettingValid('scaling', this.inputValid_);
+ if (this.inputValid_)
+ this.setSetting('scaling', this.currentValue_);
},
/** @private */
onFitToPageChange_: function() {
- this.setSetting('fitToPage', this.$$('#fit-to-page-checkbox').checked);
+ const newValue = this.$$('#fit-to-page-checkbox').checked;
+
+ if (this.fitToPageTimeout_ !== null)
+ clearTimeout(this.fitToPageTimeout_);
+
+ this.fitToPageTimeout_ = setTimeout(() => {
+ this.fitToPageTimeout_ = null;
+
+ if (newValue === this.lastFitToPageValue_)
+ return;
+
+ this.lastFitToPageValue_ = newValue;
+ this.setSetting('fitToPage', newValue);
+
+ if (newValue == false)
+ this.currentValue_ = this.lastValidScaling_;
+
+ // For tests only
+ this.fire('update-checkbox-setting', 'fitToPage');
+ }, 100);
},
/**
@@ -105,4 +174,30 @@ Polymer({
getDisabled_: function() {
return this.disabled && this.inputValid_;
},
+
+ /**
+ * @param {!print_preview_new.ScalingState} current
+ * @param {!print_preview_new.ScalingState} previous
+ * @private
+ */
+ onStateChange_: function(current, previous) {
+ if (previous == print_preview_new.ScalingState.FIT_TO_PAGE) {
+ this.ignoreFtp_ = true;
+ this.$$('#fit-to-page-checkbox').checked = false;
+ this.lastFitToPageValue_ = false;
+ this.setSetting('fitToPage', false);
+ this.ignoreFtp_ = false;
+ }
+ if (current == print_preview_new.ScalingState.FIT_TO_PAGE) {
+ if (previous == print_preview_new.ScalingState.INVALID) {
+ this.ignoreValid_ = true;
+ this.setSettingValid('scaling', true);
+ this.ignoreValid_ = false;
+ }
+ this.$$('#fit-to-page-checkbox').checked = true;
+ this.ignoreValue_ = true;
+ this.currentValue_ = this.documentInfo.fitToPageScaling.toString();
+ this.ignoreValue_ = false;
+ }
+ }
});
diff --git a/chromium/chrome/browser/resources/print_preview/new/search_dialog_css.html b/chromium/chrome/browser/resources/print_preview/new/search_dialog_css.html
index 90db69ab4cf..cf41ac97079 100644
--- a/chromium/chrome/browser/resources/print_preview/new/search_dialog_css.html
+++ b/chromium/chrome/browser/resources/print_preview/new/search_dialog_css.html
@@ -13,7 +13,9 @@
background-color: rgba(255, 255, 255, 0.75) for the inner dialog's
backdrop. See context at crbug.com/827397 */
--cr-dialog-close-image: {
+ -webkit-margin-end: 7px;
background-image: url(chrome://theme/IDR_CLOSE_DIALOG);
+ margin-top: 10px;
};
--cr-dialog-close-image-active: {
background-image: url(chrome://theme/IDR_CLOSE_DIALOG_P);
@@ -22,18 +24,31 @@
background-image: url(chrome://theme/IDR_CLOSE_DIALOG_H);
};
--cr-dialog-native: {
+ border-radius: 2px;
box-shadow: 0 4px 23px 5px rgba(0, 0, 0, 0.2),
0 2px 6px rgba(0, 0, 0, 0.15);
};
- --cr-icon-ripple-size: 0;
+ --cr-icon-ripple-size: 14px;
--cr-icon-size: 14px;
+ --cr-dialog-title: {
+ -webkit-padding-end: 16px;
+ -webkit-padding-start: 16px;
+ padding-bottom: 16px;
+ padding-top: 16px;
+ };
--cr-dialog-body: {
+ -webkit-padding-end: 16px;
+ -webkit-padding-start: 16px;
box-sizing: border-box;
+ padding-bottom: 12px;
padding-top: 0;
};
--cr-dialog-wrapper: {
max-height: calc(100vh - 40px);
};
+ --cr-dialog-close-ripple: {
+ display: none;
+ };
}
#searchBox {
@@ -44,6 +59,10 @@
#body {
height: 100vh;
}
+
+ #dialog button {
+ -webkit-margin-start: 10px;
+ }
</style>
</template>
</dom-module>
diff --git a/chromium/chrome/browser/resources/print_preview/new/select_behavior.html b/chromium/chrome/browser/resources/print_preview/new/select_behavior.html
new file mode 100644
index 00000000000..f6ef6283e8e
--- /dev/null
+++ b/chromium/chrome/browser/resources/print_preview/new/select_behavior.html
@@ -0,0 +1,3 @@
+<link rel="import" href="chrome://resources/html/cr.html">
+
+<script src="select_behavior.js"></script>
diff --git a/chromium/chrome/browser/resources/print_preview/new/select_behavior.js b/chromium/chrome/browser/resources/print_preview/new/select_behavior.js
new file mode 100644
index 00000000000..a248f6c958a
--- /dev/null
+++ b/chromium/chrome/browser/resources/print_preview/new/select_behavior.js
@@ -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.
+
+cr.define('print_preview_new', function() {
+ /**
+ * Helper functions for a select with timeout. Implemented by select settings
+ * sections, so that the preview does not immediately begin generating and
+ * freeze the dropdown when the value is changed.
+ * Assumes that the elements implementing this behavior have no more than one
+ * select element.
+ * @polymerBehavior
+ */
+ const SelectBehavior = {
+ /** @private {string} */
+ lastValue_: '',
+
+ /**
+ * Timeout used to delay processing of the selection.
+ * @private {?number}
+ */
+ timeout_: null,
+
+ /** @override */
+ ready: function() {
+ assert(this.shadowRoot.querySelectorAll('select').length == 1);
+ this.$$('select').addEventListener('change', () => {
+ if (this.timeout_) {
+ clearTimeout(this.timeout_);
+ }
+ this.timeout_ = setTimeout(this.onTimeout_.bind(this), 100);
+ });
+ },
+
+ /**
+ * Should be overridden by elements using this behavior to receive select
+ * value updates.
+ * @param {string} value The new select value to process.
+ */
+ onProcessSelectChange: function(value) {},
+
+ /**
+ * Called after a timeout after user selects a new option.
+ * @private
+ */
+ onTimeout_: function() {
+ this.timeout_ = null;
+ const value = /** @type {!HTMLSelectElement} */ (this.$$('select')).value;
+ if (this.lastValue_ != value) {
+ this.lastValue_ = value;
+ this.onProcessSelectChange(value);
+
+ // For testing only
+ this.fire('process-select-change');
+ }
+ },
+ };
+
+ return {SelectBehavior: SelectBehavior};
+});
diff --git a/chromium/chrome/browser/resources/print_preview/new/settings_behavior.js b/chromium/chrome/browser/resources/print_preview/new/settings_behavior.js
index b28e5fcd8ae..d5976f1b498 100644
--- a/chromium/chrome/browser/resources/print_preview/new/settings_behavior.js
+++ b/chromium/chrome/browser/resources/print_preview/new/settings_behavior.js
@@ -37,6 +37,7 @@ print_preview_new.Setting;
* vendorItems: !print_preview_new.Setting,
* otherOptions: !print_preview_new.Setting,
* ranges: !print_preview_new.Setting,
+ * pagesPerSheet: !print_preview_new.Setting,
* }}
*/
print_preview_new.Settings;
@@ -91,8 +92,9 @@ const SettingsBehavior = {
// is no way for the user to change the value in this case.
if (!valid)
assert(setting.available, 'Setting is not available: ' + settingName);
- if (valid != setting.valid)
- this.fire('setting-valid-changed', valid);
+ const shouldFireEvent = valid != setting.valid;
this.set(`settings.${settingName}.valid`, valid);
+ if (shouldFireEvent)
+ this.fire('setting-valid-changed', valid);
}
};
diff --git a/chromium/chrome/browser/resources/print_preview/new/settings_select.html b/chromium/chrome/browser/resources/print_preview/new/settings_select.html
index 9b867bec3b0..45eb62fb630 100644
--- a/chromium/chrome/browser/resources/print_preview/new/settings_select.html
+++ b/chromium/chrome/browser/resources/print_preview/new/settings_select.html
@@ -2,6 +2,7 @@
<link rel="import" href="../print_preview_utils.html">
<link rel="import" href="print_preview_shared_css.html">
+<link rel="import" href="select_behavior.html">
<link rel="import" href="select_css.html">
<link rel="import" href="settings_behavior.html">
@@ -9,7 +10,7 @@
<template>
<style include="print-preview-shared select">
</style>
- <select on-change="onChange_" disabled$="[[disabled]]">
+ <select disabled$="[[disabled]]">
<template is="dom-repeat" items="[[capability.option]]">
<option selected="[[isSelected_(item, selectedValue_)]]"
value="[[getValue_(item)]]">
diff --git a/chromium/chrome/browser/resources/print_preview/new/settings_select.js b/chromium/chrome/browser/resources/print_preview/new/settings_select.js
index 4877620f573..c855e071752 100644
--- a/chromium/chrome/browser/resources/print_preview/new/settings_select.js
+++ b/chromium/chrome/browser/resources/print_preview/new/settings_select.js
@@ -17,7 +17,7 @@ print_preview_new.SelectOption;
Polymer({
is: 'print-preview-settings-select',
- behaviors: [SettingsBehavior],
+ behaviors: [SettingsBehavior, print_preview_new.SelectBehavior],
properties: {
/** @type {{ option: Array<!print_preview_new.SelectOption> }} */
@@ -75,15 +75,15 @@ Polymer({
return displayName || option.name || '';
},
- /** @private */
- onChange_: function() {
- let value = null;
+ /** @param {string} value The new select value. */
+ onProcessSelectChange: function(value) {
+ let newValue = null;
try {
- value = JSON.parse(this.$$('select').value);
+ newValue = JSON.parse(value);
} catch (e) {
assertNotReached();
return;
}
- this.setSetting(this.settingName, /** @type {Object} */ (value));
+ this.setSetting(this.settingName, /** @type {Object} */ (newValue));
},
});
diff --git a/chromium/chrome/browser/resources/print_preview/preview_generator.js b/chromium/chrome/browser/resources/print_preview/preview_generator.js
index 832529cca5f..2d99ffa60bc 100644
--- a/chromium/chrome/browser/resources/print_preview/preview_generator.js
+++ b/chromium/chrome/browser/resources/print_preview/preview_generator.js
@@ -55,14 +55,6 @@ cr.define('print_preview', function() {
this.inFlightRequestId_ = -1;
/**
- * Whether the current in flight request requires generating draft pages
- * for print preview. This is true only for modifiable documents when the
- * print settings has changed sufficiently to require re-rendering.
- * @private {boolean}
- */
- this.generateDraft_ = false;
-
- /**
* Media size to generate preview with. {@code null} indicates default
* size.
* @private {print_preview.ValueType}
@@ -193,7 +185,6 @@ cr.define('print_preview', function() {
this.selectedDestination_ = this.destinationStore_.selectedDestination;
this.inFlightRequestId_++;
- this.generateDraft_ = this.documentInfo_.isModifiable;
return {
id: this.inFlightRequestId_,
request: this.getPreview_(),
@@ -224,7 +215,6 @@ cr.define('print_preview', function() {
isFirstRequest: this.inFlightRequestId_ == 0,
requestID: this.inFlightRequestId_,
previewModifiable: this.documentInfo_.isModifiable,
- generateDraftData: this.generateDraft_,
fitToPageEnabled: printTicketStore.fitToPage.getValue(),
scaleFactor: printTicketStore.scaling.getValueAsNumber(),
// NOTE: Even though the following fields dont directly relate to the
@@ -271,9 +261,7 @@ cr.define('print_preview', function() {
};
}
- const pageCount =
- this.inFlightRequestId_ > 0 ? this.documentInfo_.pageCount : -1;
- return this.nativeLayer_.getPreview(JSON.stringify(ticket), pageCount);
+ return this.nativeLayer_.getPreview(JSON.stringify(ticket));
}
/**
@@ -450,9 +438,9 @@ cr.define('print_preview', function() {
if (this.inFlightRequestId_ != previewResponseId) {
return; // Ignore old response.
}
- if (!this.generateDraft_) {
- // Dispatch a PREVIEW_START event since not generating a draft PDF,
- // which includes print preview for non-modifiable documents, does not
+ if (!this.documentInfo_.isModifiable) {
+ // Dispatch a PREVIEW_START event since not generating a PDF, which
+ // includes print preview for non-modifiable documents, does not
// trigger PAGE_READY events.
this.dispatchPreviewStartEvent_(previewUid, 0);
}
diff --git a/chromium/chrome/browser/resources/print_preview/print_preview.js b/chromium/chrome/browser/resources/print_preview/print_preview.js
index 15f928aaae4..3702bf1cc83 100644
--- a/chromium/chrome/browser/resources/print_preview/print_preview.js
+++ b/chromium/chrome/browser/resources/print_preview/print_preview.js
@@ -1222,7 +1222,7 @@ cr.define('print_preview', function() {
this.nativeLayer_.uiLoadedForTest();
} else {
combobox.value = 'landscape';
- this.layoutSettings_.onSelectChange_();
+ this.layoutSettings_.onSelectChange();
}
},
@@ -1286,7 +1286,7 @@ cr.define('print_preview', function() {
this.nativeLayer_.uiLoadedForTest();
} else if (margins >= 0 && margins < combobox.length) {
combobox.selectedIndex = margins;
- this.marginSettings_.onSelectChange_();
+ this.marginSettings_.onSelectChange();
} else {
this.nativeLayer_.uiFailedLoadingForTest();
}
diff --git a/chromium/chrome/browser/resources/print_preview/print_preview_resources.grd b/chromium/chrome/browser/resources/print_preview/print_preview_resources.grd
index 53c1ef76b60..b3f53d57bb5 100644
--- a/chromium/chrome/browser/resources/print_preview/print_preview_resources.grd
+++ b/chromium/chrome/browser/resources/print_preview/print_preview_resources.grd
@@ -155,7 +155,8 @@
type="chrome_html" />
<structure name="IDR_PRINT_PREVIEW_NEW_PREVIEW_AREA_JS"
file="new/preview_area.js"
- type="chrome_html" />
+ type="chrome_html"
+ preprocess="true" />
<structure name="IDR_PRINT_PREVIEW_NEW_HEADER_HTML"
file="new/header.html"
type="chrome_html" />
@@ -174,6 +175,12 @@
<structure name="IDR_PRINT_PREVIEW_NEW_INPUT_BEHAVIOR_JS"
file="new/input_behavior.js"
type="chrome_html" />
+ <structure name="IDR_PRINT_PREVIEW_NEW_SELECT_BEHAVIOR_HTML"
+ file="new/select_behavior.html"
+ type="chrome_html" />
+ <structure name="IDR_PRINT_PREVIEW_NEW_SELECT_BEHAVIOR_JS"
+ file="new/select_behavior.js"
+ type="chrome_html" />
<structure name="IDR_PRINT_PREVIEW_NEW_STATE_HTML"
file="new/state.html"
type="chrome_html" />
@@ -246,6 +253,12 @@
<structure name="IDR_PRINT_PREVIEW_NEW_SCALING_SETTINGS_JS"
file="new/scaling_settings.js"
type="chrome_html" />
+ <structure name="IDR_PRINT_PREVIEW_NEW_PAGES_PER_SHEET_SETTINGS_HTML"
+ file="new/pages_per_sheet_settings.html"
+ type="chrome_html" />
+ <structure name="IDR_PRINT_PREVIEW_NEW_PAGES_PER_SHEET_SETTINGS_JS"
+ file="new/pages_per_sheet_settings.js"
+ type="chrome_html" />
<structure name="IDR_PRINT_PREVIEW_NEW_OTHER_OPTIONS_SETTINGS_HTML"
file="new/other_options_settings.html"
type="chrome_html" />
@@ -255,6 +268,14 @@
<structure name="IDR_PRINT_PREVIEW_NEW_ADVANCED_OPTIONS_SETTINGS_HTML"
file="new/advanced_options_settings.html"
type="chrome_html" />
+ <structure name="IDR_PRINT_PREVIEW_NEW_MORE_SETTINGS_JS"
+ file="new/more_settings.js"
+ type="chrome_html" />
+ <structure name="IDR_PRINT_PREVIEW_NEW_MORE_SETTINGS_HTML"
+ file="new/more_settings.html"
+ type="chrome_html"
+ flattenhtml="true"
+ allowexternalscript="true" />
<structure name="IDR_PRINT_PREVIEW_NEW_ADVANCED_OPTIONS_SETTINGS_JS"
file="new/advanced_options_settings.js"
type="chrome_html" />
@@ -293,7 +314,8 @@
allowexternalscript="true" />
<structure name="IDR_PRINT_PREVIEW_NEW_DESTINATION_DIALOG_JS"
file="new/destination_dialog.js"
- type="chrome_html" />
+ type="chrome_html"
+ preprocess="true" />
<structure name="IDR_PRINT_PREVIEW_NEW_DESTINATION_LIST_HTML"
file="new/destination_list.html"
type="chrome_html" />
@@ -306,6 +328,13 @@
preprocess="true" />
<structure name="IDR_PRINT_PREVIEW_NEW_DESTINATION_LIST_ITEM_JS"
file="new/destination_list_item.js"
+ type="chrome_html"
+ preprocess="true" />
+ <structure name="IDR_PRINT_PREVIEW_NEW_PROVISIONAL_DESTINATION_RESOLVER_HTML"
+ file="new/provisional_destination_resolver.html"
+ type="chrome_html" />
+ <structure name="IDR_PRINT_PREVIEW_NEW_PROVISIONAL_DESTINATION_RESOLVER_JS"
+ file="new/provisional_destination_resolver.js"
type="chrome_html" />
<structure name="IDR_PRINT_PREVIEW_NEW_PRINT_PREVIEW_SEARCH_BOX_HTML"
file="new/print_preview_search_box.html"
diff --git a/chromium/chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings_item.js b/chromium/chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings_item.js
index 9c54b548ce9..960f277398d 100644
--- a/chromium/chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings_item.js
+++ b/chromium/chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings_item.js
@@ -48,7 +48,7 @@ cr.define('print_preview', function() {
*/
this.searchBubble_ = null;
- /** @private {!EventTracker} */
+ /** @protected {!EventTracker} */
this.tracker_ = new EventTracker();
}
diff --git a/chromium/chrome/browser/resources/print_preview/settings/layout_settings.js b/chromium/chrome/browser/resources/print_preview/settings/layout_settings.js
index ec423d22f94..93246fc3e26 100644
--- a/chromium/chrome/browser/resources/print_preview/settings/layout_settings.js
+++ b/chromium/chrome/browser/resources/print_preview/settings/layout_settings.js
@@ -45,7 +45,7 @@ cr.define('print_preview', function() {
/** @override */
enterDocument: function() {
print_preview.SettingsSection.prototype.enterDocument.call(this);
- this.tracker.add(this.select_, 'change', this.onSelectChange_.bind(this));
+ this.tracker.add(this.select_, 'change', this.onSelectChange.bind(this));
this.tracker.add(
this.landscapeTicketItem_,
print_preview.ticket_items.TicketItem.EventType.CHANGE,
@@ -55,9 +55,8 @@ cr.define('print_preview', function() {
/**
* Called when the select element is changed. Updates the print ticket
* layout selection.
- * @private
*/
- onSelectChange_: function() {
+ onSelectChange: function() {
const select = this.select_;
const isLandscape =
select.options[select.selectedIndex].value == 'landscape';
diff --git a/chromium/chrome/browser/resources/print_preview/settings/margin_settings.js b/chromium/chrome/browser/resources/print_preview/settings/margin_settings.js
index 4e8168d90a6..6af43ad7099 100644
--- a/chromium/chrome/browser/resources/print_preview/settings/margin_settings.js
+++ b/chromium/chrome/browser/resources/print_preview/settings/margin_settings.js
@@ -53,7 +53,7 @@ cr.define('print_preview', function() {
enterDocument: function() {
print_preview.SettingsSection.prototype.enterDocument.call(this);
this.tracker.add(
- assert(this.select_), 'change', this.onSelectChange_.bind(this));
+ assert(this.select_), 'change', this.onSelectChange.bind(this));
this.tracker.add(
this.marginsTypeTicketItem_,
print_preview.ticket_items.TicketItem.EventType.CHANGE,
@@ -62,7 +62,6 @@ cr.define('print_preview', function() {
/**
* @return {HTMLSelectElement} Select element containing the margin options.
- * @private
*/
get select_() {
return this.getElement().getElementsByClassName(
@@ -72,9 +71,8 @@ cr.define('print_preview', function() {
/**
* Called when the select element is changed. Updates the print ticket
* margin type.
- * @private
*/
- onSelectChange_: function() {
+ onSelectChange: function() {
const select = this.select_;
const marginsType =
/** @type {!print_preview.ticket_items.MarginsTypeValue} */ (
diff --git a/chromium/chrome/browser/resources/print_preview/settings/other_options_settings.js b/chromium/chrome/browser/resources/print_preview/settings/other_options_settings.js
index ec3d88b7a63..85c826d8349 100644
--- a/chromium/chrome/browser/resources/print_preview/settings/other_options_settings.js
+++ b/chromium/chrome/browser/resources/print_preview/settings/other_options_settings.js
@@ -138,8 +138,7 @@ cr.define('print_preview', function() {
* @private {boolean} rasterizeEnabled Whether the print as image feature is
* enabled.
*/
- this.rasterizeEnabled_ = (!cr.isWindows && !cr.isMac) &&
- loadTimeData.getBoolean('printPdfAsImageEnabled');
+ this.rasterizeEnabled_ = !cr.isWindows && !cr.isMac;
/**
* @private {!Array<!CheckboxTicketItemElement>} checkbox ticket item
@@ -218,7 +217,10 @@ cr.define('print_preview', function() {
$('rasterize-container').hidden = !this.rasterizeEnabled_;
},
- /** @override */
+ /**
+ * @public
+ * @override
+ */
updateUiStateInternal: function() {
if (this.isAvailable()) {
for (let i = 0; i < this.elements_.length; i++)
diff --git a/chromium/chrome/browser/resources/print_preview/settings/scaling_settings.js b/chromium/chrome/browser/resources/print_preview/settings/scaling_settings.js
index a4174049a4c..5a8e111aa46 100644
--- a/chromium/chrome/browser/resources/print_preview/settings/scaling_settings.js
+++ b/chromium/chrome/browser/resources/print_preview/settings/scaling_settings.js
@@ -176,7 +176,7 @@ cr.define('print_preview', function() {
/** @override */
isSectionVisibleInternal: function() {
return this.fitToPageTicketItem_.isCapabilityAvailable() ||
- (!this.collapseContent_ &&
+ (!this.collapseContent &&
this.scalingTicketItem_.isCapabilityAvailable());
},
diff --git a/chromium/chrome/browser/resources/print_preview/settings/settings_section_select.js b/chromium/chrome/browser/resources/print_preview/settings/settings_section_select.js
index fb20c2d7e06..f752d963d40 100644
--- a/chromium/chrome/browser/resources/print_preview/settings/settings_section_select.js
+++ b/chromium/chrome/browser/resources/print_preview/settings/settings_section_select.js
@@ -76,14 +76,14 @@ cr.define('print_preview', function() {
}
// Should the select content be updated?
const sameContent =
- this.ticketItem_.capability.option.length == select.length &&
- this.ticketItem_.capability.option.every(function(option, index) {
+ this.ticketItem_.capability().option.length == select.length &&
+ this.ticketItem_.capability().option.every(function(option, index) {
return select.options[index].value == JSON.stringify(option);
});
let indexToSelect = select.selectedIndex;
if (!sameContent) {
select.innerHTML = '';
- this.ticketItem_.capability.option.forEach(function(option, index) {
+ this.ticketItem_.capability().option.forEach(function(option, index) {
const selectOption = document.createElement('option');
selectOption.text = this.getCustomDisplayName_(option) ||
this.getDefaultDisplayName_(option);
diff --git a/chromium/chrome/browser/resources/reset_password/BUILD.gn b/chromium/chrome/browser/resources/reset_password/BUILD.gn
new file mode 100644
index 00000000000..1d0f2ebdd55
--- /dev/null
+++ b/chromium/chrome/browser/resources/reset_password/BUILD.gn
@@ -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.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":reset_password",
+ ]
+}
+
+js_library("reset_password") {
+ deps = [
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:util",
+ ]
+ extra_deps = [ "//chrome/browser/ui/webui/reset_password:mojo_bindings_js" ]
+ externs_list = [
+ "$root_gen_dir/chrome/browser/ui/webui/reset_password/reset_password.mojom.externs.js",
+ "$externs_path/mojo.js",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/reset_password/OWNERS b/chromium/chrome/browser/resources/reset_password/OWNERS
new file mode 100644
index 00000000000..f95b8fb48d9
--- /dev/null
+++ b/chromium/chrome/browser/resources/reset_password/OWNERS
@@ -0,0 +1,3 @@
+file://components/safe_browsing/OWNERS
+
+# COMPONENT: Services>Safebrowsing
diff --git a/chromium/chrome/browser/resources/reset_password/reset_password.html b/chromium/chrome/browser/resources/reset_password/reset_password.html
new file mode 100644
index 00000000000..fc5ccb36bcc
--- /dev/null
+++ b/chromium/chrome/browser/resources/reset_password/reset_password.html
@@ -0,0 +1,63 @@
+<!doctype html>
+<html dir="$i18n{textdirection}" lang="$i18n{language}">
+<head>
+ <meta charset="utf-8">
+ <title>$i18n{title}</title>
+ <link rel="stylesheet" href="chrome://resources/css/md_colors.css">
+ <link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css">
+ <link rel="import" href="chrome://resources/html/polymer.html">
+ <link rel="import" href="chrome://resources/cr_elements/icons.html">
+ <link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
+ <link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
+ <link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/color.html">
+ <script src="chrome://resources/js/mojo_bindings.js"></script>
+ <script src="chrome://resources/js/util.js"></script>
+ <script src="reset_password.mojom.js"></script>
+ <script src="reset_password.js"></script>
+ <style>
+ body {
+ background-color: var(--md-background-color);
+ color: var(--google-grey-700);
+ word-wrap: break-word;
+ }
+
+ .primary-button {
+ background: var(--google-blue-500);
+ color: white;
+ margin: 51px auto 0;
+ padding: 4px 24px;
+ }
+
+ .icon {
+ height: 72px;
+ margin: 0 0 40px -8px;
+ width: 72px;
+ }
+
+ .heading {
+ color: var(--paper-grey-900);
+ font-size: 1.6rem;
+ font-weight: normal;
+ line-height: 1.25rem;
+ margin-bottom: 16px;
+ }
+
+ .page-wrapper {
+ line-height: 1.6rem;
+ margin: 14vh auto 0;
+ max-width: 600px;
+ width: 100%;
+ }
+ </style>
+</head>
+<body>
+ <div class="page-wrapper">
+ <iron-icon class="icon" icon="cr:security"></iron-icon>
+ <div class="heading">$i18n{heading}</div>
+ <p>$i18n{primaryParagraph}</p>
+ <paper-button id="reset-password-button" class="primary-button">
+ $i18n{primaryButtonText}
+ </paper-button>
+ </div>
+</body>
+</html>
diff --git a/chromium/chrome/browser/resources/reset_password/reset_password.js b/chromium/chrome/browser/resources/reset_password/reset_password.js
new file mode 100644
index 00000000000..7592942ab9c
--- /dev/null
+++ b/chromium/chrome/browser/resources/reset_password/reset_password.js
@@ -0,0 +1,27 @@
+/* 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. */
+
+'use strict';
+/**
+ * JavaScript for reset_password.html, served from chrome://reset-password/.
+ */
+(function() {
+
+/** @type {mojom.ResetPasswordHandler} */
+var uiHandler;
+
+function initialize() {
+ uiHandler = new mojom.ResetPasswordHandlerPtr;
+ Mojo.bindInterface(
+ mojom.ResetPasswordHandler.name, mojo.makeRequest(uiHandler).handle);
+
+ /** @type {?HTMLElement} */
+ var resetPasswordButton = $('reset-password-button');
+ resetPasswordButton.addEventListener('click', function() {
+ uiHandler.handlePasswordReset();
+ });
+}
+
+document.addEventListener('DOMContentLoaded', initialize);
+})();
diff --git a/chromium/chrome/browser/resources/settings/BUILD.gn b/chromium/chrome/browser/resources/settings/BUILD.gn
index cd940c9f689..46341ba92cd 100644
--- a/chromium/chrome/browser/resources/settings/BUILD.gn
+++ b/chromium/chrome/browser/resources/settings/BUILD.gn
@@ -1,53 +1,173 @@
+# 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("../optimize_webui.gni")
-import("//tools/grit/grit_rule.gni")
import("//chrome/common/features.gni")
+import("//third_party/closure_compiler/compile_js.gni")
+import("//tools/grit/grit_rule.gni")
+import("//ui/webui/webui_features.gni")
+
+if (optimize_webui) {
+ settings_pak_file = "settings_resources.pak"
+ unpak_folder = "settings_resources.unpak"
+
+ optimize_webui("build") {
+ host = "settings"
+ html_in_files = [
+ "settings.html",
+ "lazy_load.html",
+ ]
+ html_out_files = [
+ "vulcanized.html",
+ "lazy_load.vulcanized.html",
+ ]
+ insert_in_head = "<base href=\"chrome://settings\">"
+ input = rebase_path("$target_gen_dir/$unpak_folder", root_build_dir)
+ js_out_files = [
+ "crisper.js",
+ "lazy_load.crisper.js",
+ ]
+
+ deps = [
+ ":unpak",
+ ]
+ }
+
+ unpak("unpak") {
+ pak_file = settings_pak_file
+ out_folder = unpak_folder
+
+ deps = [
+ ":flattened_resources",
+ ]
+ }
+
+ grit("flattened_resources") {
+ source = "settings_resources.grd"
-settings_pak_file = "settings_resources.pak"
-unpak_folder = "settings_resources.unpak"
+ # The .grd contains references to generated files.
+ source_is_generated = true
-optimize_webui("build") {
- host = "settings"
- html_in_files = [
- "settings.html",
- "lazy_load.html",
+ defines = chrome_grit_defines
+ outputs = [
+ "grit/settings_resources.h",
+ "grit/settings_resources_map.cc",
+ "grit/settings_resources_map.h",
+ settings_pak_file,
+ ]
+ output_dir = "$root_gen_dir/chrome/browser/resources/settings"
+ }
+}
+
+group("closure_compile") {
+ deps = [
+ ":settings_resources",
+ "a11y_page:closure_compile",
+ "about_page:closure_compile",
+ "android_apps_page:closure_compile",
+ "animation:closure_compile",
+ "appearance_page:closure_compile",
+ "basic_page:closure_compile",
+ "bluetooth_page:closure_compile",
+ "change_password_page:closure_compile",
+ "chrome_cleanup_page:closure_compile",
+ "clear_browsing_data_dialog:closure_compile",
+ "controls:closure_compile",
+ "date_time_page:closure_compile",
+ "default_browser_page:closure_compile",
+ "device_page:closure_compile",
+ "downloads_page:closure_compile",
+ "incompatible_applications_page:closure_compile",
+ "internet_page:closure_compile",
+ "languages_page:closure_compile",
+ "on_startup_page:closure_compile",
+ "passwords_and_forms_page:closure_compile",
+ "people_page:closure_compile",
+ "prefs:closure_compile",
+ "printing_page:closure_compile",
+ "privacy_page:closure_compile",
+ "reset_page:closure_compile",
+ "search_engines_page:closure_compile",
+ "search_page:closure_compile",
+ "settings_main:closure_compile",
+ "settings_menu:closure_compile",
+ "settings_page:closure_compile",
+ "settings_ui:closure_compile",
+ "site_settings:closure_compile",
+ "site_settings_page:closure_compile",
+ "system_page:closure_compile",
]
- html_out_files = [
- "vulcanized.html",
- "lazy_load.vulcanized.html",
+}
+
+js_type_check("settings_resources") {
+ deps = [
+ ":extension_control_browser_proxy",
+ ":find_shortcut_behavior",
+ ":focus_row_behavior",
+ ":global_scroll_target_behavior",
+ ":lifetime_browser_proxy",
+ ":page_visibility",
+ ":route",
+ ":search_settings",
]
- insert_in_head = "<base href=\"chrome://settings\">"
- input = rebase_path("$target_gen_dir/$unpak_folder", root_build_dir)
- js_out_files = [
- "crisper.js",
- "lazy_load.crisper.js",
+}
+
+js_library("extension_control_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/chrome_send.js" ]
+}
+
+js_library("find_shortcut_behavior") {
+ deps = [
+ "//third_party/polymer/v1_0/components-chromium/iron-a11y-keys-behavior:iron-a11y-keys-behavior-extracted",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
]
+}
+js_library("focus_row_behavior") {
deps = [
- ":unpak",
+ "//ui/webui/resources/js/cr/ui:focus_row",
]
}
-unpak("unpak") {
- pak_file = settings_pak_file
- out_folder = unpak_folder
+js_library("global_scroll_target_behavior") {
+ deps = [
+ ":route",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+js_library("lifetime_browser_proxy") {
deps = [
- ":flattened_resources",
+ "//ui/webui/resources/js:cr",
]
+ externs_list = [ "$externs_path/chrome_send.js" ]
}
-grit("flattened_resources") {
- source = "settings_resources.grd"
+js_library("route") {
+ deps = [
+ ":page_visibility",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+ externs_list = [ "$externs_path/metrics_private.js" ]
+}
- # The .grd contains references to generated files.
- source_is_generated = true
+js_library("page_visibility") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
- defines = chrome_grit_defines
- outputs = [
- "grit/settings_resources.h",
- "grit/settings_resources_map.cc",
- "grit/settings_resources_map.h",
- settings_pak_file,
+js_library("search_settings") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:search_highlight_utils",
]
- output_dir = "$root_gen_dir/chrome/browser/resources/settings"
}
diff --git a/chromium/chrome/browser/resources/settings/a11y_page/BUILD.gn b/chromium/chrome/browser/resources/settings/a11y_page/BUILD.gn
new file mode 100644
index 00000000000..abb609c198d
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/a11y_page/BUILD.gn
@@ -0,0 +1,46 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":a11y_page",
+ ":externs",
+ ":manage_a11y_page",
+ ":tts_subpage",
+ ]
+}
+
+js_library("a11y_page") {
+ deps = [
+ "..:route",
+ "../settings_page:settings_animated_pages",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
+
+js_library("manage_a11y_page") {
+ deps = [
+ "..:route",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
+
+js_library("tts_subpage") {
+ deps = [
+ ":externs",
+ "..:route",
+ "../languages_page:languages_browser_proxy",
+ "../settings_page:settings_animated_pages",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("externs") {
+}
diff --git a/chromium/chrome/browser/resources/settings/a11y_page/a11y_page.html b/chromium/chrome/browser/resources/settings/a11y_page/a11y_page.html
index 02339158d07..3a3255e21b2 100644
--- a/chromium/chrome/browser/resources/settings/a11y_page/a11y_page.html
+++ b/chromium/chrome/browser/resources/settings/a11y_page/a11y_page.html
@@ -52,19 +52,10 @@
<settings-subpage
associated-control="[[$$('#subpage-trigger')]]"
page-title="$i18n{manageTtsSettings}">
- <settings-tts-subpage>
+ <settings-tts-subpage prefs="{{prefs}}">
</settings-tts-subpage>
</settings-subpage>
</template>
- <template is="dom-if"
- route-path="/manageAccessibility/tts/googleTtsEngine">
- <settings-subpage
- associated-control="[[$$('#subpage-trigger')]]"
- page-title="$i18n{googleTextToSpeechSettings}">
- <settings-google-tts-engine-subpage>
- </settings-google-tts-engine-subpage>
- </settings-subpage>
- </template>
</template>
</settings-animated-pages>
</if>
diff --git a/chromium/chrome/browser/resources/settings/a11y_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/a11y_page/compiled_resources2.gyp
deleted file mode 100644
index 6f2151268c3..00000000000
--- a/chromium/chrome/browser/resources/settings/a11y_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'a11y_page',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '../compiled_resources2.gyp:route',
- '../settings_page/compiled_resources2.gyp:settings_animated_pages',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'manage_a11y_page',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(EXTERNS_GYP):settings_private',
- '../compiled_resources2.gyp:route',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'tts_subpage',
- 'dependencies': [
- 'externs',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '../settings_page/compiled_resources2.gyp:settings_animated_pages',
- '../compiled_resources2.gyp:route',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'externs',
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/a11y_page/externs.js b/chromium/chrome/browser/resources/settings/a11y_page/externs.js
index 5734b7a6218..f6ef9bc643f 100644
--- a/chromium/chrome/browser/resources/settings/a11y_page/externs.js
+++ b/chromium/chrome/browser/resources/settings/a11y_page/externs.js
@@ -9,16 +9,21 @@
*/
/**
- * @constructor
+ * Represents a voice as sent from the TTS Handler class. |languageCode| is
+ * the language, not the locale, i.e. 'en' rather than 'en-us'. |name| is the
+ * user-facing voice name, and |id| is the unique ID for that voice name (which
+ * is generated in tts_subpage.js and not passed from tts_handler.cc).
+ * |displayLanguage| is the user-facing display string, i.e. 'English'.
+ * |fullLanguageCode| is the code with locale, i.e. 'en-us' or 'en-gb'.
+ * |languageScore| is a relative measure of how closely the voice's language
+ * matches the app language, and can be used to set a default voice.
+ * @typedef {{languageCode: string, name: string, displayLanguage: string,
+ * extensionId: string, id: string, fullLanguageCode: string,
+ * languageScore: number}}
*/
-Window.prototype.speechSynthesis = function() {};
+let TtsHandlerVoice;
/**
- * @type {function(Object)}
+ * @typedef {{name: string, extensionId: string, optionsPage: string}}
*/
-Window.prototype.speechSynthesis.speak = function(utterance) {};
-
-/**
- * @constructor
- */
-Window.prototype.SpeechSynthesisUtterance = function() {};
+let TtsHandlerExtension;
diff --git a/chromium/chrome/browser/resources/settings/a11y_page/google_tts_engine_subpage.html b/chromium/chrome/browser/resources/settings/a11y_page/google_tts_engine_subpage.html
deleted file mode 100644
index 5de06e2f272..00000000000
--- a/chromium/chrome/browser/resources/settings/a11y_page/google_tts_engine_subpage.html
+++ /dev/null
@@ -1,40 +0,0 @@
-<link rel="import" href="chrome://resources/html/polymer.html">
-
-<link rel="import" href="../controls/settings_slider.html">
-<link rel="import" href="../i18n_setup.html">
-<link rel="import" href="../settings_shared_css.html">
-<link rel="import" href="../settings_vars_css.html">
-
-<dom-module id="settings-google-tts-engine-subpage">
- <template>
- <style include="settings-shared">
- h2 {
- -webkit-padding-start: var(--settings-box-row-padding);
- }
-
- .settings-box {
- -webkit-margin-end: var(--settings-box-row-padding);
- -webkit-margin-start: var(--settings-box-row-indent);
- -webkit-padding-end: 0;
- -webkit-padding-start: 0;
- }
- </style>
- <div class="settings-box block first">
- </div>
-
- <template is="dom-repeat" items="[[voiceList_]]">
- <h2>[[item.language]]</h2>
- <div class="list-frame vertical-list">
- <div class="list-item">
- <div>
- <paper-checkbox hidden="[[item.builtIn]]">
- $i18n{enableTtsVoiceLabel}
- </paper-checkbox>
- <span>[[item.name]]</span>
- </div>
- </div>
- </div>
- </template>
- </template>
- <script src="google_tts_engine_subpage.js"></script>
-</dom-module>
diff --git a/chromium/chrome/browser/resources/settings/a11y_page/google_tts_engine_subpage.js b/chromium/chrome/browser/resources/settings/a11y_page/google_tts_engine_subpage.js
deleted file mode 100644
index 048b4227bc9..00000000000
--- a/chromium/chrome/browser/resources/settings/a11y_page/google_tts_engine_subpage.js
+++ /dev/null
@@ -1,38 +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.
-
-/**
- * @fileoverview 'tts-subpage' is the collapsible section containing
- * text-to-speech settings.
- */
-
-Polymer({
- is: 'settings-google-tts-engine-subpage',
-
- behaviors: [I18nBehavior, WebUIListenerBehavior],
-
- properties: {
- /**
- * List of tts voices.
- * @private {!Array<
- * !{language: string,
- * name: string
- * }>}
- */
- voiceList_: Array
- },
-
- /** @override */
- ready: function() {
- this.addWebUIListener(
- 'google-voice-data-updated', this.onVoicesUpdated_.bind(this));
- chrome.send('getGoogleTtsVoiceData');
- },
-
- /** @private */
- onVoicesUpdated_: function(voices) {
- this.voiceList_ = voices;
- },
-
-});
diff --git a/chromium/chrome/browser/resources/settings/a11y_page/manage_a11y_page.html b/chromium/chrome/browser/resources/settings/a11y_page/manage_a11y_page.html
index b55a80e0e2a..204740a9d79 100644
--- a/chromium/chrome/browser/resources/settings/a11y_page/manage_a11y_page.html
+++ b/chromium/chrome/browser/resources/settings/a11y_page/manage_a11y_page.html
@@ -1,6 +1,7 @@
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html">
+<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html">
<link rel="import" href="../controls/settings_slider.html">
<link rel="import" href="../controls/settings_toggle_button.html">
@@ -57,7 +58,11 @@
<settings-toggle-button
pref="{{prefs.settings.a11y.select_to_speak}}"
label="$i18n{selectToSpeakTitle}"
- sub-label="$i18n{selectToSpeakDescription}">
+ sub-label="[[getSelectToSpeakDescription_(
+ prefs.settings.a11y.select_to_speak.value, hasKeyboard_,
+ '$i18nPolymer{selectToSpeakDisabledDescription}',
+ '$i18nPolymer{selectToSpeakDescription}',
+ '$i18nPolymer{selectToSpeakDescriptionWithoutKeyboard}')]]">
</settings-toggle-button>
<iron-collapse opened="[[prefs.settings.a11y.select_to_speak.value]]">
<div class="settings-box"
@@ -142,7 +147,12 @@
</paper-icon-button-light>
</div>
- <h2>$i18n{keyboardHeading}</h2>
+ <template is="dom-if" if="[[!showExperimentalFeatures_]]">
+ <h2>$i18n{keyboardHeading}</h2>
+ </template>
+ <template is="dom-if" if="[[showExperimentalFeatures_]]">
+ <h2>$i18n{keyboardAndTextInputHeading}</h2>
+ </template>
<settings-toggle-button class="first"
pref="{{prefs.settings.a11y.sticky_keys_enabled}}"
label="$i18n{stickyKeysLabel}">
@@ -151,6 +161,12 @@
pref="{{prefs.settings.a11y.virtual_keyboard}}"
label="$i18n{onScreenKeyboardLabel}">
</settings-toggle-button>
+ <template is="dom-if" if="[[showExperimentalFeatures_]]">
+ <settings-toggle-button class="continuation"
+ pref="{{prefs.settings.a11y.dictation}}"
+ label="$i18n{dictationLabel}">
+ </settings-toggle-button>
+ </template>
<settings-toggle-button class="continuation"
pref="{{prefs.settings.a11y.focus_highlight}}"
label="$i18n{focusHighlightLabel}">
@@ -163,13 +179,16 @@
<settings-toggle-button
pref="{{prefs.settings.a11y.switch_access}}"
label="$i18n{switchAccessLabel}">
- <paper-icon-button-light slot="more-actions" class="icon-settings"
- hidden="[[!prefs.settings.a11y.switch_access.value]]">
- <button on-click="onSwitchAccessSettingsTap_"
- aria-label="$i18n{selectToSpeakOptionsLabel}">
- </button>
- </paper-icon-button-light>
</settings-toggle-button>
+ <iron-collapse opened="[[prefs.settings.a11y.switch_access.value]]">
+ <div class="settings-box" actionable
+ on-click="onSwitchAccessSettingsTap_">
+ <div class="start">$i18n{switchAccessOptionsLabel}</div>
+ <paper-icon-button-light class="icon-external">
+ <button aria-label="$i18n{switchAccessOptionsLabel}"></button>
+ </paper-icon-button-light>
+ </div>
+ </iron-collapse>
</template>
<div class="settings-box two-line" on-click="onKeyboardTap_" actionable>
<div class="start">
diff --git a/chromium/chrome/browser/resources/settings/a11y_page/manage_a11y_page.js b/chromium/chrome/browser/resources/settings/a11y_page/manage_a11y_page.js
index 88fb1bb2402..2466b990bbe 100644
--- a/chromium/chrome/browser/resources/settings/a11y_page/manage_a11y_page.js
+++ b/chromium/chrome/browser/resources/settings/a11y_page/manage_a11y_page.js
@@ -10,6 +10,8 @@
Polymer({
is: 'settings-manage-a11y-page',
+ behaviors: [WebUIListenerBehavior],
+
properties: {
/**
* Preferences state.
@@ -96,6 +98,39 @@ Polymer({
return loadTimeData.getBoolean('isGuest');
}
},
+
+ /**
+ * |hasKeyboard_|starts undefined so observers don't trigger
+ * until it has been populated.
+ * @private
+ */
+ hasKeyboard_: Boolean,
+ },
+
+ /** @override */
+ attached: function() {
+ this.addWebUIListener(
+ 'has-hardware-keyboard', this.set.bind(this, 'hasKeyboard_'));
+ chrome.send('initializeKeyboardWatcher');
+ },
+
+ /**
+ * Updates the Select-to-Speak description text based on:
+ * 1. Whether Select-to-Speak is enabled.
+ * 2. If it is enabled, whether a physical keyboard is present.
+ * @param {boolean} enabled
+ * @param {boolean} hasKeyboard
+ * @param {string} disabledString String to show when Select-to-Speak is
+ * disabled.
+ * @param {string} keyboardString String to show when there is a physical
+ * keyboard
+ * @param {string} noKeyboardString String to show when there is no keyboard
+ * @private
+ */
+ getSelectToSpeakDescription_: function(
+ enabled, hasKeyboard, disabledString, keyboardString, noKeyboardString) {
+ return !enabled ? disabledString :
+ hasKeyboard ? keyboardString : noKeyboardString;
},
/** @private */
diff --git a/chromium/chrome/browser/resources/settings/a11y_page/tts_subpage.html b/chromium/chrome/browser/resources/settings/a11y_page/tts_subpage.html
index b63753a2cc2..ff710a80054 100644
--- a/chromium/chrome/browser/resources/settings/a11y_page/tts_subpage.html
+++ b/chromium/chrome/browser/resources/settings/a11y_page/tts_subpage.html
@@ -1,16 +1,19 @@
<link rel="import" href="chrome://resources/html/polymer.html">
-<link rel="import" href="google_tts_engine_subpage.html">
-<link rel="import" href="../controls/settings_slider.html">
+<link rel="import" href="chrome://resources/html/i18n_behavior.html">
+<link rel="import" href="chrome://resources/html/md_select_css.html">
+<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
+<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
+<link rel="import" href="chrome://resources/polymer/v1_0/paper-input/paper-textarea.html">
+<link rel="import" href="../device_page/display_size_slider.html">
<link rel="import" href="../i18n_setup.html">
+<link rel="import" href="../languages_page/languages_browser_proxy.html">
<link rel="import" href="../settings_shared_css.html">
<link rel="import" href="../settings_vars_css.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-input/paper-textarea.html">
<dom-module id="settings-tts-subpage">
<template>
- <style include="settings-shared">
+ <style include="settings-shared md-select">
h2 {
-webkit-padding-start: var(--settings-box-row-padding);
}
@@ -22,55 +25,103 @@
-webkit-padding-start: 0;
}
</style>
- <h2>$i18n{textToSpeechVoices}</h2>
- <div class="settings-box block first">
- </div>
<h2>$i18n{textToSpeechProperties}</h2>
<div class="settings-box first">
<div class="start">$i18n{textToSpeechRate}</div>
- <settings-slider
+ <display-size-slider
pref="{{prefs.settings.tts.speech_rate}}"
- min="0.2" max="8.0">
- </settings-slider>
+ ticks="[[speechRateTicks_()]]"
+ min-label="$i18n{textToSpeechRateMinimumLabel}"
+ max-label="$i18n{textToSpeechRateMaximumLabel}">
+ </display-size-slider>
</div>
<div class="settings-box continuation">
<div class="start">$i18n{textToSpeechPitch}</div>
- <settings-slider
+ <display-size-slider
pref="{{prefs.settings.tts.speech_pitch}}"
- min="0.2" max="3.0">
- </settings-slider>
+ ticks="[[speechPitchTicks_()]]"
+ min-label="$i18n{textToSpeechPitchMinimumLabel}"
+ max-label="$i18n{textToSpeechPitchMaximumLabel}">
+ </display-size-slider>
</div>
+ <div class="settings-box continuation">
+ <div class="start">$i18n{textToSpeechVolume}</div>
+ <display-size-slider
+ pref="{{prefs.settings.tts.speech_volume}}"
+ ticks="[[speechVolumeTicks_()]]"
+ min-label="$i18n{textToSpeechVolumeMinimumLabel}"
+ max-label="$i18n{textToSpeechVolumeMaximumLabel}">
+ </display-size-slider>
+ </div>
+
<h2>$i18n{textToSpeechPreviewHeading}</h2>
<div class="settings-box first">
<div class="start">
+ $i18n{textToSpeechPreviewVoice}
+ </div>
+ <select id="previewVoice" class="md-select"
+ label="$i18n{textToSpeechPreviewVoice}"
+ value="{{defaultPreviewVoice}}"
+ disabled="[[!hasVoices]]">
+ <template is="dom-repeat" id="previewVoiceOptions"
+ items="[[allVoices]]" as="voice">
+ <!-- TODO: Use a combobox with a search field instead. -->
+ <option value="[[voice.id]]">
+ [[voice.displayLanguage]] - [[voice.name]]
+ </option>
+ </template>
+ </select>
+ </div>
+ <div class="settings-box continuation">
+ <div class="start">
<paper-textarea id="previewInput" type="text"
label="$i18n{textToSpeechPreviewInputLabel}"
always-float-label value="$i18n{textToSpeechPreviewInput}">
</paper-textarea>
</div>
- <paper-button on-click="onPreviewTtsClick_">
+ <paper-button on-click="onPreviewTtsClick_" disabled="[[!hasVoices]]">
$i18n{textToSpeechPreviewPlay}
</paper-button>
</div>
- <h2>$i18n{textToSpeechEngines}</h2>
- <div class="settings-box block first">
- <a href="">$i18n{textToSpeechInstallEngines}</a>
+
+ <h2>$i18n{textToSpeechVoices}</h2>
+ <template is="dom-repeat" items="[[languagesToVoices]]" as="lang"
+ sort="alphabeticalSort_">
+ <div class="settings-box first">
+ <div class="start">
+ [[lang.language]]
+ </div>
+ <settings-dropdown-menu label="[[lang.language]]"
+ pref="{{prefs.settings.tts.lang_to_voice_name}}"
+ pref-key="[[lang.code]]"
+ menu-options="[[menuOptionsForLang_(lang)]]"
+ disabled="[[hasOneLanguage_(lang)]]">
+ </settings-dropdown-menu>
+ </div>
+ </template>
+ <div class="settings-box first" hidden$="[[hasVoices]]">
+ $i18n{textToSpeechNoVoicesMessage}
</div>
- <div class="settings-box two-line"
- on-click="onManageGoogleTtsEngineSettingsClick_"
- actionable>
- <div class="start" id="appearanceSettingsPrimary">
- $i18n{manageGoogleTtsEngineSettings}
- <div class="secondary" id="appearanceSettingsSecondary">
- $i18n{googleTtsEngineSettingsLinkDescription}
+ <h2>$i18n{textToSpeechEngines}</h2>
+ <template is="dom-repeat" items="[[extensions]]" as="extension">
+ <div class="settings-box continuation">
+ <div id="extension_name_[[index]]" class="start">
+ [[extension.name]]
</div>
+ <a href="[[extension.optionsPage]]"
+ tabindex=-1
+ target="_blank"
+ hidden$="[[!extension.optionsPage]]">
+ <paper-button aria-describedby="extension_name_[[index]]">
+ $i18n{settings}
+ </paper-button>
+ </a>
</div>
- <paper-icon-button-light class="subpage-arrow">
- <button aria-labelledby="appearanceSettingsPrimary"
- aria-describedby="appearanceSettingsSecondary"></button>
- </paper-icon-button-light>
+ </template>
+ <div class="settings-box block continuation">
+ <a href="">$i18n{textToSpeechInstallEngines}</a>
</div>
</template>
<script src="tts_subpage.js"></script>
diff --git a/chromium/chrome/browser/resources/settings/a11y_page/tts_subpage.js b/chromium/chrome/browser/resources/settings/a11y_page/tts_subpage.js
index 41673f54d89..ad5c2c5f88c 100644
--- a/chromium/chrome/browser/resources/settings/a11y_page/tts_subpage.js
+++ b/chromium/chrome/browser/resources/settings/a11y_page/tts_subpage.js
@@ -10,6 +10,8 @@
Polymer({
is: 'settings-tts-subpage',
+ behaviors: [WebUIListenerBehavior, I18nBehavior],
+
properties: {
/**
* Preferences state.
@@ -18,20 +20,295 @@ Polymer({
type: Object,
notify: true,
},
+
+ /**
+ * Available languages.
+ * @type {Array<{language: string, code: string, voice: TtsHandlerVoice}>}
+ */
+ languagesToVoices: {
+ type: Array,
+ notify: true,
+ },
+
+ /**
+ * All voices.
+ * @type {Array<TtsHandlerVoice>}
+ */
+ allVoices: {
+ type: Array,
+ value: [],
+ notify: true,
+ },
+
+ /**
+ * Default preview voice.
+ */
+ defaultPreviewVoice: {
+ type: String,
+ notify: true,
+ },
+
+ /**
+ * Whether any voices are loaded.
+ * @type {Boolean}
+ */
+ hasVoices: {
+ type: Boolean,
+ computed: 'hasVoices_(allVoices)',
+ },
},
- /** @private */
- onManageGoogleTtsEngineSettingsClick_: function() {
- settings.navigateTo(settings.routes.MANAGE_GOOGLE_TTS_ENGINE_SETTINGS);
+ /** @override */
+ ready: function() {
+ this.addWebUIListener(
+ 'all-voice-data-updated', this.populateVoiceList_.bind(this));
+ chrome.send('getAllTtsVoiceData');
+ this.addWebUIListener(
+ 'tts-extensions-updated', this.populateExtensionList_.bind(this));
+ chrome.send('getTtsExtensions');
+ },
+
+ /**
+ * Ticks for the Speech Rate slider. Non-linear as we expect people
+ * to want more control near 1.0.
+ * @return Array<{value: number, label: string}>
+ * @private
+ */
+ speechRateTicks_: function() {
+ return Array.from(Array(16).keys()).map(x => {
+ return x <= 4 ?
+ // Linear from rates 0.6 to 1.0
+ this.initTick_(x / 10 + .6) :
+ // Power function above 1.0 gives more control at lower values.
+ this.initTick_(Math.pow(x - 3, 2) / 20 + 1);
+ });
+ },
+
+ /**
+ * Ticks for the Speech Pitch slider. Valid pitches are between 0 and 2,
+ * exclusive of 0.
+ * @return Array<{value: number, label: string}>
+ * @private
+ */
+ speechPitchTicks_: function() {
+ return Array.from(Array(10).keys()).map(x => {
+ return this.initTick_(x * .2 + .2);
+ });
+ },
+
+ /**
+ * Ticks for the Speech Volume slider. Valid volumes are between 0 and
+ * 1 (100%), but volumes lower than .2 are excluded as being too quiet.
+ * The values are linear between .2 and 1.0.
+ * @return Array<{value: number, label: string}>
+ * @private
+ */
+ speechVolumeTicks_: function() {
+ return Array.from(Array(9).keys()).map(x => {
+ return this.initTick_(x * .1 + .2);
+ });
+ },
+
+ /**
+ * Initializes i18n labels for ticks arrays.
+ * @param {number} tick The value to make a tick for.
+ * @return {{value: number, label: string}}
+ * @private
+ */
+ initTick_: function(tick) {
+ let value = (100 * tick).toFixed(0);
+ let label = value === '100' ? this.i18n('defaultPercentage', value) :
+ this.i18n('percentage', value);
+ return {label: label, value: tick};
+ },
+
+ /**
+ * Returns true if any voices are loaded.
+ * @param {!Array<TtsHandlerVoice>} voices
+ * @return {boolean}
+ * @private
+ */
+ hasVoices_: function(voices) {
+ return voices.length > 0;
+ },
+
+ /**
+ * Populates the list of languages and voices for the UI to use in display.
+ * @param {Array<TtsHandlerVoice>} voices
+ * @private
+ */
+ populateVoiceList_: function(voices) {
+ // Build a map of language code to human-readable language and voice.
+ let result = {};
+ let languageCodeMap = {};
+ voices.forEach(voice => {
+ if (!result[voice.languageCode]) {
+ result[voice.languageCode] = {
+ language: voice.displayLanguage,
+ code: voice.languageCode,
+ voices: []
+ };
+ }
+ // Each voice gets a unique ID from its name and extension.
+ voice.id =
+ JSON.stringify({name: voice.name, extension: voice.extensionId});
+ // TODO(katie): Make voices a map rather than an array to enforce
+ // uniqueness, then convert back to an array for polymer repeat.
+ result[voice.languageCode].voices.push(voice);
+ languageCodeMap[voice.fullLanguageCode] = voice.languageCode;
+ });
+ this.updateLangToVoicePrefs_(result);
+ this.set('languagesToVoices', Object.values(result));
+ this.set('allVoices', voices);
+ this.setDefaultPreviewVoiceForLocale_(voices, languageCodeMap);
+ },
+
+ /**
+ * Sets the list of Text-to-Speech extensions for the UI.
+ * @param {Array<TtsHandlerExtension>} extensions
+ * @private
+ */
+ populateExtensionList_: function(extensions) {
+ this.extensions = extensions;
+ },
+
+ /**
+ * A function used for sorting languages alphabetically.
+ * @param {Object} first A languageToVoices array item.
+ * @param {Object} second A languageToVoices array item.
+ * @return {number} The result of the comparison.
+ * @private
+ */
+ alphabeticalSort_: function(first, second) {
+ return first.language.localeCompare(second.language);
+ },
+
+ /**
+ * Tests whether a language has just once voice.
+ * @param {Object} lang A languageToVoices array item.
+ * @return {boolean} True if the item has only one voice.
+ * @private
+ */
+ hasOneLanguage_: function(lang) {
+ return lang['voices'].length == 1;
+ },
+
+ /**
+ * Returns a list of objects that can be used as drop-down menu options for a
+ * language. This is a list of voices in that language.
+ * @param {Object} lang A languageToVoices array item.
+ * @return {Array<Object>} An array of menu options with a value and name.
+ * @private
+ */
+ menuOptionsForLang_: function(lang) {
+ return lang.voices.map(voice => {
+ return {value: voice.id, name: voice.name};
+ });
+ },
+
+ /**
+ * Updates the preferences given the current list of voices.
+ * @param {Object<string, {language: string, code: string,
+ * voices: Array<TtsHandlerVoice>}>} langToVoices
+ * @private
+ */
+ updateLangToVoicePrefs_: function(langToVoices) {
+ if (langToVoices.length == 0)
+ return;
+ let allCodes = new Set(
+ Object.keys(this.prefs.settings['tts']['lang_to_voice_name'].value));
+ for (let code in langToVoices) {
+ // Remove from allCodes, to track what we've found a default for.
+ allCodes.delete(code);
+ let voices = langToVoices[code].voices;
+ let defaultVoiceForLang =
+ this.prefs.settings['tts']['lang_to_voice_name'].value[code];
+ if (!defaultVoiceForLang || defaultVoiceForLang === '') {
+ // Initialize prefs that have no value
+ this.set(
+ 'prefs.settings.tts.lang_to_voice_name.value.' + code,
+ this.getBestVoiceForLocale_(voices));
+ continue;
+ }
+ // See if the set voice ID is in the voices list, in which case we are
+ // done checking this language.
+ if (voices.some(voice => voice.id === defaultVoiceForLang))
+ continue;
+ // Change prefs that point to voices that no longer exist.
+ this.set(
+ 'prefs.settings.tts.lang_to_voice_name.value.' + code,
+ this.getBestVoiceForLocale_(voices));
+ }
+ // If there are any items left in allCodes, they are for languages that are
+ // no longer covered by the UI. We could now delete them from the
+ // lang_to_voice_name pref.
+ for (let code of allCodes) {
+ this.set('prefs.settings.tts.lang_to_voice_name.value.' + code, '');
+ }
+ },
+
+ /**
+ * Sets the voice to show in the preview drop-down as default, based on the
+ * current locale and voice preferences.
+ * @param {Array<TtsHandlerVoice>} allVoices
+ * @param {Object<string, string>} languageCodeMap Mapping from language code
+ * to simple language code without locale.
+ * @private
+ */
+ setDefaultPreviewVoiceForLocale_: function(allVoices, languageCodeMap) {
+ if (!allVoices || allVoices.length == 0)
+ return;
+
+ // Force a synchronous render so that we can set the default.
+ this.$.previewVoiceOptions.render();
+
+ // Set something if nothing exists. This useful for new users where
+ // sometimes browserProxy.getProspectiveUILanguage() does not complete the
+ // callback.
+ if (!this.defaultPreviewVoice)
+ this.set('defaultPreviewVoice', this.getBestVoiceForLocale_(allVoices));
+
+ let browserProxy = settings.LanguagesBrowserProxyImpl.getInstance();
+ browserProxy.getProspectiveUILanguage().then(prospectiveUILanguage => {
+ let result;
+ if (prospectiveUILanguage && prospectiveUILanguage != '' &&
+ languageCodeMap[prospectiveUILanguage]) {
+ let code = languageCodeMap[prospectiveUILanguage];
+ // First try the pref value.
+ result = this.prefs.settings['tts']['lang_to_voice_name'].value[code];
+ }
+ if (!result) {
+ // If it's not a pref value yet, or the prospectiveUILanguage was
+ // missing, try using the voice score.
+ result = this.getBestVoiceForLocale_(allVoices);
+ }
+ this.set('defaultPreviewVoice', result);
+ });
+ },
+
+ /**
+ * Gets the best voice for the app locale.
+ * @param {Array<TtsHandlerVoice>} voices Voices to search through.
+ * @return {string} The ID of the best matching voice in the array.
+ * @private
+ */
+ getBestVoiceForLocale_: function(voices) {
+ let bestScore = -1;
+ let bestVoice = '';
+ voices.forEach((voice) => {
+ if (voice.languageScore > bestScore) {
+ bestScore = voice.languageScore;
+ bestVoice = voice.id;
+ }
+ });
+ return bestVoice;
},
/** @private */
onPreviewTtsClick_: function() {
- let utter = new window.SpeechSynthesisUtterance();
- if (!utter)
- return;
- utter.text = this.$.previewInput.value;
- window.speechSynthesis.speak(utter);
+ chrome.send(
+ 'previewTtsVoice',
+ [this.$.previewInput.value, this.$.previewVoice.value]);
},
});
diff --git a/chromium/chrome/browser/resources/settings/about_page/BUILD.gn b/chromium/chrome/browser/resources/settings/about_page/BUILD.gn
new file mode 100644
index 00000000000..54af5d44b21
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/about_page/BUILD.gn
@@ -0,0 +1,53 @@
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":about_page",
+ ":about_page_browser_proxy",
+ ":channel_switcher_dialog",
+ ":detailed_build_info",
+ ]
+}
+
+js_library("about_page") {
+ deps = [
+ ":about_page_browser_proxy",
+ "..:lifetime_browser_proxy",
+ "..:route",
+ "../settings_page:main_page_behavior",
+ "../settings_page:settings_animated_pages",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:parse_html_subset",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+ externs_list = [ "$externs_path/web_animations.js" ]
+}
+
+js_library("about_page_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/chrome_send.js" ]
+}
+
+js_library("detailed_build_info") {
+ deps = [
+ ":about_page_browser_proxy",
+ "//ui/webui/resources/cr_elements/policy:cr_policy_indicator_behavior",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+}
+
+js_library("channel_switcher_dialog") {
+ deps = [
+ ":about_page_browser_proxy",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/about_page/about_page.html b/chromium/chrome/browser/resources/settings/about_page/about_page.html
index 3595107a9e1..b0a041b6f06 100644
--- a/chromium/chrome/browser/resources/settings/about_page/about_page.html
+++ b/chromium/chrome/browser/resources/settings/about_page/about_page.html
@@ -72,6 +72,10 @@
overflow-x: auto;
}
+ paper-button {
+ white-space: nowrap;
+ }
+
#regulatoryInfo img {
width: 330px;
}
diff --git a/chromium/chrome/browser/resources/settings/about_page/channel_switcher_dialog.html b/chromium/chrome/browser/resources/settings/about_page/channel_switcher_dialog.html
index 32ef3eaaf96..b2daa381021 100644
--- a/chromium/chrome/browser/resources/settings/about_page/channel_switcher_dialog.html
+++ b/chromium/chrome/browser/resources/settings/about_page/channel_switcher_dialog.html
@@ -1,9 +1,9 @@
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_radio_button/cr_radio_button.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-selector/iron-selector.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-radio-button/paper-radio-button.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-radio-group/paper-radio-group.html">
<link rel="import" href="about_page_browser_proxy.html">
<link rel="import" href="../settings_shared_css.html">
@@ -21,17 +21,17 @@
<!-- TODO(dbeam): this can be policy-controlled. Show this in the UI.
https://www.chromium.org/administrators/policy-list-3#ChromeOsReleaseChannel
-->
- <paper-radio-group
+ <paper-radio-group selectable="cr-radio-button"
on-paper-radio-group-changed="onChannelSelectionChanged_">
- <paper-radio-button name="[[browserChannelEnum_.STABLE]]">
+ <cr-radio-button name="[[browserChannelEnum_.STABLE]]">
$i18n{aboutChannelDialogStable}
- </paper-radio-button>
- <paper-radio-button name="[[browserChannelEnum_.BETA]]">
+ </cr-radio-button>
+ <cr-radio-button name="[[browserChannelEnum_.BETA]]">
$i18n{aboutChannelDialogBeta}
- </paper-radio-button>
- <paper-radio-button name="[[browserChannelEnum_.DEV]]">
+ </cr-radio-button>
+ <cr-radio-button name="[[browserChannelEnum_.DEV]]">
$i18n{aboutChannelDialogDev}
- </paper-radio-button>
+ </cr-radio-button>
</paper-radio-group>
<iron-selector id="warningSelector">
<div>
diff --git a/chromium/chrome/browser/resources/settings/about_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/about_page/compiled_resources2.gyp
deleted file mode 100644
index 6e5af3eae99..00000000000
--- a/chromium/chrome/browser/resources/settings/about_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,50 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'about_page',
- 'dependencies': [
- 'about_page_browser_proxy',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:parse_html_subset',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '../compiled_resources2.gyp:lifetime_browser_proxy',
- '../compiled_resources2.gyp:route',
- '../settings_page/compiled_resources2.gyp:main_page_behavior',
- '../settings_page/compiled_resources2.gyp:settings_animated_pages',
- '<(EXTERNS_GYP):web_animations',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'about_page_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):chrome_send',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'detailed_build_info',
- 'dependencies': [
- 'about_page_browser_proxy',
- '<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_indicator_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'channel_switcher_dialog',
- 'dependencies': [
- 'about_page_browser_proxy',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/about_page/detailed_build_info.html b/chromium/chrome/browser/resources/settings/about_page/detailed_build_info.html
index 08ab773cc7c..e0c6761e7be 100644
--- a/chromium/chrome/browser/resources/settings/about_page/detailed_build_info.html
+++ b/chromium/chrome/browser/resources/settings/about_page/detailed_build_info.html
@@ -76,7 +76,9 @@
</div>
<div class="settings-box two-line single-column">
<div>$i18n{aboutCommandLineLabel}</div>
- <div id="command-line" class="secondary">$i18n{aboutCommandLine}</div>
+ <div id="command-line" class="secondary">
+ [[i18n('aboutCommandLine')]]
+ </div>
</div>
<div class="settings-box two-line single-column">
<div>$i18n{aboutBuildDateLabel}</div>
diff --git a/chromium/chrome/browser/resources/settings/android_apps_page/BUILD.gn b/chromium/chrome/browser/resources/settings/android_apps_page/BUILD.gn
new file mode 100644
index 00000000000..4ee22baac6c
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/android_apps_page/BUILD.gn
@@ -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.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":android_apps_browser_proxy",
+ ":android_apps_page",
+ ":android_apps_subpage",
+ ]
+}
+
+js_library("android_apps_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("android_apps_page") {
+ deps = [
+ ":android_apps_browser_proxy",
+ "..:route",
+ "../prefs:prefs_behavior",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
+
+js_library("android_apps_subpage") {
+ deps = [
+ ":android_apps_browser_proxy",
+ "..:route",
+ "../prefs:prefs_behavior",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/android_apps_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/android_apps_page/compiled_resources2.gyp
deleted file mode 100644
index 548dae1cc58..00000000000
--- a/chromium/chrome/browser/resources/settings/android_apps_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'android_apps_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'android_apps_page',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '../prefs/compiled_resources2.gyp:prefs_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(EXTERNS_GYP):settings_private',
- 'android_apps_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'android_apps_subpage',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '../prefs/compiled_resources2.gyp:prefs_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink',
- 'android_apps_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/animation/BUILD.gn b/chromium/chrome/browser/resources/settings/animation/BUILD.gn
new file mode 100644
index 00000000000..b26ab18bdf8
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/animation/BUILD.gn
@@ -0,0 +1,28 @@
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":animation",
+ ":fade_animations",
+ ]
+}
+
+js_library("animation") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js/cr:event_target",
+ ]
+ externs_list = [ "$externs_path/web_animations.js" ]
+}
+
+js_library("fade_animations") {
+ deps = [
+ ":animation",
+ "//third_party/polymer/v1_0/components-chromium/neon-animation:neon-animation-behavior-extracted",
+ ]
+ externs_list = [ "$externs_path/web_animations.js" ]
+}
diff --git a/chromium/chrome/browser/resources/settings/animation/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/animation/compiled_resources2.gyp
deleted file mode 100644
index be9c892fc4c..00000000000
--- a/chromium/chrome/browser/resources/settings/animation/compiled_resources2.gyp
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'animation',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/cr/compiled_resources2.gyp:event_target',
- '<(EXTERNS_GYP):web_animations',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'fade_animations',
- 'dependencies': [
- 'animation',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/neon-animation/compiled_resources2.gyp:neon-animation-behavior-extracted',
- '<(EXTERNS_GYP):web_animations',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/appearance_page/BUILD.gn b/chromium/chrome/browser/resources/settings/appearance_page/BUILD.gn
new file mode 100644
index 00000000000..b116dabd055
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/appearance_page/BUILD.gn
@@ -0,0 +1,76 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":appearance_browser_proxy",
+ ":appearance_fonts_page",
+ ":appearance_page",
+ ":fonts_browser_proxy",
+ ":home_url_input",
+ ]
+}
+
+js_library("appearance_fonts_page") {
+ deps = [
+ ":fonts_browser_proxy",
+ "../controls:settings_dropdown_menu",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+ externs_list = [ "$externs_path/chrome_send.js" ]
+}
+
+js_library("appearance_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+ externs_list = [
+ "$externs_path/chrome_send.js",
+ "$externs_path/management.js",
+ "$externs_path/settings_private.js",
+ ]
+}
+
+js_library("appearance_page") {
+ deps = [
+ ":appearance_browser_proxy",
+ "..:page_visibility",
+ "..:route",
+ "../controls:settings_dropdown_menu",
+ "../settings_page:settings_animated_pages",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+ externs_list = [
+ "$externs_path/settings_private.js",
+ "$externs_path/chrome_send.js",
+ ]
+}
+
+js_library("fonts_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/chrome_send.js" ]
+}
+
+js_library("home_url_input") {
+ deps = [
+ ":appearance_browser_proxy",
+ "../controls:pref_control_behavior",
+ "//ui/webui/resources/cr_elements/policy:cr_policy_indicator_behavior",
+ "//ui/webui/resources/cr_elements/policy:cr_policy_pref_behavior",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
diff --git a/chromium/chrome/browser/resources/settings/appearance_page/appearance_fonts_page.html b/chromium/chrome/browser/resources/settings/appearance_page/appearance_fonts_page.html
index 30194ed4b01..f335b741d5a 100644
--- a/chromium/chrome/browser/resources/settings/appearance_page/appearance_fonts_page.html
+++ b/chromium/chrome/browser/resources/settings/appearance_page/appearance_fonts_page.html
@@ -116,6 +116,7 @@
[[prefs.webkit.webprefs.default_fixed_font_size.value]]px;
font-family:
'[[prefs.webkit.webprefs.fonts.fixed.Zyyy.value]]';">
+ [[prefs.webkit.webprefs.default_font_size.value]]:
$i18n{quickBrownFox}
</div>
</div>
diff --git a/chromium/chrome/browser/resources/settings/appearance_page/appearance_page.html b/chromium/chrome/browser/resources/settings/appearance_page/appearance_page.html
index 0a71ec5e27c..dbe25f50015 100644
--- a/chromium/chrome/browser/resources/settings/appearance_page/appearance_page.html
+++ b/chromium/chrome/browser/resources/settings/appearance_page/appearance_page.html
@@ -41,16 +41,12 @@
* grit expressions and dom-if templates. That leads to a tricky thing
* to style correctly, these are a workaround. */
#themeRow paper-button {
- -webkit-margin-end: 8px;
+ -webkit-margin-end: 20px;
}
#themeRow .separator {
-webkit-margin-start: 0;
}
-
- #useSystem {
- -webkit-margin-start: calc(var(--cr-button-edge-spacing) * -1);
- }
</style>
<settings-animated-pages id="pages" section="appearance"
focus-config="[[focusConfig_]]">
diff --git a/chromium/chrome/browser/resources/settings/appearance_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/appearance_page/compiled_resources2.gyp
deleted file mode 100644
index f69539b2998..00000000000
--- a/chromium/chrome/browser/resources/settings/appearance_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,69 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'appearance_fonts_page',
- 'dependencies': [
- '../controls/compiled_resources2.gyp:settings_dropdown_menu',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '<(EXTERNS_GYP):chrome_send',
- 'fonts_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'appearance_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(EXTERNS_GYP):chrome_send',
- '<(EXTERNS_GYP):management',
- '<(EXTERNS_GYP):settings_private',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'appearance_page',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(EXTERNS_GYP):settings_private',
- '<(EXTERNS_GYP):chrome_send',
- '../compiled_resources2.gyp:route',
- '../controls/compiled_resources2.gyp:settings_dropdown_menu',
- '../settings_page/compiled_resources2.gyp:settings_animated_pages',
- '../compiled_resources2.gyp:page_visibility',
- 'appearance_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'fonts_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):chrome_send',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'home_url_input',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_indicator_behavior',
- '<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_pref_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(EXTERNS_GYP):settings_private',
- '../controls/compiled_resources2.gyp:pref_control_behavior',
- 'appearance_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/basic_page/BUILD.gn b/chromium/chrome/browser/resources/settings/basic_page/BUILD.gn
new file mode 100644
index 00000000000..c1b8501c838
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/basic_page/BUILD.gn
@@ -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.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":basic_page",
+ ]
+}
+
+js_library("basic_page") {
+ deps = [
+ "..:page_visibility",
+ "..:route",
+ "..:search_settings",
+ "../android_apps_page:android_apps_browser_proxy",
+ "../change_password_page:change_password_browser_proxy",
+ "../chrome_cleanup_page:chrome_cleanup_proxy",
+ "../settings_page:main_page_behavior",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/basic_page/basic_page.html b/chromium/chrome/browser/resources/settings/basic_page/basic_page.html
index 80ab0b65c36..d86a5c2f199 100644
--- a/chromium/chrome/browser/resources/settings/basic_page/basic_page.html
+++ b/chromium/chrome/browser/resources/settings/basic_page/basic_page.html
@@ -18,6 +18,7 @@
<link rel="import" href="../android_apps_page/android_apps_browser_proxy.html">
<link rel="import" href="../android_apps_page/android_apps_page.html">
<link rel="import" href="../bluetooth_page/bluetooth_page.html">
+<link rel="import" href="../crostini_page/crostini_page.html">
<link rel="import" href="../device_page/device_page.html">
<link rel="import" href="../internet_page/internet_page.html">
<link rel="import" href="../multidevice_page/multidevice_page.html">
@@ -27,10 +28,6 @@
<link rel="import" href="../default_browser_page/default_browser_page.html">
</if>
-<if expr="_google_chrome and is_win">
-<link rel="import" href="../chrome_cleanup_page/chrome_cleanup_page.html">
-</if>
-
<!-- TODO(michaelpg): Rename to something better than "basic" now that this page
includes both the basic and advanced settings. -->
<dom-module id="settings-basic-page">
@@ -43,9 +40,6 @@
}
#advancedToggle {
- --paper-button: {
- text-transform: none;
- }
@apply --settings-actionable;
align-items: center;
display: flex;
@@ -53,6 +47,7 @@
margin-top: 12px; /* Part of a 48px spacer (33px + 12px + 3px). */
min-height: 32px;
padding: 0 12px;
+ text-transform: none;
}
#secondaryUserBanner {
@@ -124,13 +119,6 @@
</settings-section>
</template>
</if>
-<if expr="_google_chrome and is_win">
- <template is="dom-if" if="[[showChromeCleanup]]" restamp>
- <settings-section section="chromeCleanup">
- <settings-chrome-cleanup-page></settings-chrome-cleanup-page>
- </settings-section>
- </template>
-</if>
<template is="dom-if" if="[[showChangePassword]]" restamp>
<settings-section section="changePassword">
<settings-change-password-page></settings-change-password-page>
@@ -139,7 +127,9 @@
<template is="dom-if" if="[[showPage_(pageVisibility.people)]]" restamp>
<settings-section page-title="$i18n{peoplePageTitle}"
section="people">
- <settings-people-page prefs="{{prefs}}"></settings-people-page>
+ <settings-people-page prefs="{{prefs}}"
+ page-visibility="[[pageVisibility]]">
+ </settings-people-page>
</settings-section>
</template>
<template is="dom-if" if="[[showPage_(pageVisibility.appearance)]]"
@@ -175,6 +165,13 @@
</settings-section>
</template>
<if expr="chromeos">
+ <template is="dom-if" if="[[showCrostini]]" restamp>
+ <settings-section page-title="$i18n{crostiniPageTitle}"
+ section="crostini">
+ <settings-crostini-page prefs="{{prefs}}">
+ </settings-crostini-page>
+ </settings-section>
+ </template>
<template is="dom-if"
if="[[shouldShowAndroidApps_(showAndroidApps, androidAppsInfo, pageVisibility)]]"
restamp>
@@ -308,7 +305,7 @@
restamp>
<settings-section page-title="$i18n{resetPageTitle}"
section="reset">
- <settings-reset-page></settings-reset-page>
+ <settings-reset-page prefs="{{prefs}}"></settings-reset-page>
</settings-section>
</template>
</div>
diff --git a/chromium/chrome/browser/resources/settings/basic_page/basic_page.js b/chromium/chrome/browser/resources/settings/basic_page/basic_page.js
index 9e1869eb199..8a38bda3640 100644
--- a/chromium/chrome/browser/resources/settings/basic_page/basic_page.js
+++ b/chromium/chrome/browser/resources/settings/basic_page/basic_page.js
@@ -29,16 +29,6 @@ Polymer({
/** @type {!AndroidAppsInfo|undefined} */
androidAppsInfo: Object,
- // <if expr="_google_chrome and is_win">
- showChromeCleanup: {
- type: Boolean,
- value: function() {
- return loadTimeData.getBoolean('chromeCleanupEnabled') &&
- !loadTimeData.getBoolean('userInitiatedCleanupsEnabled');
- },
- },
- // </if>
-
showChangePassword: {
type: Boolean,
value: false,
@@ -110,12 +100,6 @@ Polymer({
attached: function() {
this.currentRoute_ = settings.getCurrentRoute();
- // <if expr="_google_chrome and is_win">
- this.addEventListener('chrome-cleanup-dismissed', () => {
- this.showChromeCleanup = false;
- });
- // </if>
-
this.addWebUIListener('change-password-visibility', visibility => {
this.showChangePassword = visibility;
});
diff --git a/chromium/chrome/browser/resources/settings/basic_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/basic_page/compiled_resources2.gyp
deleted file mode 100644
index a984890d1c0..00000000000
--- a/chromium/chrome/browser/resources/settings/basic_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'basic_page',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '../android_apps_page/compiled_resources2.gyp:android_apps_browser_proxy',
- '../change_password_page/compiled_resources2.gyp:change_password_browser_proxy',
- '../chrome_cleanup_page/compiled_resources2.gyp:chrome_cleanup_proxy',
- '../compiled_resources2.gyp:route',
- '../compiled_resources2.gyp:search_settings',
- '../settings_page/compiled_resources2.gyp:main_page_behavior',
- '../compiled_resources2.gyp:page_visibility',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/bluetooth_page/BUILD.gn b/chromium/chrome/browser/resources/settings/bluetooth_page/BUILD.gn
new file mode 100644
index 00000000000..4f962207b62
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/bluetooth_page/BUILD.gn
@@ -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.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":bluetooth_device_list_item",
+ ":bluetooth_page",
+ ":bluetooth_subpage",
+ ]
+}
+
+js_library("bluetooth_page") {
+ deps = [
+ "..:route",
+ "../prefs:prefs_behavior",
+ "../settings_page:settings_animated_pages",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+ externs_list = [
+ "$externs_path/bluetooth.js",
+ "$externs_path/bluetooth_private.js",
+ ]
+ extra_sources = [
+ "$interfaces_path/bluetooth_interface.js",
+ "$interfaces_path/bluetooth_private_interface.js",
+ ]
+}
+
+js_library("bluetooth_subpage") {
+ deps = [
+ "..:route",
+ "//ui/webui/resources/cr_elements:cr_scrollable_behavior",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+ externs_list = [
+ "$externs_path/bluetooth.js",
+ "$externs_path/bluetooth_private.js",
+ ]
+ extra_sources = [
+ "$interfaces_path/bluetooth_interface.js",
+ "$interfaces_path/bluetooth_private_interface.js",
+ ]
+}
+
+js_library("bluetooth_device_list_item") {
+ deps = [
+ "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+ externs_list = [ "$externs_path/bluetooth.js" ]
+}
diff --git a/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.html b/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.html
index e5d2cb8f3b2..e27189516ce 100644
--- a/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.html
+++ b/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.html
@@ -1,9 +1,9 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_pref_indicator.html">
<link rel="import" href="chrome://resources/polymer/v1_0/neon-animation/neon-animatable.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-toggle-button/paper-toggle-button.html">
<link rel="import" href="../i18n_setup.html">
<link rel="import" href="../icons.html">
<link rel="import" href="../prefs/prefs.html">
@@ -43,13 +43,12 @@
</paper-icon-button-light>
</template>
<div class="separator"></div>
- <paper-toggle-button id="enableBluetooth"
+ <cr-toggle id="enableBluetooth"
checked="{{bluetoothToggleState_}}"
disabled$=
"[[!isToggleEnabled_(adapterState_, stateChangeInProgress_)]]"
- on-click="stopTap_"
aria-label="$i18n{bluetoothToggleA11yLabel}">
- </paper-toggle-button>
+ </cr-toggle>
</div>
</neon-animatable>
diff --git a/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js b/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js
index 73b88de9676..8b67451e0f7 100644
--- a/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js
+++ b/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js
@@ -192,14 +192,6 @@ Polymer({
* @param {!Event} e
* @private
*/
- stopTap_: function(e) {
- e.stopPropagation();
- },
-
- /**
- * @param {!Event} e
- * @private
- */
onSubpageArrowTap_: function(e) {
this.openSubpage_();
e.stopPropagation();
diff --git a/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.html b/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.html
index 018a505ac33..a8de15811b6 100644
--- a/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.html
+++ b/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.html
@@ -2,10 +2,10 @@
<link rel="import" href="chrome://resources/cr_components/chromeos/bluetooth_dialog.html">
<link rel="import" href="chrome://resources/cr_elements/cr_scrollable_behavior.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-list/iron-list.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-spinner/paper-spinner-lite.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-toggle-button/paper-toggle-button.html">
<link rel="import" href="../i18n_setup.html">
<link rel="import" href="../icons.html">
<link rel="import" href="../settings_shared_css.html">
@@ -44,12 +44,11 @@
[[getOnOffString_(bluetoothToggleState,
'$i18nPolymer{deviceOn}', '$i18nPolymer{deviceOff}')]]
</div>
- <paper-toggle-button id="enableBluetooth"
+ <cr-toggle id="enableBluetooth"
checked="{{bluetoothToggleState}}"
disabled$="[[!isToggleEnabled_(adapterState, stateChangeInProgress)]]"
- aria-label="$i18n{bluetoothToggleA11yLabel}"
- on-click="stopTap_">
- </paper-toggle-button>
+ aria-label="$i18n{bluetoothToggleA11yLabel}">
+ </cr-toggle>
</div>
<!-- Paired device list -->
diff --git a/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.js b/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.js
index 6890575195c..476a45012b2 100644
--- a/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.js
+++ b/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.js
@@ -370,14 +370,6 @@ Polymer({
* @param {!Event} event
* @private
*/
- stopTap_: function(event) {
- event.stopPropagation();
- },
-
- /**
- * @param {!Event} event
- * @private
- */
onEnableTap_: function(event) {
if (this.isToggleEnabled_())
this.bluetoothToggleState = !this.bluetoothToggleState;
diff --git a/chromium/chrome/browser/resources/settings/bluetooth_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/bluetooth_page/compiled_resources2.gyp
deleted file mode 100644
index 975856e1a61..00000000000
--- a/chromium/chrome/browser/resources/settings/bluetooth_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,45 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'bluetooth_page',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '../prefs/compiled_resources2.gyp:prefs_behavior',
- '../settings_page/compiled_resources2.gyp:settings_animated_pages',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(EXTERNS_GYP):bluetooth',
- '<(EXTERNS_GYP):bluetooth_private',
- '<(INTERFACES_GYP):bluetooth_interface',
- '<(INTERFACES_GYP):bluetooth_private_interface',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'bluetooth_subpage',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '<(DEPTH)/ui/webui/resources/cr_elements/compiled_resources2.gyp:cr_scrollable_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(EXTERNS_GYP):bluetooth',
- '<(EXTERNS_GYP):bluetooth_private',
- '<(INTERFACES_GYP):bluetooth_interface',
- '<(INTERFACES_GYP):bluetooth_private_interface',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'bluetooth_device_list_item',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(EXTERNS_GYP):bluetooth',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_action_menu/compiled_resources2.gyp:cr_action_menu',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/change_password_page/BUILD.gn b/chromium/chrome/browser/resources/settings/change_password_page/BUILD.gn
new file mode 100644
index 00000000000..183eb500816
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/change_password_page/BUILD.gn
@@ -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.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":change_password_browser_proxy",
+ ":change_password_page",
+ ]
+}
+
+js_library("change_password_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("change_password_page") {
+ deps = [
+ ":change_password_browser_proxy",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:util",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
diff --git a/chromium/chrome/browser/resources/settings/change_password_page/change_password_page.html b/chromium/chrome/browser/resources/settings/change_password_page/change_password_page.html
index ceaae386226..03202adfbb5 100644
--- a/chromium/chrome/browser/resources/settings/change_password_page/change_password_page.html
+++ b/chromium/chrome/browser/resources/settings/change_password_page/change_password_page.html
@@ -35,7 +35,7 @@
</style>
<div class="settings-box first top-aligned-settings-box">
<div class="icon-container">
- <iron-icon icon="$i18n{changePasswordPageIcon}"
+ <iron-icon icon="cr:security"
class="change-password-icon"></iron-icon>
</div>
<div class="start">
@@ -45,7 +45,7 @@
</div>
</div>
<div class="separator"></div>
- <paper-button class="primary-button" id="changePassword"
+ <paper-button class="action-button" id="changePassword"
on-click="changePassword_">
$i18n{changePasswordPageButton}
</paper-button>
diff --git a/chromium/chrome/browser/resources/settings/change_password_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/change_password_page/compiled_resources2.gyp
deleted file mode 100644
index 64476e15c62..00000000000
--- a/chromium/chrome/browser/resources/settings/change_password_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'change_password_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'change_password_page',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '<(EXTERNS_GYP):settings_private',
- 'change_password_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/chrome_cleanup_page/BUILD.gn b/chromium/chrome/browser/resources/settings/chrome_cleanup_page/BUILD.gn
new file mode 100644
index 00000000000..e300b7d3bea
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/chrome_cleanup_page/BUILD.gn
@@ -0,0 +1,40 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":chrome_cleanup_page",
+ ":chrome_cleanup_proxy",
+ ":items_to_remove_list",
+ ]
+}
+
+js_library("chrome_cleanup_proxy") {
+ deps = [
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("chrome_cleanup_page") {
+ deps = [
+ ":chrome_cleanup_proxy",
+ "//ui/webui/resources/cr_elements/cr_expand_button:cr_expand_button",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:util",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
+
+js_library("items_to_remove_list") {
+ deps = [
+ ":chrome_cleanup_proxy",
+ "//ui/webui/resources/js:cr",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.html b/chromium/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.html
index d0cb57647aa..7e00642939c 100644
--- a/chromium/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.html
+++ b/chromium/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.html
@@ -1,8 +1,8 @@
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/cr_expand_button/cr_expand_button.html">
+<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_pref_indicator.html">
<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html">
-<link rel="import" href="chrome://resources/html/util.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-collapse/iron-collapse.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
@@ -23,9 +23,6 @@
height: 20px;
width: 20px;
}
- #learn-more {
- -webkit-margin-start: 0;
- }
#powered-by-settings-box {
min-height: 1em;
@@ -67,7 +64,7 @@
}
.top-aligned-settings-box {
- align-items: start;
+ align-items: center;
/* override settings-box min-height since we use vertical padding */
min-height: 0;
padding: 15px var(--settings-box-row-padding);
@@ -87,17 +84,15 @@
<div role="status">[[title_]]</div>
<div hidden="[[!showExplanation_]]">
<span class="secondary">[[explanation_]]</span>
- <a id="learn-more" href="$i18n{chromeCleanupLearnMoreUrl}"
- on-click="learnMore_" target="_blank"
- hidden="[[!showLearnMore_]]">
- $i18n{learnMore}
- </a>
</div>
</div>
+ <cr-policy-pref-indicator
+ pref="[[prefs.software_reporter.enabled]]">
+ </cr-policy-pref-indicator>
<template is="dom-if" if="[[showActionButton_]]">
<div class="separator"></div>
- <paper-button id="action-button" class="primary-button"
- on-click="proceed_">
+ <paper-button id="action-button" class="action-button"
+ disabled$="[[!cleanupEnabled_]]" on-click="proceed_">
[[actionButtonLabel_]]
</paper-button>
</template>
@@ -106,9 +101,7 @@
id="chromeCleanupLogsUploadControl"
label="$i18n{chromeCleanupLogsUploadPermission}"
pref="[[logsUploadPref_]]"
- sub-label="[[getLogsPermissionSubLabel_(
- '$i18nPolymer{chromeCleanupTitleLogsPermissionExplanation}',
- userInitiatedCleanupsEnabled_)]]"
+ sub-label="$i18n{chromeCleanupTitleLogsPermissionExplanation}"
on-settings-boolean-control-change="changeLogsPermission_">
</settings-toggle-button>
<div id="show-items-button" class="settings-box" actionable
@@ -123,9 +116,7 @@
<items-to-remove-list
id="files-to-remove-list"
hidden="[[!hasFilesToShow_]]"
- title-visible="[[userInitiatedCleanupsEnabled_]]"
title="$i18n{chromeCleanupDetailsFilesAndPrograms}"
- initially-expanded="[[!userInitiatedCleanupsEnabled_]]"
items-to-show="[[scannerResults_.files]]">
</items-to-remove-list>
<items-to-remove-list
diff --git a/chromium/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.js b/chromium/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.js
index b1a523f8e1c..86ce99ef641 100644
--- a/chromium/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.js
+++ b/chromium/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.js
@@ -21,24 +21,10 @@ settings.ChromeCleanupIdleReason = {
};
/**
- * The source of the dismiss action. Used when reporting metrics about how the
- * card was dismissed. The numeric values must be kept in sync with the
- * definition of ChromeCleanerDismissSource in
- * src/chrome/browser/ui/webui/settings/chrome_cleanup_handler.cc.
- * @enum {number}
- */
-settings.ChromeCleanupDismissSource = {
- OTHER: 0,
- CLEANUP_SUCCESS_DONE_BUTTON: 1,
- CLEANUP_FAILURE_DONE_BUTTON: 2,
-};
-
-/**
* The possible states for the cleanup card.
* @enum {string}
*/
settings.ChromeCleanerCardState = {
- HIDDEN_CARD: 'hidden',
SCANNING_OFFERED: 'scanning_offered',
SCANNING: 'scanning',
CLEANUP_OFFERED: 'cleanup_offered',
@@ -58,9 +44,8 @@ settings.ChromeCleanerCardState = {
settings.ChromeCleanupCardFlags = {
NONE: 0,
SHOW_LOGS_PERMISSIONS: 1 << 0,
- SHOW_LEARN_MORE: 1 << 1,
- WAITING_FOR_RESULT: 1 << 2,
- SHOW_ITEMS_TO_REMOVE: 1 << 3,
+ WAITING_FOR_RESULT: 1 << 1,
+ SHOW_ITEMS_TO_REMOVE: 1 << 2,
};
/**
@@ -126,11 +111,8 @@ Polymer({
behaviors: [I18nBehavior, WebUIListenerBehavior],
properties: {
- /** @private */
- userInitiatedCleanupsEnabled_: {
- type: Boolean,
- value: false,
- },
+ /** Preferences state. */
+ prefs: Object,
/** @private */
title_: {
@@ -157,6 +139,12 @@ Polymer({
},
/** @private */
+ cleanupEnabled_: {
+ type: Boolean,
+ value: true,
+ },
+
+ /** @private */
actionButtonLabel_: {
type: String,
value: '',
@@ -168,16 +156,6 @@ Polymer({
computed: 'computeShowExplanation_(explanation_)',
},
- /**
- * Learn more should only be visible for the infected, cleaning and error
- * states.
- * @private
- */
- showLearnMore_: {
- type: Boolean,
- value: false,
- },
-
/** @private */
showLogsPermission_: {
type: Boolean,
@@ -226,8 +204,7 @@ Polymer({
/** @private */
hasRegistryKeysToShow_: {
type: Boolean,
- computed: 'computeHasRegistryKeysToShow_(' +
- 'userInitiatedCleanupsEnabled_, scannerResults_)',
+ computed: 'computeHasRegistryKeysToShow_(scannerResults_)',
},
/** @private */
@@ -286,8 +263,6 @@ Polymer({
/** @override */
attached: function() {
- this.userInitiatedCleanupsEnabled_ =
- loadTimeData.getBoolean('userInitiatedCleanupsEnabled');
this.browserProxy_ = settings.ChromeCleanupProxyImpl.getInstance();
this.cardStateToComponentsMap_ = this.buildCardStateToComponentsMap_();
@@ -304,10 +279,11 @@ Polymer({
this.addWebUIListener(
'chrome-cleanup-on-reboot-required', this.onRebootRequired_.bind(this));
this.addWebUIListener(
- 'chrome-cleanup-on-dismiss', this.onDismiss_.bind(this));
- this.addWebUIListener(
'chrome-cleanup-upload-permission-change',
this.onUploadPermissionChange_.bind(this));
+ this.addWebUIListener(
+ 'chrome-cleanup-enabled-change',
+ this.onCleanupEnabledChange_.bind(this));
this.browserProxy_.registerChromeCleanerObserver();
},
@@ -317,7 +293,7 @@ Polymer({
* @private
*/
proceed_: function() {
- listenOnce(this, 'transitionend', this.doAction_.bind(this));
+ this.doAction_();
},
getTopSettingsBoxClass_: function(showDetails) {
@@ -325,16 +301,6 @@ Polymer({
},
/**
- * Returns the logs upload permission explanation to be displayed.
- * @param {string} label
- * @return {string}
- * @private
- */
- getLogsPermissionSubLabel_: function(label) {
- return this.userInitiatedCleanupsEnabled_ ? label : '';
- },
-
- /**
* Toggles the expand button within the element being listened to.
* @param {!Event} e
* @private
@@ -361,14 +327,6 @@ Polymer({
},
/**
- * Notifies Chrome that the "learn more" link was clicked.
- * @private
- */
- learnMore_: function() {
- this.browserProxy_.notifyLearnMoreClicked();
- },
-
- /**
* @param {string} explanation
* @return {boolean}
* @private
@@ -396,9 +354,8 @@ Polymer({
* @return {boolean}
* @private
*/
- computeHasRegistryKeysToShow_(userInitiatedCleanupsEnabled, scannerResults) {
- return userInitiatedCleanupsEnabled &&
- scannerResults.registryKeys.length > 0;
+ computeHasRegistryKeysToShow_(scannerResults) {
+ return scannerResults.registryKeys.length > 0;
},
/**
@@ -410,24 +367,6 @@ Polymer({
this.ongoingAction_ = settings.ChromeCleanupOngoingAction.NONE;
this.scannerResults_ = this.emptyChromeCleanerScannerResults_;
- // If user-initiated cleanups are disabled, then the card will be shown at
- // the top of the settings page.
- if (!this.userInitiatedCleanupsEnabled_) {
- if (idleReason == settings.ChromeCleanupIdleReason.INITIAL) {
- this.dismiss_(settings.ChromeCleanupDismissSource.OTHER);
- return;
- }
-
- // When user-initiated cleanups are disabled, scanning-related idle
- // reasons are not expected. Show an error message for all reasons other
- // than |CLEANING_SUCCEEDED| and |INITIAL|.
- this.renderCleanupCard_(
- idleReason == settings.ChromeCleanupIdleReason.CLEANING_SUCCEEDED ?
- settings.ChromeCleanerCardState.CLEANUP_SUCCEEDED :
- settings.ChromeCleanerCardState.CLEANING_FAILED);
- return;
- }
-
// Ignore the idle reason and render the scan offered view if no
// interaction happened on this tab.
if (this.renderScanOfferedByDefault_) {
@@ -497,10 +436,7 @@ Polymer({
this.ongoingAction_ = settings.ChromeCleanupOngoingAction.SCANNING;
this.scannerResults_ = this.emptyChromeCleanerScannerResults_;
this.renderScanOfferedByDefault_ = false;
- this.renderCleanupCard_(
- this.userInitiatedCleanupsEnabled_ ?
- settings.ChromeCleanerCardState.SCANNING :
- settings.ChromeCleanerCardState.HIDDEN_CARD);
+ this.renderCleanupCard_(settings.ChromeCleanerCardState.SCANNING);
},
/**
@@ -614,8 +550,6 @@ Polymer({
updateCardFlags_: function(flags) {
this.showLogsPermission_ =
(flags & settings.ChromeCleanupCardFlags.SHOW_LOGS_PERMISSIONS) != 0;
- this.showLearnMore_ =
- (flags & settings.ChromeCleanupCardFlags.SHOW_LEARN_MORE) != 0;
this.isWaitingForResult_ =
(flags & settings.ChromeCleanupCardFlags.WAITING_FOR_RESULT) != 0;
this.showItemsToRemove_ =
@@ -628,44 +562,35 @@ Polymer({
},
/**
- * Listener of event 'chrome-cleanup-dismiss'.
- * Hides the Cleanup card.
- * @private
- */
- onDismiss_: function() {
- this.fire('chrome-cleanup-dismissed');
- },
-
- /**
+ * @param {boolean} managed Whether uploads are controlled by policy or not.
* @param {boolean} enabled Whether logs upload is enabled.
* @private
*/
- onUploadPermissionChange_: function(enabled) {
- this.logsUploadPref_ = {
+ onUploadPermissionChange_: function(managed, enabled) {
+ const pref = {
key: '',
type: chrome.settingsPrivate.PrefType.BOOLEAN,
value: enabled,
};
- },
-
- /** @private */
- changeLogsPermission_: function() {
- const enabled = this.$.chromeCleanupLogsUploadControl.checked;
- this.browserProxy_.setLogsUploadPermission(enabled);
+ if (managed) {
+ pref.enforcement = chrome.settingsPrivate.Enforcement.ENFORCED;
+ pref.controlledBy = chrome.settingsPrivate.ControlledBy.USER_POLICY;
+ }
+ this.logsUploadPref_ = pref;
},
/**
- * Dismiss the card.
- * @param {settings.ChromeCleanupDismissSource} source
+ * @param {boolean} enabled Whether cleanup is enabled.
* @private
*/
- dismiss_: function(source) {
- // If user initiated cleanups are enabled, the card won't be shown at the
- // top of the settings page and the dismiss button should never be rendered.
- assert(!this.userInitiatedCleanupsEnabled_);
+ onCleanupEnabledChange_: function(enabled) {
+ this.cleanupEnabled_ = enabled;
+ },
- this.renderCleanupCard_(settings.ChromeCleanerCardState.HIDDEN_CARD);
- this.browserProxy_.dismissCleanupPage(source);
+ /** @private */
+ changeLogsPermission_: function() {
+ const enabled = this.$.chromeCleanupLogsUploadControl.checked;
+ this.browserProxy_.setLogsUploadPermission(enabled);
},
/**
@@ -673,8 +598,6 @@ Polymer({
* @private
*/
startScanning_: function() {
- assert(this.userInitiatedCleanupsEnabled_);
-
this.browserProxy_.startScanning(
this.$.chromeCleanupLogsUploadControl.checked);
},
@@ -704,15 +627,11 @@ Polymer({
*/
updateShowItemsLinklabel_: function() {
const setShowItemsLabel = text => this.showItemsLinkLabel_ = text;
- if (this.userInitiatedCleanupsEnabled_) {
- this.browserProxy_
- .getItemsToRemovePluralString(
- this.scannerResults_.files.length +
- this.scannerResults_.registryKeys.length)
- .then(setShowItemsLabel);
- } else {
- setShowItemsLabel(this.i18n('chromeCleanupLinkShowItems'));
- }
+ this.browserProxy_
+ .getItemsToRemovePluralString(
+ this.scannerResults_.files.length +
+ this.scannerResults_.registryKeys.length)
+ .then(setShowItemsLabel);
},
/**
@@ -766,20 +685,6 @@ Polymer({
doAction: this.restartComputer_.bind(this),
},
- DISMISS_CLEANUP_SUCCESS: {
- label: this.i18n('done'),
- doAction: this.dismiss_.bind(
- this,
- settings.ChromeCleanupDismissSource.CLEANUP_SUCCESS_DONE_BUTTON),
- },
-
- DISMISS_CLEANUP_FAILURE: {
- label: this.i18n('done'),
- doAction: this.dismiss_.bind(
- this,
- settings.ChromeCleanupDismissSource.CLEANUP_FAILURE_DONE_BUTTON),
- },
-
TRY_SCAN_AGAIN: {
label: this.i18n('chromeCleanupTitleTryAgainButtonLabel'),
// TODO(crbug.com/776538): do not run the reporter component again.
@@ -788,32 +693,15 @@ Polymer({
},
};
- // If user-initiated cleanups are enabled, there is no need for a custom
- // link to the Help Center article, as all settings page sections contain
- // a help link by default.
- const learnMoreIfUserInitiatedCleanupsDisabled =
- this.userInitiatedCleanupsEnabled_ ?
- 0 :
- settings.ChromeCleanupCardFlags.SHOW_LEARN_MORE;
-
return new Map([
[
- settings.ChromeCleanerCardState.HIDDEN_CARD, {
- title: null,
- icon: null,
- actionButton: null,
- flags: settings.ChromeCleanupCardFlags.NONE,
- }
- ],
- [
settings.ChromeCleanerCardState.CLEANUP_OFFERED, {
title: this.i18n('chromeCleanupTitleRemove'),
explanation: this.i18n('chromeCleanupExplanationRemove'),
icon: icons.SYSTEM,
actionButton: actionButtons.REMOVE,
flags: settings.ChromeCleanupCardFlags.SHOW_LOGS_PERMISSIONS |
- settings.ChromeCleanupCardFlags.SHOW_ITEMS_TO_REMOVE |
- learnMoreIfUserInitiatedCleanupsDisabled,
+ settings.ChromeCleanupCardFlags.SHOW_ITEMS_TO_REMOVE,
}
],
[
@@ -823,7 +711,6 @@ Polymer({
icon: null,
actionButton: null,
flags: settings.ChromeCleanupCardFlags.WAITING_FOR_RESULT |
- learnMoreIfUserInitiatedCleanupsDisabled |
settings.ChromeCleanupCardFlags.SHOW_ITEMS_TO_REMOVE,
}
],
@@ -841,9 +728,7 @@ Polymer({
title: this.i18n('chromeCleanupTitleRemoved'),
explanation: null,
icon: icons.DONE,
- actionButton: this.userInitiatedCleanupsEnabled_ ?
- null :
- actionButtons.DISMISS_CLEANUP_SUCCESS,
+ actionButton: null,
flags: settings.ChromeCleanupCardFlags.NONE,
}
],
@@ -852,10 +737,8 @@ Polymer({
title: this.i18n('chromeCleanupTitleErrorCantRemove'),
explanation: this.i18n('chromeCleanupExplanationCleanupError'),
icon: icons.WARNING,
- actionButton: this.userInitiatedCleanupsEnabled_ ?
- null :
- actionButtons.DISMISS_CLEANUP_FAILURE,
- flags: learnMoreIfUserInitiatedCleanupsDisabled,
+ actionButton: null,
+ flags: settings.ChromeCleanupCardFlags.NONE,
}
],
[
@@ -892,7 +775,7 @@ Polymer({
explanation: this.i18n('chromeCleanupExplanationScanError'),
icon: icons.WARNING,
actionButton: null,
- flags: learnMoreIfUserInitiatedCleanupsDisabled,
+ flags: settings.ChromeCleanupCardFlags.NONE,
}
],
[
@@ -904,7 +787,7 @@ Polymer({
explanation: this.i18n('chromeCleanupExplanationCleanupUnavailable'),
icon: icons.WARNING,
actionButton: actionButtons.TRY_SCAN_AGAIN,
- flags: learnMoreIfUserInitiatedCleanupsDisabled,
+ flags: settings.ChromeCleanupCardFlags.NONE,
},
],
]);
diff --git a/chromium/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_proxy.js b/chromium/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_proxy.js
index c92b6624acd..24cac1a5551 100644
--- a/chromium/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_proxy.js
+++ b/chromium/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_proxy.js
@@ -29,12 +29,6 @@ cr.define('settings', function() {
restartComputer() {}
/**
- * Hides the Cleanup page from the settings menu.
- * @param {number} source
- */
- dismissCleanupPage(source) {}
-
- /**
* Updates the cleanup logs upload permission status.
* @param {boolean} enabled
*/
@@ -93,11 +87,6 @@ cr.define('settings', function() {
}
/** @override */
- dismissCleanupPage(source) {
- chrome.send('dismissCleanupPage', [source]);
- }
-
- /** @override */
setLogsUploadPermission(enabled) {
chrome.send('setLogsUploadPermission', [enabled]);
}
diff --git a/chromium/chrome/browser/resources/settings/chrome_cleanup_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/chrome_cleanup_page/compiled_resources2.gyp
deleted file mode 100644
index b9927717002..00000000000
--- a/chromium/chrome/browser/resources/settings/chrome_cleanup_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'chrome_cleanup_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'chrome_cleanup_page',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_expand_button/compiled_resources2.gyp:cr_expand_button',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '<(EXTERNS_GYP):settings_private',
- 'chrome_cleanup_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'items_to_remove_list',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- 'chrome_cleanup_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/chrome_cleanup_page/items_to_remove_list.html b/chromium/chrome/browser/resources/settings/chrome_cleanup_page/items_to_remove_list.html
index 21e3bb1cedc..a4e5792f6ac 100644
--- a/chromium/chrome/browser/resources/settings/chrome_cleanup_page/items_to_remove_list.html
+++ b/chromium/chrome/browser/resources/settings/chrome_cleanup_page/items_to_remove_list.html
@@ -25,9 +25,7 @@
margin-top: -13px;
}
</style>
- <div id="title" class="secondary" hidden="[[!titleVisible]]">
- [[title]]
- </div>
+ <div id="title" class="secondary">[[title]]</div>
<ul class="secondary">
<template is="dom-repeat" items="[[initialItems_]]">
<li class="visible-item">[[item]]</li>
diff --git a/chromium/chrome/browser/resources/settings/chrome_cleanup_page/items_to_remove_list.js b/chromium/chrome/browser/resources/settings/chrome_cleanup_page/items_to_remove_list.js
index 8b9c803fb3b..81fd4dc3bd4 100644
--- a/chromium/chrome/browser/resources/settings/chrome_cleanup_page/items_to_remove_list.js
+++ b/chromium/chrome/browser/resources/settings/chrome_cleanup_page/items_to_remove_list.js
@@ -17,14 +17,7 @@ settings.CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW = 4;
* TODO(crbug.com/776538): Update the strings to say that some items are only
* changed and not removed.
*
- * Examples:
- *
- * <!-- Items list initially expanded. -->
- * <items-to-remove-list
- * title="Files and programs:"
- * initially-expanded="true"
- * items-to-show="[[filesToShow]]">
- * </items-to-remove-list>
+ * Example:
*
* <!-- Items list initially shows |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW|
* items. If there are more than |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW|
@@ -39,26 +32,15 @@ Polymer({
is: 'items-to-remove-list',
properties: {
- titleVisible: {
- type: Boolean,
- value: true,
- },
-
title: {
type: String,
value: '',
},
/** @type {!Array<string>} */
- itemsToShow: Array,
-
- /**
- * If true, all items from |itemsToShow| will be presented on the card
- * by default, and the "show more" link will be omitted.
- */
- initiallyExpanded: {
- type: Boolean,
- value: false,
+ itemsToShow: {
+ type: Array,
+ observer: 'updateVisibleState_',
},
/**
@@ -71,10 +53,8 @@ Polymer({
},
/**
- * The items to be shown to the user the first time this component is
- * rendered. If |initiallyExpanded| is true, then it includes all items
- * from |itemsToShow|. Otherwise, it contains the first
- * |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW| items.
+ * The first |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW| items of |itemsToShow|
+ * if the list is longer than |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW|.
* @private {?Array<string>}
*/
initialItems_: Array,
@@ -98,8 +78,6 @@ Polymer({
},
},
- observers: ['updateVisibleState_(itemsToShow, initiallyExpanded)'],
-
/** @private */
expandList_: function() {
this.expanded_ = true;
@@ -110,24 +88,19 @@ Polymer({
* Decides which elements will be visible in the card and if the "show more"
* link will be rendered.
*
- * Cases handled:
- * 1. If |initiallyExpanded|, then all items will be visible.
- * 2. Otherwise:
- * (A) If size(itemsToShow) < CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW, then
- * all items will be visible.
- * (B) Otherwise, exactly |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW - 1| will
- * be visible and the "show more" link will be rendered. The list
- * presented to the user will contain exactly
- * |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW| elements, and the last one
- * will be the "show more" link.
+ * 1. If size(itemsToShow) < CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW, then all
+ * items will be visible.
+ * 2. Otherwise, exactly |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW - 1| will be
+ * visible and the "show more" link will be rendered. The list presented to
+ * the user will contain exactly |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW|
+ * elements, and the last one will be the "show more" link.
*
* @param {!Array<string>} itemsToShow
- * @param {boolean} initiallyExpanded
*/
- updateVisibleState_: function(itemsToShow, initiallyExpanded) {
+ updateVisibleState_: function(itemsToShow) {
// Start expanded if there are less than
// |settings.CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW| items to show.
- this.expanded_ = initiallyExpanded ||
+ this.expanded_ =
itemsToShow.length <= settings.CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW;
if (this.expanded_) {
diff --git a/chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/BUILD.gn b/chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/BUILD.gn
new file mode 100644
index 00000000000..cf04a888e8d
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/BUILD.gn
@@ -0,0 +1,31 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":clear_browsing_data_browser_proxy",
+ ":clear_browsing_data_dialog",
+ ]
+}
+
+js_library("clear_browsing_data_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("clear_browsing_data_dialog") {
+ deps = [
+ ":clear_browsing_data_browser_proxy",
+ "../device_page:keyboard",
+ "//third_party/polymer/v1_0/components-chromium/iron-pages:iron-pages-extracted",
+ "//third_party/polymer/v1_0/components-chromium/iron-resizable-behavior:iron-resizable-behavior-extracted",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html b/chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html
index 40e0062a39b..364342957ef 100644
--- a/chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html
+++ b/chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html
@@ -1,6 +1,7 @@
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
+<link rel="import" href="chrome://resources/cr_elements/paper_tabs_style_css.html">
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-pages/iron-pages.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
@@ -18,7 +19,7 @@
<dom-module id="settings-clear-browsing-data-dialog">
<template>
- <style include="settings-shared">
+ <style include="settings-shared paper-tabs-style">
:host {
/* Fixed height to allow multiple tabs with different height.
* The last entry in the advanced tab should show half an entry.
@@ -80,23 +81,12 @@
}
paper-tabs {
- --paper-tabs-selection-bar-color: var(--google-blue-500);
--paper-tabs: {
font-size: 100%;
height: 40px;
}
}
- paper-tab {
- --paper-tab-content: {
- color: var(--google-blue-700);
- };
- --paper-tab-content-unselected: {
- opacity: 1;
- color: var(--paper-grey-600);
- };
- }
-
.time-range-row {
margin-bottom: 12px;
}
@@ -123,13 +113,14 @@
<div slot="header">
<paper-tabs noink on-selected-changed="recordTabChange_"
selected="{{prefs.browser.last_clear_browsing_data_tab.value}}">
- <paper-tab>$i18n{basicPageTitle}</paper-tab>
- <paper-tab>$i18n{advancedPageTitle}</paper-tab>
+ <paper-tab id="basicTabTitle">$i18n{basicPageTitle}</paper-tab>
+ <paper-tab id="advancedTabTitle">$i18n{advancedPageTitle}</paper-tab>
</paper-tabs>
</div>
<div slot="body">
<iron-pages id="tabs"
- selected="[[prefs.browser.last_clear_browsing_data_tab.value]]">
+ selected="[[prefs.browser.last_clear_browsing_data_tab.value]]"
+ on-selected-item-changed="updateClearButtonState_">
<div id="basic-tab">
<div class="row time-range-row">
<span class="time-range-label">
@@ -254,8 +245,9 @@
<paper-button class="cancel-button" disabled="[[clearingInProgress_]]"
on-click="onCancelTap_">$i18n{cancel}</paper-button>
<paper-button id="clearBrowsingDataConfirm"
- class="action-button" disabled="[[clearingInProgress_]]"
- on-click="onClearBrowsingDataTap_">
+ class="action-button" on-click="onClearBrowsingDataTap_"
+ disabled="[[isClearButtonDisabled_(clearingInProgress_,
+ clearButtonDisabled_)]]">
$i18n{clearData}
</paper-button>
</div>
diff --git a/chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.js b/chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.js
index 97beb3c7906..b959fd5d399 100644
--- a/chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.js
+++ b/chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.js
@@ -57,6 +57,12 @@ Polymer({
},
/** @private */
+ clearButtonDisabled_: {
+ type: Boolean,
+ value: false,
+ },
+
+ /** @private */
isSupervised_: {
type: Boolean,
value: function() {
@@ -120,6 +126,8 @@ Polymer({
}
},
+ listeners: {'settings-boolean-control-change': 'updateClearButtonState_'},
+
/** @private {settings.ClearBrowsingDataBrowserProxy} */
browserProxy_: null,
@@ -148,6 +156,30 @@ Polymer({
},
/**
+ * Returns true if either clearing is in progress or no data type is selected.
+ * @param {boolean} clearingInProgress
+ * @param {boolean} clearButtonDisabled
+ * @return {boolean}
+ * @private
+ */
+ isClearButtonDisabled_: function(clearingInProgress, clearButtonDisabled) {
+ return clearingInProgress || clearButtonDisabled;
+ },
+
+ /**
+ * Disables the Clear Data button if no data type is selected.
+ * @private
+ */
+ updateClearButtonState_: function() {
+ // on-select-item-changed gets called with undefined during a tab change.
+ // https://github.com/PolymerElements/iron-selector/issues/95
+ const tab = this.$.tabs.selectedItem;
+ if (!tab)
+ return;
+ this.clearButtonDisabled_ = this.getSelectedDataTypes_(tab).length == 0;
+ },
+
+ /**
* Record visits to the CBD dialog.
*
* settings.RouteObserverBehavior
@@ -271,20 +303,29 @@ Polymer({
},
/**
- * Clears browsing data and maybe shows a history notice.
+ * Returns a list of selected data types.
+ * @param {!HTMLElement} tab
+ * @return {!Array<string>}
* @private
*/
- clearBrowsingData_: function() {
- this.clearingInProgress_ = true;
- const tab = this.$.tabs.selectedItem;
-
+ getSelectedDataTypes_: function(tab) {
const checkboxes = tab.querySelectorAll('settings-checkbox');
const dataTypes = [];
checkboxes.forEach((checkbox) => {
- if (checkbox.checked)
+ if (checkbox.checked && !checkbox.hidden)
dataTypes.push(checkbox.pref.key);
});
+ return dataTypes;
+ },
+ /**
+ * Clears browsing data and maybe shows a history notice.
+ * @private
+ */
+ clearBrowsingData_: function() {
+ this.clearingInProgress_ = true;
+ const tab = this.$.tabs.selectedItem;
+ const dataTypes = this.getSelectedDataTypes_(tab);
const timePeriod = tab.querySelector('.time-range-select').pref.value;
if (tab.id == 'basic-tab') {
@@ -358,5 +399,4 @@ Polymer({
'ClearBrowsingData_SwitchTo_AdvancedTab');
}
},
-
});
diff --git a/chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/compiled_resources2.gyp
deleted file mode 100644
index 8660449e98a..00000000000
--- a/chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/compiled_resources2.gyp
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'clear_browsing_data_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_dialog/compiled_resources2.gyp:cr_dialog',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'clear_browsing_data_dialog',
- 'dependencies': [
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-pages/compiled_resources2.gyp:iron-pages-extracted',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-resizable-behavior/compiled_resources2.gyp:iron-resizable-behavior-extracted',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '../device_page/compiled_resources2.gyp:keyboard',
- 'clear_browsing_data_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/compiled_resources2.gyp
deleted file mode 100644
index f56f7ebe8c4..00000000000
--- a/chromium/chrome/browser/resources/settings/compiled_resources2.gyp
+++ /dev/null
@@ -1,105 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'extension_control_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):chrome_send',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'focus_row_behavior',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_row',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'global_scroll_target_behavior',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- 'route',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'lifetime_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):chrome_send',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'route',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(EXTERNS_GYP):metrics_private',
- 'page_visibility'
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'page_visibility',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'search_settings',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:search_highlight_utils',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'settings_resources',
- 'type': 'none',
- 'dependencies': [
- 'a11y_page/compiled_resources2.gyp:*',
- 'about_page/compiled_resources2.gyp:*',
- 'android_apps_page/compiled_resources2.gyp:*',
- 'animation/compiled_resources2.gyp:*',
- 'appearance_page/compiled_resources2.gyp:*',
- 'basic_page/compiled_resources2.gyp:*',
- 'bluetooth_page/compiled_resources2.gyp:*',
- 'change_password_page/compiled_resources2.gyp:*',
- 'chrome_cleanup_page/compiled_resources2.gyp:*',
- 'clear_browsing_data_dialog/compiled_resources2.gyp:*',
- 'controls/compiled_resources2.gyp:*',
- 'date_time_page/compiled_resources2.gyp:*',
- 'default_browser_page/compiled_resources2.gyp:*',
- 'device_page/compiled_resources2.gyp:*',
- 'downloads_page/compiled_resources2.gyp:*',
- 'incompatible_applications_page/compiled_resources2.gyp:*',
- 'internet_page/compiled_resources2.gyp:*',
- 'languages_page/compiled_resources2.gyp:*',
- 'on_startup_page/compiled_resources2.gyp:*',
- 'passwords_and_forms_page/compiled_resources2.gyp:*',
- 'people_page/compiled_resources2.gyp:*',
- 'prefs/compiled_resources2.gyp:*',
- 'printing_page/compiled_resources2.gyp:*',
- 'privacy_page/compiled_resources2.gyp:*',
- 'reset_page/compiled_resources2.gyp:*',
- 'search_engines_page/compiled_resources2.gyp:*',
- 'search_page/compiled_resources2.gyp:*',
- 'settings_main/compiled_resources2.gyp:*',
- 'settings_menu/compiled_resources2.gyp:*',
- 'settings_page/compiled_resources2.gyp:*',
- 'settings_ui/compiled_resources2.gyp:*',
- 'site_settings/compiled_resources2.gyp:*',
- 'site_settings_page/compiled_resources2.gyp:*',
- 'system_page/compiled_resources2.gyp:*',
- ],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/controls/BUILD.gn b/chromium/chrome/browser/resources/settings/controls/BUILD.gn
new file mode 100644
index 00000000000..21618639641
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/controls/BUILD.gn
@@ -0,0 +1,114 @@
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":controlled_button",
+ ":controlled_radio_button",
+ ":extension_controlled_indicator",
+ ":important_site_checkbox",
+ ":pref_control_behavior",
+ ":settings_boolean_control_behavior",
+ ":settings_checkbox",
+ ":settings_dropdown_menu",
+ ":settings_radio_group",
+ ":settings_slider",
+ ":settings_toggle_button",
+ ]
+}
+
+js_library("controlled_button") {
+ deps = [
+ ":pref_control_behavior",
+ "//ui/webui/resources/cr_elements/policy:cr_policy_pref_behavior",
+ "//ui/webui/resources/js:assert",
+ ]
+}
+
+js_library("controlled_radio_button") {
+ deps = [
+ ":pref_control_behavior",
+ "../prefs:pref_util",
+ "//third_party/polymer/v1_0/components-chromium/iron-a11y-keys-behavior:iron-a11y-keys-behavior-extracted",
+ "//ui/webui/resources/cr_elements/cr_radio_button:cr_radio_button_behavior",
+ "//ui/webui/resources/js:assert",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
+
+js_library("extension_controlled_indicator") {
+ deps = [
+ "..:extension_control_browser_proxy",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+}
+
+js_library("important_site_checkbox") {
+ deps = [
+ ":settings_boolean_control_behavior",
+ "../clear_browsing_data_dialog:clear_browsing_data_browser_proxy",
+ ]
+}
+
+js_library("pref_control_behavior") {
+ deps = [
+ "../prefs:prefs_types",
+ ]
+}
+
+js_library("settings_boolean_control_behavior") {
+ deps = [
+ ":pref_control_behavior",
+ "../prefs:prefs_types",
+ "//ui/webui/resources/cr_elements/policy:cr_policy_pref_behavior",
+ "//ui/webui/resources/js:assert",
+ ]
+}
+
+js_library("settings_checkbox") {
+ deps = [
+ ":settings_boolean_control_behavior",
+ ]
+}
+
+js_library("settings_dropdown_menu") {
+ deps = [
+ ":pref_control_behavior",
+ "../prefs:pref_util",
+ "//ui/webui/resources/cr_elements/policy:cr_policy_indicator_behavior",
+ "//ui/webui/resources/cr_elements/policy:cr_policy_pref_behavior",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
+
+js_library("settings_radio_group") {
+ deps = [
+ ":pref_control_behavior",
+ "../prefs:pref_util",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
+
+js_library("settings_slider") {
+ deps = [
+ "//third_party/polymer/v1_0/components-chromium/paper-slider:paper-slider-extracted",
+ "//ui/webui/resources/cr_elements/policy:cr_policy_pref_behavior",
+ "//ui/webui/resources/js:assert",
+ ]
+}
+
+js_library("settings_toggle_button") {
+ deps = [
+ ":settings_boolean_control_behavior",
+ "//ui/webui/resources/cr_elements/cr_toggle:cr_toggle",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/controls/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/controls/compiled_resources2.gyp
deleted file mode 100644
index 32dadfbdef9..00000000000
--- a/chromium/chrome/browser/resources/settings/controls/compiled_resources2.gyp
+++ /dev/null
@@ -1,110 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'controlled_button',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_pref_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- 'pref_control_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'controlled_radio_button',
- 'dependencies': [
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-a11y-keys-behavior/compiled_resources2.gyp:iron-a11y-keys-behavior-extracted',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(EXTERNS_GYP):settings_private',
- '../prefs/compiled_resources2.gyp:pref_util',
- 'pref_control_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'extension_controlled_indicator',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '../compiled_resources2.gyp:extension_control_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'important_site_checkbox',
- 'dependencies': [
- '../clear_browsing_data_dialog/compiled_resources2.gyp:clear_browsing_data_browser_proxy',
- 'settings_boolean_control_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'pref_control_behavior',
- 'dependencies': [
- '../prefs/compiled_resources2.gyp:prefs_types',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'settings_boolean_control_behavior',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_pref_behavior',
- '../prefs/compiled_resources2.gyp:prefs_types',
- 'pref_control_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'settings_checkbox',
- 'dependencies': [
- 'settings_boolean_control_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'settings_dropdown_menu',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_indicator_behavior',
- '<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_pref_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(EXTERNS_GYP):settings_private',
- '../prefs/compiled_resources2.gyp:pref_util',
- 'pref_control_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'settings_radio_group',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):settings_private',
- '../prefs/compiled_resources2.gyp:pref_util',
- 'pref_control_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'settings_slider',
- 'dependencies': [
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/paper-slider/compiled_resources2.gyp:paper-slider-extracted',
- '<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_pref_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'settings_toggle_button',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_toggle/compiled_resources2.gyp:cr_toggle',
- 'settings_boolean_control_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/controls/controlled_button.html b/chromium/chrome/browser/resources/settings/controls/controlled_button.html
index a5cf488854f..f1d81142250 100644
--- a/chromium/chrome/browser/resources/settings/controls/controlled_button.html
+++ b/chromium/chrome/browser/resources/settings/controls/controlled_button.html
@@ -14,8 +14,6 @@
<style include="settings-shared">
:host {
--justify-margin: 8px;
- -webkit-margin-end: calc(var(--cr-button-edge-spacing) * -1);
- -webkit-margin-start: calc(var(--cr-button-edge-spacing) * -1);
align-items: center;
display: flex;
}
diff --git a/chromium/chrome/browser/resources/settings/controls/controlled_radio_button.html b/chromium/chrome/browser/resources/settings/controls/controlled_radio_button.html
index d6fcdf26b06..a8260c24312 100644
--- a/chromium/chrome/browser/resources/settings/controls/controlled_radio_button.html
+++ b/chromium/chrome/browser/resources/settings/controls/controlled_radio_button.html
@@ -1,5 +1,7 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_radio_button/cr_radio_button_behavior.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_radio_button/cr_radio_button_style_css.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_pref_indicator.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html">
<link rel="import" href="pref_control_behavior.html">
@@ -8,109 +10,15 @@
<dom-module id="controlled-radio-button">
<template>
- <style include="settings-shared">
- :host {
- --ink-to-circle: calc((var(--paper-radio-button-ink-size) -
- var(--paper-radio-button-size)) / 2);
- @apply --settings-actionable;
- align-items: center;
- display: flex;
- outline: none;
+ <style include="settings-shared cr-radio-button-style">
+ :host([disabled]) {
+ opacity: 1;
}
- #labelWrapper {
- -webkit-margin-start: var(--paper-radio-button-label-spacing, 10px);
- flex: 1;
- }
-
- #label {
- color: var(--paper-radio-button-label-color, var(--primary-text-color));
- }
-
- .circle,
- .disc,
- .disc-wrapper,
- paper-ripple {
- border-radius: 50%;
- }
-
- .disc-wrapper {
- height: var(--paper-radio-button-ink-size);
- margin: 0 calc(-1 * var(--ink-to-circle));
- position: relative;
- width: var(--paper-radio-button-ink-size);
- }
-
- .circle,
- .disc {
- box-sizing: border-box;
- height: var(--paper-radio-button-size);
- left: var(--ink-to-circle);
- position: absolute;
- top: var(--ink-to-circle);
- width: var(--paper-radio-button-size);
- }
-
- .circle {
- border: 2px solid var(--paper-radio-button-unchecked-color,
- var(--primary-text-color));
- }
-
- :host([checked]) .circle {
- border-color: var(--paper-radio-button-checked-color,
- var(--primary-color));
- }
-
- .disc {
- background-color: var(--paper-radio-button-unchecked-background-color,
- transparent);
- transform: scale(0);
- transition: border-color 200ms, transform 200ms;
- }
-
- :host([checked]) .disc {
- background-color: var(--paper-radio-button-checked-color,
- var(--primary-color));
- transform: scale(0.5);
- }
-
- paper-ripple {
- color: var(--paper-radio-button-unchecked-ink-color,
- var(--primary-text-color));
- opacity: .6;
- }
-
- :host([checked]) paper-ripple {
- color: var(--paper-radio-button-checked-ink-color,
- var(--primary-text-color));
- }
-
- :host(:not([controlled_])) {
- @apply --settings-actionable;
- }
-
- :host([controlled_]) {
- /* Disable pointer events for this whole element, as outer on-tap gets
- * triggered when clicking/tapping anywhere in :host. */
- pointer-events: none;
- }
-
- :host([controlled_]) :-webkit-any(.circle, .disc) {
- opacity: .5;
- }
-
- :host([controlled_]) .circle {
- border-color: var(--paper-radio-button-unchecked-color,
- var(--primary-text-color));
- }
-
- :host([controlled_][checked]) .disc {
- background-color: var(--paper-radio-button-unchecked-color,
- var(--primary-text-color));
- }
-
- :host([controlled_]) #labelWrapper {
- opacity: .65;
+ /* Disc and label should be transluscent, but not the policy indicator. */
+ :host([disabled]) .disc-wrapper,
+ :host([disabled]) #labelWrapper {
+ opacity: var(--cr-disabled-opacity);
}
cr-policy-pref-indicator {
@@ -122,9 +30,8 @@
</style>
<div class="disc-wrapper">
- <div class="circle"></div>
+ <div class="disc-border"></div>
<div class="disc"></div>
- <paper-ripple center hold-down="[[pressed_]]"></paper-ripple>
</div>
<div id="labelWrapper">
@@ -132,7 +39,7 @@
<slot></slot>
</div>
- <template is="dom-if" if="[[showIndicator_(controlled_, name, pref.*)]]">
+ <template is="dom-if" if="[[showIndicator_(disabled, name, pref.*)]]">
<cr-policy-pref-indicator pref="[[pref]]" on-click="onIndicatorTap_"
icon-aria-label="[[label]]">
</cr-policy-pref-indicator>
diff --git a/chromium/chrome/browser/resources/settings/controls/controlled_radio_button.js b/chromium/chrome/browser/resources/settings/controls/controlled_radio_button.js
index 53bd0505a3c..19bbcef638b 100644
--- a/chromium/chrome/browser/resources/settings/controls/controlled_radio_button.js
+++ b/chromium/chrome/browser/resources/settings/controls/controlled_radio_button.js
@@ -7,96 +7,60 @@ Polymer({
behaviors: [
PrefControlBehavior,
- Polymer.IronA11yKeysBehavior,
+ CrRadioButtonBehavior,
],
properties: {
- checked: {
+ disabled: {
type: Boolean,
- value: false,
+ computed: 'computeDisabled_(pref.*)',
reflectToAttribute: true,
- observer: 'checkedChanged_',
- },
-
- label: {
- type: String,
- value: '', // Allows the hidden$= binding to run without being set.
+ observer: 'disabledChanged_',
},
name: {
type: String,
notify: true,
},
-
- /** @private */
- controlled_: {
- type: Boolean,
- computed: 'computeControlled_(pref.*)',
- reflectToAttribute: true,
- },
-
- /** @private */
- pressed_: Boolean,
- },
-
- hostAttributes: {
- role: 'radio',
- tabindex: 0,
- },
-
- listeners: {
- 'blur': 'updatePressed_',
- 'down': 'updatePressed_',
- 'focus': 'updatePressed_',
- 'up': 'updatePressed_',
- },
-
- keyBindings: {
- // This is mainly for screenreaders, which can perform actions on things
- // that aren't focused (only focused things get synthetic click/tap events).
- 'enter:keyup': 'click',
- 'space:keyup': 'click',
- },
-
- /** @private */
- checkedChanged_: function() {
- this.setAttribute('aria-checked', this.checked ? 'true' : 'false');
},
/**
* @return {boolean} Whether the button is disabled.
* @private
*/
- computeControlled_: function() {
+ computeDisabled_: function() {
return this.pref.enforcement == chrome.settingsPrivate.Enforcement.ENFORCED;
},
/**
- * @param {boolean} controlled
- * @param {string} name
- * @return {boolean}
+ * @param {boolean} current
+ * @param {boolean} previous
* @private
*/
- showIndicator_: function(controlled, name) {
- return controlled &&
- name == Settings.PrefUtil.prefToString(assert(this.pref));
+ disabledChanged_: function(current, previous) {
+ if (previous === undefined && !this.disabled)
+ return;
+
+ this.setAttribute('tabindex', this.disabled ? -1 : 0);
+ this.setAttribute('aria-disabled', this.disabled ? 'true' : 'false');
},
/**
- * @param {!Event} e
+ * @return {boolean}
* @private
*/
- onIndicatorTap_: function(e) {
- // Disallow <controlled-radio-button on-click="..."> when controlled.
- e.preventDefault();
- e.stopPropagation();
+ showIndicator_: function() {
+ return this.disabled &&
+ this.name == Settings.PrefUtil.prefToString(assert(this.pref));
},
/**
* @param {!Event} e
* @private
*/
- updatePressed_: function(e) {
- this.pressed_ = ['down', 'focus'].includes(e.type);
+ onIndicatorTap_: function(e) {
+ // Disallow <controlled-radio-button on-click="..."> when disabled.
+ e.preventDefault();
+ e.stopPropagation();
},
});
diff --git a/chromium/chrome/browser/resources/settings/controls/important_site_checkbox.html b/chromium/chrome/browser/resources/settings/controls/important_site_checkbox.html
index 20e0d910da0..982e4d67097 100644
--- a/chromium/chrome/browser/resources/settings/controls/important_site_checkbox.html
+++ b/chromium/chrome/browser/resources/settings/controls/important_site_checkbox.html
@@ -1,7 +1,7 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_pref_indicator.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-checkbox/paper-checkbox.html">
<link rel="import" href="settings_boolean_control_behavior.html">
<link rel="import" href="../settings_shared_css.html">
@@ -15,24 +15,16 @@
width: 100%;
}
- paper-checkbox {
+ cr-checkbox {
width: 100%;
}
- paper-checkbox:not([checked]) .secondary {
- @apply --settings-secondary-unchecked;
- }
-
.middot {
padding: 0 4px;
}
-
- .label {
- @apply --settings-checkbox-label;
- }
</style>
<div id="outerRow">
- <paper-checkbox id="checkbox" checked="{{site.isChecked}}"
+ <cr-checkbox id="checkbox" checked="{{site.isChecked}}"
disabled="[[disabled]]">
<div class="label">[[site.registerableDomain]]</div>
<div class="secondary label">
@@ -45,7 +37,7 @@
$i18n{notificationWarning}
</span>
</div>
- </paper-checkbox>
+ </cr-checkbox>
</div>
</template>
<script src="important_site_checkbox.js"></script>
diff --git a/chromium/chrome/browser/resources/settings/controls/settings_boolean_control_behavior.js b/chromium/chrome/browser/resources/settings/controls/settings_boolean_control_behavior.js
index ed712bce518..0955fc101ae 100644
--- a/chromium/chrome/browser/resources/settings/controls/settings_boolean_control_behavior.js
+++ b/chromium/chrome/browser/resources/settings/controls/settings_boolean_control_behavior.js
@@ -122,9 +122,9 @@ const SettingsBooleanControlBehaviorImpl = {
/**
* @return {boolean} Whether the control should be disabled.
- * @private
+ * @protected
*/
- controlDisabled_: function() {
+ controlDisabled: function() {
return this.disabled || this.isPrefEnforced();
},
};
diff --git a/chromium/chrome/browser/resources/settings/controls/settings_checkbox.html b/chromium/chrome/browser/resources/settings/controls/settings_checkbox.html
index 0563536cb09..ec8f7cfed6e 100644
--- a/chromium/chrome/browser/resources/settings/controls/settings_checkbox.html
+++ b/chromium/chrome/browser/resources/settings/controls/settings_checkbox.html
@@ -1,7 +1,7 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_pref_indicator.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-checkbox/paper-checkbox.html">
<link rel="import" href="settings_boolean_control_behavior.html">
<link rel="import" href="../settings_shared_css.html">
@@ -19,38 +19,27 @@
min-height: var(--settings-row-min-height);
}
- paper-checkbox {
- /* Handle overflow of subLabel when it is larger than one line. */
- align-items: center;
- display: flex;
+ cr-checkbox {
/* Additional margin in case subLabel needs more than one line. */
margin-bottom: 4px;
margin-top: var(--settings-checkbox-margin-top, 4px);
width: 100%;
}
- paper-checkbox:not([checked]) .secondary {
- @apply --settings-secondary-unchecked;
- }
-
cr-policy-pref-indicator {
-webkit-margin-start: var(--settings-controlled-by-spacing);
}
-
- .label {
- @apply --settings-checkbox-label;
- }
</style>
<div id="outerRow" noSubLabel$="[[!hasSubLabel_(subLabel, subLabelHtml)]]">
- <paper-checkbox id="checkbox" checked="{{checked}}"
+ <cr-checkbox id="checkbox" checked="{{checked}}"
on-change="notifyChangedByUserInteraction"
- disabled="[[controlDisabled_(disabled, pref.*)]]">
+ disabled="[[controlDisabled(disabled, pref.*)]]">
<div class="label">[[label]] <slot></slot></div>
<div class="secondary label">
<div inner-h-t-m-l="[[subLabelHtml]]"></div>
[[subLabel]]
</div>
- </paper-checkbox>
+ </cr-checkbox>
<template is="dom-if" if="[[pref.controlledBy]]">
<cr-policy-pref-indicator pref="[[pref]]" icon-aria-label="[[label]]">
</cr-policy-pref-indicator>
diff --git a/chromium/chrome/browser/resources/settings/controls/settings_dropdown_menu.js b/chromium/chrome/browser/resources/settings/controls/settings_dropdown_menu.js
index fdace935d4b..039930fb2d4 100644
--- a/chromium/chrome/browser/resources/settings/controls/settings_dropdown_menu.js
+++ b/chromium/chrome/browser/resources/settings/controls/settings_dropdown_menu.js
@@ -48,6 +48,13 @@ Polymer({
value: false,
},
+ /** If this is a dictionary pref, this is the key for the item
+ we are interested in. */
+ prefKey: {
+ type: String,
+ value: null,
+ },
+
/**
* The value of the "custom" item.
* @private
@@ -63,7 +70,7 @@ Polymer({
},
observers: [
- 'updateSelected_(menuOptions, pref.value)',
+ 'updateSelected_(menuOptions, pref.value.*, prefKey)',
],
/**
@@ -76,10 +83,15 @@ Polymer({
if (selected == this.notFoundValue_)
return;
- const prefValue =
- Settings.PrefUtil.stringToPrefValue(selected, assert(this.pref));
- if (prefValue !== undefined)
- this.set('pref.value', prefValue);
+ if (this.prefKey) {
+ assert(this.pref);
+ this.set(`pref.value.${this.prefKey}`, selected);
+ } else {
+ const prefValue =
+ Settings.PrefUtil.stringToPrefValue(selected, assert(this.pref));
+ if (prefValue !== undefined)
+ this.set('pref.value', prefValue);
+ }
},
/**
@@ -90,7 +102,7 @@ Polymer({
if (this.menuOptions === null || !this.menuOptions.length)
return;
- const prefValue = this.pref.value;
+ const prefValue = this.prefStringValue_();
const option = this.menuOptions.find(function(menuItem) {
return menuItem.value == prefValue;
});
@@ -98,13 +110,26 @@ Polymer({
// Wait for the dom-repeat to populate the <select> before setting
// <select>#value so the correct option gets selected.
this.async(() => {
- this.$.dropdownMenu.value = option == undefined ?
- this.notFoundValue_ :
- Settings.PrefUtil.prefToString(assert(this.pref));
+ this.$.dropdownMenu.value =
+ option == undefined ? this.notFoundValue_ : prefValue;
});
},
/**
+ * Gets the current value of the preference as a string.
+ * @return {string}
+ * @private
+ */
+ prefStringValue_: function() {
+ if (this.prefKey) {
+ // Dictionary pref, values are always strings.
+ return this.pref.value[this.prefKey];
+ } else {
+ return Settings.PrefUtil.prefToString(assert(this.pref));
+ }
+ },
+
+ /**
* @param {?DropdownMenuOptionList} menuOptions
* @param {string} prefValue
* @return {boolean}
@@ -115,8 +140,8 @@ Polymer({
if (!menuOptions || !menuOptions.length)
return false;
- const option = menuOptions.find(function(menuItem) {
- return menuItem.value == prefValue;
+ const option = menuOptions.find((menuItem) => {
+ return menuItem.value == this.prefStringValue_();
});
return !option;
},
diff --git a/chromium/chrome/browser/resources/settings/controls/settings_radio_group.html b/chromium/chrome/browser/resources/settings/controls/settings_radio_group.html
index 19c4b1bb1d6..8bc90c2aeba 100644
--- a/chromium/chrome/browser/resources/settings/controls/settings_radio_group.html
+++ b/chromium/chrome/browser/resources/settings/controls/settings_radio_group.html
@@ -1,7 +1,7 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_radio_button/cr_radio_button.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-radio-group/paper-radio-group.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-radio-button/paper-radio-button.html">
<link rel="import" href="pref_control_behavior.html">
<link rel="import" href="../prefs/pref_util.html">
<link rel="import" href="../settings_shared_css.html">
@@ -11,7 +11,7 @@
<style include="settings-shared"></style>
<div>[[label]]</div>
<paper-radio-group selected="{{selected}}"
- selectable="paper-radio-button, controlled-radio-button">
+ selectable="cr-radio-button, controlled-radio-button">
<slot></slot>
</paper-radio-group>
</template>
diff --git a/chromium/chrome/browser/resources/settings/controls/settings_toggle_button.html b/chromium/chrome/browser/resources/settings/controls/settings_toggle_button.html
index 2277abc6f7e..9534a9df17a 100644
--- a/chromium/chrome/browser/resources/settings/controls/settings_toggle_button.html
+++ b/chromium/chrome/browser/resources/settings/controls/settings_toggle_button.html
@@ -67,7 +67,7 @@
on-change="onChange_"
aria-label$="[[getAriaLabel_(label, ariaLabel)]]"
aria-describedby="subLabel"
- disabled="[[controlDisabled_(disabled, pref)]]">
+ disabled="[[controlDisabled(disabled, pref)]]">
</cr-toggle>
</div>
</template>
diff --git a/chromium/chrome/browser/resources/settings/controls/settings_toggle_button.js b/chromium/chrome/browser/resources/settings/controls/settings_toggle_button.js
index 3cd57aef372..320cacdd22a 100644
--- a/chromium/chrome/browser/resources/settings/controls/settings_toggle_button.js
+++ b/chromium/chrome/browser/resources/settings/controls/settings_toggle_button.js
@@ -60,7 +60,7 @@ Polymer({
/** @private */
onDisableOrPrefChange_: function() {
- if (this.controlDisabled_()) {
+ if (this.controlDisabled()) {
this.removeAttribute('actionable');
} else {
this.setAttribute('actionable', '');
@@ -75,16 +75,9 @@ Polymer({
*/
onHostTap_: function(e) {
e.stopPropagation();
- if (this.controlDisabled_())
+ if (this.controlDisabled())
return;
- // Ignore this |tap| event, if the interaction sequence
- // (pointerdown+pointerup) began within the cr-toggle itself.
- if (/** @type {!CrToggleElement} */ (this.$.control)
- .shouldIgnoreHostTap(e)) {
- return;
- }
-
this.checked = !this.checked;
this.notifyChangedByUserInteraction();
this.fire('change');
diff --git a/chromium/chrome/browser/resources/settings/crostini_page/BUILD.gn b/chromium/chrome/browser/resources/settings/crostini_page/BUILD.gn
new file mode 100644
index 00000000000..10c5791dc4c
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/crostini_page/BUILD.gn
@@ -0,0 +1,37 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":crostini_browser_proxy",
+ ":crostini_page",
+ ":crostini_subpage",
+ ]
+}
+
+js_library("crostini_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("crostini_page") {
+ deps = [
+ ":crostini_browser_proxy",
+ "..:route",
+ "../prefs:prefs_behavior",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
+
+js_library("crostini_subpage") {
+ deps = [
+ ":crostini_browser_proxy",
+ "..:route",
+ "../prefs:prefs_behavior",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/crostini_page/crostini_browser_proxy.html b/chromium/chrome/browser/resources/settings/crostini_page/crostini_browser_proxy.html
new file mode 100644
index 00000000000..3404b910144
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/crostini_page/crostini_browser_proxy.html
@@ -0,0 +1,2 @@
+<link rel="import" href="chrome://resources/html/cr.html">
+<script src="crostini_browser_proxy.js"></script> \ No newline at end of file
diff --git a/chromium/chrome/browser/resources/settings/crostini_page/crostini_browser_proxy.js b/chromium/chrome/browser/resources/settings/crostini_page/crostini_browser_proxy.js
new file mode 100644
index 00000000000..8074cd14502
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/crostini_page/crostini_browser_proxy.js
@@ -0,0 +1,37 @@
+// 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.
+
+/**
+ * @fileoverview A helper object used by the "Linux Apps" (Crostini) section
+ * to install and uninstall Crostini.
+ */
+cr.define('settings', function() {
+ /** @interface */
+ class CrostiniBrowserProxy {
+ requestCrostiniInstallerView() {}
+ requestRemoveCrostini() {}
+ }
+
+ /** @implements {settings.CrostiniBrowserProxy} */
+ class CrostiniBrowserProxyImpl {
+ /** @override */
+ requestCrostiniInstallerView() {
+ chrome.send('requestCrostiniInstallerView');
+ }
+
+ /** @override */
+ requestRemoveCrostini() {
+ chrome.send('requestRemoveCrostini');
+ }
+ }
+
+ // The singleton instance_ can be replaced with a test version of this wrapper
+ // during testing.
+ cr.addSingletonGetter(CrostiniBrowserProxyImpl);
+
+ return {
+ CrostiniBrowserProxy: CrostiniBrowserProxy,
+ CrostiniBrowserProxyImpl: CrostiniBrowserProxyImpl,
+ };
+});
diff --git a/chromium/chrome/browser/resources/settings/crostini_page/crostini_page.html b/chromium/chrome/browser/resources/settings/crostini_page/crostini_page.html
new file mode 100644
index 00000000000..fc8ba307809
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/crostini_page/crostini_page.html
@@ -0,0 +1,64 @@
+<link rel="import" href="chrome://resources/html/polymer.html">
+
+<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_pref_indicator.html">
+<link rel="import" href="chrome://resources/html/i18n_behavior.html">
+<link rel="import" href="chrome://resources/polymer/v1_0/neon-animation/neon-animatable.html">
+<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
+<link rel="import" href="../i18n_setup.html">
+<link rel="import" href="../prefs/prefs_behavior.html">
+<link rel="import" href="../settings_page/settings_animated_pages.html">
+<link rel="import" href="../settings_page/settings_subpage.html">
+<link rel="import" href="../settings_shared_css.html">
+<link rel="import" href="crostini_browser_proxy.html">
+<link rel="import" href="crostini_subpage.html">
+
+<dom-module id="settings-crostini-page">
+ <template>
+ <style include="settings-shared"></style>
+
+ <settings-animated-pages id="pages" section="crostini"
+ focus-config="[[focusConfig_]]">
+ <neon-animatable route-path="default">
+ <div id="crostini" class="settings-box two-line first"
+ actionable$="[[prefs.crostini.enabled.value]]"
+ on-click="onSubpageTap_">
+ <div class="start">
+ $i18n{crostiniPageLabel}
+ <div class="secondary" id="secondaryText">
+ $i18n{crostiniSubtext}
+ </div>
+ </div>
+ <cr-policy-pref-indicator pref="[[prefs.crostini.enabled]]"
+ icon-aria-label="$i18n{crostiniPageTitle}">
+ </cr-policy-pref-indicator>
+ <template is="dom-if" if="[[prefs.crostini.enabled.value]]">
+ <paper-icon-button-light class="subpage-arrow">
+ <button aria-label="$i18n{crostiniPageTitle}"
+ aria-describedby="secondaryText">
+ </button>
+ </paper-icon-button-light>
+ </template>
+ <template is="dom-if" if="[[!prefs.crostini.enabled.value]]">
+ <div class="separator"></div>
+ <paper-button id="enable" on-click="onEnableTap_"
+ aria-label="$i18n{crostiniPageTitle}"
+ aria-describedby="secondaryText">
+ $i18n{crostiniEnable}
+ </paper-button>
+ </template>
+ </div>
+ </neon-animatable>
+
+ <template is="dom-if" route-path="/crostini/details">
+ <settings-subpage
+ associated-control="[[$$('#crostini')]]"
+ page-title="$i18n{crostiniPageLabel}">
+ <settings-crostini-subpage prefs="{{prefs}}">
+ </settings-crostini-subpage>
+ </settings-subpage>
+ </template>
+ </settings-animated-pages>
+
+ </template>
+ <script src="crostini_page.js"></script>
+</dom-module>
diff --git a/chromium/chrome/browser/resources/settings/crostini_page/crostini_page.js b/chromium/chrome/browser/resources/settings/crostini_page/crostini_page.js
new file mode 100644
index 00000000000..1fe0967c346
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/crostini_page/crostini_page.js
@@ -0,0 +1,54 @@
+// 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.
+
+/**
+ * @fileoverview
+ * 'crostini-page' is the settings page for enabling Crostini.
+ * Crostini Containers run Linux inside a Termina VM, allowing
+ * the user to run Linux apps on their Chromebook.
+ */
+
+Polymer({
+ is: 'settings-crostini-page',
+
+ behaviors: [PrefsBehavior],
+
+ properties: {
+ /** Preferences state. */
+ prefs: {
+ type: Object,
+ notify: true,
+ },
+
+ /** @private {!Map<string, string>} */
+ focusConfig_: {
+ type: Object,
+ value: function() {
+ const map = new Map();
+ if (settings.routes.CROSTINI_DETAILS) {
+ map.set(
+ settings.routes.CROSTINI_DETAILS.path,
+ '#crostini .subpage-arrow');
+ }
+ return map;
+ },
+ },
+ },
+
+ /**
+ * @param {!Event} event
+ * @private
+ */
+ onEnableTap_: function(event) {
+ settings.CrostiniBrowserProxyImpl.getInstance()
+ .requestCrostiniInstallerView();
+ event.stopPropagation();
+ },
+
+ /** @private */
+ onSubpageTap_: function(event) {
+ if (this.prefs.crostini.enabled.value)
+ settings.navigateTo(settings.routes.CROSTINI_DETAILS);
+ },
+});
diff --git a/chromium/chrome/browser/resources/settings/crostini_page/crostini_subpage.html b/chromium/chrome/browser/resources/settings/crostini_page/crostini_subpage.html
new file mode 100644
index 00000000000..b39b326da72
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/crostini_page/crostini_subpage.html
@@ -0,0 +1,22 @@
+<link rel="import" href="chrome://resources/html/polymer.html">
+
+<link rel="import" href="chrome://resources/html/i18n_behavior.html">
+<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
+<link rel="import" href="crostini_browser_proxy.html">
+<link rel="import" href="../i18n_setup.html">
+<link rel="import" href="../prefs/prefs_behavior.html">
+<link rel="import" href="../settings_shared_css.html">
+
+<dom-module id="settings-crostini-subpage">
+ <template>
+ <style include="settings-shared"></style>
+ <div id="remove" class="settings-box first"
+ actionable on-click="onRemoveTap_">
+ <div class="start">$i18n{crostiniRemove}</div>
+ <paper-icon-button-light class="subpage-arrow">
+ <button aria-label="$i18n{crostiniRemove}"></button>
+ </paper-icon-button-light>
+ </div>
+ </template>
+ <script src="crostini_subpage.js"></script>
+</dom-module>
diff --git a/chromium/chrome/browser/resources/settings/crostini_page/crostini_subpage.js b/chromium/chrome/browser/resources/settings/crostini_page/crostini_subpage.js
new file mode 100644
index 00000000000..40b70eceabf
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/crostini_page/crostini_subpage.js
@@ -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.
+
+/**
+ * @fileoverview
+ * 'crostini-subpage' is the settings subpage for managing Crostini.
+ */
+
+Polymer({
+ is: 'settings-crostini-subpage',
+
+ behaviors: [PrefsBehavior],
+
+ properties: {
+ /** Preferences state. */
+ prefs: {
+ type: Object,
+ notify: true,
+ },
+ },
+
+ observers: ['onCrostiniEnabledChanged_(prefs.crostini.enabled.value)'],
+
+ /** @private */
+ onCrostiniEnabledChanged_: function(enabled) {
+ if (!enabled &&
+ settings.getCurrentRoute() == settings.routes.CROSTINI_DETAILS) {
+ settings.navigateToPreviousRoute();
+ }
+ },
+
+ /**
+ * Shows a confirmation dialog when removing crostini.
+ * @param {!Event} event
+ * @private
+ */
+ onRemoveTap_: function(event) {
+ settings.CrostiniBrowserProxyImpl.getInstance().requestRemoveCrostini();
+ },
+});
diff --git a/chromium/chrome/browser/resources/settings/date_time_page/BUILD.gn b/chromium/chrome/browser/resources/settings/date_time_page/BUILD.gn
new file mode 100644
index 00000000000..60ec09b4790
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/date_time_page/BUILD.gn
@@ -0,0 +1,54 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":date_time_page",
+ ":date_time_types",
+ ":timezone_selector",
+ ":timezone_subpage",
+ ]
+}
+
+js_library("date_time_page") {
+ deps = [
+ ":date_time_types",
+ ":timezone_selector",
+ ":timezone_subpage",
+ "..:route",
+ "../prefs:prefs_behavior",
+ "//ui/webui/resources/cr_elements/policy:cr_policy_indicator_behavior",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("date_time_types") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("timezone_selector") {
+ deps = [
+ ":date_time_types",
+ "../controls:settings_dropdown_menu",
+ "../prefs:prefs_behavior",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+}
+
+js_library("timezone_subpage") {
+ deps = [
+ ":date_time_types",
+ ":timezone_selector",
+ "../prefs:prefs_behavior",
+ "//ui/webui/resources/js:cr",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/date_time_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/date_time_page/compiled_resources2.gyp
deleted file mode 100644
index bd4978e981e..00000000000
--- a/chromium/chrome/browser/resources/settings/date_time_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,51 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'date_time_page',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '../prefs/compiled_resources2.gyp:prefs_behavior',
- '<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_indicator_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- 'date_time_types',
- 'timezone_selector',
- 'timezone_subpage',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'date_time_types',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'timezone_selector',
- 'dependencies': [
- '../controls/compiled_resources2.gyp:settings_dropdown_menu',
- '../prefs/compiled_resources2.gyp:prefs_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- 'date_time_types',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'timezone_subpage',
- 'dependencies': [
- '../prefs/compiled_resources2.gyp:prefs_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- 'date_time_types',
- 'timezone_selector',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/default_browser_page/BUILD.gn b/chromium/chrome/browser/resources/settings/default_browser_page/BUILD.gn
new file mode 100644
index 00000000000..efe93f1263c
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/default_browser_page/BUILD.gn
@@ -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.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":default_browser_browser_proxy",
+ ":default_browser_page",
+ ]
+}
+
+js_library("default_browser_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("default_browser_page") {
+ deps = [
+ ":default_browser_browser_proxy",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/default_browser_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/default_browser_page/compiled_resources2.gyp
deleted file mode 100644
index b2a36059221..00000000000
--- a/chromium/chrome/browser/resources/settings/default_browser_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'default_browser_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'default_browser_page',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- 'default_browser_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/device_page/BUILD.gn b/chromium/chrome/browser/resources/settings/device_page/BUILD.gn
new file mode 100644
index 00000000000..ddcc5885ab2
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/device_page/BUILD.gn
@@ -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.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":device_page",
+ ":device_page_browser_proxy",
+ ":display",
+ ":display_layout",
+ ":display_overscan_dialog",
+ ":display_size_slider",
+ ":drag_behavior",
+ ":drive_cache_dialog",
+ ":keyboard",
+ ":layout_behavior",
+ ":night_light_slider",
+ ":pointers",
+ ":power",
+ ":storage",
+ ":stylus",
+ ]
+}
+
+js_library("device_page") {
+ deps = [
+ ":device_page_browser_proxy",
+ "..:route",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("device_page_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("pointers") {
+ deps = [
+ ":device_page_browser_proxy",
+ "../controls:settings_toggle_button",
+ ]
+}
+
+js_library("keyboard") {
+ deps = [
+ ":device_page_browser_proxy",
+ "..:route",
+ "../controls:settings_dropdown_menu",
+ "../prefs:prefs_types",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
+
+js_library("stylus") {
+ deps = [
+ ":device_page_browser_proxy",
+ "../prefs:prefs_types",
+ "//ui/webui/resources/cr_elements/policy:cr_policy_indicator",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
+
+js_library("display") {
+ deps = [
+ ":display_layout",
+ ":display_size_slider",
+ "../controls:settings_dropdown_menu",
+ "../prefs:prefs_behavior",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+ externs_list = [
+ "$externs_path/settings_private.js",
+ "$externs_path/system_display.js",
+ ]
+ extra_sources = [ "$interfaces_path/system_display_interface.js" ]
+}
+
+js_library("display_layout") {
+ deps = [
+ ":drag_behavior",
+ ":layout_behavior",
+ "//third_party/polymer/v1_0/components-chromium/iron-resizable-behavior:iron-resizable-behavior-extracted",
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/system_display.js" ]
+ extra_sources = [ "$interfaces_path/system_display_interface.js" ]
+}
+
+js_library("display_overscan_dialog") {
+ deps = [
+ ":display",
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/system_display.js" ]
+ extra_sources = [ "$interfaces_path/system_display_interface.js" ]
+}
+
+js_library("drag_behavior") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("layout_behavior") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/system_display.js" ]
+ extra_sources = [ "$interfaces_path/system_display_interface.js" ]
+}
+
+js_library("night_light_slider") {
+ deps = [
+ "../prefs:prefs_behavior",
+ "//third_party/polymer/v1_0/components-chromium/iron-a11y-keys-behavior:iron-a11y-keys-behavior-extracted",
+ "//third_party/polymer/v1_0/components-chromium/iron-resizable-behavior:iron-resizable-behavior-extracted",
+ "//third_party/polymer/v1_0/components-chromium/paper-behaviors:paper-inky-focus-behavior-extracted",
+ ]
+}
+
+js_library("display_size_slider") {
+ deps = [
+ "../prefs:prefs_behavior",
+ "//third_party/polymer/v1_0/components-chromium/iron-a11y-keys-behavior:iron-a11y-keys-behavior-extracted",
+ "//third_party/polymer/v1_0/components-chromium/iron-range-behavior:iron-range-behavior-extracted",
+ "//third_party/polymer/v1_0/components-chromium/iron-resizable-behavior:iron-resizable-behavior-extracted",
+ "//third_party/polymer/v1_0/components-chromium/paper-behaviors:paper-inky-focus-behavior-extracted",
+ "//third_party/polymer/v1_0/components-chromium/paper-progress:paper-progress-extracted",
+ "//ui/webui/resources/cr_elements/policy:cr_policy_pref_behavior",
+ ]
+}
+
+js_library("power") {
+ deps = [
+ ":device_page_browser_proxy",
+ "..:route",
+ "../prefs:prefs_types",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
+
+js_library("storage") {
+ deps = [
+ "..:route",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+}
+
+js_library("drive_cache_dialog") {
+ deps = [
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+ externs_list = [ "$externs_path/chrome_send.js" ]
+}
diff --git a/chromium/chrome/browser/resources/settings/device_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/device_page/compiled_resources2.gyp
deleted file mode 100644
index 09628082ea8..00000000000
--- a/chromium/chrome/browser/resources/settings/device_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,166 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'device_page',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- 'device_page_browser_proxy'
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'device_page_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'pointers',
- 'dependencies': [
- '../controls/compiled_resources2.gyp:settings_toggle_button',
- 'device_page_browser_proxy'
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'keyboard',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '../prefs/compiled_resources2.gyp:prefs_types',
- '../controls/compiled_resources2.gyp:settings_dropdown_menu',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(EXTERNS_GYP):settings_private',
- 'device_page_browser_proxy'
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'stylus',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_indicator',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '../prefs/compiled_resources2.gyp:prefs_types',
- 'device_page_browser_proxy'
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'display',
- 'dependencies': [
- '../prefs/compiled_resources2.gyp:prefs_behavior',
- '../controls/compiled_resources2.gyp:settings_dropdown_menu',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink',
- '<(EXTERNS_GYP):settings_private',
- '<(EXTERNS_GYP):system_display',
- '<(INTERFACES_GYP):system_display_interface',
- 'display_layout',
- 'display_size_slider'
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'display_layout',
- 'dependencies': [
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-resizable-behavior/compiled_resources2.gyp:iron-resizable-behavior-extracted',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):system_display',
- '<(INTERFACES_GYP):system_display_interface',
- 'drag_behavior',
- 'layout_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'display_overscan_dialog',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):system_display',
- '<(INTERFACES_GYP):system_display_interface',
- 'display'
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'drag_behavior',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'layout_behavior',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):system_display',
- '<(INTERFACES_GYP):system_display_interface',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'night_light_slider',
- 'dependencies': [
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-a11y-keys-behavior/compiled_resources2.gyp:iron-a11y-keys-behavior-extracted',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-resizable-behavior/compiled_resources2.gyp:iron-resizable-behavior-extracted',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/paper-behaviors/compiled_resources2.gyp:paper-inky-focus-behavior-extracted',
- '../prefs/compiled_resources2.gyp:prefs_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'display_size_slider',
- 'dependencies': [
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/paper-progress/compiled_resources2.gyp:paper-progress-extracted',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-a11y-keys-behavior/compiled_resources2.gyp:iron-a11y-keys-behavior-extracted',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-resizable-behavior/compiled_resources2.gyp:iron-resizable-behavior-extracted',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-range-behavior/compiled_resources2.gyp:iron-range-behavior-extracted',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/paper-behaviors/compiled_resources2.gyp:paper-inky-focus-behavior-extracted',
- '<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_pref_behavior',
- '../prefs/compiled_resources2.gyp:prefs_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'power',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '<(EXTERNS_GYP):settings_private',
- '../compiled_resources2.gyp:route',
- '../prefs/compiled_resources2.gyp:prefs_types',
- 'device_page_browser_proxy'
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'storage',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'drive_cache_dialog',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(EXTERNS_GYP):chrome_send',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/device_page/device_page_browser_proxy.js b/chromium/chrome/browser/resources/settings/device_page/device_page_browser_proxy.js
index ae2fb6d008c..3a1a47e19d4 100644
--- a/chromium/chrome/browser/resources/settings/device_page/device_page_browser_proxy.js
+++ b/chromium/chrome/browser/resources/settings/device_page/device_page_browser_proxy.js
@@ -6,18 +6,9 @@
cr.exportPath('settings');
/**
- * Mirrors DeviceType from ash/system/power/power_status.h.
- * @enum {number}
- */
-settings.PowerDeviceType = {
- DEDICATED_CHARGER: 0,
- DUAL_ROLE_USB: 1,
-};
-
-/**
* @typedef {{
* id: string,
- * type: settings.PowerDeviceType,
+ * is_dedicated_charger: boolean,
* description: string
* }}
*/
@@ -96,13 +87,6 @@ cr.define('settings', function() {
/** Initializes the stylus handler. */
initializeStylus() {}
- /**
- * Override to interact with the on-tap/on-keydown event on the Learn More
- * link.
- * @param {!Event} e
- */
- handleLinkEvent(e) {}
-
/** Initializes the keyboard WebUI handler. */
initializeKeyboard() {}
@@ -183,14 +167,6 @@ cr.define('settings', function() {
chrome.send('initializeStylusSettings');
}
- /** override */
- handleLinkEvent(e) {
- // Prevent the link from activating its parent element when clicked or
- // when Enter is pressed.
- if (e.type != 'keydown' || e.keyCode == 13)
- e.stopPropagation();
- }
-
/** @override */
initializeKeyboard() {
chrome.send('initializeKeyboardSettings');
diff --git a/chromium/chrome/browser/resources/settings/device_page/display.html b/chromium/chrome/browser/resources/settings/device_page/display.html
index acd9ad6a1f1..407933a2986 100644
--- a/chromium/chrome/browser/resources/settings/device_page/display.html
+++ b/chromium/chrome/browser/resources/settings/device_page/display.html
@@ -1,7 +1,9 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html">
<link rel="import" href="chrome://resources/cr_elements/cr_link_row/cr_link_row.html">
<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html">
+<link rel="import" href="chrome://resources/cr_elements/paper_tabs_style_css.html">
<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
@@ -22,7 +24,7 @@
<dom-module id="settings-display">
<template>
- <style include="settings-shared md-select iron-flex iron-flex-alignment">
+ <style include="settings-shared md-select iron-flex iron-flex-alignment paper-tabs-style">
.indented {
-webkit-margin-start: var(--cr-section-indent-padding);
align-self: stretch;
@@ -53,10 +55,6 @@
-webkit-padding-start: 0
}
- paper-tab {
- text-transform: uppercase;
- }
-
#controlsDiv > .settings-box:first-of-type {
border-top: none;
}
@@ -82,11 +80,11 @@
<template is="dom-if" if="[[showMirror_(unifiedDesktopMode_, displays)]]"
restamp>
<div class="secondary self-start">
- <paper-checkbox checked="[[isMirrored_(displays)]]"
+ <cr-checkbox checked="[[isMirrored_(displays)]]"
on-click="onMirroredTap_"
aria-label="[[getDisplayMirrorText_(displays)]]">
<div class="text-area">[[getDisplayMirrorText_(displays)]]</div>
- </paper-checkbox>
+ </cr-checkbox>
</div>
</template>
@@ -152,7 +150,7 @@
</div>
<settings-slider disabled="[[!enableSetResolution_(selectedDisplay)]]"
tick-values="[[modeValues_]]" pref="{{selectedModePref_}}"
- on-change="onSelectedModeChange_">
+ on-change="onSelectedModeSliderChange_">
</settings-slider>
</div>
</template>
@@ -163,11 +161,16 @@
<div class="start text-area layout vertical">
<div>$i18n{displayZoomTitle}</div>
<div class="secondary self-start">$i18n{displayZoomSublabel}</div>
+ <div class="secondary self-start"
+ hidden$="[[!logicalResolutionText_]]">
+ [[logicalResolutionText_]]
+ </div>
</div>
<display-size-slider id="displaySizeSlider"
ticks="[[zoomValues_]]" pref="{{selectedZoomPref_}}"
min-label="$i18n{displaySizeSliderMinLabel}"
- max-label="$i18n{displaySizeSliderMaxLabel}">
+ max-label="$i18n{displaySizeSliderMaxLabel}"
+ on-immediate-value-changed="onDisplaySizeSliderDrag_">
</display-size-slider>
</div>
diff --git a/chromium/chrome/browser/resources/settings/device_page/display.js b/chromium/chrome/browser/resources/settings/device_page/display.js
index 649b5b65ca4..4245bf5439f 100644
--- a/chromium/chrome/browser/resources/settings/device_page/display.js
+++ b/chromium/chrome/browser/resources/settings/device_page/display.js
@@ -177,6 +177,9 @@ Polymer({
/** @private */
nightLightScheduleSubLabel_: String,
+
+ /** @private */
+ logicalResolutionText_: String,
},
observers: [
@@ -315,7 +318,7 @@ Polymer({
* @private
*/
getSelectedDisplayZoom_: function(selectedDisplay) {
- const selectedZoom = selectedDisplay.displayZoomFactor * 100;
+ const selectedZoom = selectedDisplay.displayZoomFactor;
let closestMatch = this.zoomValues_[0].value;
let minimumDiff = Math.abs(closestMatch - selectedZoom);
@@ -341,9 +344,9 @@ Polymer({
let zoomValues = [];
for (let i = 0; i < selectedDisplay.availableDisplayZoomFactors.length;
i++) {
- const value =
- Math.round(selectedDisplay.availableDisplayZoomFactors[i] * 100);
- const label = this.i18n('displayZoomValue', value.toString());
+ const value = selectedDisplay.availableDisplayZoomFactors[i];
+ const label =
+ this.i18n('displayZoomValue', Math.round(value * 100).toString());
zoomValues.push({value: value, label: label});
}
return zoomValues;
@@ -386,6 +389,9 @@ Polymer({
this.currentSelectedModeIndex_ =
this.getSelectedModeIndex_(selectedDisplay);
this.set('selectedModePref_.value', this.currentSelectedModeIndex_);
+
+ this.updateLogicalResolutionText_(
+ /** @type {number} */ (this.selectedZoomPref_.value));
},
/**
@@ -542,6 +548,27 @@ Polymer({
},
/**
+ * Returns true if the given mode is the best mode for the |selectedDisplay|.
+ * @param {!chrome.system.display.DisplayUnitInfo} selectedDisplay
+ * @param {!chrome.system.display.DisplayMode} mode
+ * @return {boolean}
+ * @private
+ */
+ isBestMode_: function(selectedDisplay, mode) {
+ if (!selectedDisplay.isInternal)
+ return mode.isNative;
+
+ // Things work differently for full HD devices(1080p). The best mode is the
+ // one with 1.25 device scale factor and 0.8 ui scale.
+ if (mode.heightInNativePixels == 1080) {
+ return Math.abs(mode.uiScale - 0.8) < 0.001 &&
+ Math.abs(mode.deviceScaleFactor - 1.25) < 0.001;
+ }
+
+ return mode.uiScale == 1.0;
+ },
+
+ /**
* @return {string}
* @private
*/
@@ -557,11 +584,9 @@ Polymer({
const mode = this.selectedDisplay.modes[
/** @type {number} */ (this.selectedModePref_.value)];
assert(mode);
- const best =
- this.selectedDisplay.isInternal ? mode.uiScale == 1.0 : mode.isNative;
const widthStr = mode.width.toString();
const heightStr = mode.height.toString();
- if (best)
+ if (this.isBestMode_(this.selectedDisplay, mode))
return this.i18n('displayResolutionTextBest', widthStr, heightStr);
else if (mode.isNative)
return this.i18n('displayResolutionTextNative', widthStr, heightStr);
@@ -569,6 +594,46 @@ Polymer({
},
/**
+ * Updates the logical resolution text to be used for the display size section
+ * @param {number} zoomFactor Current zoom factor applied on the selected
+ * display.
+ * @private
+ */
+ updateLogicalResolutionText_: function(zoomFactor) {
+ if (!this.showDisplayZoomSetting_ || !this.selectedDisplay.isInternal) {
+ this.logicalResolutionText_ = '';
+ return;
+ }
+ const mode = this.selectedDisplay.modes[
+ /** @type {number} */ (this.selectedModePref_.value)];
+ const deviceScaleFactor = mode.deviceScaleFactor;
+ const inverseZoomFactor = 1.0 / zoomFactor;
+ let logicalResolutionStrId = 'displayZoomLogicalResolutionText';
+ if (Math.abs(deviceScaleFactor - inverseZoomFactor) < 0.001)
+ logicalResolutionStrId = 'displayZoomNativeLogicalResolutionNativeText';
+ else if (Math.abs(inverseZoomFactor - 1.0) < 0.001)
+ logicalResolutionStrId = 'displayZoomLogicalResolutionDefaultText';
+ const widthStr =
+ Math.round(mode.widthInNativePixels / (deviceScaleFactor * zoomFactor))
+ .toString();
+ const heightStr =
+ Math.round(mode.heightInNativePixels / (deviceScaleFactor * zoomFactor))
+ .toString();
+ this.logicalResolutionText_ =
+ this.i18n(logicalResolutionStrId, widthStr, heightStr);
+ },
+
+ /**
+ * Handles the event where the display size slider is being dragged, i.e. the
+ * mouse or tap has not been released.
+ * @param {!Event} e
+ * @private
+ */
+ onDisplaySizeSliderDrag_: function(e) {
+ this.updateLogicalResolutionText_(/** @type {number} */ (e.detail.value));
+ },
+
+ /**
* @param {!{detail: string}} e |e.detail| is the id of the selected display.
* @private
*/
@@ -626,16 +691,11 @@ Polymer({
},
/**
- * Triggered when the 'change' event for the selected mode slider is
- * triggered. This only occurs when the value is committed (i.e. not while
- * the slider is being dragged).
- * @param {number} newModeIndex The new index value for which thie function is
- * called.
+ * Updates the selected mode based on the latest pref value.
* @private
*/
- onSelectedModeChange_: function(newModeIndex) {
+ onSelectedModeSliderChange_: function() {
if (this.currentSelectedModeIndex_ == -1 ||
- this.currentSelectedModeIndex_ == newModeIndex ||
this.currentSelectedModeIndex_ == this.selectedModePref_.value) {
// Don't change the selected display mode until we have received an update
// from Chrome and the mode differs from the current mode.
@@ -651,6 +711,24 @@ Polymer({
},
/**
+ * Handles a change in the |selectedModePref| value triggered via the observer
+ * @param {number} newModeIndex The new index value for which thie function is
+ * called.
+ * @private
+ */
+ onSelectedModeChange_: function(newModeIndex) {
+ // We want to ignore all value changes to the pref due to the slider being
+ // dragged. Since this can only happen when the slider is present which is
+ // when display zoom is disabled, we can use this check.
+ // See http://crbug/845712 for more info.
+ if (!this.showDisplayZoomSetting_)
+ return;
+ if (this.currentSelectedModeIndex_ == newModeIndex)
+ return;
+ this.onSelectedModeSliderChange_();
+ },
+
+ /**
* Triggerend when the display size slider changes its value. This only
* occurs when the value is committed (i.e. not while the slider is being
* dragged).
@@ -662,7 +740,7 @@ Polymer({
/** @type {!chrome.system.display.DisplayProperties} */ const properties = {
displayZoomFactor:
- /** @type {number} */ (this.selectedZoomPref_.value) / 100.0
+ /** @type {number} */ (this.selectedZoomPref_.value)
};
settings.display.systemDisplayApi.setDisplayProperties(
diff --git a/chromium/chrome/browser/resources/settings/device_page/display_size_slider.html b/chromium/chrome/browser/resources/settings/device_page/display_size_slider.html
index 6df59e27434..cdfd00ea678 100644
--- a/chromium/chrome/browser/resources/settings/device_page/display_size_slider.html
+++ b/chromium/chrome/browser/resources/settings/device_page/display_size_slider.html
@@ -82,6 +82,7 @@
transform: translateX(-50%);
transition: margin-top 200ms cubic-bezier(0, 0, 0.2, 1);
vertical-align: middle;
+ white-space: nowrap;
width: auto;
}
diff --git a/chromium/chrome/browser/resources/settings/device_page/display_size_slider.js b/chromium/chrome/browser/resources/settings/device_page/display_size_slider.js
index 7756bedab8b..98dfc9f627f 100644
--- a/chromium/chrome/browser/resources/settings/device_page/display_size_slider.js
+++ b/chromium/chrome/browser/resources/settings/device_page/display_size_slider.js
@@ -7,6 +7,8 @@
* display-size-slider is used to change the value of a pref via a slider
* control. This specific slider is used instead of the settings-slider due to
* its implementation of the tool tip that displays the current slider value.
+ * This component fires a |immediate-value-changed| event while the dragging is
+ * active. This event includes the immediate value of the slider.
*/
/**
@@ -121,6 +123,10 @@ Polymer({
this.setAttribute('aria-valuenow', this.ticks[this.index].value);
this.setAttribute(
'aria-valuetext', this.getLabelForIndex_(this.ticks, this.index));
+ if (this.dragging) {
+ this.fire(
+ 'immediate-value-changed', {value: this.ticks[newIndex].value});
+ }
}
},
@@ -155,7 +161,7 @@ Polymer({
* container as the slider knob before creating the ripple animation. Without
* this the PaperInkyFocusBehavior does not know where to create the ripple
* animation.
- * @private
+ * @protected
*/
_createRipple: function() {
this._rippleContainer = this.$.sliderKnob;
@@ -336,6 +342,7 @@ Polymer({
eventOffsetFromOriginX = barWidth - eventOffsetFromOriginX;
const tickWidth = barWidth / (this.ticks.length - 1);
let newTickIndex = Math.round(eventOffsetFromOriginX / tickWidth);
+ this._setDragging(true);
this.startIndex_ = this.index;
// Update the index but dont update the pref until mouse is released.
@@ -347,6 +354,8 @@ Polymer({
* @private
*/
onBarUp_: function() {
+ if (this.dragging)
+ this._setDragging(false);
if (this.startIndex_ != this.index)
this.clampIndexAndUpdatePref_(this.index);
},
@@ -480,5 +489,4 @@ Polymer({
this.updateIndex_();
},
});
-
})();
diff --git a/chromium/chrome/browser/resources/settings/device_page/drag_behavior.js b/chromium/chrome/browser/resources/settings/device_page/drag_behavior.js
index 4409e66e9fb..061c36ccf28 100644
--- a/chromium/chrome/browser/resources/settings/device_page/drag_behavior.js
+++ b/chromium/chrome/browser/resources/settings/device_page/drag_behavior.js
@@ -24,9 +24,9 @@ const DragBehavior = {
/**
* The id of the element being dragged, or empty if not dragging.
- * @private {string}
+ * @protected {string}
*/
- dragId_: '',
+ dragId: '',
/** @private {!HTMLDivElement|undefined} */
container_: undefined,
@@ -191,7 +191,7 @@ const DragBehavior = {
*/
startDrag_: function(target, eventLocation) {
assert(this.dragEnabled);
- this.dragId_ = target.id;
+ this.dragId = target.id;
this.dragStartLocation_ = eventLocation;
return false;
},
@@ -203,9 +203,9 @@ const DragBehavior = {
*/
endDrag_: function(e) {
assert(this.dragEnabled);
- if (this.dragId_ && this.callback_)
- this.callback_(this.dragId_, null);
- this.dragId_ = '';
+ if (this.dragId && this.callback_)
+ this.callback_(this.dragId, null);
+ this.dragId = '';
this.lastTouchLocation_ = null;
return false;
},
@@ -218,14 +218,14 @@ const DragBehavior = {
*/
processDrag_: function(e, eventLocation) {
assert(this.dragEnabled);
- if (!this.dragId_)
+ if (!this.dragId)
return true;
if (this.callback_) {
const delta = {
x: eventLocation.x - this.dragStartLocation_.x,
y: eventLocation.y - this.dragStartLocation_.y,
};
- this.callback_(this.dragId_, delta);
+ this.callback_(this.dragId, delta);
}
return false;
},
diff --git a/chromium/chrome/browser/resources/settings/device_page/layout_behavior.js b/chromium/chrome/browser/resources/settings/device_page/layout_behavior.js
index 0260e1f7c0b..dfd75b74461 100644
--- a/chromium/chrome/browser/resources/settings/device_page/layout_behavior.js
+++ b/chromium/chrome/browser/resources/settings/device_page/layout_behavior.js
@@ -247,7 +247,7 @@ const LayoutBehavior = {
reparentOrphan_: function(orphanId, otherOrphanIds) {
const layout = this.displayLayoutMap_.get(orphanId);
assert(layout);
- if (orphanId == this.dragId_ && layout.parentId != '') {
+ if (orphanId == this.dragId && layout.parentId != '') {
this.setCalculatedDisplayBounds_(orphanId, this.dragBounds_);
return;
}
diff --git a/chromium/chrome/browser/resources/settings/device_page/night_light_slider.js b/chromium/chrome/browser/resources/settings/device_page/night_light_slider.js
index 9f2f29bd754..7003fd0be11 100644
--- a/chromium/chrome/browser/resources/settings/device_page/night_light_slider.js
+++ b/chromium/chrome/browser/resources/settings/device_page/night_light_slider.js
@@ -541,7 +541,7 @@ Polymer({
* Overrides _createRipple() from PaperInkyFocusBehavior to create the ripple
* only on a knob if it's focused, or on a dummy hidden element so that it
* doesn't show.
- * @private
+ * @protected
*/
_createRipple: function() {
if (this.isEitherKnobFocused_()) {
diff --git a/chromium/chrome/browser/resources/settings/device_page/pointers.html b/chromium/chrome/browser/resources/settings/device_page/pointers.html
index 0fb133e2933..0595aa2bf6e 100644
--- a/chromium/chrome/browser/resources/settings/device_page/pointers.html
+++ b/chromium/chrome/browser/resources/settings/device_page/pointers.html
@@ -1,11 +1,11 @@
<link rel="import" href="chrome://resources/html/polymer.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-radio-button/paper-radio-button.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_radio_button/cr_radio_button.html">
<link rel="import" href="../controls/settings_radio_group.html">
<link rel="import" href="../controls/settings_slider.html">
<link rel="import" href="../controls/settings_toggle_button.html">
-<link rel="import" href="device_page_browser_proxy.html">
<link rel="import" href="../settings_shared_css.html">
+<link rel="import" href="device_page_browser_proxy.html">
<dom-module id="settings-pointers">
<template>
@@ -79,17 +79,15 @@
<div class="list-frame">
<settings-radio-group
pref="{{prefs.settings.touchpad.natural_scroll}}">
- <paper-radio-button name="false">
+ <cr-radio-button name="false">
$i18n{traditionalScrollLabel}
- </paper-radio-button>
- <paper-radio-button name="true">
+ </cr-radio-button>
+ <cr-radio-button name="true">
$i18n{naturalScrollLabel}
- <a href="$i18n{naturalScrollLearnMoreLink}" target="_blank"
- on-click="onLearnMoreLinkActivated_"
- on-keydown="onLearnMoreLinkActivated_">
+ <a href="$i18n{naturalScrollLearnMoreLink}" target="_blank">
$i18n{naturalScrollLearnMore}
</a>
- </paper-radio-button>
+ </cr-radio-button>
</settings-radio-group>
</div>
</div>
diff --git a/chromium/chrome/browser/resources/settings/device_page/pointers.js b/chromium/chrome/browser/resources/settings/device_page/pointers.js
index d5af548c499..4414214536d 100644
--- a/chromium/chrome/browser/resources/settings/device_page/pointers.js
+++ b/chromium/chrome/browser/resources/settings/device_page/pointers.js
@@ -37,15 +37,6 @@ Polymer({
receivedMouseSwapButtonsDown_: false,
/**
- * Prevents the link from activating its parent paper-radio-button.
- * @param {!Event} e
- * @private
- */
- onLearnMoreLinkActivated_: function(e) {
- settings.DevicePageBrowserProxyImpl.getInstance().handleLinkEvent(e);
- },
-
- /**
* Mouse and touchpad sections are only subsections if they are both present.
* @param {boolean} hasMouse
* @param {boolean} hasTouchpad
diff --git a/chromium/chrome/browser/resources/settings/device_page/power.js b/chromium/chrome/browser/resources/settings/device_page/power.js
index 112a3e88677..dfeca137bfc 100644
--- a/chromium/chrome/browser/resources/settings/device_page/power.js
+++ b/chromium/chrome/browser/resources/settings/device_page/power.js
@@ -124,7 +124,7 @@ Polymer({
*/
computeShowPowerSourceDropdown_: function(powerSources) {
return powerSources.length > 0 && powerSources.every(function(source) {
- return source.type == settings.PowerDeviceType.DUAL_ROLE_USB;
+ return !source.is_dedicated_charger;
});
},
diff --git a/chromium/chrome/browser/resources/settings/downloads_page/BUILD.gn b/chromium/chrome/browser/resources/settings/downloads_page/BUILD.gn
new file mode 100644
index 00000000000..77ad172d70c
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/downloads_page/BUILD.gn
@@ -0,0 +1,55 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":add_smb_share_dialog",
+ ":downloads_browser_proxy",
+ ":downloads_page",
+ ":smb_browser_proxy",
+ ":smb_shares_page",
+ ]
+}
+
+js_library("downloads_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("smb_shares_page") {
+ deps = [
+ ":add_smb_share_dialog",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("add_smb_share_dialog") {
+ deps = [
+ ":smb_browser_proxy",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+}
+
+js_library("smb_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("downloads_page") {
+ deps = [
+ ":downloads_browser_proxy",
+ ":smb_browser_proxy",
+ "..:page_visibility",
+ "..:route",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:util",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/downloads_page/add_smb_share_dialog.html b/chromium/chrome/browser/resources/settings/downloads_page/add_smb_share_dialog.html
index b5c9ae0b853..a809f8609bc 100644
--- a/chromium/chrome/browser/resources/settings/downloads_page/add_smb_share_dialog.html
+++ b/chromium/chrome/browser/resources/settings/downloads_page/add_smb_share_dialog.html
@@ -1,18 +1,21 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
+<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
+<link rel="import" href="chrome://resources/polymer/v1_0/paper-input/paper-input.html">
<link rel="import" href="../settings_shared_css.html">
+<link rel="import" href="../settings_vars_css.html">
<link rel="import" href="smb_browser_proxy.html">
<dom-module id="settings-add-smb-share-dialog">
<template>
<style include="settings-shared">
paper-input {
- width: var(--paper-input-max-width);
+ width: var(--settings-input-max-width);
}
-
</style>
- <dialog is="cr-dialog" id="dialog">
+ <cr-dialog id="dialog">
<div slot="title">$i18n{addSmbShare}</div>
<div slot="body" spellcheck="false">
<paper-input always-float-label id="address"
@@ -20,6 +23,15 @@
value="{{mountUrl_}}"
autofocus>
</paper-input>
+ <paper-input always-float-label id="username"
+ label="$i18n{smbShareUsername}"
+ value="{{username_}}">
+ </paper-input>
+ <paper-input always-float-label id="password"
+ type="password"
+ label="$i18n{smbSharePassword}"
+ value="{{password_}}">
+ </paper-input>
</div>
<div slot="button-container">
<paper-button class="cancel-button" on-click="cancel_" id="cancel">
@@ -30,7 +42,7 @@
$i18n{add}
</paper-button>
</div>
- </dialog>
+ </cr-dialog>
</template>
<script src="add_smb_share_dialog.js"></script>
</dom-module>
diff --git a/chromium/chrome/browser/resources/settings/downloads_page/add_smb_share_dialog.js b/chromium/chrome/browser/resources/settings/downloads_page/add_smb_share_dialog.js
index 91211017400..195fa5df376 100644
--- a/chromium/chrome/browser/resources/settings/downloads_page/add_smb_share_dialog.js
+++ b/chromium/chrome/browser/resources/settings/downloads_page/add_smb_share_dialog.js
@@ -12,6 +12,12 @@ Polymer({
properties: {
/** @private {string} */
mountUrl_: String,
+
+ /** @private {string} */
+ username_: String,
+
+ /** @private {string} */
+ password_: String,
},
/** @private {?settings.SmbBrowserProxy} */
@@ -34,7 +40,7 @@ Polymer({
/** @private */
onAddButtonTap_: function() {
- this.browserProxy_.smbMount(this.mountUrl_);
+ this.browserProxy_.smbMount(this.mountUrl_, this.username_, this.password_);
this.$.dialog.close();
},
diff --git a/chromium/chrome/browser/resources/settings/downloads_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/downloads_page/compiled_resources2.gyp
deleted file mode 100644
index caa6e280437..00000000000
--- a/chromium/chrome/browser/resources/settings/downloads_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'downloads_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'smb_shares_page',
- 'dependencies': [
- 'add_smb_share_dialog'
-
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'add_smb_share_dialog',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- 'smb_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'smb_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'downloads_page',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '../compiled_resources2.gyp:page_visibility',
- '../compiled_resources2.gyp:route',
- 'downloads_browser_proxy',
- 'smb_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/downloads_page/downloads_page.html b/chromium/chrome/browser/resources/settings/downloads_page/downloads_page.html
index 089b55a6b03..90e4ca90487 100644
--- a/chromium/chrome/browser/resources/settings/downloads_page/downloads_page.html
+++ b/chromium/chrome/browser/resources/settings/downloads_page/downloads_page.html
@@ -21,70 +21,69 @@
<settings-animated-pages id="pages" section="downloads"
focus-config="[[focusConfig_]]">
<neon-animatable route-path="default">
- <div class="settings-box first two-line">
- <div class="start">
- <div>$i18n{downloadLocation}</div>
- <div class="secondary" no-search>
+ <div class="settings-box first two-line">
+ <div class="start">
+ <div>$i18n{downloadLocation}</div>
+ <div class="secondary">
<if expr="not chromeos">
- [[prefs.download.default_directory.value]]
+ [[prefs.download.default_directory.value]]
</if>
<if expr="chromeos">
- [[getDownloadLocation_(prefs.download.default_directory.value)]]
+ [[getDownloadLocation_(prefs.download.default_directory.value)]]
</if>
+ </div>
</div>
+ <div class="separator"></div>
+ <controlled-button class="secondary-button" id="changeDownloadsPath"
+ label="$i18n{changeDownloadLocation}"
+ on-click="selectDownloadLocation_"
+ pref="[[prefs.download.default_directory]]"
+ end-justified>
+ </controlled-button>
</div>
- <div class="separator"></div>
- <controlled-button class="secondary-button" id="changeDownloadsPath"
- label="$i18n{changeDownloadLocation}"
- on-click="selectDownloadLocation_"
- pref="[[prefs.download.default_directory]]"
- end-justified>
- </controlled-button>
- </div>
- <settings-toggle-button
- pref="{{prefs.download.prompt_for_download}}"
- label="$i18n{promptForDownload}">
- </settings-toggle-button>
-<if expr="chromeos">
- <settings-toggle-button class="continuation"
- pref="{{prefs.gdata.disabled}}"
- label="$i18n{disconnectGoogleDriveAccount}"
- hidden="[[!pageVisibility.googleDrive]]">
- </settings-toggle-button>
-</if>
+ <settings-toggle-button
+ pref="{{prefs.download.prompt_for_download}}"
+ label="$i18n{promptForDownload}">
+ </settings-toggle-button>
<if expr="chromeos">
- <template is="dom-if" if="[[enableSmbSettings_]]">
- <div id="smbShares" class="settings-box"
- on-click="onTapSmbShares_" actionable>
- <div class="start"> $i18n{smbSharesTitle} </div>
- <paper-icon-button-light class="subpage-arrow">
- <button aria-label="$i18n{smbSharesTitle}"></button>
- </paper-icon-button-light>
- </div>
- </template>
+ <settings-toggle-button class="continuation"
+ pref="{{prefs.gdata.disabled}}"
+ label="$i18n{disconnectGoogleDriveAccount}"
+ hidden="[[!pageVisibility.googleDrive]]">
+ </settings-toggle-button>
+ <template is="dom-if" if="[[enableSmbSettings_]]">
+ <div id="smbShares" class="settings-box"
+ on-click="onTapSmbShares_" actionable>
+ <div class="start"> $i18n{smbSharesTitle} </div>
+ <paper-icon-button-light class="subpage-arrow">
+ <button aria-label="$i18n{smbSharesTitle}"></button>
+ </paper-icon-button-light>
+ </div>
+ </template>
</if>
-</neon-animatable>
- <template is="dom-if" if="[[autoOpenDownloads_]]" restamp>
- <div class="settings-box">
- <div class="start">
- $i18n{openFileTypesAutomatically}
+ <template is="dom-if" if="[[autoOpenDownloads_]]" restamp>
+ <div class="settings-box">
+ <div class="start">
+ $i18n{openFileTypesAutomatically}
+ </div>
+ <div class="separator"></div>
+ <paper-button id="resetAutoOpenFileTypes" class="secondary-button"
+ on-click="onClearAutoOpenFileTypesTap_">
+ $i18n{clear}
+ </paper-button>
</div>
- <div class="separator"></div>
- <paper-button id="resetAutoOpenFileTypes" class="secondary-button"
- on-click="onClearAutoOpenFileTypesTap_">
- $i18n{clear}
- </paper-button>
- </div>
- </template>
-<if expr="chromeos">
- <template is="dom-if" route-path="/smbShares">
- <settings-subpage
- associated-control="[[$$('#smbShares')]]"
- page-title="$i18n{smbSharesTitle}">
- <settings-smb-shares-page>
- </settings-smb-shares-page>
- </settings-subpage>
</template>
+ </neon-animatable>
+
+<if expr="chromeos">
+ <template is="dom-if" route-path="/smbShares">
+ <settings-subpage
+ associated-control="[[$$('#smbShares')]]"
+ page-title="$i18n{smbSharesTitle}">
+ <settings-smb-shares-page>
+ </settings-smb-shares-page>
+ </settings-subpage>
+ </template>
</if>
</settings-animated-pages>
</template>
diff --git a/chromium/chrome/browser/resources/settings/downloads_page/smb_browser_proxy.js b/chromium/chrome/browser/resources/settings/downloads_page/smb_browser_proxy.js
index 94abaa2b38b..e06a5fce088 100644
--- a/chromium/chrome/browser/resources/settings/downloads_page/smb_browser_proxy.js
+++ b/chromium/chrome/browser/resources/settings/downloads_page/smb_browser_proxy.js
@@ -7,6 +7,20 @@
* interact with the browser. Used only on Chrome OS.
*/
+/**
+ * @enum {number}
+ * These values must be kept in sync with the SmbMountResult enum in
+ * chrome/browser/chromeos/smb_client/smb_service.h.
+ */
+const SmbMountResult = {
+ SUCCESS: 0,
+ UNKNOWN_FAILURE: 1,
+ AUTHENTICATION_FAILED: 2,
+ NOT_FOUND: 3,
+ UNSUPPORTED_DEVICE: 4,
+ MOUNT_EXISTS: 5,
+};
+
cr.define('settings', function() {
/** @interface */
class SmbBrowserProxy {
@@ -14,14 +28,14 @@ cr.define('settings', function() {
* Attempts to mount an Smb filesystem with the provided url.
* @param {string} smbUrl
*/
- smbMount(smbUrl) {}
+ smbMount(smbUrl, username, password) {}
}
/** @implements {settings.SmbBrowserProxy} */
class SmbBrowserProxyImpl {
/** @override */
- smbMount(smbUrl) {
- chrome.send('smbMount', [smbUrl]);
+ smbMount(smbUrl, username, password) {
+ chrome.send('smbMount', [smbUrl, username, password]);
}
}
diff --git a/chromium/chrome/browser/resources/settings/downloads_page/smb_shares_page.html b/chromium/chrome/browser/resources/settings/downloads_page/smb_shares_page.html
index 17876267835..83406eaf117 100644
--- a/chromium/chrome/browser/resources/settings/downloads_page/smb_shares_page.html
+++ b/chromium/chrome/browser/resources/settings/downloads_page/smb_shares_page.html
@@ -1,8 +1,10 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_toast/cr_toast.html">
<link rel="import" href="chrome://resources/html/action_link.html">
<link rel="import" href="chrome://resources/html/action_link_css.html">
<link rel="import" href="chrome://resources/html/assert.html">
+<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<link rel="import" href="chrome://resources/html/md_select_css.html">
<link rel="import" href="../settings_shared_css.html">
@@ -22,7 +24,7 @@
$i18n{requireNetworkMessage}
</div>
</div>
- <paper-button class="primary-button" id="addShare"
+ <paper-button class="action-button" id="addShare"
on-click="onAddShareTap_">
$i18n{addSmbShare}
</paper-button>
@@ -31,6 +33,12 @@
<settings-add-smb-share-dialog on-close="onAddSmbDialogClosed_">
</settings-add-smb-share-dialog>
</template>
+
+ <cr-toast id="errorToast" duration="3000">
+ <div class="error-message" id="addShareDoneMessage">
+ [[addShareResultText_]]
+ </div>
+ </cr-toast>
</template>
<script src="smb_shares_page.js"></script>
</dom-module>
diff --git a/chromium/chrome/browser/resources/settings/downloads_page/smb_shares_page.js b/chromium/chrome/browser/resources/settings/downloads_page/smb_shares_page.js
index 09d58992bd1..04829640903 100644
--- a/chromium/chrome/browser/resources/settings/downloads_page/smb_shares_page.js
+++ b/chromium/chrome/browser/resources/settings/downloads_page/smb_shares_page.js
@@ -5,9 +5,19 @@
Polymer({
is: 'settings-smb-shares-page',
+ behaviors: [WebUIListenerBehavior],
+
properties: {
/** @private */
showAddSmbDialog_: Boolean,
+
+ /** @private */
+ addShareResultText_: String,
+ },
+
+ /** @override */
+ attached: function() {
+ this.addWebUIListener('on-add-smb-share', this.onAddShare_.bind(this));
},
/** @private */
@@ -20,4 +30,37 @@ Polymer({
this.showAddSmbDialog_ = false;
},
+ /**
+ * @param {SmbMountResult} result
+ * @private
+ */
+ onAddShare_: function(result) {
+ switch (result) {
+ case SmbMountResult.SUCCESS:
+ this.addShareResultText_ =
+ loadTimeData.getString('smbShareAddedSuccessfulMessage');
+ break;
+ case SmbMountResult.AUTHENTICATION_FAILED:
+ this.addShareResultText_ =
+ loadTimeData.getString('smbShareAddedAuthFailedMessage');
+ break;
+ case SmbMountResult.NOT_FOUND:
+ this.addShareResultText_ =
+ loadTimeData.getString('smbShareAddedNotFoundMessage');
+ break;
+ case SmbMountResult.UNSUPPORTED_DEVICE:
+ this.addShareResultText_ =
+ loadTimeData.getString('smbShareAddedUnsupportedDeviceMessage');
+ break;
+ case SmbMountResult.MOUNT_EXISTS:
+ this.addShareResultText_ =
+ loadTimeData.getString('smbShareAddedMountExistsMessage');
+ break;
+ default:
+ this.addShareResultText_ =
+ loadTimeData.getString('smbShareAddedErrorMessage');
+ }
+ this.$.errorToast.show();
+ },
+
});
diff --git a/chromium/chrome/browser/resources/settings/find_shortcut_behavior.html b/chromium/chrome/browser/resources/settings/find_shortcut_behavior.html
new file mode 100644
index 00000000000..4fedd0e11f1
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/find_shortcut_behavior.html
@@ -0,0 +1,4 @@
+<link rel="import" href="chrome://resources/html/assert.html">
+<link rel="import" href="chrome://resources/html/cr.html">
+<link rel="import" href="chrome://resources/polymer/v1_0/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html">
+<script src="find_shortcut_behavior.js"></script>
diff --git a/chromium/chrome/browser/resources/settings/find_shortcut_behavior.js b/chromium/chrome/browser/resources/settings/find_shortcut_behavior.js
new file mode 100644
index 00000000000..51103e5b683
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/find_shortcut_behavior.js
@@ -0,0 +1,51 @@
+// 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.
+
+/**
+ * @fileoverview Listens for a find keyboard shortcut (i.e. Ctrl/Cmd+f) wherever
+ * this behavior is applied and invokes canHandleFindShortcut(). If
+ * canHandleFindShortcut() returns true, handleFindShortcut() will be called.
+ * Override these methods in your element in order to use this behavior.
+ */
+
+cr.exportPath('settings');
+
+/** @polymerBehavior */
+settings.FindShortcutBehaviorImpl = {
+ keyBindings: {
+ // <if expr="is_macosx">
+ 'meta+f': 'onFindShortcut_',
+ // </if>
+ // <if expr="not is_macosx">
+ 'ctrl+f': 'onFindShortcut_',
+ // </if>
+ },
+
+ /** @private */
+ onFindShortcut_: function(e) {
+ if (!e.defaultPrevented && this.canHandleFindShortcut()) {
+ this.handleFindShortcut();
+ e.preventDefault();
+ }
+ },
+
+ /**
+ * @return {boolean}
+ * @protected
+ */
+ canHandleFindShortcut: function() {
+ assertNotReached();
+ },
+
+ /** @protected */
+ handleFindShortcut: function() {
+ assertNotReached();
+ },
+};
+
+/** @polymerBehavior */
+settings.FindShortcutBehavior = [
+ Polymer.IronA11yKeysBehavior,
+ settings.FindShortcutBehaviorImpl,
+];
diff --git a/chromium/chrome/browser/resources/settings/google_assistant_page/BUILD.gn b/chromium/chrome/browser/resources/settings/google_assistant_page/BUILD.gn
new file mode 100644
index 00000000000..b75831dd07b
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/google_assistant_page/BUILD.gn
@@ -0,0 +1,28 @@
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":google_assistant_browser_proxy",
+ ":google_assistant_page",
+ ]
+}
+
+js_library("google_assistant_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/chrome_send.js" ]
+}
+
+js_library("google_assistant_page") {
+ deps = [
+ ":google_assistant_browser_proxy",
+ "../prefs:prefs_behavior",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/google_assistant_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/google_assistant_page/compiled_resources2.gyp
deleted file mode 100644
index 2ce6c64c5c4..00000000000
--- a/chromium/chrome/browser/resources/settings/google_assistant_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'google_assistant_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):chrome_send',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'google_assistant_page',
- 'dependencies': [
- '../prefs/compiled_resources2.gyp:prefs_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- 'google_assistant_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/icons.html b/chromium/chrome/browser/resources/settings/icons.html
index 56ce0c7a469..c939fe6599b 100644
--- a/chromium/chrome/browser/resources/settings/icons.html
+++ b/chromium/chrome/browser/resources/settings/icons.html
@@ -27,8 +27,14 @@ List icons here rather than importing large sets of (e.g. Polymer) icons.
<path fill="none" d="M1 1h22v22H1z"></path>
</g>
- <!-- Icons from https://icons.googleplex.com. -->
<if expr="chromeos">
+ <!-- Crostini Mascot icon for Settings drawer -->
+ <g id="crostini-mascot" fill-rule="evenodd">
+ <rect width="24" height="24" fill="none"></rect>
+ <path d="M6.70994751,22.1802367 C3.77039152,20.9576222 1.88689678,18.4876617 1.82270453,14.1866283 C1.52620735,14.3410271 1.18877909,14.3669908 0.800057996,14.221322 C-0.312414045,13.804436 -0.0624529958,12.4120387 0.345560769,11.1705211 C0.68346303,10.142341 1.83735671,9.39181671 2.40240955,9.23479478 C3.71763772,4.05541221 6.80346772,0 12,0 C17.2584272,0 20.3654882,3.88805047 21.6436562,9.24850027 C22.2231374,9.43172978 23.3254781,10.1695473 23.6544392,11.1705211 C24.062453,12.4120387 24.312414,13.804436 23.199942,14.221322 C22.8112853,14.3669667 22.4739044,14.3410357 22.1774428,14.186705 C22.1189307,18.5169382 20.2342349,20.9750038 17.2936622,22.1879533 C17.3379726,22.2841737 17.3614392,22.3916932 17.3614392,22.5115654 C17.3614392,23.3336051 17.750632,24 14.8965517,24 C12.813813,24 12.4581871,23.5470722 12.4180882,23.0543665 C12.2796354,22.9647547 12.14026,22.8305157 12,22.8305157 C11.8594243,22.8305157 11.7197425,22.9755283 11.5809922,23.0650454 C11.536581,23.553597 11.171131,24 9.10344828,24 C6.24936798,24 6.63856075,23.3336051 6.63856075,22.5115654 C6.63856075,22.3884786 6.66330281,22.278416 6.70994751,22.1802367 Z M12,20.3378361 C17.4851654,20.3378361 19.4630542,17.934489 19.4630542,12.6147346 C19.4630542,8.20063746 17.6641739,4.14700996 14.6790451,3.47027327 C13.7222433,3.25336374 13.052482,5.61336212 12,5.61336212 C10.947518,5.61336212 10.1820765,3.25336374 9.32095491,3.47027327 C6.32316904,4.22539115 4.53694581,8.43392639 4.53694581,12.6147346 C4.53694581,17.6346061 6.51483457,20.3378361 12,20.3378361 Z M8.27586207,9.99377535 C7.59026721,9.99377535 7.03448276,9.42257974 7.03448276,8.71797424 C7.03448276,8.01336875 7.59026721,7.44217314 8.27586207,7.44217314 C8.96145693,7.44217314 9.51724138,8.01336875 9.51724138,8.71797424 C9.51724138,9.42257974 8.96145693,9.99377535 8.27586207,9.99377535 Z M15.7241379,9.99377535 C15.0385431,9.99377535 14.4827586,9.42257974 14.4827586,8.71797424 C14.4827586,8.01336875 15.0385431,7.44217314 15.7241379,7.44217314 C16.4097328,7.44217314 16.9655172,8.01336875 16.9655172,8.71797424 C16.9655172,9.42257974 16.4097328,9.99377535 15.7241379,9.99377535 Z M12.224615,10.6827627 L13.9283449,11.4510541 C14.2234366,11.5841248 14.3564393,11.9349546 14.2254148,12.2346546 C14.1996198,12.293657 14.1645229,12.3479919 14.1215061,12.39552 L12.4275305,14.2671455 C12.2090286,14.5085621 11.8392003,14.5243719 11.6014958,14.3024578 C11.5890079,14.2907994 11.5770255,14.2785946 11.5655826,14.265878 L9.87720766,12.3895636 C9.65939502,12.1475054 9.67603268,11.771949 9.91436891,11.5507349 C9.9604013,11.5080095 10.012868,11.4730393 10.0697797,11.4471502 L11.7484004,10.6835476 C11.8998356,10.6146599 12.0729604,10.6143745 12.224615,10.6827627 Z"></path>
+ </g>
+
+ <!-- Icons from https://icons.googleplex.com. -->
<g id="play-prism"><path fill="#5A5A5A" d="M20.18 10.88l-3.06-1.74L14.26 12l2.86 2.86 3.06-1.74c.55-.31.82-.71.82-1.12 0-.41-.27-.81-.82-1.12zM4.71 2.45l8.42 8.42 2.55-2.55-10.7-6.06c-.07-.04-.14-.07-.21-.1-.17-.07-.3.05-.15.21.03.02.06.05.09.08zm0 19.1l-.08.08c-.15.15-.02.28.15.21.07-.03.14-.06.21-.1l10.69-6.06-2.55-2.55s-7.2 7.21-8.42 8.42zM12 12L3.38 3.38c-.19-.19-.38-.07-.38.19v16.86c0 .26.19.38.38.19L12 12z"></path></g>
</if>
@@ -87,7 +93,6 @@ List icons here rather than importing large sets of (e.g. Polymer) icons.
<if expr="chromeos">
<g id="laptop-chromebook"><path d="M22 18V3H2v15H0v2h24v-2h-2zm-8 0h-4v-1h4v1zm6-3H4V5h16v10z"></path></g>
</if>
- <g id="list"><path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"></path></g>
<g id="location-on"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"></path></g>
<g id="mic"><path d="M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72h-1.7z"></path></g>
<g id="midi"><path d="M21,19.1H3V5h18V19.1z M21,3H3C1.9,3,1,3.9,1,5v14c0,1.1,0.9,2,2,2h18c1.1,0,2-0.9,2-2V5C23,3.9,22.1,3,21,3z"></path><path fill="none" d="M21,19.1H3V5h18V19.1z M21,3H3C1.9,3,1,3.9,1,5v14c0,1.1,0.9,2,2,2h18c1.1,0,2-0.9,2-2V5C23,3.9,22.1,3,21,3z"></path><path d="M14,5h3v8h-3V5z"></path><path d="M15,12h1v8h-1V12z"></path><path fill="none" d="M0,0h24v24H0V0z"></path><rect x="7" y="5" width="3" height="8"></rect><rect x="8" y="12" width="1" height="8"></rect></g>
diff --git a/chromium/chrome/browser/resources/settings/images/sync_banner.png b/chromium/chrome/browser/resources/settings/images/sync_banner.png
deleted file mode 100644
index 3e6295b9338..00000000000
--- a/chromium/chrome/browser/resources/settings/images/sync_banner.png
+++ /dev/null
Binary files differ
diff --git a/chromium/chrome/browser/resources/settings/images/sync_banner.svg b/chromium/chrome/browser/resources/settings/images/sync_banner.svg
new file mode 100644
index 00000000000..a0027951f54
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/images/sync_banner.svg
@@ -0,0 +1,32 @@
+<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 680 120">
+ <style>
+ .st0{fill:#bdc0c5}.st1{fill:#e8e9eb}.st7{fill:#fff}
+ </style>
+ <path class="st0" d="M229.3 61.3h-.7V26.1c0-4.4 3.6-8 8-8H260v.7h-23.4c-4.1 0-7.4 3.3-7.4 7.4v35.1z"/>
+ <path class="st1" d="M188.5 79.2c8.1 0 14.7 6.4 15.1 14.4H163c.3-5.1 4.6-9.2 9.8-9.2 1.1 0 2.2.2 3.3.6l.4.2.3-.4c2.9-3.6 7.2-5.6 11.7-5.6m0-.7c-4.9 0-9.3 2.3-12.2 5.8a10.5 10.5 0 0 0-14 9.9h42c0-8.7-7.1-15.7-15.8-15.7z"/>
+ <path class="st0" d="M248.2 103.8h-11.6c-4.1 0-7.4-3.3-7.4-7.4V61.3h-.7v35.2c0 4.4 3.6 8 8 8h11.6v-.7zm21.7-85.3v.7c2.9 1 4.9 3.7 4.9 6.9v35.7h.7V26.1c-.1-3.5-2.4-6.6-5.6-7.6z"/>
+ <path class="st1" d="M265.9 100.1h-28.2c-2.9 0-5.2-2.3-5.2-5.2V27.4c0-2.9 2.3-5.2 5.2-5.2h28.2c2.9 0 5.2 2.3 5.2 5.2v67.5a5.1 5.1 0 0 1-5.2 5.2zm-28.2-77.3c-2.5 0-4.6 2-4.6 4.6v67.5c0 2.5 2 4.6 4.6 4.6h28.2c2.5 0 4.6-2 4.6-4.6V27.4c0-2.5-2-4.6-4.6-4.6h-28.2z"/>
+ <path d="M274.8 89.6v6.8c0 4.1-3.3 7.4-7.4 7.4h-11.6v.7h11.6c4.4 0 8-3.6 8-8v-6.8c0-.1-.6-.1-.6-.1z" fill="#e54440"/>
+ <path class="st1" d="M314.5 45.6c10.8 0 19.7 8.8 19.7 19.7S325.4 85 314.5 85s-19.7-8.8-19.7-19.7 8.9-19.7 19.7-19.7m0-1.3a21 21 0 1 0 0 42 21 21 0 0 0 0-42z"/>
+ <circle cx="325.2" cy="73.2" r="2.6" fill="#4b87f1"/>
+ <circle cx="281.6" cy="65.3" r="21" fill="#34a751"/>
+ <path d="M293.6 65.3c0 4.9 1.7 9.4 4.5 13 2.8-3.6 4.5-8.1 4.5-13s-1.7-9.4-4.5-13c-2.9 3.6-4.5 8.1-4.5 13z" opacity=".12"/>
+ <path d="M228.6 37.9v-5.2c10.7 0 19.2-3 25.1-9C263 14.4 263 .7 263 .6h5.2c0 .6 0 15.9-10.8 26.8-6.9 6.9-16.6 10.5-28.8 10.5z" fill="#f7bb2a"/>
+ <path class="st1" d="M193.9 68.7h-5.2c0-.4.1-9.1 5-18 4.6-8.2 14.4-18 35-18v5.2c-14.5 0-24.7 5.2-30.4 15.4-4.4 7.6-4.4 15.3-4.4 15.4z"/>
+ <path class="st7" d="M281.4 73.5V71h.3v1.7l2.5-2.5-2.5-2.5v1.7h-.3V67l3.3 3.3-3.3 3.2zm.3-10l-3.3-3.3 3.3-3.3v2.5h-.3v-1.7l-2.5 2.5 2.5 2.5V61h.3v2.5z"/>
+ <path class="st7" d="M286.1 67.9l-.3-.2a4.9 4.9 0 0 0-4.2-7.4V60c2.9 0 5.2 2.3 5.2 5.2a6 6 0 0 1-.7 2.7zm-4.5 2.6c-2.9 0-5.2-2.3-5.2-5.2 0-.9.2-1.8.7-2.6l.3.2a4.9 4.9 0 0 0 4.2 7.4v.2z"/>
+ <path class="st0" d="M56 57.6H38.2v-.3c0-4.9 4-8.9 8.9-8.9s8.9 4 8.9 8.9v.3zm-17.3-.5h16.7c-.1-4.5-3.8-8.1-8.4-8.1s-8.1 3.6-8.3 8.1z"/>
+ <path class="st1" d="M216.8 68.6h-17.3c0-4.8 3.9-8.6 8.6-8.6a8.5 8.5 0 0 1 8.7 8.6z"/>
+ <path d="M169.6 100.2H78.9V40.6c0-2.9 2.4-5.3 5.3-5.3h80.2c2.9 0 5.3 2.4 5.3 5.3v59.6z" fill="#f4f4f4"/>
+ <path class="st0" d="M165.3 35.9c2.1 0 3.8 1.7 3.8 3.8v59.9H79.4V39.7c0-2.1 1.7-3.8 3.8-3.8h82.1m0-.5H83.2c-2.4 0-4.3 1.9-4.3 4.3v60.5h90.7V39.7c0-2.4-1.9-4.3-4.3-4.3zm-99.4 68.5h116.6v.5H65.9z"/>
+ <path class="st7" d="M84.6 58.1c-4.1 0-7.7 1.9-10.1 4.8A8.6 8.6 0 0 0 63 71h34.5c.1-7.1-5.7-12.9-12.9-12.9z"/>
+ <path class="st0" d="M97.8 71.3H62.7V71c0-4.9 4-8.9 8.9-8.9.9 0 1.9.2 2.8.5 2.5-3 6.2-4.8 10.2-4.8 7.3 0 13.2 5.9 13.2 13.2v.3zm-34.5-.5h34c-.1-6.9-5.8-12.4-12.7-12.4-3.8 0-7.4 1.7-9.9 4.7l-.1.1-.2-.1c-.9-.3-1.8-.5-2.8-.5-4.5.1-8.2 3.7-8.3 8.2z"/>
+ <path d="M38.1 82l3.7-3.7c7.6 7.6 15.7 11.4 24.1 11.4 13.2 0 22.9-9.7 23-9.8l3.7 3.7c-.5.5-11.3 11.3-26.6 11.4-9.9 0-19.3-4.3-27.9-13z" fill="#4285f4"/>
+ <path class="st1" d="M4.3 66.4c-1.5.4-3 1-4.3 1.5v5.8c1.7-.8 3.6-1.6 5.8-2.2 11.2-3.3 22.1.3 32.3 10.5l3.7-3.7C27.3 63.8 13.4 63.8 4.3 66.4z"/>
+ <path class="st0" d="M636.6 39.4c-1.5 0-3-.3-4.4-.9-2.7-1.2-4.9-3.4-6-6.1s-1.1-5.8.1-8.6c1.2-2.7 3.4-4.9 6.1-6 2.8-1.1 5.8-1.1 8.6.1 2.7 1.2 4.9 3.4 6 6.1s1.1 5.8-.1 8.6c-1.2 2.7-3.4 4.9-6.1 6-1.4.5-2.8.8-4.2.8zm0-21.7c-1.3 0-2.7.3-3.9.8-2.6 1-4.7 3.1-5.8 5.7-1.1 2.6-1.1 5.5-.1 8.1 1 2.6 3.1 4.7 5.7 5.8s5.5 1.1 8.1.1 4.7-3.1 5.8-5.7c1.1-2.6 1.1-5.5.1-8.1s-3.1-4.7-5.7-5.8c-1.3-.7-2.8-.9-4.2-.9zm-104.4 95.2h.6v7.1h-.6zm93.6-33.6c0-3.7-3-6.8-6.8-6.8h-12v.6h12c3.4 0 6.2 2.8 6.2 6.2V120h.6V79.3zM607 73.2h-46l3-.6h43z"/>
+ <path class="st0" d="M532.8 99.9h-.6V79.3c0-3.7 3-6.8 6.8-6.8h29.5v.6H539c-3.4 0-6.2 2.8-6.2 6.2v20.6z"/>
+ <path class="st7" d="M540 93c-4.5 0-8.6 2.1-11.2 5.4-1-.4-2.1-.6-3.2-.6a9.6 9.6 0 0 0-9.6 9.6h38.4c0-8-6.4-14.4-14.4-14.4z"/>
+ <path class="st0" d="M554.7 107.7h-39v-.3a9.86 9.86 0 0 1 13-9.4c2.8-3.4 6.9-5.3 11.3-5.3 8.1 0 14.7 6.6 14.7 14.7v.3zm-38.4-.6h37.8a14.15 14.15 0 0 0-25.1-8.6l-.1.2-.2-.1c-1-.4-2.1-.5-3.1-.5-5 0-9.1 4-9.3 9z"/>
+ <path fill="none" d="M498.7 29.6L534.3-.8"/>
+ <path class="st1" d="M498.4 29.2l.6.7L534.2 0h-1.6zm143 26.6h-5.8c0 .4.1 10.2 5.6 20 5.1 9.1 16 20.1 38.8 20.1V90c-16.1 0-27.4-5.7-33.8-17.1-4.7-8.5-4.8-17.1-4.8-17.1z"/>
+</svg>
diff --git a/chromium/chrome/browser/resources/settings/images/sync_banner_2x.png b/chromium/chrome/browser/resources/settings/images/sync_banner_2x.png
deleted file mode 100644
index 47ff921d4a5..00000000000
--- a/chromium/chrome/browser/resources/settings/images/sync_banner_2x.png
+++ /dev/null
Binary files differ
diff --git a/chromium/chrome/browser/resources/settings/incompatible_applications_page/BUILD.gn b/chromium/chrome/browser/resources/settings/incompatible_applications_page/BUILD.gn
new file mode 100644
index 00000000000..78dfe00d561
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/incompatible_applications_page/BUILD.gn
@@ -0,0 +1,36 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":incompatible_application_item",
+ ":incompatible_applications_browser_proxy",
+ ":incompatible_applications_page",
+ ]
+}
+
+js_library("incompatible_applications_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("incompatible_applications_page") {
+ deps = [
+ ":incompatible_applications_browser_proxy",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("incompatible_application_item") {
+ deps = [
+ ":incompatible_applications_browser_proxy",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/incompatible_applications_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/incompatible_applications_page/compiled_resources2.gyp
deleted file mode 100644
index c73f9ebe50a..00000000000
--- a/chromium/chrome/browser/resources/settings/incompatible_applications_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,33 +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.
-{
- 'targets': [
- {
- 'target_name': 'incompatible_applications_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'incompatible_applications_page',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- 'incompatible_applications_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'incompatible_application_item',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- 'incompatible_applications_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/incompatible_applications_page/incompatible_application_item.html b/chromium/chrome/browser/resources/settings/incompatible_applications_page/incompatible_application_item.html
index 1f8027ae747..98ab469bde5 100644
--- a/chromium/chrome/browser/resources/settings/incompatible_applications_page/incompatible_application_item.html
+++ b/chromium/chrome/browser/resources/settings/incompatible_applications_page/incompatible_application_item.html
@@ -16,7 +16,7 @@
<div class="list-item">
<div class="start">[[applicationName]]</div>
<div class="separator"></div>
- <paper-button class="primary-button" on-click="onActionTap_">
+ <paper-button class="action-button" on-click="onActionTap_">
[[getActionName_(actionType)]]
</paper-button>
</div>
diff --git a/chromium/chrome/browser/resources/settings/incompatible_applications_page/incompatible_application_item.js b/chromium/chrome/browser/resources/settings/incompatible_applications_page/incompatible_application_item.js
index 72dd7f1941e..ee406fe4517 100644
--- a/chromium/chrome/browser/resources/settings/incompatible_applications_page/incompatible_application_item.js
+++ b/chromium/chrome/browser/resources/settings/incompatible_applications_page/incompatible_application_item.js
@@ -6,7 +6,7 @@
* @fileoverview
* 'incompatible-application-item' represents one item in a "list-box" of
* incompatible applications, as defined in
- * chrome/browser/conflicts/problematic_programs_updater_win.h.
+ * chrome/browser/conflicts/incompatible_applications_updater_win.h.
* This element contains a button that can be used to remove or update the
* incompatible application, depending on the value of the action-type property.
*
@@ -41,7 +41,7 @@ Polymer({
properties: {
/**
* The name of the application to be displayed. Also used for the UNINSTALL
- * action, where the name is passed to the startProgramUninstallation()
+ * action, where the name is passed to the startApplicationUninstallation()
* call.
*/
applicationName: String,
@@ -77,7 +77,7 @@ Polymer({
*/
onActionTap_: function() {
if (this.actionType === settings.ActionTypes.UNINSTALL) {
- this.browserProxy_.startProgramUninstallation(this.applicationName);
+ this.browserProxy_.startApplicationUninstallation(this.applicationName);
} else if (
this.actionType === settings.ActionTypes.MORE_INFO ||
this.actionType === settings.ActionTypes.UPGRADE) {
diff --git a/chromium/chrome/browser/resources/settings/incompatible_applications_page/incompatible_applications_browser_proxy.js b/chromium/chrome/browser/resources/settings/incompatible_applications_page/incompatible_applications_browser_proxy.js
index 7017e0a469d..4eb017bfe42 100644
--- a/chromium/chrome/browser/resources/settings/incompatible_applications_page/incompatible_applications_browser_proxy.js
+++ b/chromium/chrome/browser/resources/settings/incompatible_applications_page/incompatible_applications_browser_proxy.js
@@ -42,10 +42,11 @@ cr.define('settings', function() {
requestIncompatibleApplicationsList() {}
/**
- * Launches the Apps & Features page that allows uninstalling 'programName'.
- * @param {string} programName
+ * Launches the Apps & Features page that allows uninstalling
+ * 'applicationName'.
+ * @param {string} applicationName
*/
- startProgramUninstallation(programName) {}
+ startApplicationUninstallation(applicationName) {}
/**
* Opens the specified URL in a new tab.
@@ -86,8 +87,8 @@ cr.define('settings', function() {
}
/** @override */
- startProgramUninstallation(programName) {
- chrome.send('startProgramUninstallation', [programName]);
+ startApplicationUninstallation(applicationName) {
+ chrome.send('startApplicationUninstallation', [applicationName]);
}
/** @override */
diff --git a/chromium/chrome/browser/resources/settings/internet_page/BUILD.gn b/chromium/chrome/browser/resources/settings/internet_page/BUILD.gn
new file mode 100644
index 00000000000..67475fdf8bd
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/internet_page/BUILD.gn
@@ -0,0 +1,141 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":internet_config",
+ ":internet_detail_page",
+ ":internet_known_networks_page",
+ ":internet_page",
+ ":internet_page_browser_proxy",
+ ":internet_subpage",
+ ":network_proxy_section",
+ ":network_summary",
+ ":network_summary_item",
+ ":tether_connection_dialog",
+ ]
+}
+
+js_library("internet_page") {
+ deps = [
+ ":internet_config",
+ ":internet_page_browser_proxy",
+ "..:route",
+ "../settings_page:settings_animated_pages",
+ "//ui/webui/resources/cr_elements/chromeos/network:cr_onc_types",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+ externs_list = [
+ "$externs_path/chrome_send.js",
+ "$externs_path/management.js",
+ "$externs_path/networking_private.js",
+ ]
+ extra_sources = [ "$interfaces_path/networking_private_interface.js" ]
+}
+
+js_library("internet_page_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("internet_config") {
+ deps = [
+ "..:route",
+ "//ui/webui/resources/cr_components/chromeos/network:network_config",
+ "//ui/webui/resources/cr_elements/chromeos/network:cr_onc_types",
+ "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:util",
+ ]
+ externs_list = [ "$externs_path/networking_private.js" ]
+ extra_sources = [ "$interfaces_path/networking_private_interface.js" ]
+}
+
+js_library("internet_detail_page") {
+ deps = [
+ ":internet_page_browser_proxy",
+ ":tether_connection_dialog",
+ "..:route",
+ "//ui/webui/resources/cr_elements/chromeos/network:cr_onc_types",
+ "//ui/webui/resources/cr_elements/policy:cr_policy_network_behavior",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+ externs_list = [
+ "$externs_path/chrome_send.js",
+ "$externs_path/networking_private.js",
+ ]
+ extra_sources = [ "$interfaces_path/networking_private_interface.js" ]
+}
+
+js_library("internet_known_networks_page") {
+ deps = [
+ "//ui/webui/resources/cr_elements/chromeos/network:cr_onc_types",
+ "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
+ "//ui/webui/resources/cr_elements/policy:cr_policy_network_behavior",
+ "//ui/webui/resources/js:assert",
+ ]
+ externs_list = [ "$externs_path/networking_private.js" ]
+ extra_sources = [ "$interfaces_path/networking_private_interface.js" ]
+}
+
+js_library("internet_subpage") {
+ deps = [
+ ":internet_page_browser_proxy",
+ "..:route",
+ "//ui/webui/resources/cr_elements/chromeos/network:cr_onc_types",
+ "//ui/webui/resources/cr_elements/policy:cr_policy_network_behavior",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+ externs_list = [ "$externs_path/networking_private.js" ]
+ extra_sources = [ "$interfaces_path/networking_private_interface.js" ]
+}
+
+js_library("network_proxy_section") {
+ deps = [
+ "..:route",
+ "../controls:settings_checkbox",
+ "../prefs:prefs_behavior",
+ "//ui/webui/resources/cr_components/chromeos/network:network_proxy",
+ "//ui/webui/resources/cr_elements/chromeos/network:cr_onc_types",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+}
+
+js_library("network_summary") {
+ deps = [
+ "//ui/webui/resources/cr_elements/chromeos/network:cr_onc_types",
+ "//ui/webui/resources/cr_elements/policy:cr_policy_network_behavior",
+ "//ui/webui/resources/js:assert",
+ ]
+ extra_sources = [ "$interfaces_path/networking_private_interface.js" ]
+}
+
+js_library("network_summary_item") {
+ deps = [
+ "//ui/webui/resources/cr_elements/chromeos/network:cr_onc_types",
+ "//ui/webui/resources/cr_elements/policy:cr_policy_network_behavior",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+ extra_sources = [ "$interfaces_path/networking_private_interface.js" ]
+}
+
+js_library("tether_connection_dialog") {
+ deps = [
+ "//ui/webui/resources/cr_elements/chromeos/network:cr_onc_types",
+ "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/internet_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/internet_page/compiled_resources2.gyp
deleted file mode 100644
index cec4fe353b2..00000000000
--- a/chromium/chrome/browser/resources/settings/internet_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,134 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'internet_page',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '../settings_page/compiled_resources2.gyp:settings_animated_pages',
- '<(DEPTH)/ui/webui/resources/cr_elements/chromeos/network/compiled_resources2.gyp:cr_onc_types',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '<(EXTERNS_GYP):chrome_send',
- '<(EXTERNS_GYP):management',
- '<(EXTERNS_GYP):networking_private',
- '<(INTERFACES_GYP):networking_private_interface',
- 'internet_config',
- 'internet_page_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'internet_page_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'internet_config',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '<(DEPTH)/ui/webui/resources/cr_components/chromeos/network/compiled_resources2.gyp:network_config',
- '<(DEPTH)/ui/webui/resources/cr_elements/chromeos/network/compiled_resources2.gyp:cr_onc_types',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_dialog/compiled_resources2.gyp:cr_dialog',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- '<(EXTERNS_GYP):networking_private',
- '<(INTERFACES_GYP):networking_private_interface',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'internet_detail_page',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '<(DEPTH)/ui/webui/resources/cr_elements/chromeos/network/compiled_resources2.gyp:cr_onc_types',
- '<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_network_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(EXTERNS_GYP):chrome_send',
- '<(EXTERNS_GYP):networking_private',
- '<(INTERFACES_GYP):networking_private_interface',
- 'tether_connection_dialog',
- 'internet_page_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'internet_known_networks_page',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_action_menu/compiled_resources2.gyp:cr_action_menu',
- '<(DEPTH)/ui/webui/resources/cr_elements/chromeos/network/compiled_resources2.gyp:cr_onc_types',
- '<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_network_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(EXTERNS_GYP):networking_private',
- '<(INTERFACES_GYP):networking_private_interface',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'internet_subpage',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '<(DEPTH)/ui/webui/resources/cr_elements/chromeos/network/compiled_resources2.gyp:cr_onc_types',
- '<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_network_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(EXTERNS_GYP):networking_private',
- '<(INTERFACES_GYP):networking_private_interface',
- 'internet_page_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'network_proxy_section',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '../controls/compiled_resources2.gyp:settings_checkbox',
- '../prefs/compiled_resources2.gyp:prefs_behavior',
- '<(DEPTH)/ui/webui/resources/cr_components/chromeos/network/compiled_resources2.gyp:network_proxy',
- '<(DEPTH)/ui/webui/resources/cr_elements/chromeos/network/compiled_resources2.gyp:cr_onc_types',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'network_summary',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/chromeos/network/compiled_resources2.gyp:cr_onc_types',
- '<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_network_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(INTERFACES_GYP):networking_private_interface',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'network_summary_item',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/chromeos/network/compiled_resources2.gyp:cr_onc_types',
- '<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_network_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(INTERFACES_GYP):networking_private_interface',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'tether_connection_dialog',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/chromeos/network/compiled_resources2.gyp:cr_onc_types',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_dialog/compiled_resources2.gyp:cr_dialog',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_config.js b/chromium/chrome/browser/resources/settings/internet_page/internet_config.js
index ba7c90de4ab..d93e5869e3d 100644
--- a/chromium/chrome/browser/resources/settings/internet_page/internet_config.js
+++ b/chromium/chrome/browser/resources/settings/internet_page/internet_config.js
@@ -40,25 +40,22 @@ Polymer({
/**
* The GUID when an existing network is being configured. This will be
* empty when configuring a new network.
- * @private
*/
guid: String,
/**
* The type of network to be configured.
- * @private {!chrome.networkingPrivate.NetworkType}
+ * @type {!chrome.networkingPrivate.NetworkType}
*/
type: String,
/**
* The name of network (for display while the network details are fetched).
- * @private
*/
name: String,
/**
* Set to true to show the 'connect' button instead of 'save'.
- * @private
*/
showConnect: Boolean,
diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.html b/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.html
index 200cf41ad3c..4445ba1a4f1 100644
--- a/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.html
+++ b/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.html
@@ -9,6 +9,7 @@
<link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_network_icon.html">
<link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_onc_types.html">
<link rel="import" href="chrome://resources/cr_elements/cr_expand_button/cr_expand_button.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_network_behavior.html">
@@ -18,7 +19,6 @@
<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-toggle-button/paper-toggle-button.html">
<link rel="import" href="../controls/settings_toggle_button.html">
<link rel="import" href="../prefs/prefs.html">
<link rel="import" href="../route.html">
@@ -41,7 +41,7 @@
-webkit-margin-end: 10px;
}
- paper-toggle-button {
+ cr-toggle {
-webkit-margin-start: var(--settings-control-label-spacing);
}
@@ -80,31 +80,29 @@
</cr-policy-indicator>
</template>
</div>
- <template is="dom-if" if="[[!isSecondaryUser_]]">
- <paper-button on-click="onForgetTap_"
- hidden$="[[!showForget_(networkProperties)]]">
- $i18n{networkButtonForget}
- </paper-button>
- <paper-button on-click="onViewAccountTap_"
- hidden$="[[!showViewAccount_(networkProperties)]]">
- $i18n{networkButtonViewAccount}
- </paper-button>
- <paper-button on-click="onActivateTap_"
- hidden$="[[!showActivate_(networkProperties)]]">
- $i18n{networkButtonActivate}
- </paper-button>
- <paper-button on-click="onConfigureTap_"
- hidden$="[[!showConfigure_(networkProperties, globalPolicy)]]">
- $i18n{networkButtonConfigure}
- </paper-button>
- </template>
- <paper-button class="primary-button" on-click="onConnectTap_"
+ <paper-button on-click="onForgetTap_"
+ hidden$="[[!showForget_(networkProperties)]]">
+ $i18n{networkButtonForget}
+ </paper-button>
+ <paper-button on-click="onViewAccountTap_"
+ hidden$="[[!showViewAccount_(networkProperties)]]">
+ $i18n{networkButtonViewAccount}
+ </paper-button>
+ <paper-button on-click="onActivateTap_"
+ hidden$="[[!showActivate_(networkProperties)]]">
+ $i18n{networkButtonActivate}
+ </paper-button>
+ <paper-button on-click="onConfigureTap_"
+ hidden$="[[!showConfigure_(networkProperties, globalPolicy)]]">
+ $i18n{networkButtonConfigure}
+ </paper-button>
+ <paper-button class="action-button" on-click="onConnectTap_"
hidden$="[[!showConnect_(networkProperties, globalPolicy)]]"
disabled="[[!enableConnect_(networkProperties, defaultNetwork,
globalPolicy, networkPropertiesReceived_, outOfRange_)]]">
$i18n{networkButtonConnect}
</paper-button>
- <paper-button class="primary-button" on-click="onDisconnectTap_"
+ <paper-button class="action-button" on-click="onDisconnectTap_"
hidden$="[[!showDisconnect_(networkProperties)]]">
$i18n{networkButtonDisconnect}
</paper-button>
@@ -141,10 +139,10 @@
<cr-policy-network-indicator
property="[[networkProperties.Priority]]">
</cr-policy-network-indicator>
- <paper-toggle-button checked="{{preferNetwork_}}"
+ <cr-toggle checked="{{preferNetwork_}}"
disabled="[[isNetworkPolicyEnforced(networkProperties.Priority)]]"
aria-labelledby="preferNetworkToggleLabel">
- </paper-toggle-button>
+ </cr-toggle>
</div>
</template>
<!-- Autoconnect. -->
@@ -156,11 +154,11 @@
<cr-policy-network-indicator
property="[[getManagedAutoConnect_(networkProperties)]]">
</cr-policy-network-indicator>
- <paper-toggle-button checked="{{autoConnect_}}"
+ <cr-toggle checked="{{autoConnect_}}"
disabled="[[!enableAutoConnect_(networkProperties,
globalPolicy)]]"
aria-labelledby="autoConnectToggleLabel">
- </paper-toggle-button>
+ </cr-toggle>
</div>
</template>
<!-- Data roaming (Cellular only). -->
diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.js b/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.js
index 1667b184ab5..e802a9b48d0 100644
--- a/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.js
+++ b/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.js
@@ -246,10 +246,10 @@ Polymer({
if (!this.didSetFocus_) {
// Focus a button once the initial state is set.
this.didSetFocus_ = true;
- const button = this.$$('#titleDiv .primary-button:not([hidden])') ||
+ const button = this.$$('#titleDiv .action-button:not([hidden])') ||
this.$$('#titleDiv paper-button:not([hidden])');
if (button)
- button.focus();
+ setTimeout(() => button.focus());
}
if (this.shouldShowConfigureWhenNetworkLoaded_ &&
@@ -510,6 +510,8 @@ Polymer({
* @private
*/
showForget_: function(networkProperties) {
+ if (this.isSecondaryUser_)
+ return false;
const type = networkProperties.Type;
if (type != CrOnc.Type.WI_FI && type != CrOnc.Type.VPN)
return false;
@@ -525,6 +527,8 @@ Polymer({
* @private
*/
showActivate_: function(networkProperties) {
+ if (this.isSecondaryUser_)
+ return false;
if (!this.isCellular_(networkProperties))
return false;
const activation = networkProperties.Cellular.ActivationState;
@@ -539,11 +543,19 @@ Polymer({
* @private
*/
showConfigure_: function(networkProperties, globalPolicy) {
+ if (this.isSecondaryUser_)
+ return false;
if (this.connectNotAllowed_(networkProperties, globalPolicy))
return false;
const type = networkProperties.Type;
if (type == CrOnc.Type.CELLULAR || type == CrOnc.Type.TETHER)
return false;
+ if (type == CrOnc.Type.WI_FI) {
+ const security = networkProperties.WiFi &&
+ CrOnc.getActiveValue(networkProperties.WiFi.Security);
+ if (!security || security == CrOnc.Security.NONE)
+ return false;
+ }
if ((type == CrOnc.Type.WI_FI || type == CrOnc.Type.WI_MAX) &&
networkProperties.ConnectionState !=
CrOnc.ConnectionState.NOT_CONNECTED) {
@@ -562,6 +574,9 @@ Polymer({
* @private
*/
showViewAccount_: function(networkProperties) {
+ if (this.isSecondaryUser_)
+ return false;
+
// Show either the 'Activate' or the 'View Account' button (Cellular only).
if (!this.isCellular_(networkProperties) ||
this.showActivate_(networkProperties)) {
@@ -606,6 +621,8 @@ Polymer({
return false;
if (!networkPropertiesReceived || outOfRange)
return false;
+ if (this.isSecondaryUser_ && this.networkProperties.Connectable === false)
+ return false;
if ((networkProperties.Type == CrOnc.Type.CELLULAR) &&
(CrOnc.isSimLocked(networkProperties) ||
this.get('Cellular.Scanning', networkProperties))) {
@@ -1085,8 +1102,6 @@ Polymer({
// network.
return false;
}
- if (networkProperties.Type == CrOnc.Type.VPN)
- return false;
if (networkProperties.Type == CrOnc.Type.CELLULAR)
return true;
return this.isRememberedOrConnected_(networkProperties);
diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_page.js b/chromium/chrome/browser/resources/settings/internet_page/internet_page.js
index ed1eda816ef..0272a2fc2d9 100644
--- a/chromium/chrome/browser/resources/settings/internet_page/internet_page.js
+++ b/chromium/chrome/browser/resources/settings/internet_page/internet_page.js
@@ -315,7 +315,7 @@ Polymer({
* @private
*/
onShowNetworks_: function(event) {
- this.showNetworksSubpage_(event.detail.Type);
+ this.showNetworksSubpage_(event.detail.type);
},
/**
@@ -361,9 +361,9 @@ Polymer({
* @private
*/
onShowKnownNetworks_: function(event) {
- this.detailType_ = event.detail.Type;
+ this.detailType_ = event.detail.type;
const params = new URLSearchParams;
- params.append('type', event.detail.Type);
+ params.append('type', event.detail.type);
this.knownNetworksType_ = event.detail.type;
settings.navigateTo(settings.routes.KNOWN_NETWORKS, params);
},
diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_shared_css.html b/chromium/chrome/browser/resources/settings/internet_page/internet_shared_css.html
index 3b367ab31c3..39d86fdfa70 100644
--- a/chromium/chrome/browser/resources/settings/internet_page/internet_shared_css.html
+++ b/chromium/chrome/browser/resources/settings/internet_page/internet_shared_css.html
@@ -5,10 +5,6 @@
<dom-module id="internet-shared">
<template>
<style include="settings-shared">
- :root {
- --network-control-width: 250px;
- }
-
cr-network-icon {
-webkit-padding-end: var(--settings-box-row-padding);
}
@@ -17,17 +13,6 @@
-webkit-margin-end: var(--cr-controlled-by-spacing);
}
- paper-input-container {
- --paper-input-container-input: {
- color: var(--paper-grey-600);
- font-size: inherit;
- font-weight: 400;
- };
- margin-bottom: 0;
- margin-top: -9px;
- width: var(--network-control-width);
- }
-
.indented {
-webkit-margin-start: var(--settings-box-row-padding);
}
diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_subpage.html b/chromium/chrome/browser/resources/settings/internet_page/internet_subpage.html
index 91b79a02c34..2889a2e4f56 100644
--- a/chromium/chrome/browser/resources/settings/internet_page/internet_subpage.html
+++ b/chromium/chrome/browser/resources/settings/internet_page/internet_subpage.html
@@ -1,11 +1,11 @@
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_network_list.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-toggle-button/paper-toggle-button.html">
<link rel="import" href="../settings_shared_css.html">
<dom-module id="settings-internet-subpage">
@@ -89,12 +89,12 @@
on-click="onAddButtonTap_" tabindex$="[[tabindex]]">
</button>
</paper-icon-button-light>
- <paper-toggle-button id="deviceEnabledButton"
+ <cr-toggle id="deviceEnabledButton"
aria-label$="[[getToggleA11yString_(deviceState)]]"
checked="[[deviceIsEnabled_(deviceState)]]"
disabled="[[!enableToggleIsEnabled_(deviceState)]]"
- on-click="onDeviceEnabledTap_">
- </paper-toggle-button>
+ on-change="onDeviceEnabledChange_">
+ </cr-toggle>
</div>
</template>
@@ -215,13 +215,13 @@
$i18n{internetToggleTetherSubtext}
</div>
</div>
- <paper-toggle-button id="tetherEnabledButton"
+ <cr-toggle id="tetherEnabledButton"
aria-label="$i18n{internetToggleTetherLabel}"
aria-describedby="tetherSecondary"
checked="[[deviceIsEnabled_(tetherDeviceState)]]"
disabled="[[!tetherToggleIsEnabled_(deviceState,
tetherDeviceState)]]">
- </paper-toggle-button>
+ </cr-toggle>
</div>
</template>
</template>
diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_subpage.js b/chromium/chrome/browser/resources/settings/internet_page/internet_subpage.js
index c45566055aa..336b50c5ecd 100644
--- a/chromium/chrome/browser/resources/settings/internet_page/internet_subpage.js
+++ b/chromium/chrome/browser/resources/settings/internet_page/internet_subpage.js
@@ -447,7 +447,7 @@ Polymer({
*/
onKnownNetworksTap_: function() {
assert(this.deviceState.Type == CrOnc.Type.WI_FI);
- this.fire('show-known-networks', {Type: this.deviceState.Type});
+ this.fire('show-known-networks', {type: this.deviceState.Type});
},
/**
@@ -455,14 +455,12 @@ Polymer({
* @param {!Event} event
* @private
*/
- onDeviceEnabledTap_: function(event) {
+ onDeviceEnabledChange_: function(event) {
assert(this.deviceState);
this.fire('device-enabled-toggled', {
enabled: !this.deviceIsEnabled_(this.deviceState),
type: this.deviceState.Type
});
- // Make sure this does not propagate to onDetailsTap_.
- event.stopPropagation();
},
/**
diff --git a/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.html b/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.html
index d45bd71c155..1d168477479 100644
--- a/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.html
+++ b/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.html
@@ -2,11 +2,11 @@
<link rel="import" href="chrome://resources/cr_components/chromeos/network/network_siminfo.html">
<link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_network_icon.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-collapse/iron-collapse.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-toggle-button/paper-toggle-button.html">
<link rel="import" href="../settings_page/settings_subpage.html">
<link rel="import" href="../settings_shared_css.html">
@@ -74,12 +74,12 @@
<template is="dom-if" if="[[enableToggleIsVisible_(deviceState)]]">
<div class="separator"></div>
- <paper-toggle-button id="deviceEnabledButton"
+ <cr-toggle id="deviceEnabledButton"
aria-label$="[[getToggleA11yString_(deviceState)]]"
checked="[[deviceIsEnabled_(deviceState)]]"
disabled="[[!enableToggleIsEnabled_(deviceState)]]"
- on-click="onDeviceEnabledTap_">
- </paper-toggle-button>
+ on-change="onDeviceEnabledChange_">
+ </cr-toggle>
</template>
</div>
</template>
diff --git a/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.js b/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.js
index e7a54cb245a..ab3be60ec47 100644
--- a/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.js
+++ b/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.js
@@ -294,7 +294,7 @@ Polymer({
}
} else if (this.shouldShowSubpage_(
this.deviceState, this.networkStateList)) {
- this.fire('show-networks', this.deviceState);
+ this.fire('show-networks', {type: this.deviceState.Type});
} else if (this.activeNetworkState.GUID) {
this.fire('show-detail', this.activeNetworkState);
} else if (this.networkStateList.length > 0) {
@@ -327,13 +327,11 @@ Polymer({
* @param {!Event} event
* @private
*/
- onDeviceEnabledTap_: function(event) {
+ onDeviceEnabledChange_: function(event) {
const deviceIsEnabled = this.deviceIsEnabled_(this.deviceState);
const type = this.deviceState ? this.deviceState.Type : '';
this.fire(
'device-enabled-toggled', {enabled: !deviceIsEnabled, type: type});
- // Make sure this does not propagate to onDetailsTap_.
- event.stopPropagation();
},
/**
diff --git a/chromium/chrome/browser/resources/settings/languages_page/BUILD.gn b/chromium/chrome/browser/resources/settings/languages_page/BUILD.gn
new file mode 100644
index 00000000000..155a0ac99c7
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/languages_page/BUILD.gn
@@ -0,0 +1,94 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":add_languages_dialog",
+ ":languages",
+ ":languages_browser_proxy",
+ ":languages_page",
+ ":languages_types",
+ ":manage_input_methods_page",
+ ]
+}
+
+js_library("languages_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [
+ "$externs_path/chrome_send.js",
+ "$externs_path/input_method_private.js",
+ "$externs_path/language_settings_private.js",
+ ]
+ extra_sources = [
+ "$interfaces_path/input_method_private_interface.js",
+ "$interfaces_path/language_settings_private_interface.js",
+ ]
+}
+
+js_library("languages") {
+ deps = [
+ ":languages_browser_proxy",
+ ":languages_types",
+ "../prefs:prefs",
+ "../prefs:prefs_types",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:promise_resolver",
+ ]
+ externs_list = [
+ "$externs_path/input_method_private.js",
+ "$externs_path/language_settings_private.js",
+ ]
+ extra_sources = [
+ "$interfaces_path/input_method_private_interface.js",
+ "$interfaces_path/language_settings_private_interface.js",
+ ]
+}
+
+js_library("languages_page") {
+ deps = [
+ ":languages",
+ ":languages_types",
+ "..:lifetime_browser_proxy",
+ "..:route",
+ "../settings_page:settings_animated_pages",
+ "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
+ "//ui/webui/resources/cr_elements/cr_expand_button:cr_expand_button",
+ "//ui/webui/resources/cr_elements/cr_lazy_render:cr_lazy_render",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+}
+
+js_library("languages_types") {
+ deps = [
+ "//ui/webui/resources/js:assert",
+ ]
+ externs_list = [ "$externs_path/language_settings_private.js" ]
+}
+
+js_library("manage_input_methods_page") {
+ deps = [
+ ":languages",
+ ":languages_types",
+ "../prefs:prefs",
+ ]
+ externs_list = [ "$externs_path/language_settings_private.js" ]
+}
+
+js_library("add_languages_dialog") {
+ deps = [
+ ":languages",
+ ":languages_types",
+ "..:find_shortcut_behavior",
+ "../settings_page:settings_subpage_search",
+ "//ui/webui/resources/cr_elements:cr_scrollable_behavior",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/languages_page/add_languages_dialog.html b/chromium/chrome/browser/resources/settings/languages_page/add_languages_dialog.html
index e143de51997..0e4be549467 100644
--- a/chromium/chrome/browser/resources/settings/languages_page/add_languages_dialog.html
+++ b/chromium/chrome/browser/resources/settings/languages_page/add_languages_dialog.html
@@ -1,9 +1,9 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html">
<link rel="import" href="chrome://resources/cr_elements/cr_scrollable_behavior.html">
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-list/iron-list.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-checkbox/paper-checkbox.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<link rel="import" href="languages.html">
<link rel="import" href="../settings_page/settings_subpage_search.html">
@@ -12,12 +12,14 @@
<dom-module id="settings-add-languages-dialog">
<template>
<style include="settings-shared">
- [slot=body] {
- -webkit-padding-end: 0 !important;
- display: flex;
- flex-direction: column;
- height: 350px;
- overflow: auto;
+ cr-dialog {
+ --cr-dialog-body: {
+ -webkit-padding-end: 0;
+ display: flex;
+ flex-direction: column;
+ height: 350px;
+ overflow: auto;
+ }
}
settings-subpage-search {
@@ -33,28 +35,28 @@
-webkit-padding-start: 20px;
}
- paper-checkbox {
- --paper-checkbox-label: {
+ cr-checkbox {
+ --cr-checkbox-label-container: {
white-space: nowrap;
- }
+ };
}
</style>
<cr-dialog id="dialog" close-text="$i18n{close}">
<div slot="title">$i18n{addLanguagesDialogTitle}</div>
<div slot="body" scrollable>
- <settings-subpage-search label="[[searchLabel]]"
+ <settings-subpage-search label="$i18n{searchLanguages}" id="search"
on-search-changed="onSearchChanged_" autofocus>
</settings-subpage-search>
<iron-list class="ripple-padding" scroll-target="[[$$('[slot=body]')]]"
items="[[getLanguages_(
languages.supported, languages.enabled.*, filterValue_)]]">
<template>
- <paper-checkbox class="list-item no-outline"
+ <cr-checkbox class="list-item no-outline"
checked="[[willAdd_(item.code)]]" tabindex$="[[tabIndex]]"
title$="[[item.nativeDisplayName]]"
on-change="onLanguageCheckboxChange_">
[[getDisplayText_(item)]]
- </paper-checkbox>
+ </cr-checkbox>
</template>
</iron-list>
</div>
diff --git a/chromium/chrome/browser/resources/settings/languages_page/add_languages_dialog.js b/chromium/chrome/browser/resources/settings/languages_page/add_languages_dialog.js
index 30f4cfa2416..3a9182fcb3a 100644
--- a/chromium/chrome/browser/resources/settings/languages_page/add_languages_dialog.js
+++ b/chromium/chrome/browser/resources/settings/languages_page/add_languages_dialog.js
@@ -11,6 +11,7 @@ Polymer({
behaviors: [
CrScrollableBehavior,
+ settings.FindShortcutBehavior,
],
properties: {
@@ -49,6 +50,16 @@ Polymer({
this.$.dialog.showModal();
},
+ // Override settings.FindShortcutBehavior methods.
+ canHandleFindShortcut: function() {
+ return true;
+ },
+
+ handleFindShortcut: function() {
+ this.$.search.getSearchInput().scrollIntoViewIfNeeded();
+ this.$.search.getSearchInput().focus();
+ },
+
/**
* @param {!CustomEvent} e
* @private
@@ -106,7 +117,7 @@ Polymer({
/**
* Handler for checking or unchecking a language item.
* @param {!{model: !{item: !chrome.languageSettingsPrivate.Language},
- * target: !PaperCheckboxElement}} e
+ * target: !Element}} e
* @private
*/
onLanguageCheckboxChange_: function(e) {
diff --git a/chromium/chrome/browser/resources/settings/languages_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/languages_page/compiled_resources2.gyp
deleted file mode 100644
index 446e9c3a2b0..00000000000
--- a/chromium/chrome/browser/resources/settings/languages_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,84 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'languages_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):chrome_send',
- '<(EXTERNS_GYP):input_method_private',
- '<(EXTERNS_GYP):language_settings_private',
- '<(INTERFACES_GYP):input_method_private_interface',
- '<(INTERFACES_GYP):language_settings_private_interface',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'languages',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:promise_resolver',
- '<(EXTERNS_GYP):input_method_private',
- '<(EXTERNS_GYP):language_settings_private',
- '<(INTERFACES_GYP):input_method_private_interface',
- '<(INTERFACES_GYP):language_settings_private_interface',
- '../prefs/compiled_resources2.gyp:prefs_types',
- '../prefs/compiled_resources2.gyp:prefs',
- 'languages_types',
- 'languages_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'languages_page',
- 'dependencies': [
- '../compiled_resources2.gyp:lifetime_browser_proxy',
- '../compiled_resources2.gyp:route',
- '../settings_page/compiled_resources2.gyp:settings_animated_pages',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/paper-checkbox/compiled_resources2.gyp:paper-checkbox-extracted',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_action_menu/compiled_resources2.gyp:cr_action_menu',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_expand_button/compiled_resources2.gyp:cr_expand_button',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_lazy_render/compiled_resources2.gyp:cr_lazy_render',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink',
- 'languages',
- 'languages_types',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'languages_types',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(EXTERNS_GYP):language_settings_private',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'manage_input_methods_page',
- 'dependencies': [
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/paper-checkbox/compiled_resources2.gyp:paper-checkbox-extracted',
- '<(EXTERNS_GYP):language_settings_private',
- '../prefs/compiled_resources2.gyp:prefs',
- 'languages',
- 'languages_types',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'add_languages_dialog',
- 'dependencies': [
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/paper-checkbox/compiled_resources2.gyp:paper-checkbox-extracted',
- '<(DEPTH)/ui/webui/resources/cr_elements/compiled_resources2.gyp:cr_scrollable_behavior',
- 'languages',
- 'languages_types',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/languages_page/edit_dictionary_page.html b/chromium/chrome/browser/resources/settings/languages_page/edit_dictionary_page.html
index f7c0a8e3410..9934992b7bd 100644
--- a/chromium/chrome/browser/resources/settings/languages_page/edit_dictionary_page.html
+++ b/chromium/chrome/browser/resources/settings/languages_page/edit_dictionary_page.html
@@ -10,6 +10,7 @@
<link rel="import" href="../prefs/prefs.html">
<link rel="import" href="../prefs/prefs_behavior.html">
<link rel="import" href="../settings_shared_css.html">
+<link rel="import" href="../settings_vars_css.html">
<dom-module id="settings-edit-dictionary-page">
<template>
@@ -20,7 +21,7 @@
}
#newWord {
- width: var(--paper-input-max-width);
+ width: var(--settings-input-max-width);
}
iron-list .word {
diff --git a/chromium/chrome/browser/resources/settings/languages_page/languages.js b/chromium/chrome/browser/resources/settings/languages_page/languages.js
index e0d77b59c42..b2f7c8ab539 100644
--- a/chromium/chrome/browser/resources/settings/languages_page/languages.js
+++ b/chromium/chrome/browser/resources/settings/languages_page/languages.js
@@ -375,6 +375,21 @@ Polymer({
}
},
+ /** @private
+ * @param {string} languageCode language code
+ * @return {boolean} True if the language is in the list of allowed
+ * locales (AllowedLocales policy) or if the policy is not set (empty list)
+ * @private
+ */
+ isAllowedLocale_: function(languageCode) {
+ if (!cr.isChromeOS)
+ return true;
+
+ const pref = /** @type {!chrome.settingsPrivate.PrefObject} */ (
+ this.get('intl.allowed_locales', this.prefs));
+ return (pref.value.length == 0 || pref.value.indexOf(languageCode) != -1);
+ },
+
/**
* Constructs the languages model.
* @param {!Array<!chrome.languageSettingsPrivate.Language>}
@@ -396,6 +411,7 @@ Polymer({
language.supportsUI = !!language.supportsUI;
language.supportsTranslate = !!language.supportsTranslate;
language.supportsSpellcheck = !!language.supportsSpellcheck;
+ language.isAllowedLocale = this.isAllowedLocale_(language.code);
this.supportedLanguageMap_.set(language.code, language);
}
@@ -746,7 +762,6 @@ Polymer({
} else {
this.languageSettingsPrivate_.moveLanguage(languageCode, MoveType.DOWN);
}
-
},
/**
diff --git a/chromium/chrome/browser/resources/settings/languages_page/languages_page.html b/chromium/chrome/browser/resources/settings/languages_page/languages_page.html
index fbe12b57f92..b709740ff7e 100644
--- a/chromium/chrome/browser/resources/settings/languages_page/languages_page.html
+++ b/chromium/chrome/browser/resources/settings/languages_page/languages_page.html
@@ -1,5 +1,6 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html">
<link rel="import" href="chrome://resources/html/action_link.html">
<link rel="import" href="chrome://resources/html/action_link_css.html">
<link rel="import" href="chrome://resources/html/assert.html">
@@ -9,7 +10,6 @@
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icons/iron-icons.html">
<link rel="import" href="chrome://resources/polymer/v1_0/neon-animation/neon-animatable.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-checkbox/paper-checkbox.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html">
<link rel="import" href="chrome://resources/cr_elements/cr_action_menu/cr_action_menu.html">
<link rel="import" href="chrome://resources/cr_elements/cr_expand_button/cr_expand_button.html">
@@ -64,7 +64,8 @@
margin: 6px 0 0 0;
}
- paper-checkbox.dropdown-item {
+ cr-checkbox.dropdown-item {
+ --cr-action-menu-disabled-item-opacity: 0.38;
-webkit-margin-start: 0;
}
@@ -79,6 +80,15 @@
background-color: transparent;
}
+ #uiLanguageItem span {
+ line-height: 20px;
+ }
+
+ #uiLanguageItem cr-policy-indicator {
+ float: right;
+ margin-left: 20px;
+ }
+
.name-with-error-list {
padding: 14px 0;
}
@@ -309,7 +319,7 @@
<cr-action-menu
class$="[[getMenuClass_(prefs.translate.enabled.value)]]">
<if expr="chromeos or is_win">
- <paper-checkbox id="uiLanguageItem" slot="item"
+ <cr-checkbox id="uiLanguageItem" slot="item"
class="dropdown-item"
checked="[[isProspectiveUILanguage_(
detailLanguage_.language.code,
@@ -317,10 +327,14 @@
on-change="onUILanguageChange_"
disabled="[[disableUILanguageCheckbox_(
detailLanguage_, languages.prospectiveUILanguage)]]">
- $i18n{displayInThisLanguage}
- </paper-checkbox>
+ <span>$i18n{displayInThisLanguage}</span>
+ <cr-policy-indicator indicator-type="[[
+ getPolicyIndicatorStatus_(
+ detailLanguage_.language)]]">
+ </cr-policy-indicator>
+ </cr-checkbox>
</if>
- <paper-checkbox id="offerTranslations" slot="item"
+ <cr-checkbox id="offerTranslations" slot="item"
class="dropdown-item"
checked="[[detailLanguage_.translateEnabled]]"
on-change="onTranslateCheckboxChange_"
@@ -328,7 +342,7 @@
disabled="[[disableTranslateCheckbox_(
detailLanguage_.language, languages.translateTarget)]]">
$i18n{offerToTranslateInThisLanguage}
- </paper-checkbox>
+ </cr-checkbox>
<hr slot="item">
<button slot="item" class="dropdown-item" role="menuitem"
on-click="onMoveToTopTap_"
diff --git a/chromium/chrome/browser/resources/settings/languages_page/languages_page.js b/chromium/chrome/browser/resources/settings/languages_page/languages_page.js
index f476e9cc013..3a90fdc2082 100644
--- a/chromium/chrome/browser/resources/settings/languages_page/languages_page.js
+++ b/chromium/chrome/browser/resources/settings/languages_page/languages_page.js
@@ -302,13 +302,28 @@ Polymer({
if (languageState.language.code == prospectiveUILanguage)
return true;
+ // Check if the language is allowed by the current PolicyEnforcedLocales
+ // policy.
+ if (!languageState.language.isAllowedLocale)
+ return true;
+
// Otherwise, the prospective language can be changed to this language.
return false;
},
/**
+ * @param {!chrome.languageSettingsPrivate.Language} language
+ * @return {string} 'userPolicy' if the language is not allowed by the
+ * AllowedLocales policy, 'none' otherwise.
+ * @private
+ */
+ getPolicyIndicatorStatus_: function(language) {
+ return (language.isAllowedLocale ? 'none' : 'userPolicy');
+ },
+
+ /**
* Handler for changes to the UI language checkbox.
- * @param {!{target: !PaperCheckboxElement}} e
+ * @param {!{target: !Element}} e
* @private
*/
onUILanguageChange_: function(e) {
@@ -338,7 +353,7 @@ Polymer({
/**
* Handler for changes to the translate checkbox.
- * @param {!{target: !PaperCheckboxElement}} e
+ * @param {!{target: !Element}} e
* @private
*/
onTranslateCheckboxChange_: function(e) {
diff --git a/chromium/chrome/browser/resources/settings/languages_page/manage_input_methods_page.html b/chromium/chrome/browser/resources/settings/languages_page/manage_input_methods_page.html
index e877d374e5a..520e612bfbe 100644
--- a/chromium/chrome/browser/resources/settings/languages_page/manage_input_methods_page.html
+++ b/chromium/chrome/browser/resources/settings/languages_page/manage_input_methods_page.html
@@ -1,8 +1,8 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html">
<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/html/cr.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-checkbox/paper-checkbox.html">
<link rel="import" href="../settings_shared_css.html">
<link rel="import" href="languages.html">
@@ -16,12 +16,12 @@
<template is="dom-repeat" items="[[item.inputMethods]]">
<div class="list-item">
<div class="language-name">
- <paper-checkbox checked="[[item.enabled]]"
+ <cr-checkbox checked="[[item.enabled]]"
on-change="onCheckboxChange_"
disabled="[[!enableInputMethodCheckbox_(
item, languages.inputMethods.enabled.*)]]">
<span>[[item.displayName]]</span>
- </paper-checkbox>
+ </cr-checkbox>
</div>
</div>
</template>
diff --git a/chromium/chrome/browser/resources/settings/languages_page/manage_input_methods_page.js b/chromium/chrome/browser/resources/settings/languages_page/manage_input_methods_page.js
index bef31067cb6..2c3ede7ea09 100644
--- a/chromium/chrome/browser/resources/settings/languages_page/manage_input_methods_page.js
+++ b/chromium/chrome/browser/resources/settings/languages_page/manage_input_methods_page.js
@@ -57,7 +57,7 @@ Polymer({
/**
* Handler for an input method checkbox.
* @param {!{model: !{item: chrome.languageSettingsPrivate.InputMethod},
- * target: !PaperCheckboxElement}} e
+ * target: !Element}} e
* @private
*/
onCheckboxChange_: function(e) {
diff --git a/chromium/chrome/browser/resources/settings/multidevice_page/BUILD.gn b/chromium/chrome/browser/resources/settings/multidevice_page/BUILD.gn
new file mode 100644
index 00000000000..9e70a0e234a
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/multidevice_page/BUILD.gn
@@ -0,0 +1,14 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":multidevice_page",
+ ]
+}
+
+js_library("multidevice_page") {
+}
diff --git a/chromium/chrome/browser/resources/settings/multidevice_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/multidevice_page/compiled_resources2.gyp
deleted file mode 100644
index 72df331cb66..00000000000
--- a/chromium/chrome/browser/resources/settings/multidevice_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'multidevice_page',
- 'dependencies': [],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/on_startup_page/BUILD.gn b/chromium/chrome/browser/resources/settings/on_startup_page/BUILD.gn
new file mode 100644
index 00000000000..60ffd9a9b29
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/on_startup_page/BUILD.gn
@@ -0,0 +1,61 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":on_startup_browser_proxy",
+ ":on_startup_page",
+ ":startup_url_entry",
+ ":startup_urls_page",
+ ":startup_urls_page_browser_proxy",
+ ]
+}
+
+js_library("on_startup_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("on_startup_page") {
+ deps = [
+ ":on_startup_browser_proxy",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("startup_urls_page") {
+ deps = [
+ ":startup_url_entry",
+ ":startup_urls_page_browser_proxy",
+ "//ui/webui/resources/cr_elements:cr_scrollable_behavior",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
+
+js_library("startup_urls_page_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/chrome_send.js" ]
+}
+
+js_library("startup_url_entry") {
+ deps = [
+ ":startup_urls_page_browser_proxy",
+ "..:focus_row_behavior",
+ "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
+ "//ui/webui/resources/cr_elements/cr_lazy_render:cr_lazy_render",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:icon",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/on_startup_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/on_startup_page/compiled_resources2.gyp
deleted file mode 100644
index e68bb1a34a6..00000000000
--- a/chromium/chrome/browser/resources/settings/on_startup_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,58 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'on_startup_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'on_startup_page',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- 'on_startup_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'startup_urls_page',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink',
- '<(DEPTH)/ui/webui/resources/cr_elements/compiled_resources2.gyp:cr_scrollable_behavior',
- '<(EXTERNS_GYP):settings_private',
- 'startup_urls_page_browser_proxy',
- 'startup_url_entry',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'startup_urls_page_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):chrome_send',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'startup_url_entry',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_action_menu/compiled_resources2.gyp:cr_action_menu',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_lazy_render/compiled_resources2.gyp:cr_lazy_render',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:icon',
- '../compiled_resources2.gyp:focus_row_behavior',
- 'startup_urls_page_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/BUILD.gn b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/BUILD.gn
new file mode 100644
index 00000000000..a25ebda3030
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/BUILD.gn
@@ -0,0 +1,104 @@
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":address_edit_dialog",
+ ":autofill_section",
+ ":credit_card_edit_dialog",
+ ":password_edit_dialog",
+ ":password_list_item",
+ ":password_manager_proxy",
+ ":passwords_and_forms_page",
+ ":passwords_section",
+ ":show_password_behavior",
+ ]
+}
+
+js_library("passwords_and_forms_page") {
+ deps = [
+ ":autofill_section",
+ ":passwords_section",
+ "..:route",
+ "../prefs:prefs_behavior",
+ "../settings_page:settings_animated_pages",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [
+ "$externs_path/passwords_private.js",
+ "$externs_path/settings_private.js",
+ ]
+}
+
+js_library("autofill_section") {
+ deps = [
+ ":address_edit_dialog",
+ ":credit_card_edit_dialog",
+ "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+ externs_list = [ "$externs_path/autofill_private.js" ]
+}
+
+js_library("address_edit_dialog") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+ externs_list = [ "$externs_path/autofill_private.js" ]
+}
+
+js_library("credit_card_edit_dialog") {
+ deps = [
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+ externs_list = [ "$externs_path/autofill_private.js" ]
+}
+
+js_library("password_list_item") {
+ deps = [
+ ":show_password_behavior",
+ "..:focus_row_behavior",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
+
+js_library("password_manager_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/passwords_private.js" ]
+}
+
+js_library("passwords_section") {
+ deps = [
+ ":password_edit_dialog",
+ ":password_list_item",
+ ":password_manager_proxy",
+ "..:global_scroll_target_behavior",
+ "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
+ "//ui/webui/resources/cr_elements/cr_toast:cr_toast",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:list_property_update_behavior",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+ externs_list = [ "$externs_path/passwords_private.js" ]
+}
+
+js_library("password_edit_dialog") {
+ deps = [
+ ":show_password_behavior",
+ "//third_party/polymer/v1_0/components-chromium/paper-input:paper-input-extracted",
+ ]
+}
+
+js_library("show_password_behavior") {
+ externs_list = [ "$externs_path/passwords_private.js" ]
+}
diff --git a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/address_edit_dialog.html b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/address_edit_dialog.html
index 539781b1b6f..167dc869af7 100644
--- a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/address_edit_dialog.html
+++ b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/address_edit_dialog.html
@@ -26,7 +26,7 @@
.address-column {
-webkit-margin-end: 16px;
margin-bottom: 8px;
- width: calc((var(--paper-input-max-width) - 16px) / 2);
+ width: calc((var(--settings-input-max-width) - 16px) / 2);
}
#select-row {
@@ -42,7 +42,7 @@
}
.md-select {
- --md-select-width: var(--paper-input-max-width);
+ --md-select-width: var(--settings-input-max-width);
}
#select-label {
@@ -59,7 +59,7 @@
}
.long {
- width: var(--paper-input-max-width);
+ width: var(--settings-input-max-width);
}
#saveButton {
diff --git a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/compiled_resources2.gyp
deleted file mode 100644
index 6f53f1dd4a8..00000000000
--- a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,100 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'passwords_and_forms_page',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '../prefs/compiled_resources2.gyp:prefs_behavior',
- '../settings_page/compiled_resources2.gyp:settings_animated_pages',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):passwords_private',
- '<(EXTERNS_GYP):settings_private',
- 'autofill_section',
- 'passwords_section',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'autofill_section',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_action_menu/compiled_resources2.gyp:cr_action_menu',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink',
- '<(EXTERNS_GYP):autofill_private',
- 'address_edit_dialog',
- 'credit_card_edit_dialog',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'address_edit_dialog',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(EXTERNS_GYP):autofill_private',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'credit_card_edit_dialog',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(EXTERNS_GYP):autofill_private',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'password_list_item',
- 'dependencies': [
- '../compiled_resources2.gyp:focus_row_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- 'show_password_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'password_manager_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):passwords_private',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'passwords_section',
- 'dependencies': [
- '../compiled_resources2.gyp:global_scroll_target_behavior',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_action_menu/compiled_resources2.gyp:cr_action_menu',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_toast/compiled_resources2.gyp:cr_toast',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink',
- '<(EXTERNS_GYP):passwords_private',
- 'password_edit_dialog',
- 'password_list_item',
- 'password_manager_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'password_edit_dialog',
- 'dependencies': [
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/paper-input/compiled_resources2.gyp:paper-input-extracted',
- 'show_password_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'show_password_behavior',
- 'dependencies': [
- '<(EXTERNS_GYP):passwords_private',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.html b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.html
index 9a522be4d62..971a84c95d2 100644
--- a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.html
+++ b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.html
@@ -5,14 +5,14 @@
<link rel="import" href="chrome://resources/html/md_select_css.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-input/paper-input.html">
-<link rel="import" href="../settings_vars_css.html">
<link rel="import" href="../settings_shared_css.html">
+<link rel="import" href="../settings_vars_css.html">
<dom-module id="settings-credit-card-edit-dialog">
<template>
<style include="settings-shared md-select">
paper-input {
- width: var(--paper-input-max-width);
+ width: var(--settings-input-max-width);
}
.md-select-wrapper {
diff --git a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_edit_dialog.html b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_edit_dialog.html
index 05d713eac96..7466d9c7e92 100644
--- a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_edit_dialog.html
+++ b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_edit_dialog.html
@@ -7,6 +7,7 @@
<link rel="import" href="chrome://resources/polymer/v1_0/paper-input/paper-input.html">
<link rel="import" href="../icons.html">
<link rel="import" href="../settings_shared_css.html">
+<link rel="import" href="../settings_vars_css.html">
<link rel="import" href="show_password_behavior.html">
<dom-module id="password-edit-dialog">
@@ -32,7 +33,7 @@
}
paper-input {
- width: var(--paper-input-max-width);
+ width: var(--settings-input-max-width);
}
paper-icon-button-light {
diff --git a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_list_item.js b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_list_item.js
index 9a317f08e46..862c1dd4dc3 100644
--- a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_list_item.js
+++ b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_list_item.js
@@ -32,10 +32,7 @@ Polymer({
/**
* Get the aria label for the More Actions button on this row.
- * @param {{
- * entry: !chrome.passwordsPrivate.PasswordUiEntry,
- * password: string
- * }} item This row's item.
+ * @param {!PasswordManagerProxy.UiEntryWithPassword} item This row's item.
* @private
*/
getMoreActionsLabel_: function(item) {
diff --git a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_section.html b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_section.html
index 8f022bb9967..1648e322d94 100644
--- a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_section.html
+++ b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_section.html
@@ -6,6 +6,7 @@
<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
+<link rel="import" href="chrome://resources/html/list_property_update_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-list/iron-list.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html">
@@ -23,7 +24,7 @@
<dom-module id="passwords-section">
<template>
<style include="settings-shared passwords-shared">
- #savedPasswordsHeading {
+ #savedPasswordsHeaders {
/* This adds enough padding so that the labels are aligned with the
* columns. It is necessary due to the absence of the "more actions"
* button in the heading.
@@ -41,16 +42,6 @@
white-space: nowrap;
}
- #undoButton {
- -webkit-margin-end: 0;
- -webkit-margin-start: 32px;
- color: var(--google-blue-300);
- font-weight: 500;
- height: 32px;
- min-width: 52px;
- padding: 8px;
- }
-
#exportImportMenuButtonContainer {
-webkit-margin-end: 0;
}
@@ -102,8 +93,8 @@
</template>
</div>
<div class="list-frame">
- <div id="savedPasswordsHeading" class="list-item column-header"
- hidden$="[[!hasSome_(savedPasswords)]]">
+ <div id="savedPasswordsHeaders" class="list-item column-header"
+ hidden$="[[!hasSome_(savedPasswords, savedPasswords.splices)]]">
<div class="website-column">$i18n{editPasswordWebsiteLabel}</div>
<div class="username-column">
$i18n{editPasswordUsernameLabel}
@@ -113,7 +104,7 @@
</div>
</div>
<iron-list id="passwordList" preserve-focus
- items="[[getFilteredPasswords_(savedPasswords, filter)]]"
+ items="[[getFilteredPasswords_(filter, savedPasswords.splices)]]"
class="cr-separators list-with-header"
scroll-target="[[subpageScrollTarget]]" risk-selection>
<template>
@@ -124,7 +115,7 @@
</template>
</iron-list>
<div id="noPasswordsLabel" class="list-item"
- hidden$="[[hasSome_(savedPasswords)]]">
+ hidden$="[[hasSome_(savedPasswords, savedPasswords.splices)]]">
$i18n{noPasswordsFound}
</div>
</div>
@@ -155,7 +146,7 @@
</template>
<cr-toast id="undoToast" duration="[[toastDuration_]]">
<div id="undoLabel">$i18n{passwordDeleted}</div>
- <paper-button id="undoButton" on-click="onUndoButtonTap_">
+ <paper-button on-click="onUndoButtonTap_">
$i18n{undoRemovePassword}
</paper-button>
</cr-toast>
diff --git a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_section.js b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_section.js
index 79ac459131f..243d81313d8 100644
--- a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_section.js
+++ b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_section.js
@@ -8,7 +8,7 @@
* save any passwords.
*/
-/** @typedef {!{model: !{item: !chrome.passwordsPrivate.PasswordUiEntry}}} */
+/** @typedef {!{model: !{item: !PasswordManagerProxy.UiEntryWithPassword}}} */
let PasswordUiEntryEvent;
/** @typedef {!{model: !{item: !chrome.passwordsPrivate.ExceptionEntry}}} */
@@ -22,6 +22,7 @@ Polymer({
behaviors: [
I18nBehavior,
+ ListPropertyUpdateBehavior,
Polymer.IronA11yKeysBehavior,
settings.GlobalScrollTargetBehavior,
],
@@ -35,15 +36,21 @@ Polymer({
/**
* An array of passwords to display.
- * @type {!Array<!PasswordManagerProxy.PasswordUiEntry>}
+ * @type {!Array<!PasswordManagerProxy.UiEntryWithPassword>}
*/
- savedPasswords: Array,
+ savedPasswords: {
+ type: Array,
+ value: () => [],
+ },
/**
* An array of sites to display.
* @type {!Array<!PasswordManagerProxy.ExceptionEntry>}
*/
- passwordExceptions: Array,
+ passwordExceptions: {
+ type: Array,
+ value: () => [],
+ },
/**
* Duration of the undo toast in ms
@@ -76,7 +83,7 @@ Polymer({
/** @private */
showExportPasswords_: {
type: Boolean,
- computed: 'showExportPasswordsAndReady_(savedPasswords)'
+ computed: 'hasPasswords_(savedPasswords.splices)',
},
/** @private */
@@ -97,7 +104,7 @@ Polymer({
value: '',
},
- /** @private {!PasswordManagerProxy.PasswordUiEntry} */
+ /** @private {!PasswordManagerProxy.UiEntryWithPassword} */
lastFocused_: Object,
},
@@ -144,14 +151,24 @@ Polymer({
/** @override */
attached: function() {
// Create listener functions.
- const setSavedPasswordsListener = list => {
- this.savedPasswords = list.map(entry => {
- return {
- entry: entry,
- password: '',
- };
- });
- };
+ const setSavedPasswordsListener = list =>
+ this.updateList('savedPasswords', item => {
+ // The item uid is built from index, origin, and username for the
+ // following reasons: origin and username are enough to describe and
+ // uniquely identify an entry. It is impossible to have two entries
+ // that have the same origin and username, but different passwords,
+ // as the password update logic prevents these cases. The entry is
+ // required to force a refresh of entries, after a removal or undo of
+ // a removal has taken place. All entries before the point of
+ // modification are uneffected, but the ones following need to be
+ // refreshed. Including the index in the uid achieves this effect.
+ // See https://crbug.com/862119 how this could lead to bugs otherwise.
+ return item.entry.index + '_' + item.entry.loginPair.urls.origin +
+ '_' + item.entry.loginPair.username;
+ }, list.map(entry => ({
+ entry: entry,
+ password: '',
+ })));
const setPasswordExceptionsListener = list => {
this.passwordExceptions = list;
@@ -173,6 +190,8 @@ Polymer({
this.passwordManager_.addExceptionListChangedListener(
setPasswordExceptionsListener);
+ this.notifySplices('savedPasswords', []);
+
Polymer.RenderStatus.afterNextRender(this, function() {
Polymer.IronA11yAnnouncer.requestAvailability();
});
@@ -218,19 +237,17 @@ Polymer({
},
/**
- * @param {!Array<!PasswordManagerProxy.UiEntryWithPassword>} savedPasswords
* @param {string} filter
* @return {!Array<!PasswordManagerProxy.UiEntryWithPassword>}
* @private
*/
- getFilteredPasswords_: function(savedPasswords, filter) {
+ getFilteredPasswords_: function(filter) {
if (!filter)
- return savedPasswords;
+ return this.savedPasswords.slice();
- return savedPasswords.filter(p => {
- return [p.entry.loginPair.urls.shown, p.entry.loginPair.username].some(
- term => term.toLowerCase().includes(filter.toLowerCase()));
- });
+ return this.savedPasswords.filter(
+ p => [p.entry.loginPair.urls.shown, p.entry.loginPair.username].some(
+ term => term.toLowerCase().includes(filter.toLowerCase())));
},
/**
@@ -239,9 +256,8 @@ Polymer({
* @private
*/
passwordExceptionFilter_: function(filter) {
- return function(exception) {
- return exception.urls.shown.toLowerCase().includes(filter.toLowerCase());
- };
+ return exception => exception.urls.shown.toLowerCase().includes(
+ filter.toLowerCase());
},
/**
@@ -365,14 +381,9 @@ Polymer({
return toggleValue ? this.i18n('toggleOn') : this.i18n('toggleOff');
},
- /**
- * @private
- * @param {!Array<!PasswordManagerProxy.PasswordUiEntry>} savedPasswords
- */
- showExportPasswordsAndReady_: function(savedPasswords) {
- return loadTimeData.valueExists('showExportPasswords') &&
- loadTimeData.getBoolean('showExportPasswords') &&
- savedPasswords.length > 0;
+ /** @private */
+ hasPasswords_: function() {
+ return this.savedPasswords.length > 0;
},
/**
diff --git a/chromium/chrome/browser/resources/settings/people_page/BUILD.gn b/chromium/chrome/browser/resources/settings/people_page/BUILD.gn
new file mode 100644
index 00000000000..acd25d8e3cc
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/people_page/BUILD.gn
@@ -0,0 +1,297 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":account_manager",
+ ":change_picture",
+ ":change_picture_browser_proxy",
+ ":easy_unlock_browser_proxy",
+ ":easy_unlock_turn_off_dialog",
+ ":fingerprint_browser_proxy",
+ ":fingerprint_list",
+ ":fingerprint_progress_arc",
+ ":import_data_browser_proxy",
+ ":import_data_dialog",
+ ":lock_screen",
+ ":lock_screen_constants",
+ ":lock_state_behavior",
+ ":manage_profile",
+ ":manage_profile_browser_proxy",
+ ":password_prompt_dialog",
+ ":people_page",
+ ":profile_info_browser_proxy",
+ ":setup_fingerprint_dialog",
+ ":setup_pin_dialog",
+ ":sync_account_control",
+ ":sync_browser_proxy",
+ ":sync_page",
+ ":user_list",
+ ":users_add_user_dialog",
+ ":users_page",
+ ]
+}
+
+js_library("account_manager") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:icon",
+ ]
+}
+
+js_library("change_picture") {
+ deps = [
+ ":change_picture_browser_proxy",
+ "..:route",
+ "//third_party/polymer/v1_0/components-chromium/iron-selector:iron-selector-extracted",
+ "//ui/webui/resources/cr_elements/chromeos/cr_picture:cr_picture_list",
+ "//ui/webui/resources/cr_elements/chromeos/cr_picture:cr_picture_pane",
+ "//ui/webui/resources/cr_elements/chromeos/cr_picture:cr_picture_types",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:util",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("change_picture_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("easy_unlock_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("easy_unlock_turn_off_dialog") {
+ deps = [
+ ":easy_unlock_browser_proxy",
+ "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("fingerprint_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("fingerprint_list") {
+ deps = [
+ ":fingerprint_browser_proxy",
+ "..:route",
+ "//third_party/polymer/v1_0/components-chromium/iron-resizable-behavior:iron-resizable-behavior-extracted",
+ "//third_party/polymer/v1_0/components-chromium/paper-ripple:paper-ripple-extracted",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+ externs_list = [ "$externs_path/web_animations.js" ]
+}
+
+js_library("fingerprint_progress_arc") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("import_data_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("lock_screen") {
+ deps = [
+ ":easy_unlock_browser_proxy",
+ ":easy_unlock_turn_off_dialog",
+ ":fingerprint_browser_proxy",
+ ":lock_screen_constants",
+ ":lock_state_behavior",
+ ":password_prompt_dialog",
+ "..:route",
+ "../controls:settings_dropdown_menu",
+ "../controls:settings_toggle_button",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+}
+
+js_library("lock_screen_constants") {
+ deps = [
+ "//ui/webui/resources/cr_elements/cr_profile_avatar_selector:cr_profile_avatar_selector",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("lock_state_behavior") {
+ deps = [
+ "..:route",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+ externs_list = [ "$externs_path/quick_unlock_private.js" ]
+ extra_sources = [ "$interfaces_path/quick_unlock_private_interface.js" ]
+}
+
+js_library("manage_profile") {
+ deps = [
+ ":manage_profile_browser_proxy",
+ ":sync_browser_proxy",
+ "..:route",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("manage_profile_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/cr_elements/cr_profile_avatar_selector:cr_profile_avatar_selector",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("password_prompt_dialog") {
+ deps = [
+ ":lock_screen_constants",
+ "..:route",
+ "//third_party/polymer/v1_0/components-chromium/paper-input:paper-input-extracted",
+ ]
+ externs_list = [ "$externs_path/quick_unlock_private.js" ]
+ extra_sources = [ "$interfaces_path/quick_unlock_private_interface.js" ]
+}
+
+js_library("people_page") {
+ deps = [
+ ":lock_screen",
+ ":lock_screen_constants",
+ ":lock_state_behavior",
+ ":profile_info_browser_proxy",
+ ":sync_browser_proxy",
+ "..:page_visibility",
+ "..:route",
+ "../settings_page:settings_animated_pages",
+ "//ui/webui/resources/cr_elements/chromeos/cr_picture:cr_png_behavior",
+ "//ui/webui/resources/cr_elements/cr_toast:cr_toast",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:icon",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+}
+
+js_library("profile_info_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("setup_fingerprint_dialog") {
+ deps = [
+ ":fingerprint_browser_proxy",
+ ":fingerprint_progress_arc",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("setup_pin_dialog") {
+ deps = [
+ ":lock_screen_constants",
+ ":password_prompt_dialog",
+ "..:route",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+}
+
+js_library("sync_page") {
+ deps = [
+ ":sync_browser_proxy",
+ "..:page_visibility",
+ "..:route",
+ "../settings_page:settings_animated_pages",
+ "//third_party/polymer/v1_0/components-chromium/paper-input:paper-input-extracted",
+ "//ui/webui/resources/cr_elements/cr_expand_button:cr_expand_button",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:util",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("sync_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+
+ externs_list = [ "$externs_path/metrics_private.js" ]
+}
+
+js_library("user_list") {
+ deps = [
+ "..:route",
+ "//ui/webui/resources/cr_elements:cr_scrollable_behavior",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+ externs_list = [
+ "$externs_path/settings_private.js",
+ "$externs_path/users_private.js",
+ ]
+}
+
+js_library("users_add_user_dialog") {
+ deps = [
+ "//ui/webui/resources/js:assert",
+ ]
+ externs_list = [ "$externs_path/users_private.js" ]
+}
+
+js_library("users_page") {
+ deps = [
+ ":user_list",
+ ":users_add_user_dialog",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+}
+
+js_library("import_data_dialog") {
+ deps = [
+ ":import_data_browser_proxy",
+ "../prefs:prefs_behavior",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("sync_account_control") {
+ deps = [
+ ":profile_info_browser_proxy",
+ ":sync_browser_proxy",
+ "..:route",
+ "../prefs:prefs_behavior",
+ "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
+ "//ui/webui/resources/js:icon",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/people_page/account_manager.html b/chromium/chrome/browser/resources/settings/people_page/account_manager.html
new file mode 100644
index 00000000000..7ad4dd0e756
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/people_page/account_manager.html
@@ -0,0 +1,48 @@
+<link rel="import" href="chrome://resources/html/polymer.html">
+
+<link rel="import" href="chrome://resources/html/i18n_behavior.html">
+<link rel="import" href="chrome://resources/html/util.html">
+<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
+<link rel="import" href="../i18n_setup.html">
+<link rel="import" href="../route.html">
+<link rel="import" href="../settings_shared_css.html">
+
+<dom-module id="settings-account-manager">
+ <template>
+ <style include="settings-shared iron-flex iron-flex-alignment">
+ .profile-icon {
+ background: center / cover no-repeat;
+ border-radius: 20px;
+ flex-shrink: 0;
+ height: 40px;
+ width: 40px;
+ }
+
+ #outer {
+ margin-left: auto;
+ margin-right: auto;
+ width: 90%;
+ }
+ </style>
+ <div class="settings-box first">$i18n{accountManagerDescription}</div>
+ <div class="settings-box first">
+ <h2>$i18n{accountListHeader}</h2>
+ </div>
+ <div id="outer" class="layout vertical nowrap">
+ <template is="dom-repeat" items="[[accounts_]]">
+ <div class="settings-box">
+ <div class="profile-icon"
+ style="background-image: [[getIconImageSet_(item.pic)]]"></div>
+ <div class="middle two-line no-min-width">
+ <div class="flex text-elide">
+ <span>[[item.fullName]]</span>
+ <div class="secondary">[[item.email]]</div>
+ </div>
+ </div>
+ </div>
+ </template>
+ <div class="clear settings-box"></div>
+ </div>
+ </template>
+ <script src="account_manager.js"></script>
+</dom-module>
diff --git a/chromium/chrome/browser/resources/settings/people_page/account_manager.js b/chromium/chrome/browser/resources/settings/people_page/account_manager.js
new file mode 100644
index 00000000000..b3d4c9b82de
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/people_page/account_manager.js
@@ -0,0 +1,55 @@
+// 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.
+
+/**
+ * @fileoverview
+ * 'settings-account-manager' is the settings subpage containing controls to
+ * list, add and delete Secondary Google Accounts.
+ */
+
+/**
+ * Information for an account managed by Chrome OS AccountManager.
+ * @typedef {{
+ * fullName: string,
+ * email: string,
+ * pic: string,
+ * }}
+ */
+let Account;
+
+Polymer({
+ is: 'settings-account-manager',
+
+ behaviors: [
+ I18nBehavior,
+ ],
+
+ properties: {
+ /**
+ * List of Accounts.
+ * @type {!Array<Account>}
+ */
+ accounts_: {
+ type: Array,
+ value: function() {
+ return [];
+ },
+ },
+ },
+
+ /** @override */
+ ready: function() {
+ cr.sendWithPromise('getAccounts').then(accounts => {
+ this.set('accounts_', accounts);
+ });
+ },
+
+ /**
+ * @param {string} iconUrl
+ * @return {string} A CSS image-set for multiple scale factors.
+ * @private */
+ getIconImageSet_: function(iconUrl) {
+ return cr.icon.getImage(iconUrl);
+ },
+});
diff --git a/chromium/chrome/browser/resources/settings/people_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/people_page/compiled_resources2.gyp
deleted file mode 100644
index f64ad71864d..00000000000
--- a/chromium/chrome/browser/resources/settings/people_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,278 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'change_picture',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/chromeos/cr_picture/compiled_resources2.gyp:cr_picture_list',
- '<(DEPTH)/ui/webui/resources/cr_elements/chromeos/cr_picture/compiled_resources2.gyp:cr_picture_pane',
- '<(DEPTH)/ui/webui/resources/cr_elements/chromeos/cr_picture/compiled_resources2.gyp:cr_picture_types',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-selector/compiled_resources2.gyp:iron-selector-extracted',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '../compiled_resources2.gyp:route',
- 'change_picture_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'change_picture_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'easy_unlock_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'easy_unlock_turn_off_dialog',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_dialog/compiled_resources2.gyp:cr_dialog',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- 'easy_unlock_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'fingerprint_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'fingerprint_list',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-resizable-behavior/compiled_resources2.gyp:iron-resizable-behavior-extracted',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/paper-ripple/compiled_resources2.gyp:paper-ripple-extracted',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink',
- '<(EXTERNS_GYP):web_animations',
-
- 'fingerprint_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'fingerprint_progress_arc',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'import_data_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'lock_screen',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '../controls/compiled_resources2.gyp:settings_dropdown_menu',
- '../controls/compiled_resources2.gyp:settings_toggle_button',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink',
- 'easy_unlock_browser_proxy',
- 'easy_unlock_turn_off_dialog',
- 'fingerprint_browser_proxy',
- 'lock_screen_constants',
- 'lock_state_behavior',
- 'password_prompt_dialog',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'lock_screen_constants',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_profile_avatar_selector/compiled_resources2.gyp:cr_profile_avatar_selector',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'lock_state_behavior',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '<(EXTERNS_GYP):quick_unlock_private',
- '<(INTERFACES_GYP):quick_unlock_private_interface',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'manage_profile',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- 'manage_profile_browser_proxy',
- 'sync_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'manage_profile_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_profile_avatar_selector/compiled_resources2.gyp:cr_profile_avatar_selector',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'password_prompt_dialog',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/paper-input/compiled_resources2.gyp:paper-input-extracted',
- '<(EXTERNS_GYP):quick_unlock_private',
- '<(INTERFACES_GYP):quick_unlock_private_interface',
- 'lock_screen_constants',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'people_page',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '../settings_page/compiled_resources2.gyp:settings_animated_pages',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_toast/compiled_resources2.gyp:cr_toast',
- '<(DEPTH)/ui/webui/resources/cr_elements/chromeos/cr_picture/compiled_resources2.gyp:cr_png_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:icon',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink',
- 'lock_screen',
- 'lock_screen_constants',
- 'lock_state_behavior',
- 'profile_info_browser_proxy',
- 'sync_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'profile_info_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'setup_fingerprint_dialog',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- 'fingerprint_browser_proxy',
- 'fingerprint_progress_arc',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'setup_pin_dialog',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- 'lock_screen_constants',
- 'password_prompt_dialog',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'sync_page',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '../settings_page/compiled_resources2.gyp:settings_animated_pages',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/paper-input/compiled_resources2.gyp:paper-input-extracted',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_expand_button/compiled_resources2.gyp:cr_expand_button',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- 'sync_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'sync_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/third_party/closure_compiler/externs/compiled_resources2.gyp:metrics_private',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'user_list',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '<(DEPTH)/ui/webui/resources/cr_elements/compiled_resources2.gyp:cr_scrollable_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(EXTERNS_GYP):settings_private',
- '<(EXTERNS_GYP):users_private',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'users_add_user_dialog',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(EXTERNS_GYP):users_private',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'users_page',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink',
- 'user_list',
- 'users_add_user_dialog',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'import_data_dialog',
- 'dependencies': [
- '../prefs/compiled_resources2.gyp:prefs_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- 'import_data_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'sync_account_control',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '../prefs/compiled_resources2.gyp:prefs_behavior',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_action_menu/compiled_resources2.gyp:cr_action_menu',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:icon',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- 'profile_info_browser_proxy',
- 'sync_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/people_page/fingerprint_progress_arc.js b/chromium/chrome/browser/resources/settings/people_page/fingerprint_progress_arc.js
index 11a5e336d8d..2b3c38c77cc 100644
--- a/chromium/chrome/browser/resources/settings/people_page/fingerprint_progress_arc.js
+++ b/chromium/chrome/browser/resources/settings/people_page/fingerprint_progress_arc.js
@@ -125,7 +125,7 @@ Polymer({
* @param {number} startAngle The start angle of the arc we want to draw.
* @param {number} endAngle The end angle of the arc we want to draw.
*/
- animate: function(startAngle, endAngle) {
+ animateProgress: function(startAngle, endAngle) {
let currentAngle = startAngle;
// The value to update the angle by each tick.
const step =
diff --git a/chromium/chrome/browser/resources/settings/people_page/lock_screen.html b/chromium/chrome/browser/resources/settings/people_page/lock_screen.html
index a68afd02144..3b2ddbbe1fb 100644
--- a/chromium/chrome/browser/resources/settings/people_page/lock_screen.html
+++ b/chromium/chrome/browser/resources/settings/people_page/lock_screen.html
@@ -1,5 +1,6 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_radio_button/cr_radio_button.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator.html">
<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html">
@@ -43,8 +44,8 @@
display: block;
}
- paper-radio-button {
- --paper-radio-button-label: {
+ cr-radio-button {
+ --cr-radio-button-label: {
display: flex;
line-height: 154%; /* Apply 20px line-height to paper radio button
text to match rest of settings line-heights. */
@@ -85,7 +86,7 @@
<template is="dom-if" if="[[quickUnlockEnabled_]]">
<div id="lockOptionsDiv">
<div class="settings-box">
- <h2>$i18n{lockScreenOptions}</h2>
+ <h2>[[selectLockScreenOptionsString(hasPinLogin)]]</h2>
<template is="dom-if" if="[[quickUnlockDisabledByPolicy_]]">
<cr-policy-indicator indicator-type="userPolicy">
</cr-policy-indicator>
@@ -94,14 +95,13 @@
<div class="list-frame" >
<paper-radio-group id="unlockType"
disabled$="[[quickUnlockDisabledByPolicy_]]"
- selected="{{selectedUnlockType}}">
- <paper-radio-button name="password" class="list-item underbar">
+ selected="{{selectedUnlockType}}" selectable="cr-radio-button">
+ <cr-radio-button name="password" class="list-item underbar">
<div class="start">
$i18n{lockScreenPasswordOnly}
</div>
- </paper-radio-button>
- <paper-radio-button name="pin+password"
- class="list-item">
+ </cr-radio-button>
+ <cr-radio-button name="pin+password" class="list-item">
<div id="pinPasswordDiv" class="start">
$i18n{lockScreenPinOrPassword}
</div>
@@ -116,7 +116,7 @@
</paper-button>
</div>
</template>
- </paper-radio-button>
+ </cr-radio-button>
</paper-radio-group>
</div>
</div>
diff --git a/chromium/chrome/browser/resources/settings/people_page/lock_screen.js b/chromium/chrome/browser/resources/settings/people_page/lock_screen.js
index 4edb4a4e9ed..9bc50d77a69 100644
--- a/chromium/chrome/browser/resources/settings/people_page/lock_screen.js
+++ b/chromium/chrome/browser/resources/settings/people_page/lock_screen.js
@@ -195,6 +195,7 @@ Polymer({
settings.EasyUnlockBrowserProxyImpl.getInstance();
this.fingerprintBrowserProxy_ =
settings.FingerprintBrowserProxyImpl.getInstance();
+ this.updateNumFingerprints_();
if (this.easyUnlockAllowed_) {
this.addWebUIListener(
@@ -214,12 +215,7 @@ Polymer({
currentRouteChanged: function(newRoute, oldRoute) {
if (newRoute == settings.routes.LOCK_SCREEN) {
this.updateUnlockType();
- if (this.fingerprintUnlockEnabled_ && this.fingerprintBrowserProxy_) {
- this.fingerprintBrowserProxy_.getNumFingerprints().then(
- numFingerprints => {
- this.numFingerprints_ = numFingerprints;
- });
- }
+ this.updateNumFingerprints_();
}
if (this.shouldAskForPassword_(newRoute)) {
@@ -404,4 +400,25 @@ Polymer({
easyUnlockEnabled, proximityDetectionAllowed) {
return easyUnlockEnabled && proximityDetectionAllowed;
},
+
+ /** @private */
+ updateNumFingerprints_: function() {
+ if (this.fingerprintUnlockEnabled_ && this.fingerprintBrowserProxy_) {
+ this.fingerprintBrowserProxy_.getNumFingerprints().then(
+ numFingerprints => {
+ this.numFingerprints_ = numFingerprints;
+ });
+ }
+ },
+
+ /**
+ * Looks up the translation id, which depends on PIN login support.
+ * @param {boolean} hasPinLogin
+ * @private
+ */
+ selectLockScreenOptionsString(hasPinLogin) {
+ if (hasPinLogin)
+ return this.i18n('lockScreenOptionsLoginLock');
+ return this.i18n('lockScreenOptionsLock');
+ },
});
diff --git a/chromium/chrome/browser/resources/settings/people_page/lock_state_behavior.html b/chromium/chrome/browser/resources/settings/people_page/lock_state_behavior.html
index e5b5f0648eb..52dd5119bd0 100644
--- a/chromium/chrome/browser/resources/settings/people_page/lock_state_behavior.html
+++ b/chromium/chrome/browser/resources/settings/people_page/lock_state_behavior.html
@@ -1,3 +1,7 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/html/i18n_behavior.html">
+<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
+<link rel="import" href="../i18n_setup.html">
+
<script src="lock_state_behavior.js"></script>
diff --git a/chromium/chrome/browser/resources/settings/people_page/lock_state_behavior.js b/chromium/chrome/browser/resources/settings/people_page/lock_state_behavior.js
index 0caa83e5beb..8ef0b549f2f 100644
--- a/chromium/chrome/browser/resources/settings/people_page/lock_state_behavior.js
+++ b/chromium/chrome/browser/resources/settings/people_page/lock_state_behavior.js
@@ -15,8 +15,21 @@ const LockScreenUnlockType = {
PIN_PASSWORD: 'pin+password'
};
+/**
+ * Determining if the device supports PIN sign-in takes time, as it may require
+ * a cryptohome call. This means incorrect strings may be shown for a brief
+ * period, and updating them causes UI flicker.
+ *
+ * Cache the value since the behavior is instantiated multiple times. Caching
+ * is safe because PIN login support depends only on hardware capabilities. The
+ * value does not change after discovered.
+ *
+ * @type {boolean|undefined}
+ */
+let cachedHasPinLogin = undefined;
+
/** @polymerBehavior */
-const LockStateBehavior = {
+const LockStateBehaviorImpl = {
properties: {
/**
* The currently selected unlock type.
@@ -34,24 +47,42 @@ const LockStateBehavior = {
hasPin: {type: Boolean, notify: true},
/**
- * Interface for chrome.quickUnlockPrivate calls. May be overriden by tests.
- * @private {QuickUnlockPrivate}
+ * True if the PIN backend supports signin. undefined iff the value is still
+ * resolving.
+ * @type {boolean|undefined}
+ */
+ hasPinLogin: {type: Boolean, notify: true},
+
+ /**
+ * Interface for chrome.quickUnlockPrivate calls. May be overridden by
+ * tests.
+ * @type {QuickUnlockPrivate}
*/
- quickUnlockPrivate_: {type: Object, value: chrome.quickUnlockPrivate},
+ quickUnlockPrivate: {type: Object, value: chrome.quickUnlockPrivate},
},
/** @override */
attached: function() {
this.boundOnActiveModesChanged_ = this.updateUnlockType.bind(this);
- this.quickUnlockPrivate_.onActiveModesChanged.addListener(
+ this.quickUnlockPrivate.onActiveModesChanged.addListener(
this.boundOnActiveModesChanged_);
+ // See comment on |cachedHasPinLogin| declaration.
+ if (cachedHasPinLogin === undefined) {
+ this.addWebUIListener(
+ 'pin-login-available-changed',
+ this.handlePinLoginAvailableChanged_.bind(this));
+ chrome.send('RequestPinLoginState');
+ } else {
+ this.hasPinLogin = cachedHasPinLogin;
+ }
+
this.updateUnlockType();
},
/** @override */
detached: function() {
- this.quickUnlockPrivate_.onActiveModesChanged.removeListener(
+ this.quickUnlockPrivate.onActiveModesChanged.removeListener(
this.boundOnActiveModesChanged_);
},
@@ -61,7 +92,7 @@ const LockStateBehavior = {
* changed, and after the lockscreen preference has changed.
*/
updateUnlockType: function() {
- this.quickUnlockPrivate_.getActiveModes(modes => {
+ this.quickUnlockPrivate.getActiveModes(modes => {
if (modes.includes(chrome.quickUnlockPrivate.QuickUnlockMode.PIN)) {
this.hasPin = true;
this.selectedUnlockType = LockScreenUnlockType.PIN_PASSWORD;
@@ -74,6 +105,19 @@ const LockStateBehavior = {
/** Sets the lock screen enabled state. */
setLockScreenEnabled(authToken, enabled) {
- this.quickUnlockPrivate_.setLockScreenEnabled(authToken, enabled);
+ this.quickUnlockPrivate.setLockScreenEnabled(authToken, enabled);
+ },
+
+ /**
+ * Handler for when the pin login available state has been updated.
+ * @private
+ */
+ handlePinLoginAvailableChanged_: function(isAvailable) {
+ this.hasPinLogin = isAvailable;
+ cachedHasPinLogin = this.hasPinLogin;
},
};
+
+/** @polymerBehavior */
+const LockStateBehavior =
+ [I18nBehavior, WebUIListenerBehavior, LockStateBehaviorImpl]; \ No newline at end of file
diff --git a/chromium/chrome/browser/resources/settings/people_page/password_prompt_dialog.html b/chromium/chrome/browser/resources/settings/people_page/password_prompt_dialog.html
index 0aafe388915..ed1caf9c19c 100644
--- a/chromium/chrome/browser/resources/settings/people_page/password_prompt_dialog.html
+++ b/chromium/chrome/browser/resources/settings/people_page/password_prompt_dialog.html
@@ -4,6 +4,7 @@
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-input/paper-input.html">
<link rel="import" href="lock_screen_constants.html">
+<link rel="import" href="lock_state_behavior.html">
<link rel="import" href="../settings_shared_css.html">
<dom-module id="settings-password-prompt-dialog">
@@ -22,13 +23,16 @@
<div slot="title">$i18n{passwordPromptTitle}</div>
<div slot="body">
- <div class="settings-box first">$i18n{passwordPromptEnterPassword}</div>
+ <div class="settings-box first">
+ [[selectPasswordPromptEnterPasswordString(hasPinLogin)]]
+ </div>
<paper-input id="passwordInput" type="password"
label="$i18n{passwordPromptPasswordLabel}"
invalid$="[[passwordInvalid_]]"
on-input="onPasswordChanged_"
error-message="$i18n{passwordPromptInvalidPassword}"
+ on-value-changed="onValueChanged_"
aria-disabled="false">
</paper-input>
</div>
@@ -37,8 +41,8 @@
$i18n{cancel}
</paper-button>
- <paper-button class="action-button" on-click="submitPassword_"
- disabled$="[[!enableConfirm_(password_, passwordInvalid_)]]">
+ <paper-button id="confirmButton" class="action-button"
+ disabled$="[[!confirmEnabled_]]" on-click="submitPassword_">
$i18n{confirm}
</paper-button>
</div>
diff --git a/chromium/chrome/browser/resources/settings/people_page/password_prompt_dialog.js b/chromium/chrome/browser/resources/settings/people_page/password_prompt_dialog.js
index 34577fe8d1d..0503eceddfc 100644
--- a/chromium/chrome/browser/resources/settings/people_page/password_prompt_dialog.js
+++ b/chromium/chrome/browser/resources/settings/people_page/password_prompt_dialog.js
@@ -30,6 +30,10 @@
Polymer({
is: 'settings-password-prompt-dialog',
+ behaviors: [
+ LockStateBehavior,
+ ],
+
properties: {
/**
* A wrapper around chrome.quickUnlockPrivate.setModes with the account
@@ -44,7 +48,7 @@ Polymer({
},
/**
- * Authhentication token used when calling setModes, returned by
+ * Authentication token used when calling setModes, returned by
* quickUnlockPrivate.getAuthToken. Reflected to lock-screen.
* @private
*/
@@ -54,16 +58,17 @@ Polymer({
},
/**
- * Helper property which marks password as valid/invalid.
+ * Helper property which marks whether the confirm button should be enabled
+ * or disabled.
* @private
*/
- passwordInvalid_: Boolean,
+ confirmEnabled_: Boolean,
/**
- * Interface for chrome.quickUnlockPrivate calls. May be overriden by tests.
- * @private {QuickUnlockPrivate}
+ * Helper property which marks password as valid/invalid.
+ * @private
*/
- quickUnlockPrivate_: {type: Object, value: chrome.quickUnlockPrivate},
+ passwordInvalid_: Boolean,
/**
* writeUma_ is a function that handles writing uma stats. It may be
@@ -112,13 +117,13 @@ Polymer({
return;
}
- this.quickUnlockPrivate_.getAuthToken(password, (tokenInfo) => {
+ this.quickUnlockPrivate.getAuthToken(password, (tokenInfo) => {
if (chrome.runtime.lastError) {
this.passwordInvalid_ = true;
// Select the whole password if user entered an incorrect password.
// Return focus to the password input if it lost focus while being
// checked (user pressed confirm button).
- this.$.passwordInput.inputElement.select();
+ this.$.passwordInput.inputElement.inputElement.select();
if (!this.$.passwordInput.focused)
this.$.passwordInput.focus();
return;
@@ -130,7 +135,7 @@ Polymer({
// Create the |this.setModes| closure and automatically clear it after
// tokenInfo.lifetimeSeconds.
this.setModes = (modes, credentials, onComplete) => {
- this.quickUnlockPrivate_.setModes(
+ this.quickUnlockPrivate.setModes(
tokenInfo.token, modes, credentials, () => {
let result = true;
if (chrome.runtime.lastError) {
@@ -165,8 +170,19 @@ Polymer({
},
/** @private */
- enableConfirm_: function() {
- return !!this.$.passwordInput.value && !this.passwordInvalid_;
+ onValueChanged_: function() {
+ this.confirmEnabled_ = this.$.passwordInput.value && !this.passwordInvalid_;
+ },
+
+ /**
+ * Looks up the translation id, which depends on PIN login support.
+ * @param {boolean} hasPinLogin
+ * @private
+ */
+ selectPasswordPromptEnterPasswordString(hasPinLogin) {
+ if (hasPinLogin)
+ return this.i18n('passwordPromptEnterPasswordLoginLock');
+ return this.i18n('passwordPromptEnterPasswordLock');
},
});
})();
diff --git a/chromium/chrome/browser/resources/settings/people_page/people_page.html b/chromium/chrome/browser/resources/settings/people_page/people_page.html
index 2adc21adf82..a7f1c61b502 100644
--- a/chromium/chrome/browser/resources/settings/people_page/people_page.html
+++ b/chromium/chrome/browser/resources/settings/people_page/people_page.html
@@ -1,5 +1,6 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html">
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
<link rel="import" href="chrome://resources/cr_elements/cr_expand_button/cr_expand_button.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html">
@@ -13,7 +14,6 @@
<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="chrome://resources/polymer/v1_0/neon-animation/neon-animatable.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-checkbox/paper-checkbox.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html">
<link rel="import" href="../controls/settings_toggle_button.html">
<link rel="import" href="sync_page.html">
@@ -25,6 +25,7 @@
<link rel="import" href="../settings_shared_css.html">
<if expr="chromeos">
+<link rel="import" href="account_manager.html">
<link rel="import" href="change_picture.html">
<link rel="import" href="chrome://resources/cr_elements/chromeos/cr_picture/cr_png_behavior.html">
<link rel="import" href="fingerprint_list.html">
@@ -115,6 +116,21 @@
left: auto;
right: 0;
}
+
+ settings-sync-account-control[showing-promo] {
+ /* When showing promo in this page, text should be larger. */
+ --promo-description: {
+ font-size: 0.9rem;
+ line-height: 1.625rem;
+ }
+ --promo-title: {
+ font-size: 1.1rem;
+ line-height: 1.625rem;
+ }
+ --promo-separator: {
+ display: none;
+ }
+ }
</if>
</style>
<settings-animated-pages id="pages" section="people"
@@ -125,8 +141,12 @@
syncStatus.syncSystemEnabled, syncStatus.signinAllowed)]]">
<settings-sync-account-control
sync-status="[[syncStatus]]"
- promo-label="$i18n{peopleSignInPrompt}"
- promo-secondary-label="$i18n{peopleSignInPromptSecondary}">
+ promo-label-with-account="$i18n{peopleSignInPrompt}"
+ promo-label-with-no-account="$i18n{peopleSignInPrompt}"
+ promo-secondary-label-with-account=
+ "$i18n{peopleSignInPromptSecondaryWithAccount}"
+ promo-secondary-label-with-no-account=
+ "$i18n{peopleSignInPromptSecondaryWithNoAccount}">
</settings-sync-account-control>
</template>
<template is="dom-if" if="[[!diceEnabled_]]">
@@ -161,7 +181,7 @@
<if expr="not chromeos">
<template is="dom-if" if="[[showSignin_(syncStatus)]]">
<div class="separator"></div>
- <paper-button class="primary-button" on-click="onSigninTap_"
+ <paper-button class="action-button" on-click="onSigninTap_"
disabled="[[syncStatus.setupInProgress]]">
$i18n{syncSignin}
</paper-button>
@@ -264,21 +284,23 @@
<div id="lock-screen-subpage-trigger" class="settings-box two-line"
actionable on-click="onConfigureLockTap_">
<div class="start">
- $i18n{lockScreenTitle}
+ [[selectLockScreenTitleString(hasPinLogin)]]
<div class="secondary" id="lockScreenSecondary">
[[getPasswordState_(hasPin,
prefs.settings.enable_screen_lock.value)]]
</div>
</div>
<paper-icon-button-light class="subpage-arrow">
- <button aria-label="$i18n{lockScreenTitle}"
+ <button
+ aria-label$="[[selectLockScreenTitleString(hasPinLogin)]]"
aria-describedby="lockScreenSecondary"></button>
</paper-icon-button-light>
</div>
</if>
<div id="manage-other-people-subpage-trigger"
- class="settings-box" on-click="onManageOtherPeople_" actionable>
+ class="settings-box" on-click="onManageOtherPeople_" actionable
+ hidden="[[isChild_]]">
<div class="start">$i18n{manageOtherPeople}</div>
<paper-icon-button-light class="subpage-arrow">
<button aria-label="$i18n{manageOtherPeople}"></button>
@@ -310,13 +332,15 @@
dice-enabled="[[diceEnabled_]]"
</if>
unified-consent-enabled="[[unifiedConsentEnabled_]]"
- sync-status="[[syncStatus]]">
+ sync-status="[[syncStatus]]" prefs="{{prefs}}"
+ page-visibility="[[pageVisibility.privacy]]">
</settings-sync-page>
</settings-subpage>
</template>
<if expr="chromeos">
<template is="dom-if" route-path="/lockScreen">
- <settings-subpage page-title="$i18n{lockScreenTitle}"
+ <settings-subpage
+ page-title="[[selectLockScreenTitleString(hasPinLogin)]]"
associated-control="[[$$('#lock-screen-subpage-trigger')]]">
<settings-lock-screen
prefs="{{prefs}}">
@@ -345,6 +369,12 @@
<settings-change-picture></settings-change-picture>
</settings-subpage>
</template>
+ <template is="dom-if" route-path="/accountManager">
+ <settings-subpage
+ page-title="$i18n{accountManagerPageTitle}">
+ <settings-account-manager></settings-account-manager>
+ </settings-subpage>
+ </template>
</if>
<if expr="not chromeos">
<template is="dom-if" route-path="/manageProfile">
@@ -387,10 +417,10 @@
<template is="dom-if" if="[[!syncStatus.domain]]">
<div id="wideFooter" slot="footer">
<div class="settings-box first">
- <paper-checkbox id="deleteProfile" class="start"
+ <cr-checkbox id="deleteProfile" class="start"
checked="{{deleteProfile_}}">
$i18n{syncDisconnectDeleteProfile}
- </paper-checkbox>
+ </cr-checkbox>
<cr-expand-button expanded="{{deleteProfileWarningVisible_}}"
alt="$i18n{deleteProfileWarningExpandA11yLabel}">
</cr-expand-button>
diff --git a/chromium/chrome/browser/resources/settings/people_page/people_page.js b/chromium/chrome/browser/resources/settings/people_page/people_page.js
index f5d18c59c7e..8ddcca5e8b3 100644
--- a/chromium/chrome/browser/resources/settings/people_page/people_page.js
+++ b/chromium/chrome/browser/resources/settings/people_page/people_page.js
@@ -62,6 +62,12 @@ Polymer({
syncStatus: Object,
/**
+ * Dictionary defining page visibility.
+ * @type {!GuestModePageVisibility}
+ */
+ pageVisibility: Object,
+
+ /**
* The currently selected profile icon URL. May be a data URL.
* @private
*/
@@ -152,12 +158,26 @@ Polymer({
return map;
},
},
+
+ /**
+ * True if current user is child user.
+ */
+ isChild_: Boolean,
},
/** @private {?settings.SyncBrowserProxy} */
syncBrowserProxy_: null,
/** @override */
+ created: function() {
+ // <if expr="chromeos">
+ chrome.usersPrivate.getCurrentUser(user => {
+ this.isChild_ = user.isChild;
+ });
+ // </if>
+ },
+
+ /** @override */
attached: function() {
const profileInfoProxy = settings.ProfileInfoBrowserProxyImpl.getInstance();
profileInfoProxy.getProfileInfo().then(this.handleProfileInfo_.bind(this));
@@ -536,4 +556,15 @@ Polymer({
showSignin_: function(syncStatus) {
return !!syncStatus.signinAllowed && !syncStatus.signedIn;
},
+
+ /**
+ * Looks up the translation id, which depends on PIN login support.
+ * @param {boolean} hasPinLogin
+ * @private
+ */
+ selectLockScreenTitleString(hasPinLogin) {
+ if (hasPinLogin)
+ return this.i18n('lockScreenTitleLoginLock');
+ return this.i18n('lockScreenTitleLock');
+ },
});
diff --git a/chromium/chrome/browser/resources/settings/people_page/setup_fingerprint_dialog.js b/chromium/chrome/browser/resources/settings/people_page/setup_fingerprint_dialog.js
index 4b9ca548d58..02c6690cb1e 100644
--- a/chromium/chrome/browser/resources/settings/people_page/setup_fingerprint_dialog.js
+++ b/chromium/chrome/browser/resources/settings/people_page/setup_fingerprint_dialog.js
@@ -162,7 +162,8 @@ Polymer({
if (scan.isComplete) {
this.problemMessage_ = '';
this.step_ = settings.FingerprintSetupStep.READY;
- this.$.arc.animate(this.receivedScanCount_ * slice, 2 * Math.PI);
+ this.$.arc.animateProgress(
+ this.receivedScanCount_ * slice, 2 * Math.PI);
this.clearSensorMessageTimeout_();
} else {
this.setProblem_(scan.result);
@@ -176,7 +177,7 @@ Polymer({
opacity: [0.7, 1.0],
},
FLASH_DURATION_MS);
- this.$.arc.animate(
+ this.$.arc.animateProgress(
this.receivedScanCount_ * slice,
(this.receivedScanCount_ + 1) * slice);
this.receivedScanCount_++;
diff --git a/chromium/chrome/browser/resources/settings/people_page/sync_account_control.html b/chromium/chrome/browser/resources/settings/people_page/sync_account_control.html
index 21db10e582f..a27d4a15f14 100644
--- a/chromium/chrome/browser/resources/settings/people_page/sync_account_control.html
+++ b/chromium/chrome/browser/resources/settings/people_page/sync_account_control.html
@@ -95,9 +95,8 @@
}
#banner {
- background-image: -webkit-image-set(
- url(../images/sync_banner.png) 1x,
- url(../images/sync_banner_2x.png) 2x);
+ background-color: rgb(248, 249, 250);
+ background-image: url(../images/sync_banner.svg);
background-repeat: no-repeat;
background-size: 100% auto;
display: none;
@@ -108,34 +107,42 @@
display: block;
}
- :host([showing-promo]) #promo-headers {
- line-height: 1.625rem;
+ :host([showing-promo]) #promo-header {
padding-bottom: 10px;
padding-top: 10px;
}
- :host([showing-promo]) #promo-headers #promo-title {
- font-size: 1.1rem;
+ :host([showing-promo]) #promo-title {
+ @apply --promo-title;
}
- :host([showing-promo]) #promo-headers .secondary {
- font-size: 0.9rem;
+ :host([showing-promo]) #promo-description {
+ @apply --promo-description;
}
- :host([showing-promo]) #promo-headers .separator {
+ :host([showing-promo]) #promo-separator {
+ @apply --promo-separator;
+ }
+
+ :host([always-show-promo]) #turn-off {
display: none;
}
</style>
- <div id="banner"></div>
- <div class="settings-box first two-line" id="promo-headers"
+ <div id="banner" hidden="[[syncStatus.signedIn]]"></div>
+ <div class="settings-box first two-line" id="promo-header"
hidden="[[syncStatus.signedIn]]">
<div class="start">
- <div id="promo-title">[[promoLabel]]</div>
+ <div id="promo-title">
+ [[getLabel_(promoLabelWithAccount,
+ promoLabelWithNoAccount, shownAccount_)]]
+ </div>
<div class="secondary">
- [[promoSecondaryLabel]]
+ [[getLabel_(promoSecondaryLabelWithAccount,
+ promoSecondaryLabelWithNoAccount, shownAccount_)]]
</div>
</div>
- <div class="separator" hidden="[[shouldShowAvatarRow_]]"></div>
+ <div id="promo-separator" class="separator"
+ hidden="[[shouldShowAvatarRow_]]"></div>
<paper-button class="action-button" on-click="onSigninTap_"
disabled="[[syncStatus.setupInProgress]]" id="sign-in"
hidden="[[shouldShowAvatarRow_]]">
@@ -185,7 +192,7 @@
'$i18nPolymer{syncAsName}', shownAccount_.givenName)]]
</paper-button>
<paper-button class="secondary-button" on-click="onTurnOffButtonTap_"
- hidden="[[!syncStatus.signedIn]]"
+ hidden="[[!syncStatus.signedIn]]" id="turn-off"
disabled="[[syncStatus.setupInProgress]]">
$i18n{turnOffSync}
</paper-button>
diff --git a/chromium/chrome/browser/resources/settings/people_page/sync_account_control.js b/chromium/chrome/browser/resources/settings/people_page/sync_account_control.js
index f05f7a664d5..43c72d5ebed 100644
--- a/chromium/chrome/browser/resources/settings/people_page/sync_account_control.js
+++ b/chromium/chrome/browser/resources/settings/people_page/sync_account_control.js
@@ -21,6 +21,18 @@ Polymer({
*/
syncStatus: Object,
+ // String to be used as a title when the promo has an account.
+ promoLabelWithAccount: String,
+
+ // String to be used as title of the promo has no account.
+ promoLabelWithNoAccount: String,
+
+ // String to be used as a subtitle when the promo has an account.
+ promoSecondaryLabelWithAccount: String,
+
+ // String to be used as subtitle of the promo has no account.
+ promoSecondaryLabelWithNoAccount: String,
+
/**
* Proxy variable for syncStatus.signedIn to shield observer from being
* triggered multiple times whenever syncStatus changes.
@@ -44,9 +56,12 @@ Polymer({
reflectToAttribute: true,
},
- promoLabel: String,
-
- promoSecondaryLabel: String,
+ // This property should be set by the parent only and should not change
+ // after the element is created.
+ alwaysShowPromo: {
+ type: Boolean,
+ reflectToAttribute: true,
+ },
/** @private {boolean} */
shouldShowAvatarRow_: {
@@ -108,6 +123,11 @@ Polymer({
/** @private */
onSignedInChanged_: function() {
+ if (this.alwaysShowPromo) {
+ this.showingPromo = true;
+ return;
+ }
+
if (!this.showingPromo && !this.syncStatus.signedIn &&
this.syncBrowserProxy_.getPromoImpressionCount() <
settings.MAX_SIGNIN_PROMO_IMPRESSION) {
@@ -122,6 +142,16 @@ Polymer({
},
/**
+ * @param {string} labelWithAccount
+ * @param {string} labelWithNoAccount
+ * @return {string}
+ * @private
+ */
+ getLabel_: function(labelWithAccount, labelWithNoAccount) {
+ return this.shownAccount_ ? labelWithAccount : labelWithNoAccount;
+ },
+
+ /**
* @param {string} label
* @param {string} name
* @return {string}
diff --git a/chromium/chrome/browser/resources/settings/people_page/sync_browser_proxy.js b/chromium/chrome/browser/resources/settings/people_page/sync_browser_proxy.js
index 527e8a4cee8..e6197c05906 100644
--- a/chromium/chrome/browser/resources/settings/people_page/sync_browser_proxy.js
+++ b/chromium/chrome/browser/resources/settings/people_page/sync_browser_proxy.js
@@ -192,13 +192,6 @@ cr.define('settings', function() {
setSyncDatatypes(syncPrefs) {}
/**
- * Sets the syncAllDataTypes pref.
- * @param {boolean} syncEverything
- * @return {!Promise<!settings.PageStatus>}
- */
- setSyncEverything(syncEverything) {}
-
- /**
* Sets the sync encryption options.
* @param {!settings.SyncPrefs} syncPrefs
* @return {!Promise<!settings.PageStatus>}
@@ -289,11 +282,6 @@ cr.define('settings', function() {
}
/** @override */
- setSyncEverything(syncEverything) {
- return cr.sendWithPromise('SyncSetupSetSyncEverything', syncEverything);
- }
-
- /** @override */
setSyncEncryption(syncPrefs) {
return cr.sendWithPromise(
'SyncSetupSetEncryption', JSON.stringify(syncPrefs));
diff --git a/chromium/chrome/browser/resources/settings/people_page/sync_page.html b/chromium/chrome/browser/resources/settings/people_page/sync_page.html
index ee01bc3bc49..1c5cf73b4cc 100644
--- a/chromium/chrome/browser/resources/settings/people_page/sync_page.html
+++ b/chromium/chrome/browser/resources/settings/people_page/sync_page.html
@@ -5,16 +5,18 @@
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/cr_elements/cr_expand_button/cr_expand_button.html">
<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_radio_button/cr_radio_button.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-collapse/iron-collapse.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-input/paper-input.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-radio-button/paper-radio-button.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-radio-group/paper-radio-group.html">
<link rel="import" href="sync_browser_proxy.html">
+<link rel="import" href="../privacy_page/personalization_options.html">
<link rel="import" href="../route.html">
<link rel="import" href="../settings_shared_css.html">
+<link rel="import" href="../settings_vars_css.html">
<if expr="not chromeos">
<link rel="import" href="chrome://resources/cr_elements/cr_toast/cr_toast.html">
@@ -30,7 +32,7 @@
}
paper-input {
- width: var(--paper-input-max-width);
+ width: var(--settings-input-max-width);
--paper-input-container-focus-color: var(--google-blue-500);
--paper-input-container-input: {
font-size: inherit;
@@ -82,29 +84,37 @@
left: auto;
right: 0;
}
-
- #toast paper-button {
- -webkit-margin-end: 0;
- -webkit-margin-start: 32px;
- color: var(--google-blue-300);
- font-weight: 500;
- height: 32px;
- min-width: 52px;
- padding: 8px;
- }
</if>
</style>
<if expr="not chromeos">
<template is="dom-if" if="[[shouldShowSyncAccountControl_(diceEnabled,
unifiedConsentEnabled, syncStatus.syncSystemEnabled,
syncStatus.signinAllowed)]]">
- <settings-sync-account-control
+ <settings-sync-account-control always-show-promo
sync-status="[[syncStatus]]"
- promo-label="$i18n{syncSignInPrompt}"
- promo-secondary-label="$i18n{syncSignInPromptSecondary}">
+ promo-label-with-account="$i18n{syncSignInPromptWithAccount}"
+ promo-label-with-no-account="$i18n{syncSignInPromptWithNoAccount}"
+ promo-secondary-label-with-account="$i18n{syncSignInPromptSecondary}"
+ promo-secondary-label-with-no-account=
+ "$i18n{syncSignInPromptSecondary}">
</settings-sync-account-control>
</template>
</if>
+ <div class="settings-box first two-line"
+ hidden="[[!unifiedConsentEnabled]]">
+ <div class="start">
+ <div>$i18n{syncUnifiedConsentToggleTitle}</div>
+ <div class="secondary">$i18n{syncUnifiedConsentToggleSubtitle}</div>
+ </div>
+ <!-- For now this toggle only turns on all sync services.
+ TODO(crbug.com/800974): Add custom function for turning
+ on all unified consent services.-->
+ <cr-toggle id="syncAllDataTypesControl"
+ checked="{{syncPrefs.syncAllDataTypes}}"
+ on-change="onSyncAllDataTypesChanged_"
+ aria-labelledby="syncUnifiedConsentToggleTitle">
+ </cr-toggle>
+ </div>
<div class="settings-box first two-line" id="sync-section-toggle"
actionable$="[[!syncSectionDisabled_]]"
on-click="toggleExpandButton_"
@@ -354,13 +364,14 @@
<paper-radio-group disabled$="[[syncPrefs.encryptAllData]]"
selected="[[selectedEncryptionRadio_(
syncPrefs.passphraseTypeIsCustom)]]"
+ selectable="cr-radio-button"
on-paper-radio-group-changed=
"onEncryptionRadioSelectionChanged_">
- <paper-radio-button name="encrypt-with-google"
+ <cr-radio-button name="encrypt-with-google"
class="list-item" disabled="[[syncPrefs.encryptAllData]]">
$i18n{encryptWithGoogleCredentialsLabel}
- </paper-radio-button>
- <paper-radio-button name="encrypt-with-passphrase"
+ </cr-radio-button>
+ <cr-radio-button name="encrypt-with-passphrase"
class="list-item" disabled="[[syncPrefs.encryptAllData]]">
<template is="dom-if" if="[[syncPrefs.fullEncryptionBody]]">
<span>[[syncPrefs.fullEncryptionBody]]</span>
@@ -370,7 +381,7 @@
$i18nRaw{encryptWithSyncPassphraseLabel}
</span>
</template>
- </paper-radio-button>
+ </cr-radio-button>
</paper-radio-group>
<div id="reset-sync-message-box" class="list-item"
hidden="[[!syncPrefs.encryptAllData]]">
@@ -407,10 +418,29 @@
</div>
</div>
</iron-collapse>
+ <template is="dom-if" if="[[unifiedConsentEnabled]]">
+ <div class="settings-box two-line" id="personalize-section-toggle"
+ actionable on-click="toggleExpandButton_">
+ <div class="start">
+ <div>$i18n{personalizationSectionLabel}</div>
+ <div class="secondary">$i18n{personalizationSectionDesc}</div>
+ </div>
+ <cr-expand-button expanded="{{personalizeSectionOpened_}}"
+ alt="$i18n{syncExpandA11yLabel}">
+ </cr-expand-button>
+ </div>
+ <iron-collapse id="personalize-section"
+ opened="[[personalizeSectionOpened_]]">
+ <settings-personalization-options class="list-frame" prefs="{{prefs}}"
+ page-visibility="[[pageVisibility]]"
+ unified-consent-enabled="[[unifiedConsentEnabled]]">
+ </settings-personalization-options>
+ </iron-collapse>
+ </template>
<if expr="not chromeos">
<cr-toast id="toast" open="[[syncStatus.setupInProgress]]">
- $i18n{syncWillStart}
+ <div>$i18n{syncWillStart}</div>
<paper-button on-click="onCancelSyncClick_">
$i18n{cancelSync}
</paper-button>
diff --git a/chromium/chrome/browser/resources/settings/people_page/sync_page.js b/chromium/chrome/browser/resources/settings/people_page/sync_page.js
index edc4382915a..5076295ebae 100644
--- a/chromium/chrome/browser/resources/settings/people_page/sync_page.js
+++ b/chromium/chrome/browser/resources/settings/people_page/sync_page.js
@@ -15,6 +15,24 @@ const RadioButtonNames = {
};
/**
+ * Names of the individual data type properties to be cached from
+ * settings.SyncPrefs when the user checks 'Sync All'.
+ * @type {!Array<string>}
+ */
+const SyncPrefsIndividualDataTypes = [
+ 'appsSynced',
+ 'extensionsSynced',
+ 'preferencesSynced',
+ 'autofillSynced',
+ 'typedUrlsSynced',
+ 'themesSynced',
+ 'bookmarksSynced',
+ 'passwordsSynced',
+ 'tabsSynced',
+ 'paymentsIntegrationEnabled',
+];
+
+/**
* @fileoverview
* 'settings-sync-page' is the settings page containing sync settings.
*/
@@ -27,6 +45,14 @@ Polymer({
],
properties: {
+ /**
+ * Preferences state.
+ */
+ prefs: {
+ type: Object,
+ notify: true,
+ },
+
/** @private */
pages_: {
type: Object,
@@ -46,6 +72,12 @@ Polymer({
},
/**
+ * Dictionary defining page visibility.
+ * @type {!PrivacyPageVisibility}
+ */
+ pageVisibility: Object,
+
+ /**
* The current sync preferences, supplied by SyncBrowserProxy.
* @type {settings.SyncPrefs|undefined}
*/
@@ -106,6 +138,12 @@ Polymer({
},
/** @private */
+ personalizeSectionOpened_: {
+ type: Boolean,
+ value: true,
+ },
+
+ /** @private */
syncSectionOpened_: {
type: Boolean,
value: true,
@@ -139,6 +177,13 @@ Polymer({
*/
didAbort_: false,
+ /**
+ * Caches the individually selected synced data types. This is used to
+ * be able to restore the selections after checking and unchecking Sync All.
+ * @private {?Object}
+ */
+ cachedSyncPrefs_: null,
+
/** @override */
created: function() {
this.browserProxy_ = settings.SyncBrowserProxyImpl.getInstance();
@@ -245,7 +290,7 @@ Polymer({
listenOnce(document, 'show-container', () => {
const input = /** @type {!PaperInputElement} */ (
this.$$('#existingPassphraseInput'));
- input.inputElement.focus();
+ input.focus();
});
}
},
@@ -256,8 +301,25 @@ Polymer({
* @private
*/
onSyncAllDataTypesChanged_: function(event) {
- this.browserProxy_.setSyncEverything(event.target.checked)
- .then(this.handlePageStatusChanged_.bind(this));
+ if (event.target.checked) {
+ this.set('syncPrefs.syncAllDataTypes', true);
+
+ // Cache the previously selected preference before checking every box.
+ this.cachedSyncPrefs_ = {};
+ for (const dataType of SyncPrefsIndividualDataTypes) {
+ // These are all booleans, so this shallow copy is sufficient.
+ this.cachedSyncPrefs_[dataType] = this.syncPrefs[dataType];
+
+ this.set(['syncPrefs', dataType], true);
+ }
+ } else if (this.cachedSyncPrefs_) {
+ // Restore the previously selected preference.
+ for (const dataType of SyncPrefsIndividualDataTypes) {
+ this.set(['syncPrefs', dataType], this.cachedSyncPrefs_[dataType]);
+ }
+ }
+
+ this.onSingleSyncDataTypeChanged_();
},
/**
diff --git a/chromium/chrome/browser/resources/settings/people_page/users_add_user_dialog.html b/chromium/chrome/browser/resources/settings/people_page/users_add_user_dialog.html
index 97358beb6a5..c582dd3845f 100644
--- a/chromium/chrome/browser/resources/settings/people_page/users_add_user_dialog.html
+++ b/chromium/chrome/browser/resources/settings/people_page/users_add_user_dialog.html
@@ -5,12 +5,13 @@
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-input/paper-input.html">
<link rel="import" href="../settings_shared_css.html">
+<link rel="import" href="../settings_vars_css.html">
<dom-module id="settings-users-add-user-dialog">
<template>
<style include="settings-shared">
paper-input {
- width: var(--paper-input-max-width);
+ width: var(--settings-input-max-width);
--paper-input-container-focus-color: var(--google-blue-500);
--paper-input-container-input: {
font-size: inherit;
diff --git a/chromium/chrome/browser/resources/settings/people_page/users_page.js b/chromium/chrome/browser/resources/settings/people_page/users_page.js
index f0d5847693f..f8f19f31ff6 100644
--- a/chromium/chrome/browser/resources/settings/people_page/users_page.js
+++ b/chromium/chrome/browser/resources/settings/people_page/users_page.js
@@ -34,8 +34,8 @@ Polymer({
/** @override */
created: function() {
- chrome.usersPrivate.isCurrentUserOwner(isOwner => {
- this.isOwner_ = isOwner;
+ chrome.usersPrivate.getCurrentUser(user => {
+ this.isOwner_ = user.isOwner;
});
chrome.usersPrivate.isWhitelistManaged(isWhitelistManaged => {
diff --git a/chromium/chrome/browser/resources/settings/prefs/BUILD.gn b/chromium/chrome/browser/resources/settings/prefs/BUILD.gn
new file mode 100644
index 00000000000..6f61f794d71
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/prefs/BUILD.gn
@@ -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.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":pref_util",
+ ":prefs",
+ ":prefs_behavior",
+ ":prefs_types",
+ ]
+}
+
+js_library("pref_util") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
+
+js_library("prefs") {
+ deps = [
+ ":pref_util",
+ ":prefs_behavior",
+ ":prefs_types",
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+ extra_sources = [ "$interfaces_path/settings_private_interface.js" ]
+}
+
+js_library("prefs_behavior") {
+ deps = [
+ "//ui/webui/resources/js:assert",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
+
+js_library("prefs_types") {
+}
diff --git a/chromium/chrome/browser/resources/settings/prefs/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/prefs/compiled_resources2.gyp
deleted file mode 100644
index 1446acb3227..00000000000
--- a/chromium/chrome/browser/resources/settings/prefs/compiled_resources2.gyp
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'pref_util',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):settings_private',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'prefs',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):settings_private',
- '<(INTERFACES_GYP):settings_private_interface',
- 'pref_util',
- 'prefs_behavior',
- 'prefs_types',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'prefs_behavior',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(EXTERNS_GYP):settings_private',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'prefs_types',
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/printing_page/BUILD.gn b/chromium/chrome/browser/resources/settings/printing_page/BUILD.gn
new file mode 100644
index 00000000000..c609a9e2437
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/printing_page/BUILD.gn
@@ -0,0 +1,98 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":cloud_printers",
+ ":cups_add_printer_dialog",
+ ":cups_add_printer_dialog_util",
+ ":cups_edit_printer_dialog",
+ ":cups_printers",
+ ":cups_printers_browser_proxy",
+ ":cups_printers_list",
+ ":cups_set_manufacturer_model_behavior",
+ ":printing_browser_proxy",
+ ":printing_page",
+ ]
+}
+
+js_library("cloud_printers") {
+ deps = [
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
+
+js_library("cups_add_printer_dialog") {
+ deps = [
+ ":cups_printers_browser_proxy",
+ ":cups_set_manufacturer_model_behavior",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("cups_add_printer_dialog_util") {
+ deps = [
+ ":cups_printers_browser_proxy",
+ "//ui/webui/resources/cr_elements:cr_scrollable_behavior",
+ ]
+}
+
+js_library("cups_edit_printer_dialog") {
+ deps = [
+ ":cups_set_manufacturer_model_behavior",
+ ]
+}
+
+js_library("cups_printers") {
+ deps = [
+ ":cups_printers_browser_proxy",
+ "//ui/webui/resources/cr_elements/cr_toast:cr_toast",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+ externs_list = [ "$externs_path/networking_private.js" ]
+}
+
+js_library("cups_printers_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("cups_printers_list") {
+ deps = [
+ ":cups_printers_browser_proxy",
+ "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:icon",
+ ]
+}
+
+js_library("cups_set_manufacturer_model_behavior") {
+ deps = [
+ ":cups_printers_browser_proxy",
+ ]
+}
+
+js_library("printing_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("printing_page") {
+ deps = [
+ ":cups_printers_browser_proxy",
+ ":printing_browser_proxy",
+ "..:route",
+ "../settings_page:settings_animated_pages",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/printing_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/printing_page/compiled_resources2.gyp
deleted file mode 100644
index cc0e0003a42..00000000000
--- a/chromium/chrome/browser/resources/settings/printing_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,94 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'cloud_printers',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'cups_add_printer_dialog',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- 'cups_printers_browser_proxy',
- 'cups_set_manufacturer_model_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'cups_add_printer_dialog_util',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/compiled_resources2.gyp:cr_scrollable_behavior',
- 'cups_printers_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'cups_edit_printer_dialog',
- 'dependencies': [
- 'cups_set_manufacturer_model_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'cups_printers',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink',
- 'cups_printers_browser_proxy',
- '<(EXTERNS_GYP):networking_private',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'cups_printers_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'cups_printers_list',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_action_menu/compiled_resources2.gyp:cr_action_menu',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:icon',
- 'cups_printers_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'cups_set_manufacturer_model_behavior',
- 'dependencies': [
- 'cups_printers_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'printing_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'printing_page',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '../compiled_resources2.gyp:route',
- '../settings_page/compiled_resources2.gyp:settings_animated_pages',
- 'cups_printers_browser_proxy',
- 'printing_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.html b/chromium/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.html
index d8436bfe128..1791682d943 100644
--- a/chromium/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.html
+++ b/chromium/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.html
@@ -221,9 +221,9 @@
<div class="label">$i18n{selectDriver}</div>
<div class="secondary">
<paper-input class="browse-file-input" no-label-float readonly
- value="[[getBaseName_(activePrinter.printerPPDPath)]]"
+ value="[[newUserPPD_]]"
error-message="$i18n{selectDriverErrorMessage}"
- invalid="[[invalidPPD]]">
+ invalid="[[invalidPPD_]]">
<paper-button class="browse-button" slot="suffix"
on-click="onBrowseFile_">
$i18n{selectDriverButtonText}
diff --git a/chromium/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog_util.html b/chromium/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog_util.html
index 70ae6da07e5..0b7ecc7a51e 100644
--- a/chromium/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog_util.html
+++ b/chromium/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog_util.html
@@ -59,11 +59,16 @@
#dropdownIcon {
background-size: 24px;
}
+
+ iron-input input {
+ @apply --paper-input-container-shared-input-style;
+ }
</style>
<paper-input-container no-label-float on-click="onTap_">
- <input is="iron-input" type="search" bind-value="{{selectedItem}}"
- on-search="onInputValueChanged_" on-change="onChange_" incremental
- slot="input">
+ <iron-input id="search" slot="input" bind-value="{{selectedItem}}">
+ <input type="search" on-search="onInputValueChanged_"
+ value="{{value::input}}" on-change="onChange_" incremental>
+ </iron-input>
<paper-icon-button-light id="searchIcon" class="icon-search" hidden
slot="suffix">
<button></button>
diff --git a/chromium/chrome/browser/resources/settings/printing_page/cups_edit_printer_dialog.html b/chromium/chrome/browser/resources/settings/printing_page/cups_edit_printer_dialog.html
index 3e2cbde5af9..9c0e99e23a9 100644
--- a/chromium/chrome/browser/resources/settings/printing_page/cups_edit_printer_dialog.html
+++ b/chromium/chrome/browser/resources/settings/printing_page/cups_edit_printer_dialog.html
@@ -9,7 +9,11 @@
<dom-module id="settings-cups-edit-printer-dialog">
<template>
- <style include="cups-printer-shared"></style>
+ <style include="cups-printer-shared">
+ #existingUserPPD {
+ padding-top: 10px;
+ }
+ </style>
<add-printer-dialog>
<div slot="dialog-title">$i18n{editPrinterDialogTitle}</div>
<div slot="dialog-body">
@@ -28,7 +32,8 @@
<div class="label">$i18n{printerAddress}</div>
<div class="secondary">
<paper-input no-label-float
- value="{{activePrinter.printerAddress}}">
+ value="{{activePrinter.printerAddress}}"
+ disabled="[[!networkProtocolActive_]]">
</paper-input>
</div>
</div>
@@ -40,14 +45,32 @@
<div class="md-select-wrapper">
<select class="md-select" aria-labelledby="printerProtocol"
value="[[activePrinter.printerProtocol]]"
- on-change="onProtocolChange_">
- <option value="ipp">$i18n{printerProtocolIpp}</option>
- <option value="ipps">$i18n{printerProtocolIpps}</option>
- <option value="http">$i18n{printerProtocolHttp}</option>
- <option value="https">$i18n{printerProtocolHttps}</option>
- <option value="socket">$i18n{printerProtocolAppSocket}
+ on-change="onProtocolChange_"
+ disabled="[[!networkProtocolActive_]]">
+ <option value="ipp" disabled="[[!networkProtocolActive_]]">
+ $i18n{printerProtocolIpp}
+ </option>
+ <option value="ipps" disabled="[[!networkProtocolActive_]]">
+ $i18n{printerProtocolIpps}
+ </option>
+ <option value="http" disabled="[[!networkProtocolActive_]]">
+ $i18n{printerProtocolHttp}
+ </option>
+ <option value="https" disabled="[[!networkProtocolActive_]]">
+ $i18n{printerProtocolHttps}
+ </option>
+ <option value="socket" disabled="[[!networkProtocolActive_]]">
+ $i18n{printerProtocolAppSocket}
+ </option>
+ <option value="lpd" disabled="[[!networkProtocolActive_]]">
+ $i18n{printerProtocolLpd}
+ </option>
+ <option value="usb" disabled="[[networkProtocolActive_]]">
+ $i18n{printerProtocolUsb}
+ </option>
+ <option value="ippusb" disabled="[[networkProtocolActive_]]">
+ $i18n{printerProtocolIppUsb}
</option>
- <option value="lpd">$i18n{printerProtocolLpd}</option>
</select>
<span class="md-select-underline"></span>
</div>
@@ -59,7 +82,8 @@
<div class="label">$i18n{printerQueue}</div>
<div class="secondary">
<paper-input no-label-float
- value="{{activePrinter.printerQueue}}">
+ value="{{activePrinter.printerQueue}}"
+ disabled="[[!networkProtocolActive_]]">
</paper-input>
</div>
</div>
@@ -99,15 +123,20 @@
<div class="label">$i18n{selectDriver}</div>
<div class="secondary">
<paper-input class="browse-file-input" no-label-float readonly
- value="[[getBaseName_(activePrinter.printerPPDPath)]]"
+ value="[[newUserPPD_]]"
error-message="$i18n{selectDriverErrorMessage}"
- invalid="[[invalidPPD]]">
+ invalid="[[invalidPPD_]]">
<paper-button class="browse-button" slot="suffix"
on-click="onBrowseFile_">
$i18n{selectDriverButtonText}
</paper-button>
</paper-input>
</div>
+ <template is="dom-if" if="[[existingUserPPDMessage_]]">
+ <div class="secondary" id="existingUserPPD">
+ [[existingUserPPDMessage_]]
+ </div>
+ </template>
</div>
</div>
</div>
@@ -116,8 +145,7 @@
on-click="onCancelTap_">
$i18n{cancel}
</paper-button>
- <paper-button class="action-button" on-click="onSaveTap_"
- disabled="[[invalidPPD]]">
+ <paper-button class="action-button" on-click="onSaveTap_">
$i18n{editPrinterButtonText}
</paper-button>
</div>
diff --git a/chromium/chrome/browser/resources/settings/printing_page/cups_edit_printer_dialog.js b/chromium/chrome/browser/resources/settings/printing_page/cups_edit_printer_dialog.js
index fe8ecdc222a..7b5543d7715 100644
--- a/chromium/chrome/browser/resources/settings/printing_page/cups_edit_printer_dialog.js
+++ b/chromium/chrome/browser/resources/settings/printing_page/cups_edit_printer_dialog.js
@@ -20,6 +20,17 @@ Polymer({
* @private {boolean}
*/
needsReconfigured_: Boolean,
+
+ /**
+ * The current PPD in use by the printer.
+ * @private
+ */
+ existingUserPPDMessage_: String,
+
+ networkProtocolActive_: {
+ type: Boolean,
+ computed: 'isNetworkProtocol_(activePrinter.printerProtocol)',
+ },
},
observers: [
@@ -33,6 +44,11 @@ Polymer({
.then(
this.onGetPrinterPpdManufacturerAndModel_.bind(this),
this.onGetPrinterPpdManufacturerAndModelFailed_.bind(this));
+ let basename = this.getBaseName(this.activePrinter.printerPPDPath);
+ if (basename) {
+ this.existingUserPPDMessage_ =
+ loadTimeData.getStringF('currentPpdMessage', basename);
+ }
},
/**
@@ -110,4 +126,13 @@ Polymer({
onGetPrinterPpdManufacturerAndModelFailed_: function() {
this.needsReconfigured_ = false;
},
+
+ /**
+ * @param {string} protocol
+ * @return {boolean} Whether |protocol| is a network protocol
+ * @private
+ */
+ isNetworkProtocol_: function(protocol) {
+ return ['ipp', 'ipps', 'http', 'https', 'socket', 'lpd'].includes(protocol);
+ },
});
diff --git a/chromium/chrome/browser/resources/settings/printing_page/cups_printer_shared_css.html b/chromium/chrome/browser/resources/settings/printing_page/cups_printer_shared_css.html
index 026ed96e938..451ef9faf39 100644
--- a/chromium/chrome/browser/resources/settings/printing_page/cups_printer_shared_css.html
+++ b/chromium/chrome/browser/resources/settings/printing_page/cups_printer_shared_css.html
@@ -97,11 +97,9 @@
outline: none;
}
- paper-input-container {
- --paper-input-container-input: {
- font: inherit;
- };
- --paper-input-container-input-color: inherit;
+ #search input[type='search'] {
+ @apply --paper-input-container-shared-input-style;
+ font: inherit;
}
</style>
</template>
diff --git a/chromium/chrome/browser/resources/settings/printing_page/cups_printers.html b/chromium/chrome/browser/resources/settings/printing_page/cups_printers.html
index cfa6ea52c57..13b2968ecad 100644
--- a/chromium/chrome/browser/resources/settings/printing_page/cups_printers.html
+++ b/chromium/chrome/browser/resources/settings/printing_page/cups_printers.html
@@ -1,5 +1,7 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_pref_indicator.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_toast/cr_toast.html">
<link rel="import" href="chrome://resources/html/action_link.html">
<link rel="import" href="chrome://resources/html/action_link_css.html">
<link rel="import" href="chrome://resources/html/assert.html">
@@ -13,24 +15,6 @@
<dom-module id="settings-cups-printers">
<template>
<style include="cups-printer-shared action-link">
- #message {
- display: flex;
- justify-content: center;
- position: absolute;
- top: 85%;
- width: 100%;
- }
-
- .center {
- background-color: black;
- color: white;
- font: 13px;
- padding-bottom: 15px;
- padding-top: 15px;
- text-align: center;
- width: 350px;
- }
-
#noSearchResultsMessage {
color: var(--md-loading-message-color);
font-size: 16px;
@@ -60,8 +44,16 @@
$i18n{requireNetworkMessage}
</div>
</div>
- <paper-button class="primary-button" id="addPrinter"
- on-click="onAddPrinterTap_" disabled="[[!canAddPrinter_]]">
+ <template is="dom-if" if="[[!addPrinterButtonActive_(canAddPrinter_,
+ prefs.native_printing.user_native_printers_allowed.value)]]">
+ <cr-policy-pref-indicator
+ pref="[[prefs.native_printing.user_native_printers_allowed]]">
+ </cr-policy-pref-indicator>
+ </template>
+ <paper-button class="action-button" id="addPrinter"
+ on-click="onAddPrinterTap_"
+ disabled="[[!addPrinterButtonActive_(canAddPrinter_,
+ prefs.native_printing.user_native_printers_allowed.value)]]">
$i18n{addCupsPrinter}
</paper-button>
</div>
@@ -86,16 +78,11 @@
$i18n{noSearchResults}
</div>
- <div id="message">
- <div class="center" id="addPrinterDoneMessage" hidden>
- $i18n{printerAddedSuccessfulMessage}
+ <cr-toast id="errorToast" duration="3000">
+ <div class="error-message" id="addPrinterDoneMessage">
+ [[addPrinterResultText_]]
</div>
- <div class="center" id="addPrinterErrorMessage" hidden>
- <span id="addPrinterFailedMessage">
- $i18n{printerAddedFailedMessage}
- </span>
- </div>
- </div>
+ </cr-toast>
</template>
<script src="cups_printers.js"></script>
</dom-module>
diff --git a/chromium/chrome/browser/resources/settings/printing_page/cups_printers.js b/chromium/chrome/browser/resources/settings/printing_page/cups_printers.js
index 055f4a807c5..cf2233ae112 100644
--- a/chromium/chrome/browser/resources/settings/printing_page/cups_printers.js
+++ b/chromium/chrome/browser/resources/settings/printing_page/cups_printers.js
@@ -21,6 +21,8 @@ Polymer({
notify: true,
},
+ prefs: Object,
+
/** @type {?CupsPrinterInfo} */
activePrinter: {
type: Object,
@@ -36,6 +38,9 @@ Polymer({
/** @private */
showCupsEditPrinterDialog_: Boolean,
+
+ /**@private */
+ addPrinterResultText_: String,
},
listeners: {
@@ -57,6 +62,8 @@ Polymer({
/** @override */
attached: function() {
this.addWebUIListener('on-add-cups-printer', this.onAddPrinter_.bind(this));
+ this.addWebUIListener(
+ 'on-printers-changed', this.printersChanged_.bind(this));
this.networksChangedListener_ = this.refreshNetworks_.bind(this);
chrome.networkingPrivate.onNetworksChanged.addListener(
this.networksChangedListener_);
@@ -100,53 +107,54 @@ Polymer({
* @private
*/
onAddPrinter_: function(result_code, printerName) {
- let message;
if (result_code == PrinterSetupResult.SUCCESS) {
this.updateCupsPrintersList_();
- message = this.$.addPrinterDoneMessage;
- message.textContent =
+ this.addPrinterResultText_ =
loadTimeData.getStringF('printerAddedSuccessfulMessage', printerName);
} else {
- message = this.$.addPrinterErrorMessage;
- const messageText = this.$.addPrinterFailedMessage;
switch (result_code) {
case PrinterSetupResult.FATAL_ERROR:
- messageText.textContent =
+ this.addPrinterResultText_ =
loadTimeData.getString('printerAddedFatalErrorMessage');
break;
case PrinterSetupResult.PRINTER_UNREACHABLE:
- messageText.textContent =
+ this.addPrinterResultText_ =
loadTimeData.getString('printerAddedUnreachableMessage');
break;
case PrinterSetupResult.DBUS_ERROR:
// Simply display a generic error message as this error should only
// occur when a call to Dbus fails which isn't meaningful to the user.
- messageText.textContent =
+ this.addPrinterResultText_ =
loadTimeData.getString('printerAddedFailedmMessage');
break;
+ case PrinterSetupResult.NATIVE_PRINTERS_NOT_ALLOWED:
+ this.addPrinterResultText_ = loadTimeData.getString(
+ 'printerAddedNativePrintersNotAllowedMessage');
+ break;
+ case PrinterSetupResult.INVALID_PRINTER_UPDATE:
+ this.addPrinterResultText_ =
+ loadTimeData.getString('editPrinterInvalidPrinterUpdate');
+ break;
case PrinterSetupResult.PPD_TOO_LARGE:
- messageText.textContent =
+ this.addPrinterResultText_ =
loadTimeData.getString('printerAddedPpdTooLargeMessage');
break;
case PrinterSetupResult.INVALID_PPD:
- messageText.textContent =
+ this.addPrinterResultText_ =
loadTimeData.getString('printerAddedInvalidPpdMessage');
break;
case PrinterSetupResult.PPD_NOT_FOUND:
- messageText.textContent =
+ this.addPrinterResultText_ =
loadTimeData.getString('printerAddedPpdNotFoundMessage');
break;
case PrinterSetupResult.PPD_UNRETRIEVABLE:
- messageText.textContent =
+ this.addPrinterResultText_ =
loadTimeData.getString('printerAddedPpdUnretrievableMessage');
break;
}
}
- message.hidden = false;
- window.setTimeout(function() {
- message.hidden = true;
- }, 3000);
+ this.$.errorToast.show();
},
/** @private */
@@ -200,4 +208,16 @@ Polymer({
});
},
+ /**
+ * @param {boolean} connectedToNetwork Whether the device is connected to
+ a network.
+ * @param {boolean} userNativePrintersAllowed Whether users are allowed to
+ configure their own native printers.
+ * @return {boolean} Whether the 'Add Printer' button is active.
+ * @private
+ */
+ addPrinterButtonActive_: function(
+ connectedToNetwork, userNativePrintersAllowed) {
+ return connectedToNetwork && userNativePrintersAllowed;
+ }
});
diff --git a/chromium/chrome/browser/resources/settings/printing_page/cups_printers_browser_proxy.js b/chromium/chrome/browser/resources/settings/printing_page/cups_printers_browser_proxy.js
index f282624946f..8de6a74190e 100644
--- a/chromium/chrome/browser/resources/settings/printing_page/cups_printers_browser_proxy.js
+++ b/chromium/chrome/browser/resources/settings/printing_page/cups_printers_browser_proxy.js
@@ -78,6 +78,8 @@ const PrinterSetupResult = {
SUCCESS: 1,
PRINTER_UNREACHABLE: 2,
DBUS_ERROR: 3,
+ NATIVE_PRINTERS_NOT_ALLOWED: 4,
+ INVALID_PRINTER_UPDATE: 5,
PPD_TOO_LARGE: 10,
INVALID_PPD: 11,
PPD_NOT_FOUND: 12,
diff --git a/chromium/chrome/browser/resources/settings/printing_page/cups_set_manufacturer_model_behavior.js b/chromium/chrome/browser/resources/settings/printing_page/cups_set_manufacturer_model_behavior.js
index 43f805bf3f8..69dcd217d85 100644
--- a/chromium/chrome/browser/resources/settings/printing_page/cups_set_manufacturer_model_behavior.js
+++ b/chromium/chrome/browser/resources/settings/printing_page/cups_set_manufacturer_model_behavior.js
@@ -16,16 +16,26 @@ const SetManufacturerModelBehavior = {
notify: true,
},
- invalidPPD: {
- type: Boolean,
- value: false,
- },
-
/** @type {?Array<string>} */
manufacturerList: Array,
/** @type {?Array<string>} */
modelList: Array,
+
+ /**
+ * Whether the user selected PPD file is valid.
+ * @private
+ */
+ invalidPPD_: {
+ type: Boolean,
+ value: false,
+ },
+
+ /**
+ * The base name of a newly selected PPD file.
+ * @private
+ */
+ newUserPPD_: String,
},
observers: [
@@ -40,6 +50,18 @@ const SetManufacturerModelBehavior = {
},
/**
+ * @param {string} path The full path of the file
+ * @return {string} The base name of the file
+ * @public
+ */
+ getBaseName: function(path) {
+ if (path && path.length > 0)
+ return path.substring(path.lastIndexOf('/') + 1);
+ else
+ return '';
+ },
+
+ /**
* @param {string} manufacturer The manufacturer for which we are retrieving
* models.
* @private
@@ -92,18 +114,7 @@ const SetManufacturerModelBehavior = {
*/
printerPPDPathChanged_: function(path) {
this.set('activePrinter.printerPPDPath', path);
- this.invalidPPD = !path;
- },
-
- /**
- * @param {string} path The full path of the file
- * @return {string} The base name of the file
- * @private
- */
- getBaseName_: function(path) {
- if (path && path.length > 0)
- return path.substring(path.lastIndexOf('/') + 1);
- else
- return '';
+ this.invalidPPD_ = !path;
+ this.newUserPPD_ = this.getBaseName(path);
},
};
diff --git a/chromium/chrome/browser/resources/settings/printing_page/printing_page.html b/chromium/chrome/browser/resources/settings/printing_page/printing_page.html
index af5a328a2ef..59372e889b4 100644
--- a/chromium/chrome/browser/resources/settings/printing_page/printing_page.html
+++ b/chromium/chrome/browser/resources/settings/printing_page/printing_page.html
@@ -53,7 +53,8 @@
page-title="$i18n{cupsPrintersTitle}"
search-label="$i18n{searchLabel}"
search-term="{{searchTerm}}">
- <settings-cups-printers search-term="{{searchTerm}}">
+ <settings-cups-printers search-term="{{searchTerm}}"
+ prefs="[[prefs]]">
</settings-cups-printers>
</settings-subpage>
</template>
diff --git a/chromium/chrome/browser/resources/settings/privacy_page/BUILD.gn b/chromium/chrome/browser/resources/settings/privacy_page/BUILD.gn
new file mode 100644
index 00000000000..d2bb5b5324f
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/privacy_page/BUILD.gn
@@ -0,0 +1,49 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":personalization_options",
+ ":privacy_page",
+ ":privacy_page_browser_proxy",
+ ]
+}
+
+js_library("personalization_options") {
+ deps = [
+ ":privacy_page_browser_proxy",
+ "..:page_visibility",
+ "..:route",
+ "../controls:settings_toggle_button",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
+
+js_library("privacy_page_browser_proxy") {
+ deps = [
+ "..:lifetime_browser_proxy",
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/chrome_send.js" ]
+}
+
+js_library("privacy_page") {
+ deps = [
+ ":privacy_page_browser_proxy",
+ "..:page_visibility",
+ "..:route",
+ "../controls:settings_toggle_button",
+ "../settings_page:settings_animated_pages",
+ "../site_settings:constants",
+ "../site_settings:site_data_details_subpage",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
diff --git a/chromium/chrome/browser/resources/settings/privacy_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/privacy_page/compiled_resources2.gyp
deleted file mode 100644
index 073f1291261..00000000000
--- a/chromium/chrome/browser/resources/settings/privacy_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'privacy_page_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '../compiled_resources2.gyp:lifetime_browser_proxy',
- '<(EXTERNS_GYP):chrome_send',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'privacy_page',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink',
- '../compiled_resources2.gyp:route',
- '../controls/compiled_resources2.gyp:settings_toggle_button',
- '../settings_page/compiled_resources2.gyp:settings_animated_pages',
- '../compiled_resources2.gyp:page_visibility',
- '../site_settings/compiled_resources2.gyp:constants',
- '../site_settings/compiled_resources2.gyp:site_data_details_subpage',
- 'privacy_page_browser_proxy',
- '<(EXTERNS_GYP):settings_private',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/privacy_page/personalization_options.html b/chromium/chrome/browser/resources/settings/privacy_page/personalization_options.html
new file mode 100644
index 00000000000..7f8265a3e0c
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/privacy_page/personalization_options.html
@@ -0,0 +1,93 @@
+<link rel="import" href="chrome://resources/html/polymer.html">
+
+<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html">
+<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
+<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
+<link rel="import" href="../controls/settings_toggle_button.html">
+<link rel="import" href="../lifetime_browser_proxy.html">
+<link rel="import" href="../route.html">
+<link rel="import" href="../settings_shared_css.html">
+<link rel="import" href="privacy_page_browser_proxy.html">
+
+<dom-module id="settings-personalization-options">
+ <template>
+ <style include="settings-shared">
+ :host(.list-frame) settings-toggle-button,
+ :host(.list-frame) .settings-box {
+ -webkit-padding-end: 0;
+ -webkit-padding-start: 0;
+ }
+
+ :host(.list-frame) settings-toggle-button:first-of-type {
+ border-top: none;
+ }
+ </style>
+ <settings-toggle-button pref="{{prefs.alternate_error_pages.enabled}}"
+ label="$i18n{linkDoctorPref}"
+ sub-label="$i18n{linkDoctorPrefDesc}">
+ </settings-toggle-button>
+ <settings-toggle-button hidden="[[!pageVisibility.searchPrediction]]"
+ pref="{{prefs.search.suggest_enabled}}"
+ label="$i18n{searchSuggestPref}"
+ sub-label="$i18n{searchSuggestPrefDesc}">
+ </settings-toggle-button>
+ <settings-toggle-button id="safeBrowsingExtendedReportingControl"
+ pref="[[safeBrowsingExtendedReportingPref_]]"
+ label="$i18n{safeBrowsingEnableExtendedReporting}"
+ sub-label="$i18n{safeBrowsingEnableExtendedReportingDesc}"
+ on-settings-boolean-control-change="onSberChange_"
+ no-set-pref>
+ </settings-toggle-button>
+ <settings-toggle-button hidden="[[!pageVisibility.networkPrediction]]"
+ pref="{{prefs.net.network_prediction_options}}"
+ label="$i18n{networkPredictionEnabled}"
+ sub-label="$i18n{networkPredictionEnabledDesc}"
+ numeric-unchecked-value="[[networkPredictionEnum_.NEVER]]">
+ </settings-toggle-button>
+ <settings-toggle-button pref="{{prefs.safebrowsing.enabled}}"
+ label="$i18n{safeBrowsingEnableProtection}"
+ sub-label="$i18n{safeBrowsingEnableProtectionDesc}">
+ </settings-toggle-button>
+<if expr="_google_chrome">
+ <template is="dom-if" if="[[!unifiedConsentEnabled]]">
+ <settings-toggle-button id="spellCheckControl"
+ pref="{{prefs.spellcheck.use_spelling_service}}"
+ label="$i18n{spellingPref}"
+ sub-label="$i18n{spellingDescription}">
+ </settings-toggle-button>
+ </template>
+ <template is="dom-if" if="[[unifiedConsentEnabled]]">
+ <div class="settings-box two-line" id="spellCheckLinkBox">
+ <div class="start">
+ $i18n{spellingPref}
+ <div class="secondary" on-click="onLanguageLinkBoxClick_">
+ $i18nRaw{spellingDescription}
+ </div>
+ </div>
+ <cr-toggle checked="[[prefs.spellcheck.use_spelling_service]]" disabled>
+ </cr-toggle>
+ </div>
+ </template>
+<if expr="chromeos">
+ <settings-toggle-button pref="{{prefs.cros.metrics.reportingEnabled}}"
+ label="$i18n{enableLogging}"
+ sub-label="$i18n{enableLoggingDesc}">
+ </settings-toggle-button>
+</if><!-- chromeos -->
+<if expr="not chromeos">
+ <settings-toggle-button id="metricsReportingControl"
+ pref="[[metricsReportingPref_]]" label="$i18n{enableLogging}"
+ sub-label="$i18n{enableLoggingDesc}" no-set-pref
+ on-settings-boolean-control-change="onMetricsReportingChange_">
+ <template is="dom-if" if="[[showRestart_]]" restamp>
+ <paper-button on-click="onRestartTap_" id="restart"
+ slot="more-actions">
+ $i18n{restart}
+ </paper-button>
+ </template>
+ </settings-toggle-button>
+</if><!-- not chromeos -->
+</if><!-- _google_chrome -->
+ </template>
+ <script src="personalization_options.js"></script>
+</dom-module> \ No newline at end of file
diff --git a/chromium/chrome/browser/resources/settings/privacy_page/personalization_options.js b/chromium/chrome/browser/resources/settings/privacy_page/personalization_options.js
new file mode 100644
index 00000000000..3d5887b2a17
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/privacy_page/personalization_options.js
@@ -0,0 +1,175 @@
+// 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.
+
+/**
+ * @fileoverview
+ * 'personalization-options' contains several toggles related to
+ * personalizations.
+ */
+(function() {
+
+/**
+ * Must be kept in sync with the C++ enum of the same name.
+ * @enum {number}
+ */
+const NetworkPredictionOptions = {
+ ALWAYS: 0,
+ WIFI_ONLY: 1,
+ NEVER: 2,
+ DEFAULT: 1,
+};
+
+Polymer({
+ is: 'settings-personalization-options',
+
+ behaviors: [
+ WebUIListenerBehavior,
+ ],
+
+ properties: {
+ prefs: {
+ type: Object,
+ notify: true,
+ },
+
+ /**
+ * Dictionary defining page visibility.
+ * @type {!PrivacyPageVisibility}
+ */
+ pageVisibility: Object,
+
+ /** @private {chrome.settingsPrivate.PrefObject} */
+ safeBrowsingExtendedReportingPref_: {
+ type: Object,
+ value: function() {
+ return /** @type {chrome.settingsPrivate.PrefObject} */ ({});
+ },
+ },
+
+ /**
+ * Used for HTML bindings. This is defined as a property rather than within
+ * the ready callback, because the value needs to be available before
+ * local DOM initialization - otherwise, the toggle has unexpected behavior.
+ * @private
+ */
+ networkPredictionEnum_: {
+ type: Object,
+ value: NetworkPredictionOptions,
+ },
+
+ unifiedConsentEnabled: Boolean,
+
+ // <if expr="_google_chrome and not chromeos">
+ // TODO(dbeam): make a virtual.* pref namespace and set/get this normally
+ // (but handled differently in C++).
+ /** @private {chrome.settingsPrivate.PrefObject} */
+ metricsReportingPref_: {
+ type: Object,
+ value: function() {
+ // TODO(dbeam): this is basically only to appease PrefControlBehavior.
+ // Maybe add a no-validate attribute instead? This makes little sense.
+ return /** @type {chrome.settingsPrivate.PrefObject} */ ({});
+ },
+ },
+
+ /** @private */
+ showRestart_: Boolean,
+ // </if>
+ },
+
+ /** @override */
+ ready: function() {
+ this.browserProxy_ = settings.PrivacyPageBrowserProxyImpl.getInstance();
+
+ const setSber = this.setSafeBrowsingExtendedReporting_.bind(this);
+ this.addWebUIListener('safe-browsing-extended-reporting-change', setSber);
+ this.browserProxy_.getSafeBrowsingExtendedReporting().then(setSber);
+
+ // <if expr="_google_chrome and not chromeos">
+ const setMetricsReportingPref = this.setMetricsReportingPref_.bind(this);
+ this.addWebUIListener('metrics-reporting-change', setMetricsReportingPref);
+ this.browserProxy_.getMetricsReporting().then(setMetricsReportingPref);
+ // </if>
+ },
+
+ /** @private */
+ onSberChange_: function() {
+ const enabled = this.$.safeBrowsingExtendedReportingControl.checked;
+ this.browserProxy_.setSafeBrowsingExtendedReportingEnabled(enabled);
+ },
+
+ /**
+ * @param {!Event} e
+ * @private
+ */
+ onLanguageLinkBoxClick_: function(e) {
+ if (e.target.tagName === 'A') {
+ e.preventDefault();
+ settings.navigateTo(settings.routes.LANGUAGES);
+ }
+ },
+
+ /**
+ * @param {!SberPrefState} sberPrefState SBER enabled and managed state.
+ * @private
+ */
+ setSafeBrowsingExtendedReporting_: function(sberPrefState) {
+ // Ignore the next change because it will happen when we set the pref.
+ const pref = {
+ key: '',
+ type: chrome.settingsPrivate.PrefType.BOOLEAN,
+ value: sberPrefState.enabled,
+ };
+ if (sberPrefState.managed) {
+ pref.enforcement = chrome.settingsPrivate.Enforcement.ENFORCED;
+ pref.controlledBy = chrome.settingsPrivate.ControlledBy.USER_POLICY;
+ }
+ this.safeBrowsingExtendedReportingPref_ = pref;
+ },
+
+ // <if expr="_google_chrome and not chromeos">
+ /** @private */
+ onMetricsReportingChange_: function() {
+ const enabled = this.$.metricsReportingControl.checked;
+ this.browserProxy_.setMetricsReportingEnabled(enabled);
+ },
+
+ /**
+ * @param {!MetricsReporting} metricsReporting
+ * @private
+ */
+ setMetricsReportingPref_: function(metricsReporting) {
+ const hadPreviousPref = this.metricsReportingPref_.value !== undefined;
+ const pref = {
+ key: '',
+ type: chrome.settingsPrivate.PrefType.BOOLEAN,
+ value: metricsReporting.enabled,
+ };
+ if (metricsReporting.managed) {
+ pref.enforcement = chrome.settingsPrivate.Enforcement.ENFORCED;
+ pref.controlledBy = chrome.settingsPrivate.ControlledBy.USER_POLICY;
+ }
+
+ // Ignore the next change because it will happen when we set the pref.
+ this.metricsReportingPref_ = pref;
+
+ // TODO(dbeam): remember whether metrics reporting was enabled when Chrome
+ // started.
+ if (metricsReporting.managed)
+ this.showRestart_ = false;
+ else if (hadPreviousPref)
+ this.showRestart_ = true;
+ },
+
+ /**
+ * @param {!Event} e
+ * @private
+ */
+ onRestartTap_: function(e) {
+ e.stopPropagation();
+ settings.LifetimeBrowserProxyImpl.getInstance().restart();
+ },
+ // </if>
+});
+})();
diff --git a/chromium/chrome/browser/resources/settings/privacy_page/privacy_page.html b/chromium/chrome/browser/resources/settings/privacy_page/privacy_page.html
index c938b42ff11..1d1b892d602 100644
--- a/chromium/chrome/browser/resources/settings/privacy_page/privacy_page.html
+++ b/chromium/chrome/browser/resources/settings/privacy_page/privacy_page.html
@@ -33,6 +33,7 @@
<link rel="import" href="chrome://resources/cr_components/certificate_manager/certificate_manager.html">
</if>
<link rel="import" href="privacy_page_browser_proxy.html">
+<link rel="import" href="personalization_options.html">
<dom-module id="settings-privacy-page">
<template>
@@ -68,52 +69,22 @@
<div class="settings-box first">
<p class="privacy-explanation">$i18nRaw{improveBrowsingExperience}</p>
</div>
- <settings-toggle-button pref="{{prefs.alternate_error_pages.enabled}}"
- label="$i18n{linkDoctorPref}">
- </settings-toggle-button>
- <settings-toggle-button hidden="[[!pageVisibility.searchPrediction]]"
- pref="{{prefs.search.suggest_enabled}}"
- label="$i18n{searchSuggestPref}">
- </settings-toggle-button>
- <settings-toggle-button hidden="[[!pageVisibility.networkPrediction]]"
- pref="{{prefs.net.network_prediction_options}}"
- label="$i18n{networkPredictionEnabled}"
- numeric-unchecked-value="[[networkPredictionEnum_.NEVER]]">
- </settings-toggle-button>
- <settings-toggle-button id="safeBrowsingExtendedReportingControl"
- pref="[[safeBrowsingExtendedReportingPref_]]"
- label="$i18n{safeBrowsingEnableExtendedReporting}"
- on-settings-boolean-control-change="onSberChange_"
- no-set-pref>
- </settings-toggle-button>
- <settings-toggle-button pref="{{prefs.safebrowsing.enabled}}"
- label="$i18n{safeBrowsingEnableProtection}">
- </settings-toggle-button>
-<if expr="_google_chrome">
-<if expr="chromeos">
- <settings-toggle-button pref="{{prefs.cros.metrics.reportingEnabled}}"
- label="$i18n{enableLogging}">
- </settings-toggle-button>
-</if><!-- chromeos -->
-<if expr="not chromeos">
- <settings-toggle-button id="metricsReportingControl"
- pref="[[metricsReportingPref_]]" label="$i18n{enableLogging}"
- on-settings-boolean-control-change="onMetricsReportingChange_"
- no-set-pref>
- <template is="dom-if" if="[[showRestart_]]" restamp>
- <paper-button on-click="onRestartTap_" id="restart"
- slot="more-actions">
- $i18n{restart}
- </paper-button>
- </template>
- </settings-toggle-button>
-</if><!-- not chromeos -->
-</if><!-- _google_chrome -->
+ <template is="dom-if" if="[[!unifiedConsentEnabled_]]">
+ <settings-personalization-options prefs="{{prefs}}"
+ page-visibility="[[pageVisibility]]"
+ unified-consent-enabled="[[unifiedConsentEnabled_]]">
+ </settings-personalization-options>
+ </template>
<settings-toggle-button id="doNotTrack"
pref="{{prefs.enable_do_not_track}}" label="$i18n{doNotTrack}"
on-settings-boolean-control-change="onDoNotTrackChange_"
no-set-pref>
</settings-toggle-button>
+ <settings-toggle-button id="canMakePaymentToggle"
+ aria-label="$i18n{canMakePaymentToggleLabel}"
+ label="$i18n{canMakePaymentToggleLabel}"
+ pref="{{prefs.payments.can_make_payment_enabled}}">
+ </settings-toggle-button>
<if expr="chromeos">
<settings-toggle-button
pref="{{prefs.cros.device.attestation_for_content_protection_enabled}}"
@@ -124,13 +95,6 @@
label="$i18n{wakeOnWifi}">
</settings-toggle-button>
</if>
-<if expr="_google_chrome">
- <settings-toggle-button
- pref="{{prefs.spellcheck.use_spelling_service}}"
- label="$i18n{spellingPref}"
- sub-label="$i18n{spellingDescription}">
- </settings-toggle-button>
-</if>
<if expr="use_nss_certs or is_win or is_macosx">
<div id="manageCertificates" class="settings-box two-line"
actionable on-click="onManageCertificatesTap_">
@@ -182,6 +146,10 @@
aria-describedby="clearBrowsingDataSecondary"></button>
</paper-icon-button-light>
</div>
+ <div class="settings-box" on-click="onMoreSettingsBoxClicked_"
+ hidden="[[!unifiedConsentEnabled_]]">
+ <div class="start">$i18nRaw{syncAndPersonalizationLink}</div>
+ </div>
</neon-animatable>
<if expr="use_nss_certs">
<template is="dom-if" route-path="/certificates">
@@ -204,7 +172,7 @@
</template>
<template is="dom-if" route-path="/content/all" no-search>
- <settings-subpage page-title="$i18n{siteSettingsCategoryAllSites}">
+ <settings-subpage page-title="$i18n{siteSettingsAllSites}">
<all-sites></all-sites>
</settings-subpage>
</template>
diff --git a/chromium/chrome/browser/resources/settings/privacy_page/privacy_page.js b/chromium/chrome/browser/resources/settings/privacy_page/privacy_page.js
index c8a41ea8594..20d6993b772 100644
--- a/chromium/chrome/browser/resources/settings/privacy_page/privacy_page.js
+++ b/chromium/chrome/browser/resources/settings/privacy_page/privacy_page.js
@@ -9,17 +9,6 @@
*/
(function() {
-/**
- * Must be kept in sync with the C++ enum of the same name.
- * @enum {number}
- */
-const NetworkPredictionOptions = {
- ALWAYS: 0,
- WIFI_ONLY: 1,
- NEVER: 2,
- DEFAULT: 1,
-};
-
Polymer({
is: 'settings-privacy-page',
@@ -52,30 +41,6 @@ Polymer({
}
},
- // <if expr="_google_chrome and not chromeos">
- // TODO(dbeam): make a virtual.* pref namespace and set/get this normally
- // (but handled differently in C++).
- /** @private {chrome.settingsPrivate.PrefObject} */
- metricsReportingPref_: {
- type: Object,
- value: function() {
- // TODO(dbeam): this is basically only to appease PrefControlBehavior.
- // Maybe add a no-validate attribute instead? This makes little sense.
- return /** @type {chrome.settingsPrivate.PrefObject} */ ({});
- },
- },
-
- showRestart_: Boolean,
- // </if>
-
- /** @private {chrome.settingsPrivate.PrefObject} */
- safeBrowsingExtendedReportingPref_: {
- type: Object,
- value: function() {
- return /** @type {chrome.settingsPrivate.PrefObject} */ ({});
- },
- },
-
/** @private */
showClearBrowsingDataDialog_: Boolean,
@@ -85,17 +50,6 @@ Polymer({
value: false,
},
- /**
- * Used for HTML bindings. This is defined as a property rather than within
- * the ready callback, because the value needs to be available before
- * local DOM initialization - otherwise, the toggle has unexpected behavior.
- * @private
- */
- networkPredictionEnum_: {
- type: Object,
- value: NetworkPredictionOptions,
- },
-
/** @private */
enableSafeBrowsingSubresourceFilter_: {
type: Boolean,
@@ -157,6 +111,20 @@ Polymer({
return map;
},
},
+
+ /**
+ * This flag is used to conditionally show a set of sync UIs to the
+ * profiles that have been migrated to have a unified consent flow.
+ * TODO(scottchen): In the future when all profiles are completely migrated,
+ * this should be removed, and UIs hidden behind it should become default.
+ * @private
+ */
+ unifiedConsentEnabled_: {
+ type: Boolean,
+ value: function() {
+ return loadTimeData.getBoolean('unifiedConsentEnabled');
+ },
+ },
},
listeners: {
@@ -168,16 +136,6 @@ Polymer({
this.ContentSettingsTypes = settings.ContentSettingsTypes;
this.browserProxy_ = settings.PrivacyPageBrowserProxyImpl.getInstance();
-
- // <if expr="_google_chrome and not chromeos">
- const setMetricsReportingPref = this.setMetricsReportingPref_.bind(this);
- this.addWebUIListener('metrics-reporting-change', setMetricsReportingPref);
- this.browserProxy_.getMetricsReporting().then(setMetricsReportingPref);
- // </if>
-
- const setSber = this.setSafeBrowsingExtendedReporting_.bind(this);
- this.addWebUIListener('safe-browsing-extended-reporting-change', setSber);
- this.browserProxy_.getSafeBrowsingExtendedReporting().then(setSber);
},
/** @protected */
@@ -264,6 +222,17 @@ Polymer({
},
/**
+ * @param {!Event} e
+ * @private
+ */
+ onMoreSettingsBoxClicked_: function(e) {
+ if (e.target.tagName === 'A') {
+ e.preventDefault();
+ settings.navigateTo(settings.routes.SYNC);
+ }
+ },
+
+ /**
* This is a workaround to connect the remove all button to the subpage.
* @private
*/
@@ -295,74 +264,6 @@ Polymer({
cr.ui.focusWithoutInk(assert(this.$.clearBrowsingDataTrigger));
},
- /** @private */
- onSberChange_: function() {
- const enabled = this.$.safeBrowsingExtendedReportingControl.checked;
- this.browserProxy_.setSafeBrowsingExtendedReportingEnabled(enabled);
- },
-
- // <if expr="_google_chrome and not chromeos">
- /** @private */
- onMetricsReportingChange_: function() {
- const enabled = this.$.metricsReportingControl.checked;
- this.browserProxy_.setMetricsReportingEnabled(enabled);
- },
-
- /**
- * @param {!MetricsReporting} metricsReporting
- * @private
- */
- setMetricsReportingPref_: function(metricsReporting) {
- const hadPreviousPref = this.metricsReportingPref_.value !== undefined;
- const pref = {
- key: '',
- type: chrome.settingsPrivate.PrefType.BOOLEAN,
- value: metricsReporting.enabled,
- };
- if (metricsReporting.managed) {
- pref.enforcement = chrome.settingsPrivate.Enforcement.ENFORCED;
- pref.controlledBy = chrome.settingsPrivate.ControlledBy.USER_POLICY;
- }
-
- // Ignore the next change because it will happen when we set the pref.
- this.metricsReportingPref_ = pref;
-
- // TODO(dbeam): remember whether metrics reporting was enabled when Chrome
- // started.
- if (metricsReporting.managed)
- this.showRestart_ = false;
- else if (hadPreviousPref)
- this.showRestart_ = true;
- },
-
- /**
- * @param {!Event} e
- * @private
- */
- onRestartTap_: function(e) {
- e.stopPropagation();
- settings.LifetimeBrowserProxyImpl.getInstance().restart();
- },
- // </if>
-
- /**
- * @param {!SberPrefState} sberPrefState SBER enabled and managed state.
- * @private
- */
- setSafeBrowsingExtendedReporting_: function(sberPrefState) {
- // Ignore the next change because it will happen when we set the pref.
- const pref = {
- key: '',
- type: chrome.settingsPrivate.PrefType.BOOLEAN,
- value: sberPrefState.enabled,
- };
- if (sberPrefState.managed) {
- pref.enforcement = chrome.settingsPrivate.Enforcement.ENFORCED;
- pref.controlledBy = chrome.settingsPrivate.ControlledBy.USER_POLICY;
- }
- this.safeBrowsingExtendedReportingPref_ = pref;
- },
-
/**
* The sub-page title for the site or content settings.
* @return {string}
diff --git a/chromium/chrome/browser/resources/settings/reset_page/BUILD.gn b/chromium/chrome/browser/resources/settings/reset_page/BUILD.gn
new file mode 100644
index 00000000000..53cc82ae726
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/reset_page/BUILD.gn
@@ -0,0 +1,49 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":powerwash_dialog",
+ ":reset_browser_proxy",
+ ":reset_page",
+ ":reset_profile_dialog",
+ ]
+}
+
+js_library("powerwash_dialog") {
+ deps = [
+ ":reset_browser_proxy",
+ "..:lifetime_browser_proxy",
+ ]
+}
+
+js_library("reset_page") {
+ deps = [
+ ":reset_profile_dialog",
+ "..:route",
+ "//ui/webui/resources/cr_elements/cr_lazy_render:cr_lazy_render",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+}
+
+js_library("reset_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/chrome_send.js" ]
+}
+
+js_library("reset_profile_dialog") {
+ deps = [
+ ":reset_browser_proxy",
+ "..:route",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/reset_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/reset_page/compiled_resources2.gyp
deleted file mode 100644
index 8f1477c598c..00000000000
--- a/chromium/chrome/browser/resources/settings/reset_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'powerwash_dialog',
- 'dependencies': [
- '../compiled_resources2.gyp:lifetime_browser_proxy',
- 'reset_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'reset_page',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_lazy_render/compiled_resources2.gyp:cr_lazy_render',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink',
- 'reset_profile_dialog',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'reset_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):chrome_send',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'reset_profile_dialog',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- 'reset_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/reset_page/reset_page.html b/chromium/chrome/browser/resources/settings/reset_page/reset_page.html
index e4ba69503f8..0727c4b5ecd 100644
--- a/chromium/chrome/browser/resources/settings/reset_page/reset_page.html
+++ b/chromium/chrome/browser/resources/settings/reset_page/reset_page.html
@@ -62,16 +62,14 @@
</template>
</if>
<if expr="_google_chrome and is_win">
- <template is="dom-if" if="[[userInitiatedCleanupsEnabled_]]" restamp>
- <div class="settings-box" id="chromeCleanupSubpageTrigger"
- on-click="onChromeCleanupTap_" actionable>
- <div class="start">$i18n{resetCleanupComputerTrigger}</div>
- <paper-icon-button-light class="subpage-arrow">
- <button id="chromeCleanupArrow"
- aria-label="$i18n{resetCleanupComputerTrigger}"></button>
- </paper-icon-button-light>
- </div>
- </template>
+ <div class="settings-box" id="chromeCleanupSubpageTrigger"
+ on-click="onChromeCleanupTap_" actionable>
+ <div class="start">$i18n{resetCleanupComputerTrigger}</div>
+ <paper-icon-button-light class="subpage-arrow">
+ <button id="chromeCleanupArrow"
+ aria-label="$i18n{resetCleanupComputerTrigger}"></button>
+ </paper-icon-button-light>
+ </div>
<template is="dom-if" if="[[showIncompatibleApplications_]]" restamp>
<div class="settings-box"
id="incompatibleApplicationsSubpageTrigger"
@@ -89,15 +87,14 @@
</if>
</neon-animatable>
<if expr="_google_chrome and is_win">
- <template is="dom-if" if="[[userInitiatedCleanupsEnabled_]]">
- <template is="dom-if" route-path="/cleanup">
- <settings-subpage id="chromeCleanupSubpage"
- associated-control="[[$$('#chromeCleanupSubpageTrigger')]]"
- page-title="$i18n{resetCleanupComputerTrigger}"
- learn-more-url="$i18n{chromeCleanupLearnMoreUrl}">
- <settings-chrome-cleanup-page></settings-chrome-cleanup-page>
- </settings-subpage>
- </template>
+ <template is="dom-if" route-path="/cleanup">
+ <settings-subpage id="chromeCleanupSubpage"
+ associated-control="[[$$('#chromeCleanupSubpageTrigger')]]"
+ page-title="$i18n{resetCleanupComputerTrigger}"
+ learn-more-url="$i18n{chromeCleanupLearnMoreUrl}">
+ <settings-chrome-cleanup-page prefs="[[prefs]]">
+ </settings-chrome-cleanup-page>
+ </settings-subpage>
</template>
<template is="dom-if" if="[[showIncompatibleApplications_]]">
<template is="dom-if" route-path="/incompatibleApplications">
diff --git a/chromium/chrome/browser/resources/settings/reset_page/reset_page.js b/chromium/chrome/browser/resources/settings/reset_page/reset_page.js
index a8683102acc..8bf342fa8f3 100644
--- a/chromium/chrome/browser/resources/settings/reset_page/reset_page.js
+++ b/chromium/chrome/browser/resources/settings/reset_page/reset_page.js
@@ -21,6 +21,9 @@ Polymer({
behaviors: [settings.RouteObserverBehavior],
properties: {
+ /** Preferences state. */
+ prefs: Object,
+
// <if expr="chromeos">
/** @private */
showPowerwashDialog_: Boolean,
@@ -34,14 +37,6 @@ Polymer({
// <if expr="_google_chrome and is_win">
/** @private */
- userInitiatedCleanupsEnabled_: {
- type: Boolean,
- value: function() {
- return loadTimeData.getBoolean('userInitiatedCleanupsEnabled');
- },
- },
-
- /** @private */
showIncompatibleApplications_: {
type: Boolean,
value: function() {
diff --git a/chromium/chrome/browser/resources/settings/reset_page/reset_profile_dialog.html b/chromium/chrome/browser/resources/settings/reset_page/reset_profile_dialog.html
index d48cb08125b..64a6823036b 100644
--- a/chromium/chrome/browser/resources/settings/reset_page/reset_profile_dialog.html
+++ b/chromium/chrome/browser/resources/settings/reset_page/reset_profile_dialog.html
@@ -1,11 +1,11 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html">
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
<link rel="import" href="chrome://resources/html/action_link.html">
<link rel="import" href="chrome://resources/html/action_link_css.html">
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-checkbox/paper-checkbox.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-spinner/paper-spinner-lite.html">
<link rel="import" href="reset_browser_proxy.html">
<link rel="import" href="../i18n_setup.html">
@@ -45,8 +45,8 @@
</paper-button>
</div>
<div slot="footer">
- <paper-checkbox id="sendSettings" checked>
- $i18nRaw{resetPageFeedback}</paper-checkbox>
+ <cr-checkbox id="sendSettings" checked>
+ $i18nRaw{resetPageFeedback}</cr-checkbox>
</div>
</cr-dialog>
</template>
diff --git a/chromium/chrome/browser/resources/settings/reset_page/reset_profile_dialog.js b/chromium/chrome/browser/resources/settings/reset_page/reset_profile_dialog.js
index d4899c21931..0291bfffdcd 100644
--- a/chromium/chrome/browser/resources/settings/reset_page/reset_profile_dialog.js
+++ b/chromium/chrome/browser/resources/settings/reset_page/reset_profile_dialog.js
@@ -76,13 +76,8 @@ Polymer({
this.browserProxy_.onHideResetProfileDialog();
});
- this.$$('paper-checkbox a')
+ this.$$('cr-checkbox a')
.addEventListener('click', this.onShowReportedSettingsTap_.bind(this));
- // Prevent toggling of the checkbox when hitting the "Enter" key on the
- // link.
- this.$$('paper-checkbox a').addEventListener('keydown', function(e) {
- e.stopPropagation();
- });
},
/** @private */
diff --git a/chromium/chrome/browser/resources/settings/route.js b/chromium/chrome/browser/resources/settings/route.js
index 5191116d07b..819467b3887 100644
--- a/chromium/chrome/browser/resources/settings/route.js
+++ b/chromium/chrome/browser/resources/settings/route.js
@@ -11,6 +11,8 @@
* ACCESSIBILITY: (undefined|!settings.Route),
* ACCOUNTS: (undefined|!settings.Route),
* ADVANCED: (undefined|!settings.Route),
+ * CROSTINI: (undefined|!settings.Route),
+ * CROSTINI_DETAILS: (undefined|!settings.Route),
* ANDROID_APPS: (undefined|!settings.Route),
* ANDROID_APPS_DETAILS: (undefined|!settings.Route),
* APPEARANCE: (undefined|!settings.Route),
@@ -45,7 +47,6 @@
* LANGUAGES: (undefined|!settings.Route),
* LOCK_SCREEN: (undefined|!settings.Route),
* MANAGE_ACCESSIBILITY: (undefined|!settings.Route),
- * MANAGE_GOOGLE_TTS_ENGINE_SETTINGS: (undefined|!settings.Route),
* MANAGE_PASSWORDS: (undefined|!settings.Route),
* MANAGE_PROFILE: (undefined|!settings.Route),
* MANAGE_TTS_SETTINGS: (undefined|!settings.Route),
@@ -244,9 +245,13 @@ cr.define('settings', function() {
r.SEARCH_ENGINES = r.SEARCH.createChild('/searchEngines');
// <if expr="chromeos">
r.GOOGLE_ASSISTANT = r.SEARCH.createChild('/googleAssistant');
- // </if>
- // <if expr="chromeos">
+ if (loadTimeData.valueExists('showCrostini') &&
+ loadTimeData.getBoolean('showCrostini')) {
+ r.CROSTINI = r.BASIC.createSection('/crostini', 'crostini');
+ r.CROSTINI_DETAILS = r.CROSTINI.createChild('/crostini/details');
+ }
+
r.ANDROID_APPS = r.BASIC.createSection('/androidApps', 'androidApps');
r.ANDROID_APPS_DETAILS = r.ANDROID_APPS.createChild('/androidApps/details');
// </if>
@@ -265,6 +270,7 @@ cr.define('settings', function() {
// <if expr="chromeos">
r.CHANGE_PICTURE = r.PEOPLE.createChild('/changePicture');
r.ACCOUNTS = r.PEOPLE.createChild('/accounts');
+ r.ACCOUNT_MANAGER = r.PEOPLE.createChild('/accountManager');
r.LOCK_SCREEN = r.PEOPLE.createChild('/lockScreen');
r.FINGERPRINT = r.LOCK_SCREEN.createChild('/lockScreen/fingerprint');
// </if>
@@ -388,8 +394,6 @@ cr.define('settings', function() {
r.ACCESSIBILITY.createChild('/manageAccessibility');
r.MANAGE_TTS_SETTINGS =
r.MANAGE_ACCESSIBILITY.createChild('/manageAccessibility/tts');
- r.MANAGE_GOOGLE_TTS_ENGINE_SETTINGS = r.MANAGE_TTS_SETTINGS.createChild(
- '/manageAccessibility/tts/googleTtsEngine');
// </if>
r.SYSTEM = r.ADVANCED.createSection('/system', 'system');
@@ -402,10 +406,7 @@ cr.define('settings', function() {
r.ADVANCED.createChild('/triggeredResetProfileSettings');
r.TRIGGERED_RESET_DIALOG.isNavigableDialog = true;
// <if expr="_google_chrome and is_win">
- // This should only be added if the feature is enabled.
- if (loadTimeData.getBoolean('userInitiatedCleanupsEnabled')) {
- r.CHROME_CLEANUP = r.RESET.createChild('/cleanup');
- }
+ r.CHROME_CLEANUP = r.RESET.createChild('/cleanup');
if (loadTimeData.getBoolean('showIncompatibleApplications')) {
r.INCOMPATIBLE_APPLICATIONS =
r.RESET.createChild('/incompatibleApplications');
diff --git a/chromium/chrome/browser/resources/settings/search_engines_page/BUILD.gn b/chromium/chrome/browser/resources/settings/search_engines_page/BUILD.gn
new file mode 100644
index 00000000000..1a6231da156
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/search_engines_page/BUILD.gn
@@ -0,0 +1,75 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":omnibox_extension_entry",
+ ":search_engine_dialog",
+ ":search_engine_entry",
+ ":search_engines_browser_proxy",
+ ":search_engines_list",
+ ":search_engines_page",
+ ]
+}
+
+js_library("search_engine_dialog") {
+ deps = [
+ ":search_engines_browser_proxy",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("search_engine_entry") {
+ deps = [
+ ":search_engines_browser_proxy",
+ "..:focus_row_behavior",
+ "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:icon",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+}
+
+js_library("omnibox_extension_entry") {
+ deps = [
+ ":search_engines_browser_proxy",
+ "..:extension_control_browser_proxy",
+ "..:focus_row_behavior",
+ "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:icon",
+ ]
+}
+
+js_library("search_engines_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("search_engines_list") {
+ deps = [
+ ":search_engines_browser_proxy",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("search_engines_page") {
+ deps = [
+ ":search_engines_browser_proxy",
+ "..:global_scroll_target_behavior",
+ "//third_party/polymer/v1_0/components-chromium/iron-resizable-behavior:iron-resizable-behavior-extracted",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/search_engines_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/search_engines_page/compiled_resources2.gyp
deleted file mode 100644
index 13a59913e29..00000000000
--- a/chromium/chrome/browser/resources/settings/search_engines_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,71 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'search_engine_dialog',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- 'search_engines_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'search_engine_entry',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_action_menu/compiled_resources2.gyp:cr_action_menu',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:icon',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink',
- 'search_engines_browser_proxy',
- '../compiled_resources2.gyp:focus_row_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'omnibox_extension_entry',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_action_menu/compiled_resources2.gyp:cr_action_menu',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:icon',
- '../compiled_resources2.gyp:extension_control_browser_proxy',
- '../compiled_resources2.gyp:focus_row_behavior',
- 'search_engines_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'search_engines_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'search_engines_list',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- 'search_engines_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'search_engines_page',
- 'dependencies': [
- '../compiled_resources2.gyp:global_scroll_target_behavior',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-resizable-behavior/compiled_resources2.gyp:iron-resizable-behavior-extracted',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink',
- 'search_engines_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/search_engines_page/search_engine_dialog.html b/chromium/chrome/browser/resources/settings/search_engines_page/search_engine_dialog.html
index ce40163a034..ab45acfe4f3 100644
--- a/chromium/chrome/browser/resources/settings/search_engines_page/search_engine_dialog.html
+++ b/chromium/chrome/browser/resources/settings/search_engines_page/search_engine_dialog.html
@@ -1,6 +1,7 @@
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
+<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-input/paper-input.html">
<link rel="import" href="../i18n_setup.html">
@@ -14,12 +15,15 @@
/**
* Saves space for error message. Using calc to leave just enough
* space at all font sizes (default 0, grow/shrink with font-size).
- * Using padding instead of padding-bottom to prevent
+ * Using padding instead of padding-bottom to prevent
* paper-input-container's default padding rule to eat up the
* padding-bottom rule.
*/
padding: 8px 0 calc(1rem - 8px) 0;
};
+ --cr-dialog-body: {
+ height: 184px;
+ };
}
</style>
<cr-dialog id="dialog" close-text="$i18n{close}">
diff --git a/chromium/chrome/browser/resources/settings/search_engines_page/search_engine_dialog.js b/chromium/chrome/browser/resources/settings/search_engines_page/search_engine_dialog.js
index 50d7071658f..1ba1e5b6c8a 100644
--- a/chromium/chrome/browser/resources/settings/search_engines_page/search_engine_dialog.js
+++ b/chromium/chrome/browser/resources/settings/search_engines_page/search_engine_dialog.js
@@ -9,6 +9,8 @@
Polymer({
is: 'settings-search-engine-dialog',
+ behaviors: [WebUIListenerBehavior],
+
properties: {
/**
* The search engine to be edited. If not populated a new search engine
@@ -69,16 +71,38 @@ Polymer({
this.addEventListener('cancel', () => {
this.browserProxy_.searchEngineEditCancelled();
});
+
+ this.addWebUIListener(
+ 'search-engines-changed', this.enginesChanged_.bind(this));
},
/** @override */
attached: function() {
- this.updateActionButtonState_();
+ this.async(this.updateActionButtonState_.bind(this));
this.browserProxy_.searchEngineEditStarted(
this.model ? this.model.modelIndex : this.DEFAULT_MODEL_INDEX);
this.$.dialog.showModal();
},
+ /**
+ * @param {!SearchEnginesInfo} searchEnginesInfo
+ * @private
+ */
+ enginesChanged_: function(searchEnginesInfo) {
+ if (this.model) {
+ const engineWasRemoved = ['defaults', 'others', 'extensions'].every(
+ engineType =>
+ searchEnginesInfo[engineType].every(e => e.id != this.model.id));
+ if (engineWasRemoved) {
+ this.cancel_();
+ return;
+ }
+ }
+
+ [this.$.searchEngine, this.$.keyword, this.$.queryUrl].forEach(
+ element => this.validateElement_(element));
+ },
+
/** @private */
cancel_: function() {
this.$.dialog.cancel();
@@ -92,12 +116,10 @@ Polymer({
},
/**
- * @param {!Event} event
+ * @param {!Element} inputElement
* @private
*/
- validate_: function(event) {
- const inputElement = Polymer.dom(event).localTarget;
-
+ validateElement_: function(inputElement) {
// If element is empty, disable the action button, but don't show the red
// invalid message.
if (inputElement.value == '') {
@@ -114,6 +136,15 @@ Polymer({
});
},
+ /**
+ * @param {!Event} event
+ * @private
+ */
+ validate_: function(event) {
+ const inputElement = /** @type {!Element} */ (event.target);
+ this.validateElement_(inputElement);
+ },
+
/** @private */
updateActionButtonState_: function() {
const allValid = [
diff --git a/chromium/chrome/browser/resources/settings/search_engines_page/search_engine_entry.html b/chromium/chrome/browser/resources/settings/search_engines_page/search_engine_entry.html
index ba8d98d1039..4f058e297eb 100644
--- a/chromium/chrome/browser/resources/settings/search_engines_page/search_engine_entry.html
+++ b/chromium/chrome/browser/resources/settings/search_engines_page/search_engine_entry.html
@@ -8,7 +8,6 @@
<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html">
<link rel="import" href="../controls/extension_controlled_indicator.html">
<link rel="import" href="../focus_row_behavior.html">
-<link rel="import" href="search_engine_dialog.html">
<link rel="import" href="search_engine_entry_css.html">
<link rel="import" href="search_engines_browser_proxy.html">
<link rel="import" href="../settings_shared_css.html">
@@ -41,10 +40,6 @@
}
</style>
- <template is="dom-if" if="[[showEditSearchEngineDialog_]]" restamp>
- <settings-search-engine-dialog model="[[engine]]">
- </settings-search-engine-dialog>
- </template>
<div class="list-item" focus-row-container>
<div id="name-column">
<div class="favicon-image"
diff --git a/chromium/chrome/browser/resources/settings/search_engines_page/search_engine_entry.js b/chromium/chrome/browser/resources/settings/search_engines_page/search_engine_entry.js
index eebcd58e642..2c8621f16d9 100644
--- a/chromium/chrome/browser/resources/settings/search_engines_page/search_engine_entry.js
+++ b/chromium/chrome/browser/resources/settings/search_engines_page/search_engine_entry.js
@@ -30,9 +30,6 @@ Polymer({
'engine.canBeEdited,' +
'engine.canBeRemoved)',
},
-
- /** @private {boolean} */
- showEditSearchEngineDialog_: Boolean,
},
/** @private {settings.SearchEnginesBrowserProxy} */
@@ -96,18 +93,9 @@ Polymer({
onEditTap_: function(e) {
e.preventDefault();
this.closePopupMenu_();
-
- this.showEditSearchEngineDialog_ = true;
- this.async(() => {
- const dialog = this.$$('settings-search-engine-dialog');
- // Register listener to detect when the dialog is closed. Flip the boolean
- // once closed to force a restamp next time it is shown such that the
- // previous dialog's contents are cleared.
- dialog.addEventListener('close', () => {
- this.showEditSearchEngineDialog_ = false;
- cr.ui.focusWithoutInk(
- assert(this.$$('paper-icon-button-light button')));
- });
+ this.fire('edit-search-engine', {
+ engine: this.engine,
+ anchorElement: assert(this.$$('paper-icon-button-light button')),
});
},
diff --git a/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_browser_proxy.js b/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_browser_proxy.js
index 31c6d5105db..ab81a32c12d 100644
--- a/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_browser_proxy.js
+++ b/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_browser_proxy.js
@@ -18,6 +18,7 @@
* canBeDisabled: boolean,
* icon: string}|undefined),
* iconURL: (string|undefined),
+ * id: number,
* isOmniboxExtension: boolean,
* keyword: string,
* modelIndex: number,
diff --git a/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_list.html b/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_list.html
index 1e6af9d9737..2b6698fe907 100644
--- a/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_list.html
+++ b/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_list.html
@@ -30,7 +30,7 @@
border-top: var(--settings-separator-line);
}
- .fixed-height-container {
+ :host([fixed-height]) #container {
/* Max items we show before scrolling is 6. Adding a 7th item to the
* list will add a scroll bar to the container. */
max-height: calc((var(--settings-row-min-height) +
@@ -50,9 +50,8 @@
<div class="url">$i18n{searchEnginesQueryURL}</div>
<div class="icon-placeholder"></div>
</div>
- <div id="container"
- class$="scroll-container [[getHeightClass(scrollTarget)]]"
- scrollable$="[[isScrollable(scrollTarget)]]">
+ <div id="container" class="scroll-container"
+ scrollable$="[[fixedHeight]]">
<iron-list items="[[engines]]" scroll-target="[[scrollTarget]]"
scroll-offset="[[scrollOffset]]" preserve-focus risk-selection>
<template>
diff --git a/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_list.js b/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_list.js
index f4e193f85b4..5a015a53ca2 100644
--- a/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_list.js
+++ b/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_list.js
@@ -17,31 +17,18 @@ Polymer({
* The scroll target that this list should use.
* @type {?HTMLElement}
*/
- scrollTarget: {
- type: Element,
- value: null, // Required to populate class.
- },
+ scrollTarget: Object,
/** Used to fix scrolling glitch when list is not top most element. */
scrollOffset: Number,
/** @private {Object}*/
lastFocused_: Object,
- },
- /**
- * Fix height of list if no scrollTarget is present.
- * @return {string}
- */
- getHeightClass: function() {
- return this.scrollTarget ? '' : 'fixed-height-container';
- },
-
- /**
- * Only scroll when no target is set.
- * @return {boolean}
- */
- isScrollable: function() {
- return !this.scrollTarget;
+ fixedHeight: {
+ type: Boolean,
+ value: false,
+ reflectToAttribute: true,
+ },
},
});
diff --git a/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_page.html b/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_page.html
index 44638d4ee43..b243798f19a 100644
--- a/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_page.html
+++ b/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_page.html
@@ -32,12 +32,14 @@
<div class="no-search-results" hidden="[[matchingDefaultEngines_.length]]">
$i18n{searchNoResults}
</div>
- <settings-search-engines-list
+ <settings-search-engines-list fixed-height
hidden="[[!matchingDefaultEngines_.length]]"
engines="[[matchingDefaultEngines_]]">
</settings-search-engines-list>
- <template is="dom-if" if="[[showAddSearchEngineDialog_]]" restamp>
- <settings-search-engine-dialog></settings-search-engine-dialog>
+ <template is="dom-if" if="[[showDialog_]]" restamp>
+ <settings-search-engine-dialog model="[[dialogModel_]]"
+ on-close="onCloseDialog_">
+ </settings-search-engine-dialog>
</template>
<div class="settings-box first">
@@ -67,7 +69,7 @@
<div class="no-search-results" hidden="[[matchingExtensions_.length]]">
$i18n{searchNoResults}
</div>
- <iron-list id="extensions" class="extension-engines fixed-height-list"
+ <iron-list id="extensions" class="extension-engines"
items="[[matchingExtensions_]]" preserve-focus risk-selection>
<template>
<settings-omnibox-extension-entry engine="[[item]]"
diff --git a/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_page.js b/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_page.js
index be96505ef60..7821d110ea0 100644
--- a/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_page.js
+++ b/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_page.js
@@ -31,9 +31,6 @@ Polymer({
},
/** @private {boolean} */
- showAddSearchEngineDialog_: Boolean,
-
- /** @private {boolean} */
showExtensionsList_: {
type: Boolean,
computed: 'computeShowExtensionsList_(extensions)',
@@ -65,12 +62,34 @@ Polymer({
/** @private {HTMLElement} */
omniboxExtensionlastFocused_: Object,
+
+ /** @private {?SearchEngine} */
+ dialogModel_: {
+ type: Object,
+ value: null,
+ },
+
+ /** @private {?HTMLElement} */
+ dialogAnchorElement_: {
+ type: Object,
+ value: null,
+ },
+
+ /** @private */
+ showDialog_: {
+ type: Boolean,
+ value: false,
+ },
},
// Since the iron-list for extensions is enclosed in a dom-if, observe both
// |extensions| and |showExtensionsList_|.
observers: ['extensionsChanged_(extensions, showExtensionsList_)'],
+ listeners: {
+ 'edit-search-engine': 'onEditSearchEngine_',
+ },
+
/** @override */
ready: function() {
settings.SearchEnginesBrowserProxyImpl.getInstance()
@@ -85,6 +104,37 @@ Polymer({
});
},
+ /**
+ * @param {?SearchEngine} searchEngine
+ * @param {!HTMLElement} anchorElement
+ * @private
+ */
+ openDialog_: function(searchEngine, anchorElement) {
+ this.dialogModel_ = searchEngine;
+ this.dialogAnchorElement_ = anchorElement;
+ this.showDialog_ = true;
+ },
+
+ /** @private */
+ onCloseDialog_: function() {
+ this.showDialog_ = false;
+ const anchor = /** @type {!HTMLElement} */ (this.dialogAnchorElement_);
+ cr.ui.focusWithoutInk(anchor);
+ this.dialogModel_ = null;
+ this.dialogAnchorElement_ = null;
+ },
+
+ /**
+ * @param {!CustomEvent} e
+ * @private
+ */
+ onEditSearchEngine_: function(e) {
+ const params =
+ /** @type {!{engine: !SearchEngine, anchorElement: !HTMLElement}} */ (
+ e.detail);
+ this.openDialog_(params.engine, params.anchorElement);
+ },
+
/** @private */
extensionsChanged_: function() {
if (this.showExtensionsList_ && this.$.extensions)
@@ -96,15 +146,14 @@ Polymer({
* @private
*/
enginesChanged_: function(searchEnginesInfo) {
- this.defaultEngines = searchEnginesInfo['defaults'];
+ this.defaultEngines = searchEnginesInfo.defaults;
// Sort |otherEngines| in alphabetical order.
- this.otherEngines = searchEnginesInfo['others'].sort(function(a, b) {
- return a.name.toLocaleLowerCase().localeCompare(
- b.name.toLocaleLowerCase());
- });
+ this.otherEngines = searchEnginesInfo.others.sort(
+ (a, b) => a.name.toLocaleLowerCase().localeCompare(
+ b.name.toLocaleLowerCase()));
- this.extensions = searchEnginesInfo['extensions'];
+ this.extensions = searchEnginesInfo.extensions;
},
/**
@@ -113,17 +162,7 @@ Polymer({
*/
onAddSearchEngineTap_: function(e) {
e.preventDefault();
- this.showAddSearchEngineDialog_ = true;
- this.async(() => {
- const dialog = this.$$('settings-search-engine-dialog');
- // Register listener to detect when the dialog is closed. Flip the boolean
- // once closed to force a restamp next time it is shown such that the
- // previous dialog's contents are cleared.
- dialog.addEventListener('close', () => {
- this.showAddSearchEngineDialog_ = false;
- cr.ui.focusWithoutInk(assert(this.$.addSearchEngine));
- });
- });
+ this.openDialog_(null, assert(this.$.addSearchEngine));
},
/** @private */
diff --git a/chromium/chrome/browser/resources/settings/search_page/BUILD.gn b/chromium/chrome/browser/resources/settings/search_page/BUILD.gn
new file mode 100644
index 00000000000..458a5b7ce84
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/search_page/BUILD.gn
@@ -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.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":search_page",
+ ]
+}
+
+js_library("search_page") {
+ deps = [
+ "..:route",
+ "../prefs:prefs",
+ "../search_engines_page:search_engines_browser_proxy",
+ "../settings_page:settings_animated_pages",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:i18n_behavior",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/search_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/search_page/compiled_resources2.gyp
deleted file mode 100644
index cd75f1109e8..00000000000
--- a/chromium/chrome/browser/resources/settings/search_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'search_page',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '../compiled_resources2.gyp:route',
- '../prefs/compiled_resources2.gyp:prefs',
- '../search_engines_page/compiled_resources2.gyp:search_engines_browser_proxy',
- '../settings_page/compiled_resources2.gyp:settings_animated_pages',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/search_settings.js b/chromium/chrome/browser/resources/settings/search_settings.js
index 71971fa8246..4976d72c628 100644
--- a/chromium/chrome/browser/resources/settings/search_settings.js
+++ b/chromium/chrome/browser/resources/settings/search_settings.js
@@ -101,6 +101,7 @@ cr.define('settings', function() {
// TODO(dpapad): highlight <select> controls with a search bubble
// instead.
if (node.parentNode.nodeName != 'OPTION') {
+ request.addTextObserver(node);
cr.search_highlight_utils.highlight(
node, textContent.split(request.regExp));
}
@@ -396,6 +397,33 @@ cr.define('settings', function() {
this.queue_.onEmpty(() => {
this.resolver.resolve(this);
});
+
+ /** @private {!Set<!MutationObserver>} */
+ this.textObservers_ = new Set();
+ }
+
+ removeAllTextObservers() {
+ this.textObservers_.forEach(observer => {
+ observer.disconnect();
+ });
+ this.textObservers_.clear();
+ }
+
+ /** @param {!Node} textNode */
+ addTextObserver(textNode) {
+ const originalParentNode = /** @type {!Node} */ (textNode.parentNode);
+ const observer = new MutationObserver(mutations => {
+ const oldValue = mutations[0].oldValue.trim();
+ const newValue = textNode.nodeValue.trim();
+ if (oldValue != newValue) {
+ observer.disconnect();
+ this.textObservers_.delete(observer);
+ cr.search_highlight_utils.findAndRemoveHighlights(originalParentNode);
+ }
+ });
+ observer.observe(
+ textNode, {characterData: true, characterDataOldValue: true});
+ this.textObservers_.add(observer);
}
/**
@@ -465,6 +493,9 @@ cr.define('settings', function() {
/** @private {!Set<!settings.SearchRequest>} */
this.activeRequests_ = new Set();
+ /** @private {!Set<!settings.SearchRequest>} */
+ this.completedRequests_ = new Set();
+
/** @private {?string} */
this.lastSearchedText_ = null;
}
@@ -475,10 +506,15 @@ cr.define('settings', function() {
// submitted.
if (text != this.lastSearchedText_) {
this.activeRequests_.forEach(function(request) {
+ request.removeAllTextObservers();
request.canceled = true;
request.resolver.resolve(request);
});
this.activeRequests_.clear();
+ this.completedRequests_.forEach(request => {
+ request.removeAllTextObservers();
+ });
+ this.completedRequests_.clear();
}
this.lastSearchedText_ = text;
@@ -486,8 +522,8 @@ cr.define('settings', function() {
this.activeRequests_.add(request);
request.start();
return request.resolver.promise.then(() => {
- // Stop tracking requests that finished.
this.activeRequests_.delete(request);
+ this.completedRequests_.add(request);
return request;
});
}
diff --git a/chromium/chrome/browser/resources/settings/settings.html b/chromium/chrome/browser/resources/settings/settings.html
index 2f8a74473c8..40207595ac4 100644
--- a/chromium/chrome/browser/resources/settings/settings.html
+++ b/chromium/chrome/browser/resources/settings/settings.html
@@ -8,7 +8,7 @@
</if>
<style>
html {
- background-color: #f1f1f1;
+ background-color: rgb(248, 249, 250);
overflow: hidden;
/* Remove 300ms delay for 'click' event, when using touch interface. */
touch-action: manipulation;
diff --git a/chromium/chrome/browser/resources/settings/settings_main/BUILD.gn b/chromium/chrome/browser/resources/settings/settings_main/BUILD.gn
new file mode 100644
index 00000000000..cce4e824db1
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/settings_main/BUILD.gn
@@ -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.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":settings_main",
+ ]
+}
+
+js_library("settings_main") {
+ deps = [
+ "..:page_visibility",
+ "..:route",
+ "..:search_settings",
+ "../about_page:about_page",
+ "../basic_page:basic_page",
+ "../settings_page:main_page_behavior",
+ "//third_party/polymer/v1_0/components-chromium/iron-a11y-announcer:iron-a11y-announcer-extracted",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/settings_main/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/settings_main/compiled_resources2.gyp
deleted file mode 100644
index 1e1d0fa7af8..00000000000
--- a/chromium/chrome/browser/resources/settings/settings_main/compiled_resources2.gyp
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'settings_main',
- 'dependencies': [
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-a11y-announcer/compiled_resources2.gyp:iron-a11y-announcer-extracted',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '../compiled_resources2.gyp:route',
- '../compiled_resources2.gyp:search_settings',
- '../about_page/compiled_resources2.gyp:about_page',
- '../basic_page/compiled_resources2.gyp:basic_page',
- '../settings_page/compiled_resources2.gyp:main_page_behavior',
- '../compiled_resources2.gyp:page_visibility',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/settings_main/settings_main.html b/chromium/chrome/browser/resources/settings/settings_main/settings_main.html
index 31e3040c21e..ec1fb7c5b81 100644
--- a/chromium/chrome/browser/resources/settings/settings_main/settings_main.html
+++ b/chromium/chrome/browser/resources/settings/settings_main/settings_main.html
@@ -43,6 +43,7 @@
<template is="dom-if" if="[[showPages_.settings]]">
<settings-basic-page prefs="{{prefs}}"
page-visibility="[[pageVisibility]]"
+ show-crostini="[[showCrostini]]"
show-android-apps="[[showAndroidApps]]"
show-multidevice="[[showMultidevice]]"
have-play-store-app="[[havePlayStoreApp]]"
diff --git a/chromium/chrome/browser/resources/settings/settings_menu/BUILD.gn b/chromium/chrome/browser/resources/settings/settings_menu/BUILD.gn
new file mode 100644
index 00000000000..d138e4484cc
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/settings_menu/BUILD.gn
@@ -0,0 +1,19 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":settings_menu",
+ ]
+}
+
+js_library("settings_menu") {
+ deps = [
+ "..:page_visibility",
+ "..:route",
+ "//third_party/polymer/v1_0/components-chromium/paper-ripple:paper-ripple-extracted",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/settings_menu/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/settings_menu/compiled_resources2.gyp
deleted file mode 100644
index 305541dd0c4..00000000000
--- a/chromium/chrome/browser/resources/settings/settings_menu/compiled_resources2.gyp
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'settings_menu',
- 'dependencies': [
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/paper-ripple/compiled_resources2.gyp:paper-ripple-extracted',
- '../compiled_resources2.gyp:route',
- '../compiled_resources2.gyp:page_visibility',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/settings_menu/settings_menu.html b/chromium/chrome/browser/resources/settings/settings_menu/settings_menu.html
index 58721ca87c9..baa02f919e8 100644
--- a/chromium/chrome/browser/resources/settings/settings_menu/settings_menu.html
+++ b/chromium/chrome/browser/resources/settings/settings_menu/settings_menu.html
@@ -42,6 +42,7 @@
iron-icon {
--iron-icon-fill-color: var(--settings-nav-grey);
-webkit-margin-end: 24px;
+ pointer-events: none;
vertical-align: top;
}
@@ -52,12 +53,15 @@
#advancedButton {
-webkit-padding-end: 0;
background-color: unset;
+ border: none;
+ border-radius: initial;
height: unset;
margin-top: 8px;
text-transform: none;
}
#advancedButton:focus {
+ box-shadow: none;
outline: none;
}
@@ -116,6 +120,12 @@
$i18n{searchPageTitle}
</a>
<if expr="chromeos">
+ <a href="/crostini" hidden="[[!showCrostini]]">
+ <iron-icon icon="settings:crostini-mascot"></iron-icon>
+ $i18n{crostiniPageTitle}
+ </a>
+</if>
+<if expr="chromeos">
<a href="/androidApps" hidden="[[!showAndroidApps]]">
<iron-icon icon="settings:play-prism"></iron-icon>
$i18n{androidAppsPageTitle}
@@ -194,7 +204,8 @@
</iron-collapse>
<div id="menuSeparator"></div>
<a id="extensionsLink" href="chrome://extensions" target="_blank"
- on-click="onExtensionsLinkClick_">
+ on-click="onExtensionsLinkClick_"
+ title="$i18n{extensionsLinkTooltip}">
<span>$i18n{extensionsPageTitle}</span>
<iron-icon class="cr-icon icon-external" actionable></iron-icon>
</a>
diff --git a/chromium/chrome/browser/resources/settings/settings_page/BUILD.gn b/chromium/chrome/browser/resources/settings/settings_page/BUILD.gn
new file mode 100644
index 00000000000..54bcd159044
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/settings_page/BUILD.gn
@@ -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.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":main_page_behavior",
+ ":settings_animated_pages",
+ ":settings_section",
+ ":settings_subpage",
+ ":settings_subpage_search",
+ ]
+}
+
+js_library("main_page_behavior") {
+ deps = [
+ ":settings_section",
+ "..:route",
+ "../animation:animation",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:util",
+ ]
+}
+
+js_library("settings_animated_pages") {
+ deps = [
+ ":settings_subpage",
+ "..:route",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+}
+
+js_library("settings_section") {
+ deps = [
+ "../animation:animation",
+ ]
+ externs_list = [ "$externs_path/web_animations.js" ]
+}
+
+js_library("settings_subpage") {
+ deps = [
+ ":settings_subpage_search",
+ "..:route",
+ "//third_party/polymer/v1_0/components-chromium/iron-resizable-behavior:iron-resizable-behavior-extracted",
+ "//third_party/polymer/v1_0/components-chromium/neon-animation:neon-animatable-behavior-extracted",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+}
+
+js_library("settings_subpage_search") {
+ deps = [
+ "//third_party/polymer/v1_0/components-chromium/paper-icon-button:paper-icon-button-extracted",
+ "//third_party/polymer/v1_0/components-chromium/paper-input:paper-input-container-extracted",
+ "//ui/webui/resources/cr_elements/cr_search_field:cr_search_field_behavior",
+ "//ui/webui/resources/js:assert",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/settings_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/settings_page/compiled_resources2.gyp
deleted file mode 100644
index fe262b14fa5..00000000000
--- a/chromium/chrome/browser/resources/settings/settings_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,58 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'main_page_behavior',
- 'dependencies': [
- '../animation/compiled_resources2.gyp:animation',
- '../compiled_resources2.gyp:route',
- 'settings_section',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'settings_animated_pages',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'settings_section',
- 'dependencies': [
- '../animation/compiled_resources2.gyp:animation',
- '<(EXTERNS_GYP):web_animations',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'settings_subpage',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- 'settings_subpage_search',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/iron-resizable-behavior/compiled_resources2.gyp:iron-resizable-behavior-extracted',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/neon-animation/compiled_resources2.gyp:neon-animatable-behavior-extracted',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'settings_subpage_search',
- 'dependencies': [
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/paper-icon-button/compiled_resources2.gyp:paper-icon-button-extracted',
- '<(DEPTH)/third_party/polymer/v1_0/components-chromium/paper-input/compiled_resources2.gyp:paper-input-container-extracted',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_search_field/compiled_resources2.gyp:cr_search_field_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/settings_page/settings_animated_pages.js b/chromium/chrome/browser/resources/settings/settings_page/settings_animated_pages.js
index b20936cc35c..faa1fe20a42 100644
--- a/chromium/chrome/browser/resources/settings/settings_page/settings_animated_pages.js
+++ b/chromium/chrome/browser/resources/settings/settings_page/settings_animated_pages.js
@@ -38,6 +38,10 @@ Polymer({
focusConfig: Object,
},
+ listeners: {
+ 'neon-animation-finish': 'onNeonAnimationFinish_',
+ },
+
/**
* The last "previous" route reported by the router.
* @private {?settings.Route}
@@ -51,6 +55,18 @@ Polymer({
Polymer.dom(this).observeNodes(this.lightDomChanged_.bind(this));
},
+ /** @private */
+ onNeonAnimationFinish_: function() {
+ if (settings.lastRouteChangeWasPopstate())
+ return;
+
+ // Set initial focus when navigating to a subpage for a11y.
+ let subPage = /** @type {SettingsSubpageElement} */ (
+ this.querySelector('settings-subpage.iron-selected'));
+ if (subPage)
+ subPage.initialFocus();
+ },
+
/**
* @param {!Event} e
* @private
diff --git a/chromium/chrome/browser/resources/settings/settings_page/settings_section.html b/chromium/chrome/browser/resources/settings/settings_page/settings_section.html
index 3daf5135314..641cbe4bd23 100644
--- a/chromium/chrome/browser/resources/settings/settings_page/settings_section.html
+++ b/chromium/chrome/browser/resources/settings/settings_page/settings_section.html
@@ -1,5 +1,6 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/shadow.html">
<link rel="import" href="../animation/animation.html">
@@ -28,7 +29,7 @@
#card {
@apply --shadow-elevation-2dp;
background-color: white;
- border-radius: 2px;
+ border-radius: var(--cr-card-border-radius);
flex: 1;
}
diff --git a/chromium/chrome/browser/resources/settings/settings_page/settings_section.js b/chromium/chrome/browser/resources/settings/settings_page/settings_section.js
index a173f127690..a4546663464 100644
--- a/chromium/chrome/browser/resources/settings/settings_page/settings_section.js
+++ b/chromium/chrome/browser/resources/settings/settings_page/settings_section.js
@@ -63,7 +63,6 @@ let SettingsSectionElement = Polymer({
* Freezes the section's height so its card can be removed from the flow
* without affecting the layout of the surrounding sections.
* @param {boolean} frozen True to freeze, false to unfreeze.
- * @private
*/
setFrozen: function(frozen) {
const card = this.$.card;
diff --git a/chromium/chrome/browser/resources/settings/settings_page/settings_subpage.html b/chromium/chrome/browser/resources/settings/settings_page/settings_subpage.html
index 529fe2c9716..928ab878653 100644
--- a/chromium/chrome/browser/resources/settings/settings_page/settings_subpage.html
+++ b/chromium/chrome/browser/resources/settings/settings_page/settings_subpage.html
@@ -1,5 +1,6 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-resizable-behavior/iron-resizable-behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/neon-animation/neon-animatable-behavior.html">
@@ -57,7 +58,8 @@
</style>
<div class="settings-box first" id="headerLine">
<paper-icon-button-light class="icon-arrow-back">
- <button on-click="onTapBack_" aria-label="$i18n{back}"></button>
+ <button id="closeButton" on-click="onTapBack_"
+ aria-label="$i18n{back}"></button>
</paper-icon-button-light>
<h1>[[pageTitle]]</h1>
<slot name="subpage-title-extra"></slot>
diff --git a/chromium/chrome/browser/resources/settings/settings_page/settings_subpage.js b/chromium/chrome/browser/resources/settings/settings_page/settings_subpage.js
index d00516cda67..32880610425 100644
--- a/chromium/chrome/browser/resources/settings/settings_page/settings_subpage.js
+++ b/chromium/chrome/browser/resources/settings/settings_page/settings_subpage.js
@@ -65,6 +65,12 @@ Polymer({
}
},
+ /** Focuses the back button when page is loaded. */
+ initialFocus: function() {
+ Polymer.RenderStatus.afterNextRender(
+ this, () => cr.ui.focusWithoutInk(this.$.closeButton));
+ },
+
/**
* Clear the value of the search field.
* @param {!Event} e
diff --git a/chromium/chrome/browser/resources/settings/settings_page/settings_subpage_search.js b/chromium/chrome/browser/resources/settings/settings_page/settings_subpage_search.js
index fd4af0675b9..d9e80375277 100644
--- a/chromium/chrome/browser/resources/settings/settings_page/settings_subpage_search.js
+++ b/chromium/chrome/browser/resources/settings/settings_page/settings_subpage_search.js
@@ -24,5 +24,6 @@ Polymer({
/** @private */
onTapClear_: function() {
this.setValue('');
+ this.$.searchInput.focus();
},
});
diff --git a/chromium/chrome/browser/resources/settings/settings_resources.grd b/chromium/chrome/browser/resources/settings/settings_resources.grd
index 4474624ac7a..77e1b47cdcd 100644
--- a/chromium/chrome/browser/resources/settings/settings_resources.grd
+++ b/chromium/chrome/browser/resources/settings/settings_resources.grd
@@ -34,12 +34,6 @@
<structure name="IDR_SETTINGS_TTS_SUBPAGE_HTML"
file="a11y_page/tts_subpage.html"
type="chrome_html" />
- <structure name="IDR_SETTINGS_GOOGLE_TTS_ENGINE_SUBPAGE_JS"
- file="a11y_page/google_tts_engine_subpage.js"
- type="chrome_html" />
- <structure name="IDR_SETTINGS_GOOGLE_TTS_ENGINE_SUBPAGE_HTML"
- file="a11y_page/google_tts_engine_subpage.html"
- type="chrome_html" />
</if>
<structure name="IDR_SETTINGS_ABOUT_PAGE_BROWSER_PROXY_HTML"
file="about_page/about_page_browser_proxy.html"
@@ -90,6 +84,12 @@
file="site_settings/all_sites.js"
type="chrome_html"
preprocess="true" />
+ <structure name="IDR_SETTINGS_SITE_ENTRY_HTML"
+ file="site_settings/site_entry.html"
+ type="chrome_html" />
+ <structure name="IDR_SETTINGS_SITE_ENTRY_JS"
+ file="site_settings/site_entry.js"
+ type="chrome_html" />
<structure name="IDR_SETTINGS_CATEGORY_DEFAULT_SETTING_HTML"
file="site_settings/category_default_setting.html"
type="chrome_html" />
@@ -604,6 +604,13 @@
file="icons.html"
type="chrome_html"
preprocess="true" />
+ <structure name="IDR_SETTINGS_FIND_SHORTCUT_BEHAVIOR_HTML"
+ file ="find_shortcut_behavior.html"
+ type="chrome_html" />
+ <structure name="IDR_SETTINGS_FIND_SHORTCUT_BEHAVIOR_JS"
+ file ="find_shortcut_behavior.js"
+ type="chrome_html"
+ preprocess="true" />
<structure name="IDR_SETTINGS_POWERWASH_DIALOG_HTML"
file="reset_page/powerwash_dialog.html"
type="chrome_html" />
@@ -927,6 +934,15 @@
<structure name="IDR_SETTINGS_PDF_DOCUMENTS_JS"
file="site_settings/pdf_documents.js"
type="chrome_html" />
+ <structure name="IDR_SETTINGS_PERSONALIZATION_OPTIONS_HTML"
+ file="privacy_page/personalization_options.html"
+ type="chrome_html"
+ preprocess="true"
+ allowexternalscript="true" />
+ <structure name="IDR_SETTINGS_PERSONALIZATION_OPTIONS_JS"
+ file="privacy_page/personalization_options.js"
+ preprocess="true"
+ type="chrome_html" />
<structure name="IDR_SETTINGS_PRIVACY_PAGE_HTML"
file="privacy_page/privacy_page.html"
type="chrome_html"
@@ -1146,6 +1162,28 @@
file="site_settings/zoom_levels.js"
type="chrome_html" />
<if expr="chromeos">
+ <structure name="IDR_SETTINGS_CROSTINI_PAGE_HTML"
+ file="crostini_page/crostini_page.html"
+ type="chrome_html" />
+ <structure name="IDR_SETTINGS_CROSTINI_PAGE_JS"
+ file="crostini_page/crostini_page.js"
+ type="chrome_html" />
+ <structure name="IDR_SETTINGS_CROSTINI_SUBPAGE_HTML"
+ file="crostini_page/crostini_subpage.html"
+ type="chrome_html" />
+ <structure name="IDR_SETTINGS_CROSTINI_SUBPAGE_JS"
+ file="crostini_page/crostini_subpage.js"
+ type="chrome_html" />
+ <structure name="IDR_SETTINGS_CROSTINI_BROWSER_PROXY_JS"
+ file="crostini_page/crostini_browser_proxy.js"
+ type="chrome_html"
+ preprocess="true"
+ allowexternalscript="true" />
+ <structure name="IDR_SETTINGS_CROSTINI_BROWSER_PROXY_HTML"
+ file="crostini_page/crostini_browser_proxy.html"
+ type="chrome_html"
+ preprocess="true"
+ allowexternalscript="true" />
<structure name="IDR_SETTINGS_ANDROID_APPS_PAGE_HTML"
file="android_apps_page/android_apps_page.html"
type="chrome_html" />
@@ -1285,6 +1323,14 @@
<structure name="IDR_SETTINGS_TETHER_CONNECTION_DIALOG_JS"
file="internet_page/tether_connection_dialog.js"
type="chrome_html" />
+ <structure name="IDR_SETTINGS_PEOPLE_PAGE_ACCOUNT_MANAGER_HTML"
+ file="people_page/account_manager.html"
+ type="chrome_html"
+ preprocess="true" />
+ <structure name="IDR_SETTINGS_PEOPLE_PAGE_ACCOUNT_MANAGER_JS"
+ file="people_page/account_manager.js"
+ type="chrome_html"
+ preprocess="true" />
<structure name="IDR_SETTINGS_PEOPLE_PAGE_CHANGE_PICTURE_HTML"
file="people_page/change_picture.html"
type="chrome_html"
diff --git a/chromium/chrome/browser/resources/settings/settings_shared_css.html b/chromium/chrome/browser/resources/settings/settings_shared_css.html
index ec98c9eee58..aeb6028cfb4 100644
--- a/chromium/chrome/browser/resources/settings/settings_shared_css.html
+++ b/chromium/chrome/browser/resources/settings/settings_shared_css.html
@@ -1,7 +1,5 @@
<link rel="import" href="chrome://resources/cr_elements/paper_button_style_css.html">
-<link rel="import" href="chrome://resources/cr_elements/paper_checkbox_style_css.html">
<link rel="import" href="chrome://resources/cr_elements/paper_input_style_css.html">
-<link rel="import" href="chrome://resources/cr_elements/paper_toggle_style_css.html">
<link rel="import" href="chrome://resources/cr_elements/search_highlight_style_css.html">
<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html">
<link rel="import" href="chrome://resources/cr_elements/shared_style_css.html">
@@ -12,7 +10,7 @@
<!-- Common styles for Material Design settings. -->
<dom-module id="settings-shared">
<template>
- <style include="settings-icons paper-button-style paper-checkbox-style paper-input-style paper-toggle-style cr-shared-style search-highlight-style">
+ <style include="settings-icons paper-button-style paper-input-style cr-shared-style search-highlight-style">
/* Prevent action-links from being selected to avoid accidental
* selection when trying to click it. */
a[is=action-link] {
@@ -69,26 +67,11 @@
flex-direction: column;
}
- /* Customize the disabled state of paper buttons within a settings box. */
- .settings-box paper-button {
- --paper-button-disabled: {
- background: none;
- color: black;
- opacity: 0.26;
- };
- }
-
/* For "Advanced" toggle button. */
paper-button[toggles][active] {
background-color: var(--paper-grey-300);
}
- /* If a button is at the end of the row, shift it to overlap the end of
- * the row. */
- .settings-box paper-button:last-of-type {
- -webkit-margin-end: calc(var(--cr-button-edge-spacing) * -1);
- }
-
/* Special case for buttons inside of toggle-buttons. */
.settings-box settings-toggle-button paper-button:last-of-type {
-webkit-margin-end: 16px;
@@ -99,29 +82,6 @@
-webkit-margin-start: 16px;
}
- /* Adjust the margin between the separator and the first button. Exclude
- * .action-button since it has a background thus is visually different. */
- .separator + paper-button:not(.action-button) {
- -webkit-margin-start: calc(var(--cr-button-edge-spacing) * -1);
- }
-
- /* There are two settings button styles, .primary-button and normal
- * buttons. The primary is the action button (e.g. "edit", "delete")
- * while the normal (secondary-button) is often a "Cancel" button. */
- .primary-button:not([disabled]) {
- --paper-button-flat-keyboard-focus: {
- background: rgba(51, 103, 214, .12); /* --google-blue-700 */
- };
- color: var(--google-blue-500);
- }
-
- paper-toggle-button {
- @apply --settings-actionable;
- height: var(--settings-row-min-height);
- user-select: none; /* Prevents text selection while dragging. */
- width: 36px;
- }
-
span ~ a {
-webkit-margin-start: 4px;
}
@@ -146,16 +106,7 @@
}
controlled-radio-button,
- paper-radio-button {
- --paper-radio-button-checked-color: var(--google-blue-500);
- --paper-radio-button-label-spacing: 22px;
- --paper-radio-button-radio-container: {
- flex-shrink: 0;
- };
- --paper-radio-button-unchecked-color: var(--paper-grey-600);
- -webkit-margin-start: 2px;
- align-items: center;
- display: flex;
+ cr-radio-button {
min-height: var(--settings-row-min-height);
}
@@ -163,6 +114,11 @@
width: 100%;
}
+ paper-radio-group:focus {
+ background-color: var(--google-grey-300);
+ outline: none;
+ }
+
/* See also: .no-min-width below. */
.text-elide {
@apply --cr-text-elide;
@@ -260,6 +216,10 @@
border-top: none;
}
+ h2.first {
+ padding-top: 0;
+ }
+
.settings-box.block {
display: block;
}
@@ -349,17 +309,10 @@
* settings. */
.separator {
-webkit-border-start: var(--settings-separator-line);
- -webkit-margin-end: var(--settings-box-row-padding);
- -webkit-margin-start: var(--settings-box-row-padding);
flex-shrink: 0;
- --settings-separator-gaps: 9px;
- height: calc(var(--settings-row-min-height) -
- var(--settings-separator-gaps));
- }
-
- .two-line .separator {
- height: calc(var(--settings-row-two-line-min-height) -
- 2 * var(--settings-separator-gaps));
+ /* Match paper-button's default height. */
+ height: 32px;
+ margin: 0 16px;
}
.favicon-image {
@@ -373,6 +326,17 @@
color: var(--paper-grey-600);
font-weight: 500;
}
+
+ /* Error message that appears in a toast to indicate the success or
+ * failure of an operation. An example is when adding a printer. */
+ .error-message {
+ color: white;
+ font: 13px;
+ padding-bottom: 15px;
+ padding-top: 15px;
+ text-align: center;
+ white-space: normal;
+ }
</style>
</template>
</dom-module>
diff --git a/chromium/chrome/browser/resources/settings/settings_ui/BUILD.gn b/chromium/chrome/browser/resources/settings/settings_ui/BUILD.gn
new file mode 100644
index 00000000000..177ee20ed1c
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/settings_ui/BUILD.gn
@@ -0,0 +1,27 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":settings_ui",
+ ]
+}
+
+js_library("settings_ui") {
+ deps = [
+ "..:find_shortcut_behavior",
+ "..:global_scroll_target_behavior",
+ "..:page_visibility",
+ "../prefs:prefs",
+ "../settings_main:settings_main",
+ "//ui/webui/resources/cr_elements:cr_container_shadow_behavior",
+ "//ui/webui/resources/cr_elements/chromeos/network:cr_onc_types",
+ "//ui/webui/resources/cr_elements/cr_drawer:cr_drawer",
+ "//ui/webui/resources/cr_elements/cr_toolbar:cr_toolbar",
+ "//ui/webui/resources/cr_elements/cr_toolbar:cr_toolbar_search_field",
+ "//ui/webui/resources/cr_elements/policy:cr_policy_indicator_behavior",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/settings_ui/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/settings_ui/compiled_resources2.gyp
deleted file mode 100644
index 57468081491..00000000000
--- a/chromium/chrome/browser/resources/settings/settings_ui/compiled_resources2.gyp
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'settings_ui',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/chromeos/network/compiled_resources2.gyp:cr_onc_types',
- '<(DEPTH)/ui/webui/resources/cr_elements/compiled_resources2.gyp:cr_container_shadow_behavior',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_drawer/compiled_resources2.gyp:cr_drawer',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_toolbar/compiled_resources2.gyp:cr_toolbar',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_toolbar/compiled_resources2.gyp:cr_toolbar_search_field',
- '<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_indicator_behavior',
- '../compiled_resources2.gyp:global_scroll_target_behavior',
- '../prefs/compiled_resources2.gyp:prefs',
- '../settings_main/compiled_resources2.gyp:settings_main',
- '../compiled_resources2.gyp:page_visibility'
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/settings_ui/settings_ui.html b/chromium/chrome/browser/resources/settings/settings_ui/settings_ui.html
index 9d162ad7d88..67655dd9e52 100644
--- a/chromium/chrome/browser/resources/settings/settings_ui/settings_ui.html
+++ b/chromium/chrome/browser/resources/settings/settings_ui/settings_ui.html
@@ -5,6 +5,7 @@
<link rel="import" href="chrome://resources/cr_elements/cr_toolbar/cr_toolbar.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/color.html">
+<link rel="import" href="../find_shortcut_behavior.html">
<link rel="import" href="../global_scroll_target_behavior.html">
<link rel="import" href="../i18n_setup.html">
<link rel="import" href="../icons.html">
@@ -24,13 +25,10 @@
<template>
<style include="settings-shared">
:host {
+ @apply --cr-page-host;
@apply --layout-fit;
- color: var(--primary-text-color);
display: flex;
flex-direction: column;
- line-height: 154%; /* Apply 20px line-height to all texts by default. */
- overflow: hidden; /* Prevent double scroll bar bugs. */
- user-select: text;
}
cr-drawer {
@@ -68,6 +66,7 @@
<div class="drawer-content">
<template is="dom-if" id="drawerTemplate">
<settings-menu page-visibility="[[pageVisibility_]]"
+ show-crostini="[[showCrostini_]]"
show-android-apps="[[showAndroidApps_]]"
show-multidevice="[[showMultidevice_]]"
have-play-store-app="[[havePlayStoreApp_]]"
@@ -81,6 +80,7 @@
<settings-main id="main" prefs="{{prefs}}"
toolbar-spinner-active="{{toolbarSpinnerActive_}}"
page-visibility="[[pageVisibility_]]"
+ show-crostini="[[showCrostini_]]"
show-android-apps="[[showAndroidApps_]]"
show-multidevice="[[showMultidevice_]]"
have-play-store-app="[[havePlayStoreApp_]]"
diff --git a/chromium/chrome/browser/resources/settings/settings_ui/settings_ui.js b/chromium/chrome/browser/resources/settings/settings_ui/settings_ui.js
index 9ef5df15d23..6633fcc7e1d 100644
--- a/chromium/chrome/browser/resources/settings/settings_ui/settings_ui.js
+++ b/chromium/chrome/browser/resources/settings/settings_ui/settings_ui.js
@@ -20,7 +20,11 @@ settings.defaultResourceLoaded = true;
Polymer({
is: 'settings-ui',
- behaviors: [settings.RouteObserverBehavior, CrContainerShadowBehavior],
+ behaviors: [
+ settings.RouteObserverBehavior,
+ CrContainerShadowBehavior,
+ settings.FindShortcutBehavior,
+ ],
properties: {
/**
@@ -47,6 +51,9 @@ Polymer({
pageVisibility_: {type: Object, value: settings.pageVisibility},
/** @private */
+ showCrostini_: Boolean,
+
+ /** @private */
showAndroidApps_: Boolean,
/** @private */
@@ -130,6 +137,8 @@ Polymer({
};
// </if>
+ this.showCrostini_ = loadTimeData.valueExists('showCrostini') &&
+ loadTimeData.getBoolean('showCrostini');
this.showAndroidApps_ = loadTimeData.valueExists('androidAppsVisible') &&
loadTimeData.getBoolean('androidAppsVisible');
this.showMultidevice_ = this.showAndroidApps_ &&
@@ -190,6 +199,16 @@ Polymer({
this.$.main.searchContents(urlSearchQuery);
},
+ // Override settings.FindShortcutBehavior methods.
+ canHandleFindShortcut: function() {
+ return !this.$.drawer.open &&
+ !document.querySelector('* /deep/ cr-dialog[open]');
+ },
+
+ handleFindShortcut: function() {
+ this.$$('cr-toolbar').getSearchField().showAndFocus();
+ },
+
/**
* @param {!CustomEvent} e
* @private
diff --git a/chromium/chrome/browser/resources/settings/settings_vars_css.html b/chromium/chrome/browser/resources/settings/settings_vars_css.html
index 5e9062ead38..6febb6e8cc8 100644
--- a/chromium/chrome/browser/resources/settings/settings_vars_css.html
+++ b/chromium/chrome/browser/resources/settings/settings_vars_css.html
@@ -49,15 +49,12 @@
/* Spacing between policy (controlledBy) indicator and control. */
--settings-controlled-by-spacing: var(--cr-controlled-by-spacing);
+ --settings-input-max-width: 264px;
+
--iron-icon-fill-color: var(--paper-grey-600);
--iron-icon-height: var(--cr-icon-size);
--iron-icon-width: var(--cr-icon-size);
- --paper-radio-button-ink-size: 40px;
- --paper-radio-button-label-color: inherit;
- --paper-radio-button-size: 16px;
--paper-radio-group-item-padding: 0;
-
- --paper-tabs-selection-bar-color: var(--paper-blue-500);
}
</style>
diff --git a/chromium/chrome/browser/resources/settings/site_settings/BUILD.gn b/chromium/chrome/browser/resources/settings/site_settings/BUILD.gn
new file mode 100644
index 00000000000..957a0110b36
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/site_settings/BUILD.gn
@@ -0,0 +1,223 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":add_site_dialog",
+ ":all_sites",
+ ":category_default_setting",
+ ":category_setting_exceptions",
+ ":constants",
+ ":cookie_info",
+ ":local_data_browser_proxy",
+ ":media_picker",
+ ":protocol_handlers",
+ ":site_data",
+ ":site_data_details_subpage",
+ ":site_details",
+ ":site_details_permission",
+ ":site_list",
+ ":site_settings_behavior",
+ ":site_settings_prefs_browser_proxy",
+ ":usb_devices",
+ ":website_usage_private_api",
+ ":zoom_levels",
+ ]
+}
+
+js_library("add_site_dialog") {
+ deps = [
+ ":constants",
+ ":site_settings_behavior",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("all_sites") {
+ deps = [
+ ":constants",
+ ":site_settings_behavior",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
+
+js_library("category_default_setting") {
+ deps = [
+ ":constants",
+ ":site_settings_behavior",
+ "../settings_page:settings_animated_pages",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
+
+js_library("category_setting_exceptions") {
+ deps = [
+ ":constants",
+ "../settings_page:settings_animated_pages",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
+
+js_library("constants") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("local_data_browser_proxy") {
+ deps = [
+ ":constants",
+ ":cookie_info",
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [
+ "$externs_path/chrome_send.js",
+ "$externs_path/settings_private.js",
+ ]
+}
+
+js_library("media_picker") {
+ deps = [
+ ":site_settings_behavior",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("cookie_info") {
+ deps = [
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
+
+js_library("protocol_handlers") {
+ deps = [
+ ":site_settings_behavior",
+ "../android_apps_page:android_apps_browser_proxy",
+ "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("usb_devices") {
+ deps = [
+ ":site_settings_behavior",
+ "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("site_data") {
+ deps = [
+ ":cookie_info",
+ ":local_data_browser_proxy",
+ ":site_settings_behavior",
+ "..:global_scroll_target_behavior",
+ "../settings_page:settings_subpage_search",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:i18n_behavior",
+ "//ui/webui/resources/js:list_property_update_behavior",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+}
+
+js_library("site_data_details_subpage") {
+ deps = [
+ ":local_data_browser_proxy",
+ "..:route",
+ "//third_party/polymer/v1_0/components-chromium/iron-list:iron-list-extracted",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("site_details") {
+ deps = [
+ ":constants",
+ ":site_details_permission",
+ ":site_settings_behavior",
+ ":website_usage_private_api",
+ "..:route",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
+
+js_library("site_details_permission") {
+ deps = [
+ ":constants",
+ ":site_settings_behavior",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
+
+js_library("site_list") {
+ deps = [
+ ":constants",
+ ":site_settings_behavior",
+ "..:route",
+ "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ "//ui/webui/resources/js/cr/ui:focus_without_ink",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
+
+js_library("site_settings_behavior") {
+ deps = [
+ ":constants",
+ ":site_settings_prefs_browser_proxy",
+ "..:route",
+ "//ui/webui/resources/cr_elements/policy:cr_policy_indicator_behavior",
+ "//ui/webui/resources/cr_elements/policy:cr_policy_pref_behavior",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:icon",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
+
+js_library("site_settings_prefs_browser_proxy") {
+ deps = [
+ ":constants",
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [
+ "$externs_path/chrome_send.js",
+ "$externs_path/settings_private.js",
+ ]
+}
+
+js_library("website_usage_private_api") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/chrome_send.js" ]
+}
+
+js_library("zoom_levels") {
+ deps = [
+ ":site_settings_behavior",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/site_settings/add_site_dialog.html b/chromium/chrome/browser/resources/settings/site_settings/add_site_dialog.html
index 9d78be71445..87c2439d68d 100644
--- a/chromium/chrome/browser/resources/settings/site_settings/add_site_dialog.html
+++ b/chromium/chrome/browser/resources/settings/site_settings/add_site_dialog.html
@@ -1,5 +1,6 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html">
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
@@ -29,10 +30,10 @@
value="{{site_}}" on-input="validate_"
error-message="$i18n{notValidWebAddress}" spellcheck="false"
autofocus></paper-input>
- <paper-checkbox id="incognito"
+ <cr-checkbox id="incognito"
invisible$="[[!showIncognitoSessionOnly_]]">
$i18n{incognitoSiteOnly}
- </paper-checkbox>
+ </cr-checkbox>
</div>
<div slot="button-container">
<paper-button class="cancel-button" on-click="onCancelTap_">
diff --git a/chromium/chrome/browser/resources/settings/site_settings/all_sites.html b/chromium/chrome/browser/resources/settings/site_settings/all_sites.html
index 49e8860b245..d91cf769ff4 100644
--- a/chromium/chrome/browser/resources/settings/site_settings/all_sites.html
+++ b/chromium/chrome/browser/resources/settings/site_settings/all_sites.html
@@ -1,10 +1,7 @@
<link rel="import" href="chrome://resources/html/polymer.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html">
<link rel="import" href="../settings_shared_css.html">
-<link rel="import" href="constants.html">
-<link rel="import" href="site_list.html">
-<link rel="import" href="site_settings_behavior.html">
+<link rel="import" href="site_entry.html">
<dom-module id="all-sites">
<template>
@@ -12,28 +9,19 @@
:host {
display: block;
}
+
+ /* There is only one top-level heading for All Sites, so remove the
+ * additional leading padding used for lists. */
+ .list-frame.without-heading {
+ -webkit-padding-start: var(--settings-box-row-padding);
+ }
</style>
<div class="list-frame" hidden$="[[sites.length]]">
<div class="list-item secondary">$i18n{noSitesAdded}</div>
</div>
- <div class="list-frame menu-content vertical-list" id="listContainer">
+ <div class="list-frame without-heading" id="listContainer">
<template is="dom-repeat" items="[[sites]]">
- <div class="list-item">
- <div class="layout horizontal center flex" on-click="onOriginTap_"
- actionable>
- <div class="favicon-image"
- style$="[[computeSiteIcon(item.origin)]]">
- </div>
- <div class="middle no-min-width text-elide"
- id="displayName">
- [[item.displayName]]
- </div>
- <paper-icon-button-light class="subpage-arrow">
- <button aria-label$="[[item.displayName]]"
- aria-describedby="displayName"></button>
- </paper-icon-button-light>
- </div>
- </div>
+ <site-entry site="{{item}}" label="[[item.displayName]]">
</template>
</div>
</template>
diff --git a/chromium/chrome/browser/resources/settings/site_settings/all_sites.js b/chromium/chrome/browser/resources/settings/site_settings/all_sites.js
index 8edec7050a9..81c9e5553da 100644
--- a/chromium/chrome/browser/resources/settings/site_settings/all_sites.js
+++ b/chromium/chrome/browser/resources/settings/site_settings/all_sites.js
@@ -62,17 +62,6 @@ Polymer({
return Promise.all(promiseList);
},
- /**
- * A handler for selecting a site (by clicking on the origin).
- * @param {!{model: !{item: !SiteException}}} event
- * @private
- */
- onOriginTap_: function(event) {
- settings.navigateTo(
- settings.routes.SITE_SETTINGS_SITE_DETAILS,
- new URLSearchParams('site=' + event.model.item.origin));
- },
-
/** @private */
populateList_: function() {
this.getAllSitesList_().then(this.processExceptions_.bind(this));
diff --git a/chromium/chrome/browser/resources/settings/site_settings/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/site_settings/compiled_resources2.gyp
deleted file mode 100644
index 38e5e6cef5f..00000000000
--- a/chromium/chrome/browser/resources/settings/site_settings/compiled_resources2.gyp
+++ /dev/null
@@ -1,217 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'add_site_dialog',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- 'constants',
- 'site_settings_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'all_sites',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '<(EXTERNS_GYP):settings_private',
- 'constants',
- 'site_settings_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'category_default_setting',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '<(EXTERNS_GYP):settings_private',
- '../settings_page/compiled_resources2.gyp:settings_animated_pages',
- 'constants',
- 'site_settings_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'category_setting_exceptions',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):settings_private',
- '../settings_page/compiled_resources2.gyp:settings_animated_pages',
- 'constants',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'constants',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'local_data_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):chrome_send',
- '<(EXTERNS_GYP):settings_private',
- 'constants',
- 'cookie_info',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'media_picker',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- 'site_settings_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'cookie_info',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'protocol_handlers',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_action_menu/compiled_resources2.gyp:cr_action_menu',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- 'site_settings_behavior',
- '../android_apps_page/compiled_resources2.gyp:android_apps_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'usb_devices',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_action_menu/compiled_resources2.gyp:cr_action_menu',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- 'site_settings_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'site_data',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink',
- '../compiled_resources2.gyp:global_scroll_target_behavior',
- '../settings_page/compiled_resources2.gyp:settings_subpage_search',
- 'cookie_info',
- 'local_data_browser_proxy',
- 'site_settings_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'site_data_details_subpage',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '../compiled_resources2.gyp:route',
- 'local_data_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'site_details',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(EXTERNS_GYP):settings_private',
- 'constants',
- 'site_settings_behavior',
- 'site_details_permission',
- 'website_usage_private_api',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'site_details_permission',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- 'constants',
- 'site_settings_behavior',
- ],
- 'externs': [
- '<(EXTERNS_GYP):settings_private',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'site_list',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '<(DEPTH)/ui/webui/resources/cr_elements/cr_action_menu/compiled_resources2.gyp:cr_action_menu',
- 'constants',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink',
- '<(EXTERNS_GYP):settings_private',
- 'site_settings_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'site_settings_behavior',
- 'dependencies': [
- '../compiled_resources2.gyp:route',
- '<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_indicator_behavior',
- '<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_pref_behavior',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:icon',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(EXTERNS_GYP):settings_private',
- 'constants',
- 'site_settings_prefs_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'site_settings_prefs_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):chrome_send',
- '<(EXTERNS_GYP):settings_private',
- 'constants',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'website_usage_private_api',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):chrome_send',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'zoom_levels',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- 'site_settings_behavior',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/site_settings/edit_exception_dialog.js b/chromium/chrome/browser/resources/settings/site_settings/edit_exception_dialog.js
index 654d2464221..be6faee4bc6 100644
--- a/chromium/chrome/browser/resources/settings/site_settings/edit_exception_dialog.js
+++ b/chromium/chrome/browser/resources/settings/site_settings/edit_exception_dialog.js
@@ -13,7 +13,10 @@ Polymer({
/**
* @type {!SiteException}
*/
- model: Object,
+ model: {
+ type: Object,
+ observer: 'modelChanged_',
+ },
/** @private */
origin_: String,
@@ -72,4 +75,10 @@ Polymer({
this.invalid_ = !isValid;
});
},
+
+ /** @private */
+ modelChanged_: function() {
+ if (!this.model)
+ this.$.dialog.cancel();
+ },
});
diff --git a/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.html b/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.html
index d513605ad7c..12b5f5d0edf 100644
--- a/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.html
+++ b/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.html
@@ -24,7 +24,8 @@
}
</style>
<div class="settings-box first two-line">
- <div id="categoryLabel" class="start">
+ <div id="categoryLabel" class="start" on-click="categoryLabelClicked_"
+ actionable>
[[computeHandlersDescription_(categoryEnabled)]]
</div>
<cr-toggle id="toggle" checked="{{categoryEnabled}}"
diff --git a/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.js b/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.js
index 904fc75097c..49e6a3edce3 100644
--- a/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.js
+++ b/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.js
@@ -110,6 +110,11 @@ Polymer({
},
// </if>
+ /** @private */
+ categoryLabelClicked_: function() {
+ this.$.toggle.click();
+ },
+
/**
* Obtains the description for the main toggle.
* @return {string} The description to use.
diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_data.html b/chromium/chrome/browser/resources/settings/site_settings/site_data.html
index 8779e1c36e5..e252978aa23 100644
--- a/chromium/chrome/browser/resources/settings/site_settings/site_data.html
+++ b/chromium/chrome/browser/resources/settings/site_settings/site_data.html
@@ -3,6 +3,7 @@
<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
+<link rel="import" href="chrome://resources/html/list_property_update_behavior.html">
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html">
@@ -50,7 +51,7 @@
[[computeRemoveLabel_(filter)]]
</paper-button>
</div>
- <iron-list id="list" items="[[sites]]"
+ <iron-list id="list" items="[[sites]]" preserve-focus
scroll-target="[[subpageScrollTarget]]">
<template>
<div class="settings-box two-line site-item" first$="[[!index]]"
diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_data.js b/chromium/chrome/browser/resources/settings/site_settings/site_data.js
index 4dbf87f04fc..b20699412ec 100644
--- a/chromium/chrome/browser/resources/settings/site_settings/site_data.js
+++ b/chromium/chrome/browser/resources/settings/site_settings/site_data.js
@@ -40,6 +40,7 @@ Polymer({
behaviors: [
I18nBehavior,
+ ListPropertyUpdateBehavior,
settings.GlobalScrollTargetBehavior,
WebUIListenerBehavior,
],
@@ -102,6 +103,11 @@ Polymer({
this, currentRoute);
if (currentRoute == settings.routes.SITE_SETTINGS_SITE_DATA) {
this.isLoading_ = true;
+ // Needed to fix iron-list rendering issue. The list will not render
+ // correctly until a scroll occurs.
+ // See https://crbug.com/853906.
+ const ironList = /** @type {!IronListElement} */ (this.$$('iron-list'));
+ ironList.scrollToIndex(0);
this.browserProxy_.reloadCookies().then(this.updateSiteList_.bind(this));
}
},
@@ -145,8 +151,8 @@ Polymer({
*/
updateSiteList_: function() {
this.isLoading_ = true;
- this.browserProxy_.getDisplayList(this.filter).then((listInfo) => {
- this.sites = listInfo.items;
+ this.browserProxy_.getDisplayList(this.filter).then(listInfo => {
+ this.updateList('sites', item => item.site, listInfo.items);
this.isLoading_ = false;
this.fire('site-data-list-complete');
});
diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_details.html b/chromium/chrome/browser/resources/settings/site_settings/site_details.html
index 1a8a1bf055e..f4bd627732d 100644
--- a/chromium/chrome/browser/resources/settings/site_settings/site_details.html
+++ b/chromium/chrome/browser/resources/settings/site_settings/site_details.html
@@ -55,8 +55,8 @@
<template is="dom-if" if="[[enableSiteSettings_]]">
<div id="usage">
- <div class="settings-box first">
- <h2>$i18n{siteSettingsUsage}</h2>
+ <div class="settings-box first line-only">
+ <h2 class="first">$i18n{siteSettingsUsage}</h2>
</div>
<div class="list-frame">
<div class="list-item" id="noStorage"
diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_entry.html b/chromium/chrome/browser/resources/settings/site_settings/site_entry.html
new file mode 100644
index 00000000000..8e0e8d506a7
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/site_settings/site_entry.html
@@ -0,0 +1,24 @@
+<link rel="import" href="chrome://resources/html/polymer.html">
+
+<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html">
+<link rel="import" href="../settings_shared_css.html">
+<link rel="import" href="site_settings_behavior.html">
+
+<dom-module id="site-entry">
+ <template>
+ <style include="settings-shared"></style>
+ <div class="settings-box list-item" on-click="onOriginTap_"
+ actionable>
+ <div class="favicon-image" style$="[[computeSiteIcon(site.origin)]]">
+ </div>
+ <div class="middle text-elide" id="displayName">
+ [[site.displayName]]
+ </div>
+ <paper-icon-button-light class="subpage-arrow">
+ <button aria-label$="[[site.displayName]]"
+ aria-describedby="displayName"></button>
+ </paper-icon-button-light>
+ </div>
+ </template>
+ <script src="site_entry.js"></script>
+</dom-module>
diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_entry.js b/chromium/chrome/browser/resources/settings/site_settings/site_entry.js
new file mode 100644
index 00000000000..b424b216159
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/site_settings/site_entry.js
@@ -0,0 +1,37 @@
+// 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.
+
+/**
+ * @fileoverview
+ * 'site-entry' is an element representing a single ETLD+1 site entity.
+ */
+
+Polymer({
+ is: 'site-entry',
+
+ behaviors: [SiteSettingsBehavior],
+
+ properties: {
+ /**
+ * TODO(https://crbug.com/835712): This should be an object representing a
+ * ETLD+1 site.
+ */
+ site: Object,
+ },
+
+ /** @override */
+ ready: function() {},
+
+ /**
+ * A handler for selecting a site (by clicking on the origin).
+ * @param {!{model: !{item: !SiteException}}} event
+ * @private
+ */
+ onOriginTap_: function(event) {
+ settings.navigateTo(
+ settings.routes.SITE_SETTINGS_SITE_DETAILS,
+ new URLSearchParams('site=' + this.site.origin));
+ },
+
+});
diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_list.js b/chromium/chrome/browser/resources/settings/site_settings/site_list.js
index 650f86c7a66..29c4646b0c6 100644
--- a/chromium/chrome/browser/resources/settings/site_settings/site_list.js
+++ b/chromium/chrome/browser/resources/settings/site_settings/site_list.js
@@ -370,8 +370,10 @@ Polymer({
onEditExceptionDialogClosed_: function() {
this.showEditExceptionDialog_ = false;
this.actionMenuSite_ = null;
- this.activeDialogAnchor_.focus();
- this.activeDialogAnchor_ = null;
+ if (this.activeDialogAnchor_) {
+ this.activeDialogAnchor_.focus();
+ this.activeDialogAnchor_ = null;
+ }
},
/** @private */
diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_settings_behavior.js b/chromium/chrome/browser/resources/settings/site_settings/site_settings_behavior.js
index 5d43d656173..1c244c0b998 100644
--- a/chromium/chrome/browser/resources/settings/site_settings/site_settings_behavior.js
+++ b/chromium/chrome/browser/resources/settings/site_settings/site_settings_behavior.js
@@ -110,7 +110,7 @@ const SiteSettingsBehaviorImpl = {
* Returns true if the passed content setting is considered 'enabled'.
* @param {string} setting
* @return {boolean}
- * @private
+ * @protected
*/
computeIsSettingEnabled: function(setting) {
return setting != settings.ContentSetting.BLOCK;
@@ -120,7 +120,7 @@ const SiteSettingsBehaviorImpl = {
* Converts a string origin/pattern to a URL.
* @param {string} originOrPattern The origin/pattern to convert to URL.
* @return {URL} The URL to return (or null if origin is not a valid URL).
- * @private
+ * @protected
*/
toUrl: function(originOrPattern) {
if (originOrPattern.length == 0)
@@ -140,7 +140,7 @@ const SiteSettingsBehaviorImpl = {
* SiteException.
* @param {!RawSiteException} exception The raw site exception from C++.
* @return {!SiteException} The expanded (full) SiteException.
- * @private
+ * @protected
*/
expandSiteException: function(exception) {
const origin = exception.origin;
diff --git a/chromium/chrome/browser/resources/settings/site_settings_page/BUILD.gn b/chromium/chrome/browser/resources/settings/site_settings_page/BUILD.gn
new file mode 100644
index 00000000000..ea35eff8914
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/site_settings_page/BUILD.gn
@@ -0,0 +1,24 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":site_settings_page",
+ ]
+}
+
+js_library("site_settings_page") {
+ deps = [
+ "..:route",
+ "../site_settings:constants",
+ "../site_settings:site_settings_behavior",
+ "../site_settings:site_settings_prefs_browser_proxy",
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ "//ui/webui/resources/js:web_ui_listener_behavior",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/settings/site_settings_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/site_settings_page/compiled_resources2.gyp
deleted file mode 100644
index 5985d7c7b2a..00000000000
--- a/chromium/chrome/browser/resources/settings/site_settings_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'site_settings_page',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior',
- '../compiled_resources2.gyp:route',
- '../site_settings/compiled_resources2.gyp:constants',
- '../site_settings/compiled_resources2.gyp:site_settings_behavior',
- '../site_settings/compiled_resources2.gyp:site_settings_prefs_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/settings/site_settings_page/site_settings_page.html b/chromium/chrome/browser/resources/settings/site_settings_page/site_settings_page.html
index 32d1f2a9a7a..bbd499ce1b1 100644
--- a/chromium/chrome/browser/resources/settings/site_settings_page/site_settings_page.html
+++ b/chromium/chrome/browser/resources/settings/site_settings_page/site_settings_page.html
@@ -18,15 +18,18 @@
}
</style>
<template is="dom-if" if="[[enableSiteSettings_]]">
- <div class="settings-box first" category$="[[ALL_SITES]]"
+ <div class="settings-box first line-only">
+ <h2 class="first">$i18n{siteSettingsAllSites}</h2>
+ </div>
+ <div class="settings-box first line-only" category$="[[ALL_SITES]]"
data-route="SITE_SETTINGS_ALL" on-click="onTapNavigate_" actionable>
- <iron-icon icon="settings:list"></iron-icon>
- <div class="middle">$i18n{siteSettingsCategoryAllSites}</div>
+ <div class="start">$i18n{siteSettingsAllSitesDescription}</div>
<paper-icon-button-light class="subpage-arrow">
- <button aria-label="$i18n{siteSettingsCategoryAllSites}"></button>
+ <button aria-label="$i18n{siteSettingsAllSitesDescription}"></button>
</paper-icon-button-light>
</div>
- <div class="settings-box line-only">
+ <div class="settings-box first line-only">
+ <h2>$i18n{siteSettingsPermissions}</h2>
</div>
</template>
<div id="cookies" class="settings-box two-line first"
diff --git a/chromium/chrome/browser/resources/settings/site_settings_page/site_settings_page.js b/chromium/chrome/browser/resources/settings/site_settings_page/site_settings_page.js
index eb57c9fe1cc..4f611936a57 100644
--- a/chromium/chrome/browser/resources/settings/site_settings_page/site_settings_page.js
+++ b/chromium/chrome/browser/resources/settings/site_settings_page/site_settings_page.js
@@ -137,7 +137,8 @@ Polymer({
pairs.forEach(pair => {
const route = pair[0];
const id = pair[1];
- this.focusConfig.set(route.path, '* /deep/ #' + id + ' .subpage-arrow');
+ this.focusConfig.set(
+ route.path, '* /deep/ #' + id + ' .subpage-arrow button');
});
},
diff --git a/chromium/chrome/browser/resources/settings/system_page/BUILD.gn b/chromium/chrome/browser/resources/settings/system_page/BUILD.gn
new file mode 100644
index 00000000000..10b912a94c3
--- /dev/null
+++ b/chromium/chrome/browser/resources/settings/system_page/BUILD.gn
@@ -0,0 +1,28 @@
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":system_page",
+ ":system_page_browser_proxy",
+ ]
+}
+
+js_library("system_page_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+ externs_list = [ "$externs_path/chrome_send.js" ]
+}
+
+js_library("system_page") {
+ deps = [
+ ":system_page_browser_proxy",
+ "..:lifetime_browser_proxy",
+ ]
+ externs_list = [ "$externs_path/settings_private.js" ]
+}
diff --git a/chromium/chrome/browser/resources/settings/system_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/system_page/compiled_resources2.gyp
deleted file mode 100644
index 748399f4190..00000000000
--- a/chromium/chrome/browser/resources/settings/system_page/compiled_resources2.gyp
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'system_page_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(EXTERNS_GYP):chrome_send',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'system_page',
- 'dependencies': [
- '../compiled_resources2.gyp:lifetime_browser_proxy',
- 'system_page_browser_proxy',
- '<(EXTERNS_GYP):settings_private',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/signin/dice_sync_confirmation/BUILD.gn b/chromium/chrome/browser/resources/signin/dice_sync_confirmation/BUILD.gn
new file mode 100644
index 00000000000..12f0d83afbe
--- /dev/null
+++ b/chromium/chrome/browser/resources/signin/dice_sync_confirmation/BUILD.gn
@@ -0,0 +1,35 @@
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":sync_confirmation",
+ ":sync_confirmation_app",
+ ":sync_confirmation_browser_proxy",
+ ]
+}
+
+js_library("sync_confirmation") {
+ deps = [
+ ":sync_confirmation_browser_proxy",
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
+js_library("sync_confirmation_app") {
+ deps = [
+ ":sync_confirmation_browser_proxy",
+ "//ui/webui/resources/js:cr",
+ "//ui/webui/resources/js:load_time_data",
+ ]
+}
+
+js_library("sync_confirmation_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/chrome_send.js" ]
+}
diff --git a/chromium/chrome/browser/resources/signin/dice_sync_confirmation/compiled_resources2.gyp b/chromium/chrome/browser/resources/signin/dice_sync_confirmation/compiled_resources2.gyp
deleted file mode 100644
index dc29406822b..00000000000
--- a/chromium/chrome/browser/resources/signin/dice_sync_confirmation/compiled_resources2.gyp
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'sync_confirmation',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- 'sync_confirmation_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'sync_confirmation_app',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- 'sync_confirmation_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'sync_confirmation_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):chrome_send',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-} \ No newline at end of file
diff --git a/chromium/chrome/browser/resources/signin/dice_sync_confirmation/images/sync_confirmation_illustration.svg b/chromium/chrome/browser/resources/signin/dice_sync_confirmation/images/sync_confirmation_illustration.svg
new file mode 100644
index 00000000000..2c1c44f7863
--- /dev/null
+++ b/chromium/chrome/browser/resources/signin/dice_sync_confirmation/images/sync_confirmation_illustration.svg
@@ -0,0 +1 @@
+<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 168"><defs><style>.cls-1{fill:#fff;}.cls-2{fill:#4285f4;}.cls-3{fill:#e8e9eb;}.cls-4{fill:#f4f4f4;}.cls-5{fill:#bdc0c5;}.cls-6{fill:#34a751;}.cls-7{fill:#f7bb2a;}</style></defs><title>confirmation@1x</title><path class="cls-1" d="M256,89a41,41,0,0,0-41,39.13H297A41,41,0,0,0,256,89Z"/><path class="cls-2" d="M97.76,72H103c0-10.83,2.9-19.34,8.63-25.3,9-9.37,22.15-9.41,22.28-9.41L134,32c-.62,0-15.32,0-25.84,10.91C101.37,49.9,97.76,59.69,97.76,72Z"/><path class="cls-3" d="M82.41,102.42A35.27,35.27,0,0,1,67,106.75V112a40.36,40.36,0,0,0,18-5c8.23-4.61,18-14.42,18-35H97.76C97.76,86.48,92.6,96.71,82.41,102.42Z"/><path class="cls-3" d="M143.78,33.27v5.33h7.41a6.35,6.35,0,0,1-2.77,4.15,8.28,8.28,0,0,1-12.36-4.35h0a8.29,8.29,0,0,1,7.71-10.91A7.52,7.52,0,0,1,149,29.54L153,25.59A13.22,13.22,0,0,0,143.78,22a13.75,13.75,0,0,0-12.3,7.6,13.64,13.64,0,0,0,0,12.35h0a13.76,13.76,0,0,0,12.3,7.59,13.15,13.15,0,0,0,9.12-3.33A13.46,13.46,0,0,0,157,36.09a15.82,15.82,0,0,0-.25-2.82Z"/><path class="cls-3" d="M433,109h18v-8.48A11,11,0,0,0,433,109Z"/><path class="cls-3" d="M491,59.49H460.8a5.6,5.6,0,0,0-5.59,5.59v72.36A5.6,5.6,0,0,0,460.8,143H491a5.6,5.6,0,0,0,5.59-5.59V65.08A5.6,5.6,0,0,0,491,59.49Zm4.89,77.95a4.89,4.89,0,0,1-4.89,4.89H460.8a4.89,4.89,0,0,1-4.89-4.89V65.08a4.89,4.89,0,0,1,4.89-4.89H491a4.89,4.89,0,0,1,4.89,4.89Z"/><path class="cls-3" d="M418.43,92.8c6.1-10.92,17.06-16.46,32.56-16.46V70.72c-22,0-32.53,10.52-37.46,19.34a43.35,43.35,0,0,0-5.36,19.27h5.62A37.88,37.88,0,0,1,418.43,92.8Z"/><path class="cls-3" d="M342,50.45a9.28,9.28,0,0,1-8.17-4.86l-9.38-16.21A21.84,21.84,0,0,0,321,40.92a21,21,0,0,0,17.56,20.86l7-11.94A10.66,10.66,0,0,1,342,50.45Z"/><path class="cls-3" d="M347.91,33.67A9.58,9.58,0,0,1,351.45,41a8.47,8.47,0,0,1-1.28,4.61L340.66,62h1.26a20.93,20.93,0,0,0,15.21-6.49h-2.81a8.64,8.64,0,0,1,7.82-8.6,20.8,20.8,0,0,0,.87-5.82,21.63,21.63,0,0,0-1.23-7.35Z"/><path class="cls-3" d="M342,31.55l18.69.07a20.52,20.52,0,0,0-13.78-11A50.49,50.49,0,0,0,341,.16L341,0h-6c.6.9,1.14,1.79,1.62,2.67A44.81,44.81,0,0,1,341.83,20a20.87,20.87,0,0,0-15.94,7.49l6.88,12A9.47,9.47,0,0,1,342,31.55Z"/><circle class="cls-3" cx="342" cy="41" r="7.35" transform="translate(299.63 382.83) rotate(-89.77)"/><path class="cls-3" d="M258.56,166.88A37.06,37.06,0,0,1,221.77,144H226v-8.48a11,11,0,0,0-6.86-2.51c0-.16,0-.32,0-.48a37,37,0,0,1,34.36-39.47l-.07-1a38,38,0,0,0-35.29,40.53c0,.15,0,.3,0,.45A11,11,0,0,0,208,144h12.68a38,38,0,0,0,73.21-11.35l-1-.07A37,37,0,0,1,258.56,166.88Z"/><path class="cls-4" d="M62.72,48.5H0v88.33H67.51V53.28A4.78,4.78,0,0,0,62.72,48.5Z"/><path class="cls-5" d="M68,53.28A5.3,5.3,0,0,0,62.72,48H0v1H62.72A4.28,4.28,0,0,1,67,53.28v83.06H0v1H68Z"/><rect class="cls-5" y="143.01" width="86" height="0.99"/><path class="cls-5" d="M451.72,139.1V63.73a7.9,7.9,0,0,1,7.89-7.89h25.07v-.7H459.62a8.6,8.6,0,0,0-8.6,8.59V139.1a8.6,8.6,0,0,0,8.6,8.59H472V147H459.62A7.9,7.9,0,0,1,451.72,139.1Z"/><path class="cls-5" d="M495.22,55.55v.75a7.9,7.9,0,0,1,5.26,7.43V139.1a7.9,7.9,0,0,1-7.89,7.89H480.2v.7h12.39a8.6,8.6,0,0,0,8.6-8.59V63.73A8.61,8.61,0,0,0,495.22,55.55Z"/><path class="cls-6" d="M499.48,7.6c-11.6,11.7-11.6,28-11.59,28.74,0,.15,0,14.78-10,24.78-6.34,6.37-15.38,9.6-26.89,9.6v5.62c13.08,0,23.48-3.8,30.91-11.3,11.6-11.7,11.6-28,11.59-28.74,0-.15,0-14.78,10-24.78A29.73,29.73,0,0,1,512,5.58V0h-1.28A35.46,35.46,0,0,0,499.48,7.6Z"/><path class="cls-1" d="M62.56,99.28a11.77,11.77,0,0,0-9.48,5,7.42,7.42,0,0,0-2.7-.52c-4.49,0-8.12,4-8.12,9H74.75C74.75,105.3,69.29,99.28,62.56,99.28Z"/><path class="cls-5" d="M68,70v.53a8.35,8.35,0,0,1,8.44,7.94H68V79h9v-.26A8.88,8.88,0,0,0,68,70Z"/><path class="cls-5" d="M166.5,81a2,2,0,0,1,2-2h4.72V77a2.55,2.55,0,0,1,5.11,0V79h.49V77a3,3,0,0,0-6.09,0v1.44h-4.23A2.48,2.48,0,0,0,166,81v4.5h.49Z"/><path class="cls-5" d="M187,85.19h-1.43V81A2.49,2.49,0,0,0,183,78.48h-3.25V79H183a2,2,0,0,1,2,2v4.72H187a2.55,2.55,0,0,1,0,5.11H185v.49H187a3,3,0,0,0,0-6.09Z"/><path class="cls-5" d="M185,95.52a2,2,0,0,1-2,2h-4V96.08a3.27,3.27,0,0,0-6.54,0V98H173V96.08a2.78,2.78,0,0,1,5.56,0V98H183a2.49,2.49,0,0,0,2.48-2.48V92.26H185Z"/><path class="cls-5" d="M166.49,95.52v-4h1.43a3.27,3.27,0,1,0,0-6.54h-.24v.49h.24a2.78,2.78,0,0,1,0,5.56H166v4.5A2.49,2.49,0,0,0,168.48,98h3v-.49h-3A2,2,0,0,1,166.49,95.52Z"/><path class="cls-5" d="M231.5,32.3V47.11h2.64V32.3Zm2.15,14.32H232V32.79h1.66Z"/><path class="cls-5" d="M234.61,28H207.39A2.4,2.4,0,0,0,205,30.39v3.1h.49v-3.1a1.9,1.9,0,0,1,1.9-1.9h27.21a1.9,1.9,0,0,1,1.9,1.9V49a1.9,1.9,0,0,1-1.9,1.9H207.39a1.9,1.9,0,0,1-1.9-1.9V42.48l1.87,2.58,2.14-1.55-2.13-2.93,3.44-1.12L210,36.95l-3.43,1.11V34.44H205v.49h1.07v3.8l3.61-1.17.51,1.57-3.62,1.17,2.24,3.08-1.34,1L205,41v8a2.4,2.4,0,0,0,2.39,2.39h27.21A2.4,2.4,0,0,0,237,49V30.39A2.4,2.4,0,0,0,234.61,28Z"/><path class="cls-5" d="M219.68,34.44v3.62l-3.43-1.11-.82,2.51,3.44,1.12-2.13,2.93,2.14,1.55L221,42.14l2.12,2.92,2.14-1.55-2.13-2.93,3.44-1.12-.82-2.51-3.43,1.11V34.44Zm5.75,3.13.51,1.57-3.61,1.17,2.24,3.08-1.34,1L221,41.31l-2.23,3.06-1.34-1,2.24-3.08-3.62-1.17.51-1.57,3.61,1.17v-3.8h1.66v3.8Z"/><polygon class="cls-5" points="296.75 69.86 296.25 69.86 296.25 73.61 291.05 68.41 296.25 63.2 296.25 66.96 296.75 66.96 296.75 62 290.34 68.41 296.75 74.82 296.75 69.86"/><polygon class="cls-5" points="296.25 87.28 296.75 87.28 296.75 83.53 301.95 88.73 296.75 93.94 296.75 90.19 296.25 90.19 296.25 95.14 302.66 88.73 296.25 82.32 296.25 87.28"/><path class="cls-5" d="M296.5,68.07v.5a10,10,0,0,1,8.62,15.08l.43.25a10.5,10.5,0,0,0-9-15.83Z"/><path class="cls-5" d="M296.5,88.57a10,10,0,0,1-8.62-15.08l-.43-.25a10.5,10.5,0,0,0,9,15.83Z"/><path class="cls-5" d="M47,31.7V20.58H23.49v-3a2.1,2.1,0,0,1,2.09-2.11H44.4a2.11,2.11,0,0,1,2.11,2.11v2H47v-2A2.6,2.6,0,0,0,44.4,15H25.6A2.59,2.59,0,0,0,23,17.6v3.48H46.51V31.7a2.11,2.11,0,0,1-2.11,2.11H25.6a2.11,2.11,0,0,1-2.11-2.11v-8H45.94V23.2H23v8.5a2.6,2.6,0,0,0,2.6,2.6H44.4A2.6,2.6,0,0,0,47,31.7Z"/><path class="cls-5" d="M354,101.55a4.78,4.78,0,1,0,4.78,4.78A4.79,4.79,0,0,0,354,101.55Zm0,9.06a4.28,4.28,0,1,1,4.28-4.28A4.28,4.28,0,0,1,354,110.62Z"/><path class="cls-5" d="M365.9,102.27l-2.41-4.18a.88.88,0,0,0-1.05-.38l-2.88,1.16a9,9,0,0,0-1.85-1.07l-.43-3.06a.85.85,0,0,0-.85-.73h-4.84a.84.84,0,0,0-.84.73l-.43,3.06a9.33,9.33,0,0,0-1.85,1.07l-2.88-1.16a.85.85,0,0,0-1,.38l-2.42,4.19a.84.84,0,0,0,.22,1.09l2.44,1.9a7.56,7.56,0,0,0-.09,1.07,8,8,0,0,0,.07,1.07l-2.44,1.91a.88.88,0,0,0-.21,1.09l2.41,4.18a.87.87,0,0,0,1.05.38l2.88-1.16a9,9,0,0,0,1.85,1.07l.44,3.07a.87.87,0,0,0,.85.72h4.84a.83.83,0,0,0,.84-.73l.43-3.06a9.34,9.34,0,0,0,1.85-1.07l2.88,1.16a.85.85,0,0,0,1-.38l2.42-4.19a.84.84,0,0,0-.22-1.09l-2.41-1.91a9.82,9.82,0,0,0,.06-1.07,7.93,7.93,0,0,0-.07-1.07l2.44-1.91A.88.88,0,0,0,365.9,102.27Zm-.52.7-2.67,2.09,0,.15a7.28,7.28,0,0,1,.09,1.14,9.76,9.76,0,0,1-.07,1.15l0,.14,2.64,2.09a.33.33,0,0,1,.08.44L363,114.34a.34.34,0,0,1-.43.16l-3.14-1.26-.11.09a8.89,8.89,0,0,1-2,1.15l-.13.05-.47,3.36a.33.33,0,0,1-.34.29h-4.84a.36.36,0,0,1-.36-.3l-.47-3.34-.13-.06a8.58,8.58,0,0,1-2-1.15l-.11-.09-3.12,1.26a.36.36,0,0,1-.44-.16l-2.41-4.18a.37.37,0,0,1,.08-.45l2.67-2.09,0-.15a7.4,7.4,0,0,1-.09-1.14,7.28,7.28,0,0,1,.1-1.14l0-.15L342.64,103a.33.33,0,0,1-.08-.44L345,98.33a.34.34,0,0,1,.43-.16l3.14,1.26.11-.09a8.9,8.9,0,0,1,2-1.15l.13-.05.47-3.34a.34.34,0,0,1,.34-.3h4.84a.35.35,0,0,1,.36.3l.47,3.35.13.05a8.58,8.58,0,0,1,2,1.15l.11.09,3.12-1.26a.36.36,0,0,1,.44.16l2.41,4.18A.37.37,0,0,1,365.37,103Z"/><path class="cls-5" d="M62.56,99A12,12,0,0,0,53,104a7.64,7.64,0,0,0-2.62-.47c-4.62,0-8.38,4.14-8.38,9.24V113H75v-.28C75,105.15,69.42,99,62.56,99Zm11.93,13.44h-32c.13-4.66,3.61-8.4,7.87-8.4a7.19,7.19,0,0,1,2.62.5l.17.07.11-.15a11.5,11.5,0,0,1,9.28-4.9C69.06,99.56,74.35,105.31,74.49,112.44Z"/><path class="cls-5" d="M375.91,42.28a13.18,13.18,0,0,0-10.17,4.77A8.89,8.89,0,0,0,354,55.51v.27h35.1v-.27A13.24,13.24,0,0,0,375.91,42.28Zm-21.33,13a8.35,8.35,0,0,1,11.15-7.61l.18.06.12-.15a12.69,12.69,0,0,1,22.56,7.7Z"/><path class="cls-5" d="M441,33.51a2.5,2.5,0,1,0-2.5-2.5A2.51,2.51,0,0,0,441,33.51ZM441,29a2,2,0,1,1-2,2A2,2,0,0,1,441,29Z"/><path class="cls-5" d="M441,38a7,7,0,0,0,6.53-4.49H452V38h5V33.51h2v-5H447.53A7,7,0,1,0,441,38Zm0-13.48a6.48,6.48,0,0,1,6.11,4.32l.06.17h11.32v4h-2v4.49h-4V33h-5.3l-.06.17A6.48,6.48,0,1,1,441,24.52Z"/><path class="cls-7" d="M256,92v1a37,37,0,0,1,37,37h1A38,38,0,0,0,256,92Z"/><path class="cls-1" d="M411.08,121A16.81,16.81,0,0,0,398,127.27a11.21,11.21,0,0,0-15,10.58h44.93A16.85,16.85,0,0,0,411.08,121Z"/><path class="cls-3" d="M411.08,121.7a16.17,16.17,0,0,1,16.13,15.44H383.73a10.5,10.5,0,0,1,14-9.22l.47.17.31-.39a16.09,16.09,0,0,1,12.56-6m0-.7A16.81,16.81,0,0,0,398,127.27a11.21,11.21,0,0,0-15,10.58h44.93A16.85,16.85,0,0,0,411.08,121Z"/></svg> \ No newline at end of file
diff --git a/chromium/chrome/browser/resources/signin/dice_sync_confirmation/sync_confirmation_app.html b/chromium/chrome/browser/resources/signin/dice_sync_confirmation/sync_confirmation_app.html
index 644c00a0c8f..15d30d14ed4 100644
--- a/chromium/chrome/browser/resources/signin/dice_sync_confirmation/sync_confirmation_app.html
+++ b/chromium/chrome/browser/resources/signin/dice_sync_confirmation/sync_confirmation_app.html
@@ -1,18 +1,24 @@
<link rel="import" href="chrome://resources/html/polymer.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_radio_button/cr_radio_button.html">
+<link rel="import" href="chrome://resources/cr_elements/paper_button_style_css.html">
<link rel="import" href="chrome://resources/html/cr.html">
+<link rel="import" href="chrome://resources/html/load_time_data.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icons/iron-icons.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icons/image-icons.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icons/notification-icons.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
+<link rel="import" href="chrome://resources/polymer/v1_0/paper-radio-group/paper-radio-group.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/color.html">
<link rel="import" href="signin_shared_css.html">
<link rel="import" href="sync_confirmation_browser_proxy.html">
+<script src="chrome://sync-confirmation/strings.js"></script>
+
<dom-module id="sync-confirmation-app">
<template>
- <style include="signin-dialog-shared">
+ <style include="signin-dialog-shared paper-button-style">
:host {
display: block;
width: 512px;
@@ -23,33 +29,64 @@
padding-right: 16px;
}
- #undoButton {
+ .action-container {
+ bottom: 0;
+ box-sizing: border-box;
+ position: absolute;
+ width: 100%;
+ }
+
+ paper-button:not(.action-button) {
-webkit-margin-start: 16px;
}
<if expr="is_macosx or is_linux">
/* This works together with the button-flip in signin-dialog-shared. */
- #undoButton {
+ paper-button:not(.action-button) {
-webkit-margin-end: 16px;
-webkit-margin-start: 0;
}
</if>
#illustration-container {
- /* TODO(scottchen): should be taller once illustration is made. */
- height: 20px;
+ height: 168px;
+ margin-bottom: 32px;
+ width: 100%;
+ }
+
+ #illustration {
+ background: url(./images/sync_confirmation_illustration.svg);
+ height: 168px;
+ position: absolute;
+ top: 0;
width: 100%;
}
- #heading {
- border-bottom: 1px solid var(--paper-grey-50);
+ #illustration-container > img {
+ background: white;
+ border-radius: 50%;
+ height: 68px;
+ left: 0;
+ margin: auto;
+ position: absolute;
+ right: 0;
+ top: 96px;
+ width: 68px;
+ }
+
+ .heading {
color: var(--paper-grey-800);
font-weight: normal;
- margin-bottom: 40px;
- padding-bottom: 5px;
+ margin-bottom: 32px;
text-align: center;
}
+ #content-container {
+ /* Saves space for button row. */
+ padding-bottom: 96px;
+ position: relative;
+ }
+
.message-container {
color: var(--paper-grey-800);
display: flex;
@@ -59,7 +96,7 @@
}
.footer::before {
- border-top: 1px solid var(--paper-grey-300);
+ border-top: 2px solid var(--paper-grey-200);
content: '';
display: block;
height: 1;
@@ -106,6 +143,53 @@
background-image: -webkit-image-set(url(./images/ic_google.png) 1x,
url(./images/ic_google_2x.png) 2x);
}
+
+ #options-container {
+ -webkit-margin-start: 16px;
+ background: white;
+ bottom: 0;
+ left: 0;
+ position: absolute;
+ right: 0;
+ top: 0;
+ }
+
+ #options-heading {
+ color: var(--paper-grey-800);
+ font-weight: normal;
+ margin-top: 0;
+ }
+
+ #options-description {
+ -webkit-padding-end: 24px;
+ padding-bottom: 25px;
+ }
+
+ cr-radio-button {
+ line-height: 1.25rem;
+ }
+
+ .subtitle-text {
+ color: var(--paper-grey-600);
+ line-height: 1.25rem;
+ }
+
+ #grey-banner {
+ background: var(--paper-grey-50);
+ height: 128px;
+ top: 0;
+ width: 100%;
+ }
+
+ #settingsButton {
+ left: 16px;
+ position: absolute;
+ }
+
+ :host-context([dir='rtl']) #settingsButton {
+ left: auto;
+ right: 16px;
+ }
</style>
<!--
@@ -115,49 +199,104 @@
which user clicks to indicate consent.
-->
- <div id="illustration-container"></div>
- <h1 id="heading" consent-description>$i18n{syncConfirmationTitle}</h1>
- <div class="message-container">
- <!-- Container needed to contain the icon in a green circle. -->
- <div id="sync-logo-container" class="logo">
- <iron-icon icon="notification:sync" class="logo">
- </iron-icon>
- </div>
- <div consent-description>$i18n{syncConfirmationChromeSyncBody}</div>
+ <div id="illustration-container">
+ <div id="grey-banner"></div>
+ <div id="illustration"></div>
+ <img src="[[accountImageSrc_]]">
</div>
- <div class="message-container">
- <iron-icon icon="image:assistant" id="personalize-logo" class="logo">
- </iron-icon>
- <div consent-description>
- $i18n{syncConfirmationPersonalizeServicesBody}
- </div>
- </div>
- <div class="message-container">
- <div id="googleg-logo" class="logo"></div>
- <div consent-description>$i18n{syncConfirmationGoogleServicesBody}</div>
- </div>
- <div class="footer">
+ <div id="content-container">
+ <h1 id="syncConfirmationHeading" class="heading" consent-description
+ hidden="[[isConsentBump_]]">
+ $i18n{syncConfirmationTitle}
+ </h1>
+ <h1 class="heading" consent-description hidden="[[!isConsentBump_]]">
+ $i18n{syncConsentBumpTitle}
+ </h1>
<div class="message-container">
- <iron-icon icon="icons:settings" class="logo"></iron-icon>
- <div consent-description consent-confirmation>
- $i18nRaw{syncConfirmationSyncSettingsLinkBody}
+ <!-- Container needed to contain the icon in a green circle. -->
+ <div id="sync-logo-container" class="logo">
+ <iron-icon icon="notification:sync" class="logo">
+ </iron-icon>
</div>
+ <div consent-description>$i18n{syncConfirmationChromeSyncBody}</div>
</div>
<div class="message-container">
- <div class="logo"><!-- Spacer to line up with other texts --></div>
+ <iron-icon icon="image:assistant" id="personalize-logo" class="logo">
+ </iron-icon>
<div consent-description>
- $i18n{syncConfirmationSyncSettingsDescription}
+ $i18n{syncConfirmationPersonalizeServicesBody}
</div>
</div>
- </div>
- <div class="action-container">
- <paper-button class="primary-action" id="confirmButton"
- on-tap="onConfirm_" consent-confirmation>
- $i18n{syncConfirmationConfirmLabel}
- </paper-button>
- <paper-button class="secondary-action" id="undoButton" on-tap="onUndo_">
- $i18n{syncConfirmationUndoLabel}
- </paper-button>
+ <div class="message-container">
+ <div id="googleg-logo" class="logo"></div>
+ <div consent-description>$i18n{syncConfirmationGoogleServicesBody}</div>
+ </div>
+ <div class="footer">
+ <div class="message-container">
+ <iron-icon icon="icons:settings" class="logo"></iron-icon>
+ <div consent-description>
+ $i18n{syncConfirmationSyncSettingsDescription}
+ </div>
+ </div>
+ <div class="action-container">
+ <paper-button class="action-button" id="confirmButton"
+ on-click="onConfirm_" consent-confirmation>
+ $i18n{syncConfirmationConfirmLabel}
+ </paper-button>
+ <paper-button on-click="onUndo_" hidden="[[isConsentBump_]]">
+ $i18n{syncConfirmationUndoLabel}
+ </paper-button>
+ <paper-button id="settingsButton" on-click="onGoToSettings_"
+ hidden="[[isConsentBump_]]" consent-confirmation>
+ $i18n{syncConfirmationSettingsLabel}
+ </paper-button>
+ <paper-button on-click="onMoreOptions_" hidden="[[!isConsentBump_]]">
+ $i18n{syncConfirmationMoreOptionsLabel}
+ </paper-button>
+ </div>
+ </div>
+
+ <!-- More options dialog for the consent bump -->
+ <template is="dom-if" if="[[showMoreOptions_]]">
+ <div id="options-container">
+ <h3 id="options-heading" consent-description>
+ $i18n{syncConfirmationOptionsTitle}
+ </h3>
+ <div id="options-description" class="subtitle-text"
+ consent-description>
+ $i18n{syncConfirmationOptionsSubtitle}
+ </div>
+ <paper-radio-group selected="reviewSettings"
+ selectable="cr-radio-button">
+ <cr-radio-button name="reviewSettings">
+ $i18n{syncConfirmationOptionsReviewSettingsTitle}
+ </cr-radio-button>
+ <cr-radio-button name="noChanges">
+ $i18n{syncConfirmationOptionsMakeNoChangesTitle}
+ <div class="subtitle-text">
+ $i18n{syncConfirmationOptionsMakeNoChangesSubtitle}
+ </div>
+ </cr-radio-button>
+ <cr-radio-button name="defaultSettings">
+ <div consent-description>
+ $i18n{syncConfirmationOptionsUseDefaultTitle}
+ </div>
+ <div class="subtitle-text" consent-description>
+ $i18n{syncConfirmationOptionsUseDefaultSubtitle}
+ </div>
+ </cr-radio-button>
+ </paper-radio-group>
+ <div class="action-container">
+ <paper-button class="action-button" on-click="onOK_"
+ consent-confirmation>
+ $i18n{syncConfirmationOptionsConfirmLabel}
+ </paper-button>
+ <paper-button on-click="onBack_">
+ $i18n{syncConfirmationOptionsBackLabel}
+ </paper-button>
+ </div>
+ </div>
+ </template>
</div>
</template>
<script src="sync_confirmation_app.js"></script>
diff --git a/chromium/chrome/browser/resources/signin/dice_sync_confirmation/sync_confirmation_app.js b/chromium/chrome/browser/resources/signin/dice_sync_confirmation/sync_confirmation_app.js
index fe19b8f3dd4..f083c378e44 100644
--- a/chromium/chrome/browser/resources/signin/dice_sync_confirmation/sync_confirmation_app.js
+++ b/chromium/chrome/browser/resources/signin/dice_sync_confirmation/sync_confirmation_app.js
@@ -5,9 +5,28 @@
Polymer({
is: 'sync-confirmation-app',
- listeners: {
- // This is necessary since the settingsLink element is inserted by i18nRaw.
- 'settingsLink.tap': 'onGoToSettings_'
+ properties: {
+ /** @private */
+ isConsentBump_: {
+ type: Boolean,
+ value: function() {
+ return window.location.search.includes('consent-bump');
+ },
+ },
+
+ /** @private */
+ showMoreOptions_: {
+ type: Boolean,
+ value: false,
+ },
+
+ /** @private */
+ accountImageSrc_: {
+ type: String,
+ value: function() {
+ return loadTimeData.getString('accountPictureUrl');
+ },
+ },
},
/** @private {?sync.confirmation.SyncConfirmationBrowserProxy} */
@@ -80,5 +99,32 @@ Polymer({
.map(element => element.innerHTML.trim());
assert(consentDescription);
return consentDescription;
- }
+ },
+
+ /** @private */
+ onOK_: function(e) {
+ switch (this.$$('paper-radio-group').selected) {
+ case 'reviewSettings':
+ this.onGoToSettings_(e);
+ break;
+ case 'noChanges':
+ this.onUndo_();
+ break;
+ case 'defaultSettings':
+ this.onConfirm_(e);
+ break;
+ }
+ assertNotReached();
+ },
+
+ /** @private */
+ onMoreOptions_: function() {
+ this.showMoreOptions_ = true;
+ },
+
+ /** @private */
+ onBack_: function() {
+ this.showMoreOptions_ = false;
+ },
+
});
diff --git a/chromium/chrome/browser/resources/signin/signin_email_confirmation/signin_email_confirmation.html b/chromium/chrome/browser/resources/signin/signin_email_confirmation/signin_email_confirmation.html
index 7803717ef85..4936de02de1 100644
--- a/chromium/chrome/browser/resources/signin/signin_email_confirmation/signin_email_confirmation.html
+++ b/chromium/chrome/browser/resources/signin/signin_email_confirmation/signin_email_confirmation.html
@@ -3,8 +3,9 @@
<head>
<meta charset="utf-8">
<link rel="import" href="chrome://resources/html/polymer.html">
+ <link rel="import" href="chrome://resources/cr_elements/cr_radio_button/cr_radio_button.html">
+ <link rel="import" href="chrome://resources/cr_elements/paper_button_style_css.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
- <link rel="import" href="chrome://resources/polymer/v1_0/paper-radio-button/paper-radio-button.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-radio-group/paper-radio-group.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/color.html">
<link rel="import" href="signin_shared_css.html">
@@ -12,7 +13,7 @@
<link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="chrome://resources/html/load_time_data.html">
<link rel="import" href="chrome://resources/html/util.html">
- <style is="custom-style" include="signin-dialog-shared">
+ <style is="custom-style" include="signin-dialog-shared paper-button-style">
.container {
/* The sign-in confirmation dialog uses a width that is larger than
* the other sign-in dialogs to fit cases when the user has an email
@@ -65,8 +66,9 @@
$i18n{signinEmailConfirmationTitle}
</div>
<div class="details">
- <paper-radio-group selected="createNewUser">
- <paper-radio-button id="createNewUserRadioButton"
+ <paper-radio-group selected="createNewUser"
+ selectable="cr-radio-button">
+ <cr-radio-button id="createNewUserRadioButton"
name="createNewUser">
<div class="radio-button-title-container">
$i18n{signinEmailConfirmationCreateProfileButtonTitle}
@@ -75,8 +77,8 @@
id="createNewUserRadioButtonSubtitle">
$i18n{signinEmailConfirmationCreateProfileButtonSubtitle}
</div>
- </paper-radio-button>
- <paper-radio-button id="startSyncRadioButton" name="startSync">
+ </cr-radio-button>
+ <cr-radio-button id="startSyncRadioButton" name="startSync">
<div class="radio-button-title-container">
$i18n{signinEmailConfirmationStartSyncButtonTitle}
</div>
@@ -84,14 +86,14 @@
id="startSyncRadioButtonSubtitle">
$i18n{signinEmailConfirmationStartSyncButtonSubtitle}
</div>
- </paper-radio-button>
+ </cr-radio-button>
</paper-radio-group>
</div>
<div class="action-container">
- <paper-button class="primary-action" id="confirmButton">
+ <paper-button class="action-button" id="confirmButton">
$i18n{signinEmailConfirmationConfirmLabel}
</paper-button>
- <paper-button class="secondary-action" id="closeButton">
+ <paper-button id="closeButton">
$i18n{signinEmailConfirmationCloseLabel}
</paper-button>
</div>
diff --git a/chromium/chrome/browser/resources/signin/signin_error/signin_error.html b/chromium/chrome/browser/resources/signin/signin_error/signin_error.html
index 2e050a874f9..b85910d8d9e 100644
--- a/chromium/chrome/browser/resources/signin/signin_error/signin_error.html
+++ b/chromium/chrome/browser/resources/signin/signin_error/signin_error.html
@@ -2,6 +2,7 @@
<html i18n-values="dir:textdirection;lang:language" dir="$i18n{textdirection}">
<head>
<meta charset="utf-8">
+ <link rel="import" href="chrome://resources/cr_elements/paper_button_style_css.html">
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/color.html">
@@ -10,7 +11,7 @@
<link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="chrome://resources/html/load_time_data.html">
<link rel="import" href="chrome://resources/html/util.html">
- <style is="custom-style" include="signin-dialog-shared">
+ <style is="custom-style" include="signin-dialog-shared paper-button-style">
.details {
line-height: 20px;
margin-bottom: 8px;
@@ -82,13 +83,13 @@
<p>$i18n{profileBlockedRemoveProfileSuggestion}</p>
</div>
<div class="action-container">
- <paper-button class="primary-action" id="switchButton">
+ <paper-button class="action-button" id="switchButton">
$i18n{signinErrorSwitchLabel}
</paper-button>
- <paper-button class="secondary-action" id="closeButton">
+ <paper-button id="closeButton">
$i18n{signinErrorCloseLabel}
</paper-button>
- <paper-button class="primary-action" id="confirmButton" hidden>
+ <paper-button id="confirmButton" hidden>
$i18n{signinErrorOkLabel}
</paper-button>
</div>
diff --git a/chromium/chrome/browser/resources/signin/signin_shared_css.html b/chromium/chrome/browser/resources/signin/signin_shared_css.html
index aa41be3d512..4efc337a197 100644
--- a/chromium/chrome/browser/resources/signin/signin_shared_css.html
+++ b/chromium/chrome/browser/resources/signin/signin_shared_css.html
@@ -12,37 +12,6 @@
padding: 0;
}
- paper-button {
- font-weight: 500;
- line-height: 16px;
- margin: 0;
- padding: 8px 16px;
- }
-
- paper-button.primary-action {
- --paper-button-flat-keyboard-focus: {
- background: rgb(58, 117, 215);
- font-weight: 500;
- };
- background: var(--google-blue-500);
- color: white;
- }
-
- paper-button.secondary-action {
- --paper-button-flat-keyboard-focus: {
- background: rgba(0, 0, 0, .12);
- font-weight: 500;
- };
- color: var(--paper-grey-600);
- }
-
- paper-radio-button {
- --paper-radio-button-checked-color: var(--google-blue-500);
- --paper-radio-button-ink-size: 40px;
- --paper-radio-button-label-spacing: 16px;
- --paper-radio-button-unchecked-color: var(--paper-grey-600);
- }
-
.container {
background-color: white;
color: #333;
diff --git a/chromium/chrome/browser/resources/signin/sync_confirmation/sync_confirmation.html b/chromium/chrome/browser/resources/signin/sync_confirmation/sync_confirmation.html
index 74acb08a2dd..b689de42ad6 100644
--- a/chromium/chrome/browser/resources/signin/sync_confirmation/sync_confirmation.html
+++ b/chromium/chrome/browser/resources/signin/sync_confirmation/sync_confirmation.html
@@ -2,13 +2,14 @@
<html dir="$i18n{textdirection}" lang="$i18n{language}">
<head>
<meta charset="utf-8">
+ <link rel="import" href="chrome://resources/cr_elements/paper_button_style_css.html">
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/color.html">
<link rel="import" href="signin_shared_css.html">
<link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css">
<link rel="stylesheet" href="sync_confirmation.css"></link>
- <style is="custom-style" include="signin-dialog-shared">
+ <style is="custom-style" include="signin-dialog-shared paper-button-style">
<if expr="is_macosx or is_linux">
#undoButton {
-webkit-margin-end: 8px;
@@ -98,11 +99,11 @@
</div>
</div>
<div class="action-container">
- <paper-button class="primary-action" id="confirmButton"
+ <paper-button class="action-button" id="confirmButton"
consent-confirmation>
$i18n{syncConfirmationConfirmLabel}
</paper-button>
- <paper-button class="secondary-action" id="undoButton">
+ <paper-button id="undoButton">
$i18n{syncConfirmationUndoLabel}
</paper-button>
</div>
diff --git a/chromium/chrome/browser/resources/snippets_internals.html b/chromium/chrome/browser/resources/snippets_internals.html
deleted file mode 100644
index b3d3624d8a4..00000000000
--- a/chromium/chrome/browser/resources/snippets_internals.html
+++ /dev/null
@@ -1,251 +0,0 @@
-<!--
-Copyright 2016 The Chromium Authors. All rights reserved.
-Use of this source code is governed by a BSD-style license that can be
-found in the LICENSE file.
--->
-<!DOCTYPE html>
-<meta charset="utf-8">
-<if expr="is_android">
-<meta name="viewport" content="width=device-width, initial-scale=1.0">
-</if>
-<title>Snippets Internals</title>
-<link rel="stylesheet" href="chrome://resources/css/text_defaults.css">
-<link rel="stylesheet" href="snippets_internals.css">
-<script src="chrome://resources/js/cr.js"></script>
-<script src="chrome://resources/js/load_time_data.js"></script>
-<script src="chrome://resources/js/jstemplate_compiled.js"></script>
-<script src="chrome://resources/js/util.js"></script>
-<script src="snippets_internals.js"></script>
-<script src="strings.js"></script>
-
-<div id="info">
- <div>
- <h2>Properties</h2>
- <table class="section-details">
- <tr>
- <td class="name">Article Suggestions enabled
- <td id="flag-article-suggestions" class="value">
- <tr>
- <td class="name">Recent Tab Suggestions enabled
- <td id="flag-recent-offline-tab-suggestions" class="value">
- <tr>
- <td class="name">Offlining Recent Tabs enabled
- <td id="flag-offlining-recent-pages-feature" class="value">
- <tr>
- <td class="name">Asset Download Suggestions enabled
- <td id="flag-asset-download-suggestions" class="value">
- <tr>
- <td class="name">Offline Page Download Suggestions enabled
- <td id="flag-offline-page-download-suggestions" class="value">
- <tr>
- <td class="name">Bookmark Suggestions enabled
- <td id="flag-bookmark-suggestions" class="value">
- <tr>
- <td class="name">Physical Web Page Suggestions enabled
- <td id="flag-physical-web-page-suggestions" class="value">
- <tr>
- <td class="name">Physical Web enabled
- <td id="flag-physical-web" class="value">
- <tr>
- <td class="name">Snippets type
- <td id="switch-personalized" class="value">
- <tr>
- <td class="name">Snippets fetch URL
- <td id="switch-fetch-url" class="value">
- <tr>
- <td class="name">Server-provided experiment IDs
- <td id="experiment-ids" class="value">
- </table>
- </div>
-
- <div>
- <h2>UserClassifier</h2>
- <table class="section-details">
- <tr>
- <td class="name">User class
- <td id="user-class" class="value">
- <tr>
- <td class="name">Estimated average time to open NTP
- <td id="avg-time-to-open-ntp" class="value">
- <tr>
- <td class="name">Estimated average time to show suggestions
- <td id="avg-time-to-show" class="value">
- <tr>
- <td class="name">Estimated average time to use suggestions
- <td id="avg-time-to-use" class="value">
- </table>
- <button id="clear-classification" type="button">
- Clear my classification
- </button>
- </div>
-
- <div id="ranker">
- <h2>CategoryRanker</h2>
- <table class="section-details">
- <tr jsselect="list" style="display:none">
- <td jscontent="label">
- <td jscontent="content" class="value">
- </tr>
- </table>
- </div>
-
- <div id="snippets">
- <h2>ContentSuggestionsService</h2>
- <div class="forms">
- <div>
- <button id="submit-download" type="button">Reload suggestions</button>
- </div>
- <div>
- <button id="debug-log-dump" type="button">Dump the debug log</button>
- </div>
- <div>
- <button type="button" class="submit-clear-cached-suggestions">
- Clear cached suggestions
- </button>
- </div>
- </div>
- </div>
-
- <div id="remote-content-suggestions">
- <h2>Remote content suggestions</h2>
- <table class="section-details">
- <tr>
- <td class="name">Last Fetch Status
- <td id="remote-status" class="value">
- <tr>
- <td class="name">Last Fetch Type
- <td id="remote-authenticated" class="value">
- <tr>
- <td class="name">Last Background Fetch Time:
- <td id="last-background-fetch-time-label" class="value">
- </table>
- <div>
- <button id="background-fetch-button" type="button">
- Fetch remote suggestions in the background in 2 seconds
- </button>
- </div>
- <div>
- <button id="push-dummy-suggestion-10-seconds-button" type="button">
- Push dummy suggestion in 10 seconds
- </button>
- </div>
- <div>
- <button id="last-json-button" type="button">Show the last JSON</button>
- </div>
- <div id="last-json-container" class="hidden">
- <div id="last-json-text"></div>
- <button id="last-json-dump" type="button">Dump the last JSON</button>
- </div>
- </div>
-
- <div id="notifications">
- <h2>Notifications</h2>
- <div>
- <button id="reset-notifications-state-button" type="button">
- Reset notifications state
- </button>
- </div>
-
- <div id="content-suggestions">
- <h2>Content suggestions by category
- <span class="detail">(click for details)</span>
- <button id="submit-dump" type="button">Dump the list</button>
- </h2>
- <div jsselect="list" style="display:none">
- <div>
- <h3 style="margin-bottom: 0px; padding-bottom: 0px;">
- <span jscontent="title"></span>
- <span class="detail">
- (id = <span jscontent="categoryId"></span>,
- <span jscontent="status"></span>)
- </span>
- </h3>
- </div>
- <div class="vertical-buttons">
- <button jsvalues="category-id:categoryId" type="button"
- class="toggle-dismissed-suggestions">
- Show dismissed suggestions
- </button>
- <button jsvalues="category-id:categoryId" type="button"
- class="submit-clear-dismissed-suggestions">
- Clear dismissed suggestions
- </button>
- </div>
-
- <table class="section-details">
- <tr jsselect="suggestions" style="display:none">
- <td class="title-link">
- <span class="hidden-toggler content-suggestion-title"
- jsvalues="hidden-id:id">
- <span jscontent="title"></span>&gt;&gt;
- </span>
- <div jsvalues="id:id" class="content-suggestion-detail hidden">
- <table>
- <tr>
- <td>ID
- <td jscontent="idWithinCategory">
- <tr>
- <td>URL
- <td><a class="url" jsvalues="href:url" jscontent="url"></a>
- <tr>
- <td>URL with favicon
- <td>
- <a class="url" jsvalues="href:urlWithFavicon"
- jscontent="urlWithFavicon"></a>
- <tr>
- <td>Snippet text
- <td jscontent="snippetText">
- <tr>
- <td>Publish date
- <td class="expiry">
- <span class="date" jscontent="publishDate"></span>
- <tr>
- <td>Publisher name
- <td jscontent="publisherName">
- <tr>
- <td>Score
- <td jscontent="score">
- </table>
- </div>
- </table>
-
- <table jsvalues="id:dismissedContainerId"
- class="section-details hidden">
- <thead>
- <tr>
- <th style="text-align:left">Dismissed suggestions
- </thead>
- <tr jsselect="dismissedSuggestions" style="display:none">
- <td class="title-link">
- <span class="hidden-toggler content-suggestion-title"
- jsvalues="hidden-id:id">
- <span jscontent="title"></span> (dismissed)&gt;&gt;
- </span>
- <div jsvalues="id:id" class="content-suggestion-detail hidden">
- <table>
- <tr>
- <td>ID
- <td jscontent="suggestionId">
- <tr>
- <td>URL
- <td><a class="url" jsvalues="href:url" jscontent="url"></a>
- <tr>
- <td>Snippet text
- <td jscontent="snippetText">
- <tr>
- <td>Publish date
- <td class="expiry">
- <span class="date" jscontent="publishDate"></span>
- <tr>
- <td>Publisher name
- <td jscontent="publisherName">
- <tr>
- <td>Score
- <td jscontent="score">
- </table>
- </div>
- </table>
- </div>
- <div class="detail" id="content-suggestions-empty"></div>
- </div>
-</div>
diff --git a/chromium/chrome/browser/resources/snippets_internals.js b/chromium/chrome/browser/resources/snippets_internals.js
deleted file mode 100644
index e0c0acb275b..00000000000
--- a/chromium/chrome/browser/resources/snippets_internals.js
+++ /dev/null
@@ -1,229 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('chrome.SnippetsInternals', function() {
- 'use strict';
-
- // Stores the list of suggestions we received in receiveContentSuggestions.
- var lastSuggestions = [];
- var lastDebugLog = '';
-
- function initialize() {
- $('submit-download').addEventListener('click', function(event) {
- chrome.send('download');
- event.preventDefault();
- });
-
- $('submit-dump').addEventListener('click', function(event) {
- downloadJson(JSON.stringify(lastSuggestions, null, 2));
- event.preventDefault();
- });
-
- $('debug-log-dump').addEventListener('click', function(event) {
- downloadDebugLog(lastDebugLog);
- event.preventDefault();
- });
-
- $('last-json-button').addEventListener('click', function(event) {
- $('last-json-container').classList.toggle('hidden');
- });
-
- $('last-json-dump').addEventListener('click', function(event) {
- downloadJson($('last-json-text').innerText);
- event.preventDefault();
- });
-
- $('clear-classification').addEventListener('click', function(event) {
- chrome.send('clearClassification');
- event.preventDefault();
- });
-
- $('background-fetch-button').addEventListener('click', function(event) {
- chrome.send('fetchRemoteSuggestionsInTheBackgroundIn2Seconds');
- event.preventDefault();
- });
-
- $('push-dummy-suggestion-10-seconds-button')
- .addEventListener('click', function(event) {
- chrome.send('pushDummySuggestionIn10Seconds');
- event.preventDefault();
- });
-
- $('reset-notifications-state-button')
- .addEventListener('click', function(event) {
- chrome.send('resetNotificationsState');
- event.preventDefault();
- });
-
- window.addEventListener('focus', refreshContent);
- window.setInterval(refreshContent, 1000);
-
- chrome.send('initializationCompleted');
- refreshContent();
- }
-
- function receiveProperty(propertyId, value) {
- $(propertyId).textContent = value;
- }
-
- function receiveContentSuggestions(categoriesList) {
- lastSuggestions = categoriesList;
- displayList(categoriesList, 'content-suggestions', 'hidden-toggler');
-
- var clearCachedButtons =
- document.getElementsByClassName('submit-clear-cached-suggestions');
- for (var button of clearCachedButtons) {
- button.addEventListener('click', onClearCachedButtonClicked);
- }
-
- var clearDismissedButtons =
- document.getElementsByClassName('submit-clear-dismissed-suggestions');
- for (var button of clearDismissedButtons) {
- button.addEventListener('click', onClearDismissedButtonClicked);
- }
-
- var toggleDismissedButtons =
- document.getElementsByClassName('toggle-dismissed-suggestions');
- for (var button of toggleDismissedButtons) {
- button.addEventListener('click', onToggleDismissedButtonClicked);
- }
- }
-
- function onClearCachedButtonClicked(event) {
- event.preventDefault();
- chrome.send('clearCachedSuggestions');
- }
-
- function onClearDismissedButtonClicked(event) {
- event.preventDefault();
- var id = parseInt(event.currentTarget.getAttribute('category-id'), 10);
- chrome.send('clearDismissedSuggestions', [id]);
- }
-
- function onToggleDismissedButtonClicked(event) {
- event.preventDefault();
- var id = parseInt(event.currentTarget.getAttribute('category-id'), 10);
- var table = $('dismissed-suggestions-' + id);
- table.classList.toggle('hidden');
- chrome.send(
- 'toggleDismissedSuggestions',
- [id, !table.classList.contains('hidden')]);
- }
-
- function receiveJson(json) {
- var trimmed = json.trim();
- var hasContent = (trimmed && trimmed != '{}');
-
- if (hasContent) {
- receiveProperty('last-json-text', trimmed);
- $('last-json').classList.remove('hidden');
- } else {
- $('last-json').classList.add('hidden');
- }
- }
-
- function receiveDebugLog(debugLog) {
- if (!debugLog) {
- lastDebugLog = 'empty';
- } else {
- lastDebugLog = debugLog;
- }
- }
-
- function receiveClassification(
- userClass, timeToOpenNTP, timeToShow, timeToUse) {
- receiveProperty('user-class', userClass);
- receiveProperty('avg-time-to-open-ntp', timeToOpenNTP);
- receiveProperty('avg-time-to-show', timeToShow);
- receiveProperty('avg-time-to-use', timeToUse);
- }
-
- function receiveRankerDebugData(itemsList) {
- displayList(itemsList, 'ranker', 'no-togler');
- }
-
- function receiveLastRemoteSuggestionsBackgroundFetchTime(
- lastRemoteSuggestionsBackgroundFetchTime) {
- receiveProperty(
- 'last-background-fetch-time-label',
- lastRemoteSuggestionsBackgroundFetchTime);
- }
-
- function receiveWhetherSuggestionPushingPossible(possible) {
- $('push-dummy-suggestion-10-seconds-button').disabled = !possible;
- }
-
- function downloadJson(json) {
- // Redirect the browser to download data in |json| as a file "snippets.json"
- // (Setting Content-Disposition: attachment via a data: URL is not possible;
- // create a link with download attribute and simulate a click, instead.)
- var link = document.createElement('a');
- link.download = 'snippets.json';
- link.href = 'data:application/json,' + encodeURI(json);
- link.click();
- }
-
- function downloadDebugLog(debugLog) {
- // Redirect the browser to download data in |debugLog| as a file
- // "debug_log.txt" (Setting Content-Disposition: attachment via a data: URL
- // is not possible; create a link with download attribute and simulate a
- // click, instead.)
- var link = document.createElement('a');
- link.download = 'debug_log.txt';
- link.href = 'data:text/plain,' + encodeURI(debugLog);
- link.click();
- }
-
- function refreshContent() {
- chrome.send('refreshContent');
- }
-
- function toggleHidden(event) {
- var id = event.currentTarget.getAttribute('hidden-id');
- $(id).classList.toggle('hidden');
- }
-
- function displayList(object, domId, toggleClass) {
- jstProcess(new JsEvalContext(object), $(domId));
-
- var text;
- var display;
-
- if (object.list.length > 0) {
- text = '';
- display = 'inline';
- } else {
- text = 'The list is empty.';
- display = 'none';
- }
-
- if ($(domId + '-empty'))
- $(domId + '-empty').textContent = text;
- if ($(domId + '-clear'))
- $(domId + '-clear').style.display = display;
-
- var links = document.getElementsByClassName(toggleClass);
- for (var link of links) {
- link.addEventListener('click', toggleHidden);
- }
- }
-
- // Return an object with all of the exports.
- return {
- initialize: initialize,
- receiveProperty: receiveProperty,
- receiveContentSuggestions: receiveContentSuggestions,
- receiveJson: receiveJson,
- receiveDebugLog: receiveDebugLog,
- receiveClassification: receiveClassification,
- receiveRankerDebugData: receiveRankerDebugData,
- receiveLastRemoteSuggestionsBackgroundFetchTime:
- receiveLastRemoteSuggestionsBackgroundFetchTime,
- receiveWhetherSuggestionPushingPossible:
- receiveWhetherSuggestionPushingPossible,
- };
-});
-
-document.addEventListener(
- 'DOMContentLoaded', chrome.SnippetsInternals.initialize);
diff --git a/chromium/chrome/browser/resources/snippets_internals/.eslintrc.js b/chromium/chrome/browser/resources/snippets_internals/.eslintrc.js
new file mode 100644
index 00000000000..2d14fd3414c
--- /dev/null
+++ b/chromium/chrome/browser/resources/snippets_internals/.eslintrc.js
@@ -0,0 +1,13 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module.exports = {
+ 'env': {
+ 'browser': true,
+ 'es6': true,
+ },
+ 'rules': {
+ 'no-var': 'error',
+ },
+}; \ No newline at end of file
diff --git a/chromium/chrome/browser/resources/snippets_internals/BUILD.gn b/chromium/chrome/browser/resources/snippets_internals/BUILD.gn
new file mode 100644
index 00000000000..c636d01a7e6
--- /dev/null
+++ b/chromium/chrome/browser/resources/snippets_internals/BUILD.gn
@@ -0,0 +1,24 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":snippets_internals",
+ ]
+}
+
+js_library("snippets_internals") {
+ deps = [
+ "//third_party/jstemplate:jstemplate",
+ "//ui/webui/resources/js:util",
+ ]
+ extra_deps =
+ [ "//chrome/browser/ui/webui/snippets_internals:mojo_bindings_js" ]
+ externs_list = [
+ "$root_gen_dir/chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom.externs.js",
+ "$externs_path/mojo.js",
+ ]
+}
diff --git a/chromium/chrome/browser/resources/snippets_internals/OWNERS b/chromium/chrome/browser/resources/snippets_internals/OWNERS
new file mode 100644
index 00000000000..7e6bf66ee54
--- /dev/null
+++ b/chromium/chrome/browser/resources/snippets_internals/OWNERS
@@ -0,0 +1 @@
+file://components/ntp_snippets/OWNERS \ No newline at end of file
diff --git a/chromium/chrome/browser/resources/snippets_internals.css b/chromium/chrome/browser/resources/snippets_internals/snippets_internals.css
index f5fbe251089..a38aab56c67 100644
--- a/chromium/chrome/browser/resources/snippets_internals.css
+++ b/chromium/chrome/browser/resources/snippets_internals/snippets_internals.css
@@ -80,10 +80,12 @@ td.title-link {
}
button {
+ display: block;
min-height: 30px;
}
.vertical-buttons > button {
+ display: inline-block;
float: left;
margin-right: 5px;
max-width: 100px;
diff --git a/chromium/chrome/browser/resources/snippets_internals/snippets_internals.html b/chromium/chrome/browser/resources/snippets_internals/snippets_internals.html
new file mode 100644
index 00000000000..32cbe829a82
--- /dev/null
+++ b/chromium/chrome/browser/resources/snippets_internals/snippets_internals.html
@@ -0,0 +1,274 @@
+<!--
+Copyright 2016 The Chromium Authors. All rights reserved.
+Use of this source code is governed by a BSD-style license that can be
+found in the LICENSE file.
+-->
+
+<!doctype html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Snippets Internals</title>
+ <link rel="stylesheet" href="chrome://resources/css/text_defaults.css">
+ <link rel="stylesheet" href="snippets_internals.css">
+
+ <script src="chrome://resources/js/cr.js"></script>
+ <script src="chrome://resources/js/mojo_bindings.js"></script>
+ <script src="chrome://resources/js/jstemplate_compiled.js"></script>
+ <script src="chrome://resources/js/util.js"></script>
+
+ <script src="snippets_internals.mojom.js"></script>
+ <script src="snippets_internals.js"></script>
+</head>
+
+<body id="info">
+ <!-- Top level properties table. -->
+ <div>
+ <h2>Properties</h2>
+ <table class="section-details">
+ <tr>
+ <td class="name">Article Suggestions enabled</td>
+ <td id="flag-article-suggestions" class="value"></td>
+ </tr>
+ <tr>
+ <td class="name">Offlining Recent Tabs enabled</td>
+ <td id="flag-offlining-recent-pages-feature" class="value"></td>
+ </tr>
+ <tr>
+ <td class="name">Asset Download Suggestions enabled</td>
+ <td id="flag-asset-download-suggestions" class="value"></td>
+ </tr>
+ <tr>
+ <td class="name">Offline Page Download Suggestions enabled</td>
+ <td id="flag-offline-page-download-suggestions" class="value"></td>
+ </tr>
+ <tr>
+ <td class="name">Bookmark Suggestions enabled</td>
+ <td id="flag-bookmark-suggestions" class="value"></td>
+ </tr>
+ <tr>
+ <td class="name">Snippets fetch URL</td>
+ <td id="switch-fetch-url" class="value"></td>
+ </tr>
+ <tr>
+ <td class="name">Server-provided experiment IDs</td>
+ <td id="experiment-ids" class="value"></td>
+ </tr>
+ </table>
+ </div>
+
+ <!-- User classifier table with clear classification button.-->
+ <div>
+ <h2>User Classifier</h2>
+ <table class="section-details">
+ <tr>
+ <td class="name">User class</td>
+ <td id="user-class" class="value"></td>
+ </tr>
+ <tr>
+ <td class="name">Estimated average time to open NTP</td>
+ <td id="avg-time-to-open-ntp" class="value"></td>
+ </tr>
+ <tr>
+ <td class="name">Estimated average time to show suggestions</td>
+ <td id="avg-time-to-show" class="value"></td>
+ </tr>
+ <tr>
+ <td class="name">Estimated average time to use suggestions</td>
+ <td id="avg-time-to-use" class="value"></td>
+ </tr>
+ </table>
+ <button id="clear-classification">
+ Clear my classification
+ </button>
+ </div>
+
+ <!-- Category ranker table, populated dynamically. -->
+ <div>
+ <!-- Template cloned and populated by js. -->
+ <template id="category-ranker-row">
+ <tr>
+ <td class="name"></td>
+ <td class="value"></td>
+ </tr>
+ </template>
+ <h2>Category Ranker</h2>
+ <table class="section-details">
+ <tbody id="category-ranker-table"></tbody>
+ </table>
+ </div>
+
+ <div>
+ <h2>Content Suggestions Service Actions</h2>
+ <div class="forms">
+ <button id="reload-suggestions">Reload suggestions</button>
+ <button id="debug-log-dump">Dump the debug log</button>
+ <button id="clear-cached-suggestions">
+ Clear cached suggestions
+ </button>
+ </div>
+ </div>
+
+ <div id="remote-content-suggestions">
+ <h2>Remote content suggestions</h2>
+ <table class="section-details">
+ <tr>
+ <td class="name">Last Fetch Status</td>
+ <td id="remote-status" class="value"></td>
+ </tr>
+ <tr>
+ <td class="name">Last Fetch Type</td>
+ <td id="remote-authenticated" class="value"></td>
+ </tr>
+ <tr>
+ <td class="name">Last Background Fetch Time:</td>
+ <td id="last-background-fetch-time" class="value"></td>
+ </tr>
+ </table>
+ <button id="background-fetch-button">
+ Fetch remote suggestions in the background in 2 seconds
+ </button>
+ <button id="push-dummy-suggestion">
+ Push dummy suggestion in 10 seconds
+ </button>
+ <button id="last-json-button">Show the last JSON</button>
+ <div id="last-json-container" class="hidden">
+ <div id="last-json-text"></div>
+ <button id="last-json-dump">Dump the last JSON</button>
+ </div>
+ </div>
+
+ <div id="notifications">
+ <h2>Notifications</h2>
+ <button id="reset-notifications-state-button">
+ Reset notifications state
+ </button>
+ </div>
+
+
+ <div id="content-suggestions">
+ <h2>Content suggestions by category
+ <span class="detail">(click for details)</span>
+ <button id="submit-dump">Dump the list</button>
+ </h2>
+
+ <div jsselect="categories" style="display:none">
+ <div>
+ <h3 style="margin-bottom: 0px; padding-bottom: 0px;">
+ <span jscontent="categoryTitle"></span>
+ <span class="detail">
+ (id = <span jscontent="categoryId"></span>,
+ <span jscontent="status"></span>)
+ </span>
+ </h3>
+ </div>
+ <div class="vertical-buttons">
+ <button jsvalues="data-category-id:categoryId"
+ class="toggle-dismissed-suggestions">
+ Show dismissed suggestions
+ </button>
+ <button jsvalues="data-category-id:categoryId"
+ class="submit-clear-dismissed-suggestions">
+ Clear dismissed suggestions
+ </button>
+ </div>
+
+ <!-- Suggestions -->
+ <table class="section-details">
+ <tr jsselect="suggestions" style="display:none">
+ <td class="title-link">
+ <span class="hidden-toggler content-suggestion-title"
+ jsvalues="hidden-id:suggestionId">
+ <span jscontent="suggestionTitle"></span>&gt;&gt;
+ </span>
+ <div jsvalues="id:suggestionId" class="content-suggestion-detail hidden">
+ <table>
+ <tr>
+ <td>ID</td>
+ <td jscontent="suggestionIdWithinCategory"></td>
+ </tr>
+ <tr>
+ <td>URL</td>
+ <td><a class="url" jsvalues="href:url" jscontent="url"></a></td>
+ </tr>
+ <tr>
+ <td>URL with favicon</td>
+ <td>
+ <a class="url" jsvalues="href:faviconUrl"
+ jscontent="faviconUrl"></a>
+ </td>
+ </tr>
+ <tr>
+ <td>Snippet text</td>
+ <td jscontent="snippet"></td>
+ </tr>
+ <tr>
+ <td>Publish date</td>
+ <td class="expiry"></td>
+ <span class="date" jscontent="publishDate"></span>
+ </td>
+ </tr>
+ <tr>
+ <td>Publisher name</td>
+ <td jscontent="publisherName"></td>
+ </tr>
+ <tr>
+ <td>Score</td>
+ <td jscontent="score"></td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+ </table>
+
+ <!-- Dismissed suggestions -->
+ <table jsvalues="id: 'dismissed-category-' + categoryId"
+ class="section-details hidden">
+ <thead>
+ <tr>
+ <th style="text-align:left">Dismissed suggestions
+ </thead>
+ <tr jsselect="dismissedSuggestions" style="display:none">
+ <td class="title-link">
+ <span class="hidden-toggler content-suggestion-title"
+ jsvalues="hidden-id:suggestionId">
+ <span jscontent="suggestionTitle"></span> (dismissed)&gt;&gt;
+ </span>
+ <div jsvalues="id:suggestionId" class="content-suggestion-detail hidden">
+ <table>
+ <tr>
+ <td>ID</td>
+ <td jscontent="suggestionIdWithinCategory"></td>
+ </tr>
+ <tr>
+ <td>URL</td>
+ <td><a class="url" jsvalues="href:url" jscontent="url"></a></td>
+ </tr>
+ <tr>
+ <td>Snippet text</td>
+ <td jscontent="snippet"></td>
+ </tr>
+ <tr>
+ <td>Publish date</td>
+ <td class="expiry">
+ <span class="date" jscontent="publishDate"></span>
+ </td>
+ </tr>
+ <tr>
+ <td>Publisher name</td>
+ <td jscontent="publisherName"></td>
+ </tr>
+ <tr>
+ <td>Score</td>
+ <td jscontent="score"></td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div class="detail" id="content-suggestions-empty"></div>
+ </div>
+</body>
diff --git a/chromium/chrome/browser/resources/snippets_internals/snippets_internals.js b/chromium/chrome/browser/resources/snippets_internals/snippets_internals.js
new file mode 100644
index 00000000000..6b28f635f34
--- /dev/null
+++ b/chromium/chrome/browser/resources/snippets_internals/snippets_internals.js
@@ -0,0 +1,323 @@
+// 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.
+
+'use strict';
+
+/** @type {snippetsInternals.mojom.PageHandlerPtr} */
+let pageHandler = null;
+
+/** @type {snippetsInternals.mojom.PagePtr} */
+let page = null;
+
+/* Javascript module for chrome://snippets-internals. */
+(function() {
+
+/* Utility functions*/
+
+/**
+ * Sets all the properties contained in the mapping in the page.
+ * property map {id -> value}.
+ * @param {Map} propertyMap Property name to value mapping.
+ */
+function setPropertiesInPage(propertyMap) {
+ propertyMap.forEach(function(value, field) {
+ setPropertyInPage(field, value);
+ });
+}
+
+/**
+ * Sets the given value as textContent for the given field.
+ * @param {string} field Id of the element to set the property on.
+ * @param {string} value Property to be set in the page.
+ */
+function setPropertyInPage(field, value) {
+ $(field).textContent = value;
+}
+
+/**
+ * Downloads the given data under filename with the given datatype.
+ * Acceptable values for data type include: text/plain, application/json, etc.
+ * @param {string} fileName Name of the file to download.
+ * @param {string} dataType The content-type to download.
+ * @param {string} data The data to download.
+ */
+function downloadData(fileName, dataType, data) {
+ let dataToReport = data;
+ if (data === '') {
+ dataToReport = 'None';
+ }
+ const link = document.createElement('a');
+ link.download = fileName;
+ link.href = 'data:' + dataType + ',' + encodeURI(dataToReport);
+ link.click();
+}
+
+/**
+ * Wrapper funciton for downloadData that stringifies json.
+ * @param {string} fileName Name of file to download.
+ * @param {string} data JSON data to download.
+ */
+function downloadJson(fileName, data) {
+ downloadData(fileName, 'application/json', data);
+}
+
+/**
+ * Clears children of the given domId.
+ * @param {string} domId Id of the DOM element to be cleared.
+ */
+function clearChildrenForId(domId) {
+ const parent = $(domId);
+ while (parent.firstChild) {
+ parent.removeChild(parent.firstChild);
+ }
+}
+
+/* Page functions, as the elements appear of the page. */
+function updateGeneralProperties() {
+ pageHandler.getGeneralProperties().then(
+ response => setPropertiesInPage(response.properties));
+}
+
+function getUserClassifierProperties() {
+ pageHandler.getUserClassifierProperties().then(
+ response => setPropertiesInPage(response.properties));
+}
+
+function getCategoryRankerProperties() {
+ pageHandler.getCategoryRankerProperties().then(function(response) {
+ const domId = 'category-ranker-table';
+ clearChildrenForId(domId);
+
+ const table = $(domId);
+ const rowTemplate = $('category-ranker-row');
+ response.properties.forEach(function(value, field) {
+ const row = document.importNode(rowTemplate.content, true);
+ const td = row.querySelectorAll('td');
+
+ td[0].textContent = field;
+ td[1].textContent = value;
+ table.appendChild(row);
+ });
+ });
+}
+
+/* Check if pushing dummy suggestions is possible. */
+function checkIfPushingDummySuggestionPossible() {
+ pageHandler.isPushingDummySuggestionPossible().then(function(response) {
+ $('push-dummy-suggestion').disabled = !response.result;
+ });
+}
+
+/* Retrieve the remote content suggestions properties. */
+function getRemoteContentSuggestionsProperties() {
+ pageHandler.getRemoteContentSuggestionsProperties().then(function(response) {
+ setPropertiesInPage(response.properties);
+ });
+}
+
+/* Retrieve suggestions, ordered by category. */
+function getSuggestionsByCategory() {
+ pageHandler.getSuggestionsByCategory().then(function(response) {
+ const domId = 'content-suggestions';
+ const toggleClass = 'hidden-toggler';
+
+ jstProcess(new JsEvalContext(response), $(domId));
+
+ let text;
+ let display;
+
+ if (response.categories.length > 0) {
+ text = '';
+ display = 'inline';
+ } else {
+ text = 'The list is empty.';
+ display = 'none';
+ }
+
+ const emptyNode = $(`${domId}-empty`);
+ if (emptyNode)
+ emptyNode.textContent = text;
+
+ const clearNode = $(`${domId}-clear`);
+ if (clearNode)
+ clearNode.style.display = display;
+
+ // Toggle visibility for suggestions.
+ const links = document.getElementsByClassName(toggleClass);
+ for (const link of links) {
+ link.onclick = function(event) {
+ let id = event.currentTarget.getAttribute('hidden-id');
+ $(id).classList.toggle('hidden');
+ };
+ }
+
+ // Clear dismissed suggestions.
+ const clearDismissedButtons =
+ document.getElementsByClassName('submit-clear-dismissed-suggestions');
+ for (const button of clearDismissedButtons) {
+ button.onclick = function(event) {
+ // This is an attribute set on the elements.
+ const id = parseInt(event.currentTarget.dataset.categoryId, 10);
+
+ // Clear the suggestions and hide the table.
+ pageHandler.clearDismissedSuggestions(id);
+ const table = $('dismissed-category-' + id);
+ table.classList.add('hidden');
+
+ // Reload the data.
+ getSuggestionsByCategory();
+ };
+ }
+
+ // Toggle viewing dismissed suggestions.
+ const toggleDismissedButtons =
+ document.getElementsByClassName('toggle-dismissed-suggestions');
+ for (const button of toggleDismissedButtons) {
+ button.onclick = function(event) {
+ // This is an attribute set on the elements.
+ const id = parseInt(event.currentTarget.dataset.categoryId, 10);
+ const table = $('dismissed-category-' + id);
+ table.classList.toggle('hidden');
+ };
+ }
+ });
+}
+
+/* Wrapper functions for setting up page. */
+
+/* Refresh data. */
+function refreshContent() {
+ updateGeneralProperties();
+ getUserClassifierProperties();
+ getCategoryRankerProperties();
+ getRemoteContentSuggestionsProperties();
+ checkIfPushingDummySuggestionPossible();
+}
+
+/* Setup buttons and other event listeners. */
+function setupEventListeners() {
+ $('clear-classification').addEventListener('click', function(event) {
+ pageHandler.clearUserClassifierProperties();
+ });
+
+ $('reload-suggestions').addEventListener('click', function(event) {
+ pageHandler.reloadSuggestions();
+ });
+
+ $('debug-log-dump').addEventListener('click', function(event) {
+ pageHandler.getDebugLog().then(function(response) {
+ let logs = response.debugLog;
+ if (logs === '')
+ logs = 'No data yet. Have you enabled debug logging in chrome://flags?';
+ downloadData('debug_log.txt', 'text/plain', logs);
+ });
+ });
+
+ $('clear-cached-suggestions').addEventListener('click', function(event) {
+ pageHandler.clearCachedSuggestions();
+ });
+
+ $('background-fetch-button').addEventListener('click', function(event) {
+ $('background-fetch-button').disabled = true;
+ pageHandler.fetchSuggestionsInBackground(2).then(function(response) {
+ $('background-fetch-button').disabled = false;
+ $('last-json-container').classList.add('hidden');
+ $('last-json-button').textContent = 'Show the last JSON';
+
+ // After we've fetched, update the page.
+ getRemoteContentSuggestionsProperties();
+ });
+ });
+
+ $('push-dummy-suggestion').addEventListener('click', function(event) {
+ const content = $('push-dummy-suggestion').textContent;
+ $('push-dummy-suggestion').textContent = '...';
+ pageHandler.pushDummySuggestionInBackground(10).then(function(response) {
+ $('push-dummy-suggestion').textContent = content;
+ });
+ });
+
+ $('last-json-button').addEventListener('click', function(event) {
+ pageHandler.getLastJson().then(function(response) {
+ const container = $('last-json-container');
+ container.classList.toggle('hidden');
+
+ $('last-json-text').textContent = response.json;
+ $('last-json-button').textContent =
+ container.classList.contains('hidden') ? 'Show the last JSON' :
+ 'Hide the last JSON';
+ });
+ });
+
+ $('last-json-dump').addEventListener('click', function(event) {
+ pageHandler.getLastJson().then(function(response) {
+ downloadJson('last_snippets.json', response.json);
+ });
+ });
+
+ $('reset-notifications-state-button')
+ .addEventListener('click', function(event) {
+ pageHandler.resetNotificationState();
+ });
+
+ $('reset-notifications-state-button')
+ .addEventListener('click', function(event) {
+ pageHandler.resetNotificationState();
+ });
+
+ $('submit-dump').addEventListener('click', function(event) {
+ pageHandler.getSuggestionsByCategory().then(function(response) {
+ downloadJson('snippets.json', JSON.stringify(response.categories));
+ });
+ });
+
+ window.addEventListener('focus', getSuggestionsByCategory);
+}
+
+/* Represents the js-side of the IPC link. Backend talks to this. */
+// TODO (calamity): Add a closure interface.
+class SnippetsInternalsPageImpl extends snippetsInternals.mojom.PagePtr {
+ constructor(request) {
+ super();
+
+ const page = snippetsInternals.mojom.Page;
+ assert(page !== null);
+
+ this.binding_ = new mojo.Binding(page, this, request);
+ }
+
+ /* Callback for when suggestions change on the backend. */
+ onSuggestionsChanged() {
+ getSuggestionsByCategory();
+ }
+}
+
+/* Main entry point. */
+document.addEventListener('DOMContentLoaded', function() {
+ // Setup frontend mojo.
+ const client = new snippetsInternals.mojom.PagePtr;
+ assert(client);
+ page = new SnippetsInternalsPageImpl(mojo.makeRequest(client));
+
+ // Setup backend mojo.
+ const pageHandlerFactory = new snippetsInternals.mojom.PageHandlerFactoryPtr;
+ Mojo.bindInterface(
+ snippetsInternals.mojom.PageHandlerFactory.name,
+ mojo.makeRequest(pageHandlerFactory).handle);
+
+ // Give backend mojo a reference to frontend mojo.
+ pageHandlerFactory.createPageHandler(client).then((response) => {
+
+ pageHandler = response.handler;
+
+ // Populate value fields.
+ refreshContent();
+ getSuggestionsByCategory();
+ setInterval(refreshContent, 2000);
+
+ // Setup events.
+ setupEventListeners();
+ });
+});
+}());
diff --git a/chromium/chrome/browser/resources/vr/assets/VERSION b/chromium/chrome/browser/resources/vr/assets/VERSION
index 269703f6960..4fc45d1aac5 100644
--- a/chromium/chrome/browser/resources/vr/assets/VERSION
+++ b/chromium/chrome/browser/resources/vr/assets/VERSION
@@ -1,2 +1,2 @@
MAJOR=2
-MINOR=2 \ No newline at end of file
+MINOR=3 \ No newline at end of file
diff --git a/chromium/chrome/browser/resources/vr/assets/google_chrome/normal_gradient.png.sha1 b/chromium/chrome/browser/resources/vr/assets/google_chrome/normal_gradient.png.sha1
index 30a79ad3c93..94c792b9e0d 100644
--- a/chromium/chrome/browser/resources/vr/assets/google_chrome/normal_gradient.png.sha1
+++ b/chromium/chrome/browser/resources/vr/assets/google_chrome/normal_gradient.png.sha1
@@ -1 +1 @@
-bbe1145ae7778d7d50b02c54fd1bf4b62bbc04db \ No newline at end of file
+446510d78dc522fcef45cb88a7a7c4c6d72e17ed \ No newline at end of file
diff --git a/chromium/chrome/browser/resources/webapks/BUILD.gn b/chromium/chrome/browser/resources/webapks/BUILD.gn
new file mode 100644
index 00000000000..2b91364a254
--- /dev/null
+++ b/chromium/chrome/browser/resources/webapks/BUILD.gn
@@ -0,0 +1,18 @@
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//third_party/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":about_webapks",
+ ]
+}
+
+js_library("about_webapks") {
+ deps = [
+ "../../../../ui/webui/resources/js:util",
+ ]
+ externs_list = [ "$externs_path/chrome_send.js" ]
+}
diff --git a/chromium/chrome/browser/resources/webapks/compiled_resources2.gyp b/chromium/chrome/browser/resources/webapks/compiled_resources2.gyp
deleted file mode 100644
index dcb778bf28f..00000000000
--- a/chromium/chrome/browser/resources/webapks/compiled_resources2.gyp
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'about_webapks',
- 'dependencies': [
- '<(EXTERNS_GYP):chrome_send',
- '../../../../ui/webui/resources/js/compiled_resources2.gyp:util',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/welcome/dice_welcome/BUILD.gn b/chromium/chrome/browser/resources/welcome/dice_welcome/BUILD.gn
new file mode 100644
index 00000000000..fd1472df2d5
--- /dev/null
+++ b/chromium/chrome/browser/resources/welcome/dice_welcome/BUILD.gn
@@ -0,0 +1,27 @@
+# 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/closure_compiler/compile_js.gni")
+
+js_type_check("closure_compile") {
+ deps = [
+ ":welcome_app",
+ ":welcome_browser_proxy",
+ ]
+}
+
+js_library("welcome_app") {
+ deps = [
+ ":welcome_browser_proxy",
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/web_animations.js" ]
+}
+
+js_library("welcome_browser_proxy") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/chrome_send.js" ]
+}
diff --git a/chromium/chrome/browser/resources/welcome/dice_welcome/compiled_resources2.gyp b/chromium/chrome/browser/resources/welcome/dice_welcome/compiled_resources2.gyp
deleted file mode 100644
index 9b34e91a70b..00000000000
--- a/chromium/chrome/browser/resources/welcome/dice_welcome/compiled_resources2.gyp
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'welcome_app',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):web_animations',
- 'welcome_browser_proxy',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'welcome_browser_proxy',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(EXTERNS_GYP):chrome_send',
- ],
- 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chromium/chrome/browser/resources/welcome/welcome_win10.html b/chromium/chrome/browser/resources/welcome/welcome_win10.html
index 84b8c28c5a0..c59fa67c598 100644
--- a/chromium/chrome/browser/resources/welcome/welcome_win10.html
+++ b/chromium/chrome/browser/resources/welcome/welcome_win10.html
@@ -27,7 +27,6 @@
<template>
<style include="action-link">
:host {
- --expandable-section-height: 28.375em;
align-items: flex-start;
display: inline-flex;
flex-direction: column;
@@ -36,7 +35,11 @@
transition: opacity 300ms;
}
- :host(.accelerated) {
+ :host .section {
+ --expandable-section-height: 28.375em;
+ }
+
+ :host([is-accelerated]) .section {
--expandable-section-height: 26.375em;
}
@@ -61,8 +64,10 @@
margin: 0 -0.0625em;
}
- .heading {
+ h1 {
font-size: 2.125em;
+ font-weight: normal;
+ margin: 0;
padding-bottom: 2rem;
padding-top: 1rem;
}
@@ -283,7 +288,7 @@
}
</style>
<div class="header-logo" role="presentation"></div>
- <div class="heading" role="heading" aria-level="1">$i18n{headerText}</div>
+ <h1>$i18n{headerText}</h1>
<div class="sections">
<div class$="[[computeClasses(isCombined)]]">
<template is="dom-if" if="[[isCombined]]">
diff --git a/chromium/chrome/browser/resources/welcome/welcome_win10.js b/chromium/chrome/browser/resources/welcome/welcome_win10.js
index 91a5bacbc42..d95e5e1b733 100644
--- a/chromium/chrome/browser/resources/welcome/welcome_win10.js
+++ b/chromium/chrome/browser/resources/welcome/welcome_win10.js
@@ -8,10 +8,19 @@ Polymer({
properties: {
// Determines if the combined variant should be displayed. The combined
// variant includes instructions on how to pin Chrome to the taskbar.
- isCombined: Boolean,
+ isCombined: {
+ type: Boolean,
+ value: false,
+ },
// Indicates if the accelerated flow is enabled.
- isAccelerated: Boolean,
+ isAccelerated: {
+ type: Boolean,
+ value: function() {
+ return loadTimeData.getBoolean('acceleratedFlowEnabled');
+ },
+ reflectToAttribute: true,
+ },
},
receivePinnedState_: function(isPinnedToTaskbar) {
@@ -30,9 +39,6 @@ Polymer({
},
ready: function() {
- this.isCombined = false;
- this.isAccelerated = loadTimeData.getBoolean('accelerated_flow_enabled');
-
// The accelerated flow can be overridden with a query parameter.
const FLOWTYPE_KEY = 'flowtype';
const FLOW_TYPE_MAP = {'regular': false, 'accelerated': true};
@@ -41,16 +47,12 @@ Polymer({
if (params.get(FLOWTYPE_KEY) in FLOW_TYPE_MAP) {
this.isAccelerated = FLOW_TYPE_MAP[params.get(FLOWTYPE_KEY)];
} else {
- console.log(
+ console.error(
'Found invalid value for the \'flowtype\' parameter: %s',
params.get(FLOWTYPE_KEY));
}
}
- // The accelerated flow contains fewer steps. To account for this, toggle
- // the 'accelerated' class which reduces the height of the steps section.
- this.classList.toggle('accelerated', this.isAccelerated);
-
// Asynchronously check if Chrome is pinned to the taskbar.
cr.sendWithPromise('getPinnedToTaskbarState')
.then(this.receivePinnedState_.bind(this));
diff --git a/chromium/chrome/browser/safe_browsing/BUILD.gn b/chromium/chrome/browser/safe_browsing/BUILD.gn
index 4ded375927c..144727b401a 100644
--- a/chromium/chrome/browser/safe_browsing/BUILD.gn
+++ b/chromium/chrome/browser/safe_browsing/BUILD.gn
@@ -27,8 +27,6 @@ static_library("safe_browsing") {
"chrome_cleaner/chrome_cleaner_runner_win.h",
"chrome_cleaner/chrome_cleaner_scanner_results.cc",
"chrome_cleaner/chrome_cleaner_scanner_results.h",
- "chrome_cleaner/chrome_cleaner_state_change_observer_win.cc",
- "chrome_cleaner/chrome_cleaner_state_change_observer_win.h",
"chrome_cleaner/reporter_runner_win.cc",
"chrome_cleaner/reporter_runner_win.h",
"chrome_cleaner/settings_resetter_win.cc",
diff --git a/chromium/chrome/browser/search/BUILD.gn b/chromium/chrome/browser/search/BUILD.gn
index 5422a848f65..62302b2a12d 100644
--- a/chromium/chrome/browser/search/BUILD.gn
+++ b/chromium/chrome/browser/search/BUILD.gn
@@ -9,10 +9,12 @@ action("local_ntp_code_generate") {
header_path = "$target_gen_dir/local_ntp_js_integrity.h"
local_ntp_js = local_ntp_resources + "/local_ntp.js"
voice_js = local_ntp_resources + "/voice.js"
+ custom_bg_js = local_ntp_resources + "/custom_backgrounds.js"
inputs = [
local_ntp_js,
voice_js,
+ custom_bg_js,
]
outputs = [
@@ -23,6 +25,7 @@ action("local_ntp_code_generate") {
"--output_path=" + rebase_path(header_path, root_build_dir),
rebase_path(local_ntp_js, root_build_dir),
rebase_path(voice_js, root_build_dir),
+ rebase_path(custom_bg_js, root_build_dir),
]
}
diff --git a/chromium/chrome/browser/spellchecker/spell_check_host_chrome_impl_mac.cc b/chromium/chrome/browser/spellchecker/spell_check_host_chrome_impl_mac.cc
index 3dbe6978cb5..b6962f215d7 100644
--- a/chromium/chrome/browser/spellchecker/spell_check_host_chrome_impl_mac.cc
+++ b/chromium/chrome/browser/spellchecker/spell_check_host_chrome_impl_mac.cc
@@ -134,11 +134,9 @@ SpellingRequest::SpellingRequest(
void SpellingRequest::RequestRemoteCheck(
SpellingServiceClient* client,
const service_manager::Identity& renderer_identity) {
- BrowserContext* context = NULL;
- content::RenderProcessHost* host =
- content::RenderProcessHost::FromRendererIdentity(renderer_identity);
- if (host)
- context = host->GetBrowserContext();
+ BrowserContext* context =
+ content::BrowserContext::GetBrowserContextForServiceUserId(
+ renderer_identity.user_id());
// |this| may be gone at callback invocation if the owner has been removed.
client->RequestTextCheck(
diff --git a/chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc b/chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
index aeb5838a2a9..6a7fa0ccb4d 100644
--- a/chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
+++ b/chromium/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
@@ -65,7 +65,7 @@ bool SaveDictionaryData(std::unique_ptr<std::string> data,
bool success = false;
#if defined(OS_WIN)
base::FilePath dict_dir;
- PathService::Get(chrome::DIR_USER_DATA, &dict_dir);
+ base::PathService::Get(chrome::DIR_USER_DATA, &dict_dir);
base::FilePath fallback_file_path =
dict_dir.Append(path.BaseName());
bytes_written =
@@ -333,7 +333,7 @@ SpellcheckHunspellDictionary::OpenDictionaryFile(const base::FilePath& path) {
// Check if the dictionary exists in the fallback location. If so, use it
// rather than downloading anew.
base::FilePath user_dir;
- PathService::Get(chrome::DIR_USER_DATA, &user_dir);
+ base::PathService::Get(chrome::DIR_USER_DATA, &user_dir);
base::FilePath fallback = user_dir.Append(path.BaseName());
if (!base::PathExists(path) && base::PathExists(fallback))
dictionary.path = fallback;
@@ -379,7 +379,7 @@ SpellcheckHunspellDictionary::InitializeDictionaryLocation(
// sequence because it checks if there is a "Dictionaries" directory and
// create it.
base::FilePath dict_dir;
- PathService::Get(chrome::DIR_APP_DICTIONARIES, &dict_dir);
+ base::PathService::Get(chrome::DIR_APP_DICTIONARIES, &dict_dir);
base::FilePath dict_path =
spellcheck::GetVersionedFileName(language, dict_dir);
diff --git a/chromium/chrome/browser/spellchecker/spellcheck_service.cc b/chromium/chrome/browser/spellchecker/spellcheck_service.cc
index d66d4faf867..1a30844cd2b 100644
--- a/chromium/chrome/browser/spellchecker/spellcheck_service.cc
+++ b/chromium/chrome/browser/spellchecker/spellcheck_service.cc
@@ -337,7 +337,7 @@ void SpellcheckService::InitForAllRenderers() {
content::RenderProcessHost::AllHostsIterator());
!i.IsAtEnd(); i.Advance()) {
content::RenderProcessHost* process = i.GetCurrentValue();
- if (process && process->GetHandle())
+ if (process && process->GetProcess().Handle())
InitForRenderer(process->GetChildIdentity());
}
}
diff --git a/chromium/chrome/browser/spellchecker/spellcheck_service_browsertest.cc b/chromium/chrome/browser/spellchecker/spellcheck_service_browsertest.cc
index 6f310786d47..2ac4bc031d6 100644
--- a/chromium/chrome/browser/spellchecker/spellcheck_service_browsertest.cc
+++ b/chromium/chrome/browser/spellchecker/spellcheck_service_browsertest.cc
@@ -36,6 +36,7 @@
#include "components/user_prefs/user_prefs.h"
#include "content/public/test/mock_render_process_host.h"
#include "content/public/test/test_utils.h"
+#include "mojo/public/cpp/bindings/binding.h"
using content::BrowserContext;
using content::RenderProcessHost;
@@ -430,7 +431,7 @@ IN_PROC_BROWSER_TEST_F(SpellcheckServiceBrowserTest, DeleteCorruptedBDICT) {
// Write the corrupted BDICT data to create a corrupted BDICT file.
base::FilePath dict_dir;
- ASSERT_TRUE(PathService::Get(chrome::DIR_APP_DICTIONARIES, &dict_dir));
+ ASSERT_TRUE(base::PathService::Get(chrome::DIR_APP_DICTIONARIES, &dict_dir));
base::FilePath bdict_path =
spellcheck::GetVersionedFileName("en-US", dict_dir);
diff --git a/chromium/chrome/browser/ui/BUILD.gn b/chromium/chrome/browser/ui/BUILD.gn
index 72dde06a99a..c514878fafe 100644
--- a/chromium/chrome/browser/ui/BUILD.gn
+++ b/chromium/chrome/browser/ui/BUILD.gn
@@ -8,11 +8,11 @@ import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//build/split_static_library.gni")
import("//chrome/common/features.gni")
+import("//chromeos/assistant/assistant.gni")
import("//components/nacl/features.gni")
import("//components/offline_pages/buildflags/features.gni")
import("//components/signin/features.gni")
import("//extensions/buildflags/buildflags.gni")
-import("//media/media_options.gni")
import("//ppapi/buildflags/buildflags.gni")
import("//printing/buildflags/buildflags.gni")
import("//rlz/buildflags/buildflags.gni")
@@ -436,45 +436,6 @@ split_static_library("ui") {
"cocoa/password_reuse_warning_dialog_cocoa.mm",
"cocoa/password_reuse_warning_view_controller.h",
"cocoa/password_reuse_warning_view_controller.mm",
- "cocoa/passwords/account_avatar_fetcher_manager.h",
- "cocoa/passwords/account_avatar_fetcher_manager.mm",
- "cocoa/passwords/account_chooser_view_controller.h",
- "cocoa/passwords/account_chooser_view_controller.mm",
- "cocoa/passwords/auto_signin_view_controller.h",
- "cocoa/passwords/auto_signin_view_controller.mm",
- "cocoa/passwords/autosignin_prompt_view_controller.h",
- "cocoa/passwords/autosignin_prompt_view_controller.mm",
- "cocoa/passwords/base_passwords_content_view_controller.h",
- "cocoa/passwords/base_passwords_content_view_controller.mm",
- "cocoa/passwords/confirmation_password_saved_view_controller.h",
- "cocoa/passwords/confirmation_password_saved_view_controller.mm",
- "cocoa/passwords/credential_item_button.h",
- "cocoa/passwords/credential_item_button.mm",
- "cocoa/passwords/credentials_selection_view_cocoa.h",
- "cocoa/passwords/credentials_selection_view_cocoa.mm",
- "cocoa/passwords/manage_passwords_view_controller.h",
- "cocoa/passwords/manage_passwords_view_controller.mm",
- "cocoa/passwords/password_item_views.h",
- "cocoa/passwords/password_prompt_bridge_interface.h",
- "cocoa/passwords/password_prompt_view_bridge.h",
- "cocoa/passwords/password_prompt_view_bridge.mm",
- "cocoa/passwords/password_prompt_views_mac.mm",
- "cocoa/passwords/passwords_bubble_cocoa.h",
- "cocoa/passwords/passwords_bubble_cocoa.mm",
- "cocoa/passwords/passwords_bubble_controller.h",
- "cocoa/passwords/passwords_bubble_controller.mm",
- "cocoa/passwords/passwords_bubble_utils.h",
- "cocoa/passwords/passwords_bubble_utils.mm",
- "cocoa/passwords/passwords_list_view_controller.h",
- "cocoa/passwords/passwords_list_view_controller.mm",
- "cocoa/passwords/pending_password_view_controller.h",
- "cocoa/passwords/pending_password_view_controller.mm",
- "cocoa/passwords/save_pending_password_view_controller.h",
- "cocoa/passwords/save_pending_password_view_controller.mm",
- "cocoa/passwords/signin_promo_view_controller.h",
- "cocoa/passwords/signin_promo_view_controller.mm",
- "cocoa/passwords/update_pending_password_view_controller.h",
- "cocoa/passwords/update_pending_password_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",
@@ -682,6 +643,7 @@ split_static_library("ui") {
"confirm_bubble.h",
"crypto_module_password_dialog.h",
"cryptuiapi_shim.h",
+ "enterprise_startup_dialog.h",
"find_bar/find_bar.h",
"find_bar/find_bar_state.h",
"find_bar/find_bar_state_factory.cc",
@@ -823,6 +785,8 @@ split_static_library("ui") {
"webui/log_web_ui_url.h",
"webui/media/media_engagement_ui.cc",
"webui/media/media_engagement_ui.h",
+ "webui/media/webrtc_logs_ui.cc",
+ "webui/media/webrtc_logs_ui.h",
"webui/memory_internals_ui.cc",
"webui/memory_internals_ui.h",
"webui/metrics_handler.cc",
@@ -889,6 +853,13 @@ split_static_library("ui") {
"webui/version_ui.h",
]
+ if (safe_browsing_mode == 1) {
+ sources += [
+ "webui/reset_password/reset_password_ui.cc",
+ "webui/reset_password/reset_password_ui.h",
+ ]
+ }
+
allow_circular_includes_from = []
defines = []
if (is_win) {
@@ -945,7 +916,9 @@ split_static_library("ui") {
"//chrome/common",
"//chrome/common/net",
"//chrome/installer/util:with_no_strings",
+ "//chromeos/assistant:buildflags",
"//components/about_ui",
+ "//components/account_id",
"//components/app_modal",
"//components/autofill/content/browser:risk_proto",
"//components/autofill/core/browser",
@@ -973,6 +946,7 @@ split_static_library("ui") {
"//components/flags_ui",
"//components/gcm_driver",
"//components/google/core/browser",
+ "//components/heap_profiling",
"//components/history/content/browser",
"//components/history/core/browser",
"//components/image_fetcher/core",
@@ -991,9 +965,8 @@ split_static_library("ui") {
"//components/password_manager/content/browser",
"//components/password_manager/core/browser",
"//components/password_manager/sync/browser",
+ "//components/payments/content:utils",
"//components/pdf/browser",
- "//components/physical_web/data_source",
- "//components/physical_web/webui",
"//components/policy/core/browser",
"//components/pref_registry",
"//components/previews/content",
@@ -1016,7 +989,6 @@ split_static_library("ui") {
"//components/security_state/content",
"//components/security_state/core",
"//components/sessions",
- "//components/signin/core/account_id",
"//components/signin/core/browser",
"//components/signin/core/browser:signin_buildflags",
"//components/spellcheck/browser",
@@ -1047,6 +1019,7 @@ split_static_library("ui") {
"//components/version_ui",
"//components/web_cache/browser",
"//components/web_resource",
+ "//components/webrtc_logging/browser",
"//content/app/resources",
"//content/public/common",
"//crypto",
@@ -1104,6 +1077,10 @@ split_static_library("ui") {
deps += [ "//chrome/browser/ui/webui/discards:mojo_bindings" ]
}
+ if (is_android) {
+ deps += [ "//chrome/browser/ui/webui/snippets_internals:mojo_bindings" ]
+ }
+
if (!is_fuchsia) {
# TODO(crbug.com/753619): Enable crash reporting on Fuchsia.
deps += [
@@ -1159,6 +1136,8 @@ split_static_library("ui") {
"android/infobars/confirm_infobar.h",
"android/infobars/data_reduction_promo_infobar.cc",
"android/infobars/data_reduction_promo_infobar.h",
+ "android/infobars/download_progress_infobar.cc",
+ "android/infobars/download_progress_infobar.h",
"android/infobars/duplicate_download_infobar.cc",
"android/infobars/duplicate_download_infobar.h",
"android/infobars/framebust_block_infobar.cc",
@@ -1206,8 +1185,8 @@ split_static_library("ui") {
"android/page_info/certificate_viewer_android.cc",
"android/page_info/connection_info_popup_android.cc",
"android/page_info/connection_info_popup_android.h",
- "android/page_info/page_info_popup_android.cc",
- "android/page_info/page_info_popup_android.h",
+ "android/page_info/page_info_controller_android.cc",
+ "android/page_info/page_info_controller_android.h",
"android/simple_message_box_android.cc",
"android/snackbars/auto_signin_prompt_controller.cc",
"android/snackbars/auto_signin_prompt_controller.h",
@@ -1225,6 +1204,10 @@ split_static_library("ui") {
"android/tab_model/tab_model_list.cc",
"android/tab_model/tab_model_list.h",
"android/tab_model/tab_model_list_observer.h",
+ "android/tab_model/tab_model_observer.cc",
+ "android/tab_model/tab_model_observer.h",
+ "android/tab_model/tab_model_observer_jni_bridge.cc",
+ "android/tab_model/tab_model_observer_jni_bridge.h",
"android/toolbar/toolbar_model_android.cc",
"android/toolbar/toolbar_model_android.h",
"android/usb_chooser_dialog_android.cc",
@@ -1237,12 +1220,10 @@ split_static_library("ui") {
"webui/offline/offline_internals_ui.h",
"webui/offline/offline_internals_ui_message_handler.cc",
"webui/offline/offline_internals_ui_message_handler.h",
- "webui/physical_web/physical_web_ui.cc",
- "webui/physical_web/physical_web_ui.h",
- "webui/snippets_internals_message_handler.cc",
- "webui/snippets_internals_message_handler.h",
- "webui/snippets_internals_ui.cc",
- "webui/snippets_internals_ui.h",
+ "webui/snippets_internals/snippets_internals_page_handler.cc",
+ "webui/snippets_internals/snippets_internals_page_handler.h",
+ "webui/snippets_internals/snippets_internals_ui.cc",
+ "webui/snippets_internals/snippets_internals_ui.h",
"webui/webapks_handler.cc",
"webui/webapks_handler.h",
"webui/webapks_ui.cc",
@@ -1372,6 +1353,9 @@ split_static_library("ui") {
"fast_unload_controller.h",
"find_bar/find_bar_controller.cc",
"find_bar/find_bar_controller.h",
+ "find_bar/find_bar_platform_helper.cc",
+ "find_bar/find_bar_platform_helper.h",
+ "find_bar/find_bar_platform_helper_mac.mm",
"global_error/global_error.cc",
"global_error/global_error.h",
"global_error/global_error_bubble_view_base.h",
@@ -1387,6 +1371,9 @@ split_static_library("ui") {
"layout_constants.h",
"location_bar/location_bar.cc",
"location_bar/location_bar.h",
+ "media_router/cast_dialog_controller.h",
+ "media_router/cast_dialog_model.cc",
+ "media_router/cast_dialog_model.h",
"media_router/cast_modes_with_media_sources.cc",
"media_router/cast_modes_with_media_sources.h",
"media_router/media_cast_mode.cc",
@@ -1395,6 +1382,10 @@ split_static_library("ui") {
"media_router/media_router_dialog_controller_impl_base.h",
"media_router/media_router_file_dialog.cc",
"media_router/media_router_file_dialog.h",
+ "media_router/media_router_ui_base.cc",
+ "media_router/media_router_ui_base.h",
+ "media_router/media_router_ui_helper.cc",
+ "media_router/media_router_ui_helper.h",
"media_router/media_sink_with_cast_modes.cc",
"media_router/media_sink_with_cast_modes.h",
"media_router/presentation_receiver_window.h",
@@ -1404,6 +1395,8 @@ split_static_library("ui") {
"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",
+ "media_router/ui_media_sink.h",
"native_window_tracker.h",
"omnibox/alternate_nav_infobar_delegate.cc",
"omnibox/alternate_nav_infobar_delegate.h",
@@ -1415,10 +1408,9 @@ split_static_library("ui") {
"omnibox/chrome_omnibox_navigation_observer.h",
"omnibox/clipboard_utils.cc",
"omnibox/clipboard_utils.h",
- "omnibox/favicon_cache.cc",
- "omnibox/favicon_cache.h",
"omnibox/omnibox_theme.cc",
"omnibox/omnibox_theme.h",
+ "page_action/page_action_icon_container.h",
"page_info/page_info_dialog.cc",
"page_info/page_info_dialog.h",
"page_info/page_info_infobar_delegate.cc",
@@ -1505,6 +1497,7 @@ split_static_library("ui") {
"tabs/tab_network_state.h",
"tabs/tab_strip_model.cc",
"tabs/tab_strip_model.h",
+ "tabs/tab_strip_model_delegate.cc",
"tabs/tab_strip_model_delegate.h",
"tabs/tab_strip_model_observer.cc",
"tabs/tab_strip_model_observer.h",
@@ -1514,8 +1507,6 @@ split_static_library("ui") {
"tabs/tab_strip_model_stats_recorder.h",
"tabs/tab_utils.cc",
"tabs/tab_utils.h",
- "tabs/web_contents_closer.cc",
- "tabs/web_contents_closer.h",
"tabs/window_activity_watcher.cc",
"tabs/window_activity_watcher.h",
"task_manager/task_manager_columns.cc",
@@ -1542,6 +1533,7 @@ split_static_library("ui") {
"toolbar/media_router_contextual_menu.h",
"toolbar/recent_tabs_sub_menu_model.cc",
"toolbar/recent_tabs_sub_menu_model.h",
+ "toolbar/toolbar_action_button_state.h",
"toolbar/toolbar_action_view_controller.h",
"toolbar/toolbar_action_view_delegate.h",
"toolbar/toolbar_actions_bar.cc",
@@ -1555,12 +1547,8 @@ split_static_library("ui") {
"uma_browsing_activity_observer.h",
"unload_controller.cc",
"unload_controller.h",
- "unload_controller_web_contents_delegate.cc",
- "unload_controller_web_contents_delegate.h",
"webui/app_launcher_login_handler.cc",
"webui/app_launcher_login_handler.h",
- "webui/bookmarks_ui.cc",
- "webui/bookmarks_ui.h",
"webui/browsing_history_handler.cc",
"webui/browsing_history_handler.h",
"webui/chrome_web_contents_handler.cc",
@@ -1569,14 +1557,8 @@ split_static_library("ui") {
"webui/constrained_web_dialog_delegate_base.h",
"webui/devtools_ui.cc",
"webui/devtools_ui.h",
- "webui/extensions/extension_loader_handler.cc",
- "webui/extensions/extension_loader_handler.h",
- "webui/extensions/extension_settings_handler.cc",
- "webui/extensions/extension_settings_handler.h",
"webui/extensions/extensions_ui.cc",
"webui/extensions/extensions_ui.h",
- "webui/extensions/install_extension_handler.cc",
- "webui/extensions/install_extension_handler.h",
"webui/foreign_session_handler.cc",
"webui/foreign_session_handler.h",
"webui/help/version_updater.h",
@@ -1631,6 +1613,8 @@ split_static_library("ui") {
"webui/ntp/ntp_resource_cache.h",
"webui/ntp/ntp_resource_cache_factory.cc",
"webui/ntp/ntp_resource_cache_factory.h",
+ "webui/page_not_available_for_guest/page_not_available_for_guest_ui.cc",
+ "webui/page_not_available_for_guest/page_not_available_for_guest_ui.h",
"webui/plural_string_handler.cc",
"webui/plural_string_handler.h",
"webui/policy_indicator_localized_strings_provider.cc",
@@ -1734,6 +1718,7 @@ split_static_library("ui") {
"//chrome/browser/media/router",
"//chrome/browser/profile_resetter:profile_reset_report_proto",
"//chrome/browser/resource_coordinator:tab_metrics_event_proto",
+ "//chrome/browser/resource_coordinator/tab_ranker",
"//chrome/common:buildflags",
"//chrome/common:search_mojom",
"//components/feedback/proto",
@@ -1782,6 +1767,8 @@ split_static_library("ui") {
"ash/ash_shell_init.h",
"ash/ash_util.cc",
"ash/ash_util.h",
+ "ash/assistant/assistant_context_util.cc",
+ "ash/assistant/assistant_context_util.h",
"ash/auto_connect_notifier.cc",
"ash/auto_connect_notifier.h",
"ash/cast_config_client_media_router.cc",
@@ -1866,6 +1853,8 @@ split_static_library("ui") {
"ash/network/enrollment_dialog_view.h",
"ash/network/network_connect_delegate_chromeos.cc",
"ash/network/network_connect_delegate_chromeos.h",
+ "ash/network/network_portal_notification_controller.cc",
+ "ash/network/network_portal_notification_controller.h",
"ash/network/network_state_notifier.cc",
"ash/network/network_state_notifier.h",
"ash/network/networking_config_delegate_chromeos.cc",
@@ -1908,8 +1897,6 @@ 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_non_client_frame_view_ash.cc",
"views/frame/browser_non_client_frame_view_ash.h",
"views/frame/immersive_context_mus.cc",
@@ -1935,6 +1922,8 @@ split_static_library("ui") {
"views/select_file_dialog_extension_factory.h",
"views/tabs/window_finder_ash.cc",
"views/touch_uma/touch_uma_ash.cc",
+ "webui/chromeos/assistant_optin/assistant_optin_handler.cc",
+ "webui/chromeos/assistant_optin/assistant_optin_handler.h",
"webui/chromeos/assistant_optin/assistant_optin_screen_exit_code.h",
"webui/chromeos/assistant_optin/assistant_optin_ui.cc",
"webui/chromeos/assistant_optin/assistant_optin_ui.h",
@@ -2025,6 +2014,8 @@ split_static_library("ui") {
"webui/chromeos/login/oobe_display_chooser.h",
"webui/chromeos/login/oobe_ui.cc",
"webui/chromeos/login/oobe_ui.h",
+ "webui/chromeos/login/recommend_apps_screen_handler.cc",
+ "webui/chromeos/login/recommend_apps_screen_handler.h",
"webui/chromeos/login/reset_screen_handler.cc",
"webui/chromeos/login/reset_screen_handler.h",
"webui/chromeos/login/screenlock_icon_provider.cc",
@@ -2087,10 +2078,14 @@ split_static_library("ui") {
"webui/help/version_updater_chromeos.h",
"webui/settings/chromeos/accessibility_handler.cc",
"webui/settings/chromeos/accessibility_handler.h",
+ "webui/settings/chromeos/account_manager_handler.cc",
+ "webui/settings/chromeos/account_manager_handler.h",
"webui/settings/chromeos/android_apps_handler.cc",
"webui/settings/chromeos/android_apps_handler.h",
"webui/settings/chromeos/change_picture_handler.cc",
"webui/settings/chromeos/change_picture_handler.h",
+ "webui/settings/chromeos/crostini_handler.cc",
+ "webui/settings/chromeos/crostini_handler.h",
"webui/settings/chromeos/cups_printers_handler.cc",
"webui/settings/chromeos/cups_printers_handler.h",
"webui/settings/chromeos/date_time_handler.cc",
@@ -2125,8 +2120,10 @@ split_static_library("ui") {
"//ash",
"//ash:ash_with_content",
"//ash/app_list/presenter",
- "//ash/components/shortcut_viewer:ksv",
+ "//ash/components/shortcut_viewer:lib",
+ "//ash/components/shortcut_viewer/public/mojom",
"//ash/public/cpp",
+ "//ash/public/cpp/resources:ash_public_unscaled_resources",
"//ash/public/cpp/vector_icons",
"//ash/strings",
"//chrome/browser/chromeos",
@@ -2135,7 +2132,10 @@ split_static_library("ui") {
"//chromeos/components/proximity_auth/logging",
"//chromeos/components/proximity_auth/webui",
"//chromeos/components/tether",
+ "//chromeos/services/assistant/public/mojom",
+ "//chromeos/services/assistant/public/proto:proto",
"//components/arc",
+ "//components/captive_portal",
"//components/consent_auditor:consent_auditor",
"//components/cryptauth",
"//components/drive:drive_chromeos",
@@ -2244,8 +2244,6 @@ split_static_library("ui") {
"webui/signin/signin_error_handler.h",
"webui/signin/signin_error_ui.cc",
"webui/signin/signin_error_ui.h",
- "webui/signin/signin_supervised_user_import_handler.cc",
- "webui/signin/signin_supervised_user_import_handler.h",
"webui/signin/signin_utils_desktop.cc",
"webui/signin/signin_utils_desktop.h",
"webui/signin/signin_web_dialog_ui.cc",
@@ -2266,6 +2264,8 @@ split_static_library("ui") {
sources += [
"views/profiles/avatar_button.cc",
"views/profiles/avatar_button.h",
+ "views/profiles/avatar_toolbar_button.cc",
+ "views/profiles/avatar_toolbar_button.h",
"views/profiles/user_manager_view.cc",
"views/profiles/user_manager_view.h",
]
@@ -2305,6 +2305,11 @@ split_static_library("ui") {
sources += [
"input_method/input_method_engine.cc",
"input_method/input_method_engine.h",
+ "views/confirm_quit_bubble.cc",
+ "views/confirm_quit_bubble.h",
+ "views/confirm_quit_bubble.h",
+ "views/confirm_quit_bubble_controller.cc",
+ "views/confirm_quit_bubble_controller.h",
]
}
}
@@ -2416,6 +2421,10 @@ split_static_library("ui") {
"cocoa/profiles/profile_menu_controller.mm",
"cocoa/renderer_context_menu/render_view_context_menu_mac.h",
"cocoa/renderer_context_menu/render_view_context_menu_mac.mm",
+ "cocoa/renderer_context_menu/render_view_context_menu_mac_cocoa.h",
+ "cocoa/renderer_context_menu/render_view_context_menu_mac_cocoa.mm",
+ "cocoa/renderer_context_menu/render_view_context_menu_mac_views.h",
+ "cocoa/renderer_context_menu/render_view_context_menu_mac_views.mm",
"cocoa/scoped_menu_bar_lock.h",
"cocoa/scoped_menu_bar_lock.mm",
"cocoa/share_menu_controller.h",
@@ -2486,16 +2495,6 @@ split_static_library("ui") {
"views/tabs/window_finder_mac.mm",
]
- # MacViews browser windows are loudly marked in Chromium builds so that
- # developers notice when they're being used. See comment in
- # macviews_under_construction_window_mac.h for details.
- if (!is_chrome_branded) {
- sources += [
- "views/frame/macviews_under_construction_window_mac.h",
- "views/frame/macviews_under_construction_window_mac.mm",
- ]
- }
-
deps += [ "//extensions/components/native_app_window" ]
# Truly cocoa-browser-specific sources. These are secondary UI pieces that
@@ -2551,10 +2550,7 @@ split_static_library("ui") {
"cocoa/password_reuse_warning_dialog_cocoa.mm",
"cocoa/password_reuse_warning_view_controller.h",
"cocoa/password_reuse_warning_view_controller.mm",
- "cocoa/passwords/password_prompt_views_mac.mm",
"cocoa/simple_message_box_bridge_views.mm",
- "cocoa/simple_message_box_cocoa.h",
- "cocoa/simple_message_box_cocoa.mm",
"cocoa/subresource_filter/subresource_filter_bubble_controller.h",
"cocoa/subresource_filter/subresource_filter_bubble_controller.mm",
"javascript_dialogs/javascript_dialog_cocoa.h",
@@ -2730,7 +2726,8 @@ split_static_library("ui") {
}
if (use_ozone) {
sources += [
- "views/frame/browser_desktop_window_tree_host_ozone.cc",
+ "views/frame/browser_desktop_window_tree_host_platform.cc",
+ "views/frame/browser_desktop_window_tree_host_platform.h",
"views/frame/native_browser_frame_factory_ozone.cc",
]
} else {
@@ -3153,8 +3150,6 @@ split_static_library("ui") {
"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/bubble_icon_view.cc",
- "views/location_bar/bubble_icon_view.h",
"views/location_bar/content_setting_image_view.cc",
"views/location_bar/content_setting_image_view.h",
"views/location_bar/find_bar_icon.cc",
@@ -3175,8 +3170,14 @@ split_static_library("ui") {
"views/location_bar/star_view.h",
"views/location_bar/zoom_view.cc",
"views/location_bar/zoom_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/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",
@@ -3184,6 +3185,8 @@ split_static_library("ui") {
"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",
@@ -3196,6 +3199,10 @@ split_static_library("ui") {
"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/passwords/manage_passwords_icon_views.cc",
"views/passwords/manage_passwords_icon_views.h",
"views/permission_bubble/chooser_bubble_ui_views.cc",
@@ -3223,6 +3230,8 @@ split_static_library("ui") {
"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",
@@ -3265,6 +3274,7 @@ split_static_library("ui") {
"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",
@@ -3304,6 +3314,8 @@ split_static_library("ui") {
"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/profiles/signin_view_controller_delegate_views.cc",
@@ -3393,6 +3405,10 @@ split_static_library("ui") {
]
}
}
+
+ if (is_chrome_branded) {
+ deps += [ "//chrome/browser/ui/media_router/internal/vector_icons" ]
+ }
}
if (use_aura) {
@@ -3483,15 +3499,10 @@ split_static_library("ui") {
"app_list/app_list_model_builder.h",
"app_list/app_list_model_updater.h",
"app_list/app_list_model_updater_delegate.h",
- "app_list/app_list_service.h",
- "app_list/app_list_service_impl.cc",
- "app_list/app_list_service_impl.h",
"app_list/app_list_syncable_service.cc",
"app_list/app_list_syncable_service.h",
"app_list/app_list_syncable_service_factory.cc",
"app_list/app_list_syncable_service_factory.h",
- "app_list/app_list_view_delegate.cc",
- "app_list/app_list_view_delegate.h",
"app_list/chrome_app_list_item.cc",
"app_list/chrome_app_list_item.h",
"app_list/chrome_app_list_model_updater.cc",
@@ -3520,12 +3531,14 @@ split_static_library("ui") {
"app_list/search/arc/arc_app_data_search_provider.h",
"app_list/search/arc/arc_app_data_search_result.cc",
"app_list/search/arc/arc_app_data_search_result.h",
+ "app_list/search/arc/arc_app_shortcut_search_result.cc",
+ "app_list/search/arc/arc_app_shortcut_search_result.h",
+ "app_list/search/arc/arc_app_shortcuts_search_provider.cc",
+ "app_list/search/arc/arc_app_shortcuts_search_provider.h",
"app_list/search/arc/arc_playstore_search_provider.cc",
"app_list/search/arc/arc_playstore_search_provider.h",
"app_list/search/arc/arc_playstore_search_result.cc",
"app_list/search/arc/arc_playstore_search_result.h",
- "app_list/search/arc/icon_decode_request.cc",
- "app_list/search/arc/icon_decode_request.h",
"app_list/search/chrome_search_result.cc",
"app_list/search/chrome_search_result.h",
"app_list/search/common/json_response_fetcher.cc",
@@ -3542,16 +3555,6 @@ split_static_library("ui") {
"app_list/search/dictionary_data_store.h",
"app_list/search/extension_app_result.cc",
"app_list/search/extension_app_result.h",
- "app_list/search/history.cc",
- "app_list/search/history.h",
- "app_list/search/history_data.cc",
- "app_list/search/history_data.h",
- "app_list/search/history_data_observer.h",
- "app_list/search/history_data_store.cc",
- "app_list/search/history_data_store.h",
- "app_list/search/history_factory.cc",
- "app_list/search/history_factory.h",
- "app_list/search/history_types.h",
"app_list/search/mixer.cc",
"app_list/search/mixer.h",
"app_list/search/omnibox_provider.cc",
@@ -3570,6 +3573,12 @@ split_static_library("ui") {
"app_list/search/search_util.h",
"app_list/search/search_webstore_result.cc",
"app_list/search/search_webstore_result.h",
+ "app_list/search/settings_shortcut/settings_shortcut_metadata.cc",
+ "app_list/search/settings_shortcut/settings_shortcut_metadata.h",
+ "app_list/search/settings_shortcut/settings_shortcut_provider.cc",
+ "app_list/search/settings_shortcut/settings_shortcut_provider.h",
+ "app_list/search/settings_shortcut/settings_shortcut_result.cc",
+ "app_list/search/settings_shortcut/settings_shortcut_result.h",
"app_list/search/webstore/webstore_installer.cc",
"app_list/search/webstore/webstore_installer.h",
"app_list/search/webstore/webstore_provider.cc",
@@ -3578,8 +3587,11 @@ split_static_library("ui") {
"app_list/search/webstore/webstore_result.h",
]
deps += [
+ # TODO(wutao): Put new icons resources to ash/public/cpp/vector_icons/
+ # when UX provides them.
+ "//ash/public/cpp/app_list/vector_icons",
+ "//ash/resources/vector_icons",
"//ui/app_list",
- "//ui/app_list/vector_icons",
"//ui/views/mus/remote_view:remote_view_provider",
]
@@ -3627,24 +3639,30 @@ split_static_library("ui") {
"app_list/arc/arc_vpn_provider_manager_factory.h",
"app_list/crostini/crostini_app_context_menu.cc",
"app_list/crostini/crostini_app_context_menu.h",
+ "app_list/crostini/crostini_app_icon.cc",
+ "app_list/crostini/crostini_app_icon.h",
+ "app_list/crostini/crostini_app_icon_loader.cc",
+ "app_list/crostini/crostini_app_icon_loader.h",
"app_list/crostini/crostini_app_item.cc",
"app_list/crostini/crostini_app_item.h",
"app_list/crostini/crostini_app_model_builder.cc",
"app_list/crostini/crostini_app_model_builder.h",
- "app_list/crostini/crostini_installer_view.cc",
- "app_list/crostini/crostini_installer_view.h",
- "app_list/crostini/crostini_util.cc",
- "app_list/crostini/crostini_util.h",
+ "app_list/internal_app/internal_app_icon_loader.cc",
+ "app_list/internal_app/internal_app_icon_loader.h",
+ "app_list/internal_app/internal_app_item.cc",
+ "app_list/internal_app/internal_app_item.h",
"app_list/internal_app/internal_app_metadata.cc",
"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/search/arc_app_result.cc",
"app_list/search/arc_app_result.h",
+ "app_list/search/crostini_app_result.cc",
+ "app_list/search/crostini_app_result.h",
"app_list/search/internal_app_result.cc",
"app_list/search/internal_app_result.h",
- "ash/launcher/arc_app_deferred_launcher_controller.cc",
- "ash/launcher/arc_app_deferred_launcher_controller.h",
- "ash/launcher/arc_app_deferred_launcher_item_controller.cc",
- "ash/launcher/arc_app_deferred_launcher_item_controller.h",
+ "ash/launcher/app_window_base.cc",
+ "ash/launcher/app_window_base.h",
"ash/launcher/arc_app_shelf_id.cc",
"ash/launcher/arc_app_shelf_id.h",
"ash/launcher/arc_app_window.cc",
@@ -3655,22 +3673,55 @@ split_static_library("ui") {
"ash/launcher/arc_app_window_launcher_item_controller.h",
"ash/launcher/arc_launcher_context_menu.cc",
"ash/launcher/arc_launcher_context_menu.h",
- "ash/launcher/crostini_app_window.cc",
- "ash/launcher/crostini_app_window.h",
+ "ash/launcher/arc_shelf_spinner_item_controller.cc",
+ "ash/launcher/arc_shelf_spinner_item_controller.h",
"ash/launcher/crostini_app_window_shelf_controller.cc",
"ash/launcher/crostini_app_window_shelf_controller.h",
- "ash/launcher/crostini_app_window_shelf_item_controller.cc",
- "ash/launcher/crostini_app_window_shelf_item_controller.h",
"ash/launcher/crostini_shelf_context_menu.cc",
"ash/launcher/crostini_shelf_context_menu.h",
+ "ash/launcher/internal_app_shelf_context_menu.cc",
+ "ash/launcher/internal_app_shelf_context_menu.h",
+ "ash/launcher/internal_app_window_shelf_controller.cc",
+ "ash/launcher/internal_app_window_shelf_controller.h",
"ash/launcher/launcher_arc_app_updater.cc",
"ash/launcher/launcher_arc_app_updater.h",
+ "ash/launcher/launcher_crostini_app_updater.cc",
+ "ash/launcher/launcher_crostini_app_updater.h",
+ "ash/launcher/shelf_spinner_controller.cc",
+ "ash/launcher/shelf_spinner_controller.h",
+ "ash/launcher/shelf_spinner_item_controller.cc",
+ "ash/launcher/shelf_spinner_item_controller.h",
"views/arc_app_dialog_view.cc",
+ "views/crostini/crostini_installer_view.cc",
+ "views/crostini/crostini_installer_view.h",
+ "views/crostini/crostini_uninstaller_view.cc",
+ "views/crostini/crostini_uninstaller_view.h",
]
deps += [ "//mash/common" ]
}
}
+ if (enable_cros_assistant) {
+ deps += [
+ "//ash/public/cpp",
+ "//chromeos/services/assistant:lib",
+ "//chromeos/services/assistant/public/mojom",
+ ]
+
+ sources += [
+ "ash/assistant/assistant_card_renderer.cc",
+ "ash/assistant/assistant_card_renderer.h",
+ "ash/assistant/assistant_client.cc",
+ "ash/assistant/assistant_client.h",
+ "ash/assistant/assistant_context.cc",
+ "ash/assistant/assistant_context.h",
+ "ash/assistant/assistant_image_downloader.cc",
+ "ash/assistant/assistant_image_downloader.h",
+ "ash/assistant/platform_audio_input_host.cc",
+ "ash/assistant/platform_audio_input_host.h",
+ ]
+ }
+
if (enable_extensions) {
deps += [
"//apps",
@@ -3780,7 +3831,7 @@ split_static_library("ui") {
deps += [ "//ppapi/proxy:ipc" ]
}
- if (enable_basic_printing || enable_print_preview) {
+ if (enable_basic_printing) {
deps += [
"//components/printing/browser",
"//printing",
@@ -3845,17 +3896,10 @@ split_static_library("ui") {
}
}
- if (enable_webrtc) {
- sources += [
- "webui/media/webrtc_logs_ui.cc",
- "webui/media/webrtc_logs_ui.h",
- ]
- deps += [ "//components/webrtc_logging/browser" ]
- }
-
if (safe_browsing_mode == 1) {
deps += [
"//chrome/browser/safe_browsing:chunk_proto",
+ "//chrome/browser/ui/webui/reset_password:mojo_bindings",
"//chrome/common/safe_browsing:proto",
"//components/safe_browsing:csd_proto",
]
@@ -3944,6 +3988,8 @@ static_library("test_support") {
if (toolkit_views) {
deps += [ "//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/payments/test_chrome_payment_request_delegate.cc",
"views/payments/test_chrome_payment_request_delegate.h",
diff --git a/chromium/chrome/browser/ui/libgtkui/BUILD.gn b/chromium/chrome/browser/ui/libgtkui/BUILD.gn
index e9838d74e90..ccbed52a0a3 100644
--- a/chromium/chrome/browser/ui/libgtkui/BUILD.gn
+++ b/chromium/chrome/browser/ui/libgtkui/BUILD.gn
@@ -110,6 +110,7 @@ template("libgtkui") {
"//ui/base/ime",
"//ui/display",
"//ui/events",
+ "//ui/events:dom_keycode_converter",
"//ui/events:events_base",
"//ui/events/platform/x11",
"//ui/gfx",
diff --git a/chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.cc b/chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.cc
index 63009911a06..1c454ba4448 100644
--- a/chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.cc
@@ -11,7 +11,7 @@
#include "content/public/browser/web_ui_data_source.h"
BluetoothInternalsUI::BluetoothInternalsUI(content::WebUI* web_ui)
- : ui::MojoWebUIController<mojom::BluetoothInternalsHandler>(web_ui) {
+ : ui::MojoWebUIController(web_ui) {
// Set up the chrome://bluetooth-internals source.
content::WebUIDataSource* html_source =
content::WebUIDataSource::Create(chrome::kChromeUIBluetoothInternalsHost);
@@ -63,11 +63,14 @@ BluetoothInternalsUI::BluetoothInternalsUI(content::WebUI* web_ui)
Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource::Add(profile, html_source);
+ AddHandlerToRegistry(
+ base::BindRepeating(&BluetoothInternalsUI::BindBluetoothInternalsHandler,
+ base::Unretained(this)));
}
BluetoothInternalsUI::~BluetoothInternalsUI() {}
-void BluetoothInternalsUI::BindUIHandler(
+void BluetoothInternalsUI::BindBluetoothInternalsHandler(
mojom::BluetoothInternalsHandlerRequest request) {
page_handler_.reset(new BluetoothInternalsHandler(std::move(request)));
}
diff --git a/chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.h b/chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.h
index e28b48d756b..628df1f6ab7 100644
--- a/chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.h
+++ b/chromium/chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.h
@@ -12,18 +12,14 @@
class BluetoothInternalsHandler;
// The WebUI for chrome://bluetooth-internals
-class BluetoothInternalsUI
- : public ui::MojoWebUIController<mojom::BluetoothInternalsHandler> {
+class BluetoothInternalsUI : public ui::MojoWebUIController {
public:
explicit BluetoothInternalsUI(content::WebUI* web_ui);
~BluetoothInternalsUI() override;
private:
- // ui::MojoWebUIController overrides:
- void BindUIHandler(
- // mojo::InterfaceRequest<mojom::BluetoothInternalsHandler> request)
- // override;
- mojom::BluetoothInternalsHandlerRequest request) override;
+ void BindBluetoothInternalsHandler(
+ mojom::BluetoothInternalsHandlerRequest request);
std::unique_ptr<BluetoothInternalsHandler> page_handler_;
diff --git a/chromium/chrome/browser/ui/webui/bookmarks_ui.cc b/chromium/chrome/browser/ui/webui/bookmarks_ui.cc
deleted file mode 100644
index 1b7347e2829..00000000000
--- a/chromium/chrome/browser/ui/webui/bookmarks_ui.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/bookmarks_ui.h"
-
-#include "base/memory/ref_counted_memory.h"
-#include "base/message_loop/message_loop.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/grit/theme_resources.h"
-#include "content/public/browser/url_data_source.h"
-#include "content/public/browser/web_ui.h"
-#include "ui/base/resource/resource_bundle.h"
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// BookmarksUIHTMLSource
-//
-////////////////////////////////////////////////////////////////////////////////
-
-BookmarksUIHTMLSource::BookmarksUIHTMLSource() {
-}
-
-std::string BookmarksUIHTMLSource::GetSource() const {
- return chrome::kChromeUIBookmarksHost;
-}
-
-void BookmarksUIHTMLSource::StartDataRequest(
- const std::string& path,
- const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) {
- NOTREACHED() << "We should never get here since the extension should have"
- << "been triggered";
-
- callback.Run(NULL);
-}
-
-std::string BookmarksUIHTMLSource::GetMimeType(const std::string& path) const {
- NOTREACHED() << "We should never get here since the extension should have"
- << "been triggered";
- return "text/html";
-}
-
-BookmarksUIHTMLSource::~BookmarksUIHTMLSource() {}
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// BookmarksUI
-//
-////////////////////////////////////////////////////////////////////////////////
-
-BookmarksUI::BookmarksUI(content::WebUI* web_ui) : WebUIController(web_ui) {
- BookmarksUIHTMLSource* html_source = new BookmarksUIHTMLSource();
-
- // Set up the chrome://bookmarks/ source.
- Profile* profile = Profile::FromWebUI(web_ui);
- content::URLDataSource::Add(profile, html_source);
-}
-
-// static
-base::RefCountedMemory* BookmarksUI::GetFaviconResourceBytes(
- ui::ScaleFactor scale_factor) {
- return ui::ResourceBundle::GetSharedInstance().
- LoadDataResourceBytesForScale(IDR_BOOKMARKS_FAVICON, scale_factor);
-}
diff --git a/chromium/chrome/browser/ui/webui/bookmarks_ui.h b/chromium/chrome/browser/ui/webui/bookmarks_ui.h
deleted file mode 100644
index f4d2ab6f2e4..00000000000
--- a/chromium/chrome/browser/ui/webui/bookmarks_ui.h
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_BOOKMARKS_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_BOOKMARKS_UI_H_
-
-#include <string>
-
-#include "base/compiler_specific.h"
-#include "base/macros.h"
-#include "content/public/browser/url_data_source.h"
-#include "content/public/browser/web_ui_controller.h"
-#include "ui/base/layout.h"
-
-namespace base {
-class RefCountedMemory;
-}
-
-// This class provides the source for chrome://bookmarks/
-class BookmarksUIHTMLSource : public content::URLDataSource {
- public:
- BookmarksUIHTMLSource();
-
- // content::URLDataSource implementation.
- std::string GetSource() const override;
- void StartDataRequest(
- const std::string& path,
- const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
- const content::URLDataSource::GotDataCallback& callback) override;
- std::string GetMimeType(const std::string& path) const override;
-
- private:
- ~BookmarksUIHTMLSource() override;
-
- DISALLOW_COPY_AND_ASSIGN(BookmarksUIHTMLSource);
-};
-
-// This class is used to hook up chrome://bookmarks/ which in turn gets
-// overridden by an extension.
-class BookmarksUI : public content::WebUIController {
- public:
- explicit BookmarksUI(content::WebUI* web_ui);
-
- static base::RefCountedMemory* GetFaviconResourceBytes(
- ui::ScaleFactor scale_factor);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(BookmarksUI);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_BOOKMARKS_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/bookmarks_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/bookmarks_ui_browsertest.cc
deleted file mode 100644
index 132edd248a3..00000000000
--- a/chromium/chrome/browser/ui/webui/bookmarks_ui_browsertest.cc
+++ /dev/null
@@ -1,120 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/test/test_timeouts.h"
-#include "build/build_config.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/chrome_pages.h"
-#include "chrome/browser/ui/tabs/tab_strip_model.h"
-#include "chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/test/base/in_process_browser_test.h"
-#include "chrome/test/base/ui_test_utils.h"
-#include "content/public/browser/notification_service.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/test/browser_test_utils.h"
-#include "content/public/test/test_navigation_observer.h"
-
-class BookmarksTest : public InProcessBrowserTest {
- public:
- BookmarksTest() {}
-
- void SetUpOnMainThread() override {
- // Re-enable accessibility checks when audit failures are resolved.
- // AX_TEXT_01: http://crbug.com/559201
- // AX_ARIA_08: http://crbug.com/559202
- // EnableAccessibilityChecksForTestCase(true);
- }
-
- void OpenBookmarksManager() {
- content::TestNavigationObserver navigation_observer(
- browser()->tab_strip_model()->GetActiveWebContents(),
- MdBookmarksUI::IsEnabled() ? 1 : 2);
- navigation_observer.StartWatchingNewWebContents();
-
- // Bring up the bookmarks manager tab.
- chrome::ShowBookmarkManager(browser());
- navigation_observer.Wait();
- }
-
- void AssertIsBookmarksPage(content::WebContents* tab) {
- GURL url;
- std::string out;
-
- if (MdBookmarksUI::IsEnabled()) {
- ASSERT_TRUE(content::ExecuteScriptAndExtractString(
- tab, "domAutomationController.send(location.href)", &out));
- ASSERT_EQ("chrome://bookmarks/", out);
- return;
- }
-
- ASSERT_TRUE(content::ExecuteScriptAndExtractString(
- tab,
- "domAutomationController.send(location.protocol)",
- &out));
- ASSERT_EQ("chrome-extension:", out);
- ASSERT_TRUE(content::ExecuteScriptAndExtractString(
- tab,
- "domAutomationController.send(location.pathname)",
- &out));
- ASSERT_EQ("/main.html", out);
- }
-};
-
-IN_PROC_BROWSER_TEST_F(BookmarksTest, CommandOpensBookmarksTab) {
- ASSERT_EQ(1, browser()->tab_strip_model()->count());
-
- // Bring up the bookmarks manager tab.
- OpenBookmarksManager();
- ASSERT_EQ(1, browser()->tab_strip_model()->count());
- AssertIsBookmarksPage(browser()->tab_strip_model()->GetActiveWebContents());
-}
-
-// Flaky on Mac: https://crbug.com/524216
-#if defined(OS_MACOSX) || defined(OS_LINUX)
-#define MAYBE_CommandAgainGoesBackToBookmarksTab \
- DISABLED_CommandAgainGoesBackToBookmarksTab
-#else
-#define MAYBE_CommandAgainGoesBackToBookmarksTab \
- CommandAgainGoesBackToBookmarksTab
-#endif
-
-IN_PROC_BROWSER_TEST_F(BookmarksTest,
- MAYBE_CommandAgainGoesBackToBookmarksTab) {
- ui_test_utils::NavigateToURL(
- browser(),
- ui_test_utils::GetTestUrl(base::FilePath(),
- base::FilePath().AppendASCII("simple.html")));
- ASSERT_EQ(1, browser()->tab_strip_model()->count());
-
- // Bring up the bookmarks manager tab.
- OpenBookmarksManager();
- ASSERT_EQ(2, browser()->tab_strip_model()->count());
-
- AssertIsBookmarksPage(browser()->tab_strip_model()->GetActiveWebContents());
-
- // Switch to first tab and run command again.
- browser()->tab_strip_model()->ActivateTabAt(0, true);
- chrome::ShowBookmarkManager(browser());
-
- // Ensure the bookmarks ui tab is active.
- ASSERT_EQ(1, browser()->tab_strip_model()->active_index());
- ASSERT_EQ(2, browser()->tab_strip_model()->count());
-}
-
-IN_PROC_BROWSER_TEST_F(BookmarksTest, TwoCommandsOneTab) {
- content::TestNavigationObserver navigation_observer(
- browser()->tab_strip_model()->GetActiveWebContents());
- chrome::ShowBookmarkManager(browser());
- chrome::ShowBookmarkManager(browser());
- navigation_observer.Wait();
-
- ASSERT_EQ(1, browser()->tab_strip_model()->count());
-}
-
-IN_PROC_BROWSER_TEST_F(BookmarksTest, BookmarksLoaded) {
- ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIBookmarksURL));
- ASSERT_EQ(1, browser()->tab_strip_model()->count());
- AssertIsBookmarksPage(browser()->tab_strip_model()->GetActiveWebContents());
-}
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 90f6982423d..efe43ca5e6a 100644
--- a/chromium/chrome/browser/ui/webui/browsing_history_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/browsing_history_handler_unittest.cc
@@ -30,7 +30,6 @@
#include "components/sync/base/model_type.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/test/mock_render_process_host.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "content/public/test/test_web_ui.h"
#include "net/http/http_status_code.h"
@@ -116,8 +115,8 @@ class BrowsingHistoryHandlerTest : public ::testing::Test {
web_history_service_ = static_cast<history::FakeWebHistoryService*>(
WebHistoryServiceFactory::GetForProfile(profile_.get()));
- web_contents_.reset(content::WebContents::Create(
- content::WebContents::CreateParams(profile_.get())));
+ web_contents_ = content::WebContents::Create(
+ content::WebContents::CreateParams(profile_.get()));
web_ui_.reset(new content::TestWebUI);
web_ui_->set_web_contents(web_contents_.get());
}
@@ -153,10 +152,6 @@ class BrowsingHistoryHandlerTest : public ::testing::Test {
return std::move(service);
}
- // TODO(lukasza): https://crbug.com/832100: Move the factory into
- // TestingProfile, so individual tests don't need to worry about it.
- content::ScopedMockRenderProcessHostFactory test_process_factory_;
-
content::TestBrowserThreadBundle thread_bundle_;
std::unique_ptr<TestingProfile> profile_;
TestSyncService* sync_service_;
diff --git a/chromium/chrome/browser/ui/webui/chrome_web_contents_handler.cc b/chromium/chrome/browser/ui/webui/chrome_web_contents_handler.cc
index 3b935948db6..8d2a5e65217 100644
--- a/chromium/chrome/browser/ui/webui/chrome_web_contents_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chrome_web_contents_handler.cc
@@ -63,7 +63,7 @@ WebContents* ChromeWebContentsHandler::OpenURLFromTab(
if (browser_created && (browser != nav_params.browser))
browser->window()->Close();
- return nav_params.target_contents;
+ return nav_params.navigated_or_inserted_contents;
}
// Creates a new tab with |new_contents|. |context| is the browser context that
@@ -75,7 +75,7 @@ WebContents* ChromeWebContentsHandler::OpenURLFromTab(
void ChromeWebContentsHandler::AddNewContents(
content::BrowserContext* context,
WebContents* source,
- WebContents* new_contents,
+ std::unique_ptr<WebContents> new_contents,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture) {
@@ -90,7 +90,7 @@ void ChromeWebContentsHandler::AddNewContents(
browser = new Browser(
Browser::CreateParams(Browser::TYPE_TABBED, profile, user_gesture));
}
- NavigateParams params(browser, new_contents);
+ NavigateParams params(browser, std::move(new_contents));
params.source_contents = source;
params.disposition = disposition;
params.window_bounds = initial_rect;
diff --git a/chromium/chrome/browser/ui/webui/chrome_web_contents_handler.h b/chromium/chrome/browser/ui/webui/chrome_web_contents_handler.h
index b88ea3e2441..7833ce661b0 100644
--- a/chromium/chrome/browser/ui/webui/chrome_web_contents_handler.h
+++ b/chromium/chrome/browser/ui/webui/chrome_web_contents_handler.h
@@ -22,7 +22,7 @@ class ChromeWebContentsHandler
const content::OpenURLParams& params) override;
void AddNewContents(content::BrowserContext* context,
content::WebContents* source,
- content::WebContents* new_contents,
+ std::unique_ptr<content::WebContents> new_contents,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture) override;
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 0dd6bc00d78..4ad61d2d8ca 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
@@ -24,7 +24,6 @@
#include "chrome/browser/ui/history_ui.h"
#include "chrome/browser/ui/webui/about_ui.h"
#include "chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.h"
-#include "chrome/browser/ui/webui/bookmarks_ui.h"
#include "chrome/browser/ui/webui/components_ui.h"
#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
#include "chrome/browser/ui/webui/crashes_ui.h"
@@ -42,13 +41,13 @@
#include "chrome/browser/ui/webui/local_state/local_state_ui.h"
#include "chrome/browser/ui/webui/log_web_ui_url.h"
#include "chrome/browser/ui/webui/media/media_engagement_ui.h"
+#include "chrome/browser/ui/webui/media/webrtc_logs_ui.h"
#include "chrome/browser/ui/webui/memory_internals_ui.h"
#include "chrome/browser/ui/webui/net_export_ui.h"
#include "chrome/browser/ui/webui/net_internals/net_internals_ui.h"
#include "chrome/browser/ui/webui/ntp_tiles_internals_ui.h"
#include "chrome/browser/ui/webui/omnibox/omnibox_ui.h"
#include "chrome/browser/ui/webui/password_manager_internals/password_manager_internals_ui.h"
-#include "chrome/browser/ui/webui/physical_web/physical_web_ui.h"
#include "chrome/browser/ui/webui/policy_tool_ui.h"
#include "chrome/browser/ui/webui/policy_ui.h"
#include "chrome/browser/ui/webui/predictors/predictors_ui.h"
@@ -100,10 +99,6 @@
#include "chrome/browser/ui/webui/nacl_ui.h"
#endif
-#if BUILDFLAG(ENABLE_WEBRTC)
-#include "chrome/browser/ui/webui/media/webrtc_logs_ui.h"
-#endif
-
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
#endif
@@ -119,7 +114,7 @@
#if defined(OS_ANDROID)
#include "chrome/browser/ui/webui/offline/offline_internals_ui.h"
-#include "chrome/browser/ui/webui/snippets_internals_ui.h"
+#include "chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.h"
#include "chrome/browser/ui/webui/webapks_ui.h"
#else
#include "chrome/browser/ui/webui/devtools_ui.h"
@@ -128,6 +123,7 @@
#include "chrome/browser/ui/webui/md_downloads/md_downloads_ui.h"
#include "chrome/browser/ui/webui/md_history_ui.h"
#include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
+#include "chrome/browser/ui/webui/page_not_available_for_guest/page_not_available_for_guest_ui.h"
#include "chrome/browser/ui/webui/sync_file_system_internals/sync_file_system_internals_ui.h"
#include "chrome/browser/ui/webui/system_info_ui.h"
#endif
@@ -211,6 +207,12 @@
#include "extensions/common/manifest.h"
#endif
+#if defined(SAFE_BROWSING_DB_LOCAL)
+#include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
+#include "chrome/browser/ui/webui/reset_password/reset_password_ui.h"
+#include "components/safe_browsing/features.h"
+#endif
+
using content::WebUI;
using content::WebUIController;
using ui::WebDialogUI;
@@ -228,6 +230,14 @@ WebUIController* NewWebUI(WebUI* web_ui, const GURL& url) {
return new T(web_ui);
}
+#if !defined(OS_ANDROID)
+template <>
+WebUIController* NewWebUI<PageNotAvailableForGuestUI>(WebUI* web_ui,
+ const GURL& url) {
+ return new PageNotAvailableForGuestUI(web_ui, url.host());
+}
+#endif
+
// Special case for older about: handlers.
template<>
WebUIController* NewWebUI<AboutUI>(WebUI* web_ui, const GURL& url) {
@@ -399,11 +409,15 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
}
#endif // defined(OS_CHROMEOS)
- // Bookmarks are part of NTP on Android.
- if (url.host_piece() == chrome::kChromeUIBookmarksHost) {
- return MdBookmarksUI::IsEnabled() ? &NewWebUI<MdBookmarksUI>
- : &NewWebUI<BookmarksUI>;
+ if (profile->IsGuestSession() &&
+ (url.host_piece() == chrome::kChromeUIBookmarksHost ||
+ url.host_piece() == chrome::kChromeUIHistoryHost ||
+ url.host_piece() == chrome::kChromeUIExtensionsHost)) {
+ return &NewWebUI<PageNotAvailableForGuestUI>;
}
+ // Bookmarks are part of NTP on Android.
+ if (url.host_piece() == chrome::kChromeUIBookmarksHost)
+ return &NewWebUI<MdBookmarksUI>;
// Downloads list on Android uses the built-in download manager.
if (url.host_piece() == chrome::kChromeUIDownloadsHost)
return &NewWebUI<MdDownloadsUI>;
@@ -480,8 +494,6 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
#if defined(OS_ANDROID)
if (url.host_piece() == chrome::kChromeUIOfflineInternalsHost)
return &NewWebUI<OfflineInternalsUI>;
- if (url.host_piece() == chrome::kChromeUIPhysicalWebHost)
- return &NewWebUI<PhysicalWebUI>;
if (url.host_piece() == chrome::kChromeUISnippetsInternalsHost &&
!profile->IsOffTheRecord())
return &NewWebUI<SnippetsInternalsUI>;
@@ -570,10 +582,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<LocalDiscoveryUI>;
}
#endif
-#if BUILDFLAG(ENABLE_WEBRTC)
if (url.host_piece() == chrome::kChromeUIWebRtcLogsHost)
return &NewWebUI<WebRtcLogsUI>;
-#endif
#if !defined(OS_ANDROID)
if (url.host_piece() == chrome::kChromeUIMediaRouterHost &&
media_router::MediaRouterEnabled(profile)) {
@@ -622,6 +632,18 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<MediaEngagementUI>;
}
+#if defined(SAFE_BROWSING_DB_LOCAL)
+ bool enable_reset_password =
+ base::FeatureList::IsEnabled(
+ safe_browsing::kForceEnableResetPasswordWebUI) ||
+ safe_browsing::ChromePasswordProtectionService::
+ IsPasswordReuseProtectionConfigured(profile);
+ if (url.host_piece() == chrome::kChromeUIResetPasswordHost &&
+ enable_reset_password) {
+ return &NewWebUI<ResetPasswordUI>;
+ }
+#endif
+
return NULL;
}
@@ -679,10 +701,8 @@ void ChromeWebUIControllerFactory::GetFaviconForURL(
#if BUILDFLAG(ENABLE_EXTENSIONS)
ExtensionWebUI::HandleChromeURLOverride(&url, profile);
- // All extensions but the bookmark manager get their favicon from the icons
- // part of the manifest.
- if (url.SchemeIs(extensions::kExtensionScheme) &&
- url.host_piece() != extension_misc::kBookmarkManagerId) {
+ // All extensions get their favicon from the icons part of the manifest.
+ if (url.SchemeIs(extensions::kExtensionScheme)) {
ExtensionWebUI::GetFaviconForURL(profile, url, callback);
return;
}
@@ -743,14 +763,7 @@ ChromeWebUIControllerFactory::~ChromeWebUIControllerFactory() {
base::RefCountedMemory* ChromeWebUIControllerFactory::GetFaviconResourceBytes(
const GURL& page_url, ui::ScaleFactor scale_factor) const {
-#if !defined(OS_ANDROID) // Bookmarks are part of NTP on Android.
- // The bookmark manager is a chrome extension, so we have to check for it
- // before we check for extension scheme.
- if (page_url.host_piece() == extension_misc::kBookmarkManagerId ||
- page_url.host_piece() == chrome::kChromeUIBookmarksHost) {
- return BookmarksUI::GetFaviconResourceBytes(scale_factor);
- }
-
+#if !defined(OS_ANDROID)
// The extension scheme is handled in GetFaviconForURL.
if (page_url.SchemeIs(extensions::kExtensionScheme)) {
NOTREACHED();
@@ -786,6 +799,10 @@ base::RefCountedMemory* ChromeWebUIControllerFactory::GetFaviconResourceBytes(
return AppLauncherPageUI::GetFaviconResourceBytes(scale_factor);
#endif // !defined(OS_CHROMEOS)
+ // Bookmarks are part of NTP on Android.
+ if (page_url.host_piece() == chrome::kChromeUIBookmarksHost)
+ return MdBookmarksUI::GetFaviconResourceBytes(scale_factor);
+
// Flash is not available on android.
if (page_url.host_piece() == chrome::kChromeUIFlashHost)
return FlashUI::GetFaviconResourceBytes(scale_factor);
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
new file mode 100644
index 00000000000..2dc463e4606
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.cc
@@ -0,0 +1,49 @@
+// 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/browser_process.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/login/localized_values_builder.h"
+
+namespace {
+
+constexpr char kJsScreenPath[] = "assistantOptin";
+
+} // namespace
+
+namespace chromeos {
+
+AssistantOptInHandler::AssistantOptInHandler(
+ JSCallsContainer* js_calls_container)
+ : BaseWebUIHandler(js_calls_container) {
+ DCHECK(js_calls_container);
+ set_call_js_prefix(kJsScreenPath);
+}
+
+AssistantOptInHandler::~AssistantOptInHandler() = default;
+
+void AssistantOptInHandler::DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) {}
+
+void AssistantOptInHandler::RegisterMessages() {
+ AddCallback("initialized", &AssistantOptInHandler::HandleInitialized);
+}
+
+void AssistantOptInHandler::Initialize() {}
+
+void AssistantOptInHandler::ReloadContent(const base::DictionaryValue& dict) {
+ CallJSOrDefer("reloadContent", dict);
+}
+
+void AssistantOptInHandler::AddSettingZippy(const base::ListValue& data) {
+ CallJSOrDefer("addSettingZippy", data);
+}
+
+void AssistantOptInHandler::HandleInitialized() {
+ ExecuteDeferredJSCalls();
+}
+
+} // 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
new file mode 100644
index 00000000000..39e21c37443
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.h
@@ -0,0 +1,40 @@
+// 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/ui/webui/chromeos/login/base_webui_handler.h"
+
+namespace chromeos {
+
+class AssistantOptInHandler : public BaseWebUIHandler {
+ public:
+ explicit AssistantOptInHandler(JSCallsContainer* js_calls_container);
+ ~AssistantOptInHandler() override;
+
+ // BaseWebUIHandler:
+ void DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) override;
+ void RegisterMessages() override;
+ void Initialize() override;
+
+ // Send message and consent data to the page.
+ void ReloadContent(const base::DictionaryValue& dict);
+ void AddSettingZippy(const base::ListValue& data);
+
+ private:
+ // Handler for JS WebUI message.
+ void HandleInitialized();
+
+ 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 5699c5231b0..4d30bdadddd 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc
@@ -8,14 +8,19 @@
#include "base/bind.h"
#include "base/macros.h"
-#include "chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_arc_home_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.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 "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/prefs/pref_service.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"
namespace chromeos {
@@ -26,6 +31,30 @@ bool is_active = false;
constexpr int kAssistantOptInDialogWidth = 576;
constexpr int kAssistantOptInDialogHeight = 480;
+// Construct SettingsUiSelector for the ConsentFlow UI.
+assistant::SettingsUiSelector GetSettingsUiSelector() {
+ assistant::SettingsUiSelector selector;
+ assistant::ConsentFlowUiSelector* consent_flow_ui =
+ selector.mutable_consent_flow_ui_selector();
+ consent_flow_ui->set_flow_id(assistant::ActivityControlSettingsUiSelector::
+ ASSISTANT_SUW_ONBOARDING_ON_CHROME_OS);
+ return selector;
+}
+
+// Construct SettingsUiUpdate for user opt-in.
+assistant::SettingsUiUpdate GetSettingsUiUpdate(
+ const std::string& consent_token) {
+ assistant::SettingsUiUpdate update;
+ assistant::ConsentFlowUiUpdate* consent_flow_update =
+ update.mutable_consent_flow_ui_update();
+ consent_flow_update->set_flow_id(
+ assistant::ActivityControlSettingsUiSelector::
+ ASSISTANT_SUW_ONBOARDING_ON_CHROME_OS);
+ consent_flow_update->set_consent_token(consent_token);
+
+ return update;
+}
+
} // namespace
AssistantOptInUI::AssistantOptInUI(content::WebUI* web_ui)
@@ -34,6 +63,13 @@ AssistantOptInUI::AssistantOptInUI(content::WebUI* web_ui)
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIAssistantOptInHost);
+ js_calls_container_ = std::make_unique<JSCallsContainer>();
+
+ auto base_handler =
+ std::make_unique<AssistantOptInHandler>(js_calls_container_.get());
+ assistant_handler_ = base_handler.get();
+ AddScreenHandler(std::move(base_handler));
+
AddScreenHandler(std::make_unique<ValuePropScreenHandler>(
base::BindOnce(&AssistantOptInUI::OnExit, weak_factory_.GetWeakPtr())));
@@ -43,14 +79,45 @@ AssistantOptInUI::AssistantOptInUI(content::WebUI* web_ui)
source->AddLocalizedStrings(localized_strings);
source->SetJsonPath("strings.js");
-
source->AddResourcePath("assistant_optin.js", IDR_ASSISTANT_OPTIN_JS);
source->SetDefaultResource(IDR_ASSISTANT_OPTIN_HTML);
-
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
+
+ if (arc::VoiceInteractionControllerClient::Get()->voice_interaction_state() !=
+ ash::mojom::VoiceInteractionState::RUNNING) {
+ arc::VoiceInteractionControllerClient::Get()->AddObserver(this);
+ } else {
+ Initialize();
+ }
+}
+
+AssistantOptInUI::~AssistantOptInUI() {
+ arc::VoiceInteractionControllerClient::Get()->RemoveObserver(this);
+}
+
+void AssistantOptInUI::OnStateChanged(ash::mojom::VoiceInteractionState state) {
+ if (state == ash::mojom::VoiceInteractionState::RUNNING)
+ Initialize();
}
-AssistantOptInUI::~AssistantOptInUI() {}
+void AssistantOptInUI::Initialize() {
+ if (settings_manager_.is_bound())
+ return;
+
+ // Set up settings mojom.
+ Profile* const profile = Profile::FromWebUI(web_ui());
+ service_manager::Connector* connector =
+ content::BrowserContext::GetConnectorFor(profile);
+ connector->BindInterface(assistant::mojom::kServiceName,
+ mojo::MakeRequest(&settings_manager_));
+
+ // Send GetSettings request for the ConsentFlow UI.
+ assistant::SettingsUiSelector selector = GetSettingsUiSelector();
+ settings_manager_->GetSettings(
+ selector.SerializeAsString(),
+ base::BindOnce(&AssistantOptInUI::OnGetSettingsResponse,
+ weak_factory_.GetWeakPtr()));
+}
void AssistantOptInUI::AddScreenHandler(
std::unique_ptr<BaseWebUIHandler> handler) {
@@ -59,29 +126,84 @@ void AssistantOptInUI::AddScreenHandler(
}
void AssistantOptInUI::OnExit(AssistantOptInScreenExitCode exit_code) {
+ PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
switch (exit_code) {
case AssistantOptInScreenExitCode::VALUE_PROP_SKIPPED:
- // TODO(updowndota) Update the action to use the new Assistant service.
- GetVoiceInteractionHomeService()->OnAssistantCanceled();
+ prefs->SetBoolean(arc::prefs::kArcVoiceInteractionValuePropAccepted,
+ false);
+ prefs->SetBoolean(arc::prefs::kVoiceInteractionEnabled, false);
CloseDialog(nullptr);
break;
case AssistantOptInScreenExitCode::VALUE_PROP_ACCEPTED:
- // TODO(updowndota) Update the action to use the new Assistant service.
- GetVoiceInteractionHomeService()->OnAssistantAppRequested();
- CloseDialog(nullptr);
+ // Send the update to complete user opt-in.
+ settings_manager_->UpdateSettings(
+ GetSettingsUiUpdate(consent_token_).SerializeAsString(),
+ base::BindOnce(&AssistantOptInUI::OnUpdateSettingsResponse,
+ weak_factory_.GetWeakPtr()));
break;
default:
NOTREACHED();
}
}
-arc::ArcVoiceInteractionArcHomeService*
-AssistantOptInUI::GetVoiceInteractionHomeService() {
- Profile* const profile = Profile::FromWebUI(web_ui());
- arc::ArcVoiceInteractionArcHomeService* const home_service =
- arc::ArcVoiceInteractionArcHomeService::GetForBrowserContext(profile);
- DCHECK(home_service);
- return home_service;
+void AssistantOptInUI::OnGetSettingsResponse(const std::string& settings) {
+ assistant::SettingsUi settings_ui;
+ assistant::ConsentFlowUi::ConsentUi::ActivityControlUi activity_control_ui;
+ settings_ui.ParseFromString(settings);
+
+ DCHECK(settings_ui.has_consent_flow_ui());
+ activity_control_ui =
+ settings_ui.consent_flow_ui().consent_ui().activity_control_ui();
+ consent_token_ = activity_control_ui.consent_token();
+
+ base::ListValue zippy_data;
+ if (activity_control_ui.setting_zippy().size() == 0) {
+ // No need to consent. Close the dialog for now.
+ CloseDialog(nullptr);
+ return;
+ }
+ for (auto& setting_zippy : activity_control_ui.setting_zippy()) {
+ base::DictionaryValue data;
+ data.SetString("title", setting_zippy.title());
+ data.SetString("description", setting_zippy.description_paragraph(0));
+ data.SetString("additionalInfo",
+ setting_zippy.additional_info_paragraph(0));
+ data.SetString("iconUri", setting_zippy.icon_uri());
+ zippy_data.GetList().push_back(std::move(data));
+ }
+ assistant_handler_->AddSettingZippy(zippy_data);
+
+ base::DictionaryValue dictionary;
+ dictionary.SetString("valuePropIntro",
+ activity_control_ui.intro_text_paragraph(0));
+ dictionary.SetString("valuePropIdentity", activity_control_ui.identity());
+ dictionary.SetString("valuePropFooter",
+ activity_control_ui.footer_paragraph(0));
+ dictionary.SetString(
+ "valuePropNextButton",
+ settings_ui.consent_flow_ui().consent_ui().accept_button_text());
+ dictionary.SetString(
+ "valuePropSkipButton",
+ settings_ui.consent_flow_ui().consent_ui().reject_button_text());
+ assistant_handler_->ReloadContent(dictionary);
+}
+
+void AssistantOptInUI::OnUpdateSettingsResponse(const std::string& result) {
+ assistant::SettingsUiUpdateResult ui_result;
+ ui_result.ParseFromString(result);
+
+ DCHECK(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.";
+ }
+
+ // More screens to be added. Close the dialog for now.
+ PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
+ prefs->SetBoolean(arc::prefs::kArcVoiceInteractionValuePropAccepted, true);
+ prefs->SetBoolean(arc::prefs::kVoiceInteractionEnabled, true);
+ CloseDialog(nullptr);
}
// AssistantOptInDialog
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 7fff5334be4..1d6b7687462 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
@@ -9,34 +9,48 @@
#include "base/callback.h"
#include "base/macros.h"
+#include "chrome/browser/chromeos/arc/voice_interaction/voice_interaction_controller_client.h"
+#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_handler.h"
#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_screen_exit_code.h"
#include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h"
#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
+#include "chromeos/services/assistant/public/mojom/settings.mojom.h"
#include "content/public/browser/web_ui_controller.h"
#include "ui/web_dialogs/web_dialog_ui.h"
-namespace arc {
-class ArcVoiceInteractionArcHomeService;
-}
-
namespace chromeos {
// Controller for chrome://assistant-optin/ page.
-class AssistantOptInUI : public ui::WebDialogUI {
+class AssistantOptInUI
+ : public ui::WebDialogUI,
+ public arc::VoiceInteractionControllerClient::Observer {
public:
explicit AssistantOptInUI(content::WebUI* web_ui);
~AssistantOptInUI() override;
+ // arc::VoiceInteractionControllerClient::Observer overrides
+ void OnStateChanged(ash::mojom::VoiceInteractionState state) override;
+
private:
+ // Initilize connection to settings manager.
+ void Initialize();
+
// 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);
- // Get ArcHomeService for user action handling.
- arc::ArcVoiceInteractionArcHomeService* GetVoiceInteractionHomeService();
+ // Handle response from the settings manager.
+ void OnGetSettingsResponse(const std::string& settings);
+ void OnUpdateSettingsResponse(const std::string& settings);
+
+ // Consent token used to complete the opt-in.
+ std::string consent_token_;
+ AssistantOptInHandler* assistant_handler_ = nullptr;
+ std::unique_ptr<JSCallsContainer> js_calls_container_;
+ assistant::mojom::AssistantSettingsManagerPtr settings_manager_;
std::vector<BaseWebUIHandler*> screen_handlers_;
base::WeakPtrFactory<AssistantOptInUI> weak_factory_;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.cc
index e601e28f4a0..5cc5e1da71c 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/assistant_optin/value_prop_screen_handler.cc
@@ -30,19 +30,17 @@ ValuePropScreenHandler::~ValuePropScreenHandler() = default;
void ValuePropScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
builder->Add("locale", g_browser_process->GetApplicationLocale());
- builder->Add("voiceInteractionValuePropLoading",
- IDS_VOICE_INTERACTION_VALUE_PROP_LOADING);
- builder->Add("voiceInteractionValuePropLoadErrorTitle",
+ // TODO(updowndota) Replace this with new string constants.
+ // Use string constant for old flow for now before we have final UX.
+ builder->Add("valuePropLoading", IDS_VOICE_INTERACTION_VALUE_PROP_LOADING);
+ builder->Add("valuePropLoadErrorTitle",
IDS_VOICE_INTERACTION_VALUE_PROP_LOAD_ERROR_TITLE);
- builder->Add("voiceInteractionValuePropLoadErrorMessage",
+ builder->Add("valuePropLoadErrorMessage",
IDS_VOICE_INTERACTION_VALUE_PROP_LOAD_ERROR_MESSAGE);
- builder->Add("voiceInteractionValuePropSkipButton",
- IDS_VOICE_INTERACTION_VALUE_PROP_SKIP_BUTTON);
- builder->Add("voiceInteractionValuePropRetryButton",
+ builder->Add("valuePropRetryButton",
IDS_VOICE_INTERACTION_VALUE_PROP_RETRY_BUTTON);
- builder->Add("voiceInteractionValuePropNextButton",
- IDS_VOICE_INTERACTION_VALUE_PROP_NEXT_BUTTION);
-
+ builder->Add("valuePropMoreButton",
+ IDS_VOICE_INTERACTION_VALUE_PROP_MORE_BUTTION);
builder->Add("back", IDS_EULA_BACK_BUTTON);
builder->Add("next", IDS_EULA_NEXT_BUTTON);
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc
index 495bd41c242..2a0a1b3bdf6 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/bluetooth_pairing_dialog.cc
@@ -19,7 +19,7 @@ namespace chromeos {
namespace {
-constexpr int kBluetoothPairingDialogHeight = 400;
+constexpr int kBluetoothPairingDialogHeight = 350;
void AddBluetoothStrings(content::WebUIDataSource* html_source) {
struct {
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 20001250450..eb336106ca9 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
@@ -138,6 +138,7 @@ std::string FormatEntry(const base::FilePath& path,
StringAppendF(&out, " shared: %s\n", entry.shared() ? "true" : "false");
StringAppendF(&out, " shared_with_me: %s\n",
entry.shared_with_me() ? "true" : "false");
+ StringAppendF(&out, " alternate_url: %s\n", entry.alternate_url().c_str());
const drive::PlatformFileInfoProto& file_info = entry.file_info();
StringAppendF(&out, " file_info\n");
@@ -167,8 +168,6 @@ std::string FormatEntry(const base::FilePath& path,
if (entry.has_file_specific_info()) {
const drive::FileSpecificInfo& file_specific_info =
entry.file_specific_info();
- StringAppendF(&out, " alternate_url: %s\n",
- file_specific_info.alternate_url().c_str());
StringAppendF(&out, " content_mime_type: %s\n",
file_specific_info.content_mime_type().c_str());
StringAppendF(&out, " file_md5: %s\n",
@@ -556,8 +555,8 @@ void DriveInternalsWebUIHandler::OnGetFilesystemMetadataForLocal(
DCHECK_CURRENTLY_ON(BrowserThread::UI);
base::DictionaryValue local_metadata;
- local_metadata.SetDouble("account-largest-changestamp-local",
- metadata.largest_changestamp);
+ local_metadata.SetString("account-start-page-token-local",
+ metadata.start_page_token);
local_metadata.SetBoolean("account-metadata-refreshing", metadata.refreshing);
web_ui()->CallJavascriptFunctionUnsafe("updateLocalMetadata", local_metadata);
}
@@ -712,7 +711,7 @@ void DriveInternalsWebUIHandler::UpdateLocalStorageUsageSection() {
// Propagate the amount of local free space in bytes.
base::FilePath home_path;
- if (PathService::Get(base::DIR_HOME, &home_path)) {
+ if (base::PathService::Get(base::DIR_HOME, &home_path)) {
base::DictionaryValue* local_storage_summary = new base::DictionaryValue;
base::PostTaskWithTraitsAndReply(
FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
diff --git a/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc
index 72550162ed7..8aa100ecda3 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_handler.cc
@@ -368,7 +368,7 @@ void DeviceEmulatorMessageHandler::UpdateBatteryPercent(
int new_percent;
if (args->GetInteger(0, &new_percent)) {
power_manager::PowerSupplyProperties props =
- fake_power_manager_client_->props();
+ *fake_power_manager_client_->GetLastStatus();
props.set_battery_percent(new_percent);
fake_power_manager_client_->UpdatePowerProperties(props);
}
@@ -379,7 +379,7 @@ void DeviceEmulatorMessageHandler::UpdateBatteryState(
int battery_state;
if (args->GetInteger(0, &battery_state)) {
power_manager::PowerSupplyProperties props =
- fake_power_manager_client_->props();
+ *fake_power_manager_client_->GetLastStatus();
props.set_battery_state(
static_cast<power_manager::PowerSupplyProperties_BatteryState>(
battery_state));
@@ -392,7 +392,7 @@ void DeviceEmulatorMessageHandler::UpdateTimeToEmpty(
int new_time;
if (args->GetInteger(0, &new_time)) {
power_manager::PowerSupplyProperties props =
- fake_power_manager_client_->props();
+ *fake_power_manager_client_->GetLastStatus();
props.set_battery_time_to_empty_sec(new_time);
fake_power_manager_client_->UpdatePowerProperties(props);
}
@@ -403,7 +403,7 @@ void DeviceEmulatorMessageHandler::UpdateTimeToFull(
int new_time;
if (args->GetInteger(0, &new_time)) {
power_manager::PowerSupplyProperties props =
- fake_power_manager_client_->props();
+ *fake_power_manager_client_->GetLastStatus();
props.set_battery_time_to_full_sec(new_time);
fake_power_manager_client_->UpdatePowerProperties(props);
}
@@ -414,7 +414,7 @@ void DeviceEmulatorMessageHandler::UpdatePowerSources(
const base::ListValue* sources;
CHECK(args->GetList(0, &sources));
power_manager::PowerSupplyProperties props =
- fake_power_manager_client_->props();
+ *fake_power_manager_client_->GetLastStatus();
std::string selected_id = props.external_power_source_id();
diff --git a/chromium/chrome/browser/ui/webui/chromeos/first_run/DEPS b/chromium/chrome/browser/ui/webui/chromeos/first_run/DEPS
deleted file mode 100644
index 5d44c603bdf..00000000000
--- a/chromium/chrome/browser/ui/webui/chromeos/first_run/DEPS
+++ /dev/null
@@ -1,7 +0,0 @@
-specific_include_rules = {
- "first_run_ui\.cc": [
- # TODO(mash): Remove. http://crbug.com/770866
- "+ash/shell.h",
- "+ash/shelf/shelf.h",
- ],
-}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_ui.cc
index c666cf8c720..46fa96ea619 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/first_run/first_run_ui.cc
@@ -6,8 +6,7 @@
#include <memory>
-#include "ash/shelf/shelf.h"
-#include "ash/shell.h"
+#include "ash/public/cpp/shelf_prefs.h"
#include "base/command_line.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
@@ -21,6 +20,8 @@
#include "content/public/browser/web_ui_data_source.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h"
+#include "ui/display/display.h"
+#include "ui/display/screen.h"
namespace {
@@ -29,7 +30,8 @@ const char kShelfAlignmentBottom[] = "bottom";
const char kShelfAlignmentLeft[] = "left";
const char kShelfAlignmentRight[] = "right";
-void SetLocalizedStrings(base::DictionaryValue* localized_strings) {
+void SetLocalizedStrings(Profile* profile,
+ base::DictionaryValue* localized_strings) {
localized_strings->SetString(
"appListHeader",
l10n_util::GetStringUTF16(IDS_FIRST_RUN_APP_LIST_STEP_HEADER));
@@ -62,9 +64,11 @@ void SetLocalizedStrings(base::DictionaryValue* localized_strings) {
localized_strings->SetString(
"accessibleTitle",
l10n_util::GetStringUTF16(IDS_FIRST_RUN_STEP_ACCESSIBLE_TITLE));
- ash::Shelf* shelf = ash::Shelf::ForWindow(ash::Shell::GetPrimaryRootWindow());
+ ash::ShelfAlignment alignment = ash::GetShelfAlignmentPref(
+ profile->GetPrefs(),
+ display::Screen::GetScreen()->GetPrimaryDisplay().id());
std::string shelf_alignment;
- switch (shelf->alignment()) {
+ switch (alignment) {
case ash::SHELF_ALIGNMENT_BOTTOM:
case ash::SHELF_ALIGNMENT_BOTTOM_LOCKED:
shelf_alignment = kShelfAlignmentBottom;
@@ -79,7 +83,7 @@ void SetLocalizedStrings(base::DictionaryValue* localized_strings) {
localized_strings->SetString("shelfAlignment", shelf_alignment);
}
-content::WebUIDataSource* CreateDataSource() {
+content::WebUIDataSource* CreateDataSource(Profile* profile) {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIFirstRunHost);
source->SetJsonPath("strings.js");
@@ -88,7 +92,7 @@ content::WebUIDataSource* CreateDataSource() {
base::DictionaryValue localized_strings;
const std::string& app_locale = g_browser_process->GetApplicationLocale();
webui::SetLoadTimeDataDefaults(app_locale, &localized_strings);
- SetLocalizedStrings(&localized_strings);
+ SetLocalizedStrings(profile, &localized_strings);
source->AddLocalizedStrings(localized_strings);
return source;
}
@@ -103,7 +107,8 @@ FirstRunUI::FirstRunUI(content::WebUI* web_ui)
auto handler = std::make_unique<FirstRunHandler>();
actor_ = handler.get();
web_ui->AddMessageHandler(std::move(handler));
- content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), CreateDataSource());
+ Profile* profile = Profile::FromWebUI(web_ui);
+ content::WebUIDataSource::Add(profile, CreateDataSource(profile));
}
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc
index c197c33b4de..bf1b2908c44 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc
@@ -274,6 +274,11 @@ struct I18nContentToMessage {
{"keyboardOverlayDisableCapsLock", IDS_KEYBOARD_OVERLAY_DISABLE_CAPS_LOCK},
{"keyboardOverlayToggleChromevoxSpokenFeedback",
IDS_KEYBOARD_OVERLAY_TOGGLE_CHROMEVOX_SPOKEN_FEEDBACK},
+ {"keyboardOverlayToggleDictation", IDS_KEYBOARD_OVERLAY_TOGGLE_DICTATION},
+ {"keyboardOverlayToggleDockedMagnifier",
+ IDS_KEYBOARD_OVERLAY_TOGGLE_DOCKED_MAGNIFIER},
+ {"keyboardOverlayToggleFullscreenMagnifier",
+ IDS_KEYBOARD_OVERLAY_TOGGLE_FULLSCREEN_MAGNIFIER},
{"keyboardOverlayToggleHighContrastMode",
IDS_KEYBOARD_OVERLAY_TOGGLE_HIGH_CONTRAST_MODE},
{"keyboardOverlayToggleProjectionTouchHud",
diff --git a/chromium/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui_browsertest.cc
index d460b5a77da..7e96f446ba0 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui_browsertest.cc
@@ -167,7 +167,7 @@ IN_PROC_BROWSER_TEST_F(KeyboardOverlayUIBrowserTest,
}
}
- constexpr int kExpectedFoundAccelerators = 60;
+ constexpr int kExpectedFoundAccelerators = 62;
DCHECK_EQ(kExpectedFoundAccelerators, found_accelerators)
<< "It seems ash::kAcceleratorData or the 'shortcut' section of "
"'/chrome/browser/resources/chromeos/keyboard_overlay_data.js' has "
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/DEPS b/chromium/chrome/browser/ui/webui/chromeos/login/DEPS
index c2770adaae7..da871fcd8bd 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/DEPS
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/DEPS
@@ -27,11 +27,9 @@ specific_include_rules = {
"signin_screen_handler\.cc": [
"+ash/detachable_base",
"+ash/shell.h",
- "+ash/wallpaper/wallpaper_controller.h",
],
"signin_screen_handler\.h": [
"+ash/detachable_base/detachable_base_observer.h",
- "+ash/wallpaper/wallpaper_controller_observer.h",
],
"signin_userlist_unittest\.cc": [
"+ash/test/ash_test_base.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/OWNERS b/chromium/chrome/browser/ui/webui/chromeos/login/OWNERS
index 675ddd2e1d0..5a1a5f7ca14 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/OWNERS
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/OWNERS
@@ -1,3 +1,4 @@
achuith@chromium.org
alemate@chromium.org
jdufault@chromium.org
+per-file *active_directory*=rsorokin@chromium.org
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.cc
index 684dfbfeecf..c317f4fe707 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.cc
@@ -107,12 +107,11 @@ void ActiveDirectoryPasswordChangeScreenHandler::OnAuthFinished(
DCHECK(LoginDisplayHost::default_host());
LoginDisplayHost::default_host()->SetDisplayAndGivenName(
account_info.display_name(), account_info.given_name());
- UserContext user_context(account_id);
+ UserContext user_context(
+ user_manager::UserType::USER_TYPE_ACTIVE_DIRECTORY, account_id);
user_context.SetKey(key);
user_context.SetAuthFlow(UserContext::AUTH_FLOW_ACTIVE_DIRECTORY);
user_context.SetIsUsingOAuth(false);
- user_context.SetUserType(
- user_manager::UserType::USER_TYPE_ACTIVE_DIRECTORY);
LoginDisplayHost::default_host()->CompleteLogin(user_context);
break;
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.cc
index 5b65c12904d..79aa13e3464 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.cc
@@ -52,6 +52,8 @@ AppLaunchSplashScreenHandler::AppLaunchSplashScreenHandler(
AppLaunchSplashScreenHandler::~AppLaunchSplashScreenHandler() {
network_state_informer_->RemoveObserver(this);
+ if (delegate_)
+ delegate_->OnDeletingSplashScreenView();
}
void AppLaunchSplashScreenHandler::DeclareLocalizedValues(
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.cc
index 5363e53632c..b271749e419 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.cc
@@ -28,7 +28,10 @@ ArcKioskSplashScreenHandler::ArcKioskSplashScreenHandler()
set_call_js_prefix(kJsScreenPath);
}
-ArcKioskSplashScreenHandler::~ArcKioskSplashScreenHandler() = default;
+ArcKioskSplashScreenHandler::~ArcKioskSplashScreenHandler() {
+ if (delegate_)
+ delegate_->OnDeletingSplashScreenView();
+}
void ArcKioskSplashScreenHandler::DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) {
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 1051eee4e93..00095745435 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.h"
+#include "base/command_line.h"
#include "base/i18n/timezone.h"
#include "chrome/browser/chromeos/arc/arc_support_host.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
@@ -117,11 +118,7 @@ void ArcTermsOfServiceScreenHandler::DeclareLocalizedValues(
IDS_ARC_OPT_IN_LEARN_MORE_BACKUP_AND_RESTORE);
builder->Add("arcLearnMorePaiService", IDS_ARC_OPT_IN_LEARN_MORE_PAI_SERVICE);
builder->Add("arcOverlayClose", IDS_ARC_OOBE_TERMS_POPUP_HELP_CLOSE_BUTTON);
-}
-
-void ArcTermsOfServiceScreenHandler::SendArcManagedStatus(Profile* profile) {
- CallJS("setArcManaged",
- arc::IsArcPlayStoreEnabledPreferenceManagedForProfile(profile));
+ builder->Add("arcOverlayLoading", IDS_ARC_POPUP_HELP_LOADING);
}
void ArcTermsOfServiceScreenHandler::OnMetricsModeChanged(bool enabled,
@@ -221,13 +218,21 @@ void ArcTermsOfServiceScreenHandler::DoShow() {
// ARC is enabled (prefs::kArcEnabled = true) on showing Terms of Service. If
// user accepts ToS then prefs::kArcEnabled is left activated. If user skips
// ToS then prefs::kArcEnabled is automatically reset in ArcSessionManager.
- profile->GetPrefs()->SetBoolean(arc::prefs::kArcEnabled, true);
+ arc::SetArcPlayStoreEnabledForProfile(profile, true);
+
+ // Hide the Skip button if the ToS screen can not be skipped during OOBE.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kEnableArcOobeOptinNoSkip)) {
+ CallJS("hideSkipButton");
+ }
action_taken_ = false;
ShowScreen(kScreenId);
- SendArcManagedStatus(profile);
+ arc_managed_ = arc::IsArcPlayStoreEnabledPreferenceManagedForProfile(profile);
+ CallJS("setArcManaged", arc_managed_);
+
MaybeLoadPlayStoreToS(true);
StartNetworkAndTimeZoneObserving();
@@ -243,53 +248,80 @@ bool ArcTermsOfServiceScreenHandler::NeedDispatchEventOnAction() {
return true;
}
-void ArcTermsOfServiceScreenHandler::HandleSkip() {
- if (!NeedDispatchEventOnAction())
- return;
-
- for (auto& observer : observer_list_)
- observer.OnSkip();
-}
-
-void ArcTermsOfServiceScreenHandler::HandleAccept(
- bool enable_backup_restore,
- bool enable_location_services,
- const std::string& tos_content) {
- if (!NeedDispatchEventOnAction())
- return;
- pref_handler_->EnableBackupRestore(enable_backup_restore);
- pref_handler_->EnableLocationService(enable_location_services);
-
+void ArcTermsOfServiceScreenHandler::RecordConsents(
+ const std::string& tos_content,
+ bool record_tos_content,
+ bool tos_accepted,
+ bool record_backup_consent,
+ bool backup_accepted,
+ bool record_location_consent,
+ bool location_accepted) {
Profile* profile = ProfileManager::GetActiveUserProfile();
consent_auditor::ConsentAuditor* consent_auditor =
ConsentAuditorFactory::GetForProfile(profile);
SigninManagerBase* signin_manager =
SigninManagerFactory::GetForProfile(profile);
DCHECK(signin_manager->IsAuthenticated());
- std::string account_id = signin_manager->GetAuthenticatedAccountId();
+ const std::string account_id = signin_manager->GetAuthenticatedAccountId();
+
+ // TODO(jhorwich): Replace this approach when passing |is_managed| boolean is
+ // supported by the underlying consent protos.
+ const std::vector<int> consent_ids = ArcSupportHost::ComputePlayToSConsentIds(
+ record_tos_content ? tos_content : "");
- // Record acceptance of Play ToS.
consent_auditor->RecordGaiaConsent(
- account_id, consent_auditor::Feature::PLAY_STORE,
- ArcSupportHost::ComputePlayToSConsentIds(tos_content),
- IDS_ARC_OOBE_TERMS_BUTTON_ACCEPT, consent_auditor::ConsentStatus::GIVEN);
+ account_id, consent_auditor::Feature::PLAY_STORE, consent_ids,
+ IDS_ARC_OOBE_TERMS_BUTTON_ACCEPT,
+ tos_accepted ? consent_auditor::ConsentStatus::GIVEN
+ : consent_auditor::ConsentStatus::NOT_GIVEN);
- // If the user - not policy - chose Backup and Restore, record consent.
- if (enable_backup_restore && !backup_restore_managed_) {
+ if (record_backup_consent) {
consent_auditor->RecordGaiaConsent(
account_id, consent_auditor::Feature::BACKUP_AND_RESTORE,
{IDS_ARC_OPT_IN_DIALOG_BACKUP_RESTORE},
IDS_ARC_OOBE_TERMS_BUTTON_ACCEPT,
- consent_auditor::ConsentStatus::GIVEN);
+ backup_accepted ? consent_auditor::ConsentStatus::GIVEN
+ : consent_auditor::ConsentStatus::NOT_GIVEN);
}
- // If the user - not policy - chose Location Services, record consent.
- if (enable_location_services && !location_services_managed_) {
+ if (record_location_consent) {
consent_auditor->RecordGaiaConsent(
account_id, consent_auditor::Feature::GOOGLE_LOCATION_SERVICE,
{IDS_ARC_OPT_IN_LOCATION_SETTING}, IDS_ARC_OOBE_TERMS_BUTTON_ACCEPT,
- consent_auditor::ConsentStatus::GIVEN);
+ location_accepted ? consent_auditor::ConsentStatus::GIVEN
+ : consent_auditor::ConsentStatus::NOT_GIVEN);
}
+}
+
+void ArcTermsOfServiceScreenHandler::HandleSkip(
+ const std::string& tos_content) {
+ if (!NeedDispatchEventOnAction())
+ return;
+
+ // Record consents as not accepted for consents that are under user control
+ // when the user skips ARC setup.
+ RecordConsents(tos_content, !arc_managed_, /*tos_accepted=*/false,
+ !backup_restore_managed_, /*backup_accepted=*/false,
+ !location_services_managed_, /*location_accepted=*/false);
+
+ for (auto& observer : observer_list_)
+ observer.OnSkip();
+}
+
+void ArcTermsOfServiceScreenHandler::HandleAccept(
+ bool enable_backup_restore,
+ bool enable_location_services,
+ const std::string& tos_content) {
+ if (!NeedDispatchEventOnAction())
+ return;
+ pref_handler_->EnableBackupRestore(enable_backup_restore);
+ pref_handler_->EnableLocationService(enable_location_services);
+
+ // Record consents as accepted or not accepted as appropriate for consents
+ // that are under user control when the user completes ARC setup.
+ RecordConsents(tos_content, !arc_managed_, /*tos_accepted=*/true,
+ !backup_restore_managed_, enable_backup_restore,
+ !location_services_managed_, enable_location_services);
for (auto& observer : observer_list_)
observer.OnAccept();
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.h
index bac38856df3..45d39e2d912 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/arc_terms_of_service_screen_handler.h
@@ -17,8 +17,6 @@
#include "chromeos/network/network_state_handler_observer.h"
#include "chromeos/settings/timezone_settings.h"
-class Profile;
-
namespace arc {
class ArcOptInPreferenceHandler;
}
@@ -66,7 +64,7 @@ class ArcTermsOfServiceScreenHandler
void Initialize() override;
void DoShow();
- void HandleSkip();
+ void HandleSkip(const std::string& tos_content);
void HandleAccept(bool enable_backup_restore,
bool enable_location_services,
const std::string& tos_content);
@@ -76,8 +74,15 @@ class ArcTermsOfServiceScreenHandler
void StartNetworkAndTimeZoneObserving();
- // Sends if Arc enable status is manged to screen.
- void SendArcManagedStatus(Profile* profile);
+ // Handles the recording of consent given or not given after the user chooses
+ // to skip or accept.
+ void RecordConsents(const std::string& tos_content,
+ bool record_tos_content,
+ bool tos_accepted,
+ bool record_backup_consent,
+ bool backup_accepted,
+ bool record_location_consent,
+ bool location_accepted);
bool NeedDispatchEventOnAction();
@@ -97,6 +102,9 @@ class ArcTermsOfServiceScreenHandler
// To filter out duplicate notifications from html.
bool action_taken_ = false;
+ // To track if ARC preference is managed.
+ bool arc_managed_ = false;
+
// To track if optional features are managed preferences.
bool backup_restore_managed_ = false;
bool location_services_managed_ = false;
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 323811e0f43..6dfcccf4581 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc
@@ -6,6 +6,8 @@
#include <type_traits>
+#include "ash/public/interfaces/constants.mojom.h"
+#include "ash/public/interfaces/event_rewriter_controller.mojom.h"
#include "ash/shell.h"
#include "base/bind.h"
#include "base/strings/utf_string_conversions.h"
@@ -13,7 +15,6 @@
#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/events/keyboard_driven_event_rewriter.h"
#include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h"
#include "chrome/browser/chromeos/login/helper.h"
#include "chrome/browser/chromeos/login/lock/screen_locker.h"
@@ -42,7 +43,9 @@
#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_strings.h"
#include "components/version_info/version_info.h"
+#include "content/public/common/service_manager_connection.h"
#include "google_apis/google_api_keys.h"
+#include "services/service_manager/public/cpp/connector.h"
#include "ui/aura/window_tree_host.h"
#include "ui/display/display.h"
#include "ui/display/manager/display_manager.h"
@@ -194,6 +197,7 @@ void CoreOobeHandler::RegisterMessages() {
&CoreOobeHandler::HandleSetOobeBootstrappingSlave);
AddRawCallback("getPrimaryDisplayNameForTesting",
&CoreOobeHandler::HandleGetPrimaryDisplayNameForTesting);
+ AddCallback("setupDemoMode", &CoreOobeHandler::HandleSetupDemoMode);
}
void CoreOobeHandler::ShowSignInError(
@@ -302,11 +306,14 @@ void CoreOobeHandler::HandleUpdateCurrentScreen(
const std::string& screen_name) {
const OobeScreen screen = GetOobeScreenFromName(screen_name);
oobe_ui_->CurrentScreenChanged(screen);
- // TODO(mash): Support EventRewriterController; see crbug.com/647781
- if (!ash_util::IsRunningInMash()) {
- KeyboardDrivenEventRewriter::GetInstance()->SetArrowToTabRewritingEnabled(
- screen == OobeScreen::SCREEN_OOBE_EULA);
- }
+
+ content::ServiceManagerConnection* connection =
+ content::ServiceManagerConnection::GetForProcess();
+ ash::mojom::EventRewriterControllerPtr event_rewriter_controller_ptr;
+ connection->GetConnector()->BindInterface(ash::mojom::kServiceName,
+ &event_rewriter_controller_ptr);
+ event_rewriter_controller_ptr->SetArrowToTabRewritingEnabled(
+ screen == OobeScreen::SCREEN_OOBE_EULA);
}
void CoreOobeHandler::HandleEnableHighContrast(bool enabled) {
@@ -381,12 +388,13 @@ void CoreOobeHandler::HandleToggleResetScreen() {
->IsEnterpriseManaged()) {
// Powerwash is only available if allowed by the admin specifically for the
// purpose of installing a TPM firmware update.
- tpm_firmware_update::ShouldOfferUpdateViaPowerwash(
- base::BindOnce([](bool offer_update) {
- if (offer_update) {
+ tpm_firmware_update::GetAvailableUpdateModes(
+ base::BindOnce([](const std::set<tpm_firmware_update::Mode>& modes) {
+ if (modes.count(tpm_firmware_update::Mode::kPowerwash) > 0) {
// Force the TPM firmware update option to be enabled.
- g_browser_process->local_state()->SetBoolean(
- prefs::kFactoryResetTPMFirmwareUpdateRequested, true);
+ g_browser_process->local_state()->SetInteger(
+ prefs::kFactoryResetTPMFirmwareUpdateMode,
+ static_cast<int>(tpm_firmware_update::Mode::kPowerwash));
LaunchResetScreen();
}
}),
@@ -400,7 +408,8 @@ void CoreOobeHandler::HandleToggleResetScreen() {
// effect of dropping the FRE requirement if it was previously in effect.
const AutoEnrollmentController::FRERequirement requirement =
AutoEnrollmentController::GetFRERequirement();
- if (requirement != AutoEnrollmentController::EXPLICITLY_REQUIRED) {
+ if (requirement !=
+ AutoEnrollmentController::FRERequirement::kExplicitlyRequired) {
LaunchResetScreen();
}
}
@@ -424,6 +433,10 @@ void CoreOobeHandler::UpdateShutdownAndRebootVisibility(
CallJSOrDefer("showShutdown", !reboot_on_shutdown);
}
+void CoreOobeHandler::SetLoginUserCount(int user_count) {
+ CallJSOrDefer("setLoginUserCount", user_count);
+}
+
void CoreOobeHandler::UpdateA11yState() {
if (ash_util::IsRunningInMash()) {
NOTIMPLEMENTED();
@@ -575,6 +588,19 @@ void CoreOobeHandler::HandleGetPrimaryDisplayNameForTesting(
ResolveJavascriptCallback(*callback_id, base::Value(display_name));
}
+void CoreOobeHandler::HandleSetupDemoMode() {
+ const bool is_demo_mode_enabled =
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kEnableDemoMode);
+ if (!is_demo_mode_enabled)
+ return;
+
+ WizardController* wizard_controller = WizardController::default_controller();
+ if (wizard_controller && !wizard_controller->login_screen_started()) {
+ 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 2579735ea1f..9c57496980d 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
@@ -77,6 +77,9 @@ class CoreOobeHandler : public BaseWebUIHandler,
// false.
void UpdateShutdownAndRebootVisibility(bool reboot_on_shutdown);
+ // Notify WebUI of the user count on the views login screen.
+ void SetLoginUserCount(int user_count);
+
private:
// CoreOobeView implementation:
void ShowSignInError(int login_attempts,
@@ -130,6 +133,7 @@ class CoreOobeHandler : public BaseWebUIHandler,
void HandleHeaderBarVisible();
void HandleSetOobeBootstrappingSlave();
void HandleGetPrimaryDisplayNameForTesting(const base::ListValue* args);
+ void HandleSetupDemoMode();
// When keyboard_utils.js arrow key down event is reached, raise it
// to tab/shift-tab event.
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc
index 499a1fcd208..a03537115f1 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc
@@ -367,6 +367,7 @@ void EncryptionMigrationScreenHandler::DeclareLocalizedValues(
IDS_ENCRYPTION_MIGRATION_BUTTON_CONTINUE);
builder->Add("migrationButtonSignIn", IDS_ENCRYPTION_MIGRATION_BUTTON_SIGNIN);
builder->Add("migrationButtonReportAnIssue", IDS_REPORT_AN_ISSUE);
+ builder->Add("migrationBoardName", base::SysInfo::GetLsbReleaseBoard());
builder->Add("gaiaLoading", IDS_LOGIN_GAIA_LOADING_MESSAGE);
}
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler_unittest.cc b/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler_unittest.cc
index 1e60a10482e..567d7be991b 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler_unittest.cc
@@ -21,7 +21,7 @@
#include "chromeos/dbus/power_policy_controller.h"
#include "chromeos/login/auth/key.h"
#include "chromeos/login/auth/user_context.h"
-#include "components/signin/core/account_id/account_id.h"
+#include "components/account_id/account_id.h"
#include "components/user_manager/scoped_user_manager.h"
#include "components/user_manager/user_names.h"
#include "content/public/test/test_web_ui.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc
index 8ecb85b0cf4..442b4f9a8e6 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
@@ -61,6 +61,7 @@ const char kEnrollmentModeUIRecovery[] = "recovery";
std::string EnrollmentModeToUIMode(policy::EnrollmentConfig::Mode mode) {
switch (mode) {
case policy::EnrollmentConfig::MODE_NONE:
+ case policy::EnrollmentConfig::MODE_OFFLINE_DEMO:
break;
case policy::EnrollmentConfig::MODE_MANUAL:
case policy::EnrollmentConfig::MODE_MANUAL_REENROLLMENT:
@@ -221,11 +222,80 @@ void EnrollmentScreenHandler::ShowLicenseTypeSelectionScreen(
ShowStep(kEnrollmentStepPickLicense);
}
-void EnrollmentScreenHandler::ShowAdJoin() {
+void EnrollmentScreenHandler::ShowActiveDirectoryScreen(
+ const std::string& machine_name,
+ const std::string& username,
+ authpolicy::ErrorType error) {
observe_network_failure_ = false;
- if (!authpolicy_login_helper_)
- authpolicy_login_helper_ = std::make_unique<AuthPolicyLoginHelper>();
- ShowStep(kEnrollmentStepAdJoin);
+ switch (error) {
+ case authpolicy::ERROR_NONE: {
+ CallJS("invalidateAd", machine_name, username,
+ static_cast<int>(ActiveDirectoryErrorState::NONE));
+ ShowStep(kEnrollmentStepAdJoin);
+ return;
+ }
+ case authpolicy::ERROR_NETWORK_PROBLEM:
+ // Could be a network problem, but could also be a misspelled domain name.
+ ShowError(IDS_AD_AUTH_NETWORK_ERROR, true);
+ return;
+ case authpolicy::ERROR_PARSE_UPN_FAILED:
+ case authpolicy::ERROR_BAD_USER_NAME:
+ CallJS("invalidateAd", machine_name, username,
+ static_cast<int>(ActiveDirectoryErrorState::BAD_USERNAME));
+ ShowStep(kEnrollmentStepAdJoin);
+ return;
+ case authpolicy::ERROR_BAD_PASSWORD:
+ CallJS("invalidateAd", machine_name, username,
+ static_cast<int>(ActiveDirectoryErrorState::BAD_PASSWORD));
+ ShowStep(kEnrollmentStepAdJoin);
+ return;
+ case authpolicy::ERROR_MACHINE_NAME_TOO_LONG:
+ CallJS(
+ "invalidateAd", machine_name, username,
+ static_cast<int>(ActiveDirectoryErrorState::MACHINE_NAME_TOO_LONG));
+ ShowStep(kEnrollmentStepAdJoin);
+ return;
+ case authpolicy::ERROR_INVALID_MACHINE_NAME:
+ CallJS("invalidateAd", machine_name, username,
+ static_cast<int>(ActiveDirectoryErrorState::MACHINE_NAME_INVALID));
+ ShowStep(kEnrollmentStepAdJoin);
+ return;
+ case authpolicy::ERROR_PASSWORD_EXPIRED:
+ ShowError(IDS_AD_PASSWORD_EXPIRED, true);
+ return;
+ case authpolicy::ERROR_JOIN_ACCESS_DENIED:
+ ShowError(IDS_AD_USER_DENIED_TO_JOIN_MACHINE, true);
+ return;
+ case authpolicy::ERROR_USER_HIT_JOIN_QUOTA:
+ ShowError(IDS_AD_USER_HIT_JOIN_QUOTA, true);
+ return;
+ case authpolicy::ERROR_OU_DOES_NOT_EXIST:
+ ShowError(IDS_AD_OU_DOES_NOT_EXIST, true);
+ return;
+ case authpolicy::ERROR_INVALID_OU:
+ ShowError(IDS_AD_OU_INVALID, true);
+ return;
+ case authpolicy::ERROR_OU_ACCESS_DENIED:
+ ShowError(IDS_AD_OU_ACCESS_DENIED, true);
+ return;
+ case authpolicy::ERROR_SETTING_OU_FAILED:
+ ShowError(IDS_AD_OU_SETTING_FAILED, true);
+ return;
+ case authpolicy::ERROR_KDC_DOES_NOT_SUPPORT_ENCRYPTION_TYPE:
+ ShowError(IDS_AD_NOT_SUPPORTED_ENCRYPTION, true);
+ return;
+#if !defined(ARCH_CPU_X86_64)
+ // Currently, the Active Directory integration is only supported on x86_64
+ // systems. (see https://crbug.com/676602)
+ case authpolicy::ERROR_DBUS_FAILURE:
+ ShowError(IDS_AD_BOARD_NOT_SUPPORTED, true);
+ return;
+#endif
+ default:
+ LOG(ERROR) << "Unhandled error code: " << error;
+ ShowError(IDS_AD_DOMAIN_JOIN_UNKNOWN_ERROR, true);
+ return;
+ }
}
void EnrollmentScreenHandler::ShowAttributePromptScreen(
@@ -589,8 +659,6 @@ void EnrollmentScreenHandler::HandleClose(const std::string& reason) {
DCHECK(controller_);
if (reason == "cancel") {
- if (authpolicy_login_helper_)
- authpolicy_login_helper_->CancelRequestsAndRestart();
controller_->OnCancel();
} else if (reason == "done") {
controller_->OnConfirmationClosed();
@@ -616,82 +684,8 @@ void EnrollmentScreenHandler::HandleAdCompleteLogin(
const std::string& password) {
observe_network_failure_ = false;
DCHECK(controller_);
- DCHECK(authpolicy_login_helper_);
- authpolicy_login_helper_->JoinAdDomain(
- machine_name, distinguished_name, encryption_types, user_name, password,
- base::BindOnce(&EnrollmentScreenHandler::HandleAdDomainJoin,
- weak_ptr_factory_.GetWeakPtr(), machine_name, user_name));
-}
-
-void EnrollmentScreenHandler::HandleAdDomainJoin(
- const std::string& machine_name,
- const std::string& user_name,
- authpolicy::ErrorType code,
- const std::string& machine_domain) {
- switch (code) {
- case authpolicy::ERROR_NONE: {
- ShowEnrollmentSpinnerScreen();
- controller_->OnAdJoined(machine_domain);
- return;
- }
- case authpolicy::ERROR_NETWORK_PROBLEM:
- // Could be a network problem, but could also be a misspelled domain name.
- ShowError(IDS_AD_AUTH_NETWORK_ERROR, true);
- return;
- case authpolicy::ERROR_PARSE_UPN_FAILED:
- case authpolicy::ERROR_BAD_USER_NAME:
- CallJS("invalidateAd", machine_name, user_name,
- static_cast<int>(ActiveDirectoryErrorState::BAD_USERNAME));
- return;
- case authpolicy::ERROR_BAD_PASSWORD:
- CallJS("invalidateAd", machine_name, user_name,
- static_cast<int>(ActiveDirectoryErrorState::BAD_PASSWORD));
- return;
- case authpolicy::ERROR_MACHINE_NAME_TOO_LONG:
- CallJS(
- "invalidateAd", machine_name, user_name,
- static_cast<int>(ActiveDirectoryErrorState::MACHINE_NAME_TOO_LONG));
- return;
- case authpolicy::ERROR_INVALID_MACHINE_NAME:
- CallJS("invalidateAd", machine_name, user_name,
- static_cast<int>(ActiveDirectoryErrorState::MACHINE_NAME_INVALID));
- return;
- case authpolicy::ERROR_PASSWORD_EXPIRED:
- ShowError(IDS_AD_PASSWORD_EXPIRED, true);
- return;
- case authpolicy::ERROR_JOIN_ACCESS_DENIED:
- ShowError(IDS_AD_USER_DENIED_TO_JOIN_MACHINE, true);
- return;
- case authpolicy::ERROR_USER_HIT_JOIN_QUOTA:
- ShowError(IDS_AD_USER_HIT_JOIN_QUOTA, true);
- return;
- case authpolicy::ERROR_OU_DOES_NOT_EXIST:
- ShowError(IDS_AD_OU_DOES_NOT_EXIST, true);
- return;
- case authpolicy::ERROR_INVALID_OU:
- ShowError(IDS_AD_OU_INVALID, true);
- return;
- case authpolicy::ERROR_OU_ACCESS_DENIED:
- ShowError(IDS_AD_OU_ACCESS_DENIED, true);
- return;
- case authpolicy::ERROR_SETTING_OU_FAILED:
- ShowError(IDS_AD_OU_SETTING_FAILED, true);
- return;
- case authpolicy::ERROR_KDC_DOES_NOT_SUPPORT_ENCRYPTION_TYPE:
- ShowError(IDS_AD_NOT_SUPPORTED_ENCRYPTION, true);
- return;
-#if !defined(ARCH_CPU_X86_64)
- // Currently, the Active Directory integration is only supported on x86_64
- // systems. (see https://crbug.com/676602)
- case authpolicy::ERROR_DBUS_FAILURE:
- ShowError(IDS_AD_BOARD_NOT_SUPPORTED, true);
- return;
-#endif
- default:
- LOG(WARNING) << "Unhandled error code: " << code;
- ShowError(IDS_AD_DOMAIN_JOIN_UNKNOWN_ERROR, true);
- return;
- }
+ controller_->OnActiveDirectoryCredsProvided(
+ machine_name, distinguished_name, encryption_types, user_name, password);
}
void EnrollmentScreenHandler::HandleRetry() {
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h
index 93bfb3f7289..f34bde1bd4c 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h
@@ -15,12 +15,10 @@
#include "chrome/browser/chromeos/policy/enrollment_config.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
-#include "chromeos/dbus/auth_policy_client.h"
#include "net/base/net_errors.h"
namespace chromeos {
-class AuthPolicyLoginHelper;
class ErrorScreensHistogramHelper;
class HelpAppLauncher;
@@ -57,7 +55,9 @@ class EnrollmentScreenHandler
void ShowSigninScreen() override;
void ShowLicenseTypeSelectionScreen(
const base::DictionaryValue& license_types) override;
- void ShowAdJoin() override;
+ void ShowActiveDirectoryScreen(const std::string& machine_name,
+ const std::string& username,
+ authpolicy::ErrorType error) override;
void ShowAttributePromptScreen(const std::string& asset_id,
const std::string& location) override;
void ShowAttestationBasedEnrollmentSuccessScreen(
@@ -130,12 +130,6 @@ class EnrollmentScreenHandler
// enrollment sign-in page.
bool IsEnrollmentScreenHiddenByError() const;
- // Handler callback from AuthPolicyClient.
- void HandleAdDomainJoin(const std::string& machine_name,
- const std::string& user_name,
- authpolicy::ErrorType code,
- const std::string& machine_domain);
-
// Keeps the controller for this view.
Controller* controller_ = nullptr;
@@ -161,9 +155,6 @@ class EnrollmentScreenHandler
// Help application used for help dialogs.
scoped_refptr<HelpAppLauncher> help_app_;
- // Helper to call AuthPolicyClient and cancel calls if needed. Used to join
- // Active Directory domain.
- std::unique_ptr<AuthPolicyLoginHelper> authpolicy_login_helper_;
base::WeakPtrFactory<EnrollmentScreenHandler> weak_ptr_factory_;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.cc
index b8d7f9d35a7..ffa5c4b099d 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/error_screen_handler.cc
@@ -4,7 +4,6 @@
#include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h"
-#include "base/message_loop/message_loop.h"
#include "base/time/time.h"
#include "chrome/browser/chromeos/login/screens/error_screen.h"
#include "chrome/grit/chromium_strings.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc
index 9a56f4b08db..67624d3155c 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
@@ -6,19 +6,22 @@
#include <memory>
+#include "ash/public/cpp/ash_features.h"
#include "base/bind.h"
#include "base/callback.h"
+#include "base/containers/flat_set.h"
#include "base/feature_list.h"
#include "base/guid.h"
+#include "base/json/json_reader.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/stl_util.h"
+#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/sys_info.h"
#include "base/task_scheduler/post_task.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/chromeos/language_preferences.h"
#include "chrome/browser/chromeos/login/lock_screen_utils.h"
#include "chrome/browser/chromeos/login/reauth_stats.h"
@@ -28,12 +31,14 @@
#include "chrome/browser/chromeos/login/ui/login_display_host_webui.h"
#include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
#include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
+#include "chrome/browser/chromeos/login/users/chrome_user_manager_util.h"
#include "chrome/browser/chromeos/net/network_portal_detector_impl.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/policy/temp_certs_cache_nss.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/io_thread.h"
+#include "chrome/browser/lifetime/browser_shutdown.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h"
@@ -169,25 +174,15 @@ void UpdateAuthParams(base::DictionaryValue* params,
CrosSettings* cros_settings = CrosSettings::Get();
bool allow_new_user = true;
cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
- bool allow_guest = true;
- cros_settings->GetBoolean(kAccountsPrefAllowGuest, &allow_guest);
- params->SetBoolean("guestSignin", allow_guest);
+ params->SetBoolean(
+ "guestSignin",
+ chrome_user_manager_util::IsGuestSessionAllowed(cros_settings));
// nosignup flow if new users are not allowed.
if (!allow_new_user || is_restrictive_proxy)
params->SetString("flow", "nosignup");
- // Allow supervised user creation only if:
- // 1. Enterprise managed device > is allowed by policy.
- // 2. Consumer device > owner exists.
- // 3. New users are allowed by owner.
- // 4. Supervised users are allowed by owner.
- ChromeUserManager* user_manager = ChromeUserManager::Get();
- bool supervised_users_can_create =
- base::FeatureList::IsEnabled(features::kSupervisedUserCreation) &&
- user_manager->AreSupervisedUsersAllowed() && allow_new_user &&
- !user_manager->GetUsersAllowedForSupervisedUsersCreation().empty();
- params->SetBoolean("supervisedUsersCanCreate", supervised_users_can_create);
+ params->SetBoolean("supervisedUsersCanCreate", false);
// Now check whether we're in multi-profiles user adding scenario and
// disable GAIA right panel features if that's the case.
@@ -229,6 +224,36 @@ void GetVersionAndConsent(std::string* out_version, bool* out_consent) {
*out_consent = GoogleUpdateSettings::GetCollectStatsConsent();
}
+user_manager::UserType GetUsertypeFromServicesString(
+ const ::login::StringList& services) {
+ bool is_child = false;
+ const bool support_usm =
+ base::FeatureList::IsEnabled(features::kCrOSEnableUSMUserService);
+ using KnownFlags = base::flat_set<std::string>;
+ const KnownFlags known_flags =
+ support_usm ? KnownFlags({"uca", "usm"}) : KnownFlags({"uca"});
+
+ size_t i = 0;
+ for (const std::string& item : services) {
+ if (known_flags.find(item) != known_flags.end()) {
+ is_child = true;
+ }
+ ++i;
+ }
+
+ return is_child ? user_manager::USER_TYPE_CHILD
+ : user_manager::USER_TYPE_REGULAR;
+}
+
+user_manager::UserType CalculateUserType(const AccountId& account_id) {
+ if (user_manager::UserManager::Get()->IsSupervisedAccountId(account_id))
+ return user_manager::USER_TYPE_SUPERVISED;
+
+ if (account_id.GetAccountType() == AccountType::ACTIVE_DIRECTORY)
+ return user_manager::USER_TYPE_ACTIVE_DIRECTORY;
+
+ return user_manager::USER_TYPE_REGULAR;
+}
} // namespace
// A class that's used to specify the way how Gaia should be loaded.
@@ -285,8 +310,7 @@ void GaiaScreenHandler::MaybePreloadAuthExtension() {
if (!network_portal_detector_) {
NetworkPortalDetectorImpl* detector = new NetworkPortalDetectorImpl(
g_browser_process->system_network_context_manager()
- ->GetURLLoaderFactory(),
- false);
+ ->GetURLLoaderFactory());
detector->set_portal_test_url(GURL(kRestrictiveProxyURL));
network_portal_detector_.reset(detector);
network_portal_detector_->AddObserver(this);
@@ -351,11 +375,6 @@ void GaiaScreenHandler::LoadGaiaWithPartitionAndVersionAndConsent(
UpdateAuthParams(&params, IsRestrictiveProxy());
- int user_count = LoginDisplayHost::default_host()
- ? LoginDisplayHost::default_host()->GetUsers().size()
- : 0;
- params.SetInteger("userCount", user_count);
-
GaiaScreenMode screen_mode = GetGaiaScreenMode(context.email,
context.use_offline);
params.SetInteger("screenMode", screen_mode);
@@ -387,9 +406,14 @@ void GaiaScreenHandler::LoadGaiaWithPartitionAndVersionAndConsent(
g_browser_process->platform_part()
->browser_policy_connector_chromeos()
->IsEnterpriseManaged());
- params.SetBoolean(
- "hasDeviceOwner",
- user_manager::UserManager::Get()->GetOwnerAccountId().is_valid());
+ const AccountId& owner_account_id =
+ user_manager::UserManager::Get()->GetOwnerAccountId();
+ params.SetBoolean("hasDeviceOwner", owner_account_id.is_valid());
+ if (owner_account_id.is_valid() &&
+ user_manager::UserManager::Get()->FindUser(owner_account_id)->GetType() ==
+ user_manager::UserType::USER_TYPE_CHILD) {
+ params.SetString("obfuscatedOwnerId", owner_account_id.GetGaiaId());
+ }
params.SetString("chromeType", GetChromeType());
params.SetString("clientId",
@@ -651,12 +675,11 @@ void GaiaScreenHandler::DoAdAuth(
username, account_info.account_id(), AccountType::ACTIVE_DIRECTORY));
LoginDisplayHost::default_host()->SetDisplayAndGivenName(
account_info.display_name(), account_info.given_name());
- UserContext user_context(account_id);
+ UserContext user_context(
+ user_manager::UserType::USER_TYPE_ACTIVE_DIRECTORY, account_id);
user_context.SetKey(key);
user_context.SetAuthFlow(UserContext::AUTH_FLOW_ACTIVE_DIRECTORY);
user_context.SetIsUsingOAuth(false);
- user_context.SetUserType(
- user_manager::UserType::USER_TYPE_ACTIVE_DIRECTORY);
LoginDisplayHost::default_host()->CompleteLogin(user_context);
break;
}
@@ -708,7 +731,8 @@ void GaiaScreenHandler::HandleCompleteAuthentication(
const std::string& password,
const std::string& auth_code,
bool using_saml,
- const std::string& gaps_cookie) {
+ const std::string& gaps_cookie,
+ const ::login::StringList& services) {
if (!LoginDisplayHost::default_host())
return;
@@ -717,15 +741,15 @@ void GaiaScreenHandler::HandleCompleteAuthentication(
const std::string sanitized_email = gaia::SanitizeEmail(email);
LoginDisplayHost::default_host()->SetDisplayEmail(sanitized_email);
- UserContext user_context(GetAccountId(email, gaia_id, AccountType::GOOGLE));
+ const user_manager::UserType user_type =
+ GetUsertypeFromServicesString(services);
+
+ UserContext user_context(user_type,
+ GetAccountId(email, gaia_id, AccountType::GOOGLE));
user_context.SetKey(Key(password));
- // Only save the password for enterprise users. See https://crbug.com/386606.
- const bool is_enterprise_managed = g_browser_process->platform_part()
- ->browser_policy_connector_chromeos()
- ->IsEnterpriseManaged();
- if (is_enterprise_managed) {
- user_context.SetPasswordKey(Key(password));
- }
+ // Save the user's plaintext password for possible authentication to a
+ // network. See https://crbug.com/386606 for details.
+ user_context.SetPasswordKey(Key(password));
user_context.SetAuthCode(auth_code);
user_context.SetAuthFlow(using_saml
? UserContext::AUTH_FLOW_GAIA_WITH_SAML
@@ -787,8 +811,10 @@ void GaiaScreenHandler::HandleUpdateGaiaDialogSize(int width, int height) {
}
void GaiaScreenHandler::HandleUpdateGaiaDialogVisibility(bool visible) {
- if (LoginDisplayHost::default_host())
- LoginDisplayHost::default_host()->UpdateGaiaDialogVisibility(visible);
+ if (LoginDisplayHost::default_host()) {
+ LoginDisplayHost::default_host()->UpdateGaiaDialogVisibility(visible,
+ base::nullopt);
+ }
}
void GaiaScreenHandler::HandleShowAddUser(const base::ListValue* args) {
@@ -810,7 +836,7 @@ void GaiaScreenHandler::HandleShowAddUser(const base::ListValue* args) {
void GaiaScreenHandler::OnShowAddUser() {
signin_screen_handler_->is_account_picker_showing_first_time_ = false;
lock_screen_utils::EnforcePolicyInputMethods(std::string());
- ShowGaiaAsync();
+ ShowGaiaAsync(base::nullopt);
}
void GaiaScreenHandler::DoCompleteLogin(const std::string& gaia_id,
@@ -827,8 +853,14 @@ void GaiaScreenHandler::DoCompleteLogin(const std::string& gaia_id,
DCHECK(!gaia_id.empty());
const std::string sanitized_email = gaia::SanitizeEmail(typed_email);
LoginDisplayHost::default_host()->SetDisplayEmail(sanitized_email);
- UserContext user_context(
- GetAccountId(typed_email, gaia_id, AccountType::GOOGLE));
+ const AccountId account_id =
+ GetAccountId(typed_email, gaia_id, AccountType::GOOGLE);
+ const user_manager::User* const user =
+ user_manager::UserManager::Get()->FindUser(account_id);
+
+ UserContext user_context =
+ user ? UserContext(*user)
+ : UserContext(CalculateUserType(account_id), account_id);
user_context.SetKey(Key(password));
user_context.SetAuthFlow(using_saml
? UserContext::AUTH_FLOW_GAIA_WITH_SAML
@@ -884,12 +916,14 @@ void GaiaScreenHandler::OnCookiesCleared(
}
void GaiaScreenHandler::ShowSigninScreenForTest(const std::string& username,
- const std::string& password) {
+ const std::string& password,
+ const std::string& services) {
VLOG(2) << "ShowSigninScreenForTest for user " << username
<< ", frame_state=" << frame_state();
test_user_ = username;
test_pass_ = password;
+ test_services_ = services;
test_expects_complete_login_ = true;
// Submit login form for test if gaia is ready. If gaia is loading, login
@@ -913,6 +947,16 @@ void GaiaScreenHandler::SubmitLoginFormForTest() {
"document.getElementById('nextButton').click();";
frame->ExecuteJavaScriptForTests(base::ASCIIToUTF16(code));
+ if (!test_services_.empty()) {
+ // Prefix each doublequote with backslash, so that it will remain correct
+ // JSON after assigning to the element property.
+ std::string escaped_services;
+ base::ReplaceChars(test_services_, "\"", "\\\"", &escaped_services);
+ code = "document.getElementById('services').value = \"" + escaped_services +
+ "\";";
+ frame->ExecuteJavaScriptForTests(base::ASCIIToUTF16(code));
+ }
+
if (!test_pass_.empty()) {
code = "document.getElementById('password').value = '" + test_pass_ + "';";
code += "document.getElementById('nextButton').click();";
@@ -929,7 +973,10 @@ void GaiaScreenHandler::SetSAMLPrincipalsAPIUsed(bool api_used) {
UMA_HISTOGRAM_BOOLEAN("ChromeOS.SAML.APIUsed", api_used);
}
-void GaiaScreenHandler::ShowGaiaAsync() {
+void GaiaScreenHandler::ShowGaiaAsync(
+ const base::Optional<AccountId>& account_id) {
+ if (account_id)
+ populated_email_ = account_id->GetUserEmail();
show_when_dns_and_cookies_cleared_ = true;
if (gaia_silent_load_ && populated_email_.empty()) {
dns_cleared_ = true;
@@ -961,13 +1008,18 @@ void GaiaScreenHandler::ShowGaiaScreenIfReady() {
gaia_silent_load_ = false;
}
- // Note that LoadAuthExtension clears |populated_email_|.
- if (populated_email_.empty()) {
- LoginDisplayHost::default_host()->LoadSigninWallpaper();
- } else {
- LoginDisplayHost::default_host()->LoadWallpaper(
- user_manager::known_user::GetAccountId(
- populated_email_, std::string() /* id */, AccountType::UNKNOWN));
+ // Views-based login may reach here while pre-loading the Gaia screen, so
+ // update the wallpaper in |LoginDisplayHostMojo::UpdateGaiaDialogVisibility|
+ // instead, which controls the actual visibility of the Gaia screen.
+ if (!ash::features::IsViewsLoginEnabled()) {
+ // Note that LoadAuthExtension clears |populated_email_|.
+ if (populated_email_.empty()) {
+ LoginDisplayHost::default_host()->LoadSigninWallpaper();
+ } else {
+ LoginDisplayHost::default_host()->LoadWallpaper(
+ user_manager::known_user::GetAccountId(
+ populated_email_, std::string() /* id */, AccountType::UNKNOWN));
+ }
}
input_method::InputMethodManager* imm =
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h
index f4c4c5150bc..ca864555dfd 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h
@@ -52,7 +52,7 @@ class GaiaScreenHandler : public BaseScreenHandler,
// GaiaView:
void MaybePreloadAuthExtension() override;
void DisableRestrictiveProxyCheckForTest() override;
- void ShowGaiaAsync() override;
+ void ShowGaiaAsync(const base::Optional<AccountId>& account_id) override;
private:
// TODO (xiaoyinh): remove this dependency.
@@ -107,7 +107,8 @@ class GaiaScreenHandler : public BaseScreenHandler,
const std::string& password,
const std::string& auth_code,
bool using_saml,
- const std::string& gaps_cookie);
+ const std::string& gaps_cookie,
+ const ::login::StringList& services);
void HandleCompleteLogin(const std::string& gaia_id,
const std::string& typed_email,
const std::string& password,
@@ -158,8 +159,10 @@ class GaiaScreenHandler : public BaseScreenHandler,
const authpolicy::ActiveDirectoryAccountInfo& account_info);
// Show sign-in screen for the given credentials.
+ // Should match the same method in SigninScreenHandler.
void ShowSigninScreenForTest(const std::string& username,
- const std::string& password);
+ const std::string& password,
+ const std::string& services);
// Attempts login for test.
void SubmitLoginFormForTest();
@@ -251,6 +254,8 @@ class GaiaScreenHandler : public BaseScreenHandler,
// Test credentials.
std::string test_user_;
std::string test_pass_;
+ // Test result of userInfo.
+ std::string test_services_;
bool test_expects_complete_login_ = false;
// True if proxy doesn't allow access to google.com/generate_204.
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc b/chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc
index 5bf72ab80fd..476a23950bf 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/network_state_informer.cc
@@ -6,7 +6,6 @@
#include "base/bind.h"
#include "base/logging.h"
-#include "base/message_loop/message_loop.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/login/screens/network_error.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 62fe9bd2e68..de69ed2ca08 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
@@ -11,7 +11,6 @@
#include "base/stl_util.h"
#include "content/public/browser/browser_thread.h"
#include "ui/display/display.h"
-#include "ui/display/manager/display_manager.h"
#include "ui/display/screen.h"
#include "ui/events/devices/input_device_manager.h"
#include "ui/events/devices/touchscreen_device.h"
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 e63d5176a4f..76621b4241e 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
@@ -15,8 +15,8 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/display/display.h"
#include "ui/display/display_observer.h"
-#include "ui/display/manager/chromeos/test/touch_device_manager_test_api.h"
#include "ui/display/manager/display_manager.h"
+#include "ui/display/manager/test/touch_device_manager_test_api.h"
#include "ui/display/screen.h"
#include "ui/display/test/display_manager_test_api.h"
#include "ui/events/devices/touchscreen_device.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc
index 40285b1c400..68d2d6caf88 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc
@@ -8,6 +8,7 @@
#include <memory>
+#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/ash_switches.h"
#include "base/command_line.h"
#include "base/logging.h"
@@ -54,6 +55,7 @@
#include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.h"
+#include "chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.h"
#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"
@@ -116,6 +118,7 @@ const char kEnrollmentCSSPath[] = "enrollment.css";
const char kEnrollmentJSPath[] = "enrollment.js";
const char kArcAssistantLogoPath[] = "assistant_logo.png";
const char kArcPlaystoreCSSPath[] = "playstore.css";
+const char kArcOverlayCSSPath[] = "overlay.css";
const char kArcPlaystoreJSPath[] = "playstore.js";
const char kArcPlaystoreLogoPath[] = "playstore.svg";
const char kProductLogoPath[] = "product-logo.png";
@@ -123,6 +126,7 @@ const char kProductLogoPath[] = "product-logo.png";
#if defined(GOOGLE_CHROME_BUILD)
const char kLogo24PX1XSvgPath[] = "logo_24px-1x.svg";
const char kLogo24PX2XSvgPath[] = "logo_24px-2x.svg";
+const char kSyncConsentIcons[] = "sync-consent-icons.html";
#endif
// Creates a WebUIDataSource for chrome://oobe
@@ -166,10 +170,13 @@ content::WebUIDataSource* CreateOobeUIDataSource(
#if defined(GOOGLE_CHROME_BUILD)
source->AddResourcePath(kLogo24PX1XSvgPath, IDR_PRODUCT_LOGO_24PX_1X);
source->AddResourcePath(kLogo24PX2XSvgPath, IDR_PRODUCT_LOGO_24PX_2X);
+ source->AddResourcePath(kSyncConsentIcons,
+ IDR_PRODUCT_CHROMEOS_SYNC_CONSENT_SCREEN_ICONS);
// No #else section here as Sync Settings screen is Chrome-specific.
#endif
- // Required for postprocessing of Goolge PlayStore Terms.
+ // Required for postprocessing of Goolge PlayStore Terms and Overlay help.
+ source->AddResourcePath(kArcOverlayCSSPath, IDR_ARC_SUPPORT_OVERLAY_CSS);
source->AddResourcePath(kArcPlaystoreCSSPath, IDR_ARC_SUPPORT_PLAYSTORE_CSS);
source->AddResourcePath(kArcPlaystoreJSPath, IDR_ARC_SUPPORT_PLAYSTORE_JS);
source->AddResourcePath(kArcPlaystoreLogoPath,
@@ -292,6 +299,8 @@ OobeUI::OobeUI(content::WebUI* web_ui, const GURL& url)
AddScreenHandler(std::make_unique<ArcTermsOfServiceScreenHandler>());
+ AddScreenHandler(std::make_unique<RecommendAppsScreenHandler>());
+
AddScreenHandler(std::make_unique<UserImageScreenHandler>());
AddScreenHandler(std::make_unique<UserBoardScreenHandler>());
@@ -438,6 +447,10 @@ ArcTermsOfServiceScreenView* OobeUI::GetArcTermsOfServiceScreenView() {
return GetView<ArcTermsOfServiceScreenHandler>();
}
+RecommendAppsScreenView* OobeUI::GetRecommendAppsScreenView() {
+ return GetView<RecommendAppsScreenHandler>();
+}
+
WrongHWIDScreenView* OobeUI::GetWrongHWIDScreenView() {
return GetView<WrongHWIDScreenHandler>();
}
@@ -538,7 +551,7 @@ void OobeUI::GetLocalizedStrings(base::DictionaryValue* localized_strings) {
localized_strings->SetString(
"showViewsLock", ash::switches::IsUsingViewsLock() ? "on" : "off");
localized_strings->SetString(
- "showViewsLogin", ash::switches::IsUsingViewsLogin() ? "on" : "off");
+ "showViewsLogin", ash::features::IsViewsLoginEnabled() ? "on" : "off");
localized_strings->SetBoolean(
"changePictureVideoModeEnabled",
base::FeatureList::IsEnabled(features::kChangePictureVideoMode));
@@ -685,4 +698,8 @@ void OobeUI::OnDisplayConfigurationChanged() {
oobe_display_chooser_->TryToPlaceUiOnTouchDisplay();
}
+void OobeUI::SetLoginUserCount(int user_count) {
+ core_handler_->SetLoginUserCount(user_count);
+}
+
} // namespace chromeos
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 38483573bff..88212363233 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/oobe_ui.h
@@ -50,6 +50,7 @@ class NetworkDropdownHandler;
class NetworkStateInformer;
class NetworkView;
class OobeDisplayChooser;
+class RecommendAppsScreenView;
class SigninScreenHandler;
class SigninScreenHandlerDelegate;
class SupervisedUserCreationScreenHandler;
@@ -111,6 +112,7 @@ class OobeUI : public content::WebUIController,
TermsOfServiceScreenView* GetTermsOfServiceScreenView();
SyncConsentScreenView* GetSyncConsentScreenView();
ArcTermsOfServiceScreenView* GetArcTermsOfServiceScreenView();
+ RecommendAppsScreenView* GetRecommendAppsScreenView();
UserImageView* GetUserImageView();
ErrorScreen* GetErrorScreen();
WrongHWIDScreenView* GetWrongHWIDScreenView();
@@ -188,6 +190,9 @@ class OobeUI : public content::WebUIController,
// Re-evaluate OOBE display placement.
void OnDisplayConfigurationChanged();
+ // Notify WebUI of the user count on the views login screen.
+ void SetLoginUserCount(int user_count);
+
private:
// Lookup a view by its statically registered OobeScreen.
template <typename TView>
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
new file mode 100644
index 00000000000..43a9addf12e
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.cc
@@ -0,0 +1,53 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.h"
+
+#include "chrome/browser/chromeos/login/screens/recommend_apps_screen.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/login/localized_values_builder.h"
+
+namespace {
+
+const char kJsScreenPath[] = "login.RecommendAppsScreen";
+
+} // namespace
+
+namespace chromeos {
+
+RecommendAppsScreenHandler::RecommendAppsScreenHandler()
+ : BaseScreenHandler(kScreenId) {
+ set_call_js_prefix(kJsScreenPath);
+}
+
+RecommendAppsScreenHandler::~RecommendAppsScreenHandler() {}
+
+void RecommendAppsScreenHandler::DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) {
+ builder->Add("recommendAppsScreenTitle",
+ IDS_LOGIN_RECOMMEND_APPS_SCREEN_TITLE);
+ builder->Add("recommendAppsScreenDescription",
+ IDS_LOGIN_RECOMMEND_APPS_SCREEN_DESCRIPTION);
+ builder->Add("recommendAppsSkip", IDS_LOGIN_RECOMMEND_APPS_SKIP);
+ builder->Add("recommendAppsInstall", IDS_LOGIN_RECOMMEND_APPS_INSTALL);
+}
+
+void RecommendAppsScreenHandler::RegisterMessages() {
+ BaseScreenHandler::RegisterMessages();
+}
+
+void RecommendAppsScreenHandler::Bind(RecommendAppsScreen* screen) {
+ screen_ = screen;
+ BaseScreenHandler::SetBaseScreen(screen);
+}
+
+void RecommendAppsScreenHandler::Show() {
+ ShowScreen(kScreenId);
+}
+
+void RecommendAppsScreenHandler::Hide() {}
+
+void RecommendAppsScreenHandler::Initialize() {}
+
+} // namespace chromeos
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
new file mode 100644
index 00000000000..db4fe4987b9
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/recommend_apps_screen_handler.h
@@ -0,0 +1,44 @@
+// 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_RECOMMEND_APPS_SCREEN_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_RECOMMEND_APPS_SCREEN_HANDLER_H_
+
+#include "base/macros.h"
+#include "chrome/browser/chromeos/login/screens/recommend_apps_screen_view.h"
+#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
+
+namespace chromeos {
+
+class RecommendAppsScreen;
+
+// The sole implementation of the RecommendAppsScreenView, using WebUI.
+class RecommendAppsScreenHandler : public BaseScreenHandler,
+ public RecommendAppsScreenView {
+ public:
+ RecommendAppsScreenHandler();
+ ~RecommendAppsScreenHandler() override;
+
+ // BaseScreenHandler:
+ void DeclareLocalizedValues(
+ ::login::LocalizedValuesBuilder* builder) override;
+ void RegisterMessages() override;
+
+ // RecommendAppsScreenView:
+ void Bind(RecommendAppsScreen* screen) override;
+ void Show() override;
+ void Hide() override;
+
+ private:
+ // BaseScreenHandler:
+ void Initialize() override;
+
+ RecommendAppsScreen* screen_ = nullptr;
+
+ DISALLOW_COPY_AND_ASSIGN(RecommendAppsScreenHandler);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_RECOMMEND_APPS_SCREEN_HANDLER_H_
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 5eefbf79840..7fb22d7fea1 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
@@ -12,12 +12,12 @@
#include "ash/detachable_base/detachable_base_handler.h"
#include "ash/public/cpp/login_constants.h"
+#include "ash/public/cpp/wallpaper_types.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "ash/public/interfaces/shutdown.mojom.h"
#include "ash/public/interfaces/tray_action.mojom.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
-#include "ash/wallpaper/wallpaper_controller.h"
#include "base/bind.h"
#include "base/i18n/number_formatting.h"
#include "base/location.h"
@@ -35,7 +35,6 @@
#include "base/trace_event/trace_event.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part_chromeos.h"
-#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
#include "chrome/browser/chromeos/ash_config.h"
@@ -47,6 +46,7 @@
#include "chrome/browser/chromeos/login/lock/screen_locker.h"
#include "chrome/browser/chromeos/login/lock/webui_screen_locker.h"
#include "chrome/browser/chromeos/login/lock_screen_utils.h"
+#include "chrome/browser/chromeos/login/quick_unlock/pin_backend.h"
#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_factory.h"
#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h"
#include "chrome/browser/chromeos/login/reauth_stats.h"
@@ -57,6 +57,7 @@
#include "chrome/browser/chromeos/login/ui/login_display_host_webui.h"
#include "chrome/browser/chromeos/login/ui/login_display_webui.h"
#include "chrome/browser/chromeos/login/ui/login_feedback.h"
+#include "chrome/browser/chromeos/login/users/chrome_user_manager_util.h"
#include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
@@ -66,10 +67,12 @@
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/system/system_clock.h"
#include "chrome/browser/io_thread.h"
+#include "chrome/browser/lifetime/browser_shutdown.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_metrics.h"
#include "chrome/browser/ui/ash/session_controller_client.h"
#include "chrome/browser/ui/ash/tablet_mode_client.h"
+#include "chrome/browser/ui/ash/wallpaper_controller_client.h"
#include "chrome/browser/ui/webui/chromeos/internet_detail_dialog.h"
#include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h"
@@ -281,6 +284,7 @@ SigninScreenHandler::SigninScreenHandler(
session_manager_observer_(this),
lock_screen_apps_observer_(this),
detachable_base_observer_(this),
+ observer_binding_(this),
weak_factory_(this) {
DCHECK(network_state_informer_.get());
DCHECK(error_screen_);
@@ -319,9 +323,10 @@ SigninScreenHandler::SigninScreenHandler(
session_manager_observer_.Add(session_manager::SessionManager::Get());
if (lock_screen_apps::StateController::IsEnabled())
lock_screen_apps_observer_.Add(lock_screen_apps::StateController::Get());
- // TODO(wzang): Make this work under mash.
- if (GetAshConfig() != ash::Config::MASH)
- ash::Shell::Get()->wallpaper_controller()->AddObserver(this);
+
+ ash::mojom::WallpaperObserverAssociatedPtrInfo ptr_info;
+ observer_binding_.Bind(mojo::MakeRequest(&ptr_info));
+ WallpaperControllerClient::Get()->AddObserver(std::move(ptr_info));
// TODO(tbarzic): This is needed for login UI - remove it when login switches
// to views implementation (or otherwise, make it work under mash).
if (GetAshConfig() != ash::Config::MASH)
@@ -346,10 +351,6 @@ SigninScreenHandler::~SigninScreenHandler() {
network_state_informer_->RemoveObserver(this);
proximity_auth::ScreenlockBridge::Get()->SetLockHandler(nullptr);
proximity_auth::ScreenlockBridge::Get()->SetFocusedUser(EmptyAccountId());
-
- // TODO(wzang): Make this work under mash.
- if (GetAshConfig() != ash::Config::MASH)
- ash::Shell::Get()->wallpaper_controller()->RemoveObserver(this);
}
void SigninScreenHandler::DeclareLocalizedValues(
@@ -562,7 +563,6 @@ void SigninScreenHandler::RegisterMessages() {
AddCallback("sendFeedback", &SigninScreenHandler::HandleSendFeedback);
AddCallback("sendFeedbackAndResyncUserData",
&SigninScreenHandler::HandleSendFeedbackAndResyncUserData);
- AddCallback("setupDemoMode", &SigninScreenHandler::HandleSetupDemoMode);
// This message is sent by the kiosk app menu, but is handled here
// so we can tell the delegate to launch the app.
@@ -665,14 +665,6 @@ void SigninScreenHandler::ShowImpl() {
params.SetBoolean("disableAddUser", AllWhitelistedUsersPresent());
UpdateUIState(UI_STATE_ACCOUNT_PICKER, &params);
}
-
- // Enable pin for any users who can use it.
- if (user_manager::UserManager::IsInitialized()) {
- for (user_manager::User* user :
- user_manager::UserManager::Get()->GetLoggedInUsers()) {
- UpdatePinKeyboardState(user->GetAccountId());
- }
- }
}
void SigninScreenHandler::UpdateUIState(UIState ui_state,
@@ -871,7 +863,7 @@ void SigninScreenHandler::SetupAndShowOfflineMessage(
}
const bool guest_signin_allowed =
- IsGuestSigninAllowed() &&
+ chrome_user_manager_util::IsGuestSessionAllowed(CrosSettings::Get()) &&
IsSigninScreenError(error_screen_->GetErrorState());
error_screen_->AllowGuestSignin(guest_signin_allowed);
@@ -908,43 +900,15 @@ void SigninScreenHandler::ReloadGaia(bool force_reload) {
gaia_screen_handler_->ReloadGaia(force_reload);
}
-void SigninScreenHandler::UpdateAccountPickerColors() {
- color_utils::ColorProfile color_profile(color_utils::LumaRange::DARK,
- color_utils::SaturationRange::MUTED);
- SkColor dark_muted_color = ash::login_constants::kDefaultBaseColor;
- // TODO(wzang): Make this work under mash.
- if (GetAshConfig() != ash::Config::MASH) {
- dark_muted_color =
- ash::Shell::Get()->wallpaper_controller()->GetProminentColor(
- color_profile);
- }
- if (dark_muted_color == ash::WallpaperController::kInvalidColor)
- dark_muted_color = ash::login_constants::kDefaultBaseColor;
-
- dark_muted_color = SkColorSetA(dark_muted_color, 0xFF);
- SkColor base_color = color_utils::GetResultingPaintColor(
- SkColorSetA(ash::login_constants::kDefaultBaseColor,
- ash::login_constants::kTranslucentColorDarkenAlpha),
- dark_muted_color);
- SkColor scroll_color =
- SkColorSetA(base_color, ash::login_constants::kScrollTranslucentAlpha);
- CallJSOrDefer("login.AccountPickerScreen.setOverlayColors",
- color_utils::SkColorToRgbaString(dark_muted_color),
- color_utils::SkColorToRgbaString(scroll_color));
-}
-
void SigninScreenHandler::Initialize() {
// Preload PIN keyboard if any of the users can authenticate via PIN.
if (user_manager::UserManager::IsInitialized()) {
for (user_manager::User* user :
user_manager::UserManager::Get()->GetUnlockUsers()) {
- chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage =
- chromeos::quick_unlock::QuickUnlockFactory::GetForUser(user);
- if (quick_unlock_storage &&
- quick_unlock_storage->IsPinAuthenticationAvailable()) {
- CallJS("cr.ui.Oobe.preloadPinKeyboard");
- break;
- }
+ quick_unlock::PinBackend::GetInstance()->CanAuthenticate(
+ user->GetAccountId(),
+ base::BindOnce(&SigninScreenHandler::PreloadPinKeyboard,
+ weak_factory_.GetWeakPtr()));
}
}
@@ -973,19 +937,32 @@ void SigninScreenHandler::OnCurrentScreenChanged(OobeScreen current_screen,
}
}
-void SigninScreenHandler::OnWallpaperDataChanged() {}
+void SigninScreenHandler::OnWallpaperChanged(uint32_t image_id) {}
+
+void SigninScreenHandler::OnWallpaperColorsChanged(
+ const std::vector<SkColor>& prominent_colors) {
+ // Updates the color of the scrollable container on account picker screen,
+ // based on wallpaper color extraction results.
+ SkColor dark_muted_color =
+ prominent_colors[static_cast<int>(ash::ColorProfileType::DARK_MUTED)];
+ if (dark_muted_color == ash::kInvalidWallpaperColor)
+ dark_muted_color = ash::login_constants::kDefaultBaseColor;
-void SigninScreenHandler::OnWallpaperColorsChanged() {
- UpdateAccountPickerColors();
+ dark_muted_color = SkColorSetA(dark_muted_color, 0xFF);
+ SkColor base_color = color_utils::GetResultingPaintColor(
+ SkColorSetA(ash::login_constants::kDefaultBaseColor,
+ ash::login_constants::kTranslucentColorDarkenAlpha),
+ dark_muted_color);
+ SkColor scroll_color =
+ SkColorSetA(base_color, ash::login_constants::kScrollTranslucentAlpha);
+ CallJSOrDefer("login.AccountPickerScreen.setOverlayColors",
+ color_utils::SkColorToRgbaString(dark_muted_color),
+ color_utils::SkColorToRgbaString(scroll_color));
}
-void SigninScreenHandler::OnWallpaperBlurChanged() {
- bool show_pod_background =
- GetAshConfig() == ash::Config::MASH
- ? false
- : !ash::Shell::Get()->wallpaper_controller()->IsWallpaperBlurred();
+void SigninScreenHandler::OnWallpaperBlurChanged(bool blurred) {
CallJSOrDefer("login.AccountPickerScreen.togglePodBackground",
- show_pod_background);
+ !blurred /*show_pod_background=*/);
}
void SigninScreenHandler::ClearAndEnablePassword() {
@@ -1001,16 +978,22 @@ void SigninScreenHandler::RefocusCurrentPod() {
}
void SigninScreenHandler::UpdatePinKeyboardState(const AccountId& account_id) {
- chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage =
- chromeos::quick_unlock::QuickUnlockFactory::GetForAccountId(account_id);
- if (!quick_unlock_storage)
- return;
+ quick_unlock::PinBackend::GetInstance()->CanAuthenticate(
+ account_id, base::BindOnce(&SigninScreenHandler::SetPinEnabledForUser,
+ weak_factory_.GetWeakPtr(), account_id));
+}
- bool is_enabled = quick_unlock_storage->IsPinAuthenticationAvailable();
+void SigninScreenHandler::SetPinEnabledForUser(const AccountId& account_id,
+ bool is_enabled) {
CallJS("login.AccountPickerScreen.setPinEnabledForUser", account_id,
is_enabled);
}
+void SigninScreenHandler::PreloadPinKeyboard(bool should_preload) {
+ if (should_preload)
+ CallJS("cr.ui.Oobe.preloadPinKeyboard");
+}
+
void SigninScreenHandler::OnUserRemoved(const AccountId& account_id,
bool last_user_removed) {
CallJS("login.AccountPickerScreen.removeUser", account_id);
@@ -1091,10 +1074,10 @@ void SigninScreenHandler::ShowPasswordChangedDialog(bool show_password_error,
core_oobe_view_->ShowPasswordChangedScreen(show_password_error, email);
}
-void SigninScreenHandler::ShowSigninScreenForCreds(
- const std::string& username,
- const std::string& password) {
- gaia_screen_handler_->ShowSigninScreenForTest(username, password);
+void SigninScreenHandler::ShowSigninScreenForTest(const std::string& username,
+ const std::string& password,
+ const std::string& services) {
+ gaia_screen_handler_->ShowSigninScreenForTest(username, password, services);
}
void SigninScreenHandler::ShowWhitelistCheckFailedError() {
@@ -1229,34 +1212,34 @@ void SigninScreenHandler::HandleAuthenticateUser(const AccountId& account_id,
return;
DCHECK_EQ(account_id.GetUserEmail(),
gaia::SanitizeEmail(account_id.GetUserEmail()));
- chromeos::quick_unlock::QuickUnlockStorage* quick_unlock_storage =
- chromeos::quick_unlock::QuickUnlockFactory::GetForAccountId(account_id);
- // If pin storage is unavailable, authenticated by PIN must be false.
- DCHECK(!quick_unlock_storage ||
- quick_unlock_storage->IsPinAuthenticationAvailable() ||
- !authenticated_by_pin);
-
- UserContext user_context(account_id);
- user_context.SetKey(Key(password));
- // Only save the password for enterprise users. See https://crbug.com/386606.
- const bool is_enterprise_managed = g_browser_process->platform_part()
- ->browser_policy_connector_chromeos()
- ->IsEnterpriseManaged();
- if (is_enterprise_managed) {
- user_context.SetPasswordKey(Key(password));
- }
- user_context.SetIsUsingPin(authenticated_by_pin);
+
const user_manager::User* user =
user_manager::UserManager::Get()->FindUser(account_id);
DCHECK(user);
+ UserContext user_context;
if (!user) {
LOG(ERROR) << "HandleAuthenticateUser: User not found! account type="
<< AccountId::AccountTypeToString(account_id.GetAccountType());
+ const user_manager::UserType user_type =
+ (account_id.GetAccountType() == AccountType::ACTIVE_DIRECTORY)
+ ? user_manager::USER_TYPE_ACTIVE_DIRECTORY
+ : user_manager::UserType::USER_TYPE_REGULAR;
+ user_context = UserContext(user_type, account_id);
} else {
- user_context.SetUserType(user->GetType());
+ user_context = UserContext(*user);
}
- if (account_id.GetAccountType() == AccountType::ACTIVE_DIRECTORY)
- user_context.SetUserType(user_manager::USER_TYPE_ACTIVE_DIRECTORY);
+ user_context.SetKey(Key(password));
+ // Save the user's plaintext password for possible authentication to a
+ // network. See https://crbug.com/386606 for details.
+ user_context.SetPasswordKey(Key(password));
+ user_context.SetIsUsingPin(authenticated_by_pin);
+ if (account_id.GetAccountType() == AccountType::ACTIVE_DIRECTORY &&
+ (user_context.GetUserType() !=
+ user_manager::UserType::USER_TYPE_ACTIVE_DIRECTORY)) {
+ LOG(FATAL) << "Incorrect Active Directory user type "
+ << user_context.GetUserType();
+ }
+
delegate_->Login(user_context, SigninSpecifics());
UpdatePinKeyboardState(account_id);
@@ -1342,11 +1325,6 @@ void SigninScreenHandler::HandleToggleEnableDebuggingScreen() {
delegate_->ShowEnableDebuggingScreen();
}
-void SigninScreenHandler::HandleSetupDemoMode() {
- if (delegate_)
- delegate_->ShowDemoModeSetupScreen();
-}
-
void SigninScreenHandler::HandleToggleKioskEnableScreen() {
policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos();
@@ -1368,6 +1346,13 @@ void SigninScreenHandler::LoadUsers(const user_manager::UserList& users,
const base::ListValue& users_list) {
CallJSOrDefer("login.AccountPickerScreen.loadUsers", users_list,
delegate_->IsShowGuest());
+
+ // Enable pin for any users who can use it.
+ // TODO(jdufault): Cache pin state in BrowserProcess::local_state() so we
+ // don't need to query cryptohome every time we show login. See
+ // https://crbug.com/721938.
+ for (user_manager::User* user : users)
+ UpdatePinKeyboardState(user->GetAccountId());
}
void SigninScreenHandler::HandleAccountPickerReady() {
@@ -1407,8 +1392,13 @@ void SigninScreenHandler::HandleAccountPickerReady() {
}
// The wallpaper may have been set before the instance is initialized, so make
// sure the colors and blur state are updated.
- OnWallpaperColorsChanged();
- OnWallpaperBlurChanged();
+ WallpaperControllerClient::Get()->GetWallpaperColors(
+ base::BindOnce(&SigninScreenHandler::OnWallpaperColorsChanged,
+ weak_factory_.GetWeakPtr()));
+ WallpaperControllerClient::Get()->IsWallpaperBlurred(
+ base::BindOnce(&SigninScreenHandler::OnWallpaperBlurChanged,
+ weak_factory_.GetWeakPtr()));
+
if (delegate_)
delegate_->OnSigninScreenReady();
}
@@ -1718,15 +1708,6 @@ bool SigninScreenHandler::IsSigninScreenHiddenByError() const {
(IsSigninScreen(error_screen_->GetParentScreen()));
}
-bool SigninScreenHandler::IsGuestSigninAllowed() const {
- CrosSettings* cros_settings = CrosSettings::Get();
- if (!cros_settings)
- return false;
- bool allow_guest;
- cros_settings->GetBoolean(kAccountsPrefAllowGuest, &allow_guest);
- return allow_guest;
-}
-
net::Error SigninScreenHandler::FrameError() const {
return gaia_screen_handler_->frame_error();
}
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 75f54a36680..5afec4168ec 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
@@ -11,7 +11,7 @@
#include <string>
#include "ash/detachable_base/detachable_base_observer.h"
-#include "ash/wallpaper/wallpaper_controller_observer.h"
+#include "ash/public/interfaces/wallpaper.mojom.h"
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/containers/hash_tables.h"
@@ -37,6 +37,7 @@
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_ui.h"
+#include "mojo/public/cpp/bindings/associated_binding.h"
#include "net/base/net_errors.h"
#include "ui/base/ime/chromeos/ime_keyboard.h"
#include "ui/base/ime/chromeos/input_method_manager.h"
@@ -114,8 +115,11 @@ class LoginDisplayWebUIHandler {
virtual void ShowPasswordChangedDialog(bool show_password_error,
const std::string& email) = 0;
// Show sign-in screen for the given credentials.
- virtual void ShowSigninScreenForCreds(const std::string& username,
- const std::string& password) = 0;
+ // |services| - list of services returned by userInfo call as JSON array.
+ // Should be empty array for regular user: "[]".
+ virtual void ShowSigninScreenForTest(const std::string& username,
+ const std::string& password,
+ const std::string& services) = 0;
virtual void ShowWhitelistCheckFailedError() = 0;
virtual void ShowUnrecoverableCrypthomeErrorDialog() = 0;
virtual void LoadUsers(const user_manager::UserList& users,
@@ -162,9 +166,6 @@ class SigninScreenHandlerDelegate {
// Shows Enable Developer Features screen.
virtual void ShowEnableDebuggingScreen() = 0;
- // Shows Demo Mode Setup screen.
- virtual void ShowDemoModeSetupScreen() = 0;
-
// Shows Kiosk Enable screen.
virtual void ShowKioskEnableScreen() = 0;
@@ -229,7 +230,7 @@ class SigninScreenHandler
public lock_screen_apps::StateObserver,
public OobeUI::Observer,
public session_manager::SessionManagerObserver,
- public ash::WallpaperControllerObserver,
+ public ash::mojom::WallpaperObserver,
public ash::DetachableBaseObserver {
public:
SigninScreenHandler(
@@ -269,10 +270,11 @@ class SigninScreenHandler
OobeScreen new_screen) override;
void OnScreenInitialized(OobeScreen screen) override{};
- // ash::WallpaperControllerObserver implementation:
- void OnWallpaperDataChanged() override;
- void OnWallpaperColorsChanged() override;
- void OnWallpaperBlurChanged() override;
+ // ash::mojom::WallpaperObserver implementation:
+ void OnWallpaperChanged(uint32_t image_id) override;
+ void OnWallpaperColorsChanged(
+ const std::vector<SkColor>& prominent_colors) override;
+ void OnWallpaperBlurChanged(bool blurred) override;
// ash::DetachableBaseObserver:
void OnDetachableBasePairingStatusChanged(
@@ -318,10 +320,6 @@ class SigninScreenHandler
NetworkError::ErrorReason reason);
void ReloadGaia(bool force_reload);
- // Updates the color of the scrollable container on account picker screen,
- // based on wallpaper color extraction results.
- void UpdateAccountPickerColors();
-
// BaseScreenHandler implementation:
void DeclareLocalizedValues(
::login::LocalizedValuesBuilder* builder) override;
@@ -347,8 +345,9 @@ class SigninScreenHandler
void ShowPasswordChangedDialog(bool show_password_error,
const std::string& email) override;
void ShowErrorScreen(LoginDisplay::SigninError error_id) override;
- void ShowSigninScreenForCreds(const std::string& username,
- const std::string& password) override;
+ void ShowSigninScreenForTest(const std::string& username,
+ const std::string& password,
+ const std::string& services) override;
void ShowWhitelistCheckFailedError() override;
void ShowUnrecoverableCrypthomeErrorDialog() override;
void LoadUsers(const user_manager::UserList& users,
@@ -378,6 +377,10 @@ class SigninScreenHandler
// Enable or disable the pin keyboard for the given account.
void UpdatePinKeyboardState(const AccountId& account_id);
+ void SetPinEnabledForUser(const AccountId& account_id, bool is_enabled);
+ // Callback run by PinBackend. If |should_preload| is true the PIN keyboard is
+ // preloaded.
+ void PreloadPinKeyboard(bool should_preload);
// WebUI message handlers.
void HandleGetUsers();
@@ -396,7 +399,6 @@ class SigninScreenHandler
void HandleToggleEnrollmentScreen();
void HandleToggleEnrollmentAd();
void HandleToggleEnableDebuggingScreen();
- void HandleSetupDemoMode();
void HandleToggleKioskEnableScreen();
void HandleToggleResetScreen();
void HandleToggleKioskAutolaunchScreen();
@@ -459,9 +461,6 @@ class SigninScreenHandler
// screen.
bool IsSigninScreenHiddenByError() const;
- // Returns true if guest signin is allowed.
- bool IsGuestSigninAllowed() const;
-
bool ShouldLoadGaia() const;
net::Error FrameError() const;
@@ -597,6 +596,9 @@ class SigninScreenHandler
ScopedObserver<ash::DetachableBaseHandler, ash::DetachableBaseObserver>
detachable_base_observer_;
+ // The binding this instance uses to implement ash::mojom::WallpaperObserver.
+ mojo::AssociatedBinding<ash::mojom::WallpaperObserver> observer_binding_;
+
base::WeakPtrFactory<SigninScreenHandler> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(SigninScreenHandler);
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc b/chromium/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc
index da4ff412063..230adcacf7c 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc
@@ -17,7 +17,7 @@
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "chromeos/components/proximity_auth/screenlock_bridge.h"
-#include "components/signin/core/account_id/account_id.h"
+#include "components/account_id/account_id.h"
#include "components/user_manager/scoped_user_manager.h"
#include "components/user_manager/user.h"
#include "testing/gtest/include/gtest/gtest.h"
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
index 1936b235f4c..a6e4906ac6c 100644
--- 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
@@ -21,8 +21,8 @@
#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/signin/core/account_id/account_id.h"
#include "components/user_manager/user_manager.h"
#include "components/user_manager/user_type.h"
#include "google_apis/gaia/gaia_auth_util.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.cc b/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.cc
index 4d1b2f4a302..1441c130baa 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.cc
@@ -37,6 +37,39 @@ void SyncConsentScreenHandler::DeclareLocalizedValues(
IDS_LOGIN_SYNC_CONSENT_SCREEN_PERSONALIZE_GOOGLE_SERVICES_DESCRIPTION);
builder->Add("syncConsentReviewSyncOptionsText",
IDS_LOGIN_SYNC_CONSENT_SCREEN_REVIEW_SYNC_OPTIONS_LATER);
+
+ builder->Add("syncConsentNewScreenTitle",
+ IDS_LOGIN_SYNC_CONSENT_GET_GOOGLE_SMARTS);
+ builder->Add("syncConsentNewBookmarksDesc",
+ IDS_LOGIN_SYNC_CONSENT_YOUR_BOOKMARKS_ON_ALL_DEVICES);
+ builder->Add("syncConsentNewServicesDesc",
+ IDS_LOGIN_SYNC_CONSENT_PERSONALIZED_GOOGLE_SERVICES);
+ builder->Add("syncConsentNewImproveChrome",
+ IDS_LOGIN_SYNC_CONSENT_IMPROVE_CHROME);
+ builder->Add("syncConsentNewGoogleMayUse",
+ IDS_LOGIN_SYNC_CONSENT_GOOGLE_MAY_USE);
+ builder->Add("syncConsentNewMoreOptions",
+ IDS_LOGIN_SYNC_CONSENT_MORE_OPTIONS);
+ builder->Add("syncConsentNewYesIAmIn", IDS_LOGIN_SYNC_CONSENT_YES_I_AM_IN);
+ builder->Add("syncConsentNewSyncOptions",
+ IDS_LOGIN_SYNC_CONSENT_SYNC_OPTIONS);
+ builder->Add("syncConsentNewSyncOptionsSubtitle",
+ IDS_LOGIN_SYNC_CONSENT_SYNC_OPTIONS_SUBTITLE);
+ builder->Add("syncConsentNewChooseOption",
+ IDS_LOGIN_SYNC_CONSENT_CHOOSE_OPTION);
+ builder->Add("syncConsentNewOptionReview",
+ IDS_LOGIN_SYNC_CONSENT_OPTION_REVIEW);
+ builder->Add("syncConsentNewOptionReviewDsc",
+ IDS_LOGIN_SYNC_CONSENT_OPTION_REVIEW_DSC);
+ builder->Add("syncConsentNewOptionJustSync",
+ IDS_LOGIN_SYNC_CONSENT_OPTION_JUST_SYNC);
+ builder->Add("syncConsentNewOptionJustSyncDsc",
+ IDS_LOGIN_SYNC_CONSENT_OPTION_JUST_SYNC_DSC);
+ builder->Add("syncConsentNewOptionSyncAndPersonalization",
+ IDS_LOGIN_SYNC_CONSENT_OPTION_SYNC_AND_PERSONALIZATION);
+ builder->Add("syncConsentNewOptionSyncAndPersonalizationDsc",
+ IDS_LOGIN_SYNC_CONSENT_OPTION_SYNC_AND_PERSONALIZATION_DSC);
+
builder->Add("syncConsentAcceptAndContinue",
IDS_LOGIN_SYNC_CONSENT_SCREEN_ACCEPT_AND_CONTINUE);
}
@@ -52,6 +85,17 @@ void SyncConsentScreenHandler::Show() {
void SyncConsentScreenHandler::Hide() {}
+void SyncConsentScreenHandler::SetThrobberVisible(bool visible) {
+ CallJS("setThrobberVisible", visible);
+}
+
void SyncConsentScreenHandler::Initialize() {}
+void SyncConsentScreenHandler::GetAdditionalParameters(
+ base::DictionaryValue* parameters) {
+ parameters->Set("syncConsentMakeBetter",
+ std::make_unique<base::Value>(false));
+ BaseScreenHandler::GetAdditionalParameters(parameters);
+}
+
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.h b/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.h
index 6e8242bf95e..38cfde328c7 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.h
+++ b/chromium/chrome/browser/ui/webui/chromeos/login/sync_consent_screen_handler.h
@@ -28,10 +28,12 @@ class SyncConsentScreenHandler : public BaseScreenHandler,
void Bind(SyncConsentScreen* screen) override;
void Show() override;
void Hide() override;
+ void SetThrobberVisible(bool visible) override;
private:
// BaseScreenHandler:
void Initialize() override;
+ void GetAdditionalParameters(base::DictionaryValue* parameters) override;
SyncConsentScreen* screen_ = nullptr;
diff --git a/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.cc
index da85adea8f4..b8ed44130df 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_dialog.cc
@@ -8,10 +8,10 @@
#include "base/macros.h"
#include "base/memory/singleton.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/ui/webui_login_view.h"
#include "chrome/browser/chromeos/mobile/mobile_activator.h"
+#include "chrome/browser/lifetime/browser_shutdown.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser_dialogs.h"
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 8c0b5f028fc..48df3c8a814 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc
@@ -19,7 +19,6 @@
#include "base/macros.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/weak_ptr.h"
-#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
diff --git a/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.cc b/chromium/chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.cc
index bf9bf597fcc..3d489b5408d 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
@@ -31,7 +31,24 @@ void AddMultiDeviceSetupStrings(content::WebUIDataSource* html_source) {
const char* name;
int id;
} kLocalizedStrings[] = {
- {"title", IDS_MULTIDEVICE_SETUP_DIALOG_TITLE}, {"cancel", IDS_CANCEL},
+ {"accept", IDS_MULTIDEVICE_SETUP_ACCEPT_LABEL},
+ {"cancel", IDS_CANCEL},
+ {"done", IDS_DONE},
+ {"startSetupPageMultipleDeviceHeader",
+ IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_MULTIPLE_DEVICE_HEADER},
+ {"startSetupPageSingleDeviceHeader",
+ IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_SINGLE_DEVICE_HEADER},
+ {"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},
+ {"startSetupPageMessage", IDS_MULTIDEVICE_SETUP_START_SETUP_PAGE_MESSAGE},
+ {"title", IDS_MULTIDEVICE_SETUP_DIALOG_TITLE},
+ {"tryAgain", IDS_MULTIDEVICE_SETUP_TRY_AGAIN_LABEL},
};
for (const auto& entry : kLocalizedStrings)
diff --git a/chromium/chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.cc b/chromium/chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.cc
index 8c92d8bbbde..1951ce7a687 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/chromeos/net/shill_error.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/login/login_state.h"
+#include "chromeos/network/network_connection_handler.h"
#include "components/login/localized_values_builder.h"
#include "content/public/browser/web_ui_data_source.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -262,6 +263,7 @@ void AddConfigLocalizedStrings(content::WebUIDataSource* html_source) {
} localized_strings[] = {
{"networkCAUseDefault", IDS_SETTINGS_INTERNET_NETWORK_CA_USE_DEFAULT},
{"networkCADoNotCheck", IDS_SETTINGS_INTERNET_NETWORK_CA_DO_NOT_CHECK},
+ {"networkNoUserCert", IDS_SETTINGS_INTERNET_NETWORK_NO_USER_CERT},
{"networkCertificateName",
IDS_SETTINGS_INTERNET_NETWORK_CERTIFICATE_NAME},
{"networkCertificateNameHardwareBacked",
@@ -297,6 +299,8 @@ void AddErrorLocalizedStrings(content::WebUIDataSource* html_source) {
IDS_NETWORK_ERROR_CANNOT_CHANGE_SHARED_CONFIG},
{"Error.PolicyControlled", IDS_NETWORK_ERROR_POLICY_CONTROLLED},
{"networkErrorNoUserCertificate", IDS_NETWORK_ERROR_NO_USER_CERT},
+ {NetworkConnectionHandler::kErrorPassphraseRequired,
+ IDS_NETWORK_ERROR_PASSPHRASE_REQUIRED},
{"networkErrorUnknown", IDS_NETWORK_ERROR_UNKNOWN},
// TODO(stevenjb): Move this id to settings_strings.grdp:
{"networkErrorNotHardwareBacked",
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 7faf7cd9f86..6b8b576444a 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/slow_trace_ui.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/slow_trace_ui.cc
@@ -8,7 +8,6 @@
#include "base/bind.h"
#include "base/memory/ref_counted_memory.h"
-#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/url_constants.h"
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 24c45fd7e62..53d279a4866 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
@@ -9,7 +9,7 @@
#include "chrome/browser/chromeos/login/login_manager_test.h"
#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/common/webui_url_constants.h"
-#include "components/signin/core/account_id/account_id.h"
+#include "components/account_id/account_id.h"
#include "content/public/common/service_manager_connection.h"
#include "services/service_manager/public/cpp/connector.h"
#include "ui/aura/test/mus/change_completion_waiter.h"
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 8e6ac99b2e8..dc12be08195 100644
--- a/chromium/chrome/browser/ui/webui/chromeos/user_image_source.cc
+++ b/chromium/chrome/browser/ui/webui/chromeos/user_image_source.cc
@@ -5,12 +5,11 @@
#include "chrome/browser/ui/webui/chromeos/user_image_source.h"
#include "base/memory/ref_counted_memory.h"
-#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "chrome/browser/chromeos/login/users/default_user_image/default_user_images.h"
#include "chrome/common/url_constants.h"
-#include "components/signin/core/account_id/account_id.h"
+#include "components/account_id/account_id.h"
#include "components/user_manager/known_user.h"
#include "components/user_manager/user_manager.h"
#include "net/base/escape.h"
diff --git a/chromium/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc b/chromium/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc
index c42de33bb41..af018abc976 100644
--- a/chromium/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc
+++ b/chromium/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc
@@ -31,9 +31,9 @@ ConstrainedWebDialogDelegateBase::ConstrainedWebDialogDelegateBase(
web_dialog_delegate_(delegate),
closed_via_webui_(false) {
CHECK(delegate);
- web_contents_ =
+ web_contents_holder_ =
WebContents::Create(WebContents::CreateParams(browser_context));
- web_contents_holder_.reset(web_contents_);
+ web_contents_ = web_contents_holder_.get();
WebContentsObserver::Observe(web_contents_);
zoom::ZoomController::CreateForWebContents(web_contents_);
if (tab_delegate) {
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 196111d5a60..f5bb7fcc979 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
@@ -5,6 +5,7 @@
#include "base/callback.h"
#include "base/location.h"
#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
@@ -93,7 +94,7 @@ class ConstrainedWebDialogBrowserTest : public InProcessBrowserTest {
}
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
+ FROM_HERE, base::RunLoop::QuitCurrentWhenIdleClosureDeprecated(),
base::TimeDelta::FromMilliseconds(20));
content::RunMessageLoop();
}
diff --git a/chromium/chrome/browser/ui/webui/device_log_ui.cc b/chromium/chrome/browser/ui/webui/device_log_ui.cc
index 22d484de53a..5cec52a31c3 100644
--- a/chromium/chrome/browser/ui/webui/device_log_ui.cc
+++ b/chromium/chrome/browser/ui/webui/device_log_ui.cc
@@ -77,6 +77,7 @@ DeviceLogUI::DeviceLogUI(content::WebUI* web_ui)
IDS_DEVICE_LOG_TYPE_BLUETOOTH);
html->AddLocalizedString("logTypeUsbText", IDS_DEVICE_LOG_TYPE_USB);
html->AddLocalizedString("logTypeHidText", IDS_DEVICE_LOG_TYPE_HID);
+ html->AddLocalizedString("logTypePrinterText", IDS_DEVICE_LOG_TYPE_PRINTER);
html->AddLocalizedString("logEntryFormat", IDS_DEVICE_LOG_ENTRY);
html->SetJsonPath("strings.js");
diff --git a/chromium/chrome/browser/ui/webui/discards/discards.mojom b/chromium/chrome/browser/ui/webui/discards/discards.mojom
index 1cf89a7c276..5fe64a8b3ca 100644
--- a/chromium/chrome/browser/ui/webui/discards/discards.mojom
+++ b/chromium/chrome/browser/ui/webui/discards/discards.mojom
@@ -16,8 +16,6 @@ struct TabDiscardsInfo {
// The URL associated with the tab. This corresponds to GetLastCommittedURL,
// and is also what is visible in the Omnibox for a given tab.
string tab_url;
- // The URL of the favicon being displayed for a tab.
- string favicon_url;
// The title of the tab, as displayed on the tab itself.
string title;
// The visibility of the LifecycleUnit.
@@ -27,6 +25,11 @@ struct TabDiscardsInfo {
bool is_media;
// If the tab is currently discarded, this is true.
bool is_discarded;
+ // If the tab is currently frozen, this is true.
+ // TODO(fmeawad): is_discarded and is_frozen are mutually exclusive, instead
+ // of representing each individually, we should add a "lifecycle_state" field
+ // instead.
+ bool is_frozen;
// The number of times this tab has been discarded in the current browser
// session.
int32 discard_count;
@@ -42,6 +45,11 @@ struct TabDiscardsInfo {
// This can be manipulated by the chrome://discards UI, or via the discards
// extension API.
bool is_auto_discardable;
+ // True if a reactivation score is calculated for the tab. Reactivation score
+ // can be predicted only for background tabs.
+ bool has_reactivation_score;
+ // Tab Ranker reactivation score, if |has_reactivation_score| is true.
+ double reactivation_score;
};
// Interface for providing information about discards. Lives in the browser
diff --git a/chromium/chrome/browser/ui/webui/discards/discards_ui.cc b/chromium/chrome/browser/ui/webui/discards/discards_ui.cc
index bcf0a16b0c2..c61409079e2 100644
--- a/chromium/chrome/browser/ui/webui/discards/discards_ui.cc
+++ b/chromium/chrome/browser/ui/webui/discards/discards_ui.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/resource_coordinator/discard_reason.h"
#include "chrome/browser/resource_coordinator/lifecycle_unit.h"
+#include "chrome/browser/resource_coordinator/tab_activity_watcher.h"
#include "chrome/browser/resource_coordinator/tab_lifecycle_unit_external.h"
#include "chrome/browser/resource_coordinator/tab_manager.h"
#include "chrome/browser/resource_coordinator/time.h"
@@ -50,6 +51,15 @@ mojom::LifecycleUnitVisibility GetLifecycleUnitVisibility(
#endif
}
+resource_coordinator::LifecycleUnit* GetLifecycleUnitById(int32_t id) {
+ for (resource_coordinator::LifecycleUnit* lifecycle_unit :
+ g_browser_process->GetTabManager()->GetSortedLifecycleUnits()) {
+ if (lifecycle_unit->GetID() == id)
+ return lifecycle_unit;
+ }
+ return nullptr;
+}
+
class DiscardsDetailsProviderImpl : public mojom::DiscardsDetailsProvider {
public:
// This instance is deleted when the supplied pipe is destroyed.
@@ -83,18 +93,16 @@ class DiscardsDetailsProviderImpl : public mojom::DiscardsDetailsProvider {
tab_lifecycle_unit_external->GetWebContents();
info->tab_url = contents->GetLastCommittedURL().spec();
- // This can be empty for pages without a favicon. The WebUI takes care of
- // showing the chrome://favicon default in that case.
- info->favicon_url = lifecycle_unit->GetIconURL();
info->title = base::UTF16ToUTF8(lifecycle_unit->GetTitle());
info->visibility =
GetLifecycleUnitVisibility(lifecycle_unit->GetVisibility());
info->is_media = tab_lifecycle_unit_external->IsMediaTab();
+ info->is_frozen = tab_lifecycle_unit_external->IsFrozen();
info->is_discarded = tab_lifecycle_unit_external->IsDiscarded();
info->discard_count = tab_lifecycle_unit_external->GetDiscardCount();
info->utility_rank = rank++;
const base::TimeTicks last_focused_time =
- lifecycle_unit->GetSortKey().last_focused_time;
+ lifecycle_unit->GetLastFocusedTime();
const base::TimeDelta elapsed =
(last_focused_time == base::TimeTicks::Max())
? base::TimeDelta()
@@ -103,6 +111,12 @@ class DiscardsDetailsProviderImpl : public mojom::DiscardsDetailsProvider {
info->is_auto_discardable =
tab_lifecycle_unit_external->IsAutoDiscardable();
info->id = lifecycle_unit->GetID();
+ base::Optional<float> reactivation_score =
+ resource_coordinator::TabActivityWatcher::GetInstance()
+ ->CalculateReactivationScore(contents);
+ info->has_reactivation_score = reactivation_score.has_value();
+ if (info->has_reactivation_score)
+ info->reactivation_score = reactivation_score.value();
infos.push_back(std::move(info));
}
@@ -110,28 +124,32 @@ class DiscardsDetailsProviderImpl : public mojom::DiscardsDetailsProvider {
std::move(callback).Run(std::move(infos));
}
- void SetAutoDiscardable(int32_t tab_id,
+ void SetAutoDiscardable(int32_t id,
bool is_auto_discardable,
SetAutoDiscardableCallback callback) override {
- resource_coordinator::TabManager* tab_manager =
- g_browser_process->GetTabManager();
- tab_manager->SetTabAutoDiscardableState(tab_id, is_auto_discardable);
+ auto* lifecycle_unit = GetLifecycleUnitById(id);
+ if (lifecycle_unit) {
+ auto* tab_lifecycle_unit_external =
+ lifecycle_unit->AsTabLifecycleUnitExternal();
+ if (tab_lifecycle_unit_external)
+ tab_lifecycle_unit_external->SetAutoDiscardable(is_auto_discardable);
+ }
std::move(callback).Run();
}
- void DiscardById(int32_t tab_id,
+ void DiscardById(int32_t id,
bool urgent,
DiscardByIdCallback callback) override {
- resource_coordinator::TabManager* tab_manager =
- g_browser_process->GetTabManager();
- tab_manager->DiscardTabById(tab_id, GetDiscardReason(urgent));
+ auto* lifecycle_unit = GetLifecycleUnitById(id);
+ if (lifecycle_unit)
+ lifecycle_unit->Discard(GetDiscardReason(urgent));
std::move(callback).Run();
}
- void FreezeById(int32_t tab_id) override {
- resource_coordinator::TabManager* tab_manager =
- g_browser_process->GetTabManager();
- tab_manager->FreezeTabById(tab_id);
+ void FreezeById(int32_t id) override {
+ auto* lifecycle_unit = GetLifecycleUnitById(id);
+ if (lifecycle_unit)
+ lifecycle_unit->Freeze();
}
void Discard(bool urgent, DiscardCallback callback) override {
@@ -150,7 +168,7 @@ class DiscardsDetailsProviderImpl : public mojom::DiscardsDetailsProvider {
} // namespace
DiscardsUI::DiscardsUI(content::WebUI* web_ui)
- : ui::MojoWebUIController<mojom::DiscardsDetailsProvider>(web_ui) {
+ : ui::MojoWebUIController(web_ui) {
std::unique_ptr<content::WebUIDataSource> source(
content::WebUIDataSource::Create(chrome::kChromeUIDiscardsHost));
@@ -163,11 +181,14 @@ DiscardsUI::DiscardsUI(content::WebUI* web_ui)
Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource::Add(profile, source.release());
+ AddHandlerToRegistry(base::BindRepeating(
+ &DiscardsUI::BindDiscardsDetailsProvider, base::Unretained(this)));
}
DiscardsUI::~DiscardsUI() {}
-void DiscardsUI::BindUIHandler(mojom::DiscardsDetailsProviderRequest request) {
+void DiscardsUI::BindDiscardsDetailsProvider(
+ mojom::DiscardsDetailsProviderRequest request) {
ui_handler_ =
std::make_unique<DiscardsDetailsProviderImpl>(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 eec56b2ca9c..e4719d4ed2c 100644
--- a/chromium/chrome/browser/ui/webui/discards/discards_ui.h
+++ b/chromium/chrome/browser/ui/webui/discards/discards_ui.h
@@ -13,15 +13,14 @@
// Controller for chrome://discards. Corresponding resources are in
// file://chrome/browser/resources/discards.
-class DiscardsUI
- : public ui::MojoWebUIController<mojom::DiscardsDetailsProvider> {
+class DiscardsUI : public ui::MojoWebUIController {
public:
explicit DiscardsUI(content::WebUI* web_ui);
~DiscardsUI() override;
private:
- // ui::MojoWebUIController overrides:
- void BindUIHandler(mojom::DiscardsDetailsProviderRequest request) override;
+ void BindDiscardsDetailsProvider(
+ mojom::DiscardsDetailsProviderRequest request);
std::unique_ptr<mojom::DiscardsDetailsProvider> ui_handler_;
diff --git a/chromium/chrome/browser/ui/webui/engagement/site_engagement_ui.cc b/chromium/chrome/browser/ui/webui/engagement/site_engagement_ui.cc
index 71265fb3900..c4c77490ede 100644
--- a/chromium/chrome/browser/ui/webui/engagement/site_engagement_ui.cc
+++ b/chromium/chrome/browser/ui/webui/engagement/site_engagement_ui.cc
@@ -8,6 +8,7 @@
#include <utility>
#include <vector>
+#include "base/callback.h"
#include "base/macros.h"
#include "chrome/browser/engagement/site_engagement_service.h"
#include "chrome/browser/profiles/profile.h"
@@ -37,7 +38,7 @@ class SiteEngagementDetailsProviderImpl
// mojom::SiteEngagementDetailsProvider overrides:
void GetSiteEngagementDetails(
- const GetSiteEngagementDetailsCallback& callback) override {
+ GetSiteEngagementDetailsCallback callback) override {
SiteEngagementService* service = SiteEngagementService::Get(profile_);
std::vector<mojom::SiteEngagementDetails> scores = service->GetAllDetails();
@@ -50,7 +51,7 @@ class SiteEngagementDetailsProviderImpl
engagement_info.push_back(std::move(origin_info));
}
- callback.Run(std::move(engagement_info));
+ std::move(callback).Run(std::move(engagement_info));
}
void SetSiteEngagementBaseScoreForUrl(const GURL& origin,
@@ -76,7 +77,7 @@ class SiteEngagementDetailsProviderImpl
} // namespace
SiteEngagementUI::SiteEngagementUI(content::WebUI* web_ui)
- : ui::MojoWebUIController<mojom::SiteEngagementDetailsProvider>(web_ui) {
+ : ui::MojoWebUIController(web_ui) {
// Set up the chrome://site-engagement/ source.
std::unique_ptr<content::WebUIDataSource> source(
content::WebUIDataSource::Create(chrome::kChromeUISiteEngagementHost));
@@ -88,11 +89,15 @@ SiteEngagementUI::SiteEngagementUI(content::WebUI* web_ui)
source->SetDefaultResource(IDR_SITE_ENGAGEMENT_HTML);
source->UseGzip();
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source.release());
+
+ AddHandlerToRegistry(
+ base::BindRepeating(&SiteEngagementUI::BindSiteEngagementDetailsProvider,
+ base::Unretained(this)));
}
SiteEngagementUI::~SiteEngagementUI() {}
-void SiteEngagementUI::BindUIHandler(
+void SiteEngagementUI::BindSiteEngagementDetailsProvider(
mojom::SiteEngagementDetailsProviderRequest request) {
ui_handler_.reset(new SiteEngagementDetailsProviderImpl(
Profile::FromWebUI(web_ui()), std::move(request)));
diff --git a/chromium/chrome/browser/ui/webui/engagement/site_engagement_ui.h b/chromium/chrome/browser/ui/webui/engagement/site_engagement_ui.h
index 678050d38ce..1d84444e369 100644
--- a/chromium/chrome/browser/ui/webui/engagement/site_engagement_ui.h
+++ b/chromium/chrome/browser/ui/webui/engagement/site_engagement_ui.h
@@ -10,16 +10,14 @@
#include "ui/webui/mojo_web_ui_controller.h"
// The UI for chrome://site-engagement/.
-class SiteEngagementUI
- : public ui::MojoWebUIController<mojom::SiteEngagementDetailsProvider> {
+class SiteEngagementUI : public ui::MojoWebUIController {
public:
explicit SiteEngagementUI(content::WebUI* web_ui);
~SiteEngagementUI() override;
private:
- // ui::MojoWebUIController overrides:
- void BindUIHandler(
- mojom::SiteEngagementDetailsProviderRequest request) override;
+ void BindSiteEngagementDetailsProvider(
+ mojom::SiteEngagementDetailsProviderRequest request);
std::unique_ptr<mojom::SiteEngagementDetailsProvider> ui_handler_;
diff --git a/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_browsertest.js b/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_browsertest.js
deleted file mode 100644
index 85ec336b42c..00000000000
--- a/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_browsertest.js
+++ /dev/null
@@ -1,269 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-GEN('#include "base/command_line.h"');
-GEN('#include "chrome/common/chrome_features.h"');
-
-/**
- * TestFixture for kiosk app settings WebUI testing.
- * @extends {testing.Test}
- * @constructor
- */
-function KioskAppSettingsWebUITest() {}
-
-KioskAppSettingsWebUITest.prototype = {
- __proto__: testing.Test.prototype,
-
- /**
- * Browse to the kiosk app settings page.
- */
- browsePreload: 'chrome://extensions/',
-
- /** @override */
- commandLineSwitches: [{
- switchName: 'enable-consumer-kiosk',
- }],
-
- /** @override */
- featureList: ['', 'features::kMaterialDesignExtensions'],
-
- /**
- * Mock settings data.
- * @private
- */
- settings_: {
- apps: [
- {
- id: 'app_1',
- name: 'App1 Name',
- iconURL: '',
- autoLaunch: false,
- isLoading: false,
- },
- {
- id: 'app_2',
- name: '', // no name
- iconURL: '',
- autoLaunch: false,
- isLoading: true,
- },
- ],
- disableBailout: false,
- hasAutoLaunchApp: false
- },
-
- /**
- * Register a mock dictionary handler.
- */
- preLoad: function() {
- this.makeAndRegisterMockHandler(
- ['getKioskAppSettings',
- 'addKioskApp',
- 'removeKioskApp',
- 'enableKioskAutoLaunch',
- 'disableKioskAutoLaunch'
- ]);
- this.mockHandler.stubs().getKioskAppSettings(ANYTHING).will(
- callFunction(function() {
- extensions.KioskAppsOverlay.setSettings(this.settings_);
- }.bind(this)));
- this.mockHandler.stubs().addKioskApp(ANYTHING);
- this.mockHandler.stubs().removeKioskApp(ANYTHING);
- this.mockHandler.stubs().enableKioskAutoLaunch(ANYTHING);
- this.mockHandler.stubs().disableKioskAutoLaunch(ANYTHING);
- },
-
- setUp: function() {
- // Shows the kiosk apps management overlay.
- cr.dispatchSimpleEvent($('add-kiosk-app'), 'click');
- }
-};
-
-// Test opening kiosk app settings has correct location and app items have
-// correct label.
-TEST_F('KioskAppSettingsWebUITest', 'testOpenKioskAppSettings', function() {
- assertEquals(this.browsePreload, document.location.href);
-
- var appItems = $('kiosk-app-list').items;
- assertEquals(this.settings_.apps.length, appItems.length);
- assertEquals(this.settings_.apps[0].name, appItems[0].name.textContent);
- assertFalse(appItems[0].icon.classList.contains('spinner'));
- assertEquals(this.settings_.apps[1].id, appItems[1].name.textContent);
- assertTrue(appItems[1].icon.classList.contains('spinner'));
-});
-
-// Verify that enter key on 'kiosk-app-id-edit' adds an app.
-TEST_F('KioskAppSettingsWebUITest', 'testAddKioskApp', function() {
- var testAppId = 'app_3';
- var appIdInput = $('kiosk-app-id-edit');
-
- appIdInput.value = testAppId;
-
- this.mockHandler.expects(once()).addKioskApp([testAppId]);
- var keypress = new KeyboardEvent('keypress', {cancelable: true, bubbles: true, key: 'Enter'});
- appIdInput.dispatchEvent(keypress);
-});
-
-// Verify that the 'kiosk-app-add' button adds an app.
-TEST_F('KioskAppSettingsWebUITest', 'testAddKioskAppByAddButton', function() {
- var testAppId = 'app_3';
- $('kiosk-app-id-edit').value = testAppId;
-
- this.mockHandler.expects(once()).addKioskApp([testAppId]);
- cr.dispatchSimpleEvent($('kiosk-app-add'), 'click');
-});
-
-// Verify that the 'done' button adds an app.
-TEST_F('KioskAppSettingsWebUITest', 'testAddKioskAppByDoneButton', function() {
- var testAppId = 'app_3';
- $('kiosk-app-id-edit').value = testAppId;
-
- this.mockHandler.expects(once()).addKioskApp([testAppId]);
- cr.dispatchSimpleEvent($('kiosk-options-overlay-confirm'), 'click');
-});
-
-// Test the row delete button.
-TEST_F('KioskAppSettingsWebUITest', 'testRemoveKioskApp', function() {
- var appItem = $('kiosk-app-list').items[0];
- var appId = appItem.data.id;
-
- this.mockHandler.expects(once()).removeKioskApp([appId]);
- appItem.querySelector('.row-delete-button').click();
-});
-
-// Test enable/disable auto launch buttons.
-TEST_F('KioskAppSettingsWebUITest', 'testEnableDisableAutoLaunch', function() {
- var appItem = $('kiosk-app-list').items[0];
- var appId = appItem.data.id;
-
- var enableAutoLaunchCalled = false;
- this.mockHandler.expects(once()).enableKioskAutoLaunch([appId]).
- will(callFunction(function() {
- enableAutoLaunchCalled = true;
- }));
- appItem.querySelector('.enable-auto-launch-button').click();
- expectTrue(enableAutoLaunchCalled);
-
- var disableAutoLaunchCalled = false;
- this.mockHandler.expects(once()).disableKioskAutoLaunch([appId]).
- will(callFunction(function() {
- disableAutoLaunchCalled = true;
- }));
- appItem.querySelector('.disable-auto-launch-button').click();
- expectTrue(disableAutoLaunchCalled);
-});
-
-// Verify that updateApp updates app info.
-TEST_F('KioskAppSettingsWebUITest', 'testUpdateApp', function() {
- var appItems = $('kiosk-app-list').items;
- assertEquals(appItems[1].data.id, 'app_2');
- expectEquals(appItems[1].data.name, '');
- expectTrue(appItems[1].icon.classList.contains('spinner'));
- expectFalse(appItems[1].autoLaunch);
-
- // New data changes name, autoLaunch and isLoading.
- var newName = 'Name for App2';
- var newApp2 = {
- id: 'app_2',
- name: newName,
- iconURL: '',
- autoLaunch: true,
- isLoading: false,
- };
- extensions.KioskAppsOverlay.updateApp(newApp2);
-
- assertEquals('app_2', appItems[1].data.id);
- expectEquals(newName, appItems[1].data.name, newName);
- expectEquals(newName, appItems[1].name.textContent);
- expectFalse(appItems[1].icon.classList.contains('spinner'));
- expectTrue(appItems[1].autoLaunch);
-});
-
-// Verify that showError makes error banner visible.
-TEST_F('KioskAppSettingsWebUITest', 'testShowError', function() {
- extensions.KioskAppsOverlay.showError('A bad app');
- expectTrue($('kiosk-apps-error-banner').classList.contains('visible'));
-});
-
-// Verify that checking disable bailout checkbox brings up confirmation UI and
-// the check only remains when the confirmation UI is acknowledged.
-TEST_F('KioskAppSettingsWebUITest', 'testCheckDisableBailout', function() {
- var checkbox = $('kiosk-disable-bailout-shortcut');
- var confirmOverlay = $('kiosk-disable-bailout-confirm-overlay');
- expectFalse(confirmOverlay.classList.contains('showing'));
-
- // Un-checking the box does not trigger confirmation.
- checkbox.checked = false;
- cr.dispatchSimpleEvent(checkbox, 'change');
- expectFalse(confirmOverlay.classList.contains('showing'));
-
- // Checking the box trigger confirmation.
- checkbox.checked = true;
- cr.dispatchSimpleEvent(checkbox, 'change');
- expectTrue(confirmOverlay.classList.contains('showing'));
-
- // Confirm it and the check remains.
- cr.dispatchSimpleEvent($('kiosk-disable-bailout-confirm-button'), 'click');
- expectTrue(checkbox.checked);
- expectFalse(confirmOverlay.classList.contains('showing'));
-
- // And canceling resets the check.
- checkbox.checked = true;
- cr.dispatchSimpleEvent(checkbox, 'change');
- expectTrue(confirmOverlay.classList.contains('showing'));
- cr.dispatchSimpleEvent($('kiosk-disable-bailout-cancel-button'), 'click');
- expectFalse(checkbox.checked);
- expectFalse(confirmOverlay.classList.contains('showing'));
-});
-
-// Verify that disable bailout checkbox is hidden without kiosk auto launch.
-TEST_F('KioskAppSettingsWebUITest', 'testHideDisableBailout', function() {
- var checkbox = $('kiosk-disable-bailout-shortcut');
- var kioskEnabledSettings = {
- kioskEnabled: true,
- autoLaunchEnabled: true
- };
- extensions.KioskAppsOverlay.enableKiosk(kioskEnabledSettings);
- expectFalse(checkbox.parentNode.hidden);
-
- kioskEnabledSettings.autoLaunchEnabled = false;
- extensions.KioskAppsOverlay.enableKiosk(kioskEnabledSettings);
- expectTrue(checkbox.parentNode.hidden);
-});
-
-// Verify that disable bailout checkbox is disabled with no auto launch app.
-TEST_F('KioskAppSettingsWebUITest', 'testAllowDisableBailout', function() {
- var checkbox = $('kiosk-disable-bailout-shortcut');
-
- this.settings_.hasAutoLaunchApp = false;
- extensions.KioskAppsOverlay.setSettings(this.settings_);
- expectTrue(checkbox.disabled);
-
- this.settings_.hasAutoLaunchApp = true;
- extensions.KioskAppsOverlay.setSettings(this.settings_);
- expectFalse(checkbox.disabled);
-});
-
-/**
- * TestFixture for kiosk app settings when consumer kiosk is disabled.
- * @extends {testing.Test}
- * @constructor
- */
-function NoConsumerKioskWebUITest() {}
-
-NoConsumerKioskWebUITest.prototype = {
- __proto__: KioskAppSettingsWebUITest.prototype,
-
- /** @override */
- commandLineSwitches: [],
-
- /** @override */
- setUp: function() {}
-};
-
-// Test kiosk app settings are not visible when consumer kiosk is disabled.
-TEST_F('NoConsumerKioskWebUITest', 'settingsHidden', function() {
- assertEquals(this.browsePreload, document.location.href);
- assertTrue($('add-kiosk-app').hidden);
-});
diff --git a/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc b/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc
index 56b411c546d..c155bab90ff 100644
--- a/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc
+++ b/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc
@@ -21,15 +21,12 @@
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
-#include "chrome/grit/chromium_strings.h"
-#include "chrome/grit/generated_resources.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/settings/cros_settings_names.h"
#include "components/crx_file/id_util.h"
#include "components/strings/grit/components_strings.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/web_ui.h"
-#include "content/public/browser/web_ui_data_source.h"
#include "extensions/common/extension_urls.h"
#include "extensions/grit/extensions_browser_resources.h"
#include "ui/base/l10n/l10n_util.h"
@@ -158,52 +155,6 @@ void KioskAppsHandler::RegisterMessages() {
base::Unretained(this)));
}
-void KioskAppsHandler::GetLocalizedValues(content::WebUIDataSource* source) {
- source->AddString(
- "addKioskAppButton",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_ADD_KIOSK_APP_BUTTON));
- source->AddString(
- "kioskOverlayTitle",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_KIOSK_OVERLAY_TITLE));
- source->AddString("addKioskApp",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_KIOSK_ADD_APP));
- source->AddString(
- "kioskAppIdEditHint",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_KIOSK_ADD_APP_HINT));
- source->AddString(
- "enableAutoLaunchButton",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_KIOSK_ENABLE_AUTO_LAUNCH));
- source->AddString(
- "disableAutoLaunchButton",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_KIOSK_DISABLE_AUTO_LAUNCH));
- source->AddString("autoLaunch", l10n_util::GetStringUTF16(
- IDS_EXTENSIONS_KIOSK_AUTO_LAUNCH));
- source->AddString("invalidApp", l10n_util::GetStringUTF16(
- IDS_EXTENSIONS_KIOSK_INVALID_APP));
- source->AddString("kioskDiableBailoutShortcutLabel",
- l10n_util::GetStringUTF16(
- IDS_EXTENSIONS_KIOSK_DISABLE_BAILOUT_SHORTCUT_LABEL));
- source->AddString(
- "kioskDisableBailoutShortcutWarningBold",
- l10n_util::GetStringUTF16(
- IDS_EXTENSIONS_KIOSK_DISABLE_BAILOUT_SHORTCUT_WARNING_BOLD));
- const base::string16 product_os_name =
- l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_OS_NAME);
- source->AddString(
- "kioskDisableBailoutShortcutWarning",
- l10n_util::GetStringFUTF16(
- IDS_EXTENSIONS_KIOSK_DISABLE_BAILOUT_SHORTCUT_WARNING_FORMAT,
- product_os_name));
- source->AddString(
- "kioskDisableBailoutShortcutConfirm",
- l10n_util::GetStringUTF16(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL));
- source->AddString(
- "kioskDisableBailoutShortcutCancel",
- l10n_util::GetStringUTF16(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL));
- source->AddString("done", l10n_util::GetStringUTF16(IDS_DONE));
- source->AddString("add", l10n_util::GetStringUTF16(IDS_ADD));
-}
-
void KioskAppsHandler::OnKioskAppDataChanged(const std::string& app_id) {
UpdateApp(app_id);
}
diff --git a/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.h b/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.h
index 6971c23f62b..a7d38504888 100644
--- a/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.h
+++ b/chromium/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.h
@@ -18,10 +18,6 @@ namespace base {
class ListValue;
}
-namespace content {
-class WebUIDataSource;
-}
-
namespace chromeos {
class KioskAppManager;
@@ -33,8 +29,6 @@ class KioskAppsHandler : public content::WebUIMessageHandler,
explicit KioskAppsHandler(OwnerSettingsServiceChromeOS* service);
~KioskAppsHandler() override;
- void GetLocalizedValues(content::WebUIDataSource* source);
-
// content::WebUIMessageHandler overrides:
void RegisterMessages() override;
void OnJavascriptAllowed() override;
diff --git a/chromium/chrome/browser/ui/webui/extensions/extension_loader_handler.cc b/chromium/chrome/browser/ui/webui/extensions/extension_loader_handler.cc
deleted file mode 100644
index 12c132d3086..00000000000
--- a/chromium/chrome/browser/ui/webui/extensions/extension_loader_handler.cc
+++ /dev/null
@@ -1,225 +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/extensions/extension_loader_handler.h"
-
-#include <memory>
-#include <utility>
-
-#include "base/bind.h"
-#include "base/files/file_util.h"
-#include "base/logging.h"
-#include "base/memory/ref_counted.h"
-#include "base/strings/string16.h"
-#include "base/strings/string_util.h"
-#include "base/strings/stringprintf.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/task_scheduler/post_task.h"
-#include "base/values.h"
-#include "chrome/browser/extensions/unpacked_installer.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/grit/generated_resources.h"
-#include "content/public/browser/navigation_handle.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_ui.h"
-#include "content/public/browser/web_ui_data_source.h"
-#include "extensions/browser/extension_system.h"
-#include "extensions/browser/file_highlighter.h"
-#include "extensions/browser/path_util.h"
-#include "extensions/common/constants.h"
-#include "extensions/common/extension.h"
-#include "extensions/common/manifest_constants.h"
-#include "third_party/re2/src/re2/re2.h"
-#include "ui/base/l10n/l10n_util.h"
-
-namespace extensions {
-
-namespace {
-
-// Read a file to a string and return.
-std::string ReadFileToString(const base::FilePath& path) {
- std::string data;
- // This call can fail, but it doesn't matter for our purposes. If it fails,
- // we simply return an empty string for the manifest, and ignore it.
- base::ReadFileToString(path, &data);
- return data;
-}
-
-} // namespace
-
-ExtensionLoaderHandler::ExtensionLoaderHandler(Profile* profile)
- : profile_(profile),
- extension_error_reporter_observer_(this),
- ui_ready_(false),
- weak_ptr_factory_(this) {
- DCHECK(profile_);
- extension_error_reporter_observer_.Add(
- extensions::LoadErrorReporter::GetInstance());
-}
-
-ExtensionLoaderHandler::~ExtensionLoaderHandler() {
-}
-
-void ExtensionLoaderHandler::GetLocalizedValues(
- content::WebUIDataSource* source) {
- source->AddString(
- "extensionLoadErrorHeading",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOAD_ERROR_HEADING));
- source->AddString(
- "extensionLoadErrorMessage",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOAD_ERROR_MESSAGE));
- source->AddString(
- "extensionLoadErrorRetry",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOAD_ERROR_RETRY));
- source->AddString(
- "extensionLoadErrorGiveUp",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOAD_ERROR_GIVE_UP));
- source->AddString(
- "extensionLoadCouldNotLoadManifest",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOAD_COULD_NOT_LOAD_MANIFEST));
- source->AddString(
- "extensionLoadAdditionalFailures",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOAD_ADDITIONAL_FAILURES));
-}
-
-void ExtensionLoaderHandler::RegisterMessages() {
- // We observe WebContents in order to detect page refreshes, since notifying
- // the frontend of load failures must be delayed until the page finishes
- // loading. We never call Observe(NULL) because this object is constructed
- // on page load and persists between refreshes.
- content::WebContentsObserver::Observe(web_ui()->GetWebContents());
-
- web_ui()->RegisterMessageCallback(
- "extensionLoaderRetry",
- base::BindRepeating(&ExtensionLoaderHandler::HandleRetry,
- weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback(
- "extensionLoaderIgnoreFailure",
- base::BindRepeating(&ExtensionLoaderHandler::HandleIgnoreFailure,
- weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback(
- "extensionLoaderDisplayFailures",
- base::BindRepeating(&ExtensionLoaderHandler::HandleDisplayFailures,
- weak_ptr_factory_.GetWeakPtr()));
-}
-
-// static
-void ExtensionLoaderHandler::GetManifestError(
- const std::string& error,
- const base::FilePath& extension_path,
- const GetManifestErrorCallback& callback) {
- size_t line = 0u;
- size_t column = 0u;
- std::string regex = base::StringPrintf("%s Line: (\\d+), column: (\\d+), .*",
- manifest_errors::kManifestParseError);
- // If this was a JSON parse error, we can highlight the exact line with the
- // error. Otherwise, we should still display the manifest (for consistency,
- // reference, and so that if we ever make this really fancy and add an editor,
- // it's ready).
- //
- // This regex call can fail, but if it does, we just don't highlight anything.
- re2::RE2::FullMatch(error, regex, &line, &column);
-
- // This will read the manifest and call AddFailure with the read manifest
- // contents.
- base::PostTaskWithTraitsAndReplyWithResult(
- FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_BLOCKING},
- base::Bind(&ReadFileToString, extension_path.Append(kManifestFilename)),
- base::Bind(callback, extension_path, error, line));
-}
-
-void ExtensionLoaderHandler::HandleRetry(const base::ListValue* args) {
- DCHECK(args->empty());
- const base::FilePath file_path = failed_paths_.back();
- failed_paths_.pop_back();
- LoadUnpackedExtension(file_path);
-}
-
-void ExtensionLoaderHandler::HandleIgnoreFailure(const base::ListValue* args) {
- DCHECK(args->empty());
- failed_paths_.pop_back();
-}
-
-void ExtensionLoaderHandler::HandleDisplayFailures(
- const base::ListValue* args) {
- DCHECK(args->empty());
- ui_ready_ = true;
-
- // Notify the frontend of any load failures that were triggered while the
- // chrome://extensions page was loading.
- if (!failures_.empty())
- NotifyFrontendOfFailure();
-}
-
-void ExtensionLoaderHandler::LoadUnpackedExtension(
- const base::FilePath& file_path) {
- scoped_refptr<UnpackedInstaller> installer = UnpackedInstaller::Create(
- ExtensionSystem::Get(profile_)->extension_service());
-
- // We do our own error handling, so we don't want a load failure to trigger
- // a dialog.
- installer->set_be_noisy_on_failure(false);
-
- installer->Load(file_path);
-}
-
-void ExtensionLoaderHandler::OnLoadFailure(
- content::BrowserContext* browser_context,
- const base::FilePath& file_path,
- const std::string& error) {
- // Only show errors from our browser context.
- if (web_ui()->GetWebContents()->GetBrowserContext() != browser_context)
- return;
-
- GetManifestError(error, file_path,
- base::Bind(&ExtensionLoaderHandler::AddFailure,
- weak_ptr_factory_.GetWeakPtr()));
-}
-
-void ExtensionLoaderHandler::DidStartNavigation(
- content::NavigationHandle* navigation_handle) {
- if (!navigation_handle->IsInMainFrame())
- return;
-
- // In the event of a page reload, we ensure that the frontend is not notified
- // until the UI finishes loading, so we set |ui_ready_| to false. This is
- // balanced in HandleDisplayFailures, which is called when the frontend is
- // ready to receive failure notifications.
- if (navigation_handle->GetReloadType() != content::ReloadType::NONE)
- ui_ready_ = false;
-}
-
-void ExtensionLoaderHandler::AddFailure(
- const base::FilePath& file_path,
- const std::string& error,
- size_t line_number,
- const std::string& manifest) {
- failed_paths_.push_back(file_path);
- base::FilePath prettified_path = path_util::PrettifyPath(file_path);
-
- std::unique_ptr<base::DictionaryValue> manifest_value(
- new base::DictionaryValue());
- SourceHighlighter highlighter(manifest, line_number);
- // If the line number is 0, this highlights no regions, but still adds the
- // full manifest.
- highlighter.SetHighlightedRegions(manifest_value.get());
-
- std::unique_ptr<base::DictionaryValue> failure(new base::DictionaryValue());
- failure->SetString("path", prettified_path.LossyDisplayName());
- failure->SetString("error", error);
- failure->Set("manifest", std::move(manifest_value));
- failures_.Append(std::move(failure));
-
- // Only notify the frontend if the frontend UI is ready.
- if (ui_ready_)
- NotifyFrontendOfFailure();
-}
-
-void ExtensionLoaderHandler::NotifyFrontendOfFailure() {
- web_ui()->CallJavascriptFunctionUnsafe(
- "extensions.ExtensionLoader.notifyLoadFailed", failures_);
- failures_.Clear();
-}
-
-} // namespace extensions
diff --git a/chromium/chrome/browser/ui/webui/extensions/extension_loader_handler.h b/chromium/chrome/browser/ui/webui/extensions/extension_loader_handler.h
deleted file mode 100644
index a70ab5fb5d0..00000000000
--- a/chromium/chrome/browser/ui/webui/extensions/extension_loader_handler.h
+++ /dev/null
@@ -1,121 +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_EXTENSIONS_EXTENSION_LOADER_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_LOADER_HANDLER_H_
-
-#include <stddef.h>
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "base/callback.h"
-#include "base/compiler_specific.h"
-#include "base/files/file_path.h"
-#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
-#include "base/values.h"
-#include "chrome/browser/extensions/load_error_reporter.h"
-#include "content/public/browser/reload_type.h"
-#include "content/public/browser/web_contents_observer.h"
-#include "content/public/browser/web_ui_message_handler.h"
-
-namespace content {
-class WebUIDataSource;
-}
-
-class Profile;
-
-namespace extensions {
-
-class Extension;
-
-// The handler page for the Extension Commands UI overlay.
-class ExtensionLoaderHandler : public content::WebUIMessageHandler,
- public extensions::LoadErrorReporter::Observer,
- public content::WebContentsObserver {
- public:
- using GetManifestErrorCallback =
- base::Callback<void(const base::FilePath& file_path,
- const std::string& error,
- size_t line_number,
- const std::string& manifest)>;
-
- explicit ExtensionLoaderHandler(Profile* profile);
- ~ExtensionLoaderHandler() override;
-
- // Fetches the localized values for the page and deposits them into |source|.
- void GetLocalizedValues(content::WebUIDataSource* source);
-
- // WebUIMessageHandler implementation.
- void RegisterMessages() override;
-
- // TODO(devlin): Move this to developerPrivate.
- static void GetManifestError(const std::string& error,
- const base::FilePath& extension_path,
- const GetManifestErrorCallback& callback);
-
- private:
- // Handle the 'extensionLoaderRetry' message.
- void HandleRetry(const base::ListValue* args);
-
- // Handle the 'extensionLoaderIgnoreFailure' message.
- void HandleIgnoreFailure(const base::ListValue* args);
-
- // Handle the 'extensionLoaderDisplayFailures' message.
- void HandleDisplayFailures(const base::ListValue* args);
-
- // Try to load an unpacked extension from the given |file_path|.
- void LoadUnpackedExtension(const base::FilePath& file_path);
-
- // extensions::LoadErrorReporter::Observer:
- void OnLoadFailure(content::BrowserContext* browser_context,
- const base::FilePath& file_path,
- const std::string& error) override;
-
- // content::WebContentsObserver:
- void DidStartNavigation(
- content::NavigationHandle* navigation_handle) override;
-
- // Add a failure to |failures_|. If it was a manifest error, |manifest| will
- // hold the manifest contents, and |line_number| will point to the line at
- // which the error was found.
- void AddFailure(const base::FilePath& file_path,
- const std::string& error,
- size_t line_number,
- const std::string& manifest);
-
- // Notify the frontend of all failures.
- void NotifyFrontendOfFailure();
-
- // The profile with which this Handler is associated.
- Profile* profile_;
-
- // Holds information about all unpacked extension install failures that
- // were reported while the extensions page was loading.
- base::ListValue failures_;
-
- // Holds failed paths for load retries.
- std::vector<base::FilePath> failed_paths_;
-
- ScopedObserver<extensions::LoadErrorReporter,
- extensions::LoadErrorReporter::Observer>
- extension_error_reporter_observer_;
-
- // Set when the chrome://extensions page is fully loaded and the frontend is
- // ready to receive failure notifications. We need this because the page
- // fails to display failures if they are sent before the Javascript is loaded.
- bool ui_ready_;
-
- // Weak pointer factory for posting background tasks.
- base::WeakPtrFactory<ExtensionLoaderHandler> weak_ptr_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(ExtensionLoaderHandler);
-};
-
-} // namespace extensions
-
-#endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_LOADER_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.cc b/chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.cc
index 450ec468bee..39caabc6fc1 100644
--- a/chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.cc
@@ -9,6 +9,7 @@
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_restrictions.h"
+#include "chrome/browser/extensions/api/developer_private/developer_private_api.h"
#include "chrome/browser/extensions/chrome_test_extension_loader.h"
#include "chrome/browser/extensions/unpacked_installer.h"
#include "chrome/browser/profiles/profile.h"
@@ -22,9 +23,9 @@
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h"
+#include "content/public/test/test_utils.h"
#include "extensions/browser/extension_dialog_auto_confirm.h"
#include "extensions/browser/extension_system.h"
-#include "extensions/common/switches.h"
using extensions::Extension;
using extensions::TestManagementPolicyProvider;
@@ -33,20 +34,12 @@ ExtensionSettingsUIBrowserTest::ExtensionSettingsUIBrowserTest()
: policy_provider_(TestManagementPolicyProvider::PROHIBIT_MODIFY_STATUS |
TestManagementPolicyProvider::MUST_REMAIN_ENABLED |
TestManagementPolicyProvider::MUST_REMAIN_INSTALLED) {
- CHECK(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_));
+ CHECK(base::PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_));
test_data_dir_ = test_data_dir_.AppendASCII("extensions");
}
ExtensionSettingsUIBrowserTest::~ExtensionSettingsUIBrowserTest() {}
-void ExtensionSettingsUIBrowserTest::SetUpCommandLine(
- base::CommandLine* command_line) {
- WebUIBrowserTest::SetUpCommandLine(command_line);
- // TODO(devlin): Remove this. See https://crbug.com/816679.
- command_line->AppendSwitch(
- extensions::switches::kAllowLegacyExtensionManifests);
-}
-
void ExtensionSettingsUIBrowserTest::InstallGoodExtension() {
EXPECT_TRUE(InstallExtension(test_data_dir_.AppendASCII("good.crx")));
}
@@ -177,3 +170,48 @@ IN_PROC_BROWSER_TEST_F(ExtensionSettingsUIBrowserTest, ViewSource) {
base::RemoveChars(expected_source_text, "\n", &expected_source_text));
EXPECT_EQ(expected_source_text, actual_source_text);
}
+
+// Verify that listeners for the developer private API are only registered
+// when there is a chrome://extensions page open. This is important, since some
+// of the event construction can be expensive.
+IN_PROC_BROWSER_TEST_F(ExtensionSettingsUIBrowserTest, ListenerRegistration) {
+ Profile* profile = browser()->profile();
+ extensions::EventRouter* event_router = extensions::EventRouter::Get(profile);
+ extensions::DeveloperPrivateAPI* dev_private_api =
+ extensions::DeveloperPrivateAPI::Get(profile);
+ auto expect_has_listeners = [event_router,
+ dev_private_api](bool has_listeners) {
+ EXPECT_EQ(has_listeners, event_router->HasEventListener(
+ "developerPrivate.onItemStateChanged"));
+ EXPECT_EQ(has_listeners, event_router->HasEventListener(
+ "developerPrivate.onProfileStateChanged"));
+ EXPECT_EQ(has_listeners,
+ dev_private_api->developer_private_event_router() != nullptr);
+ };
+
+ {
+ SCOPED_TRACE("Before page load");
+ expect_has_listeners(false);
+ }
+
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(), GURL("chrome://extensions"),
+ WindowOpenDisposition::NEW_FOREGROUND_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+
+ {
+ SCOPED_TRACE("With page loaded");
+ expect_has_listeners(true);
+ }
+
+ TabStripModel* tab_strip = browser()->tab_strip_model();
+ tab_strip->CloseWebContentsAt(tab_strip->active_index(),
+ TabStripModel::CLOSE_NONE);
+ base::RunLoop().RunUntilIdle();
+ content::RunAllTasksUntilIdle();
+
+ {
+ SCOPED_TRACE("After page unload");
+ expect_has_listeners(false);
+ }
+}
diff --git a/chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.h b/chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.h
index e5c2c16c5c9..a74021ec537 100644
--- a/chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.h
+++ b/chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.h
@@ -26,8 +26,6 @@ class ExtensionSettingsUIBrowserTest : public WebUIBrowserTest {
ExtensionSettingsUIBrowserTest();
~ExtensionSettingsUIBrowserTest() override;
- void SetUpCommandLine(base::CommandLine* command_line) override;
-
protected:
void InstallGoodExtension();
diff --git a/chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.js b/chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.js
deleted file mode 100644
index 7d4bef5721f..00000000000
--- a/chromium/chrome/browser/ui/webui/extensions/extension_settings_browsertest.js
+++ /dev/null
@@ -1,539 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// TODO(dbeam): test for loading unpacked extensions?
-
-GEN('#include "chrome/browser/ui/webui/extensions/' +
- 'extension_settings_browsertest.h"');
-GEN('#include "chrome/common/chrome_features.h"');
-
-// The id of the extension from |InstallGoodExtension|.
-var GOOD_EXTENSION_ID = 'ldnnhddmnhbkjipkidpdiheffobcpfmf';
-
-// The id of the extension from |InstallErrorsExtension|.
-var ERROR_EXTENSION_ID = 'pdlpifnclfacjobnmbpngemkalkjamnf';
-
-/**
- * Test C++ fixture for settings WebUI testing.
- * @constructor
- * @extends {testing.Test}
- */
-function ExtensionSettingsUIBrowserTest() {}
-
-/**
- * TestFixture for extension settings WebUI testing.
- * @extends {testing.Test}
- * @constructor
- */
-function ExtensionSettingsWebUITest() {}
-
-ExtensionSettingsWebUITest.prototype = {
- __proto__: testing.Test.prototype,
-
- /** @override */
- isAsync: true,
-
- /** @override */
- runAccessibilityChecks: true,
-
- /** @override */
- accessibilityIssuesAreErrors: true,
-
- /**
- * A URL to load before starting each test.
- * @type {string}
- * @const
- */
- browsePreload: 'chrome://extensions/',
-
- /** @override */
- typedefCppFixture: 'ExtensionSettingsUIBrowserTest',
-
- /** @override */
- featureList: ['', 'features::kMaterialDesignExtensions'],
-
- /** @override */
- setUp: function() {
- testing.Test.prototype.setUp.call(this);
- testing.Test.disableAnimationsAndTransitions();
-
- // Enable when failure is resolved.
- // AX_ARIA_08: http://crbug.com/560903
- this.accessibilityAuditConfig.ignoreSelectors(
- 'requiredOwnedAriaRoleMissing',
- '#kiosk-app-list');
- },
-
- /**
- * Holds an array of steps that should happen in order during a test.
- * The last step should be |testDone|.
- * @protected {Array<!Function>}
- * */
- steps: [],
-
- /**
- * Advances to the next step in the test. Every step should call this.
- * @protected
- * */
- nextStep: function() {
- assertTrue(this.steps.length > 0);
- this.steps.shift().call(this);
- },
-
- /**
- * Will wait for the page to load before calling the next step. This should be
- * the first step in every test.
- * @protected
- * */
- waitForPageLoad: function() {
- assertEquals(this.browsePreload, document.location.href);
- var extensionList = getRequiredElement('extension-settings-list');
- extensionList.loadFinished.then(this.nextStep.bind(this));
- },
-
- /** @protected */
- enableDeveloperMode: function() {
- // Toggling developer mode triggers a page update, so we need to be able to
- // wait for the update to finish.
- $('extension-settings-list').resetLoadFinished();
- var waitForPage = this.waitForPageLoad.bind(this);
- document.addEventListener('devControlsVisibilityUpdated',
- function devCallback() {
- // Callback should only be handled once.
- document.removeEventListener('devControlsVisibilityUpdated', devCallback);
-
- chrome.developerPrivate.getProfileConfiguration(function(profileInfo) {
- assertTrue(extensionSettings.classList.contains('dev-mode'));
- assertTrue(profileInfo.inDeveloperMode);
-
- // This event isn't thrown because transitions are disabled.
- // Ensure transition here so that any dependent code does not break.
- ensureTransitionEndEvent($('dev-controls'), 0);
-
- waitForPage();
- });
- });
-
- var extensionSettings = getRequiredElement('extension-settings');
- assertFalse(extensionSettings.classList.contains('dev-mode'));
- $('toggle-dev-on').click();
- },
-
- /** @protected */
- testDeveloperMode: function() {
- var next = this.nextStep.bind(this);
- var checkDevModeIsOff = function() {
- chrome.developerPrivate.getProfileConfiguration(function(profileInfo) {
- assertFalse(profileInfo.inDeveloperMode);
- next();
- });
- };
- this.steps = [this.waitForPageLoad,
- checkDevModeIsOff,
- this.enableDeveloperMode,
- testDone];
- this.nextStep();
- },
-};
-
-// Flaky: http://crbug.com/505506.
-// Verify that developer mode doesn't change behavior when the number of
-// extensions changes.
-TEST_F('ExtensionSettingsWebUITest', 'DISABLED_testDeveloperModeNoExtensions',
- function() {
- this.testDeveloperMode();
-});
-
-TEST_F('ExtensionSettingsWebUITest', 'testEmptyExtensionList', function() {
- var verifyListIsHiddenAndEmpty = function() {
- assertTrue($('extension-list-wrapper').hidden);
- assertFalse($('no-extensions').hidden);
- assertEquals(0, $('extension-settings-list').childNodes.length);
- this.nextStep();
- };
-
- this.steps = [this.waitForPageLoad, verifyListIsHiddenAndEmpty, testDone];
- this.nextStep();
-});
-
-TEST_F('ExtensionSettingsWebUITest', 'testChromeSendHandled', function() {
- var testPackExtenion = function() {
- // This dialog should be hidden at first.
- assertFalse($('pack-extension-overlay').classList.contains('showing'));
-
- // Show the dialog, which triggers a chrome.send() for metrics purposes.
- cr.dispatchSimpleEvent($('pack-extension'), 'click');
- assertTrue($('pack-extension-overlay').classList.contains('showing'));
- this.nextStep();
- };
-
- this.steps = [this.waitForPageLoad, testPackExtenion, testDone];
- this.nextStep();
-});
-
-/**
- * @param {chrome.developerPrivate.EventType} eventType
- * @param {function():void} callback
- * @constructor
- */
-function UpdateListener(eventType, callback) {
- this.callback_ = callback;
- this.eventType_ = eventType;
- this.onItemStateChangedListener_ = this.onItemStateChanged_.bind(this);
- chrome.developerPrivate.onItemStateChanged.addListener(
- this.onItemStateChangedListener_);
-}
-
-UpdateListener.prototype = {
- /** @private */
- onItemStateChanged_: function(data) {
- if (this.eventType_ == data.event_type) {
- window.setTimeout(function() {
- chrome.developerPrivate.onItemStateChanged.removeListener(
- this.onItemStateChangedListener_);
- this.callback_();
- }.bind(this), 0);
- }
- }
-};
-
-function BasicExtensionSettingsWebUITest() {}
-
-BasicExtensionSettingsWebUITest.prototype = {
- __proto__: ExtensionSettingsWebUITest.prototype,
-
- /** @override */
- testGenPreamble: function() {
- // Install multiple types of extensions to ensure we handle each type.
- // TODO(devlin): There are more types to add here.
- GEN(' InstallGoodExtension();');
- GEN(' InstallErrorsExtension();');
- GEN(' InstallSharedModule();');
- GEN(' InstallPackagedApp();');
-
- GEN(' SetAutoConfirmUninstall();');
- },
-
- /** @protected */
- verifyDisabledWorks: function() {
- var listener = new UpdateListener(
- chrome.developerPrivate.EventType.UNLOADED,
- function() {
- var node = getRequiredElement(GOOD_EXTENSION_ID);
- assertTrue(node.classList.contains('inactive-extension'));
- this.nextStep();
- }.bind(this));
- chrome.management.setEnabled(GOOD_EXTENSION_ID, false);
- },
-
- /** @protected */
- verifyEnabledWorks: function() {
- var listener = new UpdateListener(
- chrome.developerPrivate.EventType.LOADED,
- function() {
- var node = getRequiredElement(GOOD_EXTENSION_ID);
- assertFalse(node.classList.contains('inactive-extension'));
- this.nextStep();
- }.bind(this));
- chrome.management.setEnabled(GOOD_EXTENSION_ID, true);
- },
-
- /** @protected */
- verifyUninstallWorks: function() {
- var listener = new UpdateListener(
- chrome.developerPrivate.EventType.UNINSTALLED,
- function() {
- assertEquals(null, $(GOOD_EXTENSION_ID));
- this.nextStep();
- }.bind(this));
- chrome.test.runWithUserGesture(function() {
- chrome.management.uninstall(GOOD_EXTENSION_ID);
- });
- },
-};
-
-// Verify that developer mode doesn't change behavior when the number of
-// extensions changes.
-TEST_F('BasicExtensionSettingsWebUITest', 'testDeveloperModeManyExtensions',
- function() {
- this.testDeveloperMode();
-});
-
-TEST_F('BasicExtensionSettingsWebUITest', 'testDisable', function() {
- this.steps = [this.waitForPageLoad, this.verifyDisabledWorks, testDone];
- this.nextStep();
-});
-
-TEST_F('BasicExtensionSettingsWebUITest', 'testEnable', function() {
- this.steps = [this.waitForPageLoad,
- this.verifyDisabledWorks,
- this.verifyEnabledWorks,
- testDone];
- this.nextStep();
-});
-
-TEST_F('BasicExtensionSettingsWebUITest', 'testUninstall', function() {
- this.steps = [this.waitForPageLoad, this.verifyUninstallWorks, testDone];
- this.nextStep();
-});
-
-TEST_F('BasicExtensionSettingsWebUITest', 'testNonEmptyExtensionList',
- function() {
- var verifyListIsNotHiddenAndEmpty = function() {
- assertFalse($('extension-list-wrapper').hidden);
- assertTrue($('no-extensions').hidden);
- assertGT($('extension-settings-list').childNodes.length, 0);
- this.nextStep();
- };
-
- this.steps = [this.waitForPageLoad, verifyListIsNotHiddenAndEmpty, testDone];
- this.nextStep();
-});
-
-function AutoScrollExtensionSettingsWebUITest() {}
-
-/**
- * A variation for testing auto-scroll when an id query param is passed in the
- * url.
- * @constructor
- * @extends {BasicExtensionSettingsWebUITest}
- */
-AutoScrollExtensionSettingsWebUITest.prototype = {
- __proto__: BasicExtensionSettingsWebUITest.prototype,
-
- /** @override */
- browsePreload: 'chrome://extensions/?id=' + GOOD_EXTENSION_ID,
-
- /** @override */
- testGenPreamble: function() {
- BasicExtensionSettingsWebUITest.prototype.testGenPreamble.call(this);
- // The window needs to be sufficiently small in order to ensure a scroll bar
- // is available.
- GEN(' ShrinkWebContentsView();');
- },
-};
-
-TEST_F('AutoScrollExtensionSettingsWebUITest', 'testAutoScroll', function() {
- var checkHasScrollbar = function() {
- assertGT(document.scrollingElement.scrollHeight,
- document.body.clientHeight);
- this.nextStep();
- };
- var checkIsScrolled = function() {
- assertGT(document.scrollingElement.scrollTop, 0);
- this.nextStep();
- };
- var checkScrolledToTop = function() {
- assertEquals(0, document.scrollingElement.scrollTop);
- this.nextStep();
- };
- var scrollToTop = function() {
- document.scrollingElement.scrollTop = 0;
- this.nextStep();
- };
- // Test that a) autoscroll works on first page load and b) updating the
- // page doesn't result in autoscroll triggering again.
- this.steps = [this.waitForPageLoad,
- checkHasScrollbar,
- checkIsScrolled,
- scrollToTop,
- this.enableDeveloperMode,
- checkScrolledToTop,
- testDone];
- this.nextStep();
-});
-
-function ErrorConsoleExtensionSettingsWebUITest() {}
-
-ErrorConsoleExtensionSettingsWebUITest.prototype = {
- __proto__: ExtensionSettingsWebUITest.prototype,
-
- /** @override */
- testGenPreamble: function() {
- GEN(' EnableErrorConsole();');
- GEN(' InstallGoodExtension();');
- GEN(' InstallErrorsExtension();');
- },
-};
-
-// Flaky on all platforms: http://crbug.com/499884, http://crbug.com/463245.
-TEST_F('ErrorConsoleExtensionSettingsWebUITest',
- 'DISABLED_testErrorListButtonVisibility', function() {
- var testButtonVisibility = function() {
- var extensionList = $('extension-list-wrapper');
-
- var visibleButtons = extensionList.querySelectorAll(
- '.errors-link:not([hidden])');
- expectEquals(1, visibleButtons.length);
-
- if (visibleButtons.length > 0) {
- var errorLink = $(ERROR_EXTENSION_ID).querySelector('.errors-link');
- expectEquals(visibleButtons[0], errorLink);
-
- var errorIcon = errorLink.querySelector('img');
- expectTrue(errorIcon.classList.contains('extension-error-warning-icon'));
- }
-
- var hiddenButtons = extensionList.querySelectorAll('.errors-link[hidden]');
- expectEquals(1, hiddenButtons.length);
-
- this.nextStep();
- };
-
- this.steps = [this.waitForPageLoad,
- this.enableDeveloperMode,
- testButtonVisibility,
- testDone];
- this.nextStep();
-});
-
-/**
- * TestFixture for extension settings WebUI testing (commands config edition).
- * @extends {testing.Test}
- * @constructor
- */
-function SettingsCommandsExtensionSettingsWebUITest() {}
-
-SettingsCommandsExtensionSettingsWebUITest.prototype = {
- __proto__: ExtensionSettingsWebUITest.prototype,
-
- /**
- * A URL to load before starting each test.
- * @type {string}
- * @const
- */
- browsePreload: 'chrome://extensions/configureCommands',
-};
-
-TEST_F('SettingsCommandsExtensionSettingsWebUITest', 'testChromeSendHandler',
- function() {
- // Just navigating to the page should trigger the chrome.send().
- var assertOverlayVisible = function() {
- assertTrue($('extension-commands-overlay').classList.contains('showing'));
- assertEquals($('extension-commands-overlay').getAttribute('aria-hidden'),
- 'false');
- this.nextStep();
- };
-
- this.steps = [this.waitForPageLoad, assertOverlayVisible, testDone];
- this.nextStep();
-});
-
-TEST_F('SettingsCommandsExtensionSettingsWebUITest', 'extensionSettingsUri',
- function() {
- var closeCommandOverlay = function() {
- assertTrue($('extension-commands-overlay').classList.contains('showing'));
- assertEquals($('extension-commands-overlay').getAttribute('aria-hidden'),
- 'false');
- assertEquals(window.location.href, 'chrome://extensions/configureCommands');
-
- // Close command overlay.
- $('extension-commands-dismiss').click();
-
- assertFalse($('extension-commands-overlay').classList.contains('showing'));
- assertEquals($('extension-commands-overlay').getAttribute('aria-hidden'),
- 'true');
- this.nextStep();
- };
-
- var checkExtensionsUrl = function() {
- // After closing the overlay, the URL shouldn't include commands overlay
- // reference.
- assertEquals(window.location.href, 'chrome://extensions/');
- this.nextStep();
- };
-
- this.steps = [this.waitForPageLoad,
- closeCommandOverlay,
- checkExtensionsUrl,
- testDone];
- this.nextStep();
-});
-
-/**
- * @constructor
- * @extends {ExtensionSettingsWebUITest}
- */
-function InstallGoodExtensionSettingsWebUITest() {}
-
-InstallGoodExtensionSettingsWebUITest.prototype = {
- __proto__: ExtensionSettingsWebUITest.prototype,
-
- /** @override */
- testGenPreamble: function() {
- GEN(' InstallGoodExtension();');
- },
-
- emptyTestForAccessibility() {
- this.steps = [this.waitForPageLoad, testDone];
- this.nextStep();
- },
-};
-
-TEST_F('InstallGoodExtensionSettingsWebUITest', 'testAccessibility',
- function() {
- this.emptyTestForAccessibility();
-});
-
-TEST_F('InstallGoodExtensionSettingsWebUITest', 'showOptions', function() {
- var showExtensionOptions = function() {
- var optionsOverlay = extensions.ExtensionOptionsOverlay.getInstance();
- optionsOverlay.setExtensionAndShow(GOOD_EXTENSION_ID, 'GOOD!', '',
- this.nextStep.bind(this));
-
- // Preferred size changes don't happen in browser tests. Just fake it.
- document.querySelector('extensionoptions').onpreferredsizechanged(
- {width: 500, height: 500});
- };
-
- this.steps = [this.waitForPageLoad, showExtensionOptions, testDone];
- this.nextStep();
-});
-
-/**
- * @constructor
- * @extends {InstallGoodExtensionSettingsWebUITest}
- */
-function ManagedExtensionSettingsWebUITest() {}
-
-ManagedExtensionSettingsWebUITest.prototype = {
- __proto__: InstallGoodExtensionSettingsWebUITest.prototype,
-
- /** @override */
- testGenPreamble: function() {
- GEN(' AddManagedPolicyProvider();');
- InstallGoodExtensionSettingsWebUITest.prototype.testGenPreamble.call(this);
- },
-};
-
-TEST_F('ManagedExtensionSettingsWebUITest', 'testAccessibility', function() {
- this.emptyTestForAccessibility();
-});
-
-/**
- * @constructor
- * @extends {InstallGoodExtensionSettingsWebUITest}
- */
-function OptionsDialogExtensionSettingsWebUITest() {}
-
-OptionsDialogExtensionSettingsWebUITest.prototype = {
- __proto__: InstallGoodExtensionSettingsWebUITest.prototype,
-
- setUp() {
- InstallGoodExtensionSettingsWebUITest.prototype.setUp.call(this);
-
- // False positive on iframe hosting the <extensionoptions> guest view.
- this.accessibilityAuditConfig.ignoreSelectors(
- 'focusableElementNotVisibleAndNotAriaHidden', 'iframe');
- },
-
- /** @override */
- browsePreload: ExtensionSettingsWebUITest.prototype.browsePreload +
- '?options=' + GOOD_EXTENSION_ID,
-};
-
-TEST_F('OptionsDialogExtensionSettingsWebUITest', 'testAccessibility',
- function() {
- this.emptyTestForAccessibility();
-});
diff --git a/chromium/chrome/browser/ui/webui/extensions/extension_settings_handler.cc b/chromium/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
deleted file mode 100644
index 8e9efd24aa9..00000000000
--- a/chromium/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
+++ /dev/null
@@ -1,319 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/extensions/extension_settings_handler.h"
-
-#include <vector>
-
-#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/apps/app_info_dialog.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/common/buildflags.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/grit/chromium_strings.h"
-#include "chrome/grit/generated_resources.h"
-#include "components/google/core/browser/google_util.h"
-#include "components/pref_registry/pref_registry_syncable.h"
-#include "components/prefs/pref_service.h"
-#include "components/strings/grit/components_strings.h"
-#include "content/public/browser/navigation_handle.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_ui.h"
-#include "content/public/browser/web_ui_data_source.h"
-#include "extensions/browser/extension_registry.h"
-#include "extensions/browser/extension_system.h"
-#include "extensions/common/extension.h"
-#include "extensions/common/extension_set.h"
-#include "extensions/common/extension_urls.h"
-#include "extensions/common/manifest.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "url/gurl.h"
-
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
-#include "chrome/browser/supervised_user/supervised_user_service.h"
-#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
-#endif
-
-namespace extensions {
-
-ExtensionSettingsHandler::ExtensionSettingsHandler()
- : extension_service_(nullptr) {
-}
-
-ExtensionSettingsHandler::~ExtensionSettingsHandler() {
-}
-
-// static
-void ExtensionSettingsHandler::RegisterProfilePrefs(
- user_prefs::PrefRegistrySyncable* registry) {
- registry->RegisterBooleanPref(
- prefs::kExtensionsUIDeveloperMode,
- false,
- user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
- registry->RegisterBooleanPref(
- prefs::kExtensionsUIDismissedADTPromo,
- false,
- user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
-}
-
-void ExtensionSettingsHandler::GetLocalizedValues(
- content::WebUIDataSource* source) {
- source->AddString("extensionSettings",
- l10n_util::GetStringUTF16(IDS_MANAGE_EXTENSIONS_SETTING_WINDOWS_TITLE));
-
- source->AddString("extensionSettingsDeveloperMode",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_DEVELOPER_MODE_LINK));
- source->AddString("extensionSettingsNoExtensions",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_NONE_INSTALLED));
- source->AddString(
- "extensionSettingsSuggestGallery",
- l10n_util::GetStringFUTF16(
- IDS_EXTENSIONS_NONE_INSTALLED_SUGGEST_GALLERY,
- base::ASCIIToUTF16(
- google_util::AppendGoogleLocaleParam(
- GURL(extension_urls::GetWebstoreExtensionsCategoryURL()),
- g_browser_process->GetApplicationLocale()).spec())));
- source->AddString("extensionSettingsGetMoreExtensions",
- l10n_util::GetStringUTF16(IDS_GET_MORE_EXTENSIONS));
- source->AddString(
- "extensionSettingsGetMoreExtensionsUrl",
- base::ASCIIToUTF16(
- google_util::AppendGoogleLocaleParam(
- GURL(extension_urls::GetWebstoreExtensionsCategoryURL()),
- g_browser_process->GetApplicationLocale()).spec()));
- source->AddString("extensionSettingsExtensionId",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_ID));
- source->AddString("extensionSettingsExtensionPath",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_PATH));
- source->AddString("extensionSettingsInspectViews",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_INSPECT_VIEWS));
- source->AddString("extensionSettingsInstallWarnings",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_INSTALL_WARNINGS));
- source->AddString("viewIncognito",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_VIEW_INCOGNITO));
- source->AddString("viewInactive",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_VIEW_INACTIVE));
- source->AddString("viewIframe",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_VIEW_IFRAME));
- source->AddString("backgroundPage",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_BACKGROUND_PAGE));
- source->AddString("extensionSettingsEnable",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_ENABLE));
- source->AddString("extensionSettingsEnabled",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_ENABLED));
- source->AddString("extensionSettingsRemove",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_REMOVE));
- source->AddString("extensionSettingsEnableIncognito",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_ENABLE_INCOGNITO));
- source->AddString("extensionSettingsEnableErrorCollection",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_ENABLE_ERROR_COLLECTION));
- source->AddString("extensionSettingsAllowFileAccess",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_ALLOW_FILE_ACCESS));
- source->AddString("extensionSettingsAllowOnAllUrls",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_ALLOW_ON_ALL_URLS));
- source->AddString("extensionSettingsIncognitoWarning",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_INCOGNITO_WARNING));
- source->AddString("extensionSettingsReloadTerminated",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_RELOAD_TERMINATED));
- source->AddString("extensionSettingsRepairCorrupted",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_REPAIR_CORRUPTED));
- source->AddString("extensionSettingsLaunch",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_LAUNCH));
- source->AddString("extensionSettingsReloadUnpacked",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_RELOAD_UNPACKED));
- source->AddString("extensionSettingsOptions",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_OPTIONS_LINK));
- if (CanShowAppInfoDialog()) {
- source->AddString("extensionSettingsPermissions",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_INFO_LINK));
- } else {
- source->AddString(
- "extensionSettingsPermissions",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_PERMISSIONS_LINK));
- }
- source->AddString("extensionSettingsVisitWebsite",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSITE));
- source->AddString("extensionSettingsVisitWebStore",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSTORE));
- source->AddString("extensionSettingsPolicyControlled",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_POLICY_CONTROLLED));
- source->AddString("extensionSettingsPolicyRecommeneded",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_POLICY_RECOMMENDED));
- source->AddString("extensionSettingsDependentExtensions",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_DEPENDENT_EXTENSIONS));
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
- const SupervisedUserService* supervised_user_service =
- SupervisedUserServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()));
- source->AddString("extensionSettingsSupervisedUser",
- supervised_user_service->GetExtensionsLockedMessage());
-#endif
- source->AddString("loading",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOADING));
- source->AddString("extensionSettingsCorruptInstall",
- l10n_util::GetStringUTF16(
- IDS_EXTENSIONS_CORRUPTED_EXTENSION));
- source->AddString("extensionSettingsSuspiciousInstall",
- l10n_util::GetStringFUTF16(
- IDS_EXTENSIONS_ADDED_WITHOUT_KNOWLEDGE,
- l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE)));
- source->AddString("extensionSettingsLearnMore",
- l10n_util::GetStringUTF16(IDS_LEARN_MORE));
- source->AddString("extensionSettingsSuspiciousInstallHelpUrl",
- base::ASCIIToUTF16(
- google_util::AppendGoogleLocaleParam(
- GURL(chrome::kRemoveNonCWSExtensionURL),
- g_browser_process->GetApplicationLocale()).spec()));
- source->AddString("extensionSettingsLoadUnpackedButton",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOAD_UNPACKED_BUTTON));
- source->AddString("extensionSettingsPackButton",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_PACK_BUTTON));
- source->AddString("extensionSettingsCommandsLink",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_COMMANDS_CONFIGURE));
- source->AddString("extensionSettingsUpdateButton",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_UPDATE_BUTTON));
- source->AddString("extensionSettingsCrashMessage",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_CRASHED_EXTENSION));
- source->AddString("extensionSettingsInDevelopment",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_IN_DEVELOPMENT));
- source->AddString("extensionSettingsWarningsTitle",
- l10n_util::GetStringUTF16(IDS_EXTENSION_WARNINGS_TITLE));
- source->AddString("extensionSettingsShowDetails",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_DETAILS));
- source->AddString("extensionSettingsHideDetails",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_HIDE_DETAILS));
- source->AddString("extensionSettingsUpdateRequiredBePolicy",
- l10n_util::GetStringUTF16(
- IDS_EXTENSIONS_DISABLED_UPDATE_REQUIRED_BY_POLICY));
-
- source->AddLocalizedString("extensionLogLevelInfo",
- IDS_EXTENSIONS_LOG_LEVEL_INFO);
- source->AddLocalizedString("extensionLogLevelWarn",
- IDS_EXTENSIONS_LOG_LEVEL_WARN);
- source->AddLocalizedString("extensionLogLevelError",
- IDS_EXTENSIONS_LOG_LEVEL_ERROR);
-
- // TODO(estade): comb through the above strings to find ones no longer used in
- // uber extensions.
- source->AddString("extensionUninstall",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL));
-
- // Pack Extension Overlay:
- source->AddString("packExtensionOverlay",
- l10n_util::GetStringUTF16(IDS_EXTENSION_PACK_DIALOG_TITLE));
- source->AddString("packExtensionHeading",
- l10n_util::GetStringUTF16(IDS_EXTENSION_PACK_DIALOG_HEADING));
- source->AddString("packExtensionCommit",
- l10n_util::GetStringUTF16(IDS_EXTENSION_PACK_BUTTON));
- source->AddString("ok", l10n_util::GetStringUTF16(IDS_OK));
- source->AddString("cancel", l10n_util::GetStringUTF16(IDS_CANCEL));
- source->AddString("packExtensionRootDir",
- l10n_util::GetStringUTF16(
- IDS_EXTENSION_PACK_DIALOG_ROOT_DIRECTORY_LABEL));
- source->AddString("packExtensionPrivateKey",
- l10n_util::GetStringUTF16(IDS_EXTENSION_PACK_DIALOG_PRIVATE_KEY_LABEL));
- source->AddString("packExtensionBrowseButton",
- l10n_util::GetStringUTF16(IDS_EXTENSION_PACK_DIALOG_BROWSE));
- source->AddString("packExtensionProceedAnyway",
- l10n_util::GetStringUTF16(IDS_EXTENSION_PROCEED_ANYWAY));
- source->AddString("packExtensionWarningTitle",
- l10n_util::GetStringUTF16(IDS_EXTENSION_PACK_WARNING_TITLE));
- source->AddString("packExtensionErrorTitle",
- l10n_util::GetStringUTF16(IDS_EXTENSION_PACK_ERROR_TITLE));
-
- // Extension Error and Extension Error Overlay:
- source->AddString("extensionErrorHeading",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_ERROR_HEADING));
- source->AddString("extensionErrorClearAll",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_ERROR_CLEAR_ALL));
- source->AddString("extensionErrorNoErrors",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_ERROR_NO_ERRORS));
- source->AddString(
- "extensionErrorNoErrorsCodeMessage",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_ERROR_NO_ERRORS_CODE_MESSAGE));
- source->AddString("extensionErrorOverlayDone",
- l10n_util::GetStringUTF16(IDS_DONE));
- source->AddString(
- "extensionErrorOverlayContextUrl",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_ERROR_CONTEXT));
- source->AddString(
- "extensionErrorOverlayStackTrace",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_ERROR_STACK_TRACE));
- source->AddString(
- "extensionErrorOverlayAnonymousFunction",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_ERROR_ANONYMOUS_FUNCTION));
- source->AddString(
- "extensionErrorOverlayLaunchDevtools",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_ERROR_LAUNCH_DEVTOOLS));
- source->AddString(
- "extensionErrorOverlayContextUnknown",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_ERROR_CONTEXT_UNKNOWN));
- source->AddString(
- "extensionErrorOverlayNoCodeToDisplay",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_ERROR_NO_CODE_TO_DISPLAY));
-
- // Extension Commands Overlay:
- source->AddString("extensionCommandsOverlay",
- l10n_util::GetStringUTF16(IDS_EXTENSION_COMMANDS_DIALOG_TITLE));
- source->AddString("extensionCommandsEmpty",
- l10n_util::GetStringUTF16(IDS_EXTENSION_COMMANDS_EMPTY));
- source->AddString("extensionCommandsInactive",
- l10n_util::GetStringUTF16(IDS_EXTENSION_COMMANDS_INACTIVE));
- source->AddString("extensionCommandsStartTyping",
- l10n_util::GetStringUTF16(IDS_EXTENSION_TYPE_SHORTCUT));
- source->AddString("extensionCommandsDelete",
- l10n_util::GetStringUTF16(IDS_EXTENSION_DELETE_SHORTCUT));
- source->AddString("extensionCommandsGlobal",
- l10n_util::GetStringUTF16(IDS_EXTENSION_COMMANDS_GLOBAL));
- source->AddString("extensionCommandsRegular",
- l10n_util::GetStringUTF16(IDS_EXTENSION_COMMANDS_NOT_GLOBAL));
- source->AddString("ok", l10n_util::GetStringUTF16(IDS_OK));
-
- // 'Bubble' text for the controlled-setting-indicator
- source->AddString("extensionControlledSettingPolicy",
- l10n_util::GetStringUTF16(IDS_CONTROLLED_SETTING_POLICY));
-}
-
-void ExtensionSettingsHandler::DidStartNavigation(
- content::NavigationHandle* navigation_handle) {
- if (!navigation_handle->IsInMainFrame())
- return;
-
- if (navigation_handle->GetReloadType() != content::ReloadType::NONE)
- ReloadUnpackedExtensions();
-}
-
-void ExtensionSettingsHandler::RegisterMessages() {
- Profile* profile = Profile::FromWebUI(web_ui())->GetOriginalProfile();
- extension_service_ =
- extensions::ExtensionSystem::Get(profile)->extension_service();
- // Clear the preference for the ADT Promo before fully removing it.
- // TODO(devlin): Take this out when everyone's been updated.
- Profile::FromWebUI(web_ui())->GetPrefs()->ClearPref(
- prefs::kExtensionsUIDismissedADTPromo);
-
- content::WebContentsObserver::Observe(web_ui()->GetWebContents());
-}
-
-void ExtensionSettingsHandler::ReloadUnpackedExtensions() {
- ExtensionRegistry* registry =
- ExtensionRegistry::Get(extension_service_->profile());
- std::vector<const Extension*> unpacked_extensions;
- for (const scoped_refptr<const extensions::Extension>& extension :
- registry->enabled_extensions()) {
- if (Manifest::IsUnpackedLocation(extension->location()))
- unpacked_extensions.push_back(extension.get());
- }
-
- for (std::vector<const Extension*>::iterator iter =
- unpacked_extensions.begin(); iter != unpacked_extensions.end(); ++iter) {
- extension_service_->ReloadExtensionWithQuietFailure((*iter)->id());
- }
-}
-
-} // namespace extensions
diff --git a/chromium/chrome/browser/ui/webui/extensions/extension_settings_handler.h b/chromium/chrome/browser/ui/webui/extensions/extension_settings_handler.h
deleted file mode 100644
index 40f4982d600..00000000000
--- a/chromium/chrome/browser/ui/webui/extensions/extension_settings_handler.h
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_
-
-#include "base/macros.h"
-#include "content/public/browser/reload_type.h"
-#include "content/public/browser/web_contents_observer.h"
-#include "content/public/browser/web_ui_message_handler.h"
-
-class ExtensionService;
-
-namespace content {
-class WebUIDataSource;
-}
-
-namespace user_prefs {
-class PrefRegistrySyncable;
-}
-
-namespace extensions {
-
-// Extension Settings UI handler.
-class ExtensionSettingsHandler : public content::WebUIMessageHandler,
- public content::WebContentsObserver {
- public:
- ExtensionSettingsHandler();
- ~ExtensionSettingsHandler() override;
-
- static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
-
- // Note: This uses |web_ui()| from |WebUIMessageHandler|, so it must only be
- // called after |web_ui->AddMessageHandler(this)| has been called.
- void GetLocalizedValues(content::WebUIDataSource* source);
-
- private:
- // WebContentsObserver implementation.
- void DidStartNavigation(
- content::NavigationHandle* navigation_handle) override;
-
- // WebUIMessageHandler implementation.
- void RegisterMessages() override;
-
- // Helper method that reloads all unpacked extensions.
- void ReloadUnpackedExtensions();
-
- // Our model. Outlives us since it's owned by our containing profile.
- ExtensionService* extension_service_;
-
- DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler);
-};
-
-} // namespace extensions
-
-#endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc b/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc
index 207eb0edb4a..8f10e4d7c59 100644
--- a/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc
+++ b/chromium/chrome/browser/ui/webui/extensions/extensions_ui.cc
@@ -14,11 +14,7 @@
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/extensions/extension_loader_handler.h"
-#include "chrome/browser/ui/webui/extensions/extension_settings_handler.h"
-#include "chrome/browser/ui/webui/extensions/install_extension_handler.h"
#include "chrome/browser/ui/webui/metrics_handler.h"
-#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
@@ -28,6 +24,7 @@
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h"
#include "components/google/core/browser/google_util.h"
+#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/navigation_handle.h"
@@ -42,7 +39,6 @@
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h"
#include "chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.h"
-#include "components/user_manager/user_manager.h"
#endif
namespace extensions {
@@ -52,10 +48,24 @@ namespace {
constexpr char kInDevModeKey[] = "inDevMode";
constexpr char kLoadTimeClassesKey[] = "loadTimeClasses";
+struct LocalizedString {
+ const char* name;
+ int id;
+};
+
+void AddLocalizedStringsBulk(content::WebUIDataSource* html_source,
+ const LocalizedString localized_strings[],
+ size_t num_strings) {
+ for (size_t i = 0; i < num_strings; i++) {
+ html_source->AddLocalizedString(localized_strings[i].name,
+ localized_strings[i].id);
+ }
+}
+
class ExtensionWebUiTimer : public content::WebContentsObserver {
public:
- explicit ExtensionWebUiTimer(content::WebContents* web_contents, bool is_md)
- : content::WebContentsObserver(web_contents), is_md_(is_md) {}
+ explicit ExtensionWebUiTimer(content::WebContents* web_contents)
+ : content::WebContentsObserver(web_contents) {}
~ExtensionWebUiTimer() override {}
void DidStartNavigation(
@@ -72,13 +82,8 @@ class ExtensionWebUiTimer : public content::WebContentsObserver {
!timer_) { // See comment in DocumentOnLoadCompletedInMainFrame()
return;
}
- if (is_md_) {
- UMA_HISTOGRAM_TIMES("Extensions.WebUi.DocumentLoadedInMainFrameTime.MD",
- timer_->Elapsed());
- } else {
- UMA_HISTOGRAM_TIMES("Extensions.WebUi.DocumentLoadedInMainFrameTime.Uber",
- timer_->Elapsed());
- }
+ UMA_HISTOGRAM_TIMES("Extensions.WebUi.DocumentLoadedInMainFrameTime.MD",
+ timer_->Elapsed());
}
void DocumentOnLoadCompletedInMainFrame() override {
@@ -89,22 +94,14 @@ class ExtensionWebUiTimer : public content::WebContentsObserver {
// will receive this current callback.
return;
}
- if (is_md_) {
- UMA_HISTOGRAM_TIMES("Extensions.WebUi.LoadCompletedInMainFrame.MD",
- timer_->Elapsed());
- } else {
- UMA_HISTOGRAM_TIMES("Extensions.WebUi.LoadCompletedInMainFrame.Uber",
- timer_->Elapsed());
- }
+ UMA_HISTOGRAM_TIMES("Extensions.WebUi.LoadCompletedInMainFrame.MD",
+ timer_->Elapsed());
timer_.reset();
}
void WebContentsDestroyed() override { delete this; }
private:
- // Whether this is the MD version of the chrome://extensions page.
- bool is_md_;
-
std::unique_ptr<base::ElapsedTimer> timer_;
DISALLOW_COPY_AND_ASSIGN(ExtensionWebUiTimer);
@@ -117,245 +114,173 @@ std::string GetLoadTimeClasses(bool in_dev_mode) {
content::WebUIDataSource* CreateMdExtensionsSource(bool in_dev_mode) {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIExtensionsHost);
+ source->OverrideContentSecurityPolicyScriptSrc(
+ "script-src chrome://resources 'self';");
source->SetJsonPath("strings.js");
- // Add common strings.
- source->AddLocalizedString("add", IDS_ADD);
- source->AddLocalizedString("back", IDS_ACCNAME_BACK);
- source->AddLocalizedString("cancel", IDS_CANCEL);
- source->AddLocalizedString("close", IDS_CLOSE);
- source->AddLocalizedString("confirm", IDS_CONFIRM);
- source->AddLocalizedString("done", IDS_DONE);
- source->AddLocalizedString("ok", IDS_OK);
- source->AddLocalizedString("controlledSettingPolicy",
- IDS_CONTROLLED_SETTING_POLICY);
-
- // Add extension-specific strings.
- source->AddLocalizedString("title",
- IDS_MANAGE_EXTENSIONS_SETTING_WINDOWS_TITLE);
- source->AddLocalizedString("toolbarTitle", IDS_MD_EXTENSIONS_TOOLBAR_TITLE);
- source->AddLocalizedString("mainMenu", IDS_MD_EXTENSIONS_MENU_BUTTON_LABEL);
- source->AddLocalizedString("search", IDS_MD_EXTENSIONS_SEARCH);
- // TODO(dpapad): Use a single merged string resource for "Clear search".
- source->AddLocalizedString("clearSearch", IDS_DOWNLOAD_CLEAR_SEARCH);
- source->AddLocalizedString("sidebarExtensions",
- IDS_MD_EXTENSIONS_SIDEBAR_EXTENSIONS);
- source->AddLocalizedString("appsTitle", IDS_MD_EXTENSIONS_APPS_TITLE);
- source->AddLocalizedString("noExtensionsOrApps",
- IDS_MD_EXTENSIONS_NO_INSTALLED_ITEMS);
- source->AddLocalizedString("noDescription", IDS_MD_EXTENSIONS_NO_DESCRIPTION);
- source->AddLocalizedString("viewInStore",
- IDS_MD_EXTENSIONS_ITEM_CHROME_WEB_STORE);
- source->AddLocalizedString("extensionWebsite",
- IDS_MD_EXTENSIONS_ITEM_EXTENSION_WEBSITE);
- source->AddLocalizedString("noSearchResults", IDS_SEARCH_NO_RESULTS);
- source->AddLocalizedString("searchResults", IDS_SEARCH_RESULTS);
- source->AddLocalizedString("dropToInstall",
- IDS_EXTENSIONS_INSTALL_DROP_TARGET);
- source->AddLocalizedString("errorsPageHeading",
- IDS_MD_EXTENSIONS_ERROR_PAGE_HEADING);
- source->AddLocalizedString("clearAll", IDS_MD_EXTENSIONS_ERROR_CLEAR_ALL);
- source->AddLocalizedString("clearEntry", IDS_MD_EXTENSIONS_A11Y_CLEAR_ENTRY);
- source->AddLocalizedString("logLevel", IDS_EXTENSIONS_LOG_LEVEL_INFO);
- source->AddLocalizedString("warnLevel", IDS_EXTENSIONS_LOG_LEVEL_WARN);
- source->AddLocalizedString("errorLevel", IDS_EXTENSIONS_LOG_LEVEL_ERROR);
- source->AddLocalizedString("anonymousFunction",
- IDS_MD_EXTENSIONS_ERROR_ANONYMOUS_FUNCTION);
- source->AddLocalizedString("errorContext", IDS_MD_EXTENSIONS_ERROR_CONTEXT);
- source->AddLocalizedString("errorContextUnknown",
- IDS_MD_EXTENSIONS_ERROR_CONTEXT_UNKNOWN);
- source->AddLocalizedString("openInDevtool",
- IDS_MD_EXTENSIONS_ERROR_LAUNCH_DEVTOOLS);
+ constexpr LocalizedString localized_strings[] = {
+ // Add common strings.
+ {"add", IDS_ADD},
+ {"back", IDS_ACCNAME_BACK},
+ {"cancel", IDS_CANCEL},
+ {"close", IDS_CLOSE},
+ {"confirm", IDS_CONFIRM},
+ {"controlledSettingPolicy", IDS_CONTROLLED_SETTING_POLICY},
+ {"done", IDS_DONE},
+ {"learnMore", IDS_LEARN_MORE},
+ {"noSearchResults", IDS_SEARCH_NO_RESULTS},
+ {"ok", IDS_OK},
+ {"searchResults", IDS_SEARCH_RESULTS},
+
+ // Add extension-specific strings.
+ {"title", IDS_MANAGE_EXTENSIONS_SETTING_WINDOWS_TITLE},
+ {"toolbarTitle", IDS_MD_EXTENSIONS_TOOLBAR_TITLE},
+ {"mainMenu", IDS_MD_EXTENSIONS_MENU_BUTTON_LABEL},
+ {"search", IDS_MD_EXTENSIONS_SEARCH},
+ // TODO(dpapad): Use a single merged string resource for "Clear search".
+ {"clearSearch", IDS_DOWNLOAD_CLEAR_SEARCH},
+ {"sidebarExtensions", IDS_MD_EXTENSIONS_SIDEBAR_EXTENSIONS},
+ {"appsTitle", IDS_MD_EXTENSIONS_APPS_TITLE},
+ {"noExtensionsOrApps", IDS_MD_EXTENSIONS_NO_INSTALLED_ITEMS},
+ {"noDescription", IDS_MD_EXTENSIONS_NO_DESCRIPTION},
+ {"viewInStore", IDS_MD_EXTENSIONS_ITEM_CHROME_WEB_STORE},
+ {"extensionWebsite", IDS_MD_EXTENSIONS_ITEM_EXTENSION_WEBSITE},
+ {"dropToInstall", IDS_EXTENSIONS_INSTALL_DROP_TARGET},
+ {"errorsPageHeading", IDS_MD_EXTENSIONS_ERROR_PAGE_HEADING},
+ {"clearAll", IDS_MD_EXTENSIONS_ERROR_CLEAR_ALL},
+ {"clearEntry", IDS_MD_EXTENSIONS_A11Y_CLEAR_ENTRY},
+ {"logLevel", IDS_EXTENSIONS_LOG_LEVEL_INFO},
+ {"warnLevel", IDS_EXTENSIONS_LOG_LEVEL_WARN},
+ {"errorLevel", IDS_EXTENSIONS_LOG_LEVEL_ERROR},
+ {"anonymousFunction", IDS_MD_EXTENSIONS_ERROR_ANONYMOUS_FUNCTION},
+ {"errorContext", IDS_MD_EXTENSIONS_ERROR_CONTEXT},
+ {"errorContextUnknown", IDS_MD_EXTENSIONS_ERROR_CONTEXT_UNKNOWN},
+ {"stackTrace", IDS_MD_EXTENSIONS_ERROR_STACK_TRACE},
+ // TODO(dpapad): Unify with Settings' IDS_SETTINGS_WEB_STORE.
+ {"openChromeWebStore", IDS_MD_EXTENSIONS_SIDEBAR_OPEN_CHROME_WEB_STORE},
+ {"keyboardShortcuts", IDS_MD_EXTENSIONS_SIDEBAR_KEYBOARD_SHORTCUTS},
+ {"incognitoInfoWarning", IDS_EXTENSIONS_INCOGNITO_WARNING},
+ {"itemId", IDS_MD_EXTENSIONS_ITEM_ID},
+ {"itemInspectViews", IDS_MD_EXTENSIONS_ITEM_INSPECT_VIEWS},
+ // NOTE: This text reads "<n> more". It's possible that it should be using
+ // a plural string instead. Unfortunately, this is non-trivial since we
+ // don't expose that capability to JS yet. Since we don't know it's a
+ // problem, use a simple placeholder for now.
+ {"itemInspectViewsExtra", IDS_MD_EXTENSIONS_ITEM_INSPECT_VIEWS_EXTRA},
+ {"noActiveViews", IDS_MD_EXTENSIONS_ITEM_NO_ACTIVE_VIEWS},
+ {"itemAllowIncognito", IDS_MD_EXTENSIONS_ITEM_ALLOW_INCOGNITO},
+ {"itemDescriptionLabel", IDS_MD_EXTENSIONS_ITEM_DESCRIPTION},
+ {"itemDependencies", IDS_MD_EXTENSIONS_ITEM_DEPENDENCIES},
+ {"itemDependentEntry", IDS_MD_EXTENSIONS_DEPENDENT_ENTRY},
+ {"itemDetails", IDS_MD_EXTENSIONS_ITEM_DETAILS},
+ {"itemErrors", IDS_MD_EXTENSIONS_ITEM_ERRORS},
+ {"accessibilityErrorLine", IDS_MD_EXTENSIONS_ACCESSIBILITY_ERROR_LINE},
+ {"accessibilityErrorMultiLine",
+ IDS_MD_EXTENSIONS_ACCESSIBILITY_ERROR_MULTI_LINE},
+ {"appIcon", IDS_MD_EXTENSIONS_APP_ICON},
+ {"extensionIcon", IDS_MD_EXTENSIONS_EXTENSION_ICON},
+ {"extensionA11yAssociation", IDS_MD_EXTENSIONS_EXTENSION_A11Y_ASSOCIATION},
+ {"itemIdHeading", IDS_MD_EXTENSIONS_ITEM_ID_HEADING},
+ {"extensionEnabled", IDS_MD_EXTENSIONS_EXTENSION_ENABLED},
+ {"appEnabled", IDS_MD_EXTENSIONS_APP_ENABLED},
+ {"installWarnings", IDS_EXTENSIONS_INSTALL_WARNINGS},
+ {"itemExtensionPath", IDS_EXTENSIONS_PATH},
+ {"itemOff", IDS_MD_EXTENSIONS_ITEM_OFF},
+ {"itemOn", IDS_MD_EXTENSIONS_ITEM_ON},
+ {"itemOptions", IDS_MD_EXTENSIONS_ITEM_OPTIONS},
+ {"itemPermissions", IDS_MD_EXTENSIONS_ITEM_PERMISSIONS},
+ {"itemPermissionsEmpty", IDS_MD_EXTENSIONS_ITEM_PERMISSIONS_EMPTY},
+ {"itemRemove", IDS_MD_EXTENSIONS_ITEM_REMOVE},
+ {"itemRemoveExtension", IDS_MD_EXTENSIONS_ITEM_REMOVE_EXTENSION},
+ {"itemSource", IDS_MD_EXTENSIONS_ITEM_SOURCE},
+ {"itemSourcePolicy", IDS_MD_EXTENSIONS_ITEM_SOURCE_POLICY},
+ {"itemSourceSideloaded", IDS_MD_EXTENSIONS_ITEM_SOURCE_SIDELOADED},
+ {"itemSourceUnpacked", IDS_MD_EXTENSIONS_ITEM_SOURCE_UNPACKED},
+ {"itemSourceWebstore", IDS_MD_EXTENSIONS_ITEM_SOURCE_WEBSTORE},
+ {"itemVersion", IDS_MD_EXTENSIONS_ITEM_VERSION},
+ // TODO(dpapad): Replace this with an Extensions specific string.
+ {"itemSize", IDS_DIRECTORY_LISTING_SIZE},
+ {"itemAllowOnFileUrls", IDS_EXTENSIONS_ALLOW_FILE_ACCESS},
+ {"itemAllowOnAllSites", IDS_EXTENSIONS_ALLOW_ON_ALL_URLS},
+ {"itemCollectErrors", IDS_EXTENSIONS_ENABLE_ERROR_COLLECTION},
+ {"itemCorruptInstall", IDS_EXTENSIONS_CORRUPTED_EXTENSION},
+ {"itemRepair", IDS_EXTENSIONS_REPAIR_CORRUPTED},
+ {"itemReload", IDS_EXTENSIONS_RELOAD_TERMINATED},
+ {"loadErrorCouldNotLoadManifest",
+ IDS_MD_EXTENSIONS_LOAD_ERROR_COULD_NOT_LOAD_MANIFEST},
+ {"loadErrorHeading", IDS_MD_EXTENSIONS_LOAD_ERROR_HEADING},
+ {"loadErrorFileLabel", IDS_MD_EXTENSIONS_LOAD_ERROR_FILE_LABEL},
+ {"loadErrorErrorLabel", IDS_MD_EXTENSIONS_LOAD_ERROR_ERROR_LABEL},
+ {"loadErrorRetry", IDS_MD_EXTENSIONS_LOAD_ERROR_RETRY},
+ {"noErrorsToShow", IDS_EXTENSIONS_ERROR_NO_ERRORS_CODE_MESSAGE},
+ {"packDialogTitle", IDS_MD_EXTENSIONS_PACK_DIALOG_TITLE},
+ {"packDialogWarningTitle", IDS_MD_EXTENSIONS_PACK_DIALOG_WARNING_TITLE},
+ {"packDialogErrorTitle", IDS_MD_EXTENSIONS_PACK_DIALOG_ERROR_TITLE},
+ {"packDialogProceedAnyway", IDS_MD_EXTENSIONS_PACK_DIALOG_PROCEED_ANYWAY},
+ {"packDialogBrowse", IDS_MD_EXTENSIONS_PACK_DIALOG_BROWSE_BUTTON},
+ {"packDialogExtensionRoot",
+ IDS_MD_EXTENSIONS_PACK_DIALOG_EXTENSION_ROOT_LABEL},
+ {"packDialogKeyFile", IDS_MD_EXTENSIONS_PACK_DIALOG_KEY_FILE_LABEL},
+ {"packDialogContent", IDS_EXTENSION_PACK_DIALOG_HEADING},
+ {"packDialogConfirm", IDS_MD_EXTENSIONS_PACK_DIALOG_CONFIRM_BUTTON},
+ {"shortcutNotSet", IDS_MD_EXTENSIONS_SHORTCUT_NOT_SET},
+ {"shortcutScopeGlobal", IDS_MD_EXTENSIONS_SHORTCUT_SCOPE_GLOBAL},
+ {"shortcutScopeLabel", IDS_MD_EXTENSIONS_SHORTCUT_SCOPE_LABEL},
+ {"shortcutScopeInChrome", IDS_MD_EXTENSIONS_SHORTCUT_SCOPE_IN_CHROME},
+ {"shortcutTypeAShortcut", IDS_MD_EXTENSIONS_TYPE_A_SHORTCUT},
+ {"shortcutIncludeStartModifier", IDS_MD_EXTENSIONS_INCLUDE_START_MODIFIER},
+ {"shortcutTooManyModifiers", IDS_MD_EXTENSIONS_TOO_MANY_MODIFIERS},
+ {"shortcutNeedCharacter", IDS_MD_EXTENSIONS_NEED_CHARACTER},
+ {"toolbarDevMode", IDS_MD_EXTENSIONS_DEVELOPER_MODE},
+ {"toolbarLoadUnpacked", IDS_MD_EXTENSIONS_TOOLBAR_LOAD_UNPACKED},
+ {"toolbarPack", IDS_MD_EXTENSIONS_TOOLBAR_PACK},
+ {"toolbarUpdateNow", IDS_MD_EXTENSIONS_TOOLBAR_UPDATE_NOW},
+ {"toolbarUpdateNowTooltip", IDS_MD_EXTENSIONS_TOOLBAR_UPDATE_NOW_TOOLTIP},
+ {"toolbarUpdateDone", IDS_MD_EXTENSIONS_TOOLBAR_UPDATE_DONE},
+ {"toolbarUpdatingToast", IDS_MD_EXTENSIONS_TOOLBAR_UPDATING_TOAST},
+ {"updateRequiredByPolicy",
+ IDS_MD_EXTENSIONS_DISABLED_UPDATE_REQUIRED_BY_POLICY},
+ {"viewBackgroundPage", IDS_EXTENSIONS_BACKGROUND_PAGE},
+ {"viewIncognito", IDS_EXTENSIONS_VIEW_INCOGNITO},
+ {"viewInactive", IDS_EXTENSIONS_VIEW_INACTIVE},
+ {"viewIframe", IDS_EXTENSIONS_VIEW_IFRAME},
+
+#if defined(OS_CHROMEOS)
+ {"manageKioskApp", IDS_MD_EXTENSIONS_MANAGE_KIOSK_APP},
+ {"kioskAddApp", IDS_MD_EXTENSIONS_KIOSK_ADD_APP},
+ {"kioskAddAppHint", IDS_MD_EXTENSIONS_KIOSK_ADD_APP_HINT},
+ {"kioskEnableAutoLaunch", IDS_MD_EXTENSIONS_KIOSK_ENABLE_AUTO_LAUNCH},
+ {"kioskDisableAutoLaunch", IDS_MD_EXTENSIONS_KIOSK_DISABLE_AUTO_LAUNCH},
+ {"kioskAutoLaunch", IDS_MD_EXTENSIONS_KIOSK_AUTO_LAUNCH},
+ {"kioskInvalidApp", IDS_MD_EXTENSIONS_KIOSK_INVALID_APP},
+ {"kioskDisableBailout",
+ IDS_MD_EXTENSIONS_KIOSK_DISABLE_BAILOUT_SHORTCUT_LABEL},
+ {"kioskDisableBailoutWarningTitle",
+ IDS_MD_EXTENSIONS_KIOSK_DISABLE_BAILOUT_SHORTCUT_WARNING_TITLE},
+#endif
+ };
+ AddLocalizedStringsBulk(source, localized_strings,
+ base::size(localized_strings));
+
source->AddString("errorLinesNotShownSingular",
l10n_util::GetPluralStringFUTF16(
IDS_MD_EXTENSIONS_ERROR_LINES_NOT_SHOWN, 1));
source->AddString("errorLinesNotShownPlural",
l10n_util::GetPluralStringFUTF16(
IDS_MD_EXTENSIONS_ERROR_LINES_NOT_SHOWN, 2));
- source->AddLocalizedString("stackTrace", IDS_MD_EXTENSIONS_ERROR_STACK_TRACE);
- // TODO(dpapad): Unify with Settings' IDS_SETTINGS_WEB_STORE.
- source->AddLocalizedString("openChromeWebStore",
- IDS_MD_EXTENSIONS_SIDEBAR_OPEN_CHROME_WEB_STORE);
- source->AddLocalizedString("keyboardShortcuts",
- IDS_MD_EXTENSIONS_SIDEBAR_KEYBOARD_SHORTCUTS);
- source->AddLocalizedString("guestModeMessage", IDS_MD_EXTENSIONS_GUEST_MODE);
- source->AddLocalizedString("incognitoInfoWarning",
- IDS_EXTENSIONS_INCOGNITO_WARNING);
- source->AddLocalizedString("itemId", IDS_MD_EXTENSIONS_ITEM_ID);
- source->AddLocalizedString("itemInspectViews",
- IDS_MD_EXTENSIONS_ITEM_INSPECT_VIEWS);
- // NOTE: This text reads "<n> more". It's possible that it should be using
- // a plural string instead. Unfortunately, this is non-trivial since we don't
- // expose that capability to JS yet. Since we don't know it's a problem, use
- // a simple placeholder for now.
- source->AddLocalizedString("itemInspectViewsExtra",
- IDS_MD_EXTENSIONS_ITEM_INSPECT_VIEWS_EXTRA);
- source->AddLocalizedString("noActiveViews",
- IDS_MD_EXTENSIONS_ITEM_NO_ACTIVE_VIEWS);
- source->AddLocalizedString("itemAllowIncognito",
- IDS_MD_EXTENSIONS_ITEM_ALLOW_INCOGNITO);
- source->AddLocalizedString("itemDescriptionLabel",
- IDS_MD_EXTENSIONS_ITEM_DESCRIPTION);
- source->AddLocalizedString("itemDependencies",
- IDS_MD_EXTENSIONS_ITEM_DEPENDENCIES);
- source->AddLocalizedString("itemDependentEntry",
- IDS_MD_EXTENSIONS_DEPENDENT_ENTRY);
- source->AddLocalizedString("itemDetails", IDS_MD_EXTENSIONS_ITEM_DETAILS);
- source->AddLocalizedString("itemErrors", IDS_MD_EXTENSIONS_ITEM_ERRORS);
- source->AddLocalizedString("accessibilityErrorLine",
- IDS_MD_EXTENSIONS_ACCESSIBILITY_ERROR_LINE);
- source->AddLocalizedString("accessibilityErrorMultiLine",
- IDS_MD_EXTENSIONS_ACCESSIBILITY_ERROR_MULTI_LINE);
- source->AddLocalizedString("appIcon", IDS_MD_EXTENSIONS_APP_ICON);
- source->AddLocalizedString("extensionIcon", IDS_MD_EXTENSIONS_EXTENSION_ICON);
- source->AddLocalizedString("extensionA11yAssociation",
- IDS_MD_EXTENSIONS_EXTENSION_A11Y_ASSOCIATION);
- source->AddLocalizedString("itemIdHeading",
- IDS_MD_EXTENSIONS_ITEM_ID_HEADING);
- source->AddLocalizedString("extensionEnabled",
- IDS_MD_EXTENSIONS_EXTENSION_ENABLED);
- source->AddLocalizedString("appEnabled", IDS_MD_EXTENSIONS_APP_ENABLED);
- source->AddString("itemExtensionPath",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_PATH));
- source->AddLocalizedString("itemOff", IDS_MD_EXTENSIONS_ITEM_OFF);
- source->AddLocalizedString("itemOn", IDS_MD_EXTENSIONS_ITEM_ON);
- source->AddLocalizedString("itemOptions", IDS_MD_EXTENSIONS_ITEM_OPTIONS);
- source->AddLocalizedString("itemPermissions",
- IDS_MD_EXTENSIONS_ITEM_PERMISSIONS);
- source->AddLocalizedString("itemPermissionsEmpty",
- IDS_MD_EXTENSIONS_ITEM_PERMISSIONS_EMPTY);
- source->AddLocalizedString("itemRemove", IDS_MD_EXTENSIONS_ITEM_REMOVE);
- source->AddLocalizedString("itemRemoveExtension",
- IDS_MD_EXTENSIONS_ITEM_REMOVE_EXTENSION);
- source->AddLocalizedString("itemSource",
- IDS_MD_EXTENSIONS_ITEM_SOURCE);
- source->AddLocalizedString("itemSourcePolicy",
- IDS_MD_EXTENSIONS_ITEM_SOURCE_POLICY);
- source->AddLocalizedString("itemSourceSideloaded",
- IDS_MD_EXTENSIONS_ITEM_SOURCE_SIDELOADED);
- source->AddLocalizedString("itemSourceUnpacked",
- IDS_MD_EXTENSIONS_ITEM_SOURCE_UNPACKED);
- source->AddLocalizedString("itemSourceWebstore",
- IDS_MD_EXTENSIONS_ITEM_SOURCE_WEBSTORE);
- source->AddLocalizedString("itemVersion",
- IDS_MD_EXTENSIONS_ITEM_VERSION);
- // TODO(dpapad): Replace this with an Extensions specific string.
- source->AddLocalizedString("itemSize", IDS_DIRECTORY_LISTING_SIZE);
- source->AddLocalizedString("itemAllowOnFileUrls",
- IDS_EXTENSIONS_ALLOW_FILE_ACCESS);
- source->AddLocalizedString("itemAllowOnAllSites",
- IDS_EXTENSIONS_ALLOW_ON_ALL_URLS);
- source->AddLocalizedString("itemCollectErrors",
- IDS_EXTENSIONS_ENABLE_ERROR_COLLECTION);
- source->AddLocalizedString("itemCorruptInstall",
- IDS_EXTENSIONS_CORRUPTED_EXTENSION);
- source->AddLocalizedString("itemRepair", IDS_EXTENSIONS_REPAIR_CORRUPTED);
- source->AddLocalizedString("itemReload", IDS_EXTENSIONS_RELOAD_TERMINATED);
source->AddString(
"itemSuspiciousInstall",
l10n_util::GetStringFUTF16(
IDS_EXTENSIONS_ADDED_WITHOUT_KNOWLEDGE,
l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE)));
- source->AddLocalizedString("learnMore", IDS_LEARN_MORE);
- source->AddLocalizedString(
- "loadErrorCouldNotLoadManifest",
- IDS_MD_EXTENSIONS_LOAD_ERROR_COULD_NOT_LOAD_MANIFEST);
- source->AddLocalizedString("loadErrorHeading",
- IDS_MD_EXTENSIONS_LOAD_ERROR_HEADING);
- source->AddLocalizedString("loadErrorFileLabel",
- IDS_MD_EXTENSIONS_LOAD_ERROR_FILE_LABEL);
- source->AddLocalizedString("loadErrorErrorLabel",
- IDS_MD_EXTENSIONS_LOAD_ERROR_ERROR_LABEL);
- source->AddLocalizedString("loadErrorRetry",
- IDS_MD_EXTENSIONS_LOAD_ERROR_RETRY);
- source->AddLocalizedString("noErrorsToShow",
- IDS_EXTENSIONS_ERROR_NO_ERRORS_CODE_MESSAGE);
- source->AddLocalizedString("packDialogTitle",
- IDS_MD_EXTENSIONS_PACK_DIALOG_TITLE);
- source->AddLocalizedString("packDialogWarningTitle",
- IDS_MD_EXTENSIONS_PACK_DIALOG_WARNING_TITLE);
- source->AddLocalizedString("packDialogErrorTitle",
- IDS_MD_EXTENSIONS_PACK_DIALOG_ERROR_TITLE);
- source->AddLocalizedString("packDialogProceedAnyway",
- IDS_MD_EXTENSIONS_PACK_DIALOG_PROCEED_ANYWAY);
- source->AddLocalizedString("packDialogBrowse",
- IDS_MD_EXTENSIONS_PACK_DIALOG_BROWSE_BUTTON);
- source->AddLocalizedString(
- "packDialogExtensionRoot",
- IDS_MD_EXTENSIONS_PACK_DIALOG_EXTENSION_ROOT_LABEL);
- source->AddLocalizedString("packDialogKeyFile",
- IDS_MD_EXTENSIONS_PACK_DIALOG_KEY_FILE_LABEL);
- source->AddLocalizedString("packDialogContent",
- IDS_EXTENSION_PACK_DIALOG_HEADING);
- source->AddLocalizedString("packDialogConfirm",
- IDS_MD_EXTENSIONS_PACK_DIALOG_CONFIRM_BUTTON);
- source->AddLocalizedString("shortcutNotSet",
- IDS_MD_EXTENSIONS_SHORTCUT_NOT_SET);
- source->AddLocalizedString("shortcutScopeGlobal",
- IDS_MD_EXTENSIONS_SHORTCUT_SCOPE_GLOBAL);
- source->AddLocalizedString("shortcutScopeLabel",
- IDS_MD_EXTENSIONS_SHORTCUT_SCOPE_LABEL);
- source->AddLocalizedString("shortcutScopeInChrome",
- IDS_MD_EXTENSIONS_SHORTCUT_SCOPE_IN_CHROME);
- source->AddLocalizedString("shortcutTypeAShortcut",
- IDS_MD_EXTENSIONS_TYPE_A_SHORTCUT);
- source->AddLocalizedString("shortcutIncludeStartModifier",
- IDS_MD_EXTENSIONS_INCLUDE_START_MODIFIER);
- source->AddLocalizedString("shortcutTooManyModifiers",
- IDS_MD_EXTENSIONS_TOO_MANY_MODIFIERS);
- source->AddLocalizedString("shortcutNeedCharacter",
- IDS_MD_EXTENSIONS_NEED_CHARACTER);
source->AddString(
"suspiciousInstallHelpUrl",
base::ASCIIToUTF16(google_util::AppendGoogleLocaleParam(
GURL(chrome::kRemoveNonCWSExtensionURL),
g_browser_process->GetApplicationLocale())
.spec()));
- source->AddLocalizedString("toolbarDevMode",
- IDS_MD_EXTENSIONS_DEVELOPER_MODE);
- source->AddLocalizedString("toolbarLoadUnpacked",
- IDS_MD_EXTENSIONS_TOOLBAR_LOAD_UNPACKED);
- source->AddLocalizedString("toolbarPack", IDS_MD_EXTENSIONS_TOOLBAR_PACK);
- source->AddLocalizedString("toolbarUpdateNow",
- IDS_MD_EXTENSIONS_TOOLBAR_UPDATE_NOW);
- source->AddLocalizedString("toolbarUpdateNowTooltip",
- IDS_MD_EXTENSIONS_TOOLBAR_UPDATE_NOW_TOOLTIP);
- source->AddLocalizedString("toolbarUpdateDone",
- IDS_MD_EXTENSIONS_TOOLBAR_UPDATE_DONE);
- source->AddLocalizedString("toolbarUpdatingToast",
- IDS_MD_EXTENSIONS_TOOLBAR_UPDATING_TOAST);
- source->AddLocalizedString(
- "updateRequiredByPolicy",
- IDS_MD_EXTENSIONS_DISABLED_UPDATE_REQUIRED_BY_POLICY);
- source->AddLocalizedString("viewBackgroundPage",
- IDS_EXTENSIONS_BACKGROUND_PAGE);
- source->AddLocalizedString("viewIncognito",
- IDS_EXTENSIONS_VIEW_INCOGNITO);
- source->AddLocalizedString("viewInactive",
- IDS_EXTENSIONS_VIEW_INACTIVE);
- source->AddLocalizedString("viewIframe",
- IDS_EXTENSIONS_VIEW_IFRAME);
#if defined(OS_CHROMEOS)
- source->AddLocalizedString("manageKioskApp",
- IDS_MD_EXTENSIONS_MANAGE_KIOSK_APP);
- source->AddLocalizedString("kioskAddApp", IDS_MD_EXTENSIONS_KIOSK_ADD_APP);
- source->AddLocalizedString("kioskAddAppHint",
- IDS_MD_EXTENSIONS_KIOSK_ADD_APP_HINT);
- source->AddLocalizedString("kioskEnableAutoLaunch",
- IDS_MD_EXTENSIONS_KIOSK_ENABLE_AUTO_LAUNCH);
- source->AddLocalizedString("kioskDisableAutoLaunch",
- IDS_MD_EXTENSIONS_KIOSK_DISABLE_AUTO_LAUNCH);
- source->AddLocalizedString("kioskAutoLaunch",
- IDS_MD_EXTENSIONS_KIOSK_AUTO_LAUNCH);
- source->AddLocalizedString("kioskInvalidApp",
- IDS_MD_EXTENSIONS_KIOSK_INVALID_APP);
- source->AddLocalizedString(
- "kioskDisableBailout",
- IDS_MD_EXTENSIONS_KIOSK_DISABLE_BAILOUT_SHORTCUT_LABEL);
- source->AddLocalizedString(
- "kioskDisableBailoutWarningTitle",
- IDS_MD_EXTENSIONS_KIOSK_DISABLE_BAILOUT_SHORTCUT_WARNING_TITLE);
source->AddString(
"kioskDisableBailoutWarningBody",
l10n_util::GetStringFUTF16(
@@ -367,9 +292,8 @@ content::WebUIDataSource* CreateMdExtensionsSource(bool in_dev_mode) {
base::ASCIIToUTF16(
google_util::AppendGoogleLocaleParam(
GURL(extension_urls::GetWebstoreExtensionsCategoryURL()),
- g_browser_process->GetApplicationLocale()).spec()));
- source->AddString("installWarnings",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_INSTALL_WARNINGS));
+ g_browser_process->GetApplicationLocale())
+ .spec()));
source->AddBoolean(kInDevModeKey, in_dev_mode);
source->AddString(kLoadTimeClassesKey, GetLoadTimeClasses(in_dev_mode));
@@ -390,82 +314,23 @@ content::WebUIDataSource* CreateMdExtensionsSource(bool in_dev_mode) {
return source;
}
-content::WebUIDataSource* CreateExtensionsHTMLSource() {
- content::WebUIDataSource* source =
- content::WebUIDataSource::Create(chrome::kChromeUIExtensionsHost);
-
- source->SetJsonPath("strings.js");
- source->AddResourcePath("extensions.js", IDR_EXTENSIONS_JS);
- source->AddResourcePath("extension_command_list.js",
- IDR_EXTENSION_COMMAND_LIST_JS);
- source->AddResourcePath("extension_list.js", IDR_EXTENSION_LIST_JS);
- source->SetDefaultResource(IDR_EXTENSIONS_HTML);
- source->DisableDenyXFrameOptions();
- return source;
-}
-
} // namespace
ExtensionsUI::ExtensionsUI(content::WebUI* web_ui) : WebUIController(web_ui) {
Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource* source = nullptr;
- bool is_md =
- base::FeatureList::IsEnabled(features::kMaterialDesignExtensions);
-
- if (is_md) {
- in_dev_mode_.Init(
- prefs::kExtensionsUIDeveloperMode, profile->GetPrefs(),
- base::Bind(&ExtensionsUI::OnDevModeChanged, base::Unretained(this)));
-
- source = CreateMdExtensionsSource(*in_dev_mode_);
+ in_dev_mode_.Init(
+ prefs::kExtensionsUIDeveloperMode, profile->GetPrefs(),
+ base::Bind(&ExtensionsUI::OnDevModeChanged, base::Unretained(this)));
- source->AddBoolean(
- "isGuest",
-#if defined(OS_CHROMEOS)
- user_manager::UserManager::Get()->IsLoggedInAsGuest() ||
- user_manager::UserManager::Get()->IsLoggedInAsPublicAccount());
-#else
- profile->IsOffTheRecord());
-#endif
-
- auto install_extension_handler =
- std::make_unique<InstallExtensionHandler>();
- InstallExtensionHandler* handler = install_extension_handler.get();
- web_ui->AddMessageHandler(std::move(install_extension_handler));
- handler->GetLocalizedValues(source);
- } else {
- source = CreateExtensionsHTMLSource();
-
- auto extension_settings_handler =
- std::make_unique<ExtensionSettingsHandler>();
- ExtensionSettingsHandler* settings_handler =
- extension_settings_handler.get();
- web_ui->AddMessageHandler(std::move(extension_settings_handler));
- settings_handler->GetLocalizedValues(source);
-
- auto extension_loader_handler =
- std::make_unique<ExtensionLoaderHandler>(profile);
- ExtensionLoaderHandler* loader_handler = extension_loader_handler.get();
- web_ui->AddMessageHandler(std::move(extension_loader_handler));
- loader_handler->GetLocalizedValues(source);
-
- auto install_extension_handler =
- std::make_unique<InstallExtensionHandler>();
- InstallExtensionHandler* install_handler = install_extension_handler.get();
- web_ui->AddMessageHandler(std::move(install_extension_handler));
- install_handler->GetLocalizedValues(source);
-
- web_ui->AddMessageHandler(std::make_unique<MetricsHandler>());
- }
+ source = CreateMdExtensionsSource(*in_dev_mode_);
#if defined(OS_CHROMEOS)
auto kiosk_app_handler = std::make_unique<chromeos::KioskAppsHandler>(
chromeos::OwnerSettingsServiceChromeOSFactory::GetForBrowserContext(
profile));
- chromeos::KioskAppsHandler* kiosk_handler = kiosk_app_handler.get();
web_ui->AddMessageHandler(std::move(kiosk_app_handler));
- kiosk_handler->GetLocalizedValues(source);
#endif
// Need to allow <object> elements so that the <extensionoptions> browser
@@ -475,7 +340,7 @@ ExtensionsUI::ExtensionsUI(content::WebUI* web_ui) : WebUIController(web_ui) {
content::WebUIDataSource::Add(profile, source);
// Handles its own lifetime.
- new ExtensionWebUiTimer(web_ui->GetWebContents(), is_md);
+ new ExtensionWebUiTimer(web_ui->GetWebContents());
}
ExtensionsUI::~ExtensionsUI() {}
@@ -487,6 +352,13 @@ base::RefCountedMemory* ExtensionsUI::GetFaviconResourceBytes(
return rb.LoadDataResourceBytesForScale(IDR_EXTENSIONS_FAVICON, scale_factor);
}
+void ExtensionsUI::RegisterProfilePrefs(
+ user_prefs::PrefRegistrySyncable* registry) {
+ registry->RegisterBooleanPref(
+ prefs::kExtensionsUIDeveloperMode, false,
+ user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
+}
+
// Normally volatile data does not belong in loadTimeData, but in this case
// prevents flickering on a very prominent surface (top of the landing page).
void ExtensionsUI::OnDevModeChanged() {
diff --git a/chromium/chrome/browser/ui/webui/extensions/extensions_ui.h b/chromium/chrome/browser/ui/webui/extensions/extensions_ui.h
index 8c2ff2a0a23..b16cc35454c 100644
--- a/chromium/chrome/browser/ui/webui/extensions/extensions_ui.h
+++ b/chromium/chrome/browser/ui/webui/extensions/extensions_ui.h
@@ -14,6 +14,10 @@ namespace base {
class RefCountedMemory;
}
+namespace user_prefs {
+class PrefRegistrySyncable;
+}
+
namespace extensions {
class ExtensionsUI : public content::WebUIController {
@@ -24,6 +28,8 @@ class ExtensionsUI : public content::WebUIController {
static base::RefCountedMemory* GetFaviconResourceBytes(
ui::ScaleFactor scale_factor);
+ static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
+
private:
// Called when developer mode is toggled.
void OnDevModeChanged();
diff --git a/chromium/chrome/browser/ui/webui/extensions/install_extension_handler.cc b/chromium/chrome/browser/ui/webui/extensions/install_extension_handler.cc
deleted file mode 100644
index 1782d196c68..00000000000
--- a/chromium/chrome/browser/ui/webui/extensions/install_extension_handler.cc
+++ /dev/null
@@ -1,142 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/extensions/install_extension_handler.h"
-
-#include <utility>
-
-#include "base/bind.h"
-#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/extensions/chrome_zipfile_installer.h"
-#include "chrome/browser/extensions/crx_installer.h"
-#include "chrome/browser/extensions/extension_install_prompt.h"
-#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/unpacked_installer.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/grit/generated_resources.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_ui.h"
-#include "content/public/browser/web_ui_data_source.h"
-#include "content/public/common/drop_data.h"
-#include "content/public/common/service_manager_connection.h"
-#include "extensions/browser/extension_system.h"
-#include "extensions/common/feature_switch.h"
-#include "net/base/filename_util.h"
-#include "ui/base/l10n/l10n_util.h"
-
-namespace extensions {
-
-InstallExtensionHandler::InstallExtensionHandler() {
-}
-
-InstallExtensionHandler::~InstallExtensionHandler() {
-}
-
-void InstallExtensionHandler::GetLocalizedValues(
- content::WebUIDataSource* source) {
- source->AddString(
- "extensionSettingsInstallDropTarget",
- l10n_util::GetStringUTF16(IDS_EXTENSIONS_INSTALL_DROP_TARGET));
-}
-
-void InstallExtensionHandler::RegisterMessages() {
- web_ui()->RegisterMessageCallback(
- "startDrag",
- base::BindRepeating(&InstallExtensionHandler::HandleStartDragMessage,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "stopDrag",
- base::BindRepeating(&InstallExtensionHandler::HandleStopDragMessage,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "installDroppedFile",
- base::BindRepeating(&InstallExtensionHandler::HandleInstallMessage,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "installDroppedDirectory",
- base::BindRepeating(
- &InstallExtensionHandler::HandleInstallDirectoryMessage,
- base::Unretained(this)));
-}
-
-void InstallExtensionHandler::HandleStartDragMessage(
- const base::ListValue* args) {
- content::DropData* drop_data =
- web_ui()->GetWebContents()->GetDropData();
- if (!drop_data) {
- DLOG(ERROR) << "No current drop data.";
- return;
- }
-
- if (drop_data->filenames.empty()) {
- DLOG(ERROR) << "Current drop data contains no files.";
- return;
- }
-
- const ui::FileInfo& file_info = drop_data->filenames.front();
-
- file_to_install_ = file_info.path;
- // Use the display name if provided, for checking file names
- // (.path is likely a random hash value in that case).
- file_display_name_ =
- file_info.display_name.empty() ? file_info.path : file_info.display_name;
-}
-
-void InstallExtensionHandler::HandleStopDragMessage(
- const base::ListValue* args) {
- file_to_install_.clear();
- file_display_name_.clear();
-}
-
-void InstallExtensionHandler::HandleInstallMessage(
- const base::ListValue* args) {
- if (file_to_install_.empty()) {
- LOG(ERROR) << "No file captured to install.";
- return;
- }
-
- Profile* profile = Profile::FromBrowserContext(
- web_ui()->GetWebContents()->GetBrowserContext());
-
- if (file_display_name_.MatchesExtension(FILE_PATH_LITERAL(".zip"))) {
- ZipFileInstaller::Create(
- content::ServiceManagerConnection::GetForProcess()->GetConnector(),
- MakeRegisterInExtensionServiceCallback(
- ExtensionSystem::Get(profile)->extension_service()))
- ->LoadFromZipFile(file_to_install_);
- } else {
- std::unique_ptr<ExtensionInstallPrompt> prompt(
- new ExtensionInstallPrompt(web_ui()->GetWebContents()));
- scoped_refptr<CrxInstaller> crx_installer(CrxInstaller::Create(
- ExtensionSystem::Get(profile)->extension_service(), std::move(prompt)));
- crx_installer->set_error_on_unsupported_requirements(true);
- crx_installer->set_off_store_install_allow_reason(
- CrxInstaller::OffStoreInstallAllowedFromSettingsPage);
- crx_installer->set_install_immediately(true);
-
- if (file_display_name_.MatchesExtension(FILE_PATH_LITERAL(".user.js"))) {
- crx_installer->InstallUserScript(
- file_to_install_, net::FilePathToFileURL(file_to_install_));
- } else if (file_display_name_.MatchesExtension(FILE_PATH_LITERAL(".crx"))) {
- crx_installer->InstallCrx(file_to_install_);
- } else {
- CHECK(false);
- }
- }
-
- file_to_install_.clear();
- file_display_name_.clear();
-}
-
-void InstallExtensionHandler::HandleInstallDirectoryMessage(
- const base::ListValue* args) {
- Profile* profile = Profile::FromBrowserContext(
- web_ui()->GetWebContents()->GetBrowserContext());
- UnpackedInstaller::Create(
- ExtensionSystem::Get(profile)->
- extension_service())->Load(file_to_install_);
-}
-
-} // namespace extensions
diff --git a/chromium/chrome/browser/ui/webui/extensions/install_extension_handler.h b/chromium/chrome/browser/ui/webui/extensions/install_extension_handler.h
deleted file mode 100644
index 265218b6ee0..00000000000
--- a/chromium/chrome/browser/ui/webui/extensions/install_extension_handler.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_EXTENSIONS_INSTALL_EXTENSION_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_INSTALL_EXTENSION_HANDLER_H_
-
-#include "base/files/file_path.h"
-#include "base/macros.h"
-#include "base/strings/string16.h"
-#include "base/values.h"
-#include "content/public/browser/web_ui_message_handler.h"
-
-namespace content {
-class WebUIDataSource;
-}
-
-namespace extensions {
-
-// Handles installing an extension when its file is dragged onto the page.
-class InstallExtensionHandler : public content::WebUIMessageHandler {
- public:
- InstallExtensionHandler();
- ~InstallExtensionHandler() override;
-
- void GetLocalizedValues(content::WebUIDataSource* source);
-
- // WebUIMessageHandler implementation.
- void RegisterMessages() override;
-
- private:
- // Handles a notification from the JavaScript that a drag has started. This is
- // needed so that we can capture the file being dragged. If we wait until
- // we receive a drop notification, the drop data in the browser process will
- // have already been destroyed.
- void HandleStartDragMessage(const base::ListValue* args);
-
- // Handles a notification from the JavaScript that a drag has stopped.
- void HandleStopDragMessage(const base::ListValue* args);
-
- // Handles a notification from the JavaScript to install the file currently
- // being dragged.
- //
- // IMPORTANT: We purposefully do not allow the JavaScript to specify the file
- // to be installed as a precaution against the extension management page
- // getting XSS'd.
- void HandleInstallMessage(const base::ListValue* args);
-
- // Handles a notification from the JavaScript to install the directory
- // currently being dragged.
- void HandleInstallDirectoryMessage(const base::ListValue* args);
-
- // The path to the file that will be installed when HandleInstallMessage() is
- // called.
- base::FilePath file_to_install_;
- base::FilePath file_display_name_;
-
- DISALLOW_COPY_AND_ASSIGN(InstallExtensionHandler);
-};
-
-} // namespace extensions
-
-#endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_INSTALL_EXTENSION_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/fileicon_source.cc b/chromium/chrome/browser/ui/webui/fileicon_source.cc
index c048f30a6c8..d78389fdce9 100644
--- a/chromium/chrome/browser/ui/webui/fileicon_source.cc
+++ b/chromium/chrome/browser/ui/webui/fileicon_source.cc
@@ -8,7 +8,6 @@
#include "base/callback.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted_memory.h"
-#include "base/message_loop/message_loop.h"
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
diff --git a/chromium/chrome/browser/ui/webui/fileicon_source_unittest.cc b/chromium/chrome/browser/ui/webui/fileicon_source_unittest.cc
index 5ae72c24b93..f88d9940b5e 100644
--- a/chromium/chrome/browser/ui/webui/fileicon_source_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/fileicon_source_unittest.cc
@@ -25,7 +25,7 @@ class TestFileIconSource : public FileIconSource {
IconLoader::IconSize icon_size,
const content::URLDataSource::GotDataCallback& callback));
- virtual ~TestFileIconSource() {}
+ ~TestFileIconSource() override {}
};
class FileIconSourceTest : public testing::Test {
diff --git a/chromium/chrome/browser/ui/webui/flags_ui.cc b/chromium/chrome/browser/ui/webui/flags_ui.cc
index a692030be7a..eca2c98b7fe 100644
--- a/chromium/chrome/browser/ui/webui/flags_ui.cc
+++ b/chromium/chrome/browser/ui/webui/flags_ui.cc
@@ -46,8 +46,8 @@
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/settings/owner_flags_storage.h"
+#include "components/account_id/account_id.h"
#include "components/pref_registry/pref_registry_syncable.h"
-#include "components/signin/core/account_id/account_id.h"
#include "components/user_manager/user_manager.h"
#endif
@@ -113,6 +113,9 @@ class FlagsDOMHandler : public WebUIMessageHandler {
// Callback for the "enableExperimentalFeature" message.
void HandleEnableExperimentalFeatureMessage(const base::ListValue* args);
+ // Callback for the "setOriginListFlag" message.
+ void HandleSetOriginListFlagMessage(const base::ListValue* args);
+
// Callback for the "restartBrowser" message. Restores all tabs on restart.
void HandleRestartBrowser(const base::ListValue* args);
@@ -138,6 +141,10 @@ void FlagsDOMHandler::RegisterMessages() {
&FlagsDOMHandler::HandleEnableExperimentalFeatureMessage,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
+ flags_ui::kSetOriginListFlag,
+ base::BindRepeating(&FlagsDOMHandler::HandleSetOriginListFlagMessage,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
flags_ui::kRestartBrowser,
base::BindRepeating(&FlagsDOMHandler::HandleRestartBrowser,
base::Unretained(this)));
@@ -210,6 +217,26 @@ void FlagsDOMHandler::HandleEnableExperimentalFeatureMessage(
enable_str == "true");
}
+void FlagsDOMHandler::HandleSetOriginListFlagMessage(
+ const base::ListValue* args) {
+ DCHECK(flags_storage_);
+ if (args->GetSize() != 2) {
+ NOTREACHED();
+ return;
+ }
+
+ std::string entry_internal_name;
+ std::string value_str;
+ if (!args->GetString(0, &entry_internal_name) ||
+ !args->GetString(1, &value_str) || entry_internal_name.empty()) {
+ NOTREACHED();
+ return;
+ }
+
+ about_flags::SetOriginListFlag(entry_internal_name, value_str,
+ flags_storage_.get());
+}
+
void FlagsDOMHandler::HandleRestartBrowser(const base::ListValue* args) {
DCHECK(flags_storage_);
#if defined(OS_CHROMEOS)
diff --git a/chromium/chrome/browser/ui/webui/inspect_ui.cc b/chromium/chrome/browser/ui/webui/inspect_ui.cc
index acad9c57e3a..42524631a82 100644
--- a/chromium/chrome/browser/ui/webui/inspect_ui.cc
+++ b/chromium/chrome/browser/ui/webui/inspect_ui.cc
@@ -470,7 +470,7 @@ void InspectUI::InspectDevices(Browser* browser) {
NavigateParams params(GetSingletonTabNavigateParams(
browser, GURL(chrome::kChromeUIInspectURL)));
params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE;
- ShowSingletonTabOverwritingNTP(browser, params);
+ ShowSingletonTabOverwritingNTP(browser, std::move(params));
}
void InspectUI::Observe(int type,
diff --git a/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui.cc b/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui.cc
index 572f66c8fae..5fbf984c00f 100644
--- a/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui.cc
+++ b/chromium/chrome/browser/ui/webui/interstitials/interstitial_ui.cc
@@ -114,6 +114,7 @@ class CaptivePortalBlockingPageWithNetInfo : public CaptivePortalBlockingPage {
login_url,
nullptr,
ssl_info,
+ net::ERR_CERT_COMMON_NAME_INVALID,
callback),
is_wifi_(is_wifi),
wifi_ssid_(wifi_ssid) {}
diff --git a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.cc b/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.cc
index b6867289c53..434ebf833c3 100644
--- a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.cc
@@ -45,8 +45,7 @@ content::WebUIDataSource* GetUnsupportedSource() {
} // namespace
InterventionsInternalsUI::InterventionsInternalsUI(content::WebUI* web_ui)
- : ui::MojoWebUIController<mojom::InterventionsInternalsPageHandler>(web_ui),
- previews_ui_service_(nullptr) {
+ : ui::MojoWebUIController(web_ui), previews_ui_service_(nullptr) {
// Set up the chrome://interventions-internals/ source.
Profile* profile = Profile::FromWebUI(web_ui);
@@ -61,11 +60,14 @@ InterventionsInternalsUI::InterventionsInternalsUI(content::WebUI* web_ui)
previews_ui_service_ = previews_service->previews_ui_service();
ui_nqe_service_ =
UINetworkQualityEstimatorServiceFactory::GetForProfile(profile);
+ AddHandlerToRegistry(base::BindRepeating(
+ &InterventionsInternalsUI::BindInterventionsInternalsPageHandler,
+ base::Unretained(this)));
}
InterventionsInternalsUI::~InterventionsInternalsUI() {}
-void InterventionsInternalsUI::BindUIHandler(
+void InterventionsInternalsUI::BindInterventionsInternalsPageHandler(
mojom::InterventionsInternalsPageHandlerRequest request) {
DCHECK(previews_ui_service_);
DCHECK(ui_nqe_service_);
diff --git a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.h b/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.h
index c3b79ebcc8a..28a0150d12e 100644
--- a/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.h
+++ b/chromium/chrome/browser/ui/webui/interventions_internals/interventions_internals_ui.h
@@ -17,16 +17,14 @@ class PreviewsUIService;
class UINetworkQualityEstimatorService;
// The WebUI for chrome://interventions-internals.
-class InterventionsInternalsUI
- : public ui::MojoWebUIController<mojom::InterventionsInternalsPageHandler> {
+class InterventionsInternalsUI : public ui::MojoWebUIController {
public:
explicit InterventionsInternalsUI(content::WebUI* web_ui);
~InterventionsInternalsUI() override;
private:
- // ui::MojoWebUIController overrides:
- void BindUIHandler(
- mojom::InterventionsInternalsPageHandlerRequest request) override;
+ void BindInterventionsInternalsPageHandler(
+ mojom::InterventionsInternalsPageHandlerRequest request);
// The PreviewsUIService associated with this UI.
previews::PreviewsUIService* previews_ui_service_;
diff --git a/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc
index 3d74af7b946..90ee886c403 100644
--- a/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc
@@ -12,7 +12,6 @@
#include "base/compiler_specific.h"
#include "base/location.h"
#include "base/macros.h"
-#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -21,6 +20,7 @@
#include "chrome/browser/media/router/providers/cast/dual_media_sink_service.h"
#include "chrome/browser/media/router/test/noop_dual_media_sink_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/ui/browser.h"
@@ -30,14 +30,12 @@
#include "chrome/common/url_constants.h"
#include "chrome/test/base/ui_test_utils.h"
#include "chrome/test/base/web_ui_browser_test.h"
-#include "components/signin/core/browser/profile_oauth2_token_service.h"
-#include "components/signin/core/browser/signin_manager.h"
-#include "components/signin/core/browser/signin_manager_base.h"
#include "google_apis/gaia/gaia_urls.h"
#include "net/http/http_status_code.h"
#include "net/url_request/test_url_fetcher_factory.h"
#include "net/url_request/url_request_status.h"
#include "net/url_request/url_request_test_util.h"
+#include "services/identity/public/cpp/identity_test_utils.h"
#if defined(OS_CHROMEOS)
#include "chrome/common/pref_names.h"
@@ -284,7 +282,6 @@ const char kURLRegisterComplete[] =
"http://1.2.3.4:8888/privet/register?action=complete&"
"user=user%40consumer.example.com";
-const char kSampleGaiaId[] = "12345";
const char kSampleUser[] = "user@consumer.example.com";
class TestMessageLoopCondition {
@@ -380,12 +377,6 @@ class LocalDiscoveryUITest : public WebUIBrowserTest {
&TestMessageLoopCondition::Signal))
.WillRepeatedly(Return());
- SigninManagerBase* signin_manager =
- SigninManagerFactory::GetForProfile(browser()->profile());
-
- DCHECK(signin_manager);
- signin_manager->SetAuthenticatedAccountInfo(kSampleGaiaId, kSampleUser);
-
fake_fetcher_factory().SetFakeResponse(
GURL(kURLInfo),
kResponseInfo,
@@ -435,12 +426,11 @@ class LocalDiscoveryUITest : public WebUIBrowserTest {
EXPECT_CALL(fake_url_fetcher_creator(), OnCreateFakeURLFetcher(
GaiaUrls::GetInstance()->oauth_user_info_url().spec()))
.Times(AnyNumber());
-
- ProfileOAuth2TokenService* token_service =
- ProfileOAuth2TokenServiceFactory::GetForProfile(browser()->profile());
-
- token_service->UpdateCredentials(
- signin_manager->GetAuthenticatedAccountId(), "MyFakeToken");
+ identity::MakePrimaryAccountAvailable(
+ SigninManagerFactory::GetForProfile(browser()->profile()),
+ ProfileOAuth2TokenServiceFactory::GetForProfile(browser()->profile()),
+ IdentityManagerFactory::GetForProfile(browser()->profile()),
+ kSampleUser);
AddLibrary(base::FilePath(FILE_PATH_LITERAL("local_discovery_ui_test.js")));
}
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 1d1f4db170d..8517d881ae0 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
@@ -9,7 +9,6 @@
#include <utility>
#include "base/bind.h"
-#include "base/message_loop/message_loop.h"
#include "base/metrics/user_metrics.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
diff --git a/chromium/chrome/browser/ui/webui/log_web_ui_url.cc b/chromium/chrome/browser/ui/webui/log_web_ui_url.cc
index d4d3ba99004..cb42bf243ca 100644
--- a/chromium/chrome/browser/ui/webui/log_web_ui_url.cc
+++ b/chromium/chrome/browser/ui/webui/log_web_ui_url.cc
@@ -26,11 +26,6 @@ bool LogWebUIUrl(const GURL& web_ui_url) {
bool should_log = web_ui_url.SchemeIs(content::kChromeUIScheme) ||
web_ui_url.SchemeIs(content::kChromeDevToolsScheme);
-#if BUILDFLAG(ENABLE_EXTENSIONS)
- if (web_ui_url.SchemeIs(extensions::kExtensionScheme))
- should_log = web_ui_url.host() == extension_misc::kBookmarkManagerId;
-#endif
-
if (should_log) {
uint32_t hash = base::Hash(web_ui_url.GetOrigin().spec());
base::UmaHistogramSparse(kWebUICreatedForUrl,
diff --git a/chromium/chrome/browser/ui/webui/log_web_ui_url_unittest.cc b/chromium/chrome/browser/ui/webui/log_web_ui_url_unittest.cc
index 8c9bd369d07..3af0dde4954 100644
--- a/chromium/chrome/browser/ui/webui/log_web_ui_url_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/log_web_ui_url_unittest.cc
@@ -17,12 +17,6 @@ TEST(LogWebUIUrlTest, ValidUrls) {
// Developer tools scheme.
EXPECT_TRUE(webui::LogWebUIUrl(GURL("chrome-devtools://devtools")));
-
-#if BUILDFLAG(ENABLE_EXTENSIONS)
- // Bookmarks Manager (the only currently allowed extension).
- EXPECT_TRUE(webui::LogWebUIUrl(GURL(
- "chrome-extension://eemcgdkfndhakfknompkggombfjjjeno")));
-#endif
}
TEST(LogWebUIUrlTest, InvalidUrls) {
@@ -31,7 +25,7 @@ TEST(LogWebUIUrlTest, InvalidUrls) {
EXPECT_FALSE(webui::LogWebUIUrl(GURL("https://facebook.com")));
EXPECT_FALSE(webui::LogWebUIUrl(GURL("ftp://ftp.mysite.com")));
- // Extensions other than the Bookmarks Manager should also be ignored.
+ // Extensions schemes should also be ignored.
EXPECT_FALSE(webui::LogWebUIUrl(GURL(
"chrome-extension://mfehgcgbbipciphmccgaenjidiccnmng")));
}
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 63fcf51691f..ca694958bb6 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
@@ -18,10 +18,12 @@
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
+#include "chrome/grit/theme_resources.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.h"
namespace {
@@ -36,6 +38,8 @@ void AddLocalizedString(content::WebUIDataSource* source,
content::WebUIDataSource* CreateMdBookmarksUIHTMLSource(Profile* profile) {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIBookmarksHost);
+ source->OverrideContentSecurityPolicyScriptSrc(
+ "script-src chrome://resources 'self';");
// Localized strings (alphabetical order).
AddLocalizedString(source, "addBookmarkTitle",
@@ -226,6 +230,8 @@ MdBookmarksUI::MdBookmarksUI(content::WebUI* web_ui) : WebUIController(web_ui) {
}
// static
-bool MdBookmarksUI::IsEnabled() {
- return base::FeatureList::IsEnabled(features::kMaterialDesignBookmarks);
+base::RefCountedMemory* MdBookmarksUI::GetFaviconResourceBytes(
+ ui::ScaleFactor scale_factor) {
+ return ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
+ IDR_BOOKMARKS_FAVICON, scale_factor);
}
diff --git a/chromium/chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.h b/chromium/chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.h
index b864ad6a5f8..5b45d17fb34 100644
--- a/chromium/chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.h
+++ b/chromium/chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.h
@@ -7,12 +7,18 @@
#include "base/macros.h"
#include "content/public/browser/web_ui_controller.h"
+#include "ui/base/resource/scale_factor.h"
+
+namespace base {
+class RefCountedMemory;
+}
class MdBookmarksUI : public content::WebUIController {
public:
explicit MdBookmarksUI(content::WebUI* web_ui);
- static bool IsEnabled();
+ static base::RefCountedMemory* GetFaviconResourceBytes(
+ ui::ScaleFactor scale_factor);
private:
DISALLOW_COPY_AND_ASSIGN(MdBookmarksUI);
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 63dbceb45fa..f7464ef1f8b 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
@@ -60,6 +60,7 @@ const char* GetDangerTypeString(download::DownloadDangerType danger_type) {
case download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS:
case download::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT:
case download::DOWNLOAD_DANGER_TYPE_USER_VALIDATED:
+ case download::DOWNLOAD_DANGER_TYPE_WHITELISTED_BY_POLICY:
case download::DOWNLOAD_DANGER_TYPE_MAX:
break;
}
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 990e68a08cf..b6e37fc3e92 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
@@ -11,7 +11,7 @@
#include "base/bind_helpers.h"
#include "base/i18n/rtl.h"
#include "base/logging.h"
-#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_loop_current.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
@@ -189,8 +189,7 @@ void MdDownloadsDOMHandler::HandleDrag(const base::ListValue* args) {
gfx::NativeView view = web_contents->GetNativeView();
{
// Enable nested tasks during DnD, while |DragDownload()| blocks.
- base::MessageLoop::ScopedNestableTaskAllower allow(
- base::MessageLoop::current());
+ base::MessageLoopCurrent::ScopedNestableTaskAllower allow;
DragDownloadItem(file, icon, view);
}
}
diff --git a/chromium/chrome/browser/ui/webui/md_downloads/md_downloads_ui.cc b/chromium/chrome/browser/ui/webui/md_downloads/md_downloads_ui.cc
index e3938ed4ed6..24b156b5a91 100644
--- a/chromium/chrome/browser/ui/webui/md_downloads/md_downloads_ui.cc
+++ b/chromium/chrome/browser/ui/webui/md_downloads/md_downloads_ui.cc
@@ -41,6 +41,8 @@ namespace {
content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIDownloadsHost);
+ source->OverrideContentSecurityPolicyScriptSrc(
+ "script-src chrome://resources 'self';");
source->AddLocalizedString("title", IDS_DOWNLOAD_TITLE);
source->AddLocalizedString("searchResultsFor", IDS_SEARCH_RESULTS);
diff --git a/chromium/chrome/browser/ui/webui/md_history_ui.cc b/chromium/chrome/browser/ui/webui/md_history_ui.cc
index d24d3ba8eac..3ea15760f4f 100644
--- a/chromium/chrome/browser/ui/webui/md_history_ui.cc
+++ b/chromium/chrome/browser/ui/webui/md_history_ui.cc
@@ -52,6 +52,8 @@ content::WebUIDataSource* CreateMdHistoryUIHTMLSource(Profile* profile,
bool use_test_title) {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIHistoryHost);
+ source->OverrideContentSecurityPolicyScriptSrc(
+ "script-src chrome://resources 'self';");
// Localized strings (alphabetical order).
source->AddLocalizedString("bookmarked", IDS_HISTORY_ENTRY_BOOKMARKED);
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 c021c705ff8..00d7e9860e0 100644
--- a/chromium/chrome/browser/ui/webui/media/media_engagement_ui.cc
+++ b/chromium/chrome/browser/ui/webui/media/media_engagement_ui.cc
@@ -6,19 +6,31 @@
#include <memory>
+#include "base/command_line.h"
+#include "base/feature_list.h"
#include "base/macros.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/media/media_engagement_score.h"
#include "chrome/browser/media/media_engagement_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
+#include "components/component_updater/component_updater_service.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_controller.h"
#include "content/public/browser/web_ui_data_source.h"
+#include "media/base/media_switches.h"
#include "mojo/public/cpp/bindings/binding.h"
namespace {
+namespace {
+
+// This is the component ID for the MEI Preload component.
+const char kPreloadComponentID[] = "aemomkdncapdnfajjbbcbdebjljbpmpj";
+
+} // namespace
+
// Implementation of media::mojom::MediaEngagementScoreDetailsProvider that
// retrieves engagement details from the MediaEngagementService.
class MediaEngagementScoreDetailsProviderImpl
@@ -48,10 +60,30 @@ class MediaEngagementScoreDetailsProviderImpl
std::move(callback).Run(media::mojom::MediaEngagementConfig::New(
MediaEngagementScore::GetScoreMinVisits(),
MediaEngagementScore::GetHighScoreLowerThreshold(),
- MediaEngagementScore::GetHighScoreUpperThreshold()));
+ MediaEngagementScore::GetHighScoreUpperThreshold(),
+ base::FeatureList::IsEnabled(media::kRecordMediaEngagementScores),
+ base::FeatureList::IsEnabled(
+ media::kMediaEngagementBypassAutoplayPolicies),
+ base::FeatureList::IsEnabled(media::kPreloadMediaEngagementData),
+ media::GetEffectiveAutoplayPolicy(
+ *base::CommandLine::ForCurrentProcess()),
+ GetPreloadVersion()));
}
private:
+ const std::string GetPreloadVersion() {
+ component_updater::ComponentUpdateService* cus =
+ g_browser_process->component_updater();
+ std::vector<component_updater::ComponentInfo> info = cus->GetComponents();
+
+ for (const auto& component : info) {
+ if (component.id == kPreloadComponentID)
+ return component.version.GetString();
+ }
+
+ return std::string();
+ }
+
Profile* profile_;
MediaEngagementService* service_;
@@ -64,8 +96,7 @@ class MediaEngagementScoreDetailsProviderImpl
} // namespace
MediaEngagementUI::MediaEngagementUI(content::WebUI* web_ui)
- : ui::MojoWebUIController<
- media::mojom::MediaEngagementScoreDetailsProvider>(web_ui) {
+ : ui::MojoWebUIController(web_ui) {
// Setup the data source behind chrome://media-engagement.
std::unique_ptr<content::WebUIDataSource> source(
content::WebUIDataSource::Create(chrome::kChromeUIMediaEngagementHost));
@@ -77,11 +108,14 @@ MediaEngagementUI::MediaEngagementUI(content::WebUI* web_ui)
source->SetDefaultResource(IDR_MEDIA_ENGAGEMENT_HTML);
source->UseGzip();
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source.release());
+ AddHandlerToRegistry(base::BindRepeating(
+ &MediaEngagementUI::BindMediaEngagementScoreDetailsProvider,
+ base::Unretained(this)));
}
MediaEngagementUI::~MediaEngagementUI() = default;
-void MediaEngagementUI::BindUIHandler(
+void MediaEngagementUI::BindMediaEngagementScoreDetailsProvider(
media::mojom::MediaEngagementScoreDetailsProviderRequest request) {
ui_handler_ = std::make_unique<MediaEngagementScoreDetailsProviderImpl>(
Profile::FromWebUI(web_ui()), std::move(request));
diff --git a/chromium/chrome/browser/ui/webui/media/media_engagement_ui.h b/chromium/chrome/browser/ui/webui/media/media_engagement_ui.h
index b8a46c43b14..a6d311226fb 100644
--- a/chromium/chrome/browser/ui/webui/media/media_engagement_ui.h
+++ b/chromium/chrome/browser/ui/webui/media/media_engagement_ui.h
@@ -10,17 +10,14 @@
#include "ui/webui/mojo_web_ui_controller.h"
// The UI for chrome://media-engagement/.
-class MediaEngagementUI
- : public ui::MojoWebUIController<
- media::mojom::MediaEngagementScoreDetailsProvider> {
+class MediaEngagementUI : public ui::MojoWebUIController {
public:
explicit MediaEngagementUI(content::WebUI* web_ui);
~MediaEngagementUI() override;
private:
- // ui::MojoWebUIController overrides:
- void BindUIHandler(media::mojom::MediaEngagementScoreDetailsProviderRequest
- request) override;
+ void BindMediaEngagementScoreDetailsProvider(
+ media::mojom::MediaEngagementScoreDetailsProviderRequest request);
std::unique_ptr<media::mojom::MediaEngagementScoreDetailsProvider>
ui_handler_;
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 43e045c5615..69df161dfeb 100644
--- a/chromium/chrome/browser/ui/webui/media/webrtc_logs_ui.cc
+++ b/chromium/chrome/browser/ui/webui/media/webrtc_logs_ui.cc
@@ -13,6 +13,7 @@
#include "base/i18n/time_formatting.h"
#include "base/macros.h"
#include "base/memory/ref_counted_memory.h"
+#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
@@ -76,7 +77,7 @@ content::WebUIDataSource* CreateWebRtcLogsUIHTMLSource() {
////////////////////////////////////////////////////////////////////////////////
// The handler for Javascript messages for the chrome://webrtc-logs/ page.
-class WebRtcLogsDOMHandler : public WebUIMessageHandler {
+class WebRtcLogsDOMHandler final : public WebUIMessageHandler {
public:
explicit WebRtcLogsDOMHandler(Profile* profile);
~WebRtcLogsDOMHandler() override;
@@ -85,8 +86,6 @@ class WebRtcLogsDOMHandler : public WebUIMessageHandler {
void RegisterMessages() override;
private:
- void OnUploadListAvailable();
-
// Asynchronously fetches the list of upload WebRTC logs. Called from JS.
void HandleRequestWebRtcLogs(const base::ListValue* args);
@@ -99,12 +98,8 @@ class WebRtcLogsDOMHandler : public WebUIMessageHandler {
// The directory where the logs are stored.
base::FilePath log_dir_;
- // Set when |upload_list_| has finished populating the list of logs.
- bool list_available_;
-
- // Set when the webpage wants to update the list (on the webpage) but
- // |upload_list_| hasn't finished populating the list of logs yet.
- bool js_request_pending_;
+ // Factory for creating weak references to instances of this class.
+ base::WeakPtrFactory<WebRtcLogsDOMHandler> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(WebRtcLogsDOMHandler);
};
@@ -113,8 +108,7 @@ WebRtcLogsDOMHandler::WebRtcLogsDOMHandler(Profile* profile)
: log_dir_(
webrtc_logging::LogList::GetWebRtcLogDirectoryForBrowserContextPath(
profile->GetPath())),
- list_available_(false),
- js_request_pending_(false) {
+ weak_ptr_factory_(this) {
upload_list_ = webrtc_logging::LogList::CreateWebRtcLogList(profile);
}
@@ -123,27 +117,19 @@ WebRtcLogsDOMHandler::~WebRtcLogsDOMHandler() {
}
void WebRtcLogsDOMHandler::RegisterMessages() {
- upload_list_->Load(base::BindOnce(
- &WebRtcLogsDOMHandler::OnUploadListAvailable, base::Unretained(this)));
+ upload_list_->Load(base::BindOnce(&WebRtcLogsDOMHandler::UpdateUI,
+ weak_ptr_factory_.GetWeakPtr()));
web_ui()->RegisterMessageCallback(
"requestWebRtcLogsList",
base::BindRepeating(&WebRtcLogsDOMHandler::HandleRequestWebRtcLogs,
- base::Unretained(this)));
+ weak_ptr_factory_.GetWeakPtr()));
}
void WebRtcLogsDOMHandler::HandleRequestWebRtcLogs(
const base::ListValue* args) {
- if (list_available_)
- UpdateUI();
- else
- js_request_pending_ = true;
-}
-
-void WebRtcLogsDOMHandler::OnUploadListAvailable() {
- list_available_ = true;
- if (js_request_pending_)
- UpdateUI();
+ upload_list_->Load(base::BindOnce(&WebRtcLogsDOMHandler::UpdateUI,
+ weak_ptr_factory_.GetWeakPtr()));
}
void WebRtcLogsDOMHandler::UpdateUI() {
diff --git a/chromium/chrome/browser/ui/webui/media_router/OWNERS b/chromium/chrome/browser/ui/webui/media_router/OWNERS
index c2e26607570..2d837dee815 100644
--- a/chromium/chrome/browser/ui/webui/media_router/OWNERS
+++ b/chromium/chrome/browser/ui/webui/media_router/OWNERS
@@ -1,5 +1,4 @@
amp@chromium.org
-apacible@chromium.org
imcheng@chromium.org
mfoltz@chromium.org
diff --git a/chromium/chrome/browser/ui/webui/media_router/media_router_dialog_controller_webui_impl_unittest.cc b/chromium/chrome/browser/ui/webui/media_router/media_router_dialog_controller_webui_impl_unittest.cc
index 29907ea8bf4..ea35a42225c 100644
--- a/chromium/chrome/browser/ui/webui/media_router/media_router_dialog_controller_webui_impl_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/media_router/media_router_dialog_controller_webui_impl_unittest.cc
@@ -17,6 +17,7 @@
#include "content/public/test/test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
+using blink::mojom::PresentationInfo;
using content::WebContents;
namespace media_router {
@@ -29,9 +30,9 @@ class MediaRouterDialogControllerWebUIImplTest : public MediaRouterWebUITest {
void OpenMediaRouterDialog();
MOCK_METHOD2(PresentationSuccessCallback,
- void(const content::PresentationInfo&, const MediaRoute&));
+ void(const blink::mojom::PresentationInfo&, const MediaRoute&));
MOCK_METHOD1(PresentationErrorCallback,
- void(const content::PresentationError& error));
+ void(const blink::mojom::PresentationError& error));
protected:
WebContents* initiator_ = nullptr;
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 e4e8a02ba28..95425a5989d 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
@@ -15,22 +15,19 @@
#include "base/strings/utf_string_conversions.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
-#include "chrome/browser/browser_process.h"
#include "chrome/browser/media/router/issue_manager.h"
#include "chrome/browser/media/router/issues_observer.h"
#include "chrome/browser/media/router/media_router.h"
#include "chrome/browser/media/router/media_router_factory.h"
-#include "chrome/browser/media/router/media_router_feature.h"
#include "chrome/browser/media/router/media_router_metrics.h"
-#include "chrome/browser/media/router/media_routes_observer.h"
#include "chrome/browser/media/router/media_sinks_observer.h"
-#include "chrome/browser/media/router/presentation/presentation_service_delegate_impl.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sessions/session_tab_helper.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/browser_tabstrip.h"
+#include "chrome/browser/ui/media_router/media_router_ui_helper.h"
#include "chrome/browser/ui/webui/media_router/media_router_localized_strings_provider.h"
#include "chrome/browser/ui/webui/media_router/media_router_resources_provider.h"
#include "chrome/browser/ui/webui/media_router/media_router_webui_message_handler.h"
@@ -40,7 +37,6 @@
#include "chrome/common/media_router/media_sink.h"
#include "chrome/common/media_router/media_source.h"
#include "chrome/common/media_router/media_source_helper.h"
-#include "chrome/common/media_router/route_request_result.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
@@ -56,7 +52,6 @@
#include "extensions/common/constants.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
-#include "third_party/icu/source/i18n/unicode/coll.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/web_dialogs/web_dialog_delegate.h"
#include "url/origin.h"
@@ -68,100 +63,6 @@
namespace media_router {
-namespace {
-
-// The amount of time to wait for a response when creating a new route.
-const int kCreateRouteTimeoutSeconds = 20;
-const int kCreateRouteTimeoutSecondsForTab = 60;
-const int kCreateRouteTimeoutSecondsForLocalFile = 60;
-const int kCreateRouteTimeoutSecondsForDesktop = 120;
-
-std::string GetHostFromURL(const GURL& gurl) {
- if (gurl.is_empty())
- return std::string();
- std::string host = gurl.host();
- if (base::StartsWith(host, "www.", base::CompareCase::INSENSITIVE_ASCII))
- host = host.substr(4);
- return host;
-}
-
-std::string TruncateHost(const std::string& host) {
- const std::string truncated =
- net::registry_controlled_domains::GetDomainAndRegistry(
- host, net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES);
- // The truncation will be empty in some scenarios (e.g. host is
- // simply an IP address). Fail gracefully.
- return truncated.empty() ? host : truncated;
-}
-
-base::TimeDelta GetRouteRequestTimeout(MediaCastMode cast_mode) {
- switch (cast_mode) {
- case PRESENTATION:
- return base::TimeDelta::FromSeconds(kCreateRouteTimeoutSeconds);
- case TAB_MIRROR:
- return base::TimeDelta::FromSeconds(kCreateRouteTimeoutSecondsForTab);
- case DESKTOP_MIRROR:
- return base::TimeDelta::FromSeconds(kCreateRouteTimeoutSecondsForDesktop);
- case LOCAL_FILE:
- return base::TimeDelta::FromSeconds(
- kCreateRouteTimeoutSecondsForLocalFile);
- default:
- NOTREACHED();
- return base::TimeDelta();
- }
-}
-
-// Returns the first source in |sources| that can be connected to by using the
-// "Cast" button in the dialog, or an empty source if there is none. This is
-// used by the Media Router to find such a matching route if it exists.
-MediaSource GetSourceForRouteObserver(const std::vector<MediaSource>& sources) {
- auto source_it =
- std::find_if(sources.begin(), sources.end(), IsCastPresentationUrl);
- return source_it != sources.end() ? *source_it : MediaSource("");
-}
-
-} // namespace
-
-// static
-std::string MediaRouterUI::GetExtensionName(
- const GURL& gurl,
- extensions::ExtensionRegistry* registry) {
- if (gurl.is_empty() || !registry)
- return std::string();
-
- const extensions::Extension* extension =
- registry->enabled_extensions().GetExtensionOrAppByURL(gurl);
-
- return extension ? extension->name() : std::string();
-}
-
-Browser* MediaRouterUI::GetBrowser() {
- return chrome::FindBrowserWithWebContents(initiator());
-}
-
-content::WebContents* MediaRouterUI::OpenTabWithUrl(const GURL url) {
- // Check if the current page is a new tab. If so open file in current page.
- // If not then open a new page.
- if (initiator_->GetVisibleURL() == chrome::kChromeUINewTabURL) {
- content::NavigationController::LoadURLParams load_params(url);
- load_params.transition_type = ui::PAGE_TRANSITION_GENERATED;
- initiator_->GetController().LoadURLWithParams(load_params);
- return initiator_;
- } else {
- return chrome::AddSelectedTabWithURL(GetBrowser(), url,
- ui::PAGE_TRANSITION_LINK);
- }
-}
-
-void MediaRouterUI::FileDialogFileSelected(
- const ui::SelectedFileInfo& file_info) {
- handler_->UserSelectedLocalMediaFile(file_info.display_name);
-}
-
-void MediaRouterUI::FileDialogSelectionFailed(const IssueInfo& issue) {
- AddIssue(issue);
-}
-
// This class calls to refresh the UI when the highest priority issue is
// updated.
class MediaRouterUI::UIIssuesObserver : public IssuesObserver {
@@ -291,49 +192,9 @@ class MediaRouterUI::WebContentsFullscreenOnLoadedObserver final
}
};
-MediaRouterUI::UIMediaRoutesObserver::UIMediaRoutesObserver(
- MediaRouter* router,
- const MediaSource::Id& source_id,
- const RoutesUpdatedCallback& callback)
- : MediaRoutesObserver(router, source_id), callback_(callback) {
- DCHECK(!callback_.is_null());
-}
-
-MediaRouterUI::UIMediaRoutesObserver::~UIMediaRoutesObserver() {}
-
-void MediaRouterUI::UIMediaRoutesObserver::OnRoutesUpdated(
- const std::vector<MediaRoute>& routes,
- const std::vector<MediaRoute::Id>& joinable_route_ids) {
- callback_.Run(routes, joinable_route_ids);
-}
-
-MediaRouterUI::UIMediaRouteControllerObserver::UIMediaRouteControllerObserver(
- MediaRouterUI* ui,
- scoped_refptr<MediaRouteController> controller)
- : MediaRouteController::Observer(std::move(controller)), ui_(ui) {
- if (controller_->current_media_status())
- OnMediaStatusUpdated(controller_->current_media_status().value());
-}
-
-MediaRouterUI::UIMediaRouteControllerObserver::
- ~UIMediaRouteControllerObserver() {}
-
-void MediaRouterUI::UIMediaRouteControllerObserver::OnMediaStatusUpdated(
- const MediaStatus& status) {
- ui_->UpdateMediaRouteStatus(status);
-}
-
-void MediaRouterUI::UIMediaRouteControllerObserver::OnControllerInvalidated() {
- ui_->OnRouteControllerInvalidated();
-}
-
MediaRouterUI::MediaRouterUI(content::WebUI* web_ui)
: ConstrainedWebDialogUI(web_ui),
ui_initialized_(false),
- current_route_request_id_(-1),
- route_request_counter_(0),
- initiator_(nullptr),
- router_(nullptr),
weak_factory_(this) {
auto handler = std::make_unique<MediaRouterWebUIMessageHandler>(this);
handler_ = handler.get();
@@ -352,230 +213,7 @@ MediaRouterUI::MediaRouterUI(content::WebUI* web_ui)
web_ui->AddMessageHandler(std::move(handler));
}
-MediaRouterUI::~MediaRouterUI() {
- if (query_result_manager_.get())
- query_result_manager_->RemoveObserver(this);
- if (presentation_service_delegate_.get())
- presentation_service_delegate_->RemoveDefaultPresentationRequestObserver(
- this);
- // If |start_presentation_context_| still exists, then it means presentation
- // route request was never attempted.
- if (start_presentation_context_) {
- bool presentation_sinks_available = std::any_of(
- sinks_.begin(), sinks_.end(), [](const MediaSinkWithCastModes& sink) {
- return base::ContainsKey(sink.cast_modes,
- MediaCastMode::PRESENTATION);
- });
- if (presentation_sinks_available) {
- start_presentation_context_->InvokeErrorCallback(
- content::PresentationError(
- content::PRESENTATION_ERROR_PRESENTATION_REQUEST_CANCELLED,
- "Dialog closed."));
- } else {
- start_presentation_context_->InvokeErrorCallback(
- content::PresentationError(
- content::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS,
- "No screens found."));
- }
- }
-}
-
-void MediaRouterUI::InitWithDefaultMediaSource(
- content::WebContents* initiator,
- PresentationServiceDelegateImpl* delegate) {
- DCHECK(initiator);
- DCHECK(!presentation_service_delegate_);
- DCHECK(!query_result_manager_.get());
-
- InitCommon(initiator);
- if (delegate) {
- presentation_service_delegate_ = delegate->GetWeakPtr();
- presentation_service_delegate_->AddDefaultPresentationRequestObserver(this);
- }
-
- if (delegate && delegate->HasDefaultPresentationRequest()) {
- OnDefaultPresentationChanged(delegate->GetDefaultPresentationRequest());
- } else {
- // Register for MediaRoute updates without a media source.
- routes_observer_ = std::make_unique<UIMediaRoutesObserver>(
- router_, MediaSource::Id(),
- base::BindRepeating(&MediaRouterUI::OnRoutesUpdated,
- base::Unretained(this)));
- }
-}
-
-void MediaRouterUI::InitWithStartPresentationContext(
- content::WebContents* initiator,
- PresentationServiceDelegateImpl* delegate,
- std::unique_ptr<StartPresentationContext> context) {
- DCHECK(initiator);
- DCHECK(delegate);
- DCHECK(context);
- DCHECK(!start_presentation_context_);
- DCHECK(!query_result_manager_);
-
- start_presentation_context_ = std::move(context);
- presentation_service_delegate_ = delegate->GetWeakPtr();
-
- InitCommon(initiator);
- OnDefaultPresentationChanged(
- start_presentation_context_->presentation_request());
-}
-
-void MediaRouterUI::InitCommon(content::WebContents* initiator) {
- DCHECK(initiator);
-
- TRACE_EVENT_NESTABLE_ASYNC_INSTANT1("media_router", "UI", initiator,
- "MediaRouterUI::InitCommon", this);
-
- router_ = GetMediaRouter();
- DCHECK(router_);
-
- // Presentation requests from content must show the origin requesting
- // presentation: crbug.com/704964
- if (start_presentation_context_)
- forced_cast_mode_ = MediaCastMode::PRESENTATION;
-
- router_->OnUserGesture();
-
- // Create |collator_| before |query_result_manager_| so that |collator_| is
- // already set up when we get a callback from |query_result_manager_|.
- UErrorCode error = U_ZERO_ERROR;
- const std::string& locale = g_browser_process->GetApplicationLocale();
- collator_.reset(
- icu::Collator::createInstance(icu::Locale(locale.c_str()), error));
- if (U_FAILURE(error)) {
- DLOG(ERROR) << "Failed to create collator for locale " << locale;
- collator_.reset();
- }
-
- query_result_manager_ = std::make_unique<QueryResultManager>(router_);
- query_result_manager_->AddObserver(this);
-
- // Use a placeholder URL as origin for mirroring.
- url::Origin origin =
- url::Origin::Create(GURL(chrome::kChromeUIMediaRouterURL));
-
- // Desktop mirror mode is always available.
- query_result_manager_->SetSourcesForCastMode(
- MediaCastMode::DESKTOP_MIRROR, {MediaSourceForDesktop()}, origin);
-
- // For now, file mirroring is always availible if enabled.
- if (CastLocalMediaEnabled()) {
- query_result_manager_->SetSourcesForCastMode(
- MediaCastMode::LOCAL_FILE, {MediaSourceForTab(0)}, origin);
- }
-
- initiator_ = initiator;
- SessionID tab_id = SessionTabHelper::IdForTab(initiator);
- if (tab_id.is_valid()) {
- MediaSource mirroring_source(MediaSourceForTab(tab_id.id()));
- query_result_manager_->SetSourcesForCastMode(MediaCastMode::TAB_MIRROR,
- {mirroring_source}, origin);
- }
-
- UpdateCastModes();
-
- // Get the current list of media routes, so that the WebUI will have routes
- // information at initialization.
- OnRoutesUpdated(router_->GetCurrentRoutes(), std::vector<MediaRoute::Id>());
-#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER)
- display_observer_ = WebContentsDisplayObserver::Create(
- initiator_,
- base::BindRepeating(&MediaRouterUI::UpdateSinks, base::Unretained(this)));
-#endif
-}
-
-void MediaRouterUI::InitForTest(
- MediaRouter* router,
- content::WebContents* initiator,
- MediaRouterWebUIMessageHandler* handler,
- std::unique_ptr<StartPresentationContext> context,
- std::unique_ptr<MediaRouterFileDialog> file_dialog) {
- handler_ = handler;
- start_presentation_context_ = std::move(context);
- InitForTest(std::move(file_dialog));
- InitCommon(initiator);
- if (start_presentation_context_) {
- OnDefaultPresentationChanged(
- start_presentation_context_->presentation_request());
- }
-
- UIInitialized();
-}
-
-void MediaRouterUI::InitForTest(
- std::unique_ptr<MediaRouterFileDialog> file_dialog) {
- media_router_file_dialog_ = std::move(file_dialog);
-}
-
-void MediaRouterUI::OnDefaultPresentationChanged(
- const content::PresentationRequest& presentation_request) {
- std::vector<MediaSource> sources =
- MediaSourcesForPresentationUrls(presentation_request.presentation_urls);
- presentation_request_ = presentation_request;
- query_result_manager_->SetSourcesForCastMode(
- MediaCastMode::PRESENTATION, sources,
- presentation_request_->frame_origin);
- // Register for MediaRoute updates. NOTE(mfoltz): If there are multiple
- // sources that can be connected to via the dialog, this will break. We will
- // need to observe multiple sources (keyed by sinks) in that case. As this is
- // Cast-specific for the forseeable future, it may be simpler to plumb a new
- // observer API for this case.
- const MediaSource source_for_route_observer =
- GetSourceForRouteObserver(sources);
- routes_observer_ = std::make_unique<UIMediaRoutesObserver>(
- router_, source_for_route_observer.id(),
- base::BindRepeating(&MediaRouterUI::OnRoutesUpdated,
- base::Unretained(this)));
-
- UpdateCastModes();
-}
-
-void MediaRouterUI::OnDefaultPresentationRemoved() {
- presentation_request_.reset();
- query_result_manager_->RemoveSourcesForCastMode(MediaCastMode::PRESENTATION);
-
- // This should not be set if the dialog was initiated with a default
- // presentation request from the top level frame. However, clear it just to
- // be safe.
- forced_cast_mode_ = base::nullopt;
-
- // Register for MediaRoute updates without a media source.
- routes_observer_ = std::make_unique<UIMediaRoutesObserver>(
- router_, MediaSource::Id(),
- base::BindRepeating(&MediaRouterUI::OnRoutesUpdated,
- base::Unretained(this)));
- UpdateCastModes();
-}
-
-void MediaRouterUI::UpdateCastModes() {
- // Gets updated cast modes from |query_result_manager_| and forwards it to UI.
- cast_modes_ = query_result_manager_->GetSupportedCastModes();
- if (ui_initialized_) {
- handler_->UpdateCastModes(cast_modes_, GetPresentationRequestSourceName(),
- forced_cast_mode());
- }
-}
-
-void MediaRouterUI::UpdateRoutesToCastModesMapping() {
- std::unordered_map<MediaSource::Id, MediaCastMode> available_source_map;
- for (const auto& cast_mode : cast_modes_) {
- for (const auto& source :
- query_result_manager_->GetSourcesForCastMode(cast_mode)) {
- available_source_map.insert(std::make_pair(source.id(), cast_mode));
- }
- }
-
- routes_and_cast_modes_.clear();
- for (const auto& route : routes_) {
- auto source_entry = available_source_map.find(route.media_source().id());
- if (source_entry != available_source_map.end()) {
- routes_and_cast_modes_.insert(
- std::make_pair(route.media_route_id(), source_entry->second));
- }
- }
-}
+MediaRouterUI::~MediaRouterUI() = default;
void MediaRouterUI::Close() {
ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate();
@@ -585,17 +223,13 @@ void MediaRouterUI::Close() {
}
}
-void MediaRouterUI::UIInitialized() {
- TRACE_EVENT_NESTABLE_ASYNC_END0("media_router", "UI", initiator_);
+void MediaRouterUI::OnUIInitialized() {
+ TRACE_EVENT_NESTABLE_ASYNC_END0("media_router", "UI", initiator());
+
ui_initialized_ = true;
- // Workaround for MediaRouterElementsBrowserTest, in which MediaRouterUI is
- // created without calling one of the |Init*()| methods.
// TODO(imcheng): We should be able to instantiate |issue_observer_| during
// InitCommon by storing an initial Issue in this class.
- if (!router_)
- router_ = GetMediaRouter();
-
// Register for Issue updates.
issues_observer_ =
std::make_unique<UIIssuesObserver>(GetIssueManager(), this);
@@ -604,184 +238,47 @@ void MediaRouterUI::UIInitialized() {
bool MediaRouterUI::CreateRoute(const MediaSink::Id& sink_id,
MediaCastMode cast_mode) {
- MediaSource::Id source_id;
- url::Origin origin;
- std::vector<MediaRouteResponseCallback> route_response_callbacks;
- base::TimeDelta timeout;
- bool incognito;
-
// Default the tab casting the content to the initiator, and change if
// necessary.
- content::WebContents* tab_contents = initiator_;
+ content::WebContents* tab_contents = initiator();
+ base::Optional<RouteParameters> params;
if (cast_mode == MediaCastMode::LOCAL_FILE) {
GURL url = media_router_file_dialog_->GetLastSelectedFileUrl();
tab_contents = OpenTabWithUrl(url);
-
- SessionID tab_id = SessionTabHelper::IdForTab(tab_contents);
- source_id = MediaSourceForTab(tab_id.id()).id();
-
- SetLocalFileRouteParameters(sink_id, &origin, url, tab_contents,
- &route_response_callbacks, &timeout,
- &incognito);
- } else if (!SetRouteParameters(sink_id, cast_mode, &source_id, &origin,
- &route_response_callbacks, &timeout,
- &incognito)) {
+ params = GetLocalFileRouteParameters(sink_id, url, tab_contents);
+ } else {
+ params = GetRouteParameters(sink_id, cast_mode);
+ }
+ if (!params) {
SendIssueForUnableToCast(cast_mode);
return false;
}
GetIssueManager()->ClearNonBlockingIssues();
- router_->CreateRoute(source_id, sink_id, origin, tab_contents,
- std::move(route_response_callbacks), timeout, incognito);
- return true;
-}
-
-bool MediaRouterUI::SetRouteParameters(
- const MediaSink::Id& sink_id,
- MediaCastMode cast_mode,
- MediaSource::Id* source_id,
- url::Origin* origin,
- std::vector<MediaRouteResponseCallback>* route_response_callbacks,
- base::TimeDelta* timeout,
- bool* incognito) {
- DCHECK(query_result_manager_.get());
- DCHECK(initiator_);
-
- // Note that there is a rarely-encountered bug, where the MediaCastMode to
- // MediaSource mapping could have been updated, between when the user clicked
- // on the UI to start a create route request, and when this function is
- // called. However, since the user does not have visibility into the
- // MediaSource, and that it occurs very rarely in practice, we leave it as-is
- // for now.
-
- std::unique_ptr<MediaSource> source =
- query_result_manager_->GetSourceForCastModeAndSink(cast_mode, sink_id);
-
- if (!source) {
- LOG(ERROR) << "No corresponding MediaSource for cast mode "
- << static_cast<int>(cast_mode) << " and sink " << sink_id;
- return false;
- }
- *source_id = source->id();
-
- bool for_presentation_source = cast_mode == MediaCastMode::PRESENTATION;
- if (for_presentation_source && !presentation_request_) {
- DLOG(ERROR) << "Requested to create a route for presentation, but "
- << "presentation request is missing.";
- return false;
- }
-
- current_route_request_id_ = ++route_request_counter_;
- *origin = for_presentation_source
- ? presentation_request_->frame_origin
- : url::Origin::Create(GURL(chrome::kChromeUIMediaRouterURL));
- DVLOG(1) << "DoCreateRoute: origin: " << *origin;
-
- // There are 3 cases. In cases (1) and (3) the MediaRouterUI will need to be
- // notified. In case (2) the dialog will be closed.
- // (1) Non-presentation route request (e.g., mirroring). No additional
- // notification necessary.
- // (2) Presentation route request for a PresentationRequest.start() call.
- // The StartPresentationContext will need to be answered with the route
- // response. (3) Browser-initiated presentation route request. If successful,
- // PresentationServiceDelegateImpl will have to be notified. Note that we
- // treat subsequent route requests from a Presentation API-initiated dialogs
- // as browser-initiated.
- if (!for_presentation_source || !start_presentation_context_) {
- route_response_callbacks->push_back(base::BindOnce(
- &MediaRouterUI::OnRouteResponseReceived, weak_factory_.GetWeakPtr(),
- current_route_request_id_, sink_id, cast_mode,
- base::UTF8ToUTF16(GetTruncatedPresentationRequestSourceName())));
- }
- if (for_presentation_source) {
- if (start_presentation_context_) {
- // |start_presentation_context_| will be nullptr after this call, as the
- // object will be transferred to the callback.
- route_response_callbacks->push_back(
- base::BindOnce(&StartPresentationContext::HandleRouteResponse,
- std::move(start_presentation_context_)));
- route_response_callbacks->push_back(base::BindOnce(
- &MediaRouterUI::HandleCreateSessionRequestRouteResponse,
- weak_factory_.GetWeakPtr()));
- } else if (presentation_service_delegate_) {
- route_response_callbacks->push_back(base::BindOnce(
- &PresentationServiceDelegateImpl::OnRouteResponse,
- presentation_service_delegate_, *presentation_request_));
- }
- }
-
- route_response_callbacks->push_back(
- base::BindOnce(&MediaRouterUI::MaybeReportCastingSource,
- weak_factory_.GetWeakPtr(), cast_mode));
-
- *timeout = GetRouteRequestTimeout(cast_mode);
- *incognito = Profile::FromWebUI(web_ui())->IsOffTheRecord();
-
- return true;
-}
-
-// TODO(crbug.com/751317): This function and the above function are messy, this
-// code would be much neater if the route params were combined in a single
-// struct, which will require mojo changes as well.
-bool MediaRouterUI::SetLocalFileRouteParameters(
- const MediaSink::Id& sink_id,
- url::Origin* origin,
- const GURL& file_url,
- content::WebContents* tab_contents,
- std::vector<MediaRouteResponseCallback>* route_response_callbacks,
- base::TimeDelta* timeout,
- bool* incognito) {
- // Use a placeholder URL as origin for local file casting, which is
- // essentially mirroring.
- *origin = url::Origin::Create(GURL(chrome::kChromeUIMediaRouterURL));
-
- route_response_callbacks->push_back(base::BindOnce(
- &MediaRouterUI::OnRouteResponseReceived, weak_factory_.GetWeakPtr(),
- current_route_request_id_, sink_id, MediaCastMode::LOCAL_FILE,
- base::UTF8ToUTF16(GetTruncatedPresentationRequestSourceName())));
-
- route_response_callbacks->push_back(
- base::BindOnce(&MediaRouterUI::MaybeReportCastingSource,
- weak_factory_.GetWeakPtr(), MediaCastMode::LOCAL_FILE));
-
- route_response_callbacks->push_back(base::BindOnce(
- &MediaRouterUI::MaybeReportFileInformation, weak_factory_.GetWeakPtr()));
-
- route_response_callbacks->push_back(
- base::BindOnce(&MediaRouterUI::FullScreenFirstVideoElement,
- weak_factory_.GetWeakPtr(), file_url, tab_contents));
-
- *timeout = GetRouteRequestTimeout(MediaCastMode::LOCAL_FILE);
- *incognito = Profile::FromWebUI(web_ui())->IsOffTheRecord();
-
+ GetMediaRouter()->CreateRoute(params->source_id, sink_id, params->origin,
+ tab_contents,
+ std::move(params->route_response_callbacks),
+ params->timeout, params->incognito);
return true;
}
bool MediaRouterUI::ConnectRoute(const MediaSink::Id& sink_id,
const MediaRoute::Id& route_id) {
- MediaSource::Id source_id;
- url::Origin origin;
- std::vector<MediaRouteResponseCallback> route_response_callbacks;
- base::TimeDelta timeout;
- bool incognito;
- if (!SetRouteParameters(sink_id, MediaCastMode::PRESENTATION, &source_id,
- &origin, &route_response_callbacks, &timeout,
- &incognito)) {
+ base::Optional<RouteParameters> params =
+ GetRouteParameters(sink_id, MediaCastMode::PRESENTATION);
+ if (!params) {
SendIssueForUnableToCast(MediaCastMode::PRESENTATION);
return false;
}
GetIssueManager()->ClearNonBlockingIssues();
- router_->ConnectRouteByRouteId(source_id, route_id, origin, initiator_,
- std::move(route_response_callbacks), timeout,
- incognito);
+ GetMediaRouter()->ConnectRouteByRouteId(
+ params->source_id, route_id, params->origin, initiator(),
+ std::move(params->route_response_callbacks), params->timeout,
+ params->incognito);
return true;
}
-void MediaRouterUI::CloseRoute(const MediaRoute::Id& route_id) {
- router_->TerminateRoute(route_id);
-}
-
void MediaRouterUI::AddIssue(const IssueInfo& issue) {
GetIssueManager()->AddIssue(issue);
}
@@ -804,12 +301,12 @@ void MediaRouterUI::SearchSinksAndCreateRoute(
const std::string& domain,
MediaCastMode cast_mode) {
std::unique_ptr<MediaSource> source =
- query_result_manager_->GetSourceForCastModeAndSink(cast_mode, sink_id);
+ query_result_manager()->GetSourceForCastModeAndSink(cast_mode, sink_id);
const std::string source_id = source ? source->id() : "";
// The CreateRoute() part of the function is accomplished in the callback
// OnSearchSinkResponseReceived().
- router_->SearchSinks(
+ GetMediaRouter()->SearchSinks(
sink_id, source_id, search_criteria, domain,
base::BindRepeating(&MediaRouterUI::OnSearchSinkResponseReceived,
weak_factory_.GetWeakPtr(), cast_mode));
@@ -848,19 +345,137 @@ void MediaRouterUI::RecordCastModeSelection(MediaCastMode cast_mode) {
}
}
-void MediaRouterUI::OnResultsUpdated(
- const std::vector<MediaSinkWithCastModes>& sinks) {
- sinks_ = sinks;
+std::string MediaRouterUI::GetPresentationRequestSourceName() const {
+ GURL gurl = GetFrameURL();
+ return gurl.SchemeIs(extensions::kExtensionScheme)
+ ? GetExtensionName(gurl, extensions::ExtensionRegistry::Get(
+ Profile::FromWebUI(web_ui())))
+ : GetHostFromURL(gurl);
+}
- const icu::Collator* collator_ptr = collator_.get();
- std::sort(sinks_.begin(), sinks_.end(),
- [collator_ptr](const MediaSinkWithCastModes& sink1,
- const MediaSinkWithCastModes& sink2) {
- return sink1.sink.CompareUsingCollator(sink2.sink, collator_ptr);
- });
+const std::set<MediaCastMode>& MediaRouterUI::cast_modes() const {
+ return cast_modes_;
+}
- if (ui_initialized_)
- UpdateSinks();
+void MediaRouterUI::SetUIInitializationTimer(const base::Time& start_time) {
+ DCHECK(!start_time.is_null());
+ start_time_ = start_time;
+}
+
+void MediaRouterUI::OnUIInitiallyLoaded() {
+ if (!start_time_.is_null()) {
+ MediaRouterMetrics::RecordMediaRouterDialogPaint(base::Time::Now() -
+ start_time_);
+ }
+}
+
+void MediaRouterUI::OnUIInitialDataReceived() {
+ if (!start_time_.is_null()) {
+ MediaRouterMetrics::RecordMediaRouterDialogLoaded(base::Time::Now() -
+ start_time_);
+ start_time_ = base::Time();
+ }
+}
+
+void MediaRouterUI::UpdateMaxDialogHeight(int height) {
+ if (ui_initialized_) {
+ handler_->UpdateMaxDialogHeight(height);
+ }
+}
+
+MediaRouteController* MediaRouterUI::GetMediaRouteController() const {
+ return route_controller_observer_
+ ? route_controller_observer_->controller().get()
+ : nullptr;
+}
+
+void MediaRouterUI::OnMediaControllerUIAvailable(
+ const MediaRoute::Id& route_id) {
+ scoped_refptr<MediaRouteController> controller =
+ GetMediaRouter()->GetRouteController(route_id);
+ if (!controller) {
+ DVLOG(1) << "Requested a route controller with an invalid route ID.";
+ return;
+ }
+ DVLOG_IF(1, route_controller_observer_)
+ << "Route controller observer unexpectedly exists.";
+ route_controller_observer_ =
+ std::make_unique<UIMediaRouteControllerObserver>(this, controller);
+}
+
+void MediaRouterUI::OnMediaControllerUIClosed() {
+ route_controller_observer_.reset();
+}
+
+void MediaRouterUI::InitForTest(
+ MediaRouter* router,
+ content::WebContents* initiator,
+ MediaRouterWebUIMessageHandler* handler,
+ std::unique_ptr<StartPresentationContext> context,
+ std::unique_ptr<MediaRouterFileDialog> file_dialog) {
+ handler_ = handler;
+ set_start_presentation_context_for_test(std::move(context));
+ InitForTest(std::move(file_dialog));
+ InitCommon(initiator);
+ if (start_presentation_context()) {
+ OnDefaultPresentationChanged(
+ start_presentation_context()->presentation_request());
+ }
+
+ OnUIInitialized();
+}
+
+void MediaRouterUI::InitForTest(
+ std::unique_ptr<MediaRouterFileDialog> file_dialog) {
+ media_router_file_dialog_ = std::move(file_dialog);
+}
+
+MediaRouterUI::UIMediaRouteControllerObserver::UIMediaRouteControllerObserver(
+ MediaRouterUI* ui,
+ scoped_refptr<MediaRouteController> controller)
+ : MediaRouteController::Observer(std::move(controller)), ui_(ui) {
+ if (controller_->current_media_status())
+ OnMediaStatusUpdated(controller_->current_media_status().value());
+}
+
+MediaRouterUI::UIMediaRouteControllerObserver::
+ ~UIMediaRouteControllerObserver() {}
+
+void MediaRouterUI::UIMediaRouteControllerObserver::OnMediaStatusUpdated(
+ const MediaStatus& status) {
+ ui_->UpdateMediaRouteStatus(status);
+}
+
+void MediaRouterUI::UIMediaRouteControllerObserver::OnControllerInvalidated() {
+ ui_->OnRouteControllerInvalidated();
+}
+
+Browser* MediaRouterUI::GetBrowser() {
+ CHECK(initiator());
+ return chrome::FindBrowserWithWebContents(initiator());
+}
+
+content::WebContents* MediaRouterUI::OpenTabWithUrl(const GURL url) {
+ // Check if the current page is a new tab. If so open file in current page.
+ // If not then open a new page.
+ if (initiator()->GetVisibleURL() == chrome::kChromeUINewTabURL) {
+ content::NavigationController::LoadURLParams load_params(url);
+ load_params.transition_type = ui::PAGE_TRANSITION_GENERATED;
+ initiator()->GetController().LoadURLWithParams(load_params);
+ return initiator();
+ } else {
+ return chrome::AddSelectedTabWithURL(GetBrowser(), url,
+ ui::PAGE_TRANSITION_LINK);
+ }
+}
+
+void MediaRouterUI::FileDialogFileSelected(
+ const ui::SelectedFileInfo& file_info) {
+ handler_->UserSelectedLocalMediaFile(file_info.display_name);
+}
+
+void MediaRouterUI::FileDialogSelectionFailed(const IssueInfo& issue) {
+ AddIssue(issue);
}
void MediaRouterUI::SetIssue(const Issue& issue) {
@@ -876,33 +491,21 @@ void MediaRouterUI::ClearIssue() {
void MediaRouterUI::OnRoutesUpdated(
const std::vector<MediaRoute>& routes,
const std::vector<MediaRoute::Id>& joinable_route_ids) {
- routes_.clear();
+ MediaRouterUIBase::OnRoutesUpdated(routes, joinable_route_ids);
joinable_route_ids_.clear();
for (const MediaRoute& route : routes) {
- if (route.for_display()) {
-#ifndef NDEBUG
- for (const MediaRoute& existing_route : routes_) {
- if (existing_route.media_sink_id() == route.media_sink_id()) {
- DVLOG(2) << "Received another route for display with the same sink"
- << " id as an existing route. " << route.media_route_id()
- << " has the same sink id as "
- << existing_route.media_sink_id() << ".";
- }
- }
-#endif
- if (base::ContainsValue(joinable_route_ids, route.media_route_id())) {
- joinable_route_ids_.push_back(route.media_route_id());
- }
-
- routes_.push_back(route);
+ if (route.for_display() &&
+ base::ContainsValue(joinable_route_ids, route.media_route_id())) {
+ joinable_route_ids_.push_back(route.media_route_id());
}
}
- UpdateRoutesToCastModesMapping();
- if (ui_initialized_)
- handler_->UpdateRoutes(routes_, joinable_route_ids_,
- routes_and_cast_modes_);
+ if (ui_initialized_) {
+ handler_->UpdateRoutes(MediaRouterUIBase::routes(), joinable_route_ids_,
+ routes_and_cast_modes());
+ }
+ UpdateRoutesToCastModesMapping();
}
void MediaRouterUI::OnRouteResponseReceived(
@@ -911,41 +514,14 @@ void MediaRouterUI::OnRouteResponseReceived(
MediaCastMode cast_mode,
const base::string16& presentation_request_source_name,
const RouteRequestResult& result) {
- DVLOG(1) << "OnRouteResponseReceived";
- // If we receive a new route that we aren't expecting, do nothing.
- if (route_request_id != current_route_request_id_)
- return;
-
- const MediaRoute* route = result.route();
- if (!route) {
- // The provider will handle sending an issue for a failed route request.
- DVLOG(1) << "MediaRouteResponse returned error: " << result.error();
- }
-
- handler_->OnCreateRouteResponseReceived(sink_id, route);
- current_route_request_id_ = -1;
-
+ MediaRouterUIBase::OnRouteResponseReceived(
+ route_request_id, sink_id, cast_mode, presentation_request_source_name,
+ result);
+ handler_->OnCreateRouteResponseReceived(sink_id, result.route());
if (result.result_code() == RouteRequestResult::TIMED_OUT)
SendIssueForRouteTimeout(cast_mode, presentation_request_source_name);
}
-void MediaRouterUI::MaybeReportCastingSource(MediaCastMode cast_mode,
- const RouteRequestResult& result) {
- if (result.result_code() == RouteRequestResult::OK)
- MediaRouterMetrics::RecordMediaRouterCastingSource(cast_mode);
-}
-
-// TODO(crbug.com/792547): Refactor these next two methods into a local media
-// casting specific location instead of here in the main ui.
-void MediaRouterUI::FullScreenFirstVideoElement(
- const GURL& file_url,
- content::WebContents* web_contents,
- const RouteRequestResult& result) {
- if (result.result_code() == RouteRequestResult::OK) {
- new WebContentsFullscreenOnLoadedObserver(file_url, web_contents);
- }
-}
-
void MediaRouterUI::MaybeReportFileInformation(
const RouteRequestResult& result) {
if (result.result_code() == RouteRequestResult::OK)
@@ -1007,131 +583,132 @@ void MediaRouterUI::SendIssueForUnableToCast(MediaCastMode cast_mode) {
IssueInfo::Severity::WARNING));
}
-GURL MediaRouterUI::GetFrameURL() const {
- return presentation_request_ ? presentation_request_->frame_origin.GetURL()
- : GURL();
+void MediaRouterUI::InitCommon(content::WebContents* initiator) {
+ MediaRouterUIBase::InitCommon(initiator);
+ UpdateCastModes();
+ // Presentation requests from content must show the origin requesting
+ // presentation: crbug.com/704964
+ if (start_presentation_context())
+ forced_cast_mode_ = MediaCastMode::PRESENTATION;
}
-std::vector<MediaSinkWithCastModes> MediaRouterUI::GetEnabledSinks() const {
-#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER)
- if (!display_observer_)
- return sinks_;
-
- // Filter out the wired display sink for the display that the dialog is on.
- // This is not the best place to do this because MRUI should not perform a
- // provider-specific behavior, but we currently do not have a way to
- // communicate dialog-specific information to/from the
- // WiredDisplayMediaRouteProvider.
- std::vector<MediaSinkWithCastModes> enabled_sinks;
- const std::string display_sink_id =
- WiredDisplayMediaRouteProvider::GetSinkIdForDisplay(
- display_observer_->GetCurrentDisplay());
- for (const MediaSinkWithCastModes& sink : sinks_) {
- if (sink.sink.id() != display_sink_id)
- enabled_sinks.push_back(sink);
- }
- return enabled_sinks;
-#else
- return sinks_;
-#endif
+void MediaRouterUI::OnDefaultPresentationChanged(
+ const content::PresentationRequest& presentation_request) {
+ MediaRouterUIBase::OnDefaultPresentationChanged(presentation_request);
+ UpdateCastModes();
}
-std::string MediaRouterUI::GetPresentationRequestSourceName() const {
- GURL gurl = GetFrameURL();
- return gurl.SchemeIs(extensions::kExtensionScheme)
- ? GetExtensionName(gurl, extensions::ExtensionRegistry::Get(
- Profile::FromWebUI(web_ui())))
- : GetHostFromURL(gurl);
-}
+void MediaRouterUI::OnDefaultPresentationRemoved() {
+ MediaRouterUIBase::OnDefaultPresentationRemoved();
-std::string MediaRouterUI::GetTruncatedPresentationRequestSourceName() const {
- GURL gurl = GetFrameURL();
- return gurl.SchemeIs(extensions::kExtensionScheme)
- ? GetExtensionName(gurl, extensions::ExtensionRegistry::Get(
- Profile::FromWebUI(web_ui())))
- : TruncateHost(GetHostFromURL(gurl));
+ // This should not be set if the dialog was initiated with a default
+ // presentation request from the top level frame. However, clear it just to
+ // be safe.
+ forced_cast_mode_ = base::nullopt;
+ UpdateCastModes();
}
-const std::set<MediaCastMode>& MediaRouterUI::cast_modes() const {
- return cast_modes_;
-}
+base::Optional<RouteParameters> MediaRouterUI::GetLocalFileRouteParameters(
+ const MediaSink::Id& sink_id,
+ const GURL& file_url,
+ content::WebContents* tab_contents) {
+ RouteParameters params;
+ SessionID::id_type tab_id = SessionTabHelper::IdForTab(tab_contents).id();
+ params.source_id = MediaSourceForTab(tab_id).id();
-void MediaRouterUI::SetUIInitializationTimer(const base::Time& start_time) {
- DCHECK(!start_time.is_null());
- start_time_ = start_time;
-}
+ // Use a placeholder URL as origin for local file casting, which is
+ // essentially mirroring.
+ params.origin = url::Origin::Create(GURL(chrome::kChromeUIMediaRouterURL));
-void MediaRouterUI::OnUIInitiallyLoaded() {
- if (!start_time_.is_null()) {
- MediaRouterMetrics::RecordMediaRouterDialogPaint(base::Time::Now() -
- start_time_);
- }
+ params.route_response_callbacks.push_back(base::BindOnce(
+ &MediaRouterUI::OnRouteResponseReceived, weak_factory_.GetWeakPtr(),
+ current_route_request_id(), sink_id, MediaCastMode::LOCAL_FILE,
+ base::UTF8ToUTF16(GetTruncatedPresentationRequestSourceName())));
+
+ params.route_response_callbacks.push_back(
+ base::BindOnce(&MediaRouterUIBase::MaybeReportCastingSource,
+ weak_factory_.GetWeakPtr(), MediaCastMode::LOCAL_FILE));
+
+ params.route_response_callbacks.push_back(base::BindOnce(
+ &MediaRouterUI::MaybeReportFileInformation, weak_factory_.GetWeakPtr()));
+
+ params.route_response_callbacks.push_back(
+ base::BindOnce(&MediaRouterUI::FullScreenFirstVideoElement,
+ weak_factory_.GetWeakPtr(), file_url, tab_contents));
+
+ params.timeout = GetRouteRequestTimeout(MediaCastMode::LOCAL_FILE);
+ CHECK(initiator());
+ params.incognito = initiator()->GetBrowserContext()->IsOffTheRecord();
+
+ return base::make_optional(std::move(params));
}
-void MediaRouterUI::OnUIInitialDataReceived() {
- if (!start_time_.is_null()) {
- MediaRouterMetrics::RecordMediaRouterDialogLoaded(base::Time::Now() -
- start_time_);
- start_time_ = base::Time();
+// TODO(crbug.com/792547): Refactor FullScreenFirstVideoElement() and
+// MaybeReportFileInformation() into a local media casting specific location
+// instead of here in the main ui.
+void MediaRouterUI::FullScreenFirstVideoElement(
+ const GURL& file_url,
+ content::WebContents* web_contents,
+ const RouteRequestResult& result) {
+ if (result.result_code() == RouteRequestResult::OK) {
+ new WebContentsFullscreenOnLoadedObserver(file_url, web_contents);
}
}
-void MediaRouterUI::UpdateMaxDialogHeight(int height) {
+void MediaRouterUI::UpdateCastModes() {
+ // Gets updated cast modes from |query_result_manager()| and forwards it to
+ // UI.
+ cast_modes_ = query_result_manager()->GetSupportedCastModes();
if (ui_initialized_) {
- handler_->UpdateMaxDialogHeight(height);
+ handler_->UpdateCastModes(cast_modes(), GetPresentationRequestSourceName(),
+ forced_cast_mode());
}
}
-MediaRouteController* MediaRouterUI::GetMediaRouteController() const {
- return route_controller_observer_
- ? route_controller_observer_->controller().get()
- : nullptr;
-}
+void MediaRouterUI::UpdateRoutesToCastModesMapping() {
+ std::unordered_map<MediaSource::Id, MediaCastMode> available_source_map;
+ for (const auto& cast_mode : cast_modes()) {
+ for (const auto& source : GetSourcesForCastMode(cast_mode))
+ available_source_map.insert(std::make_pair(source.id(), cast_mode));
+ }
-void MediaRouterUI::OnMediaControllerUIAvailable(
- const MediaRoute::Id& route_id) {
- scoped_refptr<MediaRouteController> controller =
- router_->GetRouteController(route_id);
- if (!controller) {
- DVLOG(1) << "Requested a route controller with an invalid route ID.";
- return;
+ routes_and_cast_modes_.clear();
+ for (const auto& route : routes()) {
+ auto source_entry = available_source_map.find(route.media_source().id());
+ if (source_entry != available_source_map.end()) {
+ routes_and_cast_modes_.insert(
+ std::make_pair(route.media_route_id(), source_entry->second));
+ }
}
- DVLOG_IF(1, route_controller_observer_)
- << "Route controller observer unexpectedly exists.";
- route_controller_observer_ =
- std::make_unique<UIMediaRouteControllerObserver>(this, controller);
}
-void MediaRouterUI::OnMediaControllerUIClosed() {
- route_controller_observer_.reset();
+std::string MediaRouterUI::GetSerializedInitiatorOrigin() const {
+ url::Origin origin =
+ initiator() ? url::Origin::Create(initiator()->GetLastCommittedURL())
+ : url::Origin();
+ return origin.Serialize();
}
void MediaRouterUI::OnRouteControllerInvalidated() {
route_controller_observer_.reset();
handler_->OnRouteControllerInvalidated();
}
-
void MediaRouterUI::UpdateMediaRouteStatus(const MediaStatus& status) {
handler_->UpdateMediaRouteStatus(status);
}
-std::string MediaRouterUI::GetSerializedInitiatorOrigin() const {
- url::Origin origin =
- initiator_ ? url::Origin::Create(initiator_->GetLastCommittedURL())
- : url::Origin();
- return origin.Serialize();
-}
-
IssueManager* MediaRouterUI::GetIssueManager() {
- return router_->GetIssueManager();
+ return GetMediaRouter()->GetIssueManager();
}
void MediaRouterUI::UpdateSinks() {
- handler_->UpdateSinks(GetEnabledSinks());
+ if (ui_initialized_)
+ handler_->UpdateSinks(GetEnabledSinks());
}
-MediaRouter* MediaRouterUI::GetMediaRouter() {
+MediaRouter* MediaRouterUI::GetMediaRouter() const {
return MediaRouterFactory::GetApiForBrowserContext(
web_ui()->GetWebContents()->GetBrowserContext());
}
+
} // namespace media_router
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 3f03ed7e7a6..5c75e2dc411 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
@@ -5,129 +5,53 @@
#ifndef CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_
#define CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_UI_H_
-#include <memory>
-#include <set>
-#include <string>
-#include <unordered_map>
-#include <utility>
-#include <vector>
-
-#include "base/gtest_prod_util.h"
#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
-#include "base/timer/timer.h"
-#include "build/build_config.h"
-#include "chrome/browser/media/router/media_router_dialog_controller.h"
+#include "base/strings/string16.h"
#include "chrome/browser/media/router/mojo/media_route_controller.h"
-#include "chrome/browser/media/router/presentation/presentation_service_delegate_impl.h"
#include "chrome/browser/ui/media_router/media_cast_mode.h"
#include "chrome/browser/ui/media_router/media_router_file_dialog.h"
-#include "chrome/browser/ui/media_router/media_sink_with_cast_modes.h"
-#include "chrome/browser/ui/media_router/query_result_manager.h"
+#include "chrome/browser/ui/media_router/media_router_ui_base.h"
#include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
-#include "chrome/common/media_router/issue.h"
-#include "chrome/common/media_router/media_source.h"
-#include "content/public/browser/web_ui_data_source.h"
-#include "third_party/icu/source/common/unicode/uversion.h"
-#include "ui/base/ui_features.h"
-#include "url/gurl.h"
-
-#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER)
-#include "chrome/browser/ui/webui/media_router/web_contents_display_observer.h"
-#endif
-
-namespace content {
-struct PresentationRequest;
-class WebContents;
-}
-
-namespace extensions {
-class ExtensionRegistry;
-}
+#include "chrome/common/media_router/media_route.h"
+#include "chrome/common/media_router/media_sink.h"
-namespace U_ICU_NAMESPACE {
-class Collator;
+namespace ui {
+struct SelectedFileInfo;
}
-class Browser;
-
namespace media_router {
+struct MediaStatus;
+class Issue;
class IssueManager;
class IssuesObserver;
-class MediaRoute;
-class MediaRouter;
-class MediaRoutesObserver;
class MediaRouterWebUIMessageHandler;
-class MediaSink;
class RouteRequestResult;
-// Implements the chrome://media-router user interface.
+// Functions as an intermediary between MediaRouter and WebUI Cast dialog.
class MediaRouterUI
- : public ConstrainedWebDialogUI,
- public QueryResultManager::Observer,
- public PresentationServiceDelegateImpl::
- DefaultPresentationRequestObserver,
+ : public MediaRouterUIBase,
+ public ConstrainedWebDialogUI,
public MediaRouterFileDialog::MediaRouterFileDialogDelegate {
public:
// |web_ui| owns this object and is used to initialize the base class.
explicit MediaRouterUI(content::WebUI* web_ui);
~MediaRouterUI() override;
- // Initializes internal state (e.g. starts listening for MediaSinks) for
- // targeting the default MediaSource (if any) of the initiator tab that owns
- // |initiator|: Reference to the WebContents that initiated the dialog.
- // Must not be null.
- // |delegate|, as well as mirroring sources of that tab.
- // The contents of the UI will change as the default MediaSource changes.
- // If there is a default MediaSource, then PRESENTATION MediaCastMode will be
- // added to |cast_modes_|.
- // Init* methods can only be called once.
- // |delegate|: PresentationServiceDelegateImpl of the initiator tab.
- // Must not be null.
- // TODO(imcheng): Replace use of impl with an intermediate abstract
- // interface.
- void InitWithDefaultMediaSource(content::WebContents* initiator,
- PresentationServiceDelegateImpl* delegate);
-
- // Initializes internal state targeting the presentation specified in
- // |context|. Also sets up mirroring sources based on |initiator|.
- // This is different from |InitWithDefaultMediaSource| in that it does not
- // listen for default media source changes, as the UI is fixed to the source
- // in |request|.
- // Init* methods can only be called once.
- // |initiator|: Reference to the WebContents that initiated the dialog.
- // Must not be null.
- // |delegate|: PresentationServiceDelegateImpl of the initiator tab.
- // Must not be null.
- // |context|: Context object for the PresentationRequest. This instance will
- // take
- // ownership of it. Must not be null.
- void InitWithStartPresentationContext(
- content::WebContents* initiator,
- PresentationServiceDelegateImpl* delegate,
- std::unique_ptr<StartPresentationContext> context);
-
// Closes the media router UI.
void Close();
// Notifies this instance that the UI has been initialized.
- virtual void UIInitialized();
+ virtual void OnUIInitialized();
- // Requests a route be created from the source mapped to
- // |cast_mode|, to the sink given by |sink_id|.
- // Returns true if a route request is successfully submitted.
- // |OnRouteResponseReceived()| will be invoked when the route request
- // completes.
- bool CreateRoute(const MediaSink::Id& sink_id, MediaCastMode cast_mode);
+ // MediaRouterUIBase:
+ bool CreateRoute(const MediaSink::Id& sink_id,
+ MediaCastMode cast_mode) override;
// Calls MediaRouter to join the given route.
bool ConnectRoute(const MediaSink::Id& sink_id,
const MediaRoute::Id& route_id);
- // Calls MediaRouter to close the given route.
- void CloseRoute(const MediaRoute::Id& route_id);
-
// Calls MediaRouter to add the given issue.
void AddIssue(const IssueInfo& issue);
@@ -153,16 +77,11 @@ class MediaRouterUI
// mode is MediaCastMode::DESKTOP_MIRROR.
virtual void RecordCastModeSelection(MediaCastMode cast_mode);
- // Returns a subset of |sinks_| that should be listed in the dialog.
- std::vector<MediaSinkWithCastModes> GetEnabledSinks() const;
-
// Returns the hostname of the PresentationRequest's parent frame URL.
- std::string GetPresentationRequestSourceName() const;
- std::string GetTruncatedPresentationRequestSourceName() const;
+ virtual std::string GetPresentationRequestSourceName() const;
bool HasPendingRouteRequest() const {
- return current_route_request_id_ != -1;
+ return current_route_request_id() != -1;
}
- const std::vector<MediaRoute>& routes() const { return routes_; }
const std::vector<MediaRoute::Id>& joinable_route_ids() const {
return joinable_route_ids_;
}
@@ -171,7 +90,6 @@ class MediaRouterUI
routes_and_cast_modes() const {
return routes_and_cast_modes_;
}
- const content::WebContents* initiator() const { return initiator_; }
const base::Optional<MediaCastMode>& forced_cast_mode() const {
return forced_cast_mode_;
}
@@ -203,13 +121,6 @@ class MediaRouterUI
void InitForTest(std::unique_ptr<MediaRouterFileDialog> file_dialog);
-#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER)
- void set_display_observer_for_test(
- std::unique_ptr<WebContentsDisplayObserver> display_observer) {
- display_observer_ = std::move(display_observer);
- }
-#endif
-
private:
friend class MediaRouterUITest;
@@ -228,7 +139,8 @@ class MediaRouterUI
GetExtensionNameEmptyWhenNotExtensionURL);
FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest,
RouteCreationTimeoutForPresentation);
- FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, RouteRequestFromIncognito);
+ FRIEND_TEST_ALL_PREFIXES(MediaRouterUIIncognitoTest,
+ RouteRequestFromIncognito);
FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, OpenAndCloseUIDetailsView);
FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, SendMediaCommands);
FRIEND_TEST_ALL_PREFIXES(MediaRouterUITest, SendMediaStatusUpdate);
@@ -239,28 +151,6 @@ class MediaRouterUI
class UIIssuesObserver;
class WebContentsFullscreenOnLoadedObserver;
- class UIMediaRoutesObserver : public MediaRoutesObserver {
- public:
- using RoutesUpdatedCallback =
- base::RepeatingCallback<void(const std::vector<MediaRoute>&,
- const std::vector<MediaRoute::Id>&)>;
- UIMediaRoutesObserver(MediaRouter* router,
- const MediaSource::Id& source_id,
- const RoutesUpdatedCallback& callback);
- ~UIMediaRoutesObserver() override;
-
- // MediaRoutesObserver
- void OnRoutesUpdated(
- const std::vector<MediaRoute>& routes,
- const std::vector<MediaRoute::Id>& joinable_route_ids) override;
-
- private:
- // Callback to the owning MediaRouterUI instance.
- RoutesUpdatedCallback callback_;
-
- DISALLOW_COPY_AND_ASSIGN(UIMediaRoutesObserver);
- };
-
class UIMediaRouteControllerObserver : public MediaRouteController::Observer {
public:
explicit UIMediaRouteControllerObserver(
@@ -268,7 +158,7 @@ class MediaRouterUI
scoped_refptr<MediaRouteController> controller);
~UIMediaRouteControllerObserver() override;
- // MediaRouteController::Observer
+ // MediaRouteController::Observer:
void OnMediaStatusUpdated(const MediaStatus& status) override;
void OnControllerInvalidated() override;
@@ -278,53 +168,39 @@ class MediaRouterUI
DISALLOW_COPY_AND_ASSIGN(UIMediaRouteControllerObserver);
};
- static std::string GetExtensionName(const GURL& url,
- extensions::ExtensionRegistry* registry);
-
// Retrieves the browser associated with this UI.
Browser* GetBrowser();
// Opens the URL in a tab, returns the tab it was opened in.
content::WebContents* OpenTabWithUrl(const GURL url);
- // Methods for MediaRouterFileDialogDelegate
+ // MediaRouterFileDialogDelegate:
void FileDialogFileSelected(const ui::SelectedFileInfo& file_info) override;
void FileDialogSelectionFailed(const IssueInfo& issue) override;
- // QueryResultManager::Observer
- void OnResultsUpdated(
- const std::vector<MediaSinkWithCastModes>& sinks) override;
-
// Called by |issues_observer_| when the top issue has changed.
// If the UI is already initialized, notifies |handler_| to update the UI.
// Ignored if the UI is not yet initialized.
void SetIssue(const Issue& issue);
void ClearIssue();
- // Called by |routes_observer_| when the set of active routes has changed.
- void OnRoutesUpdated(const std::vector<MediaRoute>& routes,
- const std::vector<MediaRoute::Id>& joinable_route_ids);
+ void OnRoutesUpdated(
+ const std::vector<MediaRoute>& routes,
+ const std::vector<MediaRoute::Id>& joinable_route_ids) override;
- // Callback passed to MediaRouter to receive response to route creation
- // requests.
void OnRouteResponseReceived(
int route_request_id,
const MediaSink::Id& sink_id,
MediaCastMode cast_mode,
const base::string16& presentation_request_source_name,
- const RouteRequestResult& result);
+ const RouteRequestResult& result) override;
- // Logs a UMA stat for the source that was cast if the result is successful.
- void MaybeReportCastingSource(MediaCastMode cast_mode,
- const RouteRequestResult& result);
// Sends a request to the file dialog to log UMA stats for the file that was
// cast if the result is successful.
void MaybeReportFileInformation(const RouteRequestResult& result);
- // Closes the dialog after receiving a route response when using
- // |start_presentation_context_|. This prevents the dialog from trying to use
- // the same presentation request again.
- void HandleCreateSessionRequestRouteResponse(const RouteRequestResult&);
+ void HandleCreateSessionRequestRouteResponse(
+ const RouteRequestResult&) override;
// Callback passed to MediaRouter to receive the sink ID of the sink found by
// SearchSinksAndCreateRoute().
@@ -339,35 +215,19 @@ class MediaRouterUI
// Creates and sends an issue if casting fails for any other reason.
void SendIssueForUnableToCast(MediaCastMode cast_mode);
- // Initializes the dialog with mirroring sources derived from |initiator|.
- void InitCommon(content::WebContents* initiator);
+ void InitCommon(content::WebContents* initiator) override;
- // PresentationServiceDelegateImpl::DefaultPresentationObserver
+ // PresentationServiceDelegateImpl::DefaultPresentationObserver:
void OnDefaultPresentationChanged(
const content::PresentationRequest& presentation_request) override;
void OnDefaultPresentationRemoved() override;
- // Populates common route-related parameters for CreateRoute(),
- // ConnectRoute(), and SearchSinksAndCreateRoute().
- bool SetRouteParameters(
- const MediaSink::Id& sink_id,
- MediaCastMode cast_mode,
- MediaSource::Id* source_id,
- url::Origin* origin,
- std::vector<MediaRouteResponseCallback>* route_response_callbacks,
- base::TimeDelta* timeout,
- bool* incognito);
-
// Populates route-related parameters for CreateRoute() when doing file
// casting.
- bool SetLocalFileRouteParameters(
+ base::Optional<RouteParameters> GetLocalFileRouteParameters(
const MediaSink::Id& sink_id,
- url::Origin* origin,
const GURL& file_url,
- content::WebContents* tab_contents,
- std::vector<MediaRouteResponseCallback>* route_response_callbacks,
- base::TimeDelta* timeout,
- bool* incognito);
+ content::WebContents* tab_contents);
void FullScreenFirstVideoElement(const GURL& file_url,
content::WebContents* web_contents,
@@ -381,10 +241,6 @@ class MediaRouterUI
// match the value of |routes_|.
void UpdateRoutesToCastModesMapping();
- // Returns the default PresentationRequest's frame URL if there is one.
- // Otherwise returns an empty GURL.
- GURL GetFrameURL() const;
-
// Returns the serialized origin for |initiator_|, or the serialization of an
// opaque origin ("null") if |initiator_| is not set.
std::string GetSerializedInitiatorOrigin() const;
@@ -400,65 +256,23 @@ class MediaRouterUI
// Returns the IssueManager associated with |router_|.
IssueManager* GetIssueManager();
- // Sends the current list of enabled sinks to |handler_|.
- void UpdateSinks();
+ void UpdateSinks() override;
- // Overridden by tests.
- virtual MediaRouter* GetMediaRouter();
+ MediaRouter* GetMediaRouter() const override;
// Owned by the |web_ui| passed in the ctor, and guaranteed to be deleted
// only after it has deleted |this|.
MediaRouterWebUIMessageHandler* handler_ = nullptr;
- // These are non-null while this instance is registered to receive
- // updates from them.
std::unique_ptr<IssuesObserver> issues_observer_;
- std::unique_ptr<MediaRoutesObserver> routes_observer_;
// Set to true by |handler_| when the UI has been initialized.
bool ui_initialized_;
- // Set to -1 if not tracking a pending route request.
- int current_route_request_id_;
-
- // Sequential counter for route requests. Used to update
- // |current_route_request_id_| when there is a new route request.
- int route_request_counter_;
-
- // Used for locale-aware sorting of sinks by name. Set during |InitCommon()|
- // using the current locale. Set to null
- std::unique_ptr<icu::Collator> collator_;
-
- std::vector<MediaSinkWithCastModes> sinks_;
- std::vector<MediaRoute> routes_;
std::vector<MediaRoute::Id> joinable_route_ids_;
CastModeSet cast_modes_;
std::unordered_map<MediaRoute::Id, MediaCastMode> routes_and_cast_modes_;
- std::unique_ptr<QueryResultManager> query_result_manager_;
-
- // If set, then the result of the next presentation route request will
- // be handled by this object.
- std::unique_ptr<StartPresentationContext> start_presentation_context_;
-
- // Set to the presentation request corresponding to the presentation cast
- // mode, if supported. Otherwise set to nullptr.
- base::Optional<content::PresentationRequest> presentation_request_;
-
- // It's possible for PresentationServiceDelegateImpl to be destroyed before
- // this class.
- // (e.g. if a tab with the UI open is closed, then the tab WebContents will
- // be destroyed first momentarily before the UI WebContents).
- // Holding a WeakPtr to PresentationServiceDelegateImpl is the cleanest way to
- // handle this.
- // TODO(imcheng): hold a weak ptr to an abstract type instead.
- base::WeakPtr<PresentationServiceDelegateImpl> presentation_service_delegate_;
-
- content::WebContents* initiator_;
-
- // Pointer to the MediaRouter for this instance's BrowserContext.
- MediaRouter* router_;
-
// The start time for UI initialization metrics timer. When a dialog has been
// been painted and initialized with initial data, this should be cleared.
base::Time start_time_;
@@ -474,13 +288,6 @@ class MediaRouterUI
// If set, a cast mode that is required to be shown first.
base::Optional<MediaCastMode> forced_cast_mode_;
-#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER)
- // Keeps track of which display the dialog WebContents is on.
- std::unique_ptr<WebContentsDisplayObserver> display_observer_;
-#endif
-
- // NOTE: Weak pointers must be invalidated before all other member variables.
- // Therefore |weak_factory_| must be placed at the end.
base::WeakPtrFactory<MediaRouterUI> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(MediaRouterUI);
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 b6a7d62f329..cc65de51976 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
@@ -15,6 +15,7 @@
#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/common/media_router/media_route.h"
#include "chrome/common/media_router/media_source_helper.h"
@@ -103,18 +104,18 @@ class PresentationRequestCallbacks {
PresentationRequestCallbacks() {}
explicit PresentationRequestCallbacks(
- const content::PresentationError& expected_error)
+ const blink::mojom::PresentationError& expected_error)
: expected_error_(expected_error) {}
- void Success(const content::PresentationInfo&, const MediaRoute&) {}
+ void Success(const blink::mojom::PresentationInfo&, const MediaRoute&) {}
- void Error(const content::PresentationError& error) {
+ void Error(const blink::mojom::PresentationError& error) {
EXPECT_EQ(expected_error_.error_type, error.error_type);
EXPECT_EQ(expected_error_.message, error.message);
}
private:
- content::PresentationError expected_error_;
+ blink::mojom::PresentationError expected_error_;
};
class TestMediaRouterUI : public MediaRouterUI {
@@ -123,9 +124,9 @@ class TestMediaRouterUI : public MediaRouterUI {
: MediaRouterUI(web_ui), router_(router) {}
~TestMediaRouterUI() override = default;
- MediaRouter* GetMediaRouter() override { return router_; }
-
private:
+ MediaRouter* GetMediaRouter() const override { return router_; }
+
MediaRouter* router_;
DISALLOW_COPY_AND_ASSIGN(TestMediaRouterUI);
};
@@ -172,8 +173,7 @@ class MediaRouterUITest : public ChromeRenderViewHostTestHarness {
void CreateMediaRouterUI(Profile* profile) {
SessionTabHelper::CreateForWebContents(web_contents());
- web_ui_contents_.reset(
- WebContents::Create(WebContents::CreateParams(profile)));
+ web_ui_contents_ = WebContents::Create(WebContents::CreateParams(profile));
web_ui_.set_web_contents(web_ui_contents_.get());
media_router_ui_ =
std::make_unique<TestMediaRouterUI>(&web_ui_, &mock_router_);
@@ -234,6 +234,14 @@ class MediaRouterUITest : public ChromeRenderViewHostTestHarness {
base::test::ScopedFeatureList scoped_feature_list_;
};
+class MediaRouterUIIncognitoTest : public MediaRouterUITest {
+ protected:
+ content::BrowserContext* GetBrowserContext() override {
+ return static_cast<Profile*>(MediaRouterUITest::GetBrowserContext())
+ ->GetOffTheRecordProfile();
+ }
+};
+
TEST_F(MediaRouterUITest, RouteCreationTimeoutForTab) {
CreateMediaRouterUI(profile());
std::vector<MediaRouteResponseCallback> callbacks;
@@ -337,8 +345,8 @@ TEST_F(MediaRouterUITest, RouteCreationParametersCantBeCreated) {
std::move(sink_callback).Run("foundSinkId");
}
-TEST_F(MediaRouterUITest, RouteRequestFromIncognito) {
- CreateMediaRouterUI(profile()->GetOffTheRecordProfile());
+TEST_F(MediaRouterUIIncognitoTest, RouteRequestFromIncognito) {
+ CreateMediaRouterUI(profile());
media_router_ui_->OnDefaultPresentationChanged(presentation_request_);
EXPECT_CALL(mock_router_,
@@ -371,7 +379,7 @@ TEST_F(MediaRouterUITest, SortedSinks) {
// Sorted order is 2, 3, 1.
media_router_ui_->OnResultsUpdated(unsorted_sinks);
- const auto& sorted_sinks = media_router_ui_->sinks_;
+ const auto& sorted_sinks = media_router_ui_->GetEnabledSinks();
EXPECT_EQ(sink_name2, sorted_sinks[0].sink.name());
EXPECT_EQ(sink_id3, sorted_sinks[1].sink.id());
EXPECT_EQ(sink_id1, sorted_sinks[2].sink.id());
@@ -400,7 +408,7 @@ TEST_F(MediaRouterUITest, SortSinksByIconType) {
// Sorted order is CAST, CAST_AUDIO_GROUP "A", CAST_AUDIO_GROUP "B",
// CAST_AUDIO, HANGOUT, GENERIC.
media_router_ui_->OnResultsUpdated(unsorted_sinks);
- const auto& sorted_sinks = media_router_ui_->sinks_;
+ const auto& sorted_sinks = media_router_ui_->GetEnabledSinks();
EXPECT_EQ(sink6.sink.id(), sorted_sinks[0].sink.id());
EXPECT_EQ(sink4.sink.id(), sorted_sinks[1].sink.id());
EXPECT_EQ(sink2.sink.id(), sorted_sinks[2].sink.id());
@@ -425,11 +433,11 @@ TEST_F(MediaRouterUITest, FilterNonDisplayRoutes) {
routes.push_back(display_route_2);
media_router_ui_->OnRoutesUpdated(routes, std::vector<MediaRoute::Id>());
- ASSERT_EQ(2u, media_router_ui_->routes_.size());
- EXPECT_TRUE(display_route_1.Equals(media_router_ui_->routes_[0]));
- EXPECT_TRUE(media_router_ui_->routes_[0].for_display());
- EXPECT_TRUE(display_route_2.Equals(media_router_ui_->routes_[1]));
- EXPECT_TRUE(media_router_ui_->routes_[1].for_display());
+ ASSERT_EQ(2u, media_router_ui_->routes().size());
+ EXPECT_TRUE(display_route_1.Equals(media_router_ui_->routes()[0]));
+ EXPECT_TRUE(media_router_ui_->routes()[0].for_display());
+ EXPECT_TRUE(display_route_2.Equals(media_router_ui_->routes()[1]));
+ EXPECT_TRUE(media_router_ui_->routes()[1].for_display());
}
TEST_F(MediaRouterUITest, FilterNonDisplayJoinableRoutes) {
@@ -453,11 +461,11 @@ TEST_F(MediaRouterUITest, FilterNonDisplayJoinableRoutes) {
joinable_route_ids.push_back("routeId3");
media_router_ui_->OnRoutesUpdated(routes, joinable_route_ids);
- ASSERT_EQ(2u, media_router_ui_->joinable_route_ids_.size());
+ ASSERT_EQ(2u, media_router_ui_->joinable_route_ids().size());
EXPECT_EQ(display_route_1.media_route_id(),
- media_router_ui_->joinable_route_ids_[0]);
+ media_router_ui_->joinable_route_ids()[0]);
EXPECT_EQ(display_route_2.media_route_id(),
- media_router_ui_->joinable_route_ids_[1]);
+ media_router_ui_->joinable_route_ids()[1]);
}
TEST_F(MediaRouterUITest, UIMediaRoutesObserverAssignsCurrentCastModes) {
@@ -557,42 +565,9 @@ TEST_F(MediaRouterUITest, UIMediaRoutesObserverSkipsUnavailableCastModes) {
observer.reset();
}
-TEST_F(MediaRouterUITest, GetExtensionNameExtensionPresent) {
- std::string id = "extensionid";
- GURL url = GURL("chrome-extension://" + id);
- std::unique_ptr<extensions::ExtensionRegistry> registry =
- std::make_unique<extensions::ExtensionRegistry>(nullptr);
- scoped_refptr<extensions::Extension> app =
- extensions::ExtensionBuilder(
- "test app name", extensions::ExtensionBuilder::Type::PLATFORM_APP)
- .SetID(id)
- .Build();
-
- ASSERT_TRUE(registry->AddEnabled(app));
- EXPECT_EQ("test app name",
- MediaRouterUI::GetExtensionName(url, registry.get()));
-}
-
-TEST_F(MediaRouterUITest, GetExtensionNameEmptyWhenNotInstalled) {
- std::string id = "extensionid";
- GURL url = GURL("chrome-extension://" + id);
- std::unique_ptr<extensions::ExtensionRegistry> registry =
- std::make_unique<extensions::ExtensionRegistry>(nullptr);
-
- EXPECT_EQ("", MediaRouterUI::GetExtensionName(url, registry.get()));
-}
-
-TEST_F(MediaRouterUITest, GetExtensionNameEmptyWhenNotExtensionURL) {
- GURL url = GURL("https://www.google.com");
- std::unique_ptr<extensions::ExtensionRegistry> registry =
- std::make_unique<extensions::ExtensionRegistry>(nullptr);
-
- EXPECT_EQ("", MediaRouterUI::GetExtensionName(url, registry.get()));
-}
-
TEST_F(MediaRouterUITest, NotFoundErrorOnCloseWithNoSinks) {
- content::PresentationError expected_error(
- content::PresentationErrorType::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS,
+ blink::mojom::PresentationError expected_error(
+ blink::mojom::PresentationErrorType::NO_AVAILABLE_SCREENS,
"No screens found.");
PresentationRequestCallbacks request_callbacks(expected_error);
start_presentation_context_ = std::make_unique<StartPresentationContext>(
@@ -608,8 +583,8 @@ TEST_F(MediaRouterUITest, NotFoundErrorOnCloseWithNoSinks) {
}
TEST_F(MediaRouterUITest, NotFoundErrorOnCloseWithNoCompatibleSinks) {
- content::PresentationError expected_error(
- content::PresentationErrorType::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS,
+ blink::mojom::PresentationError expected_error(
+ blink::mojom::PresentationErrorType::NO_AVAILABLE_SCREENS,
"No screens found.");
PresentationRequestCallbacks request_callbacks(expected_error);
start_presentation_context_ = std::make_unique<StartPresentationContext>(
@@ -638,9 +613,8 @@ TEST_F(MediaRouterUITest, NotFoundErrorOnCloseWithNoCompatibleSinks) {
}
TEST_F(MediaRouterUITest, AbortErrorOnClose) {
- content::PresentationError expected_error(
- content::PresentationErrorType::
- PRESENTATION_ERROR_PRESENTATION_REQUEST_CANCELLED,
+ blink::mojom::PresentationError expected_error(
+ blink::mojom::PresentationErrorType::PRESENTATION_REQUEST_CANCELLED,
"Dialog closed.");
PresentationRequestCallbacks request_callbacks(expected_error);
start_presentation_context_ = std::make_unique<StartPresentationContext>(
@@ -786,8 +760,8 @@ TEST_F(MediaRouterUITest, SendInitialMediaStatusUpdate) {
TEST_F(MediaRouterUITest, SetsForcedCastModeWithPresentationURLs) {
presentation_request_.presentation_urls.push_back(
GURL("https://google.com/presentation2"));
- content::PresentationError expected_error(
- content::PresentationErrorType::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS,
+ blink::mojom::PresentationError expected_error(
+ blink::mojom::PresentationErrorType::NO_AVAILABLE_SCREENS,
"No screens found.");
PresentationRequestCallbacks request_callbacks(expected_error);
start_presentation_context_ = std::make_unique<StartPresentationContext>(
@@ -798,8 +772,7 @@ TEST_F(MediaRouterUITest, SetsForcedCastModeWithPresentationURLs) {
base::Unretained(&request_callbacks)));
SessionTabHelper::CreateForWebContents(web_contents());
- web_ui_contents_.reset(
- WebContents::Create(WebContents::CreateParams(profile())));
+ web_ui_contents_ = WebContents::Create(WebContents::CreateParams(profile()));
web_ui_.set_web_contents(web_ui_contents_.get());
media_router_ui_ =
std::make_unique<TestMediaRouterUI>(&web_ui_, &mock_router_);
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 bcc329103d1..0a5bb0b2885 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
@@ -27,6 +27,7 @@
#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/account_tracker_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/web_ui.h"
#include "extensions/common/constants.h"
@@ -125,7 +126,7 @@ std::unique_ptr<base::DictionaryValue> SinksAndIdentityToValue(
// Convert default domains to user domain
if (domain == "default") {
domain = user_domain;
- if (domain == Profile::kNoHostedDomainFound) {
+ if (domain == AccountTrackerService::kNoHostedDomainFound) {
// Default domain will be empty for non-dasher accounts.
domain.clear();
}
@@ -555,7 +556,7 @@ void MediaRouterWebUIMessageHandler::OnRequestInitialData(
initial_data.SetBoolean("useTabMirroring", use_tab_mirroring);
web_ui()->CallJavascriptFunctionUnsafe(kSetInitialData, initial_data);
- media_router_ui_->UIInitialized();
+ media_router_ui_->OnUIInitialized();
}
void MediaRouterWebUIMessageHandler::OnCreateRoute(
@@ -698,7 +699,7 @@ void MediaRouterWebUIMessageHandler::OnCloseRoute(const base::ListValue* args) {
DVLOG(1) << "Unable to extract args.";
return;
}
- media_router_ui_->CloseRoute(route_id);
+ media_router_ui_->TerminateRoute(route_id);
UMA_HISTOGRAM_BOOLEAN("MediaRouter.Ui.Action.StopRoute", !is_local);
}
diff --git a/chromium/chrome/browser/ui/webui/media_router/media_router_webui_message_handler_unittest.cc b/chromium/chrome/browser/ui/webui/media_router/media_router_webui_message_handler_unittest.cc
index c5793056fc2..ec9102f0988 100644
--- a/chromium/chrome/browser/ui/webui/media_router/media_router_webui_message_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/media_router/media_router_webui_message_handler_unittest.cc
@@ -89,11 +89,12 @@ class MockMediaRouterUI : public MediaRouterUI {
public:
explicit MockMediaRouterUI(content::WebUI* web_ui)
: MediaRouterUI(web_ui) {}
- ~MockMediaRouterUI() {}
+ ~MockMediaRouterUI() override {}
- MOCK_METHOD0(UIInitialized, void());
+ MOCK_METHOD0(OnUIInitialized, void());
MOCK_CONST_METHOD0(UserSelectedTabMirroringForCurrentOrigin, bool());
MOCK_METHOD1(RecordCastModeSelection, void(MediaCastMode cast_mode));
+ MOCK_CONST_METHOD0(GetPresentationRequestSourceName, std::string());
MOCK_CONST_METHOD0(cast_modes, const std::set<MediaCastMode>&());
MOCK_METHOD1(OnMediaControllerUIAvailable,
void(const MediaRoute::Id& route_id));
@@ -555,6 +556,8 @@ TEST_F(MediaRouterWebUIMessageHandlerTest, RetrieveCastModeSelection) {
EXPECT_CALL(*mock_media_router_ui_, cast_modes())
.WillRepeatedly(ReturnRef(cast_modes));
+ EXPECT_CALL(*mock_media_router_ui_, GetPresentationRequestSourceName())
+ .WillRepeatedly(Return("source"));
EXPECT_CALL(*mock_media_router_ui_,
UserSelectedTabMirroringForCurrentOrigin())
.WillOnce(Return(true));
diff --git a/chromium/chrome/browser/ui/webui/memory_internals_ui.cc b/chromium/chrome/browser/ui/webui/memory_internals_ui.cc
index 324b4809393..2ab3d76daed 100644
--- a/chromium/chrome/browser/ui/webui/memory_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/memory_internals_ui.cc
@@ -25,6 +25,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
+#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_thread.h"
@@ -49,7 +50,11 @@ namespace {
// Returns the string to display at the top of the page for help.
std::string GetMessageString() {
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
- switch (ProfilingProcessHost::GetInstance()->GetMode()) {
+ Mode mode = Mode::kNone;
+ if (heap_profiling::Supervisor::GetInstance()->HasStarted()) {
+ mode = heap_profiling::Supervisor::GetInstance()->GetMode();
+ }
+ switch (mode) {
case Mode::kAll:
return std::string("Memory logging is enabled for all processes.");
@@ -212,7 +217,7 @@ void MemoryInternalsDOMHandler::HandleSaveDump(const base::ListValue* args) {
// TODO(bug 757115) Does it make sense to show the Android file picker here
// instead? Need to test what that looks like.
base::FilePath user_data_dir;
- PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
+ base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
base::FilePath output_path = user_data_dir.Append(default_file);
ProfilingProcessHost::GetInstance()->SaveTraceWithHeapDumpToFile(
std::move(output_path),
@@ -246,11 +251,21 @@ void MemoryInternalsDOMHandler::HandleReportProcess(
void MemoryInternalsDOMHandler::HandleStartProfiling(
const base::ListValue* args) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
if (!args->is_list() || args->GetList().size() != 1)
return;
- ProfilingProcessHost::GetInstance()->StartManualProfiling(
- args->GetList()[0].GetInt());
+ base::ProcessId pid = args->GetList()[0].GetInt();
+ heap_profiling::Supervisor* supervisor =
+ heap_profiling::Supervisor::GetInstance();
+ if (supervisor->HasStarted()) {
+ supervisor->StartManualProfiling(pid);
+ } else {
+ supervisor->Start(
+ content::ServiceManagerConnection::GetForProcess(),
+ base::BindOnce(&heap_profiling::Supervisor::StartManualProfiling,
+ base::Unretained(supervisor), pid));
+ }
}
void MemoryInternalsDOMHandler::GetChildProcessesOnIOThread(
@@ -278,7 +293,20 @@ void MemoryInternalsDOMHandler::GetChildProcessesOnIOThread(
void MemoryInternalsDOMHandler::GetProfiledPids(
std::vector<base::Value> children) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- ProfilingProcessHost::GetInstance()->GetProfiledPids(
+ heap_profiling::Supervisor* supervisor =
+ heap_profiling::Supervisor::GetInstance();
+
+ // The supervisor hasn't started, so return an empty list.
+ if (!supervisor->HasStarted()) {
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI, FROM_HERE,
+ base::BindOnce(&MemoryInternalsDOMHandler::ReturnProcessListOnUIThread,
+ weak_factory_.GetWeakPtr(), std::move(children),
+ std::vector<base::ProcessId>()));
+ return;
+ }
+
+ supervisor->GetProfiledPids(
base::BindOnce(&MemoryInternalsDOMHandler::ReturnProcessListOnUIThread,
weak_factory_.GetWeakPtr(), std::move(children)));
}
@@ -298,12 +326,13 @@ void MemoryInternalsDOMHandler::ReturnProcessListOnUIThread(
// Append renderer processes.
auto iter = content::RenderProcessHost::AllHostsIterator();
while (!iter.IsAtEnd()) {
- base::ProcessHandle renderer_handle = iter.GetCurrentValue()->GetHandle();
- base::ProcessId renderer_pid = base::GetProcId(renderer_handle);
- if (renderer_pid != 0) {
- // TODO(brettw) make a better description of the process, maybe see
- // what TaskManager does to get the page title.
- process_list.push_back(MakeProcessInfo(renderer_pid, "Renderer"));
+ if (iter.GetCurrentValue()->GetProcess().IsValid()) {
+ base::ProcessId renderer_pid = iter.GetCurrentValue()->GetProcess().Pid();
+ if (renderer_pid != 0) {
+ // TODO(brettw) make a better description of the process, maybe see
+ // what TaskManager does to get the page title.
+ process_list.push_back(MakeProcessInfo(renderer_pid, "Renderer"));
+ }
}
iter.Advance();
}
diff --git a/chromium/chrome/browser/ui/webui/nacl_ui.cc b/chromium/chrome/browser/ui/webui/nacl_ui.cc
index 153107f052d..2a5b2237eb4 100644
--- a/chromium/chrome/browser/ui/webui/nacl_ui.cc
+++ b/chromium/chrome/browser/ui/webui/nacl_ui.cc
@@ -259,7 +259,8 @@ void NaClDomHandler::AddPnaclInfo(base::ListValue* list) {
// Obtain the version of the PNaCl translator.
base::FilePath pnacl_path;
- bool got_path = PathService::Get(chrome::DIR_PNACL_COMPONENT, &pnacl_path);
+ bool got_path =
+ base::PathService::Get(chrome::DIR_PNACL_COMPONENT, &pnacl_path);
if (!got_path || pnacl_path.empty() || !pnacl_path_exists_) {
AddPair(list,
ASCIIToUTF16("PNaCl translator"),
@@ -344,7 +345,8 @@ void CheckVersion(const base::FilePath& pnacl_path, std::string* version) {
bool CheckPathAndVersion(std::string* version) {
base::FilePath pnacl_path;
- bool got_path = PathService::Get(chrome::DIR_PNACL_COMPONENT, &pnacl_path);
+ bool got_path =
+ base::PathService::Get(chrome::DIR_PNACL_COMPONENT, &pnacl_path);
if (got_path && !pnacl_path.empty() && base::PathExists(pnacl_path)) {
CheckVersion(pnacl_path, version);
return true;
diff --git a/chromium/chrome/browser/ui/webui/net_export_ui.cc b/chromium/chrome/browser/ui/webui/net_export_ui.cc
index 24a70cf5093..0aac4e4a1bc 100644
--- a/chromium/chrome/browser/ui/webui/net_export_ui.cc
+++ b/chromium/chrome/browser/ui/webui/net_export_ui.cc
@@ -137,10 +137,6 @@ class NetExportMessageHandler
// NetLog file.
void ShowSelectFileDialog(const base::FilePath& default_path);
- // Returns a list of context getters used to retrieve ongoing events when
- // logging starts so that net log entries can be added for those events.
- URLRequestContextGetterList GetURLRequestContexts() const;
-
// Cache of g_browser_process->net_log()->net_export_file_writer(). This
// is owned by ChromeNetLog which is owned by BrowserProcessImpl.
net_log::NetExportFileWriter* file_writer_;
@@ -154,7 +150,7 @@ class NetExportMessageHandler
// the save dialog. Their values are only valid while the save dialog is open
// on the desktop UI.
net::NetLogCaptureMode capture_mode_;
- size_t max_log_file_size_;
+ uint64_t max_log_file_size_;
scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
@@ -167,8 +163,7 @@ NetExportMessageHandler::NetExportMessageHandler()
: file_writer_(g_browser_process->net_log()->net_export_file_writer()),
state_observer_manager_(this),
weak_ptr_factory_(this) {
- file_writer_->Initialize(
- BrowserThread::GetTaskRunnerForThread(BrowserThread::IO));
+ file_writer_->Initialize();
}
NetExportMessageHandler::~NetExportMessageHandler() {
@@ -177,7 +172,7 @@ NetExportMessageHandler::~NetExportMessageHandler() {
if (select_file_dialog_)
select_file_dialog_->ListenerDestroyed();
- file_writer_->StopNetLog(nullptr, nullptr);
+ file_writer_->StopNetLog(nullptr);
}
void NetExportMessageHandler::RegisterMessages() {
@@ -270,8 +265,7 @@ void NetExportMessageHandler::OnStopNetLog(const base::ListValue* list) {
chrome_browser_net::GetWindowsServiceProviders());
#endif
- file_writer_->StopNetLog(std::move(ui_thread_polled_data),
- Profile::FromWebUI(web_ui())->GetRequestContext());
+ file_writer_->StopNetLog(std::move(ui_thread_polled_data));
}
void NetExportMessageHandler::OnSendNetLog(const base::ListValue* list) {
@@ -334,7 +328,10 @@ void NetExportMessageHandler::StartNetLog(const base::FilePath& path) {
file_writer_->StartNetLog(
path, capture_mode_, max_log_file_size_,
base::CommandLine::ForCurrentProcess()->GetCommandLineString(),
- chrome::GetChannelName(), GetURLRequestContexts());
+ chrome::GetChannelName(),
+ content::BrowserContext::GetDefaultStoragePartition(
+ Profile::FromWebUI(web_ui()))
+ ->GetNetworkContext());
}
void NetExportMessageHandler::ShowFileInShell(const base::FilePath& path) {
@@ -384,24 +381,6 @@ void NetExportMessageHandler::ShowSelectFileDialog(
&file_type_info, 0, base::FilePath::StringType(), owning_window, nullptr);
}
-NetExportMessageHandler::URLRequestContextGetterList
-NetExportMessageHandler::GetURLRequestContexts() const {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
-
- URLRequestContextGetterList context_getters;
-
- Profile* profile = Profile::FromWebUI(web_ui());
-
- context_getters.push_back(profile->GetRequestContext());
- context_getters.push_back(
- content::BrowserContext::GetDefaultStoragePartition(profile)
- ->GetMediaURLRequestContext());
- context_getters.push_back(
- g_browser_process->io_thread()->system_url_request_context_getter());
-
- return context_getters;
-}
-
} // namespace
NetExportUI::NetExportUI(content::WebUI* web_ui) : WebUIController(web_ui) {
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 9a9192ba671..12c2eb2e127 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
@@ -21,7 +21,6 @@
#include "base/files/file_util.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "base/message_loop/message_loop.h"
#include "base/sequenced_task_runner_helpers.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
@@ -65,7 +64,6 @@
#include "net/http/http_cache.h"
#include "net/http/http_network_layer.h"
#include "net/http/http_network_session.h"
-#include "net/http/http_server_properties.h"
#include "net/http/http_stream_factory.h"
#include "net/http/transport_security_state.h"
#include "net/log/net_log.h"
diff --git a/chromium/chrome/browser/ui/webui/omnibox/OWNERS b/chromium/chrome/browser/ui/webui/omnibox/OWNERS
new file mode 100644
index 00000000000..08850f42120
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/omnibox/OWNERS
@@ -0,0 +1,2 @@
+per-file *.mojom=set noparent
+per-file *.mojom=file://ipc/SECURITY_OWNERS
diff --git a/chromium/chrome/browser/ui/webui/omnibox/omnibox.mojom b/chromium/chrome/browser/ui/webui/omnibox/omnibox.mojom
index a7ccc4c32f1..0506e5324df 100644
--- a/chromium/chrome/browser/ui/webui/omnibox/omnibox.mojom
+++ b/chromium/chrome/browser/ui/webui/omnibox/omnibox.mojom
@@ -25,6 +25,7 @@ struct AutocompleteMatch {
int32 transition;
bool allowed_to_be_default_match;
string type;
+ bool has_tab_match;
string? associated_keyword;
string keyword;
bool starred;
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 089208eeacd..f56b9c74919 100644
--- a/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc
+++ b/chromium/chrome/browser/ui/webui/omnibox/omnibox_page_handler.cc
@@ -81,6 +81,7 @@ struct TypeConverter<mojom::AutocompleteMatchPtr, AutocompleteMatch> {
result->transition = input.transition;
result->allowed_to_be_default_match = input.allowed_to_be_default_match;
result->type = AutocompleteMatchType::ToString(input.type);
+ result->has_tab_match = input.has_tab_match;
if (input.associated_keyword.get() != NULL) {
result->associated_keyword =
base::UTF16ToUTF8(input.associated_keyword->keyword);
diff --git a/chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.cc b/chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.cc
index d170f64210b..217f35bbd06 100644
--- a/chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.cc
+++ b/chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.cc
@@ -14,8 +14,7 @@
#include "content/public/browser/web_ui_controller.h"
#include "content/public/browser/web_ui_data_source.h"
-OmniboxUI::OmniboxUI(content::WebUI* web_ui)
- : ui::MojoWebUIController<mojom::OmniboxPageHandler>(web_ui) {
+OmniboxUI::OmniboxUI(content::WebUI* web_ui) : ui::MojoWebUIController(web_ui) {
// Set up the chrome://omnibox/ source.
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIOmniboxHost);
@@ -27,11 +26,13 @@ OmniboxUI::OmniboxUI(content::WebUI* web_ui)
source->UseGzip();
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
+ AddHandlerToRegistry(base::BindRepeating(&OmniboxUI::BindOmniboxPageHandler,
+ base::Unretained(this)));
}
OmniboxUI::~OmniboxUI() {}
-void OmniboxUI::BindUIHandler(
+void OmniboxUI::BindOmniboxPageHandler(
mojom::OmniboxPageHandlerRequest request) {
omnibox_handler_.reset(
new OmniboxPageHandler(Profile::FromWebUI(web_ui()), std::move(request)));
diff --git a/chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.h b/chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.h
index 473c38243d4..d65e868e21b 100644
--- a/chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.h
+++ b/chromium/chrome/browser/ui/webui/omnibox/omnibox_ui.h
@@ -12,14 +12,13 @@
class OmniboxPageHandler;
// The UI for chrome://omnibox/
-class OmniboxUI : public ui::MojoWebUIController<mojom::OmniboxPageHandler> {
+class OmniboxUI : public ui::MojoWebUIController {
public:
explicit OmniboxUI(content::WebUI* contents);
~OmniboxUI() override;
private:
- // ui::MojoWebUIController overrides:
- void BindUIHandler(mojom::OmniboxPageHandlerRequest request) override;
+ void BindOmniboxPageHandler(mojom::OmniboxPageHandlerRequest request);
std::unique_ptr<OmniboxPageHandler> omnibox_handler_;
diff --git a/chromium/chrome/browser/ui/webui/page_not_available_for_guest/page_not_available_for_guest_ui.cc b/chromium/chrome/browser/ui/webui/page_not_available_for_guest/page_not_available_for_guest_ui.cc
new file mode 100644
index 00000000000..779533ad1a3
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/page_not_available_for_guest/page_not_available_for_guest_ui.cc
@@ -0,0 +1,52 @@
+// Copyright (c) 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/page_not_available_for_guest/page_not_available_for_guest_ui.h"
+
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/url_constants.h"
+#include "chrome/grit/browser_resources.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/strings/grit/components_strings.h"
+#include "content/public/browser/web_ui.h"
+#include "content/public/browser/web_ui_data_source.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace {
+
+content::WebUIDataSource* CreateHTMLSource(Profile* profile,
+ const std::string& host_name) {
+ content::WebUIDataSource* source =
+ content::WebUIDataSource::Create(host_name);
+
+ base::string16 page_title;
+ if (host_name == chrome::kChromeUIBookmarksHost)
+ page_title = l10n_util::GetStringUTF16(IDS_MD_BOOKMARK_MANAGER_TITLE);
+ else if (host_name == chrome::kChromeUIHistoryHost)
+ page_title = l10n_util::GetStringUTF16(IDS_HISTORY_TITLE);
+ else if (host_name == chrome::kChromeUIExtensionsHost)
+ page_title = l10n_util::GetStringUTF16(IDS_MD_EXTENSIONS_TOOLBAR_TITLE);
+ else
+ page_title = base::UTF8ToUTF16(host_name);
+
+ source->AddString("pageTitle", page_title);
+ base::string16 page_heading = l10n_util::GetStringFUTF16(
+ IDS_PAGE_NOT_AVAILABLE_FOR_GUEST_HEADING, page_title);
+ source->AddString("pageHeading", page_heading);
+
+ source->SetDefaultResource(IDR_PAGE_NOT_AVAILABLE_FOR_GUEST_APP_HTML);
+
+ return source;
+}
+
+} // namespace
+
+PageNotAvailableForGuestUI::PageNotAvailableForGuestUI(
+ content::WebUI* web_ui,
+ const std::string& host_name)
+ : WebUIController(web_ui) {
+ Profile* profile = Profile::FromWebUI(web_ui);
+ content::WebUIDataSource::Add(profile, CreateHTMLSource(profile, host_name));
+}
diff --git a/chromium/chrome/browser/ui/webui/page_not_available_for_guest/page_not_available_for_guest_ui.h b/chromium/chrome/browser/ui/webui/page_not_available_for_guest/page_not_available_for_guest_ui.h
new file mode 100644
index 00000000000..148ada2253c
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/page_not_available_for_guest/page_not_available_for_guest_ui.h
@@ -0,0 +1,20 @@
+// Copyright (c) 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_PAGE_NOT_AVAILABLE_FOR_GUEST_PAGE_NOT_AVAILABLE_FOR_GUEST_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_PAGE_NOT_AVAILABLE_FOR_GUEST_PAGE_NOT_AVAILABLE_FOR_GUEST_UI_H_
+
+#include "base/macros.h"
+#include "content/public/browser/web_ui_controller.h"
+
+class PageNotAvailableForGuestUI : public content::WebUIController {
+ public:
+ explicit PageNotAvailableForGuestUI(content::WebUI* web_ui,
+ const std::string& host_name);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(PageNotAvailableForGuestUI);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_PAGE_NOT_AVAILABLE_FOR_GUEST_PAGE_NOT_AVAILABLE_FOR_GUEST_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/physical_web/physical_web_ui.cc b/chromium/chrome/browser/ui/webui/physical_web/physical_web_ui.cc
deleted file mode 100644
index 62dfc1b2936..00000000000
--- a/chromium/chrome/browser/ui/webui/physical_web/physical_web_ui.cc
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/physical_web/physical_web_ui.h"
-
-#include <memory>
-
-#include "base/metrics/user_metrics.h"
-#include "chrome/browser/browser_process_impl.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/url_constants.h"
-#include "components/grit/components_resources.h"
-#include "components/physical_web/data_source/physical_web_data_source.h"
-#include "components/physical_web/webui/physical_web_base_message_handler.h"
-#include "components/physical_web/webui/physical_web_ui_constants.h"
-#include "components/strings/grit/components_strings.h"
-#include "content/public/browser/web_ui_data_source.h"
-#include "content/public/browser/web_ui_message_handler.h"
-
-namespace {
-
-content::WebUIDataSource* CreatePhysicalWebHTMLSource() {
- content::WebUIDataSource* source =
- content::WebUIDataSource::Create(chrome::kChromeUIPhysicalWebHost);
-
- source->AddLocalizedString(physical_web_ui::kTitle,
- IDS_PHYSICAL_WEB_UI_TITLE);
- source->AddLocalizedString(physical_web_ui::kEmptyMessage,
- IDS_PHYSICAL_WEB_UI_EMPTY_MESSAGE);
- source->SetJsonPath("strings.js");
- source->AddResourcePath(physical_web_ui::kPhysicalWebJS,
- IDR_PHYSICAL_WEB_UI_JS);
- source->AddResourcePath(physical_web_ui::kPhysicalWebCSS,
- IDR_PHYSICAL_WEB_UI_CSS);
- source->SetDefaultResource(IDR_PHYSICAL_WEB_UI_HTML);
- source->AddResourcePath(physical_web_ui::kPhysicalWebLinkIcon,
- IDR_PHYSICAL_WEB_UI_LINK_ICON);
- source->UseGzip();
- return source;
-}
-
-// Implements all MessageHandler core functionality. This is extends the
-// PhysicalWebBaseMessageHandler and implements functions to manipulate an
-// Android-specific WebUI object.
-class MessageHandlerImpl
- : public physical_web_ui::PhysicalWebBaseMessageHandler {
- public:
- explicit MessageHandlerImpl(content::WebUI* web_ui) : web_ui_(web_ui) {}
- ~MessageHandlerImpl() override {}
-
- private:
- void RegisterMessageCallback(
- const std::string& message,
- const physical_web_ui::MessageCallback& callback) override {
- web_ui_->RegisterMessageCallback(message, callback);
- }
- void CallJavaScriptFunction(const std::string& function,
- const base::Value& arg) override {
- web_ui_->CallJavascriptFunctionUnsafe(function, arg);
- }
- physical_web::PhysicalWebDataSource* GetPhysicalWebDataSource() override {
- return g_browser_process->GetPhysicalWebDataSource();
- }
-
- content::WebUI* const web_ui_;
- DISALLOW_COPY_AND_ASSIGN(MessageHandlerImpl);
-};
-
-class PhysicalWebMessageHandler : public content::WebUIMessageHandler {
- public:
- PhysicalWebMessageHandler() {}
- ~PhysicalWebMessageHandler() override {}
-
- void RegisterMessages() override {
- impl_.reset(new MessageHandlerImpl(web_ui()));
- impl_->RegisterMessages();
- }
-
- private:
- std::unique_ptr<MessageHandlerImpl> impl_;
- DISALLOW_COPY_AND_ASSIGN(PhysicalWebMessageHandler);
-};
-
-} // namespace
-
-PhysicalWebUI::PhysicalWebUI(content::WebUI* web_ui) : WebUIController(web_ui) {
- content::WebUIDataSource::Add(Profile::FromWebUI(web_ui),
- CreatePhysicalWebHTMLSource());
- web_ui->AddMessageHandler(std::make_unique<PhysicalWebMessageHandler>());
- base::RecordAction(base::UserMetricsAction("PhysicalWeb.WebUI.Open"));
-}
-
-PhysicalWebUI::~PhysicalWebUI() = default;
diff --git a/chromium/chrome/browser/ui/webui/physical_web/physical_web_ui.h b/chromium/chrome/browser/ui/webui/physical_web/physical_web_ui.h
deleted file mode 100644
index aa5079d2a5a..00000000000
--- a/chromium/chrome/browser/ui/webui/physical_web/physical_web_ui.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_PHYSICAL_WEB_PHYSICAL_WEB_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_PHYSICAL_WEB_PHYSICAL_WEB_UI_H_
-
-#include "base/macros.h"
-#include "content/public/browser/web_ui_controller.h"
-
-class PhysicalWebUI : public content::WebUIController {
- public:
- explicit PhysicalWebUI(content::WebUI* web_ui);
- ~PhysicalWebUI() override;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(PhysicalWebUI);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_PHYSICAL_WEB_PHYSICAL_WEB_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/policy_tool_ui.cc b/chromium/chrome/browser/ui/webui/policy_tool_ui.cc
index 83c45ebffdf..dfbc301ba27 100644
--- a/chromium/chrome/browser/ui/webui/policy_tool_ui.cc
+++ b/chromium/chrome/browser/ui/webui/policy_tool_ui.cc
@@ -27,6 +27,7 @@ content::WebUIDataSource* CreatePolicyToolUIHtmlSource() {
source->AddLocalizedString("showExpandedValue",
IDS_POLICY_SHOW_EXPANDED_VALUE);
source->AddLocalizedString("exportLinux", IDS_EXPORT_POLICIES_LINUX);
+ source->AddLocalizedString("exportMac", IDS_EXPORT_POLICIES_MAC);
source->AddLocalizedString("hideExpandedValue",
IDS_POLICY_HIDE_EXPANDED_VALUE);
source->AddLocalizedString("loadSession", IDS_POLICY_TOOL_LOAD_SESSION);
@@ -47,6 +48,7 @@ content::WebUIDataSource* CreatePolicyToolUIHtmlSource() {
source->AddLocalizedString("errorFileCorrupted",
IDS_POLICY_TOOL_CORRUPTED_FILE);
source->AddLocalizedString("enableEditing", IDS_POLICY_TOOL_ENABLE_EDITING);
+ source->AddLocalizedString("errorInvalidType", IDS_POLICY_TOOL_INVALID_TYPE);
source->AddLocalizedString("errorRenameFailed",
IDS_POLICY_TOOL_RENAME_FAILED);
source->AddLocalizedString("errorSessionExist",
diff --git a/chromium/chrome/browser/ui/webui/policy_tool_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/policy_tool_ui_browsertest.cc
index de744a0e7b0..c58d6c2c0b2 100644
--- a/chromium/chrome/browser/ui/webui/policy_tool_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/policy_tool_ui_browsertest.cc
@@ -13,6 +13,7 @@
#include "base/test/scoped_feature_list.h"
#include "base/threading/thread_restrictions.h"
#include "base/values.h"
+#include "build/build_config.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.h"
@@ -23,8 +24,11 @@
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "components/policy/core/common/plist_writer.h"
+#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/shell_dialogs/select_file_dialog.h"
#include "ui/shell_dialogs/select_file_dialog_factory.h"
#include "ui/shell_dialogs/select_file_policy.h"
@@ -67,8 +71,20 @@ class PolicyToolUITest : public InProcessBrowserTest {
std::unique_ptr<base::ListValue> ExtractSessionsList();
+ // Creates a session directly by putting a file with valid content inside the
+ // session default directory. This helps us to avoid editing a session using
+ // the UI when we need a default session with values.
+ void CreateSingleSessionWithFixedValues(
+ const base::FilePath::StringType& session_name);
void CreateMultipleSessionFiles(int count);
+ void SetPolicyValue(const std::string& policy_name,
+ const std::string& policy_value);
+
+ bool CheckPolicyStatus(const std::string& policy_name,
+ const std::string& policy_value,
+ const std::string& expected_status);
+
// Check if the error message that replaces the element is shown correctly.
// Returns 1 if error message is shown, -1 if the error message is not shown,
// and 0 if the displaying is incorrect (e.g. both error message and the
@@ -84,7 +100,7 @@ class PolicyToolUITest : public InProcessBrowserTest {
base::FilePath PolicyToolUITest::GetSessionsDir() {
base::FilePath profile_dir;
- EXPECT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &profile_dir));
+ EXPECT_TRUE(base::PathService::Get(chrome::DIR_USER_DATA, &profile_dir));
return profile_dir.AppendASCII(TestingProfile::kTestUserProfileDir)
.Append(kPolicyToolSessionsDir);
}
@@ -144,6 +160,53 @@ void PolicyToolUITest::RenameSession(const std::string& session_name,
content::RunAllTasksUntilIdle();
}
+// Set |policy_value| as a value of |policy_name|, this function will
+// run all the tasks until idle because editing a policy value will post
+// tasks in the TaskScheduler.
+void PolicyToolUITest::SetPolicyValue(const std::string& policy_name,
+ const std::string& policy_value) {
+ std::string javascript =
+ "document.getElementById('show-unset').click();"
+ "var policies = document.querySelectorAll("
+ " 'section.policy-table-section > * > tbody');"
+ "var policyEntry;"
+ "for (var i = 0; i < policies.length; ++i) {"
+ " if (policies[i].getElementsByClassName('name')[0].textContent == '" +
+ policy_name +
+ "') {"
+ " policyEntry = policies[i];"
+ " break;"
+ " }"
+ "}"
+ "policyEntry.getElementsByClassName('edit-button')[0].click();"
+ "policyEntry.getElementsByClassName('value-edit-field')[0].value = '" +
+ policy_value +
+ "';"
+ "policyEntry.getElementsByClassName('save-button')[0].click();"
+ "document.getElementById('show-unset').click();"
+ "var name = policyEntry.getElementsByClassName('name-column')[0]"
+ " .getElementsByTagName('div')[0].textContent;";
+ EXPECT_TRUE(content::ExecuteScript(
+ browser()->tab_strip_model()->GetActiveWebContents(), javascript));
+ content::RunAllTasksUntilIdle();
+}
+
+// Check the status of |policy_name| after set |policy_value| as a value.
+// Return |true| if the status is equal to |expected_status| and |false|
+// otherwise.
+bool PolicyToolUITest::CheckPolicyStatus(const std::string& policy_name,
+ const std::string& policy_value,
+ const std::string& expected_status) {
+ ui_test_utils::NavigateToURL(browser(), GURL("chrome://policy-tool"));
+ // Wait until the current session load.
+ content::RunAllTasksUntilIdle();
+ // SetPolicyValue waits until all the tasks finish.
+ SetPolicyValue(policy_name, policy_value);
+ std::unique_ptr<base::DictionaryValue> page = ExtractPolicyValues(true);
+ return base::Value(expected_status) ==
+ *page->FindPath({"chromePolicies", policy_name, "status"});
+}
+
std::unique_ptr<base::DictionaryValue> PolicyToolUITest::ExtractPolicyValues(
bool need_status) {
std::string javascript =
@@ -230,6 +293,41 @@ void PolicyToolUITest::CreateMultipleSessionFiles(int count) {
}
}
+void PolicyToolUITest::CreateSingleSessionWithFixedValues(
+ const base::FilePath::StringType& session_name) {
+ base::ScopedAllowBlockingForTesting allow_blocking;
+
+ EXPECT_TRUE(base::CreateDirectory(GetSessionsDir()));
+
+ base::ListValue list;
+ list.GetList().push_back(base::Value("https://[*.]ext.google.com").Clone());
+ list.GetList().push_back(base::Value("{}").Clone());
+ base::DictionaryValue dict, inner_dict;
+ inner_dict.SetKey("pattern", base::Value("chrome://policy"));
+ inner_dict.SetKey("filter", base::Value("{}"));
+
+ // Add values to the dict.
+ dict.SetKey("extensionPolicies", base::DictionaryValue().Clone());
+ dict.SetPath({"chromePolicies", "AutoSelectCertificateForUrls", "value"},
+ list.Clone());
+ dict.SetPath({"chromePolicies", "DeviceLoginScreenPowerManagement", "value"},
+ inner_dict.Clone());
+ dict.SetPath({"chromePolicies", "AllowDinosaurEasterEgg", "value"},
+ base::Value(true));
+ dict.SetPath({"chromePolicies", "MaxInvalidationFetchDelay", "value"},
+ base::Value(1000));
+
+ // Get JSON string from dict.
+ std::string stringified_contents;
+ base::JSONWriter::Write(dict, &stringified_contents);
+
+ // Write in file.
+ base::WriteFile(GetSessionPath(session_name), stringified_contents.c_str(),
+ stringified_contents.size());
+ base::TouchFile(GetSessionPath(session_name), base::Time::Now(),
+ base::Time::Now());
+}
+
int PolicyToolUITest::GetElementDisabledState(
const std::string& element_id,
const std::string& error_message_id) {
@@ -341,7 +439,13 @@ class TestSelectFileDialogFactoryPolicyTool
}
};
-IN_PROC_BROWSER_TEST_F(PolicyToolUITest, CreatingSessionFiles) {
+// Flaky on Win buildbots. See crbug.com/832673.
+#if defined(OS_WIN)
+#define MAYBE_CreatingSessionFiles DISABLED_CreatingSessionFiles
+#else
+#define MAYBE_CreatingSessionFiles CreatingSessionFiles
+#endif
+IN_PROC_BROWSER_TEST_F(PolicyToolUITest, MAYBE_CreatingSessionFiles) {
base::ScopedAllowBlockingForTesting allow_blocking;
// Check that the directory is not created yet.
EXPECT_FALSE(PathExists(GetSessionsDir()));
@@ -476,7 +580,7 @@ IN_PROC_BROWSER_TEST_F(PolicyToolUITest, SavingToDiskError) {
EXPECT_EQ(GetElementDisabledState("session-choice", "saving"), 1);
}
-IN_PROC_BROWSER_TEST_F(PolicyToolUITest, DefaultSession) {
+IN_PROC_BROWSER_TEST_F(PolicyToolUITest, DISABLED_DefaultSession) {
// Navigate to the tool to make sure the sessions directory is created.
ui_test_utils::NavigateToURL(browser(), GURL("chrome://policy-tool"));
@@ -514,6 +618,9 @@ IN_PROC_BROWSER_TEST_F(PolicyToolUITest, MultipleSessionsChoice) {
// Load the page. This should load the last session.
ui_test_utils::NavigateToURL(browser(), GURL("chrome://policy-tool"));
+ // Wait until the session data is loaded.
+ content::RunAllTasksUntilIdle();
+
std::unique_ptr<base::DictionaryValue> page_contents =
ExtractPolicyValues(false);
base::DictionaryValue expected;
@@ -536,6 +643,8 @@ IN_PROC_BROWSER_TEST_F(PolicyToolUITest, SessionsList) {
IN_PROC_BROWSER_TEST_F(PolicyToolUITest, DeleteSession) {
CreateMultipleSessionFiles(3);
ui_test_utils::NavigateToURL(browser(), GURL("chrome://policy-tool"));
+ // Wait until the page data is filled.
+ content::RunAllTasksUntilIdle();
EXPECT_EQ("2", ExtractSinglePolicyValue("SessionId"));
// Check that a non-current session is deleted correctly.
@@ -551,36 +660,56 @@ IN_PROC_BROWSER_TEST_F(PolicyToolUITest, DeleteSession) {
EXPECT_EQ(expected, *ExtractSessionsList());
}
-IN_PROC_BROWSER_TEST_F(PolicyToolUITest, RenameSession) {
+IN_PROC_BROWSER_TEST_F(PolicyToolUITest, RenameCurrentSession) {
CreateMultipleSessionFiles(3);
ui_test_utils::NavigateToURL(browser(), GURL("chrome://policy-tool"));
+ // Wait until the session data is loaded.
+ content::RunAllTasksUntilIdle();
EXPECT_EQ("2", ExtractSinglePolicyValue("SessionId"));
- // Check that a non-current session is renamed correctly.
- RenameSession("0", "4");
+ // RenameSession will wait until idle.
+ RenameSession("2", "5");
EXPECT_FALSE(IsSessionRenameErrorMessageDisplayed());
base::ListValue expected;
- expected.GetList().push_back(base::Value("2"));
+ expected.GetList().push_back(base::Value("5"));
expected.GetList().push_back(base::Value("1"));
- expected.GetList().push_back(base::Value("4"));
+ expected.GetList().push_back(base::Value("0"));
EXPECT_EQ(expected, *ExtractSessionsList());
+}
- // Check that the current session can be renamed properly.
- RenameSession("2", "5");
+IN_PROC_BROWSER_TEST_F(PolicyToolUITest, RenameNonCurrentSession) {
+ CreateMultipleSessionFiles(3);
+ ui_test_utils::NavigateToURL(browser(), GURL("chrome://policy-tool"));
+ // Wait until the session data is loaded.
+ content::RunAllTasksUntilIdle();
+ EXPECT_EQ("2", ExtractSinglePolicyValue("SessionId"));
+
+ // Rename a session and wait until idle.
+ RenameSession("0", "4");
EXPECT_FALSE(IsSessionRenameErrorMessageDisplayed());
- expected.GetList()[0] = base::Value("5");
+ base::ListValue expected;
+ expected.GetList().push_back(base::Value("2"));
+ expected.GetList().push_back(base::Value("1"));
+ expected.GetList().push_back(base::Value("4"));
EXPECT_EQ(expected, *ExtractSessionsList());
}
IN_PROC_BROWSER_TEST_F(PolicyToolUITest, RenameSessionWithExistingSessionName) {
CreateMultipleSessionFiles(3);
ui_test_utils::NavigateToURL(browser(), GURL("chrome://policy-tool"));
+ content::RunAllTasksUntilIdle();
+ // Make sure the current session is '2'.
EXPECT_EQ("2", ExtractSinglePolicyValue("SessionId"));
// Check that a session can not be renamed with a name of another existing
// session.
RenameSession("2", "1");
+ // Wait until the posted tasks are done. After check that name already exist
+ // the tool displays an error message in the UI.
+ content::RunAllTasksUntilIdle();
EXPECT_TRUE(IsSessionRenameErrorMessageDisplayed());
+
+ // Check the names that appear in the session list didn't change.
base::ListValue expected;
expected.GetList().push_back(base::Value("2"));
expected.GetList().push_back(base::Value("1"));
@@ -588,7 +717,12 @@ IN_PROC_BROWSER_TEST_F(PolicyToolUITest, RenameSessionWithExistingSessionName) {
EXPECT_EQ(expected, *ExtractSessionsList());
}
-IN_PROC_BROWSER_TEST_F(PolicyToolUITest, RenameSessionInvalidName) {
+#if defined(OS_WIN)
+#define MAYBE_RenameSessionInvalidName DISABLED_RenameSessionInvalidName
+#else
+#define MAYBE_RenameSessionInvalidName RenameSessionInvalidName
+#endif
+IN_PROC_BROWSER_TEST_F(PolicyToolUITest, MAYBE_RenameSessionInvalidName) {
CreateMultipleSessionFiles(3);
ui_test_utils::NavigateToURL(browser(), GURL("chrome://policy-tool"));
EXPECT_EQ("2", ExtractSinglePolicyValue("SessionId"));
@@ -608,41 +742,113 @@ IN_PROC_BROWSER_TEST_F(PolicyToolUITest, RenameSessionInvalidName) {
}
IN_PROC_BROWSER_TEST_F(PolicyToolUIExportTest, ExportSessionPolicyToLinux) {
- CreateMultipleSessionFiles(3);
+ // Create policy session with fixed values.
+ CreateSingleSessionWithFixedValues(
+ base::FilePath::FromUTF8Unsafe("test_session").value());
// Set SelectFileDialog to use our factory.
ui::SelectFileDialog::SetFactory(new TestSelectFileDialogFactoryPolicyTool(
export_policies_test_file_path_));
+ ui_test_utils::NavigateToURL(browser(), GURL("chrome://policy-tool"));
+ content::RunAllTasksUntilIdle();
+
+ content::WebContents* contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ std::string export_js = "$('export-policies-linux').click()";
+ EXPECT_TRUE(content::ExecuteScript(contents, export_js));
- // Test if the current session policy is successfully exported.
+ // Wait until export to linux is done.
+ content::RunAllTasksUntilIdle();
+ EXPECT_TRUE(
+ base::ContentsEqual(export_policies_test_file_path_,
+ GetSessionPath(FILE_PATH_LITERAL("test_session"))));
+ TestSelectFileDialogPolicyTool::SetFactory(nullptr);
+}
+
+IN_PROC_BROWSER_TEST_F(PolicyToolUIExportTest, ExportSessionToMac) {
+ base::ScopedAllowBlockingForTesting allow_blocking;
+ // Set SelectFileDialog to use our factory.
+ ui::SelectFileDialog::SetFactory(new TestSelectFileDialogFactoryPolicyTool(
+ export_policies_test_file_path_));
+ // Create a session with default values.
+ CreateSingleSessionWithFixedValues(
+ base::FilePath::FromUTF8Unsafe("test_session").value());
+
+ // Test if the current policy session is successfully exported.
ui_test_utils::NavigateToURL(browser(), GURL("chrome://policy-tool"));
- std::string javascript =
- "$('show-unset').click();"
- "var policyEntry = document.querySelectorAll("
- " 'section.policy-table-section > * > tbody')[0];"
- "policyEntry.getElementsByClassName('edit-button')[0].click();"
- "policyEntry.getElementsByClassName('value-edit-field')[0].value ="
- " 'test';"
- "policyEntry.getElementsByClassName('save-button')[0].click();"
- "$('export-policies-linux').click()";
+ content::RunAllTasksUntilIdle();
content::WebContents* contents =
browser()->tab_strip_model()->GetActiveWebContents();
- EXPECT_TRUE(content::ExecuteScript(contents, javascript));
-
- // Because we created 3 session policies (with paths {0, 1, 2}), the last one
- // is the current active session policy.
- EXPECT_TRUE(base::ContentsEqual(export_policies_test_file_path_,
- GetSessionPath(FILE_PATH_LITERAL("2"))));
-
- // Test if after an export action, we can continue exporting.
- std::string change_session_js =
- "$('session-name-field').value = '1';"
- "$('load-session-button').click();";
-
- EXPECT_TRUE(content::ExecuteScript(contents, change_session_js + javascript));
- base::TaskScheduler::GetInstance()->FlushForTesting();
- EXPECT_TRUE(base::ContentsEqual(export_policies_test_file_path_,
- GetSessionPath(FILE_PATH_LITERAL("1"))));
+ std::string export_js = "$('export-policies-mac').click()";
+ EXPECT_TRUE(content::ExecuteScript(contents, export_js));
+ // Wait until the posted task export to Mac is done.
+ content::RunAllTasksUntilIdle();
+
+ // Read the content of the exported file and the |test_session| file.
+ std::string file_export_content = "", file_session_content = "";
+ base::ReadFileToString(export_policies_test_file_path_, &file_export_content);
+ base::ReadFileToString(GetSessionPath(FILE_PATH_LITERAL("test_session")),
+ &file_session_content);
+ // The format of every session file is JSON.
+ policy::PlistWrite(*base::JSONReader::Read(file_session_content),
+ &file_session_content);
+ EXPECT_TRUE(file_export_content == file_session_content);
TestSelectFileDialogPolicyTool::SetFactory(nullptr);
}
+
+IN_PROC_BROWSER_TEST_F(PolicyToolUITest,
+ CheckPolicyTypeCorrectBooleanTypeValidation) {
+ EXPECT_TRUE(CheckPolicyStatus("AllowDinosaurEasterEgg", "true",
+ l10n_util::GetStringUTF8(IDS_POLICY_OK)));
+}
+
+IN_PROC_BROWSER_TEST_F(PolicyToolUITest,
+ CheckPolicyTypeIncorrectBooleanTypeValidation) {
+ EXPECT_TRUE(CheckPolicyStatus(
+ "AllowDinosaurEasterEgg", "string",
+ l10n_util::GetStringUTF8(IDS_POLICY_TOOL_INVALID_TYPE)));
+}
+
+IN_PROC_BROWSER_TEST_F(PolicyToolUITest,
+ CheckPolicyTypeCorrectListTypeValidation) {
+ EXPECT_TRUE(CheckPolicyStatus("ImagesAllowedForUrls", "[\"a\", \"b\"]",
+ l10n_util::GetStringUTF8(IDS_POLICY_OK)));
+}
+
+IN_PROC_BROWSER_TEST_F(PolicyToolUITest,
+ CheckPolicyTypeBoolAsListTypeValidation) {
+ EXPECT_TRUE(CheckPolicyStatus(
+ "ImagesAllowedForUrls", "true",
+ l10n_util::GetStringUTF8(IDS_POLICY_TOOL_INVALID_TYPE)));
+}
+
+IN_PROC_BROWSER_TEST_F(PolicyToolUITest,
+ CheckPolicyTypeWrongElementTypesInListValidation) {
+ EXPECT_TRUE(CheckPolicyStatus(
+ "ImagesAllowedForUrls", "[1, 2]",
+ l10n_util::GetStringUTF8(IDS_POLICY_TOOL_INVALID_TYPE)));
+}
+
+IN_PROC_BROWSER_TEST_F(PolicyToolUITest,
+ CheckPolicyTypeMalformedListValidation) {
+ EXPECT_TRUE(CheckPolicyStatus(
+ "ImagesAllowedForUrls", "[\"a\"",
+ l10n_util::GetStringUTF8(IDS_POLICY_TOOL_INVALID_TYPE)));
+}
+
+IN_PROC_BROWSER_TEST_F(PolicyToolUITest,
+ CheckPolicyTypeValidDictionaryTypeValidation) {
+ EXPECT_TRUE(
+ CheckPolicyStatus("ManagedBookmarks",
+ R"([{"toplevel_name": "My managed bookmarks folder"},)"
+ R"({"url": "google.com", "name": "Google"}])",
+ l10n_util::GetStringUTF8(IDS_POLICY_OK)));
+}
+
+IN_PROC_BROWSER_TEST_F(PolicyToolUITest,
+ CheckPolicyTypeWrongAttributesTypeValidation) {
+ EXPECT_TRUE(CheckPolicyStatus(
+ "ManagedBookmarks", "[{\"attribute\": \"value\"}]",
+ l10n_util::GetStringUTF8(IDS_POLICY_TOOL_INVALID_TYPE)));
+} \ No newline at end of file
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 c9202afefe3..b7ee3b356cb 100644
--- a/chromium/chrome/browser/ui/webui/policy_tool_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/policy_tool_ui_handler.cc
@@ -12,8 +12,11 @@
#include "base/task_scheduler/post_task.h"
#include "build/build_config.h"
#include "chrome/browser/download/download_prefs.h"
+#include "chrome/browser/policy/schema_registry_service.h"
+#include "chrome/browser/policy/schema_registry_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
+#include "components/policy/core/common/plist_writer.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_contents.h"
#include "ui/base/l10n/l10n_util.h"
@@ -33,6 +36,9 @@ const base::FilePath::CharType kPolicyToolSessionExtension[] =
const base::FilePath::CharType kPolicyToolLinuxExtension[] =
FILE_PATH_LITERAL("json");
+const base::FilePath::CharType kPolicyToolMacExtension[] =
+ FILE_PATH_LITERAL("plist");
+
// Returns the current list of all sessions sorted by last access time in
// decreasing order.
base::ListValue GetSessionsList(const base::FilePath& sessions_dir) {
@@ -62,6 +68,56 @@ base::ListValue GetSessionsList(const base::FilePath& sessions_dir) {
return session_names;
}
+// Tries to parse the value if it is necessary. If parsing was necessary, but
+// not successful, returns nullptr.
+std::unique_ptr<base::Value> ParseSinglePolicyType(
+ const policy::Schema& policy_schema,
+ const std::string& policy_name,
+ base::Value* policy_value) {
+ if (!policy_schema.valid())
+ return nullptr;
+ if (policy_value->type() == base::Value::Type::STRING &&
+ policy_schema.type() != base::Value::Type::STRING) {
+ return base::JSONReader::Read(policy_value->GetString());
+ }
+ return base::Value::ToUniquePtrValue(policy_value->Clone());
+}
+
+// Checks if the value matches the actual policy type.
+bool CheckSinglePolicyType(const policy::Schema& policy_schema,
+ const std::string& policy_name,
+ base::Value* policy_value) {
+ // If the schema is invalid, this means that the policy is unknown, and so
+ // considered valid.
+ if (!policy_schema.valid())
+ return true;
+ std::string error_path, error;
+ return policy_schema.Validate(*policy_value, policy::SCHEMA_STRICT,
+ &error_path, &error);
+}
+
+// Parses and checks policy types for a single source (e.g. chrome policies
+// or policies for one extension). For each policy, if parsing was successful
+// and the parsed value matches its expected schema, replaces the policy value
+// with the parsed value. Also, sets the 'valid' field to indicate whether the
+// value is valid for its policy.
+void ParseSourcePolicyTypes(const policy::Schema* source_schema,
+ base::Value* policies) {
+ for (const auto& policy : policies->DictItems()) {
+ const std::string policy_name = policy.first;
+ policy::Schema policy_schema = source_schema->GetKnownProperty(policy_name);
+ std::unique_ptr<base::Value> parsed_value = ParseSinglePolicyType(
+ policy_schema, policy_name, policy.second.FindKey("value"));
+ if (parsed_value &&
+ CheckSinglePolicyType(policy_schema, policy_name, parsed_value.get())) {
+ policy.second.SetKey("value", std::move(*parsed_value));
+ policy.second.SetKey("valid", base::Value(true));
+ } else {
+ policy.second.SetKey("valid", base::Value(false));
+ }
+ }
+}
+
} // namespace
PolicyToolUIHandler::PolicyToolUIHandler() : callback_weak_ptr_factory_(this) {}
@@ -101,6 +157,9 @@ void PolicyToolUIHandler::RegisterMessages() {
"exportLinux",
base::BindRepeating(&PolicyToolUIHandler::HandleExportLinux,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "exportMac", base::BindRepeating(&PolicyToolUIHandler::HandleExportMac,
+ base::Unretained(this)));
}
void PolicyToolUIHandler::OnJavascriptDisallowed() {
@@ -169,7 +228,8 @@ std::string PolicyToolUIHandler::ReadOrCreateFileCallback() {
return contents;
}
-void PolicyToolUIHandler::OnFileRead(const std::string& contents) {
+void PolicyToolUIHandler::OnSessionContentReceived(
+ const std::string& contents) {
// If the saving is disabled, send a message about that to the UI.
if (!is_saving_enabled_) {
CallJavascriptFunction("policy.Page.disableSaving");
@@ -185,8 +245,7 @@ void PolicyToolUIHandler::OnFileRead(const std::string& contents) {
base::DictionaryValue());
CallJavascriptFunction("policy.Page.disableEditing");
} else {
- // TODO(urusant): convert the policy values so that the types are
- // consistent with actual policy types.
+ ParsePolicyTypes(value.get());
CallJavascriptFunction("policy.Page.setPolicyValues", *value);
CallJavascriptFunction("policy.Page.setSessionTitle",
base::Value(session_name_));
@@ -207,7 +266,7 @@ void PolicyToolUIHandler::ImportFile() {
FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
base::BindOnce(&PolicyToolUIHandler::ReadOrCreateFileCallback,
base::Unretained(this)),
- base::BindOnce(&PolicyToolUIHandler::OnFileRead,
+ base::BindOnce(&PolicyToolUIHandler::OnSessionContentReceived,
callback_weak_ptr_factory_.GetWeakPtr()));
}
@@ -350,6 +409,7 @@ void PolicyToolUIHandler::HandleUpdateSession(const base::ListValue* args) {
base::Unretained(this), converted_values),
base::BindOnce(&PolicyToolUIHandler::OnSessionUpdated,
callback_weak_ptr_factory_.GetWeakPtr()));
+ OnSessionContentReceived(converted_values);
}
void PolicyToolUIHandler::HandleResetSession(const base::ListValue* args) {
@@ -391,11 +451,16 @@ void PolicyToolUIHandler::HandleDeleteSession(const base::ListValue* args) {
void PolicyToolUIHandler::HandleExportLinux(const base::ListValue* args) {
DCHECK_EQ(1U, args->GetSize());
-
base::JSONWriter::Write(args->GetList()[0], &session_dict_for_exporting_);
ExportSessionToFile(kPolicyToolLinuxExtension);
}
+void PolicyToolUIHandler::HandleExportMac(const base::ListValue* args) {
+ DCHECK_EQ(1U, args->GetSize());
+ policy::PlistWrite(args->GetList()[0], &session_dict_for_exporting_);
+ ExportSessionToFile(kPolicyToolMacExtension);
+}
+
void DoWriteSessionPolicyToFile(const base::FilePath& path,
const std::string& data) {
// TODO(rodmartin): Handle when WriteFile fail.
@@ -457,3 +522,31 @@ void PolicyToolUIHandler::ExportSessionToFile(
/*default_extension=*/base::FilePath::StringType(), owning_window,
/*params=*/nullptr);
}
+
+void PolicyToolUIHandler::ParsePolicyTypes(
+ base::DictionaryValue* policies_dict) {
+ // TODO(rodmartin): Is there a better way to get the
+ // types for each policy?.
+ Profile* profile = Profile::FromWebUI(web_ui());
+ policy::SchemaRegistry* registry =
+ policy::SchemaRegistryServiceFactory::GetForContext(
+ profile->GetOriginalProfile())
+ ->registry();
+ scoped_refptr<policy::SchemaMap> schema_map = registry->schema_map();
+
+ for (const auto& policies_dict : policies_dict->DictItems()) {
+ policy::PolicyNamespace policy_domain;
+ if (policies_dict.first == "chromePolicies") {
+ policy_domain = policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, "");
+ } else if (policies_dict.first == "extensionPolicies") {
+ policy_domain =
+ policy::PolicyNamespace(policy::POLICY_DOMAIN_EXTENSIONS, "");
+ } else {
+ // The domains should be only chromePolicies and extensionPolicies.
+ NOTREACHED();
+ continue;
+ }
+ const policy::Schema* schema = schema_map->GetSchema(policy_domain);
+ ParseSourcePolicyTypes(schema, &policies_dict.second);
+ }
+}
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 861fa0adefe..49f9e2ccf00 100644
--- a/chromium/chrome/browser/ui/webui/policy_tool_ui_handler.h
+++ b/chromium/chrome/browser/ui/webui/policy_tool_ui_handler.h
@@ -47,10 +47,12 @@ class PolicyToolUIHandler : public PolicyUIHandler {
void HandleExportLinux(const base::ListValue* args);
+ void HandleExportMac(const base::ListValue* args);
+
void OnSessionDeleted(bool is_successful);
std::string ReadOrCreateFileCallback();
- void OnFileRead(const std::string& contents);
+ void OnSessionContentReceived(const std::string& contents);
static SessionErrors DoRenameSession(const base::FilePath& old_session_path,
const base::FilePath& new_session_path);
@@ -82,6 +84,9 @@ class PolicyToolUIHandler : public PolicyUIHandler {
bool is_saving_enabled_ = true;
+ // Parses and checks policy types for all sources.
+ void ParsePolicyTypes(base::DictionaryValue* values);
+
// This string is filled when an export action occurs, it contains the current
// session dictionary in a specific format. This format will be JSON, PLIST,
// or REG; depending on the kind of export.
diff --git a/chromium/chrome/browser/ui/webui/policy_ui.cc b/chromium/chrome/browser/ui/webui/policy_ui.cc
index 0c2f31ea748..4eadc72116a 100644
--- a/chromium/chrome/browser/ui/webui/policy_ui.cc
+++ b/chromium/chrome/browser/ui/webui/policy_ui.cc
@@ -32,6 +32,7 @@ content::WebUIDataSource* CreatePolicyUIHtmlSource() {
source->AddLocalizedString("labelEnterpriseDisplayDomain",
IDS_POLICY_LABEL_ENTERPRISE_DISPLAY_DOMAIN);
source->AddLocalizedString("labelUsername", IDS_POLICY_LABEL_USERNAME);
+ source->AddLocalizedString("labelGaiaId", IDS_POLICY_LABEL_GAIA_ID);
source->AddLocalizedString("labelClientId", IDS_POLICY_LABEL_CLIENT_ID);
source->AddLocalizedString("labelAssetId", IDS_POLICY_LABEL_ASSET_ID);
source->AddLocalizedString("labelLocation", IDS_POLICY_LABEL_LOCATION);
diff --git a/chromium/chrome/browser/ui/webui/policy_ui_handler.cc b/chromium/chrome/browser/ui/webui/policy_ui_handler.cc
index be261745a86..d322dd5ac8c 100644
--- a/chromium/chrome/browser/ui/webui/policy_ui_handler.cc
+++ b/chromium/chrome/browser/ui/webui/policy_ui_handler.cc
@@ -143,6 +143,8 @@ void GetStatusFromCore(const policy::CloudPolicyCore* core,
dict->SetString("location", policy->annotated_location());
if (policy && policy->has_directory_api_id())
dict->SetString("directoryApiId", policy->directory_api_id());
+ if (policy && policy->has_gaia_id())
+ dict->SetString("gaiaId", policy->gaia_id());
base::TimeDelta refresh_interval =
base::TimeDelta::FromMilliseconds(refresh_scheduler ?
diff --git a/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.cc b/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.cc
index 395ee71d9f4..78b67d27f48 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.cc
@@ -9,9 +9,6 @@
#include "base/bind.h"
#include "base/callback.h"
-#include "base/files/file.h"
-#include "base/files/file_path.h"
-#include "base/files/file_util.h"
#include "base/location.h"
#include "base/memory/ref_counted.h"
#include "base/memory/ref_counted_memory.h"
@@ -58,35 +55,15 @@ const char kInvalidTicketPrintError[] = "INVALID_TICKET";
const char kProvisionalUsbLabel[] = "provisional-usb";
-// Updates |job| with raster file path, size and last modification time.
-// Returns the updated print job.
-std::unique_ptr<extensions::PrinterProviderPrintJob>
-UpdateJobFileInfoOnWorkerThread(
- const base::FilePath& raster_path,
- std::unique_ptr<extensions::PrinterProviderPrintJob> job) {
- if (base::GetFileInfo(raster_path, &job->file_info))
- job->document_path = raster_path;
- return job;
-}
-
-// Callback to PWG raster conversion.
-// Posts a task to update print job with info about file containing converted
-// PWG raster data.
+// Updates |job| with raster data. Returns the updated print job.
void UpdateJobFileInfo(std::unique_ptr<extensions::PrinterProviderPrintJob> job,
ExtensionPrinterHandler::PrintJobCallback callback,
- bool success,
- const base::FilePath& pwg_file_path) {
- if (!success) {
- std::move(callback).Run(std::move(job));
- return;
- }
-
- base::PostTaskWithTraitsAndReplyWithResult(
- FROM_HERE,
- {base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
- base::BindOnce(&UpdateJobFileInfoOnWorkerThread, pwg_file_path,
- std::move(job)),
- std::move(callback));
+ base::ReadOnlySharedMemoryRegion pwg_region) {
+ auto data =
+ base::RefCountedSharedMemoryMapping::CreateFromWholeRegion(pwg_region);
+ if (data)
+ job->document_bytes = data;
+ std::move(callback).Run(std::move(job));
}
bool HasUsbPrinterProviderPermissions(const Extension* extension) {
@@ -120,6 +97,11 @@ bool ParseProvisionalUsbPrinterId(const std::string& printer_id,
return true;
}
+extensions::PrinterProviderAPI* GetPrinterProviderAPI(Profile* profile) {
+ return extensions::PrinterProviderAPIFactory::GetInstance()
+ ->GetForBrowserContext(profile);
+}
+
} // namespace
ExtensionPrinterHandler::ExtensionPrinterHandler(Profile* profile)
@@ -161,22 +143,18 @@ void ExtensionPrinterHandler::StartGetPrinters(
weak_ptr_factory_.GetWeakPtr(), callback));
}
- extensions::PrinterProviderAPIFactory::GetInstance()
- ->GetForBrowserContext(profile_)
- ->DispatchGetPrintersRequested(
- base::Bind(&ExtensionPrinterHandler::WrapGetPrintersCallback,
- weak_ptr_factory_.GetWeakPtr(), callback));
+ GetPrinterProviderAPI(profile_)->DispatchGetPrintersRequested(
+ base::BindRepeating(&ExtensionPrinterHandler::WrapGetPrintersCallback,
+ weak_ptr_factory_.GetWeakPtr(), callback));
}
void ExtensionPrinterHandler::StartGetCapability(
const std::string& destination_id,
GetCapabilityCallback callback) {
- extensions::PrinterProviderAPIFactory::GetInstance()
- ->GetForBrowserContext(profile_)
- ->DispatchGetCapabilityRequested(
- destination_id,
- base::BindOnce(&ExtensionPrinterHandler::WrapGetCapabilityCallback,
- weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
+ GetPrinterProviderAPI(profile_)->DispatchGetCapabilityRequested(
+ destination_id,
+ base::BindOnce(&ExtensionPrinterHandler::WrapGetCapabilityCallback,
+ weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
void ExtensionPrinterHandler::StartPrint(
@@ -198,12 +176,9 @@ void ExtensionPrinterHandler::StartPrint(
cloud_devices::printer::ContentTypesCapability content_types;
content_types.LoadFrom(printer_description);
- const bool kUsePdf = content_types.Contains(kContentTypePdf) ||
+ const bool use_pdf = content_types.Contains(kContentTypePdf) ||
content_types.Contains(kContentTypeAll);
-
- if (kUsePdf) {
- // TODO(tbarzic): Consider writing larger PDF to disk and provide the data
- // the same way as it's done with PWG raster.
+ if (use_pdf) {
print_job->content_type = kContentTypePdf;
print_job->document_bytes = print_data;
DispatchPrintJob(std::move(callback), std::move(print_job));
@@ -245,12 +220,10 @@ void ExtensionPrinterHandler::StartGrantPrinterAccess(
DevicePermissionsManager::Get(profile_);
permissions_manager->AllowUsbDevice(extension_id, device);
- extensions::PrinterProviderAPIFactory::GetInstance()
- ->GetForBrowserContext(profile_)
- ->DispatchGetUsbPrinterInfoRequested(
- extension_id, device,
- base::BindOnce(&ExtensionPrinterHandler::WrapGetPrinterInfoCallback,
- weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
+ GetPrinterProviderAPI(profile_)->DispatchGetUsbPrinterInfoRequested(
+ extension_id, device,
+ base::BindOnce(&ExtensionPrinterHandler::WrapGetPrinterInfoCallback,
+ weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
void ExtensionPrinterHandler::SetPwgRasterConverterForTesting(
@@ -281,7 +254,7 @@ void ExtensionPrinterHandler::ConvertToPWGRaster(
void ExtensionPrinterHandler::DispatchPrintJob(
PrintCallback callback,
std::unique_ptr<extensions::PrinterProviderPrintJob> print_job) {
- if (print_job->document_path.empty() && !print_job->document_bytes) {
+ if (!print_job->document_bytes) {
WrapPrintCallback(std::move(callback), base::Value(kInvalidDataPrintError));
return;
}
@@ -373,7 +346,7 @@ void ExtensionPrinterHandler::OnUsbDevicesEnumerated(
device->product_string(), base::string16(), false))
.Set("extensionId", extension->id())
.Set("extensionName", extension->name())
- .SetBoolean("provisional", true)
+ .Set("provisional", true)
.Build());
}
}
diff --git a/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.h b/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.h
index ce7ab8f5ac4..6259a197bb1 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.h
+++ b/chromium/chrome/browser/ui/webui/print_preview/extension_printer_handler.h
@@ -56,7 +56,6 @@ class ExtensionPrinterHandler : public PrinterHandler {
GetPrintersDoneCallback done_callback) override;
void StartGetCapability(const std::string& destination_id,
GetCapabilityCallback callback) override;
- // TODO(tbarzic): It might make sense to have the strings in a single struct.
void StartPrint(const std::string& destination_id,
const std::string& capability,
const base::string16& job_title,
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 0ef9c338198..e1f1803d1f7 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
@@ -13,8 +13,6 @@
#include "base/bind.h"
#include "base/containers/queue.h"
-#include "base/files/file_util.h"
-#include "base/files/scoped_temp_dir.h"
#include "base/json/json_string_value_serializer.h"
#include "base/macros.h"
#include "base/memory/ref_counted_memory.h"
@@ -278,47 +276,38 @@ std::string RefCountedMemoryToString(
// Fake PwgRasterConverter used in the tests.
class FakePwgRasterConverter : public PwgRasterConverter {
public:
- FakePwgRasterConverter() : fail_conversion_(false), initialized_(false) {}
+ FakePwgRasterConverter() {}
~FakePwgRasterConverter() override = default;
- // PwgRasterConverter implementation. It writes |data| to a temp file.
+ // PwgRasterConverter implementation. It writes |data| to shared memory.
// Also, remembers conversion and bitmap settings passed into the method.
- void Start(base::RefCountedMemory* data,
+ void Start(const base::RefCountedMemory* data,
const printing::PdfRenderSettings& conversion_settings,
const printing::PwgRasterSettings& bitmap_settings,
ResultCallback callback) override {
+ base::ReadOnlySharedMemoryRegion invalid_pwg_region;
if (fail_conversion_) {
- std::move(callback).Run(false, base::FilePath());
+ std::move(callback).Run(std::move(invalid_pwg_region));
return;
}
- if (!initialized_ && !temp_dir_.CreateUniqueTempDir()) {
- ADD_FAILURE() << "Unable to create target dir for cenverter";
- std::move(callback).Run(false, base::FilePath());
- return;
- }
-
- initialized_ = true;
-
- path_ = temp_dir_.GetPath().AppendASCII("output.pwg");
- std::string data_str(data->front_as<char>(), data->size());
- int written = WriteFile(path_, data_str.c_str(), data_str.size());
- if (written != static_cast<int>(data_str.size())) {
- ADD_FAILURE() << "Failed to write pwg raster file.";
- std::move(callback).Run(false, base::FilePath());
+ base::MappedReadOnlyRegion memory =
+ base::ReadOnlySharedMemoryRegion::Create(data->size());
+ if (!memory.IsValid()) {
+ ADD_FAILURE() << "Failed to create pwg raster shared memory.";
+ std::move(callback).Run(std::move(invalid_pwg_region));
return;
}
+ memcpy(memory.mapping.memory(), data->front(), data->size());
conversion_settings_ = conversion_settings;
bitmap_settings_ = bitmap_settings;
-
- std::move(callback).Run(true, path_);
+ std::move(callback).Run(std::move(memory.region));
}
// Makes |Start| method always return an error.
void FailConversion() { fail_conversion_ = true; }
- const base::FilePath& path() { return path_; }
const printing::PdfRenderSettings& conversion_settings() const {
return conversion_settings_;
}
@@ -328,13 +317,9 @@ class FakePwgRasterConverter : public PwgRasterConverter {
}
private:
- base::ScopedTempDir temp_dir_;
-
- base::FilePath path_;
printing::PdfRenderSettings conversion_settings_;
printing::PwgRasterSettings bitmap_settings_;
- bool fail_conversion_;
- bool initialized_;
+ bool fail_conversion_ = false;
DISALLOW_COPY_AND_ASSIGN(FakePwgRasterConverter);
};
@@ -595,7 +580,7 @@ TEST_F(ExtensionPrinterHandlerTest, GetUsbPrinters) {
.Set("name", "USB Printer")
.Set("extensionName", "Provider 1")
.Set("extensionId", extension_1->id())
- .SetBoolean("provisional", true)
+ .Set("provisional", true)
.Build());
std::unique_ptr<base::DictionaryValue> extension_2_entry(
DictionaryBuilder()
@@ -605,7 +590,7 @@ TEST_F(ExtensionPrinterHandlerTest, GetUsbPrinters) {
.Set("name", "USB Printer")
.Set("extensionName", "Provider 2")
.Set("extensionId", extension_2->id())
- .SetBoolean("provisional", true)
+ .Set("provisional", true)
.Build());
EXPECT_TRUE(printers->Find(*extension_1_entry) != printers->end());
EXPECT_TRUE(printers->Find(*extension_2_entry) != printers->end());
@@ -696,7 +681,6 @@ TEST_F(ExtensionPrinterHandlerTest, Print_Pdf) {
EXPECT_EQ(title, print_job->job_title);
EXPECT_EQ(kEmptyPrintTicket, print_job->ticket_json);
EXPECT_EQ(kContentTypePDF, print_job->content_type);
- EXPECT_TRUE(print_job->document_path.empty());
ASSERT_TRUE(print_job->document_bytes);
EXPECT_EQ(RefCountedMemoryToString(print_data),
RefCountedMemoryToString(print_job->document_bytes));
@@ -761,7 +745,6 @@ TEST_F(ExtensionPrinterHandlerTest, Print_All) {
EXPECT_EQ(title, print_job->job_title);
EXPECT_EQ(kEmptyPrintTicket, print_job->ticket_json);
EXPECT_EQ(kContentTypePDF, print_job->content_type);
- EXPECT_TRUE(print_job->document_path.empty());
ASSERT_TRUE(print_job->document_bytes);
EXPECT_EQ(RefCountedMemoryToString(print_data),
RefCountedMemoryToString(print_job->document_bytes));
@@ -816,11 +799,9 @@ TEST_F(ExtensionPrinterHandlerTest, Print_Pwg) {
EXPECT_EQ(title, print_job->job_title);
EXPECT_EQ(kEmptyPrintTicket, print_job->ticket_json);
EXPECT_EQ(kContentTypePWG, print_job->content_type);
- EXPECT_FALSE(print_job->document_bytes);
- EXPECT_FALSE(print_job->document_path.empty());
- EXPECT_EQ(pwg_raster_converter_->path(), print_job->document_path);
- EXPECT_EQ(static_cast<int64_t>(print_data->size()),
- print_job->file_info.size);
+ ASSERT_TRUE(print_job->document_bytes);
+ EXPECT_EQ(RefCountedMemoryToString(print_data),
+ RefCountedMemoryToString(print_job->document_bytes));
fake_api->TriggerNextPrintCallback(kPrintRequestSuccess);
@@ -872,11 +853,9 @@ TEST_F(ExtensionPrinterHandlerTest, Print_Pwg_NonDefaultSettings) {
EXPECT_EQ(title, print_job->job_title);
EXPECT_EQ(kPrintTicketWithDuplex, print_job->ticket_json);
EXPECT_EQ(kContentTypePWG, print_job->content_type);
- EXPECT_FALSE(print_job->document_bytes);
- EXPECT_FALSE(print_job->document_path.empty());
- EXPECT_EQ(pwg_raster_converter_->path(), print_job->document_path);
- EXPECT_EQ(static_cast<int64_t>(print_data->size()),
- print_job->file_info.size);
+ ASSERT_TRUE(print_job->document_bytes);
+ EXPECT_EQ(RefCountedMemoryToString(print_data),
+ RefCountedMemoryToString(print_job->document_bytes));
fake_api->TriggerNextPrintCallback(kPrintRequestSuccess);
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 da909f11bbb..5b128dc114d 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
@@ -16,6 +16,7 @@
#include "chrome/browser/chromeos/printing/cups_print_job_manager.h"
#include "chrome/browser/chromeos/printing/cups_print_job_manager_factory.h"
#include "chrome/browser/chromeos/printing/cups_printers_manager.h"
+#include "chrome/browser/chromeos/printing/cups_printers_manager_factory.h"
#include "chrome/browser/chromeos/printing/ppd_provider_factory.h"
#include "chrome/browser/chromeos/printing/printer_configurer.h"
#include "chrome/browser/profiles/profile.h"
@@ -31,6 +32,7 @@
namespace {
using chromeos::CupsPrintersManager;
+using chromeos::CupsPrintersManagerFactory;
// Store the name used in CUPS, Printer#id in |printer_name|, the description
// as the system_driverinfo option value, and the Printer#display_name in
@@ -76,7 +78,9 @@ LocalPrinterHandlerChromeos::LocalPrinterHandlerChromeos(
Profile* profile,
content::WebContents* preview_web_contents)
: preview_web_contents_(preview_web_contents),
- printers_manager_(CupsPrintersManager::Create(profile)),
+ printers_manager_(
+ CupsPrintersManagerFactory::GetInstance()->GetForBrowserContext(
+ profile)),
printer_configurer_(chromeos::PrinterConfigurer::Create(profile)),
weak_factory_(this) {
// Construct the CupsPrintJobManager to listen for printing events.
@@ -181,9 +185,12 @@ void LocalPrinterHandlerChromeos::HandlePrinterSetup(
break;
case chromeos::PrinterSetupResult::kPrinterUnreachable:
case chromeos::PrinterSetupResult::kDbusError:
+ case chromeos::PrinterSetupResult::kComponentUnavailable:
case chromeos::PrinterSetupResult::kPpdTooLarge:
case chromeos::PrinterSetupResult::kInvalidPpd:
case chromeos::PrinterSetupResult::kFatalError:
+ case chromeos::PrinterSetupResult::kNativePrintersNotAllowed:
+ case chromeos::PrinterSetupResult::kInvalidPrinterUpdate:
LOG(ERROR) << "Unexpected error in printer setup." << result;
break;
case chromeos::PrinterSetupResult::kMaxValue:
diff --git a/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.h b/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.h
index a96aa70ee77..a846e6ffefd 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.h
+++ b/chromium/chrome/browser/ui/webui/print_preview/local_printer_handler_chromeos.h
@@ -50,7 +50,7 @@ class LocalPrinterHandlerChromeos : public PrinterHandler {
chromeos::PrinterSetupResult result);
content::WebContents* const preview_web_contents_;
- std::unique_ptr<chromeos::CupsPrintersManager> printers_manager_;
+ chromeos::CupsPrintersManager* printers_manager_;
scoped_refptr<chromeos::PpdProvider> ppd_provider_;
std::unique_ptr<chromeos::PrinterConfigurer> printer_configurer_;
base::WeakPtrFactory<LocalPrinterHandlerChromeos> weak_factory_;
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 4a5410e4a56..07e885d8b19 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
@@ -107,6 +107,7 @@ enum UserActionBuckets {
PRINT_WITH_CLOUD_PRINT,
PRINT_WITH_PRIVET,
PRINT_WITH_EXTENSION,
+ OPEN_IN_MAC_PREVIEW,
USERACTION_BUCKET_BOUNDARY
};
@@ -133,6 +134,7 @@ enum PrintSettingsBuckets {
DISTILL_PAGE_UNUSED,
SCALING,
PRINT_AS_IMAGE,
+ PAGES_PER_SHEET,
PRINT_SETTINGS_BUCKET_BOUNDARY
};
@@ -144,19 +146,89 @@ enum PrintDocumentTypeBuckets {
PRINT_DOCUMENT_TYPE_BUCKET_BOUNDARY
};
-void ReportUserActionHistogram(enum UserActionBuckets event) {
+void ReportUserActionHistogram(UserActionBuckets event) {
UMA_HISTOGRAM_ENUMERATION("PrintPreview.UserAction", event,
USERACTION_BUCKET_BOUNDARY);
}
-void ReportPrintSettingHistogram(enum PrintSettingsBuckets setting) {
+void ReportPrintSettingHistogram(PrintSettingsBuckets setting) {
UMA_HISTOGRAM_ENUMERATION("PrintPreview.PrintSettings", setting,
PRINT_SETTINGS_BUCKET_BOUNDARY);
}
-void ReportPrintDocumentTypeHistogram(enum PrintDocumentTypeBuckets doctype) {
+void ReportPrintDocumentTypeAndSizeHistograms(PrintDocumentTypeBuckets doctype,
+ size_t average_page_size_in_kb) {
UMA_HISTOGRAM_ENUMERATION("PrintPreview.PrintDocumentType", doctype,
PRINT_DOCUMENT_TYPE_BUCKET_BOUNDARY);
+ switch (doctype) {
+ case HTML_DOCUMENT:
+ UMA_HISTOGRAM_MEMORY_KB("PrintPreview.PrintDocumentSize.HTML",
+ average_page_size_in_kb);
+ break;
+ case PDF_DOCUMENT:
+ UMA_HISTOGRAM_MEMORY_KB("PrintPreview.PrintDocumentSize.PDF",
+ average_page_size_in_kb);
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
+}
+
+bool ReportPageCountHistogram(UserActionBuckets user_action, int page_count) {
+ switch (user_action) {
+ case PRINT_TO_PRINTER:
+ UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", page_count);
+ return true;
+ case PRINT_TO_PDF:
+ UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPDF", page_count);
+ return true;
+ case FALLBACK_TO_ADVANCED_SETTINGS_DIALOG:
+ UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.SystemDialog", page_count);
+ return true;
+ case PRINT_WITH_CLOUD_PRINT:
+ UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToCloudPrint",
+ page_count);
+ return true;
+ case PRINT_WITH_PRIVET:
+ UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintWithPrivet",
+ page_count);
+ return true;
+ case PRINT_WITH_EXTENSION:
+ UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintWithExtension",
+ page_count);
+ return true;
+ case OPEN_IN_MAC_PREVIEW:
+ UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.OpenInMacPreview",
+ page_count);
+ return true;
+ default:
+ return false;
+ }
+}
+
+PrinterType GetPrinterTypeForUserAction(UserActionBuckets user_action) {
+ switch (user_action) {
+ case PRINT_WITH_PRIVET:
+ return PrinterType::kPrivetPrinter;
+ case PRINT_WITH_EXTENSION:
+ return PrinterType::kExtensionPrinter;
+ case PRINT_TO_PDF:
+ return PrinterType::kPdfPrinter;
+ case PRINT_TO_PRINTER:
+ case FALLBACK_TO_ADVANCED_SETTINGS_DIALOG:
+ case OPEN_IN_MAC_PREVIEW:
+ return PrinterType::kLocalPrinter;
+ default:
+ NOTREACHED();
+ return PrinterType::kLocalPrinter;
+ }
+}
+
+base::Value GetErrorValue(UserActionBuckets user_action,
+ base::StringPiece description) {
+ return user_action == PRINT_WITH_PRIVET ? base::Value(-1)
+ : base::Value(description);
}
// Dictionary Fields for Print Preview initial settings. Keep in sync with
@@ -248,6 +320,13 @@ void ReportPrintSettingsStats(const base::DictionaryValue& settings) {
ReportPrintSettingHistogram(SCALING);
}
+ int num_pages_per_sheet = 1;
+ if (settings.GetInteger(printing::kSettingPagesPerSheet,
+ &num_pages_per_sheet) &&
+ num_pages_per_sheet != 1) {
+ ReportPrintSettingHistogram(PAGES_PER_SHEET);
+ }
+
bool collate = false;
if (settings.GetBoolean(printing::kSettingCollate, &collate) && collate)
ReportPrintSettingHistogram(COLLATE);
@@ -299,6 +378,30 @@ void ReportPrintSettingsStats(const base::DictionaryValue& settings) {
}
}
+UserActionBuckets DetermineUserAction(const base::DictionaryValue& settings) {
+ bool value = false;
+#if defined(OS_MACOSX)
+ value = settings.HasKey(printing::kSettingOpenPDFInPreview);
+#endif
+ if (value)
+ return OPEN_IN_MAC_PREVIEW;
+ if (settings.HasKey(printing::kSettingCloudPrintId))
+ return PRINT_WITH_CLOUD_PRINT;
+ settings.GetBoolean(printing::kSettingPrintWithPrivet, &value);
+ if (value)
+ return PRINT_WITH_PRIVET;
+ settings.GetBoolean(printing::kSettingPrintWithExtension, &value);
+ if (value)
+ return PRINT_WITH_EXTENSION;
+ settings.GetBoolean(printing::kSettingPrintToPDF, &value);
+ if (value)
+ return PRINT_TO_PDF;
+ settings.GetBoolean(printing::kSettingShowSystemDialog, &value);
+ if (value)
+ return FALLBACK_TO_ADVANCED_SETTINGS_DIALOG;
+ return PRINT_TO_PRINTER;
+}
+
base::LazyInstance<printing::StickySettings>::DestructorAtExit
g_sticky_settings = LAZY_INSTANCE_INITIALIZER;
@@ -561,7 +664,7 @@ void PrintPreviewHandler::HandleGetPrinterCapabilities(
}
void PrintPreviewHandler::HandleGetPreview(const base::ListValue* args) {
- DCHECK_EQ(3U, args->GetSize());
+ DCHECK_EQ(2U, args->GetSize());
std::string callback_id;
std::string json_str;
@@ -617,29 +720,6 @@ void PrintPreviewHandler::HandleGetPreview(const base::ListValue* args) {
initiator_url.ReplaceComponents(url_sanitizer).spec());
}
- bool generate_draft_data = false;
- success = settings->GetBoolean(printing::kSettingGenerateDraftData,
- &generate_draft_data);
- DCHECK(success);
-
- if (!generate_draft_data) {
- int page_count = -1;
- success = args->GetInteger(2, &page_count);
- DCHECK(success);
-
- if (page_count != -1) {
- bool preview_modifiable = false;
- success = settings->GetBoolean(printing::kSettingPreviewModifiable,
- &preview_modifiable);
- DCHECK(success);
-
- if (preview_modifiable &&
- print_preview_ui()->GetAvailableDraftPageCount() != page_count) {
- settings->SetBoolean(printing::kSettingGenerateDraftData, true);
- }
- }
- }
-
VLOG(1) << "Print preview request start";
rfh->Send(new PrintMsg_PrintPreview(rfh->GetRoutingID(), *settings));
@@ -663,109 +743,71 @@ void PrintPreviewHandler::HandlePrint(const base::ListValue* args) {
return;
}
- ReportPrintSettingsStats(*settings);
-
- // Report whether the user printed a PDF or an HTML document.
- ReportPrintDocumentTypeHistogram(print_preview_ui()->source_is_modifiable() ?
- HTML_DOCUMENT : PDF_DOCUMENT);
-
- bool print_to_pdf = false;
- bool is_cloud_printer = false;
- bool print_with_privet = false;
- bool print_with_extension = false;
- bool show_system_dialog = false;
- bool open_pdf_in_preview = false;
-#if defined(OS_MACOSX)
- open_pdf_in_preview = settings->HasKey(printing::kSettingOpenPDFInPreview);
-#endif
-
- if (!open_pdf_in_preview) {
- settings->GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf);
- settings->GetBoolean(printing::kSettingPrintWithPrivet, &print_with_privet);
- settings->GetBoolean(printing::kSettingPrintWithExtension,
- &print_with_extension);
- settings->GetBoolean(printing::kSettingShowSystemDialog,
- &show_system_dialog);
- is_cloud_printer = settings->HasKey(printing::kSettingCloudPrintId);
- }
+ const UserActionBuckets user_action = DetermineUserAction(*settings);
int page_count = 0;
if (!settings->GetInteger(printing::kSettingPreviewPageCount, &page_count) ||
page_count <= 0) {
- RejectJavascriptCallback(base::Value(callback_id), base::Value(-1));
+ RejectJavascriptCallback(base::Value(callback_id),
+ GetErrorValue(user_action, "NO_PAGE_COUNT"));
return;
}
- if (print_with_privet) {
-#if BUILDFLAG(ENABLE_SERVICE_DISCOVERY)
- UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintWithPrivet", page_count);
- ReportUserActionHistogram(PRINT_WITH_PRIVET);
-#endif
- } else if (print_with_extension) {
- UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintWithExtension",
- page_count);
- ReportUserActionHistogram(PRINT_WITH_EXTENSION);
- } else if (print_to_pdf) {
- UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPDF", page_count);
- ReportUserActionHistogram(PRINT_TO_PDF);
- } else if (show_system_dialog) {
- UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.SystemDialog", page_count);
- ReportUserActionHistogram(FALLBACK_TO_ADVANCED_SETTINGS_DIALOG);
- } else if (!open_pdf_in_preview) {
- UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", page_count);
- ReportUserActionHistogram(PRINT_TO_PRINTER);
- } else if (is_cloud_printer) {
- UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToCloudPrint",
- page_count);
- ReportUserActionHistogram(PRINT_WITH_CLOUD_PRINT);
- }
-
scoped_refptr<base::RefCountedMemory> data;
print_preview_ui()->GetPrintPreviewDataForIndex(
printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, &data);
if (!data) {
// Nothing to print, no preview available.
- RejectJavascriptCallback(
- base::Value(callback_id),
- print_with_privet ? base::Value(-1) : base::Value("NO_DATA"));
+ RejectJavascriptCallback(base::Value(callback_id),
+ GetErrorValue(user_action, "NO_DATA"));
return;
}
DCHECK(data->size());
DCHECK(data->front());
- if (is_cloud_printer) {
- // Does not send the title like the other printer handler types below,
- // because JS already has the document title from the initial settings.
- SendCloudPrintJob(callback_id, data.get());
- return;
- }
-
std::string destination_id;
std::string print_ticket;
std::string capabilities;
int width = 0;
int height = 0;
- if ((print_with_privet || print_with_extension) &&
- (!settings->GetString(printing::kSettingDeviceName, &destination_id) ||
- !settings->GetString(printing::kSettingTicket, &print_ticket) ||
- !settings->GetString(printing::kSettingCapabilities, &capabilities) ||
- !settings->GetInteger(printing::kSettingPageWidth, &width) ||
- !settings->GetInteger(printing::kSettingPageHeight, &height) ||
- width <= 0 || height <= 0)) {
+ if (user_action == PRINT_WITH_PRIVET || user_action == PRINT_WITH_EXTENSION) {
+ if (!settings->GetString(printing::kSettingDeviceName, &destination_id) ||
+ !settings->GetString(printing::kSettingTicket, &print_ticket) ||
+ !settings->GetString(printing::kSettingCapabilities, &capabilities) ||
+ !settings->GetInteger(printing::kSettingPageWidth, &width) ||
+ !settings->GetInteger(printing::kSettingPageHeight, &height) ||
+ width <= 0 || height <= 0) {
+ NOTREACHED();
+ RejectJavascriptCallback(base::Value(callback_id),
+ GetErrorValue(user_action, "FAILED"));
+ return;
+ }
+ }
+
+ // After validating |settings|, record metrics.
+ ReportPrintSettingsStats(*settings);
+ {
+ PrintDocumentTypeBuckets doc_type =
+ print_preview_ui()->source_is_modifiable() ? HTML_DOCUMENT
+ : PDF_DOCUMENT;
+ size_t average_page_size_in_kb = data->size() / page_count;
+ average_page_size_in_kb /= 1024;
+ ReportPrintDocumentTypeAndSizeHistograms(doc_type, average_page_size_in_kb);
+ }
+ ReportUserActionHistogram(user_action);
+ if (!ReportPageCountHistogram(user_action, page_count)) {
NOTREACHED();
- RejectJavascriptCallback(
- base::Value(callback_id),
- print_with_privet ? base::Value(-1) : base::Value("FAILED"));
return;
}
- PrinterType type = PrinterType::kLocalPrinter;
- if (print_with_extension)
- type = PrinterType::kExtensionPrinter;
- else if (print_with_privet)
- type = PrinterType::kPrivetPrinter;
- else if (print_to_pdf)
- type = PrinterType::kPdfPrinter;
+ if (user_action == PRINT_WITH_CLOUD_PRINT) {
+ // Does not send the title like the other printer handler types below,
+ // because JS already has the document title from the initial settings.
+ SendCloudPrintJob(callback_id, data.get());
+ return;
+ }
+
+ PrinterType type = GetPrinterTypeForUserAction(user_action);
PrinterHandler* handler = GetPrinterHandler(type);
handler->StartPrint(
destination_id, capabilities, print_preview_ui()->initiator_title(),
diff --git a/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc b/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc
index 785b773740c..281cbfbf549 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc
@@ -90,7 +90,6 @@ base::Value GetPrintPreviewTicket(bool is_pdf) {
print_ticket.SetKey(kIsFirstRequest, base::Value(true));
print_ticket.SetKey(kPreviewRequestID, base::Value(0));
print_ticket.SetKey(kSettingPreviewModifiable, base::Value(is_pdf));
- print_ticket.SetKey(kSettingGenerateDraftData, base::Value(true));
print_ticket.RemoveKey(kSettingPageWidth);
print_ticket.RemoveKey(kSettingPageHeight);
print_ticket.RemoveKey(kSettingShowSystemDialog);
@@ -106,7 +105,6 @@ std::unique_ptr<base::ListValue> ConstructPreviewArgs(
std::string json;
base::JSONWriter::Write(print_ticket, &json);
args.GetList().emplace_back(json);
- args.GetList().emplace_back(-1);
return base::ListValue::From(base::Value::ToUniquePtrValue(std::move(args)));
}
@@ -188,8 +186,6 @@ class FakePrintPreviewUI : public PrintPreviewUI {
sizeof(kTestData) - 1);
}
- int GetAvailableDraftPageCount() const override { return 1; }
-
void OnPrintPreviewRequest(int request_id) override {}
void OnCancelPendingPreviewRequest() override {}
void OnHidePreviewDialog() override {}
@@ -248,11 +244,11 @@ class PrintPreviewHandlerTest : public testing::Test {
PrintPreviewHandlerTest() {
TestingProfile::Builder builder;
profile_ = builder.Build();
- initiator_web_contents_.reset(content::WebContents::Create(
- content::WebContents::CreateParams(profile_.get())));
+ initiator_web_contents_ = content::WebContents::Create(
+ content::WebContents::CreateParams(profile_.get()));
content::WebContents* initiator = initiator_web_contents_.get();
- preview_web_contents_.reset(content::WebContents::Create(
- content::WebContents::CreateParams(profile_.get())));
+ preview_web_contents_ = content::WebContents::Create(
+ content::WebContents::CreateParams(profile_.get()));
printing::PrintViewManager::CreateForWebContents(initiator);
printing::PrintViewManager::FromWebContents(initiator)->PrintPreviewNow(
initiator->GetMainFrame(), false);
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 c2deb06ddf2..9be9474eb72 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
@@ -192,6 +192,9 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) {
IDS_PRINT_PREVIEW_DESTINATION_LABEL);
source->AddLocalizedString("copiesLabel", IDS_PRINT_PREVIEW_COPIES_LABEL);
source->AddLocalizedString("scalingLabel", IDS_PRINT_PREVIEW_SCALING_LABEL);
+ source->AddLocalizedString("pagesPerSheetLabel",
+ IDS_PRINT_PREVIEW_PAGES_PER_SHEET_LABEL);
+
source->AddLocalizedString("examplePageRangeText",
IDS_PRINT_PREVIEW_EXAMPLE_PAGE_RANGE_TEXT);
source->AddLocalizedString("layoutLabel", IDS_PRINT_PREVIEW_LAYOUT_LABEL);
@@ -395,14 +398,6 @@ void AddPrintPreviewImages(content::WebUIDataSource* source) {
}
void AddPrintPreviewFlags(content::WebUIDataSource* source, Profile* profile) {
-#if !defined(OS_MACOSX) && !defined(OS_WIN)
- bool print_pdf_as_image_enabled = base::FeatureList::IsEnabled(
- features::kPrintPdfAsImage);
- source->AddBoolean("printPdfAsImageEnabled", print_pdf_as_image_enabled);
-#else
- source->AddBoolean("printPdfAsImageEnabled", false);
-#endif
-
#if defined(OS_CHROMEOS)
source->AddBoolean("useSystemDefaultPrinter", false);
#else
@@ -420,6 +415,10 @@ void AddPrintPreviewFlags(content::WebUIDataSource* source, Profile* profile) {
enterprise_managed = base::win::IsEnterpriseManaged();
#endif
source->AddBoolean("isEnterpriseManaged", enterprise_managed);
+
+ bool nup_printing_enabled =
+ base::FeatureList::IsEnabled(features::kNupPrinting);
+ source->AddBoolean("pagesPerSheetEnabled", nup_printing_enabled);
}
void SetupPrintPreviewPlugin(content::WebUIDataSource* source) {
@@ -621,11 +620,6 @@ void PrintPreviewUI::ClearAllPreviewData() {
PrintPreviewDataService::GetInstance()->RemoveEntry(id_);
}
-int PrintPreviewUI::GetAvailableDraftPageCount() const {
- return PrintPreviewDataService::GetInstance()->GetAvailableDraftPageCount(
- id_);
-}
-
void PrintPreviewUI::SetInitiatorTitle(
const base::string16& job_title) {
initiator_title_ = job_title;
@@ -786,7 +780,7 @@ void PrintPreviewUI::OnHidePreviewDialog() {
delegate->ReleaseWebContents();
DCHECK_EQ(preview_dialog, preview_contents.get());
background_printing_manager->OwnPrintPreviewDialog(
- preview_contents.release());
+ std::move(preview_contents));
OnClosePrintPreviewDialog();
}
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 db9a4933bf5..87d879753fe 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
@@ -58,9 +58,6 @@ class PrintPreviewUI : public ConstrainedWebDialogUI {
// Clear the existing print preview data.
void ClearAllPreviewData();
- // Returns the available draft page count.
- virtual int GetAvailableDraftPageCount() const;
-
// Setters
void SetInitiatorTitle(const base::string16& initiator_title);
diff --git a/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc
index 8d8187548ad..bff768e8b7b 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc
@@ -57,7 +57,7 @@ IN_PROC_BROWSER_TEST_F(PrintPreviewBrowserTest, PrintCommands) {
ASSERT_TRUE(chrome::IsCommandEnabled(browser(), IDC_PRINT));
-#if BUILDFLAG(ENABLE_BASIC_PRINTING) && !defined(OS_CHROMEOS)
+#if BUILDFLAG(ENABLE_PRINTING) && !defined(OS_CHROMEOS)
// This is analagous to ENABLE_BASIC_PRINT_DIALOG but helps to verify
// that it is defined as expected.
bool is_basic_print_expected = true;
diff --git a/chromium/chrome/browser/ui/webui/print_preview/printer_handler.h b/chromium/chrome/browser/ui/webui/print_preview/printer_handler.h
index ec72a5998e3..66f5f29df0c 100644
--- a/chromium/chrome/browser/ui/webui/print_preview/printer_handler.h
+++ b/chromium/chrome/browser/ui/webui/print_preview/printer_handler.h
@@ -120,7 +120,6 @@ class PrinterHandler {
// |page_size|: The document page size.
// |print_data|: The document bytes to print.
// |callback| should be called in the response to the request.
- // TODO(tbarzic): Page size should be extracted from print data.
virtual void StartPrint(
const std::string& destination_id,
const std::string& capability,
diff --git a/chromium/chrome/browser/ui/webui/quota_internals/OWNERS b/chromium/chrome/browser/ui/webui/quota_internals/OWNERS
index ed698ac5e50..6fb5954d8c9 100644
--- a/chromium/chrome/browser/ui/webui/quota_internals/OWNERS
+++ b/chromium/chrome/browser/ui/webui/quota_internals/OWNERS
@@ -1,2 +1,5 @@
tzik@chromium.org
-michaeln@chromium.org
+jsbell@chromium.org
+
+# TEAM: storage-dev@chromium.org
+# COMPONENT: Blink>Storage>Quota
diff --git a/chromium/chrome/browser/ui/webui/reset_password/BUILD.gn b/chromium/chrome/browser/ui/webui/reset_password/BUILD.gn
new file mode 100644
index 00000000000..46529aa8ccb
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/reset_password/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("//mojo/public/tools/bindings/mojom.gni")
+
+mojom("mojo_bindings") {
+ sources = [
+ "reset_password.mojom",
+ ]
+}
diff --git a/chromium/chrome/browser/ui/webui/reset_password/OWNERS b/chromium/chrome/browser/ui/webui/reset_password/OWNERS
new file mode 100644
index 00000000000..22146bac43e
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/reset_password/OWNERS
@@ -0,0 +1,8 @@
+per-file *.mojom=set noparent
+per-file *.mojom=file://ipc/SECURITY_OWNERS
+
+jialiul@chromium.org
+nparker@chromium.org
+vakh@chromium.org
+
+# COMPONENT: Services>Safebrowsing
diff --git a/chromium/chrome/browser/ui/webui/reset_password/reset_password.mojom b/chromium/chrome/browser/ui/webui/reset_password/reset_password.mojom
new file mode 100644
index 00000000000..857069bbba9
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/reset_password/reset_password.mojom
@@ -0,0 +1,10 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module mojom;
+
+interface ResetPasswordHandler {
+ HandlePasswordReset();
+};
+
diff --git a/chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.cc b/chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.cc
new file mode 100644
index 00000000000..5aa829a4eeb
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.cc
@@ -0,0 +1,140 @@
+// 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/reset_password/reset_password_ui.h"
+
+#include "base/metrics/histogram_functions.h"
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
+#include "chrome/common/url_constants.h"
+#include "chrome/grit/browser_resources.h"
+#include "components/safe_browsing/common/safe_browsing_prefs.h"
+#include "components/strings/grit/components_strings.h"
+#include "components/user_prefs/user_prefs.h"
+#include "content/public/browser/browser_context.h"
+#include "content/public/browser/navigation_entry.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_ui_data_source.h"
+#include "mojo/public/cpp/bindings/binding.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace {
+
+constexpr char kStringTypeUMAName[] = "PasswordProtection.InterstitialString";
+
+// Used for UMA metric logging. Please don't reorder.
+// Indicates which type of strings are shown on this page.
+enum StringType {
+ GENERIC_NO_ORG_NAME = 0,
+ GENERIC_WITH_ORG_NAME = 1,
+ WARNING_NO_ORG_NAME = 2,
+ WARNING_WITH_ORG_NAME = 3,
+ STRING_TYPE_COUNT,
+};
+
+// Implementation of mojom::ResetPasswordHander.
+class ResetPasswordHandlerImpl : public mojom::ResetPasswordHandler {
+ public:
+ ResetPasswordHandlerImpl(
+ content::WebContents* web_contents,
+ mojo::InterfaceRequest<mojom::ResetPasswordHandler> request)
+ : web_contents_(web_contents), binding_(this, std::move(request)) {
+ DCHECK(web_contents);
+ }
+
+ ~ResetPasswordHandlerImpl() override {}
+
+ // mojom::ResetPasswordHandler overrides:
+ void HandlePasswordReset() override {
+ Profile* profile =
+ Profile::FromBrowserContext(web_contents_->GetBrowserContext());
+ safe_browsing::ChromePasswordProtectionService* service = safe_browsing::
+ ChromePasswordProtectionService::GetPasswordProtectionService(profile);
+ if (service) {
+ service->OnUserAction(
+ web_contents_, safe_browsing::PasswordProtectionService::INTERSTITIAL,
+ safe_browsing::PasswordProtectionService::CHANGE_PASSWORD);
+ }
+ }
+
+ private:
+ content::WebContents* web_contents_;
+ mojo::Binding<mojom::ResetPasswordHandler> binding_;
+
+ DISALLOW_COPY_AND_ASSIGN(ResetPasswordHandlerImpl);
+};
+
+} // namespace
+
+ResetPasswordUI::ResetPasswordUI(content::WebUI* web_ui)
+ : ui::MojoWebUIController(web_ui) {
+ base::DictionaryValue load_time_data;
+ PopulateStrings(web_ui->GetWebContents(), &load_time_data);
+ std::unique_ptr<content::WebUIDataSource> html_source(
+ content::WebUIDataSource::Create(chrome::kChromeUIResetPasswordHost));
+ html_source->AddResourcePath("reset_password.js", IDR_RESET_PASSWORD_JS);
+ html_source->AddResourcePath("reset_password.mojom.js",
+ IDR_RESET_PASSWORD_MOJO_JS);
+ html_source->SetDefaultResource(IDR_RESET_PASSWORD_HTML);
+ html_source->AddLocalizedStrings(load_time_data);
+ html_source->UseGzip();
+
+ content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
+ html_source.release());
+
+ AddHandlerToRegistry(base::BindRepeating(
+ &ResetPasswordUI::BindResetPasswordHandler, base::Unretained(this)));
+}
+
+ResetPasswordUI::~ResetPasswordUI() {}
+
+void ResetPasswordUI::BindResetPasswordHandler(
+ mojom::ResetPasswordHandlerRequest request) {
+ ui_handler_ = std::make_unique<ResetPasswordHandlerImpl>(
+ web_ui()->GetWebContents(), std::move(request));
+}
+
+void ResetPasswordUI::PopulateStrings(content::WebContents* web_contents,
+ base::DictionaryValue* load_time_data) {
+ content::NavigationEntry* nav_entry =
+ web_contents->GetController().GetPendingEntry();
+ std::string org_name =
+ safe_browsing::ChromePasswordProtectionService::
+ GetPasswordProtectionService(
+ Profile::FromBrowserContext(web_contents->GetBrowserContext()))
+ ->GetOrganizationName();
+ bool has_referrer = nav_entry->GetReferrer().url.is_valid();
+ int heading_string_id = has_referrer ? IDS_RESET_PASSWORD_WARNING_HEADING
+ : IDS_RESET_PASSWORD_HEADING;
+ base::string16 explanation_paragraph_string;
+ if (org_name.empty()) {
+ explanation_paragraph_string = l10n_util::GetStringUTF16(
+ has_referrer ? IDS_RESET_PASSWORD_WARNING_EXPLANATION_PARAGRAPH
+ : IDS_RESET_PASSWORD_EXPLANATION_PARAGRAPH);
+ base::UmaHistogramEnumeration(
+ kStringTypeUMAName,
+ has_referrer ? WARNING_NO_ORG_NAME : GENERIC_NO_ORG_NAME,
+ STRING_TYPE_COUNT);
+ } else {
+ explanation_paragraph_string = l10n_util::GetStringFUTF16(
+ has_referrer
+ ? IDS_RESET_PASSWORD_WARNING_EXPLANATION_PARAGRAPH_WITH_ORG_NAME
+ : IDS_RESET_PASSWORD_EXPLANATION_PARAGRAPH_WITH_ORG_NAME,
+ base::UTF8ToUTF16(org_name));
+ base::UmaHistogramEnumeration(
+ kStringTypeUMAName,
+ has_referrer ? WARNING_WITH_ORG_NAME : GENERIC_WITH_ORG_NAME,
+ STRING_TYPE_COUNT);
+ }
+
+ load_time_data->SetString(
+ "title", l10n_util::GetStringUTF16(IDS_RESET_PASSWORD_TITLE));
+ load_time_data->SetString("heading",
+ l10n_util::GetStringUTF16(heading_string_id));
+ load_time_data->SetString("primaryParagraph", explanation_paragraph_string);
+ load_time_data->SetString(
+ "primaryButtonText",
+ l10n_util::GetStringUTF16(IDS_RESET_PASSWORD_BUTTON));
+}
diff --git a/chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.h b/chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.h
new file mode 100644
index 00000000000..41234d359f4
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/reset_password/reset_password_ui.h
@@ -0,0 +1,37 @@
+// 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_RESET_PASSWORD_RESET_PASSWORD_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_RESET_PASSWORD_RESET_PASSWORD_UI_H_
+
+#include "base/macros.h"
+#include "chrome/browser/ui/webui/reset_password/reset_password.mojom.h"
+#include "ui/webui/mojo_web_ui_controller.h"
+
+namespace base {
+class DictionaryValue;
+}
+
+namespace content {
+class WebContents;
+}
+
+// The WebUI for chrome://reset-password/.
+class ResetPasswordUI : public ui::MojoWebUIController {
+ public:
+ explicit ResetPasswordUI(content::WebUI* web_ui);
+ ~ResetPasswordUI() override;
+
+ private:
+ void BindResetPasswordHandler(mojom::ResetPasswordHandlerRequest request);
+
+ void PopulateStrings(content::WebContents* web_content,
+ base::DictionaryValue* load_time_data);
+
+ std::unique_ptr<mojom::ResetPasswordHandler> ui_handler_;
+
+ DISALLOW_COPY_AND_ASSIGN(ResetPasswordUI);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_RESET_PASSWORD_RESET_PASSWORD_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/sandbox_internals_ui.cc b/chromium/chrome/browser/ui/webui/sandbox_internals_ui.cc
index 0ba9fbd6acd..ea2ef9b4a88 100644
--- a/chromium/chrome/browser/ui/webui/sandbox_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/sandbox_internals_ui.cc
@@ -21,8 +21,8 @@
#endif
#if defined(OS_LINUX)
-#include "content/public/browser/zygote_host_linux.h"
#include "services/service_manager/sandbox/sandbox.h"
+#include "services/service_manager/zygote/zygote_host_linux.h"
#endif
namespace {
@@ -31,7 +31,7 @@ namespace {
static void SetSandboxStatusData(content::WebUIDataSource* source) {
// Get expected sandboxing status of renderers.
const int status =
- content::ZygoteHost::GetInstance()->GetRendererSandboxStatus();
+ service_manager::ZygoteHost::GetInstance()->GetRendererSandboxStatus();
source->AddBoolean("suid", status & service_manager::SandboxLinux::kSUID);
source->AddBoolean("userNs", status & service_manager::SandboxLinux::kUserNS);
diff --git a/chromium/chrome/browser/ui/webui/settings/about_handler.cc b/chromium/chrome/browser/ui/webui/settings/about_handler.cc
index 787f802a743..8bd560132b1 100644
--- a/chromium/chrome/browser/ui/webui/settings/about_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/about_handler.cc
@@ -52,7 +52,6 @@
#include "v8/include/v8-version-string.h"
#if defined(OS_CHROMEOS)
-#include "base/files/file_util_proxy.h"
#include "base/i18n/time_formatting.h"
#include "base/sys_info.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
@@ -602,15 +601,16 @@ void AboutHandler::RequestUpdateOverCellular(const std::string& update_version,
void AboutHandler::HandleRefreshTPMFirmwareUpdateStatus(
const base::ListValue* args) {
- chromeos::tpm_firmware_update::ShouldOfferUpdateViaPowerwash(
+ chromeos::tpm_firmware_update::GetAvailableUpdateModes(
base::Bind(&AboutHandler::RefreshTPMFirmwareUpdateStatus,
weak_factory_.GetWeakPtr()),
base::TimeDelta());
}
-void AboutHandler::RefreshTPMFirmwareUpdateStatus(bool update_available) {
+void AboutHandler::RefreshTPMFirmwareUpdateStatus(
+ const std::set<chromeos::tpm_firmware_update::Mode>& modes) {
std::unique_ptr<base::DictionaryValue> event(new base::DictionaryValue);
- event->SetBoolean("updateAvailable", update_available);
+ event->SetBoolean("updateAvailable", !modes.empty());
FireWebUIListener("tpm-firmware-update-status-changed", *event);
}
diff --git a/chromium/chrome/browser/ui/webui/settings/about_handler.h b/chromium/chrome/browser/ui/webui/settings/about_handler.h
index 0e47e2580e1..3cbfa4a8d4b 100644
--- a/chromium/chrome/browser/ui/webui/settings/about_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/about_handler.h
@@ -21,6 +21,7 @@
#if defined(OS_CHROMEOS)
#include "base/task/cancelable_task_tracker.h"
+#include "chrome/browser/chromeos/tpm_firmware_update.h"
#include "chromeos/system/version_loader.h"
#endif // defined(OS_CHROMEOS)
@@ -117,7 +118,8 @@ class AboutHandler : public settings::SettingsPageUIHandler,
// Called once when the page has loaded to retrieve the TPM firmware update
// status.
void HandleRefreshTPMFirmwareUpdateStatus(const base::ListValue* args);
- void RefreshTPMFirmwareUpdateStatus(bool update_available);
+ void RefreshTPMFirmwareUpdateStatus(
+ const std::set<chromeos::tpm_firmware_update::Mode>& modes);
#endif
// Checks for and applies update.
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 c4eb7282a45..dd9e351b7e1 100644
--- a/chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/browser_lifetime_handler.cc
@@ -20,6 +20,38 @@
namespace settings {
+namespace {
+
+#if defined(OS_CHROMEOS)
+// Triggers a TPM firmware update using the least destructive mode from
+// |available_modes|.
+void TriggerTPMFirmwareUpdate(
+ const std::set<chromeos::tpm_firmware_update::Mode>& available_modes) {
+ using chromeos::tpm_firmware_update::Mode;
+
+ // Decide which update mode to use.
+ // TODO(crbug.com/854576): Re-add Mode::kPreserveDeviceState after fixing
+ // interrupted update flow issue described in the bug.
+ for (Mode mode : {Mode::kPowerwash}) {
+ if (available_modes.count(mode) == 0) {
+ continue;
+ }
+
+ // Save a TPM firmware update request in local state, which
+ // will trigger the reset screen to appear on reboot.
+ PrefService* prefs = g_browser_process->local_state();
+ prefs->SetBoolean(prefs::kFactoryResetRequested, true);
+ prefs->SetInteger(prefs::kFactoryResetTPMFirmwareUpdateMode,
+ static_cast<int>(mode));
+ prefs->CommitPendingWrite();
+ chrome::AttemptRelaunch();
+ return;
+ }
+}
+#endif // defined(OS_CHROMEOS)
+
+} // namespace
+
BrowserLifetimeHandler::BrowserLifetimeHandler() {}
BrowserLifetimeHandler::~BrowserLifetimeHandler() {}
@@ -66,18 +98,8 @@ void BrowserLifetimeHandler::HandleFactoryReset(
bool tpm_firmware_update_requested = args_list[0].GetBool();
if (tpm_firmware_update_requested) {
- chromeos::tpm_firmware_update::ShouldOfferUpdateViaPowerwash(
- base::BindOnce([](bool offer_update) {
- if (!offer_update)
- return;
-
- PrefService* prefs = g_browser_process->local_state();
- prefs->SetBoolean(prefs::kFactoryResetRequested, true);
- prefs->SetBoolean(prefs::kFactoryResetTPMFirmwareUpdateRequested,
- true);
- prefs->CommitPendingWrite();
- chrome::AttemptRelaunch();
- }), base::TimeDelta());
+ chromeos::tpm_firmware_update::GetAvailableUpdateModes(
+ base::BindOnce(&TriggerTPMFirmwareUpdate), base::TimeDelta());
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 fa100c69aa3..f07c59b79c0 100644
--- a/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler.cc
@@ -12,6 +12,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
+#include "base/strings/string16.h"
#include "base/synchronization/lock.h"
#include "base/values.h"
#include "build/build_config.h"
@@ -20,6 +21,8 @@
#include "chrome/browser/safe_browsing/chrome_cleaner/reporter_runner_win.h"
#include "chrome/browser/safe_browsing/chrome_cleaner/srt_field_trial_win.h"
#include "chrome/grit/generated_resources.h"
+#include "components/component_updater/pref_names.h"
+#include "components/prefs/pref_service.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_message_handler.h"
@@ -31,15 +34,6 @@ namespace settings {
namespace {
-// These numeric values must be kept in sync with the definition of
-// settings.ChromeCleanupDismissSource in
-// chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.js.
-enum ChromeCleanerDismissSource {
- kOther = 0,
- kCleanupSuccessDoneButton = 1,
- kCleanupFailureDoneButton = 2,
-};
-
// Returns a ListValue containing a copy of the file paths stored in |files|.
std::unique_ptr<base::ListValue> GetFilesAsListStorage(
const std::set<base::FilePath>& files) {
@@ -102,7 +96,14 @@ std::string IdleReasonToString(
} // namespace
ChromeCleanupHandler::ChromeCleanupHandler(Profile* profile)
- : controller_(ChromeCleanerController::GetInstance()), profile_(profile) {}
+ : controller_(ChromeCleanerController::GetInstance()), profile_(profile) {
+ DCHECK(g_browser_process->local_state());
+ logs_enabled_pref_.Init(g_browser_process->local_state());
+ logs_enabled_pref_.Add(
+ prefs::kSwReporterReportingEnabled,
+ base::BindRepeating(&ChromeCleanupHandler::OnLogsEnabledPrefChanged,
+ base::Unretained(this)));
+}
ChromeCleanupHandler::~ChromeCleanupHandler() {
controller_->RemoveObserver(this);
@@ -110,10 +111,6 @@ ChromeCleanupHandler::~ChromeCleanupHandler() {
void ChromeCleanupHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
- "dismissCleanupPage",
- base::BindRepeating(&ChromeCleanupHandler::HandleDismiss,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
"registerChromeCleanerObserver",
base::BindRepeating(
&ChromeCleanupHandler::HandleRegisterChromeCleanerObserver,
@@ -197,37 +194,20 @@ void ChromeCleanupHandler::OnRebootRequired() {
}
void ChromeCleanupHandler::OnLogsEnabledChanged(bool logs_enabled) {
+ // Logs are considered managed if the logs themselves are managed or if the
+ // entire cleanup feature is disabled by policy.
+ PrefService* local_state = g_browser_process->local_state();
+ bool is_managed = !controller_->IsAllowedByPolicy() ||
+ (local_state && local_state->IsManagedPreference(
+ prefs::kSwReporterReportingEnabled));
FireWebUIListener("chrome-cleanup-upload-permission-change",
- base::Value(logs_enabled));
+ base::Value(is_managed), base::Value(logs_enabled));
}
-void ChromeCleanupHandler::HandleDismiss(const base::ListValue* args) {
- CHECK_EQ(1U, args->GetSize());
- int dismiss_source_int = -1;
- CHECK(args->GetInteger(0, &dismiss_source_int));
-
- ChromeCleanerDismissSource dismiss_source =
- static_cast<ChromeCleanerDismissSource>(dismiss_source_int);
-
- switch (dismiss_source) {
- case kCleanupSuccessDoneButton:
- base::RecordAction(base::UserMetricsAction(
- "SoftwareReporter.CleanupWebui_CleanupSuccessDone"));
- break;
- case kCleanupFailureDoneButton:
- base::RecordAction(base::UserMetricsAction(
- "SoftwareReporter.CleanupWebui_CleanupFailureDone"));
- break;
- case kOther:
- break;
- default:
- NOTREACHED();
- }
-
- controller_->RemoveObserver(this);
- controller_->ResetIdleState();
-
- FireWebUIListener("chrome-cleanup-on-dismiss");
+void ChromeCleanupHandler::OnLogsEnabledPrefChanged() {
+ bool is_enabled = controller_->IsReportingAllowedByPolicy();
+ controller_->SetLogsEnabled(is_enabled);
+ OnLogsEnabledChanged(is_enabled);
}
void ChromeCleanupHandler::HandleRegisterChromeCleanerObserver(
@@ -241,6 +221,9 @@ void ChromeCleanupHandler::HandleRegisterChromeCleanerObserver(
// Send the current logs upload state.
OnLogsEnabledChanged(controller_->logs_enabled());
+
+ FireWebUIListener("chrome-cleanup-enabled-change",
+ base::Value(controller_->IsAllowedByPolicy()));
}
void ChromeCleanupHandler::HandleStartScanning(const base::ListValue* args) {
@@ -248,6 +231,9 @@ void ChromeCleanupHandler::HandleStartScanning(const base::ListValue* args) {
bool allow_logs_upload = false;
args->GetBoolean(0, &allow_logs_upload);
+ // If this operation is not allowed the UI should be disabled.
+ CHECK(controller_->IsAllowedByPolicy());
+
// The state is propagated to all open tabs and should be consistent.
DCHECK_EQ(controller_->logs_enabled(), allow_logs_upload);
@@ -263,8 +249,6 @@ void ChromeCleanupHandler::HandleRestartComputer(const base::ListValue* args) {
base::RecordAction(
base::UserMetricsAction("SoftwareReporter.CleanupWebui_RestartComputer"));
- FireWebUIListener("chrome-cleanup-on-dismiss");
-
controller_->Reboot();
}
@@ -351,11 +335,12 @@ void ChromeCleanupHandler::GetPluralString(int id,
int num_items = 0;
args->GetInteger(1, &num_items);
- DCHECK_GT(0, num_items);
- ResolveJavascriptCallback(
- base::Value(callback_id),
- base::Value(l10n_util::GetPluralStringFUTF16(id, num_items)));
+ const base::string16 plural_string =
+ num_items > 0 ? l10n_util::GetPluralStringFUTF16(id, num_items)
+ : base::string16();
+ ResolveJavascriptCallback(base::Value(callback_id),
+ base::Value(plural_string));
}
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler.h b/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler.h
index 199ca791fe2..237e11484a1 100644
--- a/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chrome_cleanup_handler.h
@@ -12,6 +12,7 @@
#include "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_controller_win.h"
#include "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_scanner_results.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
+#include "components/prefs/pref_change_registrar.h"
class Profile;
@@ -45,9 +46,8 @@ class ChromeCleanupHandler
void OnLogsEnabledChanged(bool logs_enabled) override;
private:
- // Callback for the "dismissCleanupPage" message to hide the Cleanup page
- // from the settings.
- void HandleDismiss(const base::ListValue* args);
+ // Called when prefs::kSwReporterReportingEnabled changes.
+ void OnLogsEnabledPrefChanged();
// Callback for the "registerChromeCleanerObserver" message. This registers
// this object as an observer of the Chrome Cleanup global state and
@@ -92,6 +92,7 @@ class ChromeCleanupHandler
safe_browsing::ChromeCleanerController* controller_;
Profile* profile_;
+ PrefChangeRegistrar logs_enabled_pref_;
DISALLOW_COPY_AND_ASSIGN(ChromeCleanupHandler);
};
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/DEPS b/chromium/chrome/browser/ui/webui/settings/chromeos/DEPS
deleted file mode 100644
index 9f60b59abe3..00000000000
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/DEPS
+++ /dev/null
@@ -1,6 +0,0 @@
-specific_include_rules = {
- "device_power_handler(|_unittest)\.(h|cc)": [
- # TODO(mash): Remove. http://crbug.com/770866
- "+ash/system/power/power_status.h",
- ],
-}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc
index 43375c860ec..44240697552 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/accessibility_handler.cc
@@ -12,6 +12,7 @@
#include "chrome/common/extensions/extension_constants.h"
#include "content/public/browser/web_ui.h"
#include "extensions/browser/extension_registry.h"
+#include "extensions/common/constants.h"
namespace chromeos {
namespace settings {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc
new file mode 100644
index 00000000000..aba28c25d50
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.cc
@@ -0,0 +1,104 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h"
+
+#include <utility>
+
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/logging.h"
+#include "base/macros.h"
+#include "base/values.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
+#include "chromeos/account_manager/account_manager.h"
+#include "chromeos/account_manager/account_manager_factory.h"
+#include "components/signin/core/browser/account_tracker_service.h"
+#include "components/user_manager/user.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "ui/base/webui/web_ui_util.h"
+
+namespace chromeos {
+namespace settings {
+
+AccountManagerUIHandler::AccountManagerUIHandler(
+ AccountManager* account_manager,
+ AccountTrackerService* account_tracker_service)
+ : account_manager_(account_manager),
+ account_tracker_service_(account_tracker_service),
+ weak_factory_(this) {}
+
+AccountManagerUIHandler::~AccountManagerUIHandler() = default;
+
+void AccountManagerUIHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "getAccounts",
+ base::BindRepeating(&AccountManagerUIHandler::HandleGetAccounts,
+ weak_factory_.GetWeakPtr()));
+}
+
+void AccountManagerUIHandler::HandleGetAccounts(const base::ListValue* args) {
+ AllowJavascript();
+ CHECK(!args->GetList().empty());
+ base::Value callback_id = args->GetList()[0].Clone();
+
+ account_manager_->GetAccounts(
+ base::BindOnce(&AccountManagerUIHandler::GetAccountsCallbackHandler,
+ weak_factory_.GetWeakPtr(), std::move(callback_id)));
+}
+
+void AccountManagerUIHandler::GetAccountsCallbackHandler(
+ base::Value callback_id,
+ std::vector<AccountManager::AccountKey> account_keys) {
+ base::ListValue accounts;
+
+ const AccountId device_account_id =
+ ProfileHelper::Get()
+ ->GetUserByProfile(Profile::FromWebUI(web_ui()))
+ ->GetAccountId();
+
+ base::DictionaryValue device_account;
+ for (const auto& account_key : account_keys) {
+ // We are only interested in listing GAIA accounts.
+ if (account_key.account_type !=
+ account_manager::AccountType::ACCOUNT_TYPE_GAIA) {
+ continue;
+ }
+ AccountInfo account_info =
+ account_tracker_service_->FindAccountInfoByGaiaId(account_key.id);
+ DCHECK(!account_info.IsEmpty());
+
+ base::DictionaryValue account;
+ account.SetString("fullName", account_info.full_name);
+ account.SetString("email", account_info.email);
+ gfx::Image icon =
+ account_tracker_service_->GetAccountImage(account_info.account_id);
+ account.SetString("pic", webui::GetBitmapDataUrl(icon.AsBitmap()));
+
+ // |account_key| is a GAIA account and hence |id| is the obfuscated GAIA id
+ // (see |AccountManager::AccountKey|)
+ if (account_key.id != device_account_id.GetGaiaId()) {
+ accounts.GetList().push_back(std::move(account));
+ } else {
+ device_account = std::move(account);
+ }
+ }
+
+ // Device account must show up at the top.
+ if (!device_account.empty()) {
+ accounts.GetList().insert(accounts.GetList().begin(),
+ std::move(device_account));
+ }
+
+ ResolveJavascriptCallback(callback_id, accounts);
+}
+
+void AccountManagerUIHandler::OnJavascriptAllowed() {}
+
+void AccountManagerUIHandler::OnJavascriptDisallowed() {}
+
+} // namespace settings
+} // namespace chromeos
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
new file mode 100644
index 00000000000..95316717231
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h
@@ -0,0 +1,55 @@
+// 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_SETTINGS_CHROMEOS_ACCOUNT_MANAGER_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_ACCOUNT_MANAGER_HANDLER_H_
+
+#include <vector>
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
+#include "chromeos/account_manager/account_manager.h"
+
+class AccountTrackerService;
+
+namespace chromeos {
+namespace settings {
+
+class AccountManagerUIHandler : public ::settings::SettingsPageUIHandler {
+ public:
+ // Accepts non-owning pointers to |AccountManager| and
+ // |AccountTrackerService|. Both of these must outlive |this| instance.
+ AccountManagerUIHandler(AccountManager* account_manager,
+ AccountTrackerService* account_tracker_service);
+ ~AccountManagerUIHandler() override;
+
+ // WebUIMessageHandler implementation.
+ void RegisterMessages() override;
+ void OnJavascriptAllowed() override;
+ void OnJavascriptDisallowed() override;
+
+ private:
+ // WebUI "getAccounts" message callback.
+ void HandleGetAccounts(const base::ListValue* args);
+
+ // |AccountManager::GetAccounts| callback.
+ void GetAccountsCallbackHandler(
+ base::Value callback_id,
+ std::vector<AccountManager::AccountKey> account_keys);
+
+ // A non-owning pointer to |AccountManager|.
+ AccountManager* const account_manager_;
+
+ // A non-owning pointer to |AccountTrackerService|.
+ AccountTrackerService* const account_tracker_service_;
+
+ base::WeakPtrFactory<AccountManagerUIHandler> weak_factory_;
+ DISALLOW_COPY_AND_ASSIGN(AccountManagerUIHandler);
+};
+
+} // namespace settings
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_ACCOUNT_MANAGER_HANDLER_H_
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 578bbdbb08e..d62f3fb16bb 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
@@ -149,7 +149,7 @@ void ChangePictureHandler::HandleChooseFile(const base::ListValue* args) {
std::make_unique<ChromeSelectFilePolicy>(web_ui()->GetWebContents()));
base::FilePath downloads_path;
- if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &downloads_path)) {
+ if (!base::PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &downloads_path)) {
NOTREACHED();
return;
}
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc
new file mode 100644
index 00000000000..03a08cad53e
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.cc
@@ -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.
+
+#include "chrome/browser/ui/webui/settings/chromeos/crostini_handler.h"
+
+#include "base/bind_helpers.h"
+#include "chrome/browser/chromeos/crostini/crostini_manager.h"
+#include "chrome/browser/chromeos/crostini/crostini_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() = default;
+
+void CrostiniHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "requestCrostiniInstallerView",
+ base::BindRepeating(&CrostiniHandler::HandleRequestCrostiniInstallerView,
+ weak_ptr_factory_.GetWeakPtr()));
+ web_ui()->RegisterMessageCallback(
+ "requestRemoveCrostini",
+ base::BindRepeating(&CrostiniHandler::HandleRequestRemoveCrostini,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+void CrostiniHandler::HandleRequestCrostiniInstallerView(
+ const base::ListValue* args) {
+ AllowJavascript();
+ ShowCrostiniInstallerView(Profile::FromWebUI(web_ui()));
+}
+
+void CrostiniHandler::HandleRequestRemoveCrostini(const base::ListValue* args) {
+ AllowJavascript();
+ ShowCrostiniUninstallerView(Profile::FromWebUI(web_ui()));
+}
+
+} // namespace settings
+} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_handler.h
new file mode 100644
index 00000000000..1229a331bf4
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/crostini_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_SETTINGS_CHROMEOS_CROSTINI_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_CROSTINI_HANDLER_H_
+
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
+
+namespace crostini {
+enum class ConciergeClientResult;
+}
+
+namespace chromeos {
+namespace settings {
+
+class CrostiniHandler : public ::settings::SettingsPageUIHandler {
+ public:
+ CrostiniHandler();
+ ~CrostiniHandler() override;
+
+ // SettingsPageUIHandler
+ void RegisterMessages() override;
+ void OnJavascriptAllowed() override {}
+ void OnJavascriptDisallowed() override {}
+
+ private:
+ void HandleRequestCrostiniInstallerView(const base::ListValue* args);
+ void HandleRequestRemoveCrostini(const base::ListValue* args);
+
+ // weak_ptr_factory_ should always be last member.
+ base::WeakPtrFactory<CrostiniHandler> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(CrostiniHandler);
+};
+
+} // namespace settings
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_CROSTINI_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
index 942bd8bfbc4..98fc7863982 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
@@ -20,6 +20,7 @@
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/printing/cups_printers_manager.h"
+#include "chrome/browser/chromeos/printing/cups_printers_manager_factory.h"
#include "chrome/browser/chromeos/printing/ppd_provider_factory.h"
#include "chrome/browser/chromeos/printing/printer_configurer.h"
#include "chrome/browser/chromeos/printing/printer_event_tracker.h"
@@ -31,6 +32,7 @@
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
#include "chrome/common/chrome_paths.h"
+#include "chrome/common/pref_names.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/debug_daemon_client.h"
#include "chromeos/printing/ppd_cache.h"
@@ -40,6 +42,7 @@
#include "chromeos/printing/printer_translator.h"
#include "chromeos/printing/printing_constants.h"
#include "chromeos/printing/uri_components.h"
+#include "components/device_event_log/device_event_log.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_ui.h"
@@ -64,6 +67,12 @@ void RecordPpdSource(const PpdSourceForHistogram& source) {
}
void OnRemovedPrinter(const Printer::PrinterProtocol& protocol, bool success) {
+ if (success) {
+ PRINTER_LOG(DEBUG) << "Printer removal succeeded.";
+ } else {
+ PRINTER_LOG(DEBUG) << "Printer removal failed.";
+ }
+
UMA_HISTOGRAM_ENUMERATION("Printing.CUPS.PrinterRemoved", protocol,
Printer::PrinterProtocol::kProtocolMax);
}
@@ -93,7 +102,7 @@ void QueryAutoconf(const std::string& printer_uri,
auto optional = ParseUri(printer_uri);
// Behavior for querying a non-IPP uri is undefined and disallowed.
if (!IsIppUri(printer_uri) || !optional.has_value()) {
- LOG(WARNING) << "Printer uri is invalid: " << printer_uri;
+ PRINTER_LOG(ERROR) << "Printer uri is invalid: " << printer_uri;
callback.Run(false, "", "", "", false);
return;
}
@@ -103,6 +112,21 @@ void QueryAutoconf(const std::string& printer_uri,
callback);
}
+// Returns the list of |printers| formatted as a CupsPrintersList.
+base::Value BuildCupsPrintersList(const std::vector<Printer>& printers) {
+ base::Value printers_list(base::Value::Type::LIST);
+ for (const Printer& printer : printers) {
+ // Some of these printers could be invalid but we want to allow the user
+ // to edit them. crbug.com/778383
+ printers_list.GetList().push_back(
+ base::Value::FromUniquePtrValue(GetCupsPrinterInfo(printer)));
+ }
+
+ base::Value response(base::Value::Type::DICTIONARY);
+ response.SetKey("printerList", std::move(printers_list));
+ return response;
+}
+
// Extracts a sanitized value of printerQueue from |printer_dict|. Returns an
// empty string if the value was not present in the dictionary.
std::string GetPrinterQueue(const base::DictionaryValue& printer_dict) {
@@ -174,16 +198,34 @@ std::string ReadFileToStringWithMaxSize(const base::FilePath& path,
return contents;
}
+// Determines whether changing the URI in |existing_printer| to the URI in
+// |new_printer| would be valid. Network printers are not allowed to change
+// their protocol to a non-network protocol, but can change anything else.
+// Non-network printers are not allowed to change anything in their URI.
+bool IsValidUriChange(const Printer& existing_printer,
+ const Printer& new_printer) {
+ if (new_printer.GetProtocol() == Printer::PrinterProtocol::kUnknown) {
+ return false;
+ }
+ if (existing_printer.HasNetworkProtocol()) {
+ return new_printer.HasNetworkProtocol();
+ }
+ return existing_printer.uri() == new_printer.uri();
+}
+
} // namespace
CupsPrintersHandler::CupsPrintersHandler(content::WebUI* webui)
: profile_(Profile::FromWebUI(webui)),
ppd_provider_(CreatePpdProvider(profile_)),
printer_configurer_(PrinterConfigurer::Create(profile_)),
- printers_manager_(CupsPrintersManager::Create(profile_)),
+ printers_manager_(
+ CupsPrintersManagerFactory::GetInstance()->GetForBrowserContext(
+ profile_)),
+ printers_manager_observer_(this),
weak_factory_(this) {}
-CupsPrintersHandler::~CupsPrintersHandler() {}
+CupsPrintersHandler::~CupsPrintersHandler() = default;
void CupsPrintersHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
@@ -243,11 +285,13 @@ void CupsPrintersHandler::RegisterMessages() {
}
void CupsPrintersHandler::OnJavascriptAllowed() {
- printers_manager_->AddObserver(this);
+ if (!printers_manager_observer_.IsObservingSources()) {
+ printers_manager_observer_.Add(printers_manager_);
+ }
}
void CupsPrintersHandler::OnJavascriptDisallowed() {
- printers_manager_->RemoveObserver(this);
+ printers_manager_observer_.RemoveAll();
}
void CupsPrintersHandler::HandleGetCupsPrintersList(
@@ -261,16 +305,8 @@ void CupsPrintersHandler::HandleGetCupsPrintersList(
std::vector<Printer> printers =
printers_manager_->GetPrinters(CupsPrintersManager::kConfigured);
- auto printers_list = std::make_unique<base::ListValue>();
- for (const Printer& printer : printers) {
- // Some of these printers could be invalid but we want to allow the user
- // to edit them. crbug.com/778383
- printers_list->Append(GetCupsPrinterInfo(printer));
- }
-
- auto response = std::make_unique<base::DictionaryValue>();
- response->Set("printerList", std::move(printers_list));
- ResolveJavascriptCallback(base::Value(callback_id), *response);
+ auto response = BuildCupsPrintersList(printers);
+ ResolveJavascriptCallback(base::Value(callback_id), response);
}
void CupsPrintersHandler::HandleUpdateCupsPrinter(const base::ListValue* args) {
@@ -281,6 +317,19 @@ void CupsPrintersHandler::HandleUpdateCupsPrinter(const base::ListValue* args) {
Printer printer(printer_id);
printer.set_display_name(printer_name);
+
+ if (!profile_->GetPrefs()->GetBoolean(prefs::kUserNativePrintersAllowed)) {
+ PRINTER_LOG(DEBUG) << "HandleAddCupsPrinter() called when "
+ "kUserNativePrintersAllowed is set to false";
+ // Used to log UMA metrics.
+ OnAddedPrinterCommon(printer,
+ PrinterSetupResult::kNativePrintersNotAllowed);
+ // Used to fire the web UI listener.
+ OnAddPrinterError(PrinterSetupResult::kNativePrintersNotAllowed);
+ return;
+ }
+
+ PRINTER_LOG(USER) << "Comitting printer update";
printers_manager_->UpdateConfiguredPrinter(printer);
// TODO(xdai): Replace "on-add-cups-printer" callback with Promise resolve
@@ -290,6 +339,7 @@ void CupsPrintersHandler::HandleUpdateCupsPrinter(const base::ListValue* args) {
}
void CupsPrintersHandler::HandleRemoveCupsPrinter(const base::ListValue* args) {
+ PRINTER_LOG(USER) << "Removing printer";
std::string printer_id;
std::string printer_name;
CHECK(args->GetString(0, &printer_id));
@@ -349,6 +399,7 @@ void CupsPrintersHandler::HandleGetPrinterInfo(const base::ListValue* args) {
DCHECK(printer_protocol == kIppScheme || printer_protocol == kIppsScheme)
<< "Printer info requests only supported for IPP and IPPS printers";
+ PRINTER_LOG(DEBUG) << "Querying printer info";
std::string printer_uri =
base::StringPrintf("%s://%s/%s", printer_protocol.c_str(),
printer_address.c_str(), printer_queue.c_str());
@@ -377,10 +428,13 @@ void CupsPrintersHandler::OnAutoconfQueriedDiscovered(
printer->set_manufacturer(make);
printer->set_model(model);
printer->set_make_and_model(make_and_model);
+ PRINTER_LOG(DEBUG) << "Printer queried for make and model "
+ << make_and_model;
}
// Autoconfig available, use it.
if (ipp_everywhere) {
+ PRINTER_LOG(DEBUG) << "Performing autoconf setup";
printer->mutable_ppd_reference()->autoconf = true;
printer_configurer_->SetUpPrinter(
*printer, base::Bind(&CupsPrintersHandler::OnAddedDiscoveredPrinter,
@@ -392,8 +446,8 @@ void CupsPrintersHandler::OnAutoconfQueriedDiscovered(
// We don't have enough from discovery to configure the printer. Fill in as
// much information as we can about the printer, and ask the user to supply
// the rest.
- FireWebUIListener("on-manually-add-discovered-printer",
- *GetCupsPrinterInfo(*printer));
+ PRINTER_LOG(EVENT) << "Could not query printer. Fallback to asking the user";
+ FireManuallyAddDiscoveredPrinter(*printer);
}
void CupsPrintersHandler::OnAutoconfQueried(const std::string& callback_id,
@@ -405,12 +459,16 @@ void CupsPrintersHandler::OnAutoconfQueried(const std::string& callback_id,
RecordIppQuerySuccess(success);
if (!success) {
+ PRINTER_LOG(DEBUG) << "Could not query printer";
base::DictionaryValue reject;
reject.SetString("message", "Querying printer failed");
RejectJavascriptCallback(base::Value(callback_id), reject);
return;
}
+ PRINTER_LOG(DEBUG) << "Resolved printer information: make_and_model("
+ << make_and_model << ") autoconf(" << ipp_everywhere
+ << ")";
base::DictionaryValue info;
info.SetString("manufacturer", make);
info.SetString("model", model);
@@ -427,20 +485,45 @@ void CupsPrintersHandler::HandleAddCupsPrinter(const base::ListValue* args) {
std::unique_ptr<Printer> printer = DictToPrinter(*printer_dict);
if (!printer) {
- LOG(ERROR) << "Failed to parse printer URI";
+ PRINTER_LOG(ERROR) << "Failed to parse printer URI";
OnAddPrinterError(PrinterSetupResult::kFatalError);
return;
}
+ if (!profile_->GetPrefs()->GetBoolean(prefs::kUserNativePrintersAllowed)) {
+ PRINTER_LOG(DEBUG) << "HandleAddCupsPrinter() called when "
+ "kUserNativePrintersAllowed is set to false";
+ // Used to log UMA metrics.
+ OnAddedPrinterCommon(*printer,
+ PrinterSetupResult::kNativePrintersNotAllowed);
+ // Used to fire the web UI listener.
+ OnAddPrinterError(PrinterSetupResult::kNativePrintersNotAllowed);
+ return;
+ }
+
auto optional = printer->GetUriComponents();
if (!optional.has_value()) {
// If the returned optional does not contain a value then it means that the
// printer's uri was not able to be parsed successfully.
- LOG(ERROR) << "Failed to parse printer URI";
+ PRINTER_LOG(ERROR) << "Failed to parse printer URI";
OnAddPrinterError(PrinterSetupResult::kFatalError);
return;
}
+ // If the provided printer already exists, grab the existing printer object
+ // and check that we are not making any changes that will make the printer
+ // unusable.
+ if (!printer->id().empty()) {
+ std::unique_ptr<Printer> existing_printer =
+ printers_manager_->GetPrinter(printer->id());
+ if (existing_printer) {
+ if (!IsValidUriChange(*existing_printer, *printer)) {
+ OnAddPrinterError(PrinterSetupResult::kInvalidPrinterUpdate);
+ return;
+ }
+ }
+ }
+
// Read PPD selection if it was used.
std::string ppd_manufacturer;
std::string ppd_model;
@@ -493,8 +576,8 @@ void CupsPrintersHandler::HandleAddCupsPrinter(const base::ListValue* args) {
printer->set_make_and_model(ppd_model);
}
} else {
- // TODO(crbug.com/738514): Support PPD guessing for non-autoconf printers.
- // i.e. !autoconf && !manufacturer.empty() && !model.empty()
+ // TODO(https://crbug.com/738514): Support PPD guessing for non-autoconf
+ // printers. i.e. !autoconf && !manufacturer.empty() && !model.empty()
NOTREACHED()
<< "A configuration option must have been selected to add a printer";
}
@@ -512,27 +595,39 @@ void CupsPrintersHandler::OnAddedPrinterCommon(const Printer& printer,
case PrinterSetupResult::kSuccess:
UMA_HISTOGRAM_ENUMERATION("Printing.CUPS.PrinterAdded",
printer.GetProtocol(), Printer::kProtocolMax);
+ PRINTER_LOG(USER) << "Performing printer setup";
printers_manager_->PrinterInstalled(printer);
printers_manager_->UpdateConfiguredPrinter(printer);
return;
case PrinterSetupResult::kPpdNotFound:
- LOG(WARNING) << "Could not locate requested PPD";
+ PRINTER_LOG(ERROR) << "Could not locate requested PPD";
break;
case PrinterSetupResult::kPpdTooLarge:
- LOG(WARNING) << "PPD is too large";
+ PRINTER_LOG(ERROR) << "PPD is too large";
break;
case PrinterSetupResult::kPpdUnretrievable:
- LOG(WARNING) << "Could not retrieve PPD from server";
+ PRINTER_LOG(ERROR) << "Could not retrieve PPD from server";
break;
case PrinterSetupResult::kInvalidPpd:
- LOG(WARNING) << "Provided PPD is invalid.";
+ PRINTER_LOG(ERROR) << "Provided PPD is invalid.";
break;
case PrinterSetupResult::kPrinterUnreachable:
- LOG(WARNING) << "Could not contact printer for configuration";
+ PRINTER_LOG(ERROR) << "Could not contact printer for configuration";
+ break;
+ case PrinterSetupResult::kComponentUnavailable:
+ LOG(WARNING) << "Could not install component";
break;
case PrinterSetupResult::kDbusError:
case PrinterSetupResult::kFatalError:
- LOG(ERROR) << "Unrecoverable error. Reboot required.";
+ PRINTER_LOG(ERROR) << "Unrecoverable error. Reboot required.";
+ break;
+ case PrinterSetupResult::kNativePrintersNotAllowed:
+ PRINTER_LOG(ERROR)
+ << "Unable to add or edit printer due to enterprise policy.";
+ break;
+ case PrinterSetupResult::kInvalidPrinterUpdate:
+ PRINTER_LOG(ERROR)
+ << "Requested printer changes would make printer unusable";
break;
case PrinterSetupResult::kMaxValue:
NOTREACHED() << "This is not an expected value";
@@ -551,21 +646,24 @@ void CupsPrintersHandler::OnAddedDiscoveredPrinter(
FireWebUIListener("on-add-cups-printer", base::Value(result_code),
base::Value(printer.display_name()));
} else {
- FireWebUIListener("on-manually-add-discovered-printer",
- base::Value(result_code == PrinterSetupResult::kSuccess),
- base::Value(printer.display_name()));
+ PRINTER_LOG(EVENT) << "Automatic setup failed for discovered printer. "
+ "Fall back to manual.";
+ // Could not set up printer. Asking user for manufacturer data.
+ FireManuallyAddDiscoveredPrinter(printer);
}
}
void CupsPrintersHandler::OnAddedSpecifiedPrinter(
const Printer& printer,
PrinterSetupResult result_code) {
+ PRINTER_LOG(EVENT) << "Add manual printer: " << result_code;
OnAddedPrinterCommon(printer, result_code);
FireWebUIListener("on-add-cups-printer", base::Value(result_code),
base::Value(printer.display_name()));
}
void CupsPrintersHandler::OnAddPrinterError(PrinterSetupResult result_code) {
+ PRINTER_LOG(EVENT) << "Add printer error: " << result_code;
FireWebUIListener("on-add-cups-printer", base::Value(result_code),
base::Value(""));
}
@@ -687,6 +785,7 @@ void CupsPrintersHandler::VerifyPpdContents(const base::FilePath& path,
}
void CupsPrintersHandler::HandleStartDiscovery(const base::ListValue* args) {
+ PRINTER_LOG(DEBUG) << "Start printer discovery";
discovery_active_ = true;
OnPrintersChanged(
CupsPrintersManager::kAutomatic,
@@ -697,9 +796,12 @@ void CupsPrintersHandler::HandleStartDiscovery(const base::ListValue* args) {
UMA_HISTOGRAM_COUNTS_100(
"Printing.CUPS.PrintersDiscovered",
discovered_printers_.size() + automatic_printers_.size());
+ // Scan completes immediately right now. Emit done.
+ FireWebUIListener("on-printer-discovery-done");
}
void CupsPrintersHandler::HandleStopDiscovery(const base::ListValue* args) {
+ PRINTER_LOG(DEBUG) << "Stop printer discovery";
discovered_printers_.clear();
automatic_printers_.clear();
@@ -710,6 +812,7 @@ void CupsPrintersHandler::HandleStopDiscovery(const base::ListValue* args) {
}
void CupsPrintersHandler::HandleSetUpCancel(const base::ListValue* args) {
+ PRINTER_LOG(DEBUG) << "Printer setup cancelled";
const base::DictionaryValue* printer_dict;
CHECK(args->GetDictionary(0, &printer_dict));
@@ -722,20 +825,32 @@ void CupsPrintersHandler::HandleSetUpCancel(const base::ListValue* args) {
void CupsPrintersHandler::OnPrintersChanged(
CupsPrintersManager::PrinterClass printer_class,
const std::vector<Printer>& printers) {
- if (!discovery_active_) {
- return;
- }
switch (printer_class) {
case CupsPrintersManager::kAutomatic:
automatic_printers_ = printers;
+ UpdateDiscoveredPrinters();
break;
case CupsPrintersManager::kDiscovered:
discovered_printers_ = printers;
+ UpdateDiscoveredPrinters();
+ break;
+ case CupsPrintersManager::kConfigured: {
+ auto printers_list = BuildCupsPrintersList(printers);
+ FireWebUIListener("on-printers-changed", printers_list);
break;
- default:
- // It's a class we don't care about.
+ }
+ case CupsPrintersManager::kEnterprise:
+ case CupsPrintersManager::kNumPrinterClasses:
+ // These classes are not shown.
return;
}
+}
+
+void CupsPrintersHandler::UpdateDiscoveredPrinters() {
+ if (!discovery_active_) {
+ return;
+ }
+
std::unique_ptr<base::ListValue> printers_list =
std::make_unique<base::ListValue>();
for (const Printer& printer : automatic_printers_) {
@@ -746,7 +861,6 @@ void CupsPrintersHandler::OnPrintersChanged(
}
FireWebUIListener("on-printer-discovered", *printers_list);
- FireWebUIListener("on-printer-discovery-done");
}
void CupsPrintersHandler::HandleAddDiscoveredPrinter(
@@ -756,8 +870,10 @@ void CupsPrintersHandler::HandleAddDiscoveredPrinter(
std::string printer_id;
CHECK(args->GetString(0, &printer_id));
+ PRINTER_LOG(USER) << "Adding discovered printer";
std::unique_ptr<Printer> printer = printers_manager_->GetPrinter(printer_id);
if (printer == nullptr) {
+ PRINTER_LOG(ERROR) << "Discovered printer disappeared";
// Printer disappeared, so we don't have information about it anymore and
// can't really do much. Fail the add.
FireWebUIListener("on-add-cups-printer", base::Value(false),
@@ -767,6 +883,7 @@ void CupsPrintersHandler::HandleAddDiscoveredPrinter(
auto optional = printer->GetUriComponents();
if (!optional.has_value()) {
+ PRINTER_LOG(DEBUG) << "Could not parse uri";
// The printer uri was not parsed successfully. Fail the add.
FireWebUIListener("on-add-cups-printer", base::Value(false),
base::Value(printer_id));
@@ -776,6 +893,7 @@ void CupsPrintersHandler::HandleAddDiscoveredPrinter(
if (printer->ppd_reference().autoconf ||
!printer->ppd_reference().effective_make_and_model.empty() ||
!printer->ppd_reference().user_supplied_ppd_url.empty()) {
+ PRINTER_LOG(EVENT) << "Start setup of discovered printer";
// If we have something that looks like a ppd reference for this printer,
// try to configure it.
printer_configurer_->SetUpPrinter(
@@ -788,14 +906,15 @@ void CupsPrintersHandler::HandleAddDiscoveredPrinter(
// see if we want to try IPP.
const std::string printer_uri = printer->effective_uri();
if (IsIppUri(printer_uri)) {
+ PRINTER_LOG(EVENT) << "Query printer for IPP attributes";
QueryAutoconf(
printer_uri,
base::Bind(&CupsPrintersHandler::OnAutoconfQueriedDiscovered,
weak_factory_.GetWeakPtr(), base::Passed(&printer)));
} else {
+ PRINTER_LOG(EVENT) << "Request make and model from user";
// If it's not an IPP printer, the user must choose a PPD.
- FireWebUIListener("on-manually-add-discovered-printer",
- *GetCupsPrinterInfo(*printer));
+ FireManuallyAddDiscoveredPrinter(*printer);
}
}
@@ -835,5 +954,11 @@ void CupsPrintersHandler::OnGetPrinterPpdManufacturerAndModel(
ResolveJavascriptCallback(base::Value(callback_id), info);
}
+void CupsPrintersHandler::FireManuallyAddDiscoveredPrinter(
+ const Printer& printer) {
+ FireWebUIListener("on-manually-add-discovered-printer",
+ *GetCupsPrinterInfo(printer));
+}
+
} // namespace settings
} // namespace chromeos
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h
index 0f9452af13e..447eecb1d69 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h
@@ -12,6 +12,7 @@
#include "base/files/file_path.h"
#include "base/memory/weak_ptr.h"
+#include "base/scoped_observer.h"
#include "chrome/browser/chromeos/printing/cups_printers_manager.h"
#include "chrome/browser/chromeos/printing/printer_configurer.h"
#include "chrome/browser/chromeos/printing/printer_event_tracker.h"
@@ -125,6 +126,9 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler,
const std::string& manufacturer,
const std::string& model);
+ // Emits the updated discovered printer list after new printers are received.
+ void UpdateDiscoveredPrinters();
+
// Attempt to add a discovered printer.
void HandleAddDiscoveredPrinter(const base::ListValue* args);
@@ -152,6 +156,10 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler,
void VerifyPpdContents(const base::FilePath& path,
const std::string& contents);
+ // Fires the on-manually-add-discovered-printer event with the appropriate
+ // parameters. See https://crbug.com/835476
+ void FireManuallyAddDiscoveredPrinter(const Printer& printer);
+
Profile* profile_;
// Discovery support. discovery_active_ tracks whether or not the UI
@@ -174,7 +182,10 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler,
scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
std::string webui_callback_id_;
- std::unique_ptr<CupsPrintersManager> printers_manager_;
+ CupsPrintersManager* printers_manager_;
+
+ ScopedObserver<CupsPrintersManager, CupsPrintersManager::Observer>
+ printers_manager_observer_;
base::WeakPtrFactory<CupsPrintersHandler> weak_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 59a3f7f004d..a54f351b8b7 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
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/values.h"
+#include "chrome/browser/ui/ash/tablet_mode_client.h"
#include "chromeos/chromeos_switches.h"
#include "content/public/browser/web_ui.h"
#include "content/public/common/service_manager_connection.h"
@@ -52,6 +53,10 @@ void KeyboardHandler::RegisterMessages() {
"showKeyboardShortcutsOverlay",
base::BindRepeating(&KeyboardHandler::HandleShowKeyboardShortcutsOverlay,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "initializeKeyboardWatcher",
+ base::BindRepeating(&KeyboardHandler::HandleKeyboardChange,
+ base::Unretained(this)));
}
void KeyboardHandler::OnJavascriptAllowed() {
@@ -63,12 +68,15 @@ void KeyboardHandler::OnJavascriptDisallowed() {
}
void KeyboardHandler::OnKeyboardDeviceConfigurationChanged() {
+ AllowJavascript();
UpdateShowKeys();
+ UpdateKeyboards();
}
void KeyboardHandler::HandleInitialize(const base::ListValue* args) {
AllowJavascript();
UpdateShowKeys();
+ UpdateKeyboards();
}
void KeyboardHandler::HandleShowKeyboardShortcutsOverlay(
@@ -80,6 +88,30 @@ void KeyboardHandler::HandleShowKeyboardShortcutsOverlay(
new_window_controller->ShowKeyboardOverlay();
}
+void KeyboardHandler::HandleKeyboardChange(const base::ListValue* args) {
+ AllowJavascript();
+ UpdateKeyboards();
+}
+
+void KeyboardHandler::UpdateKeyboards() {
+ bool physical_keyboard = false;
+ // In tablet mode, physical keybards are disabled / ignored.
+ if (!TabletModeClient::Get() ||
+ !TabletModeClient::Get()->tablet_mode_enabled()) {
+ physical_keyboard = true;
+ }
+ if (!physical_keyboard) {
+ for (const ui::InputDevice& keyboard :
+ ui::InputDeviceManager::GetInstance()->GetKeyboardDevices()) {
+ if (keyboard.type != ui::InputDeviceType::INPUT_DEVICE_INTERNAL) {
+ physical_keyboard = true;
+ break;
+ }
+ }
+ }
+ FireWebUIListener("has-hardware-keyboard", base::Value(physical_keyboard));
+}
+
void KeyboardHandler::UpdateShowKeys() {
// kHasChromeOSKeyboard will be unset on Chromebooks that have standalone Caps
// Lock keys.
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h
index d1afe730e6d..be8f0ae6e0b 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h
@@ -61,10 +61,16 @@ class KeyboardHandler
// Shows the Ash keyboard shortcuts overlay.
void HandleShowKeyboardShortcutsOverlay(const base::ListValue* args) const;
+ // Determines what types of keyboards are attached.
+ void HandleKeyboardChange(const base::ListValue* args);
+
// Shows or hides the Caps Lock and Diamond key settings based on whether the
// system status.
void UpdateShowKeys();
+ // Sends the UI a message about whether hardware keyboard are attached.
+ void UpdateKeyboards();
+
ScopedObserver<ui::InputDeviceManager, KeyboardHandler> observer_;
DISALLOW_COPY_AND_ASSIGN(KeyboardHandler);
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 38957b75449..c11fa3d9e8b 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
@@ -8,6 +8,7 @@
#include <utility>
#include "ash/public/cpp/ash_pref_names.h"
+#include "ash/public/cpp/power_utils.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/strings/string_number_conversions.h"
@@ -16,6 +17,7 @@
#include "base/values.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/dbus/power_manager/power_supply_properties.pb.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_ui.h"
@@ -30,7 +32,7 @@ namespace {
base::string16 GetBatteryTimeText(base::TimeDelta time_left) {
int hour = 0;
int min = 0;
- ash::PowerStatus::SplitTimeIntoHoursAndMinutes(time_left, &hour, &min);
+ ash::power_utils::SplitTimeIntoHoursAndMinutes(time_left, &hour, &min);
base::string16 time_text;
if (hour == 0 || min == 0) {
@@ -79,11 +81,8 @@ void PowerHandler::TestAPI::SetLidClosedBehavior(
PowerHandler::PowerHandler(PrefService* prefs)
: prefs_(prefs),
- power_status_observer_(this),
power_manager_client_observer_(this),
- weak_ptr_factory_(this) {
- power_status_ = ash::PowerStatus::Get();
-}
+ weak_ptr_factory_(this) {}
PowerHandler::~PowerHandler() {}
@@ -110,8 +109,6 @@ void PowerHandler::RegisterMessages() {
}
void PowerHandler::OnJavascriptAllowed() {
- power_status_observer_.Add(power_status_);
-
PowerManagerClient* power_manager_client =
DBusThreadManager::Get()->GetPowerManagerClient();
power_manager_client_observer_.Add(power_manager_client);
@@ -138,12 +135,12 @@ void PowerHandler::OnJavascriptAllowed() {
}
void PowerHandler::OnJavascriptDisallowed() {
- power_status_observer_.RemoveAll();
power_manager_client_observer_.RemoveAll();
pref_change_registrar_.reset();
}
-void PowerHandler::OnPowerStatusChanged() {
+void PowerHandler::PowerChanged(
+ const power_manager::PowerSupplyProperties& proto) {
SendBatteryStatus();
SendPowerSources();
}
@@ -162,7 +159,9 @@ void PowerHandler::LidEventReceived(PowerManagerClient::LidState state,
void PowerHandler::HandleUpdatePowerStatus(const base::ListValue* args) {
AllowJavascript();
- power_status_->RequestStatusUpdate();
+ chromeos::DBusThreadManager::Get()
+ ->GetPowerManagerClient()
+ ->RequestStatusUpdate();
}
void PowerHandler::HandleSetPowerSource(const base::ListValue* args) {
@@ -170,7 +169,8 @@ void PowerHandler::HandleSetPowerSource(const base::ListValue* args) {
std::string id;
CHECK(args->GetString(0, &id));
- power_status_->SetPowerSource(id);
+ chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->SetPowerSource(
+ id);
}
void PowerHandler::HandleRequestPowerManagementSettings(
@@ -249,16 +249,22 @@ void PowerHandler::HandleSetLidClosedBehavior(const base::ListValue* args) {
}
void PowerHandler::SendBatteryStatus() {
- bool charging = power_status_->IsBatteryCharging();
- bool calculating = power_status_->IsBatteryTimeBeingCalculated();
- int percent = power_status_->GetRoundedBatteryPercent();
+ const base::Optional<power_manager::PowerSupplyProperties>& proto =
+ DBusThreadManager::Get()->GetPowerManagerClient()->GetLastStatus();
+ DCHECK(proto);
+ bool charging = proto->battery_state() ==
+ power_manager::PowerSupplyProperties_BatteryState_CHARGING;
+ bool calculating = proto->is_calculating_battery_time();
+ int percent =
+ ash::power_utils::GetRoundedBatteryPercent(proto->battery_percent());
base::TimeDelta time_left;
bool show_time = false;
if (!calculating) {
- time_left = charging ? power_status_->GetBatteryTimeToFull()
- : power_status_->GetBatteryTimeToEmpty();
- show_time = ash::PowerStatus::ShouldDisplayBatteryTime(time_left);
+ time_left = base::TimeDelta::FromSeconds(
+ charging ? proto->battery_time_to_full_sec()
+ : proto->battery_time_to_empty_sec());
+ show_time = ash::power_utils::ShouldDisplayBatteryTime(time_left);
}
base::string16 status_text;
@@ -273,7 +279,10 @@ void PowerHandler::SendBatteryStatus() {
}
base::DictionaryValue battery_dict;
- battery_dict.SetBoolean("present", power_status_->IsBatteryPresent());
+ battery_dict.SetBoolean(
+ "present",
+ proto->battery_state() !=
+ power_manager::PowerSupplyProperties_BatteryState_NOT_PRESENT);
battery_dict.SetBoolean("charging", charging);
battery_dict.SetBoolean("calculating", calculating);
battery_dict.SetInteger("percent", percent);
@@ -283,19 +292,25 @@ void PowerHandler::SendBatteryStatus() {
}
void PowerHandler::SendPowerSources() {
+ const base::Optional<power_manager::PowerSupplyProperties>& proto =
+ DBusThreadManager::Get()->GetPowerManagerClient()->GetLastStatus();
+ DCHECK(proto);
base::ListValue sources_list;
- for (const auto& source : power_status_->GetPowerSources()) {
+ for (int i = 0; i < proto->available_external_power_source_size(); i++) {
+ const auto& source = proto->available_external_power_source(i);
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
- dict->SetString("id", source.id);
- dict->SetInteger("type", source.type);
+ dict->SetString("id", source.id());
+ dict->SetBoolean("is_dedicated_charger", source.active_by_default());
dict->SetString("description",
- l10n_util::GetStringUTF16(source.description_id));
+ ash::power_utils::PowerSourceToDisplayString(source));
sources_list.Append(std::move(dict));
}
- FireWebUIListener("power-sources-changed", sources_list,
- base::Value(power_status_->GetCurrentPowerSourceID()),
- base::Value(power_status_->IsUsbChargerConnected()));
+ FireWebUIListener(
+ "power-sources-changed", sources_list,
+ base::Value(proto->external_power_source_id()),
+ base::Value(proto->external_power() ==
+ power_manager::PowerSupplyProperties_ExternalPower_USB));
}
void PowerHandler::SendPowerManagementSettings(bool force) {
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h
index b30b3f2f14c..5344ee81b74 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/device_power_handler.h
@@ -7,7 +7,6 @@
#include <memory>
-#include "ash/system/power/power_status.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
@@ -30,7 +29,6 @@ namespace settings {
// Chrome OS battery status and power settings handler.
class PowerHandler : public ::settings::SettingsPageUIHandler,
- public ash::PowerStatus::Observer,
public PowerManagerClient::Observer {
public:
// Idle behaviors presented in the UI. These are mapped to preferences by
@@ -75,10 +73,8 @@ class PowerHandler : public ::settings::SettingsPageUIHandler,
void OnJavascriptAllowed() override;
void OnJavascriptDisallowed() override;
- // ash::PowerStatus::Observer implementation.
- void OnPowerStatusChanged() override;
-
// PowerManagerClient implementation.
+ void PowerChanged(const power_manager::PowerSupplyProperties& proto) override;
void PowerManagerRestarted() override;
void LidEventReceived(PowerManagerClient::LidState state,
const base::TimeTicks& timestamp) override;
@@ -114,12 +110,10 @@ class PowerHandler : public ::settings::SettingsPageUIHandler,
base::Optional<PowerManagerClient::SwitchStates> result);
PrefService* prefs_; // Not owned.
- ash::PowerStatus* power_status_; // Not owned.
// Used to watch power management prefs for changes so the UI can be notified.
std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
- ScopedObserver<ash::PowerStatus, PowerHandler> power_status_observer_;
ScopedObserver<PowerManagerClient, PowerHandler>
power_manager_client_observer_;
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 ea6babfcfad..287e99313d6 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
@@ -60,7 +60,6 @@ class FakeEasyUnlockService : public EasyUnlockService {
const base::ListValue* GetRemoteDevices() const override { return nullptr; }
void SetRemoteDevices(const base::ListValue& devices) override {}
- void SetRemoteBleDevices(const base::ListValue& devices) override {}
std::string GetChallenge() const override { return std::string(); }
std::string GetWrappedSecret() const override { return std::string(); }
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc b/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc
index bd4ef59c956..95fdc49d9a7 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc
@@ -31,7 +31,7 @@ namespace settings {
namespace {
// The max number of fingerprints that can be stored.
-const int kMaxAllowedFingerprints = 5;
+constexpr int kMaxAllowedFingerprints = 3;
std::unique_ptr<base::DictionaryValue> GetFingerprintsInfo(
const std::vector<std::string>& fingerprints_list) {
@@ -133,7 +133,7 @@ void FingerprintHandler::OnEnrollScanDone(uint32_t scan_result,
void FingerprintHandler::OnAuthScanDone(
uint32_t scan_result,
- const std::unordered_map<std::string, std::vector<std::string>>& matches) {
+ const base::flat_map<std::string, std::vector<std::string>>& matches) {
if (SessionManager::Get()->session_state() == SessionState::LOCKED)
return;
@@ -183,8 +183,7 @@ void FingerprintHandler::HandleGetFingerprintsList(
void FingerprintHandler::OnGetFingerprintsList(
const std::string& callback_id,
- const std::unordered_map<std::string, std::string>&
- fingerprints_list_mapping) {
+ const base::flat_map<std::string, std::string>& fingerprints_list_mapping) {
fingerprints_labels_.clear();
fingerprints_paths_.clear();
for (auto it = fingerprints_list_mapping.begin();
diff --git a/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h b/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h
index f63ea22d163..d3518f18970 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h
@@ -5,8 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_FINGERPRINT_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_FINGERPRINT_HANDLER_H_
-#include <unordered_map>
-
+#include "base/containers/flat_map.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
#include "components/session_manager/core/session_manager_observer.h"
#include "mojo/public/cpp/bindings/binding.h"
@@ -35,16 +34,15 @@ class FingerprintHandler : public ::settings::SettingsPageUIHandler,
void OnJavascriptDisallowed() override;
private:
- using AttemptMatches =
- std::unordered_map<std::string, std::vector<std::string>>;
-
// device::mojom::FingerprintObserver:
void OnRestarted() override;
void OnEnrollScanDone(uint32_t scan_result,
bool enroll_session_complete,
int percent_complete) override;
- void OnAuthScanDone(uint32_t scan_result,
- const AttemptMatches& matches) override;
+ void OnAuthScanDone(
+ uint32_t scan_result,
+ const base::flat_map<std::string, std::vector<std::string>>& matches)
+ override;
void OnSessionFailed() override;
// session_manager::SessionManagerObserver:
@@ -61,7 +59,7 @@ class FingerprintHandler : public ::settings::SettingsPageUIHandler,
void HandleEndCurrentAuthentication(const base::ListValue* args);
void OnGetFingerprintsList(const std::string& callback_id,
- const std::unordered_map<std::string, std::string>&
+ const base::flat_map<std::string, std::string>&
fingerprints_list_mapping);
void OnRequestRecordLabel(const std::string& callback_id,
const std::string& label);
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 5c6c73a6477..2b3ef9136d0 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.cc
@@ -10,19 +10,14 @@
#include "base/bind.h"
#include "base/values.h"
#include "chrome/browser/chromeos/file_system_provider/provided_file_system_info.h"
-#include "chrome/browser/chromeos/smb_client/smb_service.h"
#include "chrome/browser/profiles/profile.h"
-
-namespace {
-void DoNothingCallback(base::File::Error error) {
- return;
-}
-} // namespace
+#include "content/public/browser/web_ui_message_handler.h"
namespace chromeos {
namespace settings {
-SmbHandler::SmbHandler(Profile* profile) : profile_(profile) {}
+SmbHandler::SmbHandler(Profile* profile)
+ : profile_(profile), weak_ptr_factory_(this) {}
SmbHandler::~SmbHandler() = default;
@@ -33,9 +28,13 @@ void SmbHandler::RegisterMessages() {
}
void SmbHandler::HandleSmbMount(const base::ListValue* args) {
- CHECK_EQ(1U, args->GetSize());
+ CHECK_EQ(3U, args->GetSize());
std::string mountUrl;
+ std::string username;
+ std::string password;
CHECK(args->GetString(0, &mountUrl));
+ CHECK(args->GetString(1, &username));
+ CHECK(args->GetString(2, &password));
chromeos::smb_client::SmbService* const service =
chromeos::smb_client::SmbService::Get(profile_);
@@ -44,8 +43,14 @@ void SmbHandler::HandleSmbMount(const base::ListValue* args) {
mo.display_name = mountUrl;
mo.writable = true;
- service->Mount(mo, base::FilePath(mountUrl),
- base::BindOnce(&DoNothingCallback));
+ service->Mount(mo, base::FilePath(mountUrl), username, password,
+ base::BindOnce(&SmbHandler::HandleSmbMountResponse,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+void SmbHandler::HandleSmbMountResponse(SmbMountResult result) {
+ AllowJavascript();
+ FireWebUIListener("on-add-smb-share", base::Value(result));
}
} // namespace settings
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 fc7e14637c4..315a302f144 100644
--- a/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/chromeos/smb_handler.h
@@ -5,7 +5,10 @@
#ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SMB_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_SETTINGS_CHROMEOS_SMB_HANDLER_H_
+#include "base/files/file.h"
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/chromeos/smb_client/smb_service.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
class Profile;
@@ -13,6 +16,8 @@ class Profile;
namespace chromeos {
namespace settings {
+using smb_client::SmbMountResult;
+
class SmbHandler : public ::settings::SettingsPageUIHandler {
public:
explicit SmbHandler(Profile* profile);
@@ -26,7 +31,11 @@ class SmbHandler : public ::settings::SettingsPageUIHandler {
// WebUI call to mount an Smb Filesystem.
void HandleSmbMount(const base::ListValue* args);
+ // Callback handler for SmbMount.
+ void HandleSmbMountResponse(SmbMountResult result);
+
Profile* const profile_;
+ base::WeakPtrFactory<SmbHandler> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(SmbHandler);
};
diff --git a/chromium/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.cc b/chromium/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.cc
index 4772084b860..16bed8786c6 100644
--- a/chromium/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.cc
+++ b/chromium/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.cc
@@ -15,7 +15,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "base/win/registry.h"
-#include "chrome/browser/conflicts/problematic_programs_updater_win.h"
+#include "chrome/browser/conflicts/incompatible_applications_updater_win.h"
#include "chrome/browser/conflicts/registry_key_watcher_win.h"
#include "chrome/browser/conflicts/uninstall_application_win.h"
#include "chrome/grit/generated_resources.h"
@@ -34,10 +34,10 @@ void IncompatibleApplicationsHandler::RegisterMessages() {
HandleRequestIncompatibleApplicationsList,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
- "startProgramUninstallation",
- base::BindRepeating(
- &IncompatibleApplicationsHandler::HandleStartProgramUninstallation,
- base::Unretained(this)));
+ "startApplicationUninstallation",
+ base::BindRepeating(&IncompatibleApplicationsHandler::
+ HandleStartApplicationUninstallation,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"getSubtitlePluralString",
base::BindRepeating(
@@ -71,54 +71,58 @@ void IncompatibleApplicationsHandler::HandleRequestIncompatibleApplicationsList(
// requestIncompatibleApplicationsList().
registry_key_watchers_.clear();
- std::vector<ProblematicProgramsUpdater::ProblematicProgram>
- problematic_programs = ProblematicProgramsUpdater::GetCachedPrograms();
+ std::vector<IncompatibleApplicationsUpdater::IncompatibleApplication>
+ incompatible_applications =
+ IncompatibleApplicationsUpdater::GetCachedApplications();
base::Value application_list(base::Value::Type::LIST);
- application_list.GetList().reserve(problematic_programs.size());
+ application_list.GetList().reserve(incompatible_applications.size());
- for (const auto& program : problematic_programs) {
+ for (const auto& application : incompatible_applications) {
// Set up a registry watcher for each problem application.
// Since this instance owns the watcher, it is safe to use
// base::Unretained() because the callback won't be invoked when the watcher
// gets deleted.
auto registry_key_watcher = RegistryKeyWatcher::Create(
- program.info.registry_root, program.info.registry_key_path.c_str(),
- program.info.registry_wow64_access,
+ application.info.registry_root,
+ application.info.registry_key_path.c_str(),
+ application.info.registry_wow64_access,
base::BindOnce(&IncompatibleApplicationsHandler::OnApplicationRemoved,
- base::Unretained(this), program.info));
+ base::Unretained(this), application.info));
// Only keep the watcher if it was successfully initialized. A failure here
- // is unlikely, but the worst that can happen is that the |program| will not
- // get removed from the list automatically in the Incompatible Applications
- // subpage.
+ // is unlikely, but the worst that can happen is that the |application| will
+ // not get removed from the list automatically in the Incompatible
+ // Applications subpage.
if (registry_key_watcher) {
registry_key_watchers_.insert(
- {program.info, std::move(registry_key_watcher)});
+ {application.info, std::move(registry_key_watcher)});
}
// Also add the application to the list that is passed to the javascript.
base::Value dict(base::Value::Type::DICTIONARY);
- dict.SetKey("name", base::Value(program.info.name));
- dict.SetKey("type", base::Value(program.blacklist_action->message_type()));
- dict.SetKey("url", base::Value(program.blacklist_action->message_url()));
+ dict.SetKey("name", base::Value(application.info.name));
+ dict.SetKey("type",
+ base::Value(application.blacklist_action->message_type()));
+ dict.SetKey("url",
+ base::Value(application.blacklist_action->message_url()));
application_list.GetList().push_back(std::move(dict));
}
UMA_HISTOGRAM_COUNTS_100("IncompatibleApplicationsPage.NumApplications",
- problematic_programs.size());
+ incompatible_applications.size());
const base::Value& callback_id = args->GetList().front();
ResolveJavascriptCallback(callback_id, application_list);
}
-void IncompatibleApplicationsHandler::HandleStartProgramUninstallation(
+void IncompatibleApplicationsHandler::HandleStartApplicationUninstallation(
const base::ListValue* args) {
CHECK_EQ(1u, args->GetList().size());
base::RecordAction(base::UserMetricsAction(
"IncompatibleApplicationsPage.UninstallationStarted"));
- // Open the Apps & Settings page with the program name highlighted.
+ // Open the Apps & Settings page with the application name highlighted.
uninstall_application::LaunchUninstallFlow(
base::UTF8ToUTF16(args->GetList()[0].GetString()));
}
@@ -156,13 +160,13 @@ void IncompatibleApplicationsHandler::GetPluralString(
}
void IncompatibleApplicationsHandler::OnApplicationRemoved(
- const InstalledPrograms::ProgramInfo& program) {
+ const InstalledApplications::ApplicationInfo& application) {
base::RecordAction(base::UserMetricsAction(
"IncompatibleApplicationsPage.ApplicationRemoved"));
- registry_key_watchers_.erase(program);
+ registry_key_watchers_.erase(application);
FireWebUIListener("incompatible-application-removed",
- base::Value(program.name));
+ base::Value(application.name));
}
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.h b/chromium/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.h
index b7518f69a45..114fdb97914 100644
--- a/chromium/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.h
+++ b/chromium/chrome/browser/ui/webui/settings/incompatible_applications_handler_win.h
@@ -9,7 +9,7 @@
#include <memory>
#include "base/macros.h"
-#include "chrome/browser/conflicts/installed_programs_win.h"
+#include "chrome/browser/conflicts/installed_applications_win.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
class RegistryKeyWatcher;
@@ -35,8 +35,8 @@ class IncompatibleApplicationsHandler : public SettingsPageUIHandler {
// Sends the list of incompatible applications to the caller via a promise.
void HandleRequestIncompatibleApplicationsList(const base::ListValue* args);
- // Initiates the uninstallation of the program passed using |args|.
- void HandleStartProgramUninstallation(const base::ListValue* args);
+ // Initiates the uninstallation of the application passed using |args|.
+ void HandleStartApplicationUninstallation(const base::ListValue* args);
void HandleGetSubtitlePluralString(const base::ListValue* args);
void HandleGetSubtitleNoAdminRightsPluralString(const base::ListValue* args);
@@ -44,10 +44,12 @@ class IncompatibleApplicationsHandler : public SettingsPageUIHandler {
void GetPluralString(int id, const base::ListValue* args);
// Callback for the registry key watchers.
- void OnApplicationRemoved(const InstalledPrograms::ProgramInfo& program);
+ void OnApplicationRemoved(
+ const InstalledApplications::ApplicationInfo& application);
// Container for the watchers.
- std::map<InstalledPrograms::ProgramInfo, std::unique_ptr<RegistryKeyWatcher>>
+ std::map<InstalledApplications::ApplicationInfo,
+ std::unique_ptr<RegistryKeyWatcher>>
registry_key_watchers_;
DISALLOW_COPY_AND_ASSIGN(IncompatibleApplicationsHandler);
diff --git a/chromium/chrome/browser/ui/webui/settings/languages_handler.cc b/chromium/chrome/browser/ui/webui/settings/languages_handler.cc
index b36e7442a2d..6ec6856e4d2 100644
--- a/chromium/chrome/browser/ui/webui/settings/languages_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/languages_handler.cc
@@ -14,6 +14,7 @@
#include "content/public/browser/web_ui.h"
#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/base/locale_util.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "components/user_manager/user_manager.h"
#include "components/user_manager/user_type.h"
@@ -68,6 +69,14 @@ void LanguagesHandler::HandleSetProspectiveUILanguage(
std::string language_code;
CHECK(args->GetString(0, &language_code));
+#if defined(OS_CHROMEOS)
+ // check if prospectiveUILanguage is allowed by policy (AllowedLocales)
+ if (!chromeos::locale_util::IsAllowedLocale(language_code,
+ profile_->GetPrefs())) {
+ return;
+ }
+#endif
+
#if defined(OS_WIN)
PrefService* prefs = g_browser_process->local_state();
prefs->SetString(prefs::kApplicationLocale, language_code);
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 6ee8837135b..77f1c6afba4 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
@@ -17,6 +17,8 @@
#include "chrome/browser/plugins/plugin_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_shortcut_manager.h"
+#include "chrome/browser/signin/account_consistency_mode_manager.h"
+#include "chrome/browser/signin/unified_consent_helper.h"
#include "chrome/browser/ui/webui/policy_indicator_localized_strings_provider.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h"
@@ -48,7 +50,6 @@
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
-#include "chrome/browser/signin/account_consistency_mode_manager.h"
#include "chrome/browser/ui/webui/chromeos/bluetooth_dialog_localized_strings_provider.h"
#include "chrome/browser/ui/webui/chromeos/network_element_localized_strings_provider.h"
#include "chromeos/chromeos_switches.h"
@@ -57,10 +58,9 @@
#include "ui/chromeos/devicetype_utils.h"
#include "ui/chromeos/events/keyboard_layout_util.h"
#include "ui/display/display_switches.h"
-#include "ui/display/manager/chromeos/touch_device_manager.h"
+#include "ui/display/manager/touch_device_manager.h"
#else
#include "chrome/browser/ui/webui/settings/system_handler.h"
-#include "components/signin/core/browser/profile_management_switches.h"
#endif
#if defined(OS_WIN)
@@ -75,10 +75,6 @@
#include "chrome/browser/ui/webui/certificate_manager_localized_strings_provider.h"
#endif
-#if defined(SAFE_BROWSING_DB_LOCAL)
-#include "components/safe_browsing/password_protection/password_protection_service.h"
-#endif
-
namespace settings {
namespace {
@@ -128,6 +124,7 @@ void AddCommonStrings(content::WebUIDataSource* html_source, Profile* profile) {
{"disable", IDS_DISABLE},
{"done", IDS_DONE},
{"edit", IDS_SETTINGS_EDIT},
+ {"extensionsLinkTooltip", IDS_SETTINGS_MENU_EXTENSIONS_LINK_TOOLTIP},
{"learnMore", IDS_LEARN_MORE},
{"menuButtonLabel", IDS_SETTINGS_MENU_BUTTON_LABEL},
{"moreActions", IDS_SETTINGS_MORE_ACTIONS},
@@ -198,6 +195,7 @@ void AddA11yStrings(content::WebUIDataSource* html_source) {
{"delayBeforeClickShort", IDS_SETTINGS_DELAY_BEFORE_CLICK_SHORT},
{"delayBeforeClickLong", IDS_SETTINGS_DELAY_BEFORE_CLICK_LONG},
{"delayBeforeClickVeryLong", IDS_SETTINGS_DELAY_BEFORE_CLICK_VERY_LONG},
+ {"dictationLabel", IDS_SETTINGS_ACCESSIBILITY_DICTATION_LABEL},
{"onScreenKeyboardLabel", IDS_SETTINGS_ON_SCREEN_KEYBOARD_LABEL},
{"monoAudioLabel", IDS_SETTINGS_MONO_AUDIO_LABEL},
{"a11yExplanation", IDS_SETTINGS_ACCESSIBILITY_EXPLANATION},
@@ -208,8 +206,12 @@ void AddA11yStrings(content::WebUIDataSource* html_source) {
{"focusHighlightLabel",
IDS_SETTINGS_ACCESSIBILITY_FOCUS_HIGHLIGHT_DESCRIPTION},
{"selectToSpeakTitle", IDS_SETTINGS_ACCESSIBILITY_SELECT_TO_SPEAK_TITLE},
+ {"selectToSpeakDisabledDescription",
+ IDS_SETTINGS_ACCESSIBILITY_SELECT_TO_SPEAK_DISABLED_DESCRIPTION},
{"selectToSpeakDescription",
IDS_SETTINGS_ACCESSIBILITY_SELECT_TO_SPEAK_DESCRIPTION},
+ {"selectToSpeakDescriptionWithoutKeyboard",
+ IDS_SETTINGS_ACCESSIBILITY_SELECT_TO_SPEAK_DESCRIPTION_WITHOUT_KEYBOARD},
{"selectToSpeakOptionsLabel",
IDS_SETTINGS_ACCESSIBILITY_SELECT_TO_SPEAK_OPTIONS_LABEL},
{"switchAccessLabel", IDS_SETTINGS_ACCESSIBILITY_SWITCH_ACCESS_DESCRIPTION},
@@ -227,6 +229,8 @@ void AddA11yStrings(content::WebUIDataSource* html_source) {
{"appearanceSettingsDescription",
IDS_SETTINGS_ACCESSIBILITY_APPEARANCE_SETTINGS_DESCRIPTION},
{"keyboardHeading", IDS_SETTINGS_ACCESSIBILITY_KEYBOARD_HEADING},
+ {"keyboardAndTextInputHeading",
+ IDS_SETTINGS_ACCESSIBILITY_KEYBOARD_AND_TEXT_INPUT_HEADING},
{"keyboardSettingsTitle",
IDS_SETTINGS_ACCESSIBILITY_KEYBOARD_SETTINGS_TITLE},
{"keyboardSettingsDescription",
@@ -242,22 +246,34 @@ void AddA11yStrings(content::WebUIDataSource* html_source) {
{"manageTtsSettings", IDS_SETTINGS_MANAGE_TTS_SETTINGS},
{"ttsSettingsLinkDescription", IDS_SETTINGS_TTS_LINK_DESCRIPTION},
{"textToSpeechVoices", IDS_SETTINGS_TEXT_TO_SPEECH_VOICES},
+ {"textToSpeechNoVoicesMessage",
+ IDS_SETTINGS_TEXT_TO_SPEECH_NO_VOICES_MESSAGE},
{"textToSpeechProperties", IDS_SETTINGS_TEXT_TO_SPEECH_PROPERTIES},
{"textToSpeechRate", IDS_SETTINGS_TEXT_TO_SPEECH_RATE},
+ {"textToSpeechRateMinimumLabel",
+ IDS_SETTINGS_TEXT_TO_SPEECH_RATE_MINIMUM_LABEL},
+ {"textToSpeechRateMaximumLabel",
+ IDS_SETTINGS_TEXT_TO_SPEECH_RATE_MAXIMUM_LABEL},
{"textToSpeechPitch", IDS_SETTINGS_TEXT_TO_SPEECH_PITCH},
+ {"textToSpeechPitchMinimumLabel",
+ IDS_SETTINGS_TEXT_TO_SPEECH_PITCH_MINIMUM_LABEL},
+ {"textToSpeechPitchMaximumLabel",
+ IDS_SETTINGS_TEXT_TO_SPEECH_PITCH_MAXIMUM_LABEL},
+ {"textToSpeechVolume", IDS_SETTINGS_TEXT_TO_SPEECH_VOLUME},
+ {"textToSpeechVolumeMinimumLabel",
+ IDS_SETTINGS_TEXT_TO_SPEECH_VOLUME_MINIMUM_LABEL},
+ {"textToSpeechVolumeMaximumLabel",
+ IDS_SETTINGS_TEXT_TO_SPEECH_VOLUME_MAXIMUM_LABEL},
+ {"percentage", IDS_SETTINGS_PERCENTAGE},
+ {"defaultPercentage", IDS_SETTINGS_DEFAULT_PERCENTAGE},
{"textToSpeechPreviewHeading", IDS_SETTINGS_TEXT_TO_SPEECH_PREVIEW_HEADING},
{"textToSpeechPreviewInputLabel",
IDS_SETTINGS_TEXT_TO_SPEECH_PREVIEW_INPUT_LABEL},
{"textToSpeechPreviewInput", IDS_SETTINGS_TEXT_TO_SPEECH_PREVIEW_INPUT},
+ {"textToSpeechPreviewVoice", IDS_SETTINGS_TEXT_TO_SPEECH_PREVIEW_VOICE},
{"textToSpeechPreviewPlay", IDS_SETTINGS_TEXT_TO_SPEECH_PREVIEW_PLAY},
{"textToSpeechEngines", IDS_SETTINGS_TEXT_TO_SPEECH_ENGINES},
{"textToSpeechInstallEngines", IDS_SETTINGS_TEXT_TO_SPEECH_INSTALL_ENGINES},
- {"manageGoogleTtsEngineSettings",
- IDS_SETTINGS_MANAGE_GOOGLE_TTS_ENGINE_SETTINGS},
- {"googleTtsEngineSettingsLinkDescription",
- IDS_SETTINGS_GOOGLE_TTS_ENGINE_LINK_DESCRIPTION},
- {"googleTextToSpeechSettings", IDS_SETTINGS_GOOGLE_TTS_ENGINE_TITLE},
- {"enableTtsVoiceLabel", IDS_SETTINGS_ENABLE_TTS_VOICE_LABEL},
#endif
};
AddLocalizedStringsBulk(html_source, localized_strings,
@@ -369,13 +385,25 @@ void AddAboutStrings(content::WebUIDataSource* html_source) {
}
#if defined(OS_CHROMEOS)
+void AddCrostiniStrings(content::WebUIDataSource* html_source) {
+ LocalizedString localized_strings[] = {
+ {"crostiniPageTitle", IDS_SETTINGS_CROSTINI_TITLE},
+ {"crostiniSubtext", IDS_SETTINGS_CROSTINI_SUBTEXT},
+ {"crostiniPageLabel", IDS_SETTINGS_CROSTINI_LABEL},
+ {"crostiniEnable", IDS_SETTINGS_TURN_ON},
+ {"crostiniRemove", IDS_SETTINGS_CROSTINI_REMOVE},
+ };
+ AddLocalizedStringsBulk(html_source, localized_strings,
+ arraysize(localized_strings));
+}
+
void AddAndroidAppStrings(content::WebUIDataSource* html_source) {
LocalizedString localized_strings[] = {
{"androidAppsPageTitle", arc::IsPlayStoreAvailable()
? IDS_SETTINGS_ANDROID_APPS_TITLE
: IDS_SETTINGS_ANDROID_SETTINGS_TITLE},
{"androidAppsPageLabel", IDS_SETTINGS_ANDROID_APPS_LABEL},
- {"androidAppsEnable", IDS_SETTINGS_ANDROID_APPS_ENABLE},
+ {"androidAppsEnable", IDS_SETTINGS_TURN_ON},
{"androidAppsManageApps", IDS_SETTINGS_ANDROID_APPS_MANAGE_APPS},
{"androidAppsRemove", IDS_SETTINGS_ANDROID_APPS_REMOVE},
{"androidAppsDisableDialogTitle",
@@ -462,26 +490,13 @@ void AddBluetoothStrings(content::WebUIDataSource* html_source) {
#endif
void AddChangePasswordStrings(content::WebUIDataSource* html_source) {
-#if defined(SAFE_BROWSING_DB_LOCAL)
- bool show_softer_warning =
- safe_browsing::PasswordProtectionService::ShouldShowSofterWarning();
-
- auto title_string_id = show_softer_warning
- ? IDS_SETTINGS_CHANGE_PASSWORD_TITLE_SOFTER
- : IDS_SETTINGS_CHANGE_PASSWORD_TITLE;
LocalizedString localized_strings[] = {
- {"changePasswordPageTitle", title_string_id},
+ {"changePasswordPageTitle", IDS_SETTINGS_CHANGE_PASSWORD_TITLE},
{"changePasswordPageDetails", IDS_SETTINGS_CHANGE_PASSWORD_DETAIL},
{"changePasswordPageButton", IDS_SETTINGS_CHANGE_PASSWORD_BUTTON},
};
-
AddLocalizedStringsBulk(html_source, localized_strings,
arraysize(localized_strings));
-
- const std::string icon_id =
- show_softer_warning ? "cr:security" : "cr:warning";
- html_source->AddString("changePasswordPageIcon", icon_id);
-#endif
}
void AddClearBrowsingDataStrings(content::WebUIDataSource* html_source,
@@ -495,7 +510,7 @@ void AddClearBrowsingDataStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_CLEAR_COOKIES_AND_SITE_DATA_SUMMARY_BASIC_WITH_EXCEPTION;
}
#else // !defined(OS_CHROMEOS)
- if (signin::IsDiceEnabledForProfile(profile->GetPrefs())) {
+ if (AccountConsistencyModeManager::IsDiceEnabledForProfile(profile)) {
clear_cookies_summary_msg_id =
IDS_SETTINGS_CLEAR_COOKIES_AND_SITE_DATA_SUMMARY_BASIC_WITH_EXCEPTION;
}
@@ -690,6 +705,12 @@ void AddDeviceStrings(content::WebUIDataSource* html_source) {
{"displayZoomTitle", IDS_SETTINGS_DISPLAY_ZOOM_TITLE},
{"displayZoomSublabel", IDS_SETTINGS_DISPLAY_ZOOM_SUBLABEL},
{"displayZoomValue", IDS_SETTINGS_DISPLAY_ZOOM_VALUE},
+ {"displayZoomLogicalResolutionText",
+ IDS_SETTINGS_DISPLAY_ZOOM_LOGICAL_RESOLUTION_TEXT},
+ {"displayZoomNativeLogicalResolutionNativeText",
+ IDS_SETTINGS_DISPLAY_ZOOM_LOGICAL_RESOLUTION_NATIVE_TEXT},
+ {"displayZoomLogicalResolutionDefaultText",
+ IDS_SETTINGS_DISPLAY_ZOOM_LOGICAL_RESOLUTION_DEFAULT_TEXT},
{"displaySizeSliderMinLabel", IDS_SETTINGS_DISPLAY_ZOOM_SLIDER_MINIMUM},
{"displaySizeSliderMaxLabel", IDS_SETTINGS_DISPLAY_ZOOM_SLIDER_MAXIMUM},
{"displayScreenTitle", IDS_SETTINGS_DISPLAY_SCREEN},
@@ -802,6 +823,20 @@ void AddDownloadsStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_DOWNLOADS_SMB_SHARES_LEARN_MORE_LABEL},
{"addSmbShare", IDS_SETTINGS_DOWNLOADS_SMB_SHARES_ADD_SHARE},
{"smbShareUrl", IDS_SETTINGS_DOWNLOADS_ADD_SHARE_URL},
+ {"smbShareUsername", IDS_SETTINGS_DOWNLOADS_ADD_SHARE_USERNAME},
+ {"smbSharePassword", IDS_SETTINGS_DOWNLOADS_ADD_SHARE_PASSWORD},
+ {"smbShareAddedSuccessfulMessage",
+ IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_SUCCESS_MESSAGE},
+ {"smbShareAddedErrorMessage",
+ IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_ERROR_MESSAGE},
+ {"smbShareAddedAuthFailedMessage",
+ IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_AUTH_FAILED_MESSAGE},
+ {"smbShareAddedNotFoundMessage",
+ IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_NOT_FOUND_MESSAGE},
+ {"smbShareAddedUnsupportedDeviceMessage",
+ IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_UNSUPPORTED_DEVICE_MESSAGE},
+ {"smbShareAddedMountExistsMessage",
+ IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_MOUNT_EXISTS_MESSAGE},
#endif
};
AddLocalizedStringsBulk(html_source, localized_strings,
@@ -862,10 +897,7 @@ void AddChromeCleanupStrings(content::WebUIDataSource* html_source) {
{"chromeCleanupTitleNothingFound",
IDS_SETTINGS_RESET_CLEANUP_TITLE_NOTHING_FOUND},
{"chromeCleanupTitleRemove", IDS_SETTINGS_RESET_CLEANUP_TITLE_REMOVE},
- {"chromeCleanupTitleRemoved",
- safe_browsing::UserInitiatedCleanupsEnabled()
- ? IDS_SETTINGS_RESET_CLEANUP_TITLE_DONE
- : IDS_SETTINGS_RESET_CLEANUP_TITLE_REMOVED},
+ {"chromeCleanupTitleRemoved", IDS_SETTINGS_RESET_CLEANUP_TITLE_DONE},
{"chromeCleanupTitleRemoving", IDS_SETTINGS_RESET_CLEANUP_TITLE_REMOVING},
{"chromeCleanupTitleRestart", IDS_SETTINGS_RESET_CLEANUP_TITLE_RESTART},
{"chromeCleanupTitleScanning", IDS_SETTINGS_RESET_CLEANUP_TITLE_SCANNING},
@@ -940,9 +972,7 @@ void AddIncompatibleApplicationsStrings(content::WebUIDataSource* html_source) {
void AddResetStrings(content::WebUIDataSource* html_source) {
LocalizedString localized_strings[] = {
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
- {"resetPageTitle", safe_browsing::UserInitiatedCleanupsEnabled()
- ? IDS_SETTINGS_RESET_AND_CLEANUP
- : IDS_SETTINGS_RESET},
+ {"resetPageTitle", IDS_SETTINGS_RESET_AND_CLEANUP},
#else
{"resetPageTitle", IDS_SETTINGS_RESET},
#endif
@@ -1228,6 +1258,7 @@ void AddLanguagesStrings(content::WebUIDataSource* html_source) {
LocalizedString localized_strings[] = {
{"languagesPageTitle", IDS_SETTINGS_LANGUAGES_PAGE_TITLE},
{"languagesListTitle", IDS_SETTINGS_LANGUAGES_LANGUAGES_LIST_TITLE},
+ {"searchLanguages", IDS_SETTINGS_LANGUAGE_SEARCH},
{"languagesExpandA11yLabel",
IDS_SETTINGS_LANGUAGES_EXPAND_ACCESSIBILITY_LABEL},
{"orderLanguagesInstructions",
@@ -1373,6 +1404,7 @@ void AddPasswordsAndFormsStrings(content::WebUIDataSource* html_source) {
{"creditCardExpired", IDS_SETTINGS_CREDIT_CARD_EXPIRED},
{"editCreditCardTitle", IDS_SETTINGS_EDIT_CREDIT_CARD_TITLE},
{"addCreditCardTitle", IDS_SETTINGS_ADD_CREDIT_CARD_TITLE},
+ {"canMakePaymentToggleLabel", IDS_SETTINGS_CAN_MAKE_PAYMENT_TOGGLE_LABEL},
{"autofillDetail", IDS_SETTINGS_AUTOFILL_DETAIL},
{"passwords", IDS_SETTINGS_PASSWORDS},
{"passwordsSavePasswordsLabel",
@@ -1442,6 +1474,9 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
{"peoplePageTitle", IDS_SETTINGS_PEOPLE},
{"manageOtherPeople", IDS_SETTINGS_PEOPLE_MANAGE_OTHER_PEOPLE},
#if defined(OS_CHROMEOS)
+ {"accountManagerPageTitle", IDS_SETTINGS_ACCOUNT_MANAGER_PAGE_TITLE},
+ {"accountManagerDescription", IDS_SETTINGS_ACCOUNT_MANAGER_DESCRIPTION},
+ {"accountListHeader", IDS_SETTINGS_ACCOUNT_MANAGER_LIST_HEADER},
{"configureFingerprintTitle", IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_TITLE},
{"configureFingerprintInstructionLocateScannerStep",
IDS_SETTINGS_ADD_FINGERPRINT_DIALOG_INSTRUCTION_LOCATE_SCANNER},
@@ -1497,7 +1532,9 @@ 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},
- {"lockScreenOptions", IDS_SETTINGS_PEOPLE_LOCK_SCREEN_OPTIONS_LOCK},
+ {"lockScreenOptionsLock", IDS_SETTINGS_PEOPLE_LOCK_SCREEN_OPTIONS_LOCK},
+ {"lockScreenOptionsLoginLock",
+ IDS_SETTINGS_PEOPLE_LOCK_SCREEN_OPTIONS_LOGIN_LOCK},
{"lockScreenPasswordOnly", IDS_SETTINGS_PEOPLE_LOCK_SCREEN_PASSWORD_ONLY},
{"lockScreenPinOrPassword",
IDS_SETTINGS_PEOPLE_LOCK_SCREEN_PIN_OR_PASSWORD},
@@ -1505,9 +1542,13 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
IDS_SETTINGS_PEOPLE_LOCK_SCREEN_REGISTERED_FINGERPRINTS_LABEL},
{"lockScreenSetupPinButton",
IDS_SETTINGS_PEOPLE_LOCK_SCREEN_SETUP_PIN_BUTTON},
- {"lockScreenTitle", IDS_SETTINGS_PEOPLE_LOCK_SCREEN_TITLE_LOCK},
- {"passwordPromptEnterPassword",
+ {"lockScreenTitleLock", IDS_SETTINGS_PEOPLE_LOCK_SCREEN_TITLE_LOCK},
+ {"lockScreenTitleLoginLock",
+ IDS_SETTINGS_PEOPLE_LOCK_SCREEN_TITLE_LOGIN_LOCK},
+ {"passwordPromptEnterPasswordLock",
IDS_SETTINGS_PEOPLE_PASSWORD_PROMPT_ENTER_PASSWORD_LOCK},
+ {"passwordPromptEnterPasswordLoginLock",
+ IDS_SETTINGS_PEOPLE_PASSWORD_PROMPT_ENTER_PASSWORD_LOGIN_LOCK},
{"passwordPromptInvalidPassword",
IDS_SETTINGS_PEOPLE_PASSWORD_PROMPT_INVALID_PASSWORD},
{"passwordPromptPasswordLabel",
@@ -1546,17 +1587,26 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
#if BUILDFLAG(ENABLE_DICE_SUPPORT)
{"peopleSignIn", IDS_SETTINGS_PEOPLE_SIGN_IN},
{"peopleSignInPrompt", IDS_SETTINGS_PEOPLE_SIGN_IN_PROMPT},
- {"peopleSignInPromptSecondary",
- IDS_SETTINGS_PEOPLE_SIGN_IN_PROMPT_SECONDARY},
+ {"peopleSignInPromptSecondaryWithNoAccount",
+ IDS_SETTINGS_PEOPLE_SIGN_IN_PROMPT_SECONDARY_WITH_NO_ACCOUNT},
+ {"peopleSignInPromptSecondaryWithAccount",
+ IDS_SETTINGS_PEOPLE_SIGN_IN_PROMPT_SECONDARY_WITH_ACCOUNT},
{"useAnotherAccount", IDS_SETTINGS_PEOPLE_SYNC_ANOTHER_ACCOUNT},
{"syncAsName", IDS_SETTINGS_PEOPLE_SYNC_AS_NAME},
{"syncingTo", IDS_SETTINGS_PEOPLE_SYNCING_TO_ACCOUNT},
{"turnOffSync", IDS_SETTINGS_PEOPLE_SYNC_TURN_OFF},
{"syncNotWorking", IDS_SETTINGS_PEOPLE_SYNC_NOT_WORKING},
{"syncPaused", IDS_SETTINGS_PEOPLE_SYNC_PAUSED},
- {"syncSignInPrompt", IDS_SETTINGS_SYNC_SIGN_IN_PROMPT},
+ {"syncSignInPromptWithAccount",
+ IDS_SETTINGS_SYNC_SIGN_IN_PROMPT_WITH_ACCOUNT},
+ {"syncSignInPromptWithNoAccount",
+ IDS_SETTINGS_SYNC_SIGN_IN_PROMPT_WITH_NO_ACCOUNT},
{"syncSignInPromptSecondary", IDS_SETTINGS_SYNC_SIGN_IN_PROMPT_SECONDARY},
#endif
+ {"syncUnifiedConsentToggleTitle",
+ IDS_SETTINGS_PEOPLE_SYNC_UNIFIED_CONSENT_TOGGLE_TITLE},
+ {"syncUnifiedConsentToggleSubtitle",
+ IDS_SETTINGS_PEOPLE_SYNC_UNIFIED_CONSENT_TOGGLE_SUBTITLE},
{"syncOverview", IDS_SETTINGS_SYNC_OVERVIEW},
{"syncDisabledByAdministrator",
IDS_SETTINGS_SYNC_DISABLED_BY_ADMINISTRATOR},
@@ -1577,9 +1627,15 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
{"syncDisconnectConfirm", IDS_SETTINGS_SYNC_DISCONNECT_CONFIRM},
{"sync", IDS_SETTINGS_SYNC},
{"syncDescription", IDS_SETTINGS_SYNC_DESCRIPTION},
+ {"personalizationSectionLabel", IDS_SETTINGS_PERSONALIZATION_SECTION_LABEL},
+ {"personalizationSectionDesc", IDS_SETTINGS_PERSONALIZATION_SECTION_DESC},
+ {"personalizationExpandA11yLabel",
+ IDS_SETTINGS_PERSONALIZATION_SECTION_ACCESSIBILITY_LABEL},
{"syncExpandA11yLabel", IDS_SETTINGS_SYNC_SECTION_ACCESSIBILITY_LABEL},
{"syncAndPersonalization", IDS_SETTINGS_SYNC_SYNC_AND_PERSONALIZATION},
- {"syncPageTitle", IDS_SETTINGS_SYNC_PAGE_TITLE},
+ {"syncPageTitle", IsUnifiedConsentEnabled(profile)
+ ? IDS_SETTINGS_SYNC_SYNC_AND_PERSONALIZATION
+ : IDS_SETTINGS_SYNC_PAGE_TITLE},
{"syncLoading", IDS_SETTINGS_SYNC_LOADING},
{"syncTimeout", IDS_SETTINGS_SYNC_TIMEOUT},
{"syncEverythingCheckboxLabel",
@@ -1675,7 +1731,7 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
base::ASCIIToUTF16(sync_dashboard_url)));
// The syncDisconnect text differs depending on Dice-enabledness.
- if (signin::IsDiceEnabledForProfile(profile->GetPrefs())) {
+ if (AccountConsistencyModeManager::IsDiceEnabledForProfile(profile)) {
LocalizedString sync_disconnect_strings[] = {
{"syncDisconnect", IDS_SETTINGS_TURN_OFF_SYNC_DIALOG_CONFIRM},
{"syncDisconnectTitle", IDS_SETTINGS_TURN_OFF_SYNC_DIALOG_TITLE},
@@ -1749,6 +1805,8 @@ void AddPrintingStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_PRINTING_CUPS_PRINTER_PROTOCOL_APP_SOCKET},
{"printerProtocolLpd", IDS_SETTINGS_PRINTING_CUPS_PRINTER_PROTOCOL_LPD},
{"printerProtocolUsb", IDS_SETTINGS_PRINTING_CUPS_PRINTER_PROTOCOL_USB},
+ {"printerProtocolIppUsb",
+ IDS_SETTINGS_PRINTING_CUPS_PRINTER_PROTOCOL_IPPUSB},
{"printerConfiguringMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_CONFIGURING_MESSAGE},
{"printerManufacturer", IDS_SETTINGS_PRINTING_CUPS_PRINTER_MANUFACTURER},
@@ -1777,11 +1835,17 @@ void AddPrintingStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_PRINTING_CUPS_PRINTER_ADDED_PRINTER_PPD_NOT_FOUND},
{"printerAddedPpdUnretrievableMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_ADDED_PRINTER_PPD_UNRETRIEVABLE},
+ {"printerAddedNativePrintersNotAllowedMessage",
+ IDS_SETTINGS_PRINTING_CUPS_PRINTER_ADDED_NATIVE_PRINTERS_NOT_ALLOWED_MESSAGE},
+ {"editPrinterInvalidPrinterUpdate",
+ IDS_SETTINGS_PRINTING_CUPS_EDIT_PRINTER_INVALID_PRINTER_UPDATE},
{"requireNetworkMessage",
IDS_SETTINGS_PRINTING_CUPS_PRINTER_REQUIRE_INTERNET_MESSAGE},
{"editPrinterDialogTitle",
IDS_SETTINGS_PRINTING_CUPS_EDIT_PRINTER_DIALOG_TITLE},
{"editPrinterButtonText", IDS_SETTINGS_PRINTING_CUPS_EDIT_PRINTER_BUTTON},
+ {"currentPpdMessage",
+ IDS_SETTINGS_PRINTING_CUPS_EDIT_PRINTER_CURRENT_PPD_MESSAGE},
#else
{"localPrintersTitle", IDS_SETTINGS_PRINTING_LOCAL_PRINTERS_TITLE},
#endif
@@ -1802,49 +1866,94 @@ void AddPrintingStrings(content::WebUIDataSource* html_source) {
void AddPrivacyStrings(content::WebUIDataSource* html_source,
Profile* profile) {
LocalizedString localized_strings[] = {
- {"privacyPageTitle", IDS_SETTINGS_PRIVACY},
- {"linkDoctorPref", IDS_SETTINGS_LINKDOCTOR_PREF},
- {"searchSuggestPref", IDS_SETTINGS_SUGGEST_PREF},
- {"networkPredictionEnabled",
- IDS_SETTINGS_NETWORK_PREDICTION_ENABLED_DESCRIPTION},
- {"safeBrowsingEnableProtection",
- IDS_SETTINGS_SAFEBROWSING_ENABLEPROTECTION},
- {"spellingPref", IDS_SETTINGS_SPELLING_PREF},
- {"spellingDescription", IDS_SETTINGS_SPELLING_DESCRIPTION},
-#if defined(OS_CHROMEOS)
- {"enableLogging", IDS_SETTINGS_ENABLE_LOGGING_DIAGNOSTIC_AND_USAGE_DATA},
-#else
- {"enableLogging", IDS_SETTINGS_ENABLE_LOGGING},
-#endif
- {"doNotTrack", IDS_SETTINGS_ENABLE_DO_NOT_TRACK},
- {"doNotTrackDialogTitle", IDS_SETTINGS_ENABLE_DO_NOT_TRACK_DIALOG_TITLE},
- {"enableContentProtectionAttestation",
- IDS_SETTINGS_ENABLE_CONTENT_PROTECTION_ATTESTATION},
- {"wakeOnWifi", IDS_SETTINGS_WAKE_ON_WIFI_DESCRIPTION},
- {"manageCertificates", IDS_SETTINGS_MANAGE_CERTIFICATES},
- {"manageCertificatesDescription",
- IDS_SETTINGS_MANAGE_CERTIFICATES_DESCRIPTION},
- {"contentSettings", IDS_SETTINGS_CONTENT_SETTINGS},
- {"siteSettings", IDS_SETTINGS_SITE_SETTINGS},
- {"siteSettingsDescription", IDS_SETTINGS_SITE_SETTINGS_DESCRIPTION},
- {"clearData", IDS_SETTINGS_CLEAR_DATA},
- {"clearBrowsingData", IDS_SETTINGS_CLEAR_BROWSING_DATA},
- {"clearBrowsingDataDescription", IDS_SETTINGS_CLEAR_DATA_DESCRIPTION},
- {"titleAndCount", IDS_SETTINGS_TITLE_AND_COUNT},
+ {"privacyPageTitle", IDS_SETTINGS_PRIVACY},
+ {"doNotTrack", IDS_SETTINGS_ENABLE_DO_NOT_TRACK},
+ {"doNotTrackDialogTitle", IDS_SETTINGS_ENABLE_DO_NOT_TRACK_DIALOG_TITLE},
+ {"enableContentProtectionAttestation",
+ IDS_SETTINGS_ENABLE_CONTENT_PROTECTION_ATTESTATION},
+ {"wakeOnWifi", IDS_SETTINGS_WAKE_ON_WIFI_DESCRIPTION},
+ {"manageCertificates", IDS_SETTINGS_MANAGE_CERTIFICATES},
+ {"manageCertificatesDescription",
+ IDS_SETTINGS_MANAGE_CERTIFICATES_DESCRIPTION},
+ {"contentSettings", IDS_SETTINGS_CONTENT_SETTINGS},
+ {"siteSettings", IDS_SETTINGS_SITE_SETTINGS},
+ {"siteSettingsDescription", IDS_SETTINGS_SITE_SETTINGS_DESCRIPTION},
+ {"clearData", IDS_SETTINGS_CLEAR_DATA},
+ {"clearBrowsingData", IDS_SETTINGS_CLEAR_BROWSING_DATA},
+ {"clearBrowsingDataDescription", IDS_SETTINGS_CLEAR_DATA_DESCRIPTION},
+ {"titleAndCount", IDS_SETTINGS_TITLE_AND_COUNT},
+ {"syncAndPersonalizationLink", IDS_SETTINGS_PRIVACY_MORE_SETTINGS},
};
AddLocalizedStringsBulk(html_source, localized_strings,
arraysize(localized_strings));
+ // Select strings depending on unified-consent enabledness.
+ bool is_unified_consent_enabled = IsUnifiedConsentEnabled(profile);
+ if (is_unified_consent_enabled) {
+ LocalizedString conditional_localized_strings[] = {
+ {"searchSuggestPref", IDS_SETTINGS_SUGGEST_PREF_UNIFIED_CONSENT},
+ {"searchSuggestPrefDesc",
+ IDS_SETTINGS_SUGGEST_PREF_DESC_UNIFIED_CONSENT},
+ {"safeBrowsingEnableExtendedReporting",
+ IDS_SETTINGS_SAFEBROWSING_ENABLE_REPORTING_UNIFIED_CONSENT},
+ {"safeBrowsingEnableExtendedReportingDesc",
+ IDS_SETTINGS_SAFEBROWSING_ENABLE_REPORTING_DESC_UNIFIED_CONSENT},
+ {"networkPredictionEnabled",
+ IDS_SETTINGS_NETWORK_PREDICTION_ENABLED_LABEL_UNIFIED_CONSENT},
+ {"networkPredictionEnabledDesc",
+ IDS_SETTINGS_NETWORK_PREDICTION_ENABLED_DESC_UNIFIED_CONSENT},
+ {"linkDoctorPref", IDS_SETTINGS_LINKDOCTOR_PREF_UNIFIED_CONSENT},
+ {"linkDoctorPrefDesc",
+ IDS_SETTINGS_LINKDOCTOR_PREF_DESC_UNIFIED_CONSENT},
+ {"safeBrowsingEnableProtection",
+ IDS_SETTINGS_SAFEBROWSING_ENABLEPROTECTION_UNIFIED_CONSENT},
+ {"safeBrowsingEnableProtectionDesc",
+ IDS_SETTINGS_SAFEBROWSING_ENABLEPROTECTION_DESC_UNIFIED_CONSENT},
+ {"spellingPref", IDS_SETTINGS_SPELLING_PREF_UNIFIED_CONSENT},
+ {"spellingDescription",
+ IDS_SETTINGS_SPELLING_DESCRIPTION_UNIFIED_CONSENT},
+ {"enableLogging", IDS_SETTINGS_ENABLE_LOGGING_UNIFIED_CONSENT},
+ {"enableLoggingDesc", IDS_SETTINGS_ENABLE_LOGGING_DESC_UNIFIED_CONSENT},
+ };
+ AddLocalizedStringsBulk(html_source, conditional_localized_strings,
+ arraysize(conditional_localized_strings));
+ } else {
+ LocalizedString conditional_localized_strings[] = {
+ {"searchSuggestPref", IDS_SETTINGS_SUGGEST_PREF},
+ {"searchSuggestPrefDesc", IDS_SETTINGS_EMPTY_STRING},
+ {"safeBrowsingEnableExtendedReportingDesc", IDS_SETTINGS_EMPTY_STRING},
+ {"networkPredictionEnabled",
+ IDS_SETTINGS_NETWORK_PREDICTION_ENABLED_LABEL},
+ {"networkPredictionEnabledDesc", IDS_SETTINGS_EMPTY_STRING},
+ {"linkDoctorPref", IDS_SETTINGS_LINKDOCTOR_PREF},
+ {"linkDoctorPrefDesc", IDS_SETTINGS_EMPTY_STRING},
+ {"safeBrowsingEnableProtection",
+ IDS_SETTINGS_SAFEBROWSING_ENABLEPROTECTION},
+ {"safeBrowsingEnableProtectionDesc", IDS_SETTINGS_EMPTY_STRING},
+ {"spellingPref", IDS_SETTINGS_SPELLING_PREF},
+ {"spellingDescription", IDS_SETTINGS_SPELLING_DESCRIPTION},
+#if defined(OS_CHROMEOS)
+ {"enableLogging", IDS_SETTINGS_ENABLE_LOGGING_DIAGNOSTIC_AND_USAGE_DATA},
+#else
+ {"enableLogging", IDS_SETTINGS_ENABLE_LOGGING},
+#endif
+ {"enableLoggingDesc", IDS_SETTINGS_EMPTY_STRING},
+ };
+ AddLocalizedStringsBulk(html_source, conditional_localized_strings,
+ arraysize(conditional_localized_strings));
+
+ html_source->AddLocalizedString(
+ "safeBrowsingEnableExtendedReporting",
+ safe_browsing::ChooseOptInTextResource(
+ *profile->GetPrefs(),
+ IDS_SETTINGS_SAFEBROWSING_ENABLE_EXTENDED_REPORTING,
+ IDS_SETTINGS_SAFEBROWSING_ENABLE_SCOUT_REPORTING));
+ }
+
html_source->AddBoolean(
"importantSitesInCbd",
base::FeatureList::IsEnabled(features::kImportantSitesInCbd));
- html_source->AddLocalizedString(
- "safeBrowsingEnableExtendedReporting",
- safe_browsing::ChooseOptInTextResource(
- *profile->GetPrefs(),
- IDS_SETTINGS_SAFEBROWSING_ENABLE_EXTENDED_REPORTING,
- IDS_SETTINGS_SAFEBROWSING_ENABLE_SCOUT_REPORTING));
html_source->AddString(
"improveBrowsingExperience",
l10n_util::GetStringFUTF16(
@@ -2031,7 +2140,6 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
{"sharedWorkerName", IDS_SETTINGS_COOKIES_COOKIE_NAME_LABEL},
{"webdbDesc", IDS_SETTINGS_COOKIES_WEB_DATABASE_DESCRIPTION_LABEL},
{"siteSettingsCategoryPageTitle", IDS_SETTINGS_SITE_SETTINGS_CATEGORY},
- {"siteSettingsCategoryAllSites", IDS_SETTINGS_SITE_SETTINGS_ALL_SITES},
{"siteSettingsCategoryCamera", IDS_SETTINGS_SITE_SETTINGS_CAMERA},
{"siteSettingsCameraLabel", IDS_SETTINGS_SITE_SETTINGS_CAMERA_LABEL},
{"siteSettingsCategoryCookies", IDS_SETTINGS_SITE_SETTINGS_COOKIES},
@@ -2046,6 +2154,8 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
{"siteSettingsCategoryPopups", IDS_SETTINGS_SITE_SETTINGS_POPUPS},
{"siteSettingsCategoryZoomLevels", IDS_SETTINGS_SITE_SETTINGS_ZOOM_LEVELS},
{"siteSettingsAllSites", IDS_SETTINGS_SITE_SETTINGS_ALL_SITES},
+ {"siteSettingsAllSitesDescription",
+ IDS_SETTINGS_SITE_SETTINGS_ALL_SITES_DESCRIPTION},
{"siteSettingsAutomaticDownloads",
IDS_SETTINGS_SITE_SETTINGS_AUTOMATIC_DOWNLOADS},
{"siteSettingsBackgroundSync", IDS_SETTINGS_SITE_SETTINGS_BACKGROUND_SYNC},
@@ -2250,9 +2360,8 @@ void AddSiteSettingsStrings(content::WebUIDataSource* html_source,
AddLocalizedStringsBulk(html_source, localized_strings,
arraysize(localized_strings));
- html_source->AddBoolean("enableSiteSettings",
- base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableSiteSettings));
+ html_source->AddBoolean("enableSiteSettings", base::FeatureList::IsEnabled(
+ features::kSiteSettings));
html_source->AddBoolean(
"enableSafeBrowsingSubresourceFilter",
base::FeatureList::IsEnabled(
@@ -2417,6 +2526,7 @@ void AddLocalizedStrings(content::WebUIDataSource* html_source,
AddWebContentStrings(html_source);
#if defined(OS_CHROMEOS)
+ AddCrostiniStrings(html_source);
AddAndroidAppStrings(html_source);
AddBluetoothStrings(html_source);
AddChromeOSUserStrings(html_source, profile);
diff --git a/chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc b/chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc
index f8e4ae44148..c7ca00e9642 100644
--- a/chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc
+++ b/chromium/chrome/browser/ui/webui/settings/md_settings_ui.cc
@@ -13,6 +13,7 @@
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
+#include "build/build_config.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/unified_consent_helper.h"
#include "chrome/browser/ui/webui/metrics_handler.h"
@@ -55,7 +56,7 @@
#include "chrome/browser/safe_browsing/chrome_cleaner/srt_field_trial_win.h"
#include "chrome/browser/ui/webui/settings/chrome_cleanup_handler.h"
#if defined(GOOGLE_CHROME_BUILD)
-#include "chrome/browser/conflicts/problematic_programs_updater_win.h"
+#include "chrome/browser/conflicts/incompatible_applications_updater_win.h"
#include "chrome/browser/conflicts/token_util_win.h"
#include "chrome/browser/ui/webui/settings/incompatible_applications_handler_win.h"
#include "chrome/grit/chrome_unscaled_resources.h"
@@ -69,12 +70,17 @@
#if defined(OS_CHROMEOS)
#include "ash/public/cpp/stylus_utils.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
+#include "chrome/browser/chromeos/crostini/crostini_util.h"
#include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h"
+#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/ui/ash/ash_util.h"
#include "chrome/browser/ui/webui/settings/chromeos/accessibility_handler.h"
+#include "chrome/browser/ui/webui/settings/chromeos/account_manager_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/android_apps_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/change_picture_handler.h"
+#include "chrome/browser/ui/webui/settings/chromeos/crostini_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/date_time_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h"
@@ -88,6 +94,8 @@
#include "chrome/browser/ui/webui/settings/chromeos/internet_handler.h"
#include "chrome/browser/ui/webui/settings/chromeos/smb_handler.h"
#include "chrome/common/chrome_switches.h"
+#include "chromeos/account_manager/account_manager.h"
+#include "chromeos/account_manager/account_manager_factory.h"
#include "chromeos/chromeos_switches.h"
#include "components/arc/arc_util.h"
#else // !defined(OS_CHROMEOS)
@@ -173,8 +181,22 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
std::make_unique<chromeos::settings::AccessibilityHandler>(web_ui));
AddSettingsPageUIHandler(
std::make_unique<chromeos::settings::AndroidAppsHandler>(profile));
+
+ chromeos::AccountManagerFactory* factory =
+ g_browser_process->platform_part()->GetAccountManagerFactory();
+ chromeos::AccountManager* account_manager =
+ factory->GetAccountManager(profile->GetPath().value());
+ DCHECK(account_manager);
+ AddSettingsPageUIHandler(
+ std::make_unique<chromeos::settings::AccountManagerUIHandler>(
+ account_manager,
+ AccountTrackerServiceFactory::GetInstance()->GetForProfile(profile)));
AddSettingsPageUIHandler(
std::make_unique<chromeos::settings::ChangePictureHandler>());
+ if (IsCrostiniUIAllowedForProfile(profile)) {
+ AddSettingsPageUIHandler(
+ std::make_unique<chromeos::settings::CrostiniHandler>());
+ }
AddSettingsPageUIHandler(
std::make_unique<chromeos::settings::CupsPrintersHandler>(web_ui));
AddSettingsPageUIHandler(
@@ -208,36 +230,24 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
content::WebUIDataSource* html_source =
content::WebUIDataSource::Create(chrome::kChromeUISettingsHost);
+ html_source->OverrideContentSecurityPolicyScriptSrc(
+ "script-src chrome://resources 'self';");
#if defined(OS_WIN)
- bool chromeCleanupEnabled = false;
- bool userInitiatedCleanupsEnabled = false;
-
AddSettingsPageUIHandler(std::make_unique<ChromeCleanupHandler>(profile));
- safe_browsing::ChromeCleanerController* cleaner_controller =
- safe_browsing::ChromeCleanerController::GetInstance();
- chromeCleanupEnabled = cleaner_controller->ShouldShowCleanupInSettingsUI();
- userInitiatedCleanupsEnabled = safe_browsing::UserInitiatedCleanupsEnabled();
-
#if defined(GOOGLE_CHROME_BUILD)
html_source->AddResourcePath("partner-logo.svg", IDR_CHROME_CLEANUP_PARTNER);
#if BUILDFLAG(OPTIMIZE_WEBUI)
exclude_from_gzip.push_back("partner-logo.svg");
#endif
#endif // defined(GOOGLE_CHROME_BUILD)
-
- html_source->AddBoolean("chromeCleanupEnabled", chromeCleanupEnabled);
- // Don't need to save this variable in UpdateCleanupDataSource() because it
- // should never change while Chrome is open.
- html_source->AddBoolean("userInitiatedCleanupsEnabled",
- userInitiatedCleanupsEnabled);
#endif // defined(OS_WIN)
#if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
bool has_incompatible_applications =
- ProblematicProgramsUpdater::IsIncompatibleApplicationsWarningEnabled() &&
- ProblematicProgramsUpdater::HasCachedPrograms();
+ IncompatibleApplicationsUpdater::IsWarningEnabled() &&
+ IncompatibleApplicationsUpdater::HasCachedApplications();
html_source->AddBoolean("showIncompatibleApplications",
has_incompatible_applications);
html_source->AddBoolean("hasAdminRights", HasAdminRights());
@@ -284,6 +294,9 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
html_source->AddBoolean("hasInternalStylus",
ash::stylus_utils::HasInternalStylus());
+ html_source->AddBoolean("showCrostini",
+ IsCrostiniUIAllowedForProfile(profile));
+
// We have 2 variants of Android apps settings. Default case, when the Play
// Store app exists we show expandable section that allows as to
// enable/disable the Play Store and link to Android settings which is
@@ -311,10 +324,6 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
html_source->AddBoolean("unifiedConsentEnabled",
IsUnifiedConsentEnabled(profile));
- html_source->AddBoolean("showExportPasswords",
- base::FeatureList::IsEnabled(
- password_manager::features::kPasswordExport));
-
html_source->AddBoolean("showImportPasswords",
base::FeatureList::IsEnabled(
password_manager::features::kPasswordImport));
@@ -348,14 +357,6 @@ MdSettingsUI::MdSettingsUI(content::WebUI* web_ui)
content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
html_source);
-
-#if defined(OS_WIN)
- // This needs to be below content::WebUIDataSource::Add to make sure there
- // is a WebUIDataSource to update if the observer is immediately notified.
- cleanup_observer_.reset(
- new safe_browsing::ChromeCleanerStateChangeObserver(base::Bind(
- &MdSettingsUI::UpdateCleanupDataSource, base::Unretained(this))));
-#endif // defined(OS_WIN)
}
MdSettingsUI::~MdSettingsUI() {
@@ -386,17 +387,4 @@ void MdSettingsUI::DocumentOnLoadCompletedInMainFrame() {
base::Time::Now() - load_start_time_);
}
-#if defined(OS_WIN)
-void MdSettingsUI::UpdateCleanupDataSource(bool cleanupEnabled) {
- DCHECK(web_ui());
- Profile* profile = Profile::FromWebUI(web_ui());
-
- std::unique_ptr<base::DictionaryValue> update(new base::DictionaryValue);
- update->SetBoolean("chromeCleanupEnabled", cleanupEnabled);
-
- content::WebUIDataSource::Update(profile, chrome::kChromeUISettingsHost,
- std::move(update));
-}
-#endif // defined(OS_WIN)
-
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/md_settings_ui.h b/chromium/chrome/browser/ui/webui/settings/md_settings_ui.h
index 034c00defaf..f9182a0af66 100644
--- a/chromium/chrome/browser/ui/webui/settings/md_settings_ui.h
+++ b/chromium/chrome/browser/ui/webui/settings/md_settings_ui.h
@@ -9,14 +9,9 @@
#include "base/macros.h"
#include "base/time/time.h"
-#include "build/build_config.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_ui_controller.h"
-#if defined(OS_WIN)
-#include "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_state_change_observer_win.h"
-#endif
-
namespace content {
class WebUIMessageHandler;
}
@@ -49,12 +44,6 @@ class MdSettingsUI : public content::WebUIController,
base::Time load_start_time_;
-#if defined(OS_WIN)
- void UpdateCleanupDataSource(bool cleanupEnabled);
- std::unique_ptr<safe_browsing::ChromeCleanerStateChangeObserver>
- cleanup_observer_;
-#endif
-
DISALLOW_COPY_AND_ASSIGN(MdSettingsUI);
};
diff --git a/chromium/chrome/browser/ui/webui/settings/people_handler.cc b/chromium/chrome/browser/ui/webui/settings/people_handler.cc
index 23e8d1044e0..75d91f07c7c 100644
--- a/chromium/chrome/browser/ui/webui/settings/people_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/people_handler.cc
@@ -59,6 +59,7 @@
#include "ui/base/webui/web_ui_util.h"
#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/login/quick_unlock/pin_backend.h"
#include "components/signin/core/browser/signin_manager_base.h"
#else
#include "chrome/browser/ui/user_manager.h"
@@ -224,10 +225,6 @@ void PeopleHandler::RegisterMessages() {
base::BindRepeating(&PeopleHandler::HandleSetDatatypes,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
- "SyncSetupSetSyncEverything",
- base::BindRepeating(&PeopleHandler::HandleSetSyncEverything,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
"SyncSetupSetEncryption",
base::BindRepeating(&PeopleHandler::HandleSetEncryption,
base::Unretained(this)));
@@ -248,6 +245,10 @@ void PeopleHandler::RegisterMessages() {
"AttemptUserExit",
base::BindRepeating(&PeopleHandler::HandleAttemptUserExit,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "RequestPinLoginState",
+ base::BindRepeating(&PeopleHandler::HandleRequestPinLoginState,
+ base::Unretained(this)));
#else
web_ui()->RegisterMessageCallback(
"SyncSetupStopSyncing",
@@ -367,6 +368,12 @@ void PeopleHandler::DisplayGaiaLoginInNewTabOrWindow(
}
#endif
+#if defined(OS_CHROMEOS)
+void PeopleHandler::OnPinLoginAvailable(bool is_available) {
+ FireWebUIListener("pin-login-available-changed", base::Value(is_available));
+}
+#endif
+
void PeopleHandler::DisplaySpinner() {
configuring_sync_ = true;
@@ -461,30 +468,6 @@ void PeopleHandler::HandleSetDatatypes(const base::ListValue* args) {
ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_CHOOSE);
}
-// This function is different from HandleSetDatatypes, in that it only sets
-// the syncAllDatatypes without overriding other prefs' on-disk values.
-void PeopleHandler::HandleSetSyncEverything(const base::ListValue* args) {
- DCHECK(!sync_startup_tracker_);
-
- CHECK_EQ(2U, args->GetSize());
- const base::Value& callback_id = args->GetList()[0];
- bool sync_everything = args->GetList()[1].GetBool();
-
- ProfileSyncService* service = GetSyncService();
- // If the sync engine has shutdown for some reason, just close the sync
- // dialog.
- if (!service || !service->IsEngineInitialized()) {
- CloseSyncSetup();
- ResolveJavascriptCallback(callback_id, base::Value(kDonePageStatus));
- return;
- }
-
- service->OnUserChangedSyncEverythingOnly(sync_everything);
- ResolveJavascriptCallback(callback_id, base::Value(kConfigurePageStatus));
-
- ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_CUSTOMIZE);
-}
-
#if BUILDFLAG(ENABLE_DICE_SUPPORT)
void PeopleHandler::HandleGetStoredAccounts(const base::ListValue* args) {
CHECK_EQ(1U, args->GetSize());
@@ -638,6 +621,9 @@ void PeopleHandler::HandleShowSetupUI(const base::ListValue* args) {
if (service && !sync_blocker_)
sync_blocker_ = service->GetSetupInProgressHandle();
+ // Preemptively mark login UI as active, because the user could potentially
+ // sign-in directly from this UI without triggering handleShowSetupUI again.
+ GetLoginUIService()->SetLoginUI(this);
FireWebUIListener("sync-prefs-changed", base::DictionaryValue());
return;
}
@@ -702,6 +688,13 @@ void PeopleHandler::HandleAttemptUserExit(const base::ListValue* args) {
DVLOG(1) << "Signing out the user to fix a sync error.";
chrome::AttemptUserExit();
}
+
+void PeopleHandler::HandleRequestPinLoginState(const base::ListValue* args) {
+ AllowJavascript();
+ chromeos::quick_unlock::PinBackend::GetInstance()->HasLoginSupport(
+ base::BindOnce(&PeopleHandler::OnPinLoginAvailable,
+ weak_factory_.GetWeakPtr()));
+}
#endif
#if !defined(OS_CHROMEOS)
diff --git a/chromium/chrome/browser/ui/webui/settings/people_handler.h b/chromium/chrome/browser/ui/webui/settings/people_handler.h
index 392f0d92475..b39378b9726 100644
--- a/chromium/chrome/browser/ui/webui/settings/people_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/people_handler.h
@@ -10,6 +10,7 @@
#include "base/gtest_prod_util.h"
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h"
#include "base/strings/utf_string_conversions.h"
#include "base/timer/timer.h"
@@ -167,9 +168,11 @@ class PeopleHandler : public SettingsPageUIHandler,
void OnDidClosePage(const base::ListValue* args);
void HandleSetDatatypes(const base::ListValue* args);
void HandleSetEncryption(const base::ListValue* args);
- void HandleSetSyncEverything(const base::ListValue* args);
void HandleShowSetupUI(const base::ListValue* args);
void HandleAttemptUserExit(const base::ListValue* args);
+#if defined(OS_CHROMEOS)
+ void HandleRequestPinLoginState(const base::ListValue* args);
+#endif
void HandleStartSignin(const base::ListValue* args);
void HandleStopSyncing(const base::ListValue* args);
void HandleGetSyncStatus(const base::ListValue* args);
@@ -185,6 +188,10 @@ class PeopleHandler : public SettingsPageUIHandler,
signin_metrics::AccessPoint access_point);
#endif
+#if defined(OS_CHROMEOS)
+ void OnPinLoginAvailable(bool is_available);
+#endif
+
#if BUILDFLAG(ENABLE_DICE_SUPPORT)
void HandleGetStoredAccounts(const base::ListValue* args);
void HandleStartSyncingWithEmail(const base::ListValue* args);
@@ -255,6 +262,10 @@ class PeopleHandler : public SettingsPageUIHandler,
account_tracker_observer_;
#endif
+#if defined(OS_CHROMEOS)
+ base::WeakPtrFactory<PeopleHandler> weak_factory_{this};
+#endif
+
DISALLOW_COPY_AND_ASSIGN(PeopleHandler);
};
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 e7c647fe122..894c4e05cbd 100644
--- a/chromium/chrome/browser/ui/webui/settings/profile_info_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/profile_info_handler.cc
@@ -17,7 +17,7 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/ui/webui/chromeos/user_image_source.h"
-#include "components/signin/core/account_id/account_id.h"
+#include "components/account_id/account_id.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/notification_service.h"
#else
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 4cc1ff9e229..ea77a494627 100644
--- a/chromium/chrome/browser/ui/webui/settings/reset_settings_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/reset_settings_handler.cc
@@ -14,7 +14,9 @@
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/google/google_brand.h"
+#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/prefs/chrome_pref_service_factory.h"
#include "chrome/browser/profile_resetter/brandcode_config_fetcher.h"
#include "chrome/browser/profile_resetter/brandcoded_default_settings.h"
@@ -26,6 +28,7 @@
#include "components/prefs/pref_service.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
+#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "ui/base/l10n/l10n_util.h"
#if defined(OS_CHROMEOS)
@@ -212,10 +215,11 @@ void ResetSettingsHandler::OnShowResetProfileDialog(
if (brandcode_.empty())
return;
config_fetcher_.reset(new BrandcodeConfigFetcher(
+ g_browser_process->system_network_context_manager()
+ ->GetURLLoaderFactory(),
base::Bind(&ResetSettingsHandler::OnSettingsFetched,
base::Unretained(this)),
- GURL("https://tools.google.com/service/update2"),
- brandcode_));
+ GURL("https://tools.google.com/service/update2"), brandcode_));
}
void ResetSettingsHandler::OnHideResetProfileDialog(
diff --git a/chromium/chrome/browser/ui/webui/settings/search_engines_handler.cc b/chromium/chrome/browser/ui/webui/settings/search_engines_handler.cc
index bf98d178d56..878159e995c 100644
--- a/chromium/chrome/browser/ui/webui/settings/search_engines_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/search_engines_handler.cc
@@ -188,6 +188,7 @@ SearchEnginesHandler::CreateDictionaryForEngine(int index, bool is_default) {
// in @typedef for SearchEngine. Please update it whenever you add or remove
// any keys here.
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
+ dict->SetInteger("id", template_url->id());
dict->SetString("name", template_url->short_name());
dict->SetString("displayName",
table_model->GetText(
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 f6e53a16445..c1442684021 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
@@ -487,7 +487,7 @@ void ClearBrowsingDataHandler::UpdateCounterText(
CallJavascriptFunction(
"cr.webUIListenerCallback", base::Value("update-counter-text"),
base::Value(result->source()->GetPrefName()),
- base::Value(GetChromeCounterTextFromResult(result.get())));
+ base::Value(GetChromeCounterTextFromResult(result.get(), profile_)));
}
void ClearBrowsingDataHandler::HandleTimePeriodChanged(
diff --git a/chromium/chrome/browser/ui/webui/settings/tts_handler.cc b/chromium/chrome/browser/ui/webui/settings/tts_handler.cc
index fcb19846e6a..44cfc2fa7f9 100644
--- a/chromium/chrome/browser/ui/webui/settings/tts_handler.cc
+++ b/chromium/chrome/browser/ui/webui/settings/tts_handler.cc
@@ -5,48 +5,152 @@
#include "chrome/browser/ui/webui/settings/tts_handler.h"
#include "base/bind.h"
+#include "base/json/json_reader.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/speech/extension_api/tts_engine_extension_api.h"
+#include "chrome/browser/speech/extension_api/tts_engine_extension_observer.h"
+#include "chrome/browser/speech/tts_controller.h"
#include "chrome/browser/speech/tts_controller_impl.h"
#include "chrome/common/extensions/extension_constants.h"
#include "content/public/browser/web_ui.h"
+#include "extensions/browser/event_router.h"
+#include "extensions/browser/extension_registry.h"
+#include "extensions/common/extension.h"
+#include "extensions/common/extension_set.h"
+#include "extensions/common/manifest_handlers/options_page_info.h"
#include "ui/base/l10n/l10n_util.h"
namespace settings {
-void TtsHandler::HandleGetGoogleTtsVoiceData(const base::ListValue* args) {
+void TtsHandler::HandleGetAllTtsVoiceData(const base::ListValue* args) {
OnVoicesChanged();
}
+void TtsHandler::HandleGetTtsExtensions(const base::ListValue* args) {
+ base::ListValue responses;
+ Profile* profile = Profile::FromWebUI(web_ui());
+ extensions::ExtensionRegistry* registry =
+ extensions::ExtensionRegistry::Get(profile);
+
+ const std::set<std::string> extensions =
+ TtsEngineExtensionObserver::GetInstance(profile)->GetTtsExtensions();
+ std::set<std::string>::const_iterator iter;
+ for (iter = extensions.begin(); iter != extensions.end(); ++iter) {
+ const std::string extension_id = *iter;
+ const extensions::Extension* extension =
+ registry->GetInstalledExtension(extension_id);
+ if (!extension) {
+ // The extension is still loading from OnVoicesChange call to
+ // TtsControllerImpl::GetVoices(). Don't do any work, voices will
+ // be updated again after extension load.
+ continue;
+ }
+ base::DictionaryValue response;
+ response.SetPath({"name"}, base::Value(extension->name()));
+ response.SetPath({"extensionId"}, base::Value(extension_id));
+ if (extensions::OptionsPageInfo::HasOptionsPage(extension)) {
+ response.SetPath(
+ {"optionsPage"},
+ base::Value(
+ extensions::OptionsPageInfo::GetOptionsPage(extension).spec()));
+ }
+ responses.GetList().push_back(std::move(response));
+ }
+
+ CallJavascriptFunction("cr.webUIListenerCallback",
+ base::Value("tts-extensions-updated"), responses);
+}
+
void TtsHandler::OnVoicesChanged() {
TtsControllerImpl* impl = TtsControllerImpl::GetInstance();
std::vector<VoiceData> voices;
impl->GetVoices(Profile::FromWebUI(web_ui()), &voices);
+ const std::string& app_locale = g_browser_process->GetApplicationLocale();
base::ListValue responses;
for (const auto& voice : voices) {
- if (voice.extension_id != extension_misc::kSpeechSynthesisExtensionId)
- continue;
-
base::DictionaryValue response;
+ int language_score = GetVoiceLangMatchScore(&voice, app_locale);
+ std::string language_code = l10n_util::GetLanguage(voice.lang);
response.SetPath({"name"}, base::Value(voice.name));
+ response.SetPath({"languageCode"}, base::Value(language_code));
+ response.SetPath({"fullLanguageCode"}, base::Value(voice.lang));
+ response.SetPath({"languageScore"}, base::Value(language_score));
+ response.SetPath({"extensionId"}, base::Value(voice.extension_id));
response.SetPath(
- {"language"},
+ {"displayLanguage"},
base::Value(l10n_util::GetDisplayNameForLocale(
- voice.lang, g_browser_process->GetApplicationLocale(), true)));
- response.SetPath({"builtIn"}, base::Value(true));
+ language_code, g_browser_process->GetApplicationLocale(), true)));
responses.GetList().push_back(std::move(response));
}
AllowJavascript();
CallJavascriptFunction("cr.webUIListenerCallback",
- base::Value("google-voice-data-updated"), responses);
+ base::Value("all-voice-data-updated"), responses);
+
+ // Also refresh the TTS extensions in case they have changed.
+ HandleGetTtsExtensions(nullptr);
+}
+
+void TtsHandler::HandlePreviewTtsVoice(const base::ListValue* args) {
+ DCHECK_EQ(2U, args->GetSize());
+ std::string text;
+ std::string voice_id;
+ args->GetString(0, &text);
+ args->GetString(1, &voice_id);
+
+ if (text.empty() || voice_id.empty())
+ return;
+
+ std::unique_ptr<base::DictionaryValue> json =
+ base::DictionaryValue::From(base::JSONReader::Read(voice_id));
+ std::string name;
+ std::string extension_id;
+ json->GetString("name", &name);
+ json->GetString("extension", &extension_id);
+
+ Utterance* utterance = new Utterance(Profile::FromWebUI(web_ui()));
+ utterance->set_text(text);
+ utterance->set_voice_name(name);
+ utterance->set_extension_id(extension_id);
+ utterance->set_src_url(GURL("chrome://settings/manageAccessibility/tts"));
+ utterance->set_event_delegate(nullptr);
+ TtsController::GetInstance()->Stop();
+ TtsController::GetInstance()->SpeakOrEnqueue(utterance);
}
void TtsHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
- "getGoogleTtsVoiceData",
- base::BindRepeating(&TtsHandler::HandleGetGoogleTtsVoiceData,
+ "getAllTtsVoiceData",
+ base::BindRepeating(&TtsHandler::HandleGetAllTtsVoiceData,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "getTtsExtensions",
+ base::BindRepeating(&TtsHandler::HandleGetTtsExtensions,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "previewTtsVoice", base::BindRepeating(&TtsHandler::HandlePreviewTtsVoice,
+ base::Unretained(this)));
+}
+
+void TtsHandler::OnJavascriptAllowed() {
+ TtsController::GetInstance()->AddVoicesChangedDelegate(this);
+}
+
+void TtsHandler::OnJavascriptDisallowed() {
+ TtsController::GetInstance()->RemoveVoicesChangedDelegate(this);
+}
+
+int TtsHandler::GetVoiceLangMatchScore(const VoiceData* voice,
+ const std::string& app_locale) {
+ if (voice->lang.empty() || app_locale.empty())
+ return 0;
+ if (voice->lang == app_locale)
+ return 2;
+ return l10n_util::GetLanguage(voice->lang) ==
+ l10n_util::GetLanguage(app_locale)
+ ? 1
+ : 0;
}
} // namespace settings
diff --git a/chromium/chrome/browser/ui/webui/settings/tts_handler.h b/chromium/chrome/browser/ui/webui/settings/tts_handler.h
index 36e76c5a592..94dfef0c727 100644
--- a/chromium/chrome/browser/ui/webui/settings/tts_handler.h
+++ b/chromium/chrome/browser/ui/webui/settings/tts_handler.h
@@ -16,17 +16,22 @@ class TtsHandler : public SettingsPageUIHandler, public VoicesChangedDelegate {
TtsHandler() = default;
~TtsHandler() override = default;
- void HandleGetGoogleTtsVoiceData(const base::ListValue* args);
+ void HandleGetAllTtsVoiceData(const base::ListValue* args);
+ void HandleGetTtsExtensions(const base::ListValue* args);
+ void HandlePreviewTtsVoice(const base::ListValue* args);
// SettingsPageUIHandler implementation.
void RegisterMessages() override;
- void OnJavascriptAllowed() override {}
- void OnJavascriptDisallowed() override {}
+ void OnJavascriptAllowed() override;
+ void OnJavascriptDisallowed() override;
// VoicesChangedDelegate implementation.
void OnVoicesChanged() override;
private:
+ int GetVoiceLangMatchScore(const VoiceData* voice,
+ const std::string& app_locale);
+
DISALLOW_COPY_AND_ASSIGN(TtsHandler);
};
diff --git a/chromium/chrome/browser/ui/webui/settings_utils_win.cc b/chromium/chrome/browser/ui/webui/settings_utils_win.cc
index 7badcf5a77c..4445ceebfe2 100644
--- a/chromium/chrome/browser/ui/webui/settings_utils_win.cc
+++ b/chromium/chrome/browser/ui/webui/settings_utils_win.cc
@@ -76,15 +76,15 @@ void OpenConnectionDialogCallback() {
// new dialog to be made for each call. rundll32 uses the same global
// dialog and it seems to share with the shortcut in control panel.
base::FilePath rundll32;
- PathService::Get(base::DIR_SYSTEM, &rundll32);
+ base::PathService::Get(base::DIR_SYSTEM, &rundll32);
rundll32 = rundll32.AppendASCII("rundll32.exe");
base::FilePath shell32dll;
- PathService::Get(base::DIR_SYSTEM, &shell32dll);
+ base::PathService::Get(base::DIR_SYSTEM, &shell32dll);
shell32dll = shell32dll.AppendASCII("shell32.dll");
base::FilePath inetcpl;
- PathService::Get(base::DIR_SYSTEM, &inetcpl);
+ base::PathService::Get(base::DIR_SYSTEM, &inetcpl);
inetcpl = inetcpl.AppendASCII("inetcpl.cpl,,4");
std::wstring args(shell32dll.value());
diff --git a/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.cc b/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.cc
index f58263abf99..3773b85e3c8 100644
--- a/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.cc
+++ b/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper.cc
@@ -251,7 +251,8 @@ void DiceTurnSyncOnHelper::LoadPolicyWithCachedCredentials() {
policy::UserPolicySigninService* policy_service =
policy::UserPolicySigninServiceFactory::GetForProfile(profile_);
policy_service->FetchPolicyForSignedInUser(
- account_info_.email, dm_token_, client_id_, profile_->GetRequestContext(),
+ account_info_.GetAccountId(), dm_token_, client_id_,
+ profile_->GetRequestContext(),
base::Bind(&DiceTurnSyncOnHelper::OnPolicyFetchComplete,
weak_pointer_factory_.GetWeakPtr()));
}
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 7f134e11654..b65a4205471 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
@@ -28,6 +28,7 @@
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
+#include "components/account_id/account_id.h"
#include "components/browser_sync/profile_sync_service_mock.h"
#include "components/prefs/pref_service.h"
#include "components/signin/core/browser/account_tracker_service.h"
@@ -150,7 +151,7 @@ class FakeUserPolicySigninService : public policy::UserPolicySigninService {
// policy::UserPolicySigninServiceBase:
void FetchPolicyForSignedInUser(
- const std::string& username,
+ const AccountId& account_id,
const std::string& dm_token,
const std::string& client_id,
scoped_refptr<net::URLRequestContextGetter> profile_request_context,
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 93fe4d5a4a1..3cb823c1204 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
@@ -236,9 +236,9 @@ void InlineSigninHelper::OnClientOAuthSuccessAndBrowserOpened(
scoped_refptr<password_manager::PasswordStore> password_store =
PasswordStoreFactory::GetForProfile(profile_,
ServiceAccessType::EXPLICIT_ACCESS);
- if (password_store) {
+ if (password_store && !primary_email.empty()) {
password_store->SaveSyncPasswordHash(
- base::UTF8ToUTF16(password_),
+ primary_email, base::UTF8ToUTF16(password_),
password_manager::metrics_util::SyncPasswordHashChange::
SAVED_ON_CHROME_SIGNIN);
}
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 4ef22822f58..7082a0335c6 100644
--- a/chromium/chrome/browser/ui/webui/signin/login_ui_service.cc
+++ b/chromium/chrome/browser/ui/webui/signin/login_ui_service.cc
@@ -5,7 +5,11 @@
#include "chrome/browser/ui/webui/signin/login_ui_service.h"
#include "build/build_config.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_attributes_entry.h"
+#include "chrome/browser/profiles/profile_attributes_storage.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/signin_promo.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
@@ -17,7 +21,114 @@
#include "components/signin/core/browser/signin_header_helper.h"
#if !defined(OS_CHROMEOS)
+#include "base/scoped_observer.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
+#include "chrome/browser/signin/unified_consent_helper.h"
+#include "chrome/browser/sync/profile_sync_service_factory.h"
+#include "chrome/browser/sync/sync_ui_util.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/browser_list_observer.h"
#include "chrome/browser/ui/user_manager.h"
+#include "components/sync/base/sync_prefs.h"
+
+// The sync consent bump is shown after startup when a profile's browser
+// instance becomes active or when there is already an active instance.
+// It is only shown when |ShouldShowConsentBumpFor(profile)| returns true for a
+// given profile |profile|.
+class ConsentBumpActivator : public BrowserListObserver,
+ public LoginUIService::Observer {
+ public:
+ // Creates a ConsentBumpActivator for |profile| which is owned by
+ // |login_ui_service|.
+ ConsentBumpActivator(LoginUIService* login_ui_service, Profile* profile)
+ : login_ui_service_(login_ui_service),
+ profile_(profile),
+ scoped_browser_list_observer_(this),
+ scoped_login_ui_service_observer_(this) {
+ // Check if there is already an active browser window for |profile|.
+ Browser* active_browser = chrome::FindLastActiveWithProfile(profile);
+ if (active_browser)
+ OnBrowserSetLastActive(active_browser);
+ else
+ scoped_browser_list_observer_.Add(BrowserList::GetInstance());
+ }
+
+ // BrowserListObserver:
+ void OnBrowserSetLastActive(Browser* browser) override {
+ if (browser->profile() != profile_)
+ return;
+ // We only try to show the consent bump once after startup, so remove |this|
+ // as a |BrowserListObserver|.
+ scoped_browser_list_observer_.RemoveAll();
+
+ if (ShouldShowConsentBumpFor(profile_)) {
+ selected_browser_ = browser;
+ scoped_login_ui_service_observer_.Add(login_ui_service_);
+ selected_browser_->signin_view_controller()->ShowModalSyncConsentBump(
+ selected_browser_);
+ }
+ }
+
+ // LoginUIService::Observer:
+ void OnSyncConfirmationUIClosed(
+ LoginUIService::SyncConfirmationUIClosedResult result) override {
+ scoped_login_ui_service_observer_.RemoveAll();
+
+ // TODO(crbug.com/819909): Record that consent bump was shown.
+
+ switch (result) {
+ case LoginUIService::CONFIGURE_SYNC_FIRST:
+ chrome::ShowSettingsSubPage(selected_browser_,
+ chrome::kSyncSetupSubPage);
+ break;
+ case LoginUIService::SYNC_WITH_DEFAULT_SETTINGS:
+ // User gave unified consent.
+ // TODO(crbug.com/819909): Use unity service to record unified consent /
+ // set pref.
+ break;
+ case LoginUIService::ABORT_SIGNIN:
+ // "Make no changes" was selected.
+ break;
+ }
+ }
+
+ // This should only be called after the browser has been set up, otherwise
+ // this might crash because the profile has not been fully initialized yet.
+ static bool ShouldShowConsentBumpFor(Profile* profile) {
+ if (!profile->IsSyncAllowed() || !IsUnifiedConsentBumpEnabled(profile))
+ return false;
+
+ // TODO(crbug.com/819909): Check if the consent bump or sync confirmation
+ // has been shown already. (Unity service)
+
+ if (!ProfileSyncServiceFactory::HasProfileSyncService(profile))
+ return false;
+ sync_ui_util::MessageType sync_status = sync_ui_util::GetStatus(
+ profile, ProfileSyncServiceFactory::GetForProfile(profile),
+ *SigninManagerFactory::GetForProfile(profile));
+ syncer::SyncPrefs prefs(profile->GetPrefs());
+
+ return sync_status == sync_ui_util::SYNCED &&
+ prefs.HasKeepEverythingSynced();
+ }
+
+ private:
+ LoginUIService* login_ui_service_; // owner
+
+ Profile* profile_;
+
+ ScopedObserver<BrowserList, ConsentBumpActivator>
+ scoped_browser_list_observer_;
+ ScopedObserver<LoginUIService, ConsentBumpActivator>
+ scoped_login_ui_service_observer_;
+
+ // Used for the action handling of the consent bump.
+ Browser* selected_browser_ = nullptr;
+
+ DISALLOW_COPY_AND_ASSIGN(ConsentBumpActivator);
+};
+
#endif // !defined(OS_CHROMEOS)
LoginUIService::LoginUIService(Profile* profile)
@@ -25,6 +136,12 @@ LoginUIService::LoginUIService(Profile* profile)
: profile_(profile)
#endif
{
+#if !defined(OS_CHROMEOS)
+ if (IsUnifiedConsentBumpEnabled(profile)) {
+ consent_bump_activator_ =
+ std::make_unique<ConsentBumpActivator>(this, profile);
+ }
+#endif
}
LoginUIService::~LoginUIService() {}
@@ -60,6 +177,18 @@ void LoginUIService::ShowLoginPopup() {
#if defined(OS_CHROMEOS)
NOTREACHED();
#else
+ // There is no sign-in flow for guest or system profile.
+ if (profile_->IsGuestSession() || profile_->IsSystemProfile())
+ return;
+ // Locked profile should be unlocked with UserManager only.
+ ProfileAttributesEntry* entry;
+ if (g_browser_process->profile_manager()
+ ->GetProfileAttributesStorage()
+ .GetProfileAttributesWithPath(profile_->GetPath(), &entry) &&
+ entry->IsSigninRequired()) {
+ return;
+ }
+
chrome::ScopedTabbedBrowserDisplayer displayer(profile_);
chrome::ShowBrowserSignin(
displayer.browser(),
diff --git a/chromium/chrome/browser/ui/webui/signin/login_ui_service.h b/chromium/chrome/browser/ui/webui/signin/login_ui_service.h
index 1458430c43e..438d77285fb 100644
--- a/chromium/chrome/browser/ui/webui/signin/login_ui_service.h
+++ b/chromium/chrome/browser/ui/webui/signin/login_ui_service.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_SIGNIN_LOGIN_UI_SERVICE_H_
#include <list>
+#include <memory>
#include "base/macros.h"
#include "base/observer_list.h"
@@ -14,6 +15,7 @@
class Browser;
class Profile;
+class ConsentBumpActivator;
// The LoginUIService helps track per-profile information for the login related
// UIs - for example, whether there is login UI currently on-screen.
@@ -105,6 +107,7 @@ class LoginUIService : public KeyedService {
std::list<LoginUI*> ui_list_;
#if !defined(OS_CHROMEOS)
Profile* profile_;
+ std::unique_ptr<ConsentBumpActivator> consent_bump_activator_;
#endif
// List of observers.
diff --git a/chromium/chrome/browser/ui/webui/signin/login_ui_service_factory.cc b/chromium/chrome/browser/ui/webui/signin/login_ui_service_factory.cc
index 66c7b5c39ea..a36f3c07aba 100644
--- a/chromium/chrome/browser/ui/webui/signin/login_ui_service_factory.cc
+++ b/chromium/chrome/browser/ui/webui/signin/login_ui_service_factory.cc
@@ -7,6 +7,8 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
+#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/webui/signin/login_ui_service.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/prefs/pref_service.h"
@@ -16,6 +18,8 @@ LoginUIServiceFactory::LoginUIServiceFactory()
: BrowserContextKeyedServiceFactory(
"LoginUIServiceFactory",
BrowserContextDependencyManager::GetInstance()) {
+ DependsOn(SigninManagerFactory::GetInstance());
+ DependsOn(ProfileSyncServiceFactory::GetInstance());
}
LoginUIServiceFactory::~LoginUIServiceFactory() {}
@@ -43,3 +47,7 @@ KeyedService* LoginUIServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* profile) const {
return new LoginUIService(static_cast<Profile*>(profile));
}
+
+bool LoginUIServiceFactory::ServiceIsCreatedWithBrowserContext() const {
+ return true;
+}
diff --git a/chromium/chrome/browser/ui/webui/signin/login_ui_service_factory.h b/chromium/chrome/browser/ui/webui/signin/login_ui_service_factory.h
index d940d346685..f6defd3a23e 100644
--- a/chromium/chrome/browser/ui/webui/signin/login_ui_service_factory.h
+++ b/chromium/chrome/browser/ui/webui/signin/login_ui_service_factory.h
@@ -39,6 +39,7 @@ class LoginUIServiceFactory : public BrowserContextKeyedServiceFactory {
// BrowserContextKeyedServiceFactory:
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* profile) const override;
+ bool ServiceIsCreatedWithBrowserContext() const override;
DISALLOW_COPY_AND_ASSIGN(LoginUIServiceFactory);
};
diff --git a/chromium/chrome/browser/ui/webui/signin/login_ui_service_unittest.cc b/chromium/chrome/browser/ui/webui/signin/login_ui_service_unittest.cc
index d77bb0d95b5..23cd90f37ef 100644
--- a/chromium/chrome/browser/ui/webui/signin/login_ui_service_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/signin/login_ui_service_unittest.cc
@@ -7,8 +7,49 @@
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/macros.h"
+#include "build/build_config.h"
+#include "chrome/test/base/testing_browser_process.h"
+#include "chrome/test/base/testing_profile.h"
+#include "chrome/test/base/testing_profile_manager.h"
+#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
+#if !defined(OS_CHROMEOS)
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/test_extension_system.h"
+#include "chrome/browser/profiles/profile_attributes_entry.h"
+#include "chrome/browser/profiles/profile_attributes_storage.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/test/base/browser_with_test_window_test.h"
+#include "content/public/browser/web_contents.h"
+#include "extensions/common/extension_builder.h"
+#endif
+
+class LoginUIServiceTest : public testing::Test {
+ public:
+ LoginUIServiceTest()
+ : profile_manager_(TestingBrowserProcess::GetGlobal()),
+ profile_(nullptr) {}
+ ~LoginUIServiceTest() override {}
+
+ void SetUp() override {
+ ASSERT_TRUE(profile_manager_.SetUp());
+ profile_ = profile_manager_.CreateTestingProfile("Person 1");
+ }
+
+ protected:
+ content::TestBrowserThreadBundle thread_bundle_;
+
+ TestingProfileManager profile_manager_;
+ // Test profile used by all tests - this is owned by profile_manager_.
+ TestingProfile* profile_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(LoginUIServiceTest);
+};
+
class TestLoginUI : public LoginUIService::LoginUI {
public:
TestLoginUI() { }
@@ -19,8 +60,8 @@ class TestLoginUI : public LoginUIService::LoginUI {
DISALLOW_COPY_AND_ASSIGN(TestLoginUI);
};
-TEST(LoginUIServiceTest, CanSetMultipleLoginUIs) {
- LoginUIService service(nullptr);
+TEST_F(LoginUIServiceTest, CanSetMultipleLoginUIs) {
+ LoginUIService service(profile_);
EXPECT_EQ(nullptr, service.current_login_ui());
@@ -48,8 +89,8 @@ TEST(LoginUIServiceTest, CanSetMultipleLoginUIs) {
EXPECT_EQ(nullptr, service.current_login_ui());
}
-TEST(LoginUIServiceTest, SetProfileBlockingErrorMessage) {
- LoginUIService service(nullptr);
+TEST_F(LoginUIServiceTest, SetProfileBlockingErrorMessage) {
+ LoginUIService service(profile_);
service.SetProfileBlockingErrorMessage();
@@ -57,3 +98,39 @@ TEST(LoginUIServiceTest, SetProfileBlockingErrorMessage) {
EXPECT_EQ(base::string16(), service.GetLastLoginErrorEmail());
EXPECT_TRUE(service.IsDisplayingProfileBlockedErrorMessage());
}
+
+#if !defined(OS_CHROMEOS)
+class LoginUIServiceLoginPopupTest : public BrowserWithTestWindowTest {
+ public:
+ void SetUp() override {
+ BrowserWithTestWindowTest::SetUp();
+
+ service_ = std::make_unique<LoginUIService>(profile());
+ model_ = browser()->tab_strip_model();
+ ASSERT_EQ(0, model_->count());
+ }
+
+ std::unique_ptr<LoginUIService> service_;
+ TabStripModel* model_;
+};
+
+TEST_F(LoginUIServiceLoginPopupTest, ShowLoginPop) {
+ extensions::TestExtensionSystem* extension_system =
+ static_cast<extensions::TestExtensionSystem*>(
+ extensions::ExtensionSystem::Get(profile()));
+ extension_system->CreateExtensionService(
+ base::CommandLine::ForCurrentProcess(), base::FilePath(), false);
+ service_->ShowLoginPopup();
+ EXPECT_EQ(1, model_->count());
+}
+
+TEST_F(LoginUIServiceLoginPopupTest, NotShowLoginPopAsLockedProfile) {
+ ProfileAttributesEntry* entry;
+ ASSERT_TRUE(g_browser_process->profile_manager()
+ ->GetProfileAttributesStorage()
+ .GetProfileAttributesWithPath(profile()->GetPath(), &entry));
+ entry->SetIsSigninRequired(true);
+ service_->ShowLoginPopup();
+ EXPECT_EQ(0, model_->count());
+}
+#endif
diff --git a/chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.cc b/chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.cc
index 05d2e824c6e..ba4b6ef5ea3 100644
--- a/chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.cc
+++ b/chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.cc
@@ -6,35 +6,48 @@
#include "base/run_loop.h"
#include "base/scoped_observer.h"
+#include "base/test/bind_test_util.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/signin/account_consistency_mode_manager.h"
#include "chrome/browser/signin/signin_promo.h"
#include "chrome/browser/signin/signin_tracker_factory.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/signin_view_controller_delegate.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/webui/signin/login_ui_service.h"
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
#include "chrome/browser/ui/webui/signin/signin_utils.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "components/signin/core/browser/signin_buildflags.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h"
+#include "content/public/test/test_navigation_observer.h"
using content::MessageLoopRunner;
// anonymous namespace for signin with UI helper functions.
namespace {
+// When Desktop Identity Consistency (Dice) is enabled, the password field is
+// not easily accessible on the Gaia page. This script can be used to return it.
+const char kGetPasswordFieldFromDiceSigninPage[] =
+ "(function() {"
+ " var e = document.getElementById('password');"
+ " if (e == null) return null;"
+ " return e.querySelector('input[type=password]');"
+ "})()";
+
// The SignInObserver observes the signin manager and blocks until a
// GoogleSigninSucceeded or a GoogleSigninFailed notification is fired.
class SignInObserver : public SigninTracker::Observer {
public:
- explicit SignInObserver(bool wait_for_account_cookies)
- : seen_(false),
- running_(false),
- signed_in_(false),
- wait_for_account_cookies_(wait_for_account_cookies) {}
+ SignInObserver() : seen_(false), running_(false), signed_in_(false) {}
virtual ~SignInObserver() {}
@@ -60,22 +73,10 @@ class SignInObserver : public SigninTracker::Observer {
QuitLoopRunner();
}
- void AccountAddedToCookie(const GoogleServiceAuthError& error) override {
- if (!wait_for_account_cookies_)
- return;
- if (error.state() != GoogleServiceAuthError::NONE) {
- DVLOG(1) << "Error signing the account, error " << error.state();
- } else {
- DVLOG(1) << "Account cookies are added to cookie jar.";
- signed_in_ = true;
- }
- QuitLoopRunner();
- }
+ void AccountAddedToCookie(const GoogleServiceAuthError& error) override {}
void SigninSuccess() override {
DVLOG(1) << "Google signin succeeded.";
- if (wait_for_account_cookies_)
- return;
signed_in_ = true;
QuitLoopRunner();
}
@@ -96,10 +97,6 @@ class SignInObserver : public SigninTracker::Observer {
bool running_;
// True if a GoogleSigninSucceeded event has been observed.
bool signed_in_;
- // Whether we should block until the account cookies are added or not.
- // If false, we only wait until SigninSuccess event is fired which happens
- // prior to adding account to cookie.
- bool wait_for_account_cookies_;
scoped_refptr<MessageLoopRunner> message_loop_runner_;
};
@@ -134,8 +131,79 @@ void RunLoopFor(base::TimeDelta duration) {
run_loop.Run();
}
-} // anonymous namespace
+// Returns true if the Dice signin page is used, and false if the embedded
+// signin flow is used.
+// The Dice signin page is shown in a full tab, whereas the embedded signin flow
+// runs inside a WebUI.
+bool IsDiceSigninPageEnabled(Profile* profile) {
+ signin::AccountConsistencyMethod account_consistency =
+ AccountConsistencyModeManager::GetMethodForProfile(profile);
+ return (account_consistency != signin::AccountConsistencyMethod::kMirror) &&
+ signin::DiceMethodGreaterOrEqual(
+ account_consistency,
+ signin::AccountConsistencyMethod::kDicePrepareMigration);
+}
+
+// Returns the render frame host where Gaia credentials can be filled in.
+content::RenderFrameHost* GetSigninFrame(content::WebContents* web_contents) {
+ if (IsDiceSigninPageEnabled(
+ Profile::FromBrowserContext(web_contents->GetBrowserContext()))) {
+ // Dice displays the Gaia page directly in a tab.
+ return web_contents->GetMainFrame();
+ } else {
+ // Embedded signin flow, uses a sub-frame in WebUI.
+ return signin::GetAuthFrame(web_contents, "signin-frame");
+ }
+}
+
+// Waits until the condition is met, by polling.
+void WaitUntilCondition(const base::RepeatingCallback<bool()>& condition,
+ const std::string& error_message) {
+ for (int attempt = 0; attempt < 10; ++attempt) {
+ if (condition.Run())
+ return;
+ RunLoopFor(base::TimeDelta::FromMilliseconds(1000));
+ }
+
+ FAIL() << error_message;
+}
+
+// Evaluates a boolean script expression in the signin frame.
+bool EvaluateBooleanScriptInSigninFrame(Browser* browser,
+ const std::string& script) {
+ content::WebContents* web_contents =
+ browser->tab_strip_model()->GetActiveWebContents();
+ bool result = false;
+ EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
+ GetSigninFrame(web_contents),
+ "window.domAutomationController.send(" + script + ");", &result));
+ return result;
+}
+
+// Returns whether an element with id |element_id| exists in the signin page.
+bool ElementExistsByIdInSigninFrame(Browser* browser,
+ const std::string& element_id) {
+ return EvaluateBooleanScriptInSigninFrame(
+ browser, "document.getElementById('" + element_id + "') != null");
+}
+
+// Blocks until an element with an id from |element_ids| exists in the signin
+// page.
+void WaitUntilAnyElementExistsInSigninFrame(
+ Browser* browser,
+ const std::vector<std::string>& element_ids) {
+ WaitUntilCondition(
+ base::BindLambdaForTesting([&browser, &element_ids]() -> bool {
+ for (const std::string& element_id : element_ids) {
+ if (ElementExistsByIdInSigninFrame(browser, element_id))
+ return true;
+ }
+ return false;
+ }),
+ "Could not find elements in the signin frame");
+}
+} // namespace
namespace login_ui_test_utils {
class SigninViewControllerTestUtil {
@@ -194,52 +262,35 @@ void WaitUntilUIReady(Browser* browser) {
ASSERT_EQ("ready", message);
}
-void WaitUntilElementExistsInSigninFrame(
- Browser* browser,
- const std::vector<std::string>& element_ids) {
- for (int attempt = 0; attempt < 10; ++attempt) {
- for (const std::string& element_id : element_ids) {
- if (ElementExistsInSigninFrame(browser, element_id)) {
- return;
- }
- }
- RunLoopFor(base::TimeDelta::FromMilliseconds(1000));
- }
-
- FAIL();
-}
-
-bool ElementExistsInSigninFrame(Browser* browser,
- const std::string& element_id) {
- content::WebContents* web_contents =
- browser->tab_strip_model()->GetActiveWebContents();
- bool result = false;
- EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
- signin::GetAuthFrame(web_contents, "signin-frame"),
- "window.domAutomationController.send("
- " document.getElementById('" +
- element_id + "') != null);",
- &result));
- return result;
-}
-
void SigninInNewGaiaFlow(Browser* browser,
const std::string& email,
const std::string& password) {
content::WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents();
- WaitUntilElementExistsInSigninFrame(browser, {"identifierId"});
+ WaitUntilAnyElementExistsInSigninFrame(browser, {"identifierId"});
std::string js = "document.getElementById('identifierId').value = '" + email +
"'; document.getElementById('identifierNext').click();";
- ASSERT_TRUE(content::ExecuteScript(
- signin::GetAuthFrame(web_contents, "signin-frame"), js));
-
- WaitUntilElementExistsInSigninFrame(browser, {"password"});
- js = "document.getElementById('password').value = '" + password + "';" +
- "document.getElementById('passwordNext').click();";
- ASSERT_TRUE(content::ExecuteScript(
- signin::GetAuthFrame(web_contents, "signin-frame"), js));
+ ASSERT_TRUE(content::ExecuteScript(GetSigninFrame(web_contents), js));
+
+ // Fill the password input field.
+ if (IsDiceSigninPageEnabled(browser->profile())) {
+ std::string password_script = kGetPasswordFieldFromDiceSigninPage;
+ // Wait until the password field exists.
+ WaitUntilCondition(
+ base::BindLambdaForTesting([&browser, &password_script]() -> bool {
+ return EvaluateBooleanScriptInSigninFrame(
+ browser, password_script + " != null");
+ }),
+ "Could not find Dice password field");
+ js = password_script + ".value = '" + password + "';";
+ } else {
+ WaitUntilAnyElementExistsInSigninFrame(browser, {"password"});
+ js = "document.getElementById('password').value = '" + password + "';";
+ }
+
+ js += "document.getElementById('passwordNext').click();";
+ ASSERT_TRUE(content::ExecuteScript(GetSigninFrame(web_contents), js));
}
void SigninInOldGaiaFlow(Browser* browser,
@@ -248,24 +299,22 @@ void SigninInOldGaiaFlow(Browser* browser,
content::WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents();
- WaitUntilElementExistsInSigninFrame(browser, {"Email"});
+ WaitUntilAnyElementExistsInSigninFrame(browser, {"Email"});
std::string js = "document.getElementById('Email').value = '" + email + ";" +
"document.getElementById('next').click();";
- ASSERT_TRUE(content::ExecuteScript(
- signin::GetAuthFrame(web_contents, "signin-frame"), js));
+ ASSERT_TRUE(content::ExecuteScript(GetSigninFrame(web_contents), js));
- WaitUntilElementExistsInSigninFrame(browser, {"Passwd"});
+ WaitUntilAnyElementExistsInSigninFrame(browser, {"Passwd"});
js = "document.getElementById('Passwd').value = '" + password + "';" +
"document.getElementById('signIn').click();";
- ASSERT_TRUE(content::ExecuteScript(
- signin::GetAuthFrame(web_contents, "signin-frame"), js));
+ ASSERT_TRUE(content::ExecuteScript(GetSigninFrame(web_contents), js));
}
void ExecuteJsToSigninInSigninFrame(Browser* browser,
const std::string& email,
const std::string& password) {
- WaitUntilElementExistsInSigninFrame(browser, {"identifierNext", "next"});
- if (ElementExistsInSigninFrame(browser, "identifierNext"))
+ WaitUntilAnyElementExistsInSigninFrame(browser, {"identifierNext", "next"});
+ if (ElementExistsByIdInSigninFrame(browser, "identifierNext"))
SigninInNewGaiaFlow(browser, email, password);
else
SigninInOldGaiaFlow(browser, email, password);
@@ -273,43 +322,50 @@ void ExecuteJsToSigninInSigninFrame(Browser* browser,
bool SignInWithUI(Browser* browser,
const std::string& username,
- const std::string& password,
- bool wait_for_account_cookies,
- signin_metrics::AccessPoint access_point,
- signin_metrics::Reason signin_reason) {
- SignInObserver signin_observer(wait_for_account_cookies);
+ const std::string& password) {
+ SignInObserver signin_observer;
std::unique_ptr<SigninTracker> tracker =
SigninTrackerFactory::CreateForProfile(browser->profile(),
&signin_observer);
+ signin_metrics::AccessPoint access_point =
+ signin_metrics::AccessPoint::ACCESS_POINT_MENU;
+
+ if (IsDiceSigninPageEnabled(browser->profile())) {
+#if BUILDFLAG(ENABLE_DICE_SUPPORT)
+ chrome::ShowBrowserSignin(browser, access_point);
+ content::WebContents* active_contents =
+ browser->tab_strip_model()->GetActiveWebContents();
+ DCHECK(active_contents);
+ content::TestNavigationObserver observer(
+ active_contents, 1, content::MessageLoopRunner::QuitMode::DEFERRED);
+ observer.Wait();
+#else
+ NOTREACHED();
+#endif
+ } else {
+ GURL signin_url = signin::GetPromoURLForTab(
+ access_point, signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT,
+ false);
+ DVLOG(1) << "Navigating to " << signin_url;
+ // For some tests, the window is not shown yet and this might be the first
+ // tab navigation, so GetActiveWebContents() for CURRENT_TAB is NULL. That's
+ // why we use NEW_FOREGROUND_TAB rather than the CURRENT_TAB used by default
+ // in ui_test_utils::NavigateToURL().
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser, signin_url, WindowOpenDisposition::NEW_FOREGROUND_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+
+ // Wait for the WebUI embedding the signin flow to be ready.
+ DVLOG(1) << "Wait for login UI to be ready.";
+ WaitUntilUIReady(browser);
+ }
- GURL signin_url =
- signin::GetPromoURLForTab(access_point, signin_reason, false);
- DVLOG(1) << "Navigating to " << signin_url;
- // For some tests, the window is not shown yet and this might be the first tab
- // navigation, so GetActiveWebContents() for CURRENT_TAB is NULL. That's why
- // we use NEW_FOREGROUND_TAB rather than the CURRENT_TAB used by default in
- // ui_test_utils::NavigateToURL().
- ui_test_utils::NavigateToURLWithDisposition(
- browser, signin_url, WindowOpenDisposition::NEW_FOREGROUND_TAB,
- ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
-
- DVLOG(1) << "Wait for login UI to be ready.";
- WaitUntilUIReady(browser);
DVLOG(1) << "Sign in user: " << username;
ExecuteJsToSigninInSigninFrame(browser, username, password);
signin_observer.Wait();
return signin_observer.DidSignIn();
}
-bool SignInWithUI(Browser* browser,
- const std::string& username,
- const std::string& password) {
- return SignInWithUI(browser, username, password,
- false /* wait_for_account_cookies */,
- signin_metrics::AccessPoint::ACCESS_POINT_START_PAGE,
- signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT);
-}
-
bool DismissSyncConfirmationDialog(Browser* browser, base::TimeDelta timeout) {
SyncConfirmationClosedObserver confirmation_closed_observer;
ScopedObserver<LoginUIService, LoginUIService::Observer>
diff --git a/chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.h b/chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.h
index 8f9c5bb8673..439d50c18ee 100644
--- a/chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.h
+++ b/chromium/chrome/browser/ui/webui/signin/login_ui_test_utils.h
@@ -18,16 +18,6 @@ namespace login_ui_test_utils {
// Blocks until the login UI is available and ready for authorization.
void WaitUntilUIReady(Browser* browser);
-// Blocks until an element with an id from |element_ids| exists in the signin
-// page.
-void WaitUntilElementExistsInSigninFrame(
- Browser* browser,
- const std::vector<std::string>& element_ids);
-
-// Returns whether an element with id |element_id| exists in the signin page.
-bool ElementExistsInSigninFrame(Browser* browser,
- const std::string& element_id);
-
// Executes JavaScript code to sign in a user with email and password to the
// auth iframe hosted by gaia_auth extension. This function automatically
// detects the version of GAIA sign in page to use.
@@ -47,18 +37,6 @@ void SigninInOldGaiaFlow(Browser* browser,
// A function to sign in a user using Chrome sign-in UI interface.
// This will block until a signin succeeded or failed notification is observed.
-// In case |wait_for_account_cookies|, the call will block until the account
-// cookies have been written to the cookie jar.
-// |access_point| identifies the access point used to load the signin page.
-bool SignInWithUI(Browser* browser,
- const std::string& email,
- const std::string& password,
- bool wait_for_account_cookies,
- signin_metrics::AccessPoint access_point,
- signin_metrics::Reason signin_reason);
-
-// Most common way to sign in a user, it does not wait for cookies to be set
-// and uses the SOURCE_START_PAGE as signin source.
bool SignInWithUI(Browser* browser,
const std::string& email,
const std::string& password);
diff --git a/chromium/chrome/browser/ui/webui/signin/md_user_manager_ui.cc b/chromium/chrome/browser/ui/webui/signin/md_user_manager_ui.cc
index 4ae11a15f61..9a8756624e9 100644
--- a/chromium/chrome/browser/ui/webui/signin/md_user_manager_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/md_user_manager_ui.cc
@@ -26,10 +26,6 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/webui/web_ui_util.h"
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
-#include "chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.h"
-#endif
-
MDUserManagerUI::MDUserManagerUI(content::WebUI* web_ui)
: WebUIController(web_ui) {
auto signin_create_profile_handler =
@@ -40,13 +36,6 @@ MDUserManagerUI::MDUserManagerUI(content::WebUI* web_ui)
std::make_unique<UserManagerScreenHandler>();
user_manager_screen_handler_ = user_manager_screen_handler.get();
web_ui->AddMessageHandler(std::move(user_manager_screen_handler));
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
- auto signin_supervised_user_import_handler =
- std::make_unique<SigninSupervisedUserImportHandler>();
- signin_supervised_user_import_handler_ =
- signin_supervised_user_import_handler.get();
- web_ui->AddMessageHandler(std::move(signin_supervised_user_import_handler));
-#endif
base::DictionaryValue localized_strings;
GetLocalizedStrings(&localized_strings);
@@ -71,9 +60,6 @@ content::WebUIDataSource* MDUserManagerUI::CreateUIDataSource(
ProfileShortcutManager::IsFeatureEnabled());
source->AddBoolean("isForceSigninEnabled",
signin_util::IsForceSigninEnabled());
- source->AddBoolean(
- "isSupervisedUserCreationEnabled",
- base::FeatureList::IsEnabled(features::kSupervisedUserCreation));
source->SetJsonPath("strings.js");
@@ -83,10 +69,6 @@ content::WebUIDataSource* MDUserManagerUI::CreateUIDataSource(
source->AddResourcePath("create_profile.js", IDR_MD_CREATE_PROFILE_JS);
source->AddResourcePath("error_dialog.html", IDR_MD_ERROR_DIALOG_HTML);
source->AddResourcePath("error_dialog.js", IDR_MD_ERROR_DIALOG_JS);
- source->AddResourcePath("import_supervised_user.html",
- IDR_MD_IMPORT_SUPERVISED_USER_HTML);
- source->AddResourcePath("import_supervised_user.js",
- IDR_MD_IMPORT_SUPERVISED_USER_JS);
source->AddResourcePath("profile_browser_proxy.html",
IDR_MD_PROFILE_BROWSER_PROXY_HTML);
source->AddResourcePath("profile_browser_proxy.js",
@@ -94,14 +76,6 @@ content::WebUIDataSource* MDUserManagerUI::CreateUIDataSource(
source->AddResourcePath("shared_styles.html",
IDR_MD_USER_MANAGER_SHARED_STYLES_HTML);
source->AddResourcePath("strings.html", IDR_MD_USER_MANAGER_STRINGS_HTML);
- source->AddResourcePath("supervised_user_create_confirm.html",
- IDR_MD_SUPERVISED_USER_CREATE_CONFIRM_HTML);
- source->AddResourcePath("supervised_user_create_confirm.js",
- IDR_MD_SUPERVISED_USER_CREATE_CONFIRM_JS);
- source->AddResourcePath("supervised_user_learn_more.html",
- IDR_MD_SUPERVISED_USER_LEARN_MORE_HTML);
- source->AddResourcePath("supervised_user_learn_more.js",
- IDR_MD_SUPERVISED_USER_LEARN_MORE_JS);
source->AddResourcePath("user_manager.js", IDR_MD_USER_MANAGER_JS);
source->AddResourcePath("user_manager_pages.html",
IDR_MD_USER_MANAGER_PAGES_HTML);
@@ -121,9 +95,6 @@ void MDUserManagerUI::GetLocalizedStrings(
base::DictionaryValue* localized_strings) {
user_manager_screen_handler_->GetLocalizedValues(localized_strings);
signin_create_profile_handler_->GetLocalizedValues(localized_strings);
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
- signin_supervised_user_import_handler_->GetLocalizedValues(localized_strings);
-#endif
const std::string& app_locale = g_browser_process->GetApplicationLocale();
webui::SetLoadTimeDataDefaults(app_locale, localized_strings);
diff --git a/chromium/chrome/browser/ui/webui/signin/md_user_manager_ui.h b/chromium/chrome/browser/ui/webui/signin/md_user_manager_ui.h
index 63bf9ceed78..14c875d1cd0 100644
--- a/chromium/chrome/browser/ui/webui/signin/md_user_manager_ui.h
+++ b/chromium/chrome/browser/ui/webui/signin/md_user_manager_ui.h
@@ -6,16 +6,11 @@
#define CHROME_BROWSER_UI_WEBUI_SIGNIN_MD_USER_MANAGER_UI_H_
#include "base/macros.h"
-#include "chrome/common/buildflags.h"
#include "content/public/browser/web_ui_controller.h"
class SigninCreateProfileHandler;
class UserManagerScreenHandler;
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
-class SigninSupervisedUserImportHandler;
-#endif
-
namespace base {
class DictionaryValue;
}
@@ -37,10 +32,6 @@ class MDUserManagerUI : public content::WebUIController {
SigninCreateProfileHandler* signin_create_profile_handler_ = nullptr;
UserManagerScreenHandler* user_manager_screen_handler_ = nullptr;
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
- SigninSupervisedUserImportHandler* signin_supervised_user_import_handler_;
-#endif
-
DISALLOW_COPY_AND_ASSIGN(MDUserManagerUI);
};
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc b/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.cc
index 82cb431d651..f8777b673ec 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
@@ -47,29 +47,11 @@
#include "content/public/browser/web_ui.h"
#include "ui/base/l10n/l10n_util.h"
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
-#include "chrome/browser/supervised_user/legacy/supervised_user_registration_utility.h"
-#include "chrome/browser/supervised_user/legacy/supervised_user_sync_service.h"
-#include "chrome/browser/supervised_user/legacy/supervised_user_sync_service_factory.h"
-#include "chrome/browser/supervised_user/supervised_user_service.h"
-#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
-#endif
-
SigninCreateProfileHandler::SigninCreateProfileHandler()
: profile_creation_type_(NO_CREATION_IN_PROGRESS),
- weak_ptr_factory_(this) {
- g_browser_process->profile_manager()->
- GetProfileAttributesStorage().AddObserver(this);
-}
+ weak_ptr_factory_(this) {}
-SigninCreateProfileHandler::~SigninCreateProfileHandler() {
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
- // Cancellation is only supported for supervised users.
- CancelProfileRegistration(false);
-#endif
- g_browser_process->profile_manager()->
- GetProfileAttributesStorage().RemoveObserver(this);
-}
+SigninCreateProfileHandler::~SigninCreateProfileHandler() {}
void SigninCreateProfileHandler::GetLocalizedValues(
base::DictionaryValue* localized_strings) {
@@ -77,97 +59,20 @@ void SigninCreateProfileHandler::GetLocalizedValues(
"createDesktopShortcutLabel",
l10n_util::GetStringUTF16(
IDS_PROFILES_CREATE_DESKTOP_SHORTCUT_LABEL));
- localized_strings->SetString(
- "manageProfilesSupervisedSignedInLabel",
- l10n_util::GetStringUTF16(
- IDS_PROFILES_CREATE_SUPERVISED_MULTI_SIGNED_IN_LABEL));
- localized_strings->SetString(
- "noSignedInUserMessage",
- l10n_util::GetStringUTF16(
- IDS_PROFILES_CREATE_SUPERVISED_NO_SIGNED_IN_USER_TEXT));
localized_strings->SetString("createProfileConfirm",
l10n_util::GetStringUTF16(IDS_ADD));
localized_strings->SetString("learnMore",
l10n_util::GetStringUTF16(IDS_LEARN_MORE));
localized_strings->SetString(
- "selectAnAccount",
- l10n_util::GetStringUTF16(
- IDS_PROFILES_CREATE_SUPERVISED_SENTINEL_MENU_ITEM_TEXT));
- localized_strings->SetString(
"createProfileTitle",
l10n_util::GetStringUTF16(IDS_PROFILES_CREATE_TITLE));
localized_strings->SetString(
- "supervisedUserLearnMoreTitle",
- l10n_util::GetStringUTF16(IDS_LEGACY_SUPERVISED_USER_LEARN_MORE_TITLE));
- localized_strings->SetString(
- "supervisedUserLearnMoreDone",
- l10n_util::GetStringUTF16(
- IDS_LEGACY_SUPERVISED_USER_LEARN_MORE_DONE_BUTTON));
- localized_strings->SetString(
- "supervisedUserLearnMoreText",
- l10n_util::GetStringFUTF16(
- IDS_SUPERVISED_USER_LEARN_MORE_TEXT,
- base::ASCIIToUTF16(
- chrome::kLegacySupervisedUserManagementURL),
- base::ASCIIToUTF16(
- chrome::kLegacySupervisedUserManagementDisplayURL)));
- localized_strings->SetString(
- "importExistingSupervisedUserLink",
- l10n_util::GetStringUTF16(
- IDS_IMPORT_EXISTING_LEGACY_SUPERVISED_USER_TITLE));
- localized_strings->SetString(
- "manageProfilesExistingSupervisedUser",
- l10n_util::GetStringUTF16(
- IDS_PROFILES_CREATE_LEGACY_SUPERVISED_USER_ERROR_EXISTS_REMOTELY));
- localized_strings->SetString(
- "managedProfilesExistingLocalSupervisedUser",
- l10n_util::GetStringUTF16(
- IDS_PROFILES_CREATE_LEGACY_SUPERVISED_USER_ERROR_EXISTS_LOCALLY));
- localized_strings->SetString(
- "custodianAccountNotSelectedError",
- l10n_util::GetStringUTF16(
- IDS_PROFILES_CREATE_NO_CUSTODIAN_ACCOUNT_ERROR));
- localized_strings->SetString(
- "supervisedUserCreatedTitle",
- l10n_util::GetStringUTF16(IDS_LEGACY_SUPERVISED_USER_CREATED_TITLE));
- // The first two substitution parameters remain to be filled by the page JS.
- localized_strings->SetString(
- "supervisedUserCreatedText",
- l10n_util::GetStringFUTF16(
- IDS_SUPERVISED_USER_CREATED_TEXT,
- base::ASCIIToUTF16("$1"),
- base::ASCIIToUTF16("$2"),
- base::ASCIIToUTF16(chrome::kLegacySupervisedUserManagementURL),
- base::ASCIIToUTF16(
- chrome::kLegacySupervisedUserManagementDisplayURL)));
- localized_strings->SetString(
"exitAndChildlockLabel",
l10n_util::GetStringUTF16(
IDS_PROFILES_PROFILE_SIGNOUT_BUTTON));
- localized_strings->SetString(
- "supervisedUserCreatedDone",
- l10n_util::GetStringUTF16(
- IDS_LEGACY_SUPERVISED_USER_CREATED_DONE_BUTTON));
- localized_strings->SetString(
- "supervisedUserCreatedSwitch",
- l10n_util::GetStringUTF16(
- IDS_LEGACY_SUPERVISED_USER_CREATED_SWITCH_BUTTON));
}
void SigninCreateProfileHandler::RegisterMessages() {
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
- // Cancellation is only supported for supervised users.
- web_ui()->RegisterMessageCallback(
- "cancelCreateProfile",
- base::BindRepeating(
- &SigninCreateProfileHandler::HandleCancelProfileCreation,
- base::Unretained(this)));
-
- web_ui()->RegisterMessageCallback(
- "switchToProfile",
- base::BindRepeating(&SigninCreateProfileHandler::SwitchToProfile,
- base::Unretained(this)));
-#endif
web_ui()->RegisterMessageCallback(
"createProfile",
base::BindRepeating(&SigninCreateProfileHandler::CreateProfile,
@@ -178,11 +83,6 @@ void SigninCreateProfileHandler::RegisterMessages() {
base::BindRepeating(
&SigninCreateProfileHandler::RequestDefaultProfileIcons,
base::Unretained(this)));
-
- web_ui()->RegisterMessageCallback(
- "requestSignedInProfiles",
- base::BindRepeating(&SigninCreateProfileHandler::RequestSignedInProfiles,
- base::Unretained(this)));
}
void SigninCreateProfileHandler::RequestDefaultProfileIcons(
@@ -205,34 +105,6 @@ void SigninCreateProfileHandler::SendNewProfileDefaults() {
profile_info);
}
-void SigninCreateProfileHandler::RequestSignedInProfiles(
- const base::ListValue* args) {
- base::ListValue user_info_list;
- std::vector<ProfileAttributesEntry*> entries =
- g_browser_process->profile_manager()->
- GetProfileAttributesStorage().GetAllProfilesAttributesSortedByName();
- for (ProfileAttributesEntry* entry : entries) {
- base::string16 username = entry->GetUserName();
- if (username.empty())
- continue;
- base::string16 profile_path = entry->GetPath().AsUTF16Unsafe();
- std::unique_ptr<base::DictionaryValue> user_info(
- new base::DictionaryValue());
- user_info->SetString("username", username);
- user_info->SetString("profilePath", profile_path);
-
- user_info_list.Append(std::move(user_info));
- }
- web_ui()->CallJavascriptFunctionUnsafe("cr.webUIListenerCallback",
- base::Value("signedin-users-received"),
- user_info_list);
-}
-
-void SigninCreateProfileHandler::OnProfileAuthInfoChanged(
- const base::FilePath& profile_path) {
- RequestSignedInProfiles(nullptr);
-}
-
void SigninCreateProfileHandler::CreateProfile(const base::ListValue* args) {
if (!profiles::IsMultipleProfilesEnabled())
return;
@@ -261,46 +133,23 @@ void SigninCreateProfileHandler::CreateProfile(const base::ListValue* args) {
#endif
args->GetBoolean(2, &create_shortcut);
}
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
- std::string supervised_user_id;
- base::FilePath custodian_profile_path;
- if (GetSupervisedCreateProfileArgs(args, &supervised_user_id,
- &custodian_profile_path)) {
- // Load custodian profile.
- g_browser_process->profile_manager()->CreateProfileAsync(
- custodian_profile_path,
- base::Bind(&SigninCreateProfileHandler::LoadCustodianProfileCallback,
- weak_ptr_factory_.GetWeakPtr(), name, icon_url,
- create_shortcut, supervised_user_id),
- base::string16(), std::string(), std::string());
- } else {
- DoCreateProfile(name, icon_url, create_shortcut, std::string(), nullptr);
- }
-#else
- DoCreateProfile(name, icon_url, create_shortcut, std::string(), nullptr);
-#endif
+ DoCreateProfile(name, icon_url, create_shortcut);
}
-void SigninCreateProfileHandler::DoCreateProfile(
- const base::string16& name,
- const std::string& icon_url,
- bool create_shortcut,
- const std::string& supervised_user_id,
- Profile* custodian_profile) {
+void SigninCreateProfileHandler::DoCreateProfile(const base::string16& name,
+ const std::string& icon_url,
+ bool create_shortcut) {
ProfileMetrics::LogProfileAddNewUser(ProfileMetrics::ADD_NEW_USER_DIALOG);
profile_path_being_created_ = ProfileManager::CreateMultiProfileAsync(
name, icon_url,
base::Bind(&SigninCreateProfileHandler::OnProfileCreated,
- weak_ptr_factory_.GetWeakPtr(), create_shortcut,
- supervised_user_id, custodian_profile),
- supervised_user_id);
+ weak_ptr_factory_.GetWeakPtr(), create_shortcut),
+ /*supervised_user_id=*/std::string());
}
void SigninCreateProfileHandler::OnProfileCreated(
bool create_shortcut,
- const std::string& supervised_user_id,
- Profile* custodian_profile,
Profile* profile,
Profile::CreateStatus status) {
if (status != Profile::CREATE_STATUS_CREATED)
@@ -316,15 +165,12 @@ void SigninCreateProfileHandler::OnProfileCreated(
break;
}
case Profile::CREATE_STATUS_INITIALIZED: {
- HandleProfileCreationSuccess(create_shortcut, supervised_user_id,
- custodian_profile, profile);
+ HandleProfileCreationSuccess(create_shortcut, profile);
break;
}
// User-initiated cancellation is handled in CancelProfileRegistration and
// does not call this callback.
case Profile::CREATE_STATUS_CANCELED:
- // Supervised user registration errors are handled in
- // OnSupervisedUserRegistered().
case Profile::CREATE_STATUS_REMOTE_FAIL:
case Profile::MAX_CREATE_STATUS: {
NOTREACHED();
@@ -335,22 +181,12 @@ void SigninCreateProfileHandler::OnProfileCreated(
void SigninCreateProfileHandler::HandleProfileCreationSuccess(
bool create_shortcut,
- const std::string& supervised_user_id,
- Profile* custodian_profile,
Profile* profile) {
switch (profile_creation_type_) {
case NON_SUPERVISED_PROFILE_CREATION: {
- DCHECK(supervised_user_id.empty());
- CreateShortcutAndShowSuccess(create_shortcut, nullptr, profile);
+ CreateShortcutAndShowSuccess(create_shortcut, profile);
break;
}
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
- case SUPERVISED_PROFILE_CREATION:
- case SUPERVISED_PROFILE_IMPORT:
- RegisterSupervisedUser(create_shortcut, supervised_user_id,
- custodian_profile, profile);
- break;
-#endif
case NO_CREATION_IN_PROGRESS:
NOTREACHED();
break;
@@ -359,7 +195,6 @@ void SigninCreateProfileHandler::HandleProfileCreationSuccess(
void SigninCreateProfileHandler::CreateShortcutAndShowSuccess(
bool create_shortcut,
- Profile* custodian_profile,
Profile* profile) {
if (create_shortcut) {
DCHECK(ProfileShortcutManager::IsFeatureEnabled());
@@ -373,42 +208,13 @@ void SigninCreateProfileHandler::CreateShortcutAndShowSuccess(
DCHECK_EQ(profile_path_being_created_.value(), profile->GetPath().value());
profile_path_being_created_.clear();
DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_);
- base::DictionaryValue dict;
- dict.SetString("name", profile->GetPrefs()->GetString(prefs::kProfileName));
- dict.Set("filePath", base::CreateFilePathValue(profile->GetPath()));
bool is_force_signin_enabled = signin_util::IsForceSigninEnabled();
bool open_new_window = !is_force_signin_enabled;
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
- // If the new profile is a supervised user, instead of opening a new window
- // right away, a confirmation page will be shown by JS from the creation
- // dialog. If we are importing an existing supervised profile or creating a
- // new non-supervised user profile we don't show any confirmation, so open
- // the new window now.
-
- open_new_window =
- open_new_window && profile_creation_type_ != SUPERVISED_PROFILE_CREATION;
-
- dict.SetBoolean("showConfirmation",
- profile_creation_type_ == SUPERVISED_PROFILE_CREATION);
-
- bool is_supervised = profile_creation_type_ == SUPERVISED_PROFILE_CREATION ||
- profile_creation_type_ == SUPERVISED_PROFILE_IMPORT;
- dict.SetBoolean("isSupervised", is_supervised);
-
- if (is_supervised) {
- DCHECK(custodian_profile);
- if (custodian_profile) {
- std::string custodian_username = custodian_profile->GetProfileUserName();
- dict.SetString("custodianUsername", custodian_username);
- }
- }
-#endif
-
web_ui()->CallJavascriptFunctionUnsafe(
"cr.webUIListenerCallback",
- GetWebUIListenerName(PROFILE_CREATION_SUCCESS), dict);
+ GetWebUIListenerName(PROFILE_CREATION_SUCCESS));
if (open_new_window) {
// Opening the new window must be the last action, after all callbacks
@@ -467,13 +273,7 @@ void SigninCreateProfileHandler::RecordProfileCreationMetrics(
base::string16 SigninCreateProfileHandler::GetProfileCreationErrorMessageLocal()
const {
- int message_id = IDS_PROFILES_CREATE_LOCAL_ERROR;
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
- // Local errors can occur during supervised profile import.
- if (profile_creation_type_ == SUPERVISED_PROFILE_IMPORT)
- message_id = IDS_LEGACY_SUPERVISED_USER_IMPORT_LOCAL_ERROR;
-#endif
- return l10n_util::GetStringUTF16(message_id);
+ return l10n_util::GetStringUTF16(IDS_PROFILES_CREATE_LOCAL_ERROR);
}
void SigninCreateProfileHandler::Observe(
@@ -513,309 +313,3 @@ base::Value SigninCreateProfileHandler::GetWebUIListenerName(
NOTREACHED();
return base::Value(std::string());
}
-
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
-base::string16 SigninCreateProfileHandler::GetProfileCreateErrorMessageRemote()
- const {
- return l10n_util::GetStringUTF16(
- profile_creation_type_ == SUPERVISED_PROFILE_IMPORT
- ? IDS_LEGACY_SUPERVISED_USER_IMPORT_REMOTE_ERROR
- : IDS_PROFILES_CREATE_REMOTE_ERROR);
-}
-
-base::string16 SigninCreateProfileHandler::GetProfileCreateErrorMessageSignin()
- const {
- return l10n_util::GetStringUTF16(
- profile_creation_type_ == SUPERVISED_PROFILE_IMPORT
- ? IDS_LEGACY_SUPERVISED_USER_IMPORT_SIGN_IN_ERROR
- : IDS_PROFILES_CREATE_SIGN_IN_ERROR);
-}
-
-bool SigninCreateProfileHandler::GetSupervisedCreateProfileArgs(
- const base::ListValue* args,
- std::string* supervised_user_id,
- base::FilePath* custodian_profile_path) {
- bool supervised_user = false;
- bool success = args->GetBoolean(3, &supervised_user);
- DCHECK(success);
-
- if (!supervised_user)
- return false;
-
- success = args->GetString(4, supervised_user_id);
- DCHECK(success);
- const base::Value* path_value;
- success = args->Get(5, &path_value);
- DCHECK(success);
- success = base::GetValueAsFilePath(*path_value, custodian_profile_path);
- DCHECK(success);
-
- return !custodian_profile_path->empty();
-}
-
-void SigninCreateProfileHandler::LoadCustodianProfileCallback(
- const base::string16& name,
- const std::string& icon_url,
- bool create_shortcut,
- const std::string& supervised_user_id,
- Profile* custodian_profile,
- Profile::CreateStatus status) {
- // This method gets called once before with Profile::CREATE_STATUS_CREATED.
- switch (status) {
- case Profile::CREATE_STATUS_LOCAL_FAIL: {
- ShowProfileCreationError(nullptr, GetProfileCreationErrorMessageLocal());
- break;
- }
- case Profile::CREATE_STATUS_CREATED: {
- // Ignore the intermediate status.
- break;
- }
- case Profile::CREATE_STATUS_INITIALIZED: {
- // We are only interested in Profile::CREATE_STATUS_INITIALIZED when
- // everything is ready.
- if (!IsAccountConnected(custodian_profile) ||
- HasAuthError(custodian_profile)) {
- ShowProfileCreationError(nullptr, l10n_util::GetStringFUTF16(
- IDS_PROFILES_CREATE_CUSTODIAN_ACCOUNT_DETAILS_OUT_OF_DATE_ERROR,
- base::ASCIIToUTF16(custodian_profile->GetProfileUserName())));
- return;
- }
-
- PrefService* prefs = custodian_profile->GetPrefs();
- if (!prefs->GetBoolean(prefs::kSupervisedUserCreationAllowed)) {
- ShowProfileCreationError(
- nullptr,
- l10n_util::GetStringUTF16(
- IDS_PROFILES_CREATE_SUPERVISED_NOT_ALLOWED_BY_POLICY));
- return;
- }
-
- if (!supervised_user_id.empty()) {
- profile_creation_type_ = SUPERVISED_PROFILE_IMPORT;
-
- // Load all supervised users managed by this user in order to
- // check if this supervised user already exists on this device.
- SupervisedUserSyncService* supervised_user_sync_service =
- SupervisedUserSyncServiceFactory::GetForProfile(custodian_profile);
- if (supervised_user_sync_service) {
- supervised_user_sync_service->GetSupervisedUsersAsync(base::Bind(
- &SigninCreateProfileHandler::DoCreateProfileIfPossible,
- weak_ptr_factory_.GetWeakPtr(), name, icon_url, create_shortcut,
- supervised_user_id, custodian_profile));
- } else {
- ShowProfileCreationError(nullptr,
- GetProfileCreateErrorMessageRemote());
- }
- } else {
- profile_creation_type_ = SUPERVISED_PROFILE_CREATION;
- std::string new_supervised_user_id =
- SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId();
-
- // If sync is not yet fully initialized, the creation may take extra
- // time, so show a message. Import doesn't wait for an acknowledgment,
- // so it won't have the same potential delay.
- browser_sync::ProfileSyncService* sync_service =
- ProfileSyncServiceFactory::GetInstance()->GetForProfile(
- custodian_profile);
- browser_sync::ProfileSyncService::SyncStatusSummary status =
- sync_service->QuerySyncStatusSummary();
- if (status ==
- browser_sync::ProfileSyncService::DATATYPES_NOT_INITIALIZED) {
- ShowProfileCreationWarning(l10n_util::GetStringUTF16(
- IDS_PROFILES_CREATE_SUPERVISED_JUST_SIGNED_IN));
- }
-
- DoCreateProfile(name, icon_url, create_shortcut, new_supervised_user_id,
- custodian_profile);
- }
- break;
- }
- case Profile::CREATE_STATUS_CANCELED:
- case Profile::CREATE_STATUS_REMOTE_FAIL:
- case Profile::MAX_CREATE_STATUS: {
- NOTREACHED();
- break;
- }
- }
-}
-
-bool SigninCreateProfileHandler::IsAccountConnected(Profile* profile)
- const {
- SigninManagerBase* signin_manager =
- SigninManagerFactory::GetForProfile(profile);
- return signin_manager && signin_manager->IsAuthenticated();
-}
-
-bool SigninCreateProfileHandler::HasAuthError(Profile* profile)
- const {
- SigninErrorController* error_controller =
- SigninErrorControllerFactory::GetForProfile(profile);
- if (!error_controller)
- return true;
-
- GoogleServiceAuthError::State state = error_controller->auth_error().state();
- return state != GoogleServiceAuthError::NONE;
-}
-
-void SigninCreateProfileHandler::DoCreateProfileIfPossible(
- const base::string16& name,
- const std::string& icon_url,
- bool create_shortcut,
- const std::string& supervised_user_id,
- Profile* custodian_profile,
- const base::DictionaryValue* dict) {
- DCHECK(dict);
- if (!dict->HasKey(supervised_user_id))
- return;
-
- // Check if this supervised user already exists on this machine.
- std::vector<ProfileAttributesEntry*> entries =
- g_browser_process->profile_manager()->
- GetProfileAttributesStorage().GetAllProfilesAttributes();
- for (ProfileAttributesEntry* entry : entries) {
- if (supervised_user_id == entry->GetSupervisedUserId()) {
- ShowProfileCreationError(nullptr, GetProfileCreationErrorMessageLocal());
- return;
- }
- }
-
- DoCreateProfile(name, icon_url, create_shortcut, supervised_user_id,
- custodian_profile);
-}
-
-void SigninCreateProfileHandler::HandleCancelProfileCreation(
- const base::ListValue* args) {
- CancelProfileRegistration(true);
-}
-
-// Non-supervised user creation cannot be canceled. (Creating a non-supervised
-// profile shouldn't take significant time, and it can easily be deleted
-// afterward.)
-void SigninCreateProfileHandler::CancelProfileRegistration(
- bool user_initiated) {
- if (profile_path_being_created_.empty())
- return;
-
- ProfileManager* manager = g_browser_process->profile_manager();
- Profile* new_profile = manager->GetProfileByPath(profile_path_being_created_);
- if (!new_profile || !new_profile->IsSupervised())
- return;
-
- DCHECK(supervised_user_registration_utility_.get());
- supervised_user_registration_utility_.reset();
-
- if (user_initiated) {
- UMA_HISTOGRAM_MEDIUM_TIMES(
- "Profile.CreateTimeCanceledNoTimeout",
- base::TimeTicks::Now() - profile_creation_start_time_);
- RecordProfileCreationMetrics(Profile::CREATE_STATUS_CANCELED);
- }
-
- DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_);
- profile_creation_type_ = NO_CREATION_IN_PROGRESS;
-
- // Canceling registration means the callback passed into
- // RegisterAndInitSync() won't be called, so the cleanup must be done here.
- profile_path_being_created_.clear();
- webui::DeleteProfileAtPath(new_profile->GetPath(),
- ProfileMetrics::DELETE_PROFILE_SETTINGS);
-}
-
-void SigninCreateProfileHandler::RegisterSupervisedUser(
- bool create_shortcut,
- const std::string& supervised_user_id,
- Profile* custodian_profile,
- Profile* new_profile) {
- DCHECK_EQ(profile_path_being_created_.value(),
- new_profile->GetPath().value());
-
- SupervisedUserService* supervised_user_service =
- SupervisedUserServiceFactory::GetForProfile(new_profile);
-
- // Register the supervised user using the profile of the custodian.
- supervised_user_registration_utility_ =
- SupervisedUserRegistrationUtility::Create(custodian_profile);
- if (supervised_user_service) {
- supervised_user_service->RegisterAndInitSync(
- supervised_user_registration_utility_.get(), custodian_profile,
- supervised_user_id,
- base::BindOnce(&SigninCreateProfileHandler::OnSupervisedUserRegistered,
- weak_ptr_factory_.GetWeakPtr(), create_shortcut,
- custodian_profile, new_profile));
- }
-}
-
-void SigninCreateProfileHandler::OnSupervisedUserRegistered(
- bool create_shortcut,
- Profile* custodian_profile,
- Profile* profile,
- const GoogleServiceAuthError& error) {
- GoogleServiceAuthError::State state = error.state();
- RecordSupervisedProfileCreationMetrics(state);
- if (state == GoogleServiceAuthError::NONE) {
- CreateShortcutAndShowSuccess(create_shortcut, custodian_profile, profile);
- return;
- }
-
- base::string16 error_msg;
- if (state == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS ||
- state == GoogleServiceAuthError::USER_NOT_SIGNED_UP ||
- state == GoogleServiceAuthError::ACCOUNT_DELETED ||
- state == GoogleServiceAuthError::ACCOUNT_DISABLED) {
- error_msg = GetProfileCreateErrorMessageSignin();
- } else {
- error_msg = GetProfileCreateErrorMessageRemote();
- }
- ShowProfileCreationError(profile, error_msg);
-}
-
-void SigninCreateProfileHandler::ShowProfileCreationWarning(
- const base::string16& warning) {
- DCHECK_EQ(SUPERVISED_PROFILE_CREATION, profile_creation_type_);
- web_ui()->CallJavascriptFunctionUnsafe("cr.webUIListenerCallback",
- base::Value("create-profile-warning"),
- base::Value(warning));
-}
-
-void SigninCreateProfileHandler::RecordSupervisedProfileCreationMetrics(
- GoogleServiceAuthError::State error_state) {
- if (profile_creation_type_ == SUPERVISED_PROFILE_CREATION) {
- UMA_HISTOGRAM_ENUMERATION("Profile.SupervisedProfileCreateError",
- error_state, GoogleServiceAuthError::NUM_STATES);
- UMA_HISTOGRAM_MEDIUM_TIMES(
- "Profile.SupervisedProfileTotalCreateTime",
- base::TimeTicks::Now() - profile_creation_start_time_);
- } else {
- DCHECK_EQ(SUPERVISED_PROFILE_IMPORT, profile_creation_type_);
- UMA_HISTOGRAM_ENUMERATION("Profile.SupervisedProfileImportError",
- error_state, GoogleServiceAuthError::NUM_STATES);
- UMA_HISTOGRAM_MEDIUM_TIMES(
- "Profile.SupervisedProfileTotalImportTime",
- base::TimeTicks::Now() - profile_creation_start_time_);
- }
-}
-
-void SigninCreateProfileHandler::SwitchToProfile(
- const base::ListValue* args) {
- DCHECK(args);
- const base::Value* file_path_value;
- if (!args->Get(0, &file_path_value))
- return;
-
- base::FilePath profile_file_path;
- if (!base::GetValueAsFilePath(*file_path_value, &profile_file_path))
- return;
-
- Profile* profile = g_browser_process->profile_manager()->
- GetProfileByPath(profile_file_path);
- DCHECK(profile);
-
- profiles::OpenBrowserWindowForProfile(
- base::Bind(&SigninCreateProfileHandler::OnBrowserReadyCallback,
- weak_ptr_factory_.GetWeakPtr()),
- false, // Don't create a window if one already exists.
- true, // Create a first run window.
- profile,
- Profile::CREATE_STATUS_INITIALIZED);
-}
-#endif
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.h b/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.h
index dd6b4f00db4..448993883d7 100644
--- a/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.h
+++ b/chromium/chrome/browser/ui/webui/signin/signin_create_profile_handler.h
@@ -11,7 +11,6 @@
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/profiles/profile_window.h"
#include "chrome/common/buildflags.h"
#include "content/public/browser/notification_observer.h"
@@ -24,14 +23,9 @@ class DictionaryValue;
class ListValue;
}
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
-class SupervisedUserRegistrationUtility;
-#endif
-
// Handler for the 'create profile' page.
class SigninCreateProfileHandler : public content::WebUIMessageHandler,
- public content::NotificationObserver,
- public ProfileAttributesStorage::Observer {
+ public content::NotificationObserver {
public:
SigninCreateProfileHandler();
~SigninCreateProfileHandler() override;
@@ -45,22 +39,8 @@ class SigninCreateProfileHandler : public content::WebUIMessageHandler,
ReturnSignedInProfiles);
FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest,
CreateProfile);
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
- FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest,
- CreateSupervisedUser);
- FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest,
- ImportSupervisedUser);
- FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest,
- ImportSupervisedUserAlreadyOnDevice);
- FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest,
- CustodianNotAuthenticated);
- FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest,
- CustodianHasAuthError);
- FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest,
- NotAllowedToCreateSupervisedUser);
FRIEND_TEST_ALL_PREFIXES(SigninCreateProfileHandlerTest,
CreateProfileWithForceSignin);
-#endif
// WebUIMessageHandler implementation.
void RegisterMessages() override;
@@ -70,9 +50,6 @@ class SigninCreateProfileHandler : public content::WebUIMessageHandler,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
- // ProfileAttributesStorage::Observer implementation:
- void OnProfileAuthInfoChanged(const base::FilePath& profile_path) override;
-
// Represents the final profile creation status. It is used to map
// the status to the javascript method to be called.
enum ProfileCreationStatus {
@@ -84,10 +61,6 @@ class SigninCreateProfileHandler : public content::WebUIMessageHandler,
// It is used to map the type of the profile creation operation to the
// correct UMA metric name.
enum ProfileCreationOperationType {
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
- SUPERVISED_PROFILE_CREATION,
- SUPERVISED_PROFILE_IMPORT,
-#endif
NON_SUPERVISED_PROFILE_CREATION,
NO_CREATION_IN_PROGRESS
};
@@ -100,43 +73,27 @@ class SigninCreateProfileHandler : public content::WebUIMessageHandler,
// "requestDefaultProfileIcons" is fulfilled.
void SendNewProfileDefaults();
- // Callback for the "requestSignedInProfiles" message.
- // Sends the email address of the signed-in user, or an empty string if the
- // user is not signed in.
- void RequestSignedInProfiles(const base::ListValue* args);
-
// Asynchronously creates and initializes a new profile.
// The arguments are as follows:
// 0: name (string)
// 1: icon (string)
// 2: a flag stating whether we should create a profile desktop shortcut
// (optional, boolean)
- // 3: a flag stating whether the user should be supervised
- // (optional, boolean)
- // 4: a string representing the supervised user ID.
- // 5: a string representing the custodian profile path.
void CreateProfile(const base::ListValue* args);
// If a local error occurs during profile creation, then show an appropriate
- // error message. However, if profile creation succeeded and the
- // profile being created/imported is a supervised user profile,
- // then proceed with the registration step. Otherwise, update the UI
- // as the final task after a new profile has been created.
+ // error message. Otherwise, update the UI as the final task after a new
+ // profile has been created.
void OnProfileCreated(bool create_shortcut,
- const std::string& supervised_user_id,
- Profile* custodian_profile,
Profile* profile,
Profile::CreateStatus status);
void HandleProfileCreationSuccess(bool create_shortcut,
- const std::string& supervised_user_id,
- Profile* custodian_profile,
Profile* profile);
// Creates desktop shortcut and updates the UI to indicate success
// when creating a profile.
void CreateShortcutAndShowSuccess(bool create_shortcut,
- Profile* custodian_profile,
Profile* profile);
// Opens a new window for |profile|.
@@ -175,84 +132,7 @@ class SigninCreateProfileHandler : public content::WebUIMessageHandler,
// Asynchronously creates and initializes a new profile.
virtual void DoCreateProfile(const base::string16& name,
const std::string& icon_url,
- bool create_shortcut,
- const std::string& supervised_user_id,
- Profile* custodian_profile);
-
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
- base::string16 GetProfileCreateErrorMessageRemote() const;
- base::string16 GetProfileCreateErrorMessageSignin() const;
-
- // Extracts the supervised user ID and the custodian user profile path from
- // the args passed into CreateProfile.
- bool GetSupervisedCreateProfileArgs(const base::ListValue* args,
- std::string* supervised_user_id,
- base::FilePath* custodian_profile_path);
-
- // Callback that runs once the custodian profile has been loaded. It sets
- // |profile_creation_type_| if necessary, and calls |DoCreateProfile| if the
- // supervised user id specified in |args| is valid.
- void LoadCustodianProfileCallback(const base::string16& name,
- const std::string& icon_url,
- bool create_shortcut,
- const std::string& supervised_user_id,
- Profile* custodian_profile,
- Profile::CreateStatus status);
-
- // Cancels creation of a supervised-user profile currently in progress, as
- // indicated by profile_path_being_created_, removing the object and files
- // and canceling supervised-user registration. This is the handler for the
- // "cancelCreateProfile" message. |args| is not used.
- void HandleCancelProfileCreation(const base::ListValue* args);
-
- // Internal implementation. This may safely be called whether profile creation
- // or registration is in progress or not. |user_initiated| should be true if
- // the cancellation was deliberately requested by the user, and false if it
- // was caused implicitly, e.g. by shutting down the browser.
- void CancelProfileRegistration(bool user_initiated);
-
- // Returns true if profile has signed into chrome.
- bool IsAccountConnected(Profile* profile) const;
- // Returns true if profile has authentication error.
- bool HasAuthError(Profile* profile) const;
-
- // After a new supervised-user profile has been created, registers the user
- // with the management server.
- virtual void RegisterSupervisedUser(bool create_shortcut,
- const std::string& managed_user_id,
- Profile* custodian_profile,
- Profile* new_profile);
-
- // Called back with the result of the supervised user registration.
- void OnSupervisedUserRegistered(bool create_shortcut,
- Profile* custodian_profile,
- Profile* profile,
- const GoogleServiceAuthError& error);
-
- // Updates the UI to show a non-fatal warning when creating a profile.
- void ShowProfileCreationWarning(const base::string16& warning);
-
- // Records UMA histograms relevant to supervised user profiles
- // creation and registration.
- void RecordSupervisedProfileCreationMetrics(
- GoogleServiceAuthError::State error_state);
-
- // Creates the supervised user with the given |supervised_user_id| if the user
- // doesn't already exist on the machine.
- void DoCreateProfileIfPossible(const base::string16& name,
- const std::string& icon_url,
- bool create_shortcut,
- const std::string& supervised_user_id,
- Profile* custodian_profile,
- const base::DictionaryValue* dict);
-
- // Callback for the "switchToProfile" message. Opens a new window for the
- // profile. The profile file path is passed as a string argument.
- void SwitchToProfile(const base::ListValue* args);
-
- std::unique_ptr<SupervisedUserRegistrationUtility>
- supervised_user_registration_utility_;
-#endif
+ bool create_shortcut);
content::NotificationRegistrar registrar_;
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 94c07cbe51c..12410e53de9 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
@@ -21,7 +21,6 @@
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
-#include "components/signin/core/browser/fake_auth_status_provider.h"
#include "components/sync/model/fake_sync_change_processor.h"
#include "components/sync/model/sync_data.h"
#include "components/sync/model/sync_error_factory_mock.h"
@@ -32,11 +31,6 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
-#include "chrome/browser/supervised_user/legacy/supervised_user_sync_service.h"
-#include "chrome/browser/supervised_user/legacy/supervised_user_sync_service_factory.h"
-#endif
-
// Gmock matchers and actions.
using testing::_;
using testing::Invoke;
@@ -45,37 +39,8 @@ namespace {
const char kTestProfileName[] = "test-profile-name";
-const char kTestGaiaId1[] = "test-gaia-id-1";
-const char kTestEmail1[] = "foo1@bar.com";
-
-const char kTestGaiaId2[] = "test-gaia-id-2";
-const char kTestEmail2[] = "foo2@bar.com";
-
const char kTestWebUIResponse[] = "cr.webUIListenerCallback";
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
-const char kSupervisedUserId1[] = "test-supervised-id-1";
-const char kSupervisedUserId2[] = "test-supervised-id-2";
-
-const char kSupervisedUsername1[] = "test-supervised-username-1";
-const char kSupervisedUsername2[] = "test-supervised-username-2";
-
-const char kSupervisedUserAvatarName1[] = "chrome-avatar-index:0";
-const char kSupervisedUserAvatarName2[] = "chrome-avatar-index:1";
-
-syncer::SyncData CreateSyncData(const std::string& id,
- const std::string& name,
- const std::string& chrome_avatar) {
- sync_pb::EntitySpecifics specifics;
- specifics.mutable_managed_user()->set_id(id);
- specifics.mutable_managed_user()->set_name(name);
- specifics.mutable_managed_user()->set_acknowledged(true);
- specifics.mutable_managed_user()->set_chrome_avatar(chrome_avatar);
-
- return syncer::SyncData::CreateRemoteData(1, specifics, base::Time());
-}
-#endif
-
} // namespace
class TestSigninCreateProfileHandler : public SigninCreateProfileHandler {
@@ -89,25 +54,21 @@ class TestSigninCreateProfileHandler : public SigninCreateProfileHandler {
// Mock this method since it tries to create a profile asynchronously and the
// test terminates before the callback gets called.
- MOCK_METHOD5(DoCreateProfile,
+ MOCK_METHOD3(DoCreateProfile,
void(const base::string16& name,
const std::string& icon_url,
- bool create_shortcut,
- const std::string& supervised_user_id,
- Profile* custodian_profile));
+ bool create_shortcut));
// Creates the profile synchronously, sets the appropriate flag and calls the
// callback method to resume profile creation flow.
void RealDoCreateProfile(const base::string16& name,
const std::string& icon_url,
- bool create_shortcut,
- const std::string& supervised_user_id,
- Profile* custodian_profile) {
+ bool create_shortcut) {
// Create the profile synchronously.
Profile* profile = profile_manager_->CreateTestingProfile(
kTestProfileName,
std::unique_ptr<sync_preferences::TestingPrefServiceSyncable>(), name,
- 0, supervised_user_id, TestingProfile::TestingFactories());
+ 0, std::string(), TestingProfile::TestingFactories());
// Set the flag used to track the state of the creation flow.
profile_path_being_created_ = profile->GetPath();
@@ -115,14 +76,12 @@ class TestSigninCreateProfileHandler : public SigninCreateProfileHandler {
// Call the callback method to resume profile creation flow.
SigninCreateProfileHandler::OnProfileCreated(
create_shortcut,
- supervised_user_id,
- custodian_profile,
profile,
Profile::CREATE_STATUS_INITIALIZED);
}
// Mock this method to track when an attempt to open a new browser window for
- // the newly created/imported profile is made.
+ // the newly created profile is made.
MOCK_METHOD2(OpenNewWindowForProfile,
void(Profile* profile, Profile::CreateStatus status));
@@ -130,29 +89,6 @@ class TestSigninCreateProfileHandler : public SigninCreateProfileHandler {
// the test.
MOCK_METHOD1(OpenSigninDialogForProfile, void(Profile* profile));
- // We don't actually need to register supervised users in the test. Mock this
- // method to fake the registration part.
- MOCK_METHOD4(RegisterSupervisedUser,
- void(bool create_shortcut,
- const std::string& supervised_user_id,
- Profile* custodian_profile,
- Profile* new_profile));
-
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
- // Calls the callback method to resume profile creation flow.
- void RealRegisterSupervisedUser(bool create_shortcut,
- const std::string& supervised_user_id,
- Profile* custodian_profile,
- Profile* new_profile) {
- // Call the callback method to resume profile creation flow.
- SigninCreateProfileHandler::OnSupervisedUserRegistered(
- create_shortcut,
- custodian_profile,
- new_profile,
- GoogleServiceAuthError(GoogleServiceAuthError::NONE));
- }
-#endif
-
private:
TestingProfileManager* profile_manager_;
DISALLOW_COPY_AND_ASSIGN(TestSigninCreateProfileHandler);
@@ -173,49 +109,6 @@ class SigninCreateProfileHandlerTest : public BrowserWithTestWindowTest {
TestingProfile::TestingFactories factories;
factories.push_back(std::make_pair(SigninManagerFactory::GetInstance(),
BuildFakeSigninManagerBase));
- custodian_ = profile_manager()->CreateTestingProfile(
- "custodian-profile",
- std::unique_ptr<sync_preferences::TestingPrefServiceSyncable>(),
- base::UTF8ToUTF16("custodian-profile"), 0, std::string(), factories);
-
- // Authenticate the custodian profile.
- fake_signin_manager_ = static_cast<FakeSigninManagerForTesting*>(
- SigninManagerFactory::GetForProfile(custodian_));
- fake_signin_manager_->SetAuthenticatedAccountInfo(kTestGaiaId1,
- kTestEmail1);
-
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
- // Add supervised users to the custodian profile.
- SupervisedUserSyncService* sync_service_ =
- SupervisedUserSyncServiceFactory::GetForProfile(custodian_);
- syncer::SyncDataList sync_data;
- sync_data.push_back(CreateSyncData(kSupervisedUserId1,
- kSupervisedUsername1,
- kSupervisedUserAvatarName1));
- sync_data.push_back(CreateSyncData(kSupervisedUserId2,
- kSupervisedUsername2,
- kSupervisedUserAvatarName2));
- syncer::SyncMergeResult result = sync_service_->MergeDataAndStartSyncing(
- syncer::SUPERVISED_USERS,
- sync_data,
- std::unique_ptr<syncer::SyncChangeProcessor>(
- new syncer::FakeSyncChangeProcessor()),
- std::unique_ptr<syncer::SyncErrorFactory>(
- new syncer::SyncErrorFactoryMock()));
- EXPECT_FALSE(result.error().IsSet());
- EXPECT_EQ(2u, sync_service_->GetSupervisedUsers()->size());
-
- // The second supervised user exists on the device.
- profile_manager()->CreateTestingProfile(
- kSupervisedUsername2,
- std::unique_ptr<sync_preferences::PrefServiceSyncable>(),
- base::UTF8ToUTF16(kSupervisedUsername2), 0,
- kSupervisedUserId2, // supervised_user_id
- TestingProfile::TestingFactories());
-
- EXPECT_EQ(2u,
- profile_manager()->profile_attributes_storage()->GetNumberOfProfiles());
-#endif
}
void TearDown() override {
@@ -231,17 +124,12 @@ class SigninCreateProfileHandlerTest : public BrowserWithTestWindowTest {
return handler_.get();
}
- TestingProfile* custodian() {
- return custodian_;
- }
-
FakeSigninManagerForTesting* signin_manager() {
return fake_signin_manager_;
}
private:
std::unique_ptr<content::TestWebUI> web_ui_;
- TestingProfile* custodian_;
FakeSigninManagerForTesting* fake_signin_manager_;
std::unique_ptr<TestSigninCreateProfileHandler> handler_;
};
@@ -277,64 +165,23 @@ TEST_F(SigninCreateProfileHandlerTest, ReturnDefaultProfileNameAndIcons) {
EXPECT_NE("", profile_name);
}
-TEST_F(SigninCreateProfileHandlerTest, ReturnSignedInProfiles) {
- // Create two test profiles.
- Profile* profile_1 = profile_manager()->CreateTestingProfile("profile_1");
- ASSERT_TRUE(profile_1);
- Profile* profile_2 = profile_manager()->CreateTestingProfile("profile_2");
- ASSERT_TRUE(profile_2);
-
- // Set Auth Info only for profile_2.
- ProfileAttributesEntry* entry;
- ASSERT_TRUE(profile_manager()->profile_attributes_storage()->
- GetProfileAttributesWithPath(profile_2->GetPath(), &entry));
- entry->SetAuthInfo(kTestGaiaId2, base::UTF8ToUTF16(kTestEmail2));
-
- // Expect a JS callback with a list containing profile_2.
- EXPECT_EQ(1U, web_ui()->call_data().size());
-
- EXPECT_EQ(kTestWebUIResponse, web_ui()->call_data()[0]->function_name());
-
- std::string callback_name;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg1()->GetAsString(&callback_name));
- EXPECT_EQ("signedin-users-received", callback_name);
-
- const base::ListValue* signed_in_profiles;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg2()->GetAsList(&signed_in_profiles));
- EXPECT_EQ(1U, signed_in_profiles->GetSize());
-
- const base::DictionaryValue* signed_in_profile;
- ASSERT_TRUE(signed_in_profiles->GetDictionary(0, &signed_in_profile));
- std::string user_name;
- ASSERT_TRUE(signed_in_profile->GetString("username", &user_name));
- EXPECT_EQ(kTestEmail2, user_name);
- base::string16 profile_path;
- ASSERT_TRUE(signed_in_profile->GetString("profilePath", &profile_path));
- EXPECT_EQ(profile_2->GetPath().AsUTF16Unsafe(), profile_path);
-}
-
-
TEST_F(SigninCreateProfileHandlerTest, CreateProfile) {
// Expect the call to create the profile.
- EXPECT_CALL(*handler(), DoCreateProfile(_, _, _, _, _))
+ EXPECT_CALL(*handler(), DoCreateProfile(_, _, _))
.WillOnce(Invoke(handler(),
&TestSigninCreateProfileHandler::RealDoCreateProfile));
- // Expect no calls to register a supervised user.
- EXPECT_CALL(*handler(), RegisterSupervisedUser(_, _, _, _)).Times(0);
-
// Expect a new browser window for the new profile to be opened.
EXPECT_CALL(*handler(), OpenNewWindowForProfile(_, _));
// Expect no signin dialog opened for the new profile.
EXPECT_CALL(*handler(), OpenSigninDialogForProfile(_)).Times(0);
- // Create a non-supervised profile.
+ // Create a profile.
base::ListValue list_args;
list_args.AppendString(kTestProfileName);
list_args.AppendString(profiles::GetDefaultAvatarIconUrl(0));
list_args.AppendBoolean(false); // create_shortcut
- list_args.AppendBoolean(false); // is_supervised
handler()->CreateProfile(&list_args);
// Expect a JS callbacks with the new profile information.
@@ -345,18 +192,6 @@ TEST_F(SigninCreateProfileHandlerTest, CreateProfile) {
std::string callback_name;
ASSERT_TRUE(web_ui()->call_data()[0]->arg1()->GetAsString(&callback_name));
EXPECT_EQ("create-profile-success", callback_name);
-
- const base::DictionaryValue* profile;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg2()->GetAsDictionary(&profile));
- std::string profile_name;
- ASSERT_TRUE(profile->GetString("name", &profile_name));
- EXPECT_NE("", profile_name);
- std::string profile_path;
- ASSERT_TRUE(profile->GetString("filePath", &profile_path));
- EXPECT_NE("", profile_path);
- bool is_supervised;
- ASSERT_TRUE(profile->GetBoolean("isSupervised", &is_supervised));
- ASSERT_FALSE(is_supervised);
}
TEST_F(SigninCreateProfileHandlerTest, CreateProfileWithForceSignin) {
@@ -364,13 +199,10 @@ TEST_F(SigninCreateProfileHandlerTest, CreateProfileWithForceSignin) {
ASSERT_TRUE(signin_util::IsForceSigninEnabled());
// Expect the call to create the profile.
- EXPECT_CALL(*handler(), DoCreateProfile(_, _, _, _, _))
+ EXPECT_CALL(*handler(), DoCreateProfile(_, _, _))
.WillOnce(Invoke(handler(),
&TestSigninCreateProfileHandler::RealDoCreateProfile));
- // Expect no calls to register a supervised user.
- EXPECT_CALL(*handler(), RegisterSupervisedUser(_, _, _, _)).Times(0);
-
// Expect no new browser window for the new profile.
EXPECT_CALL(*handler(), OpenNewWindowForProfile(_, _)).Times(0);
@@ -381,7 +213,6 @@ TEST_F(SigninCreateProfileHandlerTest, CreateProfileWithForceSignin) {
list_args.AppendString(kTestProfileName);
list_args.AppendString(profiles::GetDefaultAvatarIconUrl(0));
list_args.AppendBoolean(false); // create_shortcut
- list_args.AppendBoolean(false); // is_supervised
handler()->CreateProfile(&list_args);
// Expect a JS callbacks with the new profile information.
@@ -393,253 +224,5 @@ TEST_F(SigninCreateProfileHandlerTest, CreateProfileWithForceSignin) {
ASSERT_TRUE(web_ui()->call_data()[0]->arg1()->GetAsString(&callback_name));
EXPECT_EQ("create-profile-success", callback_name);
- const base::DictionaryValue* profile;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg2()->GetAsDictionary(&profile));
- std::string profile_name;
- ASSERT_TRUE(profile->GetString("name", &profile_name));
- EXPECT_NE("", profile_name);
- std::string profile_path;
- ASSERT_TRUE(profile->GetString("filePath", &profile_path));
- EXPECT_NE("", profile_path);
- bool is_supervised;
- ASSERT_TRUE(profile->GetBoolean("isSupervised", &is_supervised));
- ASSERT_FALSE(is_supervised);
- bool show_confirmation;
- ASSERT_TRUE(profile->GetBoolean("showConfirmation", &show_confirmation));
- ASSERT_FALSE(show_confirmation);
signin_util::SetForceSigninForTesting(false);
}
-
-#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
-
-TEST_F(SigninCreateProfileHandlerTest, CreateSupervisedUser) {
- // Expect the call to create the profile.
- EXPECT_CALL(*handler(), DoCreateProfile(_, _, _, _, _))
- .WillOnce(Invoke(handler(),
- &TestSigninCreateProfileHandler::RealDoCreateProfile));
-
- // Expect the call to register the supervised user.
- EXPECT_CALL(*handler(), RegisterSupervisedUser(_, _, _, _))
- .WillOnce(Invoke(
- handler(),
- &TestSigninCreateProfileHandler::RealRegisterSupervisedUser));
-
- // Expect no new browser window for the new supervised profile to be opened.
- EXPECT_CALL(*handler(), OpenNewWindowForProfile(_, _)).Times(0);
-
- // Create a supervised profile.
- base::ListValue list_args;
- list_args.Clear();
- list_args.AppendString(kSupervisedUsername1);
- list_args.AppendString(profiles::GetDefaultAvatarIconUrl(0));
- list_args.AppendBoolean(false); // create_shortcut
- list_args.AppendBoolean(true); // is_supervised
- list_args.AppendString(""); // supervised_user_id
- list_args.AppendString(custodian()->GetPath().value());
- handler()->CreateProfile(&list_args);
-
- // Expect a JS callbacks with the new profile information.
- EXPECT_EQ(1U, web_ui()->call_data().size());
-
- EXPECT_EQ(kTestWebUIResponse, web_ui()->call_data()[0]->function_name());
-
- std::string callback_name;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg1()->GetAsString(&callback_name));
- EXPECT_EQ("create-profile-success", callback_name);
-
- const base::DictionaryValue* profile;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg2()->GetAsDictionary(&profile));
- std::string profile_name;
- ASSERT_TRUE(profile->GetString("name", &profile_name));
- EXPECT_NE("", profile_name);
- std::string profile_path;
- ASSERT_TRUE(profile->GetString("filePath", &profile_path));
- EXPECT_NE("", profile_path);
- bool is_supervised;
- ASSERT_TRUE(profile->GetBoolean("isSupervised", &is_supervised));
- ASSERT_TRUE(is_supervised);
-}
-
-TEST_F(SigninCreateProfileHandlerTest, ImportSupervisedUser) {
- // Expect the call to create the profile.
- EXPECT_CALL(*handler(), DoCreateProfile(_, _, _, _, _))
- .WillOnce(Invoke(handler(),
- &TestSigninCreateProfileHandler::RealDoCreateProfile));
-
- // Expect the call to register the supervised user.
- EXPECT_CALL(*handler(), RegisterSupervisedUser(_, _, _, _))
- .WillOnce(Invoke(
- handler(),
- &TestSigninCreateProfileHandler::RealRegisterSupervisedUser));
-
- // Expect a new browser window for the new profile to be opened.
- EXPECT_CALL(*handler(), OpenNewWindowForProfile(_, _));
-
- // Import a supervised profile.
- base::ListValue list_args;
- list_args.Clear();
- list_args.AppendString(kSupervisedUsername1);
- list_args.AppendString(profiles::GetDefaultAvatarIconUrl(0));
- list_args.AppendBoolean(false); // create_shortcut
- list_args.AppendBoolean(true); // is_supervised
- list_args.AppendString(
- kSupervisedUserId1); // supervised_user_id
- list_args.AppendString(custodian()->GetPath().value());
- handler()->CreateProfile(&list_args);
-
- // Expect a JS callbacks with the new profile information.
- EXPECT_EQ(1U, web_ui()->call_data().size());
-
- EXPECT_EQ(kTestWebUIResponse, web_ui()->call_data()[0]->function_name());
-
- std::string callback_name;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg1()->GetAsString(&callback_name));
- EXPECT_EQ("create-profile-success", callback_name);
-
- const base::DictionaryValue* profile;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg2()->GetAsDictionary(&profile));
- std::string profile_name;
- ASSERT_TRUE(profile->GetString("name", &profile_name));
- EXPECT_NE("", profile_name);
- std::string profile_path;
- ASSERT_TRUE(profile->GetString("filePath", &profile_path));
- EXPECT_NE("", profile_path);
- bool is_supervised;
- ASSERT_TRUE(profile->GetBoolean("isSupervised", &is_supervised));
- ASSERT_TRUE(is_supervised);
-}
-
-TEST_F(SigninCreateProfileHandlerTest, ImportSupervisedUserAlreadyOnDevice) {
- // Import a supervised profile whose already on the current device.
- base::ListValue list_args;
- list_args.Clear();
- list_args.AppendString(kSupervisedUsername2);
- list_args.AppendString(profiles::GetDefaultAvatarIconUrl(0));
- list_args.AppendBoolean(false);
- list_args.AppendBoolean(true);
- list_args.AppendString(kSupervisedUserId2);
- list_args.AppendString(custodian()->GetPath().value());
- handler()->CreateProfile(&list_args);
-
- // Expect a JS callbacks containing an error message.
- EXPECT_EQ(1U, web_ui()->call_data().size());
-
- EXPECT_EQ(kTestWebUIResponse, web_ui()->call_data()[0]->function_name());
-
- std::string callback_name;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg1()->GetAsString(&callback_name));
- EXPECT_EQ("create-profile-error", callback_name);
-
- base::string16 expected_error_message = l10n_util::GetStringUTF16(
- IDS_LEGACY_SUPERVISED_USER_IMPORT_LOCAL_ERROR);
- base::string16 error_message;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg2()->GetAsString(&error_message));
- EXPECT_EQ(expected_error_message, error_message);
-}
-
-TEST_F(SigninCreateProfileHandlerTest, CustodianNotAuthenticated) {
- // Stop Sync before signing out.
- SupervisedUserSyncService* sync_service_ =
- SupervisedUserSyncServiceFactory::GetForProfile(custodian());
- sync_service_->StopSyncing(syncer::SUPERVISED_USERS);
-
- // Sign out the custodian.
- signin_manager()->ForceSignOut();
-
- // Create a supervised profile.
- base::ListValue list_args;
- list_args.Clear();
- list_args.AppendString(kSupervisedUsername1);
- list_args.AppendString(profiles::GetDefaultAvatarIconUrl(0));
- list_args.AppendBoolean(false); // create_shortcut
- list_args.AppendBoolean(true); // is_supervised
- list_args.AppendString(""); // supervised_user_id
- list_args.AppendString(custodian()->GetPath().value());
- handler()->CreateProfile(&list_args);
-
- // Expect a JS callbacks containing an error message.
- EXPECT_EQ(1U, web_ui()->call_data().size());
-
- EXPECT_EQ(kTestWebUIResponse, web_ui()->call_data()[0]->function_name());
-
- std::string callback_name;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg1()->GetAsString(&callback_name));
- EXPECT_EQ("create-profile-error", callback_name);
-
- base::string16 expected_error_message = l10n_util::GetStringFUTF16(
- IDS_PROFILES_CREATE_CUSTODIAN_ACCOUNT_DETAILS_OUT_OF_DATE_ERROR,
- base::ASCIIToUTF16(custodian()->GetProfileUserName()));
- base::string16 error_message;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg2()->GetAsString(&error_message));
- EXPECT_EQ(expected_error_message, error_message);
-}
-
-TEST_F(SigninCreateProfileHandlerTest, CustodianHasAuthError) {
- // Set an Auth Error for the custodian.
- const GoogleServiceAuthError error(
- GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
- FakeAuthStatusProvider provider(
- SigninErrorControllerFactory::GetForProfile(custodian()));
- provider.SetAuthError(kTestGaiaId1, error);
-
- // Create a supervised profile.
- base::ListValue list_args;
- list_args.Clear();
- list_args.AppendString(kSupervisedUsername1);
- list_args.AppendString(profiles::GetDefaultAvatarIconUrl(0));
- list_args.AppendBoolean(false); // create_shortcut
- list_args.AppendBoolean(true); // is_supervised
- list_args.AppendString(""); // supervised_user_id
- list_args.AppendString(custodian()->GetPath().value());
- handler()->CreateProfile(&list_args);
-
- // Expect a JS callbacks containing an error message.
- EXPECT_EQ(1U, web_ui()->call_data().size());
-
- EXPECT_EQ(kTestWebUIResponse, web_ui()->call_data()[0]->function_name());
-
- std::string callback_name;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg1()->GetAsString(&callback_name));
- EXPECT_EQ("create-profile-error", callback_name);
-
- base::string16 expected_error_message = l10n_util::GetStringFUTF16(
- IDS_PROFILES_CREATE_CUSTODIAN_ACCOUNT_DETAILS_OUT_OF_DATE_ERROR,
- base::ASCIIToUTF16(custodian()->GetProfileUserName()));
- base::string16 error_message;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg2()->GetAsString(&error_message));
- EXPECT_EQ(expected_error_message, error_message);
-}
-
-TEST_F(SigninCreateProfileHandlerTest, NotAllowedToCreateSupervisedUser) {
- // Custodian is not permitted to create supervised users.
- custodian()->GetPrefs()->SetBoolean(prefs::kSupervisedUserCreationAllowed,
- false);
-
- // Create a supervised profile.
- base::ListValue list_args;
- list_args.Clear();
- list_args.AppendString(kSupervisedUsername1);
- list_args.AppendString(profiles::GetDefaultAvatarIconUrl(0));
- list_args.AppendBoolean(false); // create_shortcut
- list_args.AppendBoolean(true); // is_supervised
- list_args.AppendString(""); // supervised_user_id
- list_args.AppendString(custodian()->GetPath().value());
- handler()->CreateProfile(&list_args);
-
- // Expect a JS callbacks containing an error message.
- EXPECT_EQ(1U, web_ui()->call_data().size());
-
- EXPECT_EQ(kTestWebUIResponse, web_ui()->call_data()[0]->function_name());
-
- std::string callback_name;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg1()->GetAsString(&callback_name));
- EXPECT_EQ("create-profile-error", callback_name);
-
- base::string16 expected_error_message = l10n_util::GetStringUTF16(
- IDS_PROFILES_CREATE_SUPERVISED_NOT_ALLOWED_BY_POLICY);
- base::string16 error_message;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg2()->GetAsString(&error_message));
- EXPECT_EQ(expected_error_message, error_message);
-}
-
-#endif
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.cc b/chromium/chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.cc
deleted file mode 100644
index 1de21e772db..00000000000
--- a/chromium/chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.cc
+++ /dev/null
@@ -1,321 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.h"
-
-#include <stddef.h>
-
-#include <memory>
-#include <set>
-#include <utility>
-#include <vector>
-
-#include "base/bind.h"
-#include "base/macros.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/value_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile_attributes_entry.h"
-#include "chrome/browser/profiles/profile_attributes_storage.h"
-#include "chrome/browser/profiles/profile_avatar_icon_util.h"
-#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/signin/signin_error_controller_factory.h"
-#include "chrome/browser/signin/signin_manager_factory.h"
-#include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.h"
-#include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service_factory.h"
-#include "chrome/browser/supervised_user/legacy/supervised_user_sync_service.h"
-#include "chrome/browser/supervised_user/legacy/supervised_user_sync_service_factory.h"
-#include "chrome/browser/supervised_user/supervised_user_constants.h"
-#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/user_manager.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/grit/generated_resources.h"
-#include "components/prefs/pref_service.h"
-#include "components/signin/core/browser/signin_error_controller.h"
-#include "components/signin/core/browser/signin_manager.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/web_ui.h"
-#include "content/public/common/referrer.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "url/gurl.h"
-
-
-SigninSupervisedUserImportHandler::SigninSupervisedUserImportHandler()
- : weak_ptr_factory_(this) {
-}
-
-SigninSupervisedUserImportHandler::~SigninSupervisedUserImportHandler() {
-}
-
-void SigninSupervisedUserImportHandler::GetLocalizedValues(
- base::DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
-
- localized_strings->SetString("supervisedUserImportTitle",
- l10n_util::GetStringUTF16(
- IDS_IMPORT_EXISTING_LEGACY_SUPERVISED_USER_TITLE));
- localized_strings->SetString("supervisedUserImportText",
- l10n_util::GetStringUTF16(
- IDS_IMPORT_EXISTING_LEGACY_SUPERVISED_USER_TEXT));
- localized_strings->SetString("noSupervisedUserImportText",
- l10n_util::GetStringUTF16(IDS_IMPORT_NO_EXISTING_SUPERVISED_USER_TEXT));
- localized_strings->SetString("supervisedUserImportOk",
- l10n_util::GetStringUTF16(IDS_IMPORT_EXISTING_LEGACY_SUPERVISED_USER_OK));
- localized_strings->SetString("supervisedUserAlreadyOnThisDevice",
- l10n_util::GetStringUTF16(
- IDS_LEGACY_SUPERVISED_USER_ALREADY_ON_THIS_DEVICE));
-}
-
-void SigninSupervisedUserImportHandler::RegisterMessages() {
- web_ui()->RegisterMessageCallback(
- "getExistingSupervisedUsers",
- base::BindRepeating(
- &SigninSupervisedUserImportHandler::GetExistingSupervisedUsers,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "openUrlInLastActiveProfileBrowser",
- base::BindRepeating(
- &SigninSupervisedUserImportHandler::OpenUrlInLastActiveProfileBrowser,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "authenticateCustodian",
- base::BindRepeating(
- &SigninSupervisedUserImportHandler::AuthenticateCustodian,
- base::Unretained(this)));
- web_ui()->RegisterMessageCallback(
- "cancelLoadingSupervisedUsers",
- base::BindRepeating(
- &SigninSupervisedUserImportHandler::HandleCancelLoadSupervisedUsers,
- base::Unretained(this)));
-}
-
-void SigninSupervisedUserImportHandler::AssignWebUICallbackId(
- const base::ListValue* args) {
- CHECK_LE(1U, args->GetSize());
- CHECK(webui_callback_id_.empty());
- CHECK(args->GetString(0, &webui_callback_id_));
- AllowJavascript();
-}
-
-void SigninSupervisedUserImportHandler::OpenUrlInLastActiveProfileBrowser(
- const base::ListValue* args) {
- CHECK_EQ(1U, args->GetSize());
- std::string url;
- bool success = args->GetString(0, &url);
- DCHECK(success);
- content::OpenURLParams params(GURL(url), content::Referrer(),
- WindowOpenDisposition::NEW_FOREGROUND_TAB,
- ui::PAGE_TRANSITION_LINK, false);
- // ProfileManager::GetLastUsedProfile() will attempt to load the default
- // profile if there is no last used profile. If the default profile is not
- // fully loaded and initialized, it will attempt to do so synchronously.
- // Therefore we cannot use that method here. If the last used profile is not
- // loaded, we do nothing. This is an edge case and should not happen often.
- ProfileManager* profile_manager = g_browser_process->profile_manager();
- base::FilePath last_used_profile_dir =
- profile_manager->GetLastUsedProfileDir(profile_manager->user_data_dir());
- Profile* last_used_profile =
- profile_manager->GetProfileByPath(last_used_profile_dir);
-
- if (last_used_profile) {
- // Last used profile may be the Guest Profile.
- if (ProfileManager::IncognitoModeForced(last_used_profile))
- last_used_profile = last_used_profile->GetOffTheRecordProfile();
-
- // Get the browser owned by the last used profile or create a new one if
- // it doesn't exist.
- Browser* browser = chrome::FindLastActiveWithProfile(last_used_profile);
- if (!browser)
- browser = new Browser(
- Browser::CreateParams(Browser::TYPE_TABBED, last_used_profile, true));
- browser->OpenURL(params);
- }
-}
-
-void SigninSupervisedUserImportHandler::AuthenticateCustodian(
- const base::ListValue* args) {
- CHECK_EQ(1U, args->GetSize());
-
- std::string email;
- bool success = args->GetString(0, &email);
- DCHECK(success);
-
- UserManagerProfileDialog::ShowReauthDialog(
- web_ui()->GetWebContents()->GetBrowserContext(), email,
- signin_metrics::Reason::REASON_REAUTHENTICATION);
-}
-
-void SigninSupervisedUserImportHandler::GetExistingSupervisedUsers(
- const base::ListValue* args) {
- CHECK_EQ(2U, args->GetSize());
- AssignWebUICallbackId(args);
-
- base::FilePath custodian_profile_path;
- const base::Value* profile_path_value;
- bool success = args->Get(1, &profile_path_value);
- DCHECK(success);
- success = base::GetValueAsFilePath(*profile_path_value,
- &custodian_profile_path);
- DCHECK(success);
-
- // Load custodian profile.
- g_browser_process->profile_manager()->CreateProfileAsync(
- custodian_profile_path,
- base::Bind(
- &SigninSupervisedUserImportHandler::LoadCustodianProfileCallback,
- weak_ptr_factory_.GetWeakPtr()),
- base::string16(), std::string(), std::string());
-}
-
-void SigninSupervisedUserImportHandler::HandleCancelLoadSupervisedUsers(
- const base::ListValue* args) {
- webui_callback_id_.clear();
-}
-
-void SigninSupervisedUserImportHandler::LoadCustodianProfileCallback(
- Profile* profile, Profile::CreateStatus status) {
-
- // This method gets called once before with Profile::CREATE_STATUS_CREATED.
- switch (status) {
- case Profile::CREATE_STATUS_LOCAL_FAIL: {
- RejectCallback(GetLocalErrorMessage());
- break;
- }
- case Profile::CREATE_STATUS_CREATED: {
- // Ignore the intermediate status.
- break;
- }
- case Profile::CREATE_STATUS_INITIALIZED: {
- // We are only interested in Profile::CREATE_STATUS_INITIALIZED when
- // everything is ready.
- if (profile->IsSupervised()) {
- webui_callback_id_.clear();
- return;
- }
-
- if (!IsAccountConnected(profile) || HasAuthError(profile)) {
- RejectCallback(GetAuthErrorMessage(profile));
- return;
- }
-
- SupervisedUserSyncService* supervised_user_sync_service =
- SupervisedUserSyncServiceFactory::GetForProfile(profile);
- if (supervised_user_sync_service) {
- supervised_user_sync_service->GetSupervisedUsersAsync(
- base::Bind(
- &SigninSupervisedUserImportHandler::SendExistingSupervisedUsers,
- weak_ptr_factory_.GetWeakPtr(), profile));
- }
- break;
- }
- case Profile::CREATE_STATUS_CANCELED:
- case Profile::CREATE_STATUS_REMOTE_FAIL:
- case Profile::MAX_CREATE_STATUS: {
- NOTREACHED();
- break;
- }
- }
-}
-
-void SigninSupervisedUserImportHandler::RejectCallback(
- const base::string16& error) {
- RejectJavascriptCallback(base::Value(webui_callback_id_), base::Value(error));
- webui_callback_id_.clear();
-}
-
-base::string16 SigninSupervisedUserImportHandler::GetLocalErrorMessage() const {
- return l10n_util::GetStringUTF16(
- IDS_LEGACY_SUPERVISED_USER_IMPORT_LOCAL_ERROR);
-}
-
-base::string16 SigninSupervisedUserImportHandler::GetAuthErrorMessage(
- Profile* profile) const {
- return l10n_util::GetStringFUTF16(
- IDS_PROFILES_CREATE_CUSTODIAN_ACCOUNT_DETAILS_OUT_OF_DATE_ERROR,
- base::ASCIIToUTF16(profile->GetProfileUserName()));
-}
-
-void SigninSupervisedUserImportHandler::SendExistingSupervisedUsers(
- Profile* profile,
- const base::DictionaryValue* dict) {
- DCHECK(dict);
- std::vector<ProfileAttributesEntry*> entries =
- g_browser_process->profile_manager()->GetProfileAttributesStorage().
- GetAllProfilesAttributes();
-
- // Collect the ids of local supervised user profiles.
- std::set<std::string> supervised_user_ids;
- for (auto* entry : entries) {
- // Filter out omitted profiles. These are currently being imported, and
- // shouldn't show up as "already on this device" just yet.
- if (entry->IsLegacySupervised() && !entry->IsOmitted()) {
- supervised_user_ids.insert(entry->GetSupervisedUserId());
- }
- }
-
- base::ListValue supervised_users;
- SupervisedUserSharedSettingsService* service =
- SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(profile);
- for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) {
- const base::DictionaryValue* value = NULL;
- bool success = it.value().GetAsDictionary(&value);
- DCHECK(success);
- std::string name;
- value->GetString(SupervisedUserSyncService::kName, &name);
-
- std::unique_ptr<base::DictionaryValue> supervised_user(
- new base::DictionaryValue);
- supervised_user->SetString("id", it.key());
- supervised_user->SetString("name", name);
-
- int avatar_index = SupervisedUserSyncService::kNoAvatar;
- const base::Value* avatar_index_value =
- service->GetValue(it.key(), supervised_users::kChromeAvatarIndex);
- if (avatar_index_value) {
- success = avatar_index_value->GetAsInteger(&avatar_index);
- } else {
- // Check if there is a legacy avatar index stored.
- std::string avatar_str;
- value->GetString(SupervisedUserSyncService::kChromeAvatar, &avatar_str);
- success =
- SupervisedUserSyncService::GetAvatarIndex(avatar_str, &avatar_index);
- }
- DCHECK(success);
-
- std::string avatar_url =
- avatar_index == SupervisedUserSyncService::kNoAvatar ?
- profiles::GetDefaultAvatarIconUrl(
- profiles::GetPlaceholderAvatarIndex()) :
- profiles::GetDefaultAvatarIconUrl(avatar_index);
- supervised_user->SetString("iconURL", avatar_url);
- bool on_current_device =
- supervised_user_ids.find(it.key()) != supervised_user_ids.end();
- supervised_user->SetBoolean("onCurrentDevice", on_current_device);
-
- supervised_users.Append(std::move(supervised_user));
- }
-
- // Resolve callback with response.
- ResolveJavascriptCallback(base::Value(webui_callback_id_), supervised_users);
- webui_callback_id_.clear();
-}
-
-bool SigninSupervisedUserImportHandler::IsAccountConnected(
- Profile* profile) const {
- SigninManagerBase* signin_manager =
- SigninManagerFactory::GetForProfile(profile);
- return signin_manager && signin_manager->IsAuthenticated();
-}
-
-bool SigninSupervisedUserImportHandler::HasAuthError(Profile* profile) const {
- SigninErrorController* error_controller =
- SigninErrorControllerFactory::GetForProfile(profile);
- if (!error_controller)
- return true;
-
- GoogleServiceAuthError::State state = error_controller->auth_error().state();
- return state != GoogleServiceAuthError::NONE;
-}
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.h b/chromium/chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.h
deleted file mode 100644
index 8eaf06f2660..00000000000
--- a/chromium/chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.h
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_SUPERVISED_USER_IMPORT_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_SUPERVISED_USER_IMPORT_HANDLER_H_
-
-#include <string>
-
-#include "base/callback_list.h"
-#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
-#include "base/strings/string16.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/supervised_user/supervised_users.h"
-#include "content/public/browser/web_ui_message_handler.h"
-
-namespace base {
-class DictionaryValue;
-class ListValue;
-}
-
-// Handler for the 'import existing supervised user' dialog.
-class SigninSupervisedUserImportHandler : public content::WebUIMessageHandler {
- public:
- SigninSupervisedUserImportHandler();
- ~SigninSupervisedUserImportHandler() override;
-
- void GetLocalizedValues(base::DictionaryValue* localized_strings);
-
- // WebUIMessageHandler implementation.
- void RegisterMessages() override;
-
- private:
- FRIEND_TEST_ALL_PREFIXES(SigninSupervisedUserImportHandlerTest,
- NotAuthenticated);
- FRIEND_TEST_ALL_PREFIXES(SigninSupervisedUserImportHandlerTest, AuthError);
- FRIEND_TEST_ALL_PREFIXES(SigninSupervisedUserImportHandlerTest,
- CustodianIsSupervised);
- FRIEND_TEST_ALL_PREFIXES(SigninSupervisedUserImportHandlerTest,
- SendExistingSupervisedUsers);
- // Assigns a new |webui_callback_id_|. Ensures that previous in-flight request
- // has been fulfilled.
- void AssignWebUICallbackId(const base::ListValue* args);
-
- // Callback for the "openUrlInLastActiveProfileBrowser" message. Opens the
- // given url in a new background tab in the browser owned by the last active
- // profile. Hyperlinks don't work in the user manager since the system profile
- // browser is not tabbed.
- void OpenUrlInLastActiveProfileBrowser(const base::ListValue* args);
-
- // Used to cancel loading existing supervised users. Resets WebUI callback ID
- // of the last in-flight async request.
- void HandleCancelLoadSupervisedUsers(const base::ListValue* args);
-
- // Callback for the "getExistingSupervisedUsers" message. Returns a list of
- // supervised users attached to the given custodian profile.
- void GetExistingSupervisedUsers(const base::ListValue* args);
-
- // Callback for the "authenticateCustodian" message. Authenticates the
- // custodian profile with the given email address.
- void AuthenticateCustodian(const base::ListValue* args);
-
- void LoadCustodianProfileCallback(Profile* custodian_profile,
- Profile::CreateStatus status);
-
- // Reject the WebUI callback with an error message.
- void RejectCallback(const base::string16& error);
-
- base::string16 GetLocalErrorMessage() const;
-
- base::string16 GetAuthErrorMessage(Profile* profile) const;
-
- // Sends an array of supervised users to WebUI. Each entry is of the form:
- // supervisedProfile = {
- // id: "Supervised User ID",
- // name: "Supervised User Name",
- // iconURL: "chrome://path/to/icon/image",
- // onCurrentDevice: true or false,
- // }
- // The array holds all existing supervised users attached to the
- // custodian's profile which initiated the request.
- void SendExistingSupervisedUsers(Profile* profile,
- const base::DictionaryValue* dict);
-
- bool IsAccountConnected(Profile* profile) const;
- bool HasAuthError(Profile* profile) const;
-
- // The WebUI callback ID of the last in-flight async request. There is always
- // only one in-flight such request.
- std::string webui_callback_id_;
-
- Profile* last_used_profile;
-
- base::WeakPtrFactory<SigninSupervisedUserImportHandler> weak_ptr_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(SigninSupervisedUserImportHandler);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_SIGNIN_SUPERVISED_USER_IMPORT_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/signin/signin_supervised_user_import_handler_unittest.cc b/chromium/chrome/browser/ui/webui/signin/signin_supervised_user_import_handler_unittest.cc
deleted file mode 100644
index cc615490d3c..00000000000
--- a/chromium/chrome/browser/ui/webui/signin/signin_supervised_user_import_handler_unittest.cc
+++ /dev/null
@@ -1,234 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.h"
-
-#include "base/strings/utf_string_conversions.h"
-#include "base/time/time.h"
-#include "chrome/browser/signin/fake_signin_manager_builder.h"
-#include "chrome/browser/signin/signin_error_controller_factory.h"
-#include "chrome/browser/signin/signin_manager_factory.h"
-#include "chrome/browser/supervised_user/legacy/supervised_user_sync_service.h"
-#include "chrome/browser/supervised_user/legacy/supervised_user_sync_service_factory.h"
-#include "chrome/grit/generated_resources.h"
-#include "chrome/test/base/browser_with_test_window_test.h"
-#include "chrome/test/base/testing_browser_process.h"
-#include "chrome/test/base/testing_profile.h"
-#include "chrome/test/base/testing_profile_manager.h"
-#include "components/signin/core/browser/fake_auth_status_provider.h"
-#include "components/sync/model/fake_sync_change_processor.h"
-#include "components/sync/model/sync_error_factory_mock.h"
-#include "components/sync/protocol/sync.pb.h"
-#include "components/sync_preferences/pref_service_syncable.h"
-#include "content/public/test/test_web_ui.h"
-#include "ui/base/l10n/l10n_util.h"
-
-namespace {
-
-const char kTestGaiaId[] = "test-gaia-id";
-const char kTestEmail[] = "foo@bar.com";
-
-const char kTestWebUIResponse[] = "cr.webUIResponse";
-const char kTestCallbackId[] = "test-callback-id";
-
-const char kSupervisedUserId[] = "test-supervised-id";
-const char kSupervisedUsername[] = "test-supervised-username";
-const char kSupervisedUserAvatarName[] = "chrome-avatar-index:0";
-const char kSupervisedUserAvatarUrl[] = "chrome://theme/IDR_PROFILE_AVATAR_0";
-
-syncer::SyncData CreateSyncData(const std::string& id,
- const std::string& name,
- const std::string& chrome_avatar) {
- sync_pb::EntitySpecifics specifics;
- specifics.mutable_managed_user()->set_id(id);
- specifics.mutable_managed_user()->set_name(name);
- specifics.mutable_managed_user()->set_acknowledged(true);
- specifics.mutable_managed_user()->set_chrome_avatar(chrome_avatar);
-
- return syncer::SyncData::CreateRemoteData(1, specifics, base::Time());
-}
-
-} // namespace
-
-class TestSigninSupervisedUserImportHandler :
- public SigninSupervisedUserImportHandler {
- public:
- explicit TestSigninSupervisedUserImportHandler(content::WebUI* web_ui) {
- set_web_ui(web_ui);
- }
-};
-
-class SigninSupervisedUserImportHandlerTest : public BrowserWithTestWindowTest {
- public:
- SigninSupervisedUserImportHandlerTest() : web_ui_(new content::TestWebUI) {}
-
- void SetUp() override {
- BrowserWithTestWindowTest::SetUp();
- handler_.reset(new TestSigninSupervisedUserImportHandler(web_ui()));
-
- // Authenticate the test profile.
- fake_signin_manager_ = static_cast<FakeSigninManagerForTesting*>(
- SigninManagerFactory::GetForProfile(profile()));
- fake_signin_manager_->SetAuthenticatedAccountInfo(kTestGaiaId, kTestEmail);
-
- // Add supervised users to the profile.
- SupervisedUserSyncService* sync_service_ =
- SupervisedUserSyncServiceFactory::GetForProfile(profile());
- syncer::SyncDataList sync_data;
- sync_data.push_back(CreateSyncData(kSupervisedUserId,
- kSupervisedUsername,
- kSupervisedUserAvatarName));
- syncer::SyncMergeResult result = sync_service_->MergeDataAndStartSyncing(
- syncer::SUPERVISED_USERS,
- sync_data,
- std::unique_ptr<syncer::SyncChangeProcessor>(
- new syncer::FakeSyncChangeProcessor()),
- std::unique_ptr<syncer::SyncErrorFactory>(
- new syncer::SyncErrorFactoryMock()));
- EXPECT_FALSE(result.error().IsSet());
- EXPECT_EQ(1u, sync_service_->GetSupervisedUsers()->size());
- }
-
- void TearDown() override {
- handler_.reset();
- web_ui_.reset();
- BrowserWithTestWindowTest::TearDown();
- }
-
- TestingProfile::TestingFactories GetTestingFactories() override {
- return {{SigninManagerFactory::GetInstance(), BuildFakeSigninManagerBase}};
- }
-
- content::TestWebUI* web_ui() {
- return web_ui_.get();
- }
-
- TestSigninSupervisedUserImportHandler* handler() {
- return handler_.get();
- }
-
- FakeSigninManagerForTesting* signin_manager() {
- return fake_signin_manager_;
- }
-
- void VerifyResponse(size_t expected_total_calls,
- const std::string& expected_callback_id,
- bool expected_fulfilled) {
- EXPECT_EQ(expected_total_calls, web_ui()->call_data().size());
-
- EXPECT_EQ(kTestWebUIResponse, web_ui()->call_data()[0]->function_name());
-
- std::string callback_id;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg1()->GetAsString(&callback_id));
- EXPECT_EQ(expected_callback_id, callback_id);
-
- bool fulfilled;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg2()->GetAsBoolean(&fulfilled));
- EXPECT_EQ(expected_fulfilled, fulfilled);
- }
-
- private:
- std::unique_ptr<content::TestWebUI> web_ui_;
- std::unique_ptr<TestSigninSupervisedUserImportHandler> handler_;
- FakeSigninManagerForTesting* fake_signin_manager_;
-};
-
-TEST_F(SigninSupervisedUserImportHandlerTest, NotAuthenticated) {
- // Stop Sync before signing out.
- SupervisedUserSyncService* sync_service_ =
- SupervisedUserSyncServiceFactory::GetForProfile(profile());
- sync_service_->StopSyncing(syncer::SUPERVISED_USERS);
-
- // Sign out the user.
- signin_manager()->ForceSignOut();
-
- // Test the JS -> C++ -> JS callback path.
- base::ListValue list_args;
- list_args.AppendString(kTestCallbackId);
- list_args.AppendString(profile()->GetPath().AsUTF16Unsafe());
- handler()->GetExistingSupervisedUsers(&list_args);
-
- // Expect an error response.
- VerifyResponse(1U, kTestCallbackId, false);
-
- base::string16 expected_error_message = l10n_util::GetStringFUTF16(
- IDS_PROFILES_CREATE_CUSTODIAN_ACCOUNT_DETAILS_OUT_OF_DATE_ERROR,
- base::ASCIIToUTF16(profile()->GetProfileUserName()));
- base::string16 error_message;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg3()->GetAsString(&error_message));
- EXPECT_EQ(expected_error_message, error_message);
-}
-
-TEST_F(SigninSupervisedUserImportHandlerTest, AuthError) {
- // Set Auth Error.
- const GoogleServiceAuthError error(
- GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
- FakeAuthStatusProvider provider(
- SigninErrorControllerFactory::GetForProfile(profile()));
- provider.SetAuthError(kTestGaiaId, error);
-
- // Test the JS -> C++ -> JS callback path.
- base::ListValue list_args;
- list_args.AppendString(kTestCallbackId);
- list_args.AppendString(profile()->GetPath().AsUTF16Unsafe());
- handler()->GetExistingSupervisedUsers(&list_args);
-
- // Expect an error response.
- VerifyResponse(1U, kTestCallbackId, false);
-
- base::string16 expected_error_message = l10n_util::GetStringFUTF16(
- IDS_PROFILES_CREATE_CUSTODIAN_ACCOUNT_DETAILS_OUT_OF_DATE_ERROR,
- base::ASCIIToUTF16(profile()->GetProfileUserName()));
- base::string16 error_message;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg3()->GetAsString(&error_message));
- EXPECT_EQ(expected_error_message, error_message);
-}
-
-TEST_F(SigninSupervisedUserImportHandlerTest, CustodianIsSupervised) {
- // Build a supervised test profile.
- TestingProfile* supervised_profile = profile_manager()->CreateTestingProfile(
- "supervised-test-profile", nullptr,
- base::UTF8ToUTF16("supervised-test-profile"), 0,
- "12345", // supervised_user_id
- TestingProfile::TestingFactories());
-
- // Test the JS -> C++ -> JS callback path.
- base::ListValue list_args;
- list_args.AppendString(kTestCallbackId);
- list_args.AppendString(supervised_profile->GetPath().AsUTF16Unsafe());
- handler()->GetExistingSupervisedUsers(&list_args);
-
- // Expect to do nothing.
- EXPECT_EQ(0U, web_ui()->call_data().size());
-}
-
-TEST_F(SigninSupervisedUserImportHandlerTest, SendExistingSupervisedUsers) {
- // Test the JS -> C++ -> JS callback path.
- base::ListValue list_args;
- list_args.AppendString(kTestCallbackId);
- list_args.AppendString(profile()->GetPath().AsUTF16Unsafe());
- handler()->GetExistingSupervisedUsers(&list_args);
-
- // Expect a success response.
- VerifyResponse(1U, kTestCallbackId, true);
-
- const base::ListValue* supervised_users;
- ASSERT_TRUE(web_ui()->call_data()[0]->arg3()->GetAsList(&supervised_users));
- EXPECT_EQ(1U, supervised_users->GetSize());
-
- const base::DictionaryValue* supervised_user;
- ASSERT_TRUE(supervised_users->GetDictionary(0, &supervised_user));
- std::string id;
- ASSERT_TRUE(supervised_user->GetString("id", &id));
- EXPECT_EQ(kSupervisedUserId, id);
- std::string name;
- ASSERT_TRUE(supervised_user->GetString("name", &name));
- EXPECT_EQ(kSupervisedUsername, name);
- std::string iconURL;
- ASSERT_TRUE(supervised_user->GetString("iconURL", &iconURL));
- EXPECT_EQ(kSupervisedUserAvatarUrl, iconURL);
- bool onCurrentDevice;
- ASSERT_TRUE(supervised_user->GetBoolean("onCurrentDevice", &onCurrentDevice));
- ASSERT_FALSE(onCurrentDevice);
-}
diff --git a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.cc b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.cc
index 119d9bb48e7..0fd7181d995 100644
--- a/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.cc
+++ b/chromium/chrome/browser/ui/webui/signin/sync_confirmation_ui.cc
@@ -8,13 +8,18 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/signin/account_consistency_mode_manager.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/unified_consent_helper.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/webui/signin/sync_confirmation_handler.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
+#include "components/signin/core/browser/avatar_icon_util.h"
+#include "components/signin/core/browser/signin_manager.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 "ui/base/l10n/l10n_util.h"
@@ -57,10 +62,51 @@ SyncConfirmationUI::SyncConfirmationUI(content::WebUI* web_ui)
IDS_SYNC_CONFIRMATION_DICE_SYNC_SETTINGS_LINK_BODY);
AddStringResource(source, "syncConfirmationSyncSettingsDescription",
IDS_SYNC_CONFIRMATION_DICE_SYNC_SETTINGS_DESCRIPTION);
+ AddStringResource(source, "syncConfirmationSettingsLabel",
+ IDS_SYNC_CONFIRMATION_DICE_SETTINGS_BUTTON_LABEL);
+
+ AddStringResource(source, "syncConfirmationMoreOptionsLabel",
+ IDS_SYNC_CONFIRMATION_UNITY_MORE_OPTIONS_BUTTON_LABEL);
+ AddStringResource(source, "syncConfirmationOptionsTitle",
+ IDS_SYNC_CONFIRMATION_UNITY_MORE_OPTIONS_TITLE);
+ AddStringResource(source, "syncConfirmationOptionsSubtitle",
+ IDS_SYNC_CONFIRMATION_UNITY_MORE_OPTIONS_SUBTITLE);
+ AddStringResource(
+ source, "syncConfirmationOptionsReviewSettingsTitle",
+ IDS_SYNC_CONFIRMATION_UNITY_OPTIONS_REVIEW_SETTINGS_TITLE);
+ AddStringResource(
+ source, "syncConfirmationOptionsMakeNoChangesTitle",
+ IDS_SYNC_CONFIRMATION_UNITY_OPTIONS_MAKE_NO_CHANGES_TITLE);
+ AddStringResource(
+ source, "syncConfirmationOptionsMakeNoChangesSubtitle",
+ IDS_SYNC_CONFIRMATION_UNITY_OPTIONS_MAKE_NO_CHANGES_SUBTITLE);
+ AddStringResource(source, "syncConfirmationOptionsUseDefaultTitle",
+ IDS_SYNC_CONFIRMATION_UNITY_OPTIONS_USE_DEFAULT_TITLE);
+ AddStringResource(source, "syncConfirmationOptionsUseDefaultSubtitle",
+ IDS_SYNC_CONFIRMATION_UNITY_OPTIONS_USE_DEFAULT_SUBTITLE);
+ AddStringResource(source, "syncConfirmationOptionsConfirmLabel",
+ IDS_SYNC_CONFIRMATION_UNITY_OPTIONS_CONFIRM_BUTTON_LABEL);
+ AddStringResource(source, "syncConfirmationOptionsBackLabel",
+ IDS_SYNC_CONFIRMATION_UNITY_OPTIONS_BACK_BUTTON_LABEL);
+ AddStringResource(source, "syncConsentBumpTitle",
+ IDS_SYNC_CONFIRMATION_UNITY_CONSENT_BUMP_TITLE);
+
+ constexpr int kAccountPictureSize = 68;
+ std::string custom_picture_url = profiles::GetPlaceholderAvatarIconUrl();
+ GURL account_picture_url(SigninManagerFactory::GetForProfile(profile)
+ ->GetAuthenticatedAccountInfo()
+ .picture_url);
+ if (account_picture_url.is_valid()) {
+ custom_picture_url = signin::GetAvatarImageURLWithOptions(
+ account_picture_url, kAccountPictureSize,
+ false /* no_silhouette */)
+ .spec();
+ }
+ source->AddString("accountPictureUrl", custom_picture_url);
title_ids = IDS_SYNC_CONFIRMATION_UNITY_TITLE;
confirm_button_ids = IDS_SYNC_CONFIRMATION_DICE_CONFIRM_BUTTON_LABEL;
- undo_button_ids = IDS_SYNC_CONFIRMATION_DICE_UNDO_BUTTON_LABEL;
+ undo_button_ids = IDS_CANCEL;
} else {
source->SetDefaultResource(IDR_SYNC_CONFIRMATION_HTML);
source->AddResourcePath("sync_confirmation.css", IDR_SYNC_CONFIRMATION_CSS);
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 13b02da26c2..b2c1614bba8 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
@@ -48,8 +48,8 @@
#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
+#include "components/account_id/account_id.h"
#include "components/prefs/pref_service.h"
-#include "components/signin/core/account_id/account_id.h"
#include "components/signin/core/browser/profile_management_switches.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/notification_service.h"
diff --git a/chromium/chrome/browser/ui/webui/signin/user_manager_ui_browsertest.cc b/chromium/chrome/browser/ui/webui/signin/user_manager_ui_browsertest.cc
index 282ee5794ba..8de7fc51908 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
@@ -33,7 +33,8 @@ using ::testing::_;
class MockLoginUIService : public LoginUIService {
public:
- MockLoginUIService() : LoginUIService(nullptr) {}
+ explicit MockLoginUIService(content::BrowserContext* context)
+ : LoginUIService(static_cast<Profile*>(context)) {}
~MockLoginUIService() override {}
MOCK_METHOD3(DisplayLoginResult,
void(Browser* browser,
@@ -44,7 +45,7 @@ class MockLoginUIService : public LoginUIService {
std::unique_ptr<KeyedService> CreateLoginUIService(
content::BrowserContext* context) {
- return std::make_unique<MockLoginUIService>();
+ return std::make_unique<MockLoginUIService>(context);
}
class UserManagerUIBrowserTest : public InProcessBrowserTest,
diff --git a/chromium/chrome/browser/ui/webui/site_settings_helper.cc b/chromium/chrome/browser/ui/webui/site_settings_helper.cc
index c6e1e92baaf..de6fa116170 100644
--- a/chromium/chrome/browser/ui/webui/site_settings_helper.cc
+++ b/chromium/chrome/browser/ui/webui/site_settings_helper.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/permissions/permission_manager.h"
#include "chrome/browser/permissions/permission_result.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/usb/usb_chooser_context.h"
#include "chrome/browser/usb/usb_chooser_context_factory.h"
#include "chrome/common/pref_names.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
@@ -33,11 +34,6 @@ constexpr char kAppId[] = "appId";
constexpr char kObject[] = "object";
constexpr char kObjectName[] = "objectName";
-ChooserContextBase* GetUsbChooserContext(Profile* profile) {
- return reinterpret_cast<ChooserContextBase*>(
- UsbChooserContextFactory::GetForProfile(profile));
-}
-
namespace {
// Maps from the UI string to the object it represents (for sorting purposes).
@@ -204,6 +200,14 @@ SiteSettingSource CalculateSiteSettingSource(
return SiteSettingSource::kPreference;
}
+ChooserContextBase* GetUsbChooserContext(Profile* profile) {
+ return UsbChooserContextFactory::GetForProfile(profile);
+}
+
+const ChooserTypeNameEntry kChooserTypeGroupNames[] = {
+ {&GetUsbChooserContext, kGroupTypeUsb},
+};
+
} // namespace
bool HasRegisteredGroupName(ContentSettingsType type) {
@@ -588,9 +592,7 @@ void GetChooserExceptionsFromProfile(Profile* profile,
chooser_context->GetAllGrantedObjects();
AllOriginObjects all_origin_objects;
for (const auto& object : objects) {
- std::string name;
- bool found = object->object.GetString(chooser_type.ui_name_key, &name);
- DCHECK(found);
+ std::string name = chooser_context->GetObjectName(object->object);
// It is safe for this structure to hold references into |objects| because
// they are both destroyed at the end of this function.
all_origin_objects[make_pair(object->requesting_origin, object->source)]
diff --git a/chromium/chrome/browser/ui/webui/site_settings_helper.h b/chromium/chrome/browser/ui/webui/site_settings_helper.h
index 0a3065dc1a3..2e2507b8a14 100644
--- a/chromium/chrome/browser/ui/webui/site_settings_helper.h
+++ b/chromium/chrome/browser/ui/webui/site_settings_helper.h
@@ -133,24 +133,15 @@ void GetPolicyAllowedUrls(
// for a given content settings type and is declared early so that it can used
// by functions below.
struct ChooserTypeNameEntry {
- ContentSettingsType type;
ChooserContextBase* (*get_context)(Profile*);
const char* name;
- const char* ui_name_key;
};
-ChooserContextBase* GetUsbChooserContext(Profile* profile);
-
struct ContentSettingsTypeNameEntry {
ContentSettingsType type;
const char* name;
};
-const ChooserTypeNameEntry kChooserTypeGroupNames[] = {
- {CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, &GetUsbChooserContext,
- kGroupTypeUsb, "name"},
-};
-
const ChooserTypeNameEntry* ChooserTypeFromGroupName(const std::string& name);
// Fills in |exceptions| with Values for the given |chooser_type| from map.
diff --git a/chromium/chrome/browser/ui/webui/snippets_internals/BUILD.gn b/chromium/chrome/browser/ui/webui/snippets_internals/BUILD.gn
new file mode 100644
index 00000000000..f83f5c25536
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/snippets_internals/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("//mojo/public/tools/bindings/mojom.gni")
+
+mojom("mojo_bindings") {
+ sources = [
+ "snippets_internals.mojom",
+ ]
+}
diff --git a/chromium/chrome/browser/ui/webui/snippets_internals/OWNERS b/chromium/chrome/browser/ui/webui/snippets_internals/OWNERS
new file mode 100644
index 00000000000..30aeea0a736
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/snippets_internals/OWNERS
@@ -0,0 +1,4 @@
+file://components/ntp_snippets/OWNERS
+
+per-file *.mojom=set noparent
+per-file *.mojom=file://ipc/SECURITY_OWNERS \ No newline at end of file
diff --git a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom
new file mode 100644
index 00000000000..d7793d4a040
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom
@@ -0,0 +1,83 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module snippets_internals.mojom;
+
+struct SuggestionCategory {
+ int64 categoryId;
+ string categoryTitle;
+ string status;
+
+ array<SuggestionItem> suggestions;
+ array<SuggestionItem> dismissedSuggestions;
+};
+
+struct SuggestionItem {
+ string suggestionTitle;
+ string suggestionId;
+ string suggestionIdWithinCategory;
+ string url;
+ string faviconUrl;
+ string snippet;
+ string publishDate;
+ string publisherName;
+ float score;
+};
+
+interface PageHandlerFactory {
+ CreatePageHandler(Page page) => (PageHandler handler);
+};
+
+// Browser interface.
+interface PageHandler {
+ // Populate properties about preferences/flags.
+ GetGeneralProperties() => (map<string, string> properties);
+
+ // Populate the properties for the user classifier.
+ GetUserClassifierProperties() => (map<string, string> properties);
+
+ // Clear stored properties for the user classifier.
+ ClearUserClassifierProperties();
+
+ // Get category ranker tuples (abritrary field/values).
+ GetCategoryRankerProperties() => (map<string, string> properties);
+
+ // Reload the current suggestions.
+ ReloadSuggestions();
+
+ // Get the debug log.
+ GetDebugLog() => (string debugLog);
+
+ // Clear cached suggestions.
+ ClearCachedSuggestions();
+
+ // Get the remote content suggestions.
+ GetRemoteContentSuggestionsProperties() => (map<string, string> properties);
+
+ // Fetch suggestions in background after the given delay.
+ FetchSuggestionsInBackground(int64 delaySeconds) => ();
+
+ // Returns if it's possible to push a dummy suggestion.
+ IsPushingDummySuggestionPossible() => (bool result);
+
+ // Push dummy suggestion in background after the given delay.
+ PushDummySuggestionInBackground(int64 delaySeconds) => ();
+
+ // Download the last suggestions in json form.
+ GetLastJson() => (string json);
+
+ // Reset the notification state.
+ ResetNotificationState();
+
+ // Get the suggestions by category.
+ GetSuggestionsByCategory() => (array<SuggestionCategory> categories);
+
+ // Clear the dismissed suggestions.
+ ClearDismissedSuggestions(int64 category);
+};
+
+// Frontend interface.
+interface Page {
+ OnSuggestionsChanged();
+}; \ No newline at end of file
diff --git a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.cc b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.cc
new file mode 100644
index 00000000000..5bb1de4df68
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.cc
@@ -0,0 +1,453 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.h"
+
+#include "base/containers/flat_map.h"
+#include "base/feature_list.h"
+#include "base/i18n/time_formatting.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/stringprintf.h"
+#include "base/strings/utf_string_conversions.h"
+#include "base/time/time_to_iso8601.h"
+#include "chrome/browser/android/ntp/android_content_suggestions_notifier.h"
+#include "chrome/browser/ntp_snippets/dependent_features.h"
+#include "chrome/common/pref_names.h"
+#include "components/ntp_snippets/category_info.h"
+#include "components/ntp_snippets/features.h"
+#include "components/ntp_snippets/pref_names.h"
+#include "components/ntp_snippets/remote/remote_suggestions_fetcher.h"
+#include "components/ntp_snippets/remote/remote_suggestions_provider.h"
+#include "components/ntp_snippets/remote/remote_suggestions_provider_impl.h"
+#include "components/ntp_snippets/user_classifier.h"
+#include "components/offline_pages/core/offline_page_feature.h"
+#include "components/variations/variations_associated_data.h"
+
+using ntp_snippets::AreAssetDownloadsEnabled;
+using ntp_snippets::AreOfflinePageDownloadsEnabled;
+using ntp_snippets::Category;
+using ntp_snippets::CategoryInfo;
+using ntp_snippets::CategoryStatus;
+using ntp_snippets::ContentSuggestion;
+using ntp_snippets::IsBookmarkProviderEnabled;
+using ntp_snippets::RemoteSuggestionsProvider;
+using ntp_snippets::RemoteSuggestionsFetcher;
+using ntp_snippets::UserClassifier;
+
+namespace {
+/*
+ Non-instance helper functions.
+*/
+
+std::set<variations::VariationID> GetSnippetsExperiments() {
+ std::set<variations::VariationID> result;
+ for (const base::Feature* feature : ntp_snippets::GetAllFeatures()) {
+ base::FieldTrial* trial = base::FeatureList::GetFieldTrial(*feature);
+ if (!trial || trial->GetGroupNameWithoutActivation().empty())
+ continue;
+
+ for (variations::IDCollectionKey key :
+ {variations::GOOGLE_WEB_PROPERTIES,
+ variations::GOOGLE_WEB_PROPERTIES_SIGNED_IN,
+ variations::GOOGLE_WEB_PROPERTIES_TRIGGER}) {
+ const variations::VariationID id = variations::GetGoogleVariationID(
+ key, trial->trial_name(), trial->group_name());
+ if (id != variations::EMPTY_ID) {
+ result.insert(id);
+ }
+ }
+ }
+ return result;
+}
+
+std::string BooleanToString(bool value) {
+ return value ? "True" : "False";
+}
+
+ntp_snippets::BreakingNewsListener* GetBreakingNewsListener(
+ ntp_snippets::ContentSuggestionsService* service) {
+ DCHECK(service);
+ RemoteSuggestionsProvider* provider =
+ service->remote_suggestions_provider_for_debugging();
+ DCHECK(provider);
+ return static_cast<ntp_snippets::RemoteSuggestionsProviderImpl*>(provider)
+ ->breaking_news_listener_for_debugging();
+}
+
+std::string GetCategoryStatusName(CategoryStatus status) {
+ switch (status) {
+ case CategoryStatus::INITIALIZING:
+ return "INITIALIZING";
+ case CategoryStatus::AVAILABLE:
+ return "AVAILABLE";
+ case CategoryStatus::AVAILABLE_LOADING:
+ return "AVAILABLE_LOADING";
+ case CategoryStatus::NOT_PROVIDED:
+ return "NOT_PROVIDED";
+ case CategoryStatus::ALL_SUGGESTIONS_EXPLICITLY_DISABLED:
+ return "ALL_SUGGESTIONS_EXPLICITLY_DISABLED";
+ case CategoryStatus::CATEGORY_EXPLICITLY_DISABLED:
+ return "CATEGORY_EXPLICITLY_DISABLED";
+ case CategoryStatus::LOADING_ERROR:
+ return "LOADING_ERROR";
+ }
+ return std::string();
+}
+
+snippets_internals::mojom::SuggestionItemPtr PrepareContentSuggestionItem(
+ const ContentSuggestion& suggestion,
+ int index) {
+ auto item = snippets_internals::mojom::SuggestionItem::New();
+ item->suggestionTitle = base::UTF16ToUTF8(suggestion.title());
+ item->suggestionIdWithinCategory = suggestion.id().id_within_category();
+ item->suggestionId = "content-suggestion-" + base::IntToString(index);
+ item->url = suggestion.url().spec();
+ item->faviconUrl = suggestion.url_with_favicon().spec();
+ item->snippet = base::UTF16ToUTF8(suggestion.snippet_text());
+ item->publishDate =
+ base::UTF16ToUTF8(TimeFormatShortDateAndTime(suggestion.publish_date()));
+ item->publisherName = base::UTF16ToUTF8(suggestion.publisher_name());
+ item->score = suggestion.score();
+
+ return item;
+}
+
+} // namespace
+
+// TODO: Add browser tests.
+SnippetsInternalsPageHandler::SnippetsInternalsPageHandler(
+ snippets_internals::mojom::PageHandlerRequest request,
+ snippets_internals::mojom::PagePtr page,
+ ntp_snippets::ContentSuggestionsService* content_suggestions_service,
+ PrefService* pref_service)
+ : binding_(this, std::move(request)),
+ content_suggestions_service_observer_(this),
+ content_suggestions_service_(content_suggestions_service),
+ remote_suggestions_provider_(
+ content_suggestions_service_
+ ->remote_suggestions_provider_for_debugging()),
+ pref_service_(pref_service),
+ page_(std::move(page)),
+ weak_ptr_factory_(this) {}
+
+SnippetsInternalsPageHandler::~SnippetsInternalsPageHandler() {}
+
+/*
+ Observer methods.
+*/
+
+void SnippetsInternalsPageHandler::OnNewSuggestions(Category category) {
+ page_->OnSuggestionsChanged();
+}
+
+void SnippetsInternalsPageHandler::OnCategoryStatusChanged(
+ Category category,
+ CategoryStatus new_status) {
+ page_->OnSuggestionsChanged();
+}
+
+void SnippetsInternalsPageHandler::OnSuggestionInvalidated(
+ const ntp_snippets::ContentSuggestion::ID& suggestion_id) {
+ page_->OnSuggestionsChanged();
+}
+
+void SnippetsInternalsPageHandler::OnFullRefreshRequired() {
+ page_->OnSuggestionsChanged();
+}
+
+void SnippetsInternalsPageHandler::ContentSuggestionsServiceShutdown() {}
+
+/*
+ Instance methods.
+*/
+
+void SnippetsInternalsPageHandler::GetGeneralProperties(
+ GetGeneralPropertiesCallback callback) {
+ auto properties = base::flat_map<std::string, std::string>();
+ properties["flag-article-suggestions"] = BooleanToString(
+ base::FeatureList::IsEnabled(ntp_snippets::kArticleSuggestionsFeature));
+ properties["flag-offlining-recent-pages-feature"] =
+ BooleanToString(base::FeatureList::IsEnabled(
+ offline_pages::kOffliningRecentPagesFeature));
+ properties["flag-asset-download-suggestions"] =
+ BooleanToString(AreAssetDownloadsEnabled());
+ properties["flag-offline-page-download-suggestions"] =
+ BooleanToString(AreOfflinePageDownloadsEnabled());
+ properties["flag-bookmark-suggestions"] =
+ BooleanToString(IsBookmarkProviderEnabled());
+
+ if (remote_suggestions_provider_) {
+ const ntp_snippets::RemoteSuggestionsFetcher* fetcher =
+ remote_suggestions_provider_->suggestions_fetcher_for_debugging();
+ properties["switch-fetch-url"] = fetcher->GetFetchUrlForDebugging().spec();
+ }
+
+ std::set<variations::VariationID> ids = GetSnippetsExperiments();
+ std::vector<std::string> string_ids;
+ std::transform(ids.begin(), ids.end(), std::back_inserter(string_ids),
+ &base::IntToString);
+
+ properties["experiment-ids"] = base::JoinString(string_ids, ", ");
+ std::move(callback).Run(properties);
+}
+
+void SnippetsInternalsPageHandler::GetUserClassifierProperties(
+ GetUserClassifierPropertiesCallback callback) {
+ auto properties = base::flat_map<std::string, std::string>();
+ properties["user-class"] = content_suggestions_service_->user_classifier()
+ ->GetUserClassDescriptionForDebugging();
+ properties["avg-time-to-open-ntp"] = base::NumberToString(
+ content_suggestions_service_->user_classifier()->GetEstimatedAvgTime(
+ UserClassifier::Metric::NTP_OPENED));
+ properties["avg-time-to-show"] = base::NumberToString(
+ content_suggestions_service_->user_classifier()->GetEstimatedAvgTime(
+ UserClassifier::Metric::SUGGESTIONS_SHOWN));
+ properties["avg-time-to-use"] = base::NumberToString(
+ content_suggestions_service_->user_classifier()->GetEstimatedAvgTime(
+ UserClassifier::Metric::SUGGESTIONS_USED));
+ std::move(callback).Run(properties);
+}
+
+void SnippetsInternalsPageHandler::ClearUserClassifierProperties() {
+ content_suggestions_service_->user_classifier()
+ ->ClearClassificationForDebugging();
+}
+
+void SnippetsInternalsPageHandler::GetCategoryRankerProperties(
+ GetCategoryRankerPropertiesCallback callback) {
+ auto properties = base::flat_map<std::string, std::string>();
+ std::vector<ntp_snippets::CategoryRanker::DebugDataItem> data =
+ content_suggestions_service_->category_ranker()->GetDebugData();
+
+ for (const auto& item : data) {
+ properties[item.label] = item.content;
+ }
+
+ std::move(callback).Run(properties);
+}
+
+void SnippetsInternalsPageHandler::ReloadSuggestions() {
+ if (remote_suggestions_provider_) {
+ remote_suggestions_provider_->ReloadSuggestions();
+ }
+}
+
+void SnippetsInternalsPageHandler::GetDebugLog(GetDebugLogCallback callback) {
+ std::move(callback).Run(content_suggestions_service_->GetDebugLog());
+}
+
+void SnippetsInternalsPageHandler::ClearCachedSuggestions() {
+ content_suggestions_service_->ClearAllCachedSuggestions();
+ page_->OnSuggestionsChanged();
+}
+
+void SnippetsInternalsPageHandler::GetRemoteContentSuggestionsProperties(
+ GetRemoteContentSuggestionsPropertiesCallback callback) {
+ auto properties = base::flat_map<std::string, std::string>();
+ if (remote_suggestions_provider_) {
+ const std::string& status =
+ remote_suggestions_provider_->suggestions_fetcher_for_debugging()
+ ->GetLastStatusForDebugging();
+ if (!status.empty()) {
+ properties["remote-status"] = "Finished: " + status;
+ properties["remote-authenticated"] =
+ remote_suggestions_provider_->suggestions_fetcher_for_debugging()
+ ->WasLastFetchAuthenticatedForDebugging()
+ ? "Authenticated"
+ : "Non-authenticated";
+ }
+ }
+
+ base::Time time = base::Time::FromInternalValue(pref_service_->GetInt64(
+ ntp_snippets::prefs::kLastSuccessfulBackgroundFetchTime));
+ properties["last-background-fetch-time"] =
+ base::UTF16ToUTF8(base::TimeFormatShortDateAndTime(time));
+
+ std::move(callback).Run(properties);
+}
+
+void SnippetsInternalsPageHandler::FetchSuggestionsInBackground(
+ int64_t delaySeconds,
+ FetchSuggestionsInBackgroundCallback callback) {
+ DCHECK(delaySeconds >= 0);
+ suggestion_fetch_timer_.Start(
+ FROM_HERE, base::TimeDelta::FromSeconds(delaySeconds),
+ base::BindRepeating(
+ &SnippetsInternalsPageHandler::FetchSuggestionsInBackgroundImpl,
+ weak_ptr_factory_.GetWeakPtr(), base::Passed(std::move(callback))));
+}
+
+void SnippetsInternalsPageHandler::FetchSuggestionsInBackgroundImpl(
+ FetchSuggestionsInBackgroundCallback callback) {
+ remote_suggestions_provider_->RefetchInTheBackground(
+ RemoteSuggestionsProvider::FetchStatusCallback());
+
+ std::move(callback).Run();
+}
+
+void SnippetsInternalsPageHandler::IsPushingDummySuggestionPossible(
+ IsPushingDummySuggestionPossibleCallback callback) {
+ ntp_snippets::BreakingNewsListener* listener =
+ GetBreakingNewsListener(content_suggestions_service_);
+
+ std::move(callback).Run(listener != nullptr && listener->IsListening());
+}
+
+void SnippetsInternalsPageHandler::PushDummySuggestionInBackground(
+ int64_t delaySeconds,
+ PushDummySuggestionInBackgroundCallback callback) {
+ DCHECK(delaySeconds >= 0);
+ suggestion_push_timer_.Start(
+ FROM_HERE, base::TimeDelta::FromSeconds(delaySeconds),
+ base::BindRepeating(
+ &SnippetsInternalsPageHandler::PushDummySuggestionInBackgroundImpl,
+ weak_ptr_factory_.GetWeakPtr(), base::Passed(std::move(callback))));
+}
+
+void SnippetsInternalsPageHandler::PushDummySuggestionInBackgroundImpl(
+ PushDummySuggestionInBackgroundCallback callback) {
+ std::string json = R"(
+ {"categories" : [{
+ "id": 1,
+ "localizedTitle": "section title",
+ "suggestions" : [{
+ "ids" : ["http://url.com"],
+ "title" : "Pushed Dummy Title %s",
+ "snippet" : "Pushed Dummy Snippet",
+ "fullPageUrl" : "http://url.com",
+ "creationTime" : "%s",
+ "expirationTime" : "%s",
+ "attribution" : "Pushed Dummy Publisher",
+ "imageUrl" : "https://www.google.com/favicon.ico",
+ "notificationInfo": {
+ "shouldNotify": true,
+ "deadline": "2100-01-01T00:00:01.000Z"
+ }
+ }]
+ }]}
+ )";
+
+ const base::Time now = base::Time::Now();
+ json = base::StringPrintf(
+ json.c_str(), base::UTF16ToUTF8(base::TimeFormatTimeOfDay(now)).c_str(),
+ base::TimeToISO8601(now).c_str(),
+ base::TimeToISO8601(now + base::TimeDelta::FromMinutes(60)).c_str());
+
+ gcm::IncomingMessage message;
+ message.data["payload"] = json;
+
+ ntp_snippets::BreakingNewsListener* listener =
+ GetBreakingNewsListener(content_suggestions_service_);
+ DCHECK(listener);
+ DCHECK(listener->IsListening());
+ static_cast<ntp_snippets::BreakingNewsGCMAppHandler*>(listener)->OnMessage(
+ "com.google.breakingnews.gcm", message);
+
+ std::move(callback).Run();
+}
+
+void SnippetsInternalsPageHandler::GetLastJson(GetLastJsonCallback callback) {
+ std::string json = "";
+ if (remote_suggestions_provider_) {
+ const ntp_snippets::RemoteSuggestionsFetcher* fetcher =
+ remote_suggestions_provider_->suggestions_fetcher_for_debugging();
+ json = fetcher->GetLastJsonForDebugging();
+ }
+
+ std::move(callback).Run(json);
+}
+
+void SnippetsInternalsPageHandler::ResetNotificationState() {
+ pref_service_->SetInteger(
+ prefs::kContentSuggestionsConsecutiveIgnoredPrefName, 0);
+ pref_service_->SetInteger(prefs::kContentSuggestionsNotificationsSentCount,
+ 0);
+ pref_service_->SetInteger(prefs::kContentSuggestionsNotificationsSentDay, 0);
+ AndroidContentSuggestionsNotifier().HideAllNotifications(
+ ContentSuggestionsNotificationAction::HIDE_FRONTMOST);
+}
+
+void SnippetsInternalsPageHandler::GetSuggestionsByCategory(
+ GetSuggestionsByCategoryCallback callback) {
+ CollectDismissedSuggestions(-1, std::move(callback),
+ std::vector<ContentSuggestion>());
+}
+
+void SnippetsInternalsPageHandler::GetSuggestionsByCategoryImpl(
+ GetSuggestionsByCategoryCallback callback) {
+ std::vector<snippets_internals::mojom::SuggestionCategoryPtr> categories;
+
+ int index = 0;
+ for (Category category : content_suggestions_service_->GetCategories()) {
+ CategoryStatus status =
+ content_suggestions_service_->GetCategoryStatus(category);
+ base::Optional<CategoryInfo> info =
+ content_suggestions_service_->GetCategoryInfo(category);
+ DCHECK(info);
+ const std::vector<ContentSuggestion>& suggestions =
+ content_suggestions_service_->GetSuggestionsForCategory(category);
+
+ std::vector<snippets_internals::mojom::SuggestionItemPtr> items;
+ for (const ContentSuggestion& suggestion : suggestions) {
+ snippets_internals::mojom::SuggestionItemPtr item =
+ PrepareContentSuggestionItem(suggestion, index++);
+ items.push_back(std::move(item));
+ }
+
+ std::vector<snippets_internals::mojom::SuggestionItemPtr> dismissed_items;
+ for (const ContentSuggestion& suggestion :
+ dismissed_suggestions_[category]) {
+ snippets_internals::mojom::SuggestionItemPtr item =
+ PrepareContentSuggestionItem(suggestion, index++);
+ dismissed_items.push_back(std::move(item));
+ }
+
+ auto suggestion_category =
+ snippets_internals::mojom::SuggestionCategory::New();
+ suggestion_category->categoryTitle = base::UTF16ToUTF8(info->title());
+ suggestion_category->status = GetCategoryStatusName(status);
+ suggestion_category->categoryId = category.id();
+ suggestion_category->suggestions = std::move(items);
+ suggestion_category->dismissedSuggestions = std::move(dismissed_items);
+ categories.push_back(std::move(suggestion_category));
+ }
+
+ std::move(callback).Run(std::move(categories));
+}
+
+void SnippetsInternalsPageHandler::ClearDismissedSuggestions(
+ int64_t category_id) {
+ Category category = Category::FromIDValue(category_id);
+ content_suggestions_service_->ClearDismissedSuggestionsForDebugging(category);
+ page_->OnSuggestionsChanged();
+}
+
+void SnippetsInternalsPageHandler::CollectDismissedSuggestions(
+ int last_index,
+ GetSuggestionsByCategoryCallback callback,
+ std::vector<ContentSuggestion> suggestions) {
+ std::vector<Category> categories =
+ content_suggestions_service_->GetCategories();
+
+ // Populate our last category results.
+ if (last_index > -1)
+ dismissed_suggestions_[categories[last_index]] = std::move(suggestions);
+
+ // Find the next category for this.
+ for (size_t i = 0; i < categories.size(); i++) {
+ // Continue the process in the next method call.
+ if (last_index + 1 >= 0 && (size_t)last_index + 1 == i) {
+ content_suggestions_service_->GetDismissedSuggestionsForDebugging(
+ categories[i],
+ base::BindRepeating(
+ &SnippetsInternalsPageHandler::CollectDismissedSuggestions,
+ weak_ptr_factory_.GetWeakPtr(), i,
+ base::Passed(std::move(callback))));
+ return;
+ }
+ }
+
+ // Call into impl once the dismissed categories have been collected.
+ GetSuggestionsByCategoryImpl(std::move(callback));
+}
diff --git a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.h b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.h
new file mode 100644
index 00000000000..7922e21136d
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.h
@@ -0,0 +1,106 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_SNIPPETS_INTERNALS_PAGE_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_SNIPPETS_INTERNALS_PAGE_HANDLER_H_
+
+#include "base/macros.h"
+#include "base/scoped_observer.h"
+#include "chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom.h"
+#include "components/ntp_snippets/content_suggestions_service.h"
+#include "components/ntp_snippets/remote/remote_suggestions_provider.h"
+#include "components/prefs/pref_service.h"
+#include "mojo/public/cpp/bindings/binding.h"
+
+// TODO: Write tests for this.
+class SnippetsInternalsPageHandler
+ : public snippets_internals::mojom::PageHandler,
+ public ntp_snippets::ContentSuggestionsService::Observer {
+ public:
+ explicit SnippetsInternalsPageHandler(
+ snippets_internals::mojom::PageHandlerRequest request,
+ snippets_internals::mojom::PagePtr,
+ ntp_snippets::ContentSuggestionsService* content_suggestions_service,
+ PrefService* pref_service);
+ ~SnippetsInternalsPageHandler() override;
+
+ // snippets_internals::mojom::PageHandler
+ void GetGeneralProperties(GetGeneralPropertiesCallback) override;
+ void GetUserClassifierProperties(
+ GetUserClassifierPropertiesCallback) override;
+ void ClearUserClassifierProperties() override;
+ void GetCategoryRankerProperties(
+ GetCategoryRankerPropertiesCallback) override;
+ void ReloadSuggestions() override;
+ void GetDebugLog(GetDebugLogCallback) override;
+ void ClearCachedSuggestions() override;
+ void GetRemoteContentSuggestionsProperties(
+ GetRemoteContentSuggestionsPropertiesCallback) override;
+ void FetchSuggestionsInBackground(
+ int64_t,
+ FetchSuggestionsInBackgroundCallback) override;
+ void IsPushingDummySuggestionPossible(
+ IsPushingDummySuggestionPossibleCallback) override;
+ void PushDummySuggestionInBackground(
+ int64_t,
+ PushDummySuggestionInBackgroundCallback) override;
+ void GetLastJson(GetLastJsonCallback) override;
+ void ResetNotificationState() override;
+ void GetSuggestionsByCategory(GetSuggestionsByCategoryCallback) override;
+ void ClearDismissedSuggestions(int64_t) override;
+
+ private:
+ // ntp_snippets::ContentSuggestionsService::Observer:
+ void OnNewSuggestions(ntp_snippets::Category category) override;
+ void OnCategoryStatusChanged(
+ ntp_snippets::Category category,
+ ntp_snippets::CategoryStatus new_status) override;
+ void OnSuggestionInvalidated(
+ const ntp_snippets::ContentSuggestion::ID& suggestion_id) override;
+ void OnFullRefreshRequired() override;
+ void ContentSuggestionsServiceShutdown() override;
+
+ void FetchSuggestionsInBackgroundImpl(FetchSuggestionsInBackgroundCallback);
+ void GetSuggestionsByCategoryImpl(GetSuggestionsByCategoryCallback);
+ void PushDummySuggestionInBackgroundImpl(
+ PushDummySuggestionInBackgroundCallback);
+
+ // Misc. methods.
+ void CollectDismissedSuggestions(
+ int last_index,
+ GetSuggestionsByCategoryCallback callback,
+ std::vector<ntp_snippets::ContentSuggestion> suggestions);
+
+ // Binding from the mojo interface to concrete impl.
+ mojo::Binding<snippets_internals::mojom::PageHandler> binding_;
+
+ // Observer to notify frontend of dirty data.
+ ScopedObserver<ntp_snippets::ContentSuggestionsService,
+ ntp_snippets::ContentSuggestionsService::Observer>
+ content_suggestions_service_observer_;
+
+ // Services that provide the data & functionality.
+ ntp_snippets::ContentSuggestionsService* content_suggestions_service_;
+ ntp_snippets::RemoteSuggestionsProvider* remote_suggestions_provider_;
+ PrefService* pref_service_;
+
+ // Store dismissed suggestions in an instance variable during aggregation
+ std::map<ntp_snippets::Category,
+ std::vector<ntp_snippets::ContentSuggestion>,
+ ntp_snippets::Category::CompareByID>
+ dismissed_suggestions_;
+
+ // Timers to delay actions.
+ base::OneShotTimer suggestion_fetch_timer_;
+ base::OneShotTimer suggestion_push_timer_;
+
+ // Handle back to the page by which we can update.
+ snippets_internals::mojom::PagePtr page_;
+
+ base::WeakPtrFactory<SnippetsInternalsPageHandler> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(SnippetsInternalsPageHandler);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_SNIPPETS_INTERNALS_PAGE_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.cc b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.cc
new file mode 100644
index 00000000000..3d36440c8cd
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.cc
@@ -0,0 +1,59 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.h"
+
+#include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/snippets_internals/snippets_internals_page_handler.h"
+#include "chrome/common/url_constants.h"
+#include "chrome/grit/browser_resources.h"
+#include "content/public/browser/web_ui_data_source.h"
+
+#if defined(OS_ANDROID)
+#include "chrome/browser/android/chrome_feature_list.h"
+#endif
+
+SnippetsInternalsUI::SnippetsInternalsUI(content::WebUI* web_ui)
+ : ui::MojoWebUIController(web_ui), binding_(this) {
+ content::WebUIDataSource* source =
+ content::WebUIDataSource::Create(chrome::kChromeUISnippetsInternalsHost);
+ source->AddResourcePath("snippets_internals.css", IDR_SNIPPETS_INTERNALS_CSS);
+ source->AddResourcePath("snippets_internals.js", IDR_SNIPPETS_INTERNALS_JS);
+ source->AddResourcePath("snippets_internals.mojom.js",
+ IDR_SNIPPETS_INTERNALS_MOJO_JS);
+ source->SetDefaultResource(IDR_SNIPPETS_INTERNALS_HTML);
+ source->UseGzip();
+
+ Profile* profile = Profile::FromWebUI(web_ui);
+ content_suggestions_service_ =
+ ContentSuggestionsServiceFactory::GetInstance()->GetForProfile(profile);
+ pref_service_ = profile->GetPrefs();
+ content::WebUIDataSource::Add(profile, source);
+ AddHandlerToRegistry(base::BindRepeating(
+ &SnippetsInternalsUI::BindSnippetsInternalsPageHandlerFactory,
+ base::Unretained(this)));
+}
+
+SnippetsInternalsUI::~SnippetsInternalsUI() {}
+
+void SnippetsInternalsUI::BindSnippetsInternalsPageHandlerFactory(
+ snippets_internals::mojom::PageHandlerFactoryRequest request) {
+ if (binding_.is_bound())
+ binding_.Unbind();
+
+ binding_.Bind(std::move(request));
+}
+
+void SnippetsInternalsUI::CreatePageHandler(
+ snippets_internals::mojom::PagePtr page,
+ CreatePageHandlerCallback callback) {
+ DCHECK(page);
+ snippets_internals::mojom::PageHandlerPtr handler;
+ page_handler_.reset(new SnippetsInternalsPageHandler(
+ mojo::MakeRequest(&handler), std::move(page),
+ content_suggestions_service_, pref_service_));
+
+ std::move(callback).Run(std::move(handler));
+}
diff --git a/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.h b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.h
new file mode 100644
index 00000000000..6ed63699616
--- /dev/null
+++ b/chromium/chrome/browser/ui/webui/snippets_internals/snippets_internals_ui.h
@@ -0,0 +1,43 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_SNIPPETS_INTERNALS_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_SNIPPETS_INTERNALS_UI_H_
+
+#include "base/macros.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/snippets_internals/snippets_internals.mojom.h"
+#include "components/ntp_snippets/content_suggestions_service.h"
+#include "components/prefs/pref_service.h"
+#include "mojo/public/cpp/bindings/binding.h"
+#include "ui/webui/mojo_web_ui_controller.h"
+
+class SnippetsInternalsPageHandler;
+
+// The implementation for the chrome://snippets-internals page.
+class SnippetsInternalsUI
+ : public snippets_internals::mojom::PageHandlerFactory,
+ public ui::MojoWebUIController {
+ public:
+ explicit SnippetsInternalsUI(content::WebUI* web_ui);
+ ~SnippetsInternalsUI() override;
+
+ void CreatePageHandler(snippets_internals::mojom::PagePtr page,
+ CreatePageHandlerCallback callback) override;
+
+ private:
+ void BindSnippetsInternalsPageHandlerFactory(
+ snippets_internals::mojom::PageHandlerFactoryRequest request);
+
+ std::unique_ptr<SnippetsInternalsPageHandler> page_handler_;
+ ntp_snippets::ContentSuggestionsService* content_suggestions_service_;
+ PrefService* pref_service_;
+
+ // Binding from the mojo interface to concrete impl.
+ mojo::Binding<snippets_internals::mojom::PageHandlerFactory> binding_;
+
+ DISALLOW_COPY_AND_ASSIGN(SnippetsInternalsUI);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_SNIPPETS_INTERNALS_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/snippets_internals_message_handler.cc b/chromium/chrome/browser/ui/webui/snippets_internals_message_handler.cc
deleted file mode 100644
index a65c50f7034..00000000000
--- a/chromium/chrome/browser/ui/webui/snippets_internals_message_handler.cc
+++ /dev/null
@@ -1,653 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/snippets_internals_message_handler.h"
-
-#include <memory>
-#include <set>
-#include <utility>
-#include <vector>
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/command_line.h"
-#include "base/feature_list.h"
-#include "base/i18n/time_formatting.h"
-#include "base/json/json_reader.h"
-#include "base/logging.h"
-#include "base/metrics/field_trial.h"
-#include "base/optional.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/strings/string_split.h"
-#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/time/time.h"
-#include "base/time/time_to_iso8601.h"
-#include "base/values.h"
-#include "chrome/browser/android/chrome_feature_list.h"
-#include "chrome/browser/android/ntp/android_content_suggestions_notifier.h"
-#include "chrome/browser/ntp_snippets/dependent_features.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/chrome_features.h"
-#include "chrome/common/pref_names.h"
-#include "components/ntp_snippets/category.h"
-#include "components/ntp_snippets/category_info.h"
-#include "components/ntp_snippets/category_rankers/category_ranker.h"
-#include "components/ntp_snippets/contextual/contextual_content_suggestions_service.h"
-#include "components/ntp_snippets/features.h"
-#include "components/ntp_snippets/pref_names.h"
-#include "components/ntp_snippets/remote/remote_suggestions_fetcher.h"
-#include "components/ntp_snippets/remote/remote_suggestions_provider.h"
-#include "components/ntp_snippets/remote/remote_suggestions_provider_impl.h"
-#include "components/ntp_snippets/switches.h"
-#include "components/offline_pages/core/offline_page_feature.h"
-#include "components/prefs/pref_service.h"
-#include "components/variations/variations_associated_data.h"
-#include "content/public/browser/web_ui.h"
-#include "url/gurl.h"
-
-using ntp_snippets::AreAssetDownloadsEnabled;
-using ntp_snippets::AreOfflinePageDownloadsEnabled;
-using ntp_snippets::Category;
-using ntp_snippets::CategoryInfo;
-using ntp_snippets::CategoryStatus;
-using ntp_snippets::ContentSuggestion;
-using ntp_snippets::IsBookmarkProviderEnabled;
-using ntp_snippets::IsPhysicalWebPageProviderEnabled;
-using ntp_snippets::IsRecentTabProviderEnabled;
-using ntp_snippets::KnownCategories;
-using ntp_snippets::RemoteSuggestion;
-using ntp_snippets::RemoteSuggestionsProvider;
-using ntp_snippets::UserClassifier;
-
-namespace {
-
-std::unique_ptr<base::DictionaryValue> PrepareSuggestion(
- const ContentSuggestion& suggestion,
- int index) {
- auto entry = std::make_unique<base::DictionaryValue>();
- entry->SetString("idWithinCategory", suggestion.id().id_within_category());
- entry->SetString("url", suggestion.url().spec());
- entry->SetString("urlWithFavicon", suggestion.url_with_favicon().spec());
- entry->SetString("title", suggestion.title());
- entry->SetString("snippetText", suggestion.snippet_text());
- entry->SetString("publishDate",
- TimeFormatShortDateAndTime(suggestion.publish_date()));
- entry->SetString("fetchDate",
- TimeFormatShortDateAndTime(suggestion.fetch_date()));
- entry->SetString("publisherName", suggestion.publisher_name());
- entry->SetString("id", "content-suggestion-" + base::IntToString(index));
- entry->SetDouble("score", suggestion.score());
-
- if (suggestion.download_suggestion_extra()) {
- const auto& extra = *suggestion.download_suggestion_extra();
- auto value = std::make_unique<base::DictionaryValue>();
- value->SetString("downloadGUID", extra.download_guid);
- value->SetString("targetFilePath",
- extra.target_file_path.LossyDisplayName());
- value->SetString("mimeType", extra.mime_type);
- value->SetString(
- "offlinePageID",
- base::StringPrintf("0x%016llx", static_cast<long long unsigned int>(
- extra.offline_page_id)));
- value->SetBoolean("isDownloadAsset", extra.is_download_asset);
- entry->Set("downloadSuggestionExtra", std::move(value));
- }
-
- if (suggestion.recent_tab_suggestion_extra()) {
- const auto& extra = *suggestion.recent_tab_suggestion_extra();
- auto value = std::make_unique<base::DictionaryValue>();
- value->SetInteger("tabID", extra.tab_id);
- value->SetString(
- "offlinePageID",
- base::StringPrintf("0x%016llx", static_cast<long long unsigned int>(
- extra.offline_page_id)));
- entry->Set("recentTabSuggestionExtra", std::move(value));
- }
-
- if (suggestion.notification_extra()) {
- const auto& extra = *suggestion.notification_extra();
- auto value = std::make_unique<base::DictionaryValue>();
- value->SetString("deadline", TimeFormatShortDateAndTime(extra.deadline));
- entry->Set("notificationExtra", std::move(value));
- }
-
- return entry;
-}
-
-std::string GetCategoryStatusName(CategoryStatus status) {
- switch (status) {
- case CategoryStatus::INITIALIZING:
- return "INITIALIZING";
- case CategoryStatus::AVAILABLE:
- return "AVAILABLE";
- case CategoryStatus::AVAILABLE_LOADING:
- return "AVAILABLE_LOADING";
- case CategoryStatus::NOT_PROVIDED:
- return "NOT_PROVIDED";
- case CategoryStatus::ALL_SUGGESTIONS_EXPLICITLY_DISABLED:
- return "ALL_SUGGESTIONS_EXPLICITLY_DISABLED";
- case CategoryStatus::CATEGORY_EXPLICITLY_DISABLED:
- return "CATEGORY_EXPLICITLY_DISABLED";
- case CategoryStatus::LOADING_ERROR:
- return "LOADING_ERROR";
- }
- return std::string();
-}
-
-std::set<variations::VariationID> SnippetsExperiments() {
- std::set<variations::VariationID> result;
- for (const base::Feature* const* feature = ntp_snippets::kAllFeatures;
- *feature; ++feature) {
- base::FieldTrial* trial = base::FeatureList::GetFieldTrial(**feature);
- if (!trial) {
- continue;
- }
- if (trial->GetGroupNameWithoutActivation().empty()) {
- continue;
- }
- for (variations::IDCollectionKey key :
- {variations::GOOGLE_WEB_PROPERTIES,
- variations::GOOGLE_WEB_PROPERTIES_SIGNED_IN,
- variations::GOOGLE_WEB_PROPERTIES_TRIGGER}) {
- const variations::VariationID id = variations::GetGoogleVariationID(
- key, trial->trial_name(), trial->group_name());
- if (id != variations::EMPTY_ID) {
- result.insert(id);
- }
- }
- }
- return result;
-}
-
-ntp_snippets::BreakingNewsListener* GetBreakingNewsListener(
- ntp_snippets::ContentSuggestionsService* service) {
- DCHECK(service);
- RemoteSuggestionsProvider* provider =
- service->remote_suggestions_provider_for_debugging();
- DCHECK(provider);
- return static_cast<ntp_snippets::RemoteSuggestionsProviderImpl*>(provider)
- ->breaking_news_listener_for_debugging();
-}
-
-} // namespace
-
-SnippetsInternalsMessageHandler::SnippetsInternalsMessageHandler(
- ntp_snippets::ContentSuggestionsService* content_suggestions_service,
- PrefService* pref_service)
- : content_suggestions_service_observer_(this),
- dom_loaded_(false),
- content_suggestions_service_(content_suggestions_service),
- remote_suggestions_provider_(
- content_suggestions_service_
- ->remote_suggestions_provider_for_debugging()),
- pref_service_(pref_service),
- weak_ptr_factory_(this) {}
-
-SnippetsInternalsMessageHandler::~SnippetsInternalsMessageHandler() {}
-
-void SnippetsInternalsMessageHandler::RegisterMessages() {
- web_ui()->RegisterMessageCallback(
- "clearCachedSuggestions",
- base::BindRepeating(
- &SnippetsInternalsMessageHandler::HandleClearCachedSuggestions,
- base::Unretained(this)));
-
- web_ui()->RegisterMessageCallback(
- "clearClassification",
- base::BindRepeating(
- &SnippetsInternalsMessageHandler::HandleClearClassification,
- base::Unretained(this)));
-
- web_ui()->RegisterMessageCallback(
- "clearDismissedSuggestions",
- base::BindRepeating(
- &SnippetsInternalsMessageHandler::HandleClearDismissedSuggestions,
- base::Unretained(this)));
-
- web_ui()->RegisterMessageCallback(
- "download",
- base::BindRepeating(&SnippetsInternalsMessageHandler::HandleDownload,
- base::Unretained(this)));
-
- web_ui()->RegisterMessageCallback(
- "fetchRemoteSuggestionsInTheBackgroundIn2Seconds",
- base::BindRepeating(
- &SnippetsInternalsMessageHandler::
- HandleFetchRemoteSuggestionsInTheBackgroundIn2Seconds,
- base::Unretained(this)));
-
- web_ui()->RegisterMessageCallback(
- "resetNotificationsState",
- base::BindRepeating(
- &SnippetsInternalsMessageHandler::HandleResetNotificationsState,
- base::Unretained(this)));
-
- web_ui()->RegisterMessageCallback(
- "pushDummySuggestionIn10Seconds",
- base::BindRepeating(&SnippetsInternalsMessageHandler::
- HandlePushDummySuggestionIn10Seconds,
- base::Unretained(this)));
-
- web_ui()->RegisterMessageCallback(
- "refreshContent",
- base::BindRepeating(
- &SnippetsInternalsMessageHandler::HandleRefreshContent,
- base::Unretained(this)));
-
- web_ui()->RegisterMessageCallback(
- "toggleDismissedSuggestions",
- base::BindRepeating(
- &SnippetsInternalsMessageHandler::HandleToggleDismissedSuggestions,
- base::Unretained(this)));
-
- web_ui()->RegisterMessageCallback(
- "initializationCompleted",
- base::BindRepeating(
- &SnippetsInternalsMessageHandler::HandleInitializationCompleted,
- base::Unretained(this)));
-
- content_suggestions_service_observer_.Add(content_suggestions_service_);
-}
-
-void SnippetsInternalsMessageHandler::OnNewSuggestions(Category category) {
- if (!dom_loaded_) {
- return;
- }
- SendContentSuggestions();
-}
-
-void SnippetsInternalsMessageHandler::OnCategoryStatusChanged(
- Category category,
- CategoryStatus new_status) {
- if (!dom_loaded_) {
- return;
- }
- SendContentSuggestions();
-}
-
-void SnippetsInternalsMessageHandler::OnSuggestionInvalidated(
- const ntp_snippets::ContentSuggestion::ID& suggestion_id) {
- if (!dom_loaded_) {
- return;
- }
- SendContentSuggestions();
-}
-
-void SnippetsInternalsMessageHandler::OnFullRefreshRequired() {
- if (!dom_loaded_) {
- return;
- }
- SendContentSuggestions();
-}
-
-void SnippetsInternalsMessageHandler::ContentSuggestionsServiceShutdown() {}
-
-void SnippetsInternalsMessageHandler::HandleInitializationCompleted(
- const base::ListValue* args) {
- DCHECK_EQ(0u, args->GetSize());
- AllowJavascript();
-}
-
-void SnippetsInternalsMessageHandler::HandleRefreshContent(
- const base::ListValue* args) {
- DCHECK_EQ(0u, args->GetSize());
-
- dom_loaded_ = true;
-
- for (std::pair<const Category, DismissedState>& category_state_pair :
- dismissed_state_) {
- if (category_state_pair.second == DismissedState::VISIBLE) {
- category_state_pair.second = DismissedState::LOADING;
- content_suggestions_service_->GetDismissedSuggestionsForDebugging(
- category_state_pair.first,
- base::Bind(
- &SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded,
- weak_ptr_factory_.GetWeakPtr(), category_state_pair.first));
- }
- }
-
- SendAllContent();
-}
-
-void SnippetsInternalsMessageHandler::HandleDownload(
- const base::ListValue* args) {
- DCHECK_EQ(0u, args->GetSize());
-
- SendString("remote-status", std::string());
- SendString("remote-authenticated", std::string());
-
- if (!remote_suggestions_provider_) {
- return;
- }
-
- remote_suggestions_provider_->ReloadSuggestions();
-}
-
-void SnippetsInternalsMessageHandler::HandleClearCachedSuggestions(
- const base::ListValue* args) {
- DCHECK_EQ(0u, args->GetSize());
-
- content_suggestions_service_->ClearAllCachedSuggestions();
- SendContentSuggestions();
-}
-
-void SnippetsInternalsMessageHandler::HandleClearDismissedSuggestions(
- const base::ListValue* args) {
- DCHECK_EQ(1u, args->GetSize());
-
- int category_id;
- if (!args->GetInteger(0, &category_id)) {
- return;
- }
-
- Category category = Category::FromIDValue(category_id);
- content_suggestions_service_->ClearDismissedSuggestionsForDebugging(category);
- SendContentSuggestions();
- dismissed_state_[category] = DismissedState::LOADING;
- content_suggestions_service_->GetDismissedSuggestionsForDebugging(
- category,
- base::Bind(&SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded,
- weak_ptr_factory_.GetWeakPtr(), category));
-}
-
-void SnippetsInternalsMessageHandler::HandleToggleDismissedSuggestions(
- const base::ListValue* args) {
- DCHECK_EQ(2u, args->GetSize());
-
- int category_id;
- if (!args->GetInteger(0, &category_id)) {
- return;
- }
- bool dismissed_visible;
- if (!args->GetBoolean(1, &dismissed_visible)) {
- return;
- }
-
- Category category = Category::FromIDValue(category_id);
- if (dismissed_visible) {
- dismissed_state_[category] = DismissedState::LOADING;
- content_suggestions_service_->GetDismissedSuggestionsForDebugging(
- category,
- base::Bind(
- &SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded,
- weak_ptr_factory_.GetWeakPtr(), category));
- } else {
- dismissed_state_[category] = DismissedState::HIDDEN;
- dismissed_suggestions_[category].clear();
- }
-}
-
-void SnippetsInternalsMessageHandler::HandleClearClassification(
- const base::ListValue* args) {
- DCHECK_EQ(0u, args->GetSize());
- content_suggestions_service_->user_classifier()
- ->ClearClassificationForDebugging();
- SendClassification();
-}
-
-void SnippetsInternalsMessageHandler::
- HandleFetchRemoteSuggestionsInTheBackgroundIn2Seconds(
- const base::ListValue* args) {
- DCHECK_EQ(0u, args->GetSize());
- suggestion_push_timer_.Start(
- FROM_HERE, base::TimeDelta::FromSeconds(2),
- base::Bind(&SnippetsInternalsMessageHandler::
- FetchRemoteSuggestionsInTheBackground,
- weak_ptr_factory_.GetWeakPtr()));
-}
-
-void SnippetsInternalsMessageHandler::HandleResetNotificationsState(
- const base::ListValue* args) {
- pref_service_->SetInteger(
- prefs::kContentSuggestionsConsecutiveIgnoredPrefName, 0);
- pref_service_->SetInteger(prefs::kContentSuggestionsNotificationsSentCount,
- 0);
- pref_service_->SetInteger(prefs::kContentSuggestionsNotificationsSentDay, 0);
- AndroidContentSuggestionsNotifier().HideAllNotifications(
- ContentSuggestionsNotificationAction::HIDE_FRONTMOST);
-}
-
-void SnippetsInternalsMessageHandler::HandlePushDummySuggestionIn10Seconds(
- const base::ListValue* args) {
- suggestion_push_timer_.Start(
- FROM_HERE, base::TimeDelta::FromSeconds(10),
- base::Bind(&SnippetsInternalsMessageHandler::PushDummySuggestion,
- weak_ptr_factory_.GetWeakPtr()));
-}
-
-void SnippetsInternalsMessageHandler::SendAllContent() {
- if (!IsJavascriptAllowed()) {
- return;
- }
-
- SendBoolean(
- "flag-article-suggestions",
- base::FeatureList::IsEnabled(ntp_snippets::kArticleSuggestionsFeature));
-
- SendBoolean("flag-recent-offline-tab-suggestions",
- IsRecentTabProviderEnabled());
- SendBoolean("flag-offlining-recent-pages-feature",
- base::FeatureList::IsEnabled(
- offline_pages::kOffliningRecentPagesFeature));
-
- SendBoolean("flag-asset-download-suggestions", AreAssetDownloadsEnabled());
- SendBoolean("flag-offline-page-download-suggestions",
- AreOfflinePageDownloadsEnabled());
-
- SendBoolean("flag-bookmark-suggestions", IsBookmarkProviderEnabled());
-
- SendBoolean("flag-physical-web-page-suggestions",
- IsPhysicalWebPageProviderEnabled());
-
- SendBoolean("flag-physical-web", base::FeatureList::IsEnabled(
- chrome::android::kPhysicalWebFeature));
-
- SendClassification();
- SendRankerDebugData();
- SendLastRemoteSuggestionsBackgroundFetchTime();
- SendWhetherSuggestionPushingPossible();
-
- if (remote_suggestions_provider_) {
- const ntp_snippets::RemoteSuggestionsFetcher* fetcher =
- remote_suggestions_provider_->suggestions_fetcher_for_debugging();
- SendString("switch-fetch-url", fetcher->GetFetchUrlForDebugging().spec());
- web_ui()->CallJavascriptFunctionUnsafe(
- "chrome.SnippetsInternals.receiveJson",
- base::Value(fetcher->GetLastJsonForDebugging()));
- }
-
- CallJavascriptFunction(
- "chrome.SnippetsInternals.receiveDebugLog",
- base::Value(content_suggestions_service_->GetDebugLog()));
-
- std::set<variations::VariationID> ids = SnippetsExperiments();
- std::vector<std::string> string_ids;
- for (auto id : ids) {
- string_ids.push_back(base::IntToString(id));
- }
- SendString("experiment-ids", base::JoinString(string_ids, ", "));
-
- SendContentSuggestions();
-}
-
-void SnippetsInternalsMessageHandler::SendClassification() {
- web_ui()->CallJavascriptFunctionUnsafe(
- "chrome.SnippetsInternals.receiveClassification",
- base::Value(content_suggestions_service_->user_classifier()
- ->GetUserClassDescriptionForDebugging()),
- base::Value(
- content_suggestions_service_->user_classifier()->GetEstimatedAvgTime(
- UserClassifier::Metric::NTP_OPENED)),
- base::Value(
- content_suggestions_service_->user_classifier()->GetEstimatedAvgTime(
- UserClassifier::Metric::SUGGESTIONS_SHOWN)),
- base::Value(
- content_suggestions_service_->user_classifier()->GetEstimatedAvgTime(
- UserClassifier::Metric::SUGGESTIONS_USED)));
-}
-
-void SnippetsInternalsMessageHandler::SendRankerDebugData() {
- std::vector<ntp_snippets::CategoryRanker::DebugDataItem> data =
- content_suggestions_service_->category_ranker()->GetDebugData();
-
- std::unique_ptr<base::ListValue> items_list(new base::ListValue);
- for (const auto& item : data) {
- auto entry = std::make_unique<base::DictionaryValue>();
- entry->SetString("label", item.label);
- entry->SetString("content", item.content);
- items_list->Append(std::move(entry));
- }
-
- base::DictionaryValue result;
- result.Set("list", std::move(items_list));
- web_ui()->CallJavascriptFunctionUnsafe(
- "chrome.SnippetsInternals.receiveRankerDebugData", result);
-}
-
-void SnippetsInternalsMessageHandler::
- SendLastRemoteSuggestionsBackgroundFetchTime() {
- base::Time time = base::Time::FromInternalValue(pref_service_->GetInt64(
- ntp_snippets::prefs::kLastSuccessfulBackgroundFetchTime));
- web_ui()->CallJavascriptFunctionUnsafe(
- "chrome.SnippetsInternals."
- "receiveLastRemoteSuggestionsBackgroundFetchTime",
- base::Value(base::TimeFormatShortDateAndTime(time)));
-}
-
-void SnippetsInternalsMessageHandler::SendWhetherSuggestionPushingPossible() {
- ntp_snippets::BreakingNewsListener* listener =
- GetBreakingNewsListener(content_suggestions_service_);
- CallJavascriptFunction(
- "chrome.SnippetsInternals."
- "receiveWhetherSuggestionPushingPossible",
- base::Value(listener != nullptr && listener->IsListening()));
-}
-
-void SnippetsInternalsMessageHandler::SendContentSuggestions() {
- std::unique_ptr<base::ListValue> categories_list(new base::ListValue);
-
- int index = 0;
- for (Category category : content_suggestions_service_->GetCategories()) {
- CategoryStatus status =
- content_suggestions_service_->GetCategoryStatus(category);
- base::Optional<CategoryInfo> info =
- content_suggestions_service_->GetCategoryInfo(category);
- DCHECK(info);
- const std::vector<ContentSuggestion>& suggestions =
- content_suggestions_service_->GetSuggestionsForCategory(category);
-
- std::unique_ptr<base::ListValue> suggestions_list(new base::ListValue);
- for (const ContentSuggestion& suggestion : suggestions) {
- suggestions_list->Append(PrepareSuggestion(suggestion, index++));
- }
-
- std::unique_ptr<base::ListValue> dismissed_list(new base::ListValue);
- for (const ContentSuggestion& suggestion :
- dismissed_suggestions_[category]) {
- dismissed_list->Append(PrepareSuggestion(suggestion, index++));
- }
-
- std::unique_ptr<base::DictionaryValue> category_entry(
- new base::DictionaryValue);
- category_entry->SetInteger("categoryId", category.id());
- category_entry->SetString(
- "dismissedContainerId",
- "dismissed-suggestions-" + base::IntToString(category.id()));
- category_entry->SetString("title", info->title());
- category_entry->SetString("status", GetCategoryStatusName(status));
- category_entry->Set("suggestions", std::move(suggestions_list));
- category_entry->Set("dismissedSuggestions", std::move(dismissed_list));
- categories_list->Append(std::move(category_entry));
- }
-
- if (remote_suggestions_provider_) {
- const std::string& status =
- remote_suggestions_provider_->suggestions_fetcher_for_debugging()
- ->GetLastStatusForDebugging();
- if (!status.empty()) {
- SendString("remote-status", "Finished: " + status);
- SendString(
- "remote-authenticated",
- remote_suggestions_provider_->suggestions_fetcher_for_debugging()
- ->WasLastFetchAuthenticatedForDebugging()
- ? "Authenticated"
- : "Non-authenticated");
- }
- }
-
- base::DictionaryValue result;
- result.Set("list", std::move(categories_list));
- web_ui()->CallJavascriptFunctionUnsafe(
- "chrome.SnippetsInternals.receiveContentSuggestions", result);
-}
-
-void SnippetsInternalsMessageHandler::SendBoolean(const std::string& name,
- bool value) {
- SendString(name, value ? "True" : "False");
-}
-
-void SnippetsInternalsMessageHandler::SendString(const std::string& name,
- const std::string& value) {
- base::Value string_name(name);
- base::Value string_value(value);
-
- web_ui()->CallJavascriptFunctionUnsafe(
- "chrome.SnippetsInternals.receiveProperty", string_name, string_value);
-}
-
-void SnippetsInternalsMessageHandler::FetchRemoteSuggestionsInTheBackground() {
- remote_suggestions_provider_->RefetchInTheBackground(
- RemoteSuggestionsProvider::FetchStatusCallback());
-}
-
-void SnippetsInternalsMessageHandler::PushDummySuggestion() {
- std::string json = R"(
- {"categories" : [{
- "id": 1,
- "localizedTitle": "section title",
- "suggestions" : [{
- "ids" : ["http://url.com"],
- "title" : "Pushed Dummy Title %s",
- "snippet" : "Pushed Dummy Snippet",
- "fullPageUrl" : "http://url.com",
- "creationTime" : "%s",
- "expirationTime" : "%s",
- "attribution" : "Pushed Dummy Publisher",
- "imageUrl" : "https://www.google.com/favicon.ico",
- "notificationInfo": {
- "shouldNotify": true,
- "deadline": "2100-01-01T00:00:01.000Z"
- }
- }]
- }]}
- )";
-
- const base::Time now = base::Time::Now();
- json = base::StringPrintf(
- json.c_str(), base::UTF16ToUTF8(base::TimeFormatTimeOfDay(now)).c_str(),
- base::TimeToISO8601(now).c_str(),
- base::TimeToISO8601(now + base::TimeDelta::FromMinutes(60)).c_str());
-
- gcm::IncomingMessage message;
- message.data["payload"] = json;
-
- ntp_snippets::BreakingNewsListener* listener =
- GetBreakingNewsListener(content_suggestions_service_);
- DCHECK(listener);
- DCHECK(listener->IsListening());
- static_cast<ntp_snippets::BreakingNewsGCMAppHandler*>(listener)->OnMessage(
- "com.google.breakingnews.gcm", message);
-}
-
-void SnippetsInternalsMessageHandler::OnDismissedSuggestionsLoaded(
- Category category,
- std::vector<ContentSuggestion> dismissed_suggestions) {
- if (dismissed_state_[category] == DismissedState::HIDDEN) {
- return;
- }
- dismissed_suggestions_[category] = std::move(dismissed_suggestions);
- dismissed_state_[category] = DismissedState::VISIBLE;
- SendContentSuggestions();
-}
diff --git a/chromium/chrome/browser/ui/webui/snippets_internals_message_handler.h b/chromium/chrome/browser/ui/webui/snippets_internals_message_handler.h
deleted file mode 100644
index bb5daac50f5..00000000000
--- a/chromium/chrome/browser/ui/webui/snippets_internals_message_handler.h
+++ /dev/null
@@ -1,118 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_MESSAGE_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_MESSAGE_HANDLER_H_
-
-#include <map>
-#include <string>
-#include <vector>
-
-#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
-#include "base/scoped_observer.h"
-#include "base/timer/timer.h"
-#include "components/ntp_snippets/category.h"
-#include "components/ntp_snippets/category_status.h"
-#include "components/ntp_snippets/content_suggestion.h"
-#include "components/ntp_snippets/content_suggestions_service.h"
-#include "components/ntp_snippets/remote/remote_suggestions_provider.h"
-#include "components/ntp_snippets/status.h"
-#include "content/public/browser/web_ui_message_handler.h"
-
-namespace base {
-class ListValue;
-} // namespace base
-
-namespace ntp_snippets {
-class ContentSuggestionsService;
-} // namespace ntp_snippets
-
-class PrefService;
-
-// The implementation for the chrome://snippets-internals page.
-class SnippetsInternalsMessageHandler
- : public content::WebUIMessageHandler,
- public ntp_snippets::ContentSuggestionsService::Observer {
- public:
- SnippetsInternalsMessageHandler(
- ntp_snippets::ContentSuggestionsService* content_suggestions_service,
- PrefService* pref_service);
- ~SnippetsInternalsMessageHandler() override;
-
- private:
- enum class DismissedState { HIDDEN, LOADING, VISIBLE };
-
- // content::WebUIMessageHandler:
- void RegisterMessages() override;
-
- // ntp_snippets::ContentSuggestionsService::Observer:
- void OnNewSuggestions(ntp_snippets::Category category) override;
- void OnCategoryStatusChanged(
- ntp_snippets::Category category,
- ntp_snippets::CategoryStatus new_status) override;
- void OnSuggestionInvalidated(
- const ntp_snippets::ContentSuggestion::ID& suggestion_id) override;
- void OnFullRefreshRequired() override;
- void ContentSuggestionsServiceShutdown() override;
-
- void HandleInitializationCompleted(const base::ListValue* args);
- void HandleRefreshContent(const base::ListValue* args);
- void HandleDownload(const base::ListValue* args);
- void HandleClearCachedSuggestions(const base::ListValue* args);
- void HandleClearDismissedSuggestions(const base::ListValue* args);
- void HandleToggleDismissedSuggestions(const base::ListValue* args);
- void HandleClearClassification(const base::ListValue* args);
- void HandleFetchRemoteSuggestionsInTheBackgroundIn2Seconds(
- const base::ListValue* args);
- void HandleResetNotificationsState(const base::ListValue* args);
- void HandlePushDummySuggestionIn10Seconds(const base::ListValue* args);
-
- void SendAllContent();
- void SendClassification();
- void SendRankerDebugData();
- void SendLastRemoteSuggestionsBackgroundFetchTime();
- void SendWhetherSuggestionPushingPossible();
- void SendContentSuggestions();
- void SendBoolean(const std::string& name, bool value);
- void SendString(const std::string& name, const std::string& value);
-
- void FetchRemoteSuggestionsInTheBackground();
- void PushDummySuggestion();
-
- void OnDismissedSuggestionsLoaded(
- ntp_snippets::Category category,
- std::vector<ntp_snippets::ContentSuggestion> dismissed_suggestions);
-
- ScopedObserver<ntp_snippets::ContentSuggestionsService,
- ntp_snippets::ContentSuggestionsService::Observer>
- content_suggestions_service_observer_;
-
- // Tracks whether we can already send messages to the page.
- bool dom_loaded_;
-
- ntp_snippets::ContentSuggestionsService* content_suggestions_service_;
- // TODO(pnoland): Add back contextual content suggestions service and
- // handle the new data format.
- ntp_snippets::RemoteSuggestionsProvider* remote_suggestions_provider_;
- PrefService* pref_service_;
-
- std::map<ntp_snippets::Category,
- DismissedState,
- ntp_snippets::Category::CompareByID>
- dismissed_state_;
- std::map<ntp_snippets::Category,
- std::vector<ntp_snippets::ContentSuggestion>,
- ntp_snippets::Category::CompareByID>
- dismissed_suggestions_;
-
- base::OneShotTimer suggestion_push_timer_;
- base::OneShotTimer suggestions_fetch_timer_;
-
- base::WeakPtrFactory<SnippetsInternalsMessageHandler> weak_ptr_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(SnippetsInternalsMessageHandler);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_MESSAGE_HANDLER_H_
diff --git a/chromium/chrome/browser/ui/webui/snippets_internals_ui.cc b/chromium/chrome/browser/ui/webui/snippets_internals_ui.cc
deleted file mode 100644
index 9700dc8eeaf..00000000000
--- a/chromium/chrome/browser/ui/webui/snippets_internals_ui.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/snippets_internals_ui.h"
-
-#include <memory>
-
-#include "build/build_config.h"
-#include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/snippets_internals_message_handler.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/grit/browser_resources.h"
-#include "content/public/browser/web_ui.h"
-#include "content/public/browser/web_ui_data_source.h"
-
-#if defined(OS_ANDROID)
-#include "chrome/browser/android/chrome_feature_list.h"
-#endif
-
-namespace {
-
-content::WebUIDataSource* CreateSnippetsInternalsHTMLSource() {
- content::WebUIDataSource* source =
- content::WebUIDataSource::Create(chrome::kChromeUISnippetsInternalsHost);
-
- source->SetJsonPath("strings.js");
- source->AddResourcePath("snippets_internals.js", IDR_SNIPPETS_INTERNALS_JS);
- source->AddResourcePath("snippets_internals.css", IDR_SNIPPETS_INTERNALS_CSS);
- source->SetDefaultResource(IDR_SNIPPETS_INTERNALS_HTML);
- source->UseGzip();
- return source;
-}
-
-} // namespace
-
-SnippetsInternalsUI::SnippetsInternalsUI(content::WebUI* web_ui)
- : WebUIController(web_ui) {
- Profile* profile = Profile::FromWebUI(web_ui);
- content::WebUIDataSource::Add(profile, CreateSnippetsInternalsHTMLSource());
-
- web_ui->AddMessageHandler(std::make_unique<SnippetsInternalsMessageHandler>(
- ContentSuggestionsServiceFactory::GetInstance()->GetForProfile(profile),
- profile->GetPrefs()));
-}
-
-SnippetsInternalsUI::~SnippetsInternalsUI() {}
diff --git a/chromium/chrome/browser/ui/webui/snippets_internals_ui.h b/chromium/chrome/browser/ui/webui/snippets_internals_ui.h
deleted file mode 100644
index c6046996d71..00000000000
--- a/chromium/chrome/browser/ui/webui/snippets_internals_ui.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_UI_H_
-
-#include "base/macros.h"
-#include "content/public/browser/web_ui_controller.h"
-
-// The implementation for the chrome://snippets-internals page.
-class SnippetsInternalsUI : public content::WebUIController {
- public:
- explicit SnippetsInternalsUI(content::WebUI* web_ui);
- ~SnippetsInternalsUI() override;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(SnippetsInternalsUI);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_SNIPPETS_INTERNALS_UI_H_
diff --git a/chromium/chrome/browser/ui/webui/supervised_user_internals_message_handler.cc b/chromium/chrome/browser/ui/webui/supervised_user_internals_message_handler.cc
index 824104454b8..88885a3dcbd 100644
--- a/chromium/chrome/browser/ui/webui/supervised_user_internals_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/supervised_user_internals_message_handler.cc
@@ -27,6 +27,7 @@
#include "components/supervised_user_error_page/supervised_user_error_page.h"
#include "components/url_formatter/url_fixer.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_ui.h"
using content::BrowserThread;
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 4563fa61cc1..9bd2b4ab217 100644
--- a/chromium/chrome/browser/ui/webui/sync_internals_message_handler.cc
+++ b/chromium/chrome/browser/ui/webui/sync_internals_message_handler.cc
@@ -17,6 +17,8 @@
#include "chrome/browser/sync/user_event_service_factory.h"
#include "chrome/common/channel_info.h"
#include "components/browser_sync/profile_sync_service.h"
+#include "components/sync/base/enum_set.h"
+#include "components/sync/base/model_type.h"
#include "components/sync/base/weak_handle.h"
#include "components/sync/driver/about_sync_util.h"
#include "components/sync/driver/sync_driver_switches.h"
@@ -66,7 +68,7 @@ bool HasSomethingAtIndex(const base::ListValue* list, int index) {
SyncInternalsMessageHandler::SyncInternalsMessageHandler()
: SyncInternalsMessageHandler(base::BindRepeating(
- &syncer::sync_ui_util::ConstructAboutInformation_DEPRECATED)) {}
+ &syncer::sync_ui_util::ConstructAboutInformation)) {}
SyncInternalsMessageHandler::SyncInternalsMessageHandler(
AboutSyncDataDelegate about_sync_data_delegate)
@@ -130,6 +132,11 @@ void SyncInternalsMessageHandler::RegisterMessages() {
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
+ syncer::sync_ui_util::kTriggerRefresh,
+ base::BindRepeating(&SyncInternalsMessageHandler::HandleTriggerRefresh,
+ base::Unretained(this)));
+
+ web_ui()->RegisterMessageCallback(
syncer::sync_ui_util::kGetAllNodes,
base::BindRepeating(&SyncInternalsMessageHandler::HandleGetAllNodes,
base::Unretained(this)));
@@ -256,6 +263,18 @@ void SyncInternalsMessageHandler::HandleWriteUserEvent(
user_event_service->RecordUserEvent(event_specifics);
}
+void SyncInternalsMessageHandler::HandleTriggerRefresh(
+ const base::ListValue* args) {
+ SyncService* service = GetSyncService();
+ if (!service)
+ return;
+
+ // Only allowed to trigger refresh/schedule nudges for protocol types, things
+ // like PROXY_TABS are not allowed.
+ service->TriggerRefresh(syncer::Intersection(service->GetActiveDataTypes(),
+ syncer::ProtocolTypes()));
+}
+
void SyncInternalsMessageHandler::OnReceivedAllNodes(
int request_id,
std::unique_ptr<ListValue> nodes) {
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 4c6f4199743..336aa635bb5 100644
--- a/chromium/chrome/browser/ui/webui/sync_internals_message_handler.h
+++ b/chromium/chrome/browser/ui/webui/sync_internals_message_handler.h
@@ -68,6 +68,9 @@ class SyncInternalsMessageHandler : public content::WebUIMessageHandler,
// Handler for writeUserEvent message.
void HandleWriteUserEvent(const base::ListValue* args);
+ // Handler for triggerRefresh message.
+ void HandleTriggerRefresh(const base::ListValue* args);
+
// syncer::JsEventHandler implementation.
void HandleJsEvent(const std::string& name,
const syncer::JsEventDetails& details) override;
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 33d16953265..4478537a51c 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
@@ -20,7 +20,6 @@
#include "components/sync/user_events/fake_user_event_service.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/test/mock_render_process_host.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "content/public/test/test_web_ui.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -110,8 +109,8 @@ class SyncInternalsMessageHandlerTest : public ::testing::Test {
protected:
SyncInternalsMessageHandlerTest() {
site_instance_ = content::SiteInstance::Create(&profile_);
- web_contents_.reset(content::WebContents::Create(
- content::WebContents::CreateParams(&profile_, site_instance_.get())));
+ web_contents_ = content::WebContents::Create(
+ content::WebContents::CreateParams(&profile_, site_instance_.get()));
web_ui_.set_web_contents(web_contents_.get());
test_sync_service_ = static_cast<TestSyncService*>(
ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
@@ -197,10 +196,6 @@ class SyncInternalsMessageHandlerTest : public ::testing::Test {
void ResetHandler() { handler_.reset(); }
private:
- // TODO(lukasza): https://crbug.com/832100: Move the factory into
- // TestingProfile, so individual tests don't need to worry about it.
- content::ScopedMockRenderProcessHostFactory process_factory_;
-
content::TestBrowserThreadBundle thread_bundle_;
TestingProfile profile_;
scoped_refptr<content::SiteInstance> site_instance_;
diff --git a/chromium/chrome/browser/ui/webui/sync_internals_ui_unittest.cc b/chromium/chrome/browser/ui/webui/sync_internals_ui_unittest.cc
index 96933922e21..d11958e5b32 100644
--- a/chromium/chrome/browser/ui/webui/sync_internals_ui_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/sync_internals_ui_unittest.cc
@@ -7,7 +7,7 @@
#include <cstddef>
#include <string>
-#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_loop_current.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
@@ -75,17 +75,11 @@ class SyncInternalsUITestWithService : public ChromeRenderViewHostTestHarness {
EXPECT_CALL(mock_js_controller_, AddJsEventHandler(_));
- {
- // Needed by |sync_internals_ui_|'s constructor. The
- // message loop is provided by ChromeRenderViewHostTestHarness.
- content::TestBrowserThread ui_thread_(BrowserThread::UI,
- base::MessageLoopForUI::current());
- // |sync_internals_ui_|'s constructor triggers all the
- // expectations above.
- web_ui_.reset(new TestSyncWebUI(web_contents()));
- sync_internals_ui_ = new SyncInternalsUI(web_ui_.get());
- web_ui_->SetController(sync_internals_ui_);
- }
+ // |sync_internals_ui_|'s constructor triggers all the
+ // expectations above.
+ web_ui_.reset(new TestSyncWebUI(web_contents()));
+ sync_internals_ui_ = new SyncInternalsUI(web_ui_.get());
+ web_ui_->SetController(sync_internals_ui_);
Mock::VerifyAndClearExpectations(profile_mock);
Mock::VerifyAndClearExpectations(&mock_js_controller_);
@@ -155,17 +149,11 @@ class SyncInternalsUITestWithoutService
ChromeRenderViewHostTestHarness::SetUp();
- {
- // Needed by |sync_internals_ui_|'s constructor. The
- // message loop is provided by ChromeRenderViewHostTestHarness.
- content::TestBrowserThread ui_thread_(BrowserThread::UI,
- base::MessageLoopForUI::current());
- // |sync_internals_ui_|'s constructor triggers all the
- // expectations above.
- web_ui_.reset(new TestSyncWebUI(web_contents()));
- sync_internals_ui_ = new SyncInternalsUI(web_ui_.get());
- web_ui_->SetController(sync_internals_ui_);
- }
+ // |sync_internals_ui_|'s constructor triggers all the
+ // expectations above.
+ web_ui_.reset(new TestSyncWebUI(web_contents()));
+ sync_internals_ui_ = new SyncInternalsUI(web_ui_.get());
+ web_ui_->SetController(sync_internals_ui_);
Mock::VerifyAndClearExpectations(profile_mock);
}
diff --git a/chromium/chrome/browser/ui/webui/system_info_ui.cc b/chromium/chrome/browser/ui/webui/system_info_ui.cc
index c1865b92a95..b63bb2e4af6 100644
--- a/chromium/chrome/browser/ui/webui/system_info_ui.cc
+++ b/chromium/chrome/browser/ui/webui/system_info_ui.cc
@@ -12,7 +12,6 @@
#include "base/macros.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/weak_ptr.h"
-#include "base/message_loop/message_loop.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
diff --git a/chromium/chrome/browser/ui/webui/test_files_request_filter.cc b/chromium/chrome/browser/ui/webui/test_files_request_filter.cc
index b9604f3e5a7..e4cdc784e20 100644
--- a/chromium/chrome/browser/ui/webui/test_files_request_filter.cc
+++ b/chromium/chrome/browser/ui/webui/test_files_request_filter.cc
@@ -25,7 +25,7 @@ bool HandleTestFileRequestCallback(
std::string contents;
base::FilePath test_data_dir;
- PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
+ base::PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
if (!base::ReadFileToString(
test_data_dir.AppendASCII("webui").AppendASCII(url_substr[1]),
&contents))
diff --git a/chromium/chrome/browser/ui/webui/theme_source.cc b/chromium/chrome/browser/ui/webui/theme_source.cc
index f3681500ad5..69c30d47e93 100644
--- a/chromium/chrome/browser/ui/webui/theme_source.cc
+++ b/chromium/chrome/browser/ui/webui/theme_source.cc
@@ -5,7 +5,6 @@
#include "chrome/browser/ui/webui/theme_source.h"
#include "base/memory/ref_counted_memory.h"
-#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/resources_util.h"
diff --git a/chromium/chrome/browser/ui/webui/theme_source_unittest.cc b/chromium/chrome/browser/ui/webui/theme_source_unittest.cc
index 1fe1c490c21..abbf029bf54 100644
--- a/chromium/chrome/browser/ui/webui/theme_source_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/theme_source_unittest.cc
@@ -6,7 +6,6 @@
#include "base/bind.h"
#include "base/memory/ref_counted_memory.h"
-#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/theme_source.h"
diff --git a/chromium/chrome/browser/ui/webui/usb_internals/usb_internals_ui.cc b/chromium/chrome/browser/ui/webui/usb_internals/usb_internals_ui.cc
index 28e46d02e1c..841b9d2898a 100644
--- a/chromium/chrome/browser/ui/webui/usb_internals/usb_internals_ui.cc
+++ b/chromium/chrome/browser/ui/webui/usb_internals/usb_internals_ui.cc
@@ -11,7 +11,7 @@
#include "content/public/browser/web_ui_data_source.h"
UsbInternalsUI::UsbInternalsUI(content::WebUI* web_ui)
- : ui::MojoWebUIController<mojom::UsbInternalsPageHandler>(web_ui) {
+ : ui::MojoWebUIController(web_ui) {
// Set up the chrome://usb-internals source.
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIUsbInternalsHost);
@@ -26,11 +26,13 @@ UsbInternalsUI::UsbInternalsUI(content::WebUI* web_ui)
source->UseGzip();
content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), source);
+ AddHandlerToRegistry(base::BindRepeating(
+ &UsbInternalsUI::BindUsbInternalsPageHandler, base::Unretained(this)));
}
UsbInternalsUI::~UsbInternalsUI() {}
-void UsbInternalsUI::BindUIHandler(
+void UsbInternalsUI::BindUsbInternalsPageHandler(
mojom::UsbInternalsPageHandlerRequest request) {
page_handler_.reset(new UsbInternalsPageHandler(std::move(request)));
}
diff --git a/chromium/chrome/browser/ui/webui/usb_internals/usb_internals_ui.h b/chromium/chrome/browser/ui/webui/usb_internals/usb_internals_ui.h
index 1665116bdc5..0f4fc201756 100644
--- a/chromium/chrome/browser/ui/webui/usb_internals/usb_internals_ui.h
+++ b/chromium/chrome/browser/ui/webui/usb_internals/usb_internals_ui.h
@@ -12,15 +12,14 @@
class UsbInternalsPageHandler;
// The WebUI for chrome://usb-internals.
-class UsbInternalsUI
- : public ui::MojoWebUIController<mojom::UsbInternalsPageHandler> {
+class UsbInternalsUI : public ui::MojoWebUIController {
public:
explicit UsbInternalsUI(content::WebUI* web_ui);
~UsbInternalsUI() override;
private:
- // ui::MojoWebUIController overrides:
- void BindUIHandler(mojom::UsbInternalsPageHandlerRequest request) override;
+ void BindUsbInternalsPageHandler(
+ mojom::UsbInternalsPageHandlerRequest request);
std::unique_ptr<UsbInternalsPageHandler> page_handler_;
diff --git a/chromium/chrome/browser/ui/webui/web_dialog_web_contents_delegate_unittest.cc b/chromium/chrome/browser/ui/webui/web_dialog_web_contents_delegate_unittest.cc
index 58ee37f741d..5d7dea32cf1 100644
--- a/chromium/chrome/browser/ui/webui/web_dialog_web_contents_delegate_unittest.cc
+++ b/chromium/chrome/browser/ui/webui/web_dialog_web_contents_delegate_unittest.cc
@@ -89,11 +89,11 @@ TEST_F(WebDialogWebContentsDelegateTest, OpenURLFromTabTest) {
}
TEST_F(WebDialogWebContentsDelegateTest, AddNewContentsForegroundTabTest) {
- WebContents* contents =
+ std::unique_ptr<WebContents> contents =
WebContentsTester::CreateTestWebContents(profile(), NULL);
test_web_contents_delegate_->AddNewContents(
- NULL, contents, WindowOpenDisposition::NEW_FOREGROUND_TAB, gfx::Rect(),
- false, NULL);
+ NULL, std::move(contents), WindowOpenDisposition::NEW_FOREGROUND_TAB,
+ gfx::Rect(), false, NULL);
// This should create a new foreground tab in the existing browser.
EXPECT_EQ(1, browser()->tab_strip_model()->count());
EXPECT_EQ(1U, chrome::GetTotalBrowserCount());
diff --git a/chromium/chrome/browser/ui/webui/web_ui_test_handler.cc b/chromium/chrome/browser/ui/webui/web_ui_test_handler.cc
index efe8811db00..c89b8e98b96 100644
--- a/chromium/chrome/browser/ui/webui/web_ui_test_handler.cc
+++ b/chromium/chrome/browser/ui/webui/web_ui_test_handler.cc
@@ -6,7 +6,6 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
-#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@@ -29,8 +28,8 @@ WebUITestHandler::WebUITestHandler()
: test_done_(false),
test_succeeded_(false),
run_test_done_(false),
- run_test_succeeded_(false) {
-}
+ run_test_succeeded_(false),
+ binding_(this) {}
WebUITestHandler::~WebUITestHandler() = default;
@@ -65,6 +64,25 @@ void WebUITestHandler::RegisterMessages() {
base::Unretained(this)));
}
+void WebUITestHandler::BindToTestRunnerRequest(
+ web_ui_test::mojom::TestRunnerRequest request) {
+ binding_.Bind(std::move(request));
+}
+
+void WebUITestHandler::TestComplete(
+ const base::Optional<std::string>& message) {
+ // To ensure this gets done, do this before ASSERT* calls.
+ quit_closure_.Run();
+
+ SCOPED_TRACE("WebUITestHandler::TestComplete");
+
+ EXPECT_FALSE(test_done_);
+ test_done_ = true;
+ test_succeeded_ = !message.has_value();
+
+ EXPECT_TRUE(test_succeeded_) << *message;
+}
+
void WebUITestHandler::HandleTestResult(const base::ListValue* test_result) {
// To ensure this gets done, do this before ASSERT* calls.
quit_closure_.Run();
diff --git a/chromium/chrome/browser/ui/webui/web_ui_test_handler.h b/chromium/chrome/browser/ui/webui/web_ui_test_handler.h
index cba7ccf76a9..da2c063b56b 100644
--- a/chromium/chrome/browser/ui/webui/web_ui_test_handler.h
+++ b/chromium/chrome/browser/ui/webui/web_ui_test_handler.h
@@ -8,7 +8,9 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/strings/string16.h"
+#include "chrome/test/data/webui/web_ui_test.mojom.h"
#include "content/public/browser/web_ui_message_handler.h"
+#include "mojo/public/cpp/bindings/binding.h"
namespace base {
class ListValue;
@@ -20,7 +22,8 @@ class RenderViewHost;
}
// This class registers test framework specific handlers on WebUI objects.
-class WebUITestHandler : public content::WebUIMessageHandler {
+class WebUITestHandler : public content::WebUIMessageHandler,
+ public web_ui_test::mojom::TestRunner {
public:
WebUITestHandler();
~WebUITestHandler() override;
@@ -37,10 +40,15 @@ class WebUITestHandler : public content::WebUIMessageHandler {
// error message on failure. Returns test pass/fail.
bool RunJavaScriptTestWithResult(const base::string16& js_text);
- // WebUIMessageHandler overrides.
- // Add test handlers to the current WebUI object.
+ // Binds the Mojo test interface to this handler.
+ void BindToTestRunnerRequest(web_ui_test::mojom::TestRunnerRequest request);
+
+ // content::WebUIMessageHandler:
void RegisterMessages() override;
+ // web_ui_test::mojom::TestRunner:
+ void TestComplete(const base::Optional<std::string>& message) override;
+
private:
// Receives testResult messages.
void HandleTestResult(const base::ListValue* test_result);
@@ -70,6 +78,8 @@ class WebUITestHandler : public content::WebUIMessageHandler {
// Quits the currently running RunLoop.
base::Closure quit_closure_;
+ mojo::Binding<web_ui_test::mojom::TestRunner> binding_;
+
DISALLOW_COPY_AND_ASSIGN(WebUITestHandler);
};
diff --git a/chromium/chrome/browser/ui/webui/webapks_handler.cc b/chromium/chrome/browser/ui/webui/webapks_handler.cc
index 8a4f948778b..5df9d037ea6 100644
--- a/chromium/chrome/browser/ui/webui/webapks_handler.cc
+++ b/chromium/chrome/browser/ui/webui/webapks_handler.cc
@@ -9,21 +9,12 @@
#include "base/callback_forward.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
+#include "chrome/browser/android/color_helpers.h"
#include "chrome/browser/android/shortcut_helper.h"
#include "content/public/browser/web_ui.h"
#include "content/public/common/manifest_util.h"
#include "ui/gfx/color_utils.h"
-namespace {
-// Converts a color from the format documented in content::Manifest to a
-// rgba() CSS string.
-std::string ColorToString(int64_t color) {
- if (color == content::Manifest::kInvalidOrMissingColor)
- return std::string();
- return color_utils::SkColorToRgbaString(reinterpret_cast<uint32_t&>(color));
-}
-} // namespace
-
WebApksHandler::WebApksHandler() : weak_ptr_factory_(this) {}
WebApksHandler::~WebApksHandler() {}
@@ -62,9 +53,10 @@ void WebApksHandler::OnWebApkInfoRetrieved(
result->SetString(
"orientation",
content::WebScreenOrientationLockTypeToString(webapk_info.orientation));
- result->SetString("themeColor", ColorToString(webapk_info.theme_color));
+ result->SetString("themeColor",
+ OptionalSkColorToString(webapk_info.theme_color));
result->SetString("backgroundColor",
- ColorToString(webapk_info.background_color));
+ OptionalSkColorToString(webapk_info.background_color));
result->SetDouble("lastUpdateCheckTimeMs",
webapk_info.last_update_check_time.ToJsTime());
result->SetBoolean("relaxUpdates", webapk_info.relax_updates);
diff --git a/chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc b/chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc
index 1c31268e703..ae7ad18801f 100644
--- a/chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc
+++ b/chromium/chrome/browser/ui/webui/webui_webview_browsertest.cc
@@ -110,7 +110,7 @@ class WebUIWebViewBrowserTest : public WebUIBrowserTest {
base::FilePath(FILE_PATH_LITERAL("webview_basic.js")));
base::FilePath test_data_dir;
- PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
+ base::PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
embedded_test_server()->ServeFilesFromDirectory(test_data_dir);
ASSERT_TRUE(embedded_test_server()->Start());
}
diff --git a/chromium/chrome/browser/ui/webui/welcome_ui.cc b/chromium/chrome/browser/ui/webui/welcome_ui.cc
index 9b9267516b6..16af7154fea 100644
--- a/chromium/chrome/browser/ui/webui/welcome_ui.cc
+++ b/chromium/chrome/browser/ui/webui/welcome_ui.cc
@@ -47,12 +47,6 @@ WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url)
content::WebUIDataSource* html_source =
content::WebUIDataSource::Create(url.host());
- // Check URL for variations.
- std::string value;
- bool is_everywhere_variant =
- (net::GetValueForKeyInQuery(url, "variant", &value) &&
- value == "everywhere");
-
bool is_dice = signin::IsDiceEnabledForProfile(profile->GetPrefs());
// There are multiple possible configurations that affects the layout, but
@@ -61,9 +55,9 @@ 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 it's branded, DICE is enabled, and it's the first
- // run. otherwise use the default layout.
- if (kIsBranded && is_dice && !is_everywhere_variant) {
+ // Use special layout if the application is branded and DICE is enabled.
+ // Otherwise use the default layout.
+ if (kIsBranded && is_dice) {
html_source->AddLocalizedString("headerText", IDS_WELCOME_HEADER);
html_source->AddLocalizedString("secondHeaderText",
IDS_DICE_WELCOME_SECOND_HEADER);
@@ -71,14 +65,21 @@ WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url)
IDS_DICE_WELCOME_DESCRIPTION);
html_source->AddLocalizedString("declineText",
IDS_DICE_WELCOME_DECLINE_BUTTON);
- html_source->AddResourcePath("welcome_browser_proxy.html", IDR_DICE_WELCOME_BROWSER_PROXY_HTML);
- html_source->AddResourcePath("welcome_browser_proxy.js", IDR_DICE_WELCOME_BROWSER_PROXY_JS);
+ html_source->AddResourcePath("welcome_browser_proxy.html",
+ IDR_DICE_WELCOME_BROWSER_PROXY_HTML);
+ html_source->AddResourcePath("welcome_browser_proxy.js",
+ IDR_DICE_WELCOME_BROWSER_PROXY_JS);
html_source->AddResourcePath("welcome_app.html", IDR_DICE_WELCOME_APP_HTML);
html_source->AddResourcePath("welcome_app.js", IDR_DICE_WELCOME_APP_JS);
html_source->AddResourcePath("welcome.css", IDR_DICE_WELCOME_CSS);
html_source->SetDefaultResource(IDR_DICE_WELCOME_HTML);
} else {
- // Use default layout for non-DICE, non-first run, or unbranded build.
+ // Use default layout for non-DICE or unbranded build.
+ std::string value;
+ bool is_everywhere_variant =
+ (net::GetValueForKeyInQuery(url, "variant", &value) &&
+ value == "everywhere");
+
if (kIsBranded) {
base::string16 subheader =
is_everywhere_variant
diff --git a/chromium/chrome/browser/ui/webui/welcome_win10_handler.cc b/chromium/chrome/browser/ui/webui/welcome_win10_handler.cc
index fcc39583b60..eb83e52757c 100644
--- a/chromium/chrome/browser/ui/webui/welcome_win10_handler.cc
+++ b/chromium/chrome/browser/ui/webui/welcome_win10_handler.cc
@@ -99,6 +99,10 @@ void WelcomeWin10Handler::RegisterMessages() {
base::Unretained(this)));
}
+void WelcomeWin10Handler::OnJavascriptDisallowed() {
+ pinned_state_callback_id_.clear();
+}
+
void WelcomeWin10Handler::HandleGetPinnedToTaskbarState(
const base::ListValue* args) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
diff --git a/chromium/chrome/browser/ui/webui/welcome_win10_handler.h b/chromium/chrome/browser/ui/webui/welcome_win10_handler.h
index 423336121bb..70a0970934d 100644
--- a/chromium/chrome/browser/ui/webui/welcome_win10_handler.h
+++ b/chromium/chrome/browser/ui/webui/welcome_win10_handler.h
@@ -25,6 +25,7 @@ class WelcomeWin10Handler : public content::WebUIMessageHandler {
// content::WebUIMessageHandler:
void RegisterMessages() override;
+ void OnJavascriptDisallowed() override;
private:
// Handlers for javascript calls.
diff --git a/chromium/chrome/browser/ui/webui/welcome_win10_ui.cc b/chromium/chrome/browser/ui/webui/welcome_win10_ui.cc
index ff736d62084..018ed4d2935 100644
--- a/chromium/chrome/browser/ui/webui/welcome_win10_ui.cc
+++ b/chromium/chrome/browser/ui/webui/welcome_win10_ui.cc
@@ -93,7 +93,7 @@ WelcomeWin10UI::WelcomeWin10UI(content::WebUI* web_ui, const GURL& url)
AddLocalizedStrings(html_source, is_first_run);
// Controls the accelerated default browser flow experiment.
- html_source->AddBoolean("accelerated_flow_enabled",
+ html_source->AddBoolean("acceleratedFlowEnabled",
base::FeatureList::IsEnabled(
features::kWin10AcceleratedDefaultBrowserFlow));
diff --git a/chromium/chrome/browser/vr/BUILD.gn b/chromium/chrome/browser/vr/BUILD.gn
index f24a8aa28f8..5ec46d0aa2b 100644
--- a/chromium/chrome/browser/vr/BUILD.gn
+++ b/chromium/chrome/browser/vr/BUILD.gn
@@ -73,10 +73,12 @@ static_library("vr_common") {
"elements/omnibox_text_field.h",
"elements/oval.cc",
"elements/oval.h",
- "elements/prompt.cc",
- "elements/prompt.h",
- "elements/prompt_texture.cc",
- "elements/prompt_texture.h",
+ "elements/paged_grid_layout.cc",
+ "elements/paged_grid_layout.h",
+ "elements/paged_scroll_view.cc",
+ "elements/paged_scroll_view.h",
+ "elements/platform_ui_element.cc",
+ "elements/platform_ui_element.h",
"elements/rect.cc",
"elements/rect.h",
"elements/render_text_wrapper.cc",
@@ -89,12 +91,16 @@ static_library("vr_common") {
"elements/reticle.h",
"elements/scaled_depth_adjuster.cc",
"elements/scaled_depth_adjuster.h",
+ "elements/scrollable_element.cc",
+ "elements/scrollable_element.h",
"elements/shadow.cc",
"elements/shadow.h",
"elements/spinner.cc",
"elements/spinner.h",
"elements/text.cc",
"elements/text.h",
+ "elements/text_button.cc",
+ "elements/text_button.h",
"elements/text_input.cc",
"elements/text_input.h",
"elements/textured_element.cc",
@@ -124,6 +130,8 @@ static_library("vr_common") {
"font_fallback.h",
"fps_meter.cc",
"fps_meter.h",
+ "frame_lifecycle.cc",
+ "frame_lifecycle.h",
"ganesh_surface_provider.cc",
"ganesh_surface_provider.h",
"keyboard_delegate.h",
@@ -154,12 +162,17 @@ static_library("vr_common") {
"model/platform_toast.h",
"model/reticle_model.h",
"model/speech_recognition_model.h",
+ "model/tab_model.cc",
+ "model/tab_model.h",
"model/text_input_info.cc",
"model/text_input_info.h",
"model/toolbar_state.cc",
"model/toolbar_state.h",
"model/ui_mode.h",
"model/web_vr_model.h",
+ "platform_input_handler.h",
+ "platform_ui_input_delegate.cc",
+ "platform_ui_input_delegate.h",
"pose_util.cc",
"pose_util.h",
"renderers/base_quad_renderer.cc",
@@ -168,14 +181,20 @@ static_library("vr_common") {
"renderers/base_renderer.h",
"renderers/external_textured_quad_renderer.cc",
"renderers/external_textured_quad_renderer.h",
- "renderers/gradient_quad_renderer.cc",
- "renderers/gradient_quad_renderer.h",
+ "renderers/radial_gradient_quad_renderer.cc",
+ "renderers/radial_gradient_quad_renderer.h",
"renderers/textured_quad_renderer.cc",
"renderers/textured_quad_renderer.h",
+ "renderers/transparent_quad_renderer.cc",
+ "renderers/transparent_quad_renderer.h",
"renderers/web_vr_renderer.cc",
"renderers/web_vr_renderer.h",
"sample_queue.cc",
"sample_queue.h",
+ "sequence.cc",
+ "sequence.h",
+ "service/browser_xr_device.cc",
+ "service/browser_xr_device.h",
"service/vr_device_manager.cc",
"service/vr_device_manager.h",
"service/vr_display_host.cc",
@@ -211,6 +230,8 @@ static_library("vr_common") {
"ui_scene.h",
"ui_scene_creator.cc",
"ui_scene_creator.h",
+ "ui_test_input.cc",
+ "ui_test_input.h",
"ui_unsupported_mode.h",
"vr_features.h",
"vr_gl_util.cc",
@@ -262,11 +283,12 @@ test("vr_common_unittests") {
"elements/omnibox_formatting_unittest.cc",
"elements/omnibox_text_field_unittest.cc",
"elements/oval_unittest.cc",
- "elements/prompt_unittest.cc",
+ "elements/paged_grid_layout_unittest.cc",
"elements/rect_unittest.cc",
"elements/repositioner_unittest.cc",
"elements/resizer_unittest.cc",
"elements/scaled_depth_adjuster_unittest.cc",
+ "elements/scrollable_element_unittest.cc",
"elements/shadow_unittest.cc",
"elements/spinner_unittest.cc",
"elements/text_input_unittest.cc",
@@ -284,8 +306,6 @@ test("vr_common_unittests") {
"service/vr_device_manager_unittest.cc",
"sliding_average_unittest.cc",
"speech_recognizer_unittest.cc",
- "test/fake_ui_element_renderer.cc",
- "test/fake_ui_element_renderer.h",
"test/paths.cc",
"test/paths.h",
"test/run_all_unittests.cc",
@@ -304,7 +324,6 @@ test("vr_common_unittests") {
deps = [
":vr_test_support",
- "//mojo/common",
"//mojo/public/cpp/bindings",
"//testing/gmock",
"//ui/gfx/geometry",