summaryrefslogtreecommitdiff
path: root/chromium/extensions
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-07-14 17:41:05 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-08-04 12:37:36 +0000
commit399c965b6064c440ddcf4015f5f8e9d131c7a0a6 (patch)
tree6b06b60ff365abef0e13b3503d593a0df48d20e8 /chromium/extensions
parent7366110654eec46f21b6824f302356426f48cd74 (diff)
downloadqtwebengine-chromium-399c965b6064c440ddcf4015f5f8e9d131c7a0a6.tar.gz
BASELINE: Update Chromium to 52.0.2743.76 and Ninja to 1.7.1
Change-Id: I382f51b959689505a60f8b707255ecb344f7d8b4 Reviewed-by: Michael Brüning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/extensions')
-rw-r--r--chromium/extensions/BUILD.gn18
-rw-r--r--chromium/extensions/browser/BUILD.gn6
-rw-r--r--chromium/extensions/browser/DEPS1
-rw-r--r--chromium/extensions/browser/api/alarms/OWNERS1
-rw-r--r--chromium/extensions/browser/api/alarms/alarm_manager.cc16
-rw-r--r--chromium/extensions/browser/api/alarms/alarm_manager.h6
-rw-r--r--chromium/extensions/browser/api/alarms/alarms_api.cc9
-rw-r--r--chromium/extensions/browser/api/alarms/alarms_api_unittest.cc26
-rw-r--r--chromium/extensions/browser/api/api_resource_manager.h2
-rw-r--r--chromium/extensions/browser/api/api_resource_manager_unittest.cc2
-rw-r--r--chromium/extensions/browser/api/app_current_window_internal/app_current_window_internal_api.cc21
-rw-r--r--chromium/extensions/browser/api/app_runtime/app_runtime_api.cc44
-rw-r--r--chromium/extensions/browser/api/app_runtime/app_runtime_api.h4
-rw-r--r--chromium/extensions/browser/api/app_window/app_window_api.cc6
-rw-r--r--chromium/extensions/browser/api/app_window/app_window_apitest.cc2
-rw-r--r--chromium/extensions/browser/api/audio/audio_api.cc34
-rw-r--r--chromium/extensions/browser/api/bluetooth/bluetooth_api.cc2
-rw-r--r--chromium/extensions/browser/api/bluetooth/bluetooth_api.h4
-rw-r--r--chromium/extensions/browser/api/bluetooth/bluetooth_api_pairing_delegate.cc10
-rw-r--r--chromium/extensions/browser/api/bluetooth/bluetooth_apitest.cc13
-rw-r--r--chromium/extensions/browser/api/bluetooth/bluetooth_event_router.cc14
-rw-r--r--chromium/extensions/browser/api/bluetooth/bluetooth_event_router.h4
-rw-r--r--chromium/extensions/browser/api/bluetooth/bluetooth_event_router_unittest.cc8
-rw-r--r--chromium/extensions/browser/api/bluetooth/bluetooth_private_api.cc16
-rw-r--r--chromium/extensions/browser/api/bluetooth/bluetooth_private_apitest.cc14
-rw-r--r--chromium/extensions/browser/api/bluetooth_socket/bluetooth_api_socket.h2
-rw-r--r--chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_api.cc6
-rw-r--r--chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_api.h28
-rw-r--r--chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_apitest.cc6
-rw-r--r--chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_event_dispatcher.cc32
-rw-r--r--chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_event_dispatcher.h5
-rw-r--r--chromium/extensions/browser/api/cast_channel/DEPS1
-rw-r--r--chromium/extensions/browser/api/cast_channel/cast_auth_util.cc6
-rw-r--r--chromium/extensions/browser/api/cast_channel/cast_auth_util_unittest.cc113
-rw-r--r--chromium/extensions/browser/api/cast_channel/cast_channel_api.cc44
-rw-r--r--chromium/extensions/browser/api/cast_channel/cast_channel_api.h27
-rw-r--r--chromium/extensions/browser/api/cast_channel/cast_channel_api_unittest.cc5
-rw-r--r--chromium/extensions/browser/api/cast_channel/cast_channel_apitest.cc5
-rw-r--r--chromium/extensions/browser/api/cast_channel/cast_framer.cc20
-rw-r--r--chromium/extensions/browser/api/cast_channel/cast_framer.h7
-rw-r--r--chromium/extensions/browser/api/cast_channel/cast_framer_unittest.cc6
-rw-r--r--chromium/extensions/browser/api/cast_channel/cast_message_util.cc5
-rw-r--r--chromium/extensions/browser/api/cast_channel/cast_socket.cc25
-rw-r--r--chromium/extensions/browser/api/cast_channel/cast_socket.h28
-rw-r--r--chromium/extensions/browser/api/cast_channel/cast_socket_unittest.cc51
-rw-r--r--chromium/extensions/browser/api/cast_channel/cast_test_util.cc2
-rw-r--r--chromium/extensions/browser/api/cast_channel/cast_test_util.h11
-rw-r--r--chromium/extensions/browser/api/cast_channel/cast_transport.cc2
-rw-r--r--chromium/extensions/browser/api/cast_channel/cast_transport.h10
-rw-r--r--chromium/extensions/browser/api/cast_channel/cast_transport_unittest.cc8
-rw-r--r--chromium/extensions/browser/api/cast_channel/keep_alive_delegate.cc8
-rw-r--r--chromium/extensions/browser/api/cast_channel/keep_alive_delegate.h12
-rw-r--r--chromium/extensions/browser/api/cast_channel/keep_alive_delegate_unittest.cc13
-rw-r--r--chromium/extensions/browser/api/cast_channel/logger.cc10
-rw-r--r--chromium/extensions/browser/api/cast_channel/logger.h8
-rw-r--r--chromium/extensions/browser/api/cast_channel/logger_unittest.cc25
-rw-r--r--chromium/extensions/browser/api/declarative/declarative_api.cc16
-rw-r--r--chromium/extensions/browser/api/declarative/declarative_rule.h73
-rw-r--r--chromium/extensions/browser/api/declarative/declarative_rule_unittest.cc44
-rw-r--r--chromium/extensions/browser/api/declarative/deduping_factory_unittest.cc23
-rw-r--r--chromium/extensions/browser/api/declarative/rules_cache_delegate.cc4
-rw-r--r--chromium/extensions/browser/api/declarative/rules_cache_delegate.h6
-rw-r--r--chromium/extensions/browser/api/declarative/rules_registry.cc11
-rw-r--r--chromium/extensions/browser/api/declarative/rules_registry.h4
-rw-r--r--chromium/extensions/browser/api/declarative/rules_registry_service.cc8
-rw-r--r--chromium/extensions/browser/api/declarative/rules_registry_service.h2
-rw-r--r--chromium/extensions/browser/api/declarative/rules_registry_unittest.cc10
-rw-r--r--chromium/extensions/browser/api/declarative_webrequest/webrequest_action.cc16
-rw-r--r--chromium/extensions/browser/api/declarative_webrequest/webrequest_action.h7
-rw-r--r--chromium/extensions/browser/api/declarative_webrequest/webrequest_condition.cc19
-rw-r--r--chromium/extensions/browser/api/declarative_webrequest/webrequest_condition.h2
-rw-r--r--chromium/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.cc80
-rw-r--r--chromium/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.h12
-rw-r--r--chromium/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc30
-rw-r--r--chromium/extensions/browser/api/declarative_webrequest/webrequest_condition_unittest.cc90
-rw-r--r--chromium/extensions/browser/api/declarative_webrequest/webrequest_rules_registry.cc2
-rw-r--r--chromium/extensions/browser/api/declarative_webrequest/webrequest_rules_registry.h2
-rw-r--r--chromium/extensions/browser/api/device_permissions_manager.cc6
-rw-r--r--chromium/extensions/browser/api/device_permissions_manager.h4
-rw-r--r--chromium/extensions/browser/api/device_permissions_prompt.cc6
-rw-r--r--chromium/extensions/browser/api/device_permissions_prompt.h6
-rw-r--r--chromium/extensions/browser/api/diagnostics/diagnostics_api.h4
-rw-r--r--chromium/extensions/browser/api/diagnostics/diagnostics_api_chromeos.cc2
-rw-r--r--chromium/extensions/browser/api/display_source/display_source_api.cc6
-rw-r--r--chromium/extensions/browser/api/display_source/display_source_apitest.cc95
-rw-r--r--chromium/extensions/browser/api/display_source/display_source_apitestbase.cc533
-rw-r--r--chromium/extensions/browser/api/display_source/display_source_apitestbase.h26
-rw-r--r--chromium/extensions/browser/api/display_source/display_source_connection_delegate.h8
-rw-r--r--chromium/extensions/browser/api/display_source/display_source_connection_delegate_factory.h3
-rw-r--r--chromium/extensions/browser/api/display_source/display_source_event_router.cc4
-rw-r--r--chromium/extensions/browser/api/display_source/wifi_display/wifi_display_media_service_impl.cc134
-rw-r--r--chromium/extensions/browser/api/display_source/wifi_display/wifi_display_media_service_impl.h47
-rw-r--r--chromium/extensions/browser/api/display_source/wifi_display/wifi_display_session_service_impl.cc5
-rw-r--r--chromium/extensions/browser/api/dns/dns_api.cc4
-rw-r--r--chromium/extensions/browser/api/dns/dns_api.h4
-rw-r--r--chromium/extensions/browser/api/dns/dns_apitest.cc7
-rw-r--r--chromium/extensions/browser/api/document_scan/document_scan_api.h6
-rw-r--r--chromium/extensions/browser/api/document_scan/document_scan_api_unittest.cc2
-rw-r--r--chromium/extensions/browser/api/document_scan/document_scan_interface.h2
-rw-r--r--chromium/extensions/browser/api/document_scan/document_scan_interface_chromeos_unittest.cc2
-rw-r--r--chromium/extensions/browser/api/execute_code_function.cc2
-rw-r--r--chromium/extensions/browser/api/execute_code_function.h2
-rw-r--r--chromium/extensions/browser/api/extensions_api_client.cc13
-rw-r--r--chromium/extensions/browser/api/extensions_api_client.h16
-rw-r--r--chromium/extensions/browser/api/guest_view/app_view/app_view_guest_internal_api.cc4
-rw-r--r--chromium/extensions/browser/api/guest_view/extension_view/extension_view_internal_api.cc6
-rw-r--r--chromium/extensions/browser/api/guest_view/guest_view_internal_api.cc7
-rw-r--r--chromium/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc38
-rw-r--r--chromium/extensions/browser/api/guest_view/web_view/web_view_internal_api.h2
-rw-r--r--chromium/extensions/browser/api/hid/hid_api.cc10
-rw-r--r--chromium/extensions/browser/api/hid/hid_api.h15
-rw-r--r--chromium/extensions/browser/api/hid/hid_apitest.cc9
-rw-r--r--chromium/extensions/browser/api/hid/hid_device_manager.cc33
-rw-r--r--chromium/extensions/browser/api/hid/hid_device_manager.h12
-rw-r--r--chromium/extensions/browser/api/idle/idle_api_unittest.cc36
-rw-r--r--chromium/extensions/browser/api/idle/idle_manager.cc12
-rw-r--r--chromium/extensions/browser/api/idle/idle_manager.h9
-rw-r--r--chromium/extensions/browser/api/management/management_api.cc28
-rw-r--r--chromium/extensions/browser/api/management/management_api.h16
-rw-r--r--chromium/extensions/browser/api/management/management_api_delegate.h10
-rw-r--r--chromium/extensions/browser/api/messaging/native_message_host.h4
-rw-r--r--chromium/extensions/browser/api/messaging/native_messaging_channel.h7
-rw-r--r--chromium/extensions/browser/api/mime_handler_private/mime_handler_private_unittest.cc11
-rw-r--r--chromium/extensions/browser/api/networking_config/networking_config_api.h5
-rw-r--r--chromium/extensions/browser/api/networking_config/networking_config_service.cc23
-rw-r--r--chromium/extensions/browser/api/networking_config/networking_config_service.h10
-rw-r--r--chromium/extensions/browser/api/networking_config/networking_config_service_chromeos_unittest.cc17
-rw-r--r--chromium/extensions/browser/api/networking_config/networking_config_service_factory.cc3
-rw-r--r--chromium/extensions/browser/api/networking_private/networking_private_api.cc64
-rw-r--r--chromium/extensions/browser/api/networking_private/networking_private_api.h12
-rw-r--r--chromium/extensions/browser/api/networking_private/networking_private_chromeos.cc26
-rw-r--r--chromium/extensions/browser/api/networking_private/networking_private_chromeos.h23
-rw-r--r--chromium/extensions/browser/api/networking_private/networking_private_delegate.cc2
-rw-r--r--chromium/extensions/browser/api/networking_private/networking_private_delegate.h27
-rw-r--r--chromium/extensions/browser/api/networking_private/networking_private_delegate_factory.cc11
-rw-r--r--chromium/extensions/browser/api/networking_private/networking_private_delegate_factory.h15
-rw-r--r--chromium/extensions/browser/api/networking_private/networking_private_event_router_chromeos.cc16
-rw-r--r--chromium/extensions/browser/api/networking_private/networking_private_event_router_nonchromeos.cc8
-rw-r--r--chromium/extensions/browser/api/networking_private/networking_private_linux.cc100
-rw-r--r--chromium/extensions/browser/api/networking_private/networking_private_linux.h39
-rw-r--r--chromium/extensions/browser/api/networking_private/networking_private_service_client.cc35
-rw-r--r--chromium/extensions/browser/api/networking_private/networking_private_service_client.h21
-rw-r--r--chromium/extensions/browser/api/power/power_api.cc4
-rw-r--r--chromium/extensions/browser/api/power/power_api.h9
-rw-r--r--chromium/extensions/browser/api/power/power_api_unittest.cc14
-rw-r--r--chromium/extensions/browser/api/printer_provider/printer_provider_api.cc23
-rw-r--r--chromium/extensions/browser/api/printer_provider/printer_provider_apitest.cc17
-rw-r--r--chromium/extensions/browser/api/printer_provider_internal/printer_provider_internal_api.cc14
-rw-r--r--chromium/extensions/browser/api/printer_provider_internal/printer_provider_internal_api.h2
-rw-r--r--chromium/extensions/browser/api/runtime/runtime_api.cc44
-rw-r--r--chromium/extensions/browser/api/runtime/runtime_api.h2
-rw-r--r--chromium/extensions/browser/api/runtime/runtime_apitest.cc2
-rw-r--r--chromium/extensions/browser/api/serial/serial_api.cc4
-rw-r--r--chromium/extensions/browser/api/serial/serial_api.h22
-rw-r--r--chromium/extensions/browser/api/serial/serial_apitest.cc2
-rw-r--r--chromium/extensions/browser/api/serial/serial_connection.cc5
-rw-r--r--chromium/extensions/browser/api/serial/serial_connection.h4
-rw-r--r--chromium/extensions/browser/api/serial/serial_event_dispatcher.cc21
-rw-r--r--chromium/extensions/browser/api/serial/serial_event_dispatcher.h4
-rw-r--r--chromium/extensions/browser/api/socket/app_firewall_hole_manager.cc6
-rw-r--r--chromium/extensions/browser/api/socket/app_firewall_hole_manager.h11
-rw-r--r--chromium/extensions/browser/api/socket/socket.h6
-rw-r--r--chromium/extensions/browser/api/socket/socket_api.cc19
-rw-r--r--chromium/extensions/browser/api/socket/socket_api.h40
-rw-r--r--chromium/extensions/browser/api/socket/socket_apitest.cc6
-rw-r--r--chromium/extensions/browser/api/socket/tcp_socket.cc15
-rw-r--r--chromium/extensions/browser/api/socket/tcp_socket.h16
-rw-r--r--chromium/extensions/browser/api/socket/tls_socket.cc16
-rw-r--r--chromium/extensions/browser/api/socket/tls_socket.h6
-rw-r--r--chromium/extensions/browser/api/sockets_tcp/sockets_tcp_api.cc14
-rw-r--r--chromium/extensions/browser/api/sockets_tcp/sockets_tcp_api.h28
-rw-r--r--chromium/extensions/browser/api/sockets_tcp/sockets_tcp_api_unittest.cc13
-rw-r--r--chromium/extensions/browser/api/sockets_tcp/sockets_tcp_apitest.cc14
-rw-r--r--chromium/extensions/browser/api/sockets_tcp/tcp_socket_event_dispatcher.cc20
-rw-r--r--chromium/extensions/browser/api/sockets_tcp/tcp_socket_event_dispatcher.h4
-rw-r--r--chromium/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.cc4
-rw-r--r--chromium/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.h16
-rw-r--r--chromium/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_apitest.cc4
-rw-r--r--chromium/extensions/browser/api/sockets_tcp_server/tcp_server_socket_event_dispatcher.cc18
-rw-r--r--chromium/extensions/browser/api/sockets_tcp_server/tcp_server_socket_event_dispatcher.h7
-rw-r--r--chromium/extensions/browser/api/sockets_udp/sockets_udp_api.cc8
-rw-r--r--chromium/extensions/browser/api/sockets_udp/sockets_udp_api.h30
-rw-r--r--chromium/extensions/browser/api/sockets_udp/sockets_udp_api_unittest.cc13
-rw-r--r--chromium/extensions/browser/api/sockets_udp/sockets_udp_apitest.cc10
-rw-r--r--chromium/extensions/browser/api/sockets_udp/udp_socket_event_dispatcher.cc20
-rw-r--r--chromium/extensions/browser/api/sockets_udp/udp_socket_event_dispatcher.h5
-rw-r--r--chromium/extensions/browser/api/storage/local_value_store_cache.cc2
-rw-r--r--chromium/extensions/browser/api/storage/local_value_store_cache.h3
-rw-r--r--chromium/extensions/browser/api/storage/settings_quota_unittest.cc8
-rw-r--r--chromium/extensions/browser/api/storage/settings_storage_quota_enforcer.cc5
-rw-r--r--chromium/extensions/browser/api/storage/settings_storage_quota_enforcer.h6
-rw-r--r--chromium/extensions/browser/api/storage/settings_test_util.cc10
-rw-r--r--chromium/extensions/browser/api/storage/settings_test_util.h6
-rw-r--r--chromium/extensions/browser/api/storage/storage_api.cc3
-rw-r--r--chromium/extensions/browser/api/storage/storage_api_unittest.cc16
-rw-r--r--chromium/extensions/browser/api/storage/storage_frontend.cc13
-rw-r--r--chromium/extensions/browser/api/storage/storage_frontend.h6
-rw-r--r--chromium/extensions/browser/api/storage/storage_frontend_unittest.cc12
-rw-r--r--chromium/extensions/browser/api/system_cpu/cpu_info_provider_win.cc5
-rw-r--r--chromium/extensions/browser/api/system_display/display_info_provider.cc26
-rw-r--r--chromium/extensions/browser/api/system_display/display_info_provider.h12
-rw-r--r--chromium/extensions/browser/api/system_display/system_display_api.cc17
-rw-r--r--chromium/extensions/browser/api/system_display/system_display_apitest.cc109
-rw-r--r--chromium/extensions/browser/api/system_info/system_info_api.cc41
-rw-r--r--chromium/extensions/browser/api/system_memory/system_memory_apitest.cc2
-rw-r--r--chromium/extensions/browser/api/system_network/system_network_api.cc2
-rw-r--r--chromium/extensions/browser/api/system_network/system_network_apitest.cc2
-rw-r--r--chromium/extensions/browser/api/system_storage/system_storage_api.cc5
-rw-r--r--chromium/extensions/browser/api/system_storage/system_storage_apitest.cc2
-rw-r--r--chromium/extensions/browser/api/usb/usb_api.cc77
-rw-r--r--chromium/extensions/browser/api/usb/usb_api.h8
-rw-r--r--chromium/extensions/browser/api/usb/usb_apitest.cc16
-rw-r--r--chromium/extensions/browser/api/usb/usb_event_router.cc2
-rw-r--r--chromium/extensions/browser/api/virtual_keyboard_private/virtual_keyboard_private_api.cc4
-rw-r--r--chromium/extensions/browser/api/virtual_keyboard_private/virtual_keyboard_private_api.h2
-rw-r--r--chromium/extensions/browser/api/vpn_provider/vpn_provider_api.cc12
-rw-r--r--chromium/extensions/browser/api/vpn_provider/vpn_service.cc20
-rw-r--r--chromium/extensions/browser/api/vpn_provider/vpn_service.h13
-rw-r--r--chromium/extensions/browser/api/web_contents_capture_client.cc6
-rw-r--r--chromium/extensions/browser/api/web_request/form_data_parser.cc15
-rw-r--r--chromium/extensions/browser/api/web_request/form_data_parser.h6
-rw-r--r--chromium/extensions/browser/api/web_request/form_data_parser_unittest.cc11
-rw-r--r--chromium/extensions/browser/api/web_request/upload_data_presenter.cc9
-rw-r--r--chromium/extensions/browser/api/web_request/upload_data_presenter.h16
-rw-r--r--chromium/extensions/browser/api/web_request/upload_data_presenter_unittest.cc14
-rw-r--r--chromium/extensions/browser/api/web_request/web_request_api.cc78
-rw-r--r--chromium/extensions/browser/api/web_request/web_request_api.h33
-rw-r--r--chromium/extensions/browser/api/web_request/web_request_api_helpers.cc6
-rw-r--r--chromium/extensions/browser/api/web_request/web_request_api_helpers.h45
-rw-r--r--chromium/extensions/browser/api/web_request/web_request_event_details.cc15
-rw-r--r--chromium/extensions/browser/api/web_request/web_request_event_details.h17
-rw-r--r--chromium/extensions/browser/api/web_request/web_request_event_router_delegate.h16
-rw-r--r--chromium/extensions/browser/api/web_request/web_request_time_tracker.h4
-rw-r--r--chromium/extensions/browser/api/webcam_private/visca_webcam.cc2
-rw-r--r--chromium/extensions/browser/api/webcam_private/visca_webcam.h4
-rw-r--r--chromium/extensions/browser/api/webcam_private/visca_webcam_unittest.cc6
-rw-r--r--chromium/extensions/browser/api/webcam_private/webcam_private_api.h4
-rw-r--r--chromium/extensions/browser/api/webcam_private/webcam_private_api_chromeos.cc19
-rw-r--r--chromium/extensions/browser/api_activity_monitor.h11
-rw-r--r--chromium/extensions/browser/api_test_utils.cc75
-rw-r--r--chromium/extensions/browser/api_test_utils.h16
-rw-r--r--chromium/extensions/browser/api_unittest.cc22
-rw-r--r--chromium/extensions/browser/api_unittest.h15
-rw-r--r--chromium/extensions/browser/app_window/app_window.cc24
-rw-r--r--chromium/extensions/browser/app_window/app_window.h17
-rw-r--r--chromium/extensions/browser/app_window/app_window_contents.h5
-rw-r--r--chromium/extensions/browser/app_window/app_window_geometry_cache.cc2
-rw-r--r--chromium/extensions/browser/app_window/app_window_geometry_cache.h2
-rw-r--r--chromium/extensions/browser/app_window/app_window_geometry_cache_unittest.cc12
-rw-r--r--chromium/extensions/browser/app_window/native_app_window.h4
-rw-r--r--chromium/extensions/browser/app_window/test_app_window_contents.h2
-rw-r--r--chromium/extensions/browser/blob_holder.cc2
-rw-r--r--chromium/extensions/browser/blob_holder.h4
-rw-r--r--chromium/extensions/browser/computed_hashes.cc4
-rw-r--r--chromium/extensions/browser/computed_hashes.h4
-rw-r--r--chromium/extensions/browser/content_hash_fetcher.cc15
-rw-r--r--chromium/extensions/browser/content_hash_reader.h4
-rw-r--r--chromium/extensions/browser/content_hash_tree.cc5
-rw-r--r--chromium/extensions/browser/content_hash_tree_unittest.cc8
-rw-r--r--chromium/extensions/browser/content_verifier.cc6
-rw-r--r--chromium/extensions/browser/content_verifier.h6
-rw-r--r--chromium/extensions/browser/content_verifier_io_data.cc4
-rw-r--r--chromium/extensions/browser/content_verifier_io_data.h9
-rw-r--r--chromium/extensions/browser/content_verify_job.h4
-rw-r--r--chromium/extensions/browser/declarative_user_script_master.h4
-rw-r--r--chromium/extensions/browser/error_map.cc7
-rw-r--r--chromium/extensions/browser/error_map.h4
-rw-r--r--chromium/extensions/browser/error_map_unittest.cc4
-rw-r--r--chromium/extensions/browser/event_listener_map.cc44
-rw-r--r--chromium/extensions/browser/event_listener_map.h20
-rw-r--r--chromium/extensions/browser/event_listener_map_unittest.cc116
-rw-r--r--chromium/extensions/browser/event_router.cc67
-rw-r--r--chromium/extensions/browser/event_router.h20
-rw-r--r--chromium/extensions/browser/event_router_unittest.cc30
-rw-r--r--chromium/extensions/browser/extension_error_test_util.cc24
-rw-r--r--chromium/extensions/browser/extension_error_test_util.h11
-rw-r--r--chromium/extensions/browser/extension_event_histogram_value.h7
-rw-r--r--chromium/extensions/browser/extension_function.cc37
-rw-r--r--chromium/extensions/browser/extension_function.h28
-rw-r--r--chromium/extensions/browser/extension_function_dispatcher.cc29
-rw-r--r--chromium/extensions/browser/extension_function_histogram_value.h15
-rw-r--r--chromium/extensions/browser/extension_host.h8
-rw-r--r--chromium/extensions/browser/extension_icon_image_unittest.cc27
-rw-r--r--chromium/extensions/browser/extension_message_filter.h3
-rw-r--r--chromium/extensions/browser/extension_pref_value_map.cc5
-rw-r--r--chromium/extensions/browser/extension_pref_value_map.h5
-rw-r--r--chromium/extensions/browser/extension_pref_value_map_unittest.cc6
-rw-r--r--chromium/extensions/browser/extension_prefs.cc82
-rw-r--r--chromium/extensions/browser/extension_prefs.h29
-rw-r--r--chromium/extensions/browser/extension_prefs_factory.cc2
-rw-r--r--chromium/extensions/browser/extension_prefs_factory.h5
-rw-r--r--chromium/extensions/browser/extension_protocols.cc7
-rw-r--r--chromium/extensions/browser/extension_protocols.h4
-rw-r--r--chromium/extensions/browser/extension_registry.cc8
-rw-r--r--chromium/extensions/browser/extension_registry.h4
-rw-r--r--chromium/extensions/browser/extension_system.h2
-rw-r--r--chromium/extensions/browser/extension_throttle_entry.cc4
-rw-r--r--chromium/extensions/browser/extension_throttle_manager.cc7
-rw-r--r--chromium/extensions/browser/extension_throttle_manager.h9
-rw-r--r--chromium/extensions/browser/extension_throttle_simulation_unittest.cc15
-rw-r--r--chromium/extensions/browser/extension_throttle_unittest.cc7
-rw-r--r--chromium/extensions/browser/extension_user_script_loader.cc8
-rw-r--r--chromium/extensions/browser/extension_user_script_loader.h2
-rw-r--r--chromium/extensions/browser/extension_web_contents_observer.h18
-rw-r--r--chromium/extensions/browser/extension_zoom_request_client.cc8
-rw-r--r--chromium/extensions/browser/extension_zoom_request_client.h3
-rw-r--r--chromium/extensions/browser/extensions_browser_client.cc5
-rw-r--r--chromium/extensions/browser/extensions_browser_client.h15
-rw-r--r--chromium/extensions/browser/extensions_test.cc2
-rw-r--r--chromium/extensions/browser/extensions_test.h13
-rw-r--r--chromium/extensions/browser/external_install_info.cc4
-rw-r--r--chromium/extensions/browser/external_install_info.h8
-rw-r--r--chromium/extensions/browser/external_provider_interface.h2
-rw-r--r--chromium/extensions/browser/guest_view/app_view/app_view_apitest.cc25
-rw-r--r--chromium/extensions/browser/guest_view/app_view/app_view_guest.cc20
-rw-r--r--chromium/extensions/browser/guest_view/app_view/app_view_guest.h6
-rw-r--r--chromium/extensions/browser/guest_view/extension_options/extension_options_guest.cc11
-rw-r--r--chromium/extensions/browser/guest_view/extension_options/extension_options_guest.h2
-rw-r--r--chromium/extensions/browser/guest_view/extension_view/extension_view_guest.cc5
-rw-r--r--chromium/extensions/browser/guest_view/extensions_guest_view_manager_delegate.cc7
-rw-r--r--chromium/extensions/browser/guest_view/extensions_guest_view_manager_delegate.h2
-rw-r--r--chromium/extensions/browser/guest_view/mime_handler_view/mime_handler_stream_manager.cc16
-rw-r--r--chromium/extensions/browser/guest_view/mime_handler_view/mime_handler_stream_manager.h4
-rw-r--r--chromium/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc2
-rw-r--r--chromium/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h8
-rw-r--r--chromium/extensions/browser/guest_view/mime_handler_view/test_mime_handler_view_guest.cc4
-rw-r--r--chromium/extensions/browser/guest_view/mime_handler_view/test_mime_handler_view_guest.h2
-rw-r--r--chromium/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.cc5
-rw-r--r--chromium/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h5
-rw-r--r--chromium/extensions/browser/guest_view/web_view/web_view_apitest.cc24
-rw-r--r--chromium/extensions/browser/guest_view/web_view/web_view_find_helper.cc9
-rw-r--r--chromium/extensions/browser/guest_view/web_view/web_view_find_helper.h4
-rw-r--r--chromium/extensions/browser/guest_view/web_view/web_view_guest.cc69
-rw-r--r--chromium/extensions/browser/guest_view/web_view/web_view_guest.h8
-rw-r--r--chromium/extensions/browser/guest_view/web_view/web_view_media_access_apitest.cc10
-rw-r--r--chromium/extensions/browser/guest_view/web_view/web_view_permission_helper.cc13
-rw-r--r--chromium/extensions/browser/guest_view/web_view/web_view_permission_helper.h2
-rw-r--r--chromium/extensions/browser/image_loader_unittest.cc7
-rw-r--r--chromium/extensions/browser/info_map.h4
-rw-r--r--chromium/extensions/browser/lazy_background_task_queue_unittest.cc11
-rw-r--r--chromium/extensions/browser/load_monitoring_extension_host_queue.cc4
-rw-r--r--chromium/extensions/browser/load_monitoring_extension_host_queue.h8
-rw-r--r--chromium/extensions/browser/load_monitoring_extension_host_queue_unittest.cc12
-rw-r--r--chromium/extensions/browser/mock_extension_system.cc4
-rw-r--r--chromium/extensions/browser/mock_extension_system.h2
-rw-r--r--chromium/extensions/browser/mojo/DEPS3
-rw-r--r--chromium/extensions/browser/mojo/keep_alive_impl_unittest.cc4
-rw-r--r--chromium/extensions/browser/mojo/service_registration.cc3
-rw-r--r--chromium/extensions/browser/mojo/stash_backend.cc12
-rw-r--r--chromium/extensions/browser/mojo/stash_backend.h2
-rw-r--r--chromium/extensions/browser/mojo/stash_backend_unittest.cc6
-rw-r--r--chromium/extensions/browser/process_manager_unittest.cc23
-rw-r--r--chromium/extensions/browser/quota_service.h4
-rw-r--r--chromium/extensions/browser/quota_service_unittest.cc3
-rw-r--r--chromium/extensions/browser/sandboxed_unpacker.cc4
-rw-r--r--chromium/extensions/browser/sandboxed_unpacker_unittest.cc6
-rw-r--r--chromium/extensions/browser/state_store.cc2
-rw-r--r--chromium/extensions/browser/state_store.h9
-rw-r--r--chromium/extensions/browser/test_extension_registry_observer.cc2
-rw-r--r--chromium/extensions/browser/test_extension_registry_observer.h12
-rw-r--r--chromium/extensions/browser/test_extensions_browser_client.cc10
-rw-r--r--chromium/extensions/browser/test_extensions_browser_client.h15
-rw-r--r--chromium/extensions/browser/updater/extension_downloader.cc112
-rw-r--r--chromium/extensions/browser/updater/extension_downloader.h44
-rw-r--r--chromium/extensions/browser/updater/extension_downloader_test_delegate.h32
-rw-r--r--chromium/extensions/browser/updater/request_queue.h14
-rw-r--r--chromium/extensions/browser/updater/request_queue_impl.h11
-rw-r--r--chromium/extensions/browser/updater/safe_manifest_parser.h2
-rw-r--r--chromium/extensions/browser/updater/update_service.h2
-rw-r--r--chromium/extensions/browser/updater/update_service_unittest.cc4
-rw-r--r--chromium/extensions/browser/user_script_loader.cc17
-rw-r--r--chromium/extensions/browser/user_script_loader.h18
-rw-r--r--chromium/extensions/browser/value_store/lazy_leveldb.cc10
-rw-r--r--chromium/extensions/browser/value_store/lazy_leveldb.h11
-rw-r--r--chromium/extensions/browser/value_store/legacy_value_store_factory.cc13
-rw-r--r--chromium/extensions/browser/value_store/legacy_value_store_factory.h12
-rw-r--r--chromium/extensions/browser/value_store/leveldb_scoped_database.cc13
-rw-r--r--chromium/extensions/browser/value_store/leveldb_scoped_database.h2
-rw-r--r--chromium/extensions/browser/value_store/leveldb_scoped_database_unittest.cc6
-rw-r--r--chromium/extensions/browser/value_store/leveldb_value_store.cc33
-rw-r--r--chromium/extensions/browser/value_store/leveldb_value_store.h2
-rw-r--r--chromium/extensions/browser/value_store/leveldb_value_store_unittest.cc8
-rw-r--r--chromium/extensions/browser/value_store/test_value_store_factory.cc11
-rw-r--r--chromium/extensions/browser/value_store/test_value_store_factory.h8
-rw-r--r--chromium/extensions/browser/value_store/testing_value_store.cc27
-rw-r--r--chromium/extensions/browser/value_store/value_store.cc4
-rw-r--r--chromium/extensions/browser/value_store/value_store.h24
-rw-r--r--chromium/extensions/browser/value_store/value_store_change.cc19
-rw-r--r--chromium/extensions/browser/value_store/value_store_change.h17
-rw-r--r--chromium/extensions/browser/value_store/value_store_change_unittest.cc41
-rw-r--r--chromium/extensions/browser/value_store/value_store_factory.h8
-rw-r--r--chromium/extensions/browser/value_store/value_store_factory_impl.cc6
-rw-r--r--chromium/extensions/browser/value_store/value_store_factory_impl.h8
-rw-r--r--chromium/extensions/browser/value_store/value_store_frontend.cc10
-rw-r--r--chromium/extensions/browser/value_store/value_store_frontend.h6
-rw-r--r--chromium/extensions/browser/value_store/value_store_frontend_unittest.cc20
-rw-r--r--chromium/extensions/browser/value_store/value_store_unittest.cc121
-rw-r--r--chromium/extensions/browser/value_store/value_store_unittest.h21
-rw-r--r--chromium/extensions/browser/verified_contents.cc4
-rw-r--r--chromium/extensions/browser/web_ui_user_script_loader.cc8
-rw-r--r--chromium/extensions/browser/web_ui_user_script_loader.h8
-rw-r--r--chromium/extensions/common/BUILD.gn3
-rw-r--r--chromium/extensions/common/api/_api_features.json38
-rw-r--r--chromium/extensions/common/api/_manifest_features.json4
-rw-r--r--chromium/extensions/common/api/_permission_features.json6
-rw-r--r--chromium/extensions/common/api/bluetooth/bluetooth_manifest_data.cc10
-rw-r--r--chromium/extensions/common/api/bluetooth/bluetooth_manifest_data.h9
-rw-r--r--chromium/extensions/common/api/bluetooth/bluetooth_manifest_handler.cc2
-rw-r--r--chromium/extensions/common/api/bluetooth/bluetooth_manifest_permission.cc29
-rw-r--r--chromium/extensions/common/api/bluetooth/bluetooth_manifest_permission.h4
-rw-r--r--chromium/extensions/common/api/declarative/declarative_manifest_data.cc19
-rw-r--r--chromium/extensions/common/api/declarative/declarative_manifest_data.h5
-rw-r--r--chromium/extensions/common/api/declarative/declarative_manifest_handler.cc2
-rw-r--r--chromium/extensions/common/api/declarative/declarative_manifest_unittest.cc18
-rw-r--r--chromium/extensions/common/api/externs_checker.py3
-rwxr-xr-xchromium/extensions/common/api/externs_checker_test.py4
-rw-r--r--chromium/extensions/common/api/printer_provider/usb_printer_manifest_data.cc6
-rw-r--r--chromium/extensions/common/api/printer_provider/usb_printer_manifest_data.h5
-rw-r--r--chromium/extensions/common/api/printer_provider/usb_printer_manifest_handler.cc2
-rw-r--r--chromium/extensions/common/api/runtime.json57
-rw-r--r--chromium/extensions/common/api/sockets/sockets_manifest_data.cc10
-rw-r--r--chromium/extensions/common/api/sockets/sockets_manifest_data.h9
-rw-r--r--chromium/extensions/common/api/sockets/sockets_manifest_handler.cc2
-rw-r--r--chromium/extensions/common/api/sockets/sockets_manifest_permission.cc41
-rw-r--r--chromium/extensions/common/api/sockets/sockets_manifest_permission.h4
-rw-r--r--chromium/extensions/common/api/sockets/sockets_manifest_permission_unittest.cc90
-rw-r--r--chromium/extensions/common/api/system_display.idl54
-rw-r--r--chromium/extensions/common/cast/cast_cert_validator.cc383
-rw-r--r--chromium/extensions/common/cast/cast_cert_validator.h94
-rw-r--r--chromium/extensions/common/cast/cast_cert_validator_unittest.cc522
-rw-r--r--chromium/extensions/common/event_filter.cc8
-rw-r--r--chromium/extensions/common/event_filter.h6
-rw-r--r--chromium/extensions/common/event_filter_unittest.cc49
-rw-r--r--chromium/extensions/common/event_filtering_info.cc4
-rw-r--r--chromium/extensions/common/event_filtering_info.h5
-rw-r--r--chromium/extensions/common/event_matcher.cc2
-rw-r--r--chromium/extensions/common/event_matcher.h8
-rw-r--r--chromium/extensions/common/extension.cc9
-rw-r--r--chromium/extensions/common/extension.h16
-rw-r--r--chromium/extensions/common/extension_api.cc22
-rw-r--r--chromium/extensions/common/extension_api.h2
-rw-r--r--chromium/extensions/common/extension_builder.cc4
-rw-r--r--chromium/extensions/common/extension_builder.h10
-rw-r--r--chromium/extensions/common/extension_l10n_util.cc13
-rw-r--r--chromium/extensions/common/extension_l10n_util_unittest.cc36
-rw-r--r--chromium/extensions/common/extension_message_generator.cc6
-rw-r--r--chromium/extensions/common/extension_messages.cc65
-rw-r--r--chromium/extensions/common/extension_messages.h12
-rw-r--r--chromium/extensions/common/extension_set_unittest.cc8
-rw-r--r--chromium/extensions/common/extensions_client.h8
-rw-r--r--chromium/extensions/common/feature_switch.cc81
-rw-r--r--chromium/extensions/common/feature_switch.h15
-rw-r--r--chromium/extensions/common/features/base_feature_provider.cc8
-rw-r--r--chromium/extensions/common/features/base_feature_provider.h4
-rw-r--r--chromium/extensions/common/features/behavior_feature.cc2
-rw-r--r--chromium/extensions/common/features/behavior_feature.h1
-rw-r--r--chromium/extensions/common/features/complex_feature.cc2
-rw-r--r--chromium/extensions/common/features/complex_feature.h6
-rw-r--r--chromium/extensions/common/features/complex_feature_unittest.cc18
-rw-r--r--chromium/extensions/common/features/feature_provider.cc13
-rw-r--r--chromium/extensions/common/features/feature_provider.h6
-rw-r--r--chromium/extensions/common/features/json_feature_provider_source.cc5
-rw-r--r--chromium/extensions/common/features/simple_feature.cc2
-rw-r--r--chromium/extensions/common/features/simple_feature.h6
-rw-r--r--chromium/extensions/common/features/simple_feature_unittest.cc65
-rw-r--r--chromium/extensions/common/file_util.cc16
-rw-r--r--chromium/extensions/common/file_util.h4
-rw-r--r--chromium/extensions/common/file_util_unittest.cc4
-rw-r--r--chromium/extensions/common/manifest.cc5
-rw-r--r--chromium/extensions/common/manifest.h6
-rw-r--r--chromium/extensions/common/manifest_constants.cc1
-rw-r--r--chromium/extensions/common/manifest_constants.h1
-rw-r--r--chromium/extensions/common/manifest_handler_helpers.h2
-rw-r--r--chromium/extensions/common/manifest_handler_unittest.cc17
-rw-r--r--chromium/extensions/common/manifest_handlers/app_isolation_info.cc3
-rw-r--r--chromium/extensions/common/manifest_handlers/background_info.cc5
-rw-r--r--chromium/extensions/common/manifest_handlers/content_capabilities_handler.cc9
-rw-r--r--chromium/extensions/common/manifest_handlers/csp_info.cc3
-rw-r--r--chromium/extensions/common/manifest_handlers/default_locale_handler.cc5
-rw-r--r--chromium/extensions/common/manifest_handlers/externally_connectable.cc18
-rw-r--r--chromium/extensions/common/manifest_handlers/externally_connectable.h4
-rw-r--r--chromium/extensions/common/manifest_handlers/file_handler_info.cc5
-rw-r--r--chromium/extensions/common/manifest_handlers/icons_handler.cc5
-rw-r--r--chromium/extensions/common/manifest_handlers/icons_handler_unittest.cc31
-rw-r--r--chromium/extensions/common/manifest_handlers/incognito_info.cc3
-rw-r--r--chromium/extensions/common/manifest_handlers/kiosk_mode_info.cc5
-rw-r--r--chromium/extensions/common/manifest_handlers/launcher_page_info.cc2
-rw-r--r--chromium/extensions/common/manifest_handlers/mime_types_handler.cc2
-rw-r--r--chromium/extensions/common/manifest_handlers/nacl_modules_handler.cc5
-rw-r--r--chromium/extensions/common/manifest_handlers/oauth2_manifest_handler.cc5
-rw-r--r--chromium/extensions/common/manifest_handlers/oauth2_manifest_unittest.cc51
-rw-r--r--chromium/extensions/common/manifest_handlers/offline_enabled_info.cc3
-rw-r--r--chromium/extensions/common/manifest_handlers/options_page_info.cc21
-rw-r--r--chromium/extensions/common/manifest_handlers/options_page_info.h2
-rw-r--r--chromium/extensions/common/manifest_handlers/permissions_parser.cc10
-rw-r--r--chromium/extensions/common/manifest_handlers/permissions_parser.h7
-rw-r--r--chromium/extensions/common/manifest_handlers/requirements_info.cc5
-rw-r--r--chromium/extensions/common/manifest_handlers/requirements_info.h2
-rw-r--r--chromium/extensions/common/manifest_handlers/sandboxed_page_info.cc5
-rw-r--r--chromium/extensions/common/manifest_handlers/shared_module_info.cc5
-rw-r--r--chromium/extensions/common/manifest_handlers/web_accessible_resources_info.cc6
-rw-r--r--chromium/extensions/common/manifest_handlers/webview_info.cc8
-rw-r--r--chromium/extensions/common/manifest_handlers/webview_info.h6
-rw-r--r--chromium/extensions/common/manifest_test.cc13
-rw-r--r--chromium/extensions/common/manifest_test.h14
-rw-r--r--chromium/extensions/common/manifest_url_handlers.cc9
-rw-r--r--chromium/extensions/common/message_bundle.cc4
-rw-r--r--chromium/extensions/common/message_bundle_unittest.cc4
-rw-r--r--chromium/extensions/common/mojo/wifi_display_session_service.mojom12
-rw-r--r--chromium/extensions/common/one_shot_event.cc14
-rw-r--r--chromium/extensions/common/permissions/api_permission.cc6
-rw-r--r--chromium/extensions/common/permissions/api_permission.h7
-rw-r--r--chromium/extensions/common/permissions/api_permission_set.cc2
-rw-r--r--chromium/extensions/common/permissions/api_permission_set_unittest.cc20
-rw-r--r--chromium/extensions/common/permissions/manifest_permission.cc9
-rw-r--r--chromium/extensions/common/permissions/manifest_permission.h7
-rw-r--r--chromium/extensions/common/permissions/manifest_permission_set.cc3
-rw-r--r--chromium/extensions/common/permissions/manifest_permission_set_unittest.cc2
-rw-r--r--chromium/extensions/common/permissions/media_galleries_permission.cc96
-rw-r--r--chromium/extensions/common/permissions/media_galleries_permission_data.cc4
-rw-r--r--chromium/extensions/common/permissions/media_galleries_permission_data.h4
-rw-r--r--chromium/extensions/common/permissions/permission_set.cc25
-rw-r--r--chromium/extensions/common/permissions/permission_set.h11
-rw-r--r--chromium/extensions/common/permissions/permissions_data.cc17
-rw-r--r--chromium/extensions/common/permissions/permissions_data.h16
-rw-r--r--chromium/extensions/common/permissions/set_disjunction_permission.h18
-rw-r--r--chromium/extensions/common/permissions/settings_override_permission.cc18
-rw-r--r--chromium/extensions/common/permissions/settings_override_permission.h3
-rw-r--r--chromium/extensions/common/permissions/socket_permission.cc2
-rw-r--r--chromium/extensions/common/permissions/socket_permission_data.cc6
-rw-r--r--chromium/extensions/common/permissions/socket_permission_data.h2
-rw-r--r--chromium/extensions/common/permissions/socket_permission_entry.cc2
-rw-r--r--chromium/extensions/common/permissions/socket_permission_unittest.cc22
-rw-r--r--chromium/extensions/common/permissions/usb_device_permission_data.cc6
-rw-r--r--chromium/extensions/common/permissions/usb_device_permission_data.h4
-rw-r--r--chromium/extensions/common/stack_frame.cc10
-rw-r--r--chromium/extensions/common/stack_frame.h4
-rw-r--r--chromium/extensions/common/stack_frame_unittest.cc7
-rw-r--r--chromium/extensions/common/switches.cc4
-rw-r--r--chromium/extensions/common/switches.h1
-rw-r--r--chromium/extensions/common/update_manifest.cc2
-rw-r--r--chromium/extensions/common/url_pattern_set.cc9
-rw-r--r--chromium/extensions/common/url_pattern_set.h6
-rw-r--r--chromium/extensions/common/url_pattern_set_unittest.cc4
-rw-r--r--chromium/extensions/common/url_pattern_unittest.cc6
-rw-r--r--chromium/extensions/common/user_script.h2
-rw-r--r--chromium/extensions/common/value_builder.cc7
-rw-r--r--chromium/extensions/common/value_builder.h16
-rw-r--r--chromium/extensions/common/value_builder_unittest.cc7
-rw-r--r--chromium/extensions/common/value_counter.cc8
-rw-r--r--chromium/extensions/common/value_counter.h4
-rw-r--r--chromium/extensions/components/javascript_dialog_extensions_client/javascript_dialog_extension_client_impl.cc3
-rw-r--r--chromium/extensions/components/native_app_window/native_app_window_views.cc2
-rw-r--r--chromium/extensions/components/native_app_window/native_app_window_views.h6
-rw-r--r--chromium/extensions/extensions.gyp16
-rw-r--r--chromium/extensions/extensions.gypi18
-rw-r--r--chromium/extensions/extensions_tests.gyp5
-rw-r--r--chromium/extensions/extensions_tests.gypi3
-rw-r--r--chromium/extensions/extensions_unittests.isolate1
-rw-r--r--chromium/extensions/renderer/BUILD.gn7
-rw-r--r--chromium/extensions/renderer/DEPS2
-rw-r--r--chromium/extensions/renderer/activity_log_converter_strategy.cc13
-rw-r--r--chromium/extensions/renderer/activity_log_converter_strategy_unittest.cc20
-rw-r--r--chromium/extensions/renderer/api/automation/automation_api_helper.cc5
-rw-r--r--chromium/extensions/renderer/api/display_source/OWNERS1
-rw-r--r--chromium/extensions/renderer/api/display_source/display_source_session.cc11
-rw-r--r--chromium/extensions/renderer/api/display_source/display_source_session.h8
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/DEPS7
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_audio_encoder.cc43
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_audio_encoder.h44
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_audio_encoder_lpcm.cc237
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_descriptor.cc7
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_descriptor.h21
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_descriptor_unittest.cc63
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_packetizer.cc23
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_packetizer.h2
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_encoder.cc44
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_encoder.h81
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.cc289
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.h44
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_packetizer.cc4
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_packetizer.h2
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_packetizer_unittest.cc70
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_pipeline.cc242
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_pipeline.h114
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_session.cc16
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_session.h11
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_transport_stream_packetizer.cc498
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_transport_stream_packetizer.h16
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_video_encoder.cc99
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_video_encoder.h111
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_video_encoder_svc.cc208
-rw-r--r--chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_video_encoder_vea.cc237
-rw-r--r--chromium/extensions/renderer/api/serial/data_receiver_unittest.cc2
-rw-r--r--chromium/extensions/renderer/api/serial/data_sender_unittest.cc4
-rw-r--r--chromium/extensions/renderer/api/serial/serial_api_unittest.cc12
-rw-r--r--chromium/extensions/renderer/api_activity_logger.cc4
-rw-r--r--chromium/extensions/renderer/api_definitions_natives.cc2
-rw-r--r--chromium/extensions/renderer/api_test_base.cc13
-rw-r--r--chromium/extensions/renderer/api_test_base.h4
-rw-r--r--chromium/extensions/renderer/app_window_custom_bindings.cc2
-rw-r--r--chromium/extensions/renderer/css_native_handler.cc2
-rw-r--r--chromium/extensions/renderer/dispatcher.cc130
-rw-r--r--chromium/extensions/renderer/dispatcher.h22
-rw-r--r--chromium/extensions/renderer/display_source_custom_bindings.cc14
-rw-r--r--chromium/extensions/renderer/display_source_custom_bindings.h5
-rw-r--r--chromium/extensions/renderer/event_bindings.cc24
-rw-r--r--chromium/extensions/renderer/event_bindings.h6
-rw-r--r--chromium/extensions/renderer/extension_injection_host.cc6
-rw-r--r--chromium/extensions/renderer/extension_injection_host.h2
-rw-r--r--chromium/extensions/renderer/extensions_render_frame_observer.cc3
-rw-r--r--chromium/extensions/renderer/gc_callback_unittest.cc2
-rw-r--r--chromium/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc12
-rw-r--r--chromium/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc2
-rw-r--r--chromium/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.h2
-rw-r--r--chromium/extensions/renderer/i18n_custom_bindings.cc24
-rw-r--r--chromium/extensions/renderer/json_schema_unittest.cc2
-rw-r--r--chromium/extensions/renderer/lazy_background_page_native_handler.cc4
-rw-r--r--chromium/extensions/renderer/messaging_bindings.cc7
-rw-r--r--chromium/extensions/renderer/module_system.cc15
-rw-r--r--chromium/extensions/renderer/module_system.h26
-rw-r--r--chromium/extensions/renderer/module_system_test.cc31
-rw-r--r--chromium/extensions/renderer/module_system_test.h10
-rw-r--r--chromium/extensions/renderer/module_system_unittest.cc16
-rw-r--r--chromium/extensions/renderer/mojo/stash_client_unittest.cc5
-rw-r--r--chromium/extensions/renderer/object_backed_native_handler.cc12
-rw-r--r--chromium/extensions/renderer/print_native_handler.cc32
-rw-r--r--chromium/extensions/renderer/print_native_handler.h21
-rw-r--r--chromium/extensions/renderer/programmatic_script_injector.cc2
-rw-r--r--chromium/extensions/renderer/programmatic_script_injector.h7
-rw-r--r--chromium/extensions/renderer/render_frame_observer_natives.cc2
-rw-r--r--chromium/extensions/renderer/request_sender.cc4
-rw-r--r--chromium/extensions/renderer/request_sender.h4
-rw-r--r--chromium/extensions/renderer/resource_bundle_source_map.cc32
-rw-r--r--chromium/extensions/renderer/resource_bundle_source_map.h11
-rw-r--r--chromium/extensions/renderer/resources/binding.js59
-rw-r--r--chromium/extensions/renderer/resources/context_menus_handlers.js5
-rw-r--r--chromium/extensions/renderer/resources/json_schema.js258
-rw-r--r--chromium/extensions/renderer/resources/last_error.js5
-rw-r--r--chromium/extensions/renderer/resources/media_router_bindings.js50
-rw-r--r--chromium/extensions/renderer/resources/runtime_custom_bindings.js71
-rw-r--r--chromium/extensions/renderer/resources/schema_utils.js49
-rw-r--r--chromium/extensions/renderer/resources/send_request.js13
-rw-r--r--chromium/extensions/renderer/resources/storage_area.js19
-rw-r--r--chromium/extensions/renderer/resources/web_request_custom_bindings.js2
-rw-r--r--chromium/extensions/renderer/resources/web_request_internal_custom_bindings.js4
-rw-r--r--chromium/extensions/renderer/runtime_custom_bindings.cc66
-rw-r--r--chromium/extensions/renderer/safe_builtins.cc19
-rw-r--r--chromium/extensions/renderer/safe_builtins.h8
-rw-r--r--chromium/extensions/renderer/script_context.cc5
-rw-r--r--chromium/extensions/renderer/script_context.h6
-rw-r--r--chromium/extensions/renderer/script_injection.cc13
-rw-r--r--chromium/extensions/renderer/script_injection.h15
-rw-r--r--chromium/extensions/renderer/script_injection_manager.cc27
-rw-r--r--chromium/extensions/renderer/script_injection_manager.h6
-rw-r--r--chromium/extensions/renderer/script_injector.h4
-rw-r--r--chromium/extensions/renderer/send_request_natives.cc4
-rw-r--r--chromium/extensions/renderer/set_icon_natives.cc2
-rw-r--r--chromium/extensions/renderer/test_features_native_handler.cc6
-rw-r--r--chromium/extensions/renderer/test_native_handler.cc2
-rw-r--r--chromium/extensions/renderer/user_script_injector.cc21
-rw-r--r--chromium/extensions/renderer/user_script_injector.h4
-rw-r--r--chromium/extensions/renderer/user_script_set.cc29
-rw-r--r--chromium/extensions/renderer/user_script_set.h11
-rw-r--r--chromium/extensions/renderer/user_script_set_manager.cc6
-rw-r--r--chromium/extensions/renderer/user_script_set_manager.h17
-rw-r--r--chromium/extensions/renderer/v8_context_native_handler.cc10
-rw-r--r--chromium/extensions/renderer/v8_schema_registry.cc30
-rw-r--r--chromium/extensions/renderer/v8_schema_registry.h8
-rw-r--r--chromium/extensions/renderer/wake_event_page.cc6
-rw-r--r--chromium/extensions/renderer/wake_event_page.h10
-rw-r--r--chromium/extensions/renderer/worker_script_context_set.cc2
-rw-r--r--chromium/extensions/renderer/worker_script_context_set.h5
-rw-r--r--chromium/extensions/shell/BUILD.gn25
-rw-r--r--chromium/extensions/shell/app/shell_main_delegate.h11
-rw-r--r--chromium/extensions/shell/app_shell.gyp10
-rw-r--r--chromium/extensions/shell/browser/DEPS1
-rw-r--r--chromium/extensions/shell/browser/api/identity/identity_api.cc10
-rw-r--r--chromium/extensions/shell/browser/api/identity/identity_api.h4
-rw-r--r--chromium/extensions/shell/browser/api/identity/identity_api_unittest.cc13
-rw-r--r--chromium/extensions/shell/browser/media_capture_util.cc2
-rw-r--r--chromium/extensions/shell/browser/shell_audio_controller_chromeos_unittest.cc10
-rw-r--r--chromium/extensions/shell/browser/shell_browser_main_parts.h32
-rw-r--r--chromium/extensions/shell/browser/shell_desktop_controller_aura.cc31
-rw-r--r--chromium/extensions/shell/browser/shell_desktop_controller_aura.h22
-rw-r--r--chromium/extensions/shell/browser/shell_desktop_controller_aura_unittest.cc10
-rw-r--r--chromium/extensions/shell/browser/shell_desktop_controller_mac.h6
-rw-r--r--chromium/extensions/shell/browser/shell_desktop_controller_mac.mm6
-rw-r--r--chromium/extensions/shell/browser/shell_device_client.h8
-rw-r--r--chromium/extensions/shell/browser/shell_display_info_provider.cc2
-rw-r--r--chromium/extensions/shell/browser/shell_display_info_provider.h2
-rw-r--r--chromium/extensions/shell/browser/shell_extension_system.cc5
-rw-r--r--chromium/extensions/shell/browser/shell_extension_system.h10
-rw-r--r--chromium/extensions/shell/browser/shell_extensions_browser_client.cc13
-rw-r--r--chromium/extensions/shell/browser/shell_extensions_browser_client.h17
-rw-r--r--chromium/extensions/shell/browser/shell_native_app_window.cc2
-rw-r--r--chromium/extensions/shell/browser/shell_native_app_window.h2
-rw-r--r--chromium/extensions/shell/browser/shell_native_app_window_aura_unittest.cc10
-rw-r--r--chromium/extensions/shell/browser/shell_network_controller_chromeos.cc4
-rw-r--r--chromium/extensions/shell/browser/shell_network_controller_chromeos.h4
-rw-r--r--chromium/extensions/shell/browser/shell_oauth2_token_service_delegate.cc5
-rw-r--r--chromium/extensions/shell/browser/shell_prefs.cc8
-rw-r--r--chromium/extensions/shell/browser/shell_prefs.h6
-rw-r--r--chromium/extensions/shell/browser/shell_prefs_unittest.cc4
-rw-r--r--chromium/extensions/shell/browser/shell_screen.cc24
-rw-r--r--chromium/extensions/shell/browser/shell_screen.h28
-rw-r--r--chromium/extensions/shell/browser/shell_screen_unittest.cc8
-rw-r--r--chromium/extensions/shell/browser/shell_speech_recognition_manager_delegate.cc5
-rw-r--r--chromium/extensions/shell/browser/shell_speech_recognition_manager_delegate.h2
-rw-r--r--chromium/extensions/shell/browser/shell_url_request_context_getter.cc6
-rw-r--r--chromium/extensions/shell/browser/shell_url_request_context_getter.h14
-rw-r--r--chromium/extensions/shell/common/shell_extensions_client.cc10
-rw-r--r--chromium/extensions/shell/common/shell_extensions_client.h4
-rw-r--r--chromium/extensions/shell/renderer/shell_content_renderer_client.h13
-rw-r--r--chromium/extensions/strings/extensions_strings_gu.xtb2
-rw-r--r--chromium/extensions/strings/extensions_strings_kn.xtb2
-rw-r--r--chromium/extensions/utility/unpacker.cc6
-rw-r--r--chromium/extensions/utility/unpacker.h10
-rw-r--r--chromium/extensions/utility/unpacker_unittest.cc4
719 files changed, 7862 insertions, 5935 deletions
diff --git a/chromium/extensions/BUILD.gn b/chromium/extensions/BUILD.gn
index 9e7e2fe397a..b5e790f07ac 100644
--- a/chromium/extensions/BUILD.gn
+++ b/chromium/extensions/BUILD.gn
@@ -81,6 +81,7 @@ source_set("test_support") {
deps = [
":extensions_resources",
"//base",
+ "//components/cast_certificate:test_support",
"//components/guest_view/browser:test_support",
"//components/pref_registry:test_support",
"//components/prefs:test_support",
@@ -93,16 +94,13 @@ source_set("test_support") {
"//net:test_support",
"//testing/gmock",
"//testing/gtest",
+ "//third_party/cld_2:cld2_static",
]
public_deps = [
"//content/public/browser",
"//extensions/common/api/cast_channel:cast_channel_proto",
]
-
- if (cld_version == 2) {
- deps += [ "//third_party/cld_2:cld2_static" ]
- }
}
# GYP version: //extensions/extensions.gyp:extensions_shell_and_test_pak
@@ -158,6 +156,7 @@ test("extensions_unittests") {
data = [
"test/data/",
"//chrome/test/data/extensions/",
+ "//components/test/data/cast_certificate/",
"$root_out_dir/extensions_shell_and_test.pak",
]
@@ -185,7 +184,7 @@ test("extensions_unittests") {
"//mojo/edk/js",
"//mojo/edk/system",
"//mojo/public/cpp/bindings",
- "//mojo/shell/public/interfaces",
+ "//services/shell/public/interfaces",
"//testing/gmock",
"//testing/gtest",
"//third_party/leveldatabase",
@@ -252,14 +251,6 @@ test("extensions_browsertests") {
"//third_party/mesa:osmesa",
]
- if (is_win) {
- if (target_cpu == "x86") {
- data_deps += [
- # "$root_out_dir/wow_helper.exe" # TODO(GYP)
- ]
- }
- }
-
if (is_mac) {
deps += [ "shell:app_shell" ] # Needed for App Shell.app's Helper.
}
@@ -290,7 +281,6 @@ source_set("chrome_extensions_browsertests") {
"//chrome/common/extensions/api",
"//chrome/renderer",
"//components/autofill/content/browser:risk_proto",
- "//components/autofill/content/browser/wallet:test_support",
"//components/autofill/content/renderer:test_support",
"//components/captive_portal:test_support",
"//components/dom_distiller/content/browser",
diff --git a/chromium/extensions/browser/BUILD.gn b/chromium/extensions/browser/BUILD.gn
index e044a7a8912..f145569871f 100644
--- a/chromium/extensions/browser/BUILD.gn
+++ b/chromium/extensions/browser/BUILD.gn
@@ -11,6 +11,7 @@ source_set("browser") {
deps = [
"//base:i18n",
+ "//components/cast_certificate",
"//components/guest_view/browser",
"//components/keyed_service/content",
"//components/keyed_service/core",
@@ -31,6 +32,7 @@ source_set("browser") {
"//skia",
"//third_party/leveldatabase",
"//third_party/re2",
+ "//ui/display",
]
configs += [
@@ -83,7 +85,7 @@ source_set("browser") {
sources += nonchromeos_sources
if (is_linux) {
- configs += [ "//build/config/linux:dbus" ]
+ configs += [ "//build/config/linux/dbus" ]
deps += [ "//dbus" ]
linux_sources = rebase_path(
extensions_gypi_values.extensions_browser_sources_linux_nonchromeos,
@@ -101,7 +103,7 @@ source_set("browser") {
sources += win_or_mac_sources
}
}
- if (enable_wifi_display) {
+ if (proprietary_codecs && enable_wifi_display) {
wifi_display_sources = rebase_path(
extensions_gypi_values.extensions_browser_sources_wifi_display,
".",
diff --git a/chromium/extensions/browser/DEPS b/chromium/extensions/browser/DEPS
index abf85d9d797..b29c812fbb6 100644
--- a/chromium/extensions/browser/DEPS
+++ b/chromium/extensions/browser/DEPS
@@ -25,6 +25,7 @@ include_rules = [
"+third_party/re2",
"+third_party/WebKit/public/web",
"+third_party/zlib/google",
+ "+ui/display",
]
specific_include_rules = {
diff --git a/chromium/extensions/browser/api/alarms/OWNERS b/chromium/extensions/browser/api/alarms/OWNERS
deleted file mode 100644
index 39cb68cb187..00000000000
--- a/chromium/extensions/browser/api/alarms/OWNERS
+++ /dev/null
@@ -1 +0,0 @@
-mpcomplete@chromium.org
diff --git a/chromium/extensions/browser/api/alarms/alarm_manager.cc b/chromium/extensions/browser/api/alarms/alarm_manager.cc
index 0616481fc75..b382dff81f0 100644
--- a/chromium/extensions/browser/api/alarms/alarm_manager.cc
+++ b/chromium/extensions/browser/api/alarms/alarm_manager.cc
@@ -45,9 +45,9 @@ class DefaultAlarmDelegate : public AlarmManager::Delegate {
~DefaultAlarmDelegate() override {}
void OnAlarm(const std::string& extension_id, const Alarm& alarm) override {
- scoped_ptr<base::ListValue> args(new base::ListValue());
+ std::unique_ptr<base::ListValue> args(new base::ListValue());
args->Append(alarm.js_alarm->ToValue().release());
- scoped_ptr<Event> event(new Event(
+ std::unique_ptr<Event> event(new Event(
events::ALARMS_ON_ALARM, alarms::OnAlarm::kEventName, std::move(args)));
EventRouter::Get(browser_context_)
->DispatchEventToExtension(extension_id, std::move(event));
@@ -79,10 +79,12 @@ std::vector<Alarm> AlarmsFromValue(const base::ListValue* list) {
return alarms;
}
-scoped_ptr<base::ListValue> AlarmsToValue(const std::vector<Alarm>& alarms) {
- scoped_ptr<base::ListValue> list(new base::ListValue());
+std::unique_ptr<base::ListValue> AlarmsToValue(
+ const std::vector<Alarm>& alarms) {
+ std::unique_ptr<base::ListValue> list(new base::ListValue());
for (size_t i = 0; i < alarms.size(); ++i) {
- scoped_ptr<base::DictionaryValue> alarm = alarms[i].js_alarm->ToValue();
+ std::unique_ptr<base::DictionaryValue> alarm =
+ alarms[i].js_alarm->ToValue();
alarm->Set(kAlarmGranularity,
base::CreateTimeDeltaValue(alarms[i].granularity));
list->Append(alarm.release());
@@ -290,7 +292,7 @@ void AlarmManager::WriteToStorage(const std::string& extension_id) {
if (!storage)
return;
- scoped_ptr<base::Value> alarms;
+ std::unique_ptr<base::Value> alarms;
AlarmMap::iterator list = alarms_.find(extension_id);
if (list != alarms_.end())
alarms.reset(AlarmsToValue(list->second).release());
@@ -301,7 +303,7 @@ void AlarmManager::WriteToStorage(const std::string& extension_id) {
}
void AlarmManager::ReadFromStorage(const std::string& extension_id,
- scoped_ptr<base::Value> value) {
+ std::unique_ptr<base::Value> value) {
base::ListValue* list = NULL;
if (value.get() && value->GetAsList(&list)) {
std::vector<Alarm> alarm_states = AlarmsFromValue(list);
diff --git a/chromium/extensions/browser/api/alarms/alarm_manager.h b/chromium/extensions/browser/api/alarms/alarm_manager.h
index 66e5fb105d5..f534ea923f1 100644
--- a/chromium/extensions/browser/api/alarms/alarm_manager.h
+++ b/chromium/extensions/browser/api/alarms/alarm_manager.h
@@ -184,7 +184,7 @@ class AlarmManager : public BrowserContextKeyedAPI,
// Syncs our alarm data for the given extension to/from the state storage.
void WriteToStorage(const std::string& extension_id);
void ReadFromStorage(const std::string& extension_id,
- scoped_ptr<base::Value> value);
+ std::unique_ptr<base::Value> value);
// Set the timer to go off at the specified |time|, and set |next_poll_time|
// appropriately.
@@ -214,8 +214,8 @@ class AlarmManager : public BrowserContextKeyedAPI,
static const bool kServiceHasOwnInstanceInIncognito = true;
content::BrowserContext* const browser_context_;
- scoped_ptr<base::Clock> clock_;
- scoped_ptr<Delegate> delegate_;
+ std::unique_ptr<base::Clock> clock_;
+ std::unique_ptr<Delegate> delegate_;
// Listen to extension load notifications.
ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
diff --git a/chromium/extensions/browser/api/alarms/alarms_api.cc b/chromium/extensions/browser/api/alarms/alarms_api.cc
index 102bce4f863..fa27a54d0c4 100644
--- a/chromium/extensions/browser/api/alarms/alarms_api.cc
+++ b/chromium/extensions/browser/api/alarms/alarms_api.cc
@@ -103,7 +103,7 @@ AlarmsCreateFunction::~AlarmsCreateFunction() {
}
bool AlarmsCreateFunction::RunAsync() {
- scoped_ptr<alarms::Create::Params> params(
+ std::unique_ptr<alarms::Create::Params> params(
alarms::Create::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
const std::string& alarm_name =
@@ -135,7 +135,8 @@ void AlarmsCreateFunction::Callback() {
}
bool AlarmsGetFunction::RunAsync() {
- scoped_ptr<alarms::Get::Params> params(alarms::Get::Params::Create(*args_));
+ std::unique_ptr<alarms::Get::Params> params(
+ alarms::Get::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
std::string name = params->name.get() ? *params->name : kDefaultAlarmName;
@@ -162,7 +163,7 @@ bool AlarmsGetAllFunction::RunAsync() {
}
void AlarmsGetAllFunction::Callback(const AlarmList* alarms) {
- scoped_ptr<base::ListValue> alarms_value(new base::ListValue());
+ std::unique_ptr<base::ListValue> alarms_value(new base::ListValue());
if (alarms) {
for (const Alarm& alarm : *alarms)
alarms_value->Append(alarm.js_alarm->ToValue());
@@ -172,7 +173,7 @@ void AlarmsGetAllFunction::Callback(const AlarmList* alarms) {
}
bool AlarmsClearFunction::RunAsync() {
- scoped_ptr<alarms::Clear::Params> params(
+ std::unique_ptr<alarms::Clear::Params> params(
alarms::Clear::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
diff --git a/chromium/extensions/browser/api/alarms/alarms_api_unittest.cc b/chromium/extensions/browser/api/alarms/alarms_api_unittest.cc
index b0626f2641c..67f04b40d54 100644
--- a/chromium/extensions/browser/api/alarms/alarms_api_unittest.cc
+++ b/chromium/extensions/browser/api/alarms/alarms_api_unittest.cc
@@ -97,8 +97,9 @@ class ExtensionAlarmsTest : public ApiUnitTest {
"[\"0\", {\"delayInMinutes\": 0}]",
};
for (size_t i = 0; i < num_alarms; ++i) {
- scoped_ptr<base::DictionaryValue> result(RunFunctionAndReturnDictionary(
- new AlarmsCreateFunction(test_clock_), kCreateArgs[i]));
+ std::unique_ptr<base::DictionaryValue> result(
+ RunFunctionAndReturnDictionary(new AlarmsCreateFunction(test_clock_),
+ kCreateArgs[i]));
EXPECT_FALSE(result.get());
}
}
@@ -326,7 +327,7 @@ TEST_F(ExtensionAlarmsTest, Get) {
// Get the default one.
{
JsAlarm alarm;
- scoped_ptr<base::DictionaryValue> result(
+ std::unique_ptr<base::DictionaryValue> result(
RunFunctionAndReturnDictionary(new AlarmsGetFunction(), "[null]"));
ASSERT_TRUE(result.get());
EXPECT_TRUE(JsAlarm::Populate(*result, &alarm));
@@ -339,7 +340,7 @@ TEST_F(ExtensionAlarmsTest, Get) {
// Get "7".
{
JsAlarm alarm;
- scoped_ptr<base::DictionaryValue> result(
+ std::unique_ptr<base::DictionaryValue> result(
RunFunctionAndReturnDictionary(new AlarmsGetFunction(), "[\"7\"]"));
ASSERT_TRUE(result.get());
EXPECT_TRUE(JsAlarm::Populate(*result, &alarm));
@@ -350,8 +351,9 @@ TEST_F(ExtensionAlarmsTest, Get) {
// Get a non-existent one.
{
- scoped_ptr<base::DictionaryValue> result(RunFunctionAndReturnDictionary(
- new AlarmsGetFunction(), "[\"nobody\"]"));
+ std::unique_ptr<base::DictionaryValue> result(
+ RunFunctionAndReturnDictionary(new AlarmsGetFunction(),
+ "[\"nobody\"]"));
ASSERT_FALSE(result.get());
}
}
@@ -359,7 +361,7 @@ TEST_F(ExtensionAlarmsTest, Get) {
TEST_F(ExtensionAlarmsTest, GetAll) {
// Test getAll with 0 alarms.
{
- scoped_ptr<base::ListValue> result(
+ std::unique_ptr<base::ListValue> result(
RunFunctionAndReturnList(new AlarmsGetAllFunction(), "[]"));
std::vector<linked_ptr<JsAlarm>> alarms = ToAlarmList(result.get());
EXPECT_EQ(0u, alarms.size());
@@ -369,7 +371,7 @@ TEST_F(ExtensionAlarmsTest, GetAll) {
CreateAlarms(2);
{
- scoped_ptr<base::ListValue> result(
+ std::unique_ptr<base::ListValue> result(
RunFunctionAndReturnList(new AlarmsGetAllFunction(), "[null]"));
std::vector<linked_ptr<JsAlarm>> alarms = ToAlarmList(result.get());
EXPECT_EQ(2u, alarms.size());
@@ -418,7 +420,7 @@ void ExtensionAlarmsTestClearGetAllAlarms1Callback(
TEST_F(ExtensionAlarmsTest, Clear) {
// Clear a non-existent one.
{
- scoped_ptr<base::Value> result(
+ std::unique_ptr<base::Value> result(
RunFunctionAndReturnValue(new AlarmsClearFunction(), "[\"nobody\"]"));
bool copy_bool_result = false;
ASSERT_TRUE(result->GetAsBoolean(&copy_bool_result));
@@ -430,14 +432,14 @@ TEST_F(ExtensionAlarmsTest, Clear) {
// Clear all but the 0.001-minute alarm.
{
- scoped_ptr<base::Value> result(
+ std::unique_ptr<base::Value> result(
RunFunctionAndReturnValue(new AlarmsClearFunction(), "[\"7\"]"));
bool copy_bool_result = false;
ASSERT_TRUE(result->GetAsBoolean(&copy_bool_result));
EXPECT_TRUE(copy_bool_result);
}
{
- scoped_ptr<base::Value> result(
+ std::unique_ptr<base::Value> result(
RunFunctionAndReturnValue(new AlarmsClearFunction(), "[\"0\"]"));
bool copy_bool_result = false;
ASSERT_TRUE(result->GetAsBoolean(&copy_bool_result));
@@ -470,7 +472,7 @@ void ExtensionAlarmsTestClearAllGetAllAlarms1Callback(
TEST_F(ExtensionAlarmsTest, ClearAll) {
// ClearAll with no alarms set.
{
- scoped_ptr<base::Value> result(
+ std::unique_ptr<base::Value> result(
RunFunctionAndReturnValue(new AlarmsClearAllFunction(), "[]"));
bool copy_bool_result = false;
ASSERT_TRUE(result->GetAsBoolean(&copy_bool_result));
diff --git a/chromium/extensions/browser/api/api_resource_manager.h b/chromium/extensions/browser/api/api_resource_manager.h
index 79ef86209dd..89e5bb330d4 100644
--- a/chromium/extensions/browser/api/api_resource_manager.h
+++ b/chromium/extensions/browser/api/api_resource_manager.h
@@ -6,11 +6,11 @@
#define EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_
#include <map>
+#include <memory>
#include "base/containers/hash_tables.h"
#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/scoped_observer.h"
#include "base/threading/non_thread_safe.h"
#include "components/keyed_service/core/keyed_service.h"
diff --git a/chromium/extensions/browser/api/api_resource_manager_unittest.cc b/chromium/extensions/browser/api/api_resource_manager_unittest.cc
index d398b3075ec..7ab19c578b3 100644
--- a/chromium/extensions/browser/api/api_resource_manager_unittest.cc
+++ b/chromium/extensions/browser/api/api_resource_manager_unittest.cc
@@ -28,7 +28,7 @@ class FakeApiResource : public ApiResource {
};
TEST_F(ApiResourceManagerUnitTest, TwoAppsCannotShareResources) {
- scoped_ptr<ApiResourceManager<FakeApiResource>> manager(
+ std::unique_ptr<ApiResourceManager<FakeApiResource>> manager(
new ApiResourceManager<FakeApiResource>(browser_context()));
scoped_refptr<extensions::Extension> extension_one =
test_util::CreateEmptyExtension("one");
diff --git a/chromium/extensions/browser/api/app_current_window_internal/app_current_window_internal_api.cc b/chromium/extensions/browser/api/app_current_window_internal/app_current_window_internal_api.cc
index 661edcd8faa..4033699b539 100644
--- a/chromium/extensions/browser/api/app_current_window_internal/app_current_window_internal_api.cc
+++ b/chromium/extensions/browser/api/app_current_window_internal/app_current_window_internal_api.cc
@@ -72,7 +72,7 @@ void GetBoundsFields(const Bounds& bounds_spec, gfx::Rect* bounds) {
// Copy the constraint value from the API to our internal representation of
// content size constraints. A value of zero resets the constraints. The insets
// are used to transform window constraints to content constraints.
-void GetConstraintWidth(const scoped_ptr<int>& width,
+void GetConstraintWidth(const std::unique_ptr<int>& width,
const gfx::Insets& insets,
gfx::Size* size) {
if (!width.get())
@@ -82,7 +82,7 @@ void GetConstraintWidth(const scoped_ptr<int>& width,
: kUnboundedSize);
}
-void GetConstraintHeight(const scoped_ptr<int>& height,
+void GetConstraintHeight(const std::unique_ptr<int>& height,
const gfx::Insets& insets,
gfx::Size* size) {
if (!height.get())
@@ -177,7 +177,7 @@ bool AppCurrentWindowInternalClearAttentionFunction::RunWithWindow(
}
bool AppCurrentWindowInternalShowFunction::RunWithWindow(AppWindow* window) {
- scoped_ptr<Show::Params> params(Show::Params::Create(*args_));
+ std::unique_ptr<Show::Params> params(Show::Params::Create(*args_));
CHECK(params.get());
if (params->focused && !*params->focused)
window->Show(AppWindow::SHOW_INACTIVE);
@@ -193,7 +193,7 @@ bool AppCurrentWindowInternalHideFunction::RunWithWindow(AppWindow* window) {
bool AppCurrentWindowInternalSetBoundsFunction::RunWithWindow(
AppWindow* window) {
- scoped_ptr<SetBounds::Params> params(SetBounds::Params::Create(*args_));
+ std::unique_ptr<SetBounds::Params> params(SetBounds::Params::Create(*args_));
CHECK(params.get());
bounds::BoundsType bounds_type = bounds::GetBoundsType(params->bounds_type);
@@ -258,7 +258,7 @@ bool AppCurrentWindowInternalSetBoundsFunction::RunWithWindow(
bool AppCurrentWindowInternalSetSizeConstraintsFunction::RunWithWindow(
AppWindow* window) {
- scoped_ptr<SetSizeConstraints::Params> params(
+ std::unique_ptr<SetSizeConstraints::Params> params(
SetSizeConstraints::Params::Create(*args_));
CHECK(params.get());
@@ -303,7 +303,7 @@ bool AppCurrentWindowInternalSetIconFunction::RunWithWindow(AppWindow* window) {
return false;
}
- scoped_ptr<SetIcon::Params> params(SetIcon::Params::Create(*args_));
+ std::unique_ptr<SetIcon::Params> params(SetIcon::Params::Create(*args_));
CHECK(params.get());
// The |icon_url| parameter may be a blob url (e.g. an image fetched with an
// XMLHttpRequest) or a resource url.
@@ -323,8 +323,7 @@ bool AppCurrentWindowInternalSetShapeFunction::RunWithWindow(
return false;
}
- scoped_ptr<SetShape::Params> params(
- SetShape::Params::Create(*args_));
+ std::unique_ptr<SetShape::Params> params(SetShape::Params::Create(*args_));
const Region& shape = params->region;
// Build a region from the supplied list of rects.
@@ -332,7 +331,7 @@ bool AppCurrentWindowInternalSetShapeFunction::RunWithWindow(
// input region so that the entire window accepts input events.
// To specify an empty input region (so the window ignores all input),
// |rects| should be an empty list.
- scoped_ptr<SkRegion> region(new SkRegion);
+ std::unique_ptr<SkRegion> region(new SkRegion);
if (shape.rects) {
for (const RegionRect& input_rect : *shape.rects) {
int32_t x = input_rect.left;
@@ -360,7 +359,7 @@ bool AppCurrentWindowInternalSetAlwaysOnTopFunction::RunWithWindow(
return false;
}
- scoped_ptr<SetAlwaysOnTop::Params> params(
+ std::unique_ptr<SetAlwaysOnTop::Params> params(
SetAlwaysOnTop::Params::Create(*args_));
CHECK(params.get());
window->SetAlwaysOnTop(params->always_on_top);
@@ -369,7 +368,7 @@ bool AppCurrentWindowInternalSetAlwaysOnTopFunction::RunWithWindow(
bool AppCurrentWindowInternalSetVisibleOnAllWorkspacesFunction::RunWithWindow(
AppWindow* window) {
- scoped_ptr<SetVisibleOnAllWorkspaces::Params> params(
+ std::unique_ptr<SetVisibleOnAllWorkspaces::Params> params(
SetVisibleOnAllWorkspaces::Params::Create(*args_));
CHECK(params.get());
window->GetBaseWindow()->SetVisibleOnAllWorkspaces(params->always_visible);
diff --git a/chromium/extensions/browser/api/app_runtime/app_runtime_api.cc b/chromium/extensions/browser/api/app_runtime/app_runtime_api.cc
index fca709bd009..f24d52cb19b 100644
--- a/chromium/extensions/browser/api/app_runtime/app_runtime_api.cc
+++ b/chromium/extensions/browser/api/app_runtime/app_runtime_api.cc
@@ -31,13 +31,13 @@ namespace {
void DispatchOnEmbedRequestedEventImpl(
const std::string& extension_id,
- scoped_ptr<base::DictionaryValue> app_embedding_request_data,
+ std::unique_ptr<base::DictionaryValue> app_embedding_request_data,
content::BrowserContext* context) {
- scoped_ptr<base::ListValue> args(new base::ListValue());
+ std::unique_ptr<base::ListValue> args(new base::ListValue());
args->Append(app_embedding_request_data.release());
- scoped_ptr<Event> event(new Event(events::APP_RUNTIME_ON_EMBED_REQUESTED,
- app_runtime::OnEmbedRequested::kEventName,
- std::move(args)));
+ std::unique_ptr<Event> event(
+ new Event(events::APP_RUNTIME_ON_EMBED_REQUESTED,
+ app_runtime::OnEmbedRequested::kEventName, std::move(args)));
event->restrict_to_browser_context = context;
EventRouter::Get(context)
->DispatchEventWithLazyListener(extension_id, std::move(event));
@@ -46,10 +46,11 @@ void DispatchOnEmbedRequestedEventImpl(
->SetLastLaunchTime(extension_id, base::Time::Now());
}
-void DispatchOnLaunchedEventImpl(const std::string& extension_id,
- app_runtime::LaunchSource source,
- scoped_ptr<base::DictionaryValue> launch_data,
- BrowserContext* context) {
+void DispatchOnLaunchedEventImpl(
+ const std::string& extension_id,
+ app_runtime::LaunchSource source,
+ std::unique_ptr<base::DictionaryValue> launch_data,
+ BrowserContext* context) {
UMA_HISTOGRAM_ENUMERATION(
"Extensions.AppLaunchSource", source, NUM_APP_LAUNCH_SOURCES);
@@ -62,11 +63,11 @@ void DispatchOnLaunchedEventImpl(const std::string& extension_id,
"isPublicSession",
ExtensionsBrowserClient::Get()->IsLoggedInAsPublicAccount());
- scoped_ptr<base::ListValue> args(new base::ListValue());
+ std::unique_ptr<base::ListValue> args(new base::ListValue());
args->Append(launch_data.release());
- scoped_ptr<Event> event(new Event(events::APP_RUNTIME_ON_LAUNCHED,
- app_runtime::OnLaunched::kEventName,
- std::move(args)));
+ std::unique_ptr<Event> event(new Event(events::APP_RUNTIME_ON_LAUNCHED,
+ app_runtime::OnLaunched::kEventName,
+ std::move(args)));
event->restrict_to_browser_context = context;
EventRouter::Get(context)
->DispatchEventWithLazyListener(extension_id, std::move(event));
@@ -124,7 +125,7 @@ app_runtime::LaunchSource getLaunchSourceEnum(
// static
void AppRuntimeEventRouter::DispatchOnEmbedRequestedEvent(
content::BrowserContext* context,
- scoped_ptr<base::DictionaryValue> embed_app_data,
+ std::unique_ptr<base::DictionaryValue> embed_app_data,
const Extension* extension) {
DispatchOnEmbedRequestedEventImpl(extension->id(), std::move(embed_app_data),
context);
@@ -149,10 +150,10 @@ void AppRuntimeEventRouter::DispatchOnLaunchedEvent(
void AppRuntimeEventRouter::DispatchOnRestartedEvent(
BrowserContext* context,
const Extension* extension) {
- scoped_ptr<base::ListValue> arguments(new base::ListValue());
- scoped_ptr<Event> event(new Event(events::APP_RUNTIME_ON_RESTARTED,
- app_runtime::OnRestarted::kEventName,
- std::move(arguments)));
+ std::unique_ptr<base::ListValue> arguments(new base::ListValue());
+ std::unique_ptr<Event> event(new Event(events::APP_RUNTIME_ON_RESTARTED,
+ app_runtime::OnRestarted::kEventName,
+ std::move(arguments)));
event->restrict_to_browser_context = context;
EventRouter::Get(context)
->DispatchEventToExtension(extension->id(), std::move(event));
@@ -167,7 +168,7 @@ void AppRuntimeEventRouter::DispatchOnLaunchedEventWithFileEntries(
const std::vector<GrantedFileEntry>& file_entries) {
// TODO(sergeygs): Use the same way of creating an event (using the generated
// boilerplate) as below in DispatchOnLaunchedEventWithUrl.
- scoped_ptr<base::DictionaryValue> launch_data(new base::DictionaryValue);
+ std::unique_ptr<base::DictionaryValue> launch_data(new base::DictionaryValue);
launch_data->SetString("id", handler_id);
app_runtime::LaunchSource source_enum =
@@ -176,10 +177,11 @@ void AppRuntimeEventRouter::DispatchOnLaunchedEventWithFileEntries(
launch_data->SetString("source", app_runtime::ToString(source_enum));
}
- scoped_ptr<base::ListValue> items(new base::ListValue);
+ std::unique_ptr<base::ListValue> items(new base::ListValue);
DCHECK(file_entries.size() == entries.size());
for (size_t i = 0; i < file_entries.size(); ++i) {
- scoped_ptr<base::DictionaryValue> launch_item(new base::DictionaryValue);
+ std::unique_ptr<base::DictionaryValue> launch_item(
+ new base::DictionaryValue);
launch_item->SetString("fileSystemId", file_entries[i].filesystem_id);
launch_item->SetString("baseName", file_entries[i].registered_name);
diff --git a/chromium/extensions/browser/api/app_runtime/app_runtime_api.h b/chromium/extensions/browser/api/app_runtime/app_runtime_api.h
index 35a28d22f60..1548387b2e5 100644
--- a/chromium/extensions/browser/api/app_runtime/app_runtime_api.h
+++ b/chromium/extensions/browser/api/app_runtime/app_runtime_api.h
@@ -5,10 +5,10 @@
#ifndef EXTENSIONS_BROWSER_API_APP_RUNTIME_APP_RUNTIME_API_H_
#define EXTENSIONS_BROWSER_API_APP_RUNTIME_APP_RUNTIME_API_H_
+#include <memory>
#include <string>
#include <vector>
-#include "base/memory/scoped_ptr.h"
#include "extensions/common/constants.h"
class GURL;
@@ -33,7 +33,7 @@ class AppRuntimeEventRouter {
// Dispatches the onEmbedRequested event to the given app.
static void DispatchOnEmbedRequestedEvent(
content::BrowserContext* context,
- scoped_ptr<base::DictionaryValue> app_embedding_request_data,
+ std::unique_ptr<base::DictionaryValue> app_embedding_request_data,
const extensions::Extension* extension);
// Dispatches the onLaunched event to the given app.
diff --git a/chromium/extensions/browser/api/app_window/app_window_api.cc b/chromium/extensions/browser/api/app_window/app_window_api.cc
index 4f5ffa551fe..e5dd7139724 100644
--- a/chromium/extensions/browser/api/app_window/app_window_api.cc
+++ b/chromium/extensions/browser/api/app_window/app_window_api.cc
@@ -80,8 +80,8 @@ namespace {
// If the same property is specified for the inner and outer bounds, raise an
// error.
-bool CheckBoundsConflict(const scoped_ptr<int>& inner_property,
- const scoped_ptr<int>& outer_property,
+bool CheckBoundsConflict(const std::unique_ptr<int>& inner_property,
+ const std::unique_ptr<int>& outer_property,
const std::string& property_name,
std::string* error) {
if (inner_property.get() && outer_property.get()) {
@@ -129,7 +129,7 @@ bool AppWindowCreateFunction::RunAsync() {
if (ExtensionsBrowserClient::Get()->IsShuttingDown())
return false;
- scoped_ptr<Create::Params> params(Create::Params::Create(*args_));
+ std::unique_ptr<Create::Params> params(Create::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
GURL url = extension()->GetResourceURL(params->url);
diff --git a/chromium/extensions/browser/api/app_window/app_window_apitest.cc b/chromium/extensions/browser/api/app_window/app_window_apitest.cc
index b03fde448bf..d8215a85ae8 100644
--- a/chromium/extensions/browser/api/app_window/app_window_apitest.cc
+++ b/chromium/extensions/browser/api/app_window/app_window_apitest.cc
@@ -55,7 +55,7 @@ class TestAppWindowRegistryObserver : public AppWindowRegistry::Observer {
// Tests chrome.app.window.setIcon.
IN_PROC_BROWSER_TEST_F(ExperimentalPlatformAppBrowserTest, WindowsApiSetIcon) {
- scoped_ptr<TestAppWindowRegistryObserver> test_observer(
+ std::unique_ptr<TestAppWindowRegistryObserver> test_observer(
new TestAppWindowRegistryObserver(browser()->profile()));
ExtensionTestMessageListener listener("ready", true);
diff --git a/chromium/extensions/browser/api/audio/audio_api.cc b/chromium/extensions/browser/api/audio/audio_api.cc
index ad1f22d85e9..2c84fda51b1 100644
--- a/chromium/extensions/browser/api/audio/audio_api.cc
+++ b/chromium/extensions/browser/api/audio/audio_api.cc
@@ -40,40 +40,42 @@ AudioService* AudioAPI::GetService() const {
void AudioAPI::OnDeviceChanged() {
if (EventRouter::Get(browser_context_)) {
- scoped_ptr<Event> event(new Event(
+ std::unique_ptr<Event> event(new Event(
events::AUDIO_ON_DEVICE_CHANGED, audio::OnDeviceChanged::kEventName,
- scoped_ptr<base::ListValue>(new base::ListValue())));
+ std::unique_ptr<base::ListValue>(new base::ListValue())));
EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event));
}
}
void AudioAPI::OnLevelChanged(const std::string& id, int level) {
if (EventRouter::Get(browser_context_)) {
- scoped_ptr<base::ListValue> args = audio::OnLevelChanged::Create(id, level);
- scoped_ptr<Event> event(new Event(events::AUDIO_ON_LEVEL_CHANGED,
- audio::OnLevelChanged::kEventName,
- std::move(args)));
+ std::unique_ptr<base::ListValue> args =
+ audio::OnLevelChanged::Create(id, level);
+ std::unique_ptr<Event> event(new Event(events::AUDIO_ON_LEVEL_CHANGED,
+ audio::OnLevelChanged::kEventName,
+ std::move(args)));
EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event));
}
}
void AudioAPI::OnMuteChanged(bool is_input, bool is_muted) {
if (EventRouter::Get(browser_context_)) {
- scoped_ptr<base::ListValue> args =
+ std::unique_ptr<base::ListValue> args =
audio::OnMuteChanged::Create(is_input, is_muted);
- scoped_ptr<Event> event(new Event(events::AUDIO_ON_MUTE_CHANGED,
- audio::OnMuteChanged::kEventName,
- std::move(args)));
+ std::unique_ptr<Event> event(new Event(events::AUDIO_ON_MUTE_CHANGED,
+ audio::OnMuteChanged::kEventName,
+ std::move(args)));
EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event));
}
}
void AudioAPI::OnDevicesChanged(const DeviceInfoList& devices) {
if (EventRouter::Get(browser_context_)) {
- scoped_ptr<base::ListValue> args = audio::OnDevicesChanged::Create(devices);
- scoped_ptr<Event> event(new Event(events::AUDIO_ON_DEVICES_CHANGED,
- audio::OnDevicesChanged::kEventName,
- std::move(args)));
+ std::unique_ptr<base::ListValue> args =
+ audio::OnDevicesChanged::Create(devices);
+ std::unique_ptr<Event> event(new Event(events::AUDIO_ON_DEVICES_CHANGED,
+ audio::OnDevicesChanged::kEventName,
+ std::move(args)));
EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event));
}
}
@@ -98,7 +100,7 @@ bool AudioGetInfoFunction::RunSync() {
///////////////////////////////////////////////////////////////////////////////
bool AudioSetActiveDevicesFunction::RunSync() {
- scoped_ptr<audio::SetActiveDevices::Params> params(
+ std::unique_ptr<audio::SetActiveDevices::Params> params(
audio::SetActiveDevices::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -113,7 +115,7 @@ bool AudioSetActiveDevicesFunction::RunSync() {
///////////////////////////////////////////////////////////////////////////////
bool AudioSetPropertiesFunction::RunSync() {
- scoped_ptr<audio::SetProperties::Params> params(
+ std::unique_ptr<audio::SetProperties::Params> params(
audio::SetProperties::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
diff --git a/chromium/extensions/browser/api/bluetooth/bluetooth_api.cc b/chromium/extensions/browser/api/bluetooth/bluetooth_api.cc
index ff9780bb6e0..9c5fc508dd7 100644
--- a/chromium/extensions/browser/api/bluetooth/bluetooth_api.cc
+++ b/chromium/extensions/browser/api/bluetooth/bluetooth_api.cc
@@ -142,7 +142,7 @@ bool BluetoothGetDeviceFunction::DoWork(
scoped_refptr<BluetoothAdapter> adapter) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- scoped_ptr<GetDevice::Params> params(GetDevice::Params::Create(*args_));
+ std::unique_ptr<GetDevice::Params> params(GetDevice::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get() != NULL);
BluetoothDevice* device = adapter->GetDevice(params->device_address);
diff --git a/chromium/extensions/browser/api/bluetooth/bluetooth_api.h b/chromium/extensions/browser/api/bluetooth/bluetooth_api.h
index d4f4f1fbb50..838bd4f4c43 100644
--- a/chromium/extensions/browser/api/bluetooth/bluetooth_api.h
+++ b/chromium/extensions/browser/api/bluetooth/bluetooth_api.h
@@ -5,10 +5,10 @@
#ifndef EXTENSIONS_BROWSER_API_BLUETOOTH_BLUETOOTH_API_H_
#define EXTENSIONS_BROWSER_API_BLUETOOTH_BLUETOOTH_API_H_
+#include <memory>
#include <string>
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "device/bluetooth/bluetooth_device.h"
#include "extensions/browser/api/bluetooth/bluetooth_extension_function.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
@@ -61,7 +61,7 @@ class BluetoothAPI : public BrowserContextKeyedAPI,
content::BrowserContext* browser_context_;
// Created lazily on first access.
- scoped_ptr<BluetoothEventRouter> event_router_;
+ std::unique_ptr<BluetoothEventRouter> event_router_;
};
namespace api {
diff --git a/chromium/extensions/browser/api/bluetooth/bluetooth_api_pairing_delegate.cc b/chromium/extensions/browser/api/bluetooth/bluetooth_api_pairing_delegate.cc
index 22cb6f74ffe..4a5210fa818 100644
--- a/chromium/extensions/browser/api/bluetooth/bluetooth_api_pairing_delegate.cc
+++ b/chromium/extensions/browser/api/bluetooth/bluetooth_api_pairing_delegate.cc
@@ -4,9 +4,9 @@
#include "extensions/browser/api/bluetooth/bluetooth_api_pairing_delegate.h"
+#include <memory>
#include <utility>
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "content/public/browser/browser_context.h"
#include "device/bluetooth/bluetooth_device.h"
@@ -101,11 +101,11 @@ void BluetoothApiPairingDelegate::AuthorizePairing(
void BluetoothApiPairingDelegate::DispatchPairingEvent(
const bt_private::PairingEvent& pairing_event) {
- scoped_ptr<base::ListValue> args =
+ std::unique_ptr<base::ListValue> args =
bt_private::OnPairing::Create(pairing_event);
- scoped_ptr<Event> event(new Event(events::BLUETOOTH_PRIVATE_ON_PAIRING,
- bt_private::OnPairing::kEventName,
- std::move(args)));
+ std::unique_ptr<Event> event(new Event(events::BLUETOOTH_PRIVATE_ON_PAIRING,
+ bt_private::OnPairing::kEventName,
+ std::move(args)));
EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event));
}
diff --git a/chromium/extensions/browser/api/bluetooth/bluetooth_apitest.cc b/chromium/extensions/browser/api/bluetooth/bluetooth_apitest.cc
index 184c4c8225c..e586d4a063f 100644
--- a/chromium/extensions/browser/api/bluetooth/bluetooth_apitest.cc
+++ b/chromium/extensions/browser/api/bluetooth/bluetooth_apitest.cc
@@ -76,7 +76,7 @@ class BluetoothApiTest : public ExtensionApiTest {
const BluetoothAdapter::ErrorCallback& error_callback) {
if (mock_session_.get()) {
callback.Run(
- scoped_ptr<BluetoothDiscoverySession>(mock_session_.release()));
+ std::unique_ptr<BluetoothDiscoverySession>(mock_session_.release()));
return;
}
error_callback.Run();
@@ -91,10 +91,11 @@ class BluetoothApiTest : public ExtensionApiTest {
protected:
testing::StrictMock<MockBluetoothAdapter>* mock_adapter_;
- scoped_ptr<testing::NiceMock<MockBluetoothDiscoverySession> > mock_session_;
- scoped_ptr<testing::NiceMock<MockBluetoothDevice> > device1_;
- scoped_ptr<testing::NiceMock<MockBluetoothDevice> > device2_;
- scoped_ptr<testing::NiceMock<MockBluetoothDevice> > device3_;
+ std::unique_ptr<testing::NiceMock<MockBluetoothDiscoverySession>>
+ mock_session_;
+ std::unique_ptr<testing::NiceMock<MockBluetoothDevice>> device1_;
+ std::unique_ptr<testing::NiceMock<MockBluetoothDevice>> device2_;
+ std::unique_ptr<testing::NiceMock<MockBluetoothDevice>> device3_;
extensions::BluetoothEventRouter* event_router() {
return bluetooth_api()->event_router();
@@ -130,7 +131,7 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetAdapterState) {
scoped_refptr<api::BluetoothGetAdapterStateFunction> get_adapter_state;
get_adapter_state = setupFunction(new api::BluetoothGetAdapterStateFunction);
- scoped_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult(
+ std::unique_ptr<base::Value> result(utils::RunFunctionAndReturnSingleResult(
get_adapter_state.get(), "[]", browser()));
ASSERT_TRUE(result.get() != NULL);
api::bluetooth::AdapterState state;
diff --git a/chromium/extensions/browser/api/bluetooth/bluetooth_event_router.cc b/chromium/extensions/browser/api/bluetooth/bluetooth_event_router.cc
index 0f9345b4d0b..bd73e7983c5 100644
--- a/chromium/extensions/browser/api/bluetooth/bluetooth_event_router.cc
+++ b/chromium/extensions/browser/api/bluetooth/bluetooth_event_router.cc
@@ -137,7 +137,7 @@ void BluetoothEventRouter::StartDiscoverySessionImpl(
pre_set_filter_map_.find(extension_id);
if (pre_set_iter != pre_set_filter_map_.end()) {
adapter->StartDiscoverySessionWithFilter(
- scoped_ptr<device::BluetoothDiscoveryFilter>(pre_set_iter->second),
+ std::unique_ptr<device::BluetoothDiscoveryFilter>(pre_set_iter->second),
base::Bind(&BluetoothEventRouter::OnStartDiscoverySession,
weak_ptr_factory_.GetWeakPtr(), extension_id, callback),
error_callback);
@@ -171,7 +171,7 @@ void BluetoothEventRouter::StopDiscoverySession(
}
void BluetoothEventRouter::SetDiscoveryFilter(
- scoped_ptr<device::BluetoothDiscoveryFilter> discovery_filter,
+ std::unique_ptr<device::BluetoothDiscoveryFilter> discovery_filter,
device::BluetoothAdapter* adapter,
const std::string& extension_id,
const base::Closure& callback,
@@ -377,9 +377,9 @@ void BluetoothEventRouter::DispatchAdapterStateEvent() {
CHECK(adapter_.get());
PopulateAdapterState(*adapter_.get(), &state);
- scoped_ptr<base::ListValue> args =
+ std::unique_ptr<base::ListValue> args =
bluetooth::OnAdapterStateChanged::Create(state);
- scoped_ptr<Event> event(
+ std::unique_ptr<Event> event(
new Event(events::BLUETOOTH_ON_ADAPTER_STATE_CHANGED,
bluetooth::OnAdapterStateChanged::kEventName, std::move(args)));
EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event));
@@ -393,9 +393,9 @@ void BluetoothEventRouter::DispatchDeviceEvent(
CHECK(device);
bluetooth::BluetoothDeviceToApiDevice(*device, &extension_device);
- scoped_ptr<base::ListValue> args =
+ std::unique_ptr<base::ListValue> args =
bluetooth::OnDeviceAdded::Create(extension_device);
- scoped_ptr<Event> event(
+ std::unique_ptr<Event> event(
new Event(histogram_value, event_name, std::move(args)));
EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event));
}
@@ -440,7 +440,7 @@ void BluetoothEventRouter::CleanUpAllExtensions() {
void BluetoothEventRouter::OnStartDiscoverySession(
const std::string& extension_id,
const base::Closure& callback,
- scoped_ptr<device::BluetoothDiscoverySession> discovery_session) {
+ std::unique_ptr<device::BluetoothDiscoverySession> discovery_session) {
// Clean up any existing session instance for the extension.
DiscoverySessionMap::iterator iter =
discovery_session_map_.find(extension_id);
diff --git a/chromium/extensions/browser/api/bluetooth/bluetooth_event_router.h b/chromium/extensions/browser/api/bluetooth/bluetooth_event_router.h
index 6afaac0d8d5..4d2fb55fdfa 100644
--- a/chromium/extensions/browser/api/bluetooth/bluetooth_event_router.h
+++ b/chromium/extensions/browser/api/bluetooth/bluetooth_event_router.h
@@ -74,7 +74,7 @@ class BluetoothEventRouter : public device::BluetoothAdapter::Observer,
// Callback is called, if the filter was successfully updated.
// |error_callback| is called, if filter update failed.
void SetDiscoveryFilter(
- scoped_ptr<device::BluetoothDiscoveryFilter> discovery_filter,
+ std::unique_ptr<device::BluetoothDiscoveryFilter> discovery_filter,
device::BluetoothAdapter* adapter,
const std::string& extension_id,
const base::Closure& callback,
@@ -151,7 +151,7 @@ class BluetoothEventRouter : public device::BluetoothAdapter::Observer,
void OnStartDiscoverySession(
const std::string& extension_id,
const base::Closure& callback,
- scoped_ptr<device::BluetoothDiscoverySession> discovery_session);
+ std::unique_ptr<device::BluetoothDiscoverySession> discovery_session);
void OnSetDiscoveryFilter(const std::string& extension_id,
const base::Closure& callback);
diff --git a/chromium/extensions/browser/api/bluetooth/bluetooth_event_router_unittest.cc b/chromium/extensions/browser/api/bluetooth/bluetooth_event_router_unittest.cc
index 597d73838b7..5de97568f2f 100644
--- a/chromium/extensions/browser/api/bluetooth/bluetooth_event_router_unittest.cc
+++ b/chromium/extensions/browser/api/bluetooth/bluetooth_event_router_unittest.cc
@@ -4,11 +4,11 @@
#include "extensions/browser/api/bluetooth/bluetooth_event_router.h"
+#include <memory>
#include <string>
#include <utility>
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "content/public/browser/notification_service.h"
@@ -60,8 +60,8 @@ class BluetoothEventRouterTest : public ExtensionsTest {
// Note: |ui_thread_| must be declared before |router_|.
content::TestBrowserThread ui_thread_;
testing::StrictMock<device::MockBluetoothAdapter>* mock_adapter_;
- scoped_ptr<content::NotificationService> notification_service_;
- scoped_ptr<BluetoothEventRouter> router_;
+ std::unique_ptr<content::NotificationService> notification_service_;
+ std::unique_ptr<BluetoothEventRouter> router_;
};
TEST_F(BluetoothEventRouterTest, BluetoothEventListener) {
@@ -100,7 +100,7 @@ TEST_F(BluetoothEventRouterTest, UnloadExtension) {
// This test check that calling SetDiscoveryFilter before StartDiscoverySession
// for given extension will start session with proper filter.
TEST_F(BluetoothEventRouterTest, SetDiscoveryFilter) {
- scoped_ptr<device::BluetoothDiscoveryFilter> discovery_filter(
+ std::unique_ptr<device::BluetoothDiscoveryFilter> discovery_filter(
new device::BluetoothDiscoveryFilter(
device::BluetoothDiscoveryFilter::Transport::TRANSPORT_LE));
diff --git a/chromium/extensions/browser/api/bluetooth/bluetooth_private_api.cc b/chromium/extensions/browser/api/bluetooth/bluetooth_private_api.cc
index 79deb70543d..f4f176ab43b 100644
--- a/chromium/extensions/browser/api/bluetooth/bluetooth_private_api.cc
+++ b/chromium/extensions/browser/api/bluetooth/bluetooth_private_api.cc
@@ -142,7 +142,7 @@ BluetoothPrivateSetAdapterStateFunction::
bool BluetoothPrivateSetAdapterStateFunction::DoWork(
scoped_refptr<device::BluetoothAdapter> adapter) {
- scoped_ptr<bt_private::SetAdapterState::Params> params(
+ std::unique_ptr<bt_private::SetAdapterState::Params> params(
bt_private::SetAdapterState::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -250,7 +250,7 @@ BluetoothPrivateSetPairingResponseFunction::
bool BluetoothPrivateSetPairingResponseFunction::DoWork(
scoped_refptr<device::BluetoothAdapter> adapter) {
- scoped_ptr<bt_private::SetPairingResponse::Params> params(
+ std::unique_ptr<bt_private::SetPairingResponse::Params> params(
bt_private::SetPairingResponse::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
const bt_private::SetPairingResponseOptions& options = params->options;
@@ -311,7 +311,7 @@ BluetoothPrivateDisconnectAllFunction::
bool BluetoothPrivateDisconnectAllFunction::DoWork(
scoped_refptr<device::BluetoothAdapter> adapter) {
- scoped_ptr<bt_private::DisconnectAll::Params> params(
+ std::unique_ptr<bt_private::DisconnectAll::Params> params(
bt_private::DisconnectAll::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -364,7 +364,7 @@ BluetoothPrivateForgetDeviceFunction::~BluetoothPrivateForgetDeviceFunction() {}
bool BluetoothPrivateForgetDeviceFunction::DoWork(
scoped_refptr<device::BluetoothAdapter> adapter) {
- scoped_ptr<bt_private::ForgetDevice::Params> params(
+ std::unique_ptr<bt_private::ForgetDevice::Params> params(
bt_private::ForgetDevice::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -399,11 +399,11 @@ void BluetoothPrivateForgetDeviceFunction::OnErrorCallback(
bool BluetoothPrivateSetDiscoveryFilterFunction::DoWork(
scoped_refptr<device::BluetoothAdapter> adapter) {
- scoped_ptr<SetDiscoveryFilter::Params> params(
+ std::unique_ptr<SetDiscoveryFilter::Params> params(
SetDiscoveryFilter::Params::Create(*args_));
auto& df_param = params->discovery_filter;
- scoped_ptr<device::BluetoothDiscoveryFilter> discovery_filter;
+ std::unique_ptr<device::BluetoothDiscoveryFilter> discovery_filter;
// If all filter fields are empty, we are clearing filter. If any field is
// set, then create proper filter.
@@ -475,7 +475,7 @@ BluetoothPrivateConnectFunction::~BluetoothPrivateConnectFunction() {}
bool BluetoothPrivateConnectFunction::DoWork(
scoped_refptr<device::BluetoothAdapter> adapter) {
- scoped_ptr<bt_private::Connect::Params> params(
+ std::unique_ptr<bt_private::Connect::Params> params(
bt_private::Connect::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -577,7 +577,7 @@ BluetoothPrivatePairFunction::~BluetoothPrivatePairFunction() {}
bool BluetoothPrivatePairFunction::DoWork(
scoped_refptr<device::BluetoothAdapter> adapter) {
- scoped_ptr<bt_private::Pair::Params> params(
+ std::unique_ptr<bt_private::Pair::Params> params(
bt_private::Pair::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
diff --git a/chromium/extensions/browser/api/bluetooth/bluetooth_private_apitest.cc b/chromium/extensions/browser/api/bluetooth/bluetooth_private_apitest.cc
index 65adb8a379e..8307eb0b4f1 100644
--- a/chromium/extensions/browser/api/bluetooth/bluetooth_private_apitest.cc
+++ b/chromium/extensions/browser/api/bluetooth/bluetooth_private_apitest.cc
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <memory>
#include <utility>
#include "base/command_line.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "device/bluetooth/test/mock_bluetooth_adapter.h"
@@ -106,11 +106,11 @@ class BluetoothPrivateApiTest : public ExtensionApiTest {
pairing_event.device.vendor_id_source = bt::VENDOR_ID_SOURCE_USB;
pairing_event.device.type = bt::DEVICE_TYPE_PHONE;
- scoped_ptr<base::ListValue> args =
+ std::unique_ptr<base::ListValue> args =
bt_private::OnPairing::Create(pairing_event);
- scoped_ptr<Event> event(new Event(events::BLUETOOTH_PRIVATE_ON_PAIRING,
- bt_private::OnPairing::kEventName,
- std::move(args)));
+ std::unique_ptr<Event> event(new Event(events::BLUETOOTH_PRIVATE_ON_PAIRING,
+ bt_private::OnPairing::kEventName,
+ std::move(args)));
EventRouter::Get(browser()->profile())
->DispatchEventToExtension(kTestExtensionId, std::move(event));
}
@@ -133,7 +133,7 @@ class BluetoothPrivateApiTest : public ExtensionApiTest {
void CallSetDiscoveryFilterCallback(
device::BluetoothAdapter::DiscoverySessionCallback callback) {
- auto session_ptr = scoped_ptr<NiceMock<MockBluetoothDiscoverySession>>(
+ auto session_ptr = std::unique_ptr<NiceMock<MockBluetoothDiscoverySession>>(
mock_discovery_session_);
callback.Run(std::move(session_ptr));
@@ -145,7 +145,7 @@ class BluetoothPrivateApiTest : public ExtensionApiTest {
bool adapter_discoverable_;
scoped_refptr<NiceMock<MockBluetoothAdapter> > mock_adapter_;
- scoped_ptr<NiceMock<MockBluetoothDevice> > mock_device_;
+ std::unique_ptr<NiceMock<MockBluetoothDevice>> mock_device_;
// This discovery session will be owned by EventRouter, we'll only keep
// pointer to it.
diff --git a/chromium/extensions/browser/api/bluetooth_socket/bluetooth_api_socket.h b/chromium/extensions/browser/api/bluetooth_socket/bluetooth_api_socket.h
index 40304fb0b0d..dcc87b2dc21 100644
--- a/chromium/extensions/browser/api/bluetooth_socket/bluetooth_api_socket.h
+++ b/chromium/extensions/browser/api/bluetooth_socket/bluetooth_api_socket.h
@@ -138,7 +138,7 @@ class BluetoothApiSocket : public ApiResource {
device::BluetoothUUID uuid_;
// Application-defined string - see bluetooth.idl.
- scoped_ptr<std::string> name_;
+ std::unique_ptr<std::string> name_;
// Flag indicating whether the socket is left open when the application is
// suspended - see bluetooth.idl.
diff --git a/chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_api.cc b/chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_api.cc
index 0357ed9b951..ac1f41f76d5 100644
--- a/chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_api.cc
+++ b/chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_api.cc
@@ -301,7 +301,7 @@ void BluetoothSocketListenFunction::OnGetAdapter(
return;
}
- scoped_ptr<std::string> name;
+ std::unique_ptr<std::string> name;
if (socket->name())
name.reset(new std::string(*socket->name()));
@@ -364,7 +364,7 @@ bool BluetoothSocketListenUsingRfcommFunction::CreateParams() {
void BluetoothSocketListenUsingRfcommFunction::CreateService(
scoped_refptr<device::BluetoothAdapter> adapter,
const device::BluetoothUUID& uuid,
- scoped_ptr<std::string> name,
+ std::unique_ptr<std::string> name,
const device::BluetoothAdapter::CreateServiceCallback& callback,
const device::BluetoothAdapter::CreateServiceErrorCallback&
error_callback) {
@@ -407,7 +407,7 @@ bool BluetoothSocketListenUsingL2capFunction::CreateParams() {
void BluetoothSocketListenUsingL2capFunction::CreateService(
scoped_refptr<device::BluetoothAdapter> adapter,
const device::BluetoothUUID& uuid,
- scoped_ptr<std::string> name,
+ std::unique_ptr<std::string> name,
const device::BluetoothAdapter::CreateServiceCallback& callback,
const device::BluetoothAdapter::CreateServiceErrorCallback&
error_callback) {
diff --git a/chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_api.h b/chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_api.h
index 31de3b77da6..5203fc1c176 100644
--- a/chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_api.h
+++ b/chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_api.h
@@ -7,11 +7,11 @@
#include <stddef.h>
+#include <memory>
#include <string>
#include "base/containers/hash_tables.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "extensions/browser/api/api_resource_manager.h"
#include "extensions/browser/api/async_api_function.h"
@@ -81,7 +81,7 @@ class BluetoothSocketCreateFunction : public BluetoothSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<bluetooth_socket::Create::Params> params_;
+ std::unique_ptr<bluetooth_socket::Create::Params> params_;
};
class BluetoothSocketUpdateFunction : public BluetoothSocketAsyncApiFunction {
@@ -98,7 +98,7 @@ class BluetoothSocketUpdateFunction : public BluetoothSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<bluetooth_socket::Update::Params> params_;
+ std::unique_ptr<bluetooth_socket::Update::Params> params_;
};
class BluetoothSocketSetPausedFunction
@@ -117,7 +117,7 @@ class BluetoothSocketSetPausedFunction
void Work() override;
private:
- scoped_ptr<bluetooth_socket::SetPaused::Params> params_;
+ std::unique_ptr<bluetooth_socket::SetPaused::Params> params_;
BluetoothSocketEventDispatcher* socket_event_dispatcher_;
};
@@ -129,7 +129,7 @@ class BluetoothSocketListenFunction : public BluetoothSocketAsyncApiFunction {
virtual void CreateService(
scoped_refptr<device::BluetoothAdapter> adapter,
const device::BluetoothUUID& uuid,
- scoped_ptr<std::string> name,
+ std::unique_ptr<std::string> name,
const device::BluetoothAdapter::CreateServiceCallback& callback,
const device::BluetoothAdapter::CreateServiceErrorCallback&
error_callback) = 0;
@@ -168,7 +168,7 @@ class BluetoothSocketListenUsingRfcommFunction
void CreateService(
scoped_refptr<device::BluetoothAdapter> adapter,
const device::BluetoothUUID& uuid,
- scoped_ptr<std::string> name,
+ std::unique_ptr<std::string> name,
const device::BluetoothAdapter::CreateServiceCallback& callback,
const device::BluetoothAdapter::CreateServiceErrorCallback&
error_callback) override;
@@ -178,7 +178,7 @@ class BluetoothSocketListenUsingRfcommFunction
~BluetoothSocketListenUsingRfcommFunction() override;
private:
- scoped_ptr<bluetooth_socket::ListenUsingRfcomm::Params> params_;
+ std::unique_ptr<bluetooth_socket::ListenUsingRfcomm::Params> params_;
};
class BluetoothSocketListenUsingL2capFunction
@@ -197,7 +197,7 @@ class BluetoothSocketListenUsingL2capFunction
void CreateService(
scoped_refptr<device::BluetoothAdapter> adapter,
const device::BluetoothUUID& uuid,
- scoped_ptr<std::string> name,
+ std::unique_ptr<std::string> name,
const device::BluetoothAdapter::CreateServiceCallback& callback,
const device::BluetoothAdapter::CreateServiceErrorCallback&
error_callback) override;
@@ -207,7 +207,7 @@ class BluetoothSocketListenUsingL2capFunction
~BluetoothSocketListenUsingL2capFunction() override;
private:
- scoped_ptr<bluetooth_socket::ListenUsingL2cap::Params> params_;
+ std::unique_ptr<bluetooth_socket::ListenUsingL2cap::Params> params_;
};
class BluetoothSocketAbstractConnectFunction :
@@ -233,7 +233,7 @@ class BluetoothSocketAbstractConnectFunction :
private:
virtual void OnGetAdapter(scoped_refptr<device::BluetoothAdapter> adapter);
- scoped_ptr<bluetooth_socket::Connect::Params> params_;
+ std::unique_ptr<bluetooth_socket::Connect::Params> params_;
BluetoothSocketEventDispatcher* socket_event_dispatcher_;
};
@@ -271,7 +271,7 @@ class BluetoothSocketDisconnectFunction
private:
virtual void OnSuccess();
- scoped_ptr<bluetooth_socket::Disconnect::Params> params_;
+ std::unique_ptr<bluetooth_socket::Disconnect::Params> params_;
};
class BluetoothSocketCloseFunction : public BluetoothSocketAsyncApiFunction {
@@ -288,7 +288,7 @@ class BluetoothSocketCloseFunction : public BluetoothSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<bluetooth_socket::Close::Params> params_;
+ std::unique_ptr<bluetooth_socket::Close::Params> params_;
};
class BluetoothSocketSendFunction : public BluetoothSocketAsyncApiFunction {
@@ -309,7 +309,7 @@ class BluetoothSocketSendFunction : public BluetoothSocketAsyncApiFunction {
void OnError(BluetoothApiSocket::ErrorReason reason,
const std::string& message);
- scoped_ptr<bluetooth_socket::Send::Params> params_;
+ std::unique_ptr<bluetooth_socket::Send::Params> params_;
scoped_refptr<net::IOBuffer> io_buffer_;
size_t io_buffer_size_;
};
@@ -329,7 +329,7 @@ class BluetoothSocketGetInfoFunction : public BluetoothSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<bluetooth_socket::GetInfo::Params> params_;
+ std::unique_ptr<bluetooth_socket::GetInfo::Params> params_;
};
class BluetoothSocketGetSocketsFunction
diff --git a/chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_apitest.cc b/chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_apitest.cc
index 74c0842485a..1462ed49274 100644
--- a/chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_apitest.cc
+++ b/chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_apitest.cc
@@ -2,10 +2,10 @@
// 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/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/run_loop.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
#include "device/bluetooth/bluetooth_uuid.h"
@@ -67,8 +67,8 @@ class BluetoothSocketApiTest : public extensions::ShellApiTest {
protected:
scoped_refptr<testing::StrictMock<MockBluetoothAdapter> > mock_adapter_;
- scoped_ptr<testing::NiceMock<MockBluetoothDevice> > mock_device1_;
- scoped_ptr<testing::NiceMock<MockBluetoothDevice> > mock_device2_;
+ std::unique_ptr<testing::NiceMock<MockBluetoothDevice>> mock_device1_;
+ std::unique_ptr<testing::NiceMock<MockBluetoothDevice>> mock_device2_;
private:
scoped_refptr<Extension> empty_extension_;
diff --git a/chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_event_dispatcher.cc b/chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_event_dispatcher.cc
index d6185dbba1f..145a288825d 100644
--- a/chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_event_dispatcher.cc
+++ b/chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_event_dispatcher.cc
@@ -197,11 +197,11 @@ void BluetoothSocketEventDispatcher::ReceiveCallback(
bluetooth_socket::ReceiveInfo receive_info;
receive_info.socket_id = params.socket_id;
receive_info.data.assign(io_buffer->data(), io_buffer->data() + bytes_read);
- scoped_ptr<base::ListValue> args =
+ std::unique_ptr<base::ListValue> args =
bluetooth_socket::OnReceive::Create(receive_info);
- scoped_ptr<Event> event(new Event(events::BLUETOOTH_SOCKET_ON_RECEIVE,
- bluetooth_socket::OnReceive::kEventName,
- std::move(args)));
+ std::unique_ptr<Event> event(
+ new Event(events::BLUETOOTH_SOCKET_ON_RECEIVE,
+ bluetooth_socket::OnReceive::kEventName, std::move(args)));
PostEvent(params, std::move(event));
// Post a task to delay the read until the socket is available, as
@@ -232,9 +232,9 @@ void BluetoothSocketEventDispatcher::ReceiveErrorCallback(
receive_error_info.socket_id = params.socket_id;
receive_error_info.error_message = error;
receive_error_info.error = MapReceiveErrorReason(error_reason);
- scoped_ptr<base::ListValue> args =
+ std::unique_ptr<base::ListValue> args =
bluetooth_socket::OnReceiveError::Create(receive_error_info);
- scoped_ptr<Event> event(
+ std::unique_ptr<Event> event(
new Event(events::BLUETOOTH_SOCKET_ON_RECEIVE_ERROR,
bluetooth_socket::OnReceiveError::kEventName, std::move(args)));
PostEvent(params, std::move(event));
@@ -294,11 +294,11 @@ void BluetoothSocketEventDispatcher::AcceptCallback(
bluetooth_socket::AcceptInfo accept_info;
accept_info.socket_id = params.socket_id;
accept_info.client_socket_id = client_socket_id;
- scoped_ptr<base::ListValue> args =
+ std::unique_ptr<base::ListValue> args =
bluetooth_socket::OnAccept::Create(accept_info);
- scoped_ptr<Event> event(new Event(events::BLUETOOTH_SOCKET_ON_ACCEPT,
- bluetooth_socket::OnAccept::kEventName,
- std::move(args)));
+ std::unique_ptr<Event> event(new Event(events::BLUETOOTH_SOCKET_ON_ACCEPT,
+ bluetooth_socket::OnAccept::kEventName,
+ std::move(args)));
PostEvent(params, std::move(event));
// Post a task to delay the accept until the socket is available, as
@@ -329,11 +329,11 @@ void BluetoothSocketEventDispatcher::AcceptErrorCallback(
accept_error_info.socket_id = params.socket_id;
accept_error_info.error_message = error;
accept_error_info.error = MapAcceptErrorReason(error_reason);
- scoped_ptr<base::ListValue> args =
+ std::unique_ptr<base::ListValue> args =
bluetooth_socket::OnAcceptError::Create(accept_error_info);
- scoped_ptr<Event> event(new Event(events::BLUETOOTH_SOCKET_ON_ACCEPT_ERROR,
- bluetooth_socket::OnAcceptError::kEventName,
- std::move(args)));
+ std::unique_ptr<Event> event(
+ new Event(events::BLUETOOTH_SOCKET_ON_ACCEPT_ERROR,
+ bluetooth_socket::OnAcceptError::kEventName, std::move(args)));
PostEvent(params, std::move(event));
// Since we got an error, the socket is now "paused" until the application
@@ -347,7 +347,7 @@ void BluetoothSocketEventDispatcher::AcceptErrorCallback(
// static
void BluetoothSocketEventDispatcher::PostEvent(const SocketParams& params,
- scoped_ptr<Event> event) {
+ std::unique_ptr<Event> event) {
DCHECK_CURRENTLY_ON(params.thread_id);
BrowserThread::PostTask(
@@ -360,7 +360,7 @@ void BluetoothSocketEventDispatcher::PostEvent(const SocketParams& params,
void BluetoothSocketEventDispatcher::DispatchEvent(
void* browser_context_id,
const std::string& extension_id,
- scoped_ptr<Event> event) {
+ std::unique_ptr<Event> event) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
content::BrowserContext* context =
diff --git a/chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_event_dispatcher.h b/chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_event_dispatcher.h
index 5e45fc0c055..72a78b82253 100644
--- a/chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_event_dispatcher.h
+++ b/chromium/extensions/browser/api/bluetooth_socket/bluetooth_socket_event_dispatcher.h
@@ -101,12 +101,13 @@ class BluetoothSocketEventDispatcher
const std::string& error);
// Post an extension event from IO to UI thread
- static void PostEvent(const SocketParams& params, scoped_ptr<Event> event);
+ static void PostEvent(const SocketParams& params,
+ std::unique_ptr<Event> event);
// Dispatch an extension event on to EventRouter instance on UI thread.
static void DispatchEvent(void* browser_context_id,
const std::string& extension_id,
- scoped_ptr<Event> event);
+ std::unique_ptr<Event> event);
// Usually FILE thread (except for unit testing).
content::BrowserThread::ID thread_id_;
diff --git a/chromium/extensions/browser/api/cast_channel/DEPS b/chromium/extensions/browser/api/cast_channel/DEPS
index c6e9550543b..23ace86e7c7 100644
--- a/chromium/extensions/browser/api/cast_channel/DEPS
+++ b/chromium/extensions/browser/api/cast_channel/DEPS
@@ -1,3 +1,4 @@
include_rules = [
+ "+components/cast_certificate",
"+third_party/zlib",
]
diff --git a/chromium/extensions/browser/api/cast_channel/cast_auth_util.cc b/chromium/extensions/browser/api/cast_channel/cast_auth_util.cc
index afc433ea71b..451058b0358 100644
--- a/chromium/extensions/browser/api/cast_channel/cast_auth_util.cc
+++ b/chromium/extensions/browser/api/cast_channel/cast_auth_util.cc
@@ -10,9 +10,9 @@
#include "base/macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
+#include "components/cast_certificate/cast_cert_validator.h"
#include "extensions/browser/api/cast_channel/cast_message_util.h"
#include "extensions/common/api/cast_channel/cast_channel.pb.h"
-#include "extensions/common/cast/cast_cert_validator.h"
#include "net/cert/x509_certificate.h"
#include "net/der/parse_values.h"
@@ -26,7 +26,7 @@ const char* const kParseErrorPrefix = "Failed to parse auth message: ";
// The maximum number of days a cert can live for.
const int kMaxSelfSignedCertLifetimeInDays = 4;
-namespace cast_crypto = ::extensions::api::cast_crypto;
+namespace cast_crypto = ::cast_certificate;
// Extracts an embedded DeviceAuthMessage payload from an auth challenge reply
// message.
@@ -138,7 +138,7 @@ AuthResult AuthenticateChallengeReply(const CastMessage& challenge_reply,
AuthResult VerifyCredentials(const AuthResponse& response,
const std::string& signature_input) {
// Verify the certificate
- scoped_ptr<cast_crypto::CertVerificationContext> verification_context;
+ std::unique_ptr<cast_crypto::CertVerificationContext> verification_context;
// Build a single vector containing the certificate chain.
std::vector<std::string> cert_chain;
diff --git a/chromium/extensions/browser/api/cast_channel/cast_auth_util_unittest.cc b/chromium/extensions/browser/api/cast_channel/cast_auth_util_unittest.cc
index c474613c945..9393eac7532 100644
--- a/chromium/extensions/browser/api/cast_channel/cast_auth_util_unittest.cc
+++ b/chromium/extensions/browser/api/cast_channel/cast_auth_util_unittest.cc
@@ -6,12 +6,9 @@
#include <string>
-#include "base/files/file_util.h"
#include "base/macros.h"
-#include "base/path_service.h"
+#include "components/cast_certificate/cast_cert_validator_test_helpers.h"
#include "extensions/common/api/cast_channel/cast_channel.pb.h"
-#include "extensions/common/extension_paths.h"
-#include "net/cert/pem_tokenizer.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace extensions {
@@ -19,99 +16,6 @@ namespace api {
namespace cast_channel {
namespace {
-// Creates an std::string given a uint8_t array.
-template <size_t N>
-std::string CreateString(const uint8_t (&data)[N]) {
- return std::string(reinterpret_cast<const char*>(data), N);
-}
-
-// Reads a file from the cast certificates test data directory:
-// src/extensions/test/data/cast_certificates/
-std::string ReadTestFileToString(const std::string& file_name) {
- base::FilePath filepath;
- if (!PathService::Get(DIR_TEST_DATA, &filepath)) {
- ADD_FAILURE() << "Couldn't retrieve test data root";
- return std::string();
- }
- filepath = filepath.AppendASCII("cast_certificates/" + file_name);
-
- // Read the full contents of the file.
- std::string file_data;
- if (!base::ReadFileToString(filepath, &file_data)) {
- ADD_FAILURE() << "Couldn't read file: " << filepath.value();
- return std::string();
- }
-
- return file_data;
-}
-
-// Reads a PEM file containing "CERTIFICATE" blocks to a vector of certificate
-// data.
-std::vector<std::string> ReadCertificateChainFromFile(
- const std::string& file_name) {
- std::string file_data = ReadTestFileToString(file_name);
-
- // Read the certificate chain from the test file, which is comprised of PEM
- // blocks titled "CERTIFICATE".
- std::vector<std::string> pem_headers;
- pem_headers.push_back("CERTIFICATE");
-
- std::vector<std::string> certs;
- net::PEMTokenizer pem_tokenizer(file_data, pem_headers);
- while (pem_tokenizer.GetNext())
- certs.push_back(pem_tokenizer.data());
-
- return certs;
-}
-
-static const unsigned char kSignedData[] = {
- 0x5f, 0x76, 0x0d, 0xc8, 0x4b, 0xe7, 0x6e, 0xcb, 0x31, 0x58, 0xca, 0xd3,
- 0x7d, 0x23, 0x55, 0xbe, 0x8d, 0x52, 0x87, 0x83, 0x27, 0x52, 0x78, 0xfa,
- 0xa6, 0xdd, 0xdf, 0x13, 0x00, 0x51, 0x57, 0x6a, 0x83, 0x15, 0xcc, 0xc5,
- 0xb2, 0x5c, 0xdf, 0xe6, 0x81, 0xdc, 0x13, 0x58, 0x7b, 0x94, 0x0f, 0x69,
- 0xcc, 0xdf, 0x68, 0x41, 0x8a, 0x95, 0xe2, 0xcd, 0xf8, 0xde, 0x0f, 0x2f,
- 0x30, 0xcf, 0x73, 0xbf, 0x37, 0x52, 0x87, 0x23, 0xd7, 0xbe, 0xba, 0x7c,
- 0xde, 0x50, 0xd3, 0x77, 0x9c, 0x06, 0x82, 0x28, 0x67, 0xc1, 0x1a, 0xf5,
- 0x8a, 0xa0, 0xf2, 0x32, 0x09, 0x95, 0x41, 0x41, 0x93, 0x8e, 0x62, 0xaa,
- 0xf3, 0xe3, 0x22, 0x17, 0x43, 0x94, 0x9b, 0x63, 0xfa, 0x68, 0x20, 0x69,
- 0x38, 0xf6, 0x75, 0x6c, 0xe0, 0x3b, 0xe0, 0x8d, 0x63, 0xac, 0x7f, 0xe3,
- 0x09, 0xd8, 0xde, 0x91, 0xc8, 0x1e, 0x07, 0x4a, 0xb2, 0x1e, 0xe1, 0xe3,
- 0xf4, 0x4d, 0x3e, 0x8a, 0xf4, 0xf8, 0x83, 0x39, 0x2b, 0x50, 0x98, 0x61,
- 0x91, 0x50, 0x00, 0x34, 0x57, 0xd2, 0x0d, 0xf7, 0xfa, 0xc9, 0xcc, 0xd9,
- 0x7a, 0x3d, 0x39, 0x7a, 0x1a, 0xbd, 0xf8, 0xbe, 0x65, 0xb6, 0xea, 0x4e,
- 0x86, 0x74, 0xdd, 0x51, 0x74, 0x6e, 0xa6, 0x7f, 0x14, 0x6c, 0x6a, 0x46,
- 0xb8, 0xaf, 0xcd, 0x6c, 0x78, 0x43, 0x76, 0x47, 0x5b, 0xdc, 0xb6, 0xf6,
- 0x4d, 0x1b, 0xe0, 0xb5, 0xf9, 0xa2, 0xb8, 0x26, 0x3f, 0x3f, 0xb8, 0x80,
- 0xed, 0xce, 0xfd, 0x0e, 0xcb, 0x48, 0x7a, 0x3b, 0xdf, 0x92, 0x44, 0x04,
- 0x81, 0xe4, 0xd3, 0x1e, 0x07, 0x9b, 0x02, 0xae, 0x05, 0x5a, 0x11, 0xf2,
- 0xc2, 0x75, 0x85, 0xd5, 0xf1, 0x53, 0x4c, 0x09, 0xd0, 0x99, 0xf8, 0x3e,
- 0xf6, 0x24, 0x46, 0xae, 0x83, 0x35, 0x3e, 0x6c, 0x8c, 0x2a, 0x9f, 0x1c,
- 0x5b, 0xfb, 0x89, 0x56};
-
-static const unsigned char kSha1Signature[] = {
- 0x52, 0x56, 0xcd, 0x53, 0xfa, 0xd9, 0x44, 0x31, 0x00, 0x2e, 0x85, 0x18,
- 0x56, 0xae, 0xf9, 0xf2, 0x70, 0x16, 0xc9, 0x59, 0x53, 0xc0, 0x17, 0xd9,
- 0x09, 0x65, 0x75, 0xee, 0xba, 0xc8, 0x0d, 0x06, 0x2e, 0xb7, 0x1b, 0xd0,
- 0x6a, 0x4d, 0x58, 0xde, 0x8e, 0xbe, 0x92, 0x22, 0x53, 0x19, 0xbf, 0x74,
- 0x8f, 0xb8, 0xfc, 0x3c, 0x9b, 0x42, 0x14, 0x7d, 0xe1, 0xfc, 0xa3, 0x71,
- 0x91, 0x6c, 0x5d, 0x28, 0x69, 0x8d, 0xd2, 0xde, 0xd1, 0x8f, 0xac, 0x6d,
- 0xf6, 0x48, 0xd8, 0x6f, 0x0e, 0xc9, 0x0a, 0xfa, 0xde, 0x20, 0xe0, 0x9d,
- 0x7a, 0xf8, 0x30, 0xa8, 0xd4, 0x79, 0x15, 0x63, 0xfb, 0x97, 0xa9, 0xef,
- 0x9f, 0x9c, 0xac, 0x16, 0xba, 0x1b, 0x2c, 0x14, 0xb4, 0xa4, 0x54, 0x5e,
- 0xec, 0x04, 0x10, 0x84, 0xc2, 0xa0, 0xd9, 0x6f, 0x05, 0xd4, 0x09, 0x8c,
- 0x85, 0xe9, 0x7a, 0xd1, 0x5a, 0xa3, 0x70, 0x00, 0x30, 0x9b, 0x19, 0x44,
- 0x2a, 0x90, 0x7a, 0xcd, 0x91, 0x94, 0x90, 0x66, 0xf9, 0x2e, 0x5e, 0x43,
- 0x27, 0x33, 0x2c, 0x45, 0xa7, 0xe2, 0x3a, 0x6d, 0xc9, 0x44, 0x58, 0x39,
- 0x45, 0xcb, 0xbd, 0x2f, 0xc5, 0xb4, 0x08, 0x41, 0x4d, 0x45, 0x67, 0x55,
- 0x0d, 0x43, 0x3c, 0xb6, 0x81, 0xbb, 0xb4, 0x34, 0x07, 0x10, 0x28, 0x17,
- 0xc2, 0xad, 0x40, 0x3b, 0xaf, 0xcb, 0xc0, 0xf6, 0x9d, 0x0e, 0x9b, 0xca,
- 0x2b, 0x20, 0xdf, 0xd0, 0xa3, 0xbe, 0xea, 0x3e, 0xe0, 0x82, 0x7b, 0x93,
- 0xfd, 0x9c, 0xaf, 0x97, 0x00, 0x05, 0x44, 0x91, 0x73, 0x68, 0x92, 0x3a,
- 0x8b, 0xbc, 0x0e, 0x96, 0x5e, 0x92, 0x98, 0x70, 0xab, 0xaa, 0x6e, 0x9a,
- 0x8e, 0xb0, 0xf4, 0x92, 0xc5, 0xa0, 0xa0, 0x4b, 0xb3, 0xd5, 0x44, 0x99,
- 0x8e, 0xa1, 0xd1, 0x8f, 0xe3, 0xac, 0x71, 0x1e, 0x3f, 0xc2, 0xfd, 0x0a,
- 0x57, 0xed, 0xea, 0x04};
-
class CastAuthUtilTest : public testing::Test {
public:
CastAuthUtilTest() {}
@@ -121,17 +25,21 @@ class CastAuthUtilTest : public testing::Test {
protected:
static AuthResponse CreateAuthResponse(std::string* signed_data) {
- auto chain = ReadCertificateChainFromFile("audio_ref_dev_test_chain_3.pem");
+ auto chain = cast_certificate::testing::ReadCertificateChainFromFile(
+ "certificates/chromecast_gen1.pem");
CHECK(!chain.empty());
+ auto signature_data = cast_certificate::testing::ReadSignatureTestData(
+ "signeddata/2ZZBG9_FA8FCA3EF91A.pem");
+
AuthResponse response;
response.set_client_auth_certificate(chain[0]);
for (size_t i = 1; i < chain.size(); ++i)
response.add_intermediate_certificate(chain[i]);
- response.set_signature(CreateString(kSha1Signature));
- *signed_data = CreateString(kSignedData);
+ response.set_signature(signature_data.signature_sha1);
+ *signed_data = signature_data.message;
return response;
}
@@ -140,12 +48,15 @@ class CastAuthUtilTest : public testing::Test {
static void MangleString(std::string* str) { (*str)[0] = ~(*str)[0]; }
};
+// Note on expiration: VerifyCredentials() depends on the system clock. In
+// practice this shouldn't be a problem though since the certificate chain
+// being verified doesn't expire until 2032!
TEST_F(CastAuthUtilTest, VerifySuccess) {
std::string signed_data;
AuthResponse auth_response = CreateAuthResponse(&signed_data);
AuthResult result = VerifyCredentials(auth_response, signed_data);
EXPECT_TRUE(result.success());
- EXPECT_EQ(AuthResult::POLICY_AUDIO_ONLY, result.channel_policies);
+ EXPECT_EQ(AuthResult::POLICY_NONE, result.channel_policies);
}
TEST_F(CastAuthUtilTest, VerifyBadCA) {
diff --git a/chromium/extensions/browser/api/cast_channel/cast_channel_api.cc b/chromium/extensions/browser/api/cast_channel/cast_channel_api.cc
index 2c57b392cd2..7856cbd27dd 100644
--- a/chromium/extensions/browser/api/cast_channel/cast_channel_api.cc
+++ b/chromium/extensions/browser/api/cast_channel/cast_channel_api.cc
@@ -8,12 +8,13 @@
#include <stdint.h>
#include <limits>
+#include <memory>
#include <string>
#include <utility>
#include "base/json/json_writer.h"
#include "base/lazy_instance.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/time/default_clock.h"
#include "base/values.h"
@@ -59,7 +60,7 @@ namespace {
// T is an extension dictionary (MessageInfo or ChannelInfo)
template <class T>
std::string ParamToString(const T& info) {
- scoped_ptr<base::DictionaryValue> dict = info.ToValue();
+ std::unique_ptr<base::DictionaryValue> dict = info.ToValue();
std::string out;
base::JSONWriter::Write(*dict, &out);
return out;
@@ -109,7 +110,7 @@ bool IsValidConnectInfoIpAddress(const ConnectInfo& connect_info) {
CastChannelAPI::CastChannelAPI(content::BrowserContext* context)
: browser_context_(context),
- logger_(new Logger(make_scoped_ptr<base::Clock>(new base::DefaultClock),
+ logger_(new Logger(base::WrapUnique<base::Clock>(new base::DefaultClock),
base::Time::UnixEpoch())) {
DCHECK(browser_context_);
}
@@ -124,7 +125,7 @@ scoped_refptr<Logger> CastChannelAPI::GetLogger() {
}
void CastChannelAPI::SendEvent(const std::string& extension_id,
- scoped_ptr<Event> event) {
+ std::unique_ptr<Event> event) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
EventRouter* event_router = EventRouter::Get(GetBrowserContext());
if (event_router) {
@@ -141,11 +142,12 @@ CastChannelAPI::GetFactoryInstance() {
return g_factory.Pointer();
}
-void CastChannelAPI::SetSocketForTest(scoped_ptr<CastSocket> socket_for_test) {
+void CastChannelAPI::SetSocketForTest(
+ std::unique_ptr<CastSocket> socket_for_test) {
socket_for_test_ = std::move(socket_for_test);
}
-scoped_ptr<CastSocket> CastChannelAPI::GetSocketForTest() {
+std::unique_ptr<CastSocket> CastChannelAPI::GetSocketForTest() {
return std::move(socket_for_test_);
}
@@ -153,11 +155,12 @@ content::BrowserContext* CastChannelAPI::GetBrowserContext() const {
return browser_context_;
}
-void CastChannelAPI::SetPingTimeoutTimerForTest(scoped_ptr<base::Timer> timer) {
+void CastChannelAPI::SetPingTimeoutTimerForTest(
+ std::unique_ptr<base::Timer> timer) {
injected_timeout_timer_ = std::move(timer);
}
-scoped_ptr<base::Timer> CastChannelAPI::GetInjectedTimeoutTimerForTest() {
+std::unique_ptr<base::Timer> CastChannelAPI::GetInjectedTimeoutTimerForTest() {
return std::move(injected_timeout_timer_);
}
@@ -302,7 +305,7 @@ void CastChannelOpenFunction::AsyncWorkStart() {
DCHECK(ip_endpoint_.get());
const ConnectInfo& connect_info = params_->connect_info;
CastSocket* socket;
- scoped_ptr<CastSocket> test_socket = api_->GetSocketForTest();
+ std::unique_ptr<CastSocket> test_socket = api_->GetSocketForTest();
if (test_socket.get()) {
socket = test_socket.release();
} else {
@@ -320,8 +323,8 @@ void CastChannelOpenFunction::AsyncWorkStart() {
api_->GetLogger()->LogNewSocketEvent(*socket);
// Construct read delegates.
- scoped_ptr<api::cast_channel::CastTransport::Delegate> delegate(
- make_scoped_ptr(new CastMessageHandler(
+ std::unique_ptr<api::cast_channel::CastTransport::Delegate> delegate(
+ base::WrapUnique(new CastMessageHandler(
base::Bind(&CastChannelAPI::SendEvent, api_->AsWeakPtr()), socket,
api_->GetLogger())));
if (socket->keep_alive()) {
@@ -330,11 +333,11 @@ void CastChannelOpenFunction::AsyncWorkStart() {
new api::cast_channel::KeepAliveDelegate(
socket, api_->GetLogger(), std::move(delegate), ping_interval_,
liveness_timeout_);
- scoped_ptr<base::Timer> injected_timer =
+ std::unique_ptr<base::Timer> injected_timer =
api_->GetInjectedTimeoutTimerForTest();
if (injected_timer) {
keep_alive->SetTimersForTest(
- make_scoped_ptr(new base::Timer(false, false)),
+ base::WrapUnique(new base::Timer(false, false)),
std::move(injected_timer));
}
delegate.reset(keep_alive);
@@ -475,7 +478,7 @@ void CastChannelGetLogsFunction::AsyncWorkStart() {
DCHECK(api_);
size_t length = 0;
- scoped_ptr<char[]> out = api_->GetLogger()->GetLogs(&length);
+ std::unique_ptr<char[]> out = api_->GetLogger()->GetLogs(&length);
if (out.get()) {
SetResult(new base::BinaryValue(std::move(out), length));
} else {
@@ -510,10 +513,10 @@ void CastChannelOpenFunction::CastMessageHandler::OnError(
FillErrorInfo(error_state, logger_->GetLastErrors(socket_->id()),
&error_info);
- scoped_ptr<base::ListValue> results =
+ std::unique_ptr<base::ListValue> results =
OnError::Create(channel_info, error_info);
- scoped_ptr<Event> event(new Event(events::CAST_CHANNEL_ON_ERROR,
- OnError::kEventName, std::move(results)));
+ std::unique_ptr<Event> event(new Event(
+ events::CAST_CHANNEL_ON_ERROR, OnError::kEventName, std::move(results)));
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(ui_dispatch_cb_, socket_->owner_extension_id(),
@@ -531,10 +534,11 @@ void CastChannelOpenFunction::CastMessageHandler::OnMessage(
VLOG(1) << "Received message " << ParamToString(message_info)
<< " on channel " << ParamToString(channel_info);
- scoped_ptr<base::ListValue> results =
+ std::unique_ptr<base::ListValue> results =
OnMessage::Create(channel_info, message_info);
- scoped_ptr<Event> event(new Event(events::CAST_CHANNEL_ON_MESSAGE,
- OnMessage::kEventName, std::move(results)));
+ std::unique_ptr<Event> event(new Event(events::CAST_CHANNEL_ON_MESSAGE,
+ OnMessage::kEventName,
+ std::move(results)));
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(ui_dispatch_cb_, socket_->owner_extension_id(),
diff --git a/chromium/extensions/browser/api/cast_channel/cast_channel_api.h b/chromium/extensions/browser/api/cast_channel/cast_channel_api.h
index b4cbba602e1..b526e73e691 100644
--- a/chromium/extensions/browser/api/cast_channel/cast_channel_api.h
+++ b/chromium/extensions/browser/api/cast_channel/cast_channel_api.h
@@ -5,12 +5,12 @@
#ifndef EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_
#define EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_
+#include <memory>
#include <string>
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/threading/thread_checker.h"
#include "extensions/browser/api/api_resource_manager.h"
#include "extensions/browser/api/async_api_function.h"
@@ -59,24 +59,25 @@ class CastChannelAPI : public BrowserContextKeyedAPI,
scoped_refptr<cast_channel::Logger> GetLogger();
// Sets the CastSocket instance to be used for testing.
- void SetSocketForTest(scoped_ptr<cast_channel::CastSocket> socket_for_test);
+ void SetSocketForTest(
+ std::unique_ptr<cast_channel::CastSocket> socket_for_test);
// Returns a test CastSocket instance, if it is defined.
// Otherwise returns a scoped_ptr with a nullptr value.
- scoped_ptr<cast_channel::CastSocket> GetSocketForTest();
+ std::unique_ptr<cast_channel::CastSocket> GetSocketForTest();
// Returns the API browser context.
content::BrowserContext* GetBrowserContext() const;
// Sets injected ping timeout timer for testing.
- void SetPingTimeoutTimerForTest(scoped_ptr<base::Timer> timer);
+ void SetPingTimeoutTimerForTest(std::unique_ptr<base::Timer> timer);
// Gets the injected ping timeout timer, if set.
// Returns a null scoped ptr if there is no injected timer.
- scoped_ptr<base::Timer> GetInjectedTimeoutTimerForTest();
+ std::unique_ptr<base::Timer> GetInjectedTimeoutTimerForTest();
// Sends an event to the extension's EventRouter, if it exists.
- void SendEvent(const std::string& extension_id, scoped_ptr<Event> event);
+ void SendEvent(const std::string& extension_id, std::unique_ptr<Event> event);
private:
friend class BrowserContextKeyedAPIFactory<CastChannelAPI>;
@@ -90,8 +91,8 @@ class CastChannelAPI : public BrowserContextKeyedAPI,
content::BrowserContext* const browser_context_;
scoped_refptr<cast_channel::Logger> logger_;
- scoped_ptr<cast_channel::CastSocket> socket_for_test_;
- scoped_ptr<base::Timer> injected_timeout_timer_;
+ std::unique_ptr<cast_channel::CastSocket> socket_for_test_;
+ std::unique_ptr<base::Timer> injected_timeout_timer_;
DISALLOW_COPY_AND_ASSIGN(CastChannelAPI);
};
@@ -163,7 +164,7 @@ class CastChannelOpenFunction : public CastChannelAsyncApiFunction {
// Parameter #0 is the extension's ID.
// Parameter #1 is a scoped pointer to the event payload.
using EventDispatchCallback =
- base::Callback<void(const std::string&, scoped_ptr<Event>)>;
+ base::Callback<void(const std::string&, std::unique_ptr<Event>)>;
// Receives incoming messages and errors and provides additional API and
// origin socket context.
@@ -198,11 +199,11 @@ class CastChannelOpenFunction : public CastChannelAsyncApiFunction {
void OnOpen(cast_channel::ChannelError result);
- scoped_ptr<cast_channel::Open::Params> params_;
+ std::unique_ptr<cast_channel::Open::Params> params_;
// The id of the newly opened socket.
int new_channel_id_;
CastChannelAPI* api_;
- scoped_ptr<net::IPEndPoint> ip_endpoint_;
+ std::unique_ptr<net::IPEndPoint> ip_endpoint_;
cast_channel::ChannelAuthType channel_auth_;
base::TimeDelta liveness_timeout_;
base::TimeDelta ping_interval_;
@@ -227,7 +228,7 @@ class CastChannelSendFunction : public CastChannelAsyncApiFunction {
void OnSend(int result);
- scoped_ptr<cast_channel::Send::Params> params_;
+ std::unique_ptr<cast_channel::Send::Params> params_;
DISALLOW_COPY_AND_ASSIGN(CastChannelSendFunction);
};
@@ -248,7 +249,7 @@ class CastChannelCloseFunction : public CastChannelAsyncApiFunction {
void OnClose(int result);
- scoped_ptr<cast_channel::Close::Params> params_;
+ std::unique_ptr<cast_channel::Close::Params> params_;
DISALLOW_COPY_AND_ASSIGN(CastChannelCloseFunction);
};
diff --git a/chromium/extensions/browser/api/cast_channel/cast_channel_api_unittest.cc b/chromium/extensions/browser/api/cast_channel/cast_channel_api_unittest.cc
index 5587194d45e..6cc9124e2ae 100644
--- a/chromium/extensions/browser/api/cast_channel/cast_channel_api_unittest.cc
+++ b/chromium/extensions/browser/api/cast_channel/cast_channel_api_unittest.cc
@@ -4,7 +4,8 @@
#include "extensions/browser/api/cast_channel/cast_channel_api.h"
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "net/base/ip_endpoint.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -15,7 +16,7 @@ namespace cast_channel {
// Tests parsing of ConnectInfo.
TEST(CastChannelOpenFunctionTest, TestParseConnectInfo) {
typedef CastChannelOpenFunction ccof;
- scoped_ptr<net::IPEndPoint> ip_endpoint;
+ std::unique_ptr<net::IPEndPoint> ip_endpoint;
// Valid ConnectInfo
ConnectInfo connect_info;
diff --git a/chromium/extensions/browser/api/cast_channel/cast_channel_apitest.cc b/chromium/extensions/browser/api/cast_channel/cast_channel_apitest.cc
index 84958b263da..e578b5deca7 100644
--- a/chromium/extensions/browser/api/cast_channel/cast_channel_apitest.cc
+++ b/chromium/extensions/browser/api/cast_channel/cast_channel_apitest.cc
@@ -5,6 +5,7 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
+#include "base/memory/ptr_util.h"
#include "base/timer/mock_timer.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/extension_apitest.h"
@@ -94,12 +95,12 @@ class CastChannelAPITest : public ExtensionApiTest {
void SetUpMockCastSocket() {
extensions::CastChannelAPI* api = GetApi();
timeout_timer_ = new base::MockTimer(true, false);
- api->SetPingTimeoutTimerForTest(make_scoped_ptr(timeout_timer_));
+ api->SetPingTimeoutTimerForTest(base::WrapUnique(timeout_timer_));
net::IPEndPoint ip_endpoint(net::IPAddress(192, 168, 1, 1), 8009);
mock_cast_socket_ = new MockCastSocket;
// Transfers ownership of the socket.
- api->SetSocketForTest(make_scoped_ptr<CastSocket>(mock_cast_socket_));
+ api->SetSocketForTest(base::WrapUnique<CastSocket>(mock_cast_socket_));
ON_CALL(*mock_cast_socket_, set_id(_))
.WillByDefault(SaveArg<0>(&channel_id_));
ON_CALL(*mock_cast_socket_, id())
diff --git a/chromium/extensions/browser/api/cast_channel/cast_framer.cc b/chromium/extensions/browser/api/cast_channel/cast_framer.cc
index a5dcf3e816c..c0dec4957b6 100644
--- a/chromium/extensions/browser/api/cast_channel/cast_framer.cc
+++ b/chromium/extensions/browser/api/cast_channel/cast_framer.cc
@@ -40,7 +40,7 @@ void MessageFramer::MessageHeader::PrependToString(std::string* str) {
MessageHeader output = *this;
output.message_size = base::HostToNet32(message_size);
size_t header_size = MessageHeader::header_size();
- scoped_ptr<char, base::FreeDeleter> char_array(
+ std::unique_ptr<char, base::FreeDeleter> char_array(
static_cast<char*>(malloc(header_size)));
memcpy(char_array.get(), &output, header_size);
str->insert(0, char_array.get(), header_size);
@@ -113,14 +113,14 @@ size_t MessageFramer::BytesRequested() {
}
}
-scoped_ptr<CastMessage> MessageFramer::Ingest(size_t num_bytes,
- size_t* message_length,
- ChannelError* error) {
+std::unique_ptr<CastMessage> MessageFramer::Ingest(size_t num_bytes,
+ size_t* message_length,
+ ChannelError* error) {
DCHECK(error);
DCHECK(message_length);
if (error_) {
*error = CHANNEL_ERROR_INVALID_MESSAGE;
- return scoped_ptr<CastMessage>();
+ return nullptr;
}
DCHECK_EQ(base::checked_cast<int32_t>(message_bytes_received_),
@@ -139,7 +139,7 @@ scoped_ptr<CastMessage> MessageFramer::Ingest(size_t num_bytes,
VLOG(1) << "Error parsing header (message size too large).";
*error = CHANNEL_ERROR_INVALID_MESSAGE;
error_ = true;
- return scoped_ptr<CastMessage>();
+ return nullptr;
}
current_element_ = BODY;
body_size_ = header.message_size;
@@ -147,14 +147,14 @@ scoped_ptr<CastMessage> MessageFramer::Ingest(size_t num_bytes,
break;
case BODY:
if (BytesRequested() == 0) {
- scoped_ptr<CastMessage> parsed_message(new CastMessage);
+ std::unique_ptr<CastMessage> parsed_message(new CastMessage);
if (!parsed_message->ParseFromArray(
input_buffer_->StartOfBuffer() + MessageHeader::header_size(),
body_size_)) {
VLOG(1) << "Error parsing packet body.";
*error = CHANNEL_ERROR_INVALID_MESSAGE;
error_ = true;
- return scoped_ptr<CastMessage>();
+ return nullptr;
}
*message_length = body_size_;
Reset();
@@ -163,11 +163,11 @@ scoped_ptr<CastMessage> MessageFramer::Ingest(size_t num_bytes,
break;
default:
NOTREACHED() << "Unhandled packet element type.";
- return scoped_ptr<CastMessage>();
+ return nullptr;
}
input_buffer_->set_offset(message_bytes_received_);
- return scoped_ptr<CastMessage>();
+ return nullptr;
}
void MessageFramer::Reset() {
diff --git a/chromium/extensions/browser/api/cast_channel/cast_framer.h b/chromium/extensions/browser/api/cast_channel/cast_framer.h
index 093d6e56526..ec8fcfe6088 100644
--- a/chromium/extensions/browser/api/cast_channel/cast_framer.h
+++ b/chromium/extensions/browser/api/cast_channel/cast_framer.h
@@ -8,6 +8,7 @@
#include <stddef.h>
#include <stdint.h>
+#include <memory>
#include <string>
#include "base/macros.h"
@@ -48,9 +49,9 @@ class MessageFramer {
// if no error occurred.
// Returns A pointer to a parsed CastMessage if a message was received
// in its entirety, nullptr otherwise.
- scoped_ptr<CastMessage> Ingest(size_t num_bytes,
- size_t* message_length,
- ChannelError* error);
+ std::unique_ptr<CastMessage> Ingest(size_t num_bytes,
+ size_t* message_length,
+ ChannelError* error);
// Message header struct. If fields are added, be sure to update
// header_size(). Public to allow use of *_size() methods in unit tests.
diff --git a/chromium/extensions/browser/api/cast_channel/cast_framer_unittest.cc b/chromium/extensions/browser/api/cast_channel/cast_framer_unittest.cc
index 0ff96831973..4000e1a7ab6 100644
--- a/chromium/extensions/browser/api/cast_channel/cast_framer_unittest.cc
+++ b/chromium/extensions/browser/api/cast_channel/cast_framer_unittest.cc
@@ -42,7 +42,7 @@ class CastFramerTest : public testing::Test {
CastMessage cast_message_;
std::string cast_message_str_;
scoped_refptr<net::GrowableIOBuffer> buffer_;
- scoped_ptr<MessageFramer> framer_;
+ std::unique_ptr<MessageFramer> framer_;
};
TEST_F(CastFramerTest, TestMessageFramerCompleteMessage) {
@@ -66,7 +66,7 @@ TEST_F(CastFramerTest, TestMessageFramerCompleteMessage) {
framer_->BytesRequested());
// Remainder of packet sent over the wire.
- scoped_ptr<CastMessage> message;
+ std::unique_ptr<CastMessage> message;
message = framer_->Ingest(framer_->BytesRequested(), &message_length, &error);
EXPECT_NE(static_cast<CastMessage*>(nullptr), message.get());
EXPECT_EQ(cast_channel::CHANNEL_ERROR_NONE, error);
@@ -130,7 +130,7 @@ TEST_F(CastFramerTest, TestUnparsableBodyProto) {
EXPECT_EQ(cast_message_str_.size() - 4, framer_->BytesRequested());
// Send body, expect an error.
- scoped_ptr<CastMessage> message;
+ std::unique_ptr<CastMessage> message;
EXPECT_EQ(nullptr, framer_->Ingest(framer_->BytesRequested(), &message_length,
&error).get());
EXPECT_EQ(cast_channel::CHANNEL_ERROR_INVALID_MESSAGE, error);
diff --git a/chromium/extensions/browser/api/cast_channel/cast_message_util.cc b/chromium/extensions/browser/api/cast_channel/cast_message_util.cc
index 76fa2d0218a..f81b20aa17c 100644
--- a/chromium/extensions/browser/api/cast_channel/cast_message_util.cc
+++ b/chromium/extensions/browser/api/cast_channel/cast_message_util.cc
@@ -4,8 +4,9 @@
#include "extensions/browser/api/cast_channel/cast_message_util.h"
+#include <memory>
+
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#include "extensions/common/api/cast_channel.h"
@@ -80,7 +81,7 @@ bool CastMessageToMessageInfo(const CastMessage& message_proto,
message->destination_id = message_proto.destination_id();
message->namespace_ = message_proto.namespace_();
// Determine the type of the payload and fill base::Value appropriately.
- scoped_ptr<base::Value> value;
+ std::unique_ptr<base::Value> value;
switch (message_proto.payload_type()) {
case CastMessage_PayloadType_STRING:
if (message_proto.has_payload_utf8())
diff --git a/chromium/extensions/browser/api/cast_channel/cast_socket.cc b/chromium/extensions/browser/api/cast_channel/cast_socket.cc
index 12df2bf382e..038bdceaf7c 100644
--- a/chromium/extensions/browser/api/cast_channel/cast_socket.cc
+++ b/chromium/extensions/browser/api/cast_channel/cast_socket.cc
@@ -6,12 +6,14 @@
#include <stdlib.h>
#include <string.h>
+
#include <utility>
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/format_macros.h"
#include "base/lazy_instance.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/string_number_conversions.h"
@@ -83,7 +85,7 @@ class FakeCertVerifier : public net::CertVerifier {
net::CRLSet*,
net::CertVerifyResult* verify_result,
const net::CompletionCallback&,
- scoped_ptr<net::CertVerifier::Request>*,
+ std::unique_ptr<net::CertVerifier::Request>*,
const net::BoundNetLog&) override {
verify_result->Reset();
verify_result->verified_cert = cert;
@@ -171,19 +173,19 @@ bool CastSocketImpl::audio_only() const {
return audio_only_;
}
-scoped_ptr<net::TCPClientSocket> CastSocketImpl::CreateTcpSocket() {
+std::unique_ptr<net::TCPClientSocket> CastSocketImpl::CreateTcpSocket() {
net::AddressList addresses(ip_endpoint_);
- return scoped_ptr<net::TCPClientSocket>(
- new net::TCPClientSocket(addresses, net_log_, net_log_source_));
+ return std::unique_ptr<net::TCPClientSocket>(
+ new net::TCPClientSocket(addresses, nullptr, net_log_, net_log_source_));
// Options cannot be set on the TCPClientSocket yet, because the
// underlying platform socket will not be created until Bind()
// or Connect() is called.
}
-scoped_ptr<net::SSLClientSocket> CastSocketImpl::CreateSslSocket(
- scoped_ptr<net::StreamSocket> socket) {
+std::unique_ptr<net::SSLClientSocket> CastSocketImpl::CreateSslSocket(
+ std::unique_ptr<net::StreamSocket> socket) {
net::SSLConfig ssl_config;
- cert_verifier_ = make_scoped_ptr(new FakeCertVerifier);
+ cert_verifier_ = base::WrapUnique(new FakeCertVerifier);
transport_security_state_.reset(new net::TransportSecurityState);
net::SSLClientSocketContext context;
// CertVerifier and TransportSecurityState are owned by us, not the
@@ -191,7 +193,8 @@ scoped_ptr<net::SSLClientSocket> CastSocketImpl::CreateSslSocket(
context.cert_verifier = cert_verifier_.get();
context.transport_security_state = transport_security_state_.get();
- scoped_ptr<net::ClientSocketHandle> connection(new net::ClientSocketHandle);
+ std::unique_ptr<net::ClientSocketHandle> connection(
+ new net::ClientSocketHandle);
connection->SetSocket(std::move(socket));
net::HostPortPair host_and_port = net::HostPortPair::FromIPEndPoint(
ip_endpoint_);
@@ -239,11 +242,11 @@ bool CastSocketImpl::VerifyChallengeReply() {
}
void CastSocketImpl::SetTransportForTesting(
- scoped_ptr<CastTransport> transport) {
+ std::unique_ptr<CastTransport> transport) {
transport_ = std::move(transport);
}
-void CastSocketImpl::Connect(scoped_ptr<CastTransport::Delegate> delegate,
+void CastSocketImpl::Connect(std::unique_ptr<CastTransport::Delegate> delegate,
base::Callback<void(ChannelError)> callback) {
DCHECK(CalledOnValidThread());
VLOG_WITH_CONNECTION(1) << "Connect readyState = " << ready_state_;
@@ -425,7 +428,7 @@ int CastSocketImpl::DoSslConnectComplete(int result) {
logger_));
}
auth_delegate_ = new AuthTransportDelegate(this);
- transport_->SetReadDelegate(make_scoped_ptr(auth_delegate_));
+ transport_->SetReadDelegate(base::WrapUnique(auth_delegate_));
if (channel_auth_ == CHANNEL_AUTH_TYPE_SSL_VERIFIED) {
// Additionally verify the connection with a handshake.
SetConnectState(proto::CONN_STATE_AUTH_CHALLENGE_SEND);
diff --git a/chromium/extensions/browser/api/cast_channel/cast_socket.h b/chromium/extensions/browser/api/cast_channel/cast_socket.h
index 35edd4d84f6..3f04b207ddb 100644
--- a/chromium/extensions/browser/api/cast_channel/cast_socket.h
+++ b/chromium/extensions/browser/api/cast_channel/cast_socket.h
@@ -72,7 +72,7 @@ class CastSocket : public ApiResource {
// CHANNEL_ERROR_NONE if successful.
// |delegate| receives message receipt and error events.
// Ownership of |delegate| is transferred to this CastSocket.
- virtual void Connect(scoped_ptr<CastTransport::Delegate> delegate,
+ virtual void Connect(std::unique_ptr<CastTransport::Delegate> delegate,
base::Callback<void(ChannelError)> callback) = 0;
// Closes the channel if not already closed. On completion, the channel will
@@ -157,7 +157,7 @@ class CastSocketImpl : public CastSocket {
~CastSocketImpl() override;
// CastSocket interface.
- void Connect(scoped_ptr<CastTransport::Delegate> delegate,
+ void Connect(std::unique_ptr<CastTransport::Delegate> delegate,
base::Callback<void(ChannelError)> callback) override;
CastTransport* transport() const override;
void Close(const net::CompletionCallback& callback) override;
@@ -199,7 +199,7 @@ class CastSocketImpl : public CastSocket {
// Replaces the internally-constructed transport object with one provided
// by the caller (e.g. a mock).
- void SetTransportForTesting(scoped_ptr<CastTransport> transport);
+ void SetTransportForTesting(std::unique_ptr<CastTransport> transport);
// Verifies whether the socket complies with cast channel policy.
// Audio only channel policy mandates that a device declaring a video out
@@ -225,10 +225,10 @@ class CastSocketImpl : public CastSocket {
void CloseInternal();
// Creates an instance of TCPClientSocket.
- virtual scoped_ptr<net::TCPClientSocket> CreateTcpSocket();
+ virtual std::unique_ptr<net::TCPClientSocket> CreateTcpSocket();
// Creates an instance of SSLClientSocket with the given underlying |socket|.
- virtual scoped_ptr<net::SSLClientSocket> CreateSslSocket(
- scoped_ptr<net::StreamSocket> socket);
+ virtual std::unique_ptr<net::SSLClientSocket> CreateSslSocket(
+ std::unique_ptr<net::StreamSocket> socket);
// Extracts peer certificate from SSLClientSocket instance when the socket
// is in cert error state.
// Returns null if the certificate could not be extracted.
@@ -304,21 +304,21 @@ class CastSocketImpl : public CastSocket {
// CertVerifier is owned by us but should be deleted AFTER SSLClientSocket
// since in some cases the destructor of SSLClientSocket may call a method
// to cancel a cert verification request.
- scoped_ptr<net::CertVerifier> cert_verifier_;
- scoped_ptr<net::TransportSecurityState> transport_security_state_;
+ std::unique_ptr<net::CertVerifier> cert_verifier_;
+ std::unique_ptr<net::TransportSecurityState> transport_security_state_;
// Owned ptr to the underlying TCP socket.
- scoped_ptr<net::TCPClientSocket> tcp_socket_;
+ std::unique_ptr<net::TCPClientSocket> tcp_socket_;
// Owned ptr to the underlying SSL socket.
- scoped_ptr<net::SSLClientSocket> socket_;
+ std::unique_ptr<net::SSLClientSocket> socket_;
// Certificate of the peer. This field may be empty if the peer
// certificate is not yet fetched.
scoped_refptr<net::X509Certificate> peer_cert_;
// Reply received from the receiver to a challenge request.
- scoped_ptr<CastMessage> challenge_reply_;
+ std::unique_ptr<CastMessage> challenge_reply_;
// Callback invoked when the socket is connected or fails to connect.
base::Callback<void(ChannelError)> connect_callback_;
@@ -330,7 +330,7 @@ class CastSocketImpl : public CastSocket {
base::TimeDelta connect_timeout_;
// Timer invoked when the connection has timed out.
- scoped_ptr<base::Timer> connect_timeout_timer_;
+ std::unique_ptr<base::Timer> connect_timeout_timer_;
// Set when a timeout is triggered and the connection process has
// canceled.
@@ -367,10 +367,10 @@ class CastSocketImpl : public CastSocket {
base::CancelableClosure send_auth_challenge_callback_;
// Cast message formatting and parsing layer.
- scoped_ptr<CastTransport> transport_;
+ std::unique_ptr<CastTransport> transport_;
// Caller's message read and error handling delegate.
- scoped_ptr<CastTransport::Delegate> delegate_;
+ std::unique_ptr<CastTransport::Delegate> delegate_;
// Raw pointer to the auth handshake delegate. Used to get detailed error
// information.
diff --git a/chromium/extensions/browser/api/cast_channel/cast_socket_unittest.cc b/chromium/extensions/browser/api/cast_channel/cast_socket_unittest.cc
index dbc46dcef32..4db753a1775 100644
--- a/chromium/extensions/browser/api/cast_channel/cast_socket_unittest.cc
+++ b/chromium/extensions/browser/api/cast_channel/cast_socket_unittest.cc
@@ -10,6 +10,7 @@
#include <vector>
#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/run_loop.h"
@@ -83,12 +84,18 @@ CastMessage CreateTestMessage() {
class MockTCPSocket : public net::TCPClientSocket {
public:
explicit MockTCPSocket(const net::MockConnect& connect_data)
- : TCPClientSocket(net::AddressList(), nullptr, net::NetLog::Source()),
+ : TCPClientSocket(net::AddressList(),
+ nullptr,
+ nullptr,
+ net::NetLog::Source()),
connect_data_(connect_data),
do_nothing_(false) {}
explicit MockTCPSocket(bool do_nothing)
- : TCPClientSocket(net::AddressList(), nullptr, net::NetLog::Source()) {
+ : TCPClientSocket(net::AddressList(),
+ nullptr,
+ nullptr,
+ net::NetLog::Source()) {
CHECK(do_nothing);
do_nothing_ = do_nothing;
}
@@ -162,18 +169,18 @@ class CompleteHandler {
class TestCastSocket : public CastSocketImpl {
public:
- static scoped_ptr<TestCastSocket> Create(
+ static std::unique_ptr<TestCastSocket> Create(
Logger* logger,
uint64_t device_capabilities = cast_channel::CastDeviceCapability::NONE) {
- return scoped_ptr<TestCastSocket>(
+ return std::unique_ptr<TestCastSocket>(
new TestCastSocket(CreateIPEndPointForTest(), CHANNEL_AUTH_TYPE_SSL,
kDistantTimeoutMillis, logger, device_capabilities));
}
- static scoped_ptr<TestCastSocket> CreateSecure(
+ static std::unique_ptr<TestCastSocket> CreateSecure(
Logger* logger,
uint64_t device_capabilities = cast_channel::CastDeviceCapability::NONE) {
- return scoped_ptr<TestCastSocket>(new TestCastSocket(
+ return std::unique_ptr<TestCastSocket>(new TestCastSocket(
CreateIPEndPointForTest(), CHANNEL_AUTH_TYPE_SSL_VERIFIED,
kDistantTimeoutMillis, logger, device_capabilities));
}
@@ -203,7 +210,7 @@ class TestCastSocket : public CastSocketImpl {
void SetupMockTransport() {
mock_transport_ = new MockCastTransport;
- SetTransportForTesting(make_scoped_ptr(mock_transport_));
+ SetTransportForTesting(base::WrapUnique(mock_transport_));
}
// Socket connection helpers.
@@ -268,18 +275,19 @@ class TestCastSocket : public CastSocketImpl {
}
private:
- scoped_ptr<net::TCPClientSocket> CreateTcpSocket() override {
+ std::unique_ptr<net::TCPClientSocket> CreateTcpSocket() override {
if (tcp_unresponsive_) {
- return scoped_ptr<net::TCPClientSocket>(new MockTCPSocket(true));
+ return std::unique_ptr<net::TCPClientSocket>(new MockTCPSocket(true));
} else {
net::MockConnect* connect_data = tcp_connect_data_.get();
connect_data->peer_addr = ip_;
- return scoped_ptr<net::TCPClientSocket>(new MockTCPSocket(*connect_data));
+ return std::unique_ptr<net::TCPClientSocket>(
+ new MockTCPSocket(*connect_data));
}
}
- scoped_ptr<net::SSLClientSocket> CreateSslSocket(
- scoped_ptr<net::StreamSocket> socket) override {
+ std::unique_ptr<net::SSLClientSocket> CreateSslSocket(
+ std::unique_ptr<net::StreamSocket> socket) override {
net::MockConnect* connect_data = ssl_connect_data_.get();
connect_data->peer_addr = ip_;
@@ -287,9 +295,8 @@ class TestCastSocket : public CastSocketImpl {
reads_.data(), reads_.size(), writes_.data(), writes_.size()));
ssl_data_->set_connect_data(*connect_data);
// NOTE: net::MockTCPClientSocket inherits from net::SSLClientSocket !!
- return scoped_ptr<net::SSLClientSocket>(
- new net::MockTCPClientSocket(
- net::AddressList(), &capturing_net_log_, ssl_data_.get()));
+ return std::unique_ptr<net::SSLClientSocket>(new net::MockTCPClientSocket(
+ net::AddressList(), &capturing_net_log_, ssl_data_.get()));
}
scoped_refptr<net::X509Certificate> ExtractPeerCert() override {
@@ -309,12 +316,12 @@ class TestCastSocket : public CastSocketImpl {
net::TestNetLog capturing_net_log_;
net::IPEndPoint ip_;
// Simulated connect data
- scoped_ptr<net::MockConnect> tcp_connect_data_;
- scoped_ptr<net::MockConnect> ssl_connect_data_;
+ std::unique_ptr<net::MockConnect> tcp_connect_data_;
+ std::unique_ptr<net::MockConnect> ssl_connect_data_;
// Simulated read / write data
std::vector<net::MockWrite> writes_;
std::vector<net::MockRead> reads_;
- scoped_ptr<net::SocketDataProvider> ssl_data_;
+ std::unique_ptr<net::SocketDataProvider> ssl_data_;
// Simulated result of peer cert extraction.
bool extract_cert_result_;
// Simulated result of verifying challenge reply.
@@ -322,7 +329,7 @@ class TestCastSocket : public CastSocketImpl {
bool verify_challenge_disallow_;
// If true, makes TCP connection process stall. For timeout testing.
bool tcp_unresponsive_;
- scoped_ptr<base::MockTimer> mock_timer_;
+ std::unique_ptr<base::MockTimer> mock_timer_;
MockCastTransport* mock_transport_;
DISALLOW_COPY_AND_ASSIGN(TestCastSocket);
@@ -332,7 +339,7 @@ class CastSocketTest : public testing::Test {
public:
CastSocketTest()
: logger_(
- new Logger(make_scoped_ptr<base::Clock>(new base::SimpleTestClock),
+ new Logger(base::WrapUnique<base::Clock>(new base::SimpleTestClock),
base::Time())),
delegate_(new MockDelegate) {}
~CastSocketTest() override {}
@@ -379,9 +386,9 @@ class CastSocketTest : public testing::Test {
base::MessageLoop message_loop_;
Logger* logger_;
- scoped_ptr<TestCastSocket> socket_;
+ std::unique_ptr<TestCastSocket> socket_;
CompleteHandler handler_;
- scoped_ptr<MockDelegate> delegate_;
+ std::unique_ptr<MockDelegate> delegate_;
private:
DISALLOW_COPY_AND_ASSIGN(CastSocketTest);
diff --git a/chromium/extensions/browser/api/cast_channel/cast_test_util.cc b/chromium/extensions/browser/api/cast_channel/cast_test_util.cc
index 13a19641f2e..7a115f2bf6d 100644
--- a/chromium/extensions/browser/api/cast_channel/cast_test_util.cc
+++ b/chromium/extensions/browser/api/cast_channel/cast_test_util.cc
@@ -25,7 +25,7 @@ CastTransport::Delegate* MockCastTransport::current_delegate() const {
}
void MockCastTransport::SetReadDelegate(
- scoped_ptr<CastTransport::Delegate> delegate) {
+ std::unique_ptr<CastTransport::Delegate> delegate) {
delegate_ = std::move(delegate);
}
diff --git a/chromium/extensions/browser/api/cast_channel/cast_test_util.h b/chromium/extensions/browser/api/cast_channel/cast_test_util.h
index 550a460a66a..0c8d75551e0 100644
--- a/chromium/extensions/browser/api/cast_channel/cast_test_util.h
+++ b/chromium/extensions/browser/api/cast_channel/cast_test_util.h
@@ -27,7 +27,8 @@ class MockCastTransport : public extensions::api::cast_channel::CastTransport {
MockCastTransport();
~MockCastTransport() override;
- void SetReadDelegate(scoped_ptr<CastTransport::Delegate> delegate) override;
+ void SetReadDelegate(
+ std::unique_ptr<CastTransport::Delegate> delegate) override;
MOCK_METHOD2(SendMessage,
void(const extensions::api::cast_channel::CastMessage& message,
@@ -39,7 +40,7 @@ class MockCastTransport : public extensions::api::cast_channel::CastTransport {
CastTransport::Delegate* current_delegate() const;
private:
- scoped_ptr<CastTransport::Delegate> delegate_;
+ std::unique_ptr<CastTransport::Delegate> delegate_;
DISALLOW_COPY_AND_ASSIGN(MockCastTransport);
};
@@ -70,7 +71,7 @@ class MockCastSocket : public CastSocket {
// Proxy for ConnectRawPtr. Unpacks scoped_ptr into a GMock-friendly bare
// ptr.
- void Connect(scoped_ptr<CastTransport::Delegate> delegate,
+ void Connect(std::unique_ptr<CastTransport::Delegate> delegate,
base::Callback<void(ChannelError)> callback) override {
delegate_ = std::move(delegate);
ConnectRawPtr(delegate_.get(), callback);
@@ -92,8 +93,8 @@ class MockCastSocket : public CastSocket {
MockCastTransport* mock_transport() const { return mock_transport_.get(); }
private:
- scoped_ptr<MockCastTransport> mock_transport_;
- scoped_ptr<CastTransport::Delegate> delegate_;
+ std::unique_ptr<MockCastTransport> mock_transport_;
+ std::unique_ptr<CastTransport::Delegate> delegate_;
DISALLOW_COPY_AND_ASSIGN(MockCastSocket);
};
diff --git a/chromium/extensions/browser/api/cast_channel/cast_transport.cc b/chromium/extensions/browser/api/cast_channel/cast_transport.cc
index 8a22af65a2b..a11cc6ffbc4 100644
--- a/chromium/extensions/browser/api/cast_channel/cast_transport.cc
+++ b/chromium/extensions/browser/api/cast_channel/cast_transport.cc
@@ -144,7 +144,7 @@ proto::ErrorState CastTransportImpl::ErrorStateToProto(ChannelError state) {
}
}
-void CastTransportImpl::SetReadDelegate(scoped_ptr<Delegate> delegate) {
+void CastTransportImpl::SetReadDelegate(std::unique_ptr<Delegate> delegate) {
DCHECK(CalledOnValidThread());
DCHECK(delegate);
delegate_ = std::move(delegate);
diff --git a/chromium/extensions/browser/api/cast_channel/cast_transport.h b/chromium/extensions/browser/api/cast_channel/cast_transport.h
index 740bd5f1d3b..5d52968f0fe 100644
--- a/chromium/extensions/browser/api/cast_channel/cast_transport.h
+++ b/chromium/extensions/browser/api/cast_channel/cast_transport.h
@@ -71,7 +71,7 @@ class CastTransport {
// in-flight.
// Ownership of the pointee of |delegate| is assumed by the transport.
// Prior delegates are deleted automatically.
- virtual void SetReadDelegate(scoped_ptr<Delegate> delegate) = 0;
+ virtual void SetReadDelegate(std::unique_ptr<Delegate> delegate) = 0;
};
// Manager class for reading and writing messages to/from a socket.
@@ -95,7 +95,7 @@ class CastTransportImpl : public CastTransport, public base::NonThreadSafe {
void SendMessage(const CastMessage& message,
const net::CompletionCallback& callback) override;
void Start() override;
- void SetReadDelegate(scoped_ptr<Delegate> delegate) override;
+ void SetReadDelegate(std::unique_ptr<Delegate> delegate) override;
private:
// Internal write states.
@@ -185,16 +185,16 @@ class CastTransportImpl : public CastTransport, public base::NonThreadSafe {
scoped_refptr<net::GrowableIOBuffer> read_buffer_;
// Constructs and parses the wire representation of message frames.
- scoped_ptr<MessageFramer> framer_;
+ std::unique_ptr<MessageFramer> framer_;
// Last message received on the socket.
- scoped_ptr<CastMessage> current_message_;
+ std::unique_ptr<CastMessage> current_message_;
// Socket used for I/O operations.
net::Socket* const socket_;
// Methods for communicating message receipt and error status to client code.
- scoped_ptr<Delegate> delegate_;
+ std::unique_ptr<Delegate> delegate_;
// Write flow state machine state.
WriteState write_state_;
diff --git a/chromium/extensions/browser/api/cast_channel/cast_transport_unittest.cc b/chromium/extensions/browser/api/cast_channel/cast_transport_unittest.cc
index d8cc6f42ba8..3884d61c62b 100644
--- a/chromium/extensions/browser/api/cast_channel/cast_transport_unittest.cc
+++ b/chromium/extensions/browser/api/cast_channel/cast_transport_unittest.cc
@@ -6,9 +6,11 @@
#include <stddef.h>
#include <stdint.h>
+
#include <queue>
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/test/simple_test_clock.h"
@@ -147,13 +149,13 @@ class CastTransportTest : public testing::Test {
public:
CastTransportTest()
: logger_(
- new Logger(make_scoped_ptr<base::Clock>(new base::SimpleTestClock),
+ new Logger(base::WrapUnique<base::Clock>(new base::SimpleTestClock),
base::Time())) {
delegate_ = new MockCastTransportDelegate;
transport_.reset(new CastTransportImpl(&mock_socket_, kChannelId,
CreateIPEndPointForTest(),
auth_type_, logger_));
- transport_->SetReadDelegate(make_scoped_ptr(delegate_));
+ transport_->SetReadDelegate(base::WrapUnique(delegate_));
}
~CastTransportTest() override {}
@@ -169,7 +171,7 @@ class CastTransportTest : public testing::Test {
MockSocket mock_socket_;
ChannelAuthType auth_type_;
Logger* logger_;
- scoped_ptr<CastTransport> transport_;
+ std::unique_ptr<CastTransport> transport_;
};
// ----------------------------------------------------------------------------
diff --git a/chromium/extensions/browser/api/cast_channel/keep_alive_delegate.cc b/chromium/extensions/browser/api/cast_channel/keep_alive_delegate.cc
index fe1bd9167fc..f77c9b0beb0 100644
--- a/chromium/extensions/browser/api/cast_channel/keep_alive_delegate.cc
+++ b/chromium/extensions/browser/api/cast_channel/keep_alive_delegate.cc
@@ -36,7 +36,7 @@ bool NestedPayloadTypeEquals(const std::string& chk_type,
if (!message_info.data->GetAsString(&type_json)) {
return false;
}
- scoped_ptr<base::Value> type_value(base::JSONReader::Read(type_json));
+ std::unique_ptr<base::Value> type_value(base::JSONReader::Read(type_json));
if (!type_value.get()) {
return false;
}
@@ -82,7 +82,7 @@ CastMessage KeepAliveDelegate::CreateKeepAliveMessage(
KeepAliveDelegate::KeepAliveDelegate(
CastSocket* socket,
scoped_refptr<Logger> logger,
- scoped_ptr<CastTransport::Delegate> inner_delegate,
+ std::unique_ptr<CastTransport::Delegate> inner_delegate,
base::TimeDelta ping_interval,
base::TimeDelta liveness_timeout)
: started_(false),
@@ -102,8 +102,8 @@ KeepAliveDelegate::~KeepAliveDelegate() {
}
void KeepAliveDelegate::SetTimersForTest(
- scoped_ptr<base::Timer> injected_ping_timer,
- scoped_ptr<base::Timer> injected_liveness_timer) {
+ std::unique_ptr<base::Timer> injected_ping_timer,
+ std::unique_ptr<base::Timer> injected_liveness_timer) {
ping_timer_ = std::move(injected_ping_timer);
liveness_timer_ = std::move(injected_liveness_timer);
}
diff --git a/chromium/extensions/browser/api/cast_channel/keep_alive_delegate.h b/chromium/extensions/browser/api/cast_channel/keep_alive_delegate.h
index 27b3738eab3..0ecdf83edd3 100644
--- a/chromium/extensions/browser/api/cast_channel/keep_alive_delegate.h
+++ b/chromium/extensions/browser/api/cast_channel/keep_alive_delegate.h
@@ -35,7 +35,7 @@ class KeepAliveDelegate : public CastTransport::Delegate {
// connection.
KeepAliveDelegate(CastSocket* socket,
scoped_refptr<Logger> logger,
- scoped_ptr<CastTransport::Delegate> inner_delegate,
+ std::unique_ptr<CastTransport::Delegate> inner_delegate,
base::TimeDelta ping_interval,
base::TimeDelta liveness_timeout);
@@ -44,8 +44,8 @@ class KeepAliveDelegate : public CastTransport::Delegate {
// Creates a keep-alive message (e.g. PING or PONG).
static CastMessage CreateKeepAliveMessage(const char* message_type);
- void SetTimersForTest(scoped_ptr<base::Timer> injected_ping_timer,
- scoped_ptr<base::Timer> injected_liveness_timer);
+ void SetTimersForTest(std::unique_ptr<base::Timer> injected_ping_timer,
+ std::unique_ptr<base::Timer> injected_liveness_timer);
// CastTransport::Delegate implementation.
void Start() override;
@@ -85,7 +85,7 @@ class KeepAliveDelegate : public CastTransport::Delegate {
scoped_refptr<Logger> logger_;
// Delegate object which receives all non-keep alive messages.
- scoped_ptr<CastTransport::Delegate> inner_delegate_;
+ std::unique_ptr<CastTransport::Delegate> inner_delegate_;
// Amount of idle time to wait before disconnecting.
base::TimeDelta liveness_timeout_;
@@ -94,10 +94,10 @@ class KeepAliveDelegate : public CastTransport::Delegate {
base::TimeDelta ping_interval_;
// Fired when |ping_interval_| is exceeded or when triggered by test code.
- scoped_ptr<base::Timer> ping_timer_;
+ std::unique_ptr<base::Timer> ping_timer_;
// Fired when |liveness_timer_| is exceeded.
- scoped_ptr<base::Timer> liveness_timer_;
+ std::unique_ptr<base::Timer> liveness_timer_;
// The PING message to send over the wire.
CastMessage ping_message_;
diff --git a/chromium/extensions/browser/api/cast_channel/keep_alive_delegate_unittest.cc b/chromium/extensions/browser/api/cast_channel/keep_alive_delegate_unittest.cc
index 645d1657f75..f6f0b43da3b 100644
--- a/chromium/extensions/browser/api/cast_channel/keep_alive_delegate_unittest.cc
+++ b/chromium/extensions/browser/api/cast_channel/keep_alive_delegate_unittest.cc
@@ -7,6 +7,7 @@
#include <stdint.h>
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/test/simple_test_clock.h"
@@ -54,18 +55,18 @@ class KeepAliveDelegateTest : public testing::Test {
protected:
void SetUp() override {
inner_delegate_ = new MockCastTransportDelegate;
- logger_ = new Logger(scoped_ptr<base::Clock>(new base::SimpleTestClock),
- base::Time());
+ logger_ = new Logger(
+ std::unique_ptr<base::Clock>(new base::SimpleTestClock), base::Time());
keep_alive_.reset(new KeepAliveDelegate(
- &socket_, logger_, make_scoped_ptr(inner_delegate_),
+ &socket_, logger_, base::WrapUnique(inner_delegate_),
base::TimeDelta::FromMilliseconds(kTestPingTimeoutMillis),
base::TimeDelta::FromMilliseconds(kTestLivenessTimeoutMillis)));
liveness_timer_ = new MockTimerWithMonitoredReset(true, false);
ping_timer_ = new MockTimerWithMonitoredReset(true, false);
EXPECT_CALL(*liveness_timer_, Stop()).Times(0);
EXPECT_CALL(*ping_timer_, Stop()).Times(0);
- keep_alive_->SetTimersForTest(make_scoped_ptr(ping_timer_),
- make_scoped_ptr(liveness_timer_));
+ keep_alive_->SetTimersForTest(base::WrapUnique(ping_timer_),
+ base::WrapUnique(liveness_timer_));
}
// Runs all pending tasks in the message loop.
@@ -76,7 +77,7 @@ class KeepAliveDelegateTest : public testing::Test {
base::MessageLoop message_loop_;
MockCastSocket socket_;
- scoped_ptr<KeepAliveDelegate> keep_alive_;
+ std::unique_ptr<KeepAliveDelegate> keep_alive_;
scoped_refptr<Logger> logger_;
MockCastTransportDelegate* inner_delegate_;
MockTimerWithMonitoredReset* liveness_timer_;
diff --git a/chromium/extensions/browser/api/cast_channel/logger.cc b/chromium/extensions/browser/api/cast_channel/logger.cc
index 1ea0e24f10c..9a420d8f1c5 100644
--- a/chromium/extensions/browser/api/cast_channel/logger.cc
+++ b/chromium/extensions/browser/api/cast_channel/logger.cc
@@ -64,7 +64,7 @@ proto::ChallengeReplyErrorType ChallegeReplyErrorToProto(
}
}
-scoped_ptr<char[]> Compress(const std::string& input, size_t* length) {
+std::unique_ptr<char[]> Compress(const std::string& input, size_t* length) {
*length = 0;
z_stream stream = {0};
int result = deflateInit2(&stream,
@@ -77,7 +77,7 @@ scoped_ptr<char[]> Compress(const std::string& input, size_t* length) {
DCHECK_EQ(Z_OK, result);
size_t out_size = deflateBound(&stream, input.size());
- scoped_ptr<char[]> out(new char[out_size]);
+ std::unique_ptr<char[]> out(new char[out_size]);
stream.next_in = reinterpret_cast<uint8_t*>(const_cast<char*>(input.data()));
stream.avail_in = input.size();
@@ -125,7 +125,7 @@ Logger::AggregatedSocketEventLog::AggregatedSocketEventLog() {
Logger::AggregatedSocketEventLog::~AggregatedSocketEventLog() {
}
-Logger::Logger(scoped_ptr<base::Clock> clock, base::Time unix_epoch_time)
+Logger::Logger(std::unique_ptr<base::Clock> clock, base::Time unix_epoch_time)
: clock_(std::move(clock)), unix_epoch_time_(unix_epoch_time) {
DCHECK(clock_);
@@ -311,7 +311,7 @@ AggregatedSocketEvent& Logger::LogSocketEvent(int channel_id,
return it->second->aggregated_socket_event;
}
-scoped_ptr<char[]> Logger::GetLogs(size_t* length) const {
+std::unique_ptr<char[]> Logger::GetLogs(size_t* length) const {
*length = 0;
Log log;
@@ -341,7 +341,7 @@ scoped_ptr<char[]> Logger::GetLogs(size_t* length) const {
std::string serialized;
if (!log.SerializeToString(&serialized)) {
VLOG(2) << "Failed to serialized proto to string.";
- return scoped_ptr<char[]>();
+ return std::unique_ptr<char[]>();
}
return Compress(serialized, length);
diff --git a/chromium/extensions/browser/api/cast_channel/logger.h b/chromium/extensions/browser/api/cast_channel/logger.h
index 90c32ebf955..c9c696aa3a4 100644
--- a/chromium/extensions/browser/api/cast_channel/logger.h
+++ b/chromium/extensions/browser/api/cast_channel/logger.h
@@ -9,12 +9,12 @@
#include <deque>
#include <map>
+#include <memory>
#include <string>
#include "base/macros.h"
#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/threading/thread_checker.h"
#include "extensions/browser/api/cast_channel/logger_util.h"
#include "extensions/common/api/cast_channel/logging.pb.h"
@@ -45,7 +45,7 @@ class Logger : public base::RefCounted<Logger> {
//
// See crbug.com/518951 for information on why base::Clock
// is used instead of base::TickClock.
- Logger(scoped_ptr<base::Clock> clock, base::Time unix_epoch_time);
+ Logger(std::unique_ptr<base::Clock> clock, base::Time unix_epoch_time);
// For newly created sockets. Will create an event and log a
// CAST_SOCKET_CREATED event.
@@ -81,7 +81,7 @@ class Logger : public base::RefCounted<Logger> {
// compressed in gzip format.
// If serialization or compression failed, returns nullptr.
// |length|: If successful, assigned with size of compressed content.
- scoped_ptr<char[]> GetLogs(size_t* length) const;
+ std::unique_ptr<char[]> GetLogs(size_t* length) const;
// Clears the internal map.
void Reset();
@@ -129,7 +129,7 @@ class Logger : public base::RefCounted<Logger> {
int channel_id,
const proto::SocketEvent& socket_event);
- scoped_ptr<base::Clock> clock_;
+ std::unique_ptr<base::Clock> clock_;
AggregatedSocketEventLogMap aggregated_socket_events_;
base::Time unix_epoch_time_;
diff --git a/chromium/extensions/browser/api/cast_channel/logger_unittest.cc b/chromium/extensions/browser/api/cast_channel/logger_unittest.cc
index a9daf7bb33e..6909644da12 100644
--- a/chromium/extensions/browser/api/cast_channel/logger_unittest.cc
+++ b/chromium/extensions/browser/api/cast_channel/logger_unittest.cc
@@ -29,7 +29,8 @@ class CastChannelLoggerTest : public testing::Test {
// |logger_| will take ownership of |clock_|.
CastChannelLoggerTest()
: clock_(new base::SimpleTestClock),
- logger_(new Logger(scoped_ptr<base::Clock>(clock_), base::Time())) {}
+ logger_(
+ new Logger(std::unique_ptr<base::Clock>(clock_), base::Time())) {}
~CastChannelLoggerTest() override {}
bool Uncompress(const char* input, int length, std::string* output) {
@@ -64,20 +65,20 @@ class CastChannelLoggerTest : public testing::Test {
return success;
}
- scoped_ptr<Log> GetLog() {
+ std::unique_ptr<Log> GetLog() {
size_t length = 0;
- scoped_ptr<char[]> output = logger_->GetLogs(&length);
+ std::unique_ptr<char[]> output = logger_->GetLogs(&length);
if (!output.get())
- return scoped_ptr<Log>();
+ return std::unique_ptr<Log>();
// 20kb should be enough for test purposes.
std::string uncompressed(20000, 0);
if (!Uncompress(output.get(), length, &uncompressed))
- return scoped_ptr<Log>();
+ return std::unique_ptr<Log>();
- scoped_ptr<Log> log(new Log);
+ std::unique_ptr<Log> log(new Log);
if (!log->ParseFromString(uncompressed))
- return scoped_ptr<Log>();
+ return std::unique_ptr<Log>();
return log;
}
@@ -117,7 +118,7 @@ TEST_F(CastChannelLoggerTest, BasicLogging) {
EXPECT_EQ(last_errors.challenge_reply_error_type,
proto::CHALLENGE_REPLY_ERROR_CERT_PARSING_FAILED);
- scoped_ptr<Log> log = GetLog();
+ std::unique_ptr<Log> log = GetLog();
ASSERT_TRUE(log);
ASSERT_EQ(2, log->aggregated_socket_event_size());
@@ -247,7 +248,7 @@ TEST_F(CastChannelLoggerTest, LogSocketReadWrite) {
logger_->LogSocketEventWithRv(2, EventType::SOCKET_WRITE, -5);
clock_->Advance(base::TimeDelta::FromMicroseconds(1));
- scoped_ptr<Log> log = GetLog();
+ std::unique_ptr<Log> log = GetLog();
ASSERT_TRUE(log);
ASSERT_EQ(2, log->aggregated_socket_event_size());
@@ -274,7 +275,7 @@ TEST_F(CastChannelLoggerTest, TooManySockets) {
logger_->LogSocketEvent(i, EventType::CAST_SOCKET_CREATED);
}
- scoped_ptr<Log> log = GetLog();
+ std::unique_ptr<Log> log = GetLog();
ASSERT_TRUE(log);
ASSERT_EQ(kMaxSocketsToLog, log->aggregated_socket_event_size());
@@ -292,7 +293,7 @@ TEST_F(CastChannelLoggerTest, TooManyEvents) {
clock_->Advance(base::TimeDelta::FromMicroseconds(1));
}
- scoped_ptr<Log> log = GetLog();
+ std::unique_ptr<Log> log = GetLog();
ASSERT_TRUE(log);
ASSERT_EQ(1, log->aggregated_socket_event_size());
@@ -308,7 +309,7 @@ TEST_F(CastChannelLoggerTest, TooManyEvents) {
TEST_F(CastChannelLoggerTest, Reset) {
logger_->LogSocketEvent(1, EventType::CAST_SOCKET_CREATED);
- scoped_ptr<Log> log = GetLog();
+ std::unique_ptr<Log> log = GetLog();
ASSERT_TRUE(log);
EXPECT_EQ(1, log->aggregated_socket_event_size());
diff --git a/chromium/extensions/browser/api/declarative/declarative_api.cc b/chromium/extensions/browser/api/declarative/declarative_api.cc
index 183ca3e9cd8..5ac56a4da0b 100644
--- a/chromium/extensions/browser/api/declarative/declarative_api.cc
+++ b/chromium/extensions/browser/api/declarative/declarative_api.cc
@@ -41,11 +41,12 @@ void ConvertBinaryDictionaryValuesToBase64(base::DictionaryValue* dict);
// Encodes |binary| as base64 and returns a new StringValue populated with the
// encoded string.
-scoped_ptr<base::StringValue> ConvertBinaryToBase64(base::BinaryValue* binary) {
+std::unique_ptr<base::StringValue> ConvertBinaryToBase64(
+ base::BinaryValue* binary) {
std::string binary_data = std::string(binary->GetBuffer(), binary->GetSize());
std::string data64;
base::Base64Encode(binary_data, &data64);
- return scoped_ptr<base::StringValue>(new base::StringValue(data64));
+ return std::unique_ptr<base::StringValue>(new base::StringValue(data64));
}
// Parses through |args| replacing any BinaryValues with base64 encoded
@@ -168,7 +169,7 @@ bool RulesFunction::RunAsync() {
bool EventsEventAddRulesFunction::RunAsyncOnCorrectThread() {
ConvertBinaryListElementsToBase64(args_.get());
- scoped_ptr<AddRules::Params> params(AddRules::Params::Create(*args_));
+ std::unique_ptr<AddRules::Params> params(AddRules::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
// TODO(devlin): Remove the dependency on linked_ptr here.
@@ -180,7 +181,7 @@ bool EventsEventAddRulesFunction::RunAsyncOnCorrectThread() {
error_ = rules_registry_->AddRules(extension_id(), linked_rules);
if (error_.empty()) {
- scoped_ptr<base::ListValue> rules_value(new base::ListValue());
+ std::unique_ptr<base::ListValue> rules_value(new base::ListValue());
for (const auto& rule : linked_rules)
rules_value->Append(rule->ToValue());
SetResult(std::move(rules_value));
@@ -190,7 +191,8 @@ bool EventsEventAddRulesFunction::RunAsyncOnCorrectThread() {
}
bool EventsEventRemoveRulesFunction::RunAsyncOnCorrectThread() {
- scoped_ptr<RemoveRules::Params> params(RemoveRules::Params::Create(*args_));
+ std::unique_ptr<RemoveRules::Params> params(
+ RemoveRules::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
if (params->rule_identifiers.get()) {
@@ -204,7 +206,7 @@ bool EventsEventRemoveRulesFunction::RunAsyncOnCorrectThread() {
}
bool EventsEventGetRulesFunction::RunAsyncOnCorrectThread() {
- scoped_ptr<GetRules::Params> params(GetRules::Params::Create(*args_));
+ std::unique_ptr<GetRules::Params> params(GetRules::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
std::vector<linked_ptr<Rule> > rules;
@@ -215,7 +217,7 @@ bool EventsEventGetRulesFunction::RunAsyncOnCorrectThread() {
rules_registry_->GetAllRules(extension_id(), &rules);
}
- scoped_ptr<base::ListValue> rules_value(new base::ListValue());
+ std::unique_ptr<base::ListValue> rules_value(new base::ListValue());
for (const auto& rule : rules)
rules_value->Append(rule->ToValue());
SetResult(std::move(rules_value));
diff --git a/chromium/extensions/browser/api/declarative/declarative_rule.h b/chromium/extensions/browser/api/declarative/declarative_rule.h
index 6e8e9098097..e18f2bbde58 100644
--- a/chromium/extensions/browser/api/declarative/declarative_rule.h
+++ b/chromium/extensions/browser/api/declarative/declarative_rule.h
@@ -19,6 +19,7 @@
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/linked_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/stl_util.h"
#include "base/time/time.h"
#include "components/url_matcher/url_matcher.h"
@@ -44,7 +45,7 @@ namespace extensions {
// members:
//
// // Arguments passed through from DeclarativeConditionSet::Create.
-// static scoped_ptr<ConditionT> Create(
+// static std::unique_ptr<ConditionT> Create(
// const Extension* extension,
// URLMatcherConditionFactory* url_matcher_condition_factory,
// // Except this argument gets elements of the Values array.
@@ -60,14 +61,14 @@ namespace extensions {
template<typename ConditionT>
class DeclarativeConditionSet {
public:
- typedef std::vector<scoped_ptr<base::Value>> Values;
+ typedef std::vector<std::unique_ptr<base::Value>> Values;
typedef std::vector<linked_ptr<const ConditionT> > Conditions;
typedef typename Conditions::const_iterator const_iterator;
// Factory method that creates a DeclarativeConditionSet for |extension|
// according to the JSON array |conditions| passed by the extension API. Sets
// |error| and returns NULL in case of an error.
- static scoped_ptr<DeclarativeConditionSet> Create(
+ static std::unique_ptr<DeclarativeConditionSet> Create(
const Extension* extension,
url_matcher::URLMatcherConditionFactory* url_matcher_condition_factory,
const Values& condition_values,
@@ -119,7 +120,7 @@ class DeclarativeConditionSet {
// members:
//
// // Arguments passed through from ActionSet::Create.
-// static scoped_ptr<ActionT> Create(
+// static std::unique_ptr<ActionT> Create(
// const Extension* extension,
// // Except this argument gets elements of the Values array.
// const base::Value& definition,
@@ -143,7 +144,7 @@ class DeclarativeConditionSet {
template<typename ActionT>
class DeclarativeActionSet {
public:
- typedef std::vector<scoped_ptr<base::Value>> Values;
+ typedef std::vector<std::unique_ptr<base::Value>> Values;
typedef std::vector<scoped_refptr<const ActionT> > Actions;
explicit DeclarativeActionSet(const Actions& actions);
@@ -151,7 +152,7 @@ class DeclarativeActionSet {
// Factory method that instantiates a DeclarativeActionSet for |extension|
// according to |actions| which represents the array of actions received from
// the extension API.
- static scoped_ptr<DeclarativeActionSet> Create(
+ static std::unique_ptr<DeclarativeActionSet> Create(
content::BrowserContext* browser_context,
const Extension* extension,
const Values& action_values,
@@ -216,8 +217,8 @@ class DeclarativeRule {
DeclarativeRule(const GlobalRuleId& id,
const Tags& tags,
base::Time extension_installation_time,
- scoped_ptr<ConditionSet> conditions,
- scoped_ptr<ActionSet> actions,
+ std::unique_ptr<ConditionSet> conditions,
+ std::unique_ptr<ActionSet> actions,
Priority priority);
// Creates a DeclarativeRule for |extension| given a json definition. The
@@ -228,7 +229,7 @@ class DeclarativeRule {
// actions, error) and returns NULL if it fails. Pass NULL if no consistency
// check is needed. If |error| is empty, the translation was successful and
// the returned rule is internally consistent.
- static scoped_ptr<DeclarativeRule> Create(
+ static std::unique_ptr<DeclarativeRule> Create(
url_matcher::URLMatcherConditionFactory* url_matcher_condition_factory,
content::BrowserContext* browser_context,
const Extension* extension,
@@ -259,8 +260,8 @@ class DeclarativeRule {
GlobalRuleId id_;
Tags tags_;
base::Time extension_installation_time_; // For precedences of rules.
- scoped_ptr<ConditionSet> conditions_;
- scoped_ptr<ActionSet> actions_;
+ std::unique_ptr<ConditionSet> conditions_;
+ std::unique_ptr<ActionSet> actions_;
Priority priority_;
DISALLOW_COPY_AND_ASSIGN(DeclarativeRule);
@@ -301,7 +302,7 @@ void DeclarativeConditionSet<ConditionT>::GetURLMatcherConditionSets(
// static
template <typename ConditionT>
-scoped_ptr<DeclarativeConditionSet<ConditionT>>
+std::unique_ptr<DeclarativeConditionSet<ConditionT>>
DeclarativeConditionSet<ConditionT>::Create(
const Extension* extension,
url_matcher::URLMatcherConditionFactory* url_matcher_condition_factory,
@@ -309,12 +310,12 @@ DeclarativeConditionSet<ConditionT>::Create(
std::string* error) {
Conditions result;
- for (const scoped_ptr<base::Value>& value : condition_values) {
+ for (const std::unique_ptr<base::Value>& value : condition_values) {
CHECK(value.get());
- scoped_ptr<ConditionT> condition = ConditionT::Create(
+ std::unique_ptr<ConditionT> condition = ConditionT::Create(
extension, url_matcher_condition_factory, *value, error);
if (!error->empty())
- return scoped_ptr<DeclarativeConditionSet>();
+ return std::unique_ptr<DeclarativeConditionSet>();
result.push_back(make_linked_ptr(condition.release()));
}
@@ -334,7 +335,7 @@ DeclarativeConditionSet<ConditionT>::Create(
}
}
- return make_scoped_ptr(new DeclarativeConditionSet(
+ return base::WrapUnique(new DeclarativeConditionSet(
result, match_id_to_condition, conditions_without_urls));
}
@@ -357,26 +358,27 @@ DeclarativeActionSet<ActionT>::DeclarativeActionSet(const Actions& actions)
// static
template <typename ActionT>
-scoped_ptr<DeclarativeActionSet<ActionT>> DeclarativeActionSet<ActionT>::Create(
- content::BrowserContext* browser_context,
- const Extension* extension,
- const Values& action_values,
- std::string* error,
- bool* bad_message) {
+std::unique_ptr<DeclarativeActionSet<ActionT>>
+DeclarativeActionSet<ActionT>::Create(content::BrowserContext* browser_context,
+ const Extension* extension,
+ const Values& action_values,
+ std::string* error,
+ bool* bad_message) {
*error = "";
*bad_message = false;
Actions result;
- for (const scoped_ptr<base::Value>& value : action_values) {
+ for (const std::unique_ptr<base::Value>& value : action_values) {
CHECK(value.get());
scoped_refptr<const ActionT> action =
ActionT::Create(browser_context, extension, *value, error, bad_message);
if (!error->empty() || *bad_message)
- return scoped_ptr<DeclarativeActionSet>();
+ return std::unique_ptr<DeclarativeActionSet>();
result.push_back(action);
}
- return scoped_ptr<DeclarativeActionSet>(new DeclarativeActionSet(result));
+ return std::unique_ptr<DeclarativeActionSet>(
+ new DeclarativeActionSet(result));
}
template<typename ActionT>
@@ -420,13 +422,13 @@ int DeclarativeActionSet<ActionT>::GetMinimumPriority() const {
// DeclarativeRule
//
-template<typename ConditionT, typename ActionT>
+template <typename ConditionT, typename ActionT>
DeclarativeRule<ConditionT, ActionT>::DeclarativeRule(
const GlobalRuleId& id,
const Tags& tags,
base::Time extension_installation_time,
- scoped_ptr<ConditionSet> conditions,
- scoped_ptr<ActionSet> actions,
+ std::unique_ptr<ConditionSet> conditions,
+ std::unique_ptr<ActionSet> actions,
Priority priority)
: id_(id),
tags_(tags),
@@ -439,8 +441,8 @@ DeclarativeRule<ConditionT, ActionT>::DeclarativeRule(
}
// static
-template<typename ConditionT, typename ActionT>
-scoped_ptr<DeclarativeRule<ConditionT, ActionT> >
+template <typename ConditionT, typename ActionT>
+std::unique_ptr<DeclarativeRule<ConditionT, ActionT>>
DeclarativeRule<ConditionT, ActionT>::Create(
url_matcher::URLMatcherConditionFactory* url_matcher_condition_factory,
content::BrowserContext* browser_context,
@@ -449,18 +451,17 @@ DeclarativeRule<ConditionT, ActionT>::Create(
linked_ptr<JsonRule> rule,
ConsistencyChecker check_consistency,
std::string* error) {
- scoped_ptr<DeclarativeRule> error_result;
+ std::unique_ptr<DeclarativeRule> error_result;
- scoped_ptr<ConditionSet> conditions = ConditionSet::Create(
+ std::unique_ptr<ConditionSet> conditions = ConditionSet::Create(
extension, url_matcher_condition_factory, rule->conditions, error);
if (!error->empty())
return std::move(error_result);
CHECK(conditions.get());
bool bad_message = false;
- scoped_ptr<ActionSet> actions =
- ActionSet::Create(
- browser_context, extension, rule->actions, error, &bad_message);
+ std::unique_ptr<ActionSet> actions = ActionSet::Create(
+ browser_context, extension, rule->actions, error, &bad_message);
if (bad_message) {
// TODO(battre) Export concept of bad_message to caller, the extension
// should be killed in case it is true.
@@ -483,7 +484,7 @@ DeclarativeRule<ConditionT, ActionT>::Create(
GlobalRuleId rule_id(extension->id(), *(rule->id));
Tags tags = rule->tags ? *rule->tags : Tags();
- return scoped_ptr<DeclarativeRule>(
+ return std::unique_ptr<DeclarativeRule>(
new DeclarativeRule(rule_id, tags, extension_installation_time,
std::move(conditions), std::move(actions), priority));
}
diff --git a/chromium/extensions/browser/api/declarative/declarative_rule_unittest.cc b/chromium/extensions/browser/api/declarative/declarative_rule_unittest.cc
index 93ec58b4026..fae5a6ebf5a 100644
--- a/chromium/extensions/browser/api/declarative/declarative_rule_unittest.cc
+++ b/chromium/extensions/browser/api/declarative/declarative_rule_unittest.cc
@@ -22,7 +22,7 @@ namespace extensions {
namespace {
-scoped_ptr<base::DictionaryValue> SimpleManifest() {
+std::unique_ptr<base::DictionaryValue> SimpleManifest() {
return DictionaryBuilder()
.Set("name", "extension")
.Set("manifest_version", 2)
@@ -36,14 +36,14 @@ struct RecordingCondition {
typedef int MatchData;
URLMatcherConditionFactory* factory;
- scoped_ptr<base::Value> value;
+ std::unique_ptr<base::Value> value;
void GetURLMatcherConditionSets(
URLMatcherConditionSet::Vector* condition_sets) const {
// No condition sets.
}
- static scoped_ptr<RecordingCondition> Create(
+ static std::unique_ptr<RecordingCondition> Create(
const Extension* extension,
URLMatcherConditionFactory* url_matcher_condition_factory,
const base::Value& condition,
@@ -51,10 +51,10 @@ struct RecordingCondition {
const base::DictionaryValue* dict = NULL;
if (condition.GetAsDictionary(&dict) && dict->HasKey("bad_key")) {
*error = "Found error key";
- return scoped_ptr<RecordingCondition>();
+ return std::unique_ptr<RecordingCondition>();
}
- scoped_ptr<RecordingCondition> result(new RecordingCondition());
+ std::unique_ptr<RecordingCondition> result(new RecordingCondition());
result->factory = url_matcher_condition_factory;
result->value.reset(condition.DeepCopy());
return result;
@@ -69,7 +69,7 @@ TEST(DeclarativeConditionTest, ErrorConditionSet) {
conditions.push_back(ParseJson("{\"bad_key\": 2}"));
std::string error;
- scoped_ptr<RecordingConditionSet> result = RecordingConditionSet::Create(
+ std::unique_ptr<RecordingConditionSet> result = RecordingConditionSet::Create(
NULL, matcher.condition_factory(), conditions, &error);
EXPECT_EQ("Found error key", error);
ASSERT_FALSE(result);
@@ -83,7 +83,7 @@ TEST(DeclarativeConditionTest, CreateConditionSet) {
// Test insertion
std::string error;
- scoped_ptr<RecordingConditionSet> result = RecordingConditionSet::Create(
+ std::unique_ptr<RecordingConditionSet> result = RecordingConditionSet::Create(
NULL, matcher.condition_factory(), conditions, &error);
EXPECT_EQ("", error);
ASSERT_TRUE(result);
@@ -125,12 +125,12 @@ struct FulfillableCondition {
return match_data.value <= max_value;
}
- static scoped_ptr<FulfillableCondition> Create(
+ static std::unique_ptr<FulfillableCondition> Create(
const Extension* extension,
URLMatcherConditionFactory* url_matcher_condition_factory,
const base::Value& condition,
std::string* error) {
- scoped_ptr<FulfillableCondition> result(new FulfillableCondition());
+ std::unique_ptr<FulfillableCondition> result(new FulfillableCondition());
const base::DictionaryValue* dict;
if (!condition.GetAsDictionary(&dict)) {
*error = "Expected dict";
@@ -159,7 +159,7 @@ TEST(DeclarativeConditionTest, FulfillConditionSet) {
// Test insertion
std::string error;
- scoped_ptr<FulfillableConditionSet> result =
+ std::unique_ptr<FulfillableConditionSet> result =
FulfillableConditionSet::Create(NULL, NULL, conditions, &error);
ASSERT_EQ("", error);
ASSERT_TRUE(result);
@@ -260,7 +260,7 @@ TEST(DeclarativeActionTest, ErrorActionSet) {
std::string error;
bool bad = false;
- scoped_ptr<SummingActionSet> result =
+ std::unique_ptr<SummingActionSet> result =
SummingActionSet::Create(NULL, NULL, actions, &error, &bad);
EXPECT_EQ("the error", error);
EXPECT_FALSE(bad);
@@ -285,7 +285,7 @@ TEST(DeclarativeActionTest, ApplyActionSet) {
// Test insertion
std::string error;
bool bad = false;
- scoped_ptr<SummingActionSet> result =
+ std::unique_ptr<SummingActionSet> result =
SummingActionSet::Create(NULL, NULL, actions, &error, &bad);
EXPECT_EQ("", error);
EXPECT_FALSE(bad);
@@ -327,13 +327,9 @@ TEST(DeclarativeRuleTest, Create) {
URLMatcher matcher;
std::string error;
- scoped_ptr<Rule> rule(Rule::Create(matcher.condition_factory(),
- NULL,
- extension.get(),
- install_time,
- json_rule,
- Rule::ConsistencyChecker(),
- &error));
+ std::unique_ptr<Rule> rule(Rule::Create(
+ matcher.condition_factory(), NULL, extension.get(), install_time,
+ json_rule, Rule::ConsistencyChecker(), &error));
EXPECT_EQ("", error);
ASSERT_TRUE(rule.get());
@@ -396,13 +392,9 @@ TEST(DeclarativeRuleTest, CheckConsistency) {
" \"priority\": 200 \n"
"}"),
json_rule.get()));
- scoped_ptr<Rule> rule(Rule::Create(matcher.condition_factory(),
- NULL,
- extension.get(),
- base::Time(),
- json_rule,
- base::Bind(AtLeastOneCondition),
- &error));
+ std::unique_ptr<Rule> rule(Rule::Create(
+ matcher.condition_factory(), NULL, extension.get(), base::Time(),
+ json_rule, base::Bind(AtLeastOneCondition), &error));
EXPECT_TRUE(rule);
EXPECT_EQ("", error);
diff --git a/chromium/extensions/browser/api/declarative/deduping_factory_unittest.cc b/chromium/extensions/browser/api/declarative/deduping_factory_unittest.cc
index f4c335b7040..ea494c6d51a 100644
--- a/chromium/extensions/browser/api/declarative/deduping_factory_unittest.cc
+++ b/chromium/extensions/browser/api/declarative/deduping_factory_unittest.cc
@@ -4,8 +4,9 @@
#include "extensions/browser/api/declarative/deduping_factory.h"
+#include <memory>
+
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -72,8 +73,8 @@ scoped_refptr<const BaseClass> CreateFoo(const std::string& /*instance_type*/,
return scoped_refptr<const BaseClass>(new Foo(parameter));
}
-scoped_ptr<base::DictionaryValue> CreateDictWithParameter(int parameter) {
- scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
+std::unique_ptr<base::DictionaryValue> CreateDictWithParameter(int parameter) {
+ std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
dict->SetInteger("parameter", parameter);
return dict;
}
@@ -87,10 +88,10 @@ TEST(DedupingFactoryTest, InstantiationParameterized) {
factory.RegisterFactoryMethod(
kTypeName, DedupingFactory<BaseClass>::IS_PARAMETERIZED, &CreateFoo);
- scoped_ptr<base::DictionaryValue> d1(CreateDictWithParameter(1));
- scoped_ptr<base::DictionaryValue> d2(CreateDictWithParameter(2));
- scoped_ptr<base::DictionaryValue> d3(CreateDictWithParameter(3));
- scoped_ptr<base::DictionaryValue> d4(CreateDictWithParameter(4));
+ std::unique_ptr<base::DictionaryValue> d1(CreateDictWithParameter(1));
+ std::unique_ptr<base::DictionaryValue> d2(CreateDictWithParameter(2));
+ std::unique_ptr<base::DictionaryValue> d3(CreateDictWithParameter(3));
+ std::unique_ptr<base::DictionaryValue> d4(CreateDictWithParameter(4));
std::string error;
bool bad_message = false;
@@ -134,8 +135,8 @@ TEST(DedupingFactoryTest, InstantiationNonParameterized) {
factory.RegisterFactoryMethod(
kTypeName, DedupingFactory<BaseClass>::IS_NOT_PARAMETERIZED, &CreateFoo);
- scoped_ptr<base::DictionaryValue> d1(CreateDictWithParameter(1));
- scoped_ptr<base::DictionaryValue> d2(CreateDictWithParameter(2));
+ std::unique_ptr<base::DictionaryValue> d1(CreateDictWithParameter(1));
+ std::unique_ptr<base::DictionaryValue> d2(CreateDictWithParameter(2));
std::string error;
bool bad_message = false;
@@ -160,7 +161,7 @@ TEST(DedupingFactoryTest, TypeNames) {
factory.RegisterFactoryMethod(
kTypeName2, DedupingFactory<BaseClass>::IS_PARAMETERIZED, &CreateFoo);
- scoped_ptr<base::DictionaryValue> d1(CreateDictWithParameter(1));
+ std::unique_ptr<base::DictionaryValue> d1(CreateDictWithParameter(1));
std::string error;
bool bad_message = false;
@@ -180,7 +181,7 @@ TEST(DedupingFactoryTest, Clear) {
factory.RegisterFactoryMethod(
kTypeName, DedupingFactory<BaseClass>::IS_PARAMETERIZED, &CreateFoo);
- scoped_ptr<base::DictionaryValue> d1(CreateDictWithParameter(1));
+ std::unique_ptr<base::DictionaryValue> d1(CreateDictWithParameter(1));
std::string error;
bool bad_message = false;
diff --git a/chromium/extensions/browser/api/declarative/rules_cache_delegate.cc b/chromium/extensions/browser/api/declarative/rules_cache_delegate.cc
index 0603d6c4db7..8da41b56ba5 100644
--- a/chromium/extensions/browser/api/declarative/rules_cache_delegate.cc
+++ b/chromium/extensions/browser/api/declarative/rules_cache_delegate.cc
@@ -94,7 +94,7 @@ void RulesCacheDelegate::Init(RulesRegistry* registry) {
}
void RulesCacheDelegate::WriteToStorage(const std::string& extension_id,
- scoped_ptr<base::Value> value) {
+ std::unique_ptr<base::Value> value) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (!browser_context_)
return;
@@ -181,7 +181,7 @@ void RulesCacheDelegate::ReadFromStorage(const std::string& extension_id) {
void RulesCacheDelegate::ReadFromStorageCallback(
const std::string& extension_id,
- scoped_ptr<base::Value> value) {
+ std::unique_ptr<base::Value> value) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
content::BrowserThread::PostTask(
rules_registry_thread_,
diff --git a/chromium/extensions/browser/api/declarative/rules_cache_delegate.h b/chromium/extensions/browser/api/declarative/rules_cache_delegate.h
index 15553dab75c..f9cca0b8af4 100644
--- a/chromium/extensions/browser/api/declarative/rules_cache_delegate.h
+++ b/chromium/extensions/browser/api/declarative/rules_cache_delegate.h
@@ -5,11 +5,11 @@
#ifndef EXTENSIONS_BROWSER_API_DECLARATIVE_RULES_CACHE_DELEGATE_H__
#define EXTENSIONS_BROWSER_API_DECLARATIVE_RULES_CACHE_DELEGATE_H__
+#include <memory>
#include <set>
#include <string>
#include "base/gtest_prod_util.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "content/public/browser/browser_thread.h"
@@ -42,7 +42,7 @@ class RulesCacheDelegate {
void Init(RulesRegistry* registry);
void WriteToStorage(const std::string& extension_id,
- scoped_ptr<base::Value> value);
+ std::unique_ptr<base::Value> value);
base::WeakPtr<RulesCacheDelegate> GetWeakPtr() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
@@ -69,7 +69,7 @@ class RulesCacheDelegate {
// Read/write a list of rules serialized to Values.
void ReadFromStorage(const std::string& extension_id);
void ReadFromStorageCallback(const std::string& extension_id,
- scoped_ptr<base::Value> value);
+ std::unique_ptr<base::Value> value);
// Check the preferences whether the extension with |extension_id| has some
// rules stored on disk. If this information is not in the preferences, true
diff --git a/chromium/extensions/browser/api/declarative/rules_registry.cc b/chromium/extensions/browser/api/declarative/rules_registry.cc
index ffbcb7f896b..fd77d4646ff 100644
--- a/chromium/extensions/browser/api/declarative/rules_registry.cc
+++ b/chromium/extensions/browser/api/declarative/rules_registry.cc
@@ -38,9 +38,9 @@ const char kDuplicateRuleId[] = "Duplicate rule ID: %s";
const char kErrorCannotRemoveManifestRules[] =
"Rules declared in the 'event_rules' manifest field cannot be removed";
-scoped_ptr<base::Value> RulesToValue(
+std::unique_ptr<base::Value> RulesToValue(
const std::vector<linked_ptr<api::events::Rule>>& rules) {
- scoped_ptr<base::ListValue> list(new base::ListValue());
+ std::unique_ptr<base::ListValue> list(new base::ListValue());
for (size_t i = 0; i < rules.size(); ++i)
list->Append(rules[i]->ToValue().release());
return std::move(list);
@@ -297,9 +297,8 @@ size_t RulesRegistry::GetNumberOfUsedRuleIdentifiersForTesting() const {
return entry_count;
}
-void RulesRegistry::DeserializeAndAddRules(
- const std::string& extension_id,
- scoped_ptr<base::Value> rules) {
+void RulesRegistry::DeserializeAndAddRules(const std::string& extension_id,
+ std::unique_ptr<base::Value> rules) {
DCHECK_CURRENTLY_ON(owner_thread());
std::string error =
@@ -310,7 +309,7 @@ void RulesRegistry::DeserializeAndAddRules(
void RulesRegistry::ReportInternalError(const std::string& extension_id,
const std::string& error) {
- scoped_ptr<ExtensionError> error_instance(new InternalError(
+ std::unique_ptr<ExtensionError> error_instance(new InternalError(
extension_id, base::ASCIIToUTF16(error), logging::LOG_ERROR));
ExtensionsBrowserClient::Get()->ReportError(browser_context_,
std::move(error_instance));
diff --git a/chromium/extensions/browser/api/declarative/rules_registry.h b/chromium/extensions/browser/api/declarative/rules_registry.h
index 91f34f1cfd9..a1d4a982891 100644
--- a/chromium/extensions/browser/api/declarative/rules_registry.h
+++ b/chromium/extensions/browser/api/declarative/rules_registry.h
@@ -8,6 +8,7 @@
#include <stddef.h>
#include <map>
+#include <memory>
#include <set>
#include <string>
#include <vector>
@@ -16,7 +17,6 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/linked_ptr.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_observer.h"
@@ -224,7 +224,7 @@ class RulesRegistry : public base::RefCountedThreadSafe<RulesRegistry> {
// Deserialize the rules from the given Value object and add them to the
// RulesRegistry.
void DeserializeAndAddRules(const std::string& extension_id,
- scoped_ptr<base::Value> rules);
+ std::unique_ptr<base::Value> rules);
// Reports an internal error with the specified params to the extensions
// client.
diff --git a/chromium/extensions/browser/api/declarative/rules_registry_service.cc b/chromium/extensions/browser/api/declarative/rules_registry_service.cc
index d5c3b2f276b..8fac46194b6 100644
--- a/chromium/extensions/browser/api/declarative/rules_registry_service.cc
+++ b/chromium/extensions/browser/api/declarative/rules_registry_service.cc
@@ -4,10 +4,12 @@
#include "extensions/browser/api/declarative/rules_registry_service.h"
+#include <memory>
+
#include "base/bind.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "extensions/browser/api/declarative/rules_cache_delegate.h"
@@ -78,7 +80,7 @@ void RulesRegistryService::EnsureDefaultRulesRegistriesRegistered(
// Create a RulesCacheDelegate.
web_request_cache_delegate =
new RulesCacheDelegate(true /*log_storage_init_delay*/);
- cache_delegates_.push_back(make_scoped_ptr(web_request_cache_delegate));
+ cache_delegates_.push_back(base::WrapUnique(web_request_cache_delegate));
}
scoped_refptr<WebRequestRulesRegistry> web_request_rules_registry(
new WebRequestRulesRegistry(browser_context_, web_request_cache_delegate,
@@ -95,7 +97,7 @@ void RulesRegistryService::EnsureDefaultRulesRegistriesRegistered(
if (rules_registry_id == kDefaultRulesRegistryID) {
RulesCacheDelegate* content_rules_cache_delegate =
new RulesCacheDelegate(false /*log_storage_init_delay*/);
- cache_delegates_.push_back(make_scoped_ptr(content_rules_cache_delegate));
+ cache_delegates_.push_back(base::WrapUnique(content_rules_cache_delegate));
scoped_refptr<ContentRulesRegistry> content_rules_registry =
ExtensionsAPIClient::Get()->CreateContentRulesRegistry(
browser_context_, content_rules_cache_delegate);
diff --git a/chromium/extensions/browser/api/declarative/rules_registry_service.h b/chromium/extensions/browser/api/declarative/rules_registry_service.h
index c79f1dfd31b..b36d2ad7368 100644
--- a/chromium/extensions/browser/api/declarative/rules_registry_service.h
+++ b/chromium/extensions/browser/api/declarative/rules_registry_service.h
@@ -133,7 +133,7 @@ class RulesRegistryService : public BrowserContextKeyedAPI,
RulesRegistryMap rule_registries_;
// We own the parts of the registries which need to run on the UI thread.
- std::vector<scoped_ptr<RulesCacheDelegate>> cache_delegates_;
+ std::vector<std::unique_ptr<RulesCacheDelegate>> cache_delegates_;
// Weak pointer into rule_registries_ to make it easier to handle content rule
// conditions.
diff --git a/chromium/extensions/browser/api/declarative/rules_registry_unittest.cc b/chromium/extensions/browser/api/declarative/rules_registry_unittest.cc
index 4e76b2b8559..edf91514f5d 100644
--- a/chromium/extensions/browser/api/declarative/rules_registry_unittest.cc
+++ b/chromium/extensions/browser/api/declarative/rules_registry_unittest.cc
@@ -128,7 +128,7 @@ TEST(RulesRegistryTest, FillOptionalIdentifiers) {
EXPECT_EQ(kRuleId, *get_rules_4b[0]->id);
// Create extension
- scoped_ptr<base::DictionaryValue> manifest = ParseDictionary(
+ std::unique_ptr<base::DictionaryValue> manifest = ParseDictionary(
"{"
" \"name\": \"Test\","
" \"version\": \"1\""
@@ -188,7 +188,7 @@ TEST(RulesRegistryTest, TwoRulesInManifest) {
content::TestBrowserThread thread(content::BrowserThread::UI, &message_loop);
// Create extension
- scoped_ptr<base::DictionaryValue> manifest = ParseDictionary(
+ std::unique_ptr<base::DictionaryValue> manifest = ParseDictionary(
"{"
" \"name\": \"Test\","
" \"version\": \"1\","
@@ -232,7 +232,7 @@ TEST(RulesRegistryTest, TwoRulesInManifest) {
registry->GetAllRules(kExtensionId, &get_rules);
ASSERT_EQ(2u, get_rules.size());
- scoped_ptr<base::DictionaryValue> expected_rule_0 = ParseDictionary(
+ std::unique_ptr<base::DictionaryValue> expected_rule_0 = ParseDictionary(
"{"
" \"id\": \"000\","
" \"priority\": 200,"
@@ -247,7 +247,7 @@ TEST(RulesRegistryTest, TwoRulesInManifest) {
"}");
EXPECT_TRUE(expected_rule_0->Equals(get_rules[0]->ToValue().get()));
- scoped_ptr<base::DictionaryValue> expected_rule_1 = ParseDictionary(
+ std::unique_ptr<base::DictionaryValue> expected_rule_1 = ParseDictionary(
"{"
" \"id\": \"_0_\","
" \"priority\": 100,"
@@ -269,7 +269,7 @@ TEST(RulesRegistryTest, DeleteRuleInManifest) {
content::TestBrowserThread thread(content::BrowserThread::UI, &message_loop);
// Create extension
- scoped_ptr<base::DictionaryValue> manifest = ParseDictionary(
+ std::unique_ptr<base::DictionaryValue> manifest = ParseDictionary(
"{"
" \"name\": \"Test\","
" \"version\": \"1\","
diff --git a/chromium/extensions/browser/api/declarative_webrequest/webrequest_action.cc b/chromium/extensions/browser/api/declarative_webrequest/webrequest_action.cc
index 6cf0dbb7410..3092113cf52 100644
--- a/chromium/extensions/browser/api/declarative_webrequest/webrequest_action.cc
+++ b/chromium/extensions/browser/api/declarative_webrequest/webrequest_action.cc
@@ -53,9 +53,9 @@ const char kEmptyDocumentUrl[] = "data:text/html,";
} \
} while (0)
-scoped_ptr<helpers::RequestCookie> ParseRequestCookie(
+std::unique_ptr<helpers::RequestCookie> ParseRequestCookie(
const base::DictionaryValue* dict) {
- scoped_ptr<helpers::RequestCookie> result(new helpers::RequestCookie);
+ std::unique_ptr<helpers::RequestCookie> result(new helpers::RequestCookie);
std::string tmp;
if (dict->GetString(keys::kNameKey, &tmp))
result->name.reset(new std::string(tmp));
@@ -87,16 +87,16 @@ void ParseResponseCookieImpl(const base::DictionaryValue* dict,
cookie->http_only.reset(new bool(bool_tmp));
}
-scoped_ptr<helpers::ResponseCookie> ParseResponseCookie(
+std::unique_ptr<helpers::ResponseCookie> ParseResponseCookie(
const base::DictionaryValue* dict) {
- scoped_ptr<helpers::ResponseCookie> result(new helpers::ResponseCookie);
+ std::unique_ptr<helpers::ResponseCookie> result(new helpers::ResponseCookie);
ParseResponseCookieImpl(dict, result.get());
return result;
}
-scoped_ptr<helpers::FilterResponseCookie> ParseFilterResponseCookie(
+std::unique_ptr<helpers::FilterResponseCookie> ParseFilterResponseCookie(
const base::DictionaryValue* dict) {
- scoped_ptr<helpers::FilterResponseCookie> result(
+ std::unique_ptr<helpers::FilterResponseCookie> result(
new helpers::FilterResponseCookie);
ParseResponseCookieImpl(dict, result.get());
@@ -153,7 +153,7 @@ scoped_refptr<const WebRequestAction> CreateRedirectRequestByRegExAction(
RE2::Options options;
options.set_case_sensitive(false);
- scoped_ptr<RE2> from_pattern(new RE2(from, options));
+ std::unique_ptr<RE2> from_pattern(new RE2(from, options));
if (!from_pattern->ok()) {
*error = "Invalid pattern '" + from + "' -> '" + to + "'";
@@ -695,7 +695,7 @@ WebRequestRedirectToEmptyDocumentAction::CreateDelta(
//
WebRequestRedirectByRegExAction::WebRequestRedirectByRegExAction(
- scoped_ptr<RE2> from_pattern,
+ std::unique_ptr<RE2> from_pattern,
const std::string& to_pattern)
: WebRequestAction(ON_BEFORE_REQUEST | ON_HEADERS_RECEIVED,
ACTION_REDIRECT_BY_REGEX_DOCUMENT,
diff --git a/chromium/extensions/browser/api/declarative_webrequest/webrequest_action.h b/chromium/extensions/browser/api/declarative_webrequest/webrequest_action.h
index be7ae9d7944..2644af05f4d 100644
--- a/chromium/extensions/browser/api/declarative_webrequest/webrequest_action.h
+++ b/chromium/extensions/browser/api/declarative_webrequest/webrequest_action.h
@@ -261,8 +261,9 @@ class WebRequestRedirectByRegExAction : public WebRequestAction {
public:
// The |to_pattern| has to be passed in RE2 syntax with the exception that
// capture groups are referenced in Perl style ($1, $2, ...).
- explicit WebRequestRedirectByRegExAction(scoped_ptr<re2::RE2> from_pattern,
- const std::string& to_pattern);
+ explicit WebRequestRedirectByRegExAction(
+ std::unique_ptr<re2::RE2> from_pattern,
+ const std::string& to_pattern);
// Conversion of capture group styles between Perl style ($1, $2, ...) and
// RE2 (\1, \2, ...).
@@ -279,7 +280,7 @@ class WebRequestRedirectByRegExAction : public WebRequestAction {
private:
~WebRequestRedirectByRegExAction() override;
- scoped_ptr<re2::RE2> from_pattern_;
+ std::unique_ptr<re2::RE2> from_pattern_;
std::string to_pattern_;
DISALLOW_COPY_AND_ASSIGN(WebRequestRedirectByRegExAction);
diff --git a/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition.cc b/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition.cc
index ef72ea4496c..7e41f1228ec 100644
--- a/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition.cc
+++ b/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition.cc
@@ -125,7 +125,7 @@ void WebRequestCondition::GetURLMatcherConditionSets(
}
// static
-scoped_ptr<WebRequestCondition> WebRequestCondition::Create(
+std::unique_ptr<WebRequestCondition> WebRequestCondition::Create(
const Extension* extension,
URLMatcherConditionFactory* url_matcher_condition_factory,
const base::Value& condition,
@@ -133,18 +133,18 @@ scoped_ptr<WebRequestCondition> WebRequestCondition::Create(
const base::DictionaryValue* condition_dict = NULL;
if (!condition.GetAsDictionary(&condition_dict)) {
*error = kExpectedDictionary;
- return scoped_ptr<WebRequestCondition>();
+ return std::unique_ptr<WebRequestCondition>();
}
// Verify that we are dealing with a Condition whose type we understand.
std::string instance_type;
if (!condition_dict->GetString(keys::kInstanceTypeKey, &instance_type)) {
*error = kConditionWithoutInstanceType;
- return scoped_ptr<WebRequestCondition>();
+ return std::unique_ptr<WebRequestCondition>();
}
if (instance_type != keys::kRequestMatcherType) {
*error = kExpectedOtherConditionType;
- return scoped_ptr<WebRequestCondition>();
+ return std::unique_ptr<WebRequestCondition>();
}
WebRequestConditionAttributes attributes;
@@ -185,17 +185,16 @@ scoped_ptr<WebRequestCondition> WebRequestCondition::Create(
attributes.push_back(attribute);
}
if (!error->empty())
- return scoped_ptr<WebRequestCondition>();
+ return std::unique_ptr<WebRequestCondition>();
}
- scoped_ptr<WebRequestCondition> result(
- new WebRequestCondition(url_matcher_condition_set,
- first_party_url_matcher_condition_set,
- attributes));
+ std::unique_ptr<WebRequestCondition> result(new WebRequestCondition(
+ url_matcher_condition_set, first_party_url_matcher_condition_set,
+ attributes));
if (!result->stages()) {
*error = kConditionCannotBeFulfilled;
- return scoped_ptr<WebRequestCondition>();
+ return std::unique_ptr<WebRequestCondition>();
}
return result;
diff --git a/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition.h b/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition.h
index 0d43f46be78..2380dfe6fb8 100644
--- a/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition.h
+++ b/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition.h
@@ -78,7 +78,7 @@ class WebRequestCondition {
// Factory method that instantiates a WebRequestCondition according to
// the description |condition| passed by the extension API.
- static scoped_ptr<WebRequestCondition> Create(
+ static std::unique_ptr<WebRequestCondition> Create(
const Extension* extension,
url_matcher::URLMatcherConditionFactory* url_matcher_condition_factory,
const base::Value& condition,
diff --git a/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.cc b/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.cc
index c9c51f17acd..4b1ee0e5d63 100644
--- a/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.cc
+++ b/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.cc
@@ -13,6 +13,7 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
@@ -305,7 +306,8 @@ class HeaderMatcher {
// Creates an instance based on a list |tests| of test groups, encoded as
// dictionaries of the type declarativeWebRequest.HeaderFilter (see
// declarative_web_request.json).
- static scoped_ptr<const HeaderMatcher> Create(const base::ListValue* tests);
+ static std::unique_ptr<const HeaderMatcher> Create(
+ const base::ListValue* tests);
// Does |this| match the header "|name|: |value|"?
bool TestNameValue(const std::string& name, const std::string& value) const;
@@ -318,9 +320,9 @@ class HeaderMatcher {
// |data| is the pattern to be matched in the position given by |type|.
// Note that |data| must point to a StringValue object.
- static scoped_ptr<StringMatchTest> Create(const base::Value* data,
- MatchType type,
- bool case_sensitive);
+ static std::unique_ptr<StringMatchTest> Create(const base::Value* data,
+ MatchType type,
+ bool case_sensitive);
~StringMatchTest();
// Does |str| pass |this| StringMatchTest?
@@ -345,7 +347,7 @@ class HeaderMatcher {
// Gets the test group description in |tests| and creates the corresponding
// HeaderMatchTest. On failure returns NULL.
- static scoped_ptr<const HeaderMatchTest> Create(
+ static std::unique_ptr<const HeaderMatchTest> Create(
const base::DictionaryValue* tests);
// Does the header "|name|: |value|" match all tests in |this|?
@@ -353,20 +355,22 @@ class HeaderMatcher {
private:
// Takes ownership of the content of both |name_match| and |value_match|.
- HeaderMatchTest(std::vector<scoped_ptr<const StringMatchTest>> name_match,
- std::vector<scoped_ptr<const StringMatchTest>> value_match);
+ HeaderMatchTest(
+ std::vector<std::unique_ptr<const StringMatchTest>> name_match,
+ std::vector<std::unique_ptr<const StringMatchTest>> value_match);
// Tests to be passed by a header's name.
- const std::vector<scoped_ptr<const StringMatchTest>> name_match_;
+ const std::vector<std::unique_ptr<const StringMatchTest>> name_match_;
// Tests to be passed by a header's value.
- const std::vector<scoped_ptr<const StringMatchTest>> value_match_;
+ const std::vector<std::unique_ptr<const StringMatchTest>> value_match_;
DISALLOW_COPY_AND_ASSIGN(HeaderMatchTest);
};
- explicit HeaderMatcher(std::vector<scoped_ptr<const HeaderMatchTest>> tests);
+ explicit HeaderMatcher(
+ std::vector<std::unique_ptr<const HeaderMatchTest>> tests);
- const std::vector<scoped_ptr<const HeaderMatchTest>> tests_;
+ const std::vector<std::unique_ptr<const HeaderMatchTest>> tests_;
DISALLOW_COPY_AND_ASSIGN(HeaderMatcher);
};
@@ -376,23 +380,23 @@ class HeaderMatcher {
HeaderMatcher::~HeaderMatcher() {}
// static
-scoped_ptr<const HeaderMatcher> HeaderMatcher::Create(
+std::unique_ptr<const HeaderMatcher> HeaderMatcher::Create(
const base::ListValue* tests) {
- std::vector<scoped_ptr<const HeaderMatchTest>> header_tests;
+ std::vector<std::unique_ptr<const HeaderMatchTest>> header_tests;
for (base::ListValue::const_iterator it = tests->begin();
it != tests->end(); ++it) {
const base::DictionaryValue* tests = NULL;
if (!(*it)->GetAsDictionary(&tests))
- return scoped_ptr<const HeaderMatcher>();
+ return std::unique_ptr<const HeaderMatcher>();
- scoped_ptr<const HeaderMatchTest> header_test(
+ std::unique_ptr<const HeaderMatchTest> header_test(
HeaderMatchTest::Create(tests));
if (header_test.get() == NULL)
- return scoped_ptr<const HeaderMatcher>();
+ return std::unique_ptr<const HeaderMatcher>();
header_tests.push_back(std::move(header_test));
}
- return scoped_ptr<const HeaderMatcher>(
+ return std::unique_ptr<const HeaderMatcher>(
new HeaderMatcher(std::move(header_tests)));
}
@@ -406,19 +410,19 @@ bool HeaderMatcher::TestNameValue(const std::string& name,
}
HeaderMatcher::HeaderMatcher(
- std::vector<scoped_ptr<const HeaderMatchTest>> tests)
+ std::vector<std::unique_ptr<const HeaderMatchTest>> tests)
: tests_(std::move(tests)) {}
// HeaderMatcher::StringMatchTest implementation.
// static
-scoped_ptr<HeaderMatcher::StringMatchTest>
+std::unique_ptr<HeaderMatcher::StringMatchTest>
HeaderMatcher::StringMatchTest::Create(const base::Value* data,
MatchType type,
bool case_sensitive) {
std::string str;
CHECK(data->GetAsString(&str));
- return scoped_ptr<StringMatchTest>(
+ return std::unique_ptr<StringMatchTest>(
new StringMatchTest(str, type, case_sensitive));
}
@@ -458,18 +462,18 @@ HeaderMatcher::StringMatchTest::StringMatchTest(const std::string& data,
// HeaderMatcher::HeaderMatchTest implementation.
HeaderMatcher::HeaderMatchTest::HeaderMatchTest(
- std::vector<scoped_ptr<const StringMatchTest>> name_match,
- std::vector<scoped_ptr<const StringMatchTest>> value_match)
+ std::vector<std::unique_ptr<const StringMatchTest>> name_match,
+ std::vector<std::unique_ptr<const StringMatchTest>> value_match)
: name_match_(std::move(name_match)),
value_match_(std::move(value_match)) {}
HeaderMatcher::HeaderMatchTest::~HeaderMatchTest() {}
// static
-scoped_ptr<const HeaderMatcher::HeaderMatchTest>
+std::unique_ptr<const HeaderMatcher::HeaderMatchTest>
HeaderMatcher::HeaderMatchTest::Create(const base::DictionaryValue* tests) {
- std::vector<scoped_ptr<const StringMatchTest>> name_match;
- std::vector<scoped_ptr<const StringMatchTest>> value_match;
+ std::vector<std::unique_ptr<const StringMatchTest>> name_match;
+ std::vector<std::unique_ptr<const StringMatchTest>> value_match;
for (base::DictionaryValue::Iterator it(*tests);
!it.IsAtEnd(); it.Advance()) {
@@ -497,11 +501,11 @@ HeaderMatcher::HeaderMatchTest::Create(const base::DictionaryValue* tests) {
match_type = StringMatchTest::kEquals;
} else {
NOTREACHED(); // JSON schema type checking should prevent this.
- return scoped_ptr<const HeaderMatchTest>();
+ return std::unique_ptr<const HeaderMatchTest>();
}
const base::Value* content = &it.value();
- std::vector<scoped_ptr<const StringMatchTest>>* tests =
+ std::vector<std::unique_ptr<const StringMatchTest>>* tests =
is_name ? &name_match : &value_match;
switch (content->GetType()) {
case base::Value::TYPE_LIST: {
@@ -509,24 +513,24 @@ HeaderMatcher::HeaderMatchTest::Create(const base::DictionaryValue* tests) {
CHECK(content->GetAsList(&list));
for (base::ListValue::const_iterator it = list->begin();
it != list->end(); ++it) {
- tests->push_back(make_scoped_ptr(
+ tests->push_back(base::WrapUnique(
StringMatchTest::Create(*it, match_type, !is_name).release()));
}
break;
}
case base::Value::TYPE_STRING: {
- tests->push_back(make_scoped_ptr(
+ tests->push_back(base::WrapUnique(
StringMatchTest::Create(content, match_type, !is_name).release()));
break;
}
default: {
NOTREACHED(); // JSON schema type checking should prevent this.
- return scoped_ptr<const HeaderMatchTest>();
+ return std::unique_ptr<const HeaderMatchTest>();
}
}
}
- return scoped_ptr<const HeaderMatchTest>(
+ return std::unique_ptr<const HeaderMatchTest>(
new HeaderMatchTest(std::move(name_match), std::move(value_match)));
}
@@ -551,7 +555,7 @@ bool HeaderMatcher::HeaderMatchTest::Matches(const std::string& name,
WebRequestConditionAttributeRequestHeaders::
WebRequestConditionAttributeRequestHeaders(
- scoped_ptr<const HeaderMatcher> header_matcher,
+ std::unique_ptr<const HeaderMatcher> header_matcher,
bool positive)
: header_matcher_(std::move(header_matcher)), positive_(positive) {}
@@ -560,17 +564,17 @@ WebRequestConditionAttributeRequestHeaders::
namespace {
-scoped_ptr<const HeaderMatcher> PrepareHeaderMatcher(
+std::unique_ptr<const HeaderMatcher> PrepareHeaderMatcher(
const std::string& name,
const base::Value* value,
std::string* error) {
const base::ListValue* value_as_list = NULL;
if (!value->GetAsList(&value_as_list)) {
*error = ErrorUtils::FormatErrorMessage(kInvalidValue, name);
- return scoped_ptr<const HeaderMatcher>();
+ return std::unique_ptr<const HeaderMatcher>();
}
- scoped_ptr<const HeaderMatcher> header_matcher(
+ std::unique_ptr<const HeaderMatcher> header_matcher(
HeaderMatcher::Create(value_as_list));
if (header_matcher.get() == NULL)
*error = ErrorUtils::FormatErrorMessage(kInvalidValue, name);
@@ -589,7 +593,7 @@ WebRequestConditionAttributeRequestHeaders::Create(
DCHECK(name == keys::kRequestHeadersKey ||
name == keys::kExcludeRequestHeadersKey);
- scoped_ptr<const HeaderMatcher> header_matcher(
+ std::unique_ptr<const HeaderMatcher> header_matcher(
PrepareHeaderMatcher(name, value, error));
if (header_matcher.get() == NULL)
return scoped_refptr<const WebRequestConditionAttribute>(NULL);
@@ -645,7 +649,7 @@ bool WebRequestConditionAttributeRequestHeaders::Equals(
WebRequestConditionAttributeResponseHeaders::
WebRequestConditionAttributeResponseHeaders(
- scoped_ptr<const HeaderMatcher> header_matcher,
+ std::unique_ptr<const HeaderMatcher> header_matcher,
bool positive)
: header_matcher_(std::move(header_matcher)), positive_(positive) {}
@@ -662,7 +666,7 @@ WebRequestConditionAttributeResponseHeaders::Create(
DCHECK(name == keys::kResponseHeadersKey ||
name == keys::kExcludeResponseHeadersKey);
- scoped_ptr<const HeaderMatcher> header_matcher(
+ std::unique_ptr<const HeaderMatcher> header_matcher(
PrepareHeaderMatcher(name, value, error));
if (header_matcher.get() == NULL)
return scoped_refptr<const WebRequestConditionAttribute>(NULL);
diff --git a/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.h b/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.h
index b39a68db61d..d7afeee8447 100644
--- a/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.h
+++ b/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute.h
@@ -5,12 +5,12 @@
#ifndef EXTENSIONS_BROWSER_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITION_ATTRIBUTE_H_
#define EXTENSIONS_BROWSER_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITION_ATTRIBUTE_H_
+#include <memory>
#include <string>
#include <vector>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "content/public/common/resource_type.h"
#include "extensions/browser/api/declarative_webrequest/request_stage.h"
#include "extensions/common/api/events.h"
@@ -167,10 +167,11 @@ class WebRequestConditionAttributeRequestHeaders
private:
WebRequestConditionAttributeRequestHeaders(
- scoped_ptr<const HeaderMatcher> header_matcher, bool positive);
+ std::unique_ptr<const HeaderMatcher> header_matcher,
+ bool positive);
~WebRequestConditionAttributeRequestHeaders() override;
- const scoped_ptr<const HeaderMatcher> header_matcher_;
+ const std::unique_ptr<const HeaderMatcher> header_matcher_;
const bool positive_;
DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeRequestHeaders);
@@ -200,10 +201,11 @@ class WebRequestConditionAttributeResponseHeaders
private:
WebRequestConditionAttributeResponseHeaders(
- scoped_ptr<const HeaderMatcher> header_matcher, bool positive);
+ std::unique_ptr<const HeaderMatcher> header_matcher,
+ bool positive);
~WebRequestConditionAttributeResponseHeaders() override;
- const scoped_ptr<const HeaderMatcher> header_matcher_;
+ const std::unique_ptr<const HeaderMatcher> header_matcher_;
const bool positive_;
DISALLOW_COPY_AND_ASSIGN(WebRequestConditionAttributeResponseHeaders);
diff --git a/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc b/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc
index 7960af4b860..07f5071f5ff 100644
--- a/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc
+++ b/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc
@@ -6,9 +6,10 @@
#include <stddef.h>
+#include <memory>
+
#include "base/files/file_path.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/values.h"
#include "content/public/browser/resource_request_info.h"
@@ -99,7 +100,7 @@ TEST(WebRequestConditionAttributeTest, ResourceType) {
EXPECT_EQ(std::string(keys::kResourceTypeKey), attribute->GetName());
net::TestURLRequestContext context;
- scoped_ptr<net::URLRequest> url_request_ok(context.CreateRequest(
+ std::unique_ptr<net::URLRequest> url_request_ok(context.CreateRequest(
GURL("http://www.example.com"), net::DEFAULT_PRIORITY, NULL));
content::ResourceRequestInfo::AllocateForTesting(
url_request_ok.get(), content::RESOURCE_TYPE_SUB_FRAME,
@@ -115,7 +116,7 @@ TEST(WebRequestConditionAttributeTest, ResourceType) {
EXPECT_TRUE(attribute->IsFulfilled(WebRequestData(url_request_ok.get(),
ON_BEFORE_REQUEST)));
- scoped_ptr<net::URLRequest> url_request_fail(context.CreateRequest(
+ std::unique_ptr<net::URLRequest> url_request_fail(context.CreateRequest(
GURL("http://www.example.com"), net::DEFAULT_PRIORITY, NULL));
content::ResourceRequestInfo::AllocateForTesting(
url_request_fail.get(), content::RESOURCE_TYPE_MAIN_FRAME,
@@ -146,7 +147,7 @@ TEST(WebRequestConditionAttributeTest, ContentType) {
net::TestURLRequestContext context;
net::TestDelegate delegate;
- scoped_ptr<net::URLRequest> url_request(context.CreateRequest(
+ std::unique_ptr<net::URLRequest> url_request(context.CreateRequest(
test_server.GetURL("/headers.html"), net::DEFAULT_PRIORITY, &delegate));
url_request->Start();
base::MessageLoop::current()->Run();
@@ -230,7 +231,7 @@ TEST(WebRequestConditionAttributeTest, ThirdParty) {
const GURL url_b("http://b.com");
net::TestURLRequestContext context;
net::TestDelegate delegate;
- scoped_ptr<net::URLRequest> url_request(
+ std::unique_ptr<net::URLRequest> url_request(
context.CreateRequest(url_a, net::DEFAULT_PRIORITY, &delegate));
for (unsigned int i = 1; i <= kLastActiveStage; i <<= 1) {
@@ -321,7 +322,7 @@ TEST(WebRequestConditionAttributeTest, Stages) {
const GURL url_empty;
net::TestURLRequestContext context;
net::TestDelegate delegate;
- scoped_ptr<net::URLRequest> url_request(
+ std::unique_ptr<net::URLRequest> url_request(
context.CreateRequest(url_empty, net::DEFAULT_PRIORITY, &delegate));
for (size_t i = 0; i < arraysize(active_stages); ++i) {
@@ -366,21 +367,21 @@ void GetArrayAsVector(const std::string array[],
// Builds a DictionaryValue from an array of the form {name1, value1, name2,
// value2, ...}. Values for the same key are grouped in a ListValue.
-scoped_ptr<base::DictionaryValue> GetDictionaryFromArray(
+std::unique_ptr<base::DictionaryValue> GetDictionaryFromArray(
const std::vector<const std::string*>& array) {
const size_t length = array.size();
CHECK(length % 2 == 0);
- scoped_ptr<base::DictionaryValue> dictionary(new base::DictionaryValue);
+ std::unique_ptr<base::DictionaryValue> dictionary(new base::DictionaryValue);
for (size_t i = 0; i < length; i += 2) {
const std::string* name = array[i];
const std::string* value = array[i+1];
if (dictionary->HasKey(*name)) {
base::Value* entry = NULL;
- scoped_ptr<base::Value> entry_owned;
+ std::unique_ptr<base::Value> entry_owned;
base::ListValue* list = NULL;
if (!dictionary->GetWithoutPathExpansion(*name, &entry))
- return scoped_ptr<base::DictionaryValue>();
+ return std::unique_ptr<base::DictionaryValue>();
switch (entry->GetType()) {
case base::Value::TYPE_STRING:
// Replace the present string with a list.
@@ -397,7 +398,7 @@ scoped_ptr<base::DictionaryValue> GetDictionaryFromArray(
break;
default:
NOTREACHED(); // We never put other Values here.
- return scoped_ptr<base::DictionaryValue>();
+ return std::unique_ptr<base::DictionaryValue>();
}
} else {
dictionary->SetString(*name, *value);
@@ -418,7 +419,8 @@ void MatchAndCheck(const std::vector< std::vector<const std::string*> >& tests,
bool* result) {
base::ListValue contains_headers;
for (size_t i = 0; i < tests.size(); ++i) {
- scoped_ptr<base::DictionaryValue> temp(GetDictionaryFromArray(tests[i]));
+ std::unique_ptr<base::DictionaryValue> temp(
+ GetDictionaryFromArray(tests[i]));
ASSERT_TRUE(temp.get());
contains_headers.Append(temp.release());
}
@@ -446,7 +448,7 @@ TEST(WebRequestConditionAttributeTest, RequestHeaders) {
net::TestURLRequestContext context;
net::TestDelegate delegate;
- scoped_ptr<net::URLRequest> url_request(
+ std::unique_ptr<net::URLRequest> url_request(
context.CreateRequest(GURL("http://example.com"), // Dummy URL.
net::DEFAULT_PRIORITY, &delegate));
url_request->SetExtraRequestHeaderByName(
@@ -534,7 +536,7 @@ TEST(WebRequestConditionAttributeTest, ResponseHeaders) {
net::TestURLRequestContext context;
net::TestDelegate delegate;
- scoped_ptr<net::URLRequest> url_request(context.CreateRequest(
+ std::unique_ptr<net::URLRequest> url_request(context.CreateRequest(
test_server.GetURL("/headers.html"), net::DEFAULT_PRIORITY, &delegate));
url_request->Start();
base::MessageLoop::current()->Run();
diff --git a/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition_unittest.cc b/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition_unittest.cc
index 0de50310766..fd955270c3b 100644
--- a/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition_unittest.cc
+++ b/chromium/extensions/browser/api/declarative_webrequest/webrequest_condition_unittest.cc
@@ -4,9 +4,9 @@
#include "extensions/browser/api/declarative_webrequest/webrequest_condition.h"
+#include <memory>
#include <set>
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/test/values_test_util.h"
#include "base/values.h"
@@ -30,7 +30,7 @@ TEST(WebRequestConditionTest, CreateCondition) {
URLMatcher matcher;
std::string error;
- scoped_ptr<WebRequestCondition> result;
+ std::unique_ptr<WebRequestCondition> result;
// Test wrong condition name passed.
error.clear();
@@ -80,7 +80,7 @@ TEST(WebRequestConditionTest, CreateCondition) {
net::TestURLRequestContext context;
const GURL http_url("http://www.example.com");
- scoped_ptr<net::URLRequest> match_request(
+ std::unique_ptr<net::URLRequest> match_request(
context.CreateRequest(http_url, net::DEFAULT_PRIORITY, NULL));
WebRequestData data(match_request.get(), ON_BEFORE_REQUEST);
WebRequestDataWithMatchIds request_data(&data);
@@ -100,7 +100,7 @@ TEST(WebRequestConditionTest, CreateCondition) {
EXPECT_TRUE(result->IsFulfilled(request_data));
const GURL https_url("https://www.example.com");
- scoped_ptr<net::URLRequest> wrong_resource_type(
+ std::unique_ptr<net::URLRequest> wrong_resource_type(
context.CreateRequest(https_url, net::DEFAULT_PRIORITY, NULL));
data.request = wrong_resource_type.get();
request_data.url_match_ids = matcher.MatchURL(http_url);
@@ -126,7 +126,7 @@ TEST(WebRequestConditionTest, CreateConditionFirstPartyForCookies) {
URLMatcher matcher;
std::string error;
- scoped_ptr<WebRequestCondition> result;
+ std::unique_ptr<WebRequestCondition> result;
result = WebRequestCondition::Create(
NULL,
@@ -147,7 +147,7 @@ TEST(WebRequestConditionTest, CreateConditionFirstPartyForCookies) {
net::TestURLRequestContext context;
const GURL http_url("http://www.example.com");
const GURL first_party_url("http://fpfc.example.com");
- scoped_ptr<net::URLRequest> match_request(
+ std::unique_ptr<net::URLRequest> match_request(
context.CreateRequest(http_url, net::DEFAULT_PRIORITY, NULL));
WebRequestData data(match_request.get(), ON_BEFORE_REQUEST);
WebRequestDataWithMatchIds request_data(&data);
@@ -183,53 +183,51 @@ TEST(WebRequestConditionTest, NoUrlAttributes) {
// The empty condition.
error.clear();
- scoped_ptr<WebRequestCondition> condition_empty = WebRequestCondition::Create(
- NULL,
- matcher.condition_factory(),
- *base::test::ParseJson(
- "{ \n"
- " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n"
- "}"),
- &error);
+ std::unique_ptr<WebRequestCondition> condition_empty =
+ WebRequestCondition::Create(
+ NULL, matcher.condition_factory(),
+ *base::test::ParseJson(
+ "{ \n"
+ " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", \n"
+ "}"),
+ &error);
EXPECT_EQ("", error);
ASSERT_TRUE(condition_empty.get());
// A condition without a UrlFilter attribute, which is always true.
error.clear();
- scoped_ptr<WebRequestCondition> condition_no_url_true =
+ std::unique_ptr<WebRequestCondition> condition_no_url_true =
WebRequestCondition::Create(
- NULL,
- matcher.condition_factory(),
+ NULL, matcher.condition_factory(),
*base::test::ParseJson(
- "{ \n"
- " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", "
- "\n"
- // There is no "1st party for cookies" URL in the requests below,
- // therefore all requests are considered first party for cookies.
- " \"thirdPartyForCookies\": false, \n"
- "}"),
+ "{ \n"
+ " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", "
+ "\n"
+ // There is no "1st party for cookies" URL in the requests below,
+ // therefore all requests are considered first party for cookies.
+ " \"thirdPartyForCookies\": false, \n"
+ "}"),
&error);
EXPECT_EQ("", error);
ASSERT_TRUE(condition_no_url_true.get());
// A condition without a UrlFilter attribute, which is always false.
error.clear();
- scoped_ptr<WebRequestCondition> condition_no_url_false =
+ std::unique_ptr<WebRequestCondition> condition_no_url_false =
WebRequestCondition::Create(
- NULL,
- matcher.condition_factory(),
+ NULL, matcher.condition_factory(),
*base::test::ParseJson(
- "{ \n"
- " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", "
- "\n"
- " \"thirdPartyForCookies\": true, \n"
- "}"),
+ "{ \n"
+ " \"instanceType\": \"declarativeWebRequest.RequestMatcher\", "
+ "\n"
+ " \"thirdPartyForCookies\": true, \n"
+ "}"),
&error);
EXPECT_EQ("", error);
ASSERT_TRUE(condition_no_url_false.get());
net::TestURLRequestContext context;
- scoped_ptr<net::URLRequest> https_request(context.CreateRequest(
+ std::unique_ptr<net::URLRequest> https_request(context.CreateRequest(
GURL("https://www.example.com"), net::DEFAULT_PRIORITY, NULL));
// 1. A non-empty condition without UrlFilter attributes is fulfilled iff its
@@ -274,8 +272,9 @@ TEST(WebRequestConditionTest, CreateConditionSet) {
// Test insertion
std::string error;
- scoped_ptr<WebRequestConditionSet> result = WebRequestConditionSet::Create(
- NULL, matcher.condition_factory(), conditions, &error);
+ std::unique_ptr<WebRequestConditionSet> result =
+ WebRequestConditionSet::Create(NULL, matcher.condition_factory(),
+ conditions, &error);
EXPECT_EQ("", error);
ASSERT_TRUE(result.get());
EXPECT_EQ(2u, result->conditions().size());
@@ -289,7 +288,7 @@ TEST(WebRequestConditionTest, CreateConditionSet) {
// https://www.example.com
GURL http_url("http://www.example.com");
net::TestURLRequestContext context;
- scoped_ptr<net::URLRequest> http_request(
+ std::unique_ptr<net::URLRequest> http_request(
context.CreateRequest(http_url, net::DEFAULT_PRIORITY, NULL));
WebRequestData data(http_request.get(), ON_BEFORE_REQUEST);
WebRequestDataWithMatchIds request_data(&data);
@@ -301,7 +300,7 @@ TEST(WebRequestConditionTest, CreateConditionSet) {
GURL https_url("https://www.example.com");
request_data.url_match_ids = matcher.MatchURL(https_url);
EXPECT_EQ(1u, request_data.url_match_ids.size());
- scoped_ptr<net::URLRequest> https_request(
+ std::unique_ptr<net::URLRequest> https_request(
context.CreateRequest(https_url, net::DEFAULT_PRIORITY, NULL));
data.request = https_request.get();
EXPECT_TRUE(result->IsFulfilled(*(request_data.url_match_ids.begin()),
@@ -311,7 +310,7 @@ TEST(WebRequestConditionTest, CreateConditionSet) {
GURL https_foo_url("https://foo.example.com");
request_data.url_match_ids = matcher.MatchURL(https_foo_url);
EXPECT_EQ(0u, request_data.url_match_ids.size());
- scoped_ptr<net::URLRequest> https_foo_request(
+ std::unique_ptr<net::URLRequest> https_foo_request(
context.CreateRequest(https_foo_url, net::DEFAULT_PRIORITY, NULL));
data.request = https_foo_request.get();
EXPECT_FALSE(result->IsFulfilled(-1, request_data));
@@ -334,8 +333,9 @@ TEST(WebRequestConditionTest, TestPortFilter) {
// Test insertion
std::string error;
- scoped_ptr<WebRequestConditionSet> result = WebRequestConditionSet::Create(
- NULL, matcher.condition_factory(), conditions, &error);
+ std::unique_ptr<WebRequestConditionSet> result =
+ WebRequestConditionSet::Create(NULL, matcher.condition_factory(),
+ conditions, &error);
EXPECT_EQ("", error);
ASSERT_TRUE(result.get());
EXPECT_EQ(1u, result->conditions().size());
@@ -350,25 +350,25 @@ TEST(WebRequestConditionTest, TestPortFilter) {
// Test various URLs.
GURL http_url("http://www.example.com");
net::TestURLRequestContext context;
- scoped_ptr<net::URLRequest> http_request(
+ std::unique_ptr<net::URLRequest> http_request(
context.CreateRequest(http_url, net::DEFAULT_PRIORITY, NULL));
url_match_ids = matcher.MatchURL(http_url);
ASSERT_EQ(1u, url_match_ids.size());
GURL http_url_80("http://www.example.com:80");
- scoped_ptr<net::URLRequest> http_request_80(
+ std::unique_ptr<net::URLRequest> http_request_80(
context.CreateRequest(http_url_80, net::DEFAULT_PRIORITY, NULL));
url_match_ids = matcher.MatchURL(http_url_80);
ASSERT_EQ(1u, url_match_ids.size());
GURL http_url_1000("http://www.example.com:1000");
- scoped_ptr<net::URLRequest> http_request_1000(
+ std::unique_ptr<net::URLRequest> http_request_1000(
context.CreateRequest(http_url_1000, net::DEFAULT_PRIORITY, NULL));
url_match_ids = matcher.MatchURL(http_url_1000);
ASSERT_EQ(1u, url_match_ids.size());
GURL http_url_2000("http://www.example.com:2000");
- scoped_ptr<net::URLRequest> http_request_2000(
+ std::unique_ptr<net::URLRequest> http_request_2000(
context.CreateRequest(http_url_2000, net::DEFAULT_PRIORITY, NULL));
url_match_ids = matcher.MatchURL(http_url_2000);
ASSERT_EQ(0u, url_match_ids.size());
@@ -383,7 +383,7 @@ TEST(WebRequestConditionTest, ConditionsWithConflictingStages) {
URLMatcher matcher;
std::string error;
- scoped_ptr<WebRequestCondition> result;
+ std::unique_ptr<WebRequestCondition> result;
// Test error on incompatible application stages for involved attributes.
error.clear();
diff --git a/chromium/extensions/browser/api/declarative_webrequest/webrequest_rules_registry.cc b/chromium/extensions/browser/api/declarative_webrequest/webrequest_rules_registry.cc
index ef709b28aa2..62bf3cc3d37 100644
--- a/chromium/extensions/browser/api/declarative_webrequest/webrequest_rules_registry.cc
+++ b/chromium/extensions/browser/api/declarative_webrequest/webrequest_rules_registry.cc
@@ -170,7 +170,7 @@ std::string WebRequestRulesRegistry::AddRulesImpl(
const WebRequestRule::RuleId& rule_id(*rule->id);
DCHECK(registered_rules.find(rule_id) == registered_rules.end());
- scoped_ptr<WebRequestRule> webrequest_rule(WebRequestRule::Create(
+ std::unique_ptr<WebRequestRule> webrequest_rule(WebRequestRule::Create(
url_matcher_.condition_factory(), browser_context(), extension,
extension_installation_time, rule,
base::Bind(&Checker, base::Unretained(extension)), &error));
diff --git a/chromium/extensions/browser/api/declarative_webrequest/webrequest_rules_registry.h b/chromium/extensions/browser/api/declarative_webrequest/webrequest_rules_registry.h
index 1bdad0cc64e..9af31c719c4 100644
--- a/chromium/extensions/browser/api/declarative_webrequest/webrequest_rules_registry.h
+++ b/chromium/extensions/browser/api/declarative_webrequest/webrequest_rules_registry.h
@@ -7,6 +7,7 @@
#include <list>
#include <map>
+#include <memory>
#include <set>
#include <string>
#include <vector>
@@ -15,7 +16,6 @@
#include "base/macros.h"
#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "components/url_matcher/url_matcher.h"
#include "extensions/browser/api/declarative/declarative_rule.h"
diff --git a/chromium/extensions/browser/api/device_permissions_manager.cc b/chromium/extensions/browser/api/device_permissions_manager.cc
index 0bf8db4f696..fd9d0edbd1d 100644
--- a/chromium/extensions/browser/api/device_permissions_manager.cc
+++ b/chromium/extensions/browser/api/device_permissions_manager.cc
@@ -100,7 +100,7 @@ void SaveDevicePermissionEntry(BrowserContext* context,
devices = update.Create();
}
- scoped_ptr<base::Value> device_entry(entry->ToValue());
+ std::unique_ptr<base::Value> device_entry(entry->ToValue());
DCHECK(devices->Find(*device_entry.get()) == devices->end());
devices->Append(device_entry.release());
}
@@ -311,13 +311,13 @@ bool DevicePermissionEntry::IsPersistent() const {
return !serial_number_.empty();
}
-scoped_ptr<base::Value> DevicePermissionEntry::ToValue() const {
+std::unique_ptr<base::Value> DevicePermissionEntry::ToValue() const {
if (!IsPersistent()) {
return nullptr;
}
DCHECK(!serial_number_.empty());
- scoped_ptr<base::DictionaryValue> entry_dict(
+ std::unique_ptr<base::DictionaryValue> entry_dict(
DictionaryBuilder()
.Set(kDeviceType, TypeToString(type_))
.Set(kDeviceVendorId, vendor_id_)
diff --git a/chromium/extensions/browser/api/device_permissions_manager.h b/chromium/extensions/browser/api/device_permissions_manager.h
index 534abca2b4a..299109b5f5e 100644
--- a/chromium/extensions/browser/api/device_permissions_manager.h
+++ b/chromium/extensions/browser/api/device_permissions_manager.h
@@ -8,13 +8,13 @@
#include <stdint.h>
#include <map>
+#include <memory>
#include <set>
#include <vector>
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/scoped_observer.h"
#include "base/strings/string16.h"
#include "base/threading/thread_checker.h"
@@ -60,7 +60,7 @@ class DevicePermissionEntry : public base::RefCounted<DevicePermissionEntry> {
// Convert the device to a serializable value, returns a null pointer if the
// entry is not persistent.
- scoped_ptr<base::Value> ToValue() const;
+ std::unique_ptr<base::Value> ToValue() const;
base::string16 GetPermissionMessageString() const;
diff --git a/chromium/extensions/browser/api/device_permissions_prompt.cc b/chromium/extensions/browser/api/device_permissions_prompt.cc
index e29ae85d97e..4a6c0e61864 100644
--- a/chromium/extensions/browser/api/device_permissions_prompt.cc
+++ b/chromium/extensions/browser/api/device_permissions_prompt.cc
@@ -130,7 +130,7 @@ class UsbDevicePermissionsPrompt : public DevicePermissionsPrompt::Prompt,
return;
}
- scoped_ptr<DeviceInfo> device_info(new UsbDeviceInfo(device));
+ std::unique_ptr<DeviceInfo> device_info(new UsbDeviceInfo(device));
device->CheckUsbAccess(
base::Bind(&UsbDevicePermissionsPrompt::AddCheckedDevice, this,
base::Passed(&device_info)));
@@ -243,7 +243,7 @@ class HidDevicePermissionsPrompt : public DevicePermissionsPrompt::Prompt,
void OnDeviceAdded(scoped_refptr<device::HidDeviceInfo> device) override {
if (HasUnprotectedCollections(device) &&
(filters_.empty() || HidDeviceFilter::MatchesAny(device, filters_))) {
- scoped_ptr<DeviceInfo> device_info(new HidDeviceInfo(device));
+ std::unique_ptr<DeviceInfo> device_info(new HidDeviceInfo(device));
#if defined(OS_CHROMEOS)
chromeos::PermissionBrokerClient* client =
chromeos::DBusThreadManager::Get()->GetPermissionBrokerClient();
@@ -343,7 +343,7 @@ DevicePermissionsPrompt::Prompt::~Prompt() {
}
void DevicePermissionsPrompt::Prompt::AddCheckedDevice(
- scoped_ptr<DeviceInfo> device,
+ std::unique_ptr<DeviceInfo> device,
bool allowed) {
if (allowed) {
devices_.push_back(std::move(device));
diff --git a/chromium/extensions/browser/api/device_permissions_prompt.h b/chromium/extensions/browser/api/device_permissions_prompt.h
index 469ff594d71..cbe5e8ff6e6 100644
--- a/chromium/extensions/browser/api/device_permissions_prompt.h
+++ b/chromium/extensions/browser/api/device_permissions_prompt.h
@@ -7,13 +7,13 @@
#include <stddef.h>
+#include <memory>
#include <vector>
#include "base/callback_forward.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
namespace content {
@@ -99,7 +99,7 @@ class DevicePermissionsPrompt {
protected:
virtual ~Prompt();
- void AddCheckedDevice(scoped_ptr<DeviceInfo> device, bool allowed);
+ void AddCheckedDevice(std::unique_ptr<DeviceInfo> device, bool allowed);
const Extension* extension() const { return extension_; }
Observer* observer() const { return observer_; }
@@ -109,7 +109,7 @@ class DevicePermissionsPrompt {
// Subclasses may fill this with a particular subclass of DeviceInfo and may
// assume that only that instances of that type are stored here.
- std::vector<scoped_ptr<DeviceInfo>> devices_;
+ std::vector<std::unique_ptr<DeviceInfo>> devices_;
private:
friend class base::RefCounted<Prompt>;
diff --git a/chromium/extensions/browser/api/diagnostics/diagnostics_api.h b/chromium/extensions/browser/api/diagnostics/diagnostics_api.h
index cf7ce6c13c2..356c686eb95 100644
--- a/chromium/extensions/browser/api/diagnostics/diagnostics_api.h
+++ b/chromium/extensions/browser/api/diagnostics/diagnostics_api.h
@@ -5,9 +5,9 @@
#ifndef EXTENSIONS_BROWSER_API_DIAGNOSTICS_DIAGNOSTICS_API_H_
#define EXTENSIONS_BROWSER_API_DIAGNOSTICS_DIAGNOSTICS_API_H_
+#include <memory>
#include <string>
-#include "base/memory/scoped_ptr.h"
#include "extensions/browser/api/async_api_function.h"
#include "extensions/common/api/diagnostics.h"
@@ -47,7 +47,7 @@ class DiagnosticsSendPacketFunction : public AsyncApiFunction {
const std::string& ip,
double latency);
- scoped_ptr<api::diagnostics::SendPacket::Params> parameters_;
+ std::unique_ptr<api::diagnostics::SendPacket::Params> parameters_;
};
} // namespace extensions
diff --git a/chromium/extensions/browser/api/diagnostics/diagnostics_api_chromeos.cc b/chromium/extensions/browser/api/diagnostics/diagnostics_api_chromeos.cc
index f14b8fb0cbe..6186bc77830 100644
--- a/chromium/extensions/browser/api/diagnostics/diagnostics_api_chromeos.cc
+++ b/chromium/extensions/browser/api/diagnostics/diagnostics_api_chromeos.cc
@@ -29,7 +29,7 @@ typedef base::Callback<void(
bool ParseResult(const std::string& status, std::string* ip, double* latency) {
// Parses the result and returns IP and latency.
- scoped_ptr<base::Value> parsed_value(base::JSONReader::Read(status));
+ std::unique_ptr<base::Value> parsed_value(base::JSONReader::Read(status));
if (!parsed_value)
return false;
diff --git a/chromium/extensions/browser/api/display_source/display_source_api.cc b/chromium/extensions/browser/api/display_source/display_source_api.cc
index 9b57e6b6e3b..fb944130748 100644
--- a/chromium/extensions/browser/api/display_source/display_source_api.cc
+++ b/chromium/extensions/browser/api/display_source/display_source_api.cc
@@ -44,7 +44,7 @@ DisplaySourceGetAvailableSinksFunction::Run() {
void DisplaySourceGetAvailableSinksFunction::OnGetSinksCompleted(
const DisplaySourceSinkInfoList& sinks) {
- scoped_ptr<base::ListValue> result =
+ std::unique_ptr<base::ListValue> result =
api::display_source::GetAvailableSinks::Results::Create(sinks);
Respond(ArgumentList(std::move(result)));
}
@@ -62,7 +62,7 @@ DisplaySourceRequestAuthenticationFunction::
ExtensionFunction::ResponseAction
DisplaySourceRequestAuthenticationFunction::Run() {
- scoped_ptr<api::display_source::RequestAuthentication::Params> params(
+ std::unique_ptr<api::display_source::RequestAuthentication::Params> params(
api::display_source::RequestAuthentication::Params::Create(*args_));
if (!params) {
return RespondNow(Error(kErrorInvalidArguments));
@@ -87,7 +87,7 @@ DisplaySourceRequestAuthenticationFunction::Run() {
void DisplaySourceRequestAuthenticationFunction::OnRequestAuthCompleted(
const DisplaySourceAuthInfo& auth_info) {
- scoped_ptr<base::ListValue> result =
+ std::unique_ptr<base::ListValue> result =
api::display_source::RequestAuthentication::Results::Create(auth_info);
Respond(ArgumentList(std::move(result)));
}
diff --git a/chromium/extensions/browser/api/display_source/display_source_apitest.cc b/chromium/extensions/browser/api/display_source/display_source_apitest.cc
index 01419f3dec4..5dc2c666281 100644
--- a/chromium/extensions/browser/api/display_source/display_source_apitest.cc
+++ b/chromium/extensions/browser/api/display_source/display_source_apitest.cc
@@ -1,95 +1,22 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
+// 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 "base/memory/scoped_ptr.h"
-#include "content/public/test/test_utils.h"
-#include "extensions/browser/api/display_source/display_source_connection_delegate.h"
-#include "extensions/browser/api/display_source/display_source_connection_delegate_factory.h"
+#include "extensions/browser/api/display_source/display_source_apitestbase.h"
#include "extensions/shell/test/shell_apitest.h"
namespace extensions {
-using api::display_source::SinkInfo;
-using api::display_source::SinkState;
-using api::display_source::SINK_STATE_DISCONNECTED;
-using api::display_source::AUTHENTICATION_METHOD_PBC;
-
-namespace {
-
-DisplaySourceSinkInfo CreateSinkInfoPtr(int id,
- const std::string& name,
- SinkState state) {
- DisplaySourceSinkInfo info;
- info.id = id;
- info.name = name;
- info.state = state;
-
- return info;
-}
-
-} // namespace
-
-class MockDisplaySourceConnectionDelegate
- : public DisplaySourceConnectionDelegate {
- public:
- const DisplaySourceSinkInfoList& last_found_sinks() const override {
- return sinks_;
- }
- const Connection* connection() const override { return nullptr; }
- void GetAvailableSinks(const SinkInfoListCallback& sinks_callback,
- const StringCallback& failure_callback) override {
- AddSink(CreateSinkInfoPtr(1, "sink 1", SINK_STATE_DISCONNECTED));
- sinks_callback.Run(sinks_);
- }
-
- void RequestAuthentication(int sink_id,
- const AuthInfoCallback& auth_info_callback,
- const StringCallback& failure_callback) override {
- DisplaySourceAuthInfo info;
- info.method = AUTHENTICATION_METHOD_PBC;
- auth_info_callback.Run(info);
- }
-
- void Connect(int sink_id,
- const DisplaySourceAuthInfo& auth_info,
- const StringCallback& failure_callback) override {}
-
- void Disconnect(const StringCallback& failure_callback) override {}
-
- void StartWatchingAvailableSinks() override {
- AddSink(CreateSinkInfoPtr(2, "sink 2", SINK_STATE_DISCONNECTED));
- }
-
- void StopWatchingAvailableSinks() override {}
-
- private:
- void AddSink(DisplaySourceSinkInfo sink) {
- sinks_.push_back(std::move(sink));
- FOR_EACH_OBSERVER(DisplaySourceConnectionDelegate::Observer, observers_,
- OnSinksUpdated(sinks_));
- }
-
- DisplaySourceSinkInfoList sinks_;
-};
-
class DisplaySourceApiTest : public ShellApiTest {
- public:
- DisplaySourceApiTest() = default;
-
- private:
- static scoped_ptr<KeyedService> CreateMockDelegate(
- content::BrowserContext* profile) {
- return make_scoped_ptr<KeyedService>(
- new MockDisplaySourceConnectionDelegate());
- }
-
- void SetUpOnMainThread() override {
- ShellApiTest::SetUpOnMainThread();
- DisplaySourceConnectionDelegateFactory::GetInstance()->SetTestingFactory(
- browser_context(), &CreateMockDelegate);
- content::RunAllPendingInMessageLoop();
- }
+ public:
+ DisplaySourceApiTest() = default;
+
+ private:
+ void SetUpOnMainThread() override {
+ ShellApiTest::SetUpOnMainThread();
+ InitMockDisplaySourceConnectionDelegate(browser_context());
+ content::RunAllPendingInMessageLoop();
+ }
};
IN_PROC_BROWSER_TEST_F(DisplaySourceApiTest, DisplaySourceExtension) {
diff --git a/chromium/extensions/browser/api/display_source/display_source_apitestbase.cc b/chromium/extensions/browser/api/display_source/display_source_apitestbase.cc
new file mode 100644
index 00000000000..ee7ae1fd86b
--- /dev/null
+++ b/chromium/extensions/browser/api/display_source/display_source_apitestbase.cc
@@ -0,0 +1,533 @@
+// 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 "extensions/browser/api/display_source/display_source_apitestbase.h"
+
+#include <map>
+#include <utility>
+
+#include "base/memory/ptr_util.h"
+#include "net/base/net_errors.h"
+#include "net/udp/udp_socket.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace extensions {
+
+using api::display_source::SinkInfo;
+using api::display_source::SinkState;
+using api::display_source::AuthenticationMethod;
+using api::display_source::SINK_STATE_DISCONNECTED;
+using api::display_source::SINK_STATE_CONNECTING;
+using api::display_source::SINK_STATE_CONNECTED;
+using api::display_source::AUTHENTICATION_METHOD_PBC;
+using api::display_source::AUTHENTICATION_METHOD_PIN;
+using content::BrowserThread;
+
+class MockDisplaySourceConnectionDelegate
+ : public DisplaySourceConnectionDelegate,
+ public DisplaySourceConnectionDelegate::Connection {
+ public:
+ MockDisplaySourceConnectionDelegate();
+
+ const DisplaySourceSinkInfoList& last_found_sinks() const override;
+
+ DisplaySourceConnectionDelegate::Connection* connection()
+ override {
+ return (active_sink_ && active_sink_->state == SINK_STATE_CONNECTED)
+ ? this
+ : nullptr;
+ }
+
+ void GetAvailableSinks(const SinkInfoListCallback& sinks_callback,
+ const StringCallback& failure_callback) override;
+
+ void RequestAuthentication(int sink_id,
+ const AuthInfoCallback& auth_info_callback,
+ const StringCallback& failure_callback) override;
+
+ void Connect(int sink_id,
+ const DisplaySourceAuthInfo& auth_info,
+ const StringCallback& failure_callback) override;
+
+ void Disconnect(const StringCallback& failure_callback) override;
+
+ void StartWatchingAvailableSinks() override;
+
+ // DisplaySourceConnectionDelegate::Connection overrides
+ const DisplaySourceSinkInfo& GetConnectedSink() const override;
+
+ void StopWatchingAvailableSinks() override;
+
+ std::string GetLocalAddress() const override;
+
+ std::string GetSinkAddress() const override;
+
+ void SendMessage(const std::string& message) override;
+
+ void SetMessageReceivedCallback(
+ const StringCallback& callback) override;
+
+ private:
+ void AddSink(DisplaySourceSinkInfo sink,
+ AuthenticationMethod auth_method,
+ const std::string& pin_value);
+
+ void OnSinkConnected();
+
+ void NotifySinksUpdated();
+
+ void EnqueueSinkMessage(std::string message);
+
+ void CheckSourceMessageContent(std::string pattern,
+ const std::string& message);
+
+ void BindToUdpSocket();
+
+ void ReceiveMediaPacket();
+
+ void OnMediaPacketReceived(int net_result);
+
+ DisplaySourceSinkInfoList sinks_;
+ DisplaySourceSinkInfo* active_sink_;
+ std::map<int, std::pair<AuthenticationMethod, std::string>> auth_infos_;
+ StringCallback message_received_cb_;
+
+ struct Message {
+ enum Direction {
+ SourceToSink,
+ SinkToSource
+ };
+ std::string data;
+ Direction direction;
+
+ bool is_from_sink() const { return direction == SinkToSource; }
+ Message(const std::string& message_data, Direction direction)
+ : data(message_data), direction(direction) {}
+ };
+
+ std::list<Message> messages_list_;
+ std::string session_id_;
+
+ std::unique_ptr<net::UDPSocket,
+ content::BrowserThread::DeleteOnIOThread> socket_;
+ scoped_refptr<net::IOBuffer> recvfrom_buffer_;
+ net::IPEndPoint end_point_;
+ std::string udp_port_;
+};
+
+namespace {
+
+const size_t kSessionIdLength = 8;
+const size_t kUdpPortLength = 5;
+const char kClientPortKey[] = "client_port=";
+const char kLocalHost[] = "127.0.0.1";
+const char kSessionKey[] = "Session: ";
+const char kUnicastKey[] = "unicast ";
+const int kPortStart = 10000;
+const int kPortEnd = 65535;
+
+DisplaySourceSinkInfo CreateSinkInfo(int id, const std::string& name) {
+ DisplaySourceSinkInfo ptr;
+ ptr.id = id;
+ ptr.name = name;
+ ptr.state = SINK_STATE_DISCONNECTED;
+
+ return ptr;
+}
+
+std::unique_ptr<KeyedService> CreateMockDelegate(
+ content::BrowserContext* profile) {
+ return base::WrapUnique<KeyedService>(
+ new MockDisplaySourceConnectionDelegate());
+}
+
+void AdaptMessagePattern(std::size_t key_pos,
+ const char *key,
+ std::size_t substr_len,
+ const std::string& replace_with,
+ std::string& pattern) {
+ const std::size_t position = key_pos +
+ std::char_traits<char>::length(key);
+ pattern.replace(position, substr_len, replace_with);
+}
+
+} // namespace
+
+void InitMockDisplaySourceConnectionDelegate(content::BrowserContext* profile) {
+ DisplaySourceConnectionDelegateFactory::GetInstance()->SetTestingFactory(
+ profile, &CreateMockDelegate);
+}
+namespace {
+
+// WiFi Display session RTSP messages patterns.
+
+const char kM1Message[] = "OPTIONS * RTSP/1.0\r\n"
+ "CSeq: 1\r\n"
+ "Require: org.wfa.wfd1.0\r\n\r\n";
+
+const char kM1MessageReply[] = "RTSP/1.0 200 OK\r\n"
+ "CSeq:1\r\n"
+ "Public: org.wfa.wfd1.0, "
+ "GET_PARAMETER, SET_PARAMETER\r\n\r\n";
+
+const char kM2Message[] = "OPTIONS * RTSP/1.0\r\n"
+ "CSeq: 2\r\n"
+ "Require: org.wfa.wfd1.0\r\n\r\n";
+
+const char kM2MessageReply[] = "RTSP/1.0 200 OK\r\n"
+ "CSeq: 2\r\n"
+ "Public: org.wfa.wfd1.0, "
+ "GET_PARAMETER, SET_PARAMETER, PLAY, PAUSE, "
+ "SETUP, TEARDOWN\r\n\r\n";
+
+const char kM3Message[] = "GET_PARAMETER rtsp://localhost/wfd1.0 RTSP/1.0\r\n"
+ "CSeq: 2\r\n"
+ "Content-Type: text/parameters\r\n"
+ "Content-Length: 41\r\n\r\n"
+ "wfd_video_formats\r\n"
+ "wfd_client_rtp_ports\r\n";
+
+const char kM3MessageReply[] = "RTSP/1.0 200 OK\r\n"
+ "CSeq: 2\r\n"
+ "Content-Type: text/parameters\r\n"
+ "Content-Length: 145\r\n\r\n"
+ "wfd_video_formats: "
+ "00 00 01 01 0001FFFF 1FFFFFFF 00000FFF 00 0000 "
+ "0000 00 none none\r\n"
+ "wfd_client_rtp_ports: RTP/AVP/UDP;"
+ "unicast 00000 0 mode=play\r\n";
+
+const char kM4Message[] = "SET_PARAMETER rtsp://localhost/wfd1.0 RTSP/1.0\r\n"
+ "CSeq: 3\r\n"
+ "Content-Type: text/parameters\r\n"
+ "Content-Length: 209\r\n\r\n"
+ "wfd_client_rtp_ports: "
+ "RTP/AVP/UDP;unicast 00000 0 mode=play\r\n"
+ "wfd_presentation_URL: "
+ "rtsp://127.0.0.1/wfd1.0/streamid=0 none\r\n"
+ "wfd_video_formats: "
+ "00 00 01 01 00000001 00000000 00000000 00 0000 0000 "
+ "00 none none\r\n";
+
+const char kM4MessageReply[] = "RTSP/1.0 200 OK\r\n"
+ "CSeq: 3\r\n\r\n";
+
+const char kM5Message[] = "SET_PARAMETER rtsp://localhost/wfd1.0 RTSP/1.0\r\n"
+ "CSeq: 4\r\n"
+ "Content-Type: text/parameters\r\n"
+ "Content-Length: 27\r\n\r\n"
+ "wfd_trigger_method: SETUP\r\n";
+
+const char kM5MessageReply[] = "RTSP/1.0 200 OK\r\n"
+ "CSeq: 4\r\n\r\n";
+
+const char kM6Message[] = "SETUP rtsp://localhost/wfd1.0/streamid=0 "
+ "RTSP/1.0\r\n"
+ "CSeq: 3\r\n"
+ "Transport: RTP/AVP/UDP;unicast;"
+ "client_port=00000\r\n\r\n";
+
+const char kM6MessageReply[] = "RTSP/1.0 200 OK\r\n"
+ "CSeq: 3\r\n"
+ "Session: 00000000;timeout=60\r\n"
+ "Transport: RTP/AVP/UDP;unicast;"
+ "client_port=00000\r\n\r\n";
+
+const char kM7Message[] = "PLAY rtsp://localhost/wfd1.0/streamid=0 RTSP/1.0\r\n"
+ "CSeq: 4\r\n"
+ "Session: 00000000\r\n\r\n";
+
+const char kM7MessageReply[] = "RTSP/1.0 200 OK\r\n"
+ "CSeq: 4\r\n\r\n";
+
+const char kM8Message[] = "GET_PARAMETER rtsp://localhost/wfd1.0 RTSP/1.0\r\n"
+ "CSeq: 5\r\n\r\n";
+
+const char kM8MessageReply[] = "RTSP/1.0 200 OK\r\n"
+ "CSeq: 5\r\n\r\n";
+
+const char kM9Message[] = "GET_PARAMETER rtsp://localhost/wfd1.0 RTSP/1.0\r\n"
+ "CSeq: 6\r\n\r\n";
+
+const char kM9MessageReply[] = "RTSP/1.0 200 OK\r\n"
+ "CSeq: 6\r\n\r\n";
+
+const char kM10Message[] = "GET_PARAMETER rtsp://localhost/wfd1.0 RTSP/1.0\r\n"
+ "CSeq: 7\r\n\r\n";
+
+const char kM10MessageReply[] = "RTSP/1.0 200 OK\r\n"
+ "CSeq: 7\r\n\r\n";
+
+} // namespace
+MockDisplaySourceConnectionDelegate::MockDisplaySourceConnectionDelegate()
+ : active_sink_(nullptr) {
+ messages_list_.push_back(Message(kM1Message, Message::SourceToSink));
+ messages_list_.push_back(Message(kM1MessageReply, Message::SinkToSource));
+ messages_list_.push_back(Message(kM2Message, Message::SinkToSource));
+ messages_list_.push_back(Message(kM2MessageReply, Message::SourceToSink));
+ messages_list_.push_back(Message(kM3Message, Message::SourceToSink));
+ messages_list_.push_back(Message(kM3MessageReply, Message::SinkToSource));
+ messages_list_.push_back(Message(kM4Message, Message::SourceToSink));
+ messages_list_.push_back(Message(kM4MessageReply, Message::SinkToSource));
+ messages_list_.push_back(Message(kM5Message, Message::SourceToSink));
+ messages_list_.push_back(Message(kM5MessageReply, Message::SinkToSource));
+ messages_list_.push_back(Message(kM6Message, Message::SinkToSource));
+ messages_list_.push_back(Message(kM6MessageReply, Message::SourceToSink));
+ messages_list_.push_back(Message(kM7Message, Message::SinkToSource));
+ messages_list_.push_back(Message(kM7MessageReply, Message::SourceToSink));
+ messages_list_.push_back(Message(kM8Message, Message::SourceToSink));
+ messages_list_.push_back(Message(kM8MessageReply, Message::SinkToSource));
+ messages_list_.push_back(Message(kM9Message, Message::SourceToSink));
+ messages_list_.push_back(Message(kM9MessageReply, Message::SinkToSource));
+ messages_list_.push_back(Message(kM10Message, Message::SourceToSink));
+ messages_list_.push_back(Message(kM10MessageReply, Message::SinkToSource));
+
+ AddSink(CreateSinkInfo(1, "sink 1"), AUTHENTICATION_METHOD_PIN, "1234");
+}
+
+const DisplaySourceSinkInfoList&
+MockDisplaySourceConnectionDelegate::last_found_sinks() const {
+ return sinks_;
+}
+
+void MockDisplaySourceConnectionDelegate::GetAvailableSinks(
+ const SinkInfoListCallback& sinks_callback,
+ const StringCallback& failure_callback) {
+ sinks_callback.Run(sinks_);
+}
+
+void MockDisplaySourceConnectionDelegate::RequestAuthentication(
+ int sink_id,
+ const AuthInfoCallback& auth_info_callback,
+ const StringCallback& failure_callback) {
+ DisplaySourceAuthInfo info;
+ auto it = auth_infos_.find(sink_id);
+ ASSERT_NE(it, auth_infos_.end());
+
+ info.method = it->second.first;
+ auth_info_callback.Run(info);
+}
+
+void MockDisplaySourceConnectionDelegate::Connect(
+ int sink_id,
+ const DisplaySourceAuthInfo& auth_info,
+ const StringCallback& failure_callback) {
+ auto it = auth_infos_.find(sink_id);
+ ASSERT_NE(it, auth_infos_.end());
+ ASSERT_EQ(it->second.first, auth_info.method);
+ ASSERT_STREQ(it->second.second.c_str(), auth_info.data->c_str());
+
+ auto found = std::find_if(sinks_.begin(), sinks_.end(),
+ [sink_id](const DisplaySourceSinkInfo& sink) {
+ return sink.id == sink_id;
+ });
+
+ ASSERT_NE(found, sinks_.end());
+ active_sink_ = sinks_.data() + (found - sinks_.begin());
+ active_sink_->state = SINK_STATE_CONNECTING;
+ NotifySinksUpdated();
+
+ // Bind sink to udp socket at this stage
+ // And store udp port to udp_port_ string in order to be used
+ // In a message exchange. Then make a BrowserThread::PostTask
+ // on UI thread and call OnSinkConnected() to proceed with the test
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&MockDisplaySourceConnectionDelegate::BindToUdpSocket,
+ base::Unretained(this)));
+}
+
+void MockDisplaySourceConnectionDelegate::Disconnect(
+ const StringCallback& failure_callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ CHECK(active_sink_);
+ ASSERT_EQ(active_sink_->state, SINK_STATE_CONNECTED);
+ active_sink_->state = SINK_STATE_DISCONNECTED;
+ active_sink_ = nullptr;
+ NotifySinksUpdated();
+}
+
+void MockDisplaySourceConnectionDelegate::StartWatchingAvailableSinks() {
+ AddSink(CreateSinkInfo(2, "sink 2"), AUTHENTICATION_METHOD_PBC, "");
+}
+
+const DisplaySourceSinkInfo&
+MockDisplaySourceConnectionDelegate::GetConnectedSink() const {
+ CHECK(active_sink_);
+ return *active_sink_;
+}
+
+void MockDisplaySourceConnectionDelegate::StopWatchingAvailableSinks() {}
+
+std::string MockDisplaySourceConnectionDelegate::GetLocalAddress() const {
+ return "127.0.0.1";
+}
+
+std::string MockDisplaySourceConnectionDelegate::GetSinkAddress() const {
+ return "127.0.0.1";
+}
+
+void MockDisplaySourceConnectionDelegate::SendMessage(
+ const std::string& message) {
+ ASSERT_FALSE(messages_list_.empty());
+ ASSERT_FALSE(messages_list_.front().is_from_sink());
+
+ CheckSourceMessageContent(messages_list_.front().data, message);
+ messages_list_.pop_front();
+
+ while (!messages_list_.empty() && messages_list_.front().is_from_sink()) {
+ EnqueueSinkMessage(messages_list_.front().data);
+ messages_list_.pop_front();
+ }
+}
+
+void MockDisplaySourceConnectionDelegate::SetMessageReceivedCallback(
+ const StringCallback& callback) {
+ message_received_cb_ = callback;
+}
+
+void MockDisplaySourceConnectionDelegate::AddSink(
+ DisplaySourceSinkInfo sink,
+ AuthenticationMethod auth_method,
+ const std::string& pin_value) {
+ auth_infos_[sink.id] = {auth_method, pin_value};
+ sinks_.push_back(std::move(sink));
+ NotifySinksUpdated();
+}
+
+void MockDisplaySourceConnectionDelegate::OnSinkConnected() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ CHECK(active_sink_);
+ active_sink_->state = SINK_STATE_CONNECTED;
+ NotifySinksUpdated();
+}
+
+void MockDisplaySourceConnectionDelegate::NotifySinksUpdated() {
+ FOR_EACH_OBSERVER(DisplaySourceConnectionDelegate::Observer, observers_,
+ OnSinksUpdated(sinks_));
+}
+
+void MockDisplaySourceConnectionDelegate::
+EnqueueSinkMessage(std::string message) {
+ const std::size_t found_session_key = message.find(kSessionKey);
+ if (found_session_key != std::string::npos)
+ AdaptMessagePattern(found_session_key, kSessionKey, kSessionIdLength,
+ session_id_, message);
+
+ const std::size_t found_unicast_key = message.find(kUnicastKey);
+ if (found_unicast_key != std::string::npos)
+ AdaptMessagePattern(found_unicast_key, kUnicastKey, kUdpPortLength,
+ udp_port_, message);
+
+ const std::size_t found_clientport_key = message.find(kClientPortKey);
+ if (found_clientport_key != std::string::npos)
+ AdaptMessagePattern(found_clientport_key, kClientPortKey, kUdpPortLength,
+ udp_port_, message);
+
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ base::Bind(message_received_cb_, message));
+}
+
+void MockDisplaySourceConnectionDelegate::
+CheckSourceMessageContent(std::string pattern,
+ const std::string& message) {
+ // Message M6_reply from Source to Sink has a unique and random session id
+ // generated by Source. The id cannot be predicted and the session id should
+ // be extracted and added to the message pattern for assertion.
+ // The following code checks if messages include "Session" string.
+ // If not, assert the message normally.
+ // If yes, find the session id, add it to the pattern and to the sink message
+ // that has Session: substring inside.
+ const std::size_t found_session_key = message.find(kSessionKey);
+ if (found_session_key != std::string::npos) {
+ const std::size_t session_id_pos = found_session_key +
+ std::char_traits<char>::length(kSessionKey);
+ session_id_ = message.substr(session_id_pos, kSessionIdLength);
+ AdaptMessagePattern(found_session_key, kSessionKey, kSessionIdLength,
+ session_id_, pattern);
+ }
+
+ const std::size_t found_unicast_key = message.find(kUnicastKey);
+ if (found_unicast_key != std::string::npos)
+ AdaptMessagePattern(found_unicast_key, kUnicastKey, kUdpPortLength,
+ udp_port_, pattern);
+
+ const std::size_t found_clientport_key = message.find(kClientPortKey);
+ if (found_clientport_key != std::string::npos)
+ AdaptMessagePattern(found_clientport_key, kClientPortKey, kUdpPortLength,
+ udp_port_, pattern);
+
+ ASSERT_EQ(pattern, message);
+}
+
+void MockDisplaySourceConnectionDelegate::BindToUdpSocket() {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ socket_.reset(new net::UDPSocket(
+ net::DatagramSocket::DEFAULT_BIND, net::RandIntCallback(), nullptr,
+ net::NetLog::Source()));
+
+ net::IPAddress address;
+ ASSERT_TRUE(address.AssignFromIPLiteral(kLocalHost));
+
+ int net_result;
+ net_result = socket_->Open(net::ADDRESS_FAMILY_IPV4);
+ ASSERT_EQ(net_result, net::OK);
+
+ for (uint16_t port = kPortStart; port < kPortEnd; ++port) {
+ net::IPEndPoint local_point(address, port);
+ net_result = socket_->Bind(local_point);
+ if (net_result == net::OK) {
+ udp_port_ = std::to_string(port);
+ // When we got an udp socket established and udp port is known
+ // Change sink's status to connected and proceed with the test.
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&MockDisplaySourceConnectionDelegate::OnSinkConnected,
+ base::Unretained(this)));
+ break;
+ }
+ }
+
+ ReceiveMediaPacket();
+}
+
+void MockDisplaySourceConnectionDelegate::ReceiveMediaPacket() {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ DCHECK(socket_.get());
+ const int kBufferSize = 512;
+
+ recvfrom_buffer_ = new net::IOBuffer(kBufferSize);
+
+ int net_result = socket_->RecvFrom(
+ recvfrom_buffer_.get(), kBufferSize, &end_point_,
+ base::Bind(&MockDisplaySourceConnectionDelegate::OnMediaPacketReceived,
+ base::Unretained(this)));
+
+ if (net_result != net::ERR_IO_PENDING)
+ OnMediaPacketReceived(net_result);
+}
+
+void MockDisplaySourceConnectionDelegate::OnMediaPacketReceived(
+ int net_result) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ DCHECK(recvfrom_buffer_.get());
+ recvfrom_buffer_ = NULL;
+
+ if (net_result > 0) {
+ // We received at least one media packet.
+ // Test is completed.
+ socket_->Close();
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&MockDisplaySourceConnectionDelegate::Disconnect,
+ base::Unretained(this), StringCallback()));
+ return;
+ }
+
+ DCHECK(socket_.get());
+ ReceiveMediaPacket();
+}
+
+} // namespace extensions
diff --git a/chromium/extensions/browser/api/display_source/display_source_apitestbase.h b/chromium/extensions/browser/api/display_source/display_source_apitestbase.h
new file mode 100644
index 00000000000..e5dd3e5ebd7
--- /dev/null
+++ b/chromium/extensions/browser/api/display_source/display_source_apitestbase.h
@@ -0,0 +1,26 @@
+// 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 EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_APITESTBASE_H_
+#define EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_APITESTBASE_H_
+
+#include <memory>
+#include <string>
+
+#include "content/public/test/test_utils.h"
+#include "extensions/browser/api/display_source/display_source_connection_delegate.h"
+#include "extensions/browser/api/display_source/display_source_connection_delegate_factory.h"
+
+namespace extensions {
+
+// This functions sets up a mock connection delegate which
+// simulates having of one sink device from the beginning with the properties:
+// name is "sink 1", id is '1', auth.method is 'PIN', PIN value is '1234'.
+// Calling of "StartWatchingAvailableSinks" will add one more sink device,
+// its properties are: name is "sink 2", id is '2', auth.method is 'PBC'.
+void InitMockDisplaySourceConnectionDelegate(content::BrowserContext* profile);
+
+} // namespace extensions
+
+#endif // EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_APITESTBASE_H_
diff --git a/chromium/extensions/browser/api/display_source/display_source_connection_delegate.h b/chromium/extensions/browser/api/display_source/display_source_connection_delegate.h
index a1a3106beb8..a589e7040e0 100644
--- a/chromium/extensions/browser/api/display_source/display_source_connection_delegate.h
+++ b/chromium/extensions/browser/api/display_source/display_source_connection_delegate.h
@@ -31,7 +31,7 @@ class DisplaySourceConnectionDelegate : public KeyedService {
class Connection {
public:
// Returns the connected sink object.
- virtual DisplaySourceSinkInfo GetConnectedSink() const = 0;
+ virtual const DisplaySourceSinkInfo& GetConnectedSink() const = 0;
// Returns the local address of the source.
virtual std::string GetLocalAddress() const = 0;
@@ -41,14 +41,14 @@ class DisplaySourceConnectionDelegate : public KeyedService {
// Sends a control message to the connected sink.
// If an error occurs 'Observer::OnConnectionError' is invoked.
- virtual void SendMessage(const std::string& message) const = 0;
+ virtual void SendMessage(const std::string& message) = 0;
// Sets a callback to receive control messages from the connected sink.
// This method should only be called once in the lifetime of each
// Connection object.
// If an error occurs 'Observer::OnConnectionError' is invoked.
virtual void SetMessageReceivedCallback(
- const StringCallback& callback) const = 0;
+ const StringCallback& callback) = 0;
protected:
Connection();
@@ -90,7 +90,7 @@ class DisplaySourceConnectionDelegate : public KeyedService {
// Returns the Connection object representing the current
// connection to the sink or NULL if there is no current connection.
- virtual const Connection* connection() const = 0;
+ virtual Connection* connection() = 0;
// Queries the list of currently available sinks.
virtual void GetAvailableSinks(const SinkInfoListCallback& sinks_callback,
diff --git a/chromium/extensions/browser/api/display_source/display_source_connection_delegate_factory.h b/chromium/extensions/browser/api/display_source/display_source_connection_delegate_factory.h
index ec412a9884d..d11b55afbb2 100644
--- a/chromium/extensions/browser/api/display_source/display_source_connection_delegate_factory.h
+++ b/chromium/extensions/browser/api/display_source/display_source_connection_delegate_factory.h
@@ -5,8 +5,9 @@
#ifndef EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_CONNECTION_DELEGATE_FACTORY_H_
#define EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_CONNECTION_DELEGATE_FACTORY_H_
+#include <memory>
+
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
#include "extensions/browser/api/display_source/display_source_connection_delegate.h"
diff --git a/chromium/extensions/browser/api/display_source/display_source_event_router.cc b/chromium/extensions/browser/api/display_source/display_source_event_router.cc
index d621e94cd37..202d7f99185 100644
--- a/chromium/extensions/browser/api/display_source/display_source_event_router.cc
+++ b/chromium/extensions/browser/api/display_source/display_source_event_router.cc
@@ -86,9 +86,9 @@ void DisplaySourceEventRouter::OnSinksUpdated(
EventRouter* event_router = EventRouter::Get(browser_context_);
if (!event_router)
return;
- scoped_ptr<base::ListValue> args(
+ std::unique_ptr<base::ListValue> args(
api::display_source::OnSinksUpdated::Create(sinks));
- scoped_ptr<Event> sinks_updated_event(new Event(
+ std::unique_ptr<Event> sinks_updated_event(new Event(
events::DISPLAY_SOURCE_ON_SINKS_UPDATED,
api::display_source::OnSinksUpdated::kEventName, std::move(args)));
event_router->BroadcastEvent(std::move(sinks_updated_event));
diff --git a/chromium/extensions/browser/api/display_source/wifi_display/wifi_display_media_service_impl.cc b/chromium/extensions/browser/api/display_source/wifi_display/wifi_display_media_service_impl.cc
new file mode 100644
index 00000000000..203caa93b12
--- /dev/null
+++ b/chromium/extensions/browser/api/display_source/wifi_display/wifi_display_media_service_impl.cc
@@ -0,0 +1,134 @@
+// 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 "extensions/browser/api/display_source/wifi_display/wifi_display_media_service_impl.h"
+
+#include <string>
+#include <vector>
+
+#include "base/big_endian.h"
+#include "content/public/browser/browser_thread.h"
+#include "net/base/net_errors.h"
+
+using content::BrowserThread;
+
+namespace extensions {
+
+class WiFiDisplayMediaServiceImpl::PacketIOBuffer : public net::IOBuffer {
+ public:
+ explicit PacketIOBuffer(mojo::Array<uint8_t> array);
+
+ int size() const { return packet_data_.size(); }
+
+ private:
+ ~PacketIOBuffer() override;
+
+ std::vector<uint8_t> packet_data_;
+};
+
+WiFiDisplayMediaServiceImpl::PacketIOBuffer::PacketIOBuffer(
+ mojo::Array<uint8_t> array) {
+ array.Swap(&packet_data_);
+ data_ = reinterpret_cast<char*>(packet_data_.data());
+}
+
+WiFiDisplayMediaServiceImpl::PacketIOBuffer::~PacketIOBuffer() {
+ data_ = nullptr;
+}
+
+// static
+void WiFiDisplayMediaServiceImpl::Create(
+ WiFiDisplayMediaServiceRequest request) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ new WiFiDisplayMediaServiceImpl(std::move(request));
+}
+
+// static
+void WiFiDisplayMediaServiceImpl::BindToRequest(
+ WiFiDisplayMediaServiceRequest request) {
+ BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
+ base::Bind(WiFiDisplayMediaServiceImpl::Create,
+ base::Passed(std::move(request))));
+}
+
+WiFiDisplayMediaServiceImpl::WiFiDisplayMediaServiceImpl(
+ WiFiDisplayMediaServiceRequest request)
+ : binding_(this, std::move(request)),
+ last_send_code_(net::OK),
+ weak_factory_(this) {}
+
+WiFiDisplayMediaServiceImpl::~WiFiDisplayMediaServiceImpl() {}
+
+void WiFiDisplayMediaServiceImpl::SetDesinationPoint(
+ const mojo::String& ip_address,
+ int32_t port,
+ const SetDesinationPointCallback& callback) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ net::IPAddress address;
+ if (!address.AssignFromIPLiteral(std::string(ip_address))) {
+ DVLOG(1) << "Failed to parse IP address from " << ip_address;
+ callback.Run(false);
+ return;
+ }
+ net::IPEndPoint end_point(address, static_cast<uint16_t>(port));
+
+ rtp_socket_.reset(new net::UDPSocket(net::DatagramSocket::DEFAULT_BIND,
+ net::RandIntCallback(), nullptr,
+ net::NetLog::Source()));
+ if (rtp_socket_->Open(end_point.GetFamily()) != net::OK ||
+ rtp_socket_->Connect(end_point) != net::OK) {
+ DVLOG(1) << "Could not connect to " << end_point.ToString();
+ callback.Run(false);
+ rtp_socket_.reset();
+ return;
+ }
+ callback.Run(true);
+}
+
+void WiFiDisplayMediaServiceImpl::SendMediaPacket(mojo::Array<uint8_t> packet) {
+ DCHECK(rtp_socket_);
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+
+ if (packet.size() >> 15) {
+ DVLOG(1) << "Packet size limit is exceeded, skipping.";
+ return;
+ }
+
+ if (last_send_code_ == net::ERR_IO_PENDING) {
+ VLOG(1) << "Cannot send because of pending IO, skipping";
+ return;
+ }
+
+ // Create, queue and send a write buffer.
+ scoped_refptr<PacketIOBuffer> write_buffer =
+ new PacketIOBuffer(std::move(packet));
+ write_buffers_.push(std::move(write_buffer));
+
+ Send();
+}
+
+void WiFiDisplayMediaServiceImpl::Send() {
+ DCHECK(!write_buffers_.empty());
+ last_send_code_ = rtp_socket_->Write(
+ write_buffers_.front().get(), write_buffers_.front()->size(),
+ base::Bind(&WiFiDisplayMediaServiceImpl::OnSent,
+ weak_factory_.GetWeakPtr()));
+ if (last_send_code_ != net::ERR_IO_PENDING)
+ OnSent(last_send_code_);
+}
+
+void WiFiDisplayMediaServiceImpl::OnSent(int code) {
+ last_send_code_ = code;
+ if (code < 0) {
+ VLOG(1) << "Unrepairable UDP socket error.";
+ delete this;
+ return;
+ }
+ DCHECK(!write_buffers_.empty());
+ write_buffers_.pop();
+ if (!write_buffers_.empty())
+ Send();
+}
+
+} // namespace extensions
diff --git a/chromium/extensions/browser/api/display_source/wifi_display/wifi_display_media_service_impl.h b/chromium/extensions/browser/api/display_source/wifi_display/wifi_display_media_service_impl.h
new file mode 100644
index 00000000000..c44f93e2f52
--- /dev/null
+++ b/chromium/extensions/browser/api/display_source/wifi_display/wifi_display_media_service_impl.h
@@ -0,0 +1,47 @@
+// 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 EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_SERVICE_IMPL_H_
+#define EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_SERVICE_IMPL_H_
+
+#include <memory>
+#include <queue>
+
+#include "extensions/common/mojo/wifi_display_session_service.mojom.h"
+#include "mojo/public/cpp/bindings/array.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
+#include "net/base/io_buffer.h"
+#include "net/base/ip_endpoint.h"
+#include "net/udp/udp_socket.h"
+
+namespace extensions {
+
+class WiFiDisplayMediaServiceImpl : public WiFiDisplayMediaService {
+ public:
+ ~WiFiDisplayMediaServiceImpl() override;
+ static void BindToRequest(WiFiDisplayMediaServiceRequest request);
+
+ void SetDesinationPoint(const mojo::String& ip_address,
+ int32_t port,
+ const SetDesinationPointCallback& callback) override;
+ void SendMediaPacket(mojo::Array<uint8_t> packet) override;
+
+ private:
+ static void Create(WiFiDisplayMediaServiceRequest request);
+ explicit WiFiDisplayMediaServiceImpl(WiFiDisplayMediaServiceRequest request);
+ void Send();
+ void OnSent(int code);
+ mojo::StrongBinding<WiFiDisplayMediaService> binding_;
+ std::unique_ptr<net::UDPSocket> rtp_socket_;
+ class PacketIOBuffer;
+ std::queue<scoped_refptr<PacketIOBuffer>> write_buffers_;
+ int last_send_code_;
+ base::WeakPtrFactory<WiFiDisplayMediaServiceImpl> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(WiFiDisplayMediaServiceImpl);
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_SERVICE_IMPL_H_
diff --git a/chromium/extensions/browser/api/display_source/wifi_display/wifi_display_session_service_impl.cc b/chromium/extensions/browser/api/display_source/wifi_display/wifi_display_session_service_impl.cc
index 8143512f325..7a402b97b4f 100644
--- a/chromium/extensions/browser/api/display_source/wifi_display/wifi_display_session_service_impl.cc
+++ b/chromium/extensions/browser/api/display_source/wifi_display/wifi_display_session_service_impl.cc
@@ -79,7 +79,7 @@ void WiFiDisplaySessionServiceImpl::Connect(int32_t sink_id,
if (auth_method != AUTHENTICATION_METHOD_NONE) {
DCHECK(auth_method <= AUTHENTICATION_METHOD_LAST);
auth_info.method = static_cast<AuthenticationMethod>(auth_method);
- auth_info.data = scoped_ptr<std::string>(new std::string(auth_data));
+ auth_info.data = std::unique_ptr<std::string>(new std::string(auth_data));
}
auto on_error = base::Bind(&WiFiDisplaySessionServiceImpl::OnConnectFailed,
weak_factory_.GetWeakPtr(), sink_id);
@@ -157,7 +157,8 @@ void WiFiDisplaySessionServiceImpl::OnSinksUpdated(
auto on_message = base::Bind(&WiFiDisplaySessionServiceImpl::OnSinkMessage,
weak_factory_.GetWeakPtr());
connection->SetMessageReceivedCallback(on_message);
- client_->OnConnected(connection->GetLocalAddress());
+ client_->OnConnected(connection->GetLocalAddress(),
+ connection->GetSinkAddress());
}
if (actual_state == SINK_STATE_DISCONNECTED) {
diff --git a/chromium/extensions/browser/api/dns/dns_api.cc b/chromium/extensions/browser/api/dns/dns_api.cc
index 5513e3a081e..671254ba402 100644
--- a/chromium/extensions/browser/api/dns/dns_api.cc
+++ b/chromium/extensions/browser/api/dns/dns_api.cc
@@ -31,7 +31,7 @@ DnsResolveFunction::DnsResolveFunction()
DnsResolveFunction::~DnsResolveFunction() {}
bool DnsResolveFunction::RunAsync() {
- scoped_ptr<Resolve::Params> params(Resolve::Params::Create(*args_));
+ std::unique_ptr<Resolve::Params> params(Resolve::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
hostname_ = params->hostname;
@@ -80,7 +80,7 @@ void DnsResolveFunction::RespondOnUIThread() {
}
void DnsResolveFunction::OnLookupFinished(int resolve_result) {
- scoped_ptr<ResolveCallbackResolveInfo> resolve_info(
+ std::unique_ptr<ResolveCallbackResolveInfo> resolve_info(
new ResolveCallbackResolveInfo());
resolve_info->result_code = resolve_result;
if (resolve_result == net::OK) {
diff --git a/chromium/extensions/browser/api/dns/dns_api.h b/chromium/extensions/browser/api/dns/dns_api.h
index a8947ead2dd..ca82c86b076 100644
--- a/chromium/extensions/browser/api/dns/dns_api.h
+++ b/chromium/extensions/browser/api/dns/dns_api.h
@@ -43,8 +43,8 @@ class DnsResolveFunction : public AsyncExtensionFunction {
bool response_; // The value sent in SendResponse().
- scoped_ptr<net::HostResolver::RequestHandle> request_handle_;
- scoped_ptr<net::AddressList> addresses_;
+ std::unique_ptr<net::HostResolver::RequestHandle> request_handle_;
+ std::unique_ptr<net::AddressList> addresses_;
};
} // namespace extensions
diff --git a/chromium/extensions/browser/api/dns/dns_apitest.cc b/chromium/extensions/browser/api/dns/dns_apitest.cc
index 24586f9dafb..8cb1015f6d7 100644
--- a/chromium/extensions/browser/api/dns/dns_apitest.cc
+++ b/chromium/extensions/browser/api/dns/dns_apitest.cc
@@ -2,8 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <memory>
+
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "content/public/browser/notification_service.h"
#include "content/public/test/test_utils.h"
@@ -51,7 +52,7 @@ IN_PROC_BROWSER_TEST_F(DnsApiTest, DnsResolveIPLiteral) {
resolve_function->set_extension(empty_extension.get());
resolve_function->set_has_callback(true);
- scoped_ptr<base::Value> result(RunFunctionAndReturnSingleResult(
+ std::unique_ptr<base::Value> result(RunFunctionAndReturnSingleResult(
resolve_function.get(), "[\"127.0.0.1\"]", browser_context()));
base::DictionaryValue* dict = NULL;
ASSERT_TRUE(result->GetAsDictionary(&dict));
@@ -75,7 +76,7 @@ IN_PROC_BROWSER_TEST_F(DnsApiTest, DnsResolveHostname) {
std::string function_arguments("[\"");
function_arguments += MockHostResolverCreator::kHostname;
function_arguments += "\"]";
- scoped_ptr<base::Value> result(RunFunctionAndReturnSingleResult(
+ std::unique_ptr<base::Value> result(RunFunctionAndReturnSingleResult(
resolve_function.get(), function_arguments, browser_context()));
base::DictionaryValue* dict = NULL;
ASSERT_TRUE(result->GetAsDictionary(&dict));
diff --git a/chromium/extensions/browser/api/document_scan/document_scan_api.h b/chromium/extensions/browser/api/document_scan/document_scan_api.h
index efd0443ceff..f08aa99ac87 100644
--- a/chromium/extensions/browser/api/document_scan/document_scan_api.h
+++ b/chromium/extensions/browser/api/document_scan/document_scan_api.h
@@ -5,11 +5,11 @@
#ifndef EXTENSIONS_BROWSER_API_DOCUMENT_SCAN_DOCUMENT_SCAN_API_H_
#define EXTENSIONS_BROWSER_API_DOCUMENT_SCAN_DOCUMENT_SCAN_API_H_
+#include <memory>
#include <string>
#include <vector>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/browser/api/async_api_function.h"
#include "extensions/browser/api/document_scan/document_scan_interface.h"
#include "extensions/common/api/document_scan.h"
@@ -42,8 +42,8 @@ class DocumentScanScanFunction : public AsyncApiFunction {
const std::string& mime_type,
const std::string& error);
- scoped_ptr<document_scan::Scan::Params> params_;
- scoped_ptr<DocumentScanInterface> document_scan_interface_;
+ std::unique_ptr<document_scan::Scan::Params> params_;
+ std::unique_ptr<DocumentScanInterface> document_scan_interface_;
DISALLOW_COPY_AND_ASSIGN(DocumentScanScanFunction);
};
diff --git a/chromium/extensions/browser/api/document_scan/document_scan_api_unittest.cc b/chromium/extensions/browser/api/document_scan/document_scan_api_unittest.cc
index ddc4e4dd53f..9a092366f2b 100644
--- a/chromium/extensions/browser/api/document_scan/document_scan_api_unittest.cc
+++ b/chromium/extensions/browser/api/document_scan/document_scan_api_unittest.cc
@@ -106,7 +106,7 @@ TEST_F(DocumentScanScanFunctionTest, Success) {
EXPECT_CALL(*document_scan_interface_, Scan(_, _, _, _))
.WillOnce(InvokeScanCallback(kScanData, kMimeType, ""));
function_->set_user_gesture(true);
- scoped_ptr<base::DictionaryValue> result(
+ std::unique_ptr<base::DictionaryValue> result(
RunFunctionAndReturnDictionary(function_, "[{}]"));
ASSERT_NE(nullptr, result.get());
document_scan::ScanResults scan_results;
diff --git a/chromium/extensions/browser/api/document_scan/document_scan_interface.h b/chromium/extensions/browser/api/document_scan/document_scan_interface.h
index dbcee196b23..2fb9d4f8785 100644
--- a/chromium/extensions/browser/api/document_scan/document_scan_interface.h
+++ b/chromium/extensions/browser/api/document_scan/document_scan_interface.h
@@ -5,11 +5,11 @@
#ifndef EXTENSIONS_BROWSER_API_DOCUMENT_SCAN_DOCUMENT_SCAN_INTERFACE_H_
#define EXTENSIONS_BROWSER_API_DOCUMENT_SCAN_DOCUMENT_SCAN_INTERFACE_H_
+#include <memory>
#include <string>
#include <vector>
#include "base/callback.h"
-#include "base/memory/scoped_ptr.h"
namespace extensions {
diff --git a/chromium/extensions/browser/api/document_scan/document_scan_interface_chromeos_unittest.cc b/chromium/extensions/browser/api/document_scan/document_scan_interface_chromeos_unittest.cc
index 4de0597ddc8..3ca4499b158 100644
--- a/chromium/extensions/browser/api/document_scan/document_scan_interface_chromeos_unittest.cc
+++ b/chromium/extensions/browser/api/document_scan/document_scan_interface_chromeos_unittest.cc
@@ -41,7 +41,7 @@ class DocumentScanInterfaceChromeosTest : public testing::Test {
protected:
DocumentScanInterfaceChromeos scan_interface_;
- scoped_ptr<chromeos::MockLorgnetteManagerClient> client_;
+ std::unique_ptr<chromeos::MockLorgnetteManagerClient> client_;
};
ACTION_P2(InvokeListScannersCallback, scanner_list, error) {
diff --git a/chromium/extensions/browser/api/execute_code_function.cc b/chromium/extensions/browser/api/execute_code_function.cc
index 53fcb44a47e..9571a0dcb7b 100644
--- a/chromium/extensions/browser/api/execute_code_function.cc
+++ b/chromium/extensions/browser/api/execute_code_function.cc
@@ -84,7 +84,7 @@ void ExecuteCodeFunction::GetFileURLAndLocalizeCSS(
// Check if the file is CSS and needs localization.
if ((script_type == ScriptExecutor::CSS) && !extension_id.empty() &&
(data.find(MessageBundle::kMessageBegin) != std::string::npos)) {
- scoped_ptr<SubstitutionMap> localization_messages(
+ std::unique_ptr<SubstitutionMap> localization_messages(
file_util::LoadMessageBundleSubstitutionMap(
extension_path, extension_id, extension_default_locale));
diff --git a/chromium/extensions/browser/api/execute_code_function.h b/chromium/extensions/browser/api/execute_code_function.h
index bf984f48dd8..d7d965f9e9c 100644
--- a/chromium/extensions/browser/api/execute_code_function.h
+++ b/chromium/extensions/browser/api/execute_code_function.h
@@ -50,7 +50,7 @@ class ExecuteCodeFunction : public AsyncExtensionFunction {
}
// The injection details.
- scoped_ptr<api::extension_types::InjectDetails> details_;
+ std::unique_ptr<api::extension_types::InjectDetails> details_;
private:
// Called when contents from the file whose path is specified in JSON
diff --git a/chromium/extensions/browser/api/extensions_api_client.cc b/chromium/extensions/browser/api/extensions_api_client.cc
index bfc08d3dae3..18ee9d63db0 100644
--- a/chromium/extensions/browser/api/extensions_api_client.cc
+++ b/chromium/extensions/browser/api/extensions_api_client.cc
@@ -5,6 +5,7 @@
#include "extensions/browser/api/extensions_api_client.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "extensions/browser/api/device_permissions_prompt.h"
#include "extensions/browser/api/virtual_keyboard_private/virtual_keyboard_delegate.h"
#include "extensions/browser/api/web_request/web_request_event_router_delegate.h"
@@ -47,16 +48,16 @@ ExtensionsAPIClient::CreateExtensionOptionsGuestDelegate(
return NULL;
}
-scoped_ptr<guest_view::GuestViewManagerDelegate>
+std::unique_ptr<guest_view::GuestViewManagerDelegate>
ExtensionsAPIClient::CreateGuestViewManagerDelegate(
content::BrowserContext* context) const {
- return make_scoped_ptr(new ExtensionsGuestViewManagerDelegate(context));
+ return base::WrapUnique(new ExtensionsGuestViewManagerDelegate(context));
}
-scoped_ptr<MimeHandlerViewGuestDelegate>
+std::unique_ptr<MimeHandlerViewGuestDelegate>
ExtensionsAPIClient::CreateMimeHandlerViewGuestDelegate(
MimeHandlerViewGuest* guest) const {
- return scoped_ptr<MimeHandlerViewGuestDelegate>();
+ return std::unique_ptr<MimeHandlerViewGuestDelegate>();
}
WebViewGuestDelegate* ExtensionsAPIClient::CreateWebViewGuestDelegate(
@@ -82,13 +83,13 @@ ExtensionsAPIClient::CreateContentRulesRegistry(
return scoped_refptr<ContentRulesRegistry>();
}
-scoped_ptr<DevicePermissionsPrompt>
+std::unique_ptr<DevicePermissionsPrompt>
ExtensionsAPIClient::CreateDevicePermissionsPrompt(
content::WebContents* web_contents) const {
return nullptr;
}
-scoped_ptr<VirtualKeyboardDelegate>
+std::unique_ptr<VirtualKeyboardDelegate>
ExtensionsAPIClient::CreateVirtualKeyboardDelegate() const {
return nullptr;
}
diff --git a/chromium/extensions/browser/api/extensions_api_client.h b/chromium/extensions/browser/api/extensions_api_client.h
index d68174d935d..af805402111 100644
--- a/chromium/extensions/browser/api/extensions_api_client.h
+++ b/chromium/extensions/browser/api/extensions_api_client.h
@@ -6,9 +6,9 @@
#define EXTENSIONS_BROWSER_API_EXTENSIONS_API_CLIENT_H_
#include <map>
+#include <memory>
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/browser/api/declarative_content/content_rules_registry.h"
#include "extensions/browser/api/storage/settings_namespace.h"
@@ -88,12 +88,12 @@ class ExtensionsAPIClient {
ExtensionOptionsGuest* guest) const;
// Returns a delegate for GuestViewManagerDelegate.
- virtual scoped_ptr<guest_view::GuestViewManagerDelegate>
+ virtual std::unique_ptr<guest_view::GuestViewManagerDelegate>
CreateGuestViewManagerDelegate(content::BrowserContext* context) const;
// Creates a delegate for MimeHandlerViewGuest.
- virtual scoped_ptr<MimeHandlerViewGuestDelegate>
- CreateMimeHandlerViewGuestDelegate(MimeHandlerViewGuest* guest) const;
+ virtual std::unique_ptr<MimeHandlerViewGuestDelegate>
+ CreateMimeHandlerViewGuestDelegate(MimeHandlerViewGuest* guest) const;
// Returns a delegate for some of WebViewGuest's behavior. The caller owns the
// returned WebViewGuestDelegate.
@@ -117,12 +117,12 @@ class ExtensionsAPIClient {
RulesCacheDelegate* cache_delegate) const;
// Creates a DevicePermissionsPrompt appropriate for the embedder.
- virtual scoped_ptr<DevicePermissionsPrompt> CreateDevicePermissionsPrompt(
- content::WebContents* web_contents) const;
+ virtual std::unique_ptr<DevicePermissionsPrompt>
+ CreateDevicePermissionsPrompt(content::WebContents* web_contents) const;
// Returns a delegate for some of VirtualKeyboardAPI's behavior.
- virtual scoped_ptr<VirtualKeyboardDelegate> CreateVirtualKeyboardDelegate()
- const;
+ virtual std::unique_ptr<VirtualKeyboardDelegate>
+ CreateVirtualKeyboardDelegate() const;
// Creates a delegate for handling the management extension api.
virtual ManagementAPIDelegate* CreateManagementAPIDelegate() const;
diff --git a/chromium/extensions/browser/api/guest_view/app_view/app_view_guest_internal_api.cc b/chromium/extensions/browser/api/guest_view/app_view/app_view_guest_internal_api.cc
index bacf7cd1c8f..0f15d9accea 100644
--- a/chromium/extensions/browser/api/guest_view/app_view/app_view_guest_internal_api.cc
+++ b/chromium/extensions/browser/api/guest_view/app_view/app_view_guest_internal_api.cc
@@ -17,7 +17,7 @@ AppViewGuestInternalAttachFrameFunction::
}
bool AppViewGuestInternalAttachFrameFunction::RunAsync() {
- scoped_ptr<appview::AttachFrame::Params> params(
+ std::unique_ptr<appview::AttachFrame::Params> params(
appview::AttachFrame::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -34,7 +34,7 @@ AppViewGuestInternalDenyRequestFunction::
}
bool AppViewGuestInternalDenyRequestFunction::RunAsync() {
- scoped_ptr<appview::DenyRequest::Params> params(
+ std::unique_ptr<appview::DenyRequest::Params> params(
appview::DenyRequest::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
diff --git a/chromium/extensions/browser/api/guest_view/extension_view/extension_view_internal_api.cc b/chromium/extensions/browser/api/guest_view/extension_view/extension_view_internal_api.cc
index 878c4b583b1..53e31849d11 100644
--- a/chromium/extensions/browser/api/guest_view/extension_view/extension_view_internal_api.cc
+++ b/chromium/extensions/browser/api/guest_view/extension_view/extension_view_internal_api.cc
@@ -51,7 +51,7 @@ bool IsSrcValid(GURL src) {
bool ExtensionViewInternalLoadSrcFunction::RunAsyncSafe(
ExtensionViewGuest* guest) {
- scoped_ptr<extensionview::LoadSrc::Params> params(
+ std::unique_ptr<extensionview::LoadSrc::Params> params(
extensionview::LoadSrc::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
std::string src = params->src;
@@ -69,7 +69,7 @@ bool ExtensionViewInternalLoadSrcFunction::RunAsyncSafe(
}
bool ExtensionViewInternalParseSrcFunction::RunAsync() {
- scoped_ptr<extensionview::ParseSrc::Params> params(
+ std::unique_ptr<extensionview::ParseSrc::Params> params(
extensionview::ParseSrc::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
GURL url(params->src);
@@ -77,7 +77,7 @@ bool ExtensionViewInternalParseSrcFunction::RunAsync() {
// Return whether the src is valid and the current extension ID to
// the callback.
- scoped_ptr<base::ListValue> result_list(new base::ListValue());
+ std::unique_ptr<base::ListValue> result_list(new base::ListValue());
result_list->AppendBoolean(is_src_valid);
result_list->AppendString(url.host());
SetResultList(std::move(result_list));
diff --git a/chromium/extensions/browser/api/guest_view/guest_view_internal_api.cc b/chromium/extensions/browser/api/guest_view/guest_view_internal_api.cc
index 6a60f566b7d..cfd2d0ea65e 100644
--- a/chromium/extensions/browser/api/guest_view/guest_view_internal_api.cc
+++ b/chromium/extensions/browser/api/guest_view/guest_view_internal_api.cc
@@ -73,7 +73,8 @@ void GuestViewInternalCreateGuestFunction::CreateGuestCallback(
guest_instance_id = guest->guest_instance_id();
content_window_id = guest->proxy_routing_id();
}
- scoped_ptr<base::DictionaryValue> return_params(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> return_params(
+ new base::DictionaryValue());
return_params->SetInteger(guest_view::kID, guest_instance_id);
return_params->SetInteger(guest_view::kContentWindowID, content_window_id);
SetResult(return_params.release());
@@ -89,7 +90,7 @@ GuestViewInternalDestroyGuestFunction::
}
bool GuestViewInternalDestroyGuestFunction::RunAsync() {
- scoped_ptr<guest_view_internal::DestroyGuest::Params> params(
+ std::unique_ptr<guest_view_internal::DestroyGuest::Params> params(
guest_view_internal::DestroyGuest::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
GuestViewBase* guest = GuestViewBase::From(
@@ -108,7 +109,7 @@ GuestViewInternalSetSizeFunction::~GuestViewInternalSetSizeFunction() {
}
bool GuestViewInternalSetSizeFunction::RunAsync() {
- scoped_ptr<guest_view_internal::SetSize::Params> params(
+ std::unique_ptr<guest_view_internal::SetSize::Params> params(
guest_view_internal::SetSize::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
GuestViewBase* guest = GuestViewBase::From(
diff --git a/chromium/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc b/chromium/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc
index e33962dbe2e..f1ffb063ee9 100644
--- a/chromium/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc
+++ b/chromium/extensions/browser/api/guest_view/web_view/web_view_internal_api.cc
@@ -266,11 +266,11 @@ bool WebViewInternalCaptureVisibleRegionFunction::RunAsyncSafe(
WebViewGuest* guest) {
using api::extension_types::ImageDetails;
- scoped_ptr<web_view_internal::CaptureVisibleRegion::Params> params(
+ std::unique_ptr<web_view_internal::CaptureVisibleRegion::Params> params(
web_view_internal::CaptureVisibleRegion::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
- scoped_ptr<ImageDetails> image_details;
+ std::unique_ptr<ImageDetails> image_details;
if (args_->GetSize() > 1) {
base::Value* spec = NULL;
EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &spec) && spec);
@@ -324,7 +324,7 @@ void WebViewInternalCaptureVisibleRegionFunction::OnCaptureFailure(
}
bool WebViewInternalNavigateFunction::RunAsyncSafe(WebViewGuest* guest) {
- scoped_ptr<web_view_internal::Navigate::Params> params(
+ std::unique_ptr<web_view_internal::Navigate::Params> params(
web_view_internal::Navigate::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
std::string src = params->src;
@@ -362,7 +362,7 @@ bool WebViewInternalExecuteCodeFunction::Init() {
base::DictionaryValue* details_value = NULL;
if (!args_->GetDictionary(2, &details_value))
return false;
- scoped_ptr<InjectDetails> details(new InjectDetails());
+ std::unique_ptr<InjectDetails> details(new InjectDetails());
if (!InjectDetails::Populate(*details_value, details.get()))
return false;
@@ -476,7 +476,7 @@ WebViewInternalAddContentScriptsFunction::
ExecuteCodeFunction::ResponseAction
WebViewInternalAddContentScriptsFunction::Run() {
- scoped_ptr<web_view_internal::AddContentScripts::Params> params(
+ std::unique_ptr<web_view_internal::AddContentScripts::Params> params(
web_view_internal::AddContentScripts::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -516,7 +516,7 @@ WebViewInternalRemoveContentScriptsFunction::
ExecuteCodeFunction::ResponseAction
WebViewInternalRemoveContentScriptsFunction::Run() {
- scoped_ptr<web_view_internal::RemoveContentScripts::Params> params(
+ std::unique_ptr<web_view_internal::RemoveContentScripts::Params> params(
web_view_internal::RemoveContentScripts::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -546,7 +546,7 @@ WebViewInternalSetNameFunction::~WebViewInternalSetNameFunction() {
}
bool WebViewInternalSetNameFunction::RunAsyncSafe(WebViewGuest* guest) {
- scoped_ptr<web_view_internal::SetName::Params> params(
+ std::unique_ptr<web_view_internal::SetName::Params> params(
web_view_internal::SetName::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
guest->SetName(params->frame_name);
@@ -564,7 +564,7 @@ WebViewInternalSetAllowTransparencyFunction::
bool WebViewInternalSetAllowTransparencyFunction::RunAsyncSafe(
WebViewGuest* guest) {
- scoped_ptr<web_view_internal::SetAllowTransparency::Params> params(
+ std::unique_ptr<web_view_internal::SetAllowTransparency::Params> params(
web_view_internal::SetAllowTransparency::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
guest->SetAllowTransparency(params->allow);
@@ -581,7 +581,7 @@ WebViewInternalSetAllowScalingFunction::
}
bool WebViewInternalSetAllowScalingFunction::RunAsyncSafe(WebViewGuest* guest) {
- scoped_ptr<web_view_internal::SetAllowScaling::Params> params(
+ std::unique_ptr<web_view_internal::SetAllowScaling::Params> params(
web_view_internal::SetAllowScaling::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
guest->SetAllowScaling(params->allow);
@@ -596,7 +596,7 @@ WebViewInternalSetZoomFunction::~WebViewInternalSetZoomFunction() {
}
bool WebViewInternalSetZoomFunction::RunAsyncSafe(WebViewGuest* guest) {
- scoped_ptr<web_view_internal::SetZoom::Params> params(
+ std::unique_ptr<web_view_internal::SetZoom::Params> params(
web_view_internal::SetZoom::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
guest->SetZoom(params->zoom_factor);
@@ -612,7 +612,7 @@ WebViewInternalGetZoomFunction::~WebViewInternalGetZoomFunction() {
}
bool WebViewInternalGetZoomFunction::RunAsyncSafe(WebViewGuest* guest) {
- scoped_ptr<web_view_internal::GetZoom::Params> params(
+ std::unique_ptr<web_view_internal::GetZoom::Params> params(
web_view_internal::GetZoom::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -629,7 +629,7 @@ WebViewInternalSetZoomModeFunction::~WebViewInternalSetZoomModeFunction() {
}
bool WebViewInternalSetZoomModeFunction::RunAsyncSafe(WebViewGuest* guest) {
- scoped_ptr<web_view_internal::SetZoomMode::Params> params(
+ std::unique_ptr<web_view_internal::SetZoomMode::Params> params(
web_view_internal::SetZoomMode::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -661,7 +661,7 @@ WebViewInternalGetZoomModeFunction::~WebViewInternalGetZoomModeFunction() {
}
bool WebViewInternalGetZoomModeFunction::RunAsyncSafe(WebViewGuest* guest) {
- scoped_ptr<web_view_internal::GetZoomMode::Params> params(
+ std::unique_ptr<web_view_internal::GetZoomMode::Params> params(
web_view_internal::GetZoomMode::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -692,7 +692,7 @@ WebViewInternalFindFunction::~WebViewInternalFindFunction() {
}
bool WebViewInternalFindFunction::RunAsyncSafe(WebViewGuest* guest) {
- scoped_ptr<web_view_internal::Find::Params> params(
+ std::unique_ptr<web_view_internal::Find::Params> params(
web_view_internal::Find::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -721,7 +721,7 @@ WebViewInternalStopFindingFunction::~WebViewInternalStopFindingFunction() {
}
bool WebViewInternalStopFindingFunction::RunAsyncSafe(WebViewGuest* guest) {
- scoped_ptr<web_view_internal::StopFinding::Params> params(
+ std::unique_ptr<web_view_internal::StopFinding::Params> params(
web_view_internal::StopFinding::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -755,7 +755,7 @@ WebViewInternalLoadDataWithBaseUrlFunction::
bool WebViewInternalLoadDataWithBaseUrlFunction::RunAsyncSafe(
WebViewGuest* guest) {
- scoped_ptr<web_view_internal::LoadDataWithBaseUrl::Params> params(
+ std::unique_ptr<web_view_internal::LoadDataWithBaseUrl::Params> params(
web_view_internal::LoadDataWithBaseUrl::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -777,7 +777,7 @@ WebViewInternalGoFunction::~WebViewInternalGoFunction() {
}
bool WebViewInternalGoFunction::RunAsyncSafe(WebViewGuest* guest) {
- scoped_ptr<web_view_internal::Go::Params> params(
+ std::unique_ptr<web_view_internal::Go::Params> params(
web_view_internal::Go::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -805,7 +805,7 @@ WebViewInternalSetPermissionFunction::~WebViewInternalSetPermissionFunction() {
}
bool WebViewInternalSetPermissionFunction::RunAsyncSafe(WebViewGuest* guest) {
- scoped_ptr<web_view_internal::SetPermission::Params> params(
+ std::unique_ptr<web_view_internal::SetPermission::Params> params(
web_view_internal::SetPermission::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -854,7 +854,7 @@ WebViewInternalOverrideUserAgentFunction::
bool WebViewInternalOverrideUserAgentFunction::RunAsyncSafe(
WebViewGuest* guest) {
- scoped_ptr<web_view_internal::OverrideUserAgent::Params> params(
+ std::unique_ptr<web_view_internal::OverrideUserAgent::Params> params(
web_view_internal::OverrideUserAgent::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
diff --git a/chromium/extensions/browser/api/guest_view/web_view/web_view_internal_api.h b/chromium/extensions/browser/api/guest_view/web_view/web_view_internal_api.h
index 9f646e69721..54156f16f32 100644
--- a/chromium/extensions/browser/api/guest_view/web_view/web_view_internal_api.h
+++ b/chromium/extensions/browser/api/guest_view/web_view/web_view_internal_api.h
@@ -111,7 +111,7 @@ class WebViewInternalExecuteCodeFunction
GURL guest_src_;
- scoped_ptr<WebUIURLFetcher> url_fetcher_;
+ std::unique_ptr<WebUIURLFetcher> url_fetcher_;
DISALLOW_COPY_AND_ASSIGN(WebViewInternalExecuteCodeFunction);
};
diff --git a/chromium/extensions/browser/api/hid/hid_api.cc b/chromium/extensions/browser/api/hid/hid_api.cc
index 841795db2c4..bbf59b8746d 100644
--- a/chromium/extensions/browser/api/hid/hid_api.cc
+++ b/chromium/extensions/browser/api/hid/hid_api.cc
@@ -88,7 +88,7 @@ HidGetDevicesFunction::HidGetDevicesFunction() {}
HidGetDevicesFunction::~HidGetDevicesFunction() {}
ExtensionFunction::ResponseAction HidGetDevicesFunction::Run() {
- scoped_ptr<api::hid::GetDevices::Params> parameters =
+ std::unique_ptr<api::hid::GetDevices::Params> parameters =
hid::GetDevices::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters);
@@ -118,7 +118,7 @@ ExtensionFunction::ResponseAction HidGetDevicesFunction::Run() {
}
void HidGetDevicesFunction::OnEnumerationComplete(
- scoped_ptr<base::ListValue> devices) {
+ std::unique_ptr<base::ListValue> devices) {
Respond(OneArgument(devices.release()));
}
@@ -129,7 +129,7 @@ HidGetUserSelectedDevicesFunction::~HidGetUserSelectedDevicesFunction() {
}
ExtensionFunction::ResponseAction HidGetUserSelectedDevicesFunction::Run() {
- scoped_ptr<api::hid::GetUserSelectedDevices::Params> parameters =
+ std::unique_ptr<api::hid::GetUserSelectedDevices::Params> parameters =
hid::GetUserSelectedDevices::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters);
@@ -173,7 +173,7 @@ HidConnectFunction::HidConnectFunction() : connection_manager_(nullptr) {
HidConnectFunction::~HidConnectFunction() {}
ExtensionFunction::ResponseAction HidConnectFunction::Run() {
- scoped_ptr<api::hid::Connect::Params> parameters =
+ std::unique_ptr<api::hid::Connect::Params> parameters =
hid::Connect::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters);
@@ -221,7 +221,7 @@ HidDisconnectFunction::HidDisconnectFunction() {}
HidDisconnectFunction::~HidDisconnectFunction() {}
ExtensionFunction::ResponseAction HidDisconnectFunction::Run() {
- scoped_ptr<api::hid::Disconnect::Params> parameters =
+ std::unique_ptr<api::hid::Disconnect::Params> parameters =
hid::Disconnect::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters);
diff --git a/chromium/extensions/browser/api/hid/hid_api.h b/chromium/extensions/browser/api/hid/hid_api.h
index 99824696f9b..095a05b77b4 100644
--- a/chromium/extensions/browser/api/hid/hid_api.h
+++ b/chromium/extensions/browser/api/hid/hid_api.h
@@ -7,11 +7,11 @@
#include <stddef.h>
+#include <memory>
#include <string>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/browser/api/api_resource_manager.h"
#include "extensions/browser/api/hid/hid_connection_resource.h"
#include "extensions/browser/api/hid/hid_device_manager.h"
@@ -44,7 +44,7 @@ class HidGetDevicesFunction : public UIThreadExtensionFunction {
// ExtensionFunction:
ResponseAction Run() override;
- void OnEnumerationComplete(scoped_ptr<base::ListValue> devices);
+ void OnEnumerationComplete(std::unique_ptr<base::ListValue> devices);
DISALLOW_COPY_AND_ASSIGN(HidGetDevicesFunction);
};
@@ -65,8 +65,7 @@ class HidGetUserSelectedDevicesFunction : public UIThreadExtensionFunction {
void OnDevicesChosen(
const std::vector<scoped_refptr<device::HidDeviceInfo>>& devices);
- HidDeviceManager* device_manager_;
- scoped_ptr<DevicePermissionsPrompt> prompt_;
+ std::unique_ptr<DevicePermissionsPrompt> prompt_;
DISALLOW_COPY_AND_ASSIGN(HidGetUserSelectedDevicesFunction);
};
@@ -143,7 +142,7 @@ class HidReceiveFunction : public HidConnectionIoFunction {
scoped_refptr<net::IOBuffer> buffer,
size_t size);
- scoped_ptr<api::hid::Receive::Params> parameters_;
+ std::unique_ptr<api::hid::Receive::Params> parameters_;
DISALLOW_COPY_AND_ASSIGN(HidReceiveFunction);
};
@@ -163,7 +162,7 @@ class HidSendFunction : public HidConnectionIoFunction {
void OnFinished(bool success);
- scoped_ptr<api::hid::Send::Params> parameters_;
+ std::unique_ptr<api::hid::Send::Params> parameters_;
DISALLOW_COPY_AND_ASSIGN(HidSendFunction);
};
@@ -186,7 +185,7 @@ class HidReceiveFeatureReportFunction : public HidConnectionIoFunction {
scoped_refptr<net::IOBuffer> buffer,
size_t size);
- scoped_ptr<api::hid::ReceiveFeatureReport::Params> parameters_;
+ std::unique_ptr<api::hid::ReceiveFeatureReport::Params> parameters_;
DISALLOW_COPY_AND_ASSIGN(HidReceiveFeatureReportFunction);
};
@@ -206,7 +205,7 @@ class HidSendFeatureReportFunction : public HidConnectionIoFunction {
void OnFinished(bool success);
- scoped_ptr<api::hid::SendFeatureReport::Params> parameters_;
+ std::unique_ptr<api::hid::SendFeatureReport::Params> parameters_;
DISALLOW_COPY_AND_ASSIGN(HidSendFeatureReportFunction);
};
diff --git a/chromium/extensions/browser/api/hid/hid_apitest.cc b/chromium/extensions/browser/api/hid/hid_apitest.cc
index 706419dd393..3fb9357af3a 100644
--- a/chromium/extensions/browser/api/hid/hid_apitest.cc
+++ b/chromium/extensions/browser/api/hid/hid_apitest.cc
@@ -6,8 +6,9 @@
#include <stdint.h>
#include "base/bind.h"
+#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "device/core/mock_device_client.h"
#include "device/hid/hid_collection_info.h"
@@ -147,9 +148,9 @@ class TestExtensionsAPIClient : public ShellExtensionsAPIClient {
public:
TestExtensionsAPIClient() : ShellExtensionsAPIClient() {}
- scoped_ptr<DevicePermissionsPrompt> CreateDevicePermissionsPrompt(
+ std::unique_ptr<DevicePermissionsPrompt> CreateDevicePermissionsPrompt(
content::WebContents* web_contents) const override {
- return make_scoped_ptr(new TestDevicePermissionsPrompt(web_contents));
+ return base::WrapUnique(new TestDevicePermissionsPrompt(web_contents));
}
};
@@ -207,7 +208,7 @@ class HidApiTest : public ShellApiTest {
}
protected:
- scoped_ptr<MockDeviceClient> device_client_;
+ std::unique_ptr<MockDeviceClient> device_client_;
};
IN_PROC_BROWSER_TEST_F(HidApiTest, HidApp) {
diff --git a/chromium/extensions/browser/api/hid/hid_device_manager.cc b/chromium/extensions/browser/api/hid/hid_device_manager.cc
index 11e1569ffe9..745813f4271 100644
--- a/chromium/extensions/browser/api/hid/hid_device_manager.cc
+++ b/chromium/extensions/browser/api/hid/hid_device_manager.cc
@@ -11,6 +11,7 @@
#include <vector>
#include "base/lazy_instance.h"
+#include "base/memory/ptr_util.h"
#include "device/core/device_client.h"
#include "device/hid/hid_device_filter.h"
#include "device/hid/hid_service.h"
@@ -121,20 +122,20 @@ void HidDeviceManager::GetApiDevices(
LazyInitialize();
if (enumeration_ready_) {
- scoped_ptr<base::ListValue> devices =
+ std::unique_ptr<base::ListValue> devices =
CreateApiDeviceList(extension, filters);
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(callback, base::Passed(&devices)));
} else {
- pending_enumerations_.push_back(
- make_scoped_ptr(new GetApiDevicesParams(extension, filters, callback)));
+ pending_enumerations_.push_back(base::WrapUnique(
+ new GetApiDevicesParams(extension, filters, callback)));
}
}
-scoped_ptr<base::ListValue> HidDeviceManager::GetApiDevicesFromList(
+std::unique_ptr<base::ListValue> HidDeviceManager::GetApiDevicesFromList(
const std::vector<scoped_refptr<HidDeviceInfo>>& devices) {
DCHECK(thread_checker_.CalledOnValidThread());
- scoped_ptr<base::ListValue> device_list(new base::ListValue());
+ std::unique_ptr<base::ListValue> device_list(new base::ListValue());
for (const auto& device : devices) {
const auto device_entry = resource_ids_.find(device->device_id());
DCHECK(device_entry != resource_ids_.end());
@@ -224,7 +225,7 @@ void HidDeviceManager::OnDeviceAdded(scoped_refptr<HidDeviceInfo> device_info) {
PopulateHidDeviceInfo(&api_device_info, device_info);
if (api_device_info.collections.size() > 0) {
- scoped_ptr<base::ListValue> args(
+ std::unique_ptr<base::ListValue> args(
hid::OnDeviceAdded::Create(api_device_info));
DispatchEvent(events::HID_ON_DEVICE_ADDED, hid::OnDeviceAdded::kEventName,
std::move(args), device_info);
@@ -245,7 +246,8 @@ void HidDeviceManager::OnDeviceRemoved(
if (event_router_) {
DCHECK(enumeration_ready_);
- scoped_ptr<base::ListValue> args(hid::OnDeviceRemoved::Create(resource_id));
+ std::unique_ptr<base::ListValue> args(
+ hid::OnDeviceRemoved::Create(resource_id));
DispatchEvent(events::HID_ON_DEVICE_REMOVED,
hid::OnDeviceRemoved::kEventName, std::move(args),
device_info);
@@ -268,13 +270,13 @@ void HidDeviceManager::LazyInitialize() {
initialized_ = true;
}
-scoped_ptr<base::ListValue> HidDeviceManager::CreateApiDeviceList(
+std::unique_ptr<base::ListValue> HidDeviceManager::CreateApiDeviceList(
const Extension* extension,
const std::vector<HidDeviceFilter>& filters) {
HidService* hid_service = device::DeviceClient::Get()->GetHidService();
DCHECK(hid_service);
- scoped_ptr<base::ListValue> api_devices(new base::ListValue());
+ std::unique_ptr<base::ListValue> api_devices(new base::ListValue());
for (const ResourceIdToDeviceIdMap::value_type& map_entry : device_ids_) {
int resource_id = map_entry.first;
const HidDeviceId& device_id = map_entry.second;
@@ -317,18 +319,19 @@ void HidDeviceManager::OnEnumerationComplete(
enumeration_ready_ = true;
for (const auto& params : pending_enumerations_) {
- scoped_ptr<base::ListValue> devices =
+ std::unique_ptr<base::ListValue> devices =
CreateApiDeviceList(params->extension, params->filters);
params->callback.Run(std::move(devices));
}
pending_enumerations_.clear();
}
-void HidDeviceManager::DispatchEvent(events::HistogramValue histogram_value,
- const std::string& event_name,
- scoped_ptr<base::ListValue> event_args,
- scoped_refptr<HidDeviceInfo> device_info) {
- scoped_ptr<Event> event(
+void HidDeviceManager::DispatchEvent(
+ events::HistogramValue histogram_value,
+ const std::string& event_name,
+ std::unique_ptr<base::ListValue> event_args,
+ scoped_refptr<HidDeviceInfo> device_info) {
+ std::unique_ptr<Event> event(
new Event(histogram_value, event_name, std::move(event_args)));
event->will_dispatch_callback = base::Bind(
&WillDispatchDeviceEvent, weak_factory_.GetWeakPtr(), device_info);
diff --git a/chromium/extensions/browser/api/hid/hid_device_manager.h b/chromium/extensions/browser/api/hid/hid_device_manager.h
index 0e57e6f68f1..f75e59a0b0a 100644
--- a/chromium/extensions/browser/api/hid/hid_device_manager.h
+++ b/chromium/extensions/browser/api/hid/hid_device_manager.h
@@ -6,11 +6,11 @@
#define EXTENSIONS_BROWSER_API_HID_HID_DEVICE_MANAGER_H_
#include <map>
+#include <memory>
#include <vector>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/scoped_observer.h"
#include "base/threading/thread_checker.h"
#include "device/hid/hid_service.h"
@@ -34,7 +34,7 @@ class HidDeviceManager : public BrowserContextKeyedAPI,
public device::HidService::Observer,
public EventRouter::Observer {
public:
- typedef base::Callback<void(scoped_ptr<base::ListValue>)>
+ typedef base::Callback<void(std::unique_ptr<base::ListValue>)>
GetApiDevicesCallback;
explicit HidDeviceManager(content::BrowserContext* context);
@@ -58,7 +58,7 @@ class HidDeviceManager : public BrowserContextKeyedAPI,
// Converts a list of HidDeviceInfo objects into a value that can be returned
// through the API.
- scoped_ptr<base::ListValue> GetApiDevicesFromList(
+ std::unique_ptr<base::ListValue> GetApiDevicesFromList(
const std::vector<scoped_refptr<device::HidDeviceInfo>>& devices);
scoped_refptr<device::HidDeviceInfo> GetDeviceInfo(int resource_id);
@@ -101,7 +101,7 @@ class HidDeviceManager : public BrowserContextKeyedAPI,
// Builds a list of device info objects representing the currently enumerated
// devices, taking into account the permissions held by the given extension
// and the filters provided.
- scoped_ptr<base::ListValue> CreateApiDeviceList(
+ std::unique_ptr<base::ListValue> CreateApiDeviceList(
const Extension* extension,
const std::vector<device::HidDeviceFilter>& filters);
void OnEnumerationComplete(
@@ -109,7 +109,7 @@ class HidDeviceManager : public BrowserContextKeyedAPI,
void DispatchEvent(events::HistogramValue histogram_value,
const std::string& event_name,
- scoped_ptr<base::ListValue> event_args,
+ std::unique_ptr<base::ListValue> event_args,
scoped_refptr<device::HidDeviceInfo> device_info);
base::ThreadChecker thread_checker_;
@@ -119,7 +119,7 @@ class HidDeviceManager : public BrowserContextKeyedAPI,
ScopedObserver<device::HidService, device::HidService::Observer>
hid_service_observer_;
bool enumeration_ready_ = false;
- std::vector<scoped_ptr<GetApiDevicesParams>> pending_enumerations_;
+ std::vector<std::unique_ptr<GetApiDevicesParams>> pending_enumerations_;
int next_resource_id_ = 0;
ResourceIdToDeviceIdMap device_ids_;
DeviceIdToResourceIdMap resource_ids_;
diff --git a/chromium/extensions/browser/api/idle/idle_api_unittest.cc b/chromium/extensions/browser/api/idle/idle_api_unittest.cc
index 7e3b5a82356..f73b83aff36 100644
--- a/chromium/extensions/browser/api/idle/idle_api_unittest.cc
+++ b/chromium/extensions/browser/api/idle/idle_api_unittest.cc
@@ -5,13 +5,15 @@
#include "extensions/browser/api/idle/idle_api.h"
#include <limits.h>
+
+#include <memory>
#include <string>
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "extensions/browser/api/idle/idle_api_constants.h"
-#include "extensions/browser/api/idle/idle_manager_factory.h"
#include "extensions/browser/api/idle/idle_manager.h"
+#include "extensions/browser/api/idle/idle_manager_factory.h"
#include "extensions/browser/api_unittest.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_registry.h"
@@ -112,9 +114,9 @@ ScopedListen::~ScopedListen() {
idle_manager_->OnListenerRemoved(details);
}
-scoped_ptr<KeyedService> IdleManagerTestFactory(
+std::unique_ptr<KeyedService> IdleManagerTestFactory(
content::BrowserContext* context) {
- return make_scoped_ptr(new IdleManager(context));
+ return base::WrapUnique(new IdleManager(context));
}
} // namespace
@@ -138,10 +140,10 @@ void IdleTest::SetUp() {
idle_provider_ = new TestIdleProvider();
idle_manager_->SetIdleTimeProviderForTest(
- scoped_ptr<IdleManager::IdleTimeProvider>(idle_provider_));
+ std::unique_ptr<IdleManager::IdleTimeProvider>(idle_provider_));
event_delegate_ = new testing::StrictMock<MockEventDelegate>();
idle_manager_->SetEventDelegateForTest(
- scoped_ptr<IdleManager::EventDelegate>(event_delegate_));
+ std::unique_ptr<IdleManager::EventDelegate>(event_delegate_));
idle_manager_->Init();
}
@@ -150,7 +152,7 @@ TEST_F(IdleTest, QueryLockedActive) {
idle_provider_->set_locked(true);
idle_provider_->set_idle_time(0);
- scoped_ptr<base::Value> result(
+ std::unique_ptr<base::Value> result(
RunFunctionAndReturnValue(new IdleQueryStateFunction(), "[60]"));
std::string idle_state;
@@ -163,7 +165,7 @@ TEST_F(IdleTest, QueryLockedIdle) {
idle_provider_->set_locked(true);
idle_provider_->set_idle_time(INT_MAX);
- scoped_ptr<base::Value> result(
+ std::unique_ptr<base::Value> result(
RunFunctionAndReturnValue(new IdleQueryStateFunction(), "[60]"));
std::string idle_state;
@@ -180,7 +182,7 @@ TEST_F(IdleTest, QueryActive) {
SCOPED_TRACE(time);
idle_provider_->set_idle_time(time);
- scoped_ptr<base::Value> result(
+ std::unique_ptr<base::Value> result(
RunFunctionAndReturnValue(new IdleQueryStateFunction(), "[60]"));
std::string idle_state;
@@ -198,7 +200,7 @@ TEST_F(IdleTest, QueryIdle) {
SCOPED_TRACE(time);
idle_provider_->set_idle_time(time);
- scoped_ptr<base::Value> result(
+ std::unique_ptr<base::Value> result(
RunFunctionAndReturnValue(new IdleQueryStateFunction(), "[60]"));
std::string idle_state;
@@ -219,7 +221,7 @@ TEST_F(IdleTest, QueryMinThreshold) {
idle_provider_->set_idle_time(time);
std::string args = "[" + base::IntToString(threshold) + "]";
- scoped_ptr<base::Value> result(
+ std::unique_ptr<base::Value> result(
RunFunctionAndReturnValue(new IdleQueryStateFunction(), args));
std::string idle_state;
@@ -248,7 +250,7 @@ TEST_F(IdleTest, QueryMaxThreshold) {
idle_provider_->set_idle_time(time);
std::string args = "[" + base::IntToString(threshold) + "]";
- scoped_ptr<base::Value> result(
+ std::unique_ptr<base::Value> result(
RunFunctionAndReturnValue(new IdleQueryStateFunction(), args));
std::string idle_state;
@@ -399,7 +401,7 @@ TEST_F(IdleTest, SetDetectionInterval) {
ScopedListen listen_default(idle_manager_, "default");
ScopedListen listen_extension(idle_manager_, extension()->id());
- scoped_ptr<base::Value> result45(RunFunctionAndReturnValue(
+ std::unique_ptr<base::Value> result45(RunFunctionAndReturnValue(
new IdleSetDetectionIntervalFunction(), "[45]"));
idle_provider_->set_locked(false);
@@ -422,7 +424,7 @@ TEST_F(IdleTest, SetDetectionInterval) {
// Verifies that setting the detection interval before creating the listener
// works correctly.
TEST_F(IdleTest, SetDetectionIntervalBeforeListener) {
- scoped_ptr<base::Value> result45(RunFunctionAndReturnValue(
+ std::unique_ptr<base::Value> result45(RunFunctionAndReturnValue(
new IdleSetDetectionIntervalFunction(), "[45]"));
ScopedListen listen_extension(idle_manager_, extension()->id());
@@ -442,7 +444,7 @@ TEST_F(IdleTest, SetDetectionIntervalBeforeListener) {
TEST_F(IdleTest, SetDetectionIntervalMaximum) {
ScopedListen listen_extension(idle_manager_, extension()->id());
- scoped_ptr<base::Value> result(
+ std::unique_ptr<base::Value> result(
RunFunctionAndReturnValue(new IdleSetDetectionIntervalFunction(),
"[18000]")); // five hours in seconds
@@ -461,7 +463,7 @@ TEST_F(IdleTest, SetDetectionIntervalMaximum) {
TEST_F(IdleTest, SetDetectionIntervalMinimum) {
ScopedListen listen_extension(idle_manager_, extension()->id());
- scoped_ptr<base::Value> result(RunFunctionAndReturnValue(
+ std::unique_ptr<base::Value> result(RunFunctionAndReturnValue(
new IdleSetDetectionIntervalFunction(), "[10]"));
idle_provider_->set_locked(false);
@@ -479,7 +481,7 @@ TEST_F(IdleTest, UnloadCleanup) {
{
ScopedListen listen(idle_manager_, extension()->id());
- scoped_ptr<base::Value> result45(RunFunctionAndReturnValue(
+ std::unique_ptr<base::Value> result45(RunFunctionAndReturnValue(
new IdleSetDetectionIntervalFunction(), "[15]"));
}
diff --git a/chromium/extensions/browser/api/idle/idle_manager.cc b/chromium/extensions/browser/api/idle/idle_manager.cc
index 695e52f2766..cecb1e23f8e 100644
--- a/chromium/extensions/browser/api/idle/idle_manager.cc
+++ b/chromium/extensions/browser/api/idle/idle_manager.cc
@@ -47,11 +47,11 @@ DefaultEventDelegate::~DefaultEventDelegate() {
void DefaultEventDelegate::OnStateChanged(const std::string& extension_id,
ui::IdleState new_state) {
- scoped_ptr<base::ListValue> args(new base::ListValue());
+ std::unique_ptr<base::ListValue> args(new base::ListValue());
args->Append(IdleManager::CreateIdleValue(new_state));
- scoped_ptr<Event> event(new Event(events::IDLE_ON_STATE_CHANGED,
- idle::OnStateChanged::kEventName,
- std::move(args)));
+ std::unique_ptr<Event> event(new Event(events::IDLE_ON_STATE_CHANGED,
+ idle::OnStateChanged::kEventName,
+ std::move(args)));
event->restrict_to_browser_context = context_;
EventRouter::Get(context_)
->DispatchEventToExtension(extension_id, std::move(event));
@@ -195,13 +195,13 @@ base::StringValue* IdleManager::CreateIdleValue(ui::IdleState idle_state) {
}
void IdleManager::SetEventDelegateForTest(
- scoped_ptr<EventDelegate> event_delegate) {
+ std::unique_ptr<EventDelegate> event_delegate) {
DCHECK(thread_checker_.CalledOnValidThread());
event_delegate_ = std::move(event_delegate);
}
void IdleManager::SetIdleTimeProviderForTest(
- scoped_ptr<IdleTimeProvider> idle_time_provider) {
+ std::unique_ptr<IdleTimeProvider> idle_time_provider) {
DCHECK(thread_checker_.CalledOnValidThread());
idle_time_provider_ = std::move(idle_time_provider);
}
diff --git a/chromium/extensions/browser/api/idle/idle_manager.h b/chromium/extensions/browser/api/idle/idle_manager.h
index 9394c7a753a..5d1eb71f3a8 100644
--- a/chromium/extensions/browser/api/idle/idle_manager.h
+++ b/chromium/extensions/browser/api/idle/idle_manager.h
@@ -93,11 +93,12 @@ class IdleManager : public ExtensionRegistryObserver,
static base::StringValue* CreateIdleValue(ui::IdleState idle_state);
// Override default event class. Callee assumes ownership. Used for testing.
- void SetEventDelegateForTest(scoped_ptr<EventDelegate> event_delegate);
+ void SetEventDelegateForTest(std::unique_ptr<EventDelegate> event_delegate);
// Override default idle time calculations. Callee assumes ownership. Used
// for testing.
- void SetIdleTimeProviderForTest(scoped_ptr<IdleTimeProvider> idle_provider);
+ void SetIdleTimeProviderForTest(
+ std::unique_ptr<IdleTimeProvider> idle_provider);
private:
FRIEND_TEST_ALL_PREFIXES(IdleTest, ActiveToIdle);
@@ -129,8 +130,8 @@ class IdleManager : public ExtensionRegistryObserver,
base::RepeatingTimer poll_timer_;
- scoped_ptr<IdleTimeProvider> idle_time_provider_;
- scoped_ptr<EventDelegate> event_delegate_;
+ std::unique_ptr<IdleTimeProvider> idle_time_provider_;
+ std::unique_ptr<EventDelegate> event_delegate_;
base::ThreadChecker thread_checker_;
diff --git a/chromium/extensions/browser/api/management/management_api.cc b/chromium/extensions/browser/api/management/management_api.cc
index 984f41c7380..a1695195ab5 100644
--- a/chromium/extensions/browser/api/management/management_api.cc
+++ b/chromium/extensions/browser/api/management/management_api.cc
@@ -4,6 +4,7 @@
#include "extensions/browser/api/management/management_api.h"
+#include <memory>
#include <string>
#include <utility>
#include <vector>
@@ -13,7 +14,6 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/linked_ptr.h"
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
@@ -280,7 +280,7 @@ bool ManagementGetAllFunction::RunSync() {
}
bool ManagementGetFunction::RunSync() {
- scoped_ptr<management::Get::Params> params(
+ std::unique_ptr<management::Get::Params> params(
management::Get::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context());
@@ -307,7 +307,7 @@ bool ManagementGetSelfFunction::RunSync() {
}
bool ManagementGetPermissionWarningsByIdFunction::RunSync() {
- scoped_ptr<management::GetPermissionWarningsById::Params> params(
+ std::unique_ptr<management::GetPermissionWarningsById::Params> params(
management::GetPermissionWarningsById::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -326,7 +326,7 @@ bool ManagementGetPermissionWarningsByIdFunction::RunSync() {
}
bool ManagementGetPermissionWarningsByManifestFunction::RunAsync() {
- scoped_ptr<management::GetPermissionWarningsByManifest::Params> params(
+ std::unique_ptr<management::GetPermissionWarningsByManifest::Params> params(
management::GetPermissionWarningsByManifest::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -351,7 +351,7 @@ bool ManagementGetPermissionWarningsByManifestFunction::RunAsync() {
}
void ManagementGetPermissionWarningsByManifestFunction::OnParseSuccess(
- scoped_ptr<base::Value> value) {
+ std::unique_ptr<base::Value> value) {
if (!value->IsType(base::Value::TYPE_DICTIONARY)) {
OnParseFailure(keys::kManifestParseError);
return;
@@ -386,7 +386,7 @@ void ManagementGetPermissionWarningsByManifestFunction::OnParseFailure(
}
bool ManagementLaunchAppFunction::RunSync() {
- scoped_ptr<management::LaunchApp::Params> params(
+ std::unique_ptr<management::LaunchApp::Params> params(
management::LaunchApp::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
const Extension* extension =
@@ -415,7 +415,7 @@ ManagementSetEnabledFunction::~ManagementSetEnabledFunction() {
}
ExtensionFunction::ResponseAction ManagementSetEnabledFunction::Run() {
- scoped_ptr<management::SetEnabled::Params> params(
+ std::unique_ptr<management::SetEnabled::Params> params(
management::SetEnabled::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context());
@@ -602,7 +602,7 @@ ManagementUninstallFunction::~ManagementUninstallFunction() {
}
ExtensionFunction::ResponseAction ManagementUninstallFunction::Run() {
- scoped_ptr<management::Uninstall::Params> params(
+ std::unique_ptr<management::Uninstall::Params> params(
management::Uninstall::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -619,7 +619,7 @@ ManagementUninstallSelfFunction::~ManagementUninstallSelfFunction() {
}
ExtensionFunction::ResponseAction ManagementUninstallSelfFunction::Run() {
- scoped_ptr<management::UninstallSelf::Params> params(
+ std::unique_ptr<management::UninstallSelf::Params> params(
management::UninstallSelf::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
EXTENSION_FUNCTION_VALIDATE(extension_.get());
@@ -655,7 +655,7 @@ bool ManagementCreateAppShortcutFunction::RunAsync() {
return false;
}
- scoped_ptr<management::CreateAppShortcut::Params> params(
+ std::unique_ptr<management::CreateAppShortcut::Params> params(
management::CreateAppShortcut::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
const Extension* extension =
@@ -706,7 +706,7 @@ bool ManagementSetLaunchTypeFunction::RunSync() {
return false;
}
- scoped_ptr<management::SetLaunchType::Params> params(
+ std::unique_ptr<management::SetLaunchType::Params> params(
management::SetLaunchType::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
const Extension* extension =
@@ -787,7 +787,7 @@ bool ManagementGenerateAppForLinkFunction::RunAsync() {
return false;
}
- scoped_ptr<management::GenerateAppForLink::Params> params(
+ std::unique_ptr<management::GenerateAppForLink::Params> params(
management::GenerateAppForLink::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -862,7 +862,7 @@ void ManagementEventRouter::BroadcastEvent(
const char* event_name) {
if (extension->ShouldNotBeVisible())
return; // Don't dispatch events for built-in extenions.
- scoped_ptr<base::ListValue> args(new base::ListValue());
+ std::unique_ptr<base::ListValue> args(new base::ListValue());
if (event_name == management::OnUninstalled::kEventName) {
args->Append(new base::StringValue(extension->id()));
} else {
@@ -870,7 +870,7 @@ void ManagementEventRouter::BroadcastEvent(
}
EventRouter::Get(browser_context_)
- ->BroadcastEvent(scoped_ptr<Event>(
+ ->BroadcastEvent(std::unique_ptr<Event>(
new Event(histogram_value, event_name, std::move(args))));
}
diff --git a/chromium/extensions/browser/api/management/management_api.h b/chromium/extensions/browser/api/management/management_api.h
index fc9b563bd1a..1f4f973eb5b 100644
--- a/chromium/extensions/browser/api/management/management_api.h
+++ b/chromium/extensions/browser/api/management/management_api.h
@@ -17,8 +17,6 @@
#include "extensions/browser/extension_function.h"
#include "extensions/browser/extension_registry_observer.h"
-class ExtensionRegistry;
-class ExtensionUninstallDialog;
struct WebApplicationInfo;
namespace extensions {
@@ -87,7 +85,7 @@ class ManagementGetPermissionWarningsByManifestFunction
MANAGEMENT_GETPERMISSIONWARNINGSBYMANIFEST);
// Called when utility process finishes.
- void OnParseSuccess(scoped_ptr<base::Value> value);
+ void OnParseSuccess(std::unique_ptr<base::Value> value);
void OnParseFailure(const std::string& error);
protected:
@@ -127,9 +125,9 @@ class ManagementSetEnabledFunction : public UIThreadExtensionFunction {
std::string extension_id_;
- scoped_ptr<InstallPromptDelegate> install_prompt_;
+ std::unique_ptr<InstallPromptDelegate> install_prompt_;
- scoped_ptr<RequirementsChecker> requirements_checker_;
+ std::unique_ptr<RequirementsChecker> requirements_checker_;
};
class ManagementUninstallFunctionBase : public UIThreadExtensionFunction {
@@ -153,7 +151,7 @@ class ManagementUninstallFunctionBase : public UIThreadExtensionFunction {
std::string target_extension_id_;
- scoped_ptr<UninstallDialogDelegate> uninstall_dialog_;
+ std::unique_ptr<UninstallDialogDelegate> uninstall_dialog_;
};
class ManagementUninstallFunction : public ManagementUninstallFunctionBase {
@@ -221,7 +219,7 @@ class ManagementGenerateAppForLinkFunction : public AsyncManagementFunction {
bool RunAsync() override;
private:
- scoped_ptr<AppForLinkDelegate> app_for_link_delegate_;
+ std::unique_ptr<AppForLinkDelegate> app_for_link_delegate_;
};
class ManagementEventRouter : public ExtensionRegistryObserver {
@@ -285,9 +283,9 @@ class ManagementAPI : public BrowserContextKeyedAPI,
static const bool kServiceRedirectedInIncognito = true;
// Created lazily upon OnListenerAdded.
- scoped_ptr<ManagementEventRouter> management_event_router_;
+ std::unique_ptr<ManagementEventRouter> management_event_router_;
- scoped_ptr<ManagementAPIDelegate> delegate_;
+ std::unique_ptr<ManagementAPIDelegate> delegate_;
DISALLOW_COPY_AND_ASSIGN(ManagementAPI);
};
diff --git a/chromium/extensions/browser/api/management/management_api_delegate.h b/chromium/extensions/browser/api/management/management_api_delegate.h
index 9e127eeb7f1..330d6fef91f 100644
--- a/chromium/extensions/browser/api/management/management_api_delegate.h
+++ b/chromium/extensions/browser/api/management/management_api_delegate.h
@@ -78,14 +78,15 @@ class ManagementAPIDelegate {
// Used to show a dialog prompt in chrome when management.setEnabled extension
// function is called.
- virtual scoped_ptr<InstallPromptDelegate> SetEnabledFunctionDelegate(
+ virtual std::unique_ptr<InstallPromptDelegate> SetEnabledFunctionDelegate(
content::WebContents* web_contents,
content::BrowserContext* browser_context,
const Extension* extension,
const base::Callback<void(bool)>& callback) const = 0;
// Returns a new RequirementsChecker.
- virtual scoped_ptr<RequirementsChecker> CreateRequirementsChecker() const = 0;
+ virtual std::unique_ptr<RequirementsChecker> CreateRequirementsChecker()
+ const = 0;
// Enables the extension identified by |extension_id|.
virtual void EnableExtension(content::BrowserContext* context,
@@ -98,7 +99,7 @@ class ManagementAPIDelegate {
Extension::DisableReason disable_reason) const = 0;
// Used to show a confirmation dialog when uninstalling |target_extension|.
- virtual scoped_ptr<UninstallDialogDelegate> UninstallFunctionDelegate(
+ virtual std::unique_ptr<UninstallDialogDelegate> UninstallFunctionDelegate(
ManagementUninstallFunctionBase* function,
const Extension* target_extension,
bool show_programmatic_uninstall_ui) const = 0;
@@ -121,7 +122,8 @@ class ManagementAPIDelegate {
LaunchType launch_type) const = 0;
// Creates a bookmark app for |launch_url|.
- virtual scoped_ptr<AppForLinkDelegate> GenerateAppForLinkFunctionDelegate(
+ virtual std::unique_ptr<AppForLinkDelegate>
+ GenerateAppForLinkFunctionDelegate(
ManagementGenerateAppForLinkFunction* function,
content::BrowserContext* context,
const std::string& title,
diff --git a/chromium/extensions/browser/api/messaging/native_message_host.h b/chromium/extensions/browser/api/messaging/native_message_host.h
index da241e06f83..2d4b82f312f 100644
--- a/chromium/extensions/browser/api/messaging/native_message_host.h
+++ b/chromium/extensions/browser/api/messaging/native_message_host.h
@@ -5,9 +5,9 @@
#ifndef EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGE_HOST_H_
#define EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGE_HOST_H_
+#include <memory>
#include <string>
-#include "base/memory/scoped_ptr.h"
#include "base/single_thread_task_runner.h"
#include "ui/gfx/native_widget_types.h"
@@ -37,7 +37,7 @@ class NativeMessageHost {
};
// Creates the NativeMessageHost based on the |native_host_name|.
- static scoped_ptr<NativeMessageHost> Create(
+ static std::unique_ptr<NativeMessageHost> Create(
gfx::NativeView native_view,
const std::string& source_extension_id,
const std::string& native_host_name,
diff --git a/chromium/extensions/browser/api/messaging/native_messaging_channel.h b/chromium/extensions/browser/api/messaging/native_messaging_channel.h
index b368706dad9..bd03486a4a3 100644
--- a/chromium/extensions/browser/api/messaging/native_messaging_channel.h
+++ b/chromium/extensions/browser/api/messaging/native_messaging_channel.h
@@ -5,8 +5,9 @@
#ifndef EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGING_CHANNEL_H_
#define EXTENSIONS_BROWSER_API_MESSAGING_NATIVE_MESSAGING_CHANNEL_H_
+#include <memory>
+
#include "base/callback.h"
-#include "base/memory/scoped_ptr.h"
namespace base {
class Value;
@@ -23,7 +24,7 @@ class NativeMessagingChannel {
class EventHandler {
public:
// Called when a message is received from the other endpoint.
- virtual void OnMessage(scoped_ptr<base::Value> message) = 0;
+ virtual void OnMessage(std::unique_ptr<base::Value> message) = 0;
// Called when the channel is disconnected.
// EventHandler is guaranteed not to be called after OnDisconnect().
@@ -38,7 +39,7 @@ class NativeMessagingChannel {
virtual void Start(EventHandler* event_handler) = 0;
// Sends a message to the other endpoint.
- virtual void SendMessage(scoped_ptr<base::Value> message) = 0;
+ virtual void SendMessage(std::unique_ptr<base::Value> message) = 0;
};
} // namespace extensions
diff --git a/chromium/extensions/browser/api/mime_handler_private/mime_handler_private_unittest.cc b/chromium/extensions/browser/api/mime_handler_private/mime_handler_private_unittest.cc
index d88335890b7..d8e1035097b 100644
--- a/chromium/extensions/browser/api/mime_handler_private/mime_handler_private_unittest.cc
+++ b/chromium/extensions/browser/api/mime_handler_private/mime_handler_private_unittest.cc
@@ -4,9 +4,10 @@
#include "extensions/browser/api/mime_handler_private/mime_handler_private.h"
+#include <memory>
#include <utility>
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "content/public/browser/stream_handle.h"
#include "content/public/browser/stream_info.h"
@@ -40,8 +41,8 @@ class TestStreamHandle : public content::StreamHandle {
class MimeHandlerServiceImplTest : public testing::Test {
public:
void SetUp() override {
- scoped_ptr<content::StreamInfo> stream_info(new content::StreamInfo);
- stream_info->handle = make_scoped_ptr(new TestStreamHandle);
+ std::unique_ptr<content::StreamInfo> stream_info(new content::StreamInfo);
+ stream_info->handle = base::WrapUnique(new TestStreamHandle);
stream_info->mime_type = "test/unit";
stream_info->original_url = GURL("test://extensions_unittests");
stream_container_.reset(
@@ -60,9 +61,9 @@ class MimeHandlerServiceImplTest : public testing::Test {
}
base::MessageLoop message_loop_;
- scoped_ptr<StreamContainer> stream_container_;
+ std::unique_ptr<StreamContainer> stream_container_;
mime_handler::MimeHandlerServicePtr service_ptr_;
- scoped_ptr<mime_handler::MimeHandlerService> service_;
+ std::unique_ptr<mime_handler::MimeHandlerService> service_;
bool abort_called_ = false;
mime_handler::StreamInfoPtr stream_info_;
};
diff --git a/chromium/extensions/browser/api/networking_config/networking_config_api.h b/chromium/extensions/browser/api/networking_config/networking_config_api.h
index a5c8a0fa6bb..f5560000229 100644
--- a/chromium/extensions/browser/api/networking_config/networking_config_api.h
+++ b/chromium/extensions/browser/api/networking_config/networking_config_api.h
@@ -24,7 +24,7 @@ class NetworkingConfigSetNetworkFilterFunction
protected:
~NetworkingConfigSetNetworkFilterFunction() override;
- scoped_ptr<api::networking_config::SetNetworkFilter::Params> parameters_;
+ std::unique_ptr<api::networking_config::SetNetworkFilter::Params> parameters_;
private:
DISALLOW_COPY_AND_ASSIGN(NetworkingConfigSetNetworkFilterFunction);
@@ -43,7 +43,8 @@ class NetworkingConfigFinishAuthenticationFunction
protected:
~NetworkingConfigFinishAuthenticationFunction() override;
- scoped_ptr<api::networking_config::FinishAuthentication::Params> parameters_;
+ std::unique_ptr<api::networking_config::FinishAuthentication::Params>
+ parameters_;
private:
DISALLOW_COPY_AND_ASSIGN(NetworkingConfigFinishAuthenticationFunction);
diff --git a/chromium/extensions/browser/api/networking_config/networking_config_service.cc b/chromium/extensions/browser/api/networking_config/networking_config_service.cc
index 0f14345bbf9..c9240e0065f 100644
--- a/chromium/extensions/browser/api/networking_config/networking_config_service.cc
+++ b/chromium/extensions/browser/api/networking_config/networking_config_service.cc
@@ -6,12 +6,14 @@
#include <stddef.h>
#include <stdint.h>
+
#include <algorithm>
#include <utility>
#include <vector>
#include "base/bind.h"
#include "base/lazy_instance.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "chromeos/network/managed_network_configuration_handler.h"
@@ -51,7 +53,7 @@ NetworkingConfigService::AuthenticationResult::AuthenticationResult(
NetworkingConfigService::NetworkingConfigService(
content::BrowserContext* browser_context,
- scoped_ptr<EventDelegate> event_delegate,
+ std::unique_ptr<EventDelegate> event_delegate,
ExtensionRegistry* extension_registry)
: browser_context_(browser_context),
registry_observer_(this),
@@ -148,7 +150,7 @@ void NetworkingConfigService::OnGotProperties(
// Try to extract |bssid| field.
const base::DictionaryValue* wifi_with_state = nullptr;
std::string bssid;
- scoped_ptr<Event> event;
+ std::unique_ptr<Event> event;
if (onc_network_config.GetDictionaryWithoutPathExpansion(
::onc::network_config::kWiFi, &wifi_with_state) &&
wifi_with_state->GetStringWithoutPathExpansion(::onc::wifi::kBSSID,
@@ -166,16 +168,17 @@ void NetworkingConfigService::OnGetPropertiesFailed(
const std::string& extension_id,
const std::string& guid,
const std::string& error_name,
- scoped_ptr<base::DictionaryValue> error_data) {
+ std::unique_ptr<base::DictionaryValue> error_data) {
LOG(WARNING) << "Failed to determine BSSID for network with guid " << guid
<< ": " << error_name;
- scoped_ptr<Event> event =
+ std::unique_ptr<Event> event =
CreatePortalDetectedEventAndDispatch(extension_id, guid, nullptr);
EventRouter::Get(browser_context_)
->DispatchEventToExtension(extension_id, std::move(event));
}
-scoped_ptr<Event> NetworkingConfigService::CreatePortalDetectedEventAndDispatch(
+std::unique_ptr<Event>
+NetworkingConfigService::CreatePortalDetectedEventAndDispatch(
const std::string& extension_id,
const std::string& guid,
const std::string* bssid) {
@@ -190,14 +193,14 @@ scoped_ptr<Event> NetworkingConfigService::CreatePortalDetectedEventAndDispatch(
network_info.type = api::networking_config::NETWORK_TYPE_WIFI;
const std::vector<uint8_t>& raw_ssid = network->raw_ssid();
std::string hex_ssid = base::HexEncode(raw_ssid.data(), raw_ssid.size());
- network_info.hex_ssid = make_scoped_ptr(new std::string(hex_ssid));
- network_info.ssid = make_scoped_ptr(new std::string(network->name()));
- network_info.guid = make_scoped_ptr(new std::string(network->guid()));
+ network_info.hex_ssid = base::WrapUnique(new std::string(hex_ssid));
+ network_info.ssid = base::WrapUnique(new std::string(network->name()));
+ network_info.guid = base::WrapUnique(new std::string(network->guid()));
if (bssid)
network_info.bssid.reset(new std::string(*bssid));
- scoped_ptr<base::ListValue> results =
+ std::unique_ptr<base::ListValue> results =
api::networking_config::OnCaptivePortalDetected::Create(network_info);
- scoped_ptr<Event> event(
+ std::unique_ptr<Event> event(
new Event(events::NETWORKING_CONFIG_ON_CAPTIVE_PORTAL_DETECTED,
api::networking_config::OnCaptivePortalDetected::kEventName,
std::move(results)));
diff --git a/chromium/extensions/browser/api/networking_config/networking_config_service.h b/chromium/extensions/browser/api/networking_config/networking_config_service.h
index fae6c68fe7e..dd6985f130c 100644
--- a/chromium/extensions/browser/api/networking_config/networking_config_service.h
+++ b/chromium/extensions/browser/api/networking_config/networking_config_service.h
@@ -6,10 +6,10 @@
#define EXTENSIONS_BROWSER_API_NETWORKING_CONFIG_NETWORKING_CONFIG_SERVICE_H_
#include <map>
+#include <memory>
#include <string>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h"
#include "base/values.h"
@@ -54,7 +54,7 @@ class NetworkingConfigService : public ExtensionRegistryObserver,
// Note: |extension_registry| must outlive this class.
NetworkingConfigService(content::BrowserContext* browser_context,
- scoped_ptr<EventDelegate> event_delegate,
+ std::unique_ptr<EventDelegate> event_delegate,
ExtensionRegistry* extension_registry);
~NetworkingConfigService() override;
@@ -116,13 +116,13 @@ class NetworkingConfigService : public ExtensionRegistryObserver,
void OnGetPropertiesFailed(const std::string& extension_id,
const std::string& guid,
const std::string& error_name,
- scoped_ptr<base::DictionaryValue> error_data);
+ std::unique_ptr<base::DictionaryValue> error_data);
// Creates the captive portal event about the network with guid |guid| that is
// to be dispatched to the extension identified by |extension_id|. |bssid|
// contains a human readable, hex-encoded version of the BSSID with bytes
// separated by colons, e.g. 45:67:89:ab:cd:ef.
- scoped_ptr<Event> CreatePortalDetectedEventAndDispatch(
+ std::unique_ptr<Event> CreatePortalDetectedEventAndDispatch(
const std::string& extension_id,
const std::string& guid,
const std::string* bssid);
@@ -135,7 +135,7 @@ class NetworkingConfigService : public ExtensionRegistryObserver,
ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
registry_observer_;
- scoped_ptr<EventDelegate> event_delegate_;
+ std::unique_ptr<EventDelegate> event_delegate_;
// This map associates a given hex encoded SSID to an extension entry.
std::map<std::string, std::string> hex_ssid_to_extension_id_;
diff --git a/chromium/extensions/browser/api/networking_config/networking_config_service_chromeos_unittest.cc b/chromium/extensions/browser/api/networking_config/networking_config_service_chromeos_unittest.cc
index 93bab3a429a..a04f4f10bc0 100644
--- a/chromium/extensions/browser/api/networking_config/networking_config_service_chromeos_unittest.cc
+++ b/chromium/extensions/browser/api/networking_config/networking_config_service_chromeos_unittest.cc
@@ -45,19 +45,20 @@ class NetworkingConfigServiceTest : public ApiUnitTest {
void SetUp() override {
ApiUnitTest::SetUp();
- extension_registry_ = scoped_ptr<ExtensionRegistry>(
+ extension_registry_ = std::unique_ptr<ExtensionRegistry>(
new ExtensionRegistry(browser_context()));
- scoped_ptr<MockEventDelegate> mock_event_delegate =
- scoped_ptr<MockEventDelegate>(new MockEventDelegate());
- service_ = scoped_ptr<NetworkingConfigService>(new NetworkingConfigService(
- browser_context(), std::move(mock_event_delegate),
- extension_registry_.get()));
+ std::unique_ptr<MockEventDelegate> mock_event_delegate =
+ std::unique_ptr<MockEventDelegate>(new MockEventDelegate());
+ service_ =
+ std::unique_ptr<NetworkingConfigService>(new NetworkingConfigService(
+ browser_context(), std::move(mock_event_delegate),
+ extension_registry_.get()));
DCHECK(service_);
}
protected:
- scoped_ptr<ExtensionRegistry> extension_registry_;
- scoped_ptr<NetworkingConfigService> service_;
+ std::unique_ptr<ExtensionRegistry> extension_registry_;
+ std::unique_ptr<NetworkingConfigService> service_;
};
TEST_F(NetworkingConfigServiceTest, BasicRegisterHexSsid) {
diff --git a/chromium/extensions/browser/api/networking_config/networking_config_service_factory.cc b/chromium/extensions/browser/api/networking_config/networking_config_service_factory.cc
index 38b9f902a24..a8375941a39 100644
--- a/chromium/extensions/browser/api/networking_config/networking_config_service_factory.cc
+++ b/chromium/extensions/browser/api/networking_config/networking_config_service_factory.cc
@@ -6,6 +6,7 @@
#include <string>
+#include "base/memory/ptr_util.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "extensions/browser/api/networking_config/networking_config_service.h"
#include "extensions/browser/extension_registry_factory.h"
@@ -71,7 +72,7 @@ NetworkingConfigServiceFactory::~NetworkingConfigServiceFactory() {
KeyedService* NetworkingConfigServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
return new NetworkingConfigService(
- context, make_scoped_ptr(new DefaultEventDelegate(context)),
+ context, base::WrapUnique(new DefaultEventDelegate(context)),
ExtensionRegistry::Get(context));
}
diff --git a/chromium/extensions/browser/api/networking_private/networking_private_api.cc b/chromium/extensions/browser/api/networking_private/networking_private_api.cc
index 4e6368fc054..e9c086d680a 100644
--- a/chromium/extensions/browser/api/networking_private/networking_private_api.cc
+++ b/chromium/extensions/browser/api/networking_private/networking_private_api.cc
@@ -50,7 +50,7 @@ NetworkingPrivateGetPropertiesFunction::
}
bool NetworkingPrivateGetPropertiesFunction::RunAsync() {
- scoped_ptr<private_api::GetProperties::Params> params =
+ std::unique_ptr<private_api::GetProperties::Params> params =
private_api::GetProperties::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
@@ -63,7 +63,7 @@ bool NetworkingPrivateGetPropertiesFunction::RunAsync() {
}
void NetworkingPrivateGetPropertiesFunction::Success(
- scoped_ptr<base::DictionaryValue> result) {
+ std::unique_ptr<base::DictionaryValue> result) {
SetResult(result.release());
SendResponse(true);
}
@@ -81,7 +81,7 @@ NetworkingPrivateGetManagedPropertiesFunction::
}
bool NetworkingPrivateGetManagedPropertiesFunction::RunAsync() {
- scoped_ptr<private_api::GetManagedProperties::Params> params =
+ std::unique_ptr<private_api::GetManagedProperties::Params> params =
private_api::GetManagedProperties::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
@@ -96,7 +96,7 @@ bool NetworkingPrivateGetManagedPropertiesFunction::RunAsync() {
}
void NetworkingPrivateGetManagedPropertiesFunction::Success(
- scoped_ptr<base::DictionaryValue> result) {
+ std::unique_ptr<base::DictionaryValue> result) {
SetResult(result.release());
SendResponse(true);
}
@@ -114,7 +114,7 @@ NetworkingPrivateGetStateFunction::~NetworkingPrivateGetStateFunction() {
}
bool NetworkingPrivateGetStateFunction::RunAsync() {
- scoped_ptr<private_api::GetState::Params> params =
+ std::unique_ptr<private_api::GetState::Params> params =
private_api::GetState::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
@@ -126,7 +126,7 @@ bool NetworkingPrivateGetStateFunction::RunAsync() {
}
void NetworkingPrivateGetStateFunction::Success(
- scoped_ptr<base::DictionaryValue> result) {
+ std::unique_ptr<base::DictionaryValue> result) {
SetResult(result.release());
SendResponse(true);
}
@@ -144,11 +144,11 @@ NetworkingPrivateSetPropertiesFunction::
}
bool NetworkingPrivateSetPropertiesFunction::RunAsync() {
- scoped_ptr<private_api::SetProperties::Params> params =
+ std::unique_ptr<private_api::SetProperties::Params> params =
private_api::SetProperties::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
- scoped_ptr<base::DictionaryValue> properties_dict(
+ std::unique_ptr<base::DictionaryValue> properties_dict(
params->properties.ToValue());
GetDelegate(browser_context())
@@ -176,11 +176,11 @@ NetworkingPrivateCreateNetworkFunction::
}
bool NetworkingPrivateCreateNetworkFunction::RunAsync() {
- scoped_ptr<private_api::CreateNetwork::Params> params =
+ std::unique_ptr<private_api::CreateNetwork::Params> params =
private_api::CreateNetwork::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
- scoped_ptr<base::DictionaryValue> properties_dict(
+ std::unique_ptr<base::DictionaryValue> properties_dict(
params->properties.ToValue());
GetDelegate(browser_context())
@@ -209,7 +209,7 @@ NetworkingPrivateForgetNetworkFunction::
}
bool NetworkingPrivateForgetNetworkFunction::RunAsync() {
- scoped_ptr<private_api::ForgetNetwork::Params> params =
+ std::unique_ptr<private_api::ForgetNetwork::Params> params =
private_api::ForgetNetwork::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
@@ -237,7 +237,7 @@ NetworkingPrivateGetNetworksFunction::~NetworkingPrivateGetNetworksFunction() {
}
bool NetworkingPrivateGetNetworksFunction::RunAsync() {
- scoped_ptr<private_api::GetNetworks::Params> params =
+ std::unique_ptr<private_api::GetNetworks::Params> params =
private_api::GetNetworks::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
@@ -258,7 +258,7 @@ bool NetworkingPrivateGetNetworksFunction::RunAsync() {
}
void NetworkingPrivateGetNetworksFunction::Success(
- scoped_ptr<base::ListValue> network_list) {
+ std::unique_ptr<base::ListValue> network_list) {
SetResult(network_list.release());
SendResponse(true);
}
@@ -276,7 +276,7 @@ NetworkingPrivateGetVisibleNetworksFunction::
}
bool NetworkingPrivateGetVisibleNetworksFunction::RunAsync() {
- scoped_ptr<private_api::GetVisibleNetworks::Params> params =
+ std::unique_ptr<private_api::GetVisibleNetworks::Params> params =
private_api::GetVisibleNetworks::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
@@ -295,7 +295,7 @@ bool NetworkingPrivateGetVisibleNetworksFunction::RunAsync() {
}
void NetworkingPrivateGetVisibleNetworksFunction::Success(
- scoped_ptr<base::ListValue> network_properties_list) {
+ std::unique_ptr<base::ListValue> network_properties_list) {
SetResult(network_properties_list.release());
SendResponse(true);
}
@@ -314,13 +314,13 @@ NetworkingPrivateGetEnabledNetworkTypesFunction::
}
bool NetworkingPrivateGetEnabledNetworkTypesFunction::RunSync() {
- scoped_ptr<base::ListValue> enabled_networks_onc_types(
+ std::unique_ptr<base::ListValue> enabled_networks_onc_types(
GetDelegate(browser_context())->GetEnabledNetworkTypes());
if (!enabled_networks_onc_types) {
error_ = networking_private::kErrorNotSupported;
return false;
}
- scoped_ptr<base::ListValue> enabled_networks_list(new base::ListValue);
+ std::unique_ptr<base::ListValue> enabled_networks_list(new base::ListValue);
for (base::ListValue::iterator iter = enabled_networks_onc_types->begin();
iter != enabled_networks_onc_types->end(); ++iter) {
std::string type;
@@ -354,14 +354,14 @@ NetworkingPrivateGetDeviceStatesFunction::
}
bool NetworkingPrivateGetDeviceStatesFunction::RunSync() {
- scoped_ptr<NetworkingPrivateDelegate::DeviceStateList> device_states(
+ std::unique_ptr<NetworkingPrivateDelegate::DeviceStateList> device_states(
GetDelegate(browser_context())->GetDeviceStateList());
if (!device_states) {
error_ = networking_private::kErrorNotSupported;
return false;
}
- scoped_ptr<base::ListValue> device_state_list(new base::ListValue);
+ std::unique_ptr<base::ListValue> device_state_list(new base::ListValue);
for (const auto& properties : *device_states)
device_state_list->Append(properties->ToValue().release());
SetResult(device_state_list.release());
@@ -376,7 +376,7 @@ NetworkingPrivateEnableNetworkTypeFunction::
}
bool NetworkingPrivateEnableNetworkTypeFunction::RunSync() {
- scoped_ptr<private_api::EnableNetworkType::Params> params =
+ std::unique_ptr<private_api::EnableNetworkType::Params> params =
private_api::EnableNetworkType::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
@@ -392,7 +392,7 @@ NetworkingPrivateDisableNetworkTypeFunction::
}
bool NetworkingPrivateDisableNetworkTypeFunction::RunSync() {
- scoped_ptr<private_api::DisableNetworkType::Params> params =
+ std::unique_ptr<private_api::DisableNetworkType::Params> params =
private_api::DisableNetworkType::Params::Create(*args_);
return GetDelegate(browser_context())
@@ -418,7 +418,7 @@ NetworkingPrivateStartConnectFunction::
}
bool NetworkingPrivateStartConnectFunction::RunAsync() {
- scoped_ptr<private_api::StartConnect::Params> params =
+ std::unique_ptr<private_api::StartConnect::Params> params =
private_api::StartConnect::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
@@ -447,7 +447,7 @@ NetworkingPrivateStartDisconnectFunction::
}
bool NetworkingPrivateStartDisconnectFunction::RunAsync() {
- scoped_ptr<private_api::StartDisconnect::Params> params =
+ std::unique_ptr<private_api::StartDisconnect::Params> params =
private_api::StartDisconnect::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
@@ -477,7 +477,7 @@ NetworkingPrivateStartActivateFunction::
}
bool NetworkingPrivateStartActivateFunction::RunAsync() {
- scoped_ptr<private_api::StartActivate::Params> params =
+ std::unique_ptr<private_api::StartActivate::Params> params =
private_api::StartActivate::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
@@ -506,7 +506,7 @@ NetworkingPrivateVerifyDestinationFunction::
}
bool NetworkingPrivateVerifyDestinationFunction::RunAsync() {
- scoped_ptr<private_api::VerifyDestination::Params> params =
+ std::unique_ptr<private_api::VerifyDestination::Params> params =
private_api::VerifyDestination::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
@@ -539,7 +539,7 @@ NetworkingPrivateVerifyAndEncryptCredentialsFunction::
}
bool NetworkingPrivateVerifyAndEncryptCredentialsFunction::RunAsync() {
- scoped_ptr<private_api::VerifyAndEncryptCredentials::Params> params =
+ std::unique_ptr<private_api::VerifyAndEncryptCredentials::Params> params =
private_api::VerifyAndEncryptCredentials::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
@@ -575,7 +575,7 @@ NetworkingPrivateVerifyAndEncryptDataFunction::
}
bool NetworkingPrivateVerifyAndEncryptDataFunction::RunAsync() {
- scoped_ptr<private_api::VerifyAndEncryptData::Params> params =
+ std::unique_ptr<private_api::VerifyAndEncryptData::Params> params =
private_api::VerifyAndEncryptData::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
@@ -609,7 +609,7 @@ NetworkingPrivateSetWifiTDLSEnabledStateFunction::
}
bool NetworkingPrivateSetWifiTDLSEnabledStateFunction::RunAsync() {
- scoped_ptr<private_api::SetWifiTDLSEnabledState::Params> params =
+ std::unique_ptr<private_api::SetWifiTDLSEnabledState::Params> params =
private_api::SetWifiTDLSEnabledState::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
@@ -644,7 +644,7 @@ NetworkingPrivateGetWifiTDLSStatusFunction::
}
bool NetworkingPrivateGetWifiTDLSStatusFunction::RunAsync() {
- scoped_ptr<private_api::GetWifiTDLSStatus::Params> params =
+ std::unique_ptr<private_api::GetWifiTDLSStatus::Params> params =
private_api::GetWifiTDLSStatus::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
@@ -679,7 +679,7 @@ NetworkingPrivateGetCaptivePortalStatusFunction::
}
bool NetworkingPrivateGetCaptivePortalStatusFunction::RunAsync() {
- scoped_ptr<private_api::GetCaptivePortalStatus::Params> params =
+ std::unique_ptr<private_api::GetCaptivePortalStatus::Params> params =
private_api::GetCaptivePortalStatus::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
@@ -713,7 +713,7 @@ NetworkingPrivateUnlockCellularSimFunction::
~NetworkingPrivateUnlockCellularSimFunction() {}
bool NetworkingPrivateUnlockCellularSimFunction::RunAsync() {
- scoped_ptr<private_api::UnlockCellularSim::Params> params =
+ std::unique_ptr<private_api::UnlockCellularSim::Params> params =
private_api::UnlockCellularSim::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
@@ -744,7 +744,7 @@ NetworkingPrivateSetCellularSimStateFunction::
~NetworkingPrivateSetCellularSimStateFunction() {}
bool NetworkingPrivateSetCellularSimStateFunction::RunAsync() {
- scoped_ptr<private_api::SetCellularSimState::Params> params =
+ std::unique_ptr<private_api::SetCellularSimState::Params> params =
private_api::SetCellularSimState::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
diff --git a/chromium/extensions/browser/api/networking_private/networking_private_api.h b/chromium/extensions/browser/api/networking_private/networking_private_api.h
index 6283839f547..b2a6892d626 100644
--- a/chromium/extensions/browser/api/networking_private/networking_private_api.h
+++ b/chromium/extensions/browser/api/networking_private/networking_private_api.h
@@ -5,10 +5,10 @@
#ifndef EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_API_H_
#define EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_API_H_
+#include <memory>
#include <string>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "extensions/browser/extension_function.h"
@@ -40,7 +40,7 @@ class NetworkingPrivateGetPropertiesFunction : public AsyncExtensionFunction {
bool RunAsync() override;
private:
- void Success(scoped_ptr<base::DictionaryValue> result);
+ void Success(std::unique_ptr<base::DictionaryValue> result);
void Failure(const std::string& error_name);
DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetPropertiesFunction);
@@ -61,7 +61,7 @@ class NetworkingPrivateGetManagedPropertiesFunction
bool RunAsync() override;
private:
- void Success(scoped_ptr<base::DictionaryValue> result);
+ void Success(std::unique_ptr<base::DictionaryValue> result);
void Failure(const std::string& error);
DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetManagedPropertiesFunction);
@@ -81,7 +81,7 @@ class NetworkingPrivateGetStateFunction : public AsyncExtensionFunction {
bool RunAsync() override;
private:
- void Success(scoped_ptr<base::DictionaryValue> result);
+ void Success(std::unique_ptr<base::DictionaryValue> result);
void Failure(const std::string& error);
DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetStateFunction);
@@ -161,7 +161,7 @@ class NetworkingPrivateGetNetworksFunction : public AsyncExtensionFunction {
bool RunAsync() override;
private:
- void Success(scoped_ptr<base::ListValue> network_list);
+ void Success(std::unique_ptr<base::ListValue> network_list);
void Failure(const std::string& error);
DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetNetworksFunction);
@@ -182,7 +182,7 @@ class NetworkingPrivateGetVisibleNetworksFunction
bool RunAsync() override;
private:
- void Success(scoped_ptr<base::ListValue> network_list);
+ void Success(std::unique_ptr<base::ListValue> network_list);
void Failure(const std::string& error);
DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetVisibleNetworksFunction);
diff --git a/chromium/extensions/browser/api/networking_private/networking_private_chromeos.cc b/chromium/extensions/browser/api/networking_private/networking_private_chromeos.cc
index a7108488a2a..2a072744b30 100644
--- a/chromium/extensions/browser/api/networking_private/networking_private_chromeos.cc
+++ b/chromium/extensions/browser/api/networking_private/networking_private_chromeos.cc
@@ -126,7 +126,7 @@ void AppendDeviceState(
break;
}
DCHECK_NE(private_api::DEVICE_STATE_TYPE_NONE, state);
- scoped_ptr<private_api::DeviceStateProperties> properties(
+ std::unique_ptr<private_api::DeviceStateProperties> properties(
new private_api::DeviceStateProperties);
properties->type = private_api::ParseNetworkType(type);
properties->state = state;
@@ -143,7 +143,7 @@ void AppendDeviceState(
void NetworkHandlerFailureCallback(
const NetworkingPrivateDelegate::FailureCallback& callback,
const std::string& error_name,
- scoped_ptr<base::DictionaryValue> error_data) {
+ std::unique_ptr<base::DictionaryValue> error_data) {
callback.Run(error_name);
}
@@ -207,7 +207,7 @@ namespace extensions {
NetworkingPrivateChromeOS::NetworkingPrivateChromeOS(
content::BrowserContext* browser_context,
- scoped_ptr<VerifyDelegate> verify_delegate)
+ std::unique_ptr<VerifyDelegate> verify_delegate)
: NetworkingPrivateDelegate(std::move(verify_delegate)),
browser_context_(browser_context),
weak_ptr_factory_(this) {}
@@ -279,7 +279,7 @@ void NetworkingPrivateChromeOS::GetState(
return;
}
- scoped_ptr<base::DictionaryValue> network_properties =
+ std::unique_ptr<base::DictionaryValue> network_properties =
chromeos::network_util::TranslateNetworkStateToONC(network_state);
AppendThirdPartyProviderName(network_properties.get());
@@ -288,7 +288,7 @@ void NetworkingPrivateChromeOS::GetState(
void NetworkingPrivateChromeOS::SetProperties(
const std::string& guid,
- scoped_ptr<base::DictionaryValue> properties,
+ std::unique_ptr<base::DictionaryValue> properties,
const VoidCallback& success_callback,
const FailureCallback& failure_callback) {
std::string service_path, error;
@@ -311,7 +311,7 @@ void NetworkHandlerCreateCallback(
void NetworkingPrivateChromeOS::CreateNetwork(
bool shared,
- scoped_ptr<base::DictionaryValue> properties,
+ std::unique_ptr<base::DictionaryValue> properties,
const StringCallback& success_callback,
const FailureCallback& failure_callback) {
std::string user_id_hash, error;
@@ -352,7 +352,7 @@ void NetworkingPrivateChromeOS::GetNetworks(
const FailureCallback& failure_callback) {
NetworkTypePattern pattern =
chromeos::onc::NetworkTypePatternFromOncType(network_type);
- scoped_ptr<base::ListValue> network_properties_list =
+ std::unique_ptr<base::ListValue> network_properties_list =
chromeos::network_util::TranslateNetworkListToONC(
pattern, configured_only, visible_only, limit);
@@ -549,11 +549,11 @@ void NetworkingPrivateChromeOS::SetCellularSimState(
base::Bind(&NetworkHandlerFailureCallback, failure_callback));
}
-scoped_ptr<base::ListValue>
+std::unique_ptr<base::ListValue>
NetworkingPrivateChromeOS::GetEnabledNetworkTypes() {
chromeos::NetworkStateHandler* state_handler = GetStateHandler();
- scoped_ptr<base::ListValue> network_list(new base::ListValue);
+ std::unique_ptr<base::ListValue> network_list(new base::ListValue);
if (state_handler->IsTechnologyEnabled(NetworkTypePattern::Ethernet()))
network_list->AppendString(::onc::network_type::kEthernet);
@@ -567,13 +567,13 @@ NetworkingPrivateChromeOS::GetEnabledNetworkTypes() {
return network_list;
}
-scoped_ptr<NetworkingPrivateDelegate::DeviceStateList>
+std::unique_ptr<NetworkingPrivateDelegate::DeviceStateList>
NetworkingPrivateChromeOS::GetDeviceStateList() {
std::set<std::string> technologies_found;
NetworkStateHandler::DeviceStateList devices;
NetworkHandler::Get()->network_state_handler()->GetDeviceList(&devices);
- scoped_ptr<DeviceStateList> device_state_list(new DeviceStateList);
+ std::unique_ptr<DeviceStateList> device_state_list(new DeviceStateList);
for (const DeviceState* device : devices) {
std::string onc_type =
chromeos::network_util::TranslateShillTypeToONC(device->type());
@@ -627,7 +627,7 @@ void NetworkingPrivateChromeOS::GetPropertiesCallback(
const DictionaryCallback& callback,
const std::string& service_path,
const base::DictionaryValue& dictionary) {
- scoped_ptr<base::DictionaryValue> dictionary_copy(dictionary.DeepCopy());
+ std::unique_ptr<base::DictionaryValue> dictionary_copy(dictionary.DeepCopy());
AppendThirdPartyProviderName(dictionary_copy.get());
callback.Run(std::move(dictionary_copy));
}
@@ -660,7 +660,7 @@ void NetworkingPrivateChromeOS::ConnectFailureCallback(
const VoidCallback& success_callback,
const FailureCallback& failure_callback,
const std::string& error_name,
- scoped_ptr<base::DictionaryValue> error_data) {
+ std::unique_ptr<base::DictionaryValue> error_data) {
// TODO(stevenjb): Temporary workaround to show the configuration UI.
// Eventually the caller (e.g. Settings) should handle any failures and
// show its own configuration UI. crbug.com/380937.
diff --git a/chromium/extensions/browser/api/networking_private/networking_private_chromeos.h b/chromium/extensions/browser/api/networking_private/networking_private_chromeos.h
index f393fcb6137..9cf77ba755c 100644
--- a/chromium/extensions/browser/api/networking_private/networking_private_chromeos.h
+++ b/chromium/extensions/browser/api/networking_private/networking_private_chromeos.h
@@ -5,10 +5,10 @@
#ifndef EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_CHROMEOS_H_
#define EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_CHROMEOS_H_
+#include <memory>
#include <string>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "extensions/browser/api/networking_private/networking_private_delegate.h"
@@ -28,7 +28,7 @@ class NetworkingPrivateChromeOS : public NetworkingPrivateDelegate {
public:
// |verify_delegate| is passed to NetworkingPrivateDelegate and may be NULL.
NetworkingPrivateChromeOS(content::BrowserContext* browser_context,
- scoped_ptr<VerifyDelegate> verify_delegate);
+ std::unique_ptr<VerifyDelegate> verify_delegate);
~NetworkingPrivateChromeOS() override;
// NetworkingPrivateApi
@@ -42,11 +42,11 @@ class NetworkingPrivateChromeOS : public NetworkingPrivateDelegate {
const DictionaryCallback& success_callback,
const FailureCallback& failure_callback) override;
void SetProperties(const std::string& guid,
- scoped_ptr<base::DictionaryValue> properties,
+ std::unique_ptr<base::DictionaryValue> properties,
const VoidCallback& success_callback,
const FailureCallback& failure_callback) override;
void CreateNetwork(bool shared,
- scoped_ptr<base::DictionaryValue> properties,
+ std::unique_ptr<base::DictionaryValue> properties,
const StringCallback& success_callback,
const FailureCallback& failure_callback) override;
void ForgetNetwork(const std::string& guid,
@@ -90,8 +90,8 @@ class NetworkingPrivateChromeOS : public NetworkingPrivateDelegate {
const std::string& new_pin,
const VoidCallback& success_callback,
const FailureCallback& failure_callback) override;
- scoped_ptr<base::ListValue> GetEnabledNetworkTypes() override;
- scoped_ptr<DeviceStateList> GetDeviceStateList() override;
+ std::unique_ptr<base::ListValue> GetEnabledNetworkTypes() override;
+ std::unique_ptr<DeviceStateList> GetDeviceStateList() override;
bool EnableNetworkType(const std::string& type) override;
bool DisableNetworkType(const std::string& type) override;
bool RequestScan() override;
@@ -111,11 +111,12 @@ class NetworkingPrivateChromeOS : public NetworkingPrivateDelegate {
// Handles connection failures, possibly showing UI for configuration
// failures, then calls the appropriate callback.
- void ConnectFailureCallback(const std::string& guid,
- const VoidCallback& success_callback,
- const FailureCallback& failure_callback,
- const std::string& error_name,
- scoped_ptr<base::DictionaryValue> error_data);
+ void ConnectFailureCallback(
+ const std::string& guid,
+ const VoidCallback& success_callback,
+ const FailureCallback& failure_callback,
+ const std::string& error_name,
+ std::unique_ptr<base::DictionaryValue> error_data);
content::BrowserContext* browser_context_;
base::WeakPtrFactory<NetworkingPrivateChromeOS> weak_ptr_factory_;
diff --git a/chromium/extensions/browser/api/networking_private/networking_private_delegate.cc b/chromium/extensions/browser/api/networking_private/networking_private_delegate.cc
index b9c722e5bf6..03be932348a 100644
--- a/chromium/extensions/browser/api/networking_private/networking_private_delegate.cc
+++ b/chromium/extensions/browser/api/networking_private/networking_private_delegate.cc
@@ -19,7 +19,7 @@ NetworkingPrivateDelegate::UIDelegate::UIDelegate() {}
NetworkingPrivateDelegate::UIDelegate::~UIDelegate() {}
NetworkingPrivateDelegate::NetworkingPrivateDelegate(
- scoped_ptr<VerifyDelegate> verify_delegate)
+ std::unique_ptr<VerifyDelegate> verify_delegate)
: verify_delegate_(std::move(verify_delegate)) {}
NetworkingPrivateDelegate::~NetworkingPrivateDelegate() {
diff --git a/chromium/extensions/browser/api/networking_private/networking_private_delegate.h b/chromium/extensions/browser/api/networking_private/networking_private_delegate.h
index 410d4858d84..06ab8b8c347 100644
--- a/chromium/extensions/browser/api/networking_private/networking_private_delegate.h
+++ b/chromium/extensions/browser/api/networking_private/networking_private_delegate.h
@@ -5,12 +5,12 @@
#ifndef EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_DELEGATE_H_
#define EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_DELEGATE_H_
+#include <memory>
#include <string>
#include <vector>
#include "base/callback.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/values.h"
#include "components/keyed_service/core/keyed_service.h"
@@ -33,14 +33,15 @@ struct VerificationProperties;
class NetworkingPrivateDelegate : public KeyedService {
public:
using DictionaryCallback =
- base::Callback<void(scoped_ptr<base::DictionaryValue>)>;
+ base::Callback<void(std::unique_ptr<base::DictionaryValue>)>;
using VoidCallback = base::Callback<void()>;
using BoolCallback = base::Callback<void(bool)>;
using StringCallback = base::Callback<void(const std::string&)>;
- using NetworkListCallback = base::Callback<void(scoped_ptr<base::ListValue>)>;
+ using NetworkListCallback =
+ base::Callback<void(std::unique_ptr<base::ListValue>)>;
using FailureCallback = base::Callback<void(const std::string&)>;
- using DeviceStateList =
- std::vector<scoped_ptr<api::networking_private::DeviceStateProperties>>;
+ using DeviceStateList = std::vector<
+ std::unique_ptr<api::networking_private::DeviceStateProperties>>;
using VerificationProperties =
api::networking_private::VerificationProperties;
@@ -99,10 +100,10 @@ class NetworkingPrivateDelegate : public KeyedService {
// If |verify_delegate| is not NULL, the Verify* methods will be forwarded
// to the delegate. Otherwise they will fail with a NotSupported error.
explicit NetworkingPrivateDelegate(
- scoped_ptr<VerifyDelegate> verify_delegate);
+ std::unique_ptr<VerifyDelegate> verify_delegate);
~NetworkingPrivateDelegate() override;
- void set_ui_delegate(scoped_ptr<UIDelegate> ui_delegate) {
+ void set_ui_delegate(std::unique_ptr<UIDelegate> ui_delegate) {
ui_delegate_.reset(ui_delegate.release());
}
@@ -120,11 +121,11 @@ class NetworkingPrivateDelegate : public KeyedService {
const DictionaryCallback& success_callback,
const FailureCallback& failure_callback) = 0;
virtual void SetProperties(const std::string& guid,
- scoped_ptr<base::DictionaryValue> properties,
+ std::unique_ptr<base::DictionaryValue> properties,
const VoidCallback& success_callback,
const FailureCallback& failure_callback) = 0;
virtual void CreateNetwork(bool shared,
- scoped_ptr<base::DictionaryValue> properties,
+ std::unique_ptr<base::DictionaryValue> properties,
const StringCallback& success_callback,
const FailureCallback& failure_callback) = 0;
virtual void ForgetNetwork(const std::string& guid,
@@ -174,10 +175,10 @@ class NetworkingPrivateDelegate : public KeyedService {
// Synchronous methods
// Returns a list of ONC type strings.
- virtual scoped_ptr<base::ListValue> GetEnabledNetworkTypes() = 0;
+ virtual std::unique_ptr<base::ListValue> GetEnabledNetworkTypes() = 0;
// Returns a list of DeviceStateProperties.
- virtual scoped_ptr<DeviceStateList> GetDeviceStateList() = 0;
+ virtual std::unique_ptr<DeviceStateList> GetDeviceStateList() = 0;
// Returns true if the ONC network type |type| is enabled.
virtual bool EnableNetworkType(const std::string& type) = 0;
@@ -211,10 +212,10 @@ class NetworkingPrivateDelegate : public KeyedService {
private:
// Interface for Verify* methods. May be null.
- scoped_ptr<VerifyDelegate> verify_delegate_;
+ std::unique_ptr<VerifyDelegate> verify_delegate_;
// Interface for UI methods. May be null.
- scoped_ptr<UIDelegate> ui_delegate_;
+ std::unique_ptr<UIDelegate> ui_delegate_;
DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateDelegate);
};
diff --git a/chromium/extensions/browser/api/networking_private/networking_private_delegate_factory.cc b/chromium/extensions/browser/api/networking_private/networking_private_delegate_factory.cc
index 972cda00ba1..2cee55591e6 100644
--- a/chromium/extensions/browser/api/networking_private/networking_private_delegate_factory.cc
+++ b/chromium/extensions/browser/api/networking_private/networking_private_delegate_factory.cc
@@ -58,19 +58,19 @@ NetworkingPrivateDelegateFactory::~NetworkingPrivateDelegateFactory() {
}
void NetworkingPrivateDelegateFactory::SetVerifyDelegateFactory(
- scoped_ptr<VerifyDelegateFactory> factory) {
+ std::unique_ptr<VerifyDelegateFactory> factory) {
verify_factory_.reset(factory.release());
}
void NetworkingPrivateDelegateFactory::SetUIDelegateFactory(
- scoped_ptr<UIDelegateFactory> factory) {
+ std::unique_ptr<UIDelegateFactory> factory) {
ui_factory_.reset(factory.release());
}
KeyedService* NetworkingPrivateDelegateFactory::BuildServiceInstanceFor(
BrowserContext* browser_context) const {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- scoped_ptr<NetworkingPrivateDelegate::VerifyDelegate> verify_delegate;
+ std::unique_ptr<NetworkingPrivateDelegate::VerifyDelegate> verify_delegate;
if (verify_factory_)
verify_delegate = verify_factory_->CreateDelegate();
@@ -79,10 +79,9 @@ KeyedService* NetworkingPrivateDelegateFactory::BuildServiceInstanceFor(
delegate = new NetworkingPrivateChromeOS(browser_context,
std::move(verify_delegate));
#elif defined(OS_LINUX)
- delegate =
- new NetworkingPrivateLinux(browser_context, std::move(verify_delegate));
+ delegate = new NetworkingPrivateLinux(std::move(verify_delegate));
#elif defined(OS_WIN) || defined(OS_MACOSX)
- scoped_ptr<wifi::WiFiService> wifi_service(wifi::WiFiService::Create());
+ std::unique_ptr<wifi::WiFiService> wifi_service(wifi::WiFiService::Create());
delegate = new NetworkingPrivateServiceClient(std::move(wifi_service),
std::move(verify_delegate));
#else
diff --git a/chromium/extensions/browser/api/networking_private/networking_private_delegate_factory.h b/chromium/extensions/browser/api/networking_private/networking_private_delegate_factory.h
index e048d72b3e8..9aa3063a020 100644
--- a/chromium/extensions/browser/api/networking_private/networking_private_delegate_factory.h
+++ b/chromium/extensions/browser/api/networking_private/networking_private_delegate_factory.h
@@ -4,8 +4,9 @@
#ifndef EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_DELEGATE_FACTORY_H_
#define EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_DELEGATE_FACTORY_H_
+#include <memory>
+
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "build/build_config.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
@@ -36,7 +37,7 @@ class NetworkingPrivateDelegateFactory
VerifyDelegateFactory();
virtual ~VerifyDelegateFactory();
- virtual scoped_ptr<NetworkingPrivateDelegate::VerifyDelegate>
+ virtual std::unique_ptr<NetworkingPrivateDelegate::VerifyDelegate>
CreateDelegate() = 0;
private:
@@ -48,7 +49,7 @@ class NetworkingPrivateDelegateFactory
UIDelegateFactory();
virtual ~UIDelegateFactory();
- virtual scoped_ptr<NetworkingPrivateDelegate::UIDelegate>
+ virtual std::unique_ptr<NetworkingPrivateDelegate::UIDelegate>
CreateDelegate() = 0;
private:
@@ -56,8 +57,8 @@ class NetworkingPrivateDelegateFactory
};
// Provide optional factories for creating delegate instances.
- void SetVerifyDelegateFactory(scoped_ptr<VerifyDelegateFactory> factory);
- void SetUIDelegateFactory(scoped_ptr<UIDelegateFactory> factory);
+ void SetVerifyDelegateFactory(std::unique_ptr<VerifyDelegateFactory> factory);
+ void SetUIDelegateFactory(std::unique_ptr<UIDelegateFactory> factory);
static NetworkingPrivateDelegate* GetForBrowserContext(
content::BrowserContext* browser_context);
@@ -77,8 +78,8 @@ class NetworkingPrivateDelegateFactory
bool ServiceIsCreatedWithBrowserContext() const override;
bool ServiceIsNULLWhileTesting() const override;
- scoped_ptr<VerifyDelegateFactory> verify_factory_;
- scoped_ptr<UIDelegateFactory> ui_factory_;
+ std::unique_ptr<VerifyDelegateFactory> verify_factory_;
+ std::unique_ptr<UIDelegateFactory> ui_factory_;
DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateDelegateFactory);
};
diff --git a/chromium/extensions/browser/api/networking_private/networking_private_event_router_chromeos.cc b/chromium/extensions/browser/api/networking_private/networking_private_event_router_chromeos.cc
index 259fcd3671a..a05de423be0 100644
--- a/chromium/extensions/browser/api/networking_private/networking_private_event_router_chromeos.cc
+++ b/chromium/extensions/browser/api/networking_private/networking_private_event_router_chromeos.cc
@@ -166,9 +166,9 @@ void NetworkingPrivateEventRouterImpl::NetworkListChanged() {
changes.push_back((*iter)->guid());
}
- scoped_ptr<base::ListValue> args(
+ std::unique_ptr<base::ListValue> args(
api::networking_private::OnNetworkListChanged::Create(changes));
- scoped_ptr<Event> extension_event(
+ std::unique_ptr<Event> extension_event(
new Event(events::NETWORKING_PRIVATE_ON_NETWORK_LIST_CHANGED,
api::networking_private::OnNetworkListChanged::kEventName,
std::move(args)));
@@ -182,9 +182,9 @@ void NetworkingPrivateEventRouterImpl::DeviceListChanged() {
return;
}
- scoped_ptr<base::ListValue> args(
+ std::unique_ptr<base::ListValue> args(
api::networking_private::OnDeviceStateListChanged::Create());
- scoped_ptr<Event> extension_event(
+ std::unique_ptr<Event> extension_event(
new Event(events::NETWORKING_PRIVATE_ON_DEVICE_STATE_LIST_CHANGED,
api::networking_private::OnDeviceStateListChanged::kEventName,
std::move(args)));
@@ -201,10 +201,10 @@ void NetworkingPrivateEventRouterImpl::NetworkPropertiesUpdated(
return;
}
NET_LOG_EVENT("NetworkingPrivate.NetworkPropertiesUpdated", network->path());
- scoped_ptr<base::ListValue> args(
+ std::unique_ptr<base::ListValue> args(
api::networking_private::OnNetworksChanged::Create(
std::vector<std::string>(1, network->guid())));
- scoped_ptr<Event> extension_event(new Event(
+ std::unique_ptr<Event> extension_event(new Event(
events::NETWORKING_PRIVATE_ON_NETWORKS_CHANGED,
api::networking_private::OnNetworksChanged::kEventName, std::move(args)));
event_router->BroadcastEvent(std::move(extension_event));
@@ -262,10 +262,10 @@ void NetworkingPrivateEventRouterImpl::OnPortalDetectionCompleted(
break;
}
- scoped_ptr<base::ListValue> args(
+ std::unique_ptr<base::ListValue> args(
api::networking_private::OnPortalDetectionCompleted::Create(path,
status));
- scoped_ptr<Event> extension_event(
+ std::unique_ptr<Event> extension_event(
new Event(events::NETWORKING_PRIVATE_ON_PORTAL_DETECTION_COMPLETED,
api::networking_private::OnPortalDetectionCompleted::kEventName,
std::move(args)));
diff --git a/chromium/extensions/browser/api/networking_private/networking_private_event_router_nonchromeos.cc b/chromium/extensions/browser/api/networking_private/networking_private_event_router_nonchromeos.cc
index 99db0a132c9..36304835b7b 100644
--- a/chromium/extensions/browser/api/networking_private/networking_private_event_router_nonchromeos.cc
+++ b/chromium/extensions/browser/api/networking_private/networking_private_event_router_nonchromeos.cc
@@ -135,9 +135,9 @@ void NetworkingPrivateEventRouterImpl::OnNetworksChangedEvent(
EventRouter* event_router = EventRouter::Get(browser_context_);
if (!event_router)
return;
- scoped_ptr<base::ListValue> args(
+ std::unique_ptr<base::ListValue> args(
api::networking_private::OnNetworksChanged::Create(network_guids));
- scoped_ptr<Event> netchanged_event(new Event(
+ std::unique_ptr<Event> netchanged_event(new Event(
events::NETWORKING_PRIVATE_ON_NETWORKS_CHANGED,
api::networking_private::OnNetworksChanged::kEventName, std::move(args)));
event_router->BroadcastEvent(std::move(netchanged_event));
@@ -148,9 +148,9 @@ void NetworkingPrivateEventRouterImpl::OnNetworkListChangedEvent(
EventRouter* event_router = EventRouter::Get(browser_context_);
if (!event_router)
return;
- scoped_ptr<base::ListValue> args(
+ std::unique_ptr<base::ListValue> args(
api::networking_private::OnNetworkListChanged::Create(network_guids));
- scoped_ptr<Event> netlistchanged_event(
+ std::unique_ptr<Event> netlistchanged_event(
new Event(events::NETWORKING_PRIVATE_ON_NETWORK_LIST_CHANGED,
api::networking_private::OnNetworkListChanged::kEventName,
std::move(args)));
diff --git a/chromium/extensions/browser/api/networking_private/networking_private_linux.cc b/chromium/extensions/browser/api/networking_private/networking_private_linux.cc
index dd489034c13..fe119c520f0 100644
--- a/chromium/extensions/browser/api/networking_private/networking_private_linux.cc
+++ b/chromium/extensions/browser/api/networking_private/networking_private_linux.cc
@@ -15,7 +15,6 @@
#include "base/strings/utf_string_conversions.h"
#include "base/threading/sequenced_worker_pool.h"
#include "components/onc/onc_constants.h"
-#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "dbus/bus.h"
#include "dbus/message.h"
@@ -79,9 +78,9 @@ bool GuidToSsid(const std::string& guid, std::string* ssid) {
// Iterates over the map cloning the contained networks to a
// list then returns the list.
-scoped_ptr<base::ListValue> CopyNetworkMapToList(
+std::unique_ptr<base::ListValue> CopyNetworkMapToList(
const NetworkingPrivateLinux::NetworkMap& network_map) {
- scoped_ptr<base::ListValue> network_list(new base::ListValue);
+ std::unique_ptr<base::ListValue> network_list(new base::ListValue);
for (const auto& network : network_map) {
network_list->Append(network.second->DeepCopy());
@@ -109,7 +108,7 @@ void ReportNotSupported(
// Fires the appropriate callback when the network connect operation succeeds
// or fails.
void OnNetworkConnectOperationCompleted(
- scoped_ptr<std::string> error,
+ std::unique_ptr<std::string> error,
const NetworkingPrivateDelegate::VoidCallback& success_callback,
const NetworkingPrivateDelegate::FailureCallback& failure_callback) {
if (!error->empty()) {
@@ -122,8 +121,8 @@ void OnNetworkConnectOperationCompleted(
// Fires the appropriate callback when the network properties are returned
// from the |dbus_thread_|.
void GetCachedNetworkPropertiesCallback(
- scoped_ptr<std::string> error,
- scoped_ptr<base::DictionaryValue> properties,
+ std::unique_ptr<std::string> error,
+ std::unique_ptr<base::DictionaryValue> properties,
const NetworkingPrivateDelegate::DictionaryCallback& success_callback,
const NetworkingPrivateDelegate::FailureCallback& failure_callback) {
if (!error->empty()) {
@@ -136,10 +135,8 @@ void GetCachedNetworkPropertiesCallback(
} // namespace
NetworkingPrivateLinux::NetworkingPrivateLinux(
- content::BrowserContext* browser_context,
- scoped_ptr<VerifyDelegate> verify_delegate)
+ std::unique_ptr<VerifyDelegate> verify_delegate)
: NetworkingPrivateDelegate(std::move(verify_delegate)),
- browser_context_(browser_context),
dbus_thread_("Networking Private DBus"),
network_manager_proxy_(NULL) {
base::Thread::Options thread_options(base::MessageLoop::Type::TYPE_IO, 0);
@@ -211,8 +208,8 @@ void NetworkingPrivateLinux::GetState(
if (!CheckNetworkManagerSupported(failure_callback))
return;
- scoped_ptr<std::string> error(new std::string);
- scoped_ptr<base::DictionaryValue> network_properties(
+ std::unique_ptr<std::string> error(new std::string);
+ std::unique_ptr<base::DictionaryValue> network_properties(
new base::DictionaryValue);
// Runs GetCachedNetworkProperties on |dbus_thread|.
@@ -246,7 +243,7 @@ void NetworkingPrivateLinux::GetCachedNetworkProperties(
}
// Make a copy of the properties out of the cached map.
- scoped_ptr<base::DictionaryValue> temp_properties(
+ std::unique_ptr<base::DictionaryValue> temp_properties(
network_iter->second->DeepCopy());
// Swap the new copy into the dictionary that is shared with the reply.
@@ -255,7 +252,7 @@ void NetworkingPrivateLinux::GetCachedNetworkProperties(
void NetworkingPrivateLinux::SetProperties(
const std::string& guid,
- scoped_ptr<base::DictionaryValue> properties,
+ std::unique_ptr<base::DictionaryValue> properties,
const VoidCallback& success_callback,
const FailureCallback& failure_callback) {
ReportNotSupported("SetProperties", failure_callback);
@@ -263,7 +260,7 @@ void NetworkingPrivateLinux::SetProperties(
void NetworkingPrivateLinux::CreateNetwork(
bool shared,
- scoped_ptr<base::DictionaryValue> properties,
+ std::unique_ptr<base::DictionaryValue> properties,
const StringCallback& success_callback,
const FailureCallback& failure_callback) {
ReportNotSupported("CreateNetwork", failure_callback);
@@ -288,7 +285,7 @@ void NetworkingPrivateLinux::GetNetworks(
return;
}
- scoped_ptr<NetworkMap> network_map(new NetworkMap);
+ std::unique_ptr<NetworkMap> network_map(new NetworkMap);
if (!(network_type == ::onc::network_type::kWiFi ||
network_type == ::onc::network_type::kWireless ||
@@ -316,7 +313,7 @@ bool NetworkingPrivateLinux::GetNetworksForScanRequest() {
return false;
}
- scoped_ptr<NetworkMap> network_map(new NetworkMap);
+ std::unique_ptr<NetworkMap> network_map(new NetworkMap);
// Runs GetAllWiFiAccessPoints on the dbus_thread and returns the
// results back to SendNetworkListChangedEvent to fire the event. No
@@ -402,7 +399,7 @@ void NetworkingPrivateLinux::ConnectToNetwork(const std::string& guid,
builder.AppendObjectPath(device_path);
builder.AppendObjectPath(access_point_path);
- scoped_ptr<dbus::Response> response(
+ std::unique_ptr<dbus::Response> response(
network_manager_proxy_->CallMethodAndBlock(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT));
if (!response) {
@@ -461,7 +458,7 @@ void NetworkingPrivateLinux::DisconnectFromNetwork(const std::string& guid,
return;
}
- scoped_ptr<NetworkMap> network_map(new NetworkMap);
+ std::unique_ptr<NetworkMap> network_map(new NetworkMap);
GetAllWiFiAccessPoints(false /* configured_only */, false /* visible_only */,
0 /* limit */, network_map.get());
@@ -487,7 +484,7 @@ void NetworkingPrivateLinux::DisconnectFromNetwork(const std::string& guid,
dbus::MethodCall method_call(
networking_private::kNetworkManagerDeviceNamespace,
networking_private::kNetworkManagerDisconnectMethod);
- scoped_ptr<dbus::Response> response(device_proxy->CallMethodAndBlock(
+ std::unique_ptr<dbus::Response> response(device_proxy->CallMethodAndBlock(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT));
if (!response) {
@@ -504,7 +501,7 @@ void NetworkingPrivateLinux::StartConnect(
if (!CheckNetworkManagerSupported(failure_callback))
return;
- scoped_ptr<std::string> error(new std::string);
+ std::unique_ptr<std::string> error(new std::string);
// Runs ConnectToNetwork on |dbus_thread|.
dbus_thread_.task_runner()->PostTaskAndReply(
@@ -522,7 +519,7 @@ void NetworkingPrivateLinux::StartDisconnect(
if (!CheckNetworkManagerSupported(failure_callback))
return;
- scoped_ptr<std::string> error(new std::string);
+ std::unique_ptr<std::string> error(new std::string);
// Runs DisconnectFromNetwork on |dbus_thread|.
dbus_thread_.task_runner()->PostTaskAndReply(
@@ -574,16 +571,17 @@ void NetworkingPrivateLinux::SetCellularSimState(
ReportNotSupported("SetCellularSimState", failure_callback);
}
-scoped_ptr<base::ListValue> NetworkingPrivateLinux::GetEnabledNetworkTypes() {
- scoped_ptr<base::ListValue> network_list(new base::ListValue);
+std::unique_ptr<base::ListValue>
+NetworkingPrivateLinux::GetEnabledNetworkTypes() {
+ std::unique_ptr<base::ListValue> network_list(new base::ListValue);
network_list->AppendString(::onc::network_type::kWiFi);
return network_list;
}
-scoped_ptr<NetworkingPrivateDelegate::DeviceStateList>
+std::unique_ptr<NetworkingPrivateDelegate::DeviceStateList>
NetworkingPrivateLinux::GetDeviceStateList() {
- scoped_ptr<DeviceStateList> device_state_list(new DeviceStateList);
- scoped_ptr<api::networking_private::DeviceStateProperties> properties(
+ std::unique_ptr<DeviceStateList> device_state_list(new DeviceStateList);
+ std::unique_ptr<api::networking_private::DeviceStateProperties> properties(
new api::networking_private::DeviceStateProperties);
properties->type = api::networking_private::NETWORK_TYPE_WIFI;
properties->state = api::networking_private::DEVICE_STATE_TYPE_ENABLED;
@@ -614,10 +612,11 @@ void NetworkingPrivateLinux::RemoveObserver(
}
void NetworkingPrivateLinux::OnAccessPointsFound(
- scoped_ptr<NetworkMap> network_map,
+ std::unique_ptr<NetworkMap> network_map,
const NetworkListCallback& success_callback,
const FailureCallback& failure_callback) {
- scoped_ptr<base::ListValue> network_list = CopyNetworkMapToList(*network_map);
+ std::unique_ptr<base::ListValue> network_list =
+ CopyNetworkMapToList(*network_map);
// Give ownership to the member variable.
network_map_.swap(network_map);
SendNetworkListChangedEvent(*network_list);
@@ -625,8 +624,9 @@ void NetworkingPrivateLinux::OnAccessPointsFound(
}
void NetworkingPrivateLinux::OnAccessPointsFoundViaScan(
- scoped_ptr<NetworkMap> network_map) {
- scoped_ptr<base::ListValue> network_list = CopyNetworkMapToList(*network_map);
+ std::unique_ptr<NetworkMap> network_map) {
+ std::unique_ptr<base::ListValue> network_list =
+ CopyNetworkMapToList(*network_map);
// Give ownership to the member variable.
network_map_.swap(network_map);
SendNetworkListChangedEvent(*network_list);
@@ -656,7 +656,7 @@ bool NetworkingPrivateLinux::GetNetworkDevices(
networking_private::kNetworkManagerNamespace,
networking_private::kNetworkManagerGetDevicesMethod);
- scoped_ptr<dbus::Response> device_response(
+ std::unique_ptr<dbus::Response> device_response(
network_manager_proxy_->CallMethodAndBlock(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT));
@@ -684,7 +684,7 @@ NetworkingPrivateLinux::DeviceType NetworkingPrivateLinux::GetDeviceType(
builder.AppendString(networking_private::kNetworkManagerDeviceNamespace);
builder.AppendString(networking_private::kNetworkManagerDeviceType);
- scoped_ptr<dbus::Response> response(device_proxy->CallMethodAndBlock(
+ std::unique_ptr<dbus::Response> response(device_proxy->CallMethodAndBlock(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT));
if (!response) {
@@ -733,7 +733,7 @@ void NetworkingPrivateLinux::GetAllWiFiAccessPoints(bool configured_only,
}
}
-scoped_ptr<dbus::Response> NetworkingPrivateLinux::GetAccessPointProperty(
+std::unique_ptr<dbus::Response> NetworkingPrivateLinux::GetAccessPointProperty(
dbus::ObjectProxy* access_point_proxy,
const std::string& property_name) {
AssertOnDBusThread();
@@ -742,8 +742,9 @@ scoped_ptr<dbus::Response> NetworkingPrivateLinux::GetAccessPointProperty(
dbus::MessageWriter builder(&method_call);
builder.AppendString(networking_private::kNetworkManagerAccessPointNamespace);
builder.AppendString(property_name);
- scoped_ptr<dbus::Response> response = access_point_proxy->CallMethodAndBlock(
- &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT);
+ std::unique_ptr<dbus::Response> response =
+ access_point_proxy->CallMethodAndBlock(
+ &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT);
if (!response) {
LOG(ERROR) << "Failed to get property for " << property_name;
}
@@ -752,14 +753,14 @@ scoped_ptr<dbus::Response> NetworkingPrivateLinux::GetAccessPointProperty(
bool NetworkingPrivateLinux::GetAccessPointInfo(
const dbus::ObjectPath& access_point_path,
- const scoped_ptr<base::DictionaryValue>& access_point_info) {
+ const std::unique_ptr<base::DictionaryValue>& access_point_info) {
AssertOnDBusThread();
dbus::ObjectProxy* access_point_proxy = dbus_->GetObjectProxy(
networking_private::kNetworkManagerNamespace, access_point_path);
// Read the SSID. The GUID is derived from the Ssid.
{
- scoped_ptr<dbus::Response> response(GetAccessPointProperty(
+ std::unique_ptr<dbus::Response> response(GetAccessPointProperty(
access_point_proxy, networking_private::kNetworkManagerSsidProperty));
if (!response) {
@@ -791,7 +792,7 @@ bool NetworkingPrivateLinux::GetAccessPointInfo(
// Read signal strength.
{
- scoped_ptr<dbus::Response> response(GetAccessPointProperty(
+ std::unique_ptr<dbus::Response> response(GetAccessPointProperty(
access_point_proxy,
networking_private::kNetworkManagerStrengthProperty));
if (!response) {
@@ -816,7 +817,7 @@ bool NetworkingPrivateLinux::GetAccessPointInfo(
uint32_t wpa_security_flags = 0;
{
- scoped_ptr<dbus::Response> response(GetAccessPointProperty(
+ std::unique_ptr<dbus::Response> response(GetAccessPointProperty(
access_point_proxy,
networking_private::kNetworkManagerWpaFlagsProperty));
if (!response) {
@@ -834,7 +835,7 @@ bool NetworkingPrivateLinux::GetAccessPointInfo(
uint32_t rsn_security_flags = 0;
{
- scoped_ptr<dbus::Response> response(GetAccessPointProperty(
+ std::unique_ptr<dbus::Response> response(GetAccessPointProperty(
access_point_proxy,
networking_private::kNetworkManagerRsnFlagsProperty));
if (!response) {
@@ -872,7 +873,7 @@ bool NetworkingPrivateLinux::AddAccessPointsFromDevice(
dbus::MethodCall method_call(
networking_private::kNetworkManagerWirelessDeviceNamespace,
networking_private::kNetworkManagerGetAccessPointsMethod);
- scoped_ptr<dbus::Response> response(device_proxy->CallMethodAndBlock(
+ std::unique_ptr<dbus::Response> response(device_proxy->CallMethodAndBlock(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT));
if (!response) {
@@ -890,7 +891,8 @@ bool NetworkingPrivateLinux::AddAccessPointsFromDevice(
}
for (const auto& access_point_path : access_point_paths) {
- scoped_ptr<base::DictionaryValue> access_point(new base::DictionaryValue);
+ std::unique_ptr<base::DictionaryValue> access_point(
+ new base::DictionaryValue);
if (GetAccessPointInfo(access_point_path, access_point)) {
std::string connection_state =
@@ -920,7 +922,7 @@ bool NetworkingPrivateLinux::AddAccessPointsFromDevice(
void NetworkingPrivateLinux::AddOrUpdateAccessPoint(
NetworkMap* network_map,
const std::string& network_guid,
- scoped_ptr<base::DictionaryValue>& access_point) {
+ std::unique_ptr<base::DictionaryValue>& access_point) {
base::string16 ssid;
std::string connection_state;
int signal_strength;
@@ -992,7 +994,7 @@ bool NetworkingPrivateLinux::GetConnectedAccessPoint(
builder.AppendString(networking_private::kNetworkManagerNamespace);
builder.AppendString(networking_private::kNetworkManagerActiveConnections);
- scoped_ptr<dbus::Response> response(
+ std::unique_ptr<dbus::Response> response(
network_manager_proxy_->CallMethodAndBlock(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT));
@@ -1050,7 +1052,7 @@ bool NetworkingPrivateLinux::GetDeviceOfConnection(
networking_private::kNetworkManagerActiveConnectionNamespace);
builder.AppendString("Devices");
- scoped_ptr<dbus::Response> response(connection_proxy->CallMethodAndBlock(
+ std::unique_ptr<dbus::Response> response(connection_proxy->CallMethodAndBlock(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT));
if (!response) {
@@ -1098,7 +1100,7 @@ bool NetworkingPrivateLinux::GetAccessPointForConnection(
networking_private::kNetworkManagerActiveConnectionNamespace);
builder.AppendString(networking_private::kNetworkManagerSpecificObject);
- scoped_ptr<dbus::Response> response(connection_proxy->CallMethodAndBlock(
+ std::unique_ptr<dbus::Response> response(connection_proxy->CallMethodAndBlock(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT));
if (!response) {
@@ -1159,7 +1161,7 @@ bool NetworkingPrivateLinux::SetConnectionStateAndPostEvent(
network_iter->second->SetString(kAccessPointInfoConnectionState,
connection_state);
- scoped_ptr<GuidList> changed_networks(new GuidList());
+ std::unique_ptr<GuidList> changed_networks(new GuidList());
changed_networks->push_back(guid);
// Only add a second network if it exists and it is not the same as the
@@ -1189,7 +1191,7 @@ void NetworkingPrivateLinux::OnNetworkListChangedEventOnUIThread(
}
void NetworkingPrivateLinux::PostOnNetworksChangedToUIThread(
- scoped_ptr<GuidList> guid_list) {
+ std::unique_ptr<GuidList> guid_list) {
AssertOnDBusThread();
content::BrowserThread::PostTask(
@@ -1199,7 +1201,7 @@ void NetworkingPrivateLinux::PostOnNetworksChangedToUIThread(
}
void NetworkingPrivateLinux::OnNetworksChangedEventTask(
- scoped_ptr<GuidList> guid_list) {
+ std::unique_ptr<GuidList> guid_list) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
OnNetworksChangedEventOnUIThread(*guid_list);
}
diff --git a/chromium/extensions/browser/api/networking_private/networking_private_linux.h b/chromium/extensions/browser/api/networking_private/networking_private_linux.h
index e33c7b889cd..39e93bd255b 100644
--- a/chromium/extensions/browser/api/networking_private/networking_private_linux.h
+++ b/chromium/extensions/browser/api/networking_private/networking_private_linux.h
@@ -17,10 +17,6 @@
#include "components/keyed_service/core/keyed_service.h"
#include "extensions/browser/api/networking_private/networking_private_delegate.h"
-namespace content {
-class BrowserContext;
-}
-
namespace dbus {
class Bus;
class ObjectPath;
@@ -38,8 +34,8 @@ class NetworkingPrivateLinux : public NetworkingPrivateDelegate {
typedef std::vector<std::string> GuidList;
- NetworkingPrivateLinux(content::BrowserContext* browser_context,
- scoped_ptr<VerifyDelegate> verify_delegate);
+ explicit NetworkingPrivateLinux(
+ std::unique_ptr<VerifyDelegate> verify_delegate);
// NetworkingPrivateDelegate
void GetProperties(const std::string& guid,
@@ -52,11 +48,11 @@ class NetworkingPrivateLinux : public NetworkingPrivateDelegate {
const DictionaryCallback& success_callback,
const FailureCallback& failure_callback) override;
void SetProperties(const std::string& guid,
- scoped_ptr<base::DictionaryValue> properties,
+ std::unique_ptr<base::DictionaryValue> properties,
const VoidCallback& success_callback,
const FailureCallback& failure_callback) override;
void CreateNetwork(bool shared,
- scoped_ptr<base::DictionaryValue> properties,
+ std::unique_ptr<base::DictionaryValue> properties,
const StringCallback& success_callback,
const FailureCallback& failure_callback) override;
void ForgetNetwork(const std::string& guid,
@@ -97,8 +93,8 @@ class NetworkingPrivateLinux : public NetworkingPrivateDelegate {
const VoidCallback& success_callback,
const FailureCallback& failure_callback) override;
- scoped_ptr<base::ListValue> GetEnabledNetworkTypes() override;
- scoped_ptr<DeviceStateList> GetDeviceStateList() override;
+ std::unique_ptr<base::ListValue> GetEnabledNetworkTypes() override;
+ std::unique_ptr<DeviceStateList> GetDeviceStateList() override;
bool EnableNetworkType(const std::string& type) override;
bool DisableNetworkType(const std::string& type) override;
bool RequestScan() override;
@@ -181,13 +177,13 @@ class NetworkingPrivateLinux : public NetworkingPrivateDelegate {
// Reply callback accepts the map of networks and fires the
// OnNetworkListChanged event and user callbacks.
- void OnAccessPointsFound(scoped_ptr<NetworkMap> network_map,
+ void OnAccessPointsFound(std::unique_ptr<NetworkMap> network_map,
const NetworkListCallback& success_callback,
const FailureCallback& failure_callback);
// Reply callback accepts the map of networks and fires the
// OnNetworkListChanged event.
- void OnAccessPointsFoundViaScan(scoped_ptr<NetworkMap> network_map);
+ void OnAccessPointsFoundViaScan(std::unique_ptr<NetworkMap> network_map);
// Helper function for OnAccessPointsFound and OnAccessPointsFoundViaScan to
// fire the OnNetworkListChangedEvent.
@@ -198,21 +194,22 @@ class NetworkingPrivateLinux : public NetworkingPrivateDelegate {
// supplied |access_point_path|.
bool GetAccessPointInfo(
const dbus::ObjectPath& access_point_path,
- const scoped_ptr<base::DictionaryValue>& access_point_info);
+ const std::unique_ptr<base::DictionaryValue>& access_point_info);
// Helper function to extract a property from a device.
// Returns the dbus::Response object from calling Get on the supplied
// |property_name|.
- scoped_ptr<dbus::Response> GetAccessPointProperty(
+ std::unique_ptr<dbus::Response> GetAccessPointProperty(
dbus::ObjectProxy* access_point_proxy,
const std::string& property_name);
// If the access_point is not already in the map it is added. Otherwise
// the access point is updated (eg. with the max of the signal
// strength).
- void AddOrUpdateAccessPoint(NetworkMap* network_map,
- const std::string& network_guid,
- scoped_ptr<base::DictionaryValue>& access_point);
+ void AddOrUpdateAccessPoint(
+ NetworkMap* network_map,
+ const std::string& network_guid,
+ std::unique_ptr<base::DictionaryValue>& access_point);
// Maps the WPA security flags to a human readable string.
void MapSecurityFlagsToString(uint32_t securityFlags, std::string* security);
@@ -245,11 +242,11 @@ class NetworkingPrivateLinux : public NetworkingPrivateDelegate {
// Helper method to post an OnNetworkChanged event to the UI thread from the
// dbus thread. Used for connection status progress during |StartConnect|.
- void PostOnNetworksChangedToUIThread(scoped_ptr<GuidList> guid_list);
+ void PostOnNetworksChangedToUIThread(std::unique_ptr<GuidList> guid_list);
// Helper method to be called from the UI thread and manage ownership of the
// passed vector from the |dbus_thread_|.
- void OnNetworksChangedEventTask(scoped_ptr<GuidList> guid_list);
+ void OnNetworksChangedEventTask(std::unique_ptr<GuidList> guid_list);
void GetCachedNetworkProperties(const std::string& guid,
base::DictionaryValue* properties,
@@ -259,8 +256,6 @@ class NetworkingPrivateLinux : public NetworkingPrivateDelegate {
void OnNetworkListChangedEventOnUIThread(const GuidList& network_guids);
- // Browser context.
- content::BrowserContext* browser_context_;
// Thread used for DBus actions.
base::Thread dbus_thread_;
// DBus instance. Only access on |dbus_thread_|.
@@ -270,7 +265,7 @@ class NetworkingPrivateLinux : public NetworkingPrivateDelegate {
// This is owned by |dbus_| object. Only access on |dbus_thread_|.
dbus::ObjectProxy* network_manager_proxy_;
// Holds the current mapping of known networks. Only access on |dbus_thread_|.
- scoped_ptr<NetworkMap> network_map_;
+ std::unique_ptr<NetworkMap> network_map_;
// Observers to Network Events.
base::ObserverList<NetworkingPrivateDelegateObserver>
network_events_observers_;
diff --git a/chromium/extensions/browser/api/networking_private/networking_private_service_client.cc b/chromium/extensions/browser/api/networking_private/networking_private_service_client.cc
index d9c5cf0f64d..5a40cc13b7d 100644
--- a/chromium/extensions/browser/api/networking_private/networking_private_service_client.cc
+++ b/chromium/extensions/browser/api/networking_private/networking_private_service_client.cc
@@ -7,7 +7,7 @@
#include "base/base64.h"
#include "base/bind.h"
#include "base/sequenced_task_runner.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "base/threading/worker_pool.h"
#include "components/onc/onc_constants.h"
#include "content/public/browser/browser_thread.h"
@@ -24,7 +24,8 @@ namespace {
const char kNetworkingPrivateSequenceTokenName[] = "NetworkingPrivate";
// Deletes WiFiService object on the worker thread.
-void ShutdownWifiServiceOnWorkerThread(scoped_ptr<WiFiService> wifi_service) {
+void ShutdownWifiServiceOnWorkerThread(
+ std::unique_ptr<WiFiService> wifi_service) {
DCHECK(wifi_service.get());
}
@@ -37,8 +38,8 @@ NetworkingPrivateServiceClient::ServiceCallbacks::~ServiceCallbacks() {
}
NetworkingPrivateServiceClient::NetworkingPrivateServiceClient(
- scoped_ptr<WiFiService> wifi_service,
- scoped_ptr<VerifyDelegate> verify_delegate)
+ std::unique_ptr<WiFiService> wifi_service,
+ std::unique_ptr<VerifyDelegate> verify_delegate)
: NetworkingPrivateDelegate(std::move(verify_delegate)),
wifi_service_(std::move(wifi_service)),
weak_factory_(this) {
@@ -124,7 +125,7 @@ void NetworkingPrivateServiceClient::GetProperties(
service_callbacks->failure_callback = failure_callback;
service_callbacks->get_properties_callback = success_callback;
- scoped_ptr<base::DictionaryValue> properties(new base::DictionaryValue);
+ std::unique_ptr<base::DictionaryValue> properties(new base::DictionaryValue);
std::string* error = new std::string;
base::DictionaryValue* properties_ptr = properties.get();
@@ -145,7 +146,7 @@ void NetworkingPrivateServiceClient::GetManagedProperties(
service_callbacks->failure_callback = failure_callback;
service_callbacks->get_properties_callback = success_callback;
- scoped_ptr<base::DictionaryValue> properties(new base::DictionaryValue);
+ std::unique_ptr<base::DictionaryValue> properties(new base::DictionaryValue);
std::string* error = new std::string;
base::DictionaryValue* properties_ptr = properties.get();
@@ -166,7 +167,7 @@ void NetworkingPrivateServiceClient::GetState(
service_callbacks->failure_callback = failure_callback;
service_callbacks->get_properties_callback = success_callback;
- scoped_ptr<base::DictionaryValue> properties(new base::DictionaryValue);
+ std::unique_ptr<base::DictionaryValue> properties(new base::DictionaryValue);
std::string* error = new std::string;
base::DictionaryValue* properties_ptr = properties.get();
@@ -181,7 +182,7 @@ void NetworkingPrivateServiceClient::GetState(
void NetworkingPrivateServiceClient::SetProperties(
const std::string& guid,
- scoped_ptr<base::DictionaryValue> properties,
+ std::unique_ptr<base::DictionaryValue> properties,
const VoidCallback& success_callback,
const FailureCallback& failure_callback) {
ServiceCallbacks* service_callbacks = AddServiceCallbacks();
@@ -201,7 +202,7 @@ void NetworkingPrivateServiceClient::SetProperties(
void NetworkingPrivateServiceClient::CreateNetwork(
bool shared,
- scoped_ptr<base::DictionaryValue> properties,
+ std::unique_ptr<base::DictionaryValue> properties,
const StringCallback& success_callback,
const FailureCallback& failure_callback) {
ServiceCallbacks* service_callbacks = AddServiceCallbacks();
@@ -239,7 +240,7 @@ void NetworkingPrivateServiceClient::GetNetworks(
service_callbacks->failure_callback = failure_callback;
service_callbacks->get_visible_networks_callback = success_callback;
- scoped_ptr<base::ListValue> networks(new base::ListValue);
+ std::unique_ptr<base::ListValue> networks(new base::ListValue);
// TODO(stevenjb/mef): Apply filters (configured, visible, limit).
@@ -330,17 +331,17 @@ void NetworkingPrivateServiceClient::SetCellularSimState(
failure_callback.Run(networking_private::kErrorNotSupported);
}
-scoped_ptr<base::ListValue>
+std::unique_ptr<base::ListValue>
NetworkingPrivateServiceClient::GetEnabledNetworkTypes() {
- scoped_ptr<base::ListValue> network_list;
+ std::unique_ptr<base::ListValue> network_list;
network_list->AppendString(::onc::network_type::kWiFi);
return network_list;
}
-scoped_ptr<NetworkingPrivateDelegate::DeviceStateList>
+std::unique_ptr<NetworkingPrivateDelegate::DeviceStateList>
NetworkingPrivateServiceClient::GetDeviceStateList() {
- scoped_ptr<DeviceStateList> device_state_list(new DeviceStateList);
- scoped_ptr<api::networking_private::DeviceStateProperties> properties(
+ std::unique_ptr<DeviceStateList> device_state_list(new DeviceStateList);
+ std::unique_ptr<api::networking_private::DeviceStateProperties> properties(
new api::networking_private::DeviceStateProperties);
properties->type = api::networking_private::NETWORK_TYPE_WIFI;
properties->state = api::networking_private::DEVICE_STATE_TYPE_ENABLED;
@@ -370,7 +371,7 @@ bool NetworkingPrivateServiceClient::RequestScan() {
void NetworkingPrivateServiceClient::AfterGetProperties(
ServiceCallbacksID callback_id,
const std::string& network_guid,
- scoped_ptr<base::DictionaryValue> properties,
+ std::unique_ptr<base::DictionaryValue> properties,
const std::string* error) {
ServiceCallbacks* service_callbacks = callbacks_map_.Lookup(callback_id);
DCHECK(service_callbacks);
@@ -386,7 +387,7 @@ void NetworkingPrivateServiceClient::AfterGetProperties(
void NetworkingPrivateServiceClient::AfterGetVisibleNetworks(
ServiceCallbacksID callback_id,
- scoped_ptr<base::ListValue> networks) {
+ std::unique_ptr<base::ListValue> networks) {
ServiceCallbacks* service_callbacks = callbacks_map_.Lookup(callback_id);
DCHECK(service_callbacks);
DCHECK(!service_callbacks->get_visible_networks_callback.is_null());
diff --git a/chromium/extensions/browser/api/networking_private/networking_private_service_client.h b/chromium/extensions/browser/api/networking_private/networking_private_service_client.h
index 63805db98a2..6e59b68ea04 100644
--- a/chromium/extensions/browser/api/networking_private/networking_private_service_client.h
+++ b/chromium/extensions/browser/api/networking_private/networking_private_service_client.h
@@ -7,12 +7,12 @@
#include <stdint.h>
+#include <memory>
#include <string>
#include <vector>
#include "base/id_map.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/strings/string16.h"
@@ -43,8 +43,9 @@ class NetworkingPrivateServiceClient
// Takes ownership of |wifi_service| which is accessed and deleted on the
// worker thread. The deletion task is posted from the destructor.
// |verify_delegate| is passed to NetworkingPrivateDelegate and may be NULL.
- NetworkingPrivateServiceClient(scoped_ptr<wifi::WiFiService> wifi_service,
- scoped_ptr<VerifyDelegate> verify_delegate);
+ NetworkingPrivateServiceClient(
+ std::unique_ptr<wifi::WiFiService> wifi_service,
+ std::unique_ptr<VerifyDelegate> verify_delegate);
// KeyedService
void Shutdown() override;
@@ -60,11 +61,11 @@ class NetworkingPrivateServiceClient
const DictionaryCallback& success_callback,
const FailureCallback& failure_callback) override;
void SetProperties(const std::string& guid,
- scoped_ptr<base::DictionaryValue> properties_dict,
+ std::unique_ptr<base::DictionaryValue> properties_dict,
const VoidCallback& success_callback,
const FailureCallback& failure_callback) override;
void CreateNetwork(bool shared,
- scoped_ptr<base::DictionaryValue> properties_dict,
+ std::unique_ptr<base::DictionaryValue> properties_dict,
const StringCallback& success_callback,
const FailureCallback& failure_callback) override;
void ForgetNetwork(const std::string& guid,
@@ -104,8 +105,8 @@ class NetworkingPrivateServiceClient
const std::string& new_pin,
const VoidCallback& success_callback,
const FailureCallback& failure_callback) override;
- scoped_ptr<base::ListValue> GetEnabledNetworkTypes() override;
- scoped_ptr<DeviceStateList> GetDeviceStateList() override;
+ std::unique_ptr<base::ListValue> GetEnabledNetworkTypes() override;
+ std::unique_ptr<DeviceStateList> GetDeviceStateList() override;
bool EnableNetworkType(const std::string& type) override;
bool DisableNetworkType(const std::string& type) override;
bool RequestScan() override;
@@ -142,7 +143,7 @@ class NetworkingPrivateServiceClient
// Callback wrappers.
void AfterGetProperties(ServiceCallbacksID callback_id,
const std::string& network_guid,
- scoped_ptr<base::DictionaryValue> properties,
+ std::unique_ptr<base::DictionaryValue> properties,
const std::string* error);
void AfterSetProperties(ServiceCallbacksID callback_id,
const std::string* error);
@@ -150,7 +151,7 @@ class NetworkingPrivateServiceClient
const std::string* network_guid,
const std::string* error);
void AfterGetVisibleNetworks(ServiceCallbacksID callback_id,
- scoped_ptr<base::ListValue> networks);
+ std::unique_ptr<base::ListValue> networks);
void AfterStartConnect(ServiceCallbacksID callback_id,
const std::string* error);
void AfterStartDisconnect(ServiceCallbacksID callback_id,
@@ -172,7 +173,7 @@ class NetworkingPrivateServiceClient
base::ObserverList<NetworkingPrivateDelegateObserver>
network_events_observers_;
// Interface to WiFiService. Used and deleted on the worker thread.
- scoped_ptr<wifi::WiFiService> wifi_service_;
+ std::unique_ptr<wifi::WiFiService> wifi_service_;
// Sequence token associated with wifi tasks.
base::SequencedWorkerPool::SequenceToken sequence_token_;
// Task runner for worker tasks.
diff --git a/chromium/extensions/browser/api/power/power_api.cc b/chromium/extensions/browser/api/power/power_api.cc
index 4c9ed0dcd98..e8b1c53c50a 100644
--- a/chromium/extensions/browser/api/power/power_api.cc
+++ b/chromium/extensions/browser/api/power/power_api.cc
@@ -35,7 +35,7 @@ base::LazyInstance<BrowserContextKeyedAPIFactory<PowerAPI>> g_factory =
} // namespace
bool PowerRequestKeepAwakeFunction::RunSync() {
- scoped_ptr<api::power::RequestKeepAwake::Params> params(
+ std::unique_ptr<api::power::RequestKeepAwake::Params> params(
api::power::RequestKeepAwake::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
EXTENSION_FUNCTION_VALIDATE(params->level != api::power::LEVEL_NONE);
@@ -112,7 +112,7 @@ void PowerAPI::UpdatePowerSaveBlocker() {
if (!power_save_blocker_ || new_level != current_level_) {
content::PowerSaveBlocker::PowerSaveBlockerType type =
LevelToPowerSaveBlockerType(new_level);
- scoped_ptr<content::PowerSaveBlocker> new_blocker(
+ std::unique_ptr<content::PowerSaveBlocker> new_blocker(
create_blocker_function_.Run(type,
content::PowerSaveBlocker::kReasonOther,
kPowerSaveBlockerDescription));
diff --git a/chromium/extensions/browser/api/power/power_api.h b/chromium/extensions/browser/api/power/power_api.h
index 313151d7757..e68bd57f6b2 100644
--- a/chromium/extensions/browser/api/power/power_api.h
+++ b/chromium/extensions/browser/api/power/power_api.h
@@ -6,11 +6,11 @@
#define EXTENSIONS_BROWSER_API_POWER_POWER_API_H_
#include <map>
+#include <memory>
#include <string>
#include "base/callback.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "content/public/browser/power_save_blocker.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
#include "extensions/browser/extension_function.h"
@@ -53,10 +53,11 @@ class PowerReleaseKeepAwakeFunction : public SyncExtensionFunction {
class PowerAPI : public BrowserContextKeyedAPI,
public extensions::ExtensionRegistryObserver {
public:
- typedef base::Callback<scoped_ptr<content::PowerSaveBlocker>(
+ typedef base::Callback<std::unique_ptr<content::PowerSaveBlocker>(
content::PowerSaveBlocker::PowerSaveBlockerType,
content::PowerSaveBlocker::Reason,
- const std::string&)> CreateBlockerFunction;
+ const std::string&)>
+ CreateBlockerFunction;
static PowerAPI* Get(content::BrowserContext* context);
@@ -103,7 +104,7 @@ class PowerAPI : public BrowserContextKeyedAPI,
// actually changing the system power-saving settings.
CreateBlockerFunction create_blocker_function_;
- scoped_ptr<content::PowerSaveBlocker> power_save_blocker_;
+ std::unique_ptr<content::PowerSaveBlocker> power_save_blocker_;
// Current level used by |power_save_blocker_|. Meaningless if
// |power_save_blocker_| is NULL.
diff --git a/chromium/extensions/browser/api/power/power_api_unittest.cc b/chromium/extensions/browser/api/power/power_api_unittest.cc
index 693abd10b04..54b8403d9e4 100644
--- a/chromium/extensions/browser/api/power/power_api_unittest.cc
+++ b/chromium/extensions/browser/api/power/power_api_unittest.cc
@@ -5,11 +5,11 @@
#include "extensions/browser/api/power/power_api.h"
#include <deque>
+#include <memory>
#include <string>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "content/public/browser/power_save_blocker.h"
#include "extensions/browser/api_test_utils.h"
@@ -88,7 +88,7 @@ class PowerSaveBlockerStubManager {
private:
// Creates a new PowerSaveBlockerStub of type |type|.
- scoped_ptr<content::PowerSaveBlocker> CreateStub(
+ std::unique_ptr<content::PowerSaveBlocker> CreateStub(
content::PowerSaveBlocker::PowerSaveBlockerType type,
content::PowerSaveBlocker::Reason reason,
const std::string& description) {
@@ -103,11 +103,9 @@ class PowerSaveBlockerStubManager {
unblock_request = UNBLOCK_DISPLAY_SLEEP;
break;
}
- return scoped_ptr<content::PowerSaveBlocker>(
- new PowerSaveBlockerStub(
- base::Bind(&PowerSaveBlockerStubManager::AppendRequest,
- weak_ptr_factory_.GetWeakPtr(),
- unblock_request)));
+ return std::unique_ptr<content::PowerSaveBlocker>(new PowerSaveBlockerStub(
+ base::Bind(&PowerSaveBlockerStubManager::AppendRequest,
+ weak_ptr_factory_.GetWeakPtr(), unblock_request)));
}
void AppendRequest(Request request) {
@@ -169,7 +167,7 @@ class PowerAPITest : public ApiUnitTest {
UnloadedExtensionInfo::REASON_UNINSTALL);
}
- scoped_ptr<PowerSaveBlockerStubManager> manager_;
+ std::unique_ptr<PowerSaveBlockerStubManager> manager_;
};
TEST_F(PowerAPITest, RequestAndRelease) {
diff --git a/chromium/extensions/browser/api/printer_provider/printer_provider_api.cc b/chromium/extensions/browser/api/printer_provider/printer_provider_api.cc
index ed776e5b4df..762bd7e0c12 100644
--- a/chromium/extensions/browser/api/printer_provider/printer_provider_api.cc
+++ b/chromium/extensions/browser/api/printer_provider/printer_provider_api.cc
@@ -523,12 +523,12 @@ void PrinterProviderAPIImpl::DispatchGetPrintersRequested(
// be needed later on.
int request_id = pending_get_printers_requests_.Add(callback);
- scoped_ptr<base::ListValue> internal_args(new base::ListValue);
+ std::unique_ptr<base::ListValue> internal_args(new base::ListValue);
// Request id is not part of the public API, but it will be massaged out in
// custom bindings.
internal_args->AppendInteger(request_id);
- scoped_ptr<Event> event(
+ std::unique_ptr<Event> event(
new Event(events::PRINTER_PROVIDER_ON_GET_PRINTERS_REQUESTED,
api::printer_provider::OnGetPrintersRequested::kEventName,
std::move(internal_args)));
@@ -561,13 +561,13 @@ void PrinterProviderAPIImpl::DispatchGetCapabilityRequested(
int request_id = pending_capability_requests_[extension_id].Add(callback);
- scoped_ptr<base::ListValue> internal_args(new base::ListValue);
+ std::unique_ptr<base::ListValue> internal_args(new base::ListValue);
// Request id is not part of the public API, but it will be massaged out in
// custom bindings.
internal_args->AppendInteger(request_id);
internal_args->AppendString(internal_printer_id);
- scoped_ptr<Event> event(
+ std::unique_ptr<Event> event(
new Event(events::PRINTER_PROVIDER_ON_GET_CAPABILITY_REQUESTED,
api::printer_provider::OnGetCapabilityRequested::kEventName,
std::move(internal_args)));
@@ -596,7 +596,8 @@ void PrinterProviderAPIImpl::DispatchPrintRequested(
print_job.printer_id = internal_printer_id;
JSONStringValueDeserializer deserializer(job.ticket_json);
- scoped_ptr<base::Value> ticket_value = deserializer.Deserialize(NULL, NULL);
+ std::unique_ptr<base::Value> ticket_value =
+ deserializer.Deserialize(NULL, NULL);
if (!ticket_value ||
!api::printer_provider::PrintJob::Ticket::Populate(*ticket_value,
&print_job.ticket)) {
@@ -609,12 +610,12 @@ void PrinterProviderAPIImpl::DispatchPrintRequested(
print_job.title = base::UTF16ToUTF8(job.job_title);
int request_id = pending_print_requests_[extension_id].Add(job, callback);
- scoped_ptr<base::ListValue> internal_args(new base::ListValue);
+ std::unique_ptr<base::ListValue> internal_args(new base::ListValue);
// Request id is not part of the public API and it will be massaged out in
// custom bindings.
internal_args->AppendInteger(request_id);
internal_args->Append(print_job.ToValue().release());
- scoped_ptr<Event> event(
+ std::unique_ptr<Event> event(
new Event(events::PRINTER_PROVIDER_ON_PRINT_REQUESTED,
api::printer_provider::OnPrintRequested::kEventName,
std::move(internal_args)));
@@ -647,12 +648,12 @@ void PrinterProviderAPIImpl::DispatchGetUsbPrinterInfoRequested(
api::usb::Device api_device;
UsbGuidMap::Get(browser_context_)->GetApiDevice(device, &api_device);
- scoped_ptr<base::ListValue> internal_args(new base::ListValue());
+ std::unique_ptr<base::ListValue> internal_args(new base::ListValue());
// Request id is not part of the public API and it will be massaged out in
// custom bindings.
internal_args->AppendInteger(request_id);
internal_args->Append(api_device.ToValue());
- scoped_ptr<Event> event(
+ std::unique_ptr<Event> event(
new Event(events::PRINTER_PROVIDER_ON_GET_USB_PRINTER_INFO_REQUESTED,
api::printer_provider::OnGetUsbPrinterInfoRequested::kEventName,
std::move(internal_args)));
@@ -668,7 +669,7 @@ void PrinterProviderAPIImpl::OnGetPrintersResult(
// Update some printer description properties to better identify the extension
// managing the printer.
for (const api::printer_provider::PrinterInfo& p : result) {
- scoped_ptr<base::DictionaryValue> printer(p.ToValue());
+ std::unique_ptr<base::DictionaryValue> printer(p.ToValue());
UpdatePrinterWithExtensionInfo(printer.get(), extension);
printer_list.Append(std::move(printer));
}
@@ -702,7 +703,7 @@ void PrinterProviderAPIImpl::OnGetUsbPrinterInfoResult(
int request_id,
const api::printer_provider::PrinterInfo* result) {
if (result) {
- scoped_ptr<base::DictionaryValue> printer(result->ToValue());
+ std::unique_ptr<base::DictionaryValue> printer(result->ToValue());
UpdatePrinterWithExtensionInfo(printer.get(), extension);
pending_usb_printer_info_requests_[extension->id()].Complete(request_id,
*printer);
diff --git a/chromium/extensions/browser/api/printer_provider/printer_provider_apitest.cc b/chromium/extensions/browser/api/printer_provider/printer_provider_apitest.cc
index b49663c8691..ca949ec43c5 100644
--- a/chromium/extensions/browser/api/printer_provider/printer_provider_apitest.cc
+++ b/chromium/extensions/browser/api/printer_provider/printer_provider_apitest.cc
@@ -297,7 +297,8 @@ class PrinterProviderApiTest : public ShellApiTest {
test_param, &extension_id);
ASSERT_FALSE(extension_id.empty());
- scoped_ptr<base::Value> expected_printer_info(new base::DictionaryValue());
+ std::unique_ptr<base::Value> expected_printer_info(
+ new base::DictionaryValue());
base::RunLoop run_loop;
StartGetUsbPrinterInfoRequest(
extension_id, device,
@@ -330,7 +331,7 @@ class PrinterProviderApiTest : public ShellApiTest {
// in |expoected_printers| are unique.
void ValidatePrinterListValue(
const base::ListValue& printers,
- const std::vector<scoped_ptr<base::Value>> expected_printers) {
+ const std::vector<std::unique_ptr<base::Value>> expected_printers) {
ASSERT_EQ(expected_printers.size(), printers.GetSize());
for (const auto& printer_value : expected_printers) {
EXPECT_TRUE(printers.Find(*printer_value.get()) != printers.end())
@@ -489,7 +490,7 @@ IN_PROC_BROWSER_TEST_F(PrinterProviderApiTest, GetPrintersSuccess) {
run_loop.Run();
- std::vector<scoped_ptr<base::Value>> expected_printers;
+ std::vector<std::unique_ptr<base::Value>> expected_printers;
expected_printers.push_back(
DictionaryBuilder()
.Set("description", "Test printer")
@@ -528,7 +529,7 @@ IN_PROC_BROWSER_TEST_F(PrinterProviderApiTest, GetPrintersAsyncSuccess) {
run_loop.Run();
- std::vector<scoped_ptr<base::Value>> expected_printers;
+ std::vector<std::unique_ptr<base::Value>> expected_printers;
expected_printers.push_back(
DictionaryBuilder()
.Set("description", "Test printer")
@@ -566,7 +567,7 @@ IN_PROC_BROWSER_TEST_F(PrinterProviderApiTest, GetPrintersTwoExtensions) {
run_loop.Run();
- std::vector<scoped_ptr<base::Value>> expected_printers;
+ std::vector<std::unique_ptr<base::Value>> expected_printers;
expected_printers.push_back(
DictionaryBuilder()
.Set("description", "Test printer")
@@ -661,7 +662,7 @@ IN_PROC_BROWSER_TEST_F(PrinterProviderApiTest,
run_loop.Run();
- std::vector<scoped_ptr<base::Value>> expected_printers;
+ std::vector<std::unique_ptr<base::Value>> expected_printers;
expected_printers.push_back(
DictionaryBuilder()
.Set("description", "Test printer")
@@ -708,7 +709,7 @@ IN_PROC_BROWSER_TEST_F(PrinterProviderApiTest,
run_loop.Run();
- std::vector<scoped_ptr<base::Value>> expected_printers;
+ std::vector<std::unique_ptr<base::Value>> expected_printers;
expected_printers.push_back(
DictionaryBuilder()
.Set("description", "Test printer")
@@ -826,7 +827,7 @@ IN_PROC_BROWSER_TEST_F(PrinterProviderApiTest, GetUsbPrinterInfo) {
ASSERT_FALSE(extension_id.empty());
UsbGuidMap* guid_map = UsbGuidMap::Get(browser_context());
- scoped_ptr<base::Value> expected_printer_info(
+ std::unique_ptr<base::Value> expected_printer_info(
DictionaryBuilder()
.Set("description", "This printer is a USB device.")
.Set("extensionId", extension_id)
diff --git a/chromium/extensions/browser/api/printer_provider_internal/printer_provider_internal_api.cc b/chromium/extensions/browser/api/printer_provider_internal/printer_provider_internal_api.cc
index e032703dfeb..e9f3e0b5ab7 100644
--- a/chromium/extensions/browser/api/printer_provider_internal/printer_provider_internal_api.cc
+++ b/chromium/extensions/browser/api/printer_provider_internal/printer_provider_internal_api.cc
@@ -4,6 +4,7 @@
#include "extensions/browser/api/printer_provider_internal/printer_provider_internal_api.h"
+#include <memory>
#include <string>
#include <utility>
#include <vector>
@@ -13,7 +14,6 @@
#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/memory/ref_counted_memory.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "content/public/browser/blob_handle.h"
#include "content/public/browser/browser_context.h"
@@ -106,7 +106,7 @@ PrinterProviderInternalReportPrintResultFunction::
ExtensionFunction::ResponseAction
PrinterProviderInternalReportPrintResultFunction::Run() {
- scoped_ptr<internal_api::ReportPrintResult::Params> params(
+ std::unique_ptr<internal_api::ReportPrintResult::Params> params(
internal_api::ReportPrintResult::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -126,7 +126,7 @@ PrinterProviderInternalReportPrinterCapabilityFunction::
ExtensionFunction::ResponseAction
PrinterProviderInternalReportPrinterCapabilityFunction::Run() {
- scoped_ptr<internal_api::ReportPrinterCapability::Params> params(
+ std::unique_ptr<internal_api::ReportPrinterCapability::Params> params(
internal_api::ReportPrinterCapability::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -154,7 +154,7 @@ PrinterProviderInternalReportPrintersFunction::
ExtensionFunction::ResponseAction
PrinterProviderInternalReportPrintersFunction::Run() {
- scoped_ptr<internal_api::ReportPrinters::Params> params(
+ std::unique_ptr<internal_api::ReportPrinters::Params> params(
internal_api::ReportPrinters::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -184,7 +184,7 @@ PrinterProviderInternalGetPrintDataFunction::
ExtensionFunction::ResponseAction
PrinterProviderInternalGetPrintDataFunction::Run() {
- scoped_ptr<internal_api::GetPrintData::Params> params(
+ std::unique_ptr<internal_api::GetPrintData::Params> params(
internal_api::GetPrintData::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -221,7 +221,7 @@ void PrinterProviderInternalGetPrintDataFunction::OnBlob(
const std::string& type,
int size,
const scoped_refptr<base::RefCountedMemory>& data,
- scoped_ptr<content::BlobHandle> blob) {
+ std::unique_ptr<content::BlobHandle> blob) {
if (!blob) {
SetError("Unable to create the blob.");
SendResponse(false);
@@ -256,7 +256,7 @@ PrinterProviderInternalReportUsbPrinterInfoFunction::
ExtensionFunction::ResponseAction
PrinterProviderInternalReportUsbPrinterInfoFunction::Run() {
- scoped_ptr<internal_api::ReportUsbPrinterInfo::Params> params(
+ std::unique_ptr<internal_api::ReportUsbPrinterInfo::Params> params(
internal_api::ReportUsbPrinterInfo::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
diff --git a/chromium/extensions/browser/api/printer_provider_internal/printer_provider_internal_api.h b/chromium/extensions/browser/api/printer_provider_internal/printer_provider_internal_api.h
index 472cf193f67..0f082a94a01 100644
--- a/chromium/extensions/browser/api/printer_provider_internal/printer_provider_internal_api.h
+++ b/chromium/extensions/browser/api/printer_provider_internal/printer_provider_internal_api.h
@@ -154,7 +154,7 @@ class PrinterProviderInternalGetPrintDataFunction
void OnBlob(const std::string& type,
int size,
const scoped_refptr<base::RefCountedMemory>& data,
- scoped_ptr<content::BlobHandle> blob);
+ std::unique_ptr<content::BlobHandle> blob);
DECLARE_EXTENSION_FUNCTION("printerProviderInternal.getPrintData",
PRINTERPROVIDERINTERNAL_GETPRINTDATA)
diff --git a/chromium/extensions/browser/api/runtime/runtime_api.cc b/chromium/extensions/browser/api/runtime/runtime_api.cc
index a42e4662ba7..e62805e6742 100644
--- a/chromium/extensions/browser/api/runtime/runtime_api.cc
+++ b/chromium/extensions/browser/api/runtime/runtime_api.cc
@@ -4,11 +4,11 @@
#include "extensions/browser/api/runtime/runtime_api.h"
+#include <memory>
#include <utility>
#include "base/lazy_instance.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram.h"
#include "base/values.h"
#include "base/version.h"
@@ -113,10 +113,10 @@ void DispatchOnStartupEventImpl(BrowserContext* browser_context,
return;
}
- scoped_ptr<base::ListValue> event_args(new base::ListValue());
- scoped_ptr<Event> event(new Event(events::RUNTIME_ON_STARTUP,
- runtime::OnStartup::kEventName,
- std::move(event_args)));
+ std::unique_ptr<base::ListValue> event_args(new base::ListValue());
+ std::unique_ptr<Event> event(new Event(events::RUNTIME_ON_STARTUP,
+ runtime::OnStartup::kEventName,
+ std::move(event_args)));
EventRouter::Get(browser_context)
->DispatchEventToExtension(extension_id, std::move(event));
}
@@ -287,7 +287,7 @@ void RuntimeAPI::StorePendingOnInstallInfoToPref(const Extension* extension) {
// |pending_on_install_info| currently only contains a version string. Instead
// of making the pref hold a plain string, we store it as a dictionary value
// so that we can add more stuff to it in the future if necessary.
- scoped_ptr<base::DictionaryValue> pending_on_install_info(
+ std::unique_ptr<base::DictionaryValue> pending_on_install_info(
new base::DictionaryValue());
base::Version previous_version =
delegate_->GetPreviousExtensionVersion(extension);
@@ -346,7 +346,7 @@ void RuntimeEventRouter::DispatchOnInstalledEvent(
if (!system)
return;
- scoped_ptr<base::ListValue> event_args(new base::ListValue());
+ std::unique_ptr<base::ListValue> event_args(new base::ListValue());
base::DictionaryValue* info = new base::DictionaryValue();
event_args->Append(info);
if (old_version.IsValid()) {
@@ -359,9 +359,9 @@ void RuntimeEventRouter::DispatchOnInstalledEvent(
}
EventRouter* event_router = EventRouter::Get(context);
DCHECK(event_router);
- scoped_ptr<Event> event(new Event(events::RUNTIME_ON_INSTALLED,
- runtime::OnInstalled::kEventName,
- std::move(event_args)));
+ std::unique_ptr<Event> event(new Event(events::RUNTIME_ON_INSTALLED,
+ runtime::OnInstalled::kEventName,
+ std::move(event_args)));
event_router->DispatchEventWithLazyListener(extension_id, std::move(event));
if (old_version.IsValid()) {
@@ -369,20 +369,20 @@ void RuntimeEventRouter::DispatchOnInstalledEvent(
ExtensionRegistry::Get(context)->enabled_extensions().GetByID(
extension_id);
if (extension && SharedModuleInfo::IsSharedModule(extension)) {
- scoped_ptr<ExtensionSet> dependents =
+ std::unique_ptr<ExtensionSet> dependents =
system->GetDependentExtensions(extension);
for (ExtensionSet::const_iterator i = dependents->begin();
i != dependents->end();
i++) {
- scoped_ptr<base::ListValue> sm_event_args(new base::ListValue());
+ std::unique_ptr<base::ListValue> sm_event_args(new base::ListValue());
base::DictionaryValue* sm_info = new base::DictionaryValue();
sm_event_args->Append(sm_info);
sm_info->SetString(kInstallReason, kInstallReasonSharedModuleUpdate);
sm_info->SetString(kInstallPreviousVersion, old_version.GetString());
sm_info->SetString(kInstallId, extension_id);
- scoped_ptr<Event> sm_event(new Event(events::RUNTIME_ON_INSTALLED,
- runtime::OnInstalled::kEventName,
- std::move(sm_event_args)));
+ std::unique_ptr<Event> sm_event(new Event(
+ events::RUNTIME_ON_INSTALLED, runtime::OnInstalled::kEventName,
+ std::move(sm_event_args)));
event_router->DispatchEventWithLazyListener((*i)->id(),
std::move(sm_event));
}
@@ -399,13 +399,13 @@ void RuntimeEventRouter::DispatchOnUpdateAvailableEvent(
if (!system)
return;
- scoped_ptr<base::ListValue> args(new base::ListValue);
+ std::unique_ptr<base::ListValue> args(new base::ListValue);
args->Append(manifest->DeepCopy());
EventRouter* event_router = EventRouter::Get(context);
DCHECK(event_router);
- scoped_ptr<Event> event(new Event(events::RUNTIME_ON_UPDATE_AVAILABLE,
- runtime::OnUpdateAvailable::kEventName,
- std::move(args)));
+ std::unique_ptr<Event> event(new Event(events::RUNTIME_ON_UPDATE_AVAILABLE,
+ runtime::OnUpdateAvailable::kEventName,
+ std::move(args)));
event_router->DispatchEventToExtension(extension_id, std::move(event));
}
@@ -416,10 +416,10 @@ void RuntimeEventRouter::DispatchOnBrowserUpdateAvailableEvent(
if (!system)
return;
- scoped_ptr<base::ListValue> args(new base::ListValue);
+ std::unique_ptr<base::ListValue> args(new base::ListValue);
EventRouter* event_router = EventRouter::Get(context);
DCHECK(event_router);
- scoped_ptr<Event> event(new Event(
+ std::unique_ptr<Event> event(new Event(
events::RUNTIME_ON_BROWSER_UPDATE_AVAILABLE,
runtime::OnBrowserUpdateAvailable::kEventName, std::move(args)));
event_router->BroadcastEvent(std::move(event));
@@ -434,7 +434,7 @@ void RuntimeEventRouter::DispatchOnRestartRequiredEvent(
if (!system)
return;
- scoped_ptr<Event> event(
+ std::unique_ptr<Event> event(
new Event(events::RUNTIME_ON_RESTART_REQUIRED,
runtime::OnRestartRequired::kEventName,
api::runtime::OnRestartRequired::Create(reason)));
diff --git a/chromium/extensions/browser/api/runtime/runtime_api.h b/chromium/extensions/browser/api/runtime/runtime_api.h
index 5f6fbe5a2d3..187f7b0d7f1 100644
--- a/chromium/extensions/browser/api/runtime/runtime_api.h
+++ b/chromium/extensions/browser/api/runtime/runtime_api.h
@@ -102,7 +102,7 @@ class RuntimeAPI : public BrowserContextKeyedAPI,
void RemovePendingOnInstallInfoFromPref(const ExtensionId& extension_id);
void StorePendingOnInstallInfoToPref(const Extension* extension);
- scoped_ptr<RuntimeAPIDelegate> delegate_;
+ std::unique_ptr<RuntimeAPIDelegate> delegate_;
content::BrowserContext* browser_context_;
diff --git a/chromium/extensions/browser/api/runtime/runtime_apitest.cc b/chromium/extensions/browser/api/runtime/runtime_apitest.cc
index cc7226687a0..78f5998cffd 100644
--- a/chromium/extensions/browser/api/runtime/runtime_apitest.cc
+++ b/chromium/extensions/browser/api/runtime/runtime_apitest.cc
@@ -53,7 +53,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeRuntimeOpenOptionsPageError) {
}
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeRuntimeGetPlatformInfo) {
- scoped_ptr<base::Value> result(
+ std::unique_ptr<base::Value> result(
extension_function_test_utils::RunFunctionAndReturnSingleResult(
new RuntimeGetPlatformInfoFunction(), "[]", browser()));
ASSERT_TRUE(result.get() != NULL);
diff --git a/chromium/extensions/browser/api/serial/serial_api.cc b/chromium/extensions/browser/api/serial/serial_api.cc
index 74346baa2f5..3f126a80046 100644
--- a/chromium/extensions/browser/api/serial/serial_api.cc
+++ b/chromium/extensions/browser/api/serial/serial_api.cc
@@ -43,7 +43,7 @@ const char kErrorSerialConnectionNotFound[] = "Serial connection not found.";
const char kErrorGetControlSignalsFailed[] = "Failed to get control signals.";
template <class T>
-void SetDefaultScopedPtrValue(scoped_ptr<T>& ptr, const T& value) {
+void SetDefaultScopedPtrValue(std::unique_ptr<T>& ptr, const T& value) {
if (!ptr.get())
ptr.reset(new T(value));
}
@@ -86,7 +86,7 @@ bool SerialGetDevicesFunction::Prepare() {
void SerialGetDevicesFunction::Work() {
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
- scoped_ptr<device::SerialDeviceEnumerator> enumerator =
+ std::unique_ptr<device::SerialDeviceEnumerator> enumerator =
device::SerialDeviceEnumerator::Create();
mojo::Array<device::serial::DeviceInfoPtr> devices = enumerator->GetDevices();
results_ = serial::GetDevices::Results::Create(
diff --git a/chromium/extensions/browser/api/serial/serial_api.h b/chromium/extensions/browser/api/serial/serial_api.h
index c6831fb6730..d22808f23b1 100644
--- a/chromium/extensions/browser/api/serial/serial_api.h
+++ b/chromium/extensions/browser/api/serial/serial_api.h
@@ -72,7 +72,7 @@ class SerialConnectFunction : public SerialAsyncApiFunction {
void OnConnected(bool success);
void FinishConnect();
- scoped_ptr<serial::Connect::Params> params_;
+ std::unique_ptr<serial::Connect::Params> params_;
// SerialEventDispatcher is owned by a BrowserContext.
SerialEventDispatcher* serial_event_dispatcher_;
@@ -98,7 +98,7 @@ class SerialUpdateFunction : public SerialAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<serial::Update::Params> params_;
+ std::unique_ptr<serial::Update::Params> params_;
};
class SerialDisconnectFunction : public SerialAsyncApiFunction {
@@ -115,7 +115,7 @@ class SerialDisconnectFunction : public SerialAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<serial::Disconnect::Params> params_;
+ std::unique_ptr<serial::Disconnect::Params> params_;
};
class SerialSetPausedFunction : public SerialAsyncApiFunction {
@@ -132,7 +132,7 @@ class SerialSetPausedFunction : public SerialAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<serial::SetPaused::Params> params_;
+ std::unique_ptr<serial::SetPaused::Params> params_;
SerialEventDispatcher* serial_event_dispatcher_;
};
@@ -150,7 +150,7 @@ class SerialGetInfoFunction : public SerialAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<serial::GetInfo::Params> params_;
+ std::unique_ptr<serial::GetInfo::Params> params_;
};
class SerialGetConnectionsFunction : public SerialAsyncApiFunction {
@@ -183,7 +183,7 @@ class SerialSendFunction : public SerialAsyncApiFunction {
private:
void OnSendComplete(int bytes_sent, serial::SendError error);
- scoped_ptr<serial::Send::Params> params_;
+ std::unique_ptr<serial::Send::Params> params_;
};
class SerialFlushFunction : public SerialAsyncApiFunction {
@@ -200,7 +200,7 @@ class SerialFlushFunction : public SerialAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<serial::Flush::Params> params_;
+ std::unique_ptr<serial::Flush::Params> params_;
};
class SerialGetControlSignalsFunction : public SerialAsyncApiFunction {
@@ -218,7 +218,7 @@ class SerialGetControlSignalsFunction : public SerialAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<serial::GetControlSignals::Params> params_;
+ std::unique_ptr<serial::GetControlSignals::Params> params_;
};
class SerialSetControlSignalsFunction : public SerialAsyncApiFunction {
@@ -236,7 +236,7 @@ class SerialSetControlSignalsFunction : public SerialAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<serial::SetControlSignals::Params> params_;
+ std::unique_ptr<serial::SetControlSignals::Params> params_;
};
class SerialSetBreakFunction : public SerialAsyncApiFunction {
@@ -252,7 +252,7 @@ class SerialSetBreakFunction : public SerialAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<serial::SetBreak::Params> params_;
+ std::unique_ptr<serial::SetBreak::Params> params_;
};
class SerialClearBreakFunction : public SerialAsyncApiFunction {
@@ -268,7 +268,7 @@ class SerialClearBreakFunction : public SerialAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<serial::ClearBreak::Params> params_;
+ std::unique_ptr<serial::ClearBreak::Params> params_;
};
} // namespace api
diff --git a/chromium/extensions/browser/api/serial/serial_apitest.cc b/chromium/extensions/browser/api/serial/serial_apitest.cc
index f56ff94345c..40ee4e919f0 100644
--- a/chromium/extensions/browser/api/serial/serial_apitest.cc
+++ b/chromium/extensions/browser/api/serial/serial_apitest.cc
@@ -138,7 +138,7 @@ void CreateTestSerialServiceOnFileThread(
io_handler_factory,
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::IO));
- scoped_ptr<device::SerialDeviceEnumerator> device_enumerator(
+ std::unique_ptr<device::SerialDeviceEnumerator> device_enumerator(
new FakeSerialDeviceEnumerator);
new device::SerialServiceImpl(
connection_factory, std::move(device_enumerator), std::move(request));
diff --git a/chromium/extensions/browser/api/serial/serial_connection.cc b/chromium/extensions/browser/api/serial/serial_connection.cc
index 6e4cde90309..06dae2c9a4c 100644
--- a/chromium/extensions/browser/api/serial/serial_connection.cc
+++ b/chromium/extensions/browser/api/serial/serial_connection.cc
@@ -9,6 +9,7 @@
#include "base/files/file_path.h"
#include "base/lazy_instance.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "device/serial/buffer.h"
#include "extensions/browser/api/api_resource_manager.h"
@@ -222,7 +223,7 @@ bool SerialConnection::Receive(const ReceiveCompleteCallback& callback) {
return false;
receive_complete_ = callback;
receive_buffer_ = new net::IOBuffer(buffer_size_);
- io_handler_->Read(make_scoped_ptr(new device::ReceiveBuffer(
+ io_handler_->Read(base::WrapUnique(new device::ReceiveBuffer(
receive_buffer_, buffer_size_,
base::Bind(&SerialConnection::OnAsyncReadComplete, AsWeakPtr()))));
receive_timeout_task_.reset();
@@ -240,7 +241,7 @@ bool SerialConnection::Send(const std::vector<char>& data,
if (!send_complete_.is_null())
return false;
send_complete_ = callback;
- io_handler_->Write(make_scoped_ptr(new device::SendBuffer(
+ io_handler_->Write(base::WrapUnique(new device::SendBuffer(
data, base::Bind(&SerialConnection::OnAsyncWriteComplete, AsWeakPtr()))));
send_timeout_task_.reset();
if (send_timeout_ > 0) {
diff --git a/chromium/extensions/browser/api/serial/serial_connection.h b/chromium/extensions/browser/api/serial/serial_connection.h
index 428e2d66ea4..d9ab5d79756 100644
--- a/chromium/extensions/browser/api/serial/serial_connection.h
+++ b/chromium/extensions/browser/api/serial/serial_connection.h
@@ -187,11 +187,11 @@ class SerialConnection : public ApiResource,
// Closure which will trigger a receive timeout unless cancelled. Reset on
// initialization and after every successful Receive().
- scoped_ptr<TimeoutTask> receive_timeout_task_;
+ std::unique_ptr<TimeoutTask> receive_timeout_task_;
// Write timeout closure. Reset on initialization and after every successful
// Send().
- scoped_ptr<TimeoutTask> send_timeout_task_;
+ std::unique_ptr<TimeoutTask> send_timeout_task_;
scoped_refptr<net::IOBuffer> receive_buffer_;
diff --git a/chromium/extensions/browser/api/serial/serial_event_dispatcher.cc b/chromium/extensions/browser/api/serial/serial_event_dispatcher.cc
index 31e44b041b0..31fb191d904 100644
--- a/chromium/extensions/browser/api/serial/serial_event_dispatcher.cc
+++ b/chromium/extensions/browser/api/serial/serial_event_dispatcher.cc
@@ -107,8 +107,9 @@ void SerialEventDispatcher::ReceiveCallback(const ReceiveParams& params,
serial::ReceiveInfo receive_info;
receive_info.connection_id = params.connection_id;
receive_info.data = data;
- scoped_ptr<base::ListValue> args = serial::OnReceive::Create(receive_info);
- scoped_ptr<extensions::Event> event(
+ std::unique_ptr<base::ListValue> args =
+ serial::OnReceive::Create(receive_info);
+ std::unique_ptr<extensions::Event> event(
new extensions::Event(extensions::events::SERIAL_ON_RECEIVE,
serial::OnReceive::kEventName, std::move(args)));
PostEvent(params, std::move(event));
@@ -118,9 +119,9 @@ void SerialEventDispatcher::ReceiveCallback(const ReceiveParams& params,
serial::ReceiveErrorInfo error_info;
error_info.connection_id = params.connection_id;
error_info.error = error;
- scoped_ptr<base::ListValue> args =
+ std::unique_ptr<base::ListValue> args =
serial::OnReceiveError::Create(error_info);
- scoped_ptr<extensions::Event> event(new extensions::Event(
+ std::unique_ptr<extensions::Event> event(new extensions::Event(
extensions::events::SERIAL_ON_RECEIVE_ERROR,
serial::OnReceiveError::kEventName, std::move(args)));
PostEvent(params, std::move(event));
@@ -138,8 +139,9 @@ void SerialEventDispatcher::ReceiveCallback(const ReceiveParams& params,
}
// static
-void SerialEventDispatcher::PostEvent(const ReceiveParams& params,
- scoped_ptr<extensions::Event> event) {
+void SerialEventDispatcher::PostEvent(
+ const ReceiveParams& params,
+ std::unique_ptr<extensions::Event> event) {
DCHECK_CURRENTLY_ON(params.thread_id);
BrowserThread::PostTask(
@@ -149,9 +151,10 @@ void SerialEventDispatcher::PostEvent(const ReceiveParams& params,
}
// static
-void SerialEventDispatcher::DispatchEvent(void* browser_context_id,
- const std::string& extension_id,
- scoped_ptr<extensions::Event> event) {
+void SerialEventDispatcher::DispatchEvent(
+ void* browser_context_id,
+ const std::string& extension_id,
+ std::unique_ptr<extensions::Event> event) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
content::BrowserContext* context =
diff --git a/chromium/extensions/browser/api/serial/serial_event_dispatcher.h b/chromium/extensions/browser/api/serial/serial_event_dispatcher.h
index 10188af493a..70588ca0353 100644
--- a/chromium/extensions/browser/api/serial/serial_event_dispatcher.h
+++ b/chromium/extensions/browser/api/serial/serial_event_dispatcher.h
@@ -65,11 +65,11 @@ class SerialEventDispatcher : public BrowserContextKeyedAPI {
serial::ReceiveError error);
static void PostEvent(const ReceiveParams& params,
- scoped_ptr<extensions::Event> event);
+ std::unique_ptr<extensions::Event> event);
static void DispatchEvent(void* browser_context_id,
const std::string& extension_id,
- scoped_ptr<extensions::Event> event);
+ std::unique_ptr<extensions::Event> event);
content::BrowserThread::ID thread_id_;
content::BrowserContext* const context_;
diff --git a/chromium/extensions/browser/api/socket/app_firewall_hole_manager.cc b/chromium/extensions/browser/api/socket/app_firewall_hole_manager.cc
index f5973734081..db9d3d76d26 100644
--- a/chromium/extensions/browser/api/socket/app_firewall_hole_manager.cc
+++ b/chromium/extensions/browser/api/socket/app_firewall_hole_manager.cc
@@ -97,7 +97,7 @@ void AppFirewallHole::SetVisible(bool app_visible) {
}
void AppFirewallHole::OnFirewallHoleOpened(
- scoped_ptr<FirewallHole> firewall_hole) {
+ std::unique_ptr<FirewallHole> firewall_hole) {
if (app_visible_) {
DCHECK(!firewall_hole_);
firewall_hole_ = std::move(firewall_hole);
@@ -117,11 +117,11 @@ AppFirewallHoleManager* AppFirewallHoleManager::Get(BrowserContext* context) {
return AppFirewallHoleManagerFactory::GetForBrowserContext(context, true);
}
-scoped_ptr<AppFirewallHole> AppFirewallHoleManager::Open(
+std::unique_ptr<AppFirewallHole> AppFirewallHoleManager::Open(
AppFirewallHole::PortType type,
uint16_t port,
const std::string& extension_id) {
- scoped_ptr<AppFirewallHole> hole(
+ std::unique_ptr<AppFirewallHole> hole(
new AppFirewallHole(this, type, port, extension_id));
tracked_holes_.insert(std::make_pair(extension_id, hole.get()));
if (HasVisibleAppWindows(context_, extension_id)) {
diff --git a/chromium/extensions/browser/api/socket/app_firewall_hole_manager.h b/chromium/extensions/browser/api/socket/app_firewall_hole_manager.h
index 0c125201938..d839071ab74 100644
--- a/chromium/extensions/browser/api/socket/app_firewall_hole_manager.h
+++ b/chromium/extensions/browser/api/socket/app_firewall_hole_manager.h
@@ -43,7 +43,8 @@ class AppFirewallHole {
const std::string& extension_id);
void SetVisible(bool app_visible);
- void OnFirewallHoleOpened(scoped_ptr<chromeos::FirewallHole> firewall_hole);
+ void OnFirewallHoleOpened(
+ std::unique_ptr<chromeos::FirewallHole> firewall_hole);
PortType type_;
uint16_t port_;
@@ -55,7 +56,7 @@ class AppFirewallHole {
AppFirewallHoleManager* manager_;
// This will hold the FirewallHole object if one is opened.
- scoped_ptr<chromeos::FirewallHole> firewall_hole_;
+ std::unique_ptr<chromeos::FirewallHole> firewall_hole_;
base::WeakPtrFactory<AppFirewallHole> weak_factory_;
};
@@ -74,9 +75,9 @@ class AppFirewallHoleManager : public KeyedService,
// Takes ownership of the AppFirewallHole and will open a port on the system
// firewall if the associated application is currently visible.
- scoped_ptr<AppFirewallHole> Open(AppFirewallHole::PortType type,
- uint16_t port,
- const std::string& extension_id);
+ std::unique_ptr<AppFirewallHole> Open(AppFirewallHole::PortType type,
+ uint16_t port,
+ const std::string& extension_id);
private:
friend class AppFirewallHole;
diff --git a/chromium/extensions/browser/api/socket/socket.h b/chromium/extensions/browser/api/socket/socket.h
index fefe6bc0f20..ef1c43605da 100644
--- a/chromium/extensions/browser/api/socket/socket.h
+++ b/chromium/extensions/browser/api/socket/socket.h
@@ -40,7 +40,7 @@ typedef base::Callback<void(int,
scoped_refptr<net::IOBuffer> io_buffer,
const std::string&,
uint16_t)> RecvFromCompletionCallback;
-typedef base::Callback<void(int, scoped_ptr<net::TCPClientSocket>)>
+typedef base::Callback<void(int, std::unique_ptr<net::TCPClientSocket>)>
AcceptCompletionCallback;
// A Socket wraps a low-level socket and includes housekeeping information that
@@ -64,7 +64,7 @@ class Socket : public ApiResource {
#if defined(OS_CHROMEOS)
void set_firewall_hole(
- scoped_ptr<AppFirewallHole, content::BrowserThread::DeleteOnUIThread>
+ std::unique_ptr<AppFirewallHole, content::BrowserThread::DeleteOnUIThread>
firewall_hole) {
firewall_hole_ = std::move(firewall_hole);
}
@@ -149,7 +149,7 @@ class Socket : public ApiResource {
#if defined(OS_CHROMEOS)
// Represents a hole punched in the system firewall for this socket.
- scoped_ptr<AppFirewallHole, content::BrowserThread::DeleteOnUIThread>
+ std::unique_ptr<AppFirewallHole, content::BrowserThread::DeleteOnUIThread>
firewall_hole_;
#endif // OS_CHROMEOS
};
diff --git a/chromium/extensions/browser/api/socket/socket_api.cc b/chromium/extensions/browser/api/socket/socket_api.cc
index 4b1074a0085..b69d56f6744 100644
--- a/chromium/extensions/browser/api/socket/socket_api.cc
+++ b/chromium/extensions/browser/api/socket/socket_api.cc
@@ -12,6 +12,7 @@
#include "build/build_config.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/resource_context.h"
+#include "content/public/browser/storage_partition.h"
#include "extensions/browser/api/dns/host_resolver_wrapper.h"
#include "extensions/browser/api/socket/socket.h"
#include "extensions/browser/api/socket/tcp_socket.h"
@@ -74,9 +75,9 @@ bool SocketAsyncApiFunction::PrePrepare() {
bool SocketAsyncApiFunction::Respond() { return error_.empty(); }
-scoped_ptr<SocketResourceManagerInterface>
+std::unique_ptr<SocketResourceManagerInterface>
SocketAsyncApiFunction::CreateSocketResourceManager() {
- return scoped_ptr<SocketResourceManagerInterface>(
+ return std::unique_ptr<SocketResourceManagerInterface>(
new SocketResourceManager<Socket>());
}
@@ -138,7 +139,7 @@ void SocketAsyncApiFunction::OpenFirewallHoleOnUIThread(
DCHECK_CURRENTLY_ON(BrowserThread::UI);
AppFirewallHoleManager* manager =
AppFirewallHoleManager::Get(browser_context());
- scoped_ptr<AppFirewallHole, BrowserThread::DeleteOnUIThread> hole(
+ std::unique_ptr<AppFirewallHole, BrowserThread::DeleteOnUIThread> hole(
manager->Open(type, port, extension_id()).release());
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
@@ -148,7 +149,7 @@ void SocketAsyncApiFunction::OpenFirewallHoleOnUIThread(
void SocketAsyncApiFunction::OnFirewallHoleOpened(
int socket_id,
- scoped_ptr<AppFirewallHole, BrowserThread::DeleteOnUIThread> hole) {
+ std::unique_ptr<AppFirewallHole, BrowserThread::DeleteOnUIThread> hole) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!hole) {
error_ = kFirewallFailure;
@@ -460,8 +461,9 @@ void SocketAcceptFunction::AsyncWorkStart() {
}
}
-void SocketAcceptFunction::OnAccept(int result_code,
- scoped_ptr<net::TCPClientSocket> socket) {
+void SocketAcceptFunction::OnAccept(
+ int result_code,
+ std::unique_ptr<net::TCPClientSocket> socket) {
base::DictionaryValue* result = new base::DictionaryValue();
result->SetInteger(kResultCodeKey, result_code);
if (socket) {
@@ -1010,7 +1012,8 @@ bool SocketSecureFunction::Prepare() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
params_ = api::socket::Secure::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params_.get());
- url_request_getter_ = browser_context()->GetRequestContext();
+ url_request_getter_ = content::BrowserContext::GetDefaultStoragePartition(
+ browser_context())->GetURLRequestContext();
return true;
}
@@ -1056,7 +1059,7 @@ void SocketSecureFunction::AsyncWorkStart() {
base::Bind(&SocketSecureFunction::TlsConnectDone, this));
}
-void SocketSecureFunction::TlsConnectDone(scoped_ptr<TLSSocket> socket,
+void SocketSecureFunction::TlsConnectDone(std::unique_ptr<TLSSocket> socket,
int result) {
// if an error occurred, socket MUST be NULL.
DCHECK(result == net::OK || socket == NULL);
diff --git a/chromium/extensions/browser/api/socket/socket_api.h b/chromium/extensions/browser/api/socket/socket_api.h
index 9094f6097d6..9a73a82d6c8 100644
--- a/chromium/extensions/browser/api/socket/socket_api.h
+++ b/chromium/extensions/browser/api/socket/socket_api.h
@@ -117,8 +117,8 @@ class SocketAsyncApiFunction : public AsyncApiFunction {
bool PrePrepare() override;
bool Respond() override;
- virtual scoped_ptr<SocketResourceManagerInterface>
- CreateSocketResourceManager();
+ virtual std::unique_ptr<SocketResourceManagerInterface>
+ CreateSocketResourceManager();
int AddSocket(Socket* socket);
Socket* GetSocket(int api_resource_id);
@@ -138,11 +138,11 @@ class SocketAsyncApiFunction : public AsyncApiFunction {
int socket_id);
void OnFirewallHoleOpened(
int socket_id,
- scoped_ptr<AppFirewallHole, content::BrowserThread::DeleteOnUIThread>
+ std::unique_ptr<AppFirewallHole, content::BrowserThread::DeleteOnUIThread>
hole);
#endif // OS_CHROMEOS
- scoped_ptr<SocketResourceManagerInterface> manager_;
+ std::unique_ptr<SocketResourceManagerInterface> manager_;
};
class SocketExtensionWithDnsLookupFunction : public SocketAsyncApiFunction {
@@ -182,7 +182,7 @@ class SocketCreateFunction : public SocketAsyncApiFunction {
FRIEND_TEST_ALL_PREFIXES(SocketUnitTest, Create);
enum SocketType { kSocketTypeInvalid = -1, kSocketTypeTCP, kSocketTypeUDP };
- scoped_ptr<api::socket::Create::Params> params_;
+ std::unique_ptr<api::socket::Create::Params> params_;
SocketType socket_type_;
};
@@ -272,7 +272,7 @@ class SocketListenFunction : public SocketAsyncApiFunction {
void AsyncWorkStart() override;
private:
- scoped_ptr<api::socket::Listen::Params> params_;
+ std::unique_ptr<api::socket::Listen::Params> params_;
};
class SocketAcceptFunction : public SocketAsyncApiFunction {
@@ -289,9 +289,9 @@ class SocketAcceptFunction : public SocketAsyncApiFunction {
void AsyncWorkStart() override;
private:
- void OnAccept(int result_code, scoped_ptr<net::TCPClientSocket> socket);
+ void OnAccept(int result_code, std::unique_ptr<net::TCPClientSocket> socket);
- scoped_ptr<api::socket::Accept::Params> params_;
+ std::unique_ptr<api::socket::Accept::Params> params_;
};
class SocketReadFunction : public SocketAsyncApiFunction {
@@ -309,7 +309,7 @@ class SocketReadFunction : public SocketAsyncApiFunction {
void OnCompleted(int result, scoped_refptr<net::IOBuffer> io_buffer);
private:
- scoped_ptr<api::socket::Read::Params> params_;
+ std::unique_ptr<api::socket::Read::Params> params_;
};
class SocketWriteFunction : public SocketAsyncApiFunction {
@@ -350,7 +350,7 @@ class SocketRecvFromFunction : public SocketAsyncApiFunction {
uint16_t port);
private:
- scoped_ptr<api::socket::RecvFrom::Params> params_;
+ std::unique_ptr<api::socket::RecvFrom::Params> params_;
};
class SocketSendToFunction : public SocketExtensionWithDnsLookupFunction {
@@ -394,7 +394,7 @@ class SocketSetKeepAliveFunction : public SocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<api::socket::SetKeepAlive::Params> params_;
+ std::unique_ptr<api::socket::SetKeepAlive::Params> params_;
};
class SocketSetNoDelayFunction : public SocketAsyncApiFunction {
@@ -411,7 +411,7 @@ class SocketSetNoDelayFunction : public SocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<api::socket::SetNoDelay::Params> params_;
+ std::unique_ptr<api::socket::SetNoDelay::Params> params_;
};
class SocketGetInfoFunction : public SocketAsyncApiFunction {
@@ -428,7 +428,7 @@ class SocketGetInfoFunction : public SocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<api::socket::GetInfo::Params> params_;
+ std::unique_ptr<api::socket::GetInfo::Params> params_;
};
class SocketGetNetworkListFunction : public AsyncExtensionFunction {
@@ -459,7 +459,7 @@ class SocketJoinGroupFunction : public SocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<api::socket::JoinGroup::Params> params_;
+ std::unique_ptr<api::socket::JoinGroup::Params> params_;
};
class SocketLeaveGroupFunction : public SocketAsyncApiFunction {
@@ -476,7 +476,7 @@ class SocketLeaveGroupFunction : public SocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<api::socket::LeaveGroup::Params> params_;
+ std::unique_ptr<api::socket::LeaveGroup::Params> params_;
};
class SocketSetMulticastTimeToLiveFunction : public SocketAsyncApiFunction {
@@ -494,7 +494,7 @@ class SocketSetMulticastTimeToLiveFunction : public SocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<api::socket::SetMulticastTimeToLive::Params> params_;
+ std::unique_ptr<api::socket::SetMulticastTimeToLive::Params> params_;
};
class SocketSetMulticastLoopbackModeFunction : public SocketAsyncApiFunction {
@@ -512,7 +512,7 @@ class SocketSetMulticastLoopbackModeFunction : public SocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<api::socket::SetMulticastLoopbackMode::Params> params_;
+ std::unique_ptr<api::socket::SetMulticastLoopbackMode::Params> params_;
};
class SocketGetJoinedGroupsFunction : public SocketAsyncApiFunction {
@@ -530,7 +530,7 @@ class SocketGetJoinedGroupsFunction : public SocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<api::socket::GetJoinedGroups::Params> params_;
+ std::unique_ptr<api::socket::GetJoinedGroups::Params> params_;
};
class SocketSecureFunction : public SocketAsyncApiFunction {
@@ -547,9 +547,9 @@ class SocketSecureFunction : public SocketAsyncApiFunction {
private:
// Callback from TLSSocket::UpgradeSocketToTLS().
- void TlsConnectDone(scoped_ptr<TLSSocket> socket, int result);
+ void TlsConnectDone(std::unique_ptr<TLSSocket> socket, int result);
- scoped_ptr<api::socket::Secure::Params> params_;
+ std::unique_ptr<api::socket::Secure::Params> params_;
scoped_refptr<net::URLRequestContextGetter> url_request_getter_;
DISALLOW_COPY_AND_ASSIGN(SocketSecureFunction);
diff --git a/chromium/extensions/browser/api/socket/socket_apitest.cc b/chromium/extensions/browser/api/socket/socket_apitest.cc
index edc5a84541c..3d581041860 100644
--- a/chromium/extensions/browser/api/socket/socket_apitest.cc
+++ b/chromium/extensions/browser/api/socket/socket_apitest.cc
@@ -24,7 +24,7 @@ IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketUDPCreateGood) {
socket_create_function->set_extension(empty_extension.get());
socket_create_function->set_has_callback(true);
- scoped_ptr<base::Value> result(RunFunctionAndReturnSingleResult(
+ std::unique_ptr<base::Value> result(RunFunctionAndReturnSingleResult(
socket_create_function.get(), "[\"udp\"]", browser_context()));
base::DictionaryValue* value = NULL;
ASSERT_TRUE(result->GetAsDictionary(&value));
@@ -41,7 +41,7 @@ IN_PROC_BROWSER_TEST_F(SocketApiTest, SocketTCPCreateGood) {
socket_create_function->set_extension(empty_extension.get());
socket_create_function->set_has_callback(true);
- scoped_ptr<base::Value> result(RunFunctionAndReturnSingleResult(
+ std::unique_ptr<base::Value> result(RunFunctionAndReturnSingleResult(
socket_create_function.get(), "[\"tcp\"]", browser_context()));
base::DictionaryValue* value = NULL;
ASSERT_TRUE(result->GetAsDictionary(&value));
@@ -58,7 +58,7 @@ IN_PROC_BROWSER_TEST_F(SocketApiTest, GetNetworkList) {
socket_function->set_extension(empty_extension.get());
socket_function->set_has_callback(true);
- scoped_ptr<base::Value> result(RunFunctionAndReturnSingleResult(
+ std::unique_ptr<base::Value> result(RunFunctionAndReturnSingleResult(
socket_function.get(), "[]", browser_context()));
// If we're invoking socket tests, all we can confirm is that we have at
diff --git a/chromium/extensions/browser/api/socket/tcp_socket.cc b/chromium/extensions/browser/api/socket/tcp_socket.cc
index d4aaafbd6c2..5053b869378 100644
--- a/chromium/extensions/browser/api/socket/tcp_socket.cc
+++ b/chromium/extensions/browser/api/socket/tcp_socket.cc
@@ -7,6 +7,7 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "extensions/browser/api/api_resource.h"
#include "net/base/address_list.h"
#include "net/base/ip_endpoint.h"
@@ -45,7 +46,7 @@ ApiResourceManager<ResumableTCPServerSocket>::GetFactoryInstance() {
TCPSocket::TCPSocket(const std::string& owner_extension_id)
: Socket(owner_extension_id), socket_mode_(UNKNOWN) {}
-TCPSocket::TCPSocket(scoped_ptr<net::TCPClientSocket> tcp_client_socket,
+TCPSocket::TCPSocket(std::unique_ptr<net::TCPClientSocket> tcp_client_socket,
const std::string& owner_extension_id,
bool is_connected)
: Socket(owner_extension_id),
@@ -54,7 +55,7 @@ TCPSocket::TCPSocket(scoped_ptr<net::TCPClientSocket> tcp_client_socket,
this->is_connected_ = is_connected;
}
-TCPSocket::TCPSocket(scoped_ptr<net::TCPServerSocket> tcp_server_socket,
+TCPSocket::TCPSocket(std::unique_ptr<net::TCPServerSocket> tcp_server_socket,
const std::string& owner_extension_id)
: Socket(owner_extension_id),
server_socket_(std::move(tcp_server_socket)),
@@ -62,7 +63,7 @@ TCPSocket::TCPSocket(scoped_ptr<net::TCPServerSocket> tcp_server_socket,
// static
TCPSocket* TCPSocket::CreateSocketForTesting(
- scoped_ptr<net::TCPClientSocket> tcp_client_socket,
+ std::unique_ptr<net::TCPClientSocket> tcp_client_socket,
const std::string& owner_extension_id,
bool is_connected) {
return new TCPSocket(std::move(tcp_client_socket), owner_extension_id,
@@ -71,7 +72,7 @@ TCPSocket* TCPSocket::CreateSocketForTesting(
// static
TCPSocket* TCPSocket::CreateServerSocketForTesting(
- scoped_ptr<net::TCPServerSocket> tcp_server_socket,
+ std::unique_ptr<net::TCPServerSocket> tcp_server_socket,
const std::string& owner_extension_id) {
return new TCPSocket(std::move(tcp_server_socket), owner_extension_id);
}
@@ -99,7 +100,7 @@ void TCPSocket::Connect(const net::AddressList& address,
int result = net::ERR_CONNECTION_FAILED;
if (!is_connected_) {
socket_.reset(
- new net::TCPClientSocket(address, NULL, net::NetLog::Source()));
+ new net::TCPClientSocket(address, NULL, NULL, net::NetLog::Source()));
result = socket_->Connect(
base::Bind(&TCPSocket::OnConnectComplete, base::Unretained(this)));
}
@@ -299,7 +300,7 @@ void TCPSocket::OnAccept(int result) {
DCHECK(!accept_callback_.is_null());
if (result == net::OK && accept_socket_.get()) {
accept_callback_.Run(result,
- make_scoped_ptr(static_cast<net::TCPClientSocket*>(
+ base::WrapUnique(static_cast<net::TCPClientSocket*>(
accept_socket_.release())));
} else {
accept_callback_.Run(result, NULL);
@@ -344,7 +345,7 @@ ResumableTCPSocket::ResumableTCPSocket(const std::string& owner_extension_id)
paused_(false) {}
ResumableTCPSocket::ResumableTCPSocket(
- scoped_ptr<net::TCPClientSocket> tcp_client_socket,
+ std::unique_ptr<net::TCPClientSocket> tcp_client_socket,
const std::string& owner_extension_id,
bool is_connected)
: TCPSocket(std::move(tcp_client_socket), owner_extension_id, is_connected),
diff --git a/chromium/extensions/browser/api/socket/tcp_socket.h b/chromium/extensions/browser/api/socket/tcp_socket.h
index b6f3281a9da..38f6187c315 100644
--- a/chromium/extensions/browser/api/socket/tcp_socket.h
+++ b/chromium/extensions/browser/api/socket/tcp_socket.h
@@ -25,7 +25,7 @@ namespace extensions {
class TCPSocket : public Socket {
public:
explicit TCPSocket(const std::string& owner_extension_id);
- TCPSocket(scoped_ptr<net::TCPClientSocket> tcp_client_socket,
+ TCPSocket(std::unique_ptr<net::TCPClientSocket> tcp_client_socket,
const std::string& owner_extension_id,
bool is_connected = false);
@@ -62,11 +62,11 @@ class TCPSocket : public Socket {
Socket::SocketType GetSocketType() const override;
static TCPSocket* CreateSocketForTesting(
- scoped_ptr<net::TCPClientSocket> tcp_client_socket,
+ std::unique_ptr<net::TCPClientSocket> tcp_client_socket,
const std::string& owner_extension_id,
bool is_connected = false);
static TCPSocket* CreateServerSocketForTesting(
- scoped_ptr<net::TCPServerSocket> tcp_server_socket,
+ std::unique_ptr<net::TCPServerSocket> tcp_server_socket,
const std::string& owner_extension_id);
// Returns NULL if GetSocketType() isn't TYPE_TCP or if the connection
@@ -87,11 +87,11 @@ class TCPSocket : public Socket {
void OnReadComplete(scoped_refptr<net::IOBuffer> io_buffer, int result);
void OnAccept(int result);
- TCPSocket(scoped_ptr<net::TCPServerSocket> tcp_server_socket,
+ TCPSocket(std::unique_ptr<net::TCPServerSocket> tcp_server_socket,
const std::string& owner_extension_id);
- scoped_ptr<net::TCPClientSocket> socket_;
- scoped_ptr<net::TCPServerSocket> server_socket_;
+ std::unique_ptr<net::TCPClientSocket> socket_;
+ std::unique_ptr<net::TCPServerSocket> server_socket_;
enum SocketMode { UNKNOWN = 0, CLIENT, SERVER, };
SocketMode socket_mode_;
@@ -100,7 +100,7 @@ class TCPSocket : public Socket {
ReadCompletionCallback read_callback_;
- scoped_ptr<net::StreamSocket> accept_socket_;
+ std::unique_ptr<net::StreamSocket> accept_socket_;
AcceptCompletionCallback accept_callback_;
};
@@ -111,7 +111,7 @@ class ResumableTCPSocket : public TCPSocket {
public:
explicit ResumableTCPSocket(const std::string& owner_extension_id);
explicit ResumableTCPSocket(
- scoped_ptr<net::TCPClientSocket> tcp_client_socket,
+ std::unique_ptr<net::TCPClientSocket> tcp_client_socket,
const std::string& owner_extension_id,
bool is_connected);
diff --git a/chromium/extensions/browser/api/socket/tls_socket.cc b/chromium/extensions/browser/api/socket/tls_socket.cc
index 1dc86345eb3..686d37f5ba8 100644
--- a/chromium/extensions/browser/api/socket/tls_socket.cc
+++ b/chromium/extensions/browser/api/socket/tls_socket.cc
@@ -36,7 +36,7 @@ uint16_t SSLProtocolVersionFromString(const std::string& version_str) {
return version;
}
-void TlsConnectDone(scoped_ptr<net::SSLClientSocket> ssl_socket,
+void TlsConnectDone(std::unique_ptr<net::SSLClientSocket> ssl_socket,
const std::string& extension_id,
const extensions::TLSSocket::SecureCallback& callback,
int result) {
@@ -47,14 +47,14 @@ void TlsConnectDone(scoped_ptr<net::SSLClientSocket> ssl_socket,
// which is promoted here to a new API-accessible socket (via a TLSSocket
// wrapper), or deleted.
if (result != net::OK) {
- callback.Run(scoped_ptr<extensions::TLSSocket>(), result);
+ callback.Run(std::unique_ptr<extensions::TLSSocket>(), result);
return;
};
// Wrap the StreamSocket in a TLSSocket, which matches the extension socket
// API. Set the handle of the socket to the new value, so that it can be
// used for read/write/close/etc.
- scoped_ptr<extensions::TLSSocket> wrapper(
+ std::unique_ptr<extensions::TLSSocket> wrapper(
new extensions::TLSSocket(std::move(ssl_socket), extension_id));
// Caller will end up deleting the prior TCPSocket, once it calls
@@ -69,7 +69,7 @@ namespace extensions {
const char kTLSSocketTypeInvalidError[] =
"Cannot listen on a socket that is already connected.";
-TLSSocket::TLSSocket(scoped_ptr<net::StreamSocket> tls_socket,
+TLSSocket::TLSSocket(std::unique_ptr<net::StreamSocket> tls_socket,
const std::string& owner_extension_id)
: ResumableTCPSocket(owner_extension_id),
tls_socket_(std::move(tls_socket)) {}
@@ -186,7 +186,7 @@ void TLSSocket::UpgradeSocketToTLS(
const TLSSocket::SecureCallback& callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
TCPSocket* tcp_socket = static_cast<TCPSocket*>(socket);
- scoped_ptr<net::SSLClientSocket> null_sock;
+ std::unique_ptr<net::SSLClientSocket> null_sock;
if (!tcp_socket || tcp_socket->GetSocketType() != Socket::TYPE_TCP ||
!tcp_socket->ClientStream() || !tcp_socket->IsConnected() ||
@@ -227,14 +227,14 @@ void TLSSocket::UpgradeSocketToTLS(
net::HostPortPair host_and_port(canon_host, dest_host_port_pair.port());
- scoped_ptr<net::ClientSocketHandle> socket_handle(
+ std::unique_ptr<net::ClientSocketHandle> socket_handle(
new net::ClientSocketHandle());
// Set the socket handle to the socket's client stream (that should be the
// only one active here). Then have the old socket release ownership on
// that client stream.
socket_handle->SetSocket(
- scoped_ptr<net::StreamSocket>(tcp_socket->ClientStream()));
+ std::unique_ptr<net::StreamSocket>(tcp_socket->ClientStream()));
tcp_socket->Release();
DCHECK(transport_security_state);
@@ -266,7 +266,7 @@ void TLSSocket::UpgradeSocketToTLS(
net::ClientSocketFactory::GetDefaultFactory();
// Create the socket.
- scoped_ptr<net::SSLClientSocket> ssl_socket(
+ std::unique_ptr<net::SSLClientSocket> ssl_socket(
socket_factory->CreateSSLClientSocket(
std::move(socket_handle), host_and_port, ssl_config, context));
diff --git a/chromium/extensions/browser/api/socket/tls_socket.h b/chromium/extensions/browser/api/socket/tls_socket.h
index 2bd5ea7c392..2f7a683efb4 100644
--- a/chromium/extensions/browser/api/socket/tls_socket.h
+++ b/chromium/extensions/browser/api/socket/tls_socket.h
@@ -36,9 +36,9 @@ class TLSSocket;
// touch any socket state.
class TLSSocket : public ResumableTCPSocket {
public:
- typedef base::Callback<void(scoped_ptr<TLSSocket>, int)> SecureCallback;
+ typedef base::Callback<void(std::unique_ptr<TLSSocket>, int)> SecureCallback;
- TLSSocket(scoped_ptr<net::StreamSocket> tls_socket,
+ TLSSocket(std::unique_ptr<net::StreamSocket> tls_socket,
const std::string& owner_extension_id);
~TLSSocket() override;
@@ -110,7 +110,7 @@ class TLSSocket : public ResumableTCPSocket {
void OnReadComplete(const scoped_refptr<net::IOBuffer>& io_buffer,
int result);
- scoped_ptr<net::StreamSocket> tls_socket_;
+ std::unique_ptr<net::StreamSocket> tls_socket_;
ReadCompletionCallback read_callback_;
};
diff --git a/chromium/extensions/browser/api/sockets_tcp/sockets_tcp_api.cc b/chromium/extensions/browser/api/sockets_tcp/sockets_tcp_api.cc
index be36153cbbc..b2c06096008 100644
--- a/chromium/extensions/browser/api/sockets_tcp/sockets_tcp_api.cc
+++ b/chromium/extensions/browser/api/sockets_tcp/sockets_tcp_api.cc
@@ -5,6 +5,7 @@
#include "extensions/browser/api/sockets_tcp/sockets_tcp_api.h"
#include "content/public/browser/browser_context.h"
+#include "content/public/browser/storage_partition.h"
#include "content/public/common/socket_permission_request.h"
#include "extensions/browser/api/socket/tcp_socket.h"
#include "extensions/browser/api/socket/tls_socket.h"
@@ -87,9 +88,9 @@ using content::SocketPermissionRequest;
TCPSocketAsyncApiFunction::~TCPSocketAsyncApiFunction() {}
-scoped_ptr<SocketResourceManagerInterface>
+std::unique_ptr<SocketResourceManagerInterface>
TCPSocketAsyncApiFunction::CreateSocketResourceManager() {
- return scoped_ptr<SocketResourceManagerInterface>(
+ return std::unique_ptr<SocketResourceManagerInterface>(
new SocketResourceManager<ResumableTCPSocket>());
}
@@ -100,9 +101,9 @@ ResumableTCPSocket* TCPSocketAsyncApiFunction::GetTcpSocket(int socket_id) {
TCPSocketExtensionWithDnsLookupFunction::
~TCPSocketExtensionWithDnsLookupFunction() {}
-scoped_ptr<SocketResourceManagerInterface>
+std::unique_ptr<SocketResourceManagerInterface>
TCPSocketExtensionWithDnsLookupFunction::CreateSocketResourceManager() {
- return scoped_ptr<SocketResourceManagerInterface>(
+ return std::unique_ptr<SocketResourceManagerInterface>(
new SocketResourceManager<ResumableTCPSocket>());
}
@@ -455,7 +456,8 @@ bool SocketsTcpSecureFunction::Prepare() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
params_ = api::sockets_tcp::Secure::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params_.get());
- url_request_getter_ = browser_context()->GetRequestContext();
+ url_request_getter_ = content::BrowserContext::GetDefaultStoragePartition(
+ browser_context())->GetURLRequestContext();
return true;
}
@@ -520,7 +522,7 @@ void SocketsTcpSecureFunction::AsyncWorkStart() {
base::Bind(&SocketsTcpSecureFunction::TlsConnectDone, this));
}
-void SocketsTcpSecureFunction::TlsConnectDone(scoped_ptr<TLSSocket> socket,
+void SocketsTcpSecureFunction::TlsConnectDone(std::unique_ptr<TLSSocket> socket,
int result) {
// If an error occurred, socket MUST be NULL
DCHECK(result == net::OK || socket == NULL);
diff --git a/chromium/extensions/browser/api/sockets_tcp/sockets_tcp_api.h b/chromium/extensions/browser/api/sockets_tcp/sockets_tcp_api.h
index bbea8f4c3dc..c4b3ee883c6 100644
--- a/chromium/extensions/browser/api/sockets_tcp/sockets_tcp_api.h
+++ b/chromium/extensions/browser/api/sockets_tcp/sockets_tcp_api.h
@@ -26,7 +26,7 @@ class TCPSocketAsyncApiFunction : public SocketAsyncApiFunction {
protected:
~TCPSocketAsyncApiFunction() override;
- scoped_ptr<SocketResourceManagerInterface> CreateSocketResourceManager()
+ std::unique_ptr<SocketResourceManagerInterface> CreateSocketResourceManager()
override;
ResumableTCPSocket* GetTcpSocket(int socket_id);
@@ -37,7 +37,7 @@ class TCPSocketExtensionWithDnsLookupFunction
protected:
~TCPSocketExtensionWithDnsLookupFunction() override;
- scoped_ptr<SocketResourceManagerInterface> CreateSocketResourceManager()
+ std::unique_ptr<SocketResourceManagerInterface> CreateSocketResourceManager()
override;
ResumableTCPSocket* GetTcpSocket(int socket_id);
@@ -58,7 +58,7 @@ class SocketsTcpCreateFunction : public TCPSocketAsyncApiFunction {
private:
FRIEND_TEST_ALL_PREFIXES(SocketsTcpUnitTest, Create);
- scoped_ptr<sockets_tcp::Create::Params> params_;
+ std::unique_ptr<sockets_tcp::Create::Params> params_;
};
class SocketsTcpUpdateFunction : public TCPSocketAsyncApiFunction {
@@ -75,7 +75,7 @@ class SocketsTcpUpdateFunction : public TCPSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<sockets_tcp::Update::Params> params_;
+ std::unique_ptr<sockets_tcp::Update::Params> params_;
};
class SocketsTcpSetPausedFunction : public TCPSocketAsyncApiFunction {
@@ -92,7 +92,7 @@ class SocketsTcpSetPausedFunction : public TCPSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<sockets_tcp::SetPaused::Params> params_;
+ std::unique_ptr<sockets_tcp::SetPaused::Params> params_;
TCPSocketEventDispatcher* socket_event_dispatcher_;
};
@@ -111,7 +111,7 @@ class SocketsTcpSetKeepAliveFunction : public TCPSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<sockets_tcp::SetKeepAlive::Params> params_;
+ std::unique_ptr<sockets_tcp::SetKeepAlive::Params> params_;
};
class SocketsTcpSetNoDelayFunction : public TCPSocketAsyncApiFunction {
@@ -128,7 +128,7 @@ class SocketsTcpSetNoDelayFunction : public TCPSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<sockets_tcp::SetNoDelay::Params> params_;
+ std::unique_ptr<sockets_tcp::SetNoDelay::Params> params_;
};
class SocketsTcpConnectFunction
@@ -152,7 +152,7 @@ class SocketsTcpConnectFunction
void StartConnect();
void OnCompleted(int net_result);
- scoped_ptr<sockets_tcp::Connect::Params> params_;
+ std::unique_ptr<sockets_tcp::Connect::Params> params_;
TCPSocketEventDispatcher* socket_event_dispatcher_;
};
@@ -170,7 +170,7 @@ class SocketsTcpDisconnectFunction : public TCPSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<sockets_tcp::Disconnect::Params> params_;
+ std::unique_ptr<sockets_tcp::Disconnect::Params> params_;
};
class SocketsTcpSendFunction : public TCPSocketAsyncApiFunction {
@@ -190,7 +190,7 @@ class SocketsTcpSendFunction : public TCPSocketAsyncApiFunction {
void OnCompleted(int net_result);
void SetSendResult(int net_result, int bytes_sent);
- scoped_ptr<sockets_tcp::Send::Params> params_;
+ std::unique_ptr<sockets_tcp::Send::Params> params_;
scoped_refptr<net::IOBuffer> io_buffer_;
size_t io_buffer_size_;
};
@@ -209,7 +209,7 @@ class SocketsTcpCloseFunction : public TCPSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<sockets_tcp::Close::Params> params_;
+ std::unique_ptr<sockets_tcp::Close::Params> params_;
};
class SocketsTcpGetInfoFunction : public TCPSocketAsyncApiFunction {
@@ -226,7 +226,7 @@ class SocketsTcpGetInfoFunction : public TCPSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<sockets_tcp::GetInfo::Params> params_;
+ std::unique_ptr<sockets_tcp::GetInfo::Params> params_;
};
class SocketsTcpGetSocketsFunction : public TCPSocketAsyncApiFunction {
@@ -255,12 +255,12 @@ class SocketsTcpSecureFunction : public TCPSocketAsyncApiFunction {
void AsyncWorkStart() override;
private:
- virtual void TlsConnectDone(scoped_ptr<extensions::TLSSocket> sock,
+ virtual void TlsConnectDone(std::unique_ptr<extensions::TLSSocket> sock,
int result);
bool paused_;
bool persistent_;
- scoped_ptr<sockets_tcp::Secure::Params> params_;
+ std::unique_ptr<sockets_tcp::Secure::Params> params_;
scoped_refptr<net::URLRequestContextGetter> url_request_getter_;
DISALLOW_COPY_AND_ASSIGN(SocketsTcpSecureFunction);
diff --git a/chromium/extensions/browser/api/sockets_tcp/sockets_tcp_api_unittest.cc b/chromium/extensions/browser/api/sockets_tcp/sockets_tcp_api_unittest.cc
index 83c9faeaa39..fa52b9d5ee9 100644
--- a/chromium/extensions/browser/api/sockets_tcp/sockets_tcp_api_unittest.cc
+++ b/chromium/extensions/browser/api/sockets_tcp/sockets_tcp_api_unittest.cc
@@ -2,13 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/memory/scoped_ptr.h"
+#include "extensions/browser/api/sockets_tcp/sockets_tcp_api.h"
+
+#include <memory>
+
+#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "content/public/test/test_browser_context.h"
#include "extensions/browser/api/api_resource_manager.h"
#include "extensions/browser/api/socket/socket.h"
#include "extensions/browser/api/socket/tcp_socket.h"
-#include "extensions/browser/api/sockets_tcp/sockets_tcp_api.h"
#include "extensions/browser/api_unittest.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -16,9 +19,9 @@
namespace extensions {
namespace api {
-static scoped_ptr<KeyedService> ApiResourceManagerTestFactory(
+static std::unique_ptr<KeyedService> ApiResourceManagerTestFactory(
content::BrowserContext* context) {
- return make_scoped_ptr(new ApiResourceManager<ResumableTCPSocket>(context));
+ return base::WrapUnique(new ApiResourceManager<ResumableTCPSocket>(context));
}
class SocketsTcpUnitTest : public ApiUnitTest {
@@ -42,7 +45,7 @@ TEST_F(SocketsTcpUnitTest, Create) {
function->set_work_thread_id(id);
// Run tests
- scoped_ptr<base::DictionaryValue> result(RunFunctionAndReturnDictionary(
+ std::unique_ptr<base::DictionaryValue> result(RunFunctionAndReturnDictionary(
function, "[{\"persistent\": true, \"name\": \"foo\"}]"));
ASSERT_TRUE(result.get());
}
diff --git a/chromium/extensions/browser/api/sockets_tcp/sockets_tcp_apitest.cc b/chromium/extensions/browser/api/sockets_tcp/sockets_tcp_apitest.cc
index f11908d4979..bb5665f333a 100644
--- a/chromium/extensions/browser/api/sockets_tcp/sockets_tcp_apitest.cc
+++ b/chromium/extensions/browser/api/sockets_tcp/sockets_tcp_apitest.cc
@@ -60,12 +60,12 @@ IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketsTcpCreateGood) {
socket_create_function->set_extension(empty_extension.get());
socket_create_function->set_has_callback(true);
- scoped_ptr<base::Value> result(
+ std::unique_ptr<base::Value> result(
api_test_utils::RunFunctionAndReturnSingleResult(
socket_create_function.get(), "[]", browser_context()));
ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType());
- scoped_ptr<base::DictionaryValue> value =
+ std::unique_ptr<base::DictionaryValue> value =
base::DictionaryValue::From(std::move(result));
int socketId = -1;
EXPECT_TRUE(value->GetInteger("socketId", &socketId));
@@ -73,9 +73,11 @@ IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketsTcpCreateGood) {
}
IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketTcpExtension) {
- scoped_ptr<net::SpawnedTestServer> test_server(new net::SpawnedTestServer(
- net::SpawnedTestServer::TYPE_TCP_ECHO, net::SpawnedTestServer::kLocalhost,
- base::FilePath(FILE_PATH_LITERAL("net/data"))));
+ std::unique_ptr<net::SpawnedTestServer> test_server(
+ new net::SpawnedTestServer(
+ net::SpawnedTestServer::TYPE_TCP_ECHO,
+ net::SpawnedTestServer::kLocalhost,
+ base::FilePath(FILE_PATH_LITERAL("net/data"))));
EXPECT_TRUE(test_server->Start());
net::HostPortPair host_port_pair = test_server->host_port_pair();
@@ -99,7 +101,7 @@ IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketTcpExtension) {
}
IN_PROC_BROWSER_TEST_F(SocketsTcpApiTest, SocketTcpExtensionTLS) {
- scoped_ptr<net::SpawnedTestServer> test_https_server(
+ std::unique_ptr<net::SpawnedTestServer> test_https_server(
new net::SpawnedTestServer(
net::SpawnedTestServer::TYPE_HTTPS, net::BaseTestServer::SSLOptions(),
base::FilePath(FILE_PATH_LITERAL("net/data"))));
diff --git a/chromium/extensions/browser/api/sockets_tcp/tcp_socket_event_dispatcher.cc b/chromium/extensions/browser/api/sockets_tcp/tcp_socket_event_dispatcher.cc
index 7d2f2ca46cf..205593a2562 100644
--- a/chromium/extensions/browser/api/sockets_tcp/tcp_socket_event_dispatcher.cc
+++ b/chromium/extensions/browser/api/sockets_tcp/tcp_socket_event_dispatcher.cc
@@ -134,11 +134,11 @@ void TCPSocketEventDispatcher::ReadCallback(
sockets_tcp::ReceiveInfo receive_info;
receive_info.socket_id = params.socket_id;
receive_info.data.assign(io_buffer->data(), io_buffer->data() + bytes_read);
- scoped_ptr<base::ListValue> args =
+ std::unique_ptr<base::ListValue> args =
sockets_tcp::OnReceive::Create(receive_info);
- scoped_ptr<Event> event(new Event(events::SOCKETS_TCP_ON_RECEIVE,
- sockets_tcp::OnReceive::kEventName,
- std::move(args)));
+ std::unique_ptr<Event> event(new Event(events::SOCKETS_TCP_ON_RECEIVE,
+ sockets_tcp::OnReceive::kEventName,
+ std::move(args)));
PostEvent(params, std::move(event));
// Post a task to delay the read until the socket is available, as
@@ -156,11 +156,11 @@ void TCPSocketEventDispatcher::ReadCallback(
sockets_tcp::ReceiveErrorInfo receive_error_info;
receive_error_info.socket_id = params.socket_id;
receive_error_info.result_code = bytes_read;
- scoped_ptr<base::ListValue> args =
+ std::unique_ptr<base::ListValue> args =
sockets_tcp::OnReceiveError::Create(receive_error_info);
- scoped_ptr<Event> event(new Event(events::SOCKETS_TCP_ON_RECEIVE_ERROR,
- sockets_tcp::OnReceiveError::kEventName,
- std::move(args)));
+ std::unique_ptr<Event> event(
+ new Event(events::SOCKETS_TCP_ON_RECEIVE_ERROR,
+ sockets_tcp::OnReceiveError::kEventName, std::move(args)));
PostEvent(params, std::move(event));
// Since we got an error, the socket is now "paused" until the application
@@ -175,7 +175,7 @@ void TCPSocketEventDispatcher::ReadCallback(
// static
void TCPSocketEventDispatcher::PostEvent(const ReadParams& params,
- scoped_ptr<Event> event) {
+ std::unique_ptr<Event> event) {
DCHECK_CURRENTLY_ON(params.thread_id);
BrowserThread::PostTask(
@@ -187,7 +187,7 @@ void TCPSocketEventDispatcher::PostEvent(const ReadParams& params,
// static
void TCPSocketEventDispatcher::DispatchEvent(void* browser_context_id,
const std::string& extension_id,
- scoped_ptr<Event> event) {
+ std::unique_ptr<Event> event) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
content::BrowserContext* context =
diff --git a/chromium/extensions/browser/api/sockets_tcp/tcp_socket_event_dispatcher.h b/chromium/extensions/browser/api/sockets_tcp/tcp_socket_event_dispatcher.h
index 0c90980fb5e..be933113073 100644
--- a/chromium/extensions/browser/api/sockets_tcp/tcp_socket_event_dispatcher.h
+++ b/chromium/extensions/browser/api/sockets_tcp/tcp_socket_event_dispatcher.h
@@ -78,12 +78,12 @@ class TCPSocketEventDispatcher
scoped_refptr<net::IOBuffer> io_buffer);
// Post an extension event from IO to UI thread
- static void PostEvent(const ReadParams& params, scoped_ptr<Event> event);
+ static void PostEvent(const ReadParams& params, std::unique_ptr<Event> event);
// Dispatch an extension event on to EventRouter instance on UI thread.
static void DispatchEvent(void* browser_context_id,
const std::string& extension_id,
- scoped_ptr<Event> event);
+ std::unique_ptr<Event> event);
// Usually IO thread (except for unit testing).
content::BrowserThread::ID thread_id_;
diff --git a/chromium/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.cc b/chromium/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.cc
index bc39c83fe88..87b332a60c4 100644
--- a/chromium/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.cc
+++ b/chromium/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.cc
@@ -62,9 +62,9 @@ namespace api {
TCPServerSocketAsyncApiFunction::~TCPServerSocketAsyncApiFunction() {}
-scoped_ptr<SocketResourceManagerInterface>
+std::unique_ptr<SocketResourceManagerInterface>
TCPServerSocketAsyncApiFunction::CreateSocketResourceManager() {
- return scoped_ptr<SocketResourceManagerInterface>(
+ return std::unique_ptr<SocketResourceManagerInterface>(
new SocketResourceManager<ResumableTCPServerSocket>());
}
diff --git a/chromium/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.h b/chromium/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.h
index a125b283ebd..b5f93c633c4 100644
--- a/chromium/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.h
+++ b/chromium/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.h
@@ -20,7 +20,7 @@ class TCPServerSocketAsyncApiFunction : public SocketAsyncApiFunction {
protected:
~TCPServerSocketAsyncApiFunction() override;
- scoped_ptr<SocketResourceManagerInterface> CreateSocketResourceManager()
+ std::unique_ptr<SocketResourceManagerInterface> CreateSocketResourceManager()
override;
ResumableTCPServerSocket* GetTcpSocket(int socket_id);
@@ -42,7 +42,7 @@ class SocketsTcpServerCreateFunction : public TCPServerSocketAsyncApiFunction {
private:
FRIEND_TEST_ALL_PREFIXES(SocketsTcpServerUnitTest, Create);
- scoped_ptr<sockets_tcp_server::Create::Params> params_;
+ std::unique_ptr<sockets_tcp_server::Create::Params> params_;
};
class SocketsTcpServerUpdateFunction : public TCPServerSocketAsyncApiFunction {
@@ -60,7 +60,7 @@ class SocketsTcpServerUpdateFunction : public TCPServerSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<sockets_tcp_server::Update::Params> params_;
+ std::unique_ptr<sockets_tcp_server::Update::Params> params_;
};
class SocketsTcpServerSetPausedFunction
@@ -79,7 +79,7 @@ class SocketsTcpServerSetPausedFunction
void Work() override;
private:
- scoped_ptr<sockets_tcp_server::SetPaused::Params> params_;
+ std::unique_ptr<sockets_tcp_server::SetPaused::Params> params_;
TCPServerSocketEventDispatcher* socket_event_dispatcher_;
};
@@ -98,7 +98,7 @@ class SocketsTcpServerListenFunction : public TCPServerSocketAsyncApiFunction {
void AsyncWorkStart() override;
private:
- scoped_ptr<sockets_tcp_server::Listen::Params> params_;
+ std::unique_ptr<sockets_tcp_server::Listen::Params> params_;
TCPServerSocketEventDispatcher* socket_event_dispatcher_;
};
@@ -118,7 +118,7 @@ class SocketsTcpServerDisconnectFunction
void Work() override;
private:
- scoped_ptr<sockets_tcp_server::Disconnect::Params> params_;
+ std::unique_ptr<sockets_tcp_server::Disconnect::Params> params_;
};
class SocketsTcpServerCloseFunction : public TCPServerSocketAsyncApiFunction {
@@ -136,7 +136,7 @@ class SocketsTcpServerCloseFunction : public TCPServerSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<sockets_tcp_server::Close::Params> params_;
+ std::unique_ptr<sockets_tcp_server::Close::Params> params_;
};
class SocketsTcpServerGetInfoFunction : public TCPServerSocketAsyncApiFunction {
@@ -154,7 +154,7 @@ class SocketsTcpServerGetInfoFunction : public TCPServerSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<sockets_tcp_server::GetInfo::Params> params_;
+ std::unique_ptr<sockets_tcp_server::GetInfo::Params> params_;
};
class SocketsTcpServerGetSocketsFunction
diff --git a/chromium/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_apitest.cc b/chromium/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_apitest.cc
index c54724ba7c5..cff342458a8 100644
--- a/chromium/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_apitest.cc
+++ b/chromium/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_apitest.cc
@@ -59,11 +59,11 @@ IN_PROC_BROWSER_TEST_F(SocketsTcpServerApiTest, SocketTCPCreateGood) {
socket_create_function->set_extension(empty_extension.get());
socket_create_function->set_has_callback(true);
- scoped_ptr<base::Value> result(
+ std::unique_ptr<base::Value> result(
api_test_utils::RunFunctionAndReturnSingleResult(
socket_create_function.get(), "[]", browser_context()));
ASSERT_EQ(base::Value::TYPE_DICTIONARY, result->GetType());
- scoped_ptr<base::DictionaryValue> value =
+ std::unique_ptr<base::DictionaryValue> value =
base::DictionaryValue::From(std::move(result));
int socketId = -1;
EXPECT_TRUE(value->GetInteger("socketId", &socketId));
diff --git a/chromium/extensions/browser/api/sockets_tcp_server/tcp_server_socket_event_dispatcher.cc b/chromium/extensions/browser/api/sockets_tcp_server/tcp_server_socket_event_dispatcher.cc
index a43d6be185f..a8d8adeacae 100644
--- a/chromium/extensions/browser/api/sockets_tcp_server/tcp_server_socket_event_dispatcher.cc
+++ b/chromium/extensions/browser/api/sockets_tcp_server/tcp_server_socket_event_dispatcher.cc
@@ -124,7 +124,7 @@ void TCPServerSocketEventDispatcher::StartAccept(const AcceptParams& params) {
void TCPServerSocketEventDispatcher::AcceptCallback(
const AcceptParams& params,
int result_code,
- scoped_ptr<net::TCPClientSocket> socket) {
+ std::unique_ptr<net::TCPClientSocket> socket) {
DCHECK_CURRENTLY_ON(params.thread_id);
if (result_code >= 0) {
@@ -137,11 +137,11 @@ void TCPServerSocketEventDispatcher::AcceptCallback(
sockets_tcp_server::AcceptInfo accept_info;
accept_info.socket_id = params.socket_id;
accept_info.client_socket_id = client_socket_id;
- scoped_ptr<base::ListValue> args =
+ std::unique_ptr<base::ListValue> args =
sockets_tcp_server::OnAccept::Create(accept_info);
- scoped_ptr<Event> event(new Event(events::SOCKETS_TCP_SERVER_ON_ACCEPT,
- sockets_tcp_server::OnAccept::kEventName,
- std::move(args)));
+ std::unique_ptr<Event> event(
+ new Event(events::SOCKETS_TCP_SERVER_ON_ACCEPT,
+ sockets_tcp_server::OnAccept::kEventName, std::move(args)));
PostEvent(params, std::move(event));
// Post a task to delay the "accept" until the socket is available, as
@@ -156,9 +156,9 @@ void TCPServerSocketEventDispatcher::AcceptCallback(
sockets_tcp_server::AcceptErrorInfo accept_error_info;
accept_error_info.socket_id = params.socket_id;
accept_error_info.result_code = result_code;
- scoped_ptr<base::ListValue> args =
+ std::unique_ptr<base::ListValue> args =
sockets_tcp_server::OnAcceptError::Create(accept_error_info);
- scoped_ptr<Event> event(new Event(
+ std::unique_ptr<Event> event(new Event(
events::SOCKETS_TCP_SERVER_ON_ACCEPT_ERROR,
sockets_tcp_server::OnAcceptError::kEventName, std::move(args)));
PostEvent(params, std::move(event));
@@ -175,7 +175,7 @@ void TCPServerSocketEventDispatcher::AcceptCallback(
// static
void TCPServerSocketEventDispatcher::PostEvent(const AcceptParams& params,
- scoped_ptr<Event> event) {
+ std::unique_ptr<Event> event) {
DCHECK_CURRENTLY_ON(params.thread_id);
BrowserThread::PostTask(
@@ -188,7 +188,7 @@ void TCPServerSocketEventDispatcher::PostEvent(const AcceptParams& params,
void TCPServerSocketEventDispatcher::DispatchEvent(
void* browser_context_id,
const std::string& extension_id,
- scoped_ptr<Event> event) {
+ std::unique_ptr<Event> event) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
content::BrowserContext* context =
diff --git a/chromium/extensions/browser/api/sockets_tcp_server/tcp_server_socket_event_dispatcher.h b/chromium/extensions/browser/api/sockets_tcp_server/tcp_server_socket_event_dispatcher.h
index e792b829cde..13aa0e2bc58 100644
--- a/chromium/extensions/browser/api/sockets_tcp_server/tcp_server_socket_event_dispatcher.h
+++ b/chromium/extensions/browser/api/sockets_tcp_server/tcp_server_socket_event_dispatcher.h
@@ -78,15 +78,16 @@ class TCPServerSocketEventDispatcher
// Called when socket accepts a new connection.
static void AcceptCallback(const AcceptParams& params,
int result_code,
- scoped_ptr<net::TCPClientSocket> socket);
+ std::unique_ptr<net::TCPClientSocket> socket);
// Post an extension event from |thread_id| to UI thread
- static void PostEvent(const AcceptParams& params, scoped_ptr<Event> event);
+ static void PostEvent(const AcceptParams& params,
+ std::unique_ptr<Event> event);
// Dispatch an extension event on to EventRouter instance on UI thread.
static void DispatchEvent(void* browser_context_id,
const std::string& extension_id,
- scoped_ptr<Event> event);
+ std::unique_ptr<Event> event);
// Usually IO thread (except for unit testing).
content::BrowserThread::ID thread_id_;
diff --git a/chromium/extensions/browser/api/sockets_udp/sockets_udp_api.cc b/chromium/extensions/browser/api/sockets_udp/sockets_udp_api.cc
index dfefb738ce8..9e2e607a4bd 100644
--- a/chromium/extensions/browser/api/sockets_udp/sockets_udp_api.cc
+++ b/chromium/extensions/browser/api/sockets_udp/sockets_udp_api.cc
@@ -22,9 +22,9 @@ const int kWildcardPort = 0;
UDPSocketAsyncApiFunction::~UDPSocketAsyncApiFunction() {}
-scoped_ptr<SocketResourceManagerInterface>
+std::unique_ptr<SocketResourceManagerInterface>
UDPSocketAsyncApiFunction::CreateSocketResourceManager() {
- return scoped_ptr<SocketResourceManagerInterface>(
+ return std::unique_ptr<SocketResourceManagerInterface>(
new SocketResourceManager<ResumableUDPSocket>());
}
@@ -35,9 +35,9 @@ ResumableUDPSocket* UDPSocketAsyncApiFunction::GetUdpSocket(int socket_id) {
UDPSocketExtensionWithDnsLookupFunction::
~UDPSocketExtensionWithDnsLookupFunction() {}
-scoped_ptr<SocketResourceManagerInterface>
+std::unique_ptr<SocketResourceManagerInterface>
UDPSocketExtensionWithDnsLookupFunction::CreateSocketResourceManager() {
- return scoped_ptr<SocketResourceManagerInterface>(
+ return std::unique_ptr<SocketResourceManagerInterface>(
new SocketResourceManager<ResumableUDPSocket>());
}
diff --git a/chromium/extensions/browser/api/sockets_udp/sockets_udp_api.h b/chromium/extensions/browser/api/sockets_udp/sockets_udp_api.h
index 3ade564eb91..27ee801af2a 100644
--- a/chromium/extensions/browser/api/sockets_udp/sockets_udp_api.h
+++ b/chromium/extensions/browser/api/sockets_udp/sockets_udp_api.h
@@ -24,7 +24,7 @@ class UDPSocketAsyncApiFunction : public SocketAsyncApiFunction {
protected:
~UDPSocketAsyncApiFunction() override;
- scoped_ptr<SocketResourceManagerInterface> CreateSocketResourceManager()
+ std::unique_ptr<SocketResourceManagerInterface> CreateSocketResourceManager()
override;
ResumableUDPSocket* GetUdpSocket(int socket_id);
@@ -35,7 +35,7 @@ class UDPSocketExtensionWithDnsLookupFunction
protected:
~UDPSocketExtensionWithDnsLookupFunction() override;
- scoped_ptr<SocketResourceManagerInterface> CreateSocketResourceManager()
+ std::unique_ptr<SocketResourceManagerInterface> CreateSocketResourceManager()
override;
ResumableUDPSocket* GetUdpSocket(int socket_id);
@@ -56,7 +56,7 @@ class SocketsUdpCreateFunction : public UDPSocketAsyncApiFunction {
private:
FRIEND_TEST_ALL_PREFIXES(SocketsUdpUnitTest, Create);
- scoped_ptr<sockets_udp::Create::Params> params_;
+ std::unique_ptr<sockets_udp::Create::Params> params_;
};
class SocketsUdpUpdateFunction : public UDPSocketAsyncApiFunction {
@@ -73,7 +73,7 @@ class SocketsUdpUpdateFunction : public UDPSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<sockets_udp::Update::Params> params_;
+ std::unique_ptr<sockets_udp::Update::Params> params_;
};
class SocketsUdpSetPausedFunction : public UDPSocketAsyncApiFunction {
@@ -90,7 +90,7 @@ class SocketsUdpSetPausedFunction : public UDPSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<sockets_udp::SetPaused::Params> params_;
+ std::unique_ptr<sockets_udp::SetPaused::Params> params_;
UDPSocketEventDispatcher* socket_event_dispatcher_;
};
@@ -108,7 +108,7 @@ class SocketsUdpBindFunction : public UDPSocketAsyncApiFunction {
void AsyncWorkStart() override;
private:
- scoped_ptr<sockets_udp::Bind::Params> params_;
+ std::unique_ptr<sockets_udp::Bind::Params> params_;
UDPSocketEventDispatcher* socket_event_dispatcher_;
};
@@ -133,7 +133,7 @@ class SocketsUdpSendFunction : public UDPSocketExtensionWithDnsLookupFunction {
private:
void StartSendTo();
- scoped_ptr<sockets_udp::Send::Params> params_;
+ std::unique_ptr<sockets_udp::Send::Params> params_;
scoped_refptr<net::IOBuffer> io_buffer_;
size_t io_buffer_size_;
};
@@ -152,7 +152,7 @@ class SocketsUdpCloseFunction : public UDPSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<sockets_udp::Close::Params> params_;
+ std::unique_ptr<sockets_udp::Close::Params> params_;
};
class SocketsUdpGetInfoFunction : public UDPSocketAsyncApiFunction {
@@ -169,7 +169,7 @@ class SocketsUdpGetInfoFunction : public UDPSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<sockets_udp::GetInfo::Params> params_;
+ std::unique_ptr<sockets_udp::GetInfo::Params> params_;
};
class SocketsUdpGetSocketsFunction : public UDPSocketAsyncApiFunction {
@@ -200,7 +200,7 @@ class SocketsUdpJoinGroupFunction : public UDPSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<sockets_udp::JoinGroup::Params> params_;
+ std::unique_ptr<sockets_udp::JoinGroup::Params> params_;
};
class SocketsUdpLeaveGroupFunction : public UDPSocketAsyncApiFunction {
@@ -217,7 +217,7 @@ class SocketsUdpLeaveGroupFunction : public UDPSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<sockets_udp::LeaveGroup::Params> params_;
+ std::unique_ptr<sockets_udp::LeaveGroup::Params> params_;
};
class SocketsUdpSetMulticastTimeToLiveFunction
@@ -236,7 +236,7 @@ class SocketsUdpSetMulticastTimeToLiveFunction
void Work() override;
private:
- scoped_ptr<sockets_udp::SetMulticastTimeToLive::Params> params_;
+ std::unique_ptr<sockets_udp::SetMulticastTimeToLive::Params> params_;
};
class SocketsUdpSetMulticastLoopbackModeFunction
@@ -255,7 +255,7 @@ class SocketsUdpSetMulticastLoopbackModeFunction
void Work() override;
private:
- scoped_ptr<sockets_udp::SetMulticastLoopbackMode::Params> params_;
+ std::unique_ptr<sockets_udp::SetMulticastLoopbackMode::Params> params_;
};
class SocketsUdpGetJoinedGroupsFunction : public UDPSocketAsyncApiFunction {
@@ -273,7 +273,7 @@ class SocketsUdpGetJoinedGroupsFunction : public UDPSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<sockets_udp::GetJoinedGroups::Params> params_;
+ std::unique_ptr<sockets_udp::GetJoinedGroups::Params> params_;
};
class SocketsUdpSetBroadcastFunction : public UDPSocketAsyncApiFunction {
@@ -291,7 +291,7 @@ class SocketsUdpSetBroadcastFunction : public UDPSocketAsyncApiFunction {
void Work() override;
private:
- scoped_ptr<sockets_udp::SetBroadcast::Params> params_;
+ std::unique_ptr<sockets_udp::SetBroadcast::Params> params_;
};
} // namespace api
diff --git a/chromium/extensions/browser/api/sockets_udp/sockets_udp_api_unittest.cc b/chromium/extensions/browser/api/sockets_udp/sockets_udp_api_unittest.cc
index ebba7bcc1a9..5d4e4b49934 100644
--- a/chromium/extensions/browser/api/sockets_udp/sockets_udp_api_unittest.cc
+++ b/chromium/extensions/browser/api/sockets_udp/sockets_udp_api_unittest.cc
@@ -2,12 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/memory/scoped_ptr.h"
+#include "extensions/browser/api/sockets_udp/sockets_udp_api.h"
+
+#include <memory>
+
+#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "extensions/browser/api/api_resource_manager.h"
#include "extensions/browser/api/socket/socket.h"
#include "extensions/browser/api/socket/udp_socket.h"
-#include "extensions/browser/api/sockets_udp/sockets_udp_api.h"
#include "extensions/browser/api_unittest.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -15,9 +18,9 @@
namespace extensions {
namespace api {
-static scoped_ptr<KeyedService> ApiResourceManagerTestFactory(
+static std::unique_ptr<KeyedService> ApiResourceManagerTestFactory(
content::BrowserContext* context) {
- return make_scoped_ptr(new ApiResourceManager<ResumableUDPSocket>(context));
+ return base::WrapUnique(new ApiResourceManager<ResumableUDPSocket>(context));
}
class SocketsUdpUnitTest : public ApiUnitTest {
@@ -41,7 +44,7 @@ TEST_F(SocketsUdpUnitTest, Create) {
function->set_work_thread_id(id);
// Run tests
- scoped_ptr<base::DictionaryValue> result(RunFunctionAndReturnDictionary(
+ std::unique_ptr<base::DictionaryValue> result(RunFunctionAndReturnDictionary(
function, "[{\"persistent\": true, \"name\": \"foo\"}]"));
ASSERT_TRUE(result.get());
}
diff --git a/chromium/extensions/browser/api/sockets_udp/sockets_udp_apitest.cc b/chromium/extensions/browser/api/sockets_udp/sockets_udp_apitest.cc
index 85cbfffdb89..a602d41da6e 100644
--- a/chromium/extensions/browser/api/sockets_udp/sockets_udp_apitest.cc
+++ b/chromium/extensions/browser/api/sockets_udp/sockets_udp_apitest.cc
@@ -59,7 +59,7 @@ IN_PROC_BROWSER_TEST_F(SocketsUdpApiTest, SocketsUdpCreateGood) {
socket_create_function->set_extension(empty_extension.get());
socket_create_function->set_has_callback(true);
- scoped_ptr<base::Value> result(
+ std::unique_ptr<base::Value> result(
api_test_utils::RunFunctionAndReturnSingleResult(
socket_create_function.get(), "[]", browser_context()));
@@ -71,9 +71,11 @@ IN_PROC_BROWSER_TEST_F(SocketsUdpApiTest, SocketsUdpCreateGood) {
}
IN_PROC_BROWSER_TEST_F(SocketsUdpApiTest, SocketsUdpExtension) {
- scoped_ptr<net::SpawnedTestServer> test_server(new net::SpawnedTestServer(
- net::SpawnedTestServer::TYPE_UDP_ECHO, net::SpawnedTestServer::kLocalhost,
- base::FilePath(FILE_PATH_LITERAL("net/data"))));
+ std::unique_ptr<net::SpawnedTestServer> test_server(
+ new net::SpawnedTestServer(
+ net::SpawnedTestServer::TYPE_UDP_ECHO,
+ net::SpawnedTestServer::kLocalhost,
+ base::FilePath(FILE_PATH_LITERAL("net/data"))));
EXPECT_TRUE(test_server->Start());
net::HostPortPair host_port_pair = test_server->host_port_pair();
diff --git a/chromium/extensions/browser/api/sockets_udp/udp_socket_event_dispatcher.cc b/chromium/extensions/browser/api/sockets_udp/udp_socket_event_dispatcher.cc
index 07e2a22f929..33f3fc7e910 100644
--- a/chromium/extensions/browser/api/sockets_udp/udp_socket_event_dispatcher.cc
+++ b/chromium/extensions/browser/api/sockets_udp/udp_socket_event_dispatcher.cc
@@ -119,11 +119,11 @@ void UDPSocketEventDispatcher::ReceiveCallback(
receive_info.data.assign(io_buffer->data(), io_buffer->data() + bytes_read);
receive_info.remote_address = address;
receive_info.remote_port = port;
- scoped_ptr<base::ListValue> args =
+ std::unique_ptr<base::ListValue> args =
sockets_udp::OnReceive::Create(receive_info);
- scoped_ptr<Event> event(new Event(events::SOCKETS_UDP_ON_RECEIVE,
- sockets_udp::OnReceive::kEventName,
- std::move(args)));
+ std::unique_ptr<Event> event(new Event(events::SOCKETS_UDP_ON_RECEIVE,
+ sockets_udp::OnReceive::kEventName,
+ std::move(args)));
PostEvent(params, std::move(event));
// Post a task to delay the read until the socket is available, as
@@ -141,11 +141,11 @@ void UDPSocketEventDispatcher::ReceiveCallback(
sockets_udp::ReceiveErrorInfo receive_error_info;
receive_error_info.socket_id = params.socket_id;
receive_error_info.result_code = bytes_read;
- scoped_ptr<base::ListValue> args =
+ std::unique_ptr<base::ListValue> args =
sockets_udp::OnReceiveError::Create(receive_error_info);
- scoped_ptr<Event> event(new Event(events::SOCKETS_UDP_ON_RECEIVE_ERROR,
- sockets_udp::OnReceiveError::kEventName,
- std::move(args)));
+ std::unique_ptr<Event> event(
+ new Event(events::SOCKETS_UDP_ON_RECEIVE_ERROR,
+ sockets_udp::OnReceiveError::kEventName, std::move(args)));
PostEvent(params, std::move(event));
// Since we got an error, the socket is now "paused" until the application
@@ -160,7 +160,7 @@ void UDPSocketEventDispatcher::ReceiveCallback(
/* static */
void UDPSocketEventDispatcher::PostEvent(const ReceiveParams& params,
- scoped_ptr<Event> event) {
+ std::unique_ptr<Event> event) {
DCHECK_CURRENTLY_ON(params.thread_id);
BrowserThread::PostTask(
@@ -172,7 +172,7 @@ void UDPSocketEventDispatcher::PostEvent(const ReceiveParams& params,
/*static*/
void UDPSocketEventDispatcher::DispatchEvent(void* browser_context_id,
const std::string& extension_id,
- scoped_ptr<Event> event) {
+ std::unique_ptr<Event> event) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
content::BrowserContext* context =
diff --git a/chromium/extensions/browser/api/sockets_udp/udp_socket_event_dispatcher.h b/chromium/extensions/browser/api/sockets_udp/udp_socket_event_dispatcher.h
index ff8f111c295..dcc8b397054 100644
--- a/chromium/extensions/browser/api/sockets_udp/udp_socket_event_dispatcher.h
+++ b/chromium/extensions/browser/api/sockets_udp/udp_socket_event_dispatcher.h
@@ -79,12 +79,13 @@ class UDPSocketEventDispatcher
uint16_t port);
// Post an extension event from IO to UI thread
- static void PostEvent(const ReceiveParams& params, scoped_ptr<Event> event);
+ static void PostEvent(const ReceiveParams& params,
+ std::unique_ptr<Event> event);
// Dispatch an extension event on to EventRouter instance on UI thread.
static void DispatchEvent(void* browser_context_id,
const std::string& extension_id,
- scoped_ptr<Event> event);
+ std::unique_ptr<Event> event);
// Usually IO thread (except for unit testing).
content::BrowserThread::ID thread_id_;
diff --git a/chromium/extensions/browser/api/storage/local_value_store_cache.cc b/chromium/extensions/browser/api/storage/local_value_store_cache.cc
index 920d1305db3..5a941185b72 100644
--- a/chromium/extensions/browser/api/storage/local_value_store_cache.cc
+++ b/chromium/extensions/browser/api/storage/local_value_store_cache.cc
@@ -78,7 +78,7 @@ ValueStore* LocalValueStoreCache::GetStorage(const Extension* extension) {
ValueStoreFactory::ModelType model_type =
extension->is_app() ? ValueStoreFactory::ModelType::APP
: ValueStoreFactory::ModelType::EXTENSION;
- scoped_ptr<ValueStore> store = storage_factory_->CreateSettingsStore(
+ std::unique_ptr<ValueStore> store = storage_factory_->CreateSettingsStore(
settings_namespace::LOCAL, model_type, extension->id());
linked_ptr<SettingsStorageQuotaEnforcer> storage(
new SettingsStorageQuotaEnforcer(quota_, std::move(store)));
diff --git a/chromium/extensions/browser/api/storage/local_value_store_cache.h b/chromium/extensions/browser/api/storage/local_value_store_cache.h
index c3303a5ef66..b125bbb3006 100644
--- a/chromium/extensions/browser/api/storage/local_value_store_cache.h
+++ b/chromium/extensions/browser/api/storage/local_value_store_cache.h
@@ -5,11 +5,12 @@
#ifndef EXTENSIONS_BROWSER_API_STORAGE_LOCAL_VALUE_STORE_CACHE_H_
#define EXTENSIONS_BROWSER_API_STORAGE_LOCAL_VALUE_STORE_CACHE_H_
+#include <memory>
+
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/browser/api/storage/settings_storage_quota_enforcer.h"
#include "extensions/browser/api/storage/value_store_cache.h"
diff --git a/chromium/extensions/browser/api/storage/settings_quota_unittest.cc b/chromium/extensions/browser/api/storage/settings_quota_unittest.cc
index 3681401a49c..b431df5182f 100644
--- a/chromium/extensions/browser/api/storage/settings_quota_unittest.cc
+++ b/chromium/extensions/browser/api/storage/settings_quota_unittest.cc
@@ -4,9 +4,11 @@
#include <stddef.h>
+#include <memory>
+
#include "base/json/json_writer.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "extensions/browser/api/storage/settings_storage_quota_enforcer.h"
#include "extensions/browser/value_store/testing_value_store.h"
@@ -55,7 +57,7 @@ class ExtensionSettingsQuotaTest : public testing::Test {
SettingsStorageQuotaEnforcer::Limits limits =
{ quota_bytes, quota_bytes_per_item, max_items };
storage_.reset(
- new SettingsStorageQuotaEnforcer(limits, make_scoped_ptr(delegate_)));
+ new SettingsStorageQuotaEnforcer(limits, base::WrapUnique(delegate_)));
}
// Returns whether the settings in |storage_| and |delegate_| are the same as
@@ -71,7 +73,7 @@ class ExtensionSettingsQuotaTest : public testing::Test {
base::ListValue byte_value_256_;
// Quota enforcing storage area being tested.
- scoped_ptr<SettingsStorageQuotaEnforcer> storage_;
+ std::unique_ptr<SettingsStorageQuotaEnforcer> storage_;
// In-memory storage area being delegated to. Always owned by |storage_|.
TestingValueStore* delegate_;
diff --git a/chromium/extensions/browser/api/storage/settings_storage_quota_enforcer.cc b/chromium/extensions/browser/api/storage/settings_storage_quota_enforcer.cc
index 7d3703cd4db..d4e9e699b8f 100644
--- a/chromium/extensions/browser/api/storage/settings_storage_quota_enforcer.cc
+++ b/chromium/extensions/browser/api/storage/settings_storage_quota_enforcer.cc
@@ -4,9 +4,10 @@
#include "extensions/browser/api/storage/settings_storage_quota_enforcer.h"
+#include <memory>
+
#include "base/bind.h"
#include "base/json/json_writer.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/stl_util.h"
@@ -72,7 +73,7 @@ ValueStore::Status QuotaExceededError(Resource resource) {
SettingsStorageQuotaEnforcer::SettingsStorageQuotaEnforcer(
const Limits& limits,
- scoped_ptr<ValueStore> delegate)
+ std::unique_ptr<ValueStore> delegate)
: limits_(limits),
delegate_(std::move(delegate)),
used_total_(0),
diff --git a/chromium/extensions/browser/api/storage/settings_storage_quota_enforcer.h b/chromium/extensions/browser/api/storage/settings_storage_quota_enforcer.h
index 33de5b7fa13..ae8b511e984 100644
--- a/chromium/extensions/browser/api/storage/settings_storage_quota_enforcer.h
+++ b/chromium/extensions/browser/api/storage/settings_storage_quota_enforcer.h
@@ -8,12 +8,12 @@
#include <stddef.h>
#include <map>
+#include <memory>
#include <string>
#include <vector>
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "extensions/browser/value_store/value_store.h"
@@ -35,7 +35,7 @@ class SettingsStorageQuotaEnforcer : public ValueStore {
};
SettingsStorageQuotaEnforcer(const Limits& limits,
- scoped_ptr<ValueStore> delegate);
+ std::unique_ptr<ValueStore> delegate);
~SettingsStorageQuotaEnforcer() override;
@@ -72,7 +72,7 @@ class SettingsStorageQuotaEnforcer : public ValueStore {
const Limits limits_;
// The delegate storage area.
- scoped_ptr<ValueStore> const delegate_;
+ std::unique_ptr<ValueStore> const delegate_;
// Total bytes in used by |delegate_|. Includes both key lengths and
// JSON-encoded values.
diff --git a/chromium/extensions/browser/api/storage/settings_test_util.cc b/chromium/extensions/browser/api/storage/settings_test_util.cc
index 44425412439..0521d235d95 100644
--- a/chromium/extensions/browser/api/storage/settings_test_util.cc
+++ b/chromium/extensions/browser/api/storage/settings_test_util.cc
@@ -17,21 +17,21 @@ namespace extensions {
namespace settings_test_util {
// Creates a kilobyte of data.
-scoped_ptr<base::Value> CreateKilobyte() {
+std::unique_ptr<base::Value> CreateKilobyte() {
std::string kilobyte_string;
for (int i = 0; i < 1024; ++i) {
kilobyte_string += "a";
}
- return scoped_ptr<base::Value>(new base::StringValue(kilobyte_string));
+ return std::unique_ptr<base::Value>(new base::StringValue(kilobyte_string));
}
// Creates a megabyte of data.
-scoped_ptr<base::Value> CreateMegabyte() {
+std::unique_ptr<base::Value> CreateMegabyte() {
base::ListValue* megabyte = new base::ListValue();
for (int i = 0; i < 1000; ++i) {
megabyte->Append(CreateKilobyte().release());
}
- return scoped_ptr<base::Value>(megabyte);
+ return std::unique_ptr<base::Value>(megabyte);
}
// Intended as a StorageCallback from GetStorage.
@@ -71,7 +71,7 @@ scoped_refptr<const Extension> AddExtensionWithIdAndPermissions(
manifest.SetString("name", std::string("Test extension ") + id);
manifest.SetString("version", "1.0");
- scoped_ptr<base::ListValue> permissions(new base::ListValue());
+ std::unique_ptr<base::ListValue> permissions(new base::ListValue());
for (std::set<std::string>::const_iterator it = permissions_set.begin();
it != permissions_set.end(); ++it) {
permissions->Append(new base::StringValue(*it));
diff --git a/chromium/extensions/browser/api/storage/settings_test_util.h b/chromium/extensions/browser/api/storage/settings_test_util.h
index 07a1d5242e1..a48480b2cff 100644
--- a/chromium/extensions/browser/api/storage/settings_test_util.h
+++ b/chromium/extensions/browser/api/storage/settings_test_util.h
@@ -5,13 +5,13 @@
#ifndef EXTENSIONS_BROWSER_API_STORAGE_SETTINGS_TEST_UTIL_H_
#define EXTENSIONS_BROWSER_API_STORAGE_SETTINGS_TEST_UTIL_H_
+#include <memory>
#include <set>
#include <string>
#include "base/compiler_specific.h"
#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "chrome/test/base/testing_profile.h"
#include "extensions/browser/api/storage/settings_namespace.h"
#include "extensions/browser/event_router.h"
@@ -28,10 +28,10 @@ class StorageFrontend;
namespace settings_test_util {
// Creates a kilobyte of data.
-scoped_ptr<base::Value> CreateKilobyte();
+std::unique_ptr<base::Value> CreateKilobyte();
// Creates a megabyte of data.
-scoped_ptr<base::Value> CreateMegabyte();
+std::unique_ptr<base::Value> CreateMegabyte();
// Synchronously gets the storage area for an extension from |frontend|.
ValueStore* GetStorage(scoped_refptr<const Extension> extension,
diff --git a/chromium/extensions/browser/api/storage/storage_api.cc b/chromium/extensions/browser/api/storage/storage_api.cc
index 16a46b0c37d..4b1928e4711 100644
--- a/chromium/extensions/browser/api/storage/storage_api.cc
+++ b/chromium/extensions/browser/api/storage/storage_api.cc
@@ -11,6 +11,7 @@
#include <vector>
#include "base/bind.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "content/public/browser/browser_thread.h"
@@ -175,7 +176,7 @@ ExtensionFunction::ResponseValue StorageStorageAreaGetFunction::RunWithStorage(
base::DictionaryValue* with_default_values = as_dict->DeepCopy();
with_default_values->MergeDictionary(&result->settings());
return UseReadResult(ValueStore::MakeReadResult(
- make_scoped_ptr(with_default_values), result->status()));
+ base::WrapUnique(with_default_values), result->status()));
}
default:
diff --git a/chromium/extensions/browser/api/storage/storage_api_unittest.cc b/chromium/extensions/browser/api/storage/storage_api_unittest.cc
index 4a013db42a0..5fe71591e61 100644
--- a/chromium/extensions/browser/api/storage/storage_api_unittest.cc
+++ b/chromium/extensions/browser/api/storage/storage_api_unittest.cc
@@ -2,16 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "extensions/browser/api/storage/storage_api.h"
+
+#include <memory>
+
#include "base/command_line.h"
#include "base/files/file_path.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/stringprintf.h"
#include "content/public/test/test_browser_context.h"
#include "extensions/browser/api/extensions_api_client.h"
#include "extensions/browser/api/storage/settings_storage_quota_enforcer.h"
#include "extensions/browser/api/storage/settings_test_util.h"
-#include "extensions/browser/api/storage/storage_api.h"
#include "extensions/browser/api/storage/storage_frontend.h"
#include "extensions/browser/api_unittest.h"
#include "extensions/browser/event_router.h"
@@ -30,15 +33,16 @@ namespace extensions {
namespace {
// Caller owns the returned object.
-scoped_ptr<KeyedService> CreateStorageFrontendForTesting(
+std::unique_ptr<KeyedService> CreateStorageFrontendForTesting(
content::BrowserContext* context) {
scoped_refptr<ValueStoreFactory> factory =
new ValueStoreFactoryImpl(context->GetPath());
return StorageFrontend::CreateForTesting(factory, context);
}
-scoped_ptr<KeyedService> BuildEventRouter(content::BrowserContext* context) {
- return make_scoped_ptr(new extensions::EventRouter(context, nullptr));
+std::unique_ptr<KeyedService> BuildEventRouter(
+ content::BrowserContext* context) {
+ return base::WrapUnique(new extensions::EventRouter(context, nullptr));
}
} // namespace
@@ -61,7 +65,7 @@ class StorageApiUnittest : public ApiUnitTest {
// |value| with the string result.
testing::AssertionResult RunGetFunction(const std::string& key,
std::string* value) {
- scoped_ptr<base::Value> result = RunFunctionAndReturnValue(
+ std::unique_ptr<base::Value> result = RunFunctionAndReturnValue(
new StorageStorageAreaGetFunction(),
base::StringPrintf("[\"local\", \"%s\"]", key.c_str()));
if (!result.get())
diff --git a/chromium/extensions/browser/api/storage/storage_frontend.cc b/chromium/extensions/browser/api/storage/storage_frontend.cc
index 911a49290bf..1e60c44b747 100644
--- a/chromium/extensions/browser/api/storage/storage_frontend.cc
+++ b/chromium/extensions/browser/api/storage/storage_frontend.cc
@@ -11,6 +11,7 @@
#include "base/files/file_path.h"
#include "base/json/json_reader.h"
#include "base/lazy_instance.h"
+#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/trace_event/trace_event.h"
#include "content/public/browser/browser_context.h"
@@ -46,13 +47,13 @@ class DefaultObserver : public SettingsObserver {
const std::string& change_json) override {
// TODO(gdk): This is a temporary hack while the refactoring for
// string-based event payloads is removed. http://crbug.com/136045
- scoped_ptr<base::ListValue> args(new base::ListValue());
+ std::unique_ptr<base::ListValue> args(new base::ListValue());
args->Append(base::JSONReader::Read(change_json));
args->Append(new base::StringValue(settings_namespace::ToString(
settings_namespace)));
- scoped_ptr<Event> event(new Event(events::STORAGE_ON_CHANGED,
- api::storage::OnChanged::kEventName,
- std::move(args)));
+ std::unique_ptr<Event> event(new Event(events::STORAGE_ON_CHANGED,
+ api::storage::OnChanged::kEventName,
+ std::move(args)));
EventRouter::Get(browser_context_)
->DispatchEventToExtension(extension_id, std::move(event));
}
@@ -69,10 +70,10 @@ StorageFrontend* StorageFrontend::Get(BrowserContext* context) {
}
// static
-scoped_ptr<StorageFrontend> StorageFrontend::CreateForTesting(
+std::unique_ptr<StorageFrontend> StorageFrontend::CreateForTesting(
const scoped_refptr<ValueStoreFactory>& storage_factory,
BrowserContext* context) {
- return make_scoped_ptr(new StorageFrontend(storage_factory, context));
+ return base::WrapUnique(new StorageFrontend(storage_factory, context));
}
StorageFrontend::StorageFrontend(BrowserContext* context)
diff --git a/chromium/extensions/browser/api/storage/storage_frontend.h b/chromium/extensions/browser/api/storage/storage_frontend.h
index 6d3427fd546..c43b81e2e28 100644
--- a/chromium/extensions/browser/api/storage/storage_frontend.h
+++ b/chromium/extensions/browser/api/storage/storage_frontend.h
@@ -6,11 +6,11 @@
#define EXTENSIONS_BROWSER_API_STORAGE_STORAGE_FRONTEND_H_
#include <map>
+#include <memory>
#include <string>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/browser/api/storage/settings_namespace.h"
#include "extensions/browser/api/storage/settings_observer.h"
#include "extensions/browser/api/storage/value_store_cache.h"
@@ -31,7 +31,7 @@ class StorageFrontend : public BrowserContextKeyedAPI {
static StorageFrontend* Get(content::BrowserContext* context);
// Creates with a specific |storage_factory|.
- static scoped_ptr<StorageFrontend> CreateForTesting(
+ static std::unique_ptr<StorageFrontend> CreateForTesting(
const scoped_refptr<ValueStoreFactory>& storage_factory,
content::BrowserContext* context);
@@ -87,7 +87,7 @@ class StorageFrontend : public BrowserContextKeyedAPI {
scoped_refptr<SettingsObserverList> observers_;
// Observer for |browser_context_|.
- scoped_ptr<SettingsObserver> browser_context_observer_;
+ std::unique_ptr<SettingsObserver> browser_context_observer_;
// Maps a known namespace to its corresponding ValueStoreCache. The caches
// are owned by this object.
diff --git a/chromium/extensions/browser/api/storage/storage_frontend_unittest.cc b/chromium/extensions/browser/api/storage/storage_frontend_unittest.cc
index 5995ceb2dbe..e54f73b9156 100644
--- a/chromium/extensions/browser/api/storage/storage_frontend_unittest.cc
+++ b/chromium/extensions/browser/api/storage/storage_frontend_unittest.cc
@@ -2,10 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "extensions/browser/api/storage/storage_frontend.h"
+
+#include <memory>
+
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
#include "content/public/browser/browser_context.h"
@@ -14,7 +17,6 @@
#include "extensions/browser/api/extensions_api_client.h"
#include "extensions/browser/api/storage/settings_namespace.h"
#include "extensions/browser/api/storage/settings_test_util.h"
-#include "extensions/browser/api/storage/storage_frontend.h"
#include "extensions/browser/extensions_test.h"
#include "extensions/browser/value_store/value_store.h"
#include "extensions/browser/value_store/value_store_factory_impl.h"
@@ -64,7 +66,7 @@ class ExtensionSettingsFrontendTest : public ExtensionsTest {
}
base::ScopedTempDir temp_dir_;
- scoped_ptr<StorageFrontend> frontend_;
+ std::unique_ptr<StorageFrontend> frontend_;
scoped_refptr<ValueStoreFactoryImpl> storage_factory_;
private:
@@ -192,7 +194,7 @@ TEST_F(ExtensionSettingsFrontendTest,
util::GetStorage(extension, settings::LOCAL, frontend_.get());
// Sync storage should run out after ~100K.
- scoped_ptr<base::Value> kilobyte = util::CreateKilobyte();
+ std::unique_ptr<base::Value> kilobyte = util::CreateKilobyte();
for (int i = 0; i < 100; ++i) {
sync_storage->Set(DEFAULTS, base::IntToString(i), *kilobyte);
}
@@ -209,7 +211,7 @@ TEST_F(ExtensionSettingsFrontendTest,
local_storage->Set(DEFAULTS, "WontError", *kilobyte)->status().ok());
// Local storage should run out after ~5MB.
- scoped_ptr<base::Value> megabyte = util::CreateMegabyte();
+ std::unique_ptr<base::Value> megabyte = util::CreateMegabyte();
for (int i = 0; i < 5; ++i) {
local_storage->Set(DEFAULTS, base::IntToString(i), *megabyte);
}
diff --git a/chromium/extensions/browser/api/system_cpu/cpu_info_provider_win.cc b/chromium/extensions/browser/api/system_cpu/cpu_info_provider_win.cc
index eba4891b625..3aa8857f6c7 100644
--- a/chromium/extensions/browser/api/system_cpu/cpu_info_provider_win.cc
+++ b/chromium/extensions/browser/api/system_cpu/cpu_info_provider_win.cc
@@ -7,7 +7,8 @@
#include <windows.h>
#include <winternl.h>
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "base/sys_info.h"
namespace extensions {
@@ -38,7 +39,7 @@ bool CpuInfoProvider::QueryCpuTimePerProcessor(
CHECK(NtQuerySystemInformation != NULL);
int num_of_processors = base::SysInfo::NumberOfProcessors();
- scoped_ptr<SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION[]> processor_info(
+ std::unique_ptr<SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION[]> processor_info(
new SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION[num_of_processors]);
ULONG returned_bytes = 0,
diff --git a/chromium/extensions/browser/api/system_display/display_info_provider.cc b/chromium/extensions/browser/api/system_display/display_info_provider.cc
index 54c247af3fc..8260a842e9c 100644
--- a/chromium/extensions/browser/api/system_display/display_info_provider.cc
+++ b/chromium/extensions/browser/api/system_display/display_info_provider.cc
@@ -6,8 +6,8 @@
#include "base/strings/string_number_conversions.h"
#include "extensions/common/api/system_display.h"
-#include "ui/gfx/display.h"
-#include "ui/gfx/screen.h"
+#include "ui/display/display.h"
+#include "ui/display/screen.h"
namespace extensions {
@@ -17,15 +17,15 @@ namespace {
DisplayInfoProvider* g_display_info_provider = NULL;
// Converts Rotation enum to integer.
-int RotationToDegrees(gfx::Display::Rotation rotation) {
+int RotationToDegrees(display::Display::Rotation rotation) {
switch (rotation) {
- case gfx::Display::ROTATE_0:
+ case display::Display::ROTATE_0:
return 0;
- case gfx::Display::ROTATE_90:
+ case display::Display::ROTATE_90:
return 90;
- case gfx::Display::ROTATE_180:
+ case display::Display::ROTATE_180:
return 180;
- case gfx::Display::ROTATE_270:
+ case display::Display::ROTATE_270:
return 270;
}
return 0;
@@ -52,7 +52,7 @@ void DisplayInfoProvider::InitializeForTesting(
// static
// Creates new DisplayUnitInfo struct for |display|.
api::system_display::DisplayUnitInfo DisplayInfoProvider::CreateDisplayUnitInfo(
- const gfx::Display& display,
+ const display::Display& display,
int64_t primary_display_id) {
api::system_display::DisplayUnitInfo unit;
const gfx::Rect& bounds = display.bounds();
@@ -75,12 +75,12 @@ api::system_display::DisplayUnitInfo DisplayInfoProvider::CreateDisplayUnitInfo(
void DisplayInfoProvider::EnableUnifiedDesktop(bool enable) {}
-DisplayInfo DisplayInfoProvider::GetAllDisplaysInfo() {
- gfx::Screen* screen = gfx::Screen::GetScreen();
+DisplayUnitInfoList DisplayInfoProvider::GetAllDisplaysInfo() {
+ display::Screen* screen = display::Screen::GetScreen();
int64_t primary_id = screen->GetPrimaryDisplay().id();
- std::vector<gfx::Display> displays = screen->GetAllDisplays();
- DisplayInfo all_displays;
- for (const gfx::Display& display : displays) {
+ std::vector<display::Display> displays = screen->GetAllDisplays();
+ DisplayUnitInfoList all_displays;
+ for (const display::Display& display : displays) {
api::system_display::DisplayUnitInfo unit =
CreateDisplayUnitInfo(display, primary_id);
UpdateDisplayUnitInfoForPlatform(display, &unit);
diff --git a/chromium/extensions/browser/api/system_display/display_info_provider.h b/chromium/extensions/browser/api/system_display/display_info_provider.h
index 48e3d9e537f..22783a0658d 100644
--- a/chromium/extensions/browser/api/system_display/display_info_provider.h
+++ b/chromium/extensions/browser/api/system_display/display_info_provider.h
@@ -12,7 +12,7 @@
#include "base/macros.h"
-namespace gfx {
+namespace display {
class Display;
}
@@ -25,7 +25,7 @@ struct DisplayUnitInfo;
}
}
-typedef std::vector<api::system_display::DisplayUnitInfo> DisplayInfo;
+typedef std::vector<api::system_display::DisplayUnitInfo> DisplayUnitInfoList;
class DisplayInfoProvider {
public:
@@ -50,15 +50,15 @@ class DisplayInfoProvider {
virtual void EnableUnifiedDesktop(bool enable);
// Get display information.
- virtual DisplayInfo GetAllDisplaysInfo();
+ virtual DisplayUnitInfoList GetAllDisplaysInfo();
protected:
DisplayInfoProvider();
- // Create a DisplayUnitInfo from a gfx::Display for implementations of
+ // Create a DisplayUnitInfo from a display::Display for implementations of
// GetAllDisplaysInfo()
static api::system_display::DisplayUnitInfo CreateDisplayUnitInfo(
- const gfx::Display& display,
+ const display::Display& display,
int64_t primary_display_id);
private:
@@ -67,7 +67,7 @@ class DisplayInfoProvider {
// Update the content of the |unit| obtained for |display| using
// platform specific method.
virtual void UpdateDisplayUnitInfoForPlatform(
- const gfx::Display& display,
+ const display::Display& display,
api::system_display::DisplayUnitInfo* unit) = 0;
DISALLOW_COPY_AND_ASSIGN(DisplayInfoProvider);
diff --git a/chromium/extensions/browser/api/system_display/system_display_api.cc b/chromium/extensions/browser/api/system_display/system_display_api.cc
index 423109d2ab3..b8dc9c38752 100644
--- a/chromium/extensions/browser/api/system_display/system_display_api.cc
+++ b/chromium/extensions/browser/api/system_display/system_display_api.cc
@@ -4,6 +4,7 @@
#include "extensions/browser/api/system_display/system_display_api.h"
+#include <memory>
#include <string>
#include "build/build_config.h"
@@ -11,9 +12,7 @@
#include "extensions/common/api/system_display.h"
#if defined(OS_CHROMEOS)
-#include "base/memory/scoped_ptr.h"
#include "extensions/common/manifest_handlers/kiosk_mode_info.h"
-#include "ui/gfx/screen.h"
#endif
namespace extensions {
@@ -23,7 +22,7 @@ using api::system_display::DisplayUnitInfo;
namespace SetDisplayProperties = api::system_display::SetDisplayProperties;
bool SystemDisplayGetInfoFunction::RunSync() {
- DisplayInfo all_displays_info =
+ DisplayUnitInfoList all_displays_info =
DisplayInfoProvider::Get()->GetAllDisplaysInfo();
results_ = api::system_display::GetInfo::Results::Create(all_displays_info);
return true;
@@ -34,18 +33,18 @@ bool SystemDisplaySetDisplayPropertiesFunction::RunSync() {
SetError("Function available only on ChromeOS.");
return false;
#else
- if (!KioskModeInfo::IsKioskEnabled(extension())) {
+ if (extension() && !KioskModeInfo::IsKioskEnabled(extension())) {
SetError("The extension needs to be kiosk enabled to use the function.");
return false;
}
std::string error;
- scoped_ptr<SetDisplayProperties::Params> params(
+ std::unique_ptr<SetDisplayProperties::Params> params(
SetDisplayProperties::Params::Create(*args_));
- bool success =
+ bool result =
DisplayInfoProvider::Get()->SetInfo(params->id, params->info, &error);
- if (!success)
+ if (!result)
SetError(error);
- return true;
+ return result;
#endif
}
@@ -54,7 +53,7 @@ bool SystemDisplayEnableUnifiedDesktopFunction::RunSync() {
SetError("Function available only on ChromeOS.");
return false;
#else
- scoped_ptr<api::system_display::EnableUnifiedDesktop::Params> params(
+ std::unique_ptr<api::system_display::EnableUnifiedDesktop::Params> params(
api::system_display::EnableUnifiedDesktop::Params::Create(*args_));
DisplayInfoProvider::Get()->EnableUnifiedDesktop(params->enabled);
return true;
diff --git a/chromium/extensions/browser/api/system_display/system_display_apitest.cc b/chromium/extensions/browser/api/system_display/system_display_apitest.cc
index 2c0548ec7ce..bdca5c36caa 100644
--- a/chromium/extensions/browser/api/system_display/system_display_apitest.cc
+++ b/chromium/extensions/browser/api/system_display/system_display_apitest.cc
@@ -15,15 +15,14 @@
#include "extensions/browser/api_test_utils.h"
#include "extensions/common/api/system_display.h"
#include "extensions/shell/test/shell_apitest.h"
-#include "ui/gfx/display.h"
-#include "ui/gfx/display_observer.h"
-#include "ui/gfx/screen.h"
+#include "ui/display/display.h"
+#include "ui/display/screen.h"
namespace extensions {
using api::system_display::Bounds;
using api::system_display::DisplayUnitInfo;
-using gfx::Screen;
+using display::Screen;
class MockScreen : public Screen {
public:
@@ -31,7 +30,7 @@ class MockScreen : public Screen {
for (int i = 0; i < 4; i++) {
gfx::Rect bounds(0, 0, 1280, 720);
gfx::Rect work_area(0, 0, 960, 720);
- gfx::Display display(i, bounds);
+ display::Display display(i, bounds);
display.set_work_area(work_area);
displays_.push_back(display);
}
@@ -39,35 +38,36 @@ class MockScreen : public Screen {
~MockScreen() override {}
protected:
- // Overridden from gfx::Screen:
+ // Overridden from display::Screen:
gfx::Point GetCursorScreenPoint() override { return gfx::Point(); }
- gfx::NativeWindow GetWindowUnderCursor() override {
- return gfx::NativeWindow();
- }
+ bool IsWindowUnderCursor(gfx::NativeWindow window) override { return false; }
gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override {
return gfx::NativeWindow();
}
int GetNumDisplays() const override {
return static_cast<int>(displays_.size());
}
- std::vector<gfx::Display> GetAllDisplays() const override {
+ std::vector<display::Display> GetAllDisplays() const override {
return displays_;
}
- gfx::Display GetDisplayNearestWindow(gfx::NativeView window) const override {
- return gfx::Display(0);
+ display::Display GetDisplayNearestWindow(
+ gfx::NativeView window) const override {
+ return display::Display(0);
}
- gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override {
- return gfx::Display(0);
+ display::Display GetDisplayNearestPoint(
+ const gfx::Point& point) const override {
+ return display::Display(0);
}
- gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override {
- return gfx::Display(0);
+ display::Display GetDisplayMatching(
+ const gfx::Rect& match_rect) const override {
+ return display::Display(0);
}
- gfx::Display GetPrimaryDisplay() const override { return displays_[0]; }
- void AddObserver(gfx::DisplayObserver* observer) override {}
- void RemoveObserver(gfx::DisplayObserver* observer) override {}
+ display::Display GetPrimaryDisplay() const override { return displays_[0]; }
+ void AddObserver(display::DisplayObserver* observer) override {}
+ void RemoveObserver(display::DisplayObserver* observer) override {}
private:
- std::vector<gfx::Display> displays_;
+ std::vector<display::Display> displays_;
DISALLOW_COPY_AND_ASSIGN(MockScreen);
};
@@ -92,7 +92,7 @@ class MockDisplayInfoProvider : public DisplayInfoProvider {
unified_desktop_enabled_ = enable;
}
- scoped_ptr<base::DictionaryValue> GetSetInfoValue() {
+ std::unique_ptr<base::DictionaryValue> GetSetInfoValue() {
return std::move(set_info_value_);
}
@@ -104,7 +104,7 @@ class MockDisplayInfoProvider : public DisplayInfoProvider {
// Update the content of the |unit| obtained for |display| using
// platform specific method.
void UpdateDisplayUnitInfoForPlatform(
- const gfx::Display& display,
+ const display::Display& display,
extensions::api::system_display::DisplayUnitInfo* unit) override {
int64_t id = display.id();
unit->name = "DISPLAY NAME FOR " + base::Int64ToString(id);
@@ -124,7 +124,7 @@ class MockDisplayInfoProvider : public DisplayInfoProvider {
}
}
- scoped_ptr<base::DictionaryValue> set_info_value_;
+ std::unique_ptr<base::DictionaryValue> set_info_value_;
std::string set_info_display_id_;
bool unified_desktop_enabled_ = false;
@@ -140,14 +140,14 @@ class SystemDisplayApiTest : public ShellApiTest {
void SetUpOnMainThread() override {
ShellApiTest::SetUpOnMainThread();
- ANNOTATE_LEAKING_OBJECT_PTR(gfx::Screen::GetScreen());
- gfx::Screen::SetScreenInstance(screen_.get());
+ ANNOTATE_LEAKING_OBJECT_PTR(display::Screen::GetScreen());
+ display::Screen::SetScreenInstance(screen_.get());
DisplayInfoProvider::InitializeForTesting(provider_.get());
}
protected:
- scoped_ptr<MockDisplayInfoProvider> provider_;
- scoped_ptr<gfx::Screen> screen_;
+ std::unique_ptr<MockDisplayInfoProvider> provider_;
+ std::unique_ptr<display::Screen> screen_;
private:
DISALLOW_COPY_AND_ASSIGN(SystemDisplayApiTest);
@@ -169,24 +169,24 @@ IN_PROC_BROWSER_TEST_F(SystemDisplayApiTest, SetDisplay) {
api_test_utils::RunFunctionAndReturnError(
set_info_function.get(), "[\"display_id\", {}]", browser_context()));
- scoped_ptr<base::DictionaryValue> set_info = provider_->GetSetInfoValue();
+ std::unique_ptr<base::DictionaryValue> set_info =
+ provider_->GetSetInfoValue();
EXPECT_FALSE(set_info);
}
#endif // !defined(OS_CHROMEOS)
#if defined(OS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(SystemDisplayApiTest, SetDisplayNotKioskEnabled) {
- scoped_ptr<base::DictionaryValue> test_extension_value(
- api_test_utils::ParseDictionary(
- "{\n"
- " \"name\": \"Test\",\n"
- " \"version\": \"1.0\",\n"
- " \"app\": {\n"
- " \"background\": {\n"
- " \"scripts\": [\"background.js\"]\n"
- " }\n"
- " }\n"
- "}"));
+ std::unique_ptr<base::DictionaryValue> test_extension_value(
+ api_test_utils::ParseDictionary("{\n"
+ " \"name\": \"Test\",\n"
+ " \"version\": \"1.0\",\n"
+ " \"app\": {\n"
+ " \"background\": {\n"
+ " \"scripts\": [\"background.js\"]\n"
+ " }\n"
+ " }\n"
+ "}"));
scoped_refptr<Extension> test_extension(
api_test_utils::CreateExtension(test_extension_value.get()));
@@ -201,23 +201,23 @@ IN_PROC_BROWSER_TEST_F(SystemDisplayApiTest, SetDisplayNotKioskEnabled) {
api_test_utils::RunFunctionAndReturnError(
set_info_function.get(), "[\"display_id\", {}]", browser_context()));
- scoped_ptr<base::DictionaryValue> set_info = provider_->GetSetInfoValue();
+ std::unique_ptr<base::DictionaryValue> set_info =
+ provider_->GetSetInfoValue();
EXPECT_FALSE(set_info);
}
IN_PROC_BROWSER_TEST_F(SystemDisplayApiTest, SetDisplayKioskEnabled) {
- scoped_ptr<base::DictionaryValue> test_extension_value(
- api_test_utils::ParseDictionary(
- "{\n"
- " \"name\": \"Test\",\n"
- " \"version\": \"1.0\",\n"
- " \"app\": {\n"
- " \"background\": {\n"
- " \"scripts\": [\"background.js\"]\n"
- " }\n"
- " },\n"
- " \"kiosk_enabled\": true\n"
- "}"));
+ std::unique_ptr<base::DictionaryValue> test_extension_value(
+ api_test_utils::ParseDictionary("{\n"
+ " \"name\": \"Test\",\n"
+ " \"version\": \"1.0\",\n"
+ " \"app\": {\n"
+ " \"background\": {\n"
+ " \"scripts\": [\"background.js\"]\n"
+ " }\n"
+ " },\n"
+ " \"kiosk_enabled\": true\n"
+ "}"));
scoped_refptr<Extension> test_extension(
api_test_utils::CreateExtension(test_extension_value.get()));
@@ -239,7 +239,8 @@ IN_PROC_BROWSER_TEST_F(SystemDisplayApiTest, SetDisplayKioskEnabled) {
"}]",
browser_context()));
- scoped_ptr<base::DictionaryValue> set_info = provider_->GetSetInfoValue();
+ std::unique_ptr<base::DictionaryValue> set_info =
+ provider_->GetSetInfoValue();
ASSERT_TRUE(set_info);
EXPECT_TRUE(api_test_utils::GetBoolean(set_info.get(), "isPrimary"));
EXPECT_EQ("mirroringId",
@@ -258,7 +259,7 @@ IN_PROC_BROWSER_TEST_F(SystemDisplayApiTest, SetDisplayKioskEnabled) {
}
IN_PROC_BROWSER_TEST_F(SystemDisplayApiTest, EnableUnifiedDesktop) {
- scoped_ptr<base::DictionaryValue> test_extension_value(
+ std::unique_ptr<base::DictionaryValue> test_extension_value(
api_test_utils::ParseDictionary("{\n"
" \"name\": \"Test\",\n"
" \"version\": \"1.0\",\n"
diff --git a/chromium/extensions/browser/api/system_info/system_info_api.cc b/chromium/extensions/browser/api/system_info/system_info_api.cc
index 42679d66afd..dbd98376150 100644
--- a/chromium/extensions/browser/api/system_info/system_info_api.cc
+++ b/chromium/extensions/browser/api/system_info/system_info_api.cc
@@ -6,13 +6,13 @@
#include <stdint.h>
+#include <memory>
#include <set>
#include <utility>
#include "base/bind.h"
#include "base/lazy_instance.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "base/strings/string_util.h"
#include "base/values.h"
@@ -24,8 +24,8 @@
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/common/api/system_display.h"
#include "extensions/common/api/system_storage.h"
-#include "ui/gfx/display_observer.h"
-#include "ui/gfx/screen.h"
+#include "ui/display/display_observer.h"
+#include "ui/display/screen.h"
namespace extensions {
@@ -49,7 +49,7 @@ bool IsSystemStorageEvent(const std::string& event_name) {
// Event router for systemInfo API. It is a singleton instance shared by
// multiple profiles.
-class SystemInfoEventRouter : public gfx::DisplayObserver,
+class SystemInfoEventRouter : public display::DisplayObserver,
public storage_monitor::RemovableStorageObserver {
public:
static SystemInfoEventRouter* GetInstance();
@@ -62,10 +62,10 @@ class SystemInfoEventRouter : public gfx::DisplayObserver,
void RemoveEventListener(const std::string& event_name);
private:
- // gfx::DisplayObserver:
- void OnDisplayAdded(const gfx::Display& new_display) override;
- void OnDisplayRemoved(const gfx::Display& old_display) override;
- void OnDisplayMetricsChanged(const gfx::Display& display,
+ // display::DisplayObserver:
+ void OnDisplayAdded(const display::Display& new_display) override;
+ void OnDisplayRemoved(const display::Display& old_display) override;
+ void OnDisplayMetricsChanged(const display::Display& display,
uint32_t metrics) override;
// RemovableStorageObserver implementation.
@@ -78,7 +78,7 @@ class SystemInfoEventRouter : public gfx::DisplayObserver,
// processes cross multiple profiles.
void DispatchEvent(events::HistogramValue histogram_value,
const std::string& event_name,
- scoped_ptr<base::ListValue> args);
+ std::unique_ptr<base::ListValue> args);
// Called to dispatch the systemInfo.display.onDisplayChanged event.
void OnDisplayChanged();
@@ -119,7 +119,7 @@ void SystemInfoEventRouter::AddEventListener(const std::string& event_name) {
return;
if (IsDisplayChangedEvent(event_name)) {
- gfx::Screen* screen = gfx::Screen::GetScreen();
+ display::Screen* screen = display::Screen::GetScreen();
if (screen)
screen->AddObserver(this);
}
@@ -145,7 +145,7 @@ void SystemInfoEventRouter::RemoveEventListener(const std::string& event_name) {
}
if (IsDisplayChangedEvent(event_name)) {
- gfx::Screen* screen = gfx::Screen::GetScreen();
+ display::Screen* screen = display::Screen::GetScreen();
if (screen)
screen->RemoveObserver(this);
}
@@ -166,7 +166,7 @@ void SystemInfoEventRouter::OnRemovableStorageAttached(
const storage_monitor::StorageInfo& info) {
StorageUnitInfo unit;
systeminfo::BuildStorageUnitInfo(info, &unit);
- scoped_ptr<base::ListValue> args(new base::ListValue);
+ std::unique_ptr<base::ListValue> args(new base::ListValue);
args->Append(unit.ToValue().release());
DispatchEvent(events::SYSTEM_STORAGE_ON_ATTACHED,
system_storage::OnAttached::kEventName, std::move(args));
@@ -174,7 +174,7 @@ void SystemInfoEventRouter::OnRemovableStorageAttached(
void SystemInfoEventRouter::OnRemovableStorageDetached(
const storage_monitor::StorageInfo& info) {
- scoped_ptr<base::ListValue> args(new base::ListValue);
+ std::unique_ptr<base::ListValue> args(new base::ListValue);
std::string transient_id =
StorageMonitor::GetInstance()->GetTransientIdForDeviceId(
info.device_id());
@@ -184,21 +184,24 @@ void SystemInfoEventRouter::OnRemovableStorageDetached(
system_storage::OnDetached::kEventName, std::move(args));
}
-void SystemInfoEventRouter::OnDisplayAdded(const gfx::Display& new_display) {
+void SystemInfoEventRouter::OnDisplayAdded(
+ const display::Display& new_display) {
OnDisplayChanged();
}
-void SystemInfoEventRouter::OnDisplayRemoved(const gfx::Display& old_display) {
+void SystemInfoEventRouter::OnDisplayRemoved(
+ const display::Display& old_display) {
OnDisplayChanged();
}
-void SystemInfoEventRouter::OnDisplayMetricsChanged(const gfx::Display& display,
- uint32_t metrics) {
+void SystemInfoEventRouter::OnDisplayMetricsChanged(
+ const display::Display& display,
+ uint32_t metrics) {
OnDisplayChanged();
}
void SystemInfoEventRouter::OnDisplayChanged() {
- scoped_ptr<base::ListValue> args(new base::ListValue());
+ std::unique_ptr<base::ListValue> args(new base::ListValue());
DispatchEvent(events::SYSTEM_DISPLAY_ON_DISPLAY_CHANGED,
system_display::OnDisplayChanged::kEventName, std::move(args));
}
@@ -206,7 +209,7 @@ void SystemInfoEventRouter::OnDisplayChanged() {
void SystemInfoEventRouter::DispatchEvent(
events::HistogramValue histogram_value,
const std::string& event_name,
- scoped_ptr<base::ListValue> args) {
+ std::unique_ptr<base::ListValue> args) {
ExtensionsBrowserClient::Get()->BroadcastEventToRenderers(
histogram_value, event_name, std::move(args));
}
diff --git a/chromium/extensions/browser/api/system_memory/system_memory_apitest.cc b/chromium/extensions/browser/api/system_memory/system_memory_apitest.cc
index 64be93c4f56..4c892c26991 100644
--- a/chromium/extensions/browser/api/system_memory/system_memory_apitest.cc
+++ b/chromium/extensions/browser/api/system_memory/system_memory_apitest.cc
@@ -35,7 +35,7 @@ class SystemMemoryApiTest : public ShellApiTest {
}
private:
- scoped_ptr<base::MessageLoop> message_loop_;
+ std::unique_ptr<base::MessageLoop> message_loop_;
};
IN_PROC_BROWSER_TEST_F(SystemMemoryApiTest, Memory) {
diff --git a/chromium/extensions/browser/api/system_network/system_network_api.cc b/chromium/extensions/browser/api/system_network/system_network_api.cc
index 0b196bd617e..ece1ebbe9ff 100644
--- a/chromium/extensions/browser/api/system_network/system_network_api.cc
+++ b/chromium/extensions/browser/api/system_network/system_network_api.cc
@@ -4,8 +4,6 @@
#include "extensions/browser/api/system_network/system_network_api.h"
-#include "net/base/ip_address_number.h"
-
namespace {
const char kNetworkListError[] = "Network lookup failed or unsupported";
} // namespace
diff --git a/chromium/extensions/browser/api/system_network/system_network_apitest.cc b/chromium/extensions/browser/api/system_network/system_network_apitest.cc
index f7c1964345b..047857e2120 100644
--- a/chromium/extensions/browser/api/system_network/system_network_apitest.cc
+++ b/chromium/extensions/browser/api/system_network/system_network_apitest.cc
@@ -34,7 +34,7 @@ IN_PROC_BROWSER_TEST_F(SystemNetworkApiTest, GetNetworkInterfaces) {
socket_function->set_extension(empty_extension.get());
socket_function->set_has_callback(true);
- scoped_ptr<base::Value> result(RunFunctionAndReturnSingleResult(
+ std::unique_ptr<base::Value> result(RunFunctionAndReturnSingleResult(
socket_function.get(), "[]", browser_context()));
ASSERT_EQ(base::Value::TYPE_LIST, result->GetType());
diff --git a/chromium/extensions/browser/api/system_storage/system_storage_api.cc b/chromium/extensions/browser/api/system_storage/system_storage_api.cc
index de460183ea3..cd20f4f6b4c 100644
--- a/chromium/extensions/browser/api/system_storage/system_storage_api.cc
+++ b/chromium/extensions/browser/api/system_storage/system_storage_api.cc
@@ -41,7 +41,8 @@ SystemStorageEjectDeviceFunction::~SystemStorageEjectDeviceFunction() {
bool SystemStorageEjectDeviceFunction::RunAsync() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- scoped_ptr<EjectDevice::Params> params(EjectDevice::Params::Create(*args_));
+ std::unique_ptr<EjectDevice::Params> params(
+ EjectDevice::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
StorageMonitor::GetInstance()->EnsureInitialized(
@@ -102,7 +103,7 @@ SystemStorageGetAvailableCapacityFunction::
bool SystemStorageGetAvailableCapacityFunction::RunAsync() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- scoped_ptr<GetAvailableCapacity::Params> params(
+ std::unique_ptr<GetAvailableCapacity::Params> params(
GetAvailableCapacity::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
diff --git a/chromium/extensions/browser/api/system_storage/system_storage_apitest.cc b/chromium/extensions/browser/api/system_storage/system_storage_apitest.cc
index c57b311ec1d..3d0168cace7 100644
--- a/chromium/extensions/browser/api/system_storage/system_storage_apitest.cc
+++ b/chromium/extensions/browser/api/system_storage/system_storage_apitest.cc
@@ -102,7 +102,7 @@ class SystemStorageApiTest : public extensions::ShellApiTest {
}
private:
- scoped_ptr<base::MessageLoop> message_loop_;
+ std::unique_ptr<base::MessageLoop> message_loop_;
};
IN_PROC_BROWSER_TEST_F(SystemStorageApiTest, Storage) {
diff --git a/chromium/extensions/browser/api/usb/usb_api.cc b/chromium/extensions/browser/api/usb/usb_api.cc
index 49ad2c2ebcd..6c8328fa2a7 100644
--- a/chromium/extensions/browser/api/usb/usb_api.cc
+++ b/chromium/extensions/browser/api/usb/usb_api.cc
@@ -5,13 +5,13 @@
#include "extensions/browser/api/usb/usb_api.h"
#include <algorithm>
+#include <memory>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
#include "base/barrier_closure.h"
-#include "base/memory/scoped_ptr.h"
#include "device/core/device_client.h"
#include "device/usb/usb_descriptors.h"
#include "device/usb/usb_device_handle.h"
@@ -459,15 +459,21 @@ UsbTransferFunction::~UsbTransferFunction() {
void UsbTransferFunction::OnCompleted(UsbTransferStatus status,
scoped_refptr<net::IOBuffer> data,
size_t length) {
- scoped_ptr<base::DictionaryValue> transfer_info(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> transfer_info(
+ new base::DictionaryValue());
transfer_info->SetInteger(kResultCodeKey, status);
- transfer_info->Set(kDataKey, base::BinaryValue::CreateWithCopiedBuffer(
- data->data(), length));
+
+ if (data) {
+ transfer_info->Set(kDataKey, base::BinaryValue::CreateWithCopiedBuffer(
+ data->data(), length));
+ } else {
+ transfer_info->Set(kDataKey, new base::BinaryValue());
+ }
if (status == device::USB_TRANSFER_COMPLETED) {
Respond(OneArgument(std::move(transfer_info)));
} else {
- scoped_ptr<base::ListValue> error_args(new base::ListValue());
+ std::unique_ptr<base::ListValue> error_args(new base::ListValue());
error_args->Append(std::move(transfer_info));
// Using ErrorWithArguments is discouraged but required to provide the
// detailed transfer info as the transfer may have partially succeeded.
@@ -483,7 +489,7 @@ UsbFindDevicesFunction::~UsbFindDevicesFunction() {
}
ExtensionFunction::ResponseAction UsbFindDevicesFunction::Run() {
- scoped_ptr<extensions::api::usb::FindDevices::Params> parameters =
+ std::unique_ptr<extensions::api::usb::FindDevices::Params> parameters =
FindDevices::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters.get());
@@ -549,7 +555,7 @@ UsbGetDevicesFunction::~UsbGetDevicesFunction() {
}
ExtensionFunction::ResponseAction UsbGetDevicesFunction::Run() {
- scoped_ptr<extensions::api::usb::GetDevices::Params> parameters =
+ std::unique_ptr<extensions::api::usb::GetDevices::Params> parameters =
GetDevices::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters.get());
@@ -579,7 +585,7 @@ ExtensionFunction::ResponseAction UsbGetDevicesFunction::Run() {
void UsbGetDevicesFunction::OnGetDevicesComplete(
const std::vector<scoped_refptr<UsbDevice>>& devices) {
- scoped_ptr<base::ListValue> result(new base::ListValue());
+ std::unique_ptr<base::ListValue> result(new base::ListValue());
UsbGuidMap* guid_map = UsbGuidMap::Get(browser_context());
for (const scoped_refptr<UsbDevice>& device : devices) {
if ((filters_.empty() || UsbDeviceFilter::MatchesAny(device, filters_)) &&
@@ -600,8 +606,8 @@ UsbGetUserSelectedDevicesFunction::~UsbGetUserSelectedDevicesFunction() {
}
ExtensionFunction::ResponseAction UsbGetUserSelectedDevicesFunction::Run() {
- scoped_ptr<extensions::api::usb::GetUserSelectedDevices::Params> parameters =
- GetUserSelectedDevices::Params::Create(*args_);
+ std::unique_ptr<extensions::api::usb::GetUserSelectedDevices::Params>
+ parameters = GetUserSelectedDevices::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters.get());
if (!user_gesture()) {
@@ -635,7 +641,7 @@ ExtensionFunction::ResponseAction UsbGetUserSelectedDevicesFunction::Run() {
void UsbGetUserSelectedDevicesFunction::OnDevicesChosen(
const std::vector<scoped_refptr<UsbDevice>>& devices) {
- scoped_ptr<base::ListValue> result(new base::ListValue());
+ std::unique_ptr<base::ListValue> result(new base::ListValue());
UsbGuidMap* guid_map = UsbGuidMap::Get(browser_context());
for (const auto& device : devices) {
Device api_device;
@@ -651,7 +657,7 @@ UsbGetConfigurationsFunction::UsbGetConfigurationsFunction() {}
UsbGetConfigurationsFunction::~UsbGetConfigurationsFunction() {}
ExtensionFunction::ResponseAction UsbGetConfigurationsFunction::Run() {
- scoped_ptr<extensions::api::usb::GetConfigurations::Params> parameters =
+ std::unique_ptr<extensions::api::usb::GetConfigurations::Params> parameters =
GetConfigurations::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters.get());
@@ -677,7 +683,7 @@ ExtensionFunction::ResponseAction UsbGetConfigurationsFunction::Run() {
return RespondNow(Error(kErrorNoDevice));
}
- scoped_ptr<base::ListValue> configs(new base::ListValue());
+ std::unique_ptr<base::ListValue> configs(new base::ListValue());
const UsbConfigDescriptor* active_config = device->GetActiveConfiguration();
for (const UsbConfigDescriptor& config : device->configurations()) {
ConfigDescriptor api_config = ConvertConfigDescriptor(config);
@@ -697,7 +703,7 @@ UsbRequestAccessFunction::~UsbRequestAccessFunction() {
}
ExtensionFunction::ResponseAction UsbRequestAccessFunction::Run() {
- scoped_ptr<extensions::api::usb::RequestAccess::Params> parameters =
+ std::unique_ptr<extensions::api::usb::RequestAccess::Params> parameters =
RequestAccess::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters.get());
return RespondNow(OneArgument(new base::FundamentalValue(true)));
@@ -710,7 +716,7 @@ UsbOpenDeviceFunction::~UsbOpenDeviceFunction() {
}
ExtensionFunction::ResponseAction UsbOpenDeviceFunction::Run() {
- scoped_ptr<extensions::api::usb::OpenDevice::Params> parameters =
+ std::unique_ptr<extensions::api::usb::OpenDevice::Params> parameters =
OpenDevice::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters.get());
@@ -764,7 +770,7 @@ UsbSetConfigurationFunction::~UsbSetConfigurationFunction() {
}
ExtensionFunction::ResponseAction UsbSetConfigurationFunction::Run() {
- scoped_ptr<extensions::api::usb::SetConfiguration::Params> parameters =
+ std::unique_ptr<extensions::api::usb::SetConfiguration::Params> parameters =
SetConfiguration::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters.get());
@@ -795,7 +801,7 @@ UsbGetConfigurationFunction::~UsbGetConfigurationFunction() {
}
ExtensionFunction::ResponseAction UsbGetConfigurationFunction::Run() {
- scoped_ptr<extensions::api::usb::GetConfiguration::Params> parameters =
+ std::unique_ptr<extensions::api::usb::GetConfiguration::Params> parameters =
GetConfiguration::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters.get());
@@ -823,7 +829,7 @@ UsbListInterfacesFunction::~UsbListInterfacesFunction() {
}
ExtensionFunction::ResponseAction UsbListInterfacesFunction::Run() {
- scoped_ptr<extensions::api::usb::ListInterfaces::Params> parameters =
+ std::unique_ptr<extensions::api::usb::ListInterfaces::Params> parameters =
ListInterfaces::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters.get());
@@ -838,7 +844,7 @@ ExtensionFunction::ResponseAction UsbListInterfacesFunction::Run() {
if (config_descriptor) {
ConfigDescriptor config = ConvertConfigDescriptor(*config_descriptor);
- scoped_ptr<base::ListValue> result(new base::ListValue);
+ std::unique_ptr<base::ListValue> result(new base::ListValue);
for (size_t i = 0; i < config.interfaces.size(); ++i) {
result->Append(config.interfaces[i].ToValue());
}
@@ -856,7 +862,7 @@ UsbCloseDeviceFunction::~UsbCloseDeviceFunction() {
}
ExtensionFunction::ResponseAction UsbCloseDeviceFunction::Run() {
- scoped_ptr<extensions::api::usb::CloseDevice::Params> parameters =
+ std::unique_ptr<extensions::api::usb::CloseDevice::Params> parameters =
CloseDevice::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters.get());
@@ -878,7 +884,7 @@ UsbClaimInterfaceFunction::~UsbClaimInterfaceFunction() {
}
ExtensionFunction::ResponseAction UsbClaimInterfaceFunction::Run() {
- scoped_ptr<extensions::api::usb::ClaimInterface::Params> parameters =
+ std::unique_ptr<extensions::api::usb::ClaimInterface::Params> parameters =
ClaimInterface::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters.get());
@@ -909,7 +915,7 @@ UsbReleaseInterfaceFunction::~UsbReleaseInterfaceFunction() {
}
ExtensionFunction::ResponseAction UsbReleaseInterfaceFunction::Run() {
- scoped_ptr<extensions::api::usb::ReleaseInterface::Params> parameters =
+ std::unique_ptr<extensions::api::usb::ReleaseInterface::Params> parameters =
ReleaseInterface::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters.get());
@@ -942,7 +948,7 @@ UsbSetInterfaceAlternateSettingFunction::
ExtensionFunction::ResponseAction
UsbSetInterfaceAlternateSettingFunction::Run() {
- scoped_ptr<extensions::api::usb::SetInterfaceAlternateSetting::Params>
+ std::unique_ptr<extensions::api::usb::SetInterfaceAlternateSetting::Params>
parameters = SetInterfaceAlternateSetting::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters.get());
@@ -973,7 +979,7 @@ UsbControlTransferFunction::~UsbControlTransferFunction() {
}
ExtensionFunction::ResponseAction UsbControlTransferFunction::Run() {
- scoped_ptr<extensions::api::usb::ControlTransfer::Params> parameters =
+ std::unique_ptr<extensions::api::usb::ControlTransfer::Params> parameters =
ControlTransfer::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters.get());
@@ -1030,7 +1036,7 @@ UsbBulkTransferFunction::~UsbBulkTransferFunction() {
}
ExtensionFunction::ResponseAction UsbBulkTransferFunction::Run() {
- scoped_ptr<extensions::api::usb::BulkTransfer::Params> parameters =
+ std::unique_ptr<extensions::api::usb::BulkTransfer::Params> parameters =
BulkTransfer::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters.get());
@@ -1076,7 +1082,7 @@ UsbInterruptTransferFunction::~UsbInterruptTransferFunction() {
}
ExtensionFunction::ResponseAction UsbInterruptTransferFunction::Run() {
- scoped_ptr<extensions::api::usb::InterruptTransfer::Params> parameters =
+ std::unique_ptr<extensions::api::usb::InterruptTransfer::Params> parameters =
InterruptTransfer::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters.get());
@@ -1122,8 +1128,8 @@ UsbIsochronousTransferFunction::~UsbIsochronousTransferFunction() {
}
ExtensionFunction::ResponseAction UsbIsochronousTransferFunction::Run() {
- scoped_ptr<extensions::api::usb::IsochronousTransfer::Params> parameters =
- IsochronousTransfer::Params::Create(*args_);
+ std::unique_ptr<extensions::api::usb::IsochronousTransfer::Params>
+ parameters = IsochronousTransfer::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(parameters.get());
scoped_refptr<UsbDeviceHandle> device_handle =
@@ -1186,7 +1192,7 @@ void UsbIsochronousTransferFunction::OnCompleted(
[](const size_t& a, const UsbDeviceHandle::IsochronousPacket& packet) {
return a + packet.transferred_length;
});
- scoped_ptr<char[]> buffer(new char[length]);
+ std::unique_ptr<char[]> buffer(new char[length]);
UsbTransferStatus status = device::USB_TRANSFER_COMPLETED;
size_t buffer_offset = 0;
@@ -1198,20 +1204,23 @@ void UsbIsochronousTransferFunction::OnCompleted(
status = packet.status;
}
- memcpy(&buffer[buffer_offset], data->data() + data_offset,
- packet.transferred_length);
+ if (data) {
+ memcpy(&buffer[buffer_offset], data->data() + data_offset,
+ packet.transferred_length);
+ }
buffer_offset += packet.transferred_length;
data_offset += packet.length;
}
- scoped_ptr<base::DictionaryValue> transfer_info(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> transfer_info(
+ new base::DictionaryValue());
transfer_info->SetInteger(kResultCodeKey, status);
transfer_info->Set(kDataKey,
new base::BinaryValue(std::move(buffer), length));
if (status == device::USB_TRANSFER_COMPLETED) {
Respond(OneArgument(std::move(transfer_info)));
} else {
- scoped_ptr<base::ListValue> error_args(new base::ListValue());
+ std::unique_ptr<base::ListValue> error_args(new base::ListValue());
error_args->Append(std::move(transfer_info));
// Using ErrorWithArguments is discouraged but required to provide the
// detailed transfer info as the transfer may have partially succeeded.
@@ -1252,7 +1261,7 @@ void UsbResetDeviceFunction::OnComplete(bool success) {
}
ReleaseDeviceHandle(parameters_->handle);
- scoped_ptr<base::ListValue> error_args(new base::ListValue());
+ std::unique_ptr<base::ListValue> error_args(new base::ListValue());
error_args->AppendBoolean(false);
// Using ErrorWithArguments is discouraged but required to maintain
// compatibility with existing applications.
diff --git a/chromium/extensions/browser/api/usb/usb_api.h b/chromium/extensions/browser/api/usb/usb_api.h
index 397b1ad78d0..0146e6b7c2f 100644
--- a/chromium/extensions/browser/api/usb/usb_api.h
+++ b/chromium/extensions/browser/api/usb/usb_api.h
@@ -8,12 +8,12 @@
#include <stddef.h>
#include <stdint.h>
+#include <memory>
#include <string>
#include <vector>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "device/usb/usb_device.h"
#include "device/usb/usb_device_filter.h"
#include "device/usb/usb_device_handle.h"
@@ -83,7 +83,7 @@ class UsbFindDevicesFunction : public UIThreadExtensionFunction {
uint16_t vendor_id_;
uint16_t product_id_;
- scoped_ptr<base::ListValue> result_;
+ std::unique_ptr<base::ListValue> result_;
base::Closure barrier_;
DISALLOW_COPY_AND_ASSIGN(UsbFindDevicesFunction);
@@ -125,7 +125,7 @@ class UsbGetUserSelectedDevicesFunction : public UIThreadExtensionFunction {
void OnDevicesChosen(
const std::vector<scoped_refptr<device::UsbDevice>>& devices);
- scoped_ptr<DevicePermissionsPrompt> prompt_;
+ std::unique_ptr<DevicePermissionsPrompt> prompt_;
DISALLOW_COPY_AND_ASSIGN(UsbGetUserSelectedDevicesFunction);
};
@@ -369,7 +369,7 @@ class UsbResetDeviceFunction : public UsbConnectionFunction {
void OnComplete(bool success);
- scoped_ptr<extensions::api::usb::ResetDevice::Params> parameters_;
+ std::unique_ptr<extensions::api::usb::ResetDevice::Params> parameters_;
DISALLOW_COPY_AND_ASSIGN(UsbResetDeviceFunction);
};
diff --git a/chromium/extensions/browser/api/usb/usb_apitest.cc b/chromium/extensions/browser/api/usb/usb_apitest.cc
index 887ae2170fb..e9f41fc69d0 100644
--- a/chromium/extensions/browser/api/usb/usb_apitest.cc
+++ b/chromium/extensions/browser/api/usb/usb_apitest.cc
@@ -6,6 +6,7 @@
#include <numeric>
+#include "base/memory/ptr_util.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/test_utils.h"
@@ -45,8 +46,13 @@ ACTION_TEMPLATE(InvokeCallback,
ACTION_TEMPLATE(InvokeUsbTransferCallback,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_1_VALUE_PARAMS(p1)) {
- net::IOBuffer* io_buffer = new net::IOBuffer(1);
- memset(io_buffer->data(), 0, 1); // Avoid uninitialized reads.
+ net::IOBuffer* io_buffer = nullptr;
+ size_t length = 0;
+ if (p1 != device::USB_TRANSFER_ERROR) {
+ length = 1;
+ io_buffer = new net::IOBuffer(length);
+ memset(io_buffer->data(), 0, length); // Avoid uninitialized reads.
+ }
::std::tr1::get<k>(args).Run(p1, io_buffer, 1);
}
@@ -112,9 +118,9 @@ class TestExtensionsAPIClient : public ShellExtensionsAPIClient {
public:
TestExtensionsAPIClient() : ShellExtensionsAPIClient() {}
- scoped_ptr<DevicePermissionsPrompt> CreateDevicePermissionsPrompt(
+ std::unique_ptr<DevicePermissionsPrompt> CreateDevicePermissionsPrompt(
content::WebContents* web_contents) const override {
- return make_scoped_ptr(new TestDevicePermissionsPrompt(web_contents));
+ return base::WrapUnique(new TestDevicePermissionsPrompt(web_contents));
}
};
@@ -141,7 +147,7 @@ class UsbApiTest : public ShellApiTest {
protected:
scoped_refptr<MockUsbDeviceHandle> mock_device_handle_;
scoped_refptr<MockUsbDevice> mock_device_;
- scoped_ptr<MockDeviceClient> device_client_;
+ std::unique_ptr<MockDeviceClient> device_client_;
};
} // namespace
diff --git a/chromium/extensions/browser/api/usb/usb_event_router.cc b/chromium/extensions/browser/api/usb/usb_event_router.cc
index 8c8acdd4a3d..31b550c1e09 100644
--- a/chromium/extensions/browser/api/usb/usb_event_router.cc
+++ b/chromium/extensions/browser/api/usb/usb_event_router.cc
@@ -105,7 +105,7 @@ void UsbEventRouter::DispatchEvent(const std::string& event_name,
usb::Device device_obj;
UsbGuidMap::Get(browser_context_)->GetApiDevice(device, &device_obj);
- scoped_ptr<Event> event;
+ std::unique_ptr<Event> event;
if (event_name == usb::OnDeviceAdded::kEventName) {
event.reset(new Event(events::USB_ON_DEVICE_ADDED,
usb::OnDeviceAdded::kEventName,
diff --git a/chromium/extensions/browser/api/virtual_keyboard_private/virtual_keyboard_private_api.cc b/chromium/extensions/browser/api/virtual_keyboard_private/virtual_keyboard_private_api.cc
index cb85a9f98f5..cad4f8b9a1d 100644
--- a/chromium/extensions/browser/api/virtual_keyboard_private/virtual_keyboard_private_api.cc
+++ b/chromium/extensions/browser/api/virtual_keyboard_private/virtual_keyboard_private_api.cc
@@ -136,7 +136,7 @@ bool VirtualKeyboardPrivateOpenSettingsFunction::RunSync() {
bool VirtualKeyboardPrivateSetModeFunction::RunSync() {
VirtualKeyboardDelegate* delegate = GetDelegate(this);
if (delegate) {
- scoped_ptr<SetMode::Params> params = SetMode::Params::Create(*args_);
+ std::unique_ptr<SetMode::Params> params = SetMode::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
if (!delegate->SetVirtualKeyboardMode(params->mode)) {
error_ = kVirtualKeyboardNotEnabled;
@@ -152,7 +152,7 @@ bool VirtualKeyboardPrivateSetModeFunction::RunSync() {
bool VirtualKeyboardPrivateSetKeyboardStateFunction::RunSync() {
VirtualKeyboardDelegate* delegate = GetDelegate(this);
if (delegate) {
- scoped_ptr<SetRequestedKeyboardState::Params> params =
+ std::unique_ptr<SetRequestedKeyboardState::Params> params =
SetRequestedKeyboardState::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
if (!delegate->SetRequestedKeyboardState(params->state)) {
diff --git a/chromium/extensions/browser/api/virtual_keyboard_private/virtual_keyboard_private_api.h b/chromium/extensions/browser/api/virtual_keyboard_private/virtual_keyboard_private_api.h
index ebf0720feaf..929eb0aca11 100644
--- a/chromium/extensions/browser/api/virtual_keyboard_private/virtual_keyboard_private_api.h
+++ b/chromium/extensions/browser/api/virtual_keyboard_private/virtual_keyboard_private_api.h
@@ -165,7 +165,7 @@ class VirtualKeyboardAPI : public BrowserContextKeyedAPI {
// Require accces to delegate while incognito or during login.
static const bool kServiceHasOwnInstanceInIncognito = true;
- scoped_ptr<VirtualKeyboardDelegate> delegate_;
+ std::unique_ptr<VirtualKeyboardDelegate> delegate_;
};
} // namespace extensions
diff --git a/chromium/extensions/browser/api/vpn_provider/vpn_provider_api.cc b/chromium/extensions/browser/api/vpn_provider/vpn_provider_api.cc
index 601835db076..5856f3deff5 100644
--- a/chromium/extensions/browser/api/vpn_provider/vpn_provider_api.cc
+++ b/chromium/extensions/browser/api/vpn_provider/vpn_provider_api.cc
@@ -4,11 +4,11 @@
#include "extensions/browser/api/vpn_provider/vpn_provider_api.h"
+#include <memory>
#include <vector>
#include "base/bind.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/values.h"
@@ -189,7 +189,7 @@ VpnProviderCreateConfigFunction::~VpnProviderCreateConfigFunction() {
}
ExtensionFunction::ResponseAction VpnProviderCreateConfigFunction::Run() {
- scoped_ptr<api_vpn::CreateConfig::Params> params(
+ std::unique_ptr<api_vpn::CreateConfig::Params> params(
api_vpn::CreateConfig::Params::Create(*args_));
if (!params) {
return RespondNow(Error("Invalid arguments."));
@@ -219,7 +219,7 @@ VpnProviderDestroyConfigFunction::~VpnProviderDestroyConfigFunction() {
}
ExtensionFunction::ResponseAction VpnProviderDestroyConfigFunction::Run() {
- scoped_ptr<api_vpn::DestroyConfig::Params> params(
+ std::unique_ptr<api_vpn::DestroyConfig::Params> params(
api_vpn::DestroyConfig::Params::Create(*args_));
if (!params) {
return RespondNow(Error("Invalid arguments."));
@@ -246,7 +246,7 @@ VpnProviderSetParametersFunction::~VpnProviderSetParametersFunction() {
}
ExtensionFunction::ResponseAction VpnProviderSetParametersFunction::Run() {
- scoped_ptr<api_vpn::SetParameters::Params> params(
+ std::unique_ptr<api_vpn::SetParameters::Params> params(
api_vpn::SetParameters::Params::Create(*args_));
if (!params) {
return RespondNow(Error("Invalid arguments."));
@@ -281,7 +281,7 @@ VpnProviderSendPacketFunction::~VpnProviderSendPacketFunction() {
}
ExtensionFunction::ResponseAction VpnProviderSendPacketFunction::Run() {
- scoped_ptr<api_vpn::SendPacket::Params> params(
+ std::unique_ptr<api_vpn::SendPacket::Params> params(
api_vpn::SendPacket::Params::Create(*args_));
if (!params) {
return RespondNow(Error("Invalid arguments."));
@@ -310,7 +310,7 @@ VpnProviderNotifyConnectionStateChangedFunction::
ExtensionFunction::ResponseAction
VpnProviderNotifyConnectionStateChangedFunction::Run() {
- scoped_ptr<api_vpn::NotifyConnectionStateChanged::Params> params(
+ std::unique_ptr<api_vpn::NotifyConnectionStateChanged::Params> params(
api_vpn::NotifyConnectionStateChanged::Params::Create(*args_));
if (!params) {
return RespondNow(Error("Invalid arguments."));
diff --git a/chromium/extensions/browser/api/vpn_provider/vpn_service.cc b/chromium/extensions/browser/api/vpn_provider/vpn_service.cc
index 09452d5290f..1f1b95bb251 100644
--- a/chromium/extensions/browser/api/vpn_provider/vpn_service.cc
+++ b/chromium/extensions/browser/api/vpn_provider/vpn_service.cc
@@ -99,7 +99,7 @@ void VpnService::VpnConfiguration::OnPacketReceived(
if (!vpn_service_) {
return;
}
- scoped_ptr<base::ListValue> event_args =
+ std::unique_ptr<base::ListValue> event_args =
api_vpn::OnPacketReceived::Create(data);
vpn_service_->SendSignalToExtension(
extension_id_, extensions::events::VPN_PROVIDER_ON_PACKET_RECEIVED,
@@ -124,8 +124,9 @@ void VpnService::VpnConfiguration::OnPlatformMessage(uint32_t message) {
// TODO(kaliamoorthi): Update the lower layers to get the error message and
// pass in the error instead of std::string().
- scoped_ptr<base::ListValue> event_args = api_vpn::OnPlatformMessage::Create(
- configuration_name_, platform_message, std::string());
+ std::unique_ptr<base::ListValue> event_args =
+ api_vpn::OnPlatformMessage::Create(configuration_name_, platform_message,
+ std::string());
vpn_service_->SendSignalToExtension(
extension_id_, extensions::events::VPN_PROVIDER_ON_PLATFORM_MESSAGE,
@@ -225,7 +226,7 @@ void VpnService::OnConfigurationRemoved(const std::string& service_path,
VpnConfiguration* configuration =
service_path_to_configuration_map_[service_path];
- scoped_ptr<base::ListValue> event_args =
+ std::unique_ptr<base::ListValue> event_args =
api_vpn::OnConfigRemoved::Create(configuration->configuration_name());
SendSignalToExtension(configuration->extension_id(),
extensions::events::VPN_PROVIDER_ON_CONFIG_REMOVED,
@@ -282,8 +283,7 @@ void VpnService::OnGetPropertiesSuccess(
void VpnService::OnGetPropertiesFailure(
const std::string& error_name,
- scoped_ptr<base::DictionaryValue> error_data) {
-}
+ std::unique_ptr<base::DictionaryValue> error_data) {}
void VpnService::NetworkListChanged() {
NetworkStateHandler::NetworkStateList network_list;
@@ -512,7 +512,7 @@ void VpnService::OnCreateConfigurationFailure(
const VpnService::FailureCallback& callback,
VpnConfiguration* configuration,
const std::string& error_name,
- scoped_ptr<base::DictionaryValue> error_data) {
+ std::unique_ptr<base::DictionaryValue> error_data) {
DestroyConfigurationInternal(configuration);
callback.Run(error_name, std::string());
}
@@ -525,7 +525,7 @@ void VpnService::OnRemoveConfigurationSuccess(
void VpnService::OnRemoveConfigurationFailure(
const VpnService::FailureCallback& callback,
const std::string& error_name,
- scoped_ptr<base::DictionaryValue> error_data) {
+ std::unique_ptr<base::DictionaryValue> error_data) {
callback.Run(error_name, std::string());
}
@@ -533,8 +533,8 @@ void VpnService::SendSignalToExtension(
const std::string& extension_id,
extensions::events::HistogramValue histogram_value,
const std::string& event_name,
- scoped_ptr<base::ListValue> event_args) {
- scoped_ptr<extensions::Event> event(new extensions::Event(
+ std::unique_ptr<base::ListValue> event_args) {
+ std::unique_ptr<extensions::Event> event(new extensions::Event(
histogram_value, event_name, std::move(event_args), browser_context_));
event_router_->DispatchEventToExtension(extension_id, std::move(event));
diff --git a/chromium/extensions/browser/api/vpn_provider/vpn_service.h b/chromium/extensions/browser/api/vpn_provider/vpn_service.h
index 6e515c9b41f..b439a3e255e 100644
--- a/chromium/extensions/browser/api/vpn_provider/vpn_service.h
+++ b/chromium/extensions/browser/api/vpn_provider/vpn_service.h
@@ -6,12 +6,12 @@
#define EXTENSIONS_BROWSER_API_VPN_PROVIDER_VPN_SERVICE_H_
#include <map>
+#include <memory>
#include <string>
#include <vector>
#include "base/callback.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chromeos/network/network_configuration_observer.h"
#include "chromeos/network/network_state_handler_observer.h"
@@ -178,7 +178,7 @@ class VpnService : public KeyedService,
const FailureCallback& callback,
VpnConfiguration* configuration,
const std::string& error_name,
- scoped_ptr<base::DictionaryValue> error_data);
+ std::unique_ptr<base::DictionaryValue> error_data);
// Callback used to indicate that removing a configuration succeeded.
void OnRemoveConfigurationSuccess(const SuccessCallback& callback);
@@ -187,15 +187,16 @@ class VpnService : public KeyedService,
void OnRemoveConfigurationFailure(
const FailureCallback& callback,
const std::string& error_name,
- scoped_ptr<base::DictionaryValue> error_data);
+ std::unique_ptr<base::DictionaryValue> error_data);
// Callback used to indicate that GetProperties was successful.
void OnGetPropertiesSuccess(const std::string& service_path,
const base::DictionaryValue& dictionary);
// Callback used to indicate that GetProperties failed.
- void OnGetPropertiesFailure(const std::string& error_name,
- scoped_ptr<base::DictionaryValue> error_data);
+ void OnGetPropertiesFailure(
+ const std::string& error_name,
+ std::unique_ptr<base::DictionaryValue> error_data);
// Creates and adds the configuration to the internal store.
VpnConfiguration* CreateConfigurationInternal(
@@ -216,7 +217,7 @@ class VpnService : public KeyedService,
void SendSignalToExtension(const std::string& extension_id,
extensions::events::HistogramValue histogram_value,
const std::string& event_name,
- scoped_ptr<base::ListValue> event_args);
+ std::unique_ptr<base::ListValue> event_args);
// Destroy configurations belonging to the extension.
void DestroyConfigurationsForExtension(
diff --git a/chromium/extensions/browser/api/web_contents_capture_client.cc b/chromium/extensions/browser/api/web_contents_capture_client.cc
index 6dff09e7d56..97b8436f495 100644
--- a/chromium/extensions/browser/api/web_contents_capture_client.cc
+++ b/chromium/extensions/browser/api/web_contents_capture_client.cc
@@ -11,11 +11,11 @@
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_function.h"
#include "extensions/common/constants.h"
+#include "ui/display/display.h"
+#include "ui/display/screen.h"
#include "ui/gfx/codec/jpeg_codec.h"
#include "ui/gfx/codec/png_codec.h"
-#include "ui/gfx/display.h"
#include "ui/gfx/geometry/size_conversions.h"
-#include "ui/gfx/screen.h"
using content::RenderWidgetHost;
using content::RenderWidgetHostView;
@@ -64,7 +64,7 @@ bool WebContentsCaptureClient::CaptureAsync(
const gfx::Size view_size = view->GetViewBounds().size();
gfx::Size bitmap_size = view_size;
const gfx::NativeView native_view = view->GetNativeView();
- gfx::Screen* const screen = gfx::Screen::GetScreen();
+ display::Screen* const screen = display::Screen::GetScreen();
const float scale =
screen->GetDisplayNearestWindow(native_view).device_scale_factor();
if (scale > 1.0f)
diff --git a/chromium/extensions/browser/api/web_request/form_data_parser.cc b/chromium/extensions/browser/api/web_request/form_data_parser.cc
index f81c1099564..6966e431b82 100644
--- a/chromium/extensions/browser/api/web_request/form_data_parser.cc
+++ b/chromium/extensions/browser/api/web_request/form_data_parser.cc
@@ -296,7 +296,7 @@ FormDataParser::Result::~Result() {}
FormDataParser::~FormDataParser() {}
// static
-scoped_ptr<FormDataParser> FormDataParser::Create(
+std::unique_ptr<FormDataParser> FormDataParser::Create(
const net::URLRequest& request) {
std::string value;
const bool found = request.extra_request_headers().GetHeader(
@@ -305,7 +305,7 @@ scoped_ptr<FormDataParser> FormDataParser::Create(
}
// static
-scoped_ptr<FormDataParser> FormDataParser::CreateFromContentTypeHeader(
+std::unique_ptr<FormDataParser> FormDataParser::CreateFromContentTypeHeader(
const std::string* content_type_header) {
enum ParserChoice {URL_ENCODED, MULTIPART, ERROR_CHOICE};
ParserChoice choice = ERROR_CHOICE;
@@ -326,7 +326,7 @@ scoped_ptr<FormDataParser> FormDataParser::CreateFromContentTypeHeader(
size_t offset = content_type_header->find(kBoundaryString);
if (offset == std::string::npos) {
// Malformed header.
- return scoped_ptr<FormDataParser>();
+ return std::unique_ptr<FormDataParser>();
}
offset += sizeof(kBoundaryString) - 1;
boundary = content_type_header->substr(
@@ -339,14 +339,15 @@ scoped_ptr<FormDataParser> FormDataParser::CreateFromContentTypeHeader(
switch (choice) {
case URL_ENCODED:
- return scoped_ptr<FormDataParser>(new FormDataParserUrlEncoded());
+ return std::unique_ptr<FormDataParser>(new FormDataParserUrlEncoded());
case MULTIPART:
- return scoped_ptr<FormDataParser>(new FormDataParserMultipart(boundary));
+ return std::unique_ptr<FormDataParser>(
+ new FormDataParserMultipart(boundary));
case ERROR_CHOICE:
- return scoped_ptr<FormDataParser>();
+ return std::unique_ptr<FormDataParser>();
}
NOTREACHED(); // Some compilers do not believe this is unreachable.
- return scoped_ptr<FormDataParser>();
+ return std::unique_ptr<FormDataParser>();
}
FormDataParser::FormDataParser() {}
diff --git a/chromium/extensions/browser/api/web_request/form_data_parser.h b/chromium/extensions/browser/api/web_request/form_data_parser.h
index 0c49caa0138..7487a2439d5 100644
--- a/chromium/extensions/browser/api/web_request/form_data_parser.h
+++ b/chromium/extensions/browser/api/web_request/form_data_parser.h
@@ -5,10 +5,10 @@
#ifndef EXTENSIONS_BROWSER_API_WEB_REQUEST_FORM_DATA_PARSER_H_
#define EXTENSIONS_BROWSER_API_WEB_REQUEST_FORM_DATA_PARSER_H_
+#include <memory>
#include <string>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
// Cannot forward declare StringPiece because it is a typedef.
#include "base/strings/string_piece.h"
@@ -44,12 +44,12 @@ class FormDataParser {
// Creates a correct parser instance based on the |request|. Returns NULL
// on failure.
- static scoped_ptr<FormDataParser> Create(const net::URLRequest& request);
+ static std::unique_ptr<FormDataParser> Create(const net::URLRequest& request);
// Creates a correct parser instance based on |content_type_header|, the
// "Content-Type" request header value. If |content_type_header| is NULL, it
// defaults to "application/x-www-form-urlencoded". Returns NULL on failure.
- static scoped_ptr<FormDataParser> CreateFromContentTypeHeader(
+ static std::unique_ptr<FormDataParser> CreateFromContentTypeHeader(
const std::string* content_type_header);
// Returns true if there was some data, it was well formed and all was read.
diff --git a/chromium/extensions/browser/api/web_request/form_data_parser_unittest.cc b/chromium/extensions/browser/api/web_request/form_data_parser_unittest.cc
index 6f700c7ae6d..8a5648f626e 100644
--- a/chromium/extensions/browser/api/web_request/form_data_parser_unittest.cc
+++ b/chromium/extensions/browser/api/web_request/form_data_parser_unittest.cc
@@ -16,11 +16,12 @@ namespace {
// Attempts to create a parser corresponding to the |content_type_header|.
// On success, returns the parser.
-scoped_ptr<FormDataParser> InitParser(const std::string& content_type_header) {
- scoped_ptr<FormDataParser> parser(
+std::unique_ptr<FormDataParser> InitParser(
+ const std::string& content_type_header) {
+ std::unique_ptr<FormDataParser> parser(
FormDataParser::CreateFromContentTypeHeader(&content_type_header));
if (parser.get() == NULL)
- return scoped_ptr<FormDataParser>();
+ return std::unique_ptr<FormDataParser>();
return parser;
}
@@ -33,7 +34,7 @@ bool RunParser(const std::string& content_type_header,
std::vector<std::string>* output) {
DCHECK(output);
output->clear();
- scoped_ptr<FormDataParser> parser(InitParser(content_type_header));
+ std::unique_ptr<FormDataParser> parser(InitParser(content_type_header));
if (!parser.get())
return false;
FormDataParser::Result result;
@@ -54,7 +55,7 @@ bool RunParser(const std::string& content_type_header,
bool CheckParserFails(const std::string& content_type_header,
const std::vector<const base::StringPiece*>& bytes) {
std::vector<std::string> output;
- scoped_ptr<FormDataParser> parser(InitParser(content_type_header));
+ std::unique_ptr<FormDataParser> parser(InitParser(content_type_header));
if (!parser.get())
return false;
FormDataParser::Result result;
diff --git a/chromium/extensions/browser/api/web_request/upload_data_presenter.cc b/chromium/extensions/browser/api/web_request/upload_data_presenter.cc
index bdd80d69081..48a88c7d32e 100644
--- a/chromium/extensions/browser/api/web_request/upload_data_presenter.cc
+++ b/chromium/extensions/browser/api/web_request/upload_data_presenter.cc
@@ -81,7 +81,7 @@ bool RawDataPresenter::Succeeded() {
return success_;
}
-scoped_ptr<base::Value> RawDataPresenter::Result() {
+std::unique_ptr<base::Value> RawDataPresenter::Result() {
if (!success_)
return nullptr;
@@ -136,7 +136,7 @@ bool ParsedDataPresenter::Succeeded() {
return success_;
}
-scoped_ptr<base::Value> ParsedDataPresenter::Result() {
+std::unique_ptr<base::Value> ParsedDataPresenter::Result() {
if (!success_)
return nullptr;
@@ -144,9 +144,10 @@ scoped_ptr<base::Value> ParsedDataPresenter::Result() {
}
// static
-scoped_ptr<ParsedDataPresenter> ParsedDataPresenter::CreateForTests() {
+std::unique_ptr<ParsedDataPresenter> ParsedDataPresenter::CreateForTests() {
const std::string form_type("application/x-www-form-urlencoded");
- return scoped_ptr<ParsedDataPresenter>(new ParsedDataPresenter(form_type));
+ return std::unique_ptr<ParsedDataPresenter>(
+ new ParsedDataPresenter(form_type));
}
ParsedDataPresenter::ParsedDataPresenter(const std::string& form_type)
diff --git a/chromium/extensions/browser/api/web_request/upload_data_presenter.h b/chromium/extensions/browser/api/web_request/upload_data_presenter.h
index 90e3d44796b..05630f3dcbc 100644
--- a/chromium/extensions/browser/api/web_request/upload_data_presenter.h
+++ b/chromium/extensions/browser/api/web_request/upload_data_presenter.h
@@ -7,12 +7,12 @@
#include <stddef.h>
+#include <memory>
#include <string>
#include <vector>
#include "base/gtest_prod_util.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
namespace base {
class DictionaryValue;
@@ -57,7 +57,7 @@ class UploadDataPresenter {
virtual ~UploadDataPresenter();
virtual void FeedNext(const net::UploadElementReader& reader) = 0;
virtual bool Succeeded() = 0;
- virtual scoped_ptr<base::Value> Result() = 0;
+ virtual std::unique_ptr<base::Value> Result() = 0;
protected:
UploadDataPresenter() {}
@@ -77,7 +77,7 @@ class RawDataPresenter : public UploadDataPresenter {
// Implementation of UploadDataPresenter.
void FeedNext(const net::UploadElementReader& reader) override;
bool Succeeded() override;
- scoped_ptr<base::Value> Result() override;
+ std::unique_ptr<base::Value> Result() override;
private:
void FeedNextBytes(const char* bytes, size_t size);
@@ -85,7 +85,7 @@ class RawDataPresenter : public UploadDataPresenter {
FRIEND_TEST_ALL_PREFIXES(WebRequestUploadDataPresenterTest, RawData);
bool success_;
- scoped_ptr<base::ListValue> list_;
+ std::unique_ptr<base::ListValue> list_;
DISALLOW_COPY_AND_ASSIGN(RawDataPresenter);
};
@@ -107,12 +107,12 @@ class ParsedDataPresenter : public UploadDataPresenter {
// Implementation of UploadDataPresenter.
void FeedNext(const net::UploadElementReader& reader) override;
bool Succeeded() override;
- scoped_ptr<base::Value> Result() override;
+ std::unique_ptr<base::Value> Result() override;
// Allows to create ParsedDataPresenter without the URLRequest. Uses the
// parser for "application/x-www-form-urlencoded" form encoding. Only use this
// in tests.
- static scoped_ptr<ParsedDataPresenter> CreateForTests();
+ static std::unique_ptr<ParsedDataPresenter> CreateForTests();
private:
// This constructor is used in CreateForTests.
@@ -120,9 +120,9 @@ class ParsedDataPresenter : public UploadDataPresenter {
// Clears resources and the success flag.
void Abort();
- scoped_ptr<FormDataParser> parser_;
+ std::unique_ptr<FormDataParser> parser_;
bool success_;
- scoped_ptr<base::DictionaryValue> dictionary_;
+ std::unique_ptr<base::DictionaryValue> dictionary_;
DISALLOW_COPY_AND_ASSIGN(ParsedDataPresenter);
};
diff --git a/chromium/extensions/browser/api/web_request/upload_data_presenter_unittest.cc b/chromium/extensions/browser/api/web_request/upload_data_presenter_unittest.cc
index f28619dfbd3..50b648680ca 100644
--- a/chromium/extensions/browser/api/web_request/upload_data_presenter_unittest.cc
+++ b/chromium/extensions/browser/api/web_request/upload_data_presenter_unittest.cc
@@ -23,18 +23,18 @@ TEST(WebRequestUploadDataPresenterTest, ParsedData) {
net::UploadBytesElementReader element(block, sizeof(block) - 1);
// Expected output.
- scoped_ptr<base::ListValue> values(new base::ListValue);
+ std::unique_ptr<base::ListValue> values(new base::ListValue);
values->Append(new base::StringValue("value"));
base::DictionaryValue expected_form;
expected_form.SetWithoutPathExpansion("key.with.dots", values.release());
// Real output.
- scoped_ptr<ParsedDataPresenter> parsed_data_presenter(
+ std::unique_ptr<ParsedDataPresenter> parsed_data_presenter(
ParsedDataPresenter::CreateForTests());
ASSERT_TRUE(parsed_data_presenter.get() != NULL);
parsed_data_presenter->FeedNext(element);
EXPECT_TRUE(parsed_data_presenter->Succeeded());
- scoped_ptr<base::Value> result = parsed_data_presenter->Result();
+ std::unique_ptr<base::Value> result = parsed_data_presenter->Result();
ASSERT_TRUE(result.get() != NULL);
EXPECT_TRUE(result->Equals(&expected_form));
@@ -49,13 +49,13 @@ TEST(WebRequestUploadDataPresenterTest, RawData) {
const size_t block2_size = sizeof(block2) - 1;
// Expected output.
- scoped_ptr<base::BinaryValue> expected_a(
+ std::unique_ptr<base::BinaryValue> expected_a(
base::BinaryValue::CreateWithCopiedBuffer(block1, block1_size));
ASSERT_TRUE(expected_a.get() != NULL);
- scoped_ptr<base::StringValue> expected_b(
+ std::unique_ptr<base::StringValue> expected_b(
new base::StringValue(kFilename));
ASSERT_TRUE(expected_b.get() != NULL);
- scoped_ptr<base::BinaryValue> expected_c(
+ std::unique_ptr<base::BinaryValue> expected_c(
base::BinaryValue::CreateWithCopiedBuffer(block2, block2_size));
ASSERT_TRUE(expected_c.get() != NULL);
@@ -73,7 +73,7 @@ TEST(WebRequestUploadDataPresenterTest, RawData) {
raw_presenter.FeedNextFile(kFilename);
raw_presenter.FeedNextBytes(block2, block2_size);
EXPECT_TRUE(raw_presenter.Succeeded());
- scoped_ptr<base::Value> result = raw_presenter.Result();
+ std::unique_ptr<base::Value> result = raw_presenter.Result();
ASSERT_TRUE(result.get() != NULL);
EXPECT_TRUE(result->Equals(&expected_list));
diff --git a/chromium/extensions/browser/api/web_request/web_request_api.cc b/chromium/extensions/browser/api/web_request/web_request_api.cc
index d8da8ecdc05..34922a281af 100644
--- a/chromium/extensions/browser/api/web_request/web_request_api.cc
+++ b/chromium/extensions/browser/api/web_request/web_request_api.cc
@@ -7,6 +7,7 @@
#include <stddef.h>
#include <algorithm>
+#include <memory>
#include <utility>
#include <vector>
@@ -15,7 +16,6 @@
#include "base/json/json_writer.h"
#include "base/lazy_instance.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
@@ -234,7 +234,7 @@ void SendOnMessageEventOnUI(
const std::string& extension_id,
bool is_web_view_guest,
const WebViewRendererState::WebViewInfo& web_view_info,
- scoped_ptr<WebRequestEventDetails> event_details) {
+ std::unique_ptr<WebRequestEventDetails> event_details) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
content::BrowserContext* browser_context =
@@ -242,7 +242,7 @@ void SendOnMessageEventOnUI(
if (!ExtensionsBrowserClient::Get()->IsValidContext(browser_context))
return;
- scoped_ptr<base::ListValue> event_args(new base::ListValue);
+ std::unique_ptr<base::ListValue> event_args(new base::ListValue);
event_details->DetermineFrameIdOnUI();
event_args->Append(event_details->GetAndClearDict());
@@ -264,7 +264,7 @@ void SendOnMessageEventOnUI(
event_name = declarative_keys::kOnMessage;
}
- scoped_ptr<Event> event(new Event(
+ std::unique_ptr<Event> event(new Event(
histogram_value, event_name, std::move(event_args), browser_context,
GURL(), EventRouter::USER_GESTURE_UNKNOWN, event_filtering_info));
event_router->DispatchEventToExtension(extension_id, std::move(event));
@@ -594,11 +594,11 @@ void ExtensionWebRequestEventRouter::RegisterRulesRegistry(
rules_registries_.erase(key);
}
-scoped_ptr<WebRequestEventDetails>
+std::unique_ptr<WebRequestEventDetails>
ExtensionWebRequestEventRouter::CreateEventDetails(
const net::URLRequest* request,
int extra_info_spec) {
- scoped_ptr<WebRequestEventDetails> event_details(
+ std::unique_ptr<WebRequestEventDetails> event_details(
new WebRequestEventDetails(request, extra_info_spec));
int render_frame_id = -1;
@@ -646,7 +646,7 @@ int ExtensionWebRequestEventRouter::OnBeforeRequest(
web_request::OnBeforeRequest::kEventName, request, &extra_info_spec);
if (!listeners.empty() &&
!GetAndSetSignaled(request->identifier(), kOnBeforeRequest)) {
- scoped_ptr<WebRequestEventDetails> event_details(
+ std::unique_ptr<WebRequestEventDetails> event_details(
CreateEventDetails(request, extra_info_spec));
event_details->SetRequestBody(request);
@@ -695,7 +695,7 @@ int ExtensionWebRequestEventRouter::OnBeforeSendHeaders(
request, &extra_info_spec);
if (!listeners.empty() &&
!GetAndSetSignaled(request->identifier(), kOnBeforeSendHeaders)) {
- scoped_ptr<WebRequestEventDetails> event_details(
+ std::unique_ptr<WebRequestEventDetails> event_details(
CreateEventDetails(request, extra_info_spec));
event_details->SetRequestHeaders(*headers);
@@ -743,7 +743,7 @@ void ExtensionWebRequestEventRouter::OnSendHeaders(
if (listeners.empty())
return;
- scoped_ptr<WebRequestEventDetails> event_details(
+ std::unique_ptr<WebRequestEventDetails> event_details(
CreateEventDetails(request, extra_info_spec));
event_details->SetRequestHeaders(headers);
@@ -774,7 +774,7 @@ int ExtensionWebRequestEventRouter::OnHeadersReceived(
if (!listeners.empty() &&
!GetAndSetSignaled(request->identifier(), kOnHeadersReceived)) {
- scoped_ptr<WebRequestEventDetails> event_details(
+ std::unique_ptr<WebRequestEventDetails> event_details(
CreateEventDetails(request, extra_info_spec));
event_details->SetResponseHeaders(request, original_response_headers);
@@ -826,7 +826,7 @@ ExtensionWebRequestEventRouter::OnAuthRequired(
if (listeners.empty())
return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION;
- scoped_ptr<WebRequestEventDetails> event_details(
+ std::unique_ptr<WebRequestEventDetails> event_details(
CreateEventDetails(request, extra_info_spec));
event_details->SetResponseHeaders(request, request->response_headers());
event_details->SetAuthInfo(auth_info);
@@ -868,7 +868,7 @@ void ExtensionWebRequestEventRouter::OnBeforeRedirect(
if (listeners.empty())
return;
- scoped_ptr<WebRequestEventDetails> event_details(
+ std::unique_ptr<WebRequestEventDetails> event_details(
CreateEventDetails(request, extra_info_spec));
event_details->SetResponseHeaders(request, request->response_headers());
event_details->SetResponseSource(request);
@@ -895,7 +895,7 @@ void ExtensionWebRequestEventRouter::OnResponseStarted(
if (listeners.empty())
return;
- scoped_ptr<WebRequestEventDetails> event_details(
+ std::unique_ptr<WebRequestEventDetails> event_details(
CreateEventDetails(request, extra_info_spec));
event_details->SetResponseHeaders(request, request->response_headers());
event_details->SetResponseSource(request);
@@ -933,7 +933,7 @@ void ExtensionWebRequestEventRouter::OnCompleted(
if (listeners.empty())
return;
- scoped_ptr<WebRequestEventDetails> event_details(
+ std::unique_ptr<WebRequestEventDetails> event_details(
CreateEventDetails(request, extra_info_spec));
event_details->SetResponseHeaders(request, request->response_headers());
event_details->SetResponseSource(request);
@@ -973,7 +973,7 @@ void ExtensionWebRequestEventRouter::OnErrorOccurred(
if (listeners.empty())
return;
- scoped_ptr<WebRequestEventDetails> event_details(
+ std::unique_ptr<WebRequestEventDetails> event_details(
CreateEventDetails(request, extra_info_spec));
if (started)
event_details->SetResponseSource(request);
@@ -1005,12 +1005,12 @@ bool ExtensionWebRequestEventRouter::DispatchEvent(
void* browser_context,
net::URLRequest* request,
const std::vector<const EventListener*>& listeners,
- scoped_ptr<WebRequestEventDetails> event_details) {
+ std::unique_ptr<WebRequestEventDetails> event_details) {
// TODO(mpcomplete): Consider consolidating common (extension_id,json_args)
// pairs into a single message sent to a list of sub_event_names.
int num_handlers_blocking = 0;
- scoped_ptr<std::vector<EventListener>> listeners_to_dispatch(
+ std::unique_ptr<std::vector<EventListener>> listeners_to_dispatch(
new std::vector<EventListener>());
listeners_to_dispatch->reserve(listeners.size());
for (const EventListener* listener : listeners) {
@@ -1050,8 +1050,8 @@ bool ExtensionWebRequestEventRouter::DispatchEvent(
void ExtensionWebRequestEventRouter::DispatchEventToListeners(
void* browser_context,
- scoped_ptr<std::vector<EventListener>> listeners,
- scoped_ptr<WebRequestEventDetails> event_details) {
+ std::unique_ptr<std::vector<EventListener>> listeners,
+ std::unique_ptr<WebRequestEventDetails> event_details) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(listeners.get());
DCHECK_GT(listeners->size(), 0UL);
@@ -1084,7 +1084,7 @@ void ExtensionWebRequestEventRouter::DispatchEventToListeners(
continue;
// Filter out the optional keys that this listener didn't request.
- scoped_ptr<base::ListValue> args_filtered(new base::ListValue);
+ std::unique_ptr<base::ListValue> args_filtered(new base::ListValue);
args_filtered->Append(
event_details->GetFilteredDict(listener->extra_info_spec));
@@ -1182,6 +1182,16 @@ void ExtensionWebRequestEventRouter::RemoveEventListener(
if (it == event_listeners.end())
return;
+#if defined(OS_WIN)
+ // Debugging https://crbug.com/589735
+ // Please post crash reports at the following lines to the above issue.
+ unsigned event_listener_count = event_listeners.count(listener);
+ CHECK_GE(event_listener_count, 0u);
+ CHECK_GE(event_listener_count, 1u);
+ CHECK_LE(event_listener_count, 2u);
+ CHECK_EQ(event_listener_count, 1u);
+ CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+#endif // OS_WIN
CHECK_EQ(event_listeners.count(listener), 1u) <<
"extension=" << extension_id << " event=" << event_name;
@@ -1492,7 +1502,7 @@ helpers::EventResponseDelta* CalculateDelta(
}
base::Value* SerializeResponseHeaders(const helpers::ResponseHeaders& headers) {
- scoped_ptr<base::ListValue> serialized_headers(new base::ListValue());
+ std::unique_ptr<base::ListValue> serialized_headers(new base::ListValue());
for (const auto& it : headers) {
serialized_headers->Append(
helpers::CreateHeaderDictionary(it.first, it.second));
@@ -1507,9 +1517,9 @@ base::Value* SerializeResponseHeaders(const helpers::ResponseHeaders& headers) {
template <typename CookieType>
base::ListValue* SummarizeCookieModifications(
const std::vector<linked_ptr<CookieType>>& modifications) {
- scoped_ptr<base::ListValue> cookie_modifications(new base::ListValue());
+ std::unique_ptr<base::ListValue> cookie_modifications(new base::ListValue());
for (const auto& it : modifications) {
- scoped_ptr<base::DictionaryValue> summary(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> summary(new base::DictionaryValue());
const CookieType& mod = *(it.get());
switch (mod.type) {
case helpers::ADD:
@@ -1552,16 +1562,16 @@ base::ListValue* SummarizeCookieModifications(
// Converts an EventResponseDelta object to a dictionary value suitable for the
// activity log.
-scoped_ptr<base::DictionaryValue> SummarizeResponseDelta(
+std::unique_ptr<base::DictionaryValue> SummarizeResponseDelta(
const std::string& event_name,
const helpers::EventResponseDelta& delta) {
- scoped_ptr<base::DictionaryValue> details(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> details(new base::DictionaryValue());
if (delta.cancel)
details->SetBoolean(activity_log::kCancelKey, true);
if (!delta.new_url.is_empty())
details->SetString(activity_log::kNewUrlKey, delta.new_url.spec());
- scoped_ptr<base::ListValue> modified_headers(new base::ListValue());
+ std::unique_ptr<base::ListValue> modified_headers(new base::ListValue());
net::HttpRequestHeaders::Iterator iter(delta.modified_request_headers);
while (iter.GetNext()) {
modified_headers->Append(
@@ -1572,7 +1582,7 @@ scoped_ptr<base::DictionaryValue> SummarizeResponseDelta(
modified_headers.release());
}
- scoped_ptr<base::ListValue> deleted_headers(new base::ListValue());
+ std::unique_ptr<base::ListValue> deleted_headers(new base::ListValue());
deleted_headers->AppendStrings(delta.deleted_request_headers);
if (!deleted_headers->empty()) {
details->Set(activity_log::kDeletedRequestHeadersKey,
@@ -1610,7 +1620,7 @@ void ExtensionWebRequestEventRouter::LogExtensionActivity(
const std::string& extension_id,
const GURL& url,
const std::string& api_call,
- scoped_ptr<base::DictionaryValue> details) {
+ std::unique_ptr<base::DictionaryValue> details) {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(
BrowserThread::UI,
@@ -1638,7 +1648,7 @@ void ExtensionWebRequestEventRouter::DecrementBlockCount(
const std::string& event_name,
uint64_t request_id,
EventResponse* response) {
- scoped_ptr<EventResponse> response_scoped(response);
+ std::unique_ptr<EventResponse> response_scoped(response);
// It's possible that this request was deleted, or cancelled by a previous
// event handler. If so, ignore this response.
@@ -1704,7 +1714,7 @@ void ExtensionWebRequestEventRouter::SendMessages(
for (const auto& delta : deltas) {
const std::set<std::string>& messages = delta->messages_to_extension;
for (const std::string& message : messages) {
- scoped_ptr<WebRequestEventDetails> event_details(
+ std::unique_ptr<WebRequestEventDetails> event_details(
CreateEventDetails(blocked_request.request, /* extra_info_spec */ 0));
WebViewRendererState::WebViewInfo web_view_info;
bool is_web_view_guest = GetWebViewInfo(blocked_request.request,
@@ -2120,7 +2130,7 @@ void WebRequestInternalEventHandledFunction::RespondWithError(
const std::string& event_name,
const std::string& sub_event_name,
uint64_t request_id,
- scoped_ptr<ExtensionWebRequestEventRouter::EventResponse> response,
+ std::unique_ptr<ExtensionWebRequestEventRouter::EventResponse> response,
const std::string& error) {
error_ = error;
ExtensionWebRequestEventRouter::GetInstance()->OnEventHandled(
@@ -2145,7 +2155,7 @@ bool WebRequestInternalEventHandledFunction::RunSync() {
EXTENSION_FUNCTION_VALIDATE(base::StringToUint64(request_id_str,
&request_id));
- scoped_ptr<ExtensionWebRequestEventRouter::EventResponse> response;
+ std::unique_ptr<ExtensionWebRequestEventRouter::EventResponse> response;
if (HasOptionalArgument(3)) {
base::DictionaryValue* value = NULL;
EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(3, &value));
@@ -2196,8 +2206,8 @@ bool WebRequestInternalEventHandledFunction::RunSync() {
}
base::ListValue* headers_value = NULL;
- scoped_ptr<net::HttpRequestHeaders> request_headers;
- scoped_ptr<helpers::ResponseHeaders> response_headers;
+ std::unique_ptr<net::HttpRequestHeaders> request_headers;
+ std::unique_ptr<helpers::ResponseHeaders> response_headers;
if (has_request_headers) {
request_headers.reset(new net::HttpRequestHeaders());
EXTENSION_FUNCTION_VALIDATE(value->GetList(keys::kRequestHeadersKey,
diff --git a/chromium/extensions/browser/api/web_request/web_request_api.h b/chromium/extensions/browser/api/web_request/web_request_api.h
index 382860d7420..51948382bbc 100644
--- a/chromium/extensions/browser/api/web_request/web_request_api.h
+++ b/chromium/extensions/browser/api/web_request/web_request_api.h
@@ -146,11 +146,11 @@ class ExtensionWebRequestEventRouter
// Response values. These are mutually exclusive.
bool cancel;
GURL new_url;
- scoped_ptr<net::HttpRequestHeaders> request_headers;
- scoped_ptr<extension_web_request_api_helpers::ResponseHeaders>
+ std::unique_ptr<net::HttpRequestHeaders> request_headers;
+ std::unique_ptr<extension_web_request_api_helpers::ResponseHeaders>
response_headers;
- scoped_ptr<net::AuthCredentials> auth_credentials;
+ std::unique_ptr<net::AuthCredentials> auth_credentials;
private:
DISALLOW_COPY_AND_ASSIGN(EventResponse);
@@ -325,12 +325,12 @@ class ExtensionWebRequestEventRouter
bool DispatchEvent(void* browser_context,
net::URLRequest* request,
const std::vector<const EventListener*>& listeners,
- scoped_ptr<WebRequestEventDetails> event_details);
+ std::unique_ptr<WebRequestEventDetails> event_details);
void DispatchEventToListeners(
void* browser_context,
- scoped_ptr<std::vector<EventListener>> listeners,
- scoped_ptr<WebRequestEventDetails> event_details);
+ std::unique_ptr<std::vector<EventListener>> listeners,
+ std::unique_ptr<WebRequestEventDetails> event_details);
// Returns a list of event listeners that care about the given event, based
// on their filter parameters. |extra_info_spec| will contain the combined
@@ -373,13 +373,12 @@ class ExtensionWebRequestEventRouter
EventResponse* response);
// Logs an extension action.
- void LogExtensionActivity(
- void* browser_context_id,
- bool is_incognito,
- const std::string& extension_id,
- const GURL& url,
- const std::string& api_call,
- scoped_ptr<base::DictionaryValue> details);
+ void LogExtensionActivity(void* browser_context_id,
+ bool is_incognito,
+ const std::string& extension_id,
+ const GURL& url,
+ const std::string& api_call,
+ std::unique_ptr<base::DictionaryValue> details);
// Processes the generated deltas from blocked_requests_ on the specified
// request. If |call_back| is true, the callback registered in
@@ -418,7 +417,7 @@ class ExtensionWebRequestEventRouter
extensions::RequestStage request_stage);
// Returns event details for a given request.
- scoped_ptr<WebRequestEventDetails> CreateEventDetails(
+ std::unique_ptr<WebRequestEventDetails> CreateEventDetails(
const net::URLRequest* request,
int extra_info_spec);
@@ -465,7 +464,7 @@ class ExtensionWebRequestEventRouter
// Keeps track of time spent waiting on extensions using the blocking
// webRequest API.
- scoped_ptr<ExtensionWebRequestTimeTracker> request_time_tracker_;
+ std::unique_ptr<ExtensionWebRequestTimeTracker> request_time_tracker_;
CallbacksForPageLoad callbacks_for_page_load_;
@@ -475,7 +474,7 @@ class ExtensionWebRequestEventRouter
std::map<RulesRegistryKey,
scoped_refptr<extensions::WebRequestRulesRegistry> > rules_registries_;
- scoped_ptr<extensions::WebRequestEventRouterDelegate>
+ std::unique_ptr<extensions::WebRequestEventRouterDelegate>
web_request_event_router_delegate_;
DISALLOW_COPY_AND_ASSIGN(ExtensionWebRequestEventRouter);
@@ -523,7 +522,7 @@ class WebRequestInternalEventHandledFunction
const std::string& event_name,
const std::string& sub_event_name,
uint64_t request_id,
- scoped_ptr<ExtensionWebRequestEventRouter::EventResponse> response,
+ std::unique_ptr<ExtensionWebRequestEventRouter::EventResponse> response,
const std::string& error);
// ExtensionFunction:
diff --git a/chromium/extensions/browser/api/web_request/web_request_api_helpers.cc b/chromium/extensions/browser/api/web_request/web_request_api_helpers.cc
index 6bdb87c7bef..11b15638792 100644
--- a/chromium/extensions/browser/api/web_request/web_request_api_helpers.cc
+++ b/chromium/extensions/browser/api/web_request/web_request_api_helpers.cc
@@ -260,10 +260,10 @@ net::NetLog::ParametersCallback CreateNetLogExtensionIdCallback(
}
// Creates NetLog parameters to indicate that an extension modified a request.
-scoped_ptr<base::Value> NetLogModificationCallback(
+std::unique_ptr<base::Value> NetLogModificationCallback(
const EventResponseDelta* delta,
net::NetLogCaptureMode capture_mode) {
- scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
dict->SetString("extension_id", delta->extension_id);
base::ListValue* modified_headers = new base::ListValue();
@@ -429,7 +429,7 @@ EventResponseDelta* CalculateOnAuthRequiredDelta(
const std::string& extension_id,
const base::Time& extension_install_time,
bool cancel,
- scoped_ptr<net::AuthCredentials>* auth_credentials) {
+ std::unique_ptr<net::AuthCredentials>* auth_credentials) {
EventResponseDelta* result =
new EventResponseDelta(extension_id, extension_install_time);
result->cancel = cancel;
diff --git a/chromium/extensions/browser/api/web_request/web_request_api_helpers.h b/chromium/extensions/browser/api/web_request/web_request_api_helpers.h
index a41c52ff484..450f3cae2f0 100644
--- a/chromium/extensions/browser/api/web_request/web_request_api_helpers.h
+++ b/chromium/extensions/browser/api/web_request/web_request_api_helpers.h
@@ -8,13 +8,13 @@
#define EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_HELPERS_H_
#include <list>
+#include <memory>
#include <set>
#include <string>
#include "base/macros.h"
#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "content/public/common/resource_type.h"
#include "extensions/browser/warning_set.h"
@@ -66,8 +66,9 @@ struct ExtraInfoSpec {
struct RequestCookie {
RequestCookie();
~RequestCookie();
- scoped_ptr<std::string> name;
- scoped_ptr<std::string> value;
+ std::unique_ptr<std::string> name;
+ std::unique_ptr<std::string> value;
+
private:
DISALLOW_COPY_AND_ASSIGN(RequestCookie);
};
@@ -79,14 +80,15 @@ bool NullableEquals(const RequestCookie* a, const RequestCookie* b);
struct ResponseCookie {
ResponseCookie();
~ResponseCookie();
- scoped_ptr<std::string> name;
- scoped_ptr<std::string> value;
- scoped_ptr<std::string> expires;
- scoped_ptr<int> max_age;
- scoped_ptr<std::string> domain;
- scoped_ptr<std::string> path;
- scoped_ptr<bool> secure;
- scoped_ptr<bool> http_only;
+ std::unique_ptr<std::string> name;
+ std::unique_ptr<std::string> value;
+ std::unique_ptr<std::string> expires;
+ std::unique_ptr<int> max_age;
+ std::unique_ptr<std::string> domain;
+ std::unique_ptr<std::string> path;
+ std::unique_ptr<bool> secure;
+ std::unique_ptr<bool> http_only;
+
private:
DISALLOW_COPY_AND_ASSIGN(ResponseCookie);
};
@@ -98,9 +100,10 @@ bool NullableEquals(const ResponseCookie* a, const ResponseCookie* b);
struct FilterResponseCookie : ResponseCookie {
FilterResponseCookie();
~FilterResponseCookie();
- scoped_ptr<int> age_lower_bound;
- scoped_ptr<int> age_upper_bound;
- scoped_ptr<bool> session_cookie;
+ std::unique_ptr<int> age_lower_bound;
+ std::unique_ptr<int> age_upper_bound;
+ std::unique_ptr<bool> session_cookie;
+
private:
DISALLOW_COPY_AND_ASSIGN(FilterResponseCookie);
};
@@ -119,9 +122,10 @@ struct RequestCookieModification {
~RequestCookieModification();
CookieModificationType type;
// Used for EDIT and REMOVE. NULL for ADD.
- scoped_ptr<RequestCookie> filter;
+ std::unique_ptr<RequestCookie> filter;
// Used for ADD and EDIT. NULL for REMOVE.
- scoped_ptr<RequestCookie> modification;
+ std::unique_ptr<RequestCookie> modification;
+
private:
DISALLOW_COPY_AND_ASSIGN(RequestCookieModification);
};
@@ -134,9 +138,10 @@ struct ResponseCookieModification {
~ResponseCookieModification();
CookieModificationType type;
// Used for EDIT and REMOVE.
- scoped_ptr<FilterResponseCookie> filter;
+ std::unique_ptr<FilterResponseCookie> filter;
// Used for ADD and EDIT.
- scoped_ptr<ResponseCookie> modification;
+ std::unique_ptr<ResponseCookie> modification;
+
private:
DISALLOW_COPY_AND_ASSIGN(ResponseCookieModification);
};
@@ -177,7 +182,7 @@ struct EventResponseDelta {
ResponseHeaders deleted_response_headers;
// Authentication Credentials to use.
- scoped_ptr<net::AuthCredentials> auth_credentials;
+ std::unique_ptr<net::AuthCredentials> auth_credentials;
// Modifications to cookies in request headers.
RequestCookieModifications request_cookie_modifications;
@@ -243,7 +248,7 @@ EventResponseDelta* CalculateOnAuthRequiredDelta(
const std::string& extension_id,
const base::Time& extension_install_time,
bool cancel,
- scoped_ptr<net::AuthCredentials>* auth_credentials);
+ std::unique_ptr<net::AuthCredentials>* auth_credentials);
// These functions merge the responses (the |deltas|) of request handlers.
// The |deltas| need to be sorted in decreasing order of precedence of
diff --git a/chromium/extensions/browser/api/web_request/web_request_event_details.cc b/chromium/extensions/browser/api/web_request/web_request_event_details.cc
index 04fa9fbfeaa..a9f2f839123 100644
--- a/chromium/extensions/browser/api/web_request/web_request_event_details.cc
+++ b/chromium/extensions/browser/api/web_request/web_request_event_details.cc
@@ -74,7 +74,7 @@ void WebRequestEventDetails::SetRequestBody(const net::URLRequest* request) {
static const char* const kKeys[] = {keys::kRequestBodyFormDataKey,
keys::kRequestBodyRawKey};
- const std::vector<scoped_ptr<net::UploadElementReader>>* readers =
+ const std::vector<std::unique_ptr<net::UploadElementReader>>* readers =
upload_data->GetElementReaders();
bool some_succeeded = false;
if (readers) {
@@ -160,16 +160,16 @@ void WebRequestEventDetails::DetermineFrameIdOnUI() {
void WebRequestEventDetails::DetermineFrameIdOnIO(
const DeterminedFrameIdCallback& callback) {
- scoped_ptr<WebRequestEventDetails> self(this);
+ std::unique_ptr<WebRequestEventDetails> self(this);
ExtensionApiFrameIdMap::Get()->GetFrameDataOnIO(
render_process_id_, render_frame_id_,
base::Bind(&WebRequestEventDetails::OnDeterminedFrameId,
base::Unretained(this), base::Passed(&self), callback));
}
-scoped_ptr<base::DictionaryValue> WebRequestEventDetails::GetFilteredDict(
+std::unique_ptr<base::DictionaryValue> WebRequestEventDetails::GetFilteredDict(
int extra_info_spec) const {
- scoped_ptr<base::DictionaryValue> result = dict_.CreateDeepCopy();
+ std::unique_ptr<base::DictionaryValue> result = dict_.CreateDeepCopy();
if ((extra_info_spec & ExtraInfoSpec::REQUEST_BODY) && request_body_)
result->Set(keys::kRequestBodyKey, request_body_->CreateDeepCopy());
if ((extra_info_spec & ExtraInfoSpec::REQUEST_HEADERS) && request_headers_)
@@ -179,14 +179,15 @@ scoped_ptr<base::DictionaryValue> WebRequestEventDetails::GetFilteredDict(
return result;
}
-scoped_ptr<base::DictionaryValue> WebRequestEventDetails::GetAndClearDict() {
- scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue);
+std::unique_ptr<base::DictionaryValue>
+WebRequestEventDetails::GetAndClearDict() {
+ std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue);
dict_.Swap(result.get());
return result;
}
void WebRequestEventDetails::OnDeterminedFrameId(
- scoped_ptr<WebRequestEventDetails> self,
+ std::unique_ptr<WebRequestEventDetails> self,
const DeterminedFrameIdCallback& callback,
const ExtensionApiFrameIdMap::FrameData& frame_data) {
dict_.SetInteger(keys::kFrameIdKey, frame_data.frame_id);
diff --git a/chromium/extensions/browser/api/web_request/web_request_event_details.h b/chromium/extensions/browser/api/web_request/web_request_event_details.h
index 7bb36448f0e..bd9c995a15b 100644
--- a/chromium/extensions/browser/api/web_request/web_request_event_details.h
+++ b/chromium/extensions/browser/api/web_request/web_request_event_details.h
@@ -5,11 +5,11 @@
#ifndef EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_EVENT_DETAILS_H_
#define EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_EVENT_DETAILS_H_
+#include <memory>
#include <string>
#include "base/callback_forward.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "extensions/browser/extension_api_frame_id_map.h"
@@ -37,7 +37,7 @@ namespace extensions {
class WebRequestEventDetails {
public:
using DeterminedFrameIdCallback =
- base::Callback<void(scoped_ptr<WebRequestEventDetails>)>;
+ base::Callback<void(std::unique_ptr<WebRequestEventDetails>)>;
// Create a WebRequestEventDetails with the following keys:
// - method
@@ -111,14 +111,15 @@ class WebRequestEventDetails {
// Create an event dictionary that contains all required keys, and also the
// extra keys as specified by the |extra_info_spec| filter.
// This can be called from any thread.
- scoped_ptr<base::DictionaryValue> GetFilteredDict(int extra_info_spec) const;
+ std::unique_ptr<base::DictionaryValue> GetFilteredDict(
+ int extra_info_spec) const;
// Get the internal dictionary, unfiltered. After this call, the internal
// dictionary is empty.
- scoped_ptr<base::DictionaryValue> GetAndClearDict();
+ std::unique_ptr<base::DictionaryValue> GetAndClearDict();
private:
- void OnDeterminedFrameId(scoped_ptr<WebRequestEventDetails> self,
+ void OnDeterminedFrameId(std::unique_ptr<WebRequestEventDetails> self,
const DeterminedFrameIdCallback& callback,
const ExtensionApiFrameIdMap::FrameData& frame_data);
@@ -126,9 +127,9 @@ class WebRequestEventDetails {
base::DictionaryValue dict_;
// Extra event details: Only included when |extra_info_spec_| matches.
- scoped_ptr<base::DictionaryValue> request_body_;
- scoped_ptr<base::ListValue> request_headers_;
- scoped_ptr<base::ListValue> response_headers_;
+ std::unique_ptr<base::DictionaryValue> request_body_;
+ std::unique_ptr<base::ListValue> request_headers_;
+ std::unique_ptr<base::ListValue> response_headers_;
int extra_info_spec_;
diff --git a/chromium/extensions/browser/api/web_request/web_request_event_router_delegate.h b/chromium/extensions/browser/api/web_request/web_request_event_router_delegate.h
index 5ccf1adb715..fa23fb6b524 100644
--- a/chromium/extensions/browser/api/web_request/web_request_event_router_delegate.h
+++ b/chromium/extensions/browser/api/web_request/web_request_event_router_delegate.h
@@ -5,10 +5,10 @@
#ifndef EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_EVENT_ROUTER_DELEGATE_H_
#define EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_EVENT_ROUTER_DELEGATE_H_
+#include <memory>
#include <string>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
class GURL;
@@ -35,13 +35,13 @@ class WebRequestEventRouterDelegate {
virtual ~WebRequestEventRouterDelegate();
// Logs an extension action.
- virtual void LogExtensionActivity(content::BrowserContext* browser_context,
- bool is_incognito,
- const std::string& extension_id,
- const GURL& url,
- const std::string& api_call,
- scoped_ptr<base::DictionaryValue> details) {
- }
+ virtual void LogExtensionActivity(
+ content::BrowserContext* browser_context,
+ bool is_incognito,
+ const std::string& extension_id,
+ const GURL& url,
+ const std::string& api_call,
+ std::unique_ptr<base::DictionaryValue> details) {}
// Notifies that a webRequest event that normally would be forwarded to a
// listener was instead blocked because of withheld permissions.
diff --git a/chromium/extensions/browser/api/web_request/web_request_time_tracker.h b/chromium/extensions/browser/api/web_request/web_request_time_tracker.h
index af3073189d4..1314f351a62 100644
--- a/chromium/extensions/browser/api/web_request/web_request_time_tracker.h
+++ b/chromium/extensions/browser/api/web_request/web_request_time_tracker.h
@@ -9,13 +9,13 @@
#include <stdint.h>
#include <map>
+#include <memory>
#include <queue>
#include <set>
#include <string>
#include "base/gtest_prod_util.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "url/gurl.h"
@@ -115,7 +115,7 @@ class ExtensionWebRequestTimeTracker {
std::set<int64_t> moderate_delays_;
// Defaults to a delegate that sets warnings in the extension service.
- scoped_ptr<ExtensionWebRequestTimeTrackerDelegate> delegate_;
+ std::unique_ptr<ExtensionWebRequestTimeTrackerDelegate> delegate_;
FRIEND_TEST_ALL_PREFIXES(ExtensionWebRequestTimeTrackerTest, Basic);
FRIEND_TEST_ALL_PREFIXES(ExtensionWebRequestTimeTrackerTest,
diff --git a/chromium/extensions/browser/api/webcam_private/visca_webcam.cc b/chromium/extensions/browser/api/webcam_private/visca_webcam.cc
index 18c847b7d9f..7efd55ffb75 100644
--- a/chromium/extensions/browser/api/webcam_private/visca_webcam.cc
+++ b/chromium/extensions/browser/api/webcam_private/visca_webcam.cc
@@ -489,7 +489,7 @@ void ViscaWebcam::Reset(bool pan,
}
void ViscaWebcam::OpenForTesting(
- scoped_ptr<SerialConnection> serial_connection) {
+ std::unique_ptr<SerialConnection> serial_connection) {
serial_connection_ = std::move(serial_connection);
}
diff --git a/chromium/extensions/browser/api/webcam_private/visca_webcam.h b/chromium/extensions/browser/api/webcam_private/visca_webcam.h
index 0afe201f210..fb18fcbba60 100644
--- a/chromium/extensions/browser/api/webcam_private/visca_webcam.h
+++ b/chromium/extensions/browser/api/webcam_private/visca_webcam.h
@@ -114,13 +114,13 @@ class ViscaWebcam : public Webcam {
const SetPTZCompleteCallback& callback) override;
// Used only in unit tests in place of Open().
- void OpenForTesting(scoped_ptr<SerialConnection> serial_connection);
+ void OpenForTesting(std::unique_ptr<SerialConnection> serial_connection);
// Used only in unit tests to retrieve |serial_connection_| since this class
// owns it.
SerialConnection* GetSerialConnectionForTesting();
- scoped_ptr<SerialConnection> serial_connection_;
+ std::unique_ptr<SerialConnection> serial_connection_;
// Stores the response for the current command.
std::vector<char> data_buffer_;
diff --git a/chromium/extensions/browser/api/webcam_private/visca_webcam_unittest.cc b/chromium/extensions/browser/api/webcam_private/visca_webcam_unittest.cc
index 5cf98c49b12..303f4670250 100644
--- a/chromium/extensions/browser/api/webcam_private/visca_webcam_unittest.cc
+++ b/chromium/extensions/browser/api/webcam_private/visca_webcam_unittest.cc
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "extensions/browser/api/webcam_private/visca_webcam.h"
+
#include <vector>
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "content/public/test/test_browser_thread_bundle.h"
-#include "extensions/browser/api/webcam_private/visca_webcam.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace extensions {
@@ -92,7 +94,7 @@ class ViscaWebcamTest : public testing::Test {
protected:
ViscaWebcamTest() {
webcam_ = new ViscaWebcam;
- webcam_->OpenForTesting(make_scoped_ptr(new TestSerialConnection));
+ webcam_->OpenForTesting(base::WrapUnique(new TestSerialConnection));
}
~ViscaWebcamTest() override {}
diff --git a/chromium/extensions/browser/api/webcam_private/webcam_private_api.h b/chromium/extensions/browser/api/webcam_private/webcam_private_api.h
index 04efcd2eec5..68752b5d403 100644
--- a/chromium/extensions/browser/api/webcam_private/webcam_private_api.h
+++ b/chromium/extensions/browser/api/webcam_private/webcam_private_api.h
@@ -6,9 +6,9 @@
#define EXTENSIONS_BROWSER_API_WEBCAM_PRIVATE_WEBCAM_PRIVATE_API_H_
#include <map>
+#include <memory>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/scoped_observer.h"
#include "extensions/browser/api/api_resource_manager.h"
#include "extensions/browser/api/webcam_private/webcam.h"
@@ -73,7 +73,7 @@ class WebcamPrivateAPI : public BrowserContextKeyedAPI {
static const bool kServiceRedirectedInIncognito = true;
content::BrowserContext* const browser_context_;
- scoped_ptr<ApiResourceManager<WebcamResource>> webcam_resource_manager_;
+ std::unique_ptr<ApiResourceManager<WebcamResource>> webcam_resource_manager_;
base::WeakPtrFactory<WebcamPrivateAPI> weak_ptr_factory_;
diff --git a/chromium/extensions/browser/api/webcam_private/webcam_private_api_chromeos.cc b/chromium/extensions/browser/api/webcam_private/webcam_private_api_chromeos.cc
index 31e381b37f9..353517c063e 100644
--- a/chromium/extensions/browser/api/webcam_private/webcam_private_api_chromeos.cc
+++ b/chromium/extensions/browser/api/webcam_private/webcam_private_api_chromeos.cc
@@ -13,6 +13,7 @@
#include "extensions/browser/process_manager.h"
#include "extensions/browser/process_manager_factory.h"
#include "extensions/common/api/webcam_private.h"
+#include "url/origin.h"
namespace webcam_private = extensions::api::webcam_private;
@@ -113,8 +114,8 @@ void WebcamPrivateAPI::OnOpenSerialWebcam(
bool WebcamPrivateAPI::GetDeviceId(const std::string& extension_id,
const std::string& webcam_id,
std::string* device_id) {
- GURL security_origin =
- extensions::Extension::GetBaseURLFromExtensionId(extension_id);
+ url::Origin security_origin(
+ extensions::Extension::GetBaseURLFromExtensionId(extension_id));
return content::GetMediaDeviceIDForHMAC(
content::MEDIA_DEVICE_VIDEO_CAPTURE,
@@ -126,8 +127,8 @@ bool WebcamPrivateAPI::GetDeviceId(const std::string& extension_id,
std::string WebcamPrivateAPI::GetWebcamId(const std::string& extension_id,
const std::string& device_id) {
- GURL security_origin =
- extensions::Extension::GetBaseURLFromExtensionId(extension_id);
+ url::Origin security_origin(
+ extensions::Extension::GetBaseURLFromExtensionId(extension_id));
return content::GetHMACForMediaDeviceID(
browser_context_->GetResourceContext()->GetMediaDeviceIDSalt(),
@@ -183,7 +184,7 @@ WebcamPrivateOpenSerialWebcamFunction::
}
bool WebcamPrivateOpenSerialWebcamFunction::RunAsync() {
- scoped_ptr<webcam_private::OpenSerialWebcam::Params> params(
+ std::unique_ptr<webcam_private::OpenSerialWebcam::Params> params(
webcam_private::OpenSerialWebcam::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -218,7 +219,7 @@ WebcamPrivateCloseWebcamFunction::~WebcamPrivateCloseWebcamFunction() {
}
bool WebcamPrivateCloseWebcamFunction::RunAsync() {
- scoped_ptr<webcam_private::CloseWebcam::Params> params(
+ std::unique_ptr<webcam_private::CloseWebcam::Params> params(
webcam_private::CloseWebcam::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -233,7 +234,7 @@ WebcamPrivateSetFunction::~WebcamPrivateSetFunction() {
}
bool WebcamPrivateSetFunction::RunAsync() {
- scoped_ptr<webcam_private::Set::Params> params(
+ std::unique_ptr<webcam_private::Set::Params> params(
webcam_private::Set::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -333,7 +334,7 @@ WebcamPrivateGetFunction::~WebcamPrivateGetFunction() {
}
bool WebcamPrivateGetFunction::RunAsync() {
- scoped_ptr<webcam_private::Get::Params> params(
+ std::unique_ptr<webcam_private::Get::Params> params(
webcam_private::Get::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -397,7 +398,7 @@ WebcamPrivateResetFunction::~WebcamPrivateResetFunction() {
}
bool WebcamPrivateResetFunction::RunAsync() {
- scoped_ptr<webcam_private::Reset::Params> params(
+ std::unique_ptr<webcam_private::Reset::Params> params(
webcam_private::Reset::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
diff --git a/chromium/extensions/browser/api_activity_monitor.h b/chromium/extensions/browser/api_activity_monitor.h
index b8f0cc32c40..9ef97a4a4ef 100644
--- a/chromium/extensions/browser/api_activity_monitor.h
+++ b/chromium/extensions/browser/api_activity_monitor.h
@@ -5,9 +5,9 @@
#ifndef EXTENSIONS_BROWSER_API_ACTIVITY_MONITOR_H_
#define EXTENSIONS_BROWSER_API_ACTIVITY_MONITOR_H_
+#include <memory>
#include <string>
-#include "base/memory/scoped_ptr.h"
namespace base {
class ListValue;
@@ -21,14 +21,15 @@ namespace extensions {
class ApiActivityMonitor {
public:
// Called when an API event is dispatched to an extension.
- virtual void OnApiEventDispatched(const std::string& extension_id,
- const std::string& event_name,
- scoped_ptr<base::ListValue> event_args) = 0;
+ virtual void OnApiEventDispatched(
+ const std::string& extension_id,
+ const std::string& event_name,
+ std::unique_ptr<base::ListValue> event_args) = 0;
// Called when an extension calls an API function.
virtual void OnApiFunctionCalled(const std::string& extension_id,
const std::string& api_name,
- scoped_ptr<base::ListValue> args) = 0;
+ std::unique_ptr<base::ListValue> args) = 0;
protected:
virtual ~ApiActivityMonitor() {}
diff --git a/chromium/extensions/browser/api_test_utils.cc b/chromium/extensions/browser/api_test_utils.cc
index 7d5362423eb..0dafbbe0078 100644
--- a/chromium/extensions/browser/api_test_utils.cc
+++ b/chromium/extensions/browser/api_test_utils.cc
@@ -4,10 +4,11 @@
#include "extensions/browser/api_test_utils.h"
+#include <memory>
#include <utility>
+#include "base/callback_helpers.h"
#include "base/json/json_reader.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "components/crx_file/id_util.h"
#include "content/public/browser/browser_context.h"
@@ -21,11 +22,11 @@ using extensions::ExtensionFunctionDispatcher;
namespace {
-scoped_ptr<base::Value> ParseJSON(const std::string& data) {
+std::unique_ptr<base::Value> ParseJSON(const std::string& data) {
return base::JSONReader::Read(data);
}
-scoped_ptr<base::ListValue> ParseList(const std::string& data) {
+std::unique_ptr<base::ListValue> ParseList(const std::string& data) {
return base::ListValue::From(ParseJSON(data));
}
@@ -34,14 +35,10 @@ scoped_ptr<base::ListValue> ParseList(const std::string& data) {
class SendResponseDelegate
: public UIThreadExtensionFunction::DelegateForTests {
public:
- SendResponseDelegate() : should_post_quit_(false) {}
+ SendResponseDelegate() {}
virtual ~SendResponseDelegate() {}
- void set_should_post_quit(bool should_quit) {
- should_post_quit_ = should_quit;
- }
-
bool HasResponse() { return response_.get() != NULL; }
bool GetResponse() {
@@ -56,14 +53,19 @@ class SendResponseDelegate
ASSERT_FALSE(HasResponse());
response_.reset(new bool);
*response_ = success;
- if (should_post_quit_) {
- base::MessageLoopForUI::current()->QuitWhenIdle();
- }
+ run_loop_.Quit();
+ }
+
+ void WaitForResponse() {
+ // If the RunAsync of UIThreadExtensionFunction already called SendResponse,
+ // this will finish immediately.
+ run_loop_.Run();
}
private:
- scoped_ptr<bool> response_;
- bool should_post_quit_;
+ base::RunLoop run_loop_;
+ std::unique_ptr<bool> response_;
+ DISALLOW_COPY_AND_ASSIGN(SendResponseDelegate);
};
} // namespace
@@ -72,7 +74,8 @@ namespace extensions {
namespace api_test_utils {
-scoped_ptr<base::DictionaryValue> ParseDictionary(const std::string& data) {
+std::unique_ptr<base::DictionaryValue> ParseDictionary(
+ const std::string& data) {
return base::DictionaryValue::From(ParseJSON(data));
}
@@ -122,7 +125,7 @@ scoped_refptr<Extension> CreateExtension(
scoped_refptr<Extension> CreateEmptyExtensionWithLocation(
Manifest::Location location) {
- scoped_ptr<base::DictionaryValue> test_extension_value =
+ std::unique_ptr<base::DictionaryValue> test_extension_value =
ParseDictionary("{\"name\": \"Test\", \"version\": \"1.0\"}");
return CreateExtension(location, test_extension_value.get(), std::string());
}
@@ -131,7 +134,7 @@ base::Value* RunFunctionWithDelegateAndReturnSingleResult(
UIThreadExtensionFunction* function,
const std::string& args,
content::BrowserContext* context,
- scoped_ptr<extensions::ExtensionFunctionDispatcher> dispatcher) {
+ std::unique_ptr<extensions::ExtensionFunctionDispatcher> dispatcher) {
return RunFunctionWithDelegateAndReturnSingleResult(
function, args, context, std::move(dispatcher), NONE);
}
@@ -140,7 +143,7 @@ base::Value* RunFunctionWithDelegateAndReturnSingleResult(
UIThreadExtensionFunction* function,
const std::string& args,
content::BrowserContext* context,
- scoped_ptr<extensions::ExtensionFunctionDispatcher> dispatcher,
+ std::unique_ptr<extensions::ExtensionFunctionDispatcher> dispatcher,
RunFunctionFlags flags) {
scoped_refptr<ExtensionFunction> function_owner(function);
// Without a callback the function will not generate a result.
@@ -168,7 +171,7 @@ base::Value* RunFunctionAndReturnSingleResult(
const std::string& args,
content::BrowserContext* context,
RunFunctionFlags flags) {
- scoped_ptr<ExtensionFunctionDispatcher> dispatcher(
+ std::unique_ptr<ExtensionFunctionDispatcher> dispatcher(
new ExtensionFunctionDispatcher(context));
return RunFunctionWithDelegateAndReturnSingleResult(
@@ -185,7 +188,7 @@ std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function,
const std::string& args,
content::BrowserContext* context,
RunFunctionFlags flags) {
- scoped_ptr<ExtensionFunctionDispatcher> dispatcher(
+ std::unique_ptr<ExtensionFunctionDispatcher> dispatcher(
new ExtensionFunctionDispatcher(context));
scoped_refptr<ExtensionFunction> function_owner(function);
// Without a callback the function will not generate a result.
@@ -198,28 +201,30 @@ std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function,
bool RunFunction(UIThreadExtensionFunction* function,
const std::string& args,
content::BrowserContext* context) {
- scoped_ptr<ExtensionFunctionDispatcher> dispatcher(
+ std::unique_ptr<ExtensionFunctionDispatcher> dispatcher(
new ExtensionFunctionDispatcher(context));
return RunFunction(function, args, context, std::move(dispatcher), NONE);
}
-bool RunFunction(UIThreadExtensionFunction* function,
- const std::string& args,
- content::BrowserContext* context,
- scoped_ptr<extensions::ExtensionFunctionDispatcher> dispatcher,
- RunFunctionFlags flags) {
- scoped_ptr<base::ListValue> parsed_args = ParseList(args);
+bool RunFunction(
+ UIThreadExtensionFunction* function,
+ const std::string& args,
+ content::BrowserContext* context,
+ std::unique_ptr<extensions::ExtensionFunctionDispatcher> dispatcher,
+ RunFunctionFlags flags) {
+ std::unique_ptr<base::ListValue> parsed_args = ParseList(args);
EXPECT_TRUE(parsed_args.get())
<< "Could not parse extension function arguments: " << args;
return RunFunction(function, std::move(parsed_args), context,
std::move(dispatcher), flags);
}
-bool RunFunction(UIThreadExtensionFunction* function,
- scoped_ptr<base::ListValue> args,
- content::BrowserContext* context,
- scoped_ptr<extensions::ExtensionFunctionDispatcher> dispatcher,
- RunFunctionFlags flags) {
+bool RunFunction(
+ UIThreadExtensionFunction* function,
+ std::unique_ptr<base::ListValue> args,
+ content::BrowserContext* context,
+ std::unique_ptr<extensions::ExtensionFunctionDispatcher> dispatcher,
+ RunFunctionFlags flags) {
SendResponseDelegate response_delegate;
function->set_test_delegate(&response_delegate);
function->SetArgs(args.get());
@@ -230,13 +235,7 @@ bool RunFunction(UIThreadExtensionFunction* function,
function->set_browser_context(context);
function->set_include_incognito(flags & INCLUDE_INCOGNITO);
function->Run()->Execute();
-
- // If the RunAsync of |function| didn't already call SendResponse, run the
- // message loop until they do.
- if (!response_delegate.HasResponse()) {
- response_delegate.set_should_post_quit(true);
- content::RunMessageLoop();
- }
+ response_delegate.WaitForResponse();
EXPECT_TRUE(response_delegate.HasResponse());
return response_delegate.GetResponse();
diff --git a/chromium/extensions/browser/api_test_utils.h b/chromium/extensions/browser/api_test_utils.h
index 0a74f82df74..81d57a801fc 100644
--- a/chromium/extensions/browser/api_test_utils.h
+++ b/chromium/extensions/browser/api_test_utils.h
@@ -5,10 +5,10 @@
#ifndef EXTENSIONS_BROWSER_API_TEST_UTILS_H_
#define EXTENSIONS_BROWSER_API_TEST_UTILS_H_
+#include <memory>
#include <string>
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/common/manifest.h"
class UIThreadExtensionFunction;
@@ -30,7 +30,7 @@ class ExtensionFunctionDispatcher;
// TODO(yoz): crbug.com/394840: Remove duplicate functionality in
// chrome/browser/extensions/extension_function_test_utils.h.
//
-// TODO(ckehoe): Accept args as scoped_ptr<base::Value>,
+// TODO(ckehoe): Accept args as std::unique_ptr<base::Value>,
// and migrate existing users to the new API.
namespace api_test_utils {
@@ -38,7 +38,7 @@ enum RunFunctionFlags { NONE = 0, INCLUDE_INCOGNITO = 1 << 0 };
// Parse JSON and return as the specified type, or NULL if the JSON is invalid
// or not the specified type.
-scoped_ptr<base::DictionaryValue> ParseDictionary(const std::string& data);
+std::unique_ptr<base::DictionaryValue> ParseDictionary(const std::string& data);
// Get |key| from |val| as the specified type. If |key| does not exist, or is
// not of the specified type, adds a failure to the current test and returns
@@ -69,12 +69,12 @@ base::Value* RunFunctionWithDelegateAndReturnSingleResult(
UIThreadExtensionFunction* function,
const std::string& args,
content::BrowserContext* context,
- scoped_ptr<ExtensionFunctionDispatcher> dispatcher);
+ std::unique_ptr<ExtensionFunctionDispatcher> dispatcher);
base::Value* RunFunctionWithDelegateAndReturnSingleResult(
UIThreadExtensionFunction* function,
const std::string& args,
content::BrowserContext* context,
- scoped_ptr<ExtensionFunctionDispatcher> dispatcher,
+ std::unique_ptr<ExtensionFunctionDispatcher> dispatcher,
RunFunctionFlags flags);
// RunFunctionWithDelegateAndReturnSingleResult, except with a NULL
@@ -116,12 +116,12 @@ bool RunFunction(UIThreadExtensionFunction* function,
bool RunFunction(UIThreadExtensionFunction* function,
const std::string& args,
content::BrowserContext* context,
- scoped_ptr<ExtensionFunctionDispatcher> dispatcher,
+ std::unique_ptr<ExtensionFunctionDispatcher> dispatcher,
RunFunctionFlags flags);
bool RunFunction(UIThreadExtensionFunction* function,
- scoped_ptr<base::ListValue> args,
+ std::unique_ptr<base::ListValue> args,
content::BrowserContext* context,
- scoped_ptr<ExtensionFunctionDispatcher> dispatcher,
+ std::unique_ptr<ExtensionFunctionDispatcher> dispatcher,
RunFunctionFlags flags);
} // namespace api_test_utils
diff --git a/chromium/extensions/browser/api_unittest.cc b/chromium/extensions/browser/api_unittest.cc
index ada00c01506..c8faa21048e 100644
--- a/chromium/extensions/browser/api_unittest.cc
+++ b/chromium/extensions/browser/api_unittest.cc
@@ -53,6 +53,12 @@ void ApiUnitTest::SetUp() {
.Build();
}
+void ApiUnitTest::TearDown() {
+ extension_ = nullptr;
+ contents_.reset();
+ ExtensionsTest::TearDown();
+}
+
void ApiUnitTest::CreateBackgroundPage() {
if (!contents_) {
GURL url = BackgroundInfo::GetBackgroundURL(extension());
@@ -65,19 +71,19 @@ void ApiUnitTest::CreateBackgroundPage() {
}
}
-scoped_ptr<base::Value> ApiUnitTest::RunFunctionAndReturnValue(
+std::unique_ptr<base::Value> ApiUnitTest::RunFunctionAndReturnValue(
UIThreadExtensionFunction* function,
const std::string& args) {
function->set_extension(extension());
if (contents_)
function->SetRenderFrameHost(contents_->GetMainFrame());
- return scoped_ptr<base::Value>(utils::RunFunctionAndReturnSingleResult(
+ return std::unique_ptr<base::Value>(utils::RunFunctionAndReturnSingleResult(
function, args, browser_context()));
}
-scoped_ptr<base::DictionaryValue> ApiUnitTest::RunFunctionAndReturnDictionary(
- UIThreadExtensionFunction* function,
- const std::string& args) {
+std::unique_ptr<base::DictionaryValue>
+ApiUnitTest::RunFunctionAndReturnDictionary(UIThreadExtensionFunction* function,
+ const std::string& args) {
base::Value* value = RunFunctionAndReturnValue(function, args).release();
base::DictionaryValue* dict = NULL;
@@ -87,10 +93,10 @@ scoped_ptr<base::DictionaryValue> ApiUnitTest::RunFunctionAndReturnDictionary(
// We expect to either have successfuly retrieved a dictionary from the value,
// or the value to have been NULL.
EXPECT_TRUE(dict || !value);
- return scoped_ptr<base::DictionaryValue>(dict);
+ return std::unique_ptr<base::DictionaryValue>(dict);
}
-scoped_ptr<base::ListValue> ApiUnitTest::RunFunctionAndReturnList(
+std::unique_ptr<base::ListValue> ApiUnitTest::RunFunctionAndReturnList(
UIThreadExtensionFunction* function,
const std::string& args) {
base::Value* value = RunFunctionAndReturnValue(function, args).release();
@@ -102,7 +108,7 @@ scoped_ptr<base::ListValue> ApiUnitTest::RunFunctionAndReturnList(
// We expect to either have successfuly retrieved a list from the value,
// or the value to have been NULL.
EXPECT_TRUE(list || !value);
- return scoped_ptr<base::ListValue>(list);
+ return std::unique_ptr<base::ListValue>(list);
}
std::string ApiUnitTest::RunFunctionAndReturnError(
diff --git a/chromium/extensions/browser/api_unittest.h b/chromium/extensions/browser/api_unittest.h
index 4e31c32fe88..ad46d88b1bb 100644
--- a/chromium/extensions/browser/api_unittest.h
+++ b/chromium/extensions/browser/api_unittest.h
@@ -5,10 +5,10 @@
#ifndef EXTENSIONS_BROWSER_API_UNITTEST_H_
#define EXTENSIONS_BROWSER_API_UNITTEST_H_
+#include <memory>
#include <string>
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "components/pref_registry/testing_pref_service_syncable.h"
#include "extensions/browser/extensions_test.h"
@@ -49,6 +49,7 @@ class ApiUnitTest : public ExtensionsTest {
protected:
// SetUp creates and loads an empty, unpacked Extension.
void SetUp() override;
+ void TearDown() override;
// Creates a background page for |extension_|, and sets it for the WebContents
// to be used in API calls.
@@ -60,19 +61,19 @@ class ApiUnitTest : public ExtensionsTest {
// See also the RunFunction* methods in extension_function_test_utils.h.
// Return the function result as a base::Value.
- scoped_ptr<base::Value> RunFunctionAndReturnValue(
+ std::unique_ptr<base::Value> RunFunctionAndReturnValue(
UIThreadExtensionFunction* function,
const std::string& args);
// Return the function result as a base::DictionaryValue, or NULL.
// This will EXPECT-fail if the result is not a DictionaryValue.
- scoped_ptr<base::DictionaryValue> RunFunctionAndReturnDictionary(
+ std::unique_ptr<base::DictionaryValue> RunFunctionAndReturnDictionary(
UIThreadExtensionFunction* function,
const std::string& args);
// Return the function result as a base::ListValue, or NULL.
// This will EXPECT-fail if the result is not a ListValue.
- scoped_ptr<base::ListValue> RunFunctionAndReturnList(
+ std::unique_ptr<base::ListValue> RunFunctionAndReturnList(
UIThreadExtensionFunction* function,
const std::string& args);
@@ -86,14 +87,14 @@ class ApiUnitTest : public ExtensionsTest {
const std::string& args);
private:
- scoped_ptr<content::NotificationService> notification_service_;
+ std::unique_ptr<content::NotificationService> notification_service_;
- scoped_ptr<content::TestBrowserThreadBundle> thread_bundle_;
+ std::unique_ptr<content::TestBrowserThreadBundle> thread_bundle_;
user_prefs::TestingPrefServiceSyncable testing_pref_service_;
// The WebContents used to associate a RenderViewHost with API function calls,
// or null.
- scoped_ptr<content::WebContents> contents_;
+ std::unique_ptr<content::WebContents> contents_;
// The Extension used when running API function calls.
scoped_refptr<Extension> extension_;
diff --git a/chromium/extensions/browser/app_window/app_window.cc b/chromium/extensions/browser/app_window/app_window.cc
index 7294d6f8463..491332212f3 100644
--- a/chromium/extensions/browser/app_window/app_window.cc
+++ b/chromium/extensions/browser/app_window/app_window.cc
@@ -16,7 +16,7 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task_runner.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
@@ -53,8 +53,9 @@
#include "extensions/grit/extensions_browser_resources.h"
#include "third_party/skia/include/core/SkRegion.h"
#include "ui/base/resource/resource_bundle.h"
+#include "ui/display/display.h"
+#include "ui/display/screen.h"
#include "ui/events/keycodes/keyboard_codes.h"
-#include "ui/gfx/screen.h"
#if !defined(OS_MACOSX)
#include "components/prefs/pref_service.h"
@@ -88,7 +89,7 @@ void SetBoundsProperties(const gfx::Rect& bounds,
const gfx::Size& max_size,
const std::string& bounds_name,
base::DictionaryValue* window_properties) {
- scoped_ptr<base::DictionaryValue> bounds_properties(
+ std::unique_ptr<base::DictionaryValue> bounds_properties(
new base::DictionaryValue());
bounds_properties->SetInteger("left", bounds.x());
@@ -583,7 +584,7 @@ void AppWindow::SetAppIconUrl(const GURL& url) {
image_loader_ptr_factory_.GetWeakPtr()));
}
-void AppWindow::UpdateShape(scoped_ptr<SkRegion> region) {
+void AppWindow::UpdateShape(std::unique_ptr<SkRegion> region) {
native_app_window_->UpdateShape(std::move(region));
}
@@ -857,13 +858,12 @@ void AppWindow::SetNativeWindowFullscreen() {
bool AppWindow::IntersectsWithTaskbar() const {
#if defined(OS_WIN)
- gfx::Screen* screen = gfx::Screen::GetScreen();
+ display::Screen* screen = display::Screen::GetScreen();
gfx::Rect window_bounds = native_app_window_->GetRestoredBounds();
- std::vector<gfx::Display> displays = screen->GetAllDisplays();
+ std::vector<display::Display> displays = screen->GetAllDisplays();
- for (std::vector<gfx::Display>::const_iterator it = displays.begin();
- it != displays.end();
- ++it) {
+ for (std::vector<display::Display>::const_iterator it = displays.begin();
+ it != displays.end(); ++it) {
gfx::Rect taskbar_bounds = it->bounds();
taskbar_bounds.Subtract(it->work_area());
if (taskbar_bounds.IsEmpty())
@@ -1018,7 +1018,7 @@ void AppWindow::SaveWindowPosition() {
gfx::Rect bounds = native_app_window_->GetRestoredBounds();
gfx::Rect screen_bounds =
- gfx::Screen::GetScreen()->GetDisplayMatching(bounds).work_area();
+ display::Screen::GetScreen()->GetDisplayMatching(bounds).work_area();
ui::WindowShowState window_state = native_app_window_->GetRestoredState();
cache->SaveGeometry(
extension_id(), window_key_, bounds, screen_bounds, window_state);
@@ -1084,8 +1084,8 @@ AppWindow::CreateParams AppWindow::LoadDefaults(CreateParams params)
&cached_state)) {
// App window has cached screen bounds, make sure it fits on screen in
// case the screen resolution changed.
- gfx::Screen* screen = gfx::Screen::GetScreen();
- gfx::Display display = screen->GetDisplayMatching(cached_bounds);
+ display::Screen* screen = display::Screen::GetScreen();
+ display::Display display = screen->GetDisplayMatching(cached_bounds);
gfx::Rect current_screen_bounds = display.work_area();
SizeConstraints constraints(params.GetWindowMinimumSize(gfx::Insets()),
params.GetWindowMaximumSize(gfx::Insets()));
diff --git a/chromium/extensions/browser/app_window/app_window.h b/chromium/extensions/browser/app_window/app_window.h
index e41575dae1a..e503669ab1f 100644
--- a/chromium/extensions/browser/app_window/app_window.h
+++ b/chromium/extensions/browser/app_window/app_window.h
@@ -7,12 +7,12 @@
#include <stdint.h>
+#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "components/sessions/core/session_id.h"
#include "components/web_modal/web_contents_modal_dialog_manager_delegate.h"
@@ -272,7 +272,7 @@ class AppWindow : public content::WebContentsDelegate,
void SetAppIconUrl(const GURL& icon_url);
// Set the window shape. Passing a NULL |region| sets the default shape.
- void UpdateShape(scoped_ptr<SkRegion> region);
+ void UpdateShape(std::unique_ptr<SkRegion> region);
// Called from the render interface to modify the draggable regions.
void UpdateDraggableRegions(const std::vector<DraggableRegion>& regions);
@@ -368,7 +368,8 @@ class AppWindow : public content::WebContentsDelegate,
// remove this TODO.
bool is_ime_window() const { return is_ime_window_; }
- void SetAppWindowContentsForTesting(scoped_ptr<AppWindowContents> contents) {
+ void SetAppWindowContentsForTesting(
+ std::unique_ptr<AppWindowContents> contents) {
app_window_contents_ = std::move(contents);
}
@@ -516,12 +517,12 @@ class AppWindow : public content::WebContentsDelegate,
GURL app_icon_url_;
// An object to load the app's icon as an extension resource.
- scoped_ptr<IconImage> app_icon_image_;
+ std::unique_ptr<IconImage> app_icon_image_;
- scoped_ptr<NativeAppWindow> native_app_window_;
- scoped_ptr<AppWindowContents> app_window_contents_;
- scoped_ptr<AppDelegate> app_delegate_;
- scoped_ptr<AppWebContentsHelper> helper_;
+ std::unique_ptr<NativeAppWindow> native_app_window_;
+ std::unique_ptr<AppWindowContents> app_window_contents_;
+ std::unique_ptr<AppDelegate> app_delegate_;
+ std::unique_ptr<AppWebContentsHelper> helper_;
// The initial url this AppWindow was navigated to.
GURL initial_url_;
diff --git a/chromium/extensions/browser/app_window/app_window_contents.h b/chromium/extensions/browser/app_window/app_window_contents.h
index 732197c391c..85b56c7d62f 100644
--- a/chromium/extensions/browser/app_window/app_window_contents.h
+++ b/chromium/extensions/browser/app_window/app_window_contents.h
@@ -7,8 +7,9 @@
#include <stdint.h>
+#include <memory>
+
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "content/public/browser/web_contents_observer.h"
#include "extensions/browser/app_window/app_window.h"
#include "url/gurl.h"
@@ -53,7 +54,7 @@ class AppWindowContentsImpl : public AppWindowContents,
AppWindow* host_; // This class is owned by |host_|
GURL url_;
- scoped_ptr<content::WebContents> web_contents_;
+ std::unique_ptr<content::WebContents> web_contents_;
bool is_blocking_requests_;
bool is_window_ready_;
diff --git a/chromium/extensions/browser/app_window/app_window_geometry_cache.cc b/chromium/extensions/browser/app_window/app_window_geometry_cache.cc
index adc8631d9d1..e1ee46ea411 100644
--- a/chromium/extensions/browser/app_window/app_window_geometry_cache.cc
+++ b/chromium/extensions/browser/app_window/app_window_geometry_cache.cc
@@ -106,7 +106,7 @@ void AppWindowGeometryCache::SyncToStorage() {
const std::string& extension_id = *it;
const ExtensionData& extension_data = cache_[extension_id];
- scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
+ std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
for (ExtensionData::const_iterator it = extension_data.begin(),
eit = extension_data.end();
it != eit;
diff --git a/chromium/extensions/browser/app_window/app_window_geometry_cache.h b/chromium/extensions/browser/app_window/app_window_geometry_cache.h
index 1fbdb7333fa..f4547f7972d 100644
--- a/chromium/extensions/browser/app_window/app_window_geometry_cache.h
+++ b/chromium/extensions/browser/app_window/app_window_geometry_cache.h
@@ -8,10 +8,10 @@
#include <stddef.h>
#include <map>
+#include <memory>
#include <set>
#include <string>
-#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "base/observer_list.h"
#include "base/scoped_observer.h"
diff --git a/chromium/extensions/browser/app_window/app_window_geometry_cache_unittest.cc b/chromium/extensions/browser/app_window/app_window_geometry_cache_unittest.cc
index 3c664c659fe..30f428dd088 100644
--- a/chromium/extensions/browser/app_window/app_window_geometry_cache_unittest.cc
+++ b/chromium/extensions/browser/app_window/app_window_geometry_cache_unittest.cc
@@ -6,10 +6,10 @@
#include <stddef.h>
+#include <memory>
#include <utility>
#include "base/files/file_path.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/mock_pref_change_callback.h"
@@ -74,10 +74,10 @@ class AppWindowGeometryCacheTest : public ExtensionsTest {
protected:
base::MessageLoopForUI ui_message_loop_;
content::TestBrowserThread ui_thread_;
- scoped_ptr<ExtensionPrefValueMap> extension_pref_value_map_;
- scoped_ptr<PrefService> pref_service_;
- scoped_ptr<ExtensionPrefs> extension_prefs_;
- scoped_ptr<AppWindowGeometryCache> cache_;
+ std::unique_ptr<ExtensionPrefValueMap> extension_pref_value_map_;
+ std::unique_ptr<PrefService> pref_service_;
+ std::unique_ptr<ExtensionPrefs> extension_prefs_;
+ std::unique_ptr<AppWindowGeometryCache> cache_;
};
void AppWindowGeometryCacheTest::SetUp() {
@@ -120,7 +120,7 @@ void AppWindowGeometryCacheTest::AddGeometryAndLoadExtension(
const gfx::Rect& bounds,
const gfx::Rect& screen_bounds,
ui::WindowShowState state) {
- scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
+ std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
base::DictionaryValue* value = new base::DictionaryValue;
value->SetInteger("x", bounds.x());
value->SetInteger("y", bounds.y());
diff --git a/chromium/extensions/browser/app_window/native_app_window.h b/chromium/extensions/browser/app_window/native_app_window.h
index 40da36834b1..943efdc7586 100644
--- a/chromium/extensions/browser/app_window/native_app_window.h
+++ b/chromium/extensions/browser/app_window/native_app_window.h
@@ -5,9 +5,9 @@
#ifndef EXTENSIONS_BROWSER_APP_WINDOW_NATIVE_APP_WINDOW_H_
#define EXTENSIONS_BROWSER_APP_WINDOW_NATIVE_APP_WINDOW_H_
+#include <memory>
#include <vector>
-#include "base/memory/scoped_ptr.h"
#include "components/web_modal/web_contents_modal_dialog_host.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/base_window.h"
@@ -49,7 +49,7 @@ class NativeAppWindow : public ui::BaseWindow,
// Called when the window shape is changed. If |region| is NULL then the
// window is restored to the default shape.
- virtual void UpdateShape(scoped_ptr<SkRegion> region) = 0;
+ virtual void UpdateShape(std::unique_ptr<SkRegion> region) = 0;
// Allows the window to handle unhandled keyboard messages coming back from
// the renderer.
diff --git a/chromium/extensions/browser/app_window/test_app_window_contents.h b/chromium/extensions/browser/app_window/test_app_window_contents.h
index c118fe65e9e..8c082cbf20a 100644
--- a/chromium/extensions/browser/app_window/test_app_window_contents.h
+++ b/chromium/extensions/browser/app_window/test_app_window_contents.h
@@ -36,7 +36,7 @@ class TestAppWindowContents : public AppWindowContents {
WindowController* GetWindowController() const override;
private:
- scoped_ptr<content::WebContents> web_contents_;
+ std::unique_ptr<content::WebContents> web_contents_;
DISALLOW_COPY_AND_ASSIGN(TestAppWindowContents);
};
diff --git a/chromium/extensions/browser/blob_holder.cc b/chromium/extensions/browser/blob_holder.cc
index 552c17ada34..26e2ee91120 100644
--- a/chromium/extensions/browser/blob_holder.cc
+++ b/chromium/extensions/browser/blob_holder.cc
@@ -41,7 +41,7 @@ BlobHolder::~BlobHolder() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
}
-void BlobHolder::HoldBlobReference(scoped_ptr<content::BlobHandle> blob) {
+void BlobHolder::HoldBlobReference(std::unique_ptr<content::BlobHandle> blob) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(!ContainsBlobHandle(blob.get()));
diff --git a/chromium/extensions/browser/blob_holder.h b/chromium/extensions/browser/blob_holder.h
index efaed928074..68e519d608c 100644
--- a/chromium/extensions/browser/blob_holder.h
+++ b/chromium/extensions/browser/blob_holder.h
@@ -6,12 +6,12 @@
#define EXTENSIONS_BROWSER_BLOB_HOLDER_H_
#include <map>
+#include <memory>
#include <string>
#include <vector>
#include "base/macros.h"
#include "base/memory/linked_ptr.h"
-#include "base/memory/scoped_ptr.h"
#include "base/supports_user_data.h"
namespace content {
@@ -34,7 +34,7 @@ class BlobHolder : public base::SupportsUserData::Data {
~BlobHolder() override;
// Causes BlobHolder to take ownership of |blob|.
- void HoldBlobReference(scoped_ptr<content::BlobHandle> blob);
+ void HoldBlobReference(std::unique_ptr<content::BlobHandle> blob);
private:
typedef std::multimap<std::string, linked_ptr<content::BlobHandle> >
diff --git a/chromium/extensions/browser/computed_hashes.cc b/chromium/extensions/browser/computed_hashes.cc
index 35ea525508b..dbfe0061099 100644
--- a/chromium/extensions/browser/computed_hashes.cc
+++ b/chromium/extensions/browser/computed_hashes.cc
@@ -37,7 +37,7 @@ bool ComputedHashes::Reader::InitFromFile(const base::FilePath& path) {
return false;
base::DictionaryValue* top_dictionary = NULL;
- scoped_ptr<base::Value> value(base::JSONReader::Read(contents));
+ std::unique_ptr<base::Value> value(base::JSONReader::Read(contents));
if (!value.get() || !value->GetAsDictionary(&top_dictionary))
return false;
@@ -177,7 +177,7 @@ void ComputedHashes::ComputeHashesForContent(const std::string& contents,
const char* block_start = contents.data() + offset;
DCHECK(offset <= contents.size());
size_t bytes_to_read = std::min(contents.size() - offset, block_size);
- scoped_ptr<crypto::SecureHash> hash(
+ std::unique_ptr<crypto::SecureHash> hash(
crypto::SecureHash::Create(crypto::SecureHash::SHA256));
hash->Update(block_start, bytes_to_read);
diff --git a/chromium/extensions/browser/computed_hashes.h b/chromium/extensions/browser/computed_hashes.h
index 071abf08767..0451640e9a3 100644
--- a/chromium/extensions/browser/computed_hashes.h
+++ b/chromium/extensions/browser/computed_hashes.h
@@ -8,10 +8,10 @@
#include <stddef.h>
#include <map>
+#include <memory>
#include <string>
#include <vector>
-#include "base/memory/scoped_ptr.h"
namespace base {
class FilePath;
@@ -59,7 +59,7 @@ class ComputedHashes {
private:
// Each element of this list contains the path and block hashes for one
// file.
- scoped_ptr<base::ListValue> file_list_;
+ std::unique_ptr<base::ListValue> file_list_;
};
// Computes the SHA256 hash of each |block_size| chunk in |contents|, placing
diff --git a/chromium/extensions/browser/content_hash_fetcher.cc b/chromium/extensions/browser/content_hash_fetcher.cc
index dbe0f2185ab..678cf5f659c 100644
--- a/chromium/extensions/browser/content_hash_fetcher.cc
+++ b/chromium/extensions/browser/content_hash_fetcher.cc
@@ -21,6 +21,7 @@
#include "base/version.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/storage_partition.h"
#include "crypto/sha2.h"
#include "extensions/browser/computed_hashes.h"
#include "extensions/browser/content_hash_tree.h"
@@ -138,14 +139,14 @@ class ContentHashFetcherJob
content::BrowserThread::ID creation_thread_;
// Used for fetching content signatures.
- scoped_ptr<net::URLFetcher> url_fetcher_;
+ std::unique_ptr<net::URLFetcher> url_fetcher_;
// The key used to validate verified_contents.json.
ContentVerifierKey key_;
// The parsed contents of the verified_contents.json file, either read from
// disk or fetched from the network and then written to disk.
- scoped_ptr<VerifiedContents> verified_contents_;
+ std::unique_ptr<VerifiedContents> verified_contents_;
// Whether this job succeeded.
bool success_;
@@ -255,7 +256,7 @@ void ContentHashFetcherJob::DoneCheckingForVerifiedContents(bool found) {
// contents to be written into a file. Also ensures that the directory for
// |path| exists, creating it if needed.
static int WriteFileHelper(const base::FilePath& path,
- scoped_ptr<std::string> content) {
+ std::unique_ptr<std::string> content) {
base::FilePath dir = path.DirName();
return (base::CreateDirectoryAndGetError(dir, NULL) &&
base::WriteFile(path, content->data(), content->size()));
@@ -267,7 +268,7 @@ void ContentHashFetcherJob::OnURLFetchComplete(const net::URLFetcher* source) {
<< fetch_url_.possibly_invalid_spec();
if (IsCancelled())
return;
- scoped_ptr<std::string> response(new std::string);
+ std::unique_ptr<std::string> response(new std::string);
if (!url_fetcher_->GetStatus().is_success() ||
!url_fetcher_->GetResponseAsString(response.get())) {
DoneFetchingVerifiedContents(false);
@@ -278,7 +279,7 @@ void ContentHashFetcherJob::OnURLFetchComplete(const net::URLFetcher* source) {
// can be a login redirect html, xml file, etc. if you aren't logged in with
// the right cookies). TODO(asargent) - It would be a nice enhancement to
// move to parsing this in a sandboxed helper (crbug.com/372878).
- scoped_ptr<base::Value> parsed(base::JSONReader::Read(*response));
+ std::unique_ptr<base::Value> parsed(base::JSONReader::Read(*response));
if (parsed) {
VLOG(1) << "JSON parsed ok for " << extension_id_;
@@ -462,7 +463,9 @@ void ContentHashFetcher::DoFetch(const Extension* extension, bool force) {
GURL url =
delegate_->GetSignatureFetchUrl(extension->id(), *extension->version());
ContentHashFetcherJob* job = new ContentHashFetcherJob(
- context_->GetRequestContext(), delegate_->GetPublicKey(), extension->id(),
+ content::BrowserContext::GetDefaultStoragePartition(context_)->
+ GetURLRequestContext(),
+ delegate_->GetPublicKey(), extension->id(),
extension->path(), url, force,
base::Bind(&ContentHashFetcher::JobFinished,
weak_ptr_factory_.GetWeakPtr()));
diff --git a/chromium/extensions/browser/content_hash_reader.h b/chromium/extensions/browser/content_hash_reader.h
index 882b20b612e..b8b5c30ff9e 100644
--- a/chromium/extensions/browser/content_hash_reader.h
+++ b/chromium/extensions/browser/content_hash_reader.h
@@ -5,13 +5,13 @@
#ifndef EXTENSIONS_BROWSER_CONTENT_HASH_READER_H_
#define EXTENSIONS_BROWSER_CONTENT_HASH_READER_H_
+#include <memory>
#include <string>
#include <vector>
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/version.h"
#include "extensions/browser/content_verifier_delegate.h"
@@ -82,7 +82,7 @@ class ContentHashReader : public base::RefCountedThreadSafe<ContentHashReader> {
// The blocksize used for generating the hashes.
int block_size_;
- scoped_ptr<VerifiedContents> verified_contents_;
+ std::unique_ptr<VerifiedContents> verified_contents_;
std::vector<std::string> hashes_;
diff --git a/chromium/extensions/browser/content_hash_tree.cc b/chromium/extensions/browser/content_hash_tree.cc
index 9831c12e7f8..8abbf6fd9f1 100644
--- a/chromium/extensions/browser/content_hash_tree.cc
+++ b/chromium/extensions/browser/content_hash_tree.cc
@@ -4,7 +4,8 @@
#include "extensions/browser/content_hash_tree.h"
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "base/stl_util.h"
#include "crypto/secure_hash.h"
#include "crypto/sha2.h"
@@ -32,7 +33,7 @@ std::string ComputeTreeHashRoot(const std::vector<std::string>& leaf_hashes,
// |branch_factor| elements to form the hash of each parent node.
std::vector<std::string>::const_iterator i = current->begin();
while (i != current->end()) {
- scoped_ptr<crypto::SecureHash> hash(
+ std::unique_ptr<crypto::SecureHash> hash(
crypto::SecureHash::Create(crypto::SecureHash::SHA256));
for (int j = 0; j < branch_factor && i != current->end(); j++) {
DCHECK_EQ(i->size(), crypto::kSHA256Length);
diff --git a/chromium/extensions/browser/content_hash_tree_unittest.cc b/chromium/extensions/browser/content_hash_tree_unittest.cc
index b5aada8c9cc..6d35dd55b8c 100644
--- a/chromium/extensions/browser/content_hash_tree_unittest.cc
+++ b/chromium/extensions/browser/content_hash_tree_unittest.cc
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/memory/scoped_ptr.h"
+#include "extensions/browser/content_hash_tree.h"
+
+#include <memory>
+
#include "base/stl_util.h"
#include "crypto/secure_hash.h"
#include "crypto/sha2.h"
-#include "extensions/browser/content_hash_tree.h"
#include "testing/gtest/include/gtest/gtest.h"
using crypto::kSHA256Length;
@@ -38,7 +40,7 @@ TEST(ContentHashTreeTest, HashTreeBasics) {
nodes.push_back(node2);
std::string expected(kSHA256Length, 0);
- scoped_ptr<SecureHash> hash(SecureHash::Create(SecureHash::SHA256));
+ std::unique_ptr<SecureHash> hash(SecureHash::Create(SecureHash::SHA256));
hash->Update(node1.data(), node1.size());
hash->Update(node2.data(), node2.size());
hash->Finish(string_as_array(&expected), expected.size());
diff --git a/chromium/extensions/browser/content_verifier.cc b/chromium/extensions/browser/content_verifier.cc
index ea464e81be8..c47db07826f 100644
--- a/chromium/extensions/browser/content_verifier.cc
+++ b/chromium/extensions/browser/content_verifier.cc
@@ -158,13 +158,13 @@ void ContentVerifier::OnExtensionLoaded(
std::set<base::FilePath> original_image_paths =
delegate_->GetBrowserImagePaths(extension);
- scoped_ptr<std::set<base::FilePath>> image_paths(
+ std::unique_ptr<std::set<base::FilePath>> image_paths(
new std::set<base::FilePath>);
for (const auto& path : original_image_paths) {
image_paths->insert(NormalizeRelativePath(path));
}
- scoped_ptr<ContentVerifierIOData::ExtensionData> data(
+ std::unique_ptr<ContentVerifierIOData::ExtensionData> data(
new ContentVerifierIOData::ExtensionData(
std::move(image_paths),
extension->version() ? *extension->version() : base::Version()));
@@ -251,7 +251,7 @@ bool ContentVerifier::ShouldVerifyAnyPaths(
const std::set<base::FilePath>& browser_images = *(data->browser_image_paths);
base::FilePath locales_dir = extension_root.Append(kLocaleFolder);
- scoped_ptr<std::set<std::string> > all_locales;
+ std::unique_ptr<std::set<std::string>> all_locales;
for (std::set<base::FilePath>::const_iterator i = relative_paths.begin();
i != relative_paths.end();
diff --git a/chromium/extensions/browser/content_verifier.h b/chromium/extensions/browser/content_verifier.h
index 8d6f47b5c64..83707bbc04c 100644
--- a/chromium/extensions/browser/content_verifier.h
+++ b/chromium/extensions/browser/content_verifier.h
@@ -5,12 +5,12 @@
#ifndef EXTENSIONS_BROWSER_CONTENT_VERIFIER_H_
#define EXTENSIONS_BROWSER_CONTENT_VERIFIER_H_
+#include <memory>
#include <set>
#include <string>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/scoped_observer.h"
#include "base/version.h"
#include "extensions/browser/content_verifier_delegate.h"
@@ -95,10 +95,10 @@ class ContentVerifier : public base::RefCountedThreadSafe<ContentVerifier>,
content::BrowserContext* context_;
- scoped_ptr<ContentVerifierDelegate> delegate_;
+ std::unique_ptr<ContentVerifierDelegate> delegate_;
// For fetching content hash signatures.
- scoped_ptr<ContentHashFetcher> fetcher_;
+ std::unique_ptr<ContentHashFetcher> fetcher_;
// For observing the ExtensionRegistry.
ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> observer_;
diff --git a/chromium/extensions/browser/content_verifier_io_data.cc b/chromium/extensions/browser/content_verifier_io_data.cc
index d3353be2526..8f8854c994c 100644
--- a/chromium/extensions/browser/content_verifier_io_data.cc
+++ b/chromium/extensions/browser/content_verifier_io_data.cc
@@ -11,7 +11,7 @@
namespace extensions {
ContentVerifierIOData::ExtensionData::ExtensionData(
- scoped_ptr<std::set<base::FilePath>> browser_image_paths,
+ std::unique_ptr<std::set<base::FilePath>> browser_image_paths,
const base::Version& version) {
this->browser_image_paths = std::move(browser_image_paths);
this->version = version;
@@ -27,7 +27,7 @@ ContentVerifierIOData::~ContentVerifierIOData() {
}
void ContentVerifierIOData::AddData(const std::string& extension_id,
- scoped_ptr<ExtensionData> data) {
+ std::unique_ptr<ExtensionData> data) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
CHECK(data->browser_image_paths.get());
data_map_[extension_id] = linked_ptr<ExtensionData>(data.release());
diff --git a/chromium/extensions/browser/content_verifier_io_data.h b/chromium/extensions/browser/content_verifier_io_data.h
index 92e8248b8ca..65f38efa44c 100644
--- a/chromium/extensions/browser/content_verifier_io_data.h
+++ b/chromium/extensions/browser/content_verifier_io_data.h
@@ -6,13 +6,13 @@
#define EXTENSIONS_BROWSER_CONTENT_VERIFIER_IO_DATA_H_
#include <map>
+#include <memory>
#include <set>
#include <string>
#include "base/files/file_path.h"
#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/version.h"
namespace extensions {
@@ -23,17 +23,18 @@ class ContentVerifierIOData
: public base::RefCountedThreadSafe<ContentVerifierIOData> {
public:
struct ExtensionData {
- scoped_ptr<std::set<base::FilePath>> browser_image_paths;
+ std::unique_ptr<std::set<base::FilePath>> browser_image_paths;
base::Version version;
- ExtensionData(scoped_ptr<std::set<base::FilePath>> browser_image_paths,
+ ExtensionData(std::unique_ptr<std::set<base::FilePath>> browser_image_paths,
const base::Version& version);
~ExtensionData();
};
ContentVerifierIOData();
- void AddData(const std::string& extension_id, scoped_ptr<ExtensionData> data);
+ void AddData(const std::string& extension_id,
+ std::unique_ptr<ExtensionData> data);
void RemoveData(const std::string& extension_id);
void Clear();
diff --git a/chromium/extensions/browser/content_verify_job.h b/chromium/extensions/browser/content_verify_job.h
index 30e46e1d145..fc9223026c9 100644
--- a/chromium/extensions/browser/content_verify_job.h
+++ b/chromium/extensions/browser/content_verify_job.h
@@ -7,12 +7,12 @@
#include <stdint.h>
+#include <memory>
#include <string>
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/threading/thread_checker.h"
namespace base {
@@ -129,7 +129,7 @@ class ContentVerifyJob : public base::RefCountedThreadSafe<ContentVerifyJob> {
int current_block_;
// The hash we're building up for the bytes of |current_block_|.
- scoped_ptr<crypto::SecureHash> current_hash_;
+ std::unique_ptr<crypto::SecureHash> current_hash_;
// The number of bytes we've already input into |current_hash_|.
int current_hash_byte_count_;
diff --git a/chromium/extensions/browser/declarative_user_script_master.h b/chromium/extensions/browser/declarative_user_script_master.h
index 64f8daec6b3..422b747ffab 100644
--- a/chromium/extensions/browser/declarative_user_script_master.h
+++ b/chromium/extensions/browser/declarative_user_script_master.h
@@ -5,10 +5,10 @@
#ifndef EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MASTER_H_
#define EXTENSIONS_BROWSER_DECLARATIVE_USER_SCRIPT_MASTER_H_
+#include <memory>
#include <set>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/scoped_observer.h"
#include "extensions/common/host_id.h"
@@ -65,7 +65,7 @@ class DeclarativeUserScriptMaster {
// Script loader that handles loading contents of scripts into shared memory
// and notifying renderers of script updates.
- scoped_ptr<UserScriptLoader> loader_;
+ std::unique_ptr<UserScriptLoader> loader_;
DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptMaster);
};
diff --git a/chromium/extensions/browser/error_map.cc b/chromium/extensions/browser/error_map.cc
index 5f94e34284a..9a806002859 100644
--- a/chromium/extensions/browser/error_map.cc
+++ b/chromium/extensions/browser/error_map.cc
@@ -98,7 +98,7 @@ class ErrorMap::ExtensionEntry {
void DeleteAllErrors();
// Add the error to the list, and return a weak reference.
- const ExtensionError* AddError(scoped_ptr<ExtensionError> error);
+ const ExtensionError* AddError(std::unique_ptr<ExtensionError> error);
const ErrorList* list() const { return &list_; }
@@ -138,7 +138,7 @@ void ErrorMap::ExtensionEntry::DeleteAllErrors() {
}
const ExtensionError* ErrorMap::ExtensionEntry::AddError(
- scoped_ptr<ExtensionError> error) {
+ std::unique_ptr<ExtensionError> error) {
for (ErrorList::iterator iter = list_.begin(); iter != list_.end(); ++iter) {
// If we find a duplicate error, remove the old error and add the new one,
// incrementing the occurrence count of the error. We use the new error
@@ -182,7 +182,8 @@ const ErrorList& ErrorMap::GetErrorsForExtension(
return iter != map_.end() ? *iter->second->list() : g_empty_error_list.Get();
}
-const ExtensionError* ErrorMap::AddError(scoped_ptr<ExtensionError> error) {
+const ExtensionError* ErrorMap::AddError(
+ std::unique_ptr<ExtensionError> error) {
EntryMap::iterator iter = map_.find(error->extension_id());
if (iter == map_.end()) {
iter = map_.insert(std::pair<std::string, ExtensionEntry*>(
diff --git a/chromium/extensions/browser/error_map.h b/chromium/extensions/browser/error_map.h
index 929335ab48d..c4c7f102c21 100644
--- a/chromium/extensions/browser/error_map.h
+++ b/chromium/extensions/browser/error_map.h
@@ -9,11 +9,11 @@
#include <deque>
#include <map>
+#include <memory>
#include <set>
#include <string>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/browser/extension_error.h"
namespace extensions {
@@ -61,7 +61,7 @@ class ErrorMap {
const ErrorList& GetErrorsForExtension(const std::string& extension_id) const;
// Add the |error| to the ErrorMap.
- const ExtensionError* AddError(scoped_ptr<ExtensionError> error);
+ const ExtensionError* AddError(std::unique_ptr<ExtensionError> error);
// Removes errors that match the given |filter| from the map. If non-null,
// |affected_ids| will be populated with the set of extension ids that were
diff --git a/chromium/extensions/browser/error_map_unittest.cc b/chromium/extensions/browser/error_map_unittest.cc
index a118f6e53c8..2b43f33f972 100644
--- a/chromium/extensions/browser/error_map_unittest.cc
+++ b/chromium/extensions/browser/error_map_unittest.cc
@@ -6,10 +6,10 @@
#include <stddef.h>
+#include <memory>
#include <utility>
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "components/crx_file/id_util.h"
#include "extensions/browser/extension_error.h"
@@ -151,7 +151,7 @@ TEST_F(ErrorMapUnitTest, DuplicateErrorsAreReplaced) {
// Create an error identical to the second error reported, save its
// location, and add it to the error map.
- scoped_ptr<ExtensionError> runtime_error2 =
+ std::unique_ptr<ExtensionError> runtime_error2 =
CreateNewRuntimeError(kId, base::UintToString(1u));
const ExtensionError* weak_error = runtime_error2.get();
ASSERT_TRUE(errors_.AddError(std::move(runtime_error2)));
diff --git a/chromium/extensions/browser/event_listener_map.cc b/chromium/extensions/browser/event_listener_map.cc
index af91b6fbec2..1dc908342b0 100644
--- a/chromium/extensions/browser/event_listener_map.cc
+++ b/chromium/extensions/browser/event_listener_map.cc
@@ -8,6 +8,7 @@
#include <utility>
+#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "content/public/browser/render_process_host.h"
#include "extensions/browser/event_router.h"
@@ -21,23 +22,23 @@ namespace extensions {
typedef EventFilter::MatcherID MatcherID;
// static
-scoped_ptr<EventListener> EventListener::ForExtension(
+std::unique_ptr<EventListener> EventListener::ForExtension(
const std::string& event_name,
const std::string& extension_id,
content::RenderProcessHost* process,
- scoped_ptr<base::DictionaryValue> filter) {
- return make_scoped_ptr(new EventListener(event_name, extension_id, GURL(),
- process, std::move(filter)));
+ std::unique_ptr<base::DictionaryValue> filter) {
+ return base::WrapUnique(new EventListener(event_name, extension_id, GURL(),
+ process, std::move(filter)));
}
// static
-scoped_ptr<EventListener> EventListener::ForURL(
+std::unique_ptr<EventListener> EventListener::ForURL(
const std::string& event_name,
const GURL& listener_url,
content::RenderProcessHost* process,
- scoped_ptr<base::DictionaryValue> filter) {
- return make_scoped_ptr(new EventListener(event_name, "", listener_url,
- process, std::move(filter)));
+ std::unique_ptr<base::DictionaryValue> filter) {
+ return base::WrapUnique(new EventListener(event_name, "", listener_url,
+ process, std::move(filter)));
}
EventListener::~EventListener() {}
@@ -53,13 +54,13 @@ bool EventListener::Equals(const EventListener* other) const {
(!filter_.get() || filter_->Equals(other->filter_.get()));
}
-scoped_ptr<EventListener> EventListener::Copy() const {
- scoped_ptr<DictionaryValue> filter_copy;
+std::unique_ptr<EventListener> EventListener::Copy() const {
+ std::unique_ptr<DictionaryValue> filter_copy;
if (filter_)
filter_copy.reset(filter_->DeepCopy());
- return scoped_ptr<EventListener>(new EventListener(event_name_, extension_id_,
- listener_url_, process_,
- std::move(filter_copy)));
+ return std::unique_ptr<EventListener>(
+ new EventListener(event_name_, extension_id_, listener_url_, process_,
+ std::move(filter_copy)));
}
bool EventListener::IsLazy() const {
@@ -78,7 +79,7 @@ EventListener::EventListener(const std::string& event_name,
const std::string& extension_id,
const GURL& listener_url,
content::RenderProcessHost* process,
- scoped_ptr<DictionaryValue> filter)
+ std::unique_ptr<DictionaryValue> filter)
: event_name_(event_name),
extension_id_(extension_id),
listener_url_(listener_url),
@@ -92,11 +93,12 @@ EventListenerMap::EventListenerMap(Delegate* delegate)
EventListenerMap::~EventListenerMap() {}
-bool EventListenerMap::AddListener(scoped_ptr<EventListener> listener) {
+bool EventListenerMap::AddListener(std::unique_ptr<EventListener> listener) {
if (HasListener(listener.get()))
return false;
if (listener->filter()) {
- scoped_ptr<EventMatcher> matcher(ParseEventMatcher(listener->filter()));
+ std::unique_ptr<EventMatcher> matcher(
+ ParseEventMatcher(listener->filter()));
MatcherID id = event_filter_.AddEventMatcher(listener->event_name(),
std::move(matcher));
listener->set_matcher_id(id);
@@ -111,10 +113,10 @@ bool EventListenerMap::AddListener(scoped_ptr<EventListener> listener) {
return true;
}
-scoped_ptr<EventMatcher> EventListenerMap::ParseEventMatcher(
+std::unique_ptr<EventMatcher> EventListenerMap::ParseEventMatcher(
DictionaryValue* filter_dict) {
- return scoped_ptr<EventMatcher>(new EventMatcher(
- make_scoped_ptr(filter_dict->DeepCopy()), MSG_ROUTING_NONE));
+ return std::unique_ptr<EventMatcher>(new EventMatcher(
+ base::WrapUnique(filter_dict->DeepCopy()), MSG_ROUTING_NONE));
}
bool EventListenerMap::RemoveListener(const EventListener* listener) {
@@ -204,7 +206,7 @@ void EventListenerMap::LoadUnfilteredLazyListeners(
for (std::set<std::string>::const_iterator it = event_names.begin();
it != event_names.end(); ++it) {
AddListener(EventListener::ForExtension(
- *it, extension_id, NULL, scoped_ptr<DictionaryValue>()));
+ *it, extension_id, NULL, std::unique_ptr<DictionaryValue>()));
}
}
@@ -221,7 +223,7 @@ void EventListenerMap::LoadFilteredLazyListeners(
if (!filter_list->GetDictionary(i, &filter))
continue;
AddListener(EventListener::ForExtension(
- it.key(), extension_id, NULL, make_scoped_ptr(filter->DeepCopy())));
+ it.key(), extension_id, NULL, base::WrapUnique(filter->DeepCopy())));
}
}
}
diff --git a/chromium/extensions/browser/event_listener_map.h b/chromium/extensions/browser/event_listener_map.h
index 0ce5f3c3ac5..fe1568edc02 100644
--- a/chromium/extensions/browser/event_listener_map.h
+++ b/chromium/extensions/browser/event_listener_map.h
@@ -6,12 +6,12 @@
#define EXTENSIONS_BROWSER_EVENT_LISTENER_MAP_H_
#include <map>
+#include <memory>
#include <set>
#include <string>
#include <vector>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/common/event_filter.h"
#include "url/gurl.h"
@@ -50,22 +50,22 @@ class EventListener {
// url: [{hostSuffix: 'google.com'}],
// tabId: 5
// }
- static scoped_ptr<EventListener> ForExtension(
+ static std::unique_ptr<EventListener> ForExtension(
const std::string& event_name,
const std::string& extension_id,
content::RenderProcessHost* process,
- scoped_ptr<base::DictionaryValue> filter);
- static scoped_ptr<EventListener> ForURL(
+ std::unique_ptr<base::DictionaryValue> filter);
+ static std::unique_ptr<EventListener> ForURL(
const std::string& event_name,
const GURL& listener_url,
content::RenderProcessHost* process,
- scoped_ptr<base::DictionaryValue> filter);
+ std::unique_ptr<base::DictionaryValue> filter);
~EventListener();
bool Equals(const EventListener* other) const;
- scoped_ptr<EventListener> Copy() const;
+ std::unique_ptr<EventListener> Copy() const;
// Returns true in the case of a lazy background page, and thus no process.
bool IsLazy() const;
@@ -90,13 +90,13 @@ class EventListener {
const std::string& extension_id,
const GURL& listener_url,
content::RenderProcessHost* process,
- scoped_ptr<base::DictionaryValue> filter);
+ std::unique_ptr<base::DictionaryValue> filter);
const std::string event_name_;
const std::string extension_id_;
const GURL listener_url_;
content::RenderProcessHost* process_;
- scoped_ptr<base::DictionaryValue> filter_;
+ std::unique_ptr<base::DictionaryValue> filter_;
EventFilter::MatcherID matcher_id_; // -1 if unset.
DISALLOW_COPY_AND_ASSIGN(EventListener);
@@ -123,7 +123,7 @@ class EventListenerMap {
// extensions::Event.
// Returns true if the listener was added (in the case that it has never been
// seen before).
- bool AddListener(scoped_ptr<EventListener> listener);
+ bool AddListener(std::unique_ptr<EventListener> listener);
// Remove a listener that .Equals() |listener|.
// Returns true if the listener was removed .
@@ -178,7 +178,7 @@ class EventListenerMap {
void CleanupListener(EventListener* listener);
bool IsFilteredEvent(const Event& event) const;
- scoped_ptr<EventMatcher> ParseEventMatcher(
+ std::unique_ptr<EventMatcher> ParseEventMatcher(
base::DictionaryValue* filter_dict);
// Listens for removals from this map.
diff --git a/chromium/extensions/browser/event_listener_map_unittest.cc b/chromium/extensions/browser/event_listener_map_unittest.cc
index 0fa17d08267..0b691cef623 100644
--- a/chromium/extensions/browser/event_listener_map_unittest.cc
+++ b/chromium/extensions/browser/event_listener_map_unittest.cc
@@ -5,6 +5,7 @@
#include "extensions/browser/event_listener_map.h"
#include "base/bind.h"
+#include "base/memory/ptr_util.h"
#include "content/public/test/mock_render_process_host.h"
#include "content/public/test/test_browser_context.h"
#include "extensions/browser/event_router.h"
@@ -25,11 +26,12 @@ const char kEvent1Name[] = "event1";
const char kEvent2Name[] = "event2";
const char kURL[] = "https://google.com/some/url";
-typedef base::Callback<scoped_ptr<EventListener>(
+typedef base::Callback<std::unique_ptr<EventListener>(
const std::string&, // event_name
content::RenderProcessHost*, // process
base::DictionaryValue* // filter (takes ownership)
- )> EventListenerConstructor;
+ )>
+ EventListenerConstructor;
class EmptyDelegate : public EventListenerMap::Delegate {
void OnListenerAdded(const EventListener* listener) override{};
@@ -44,11 +46,11 @@ class EventListenerMapTest : public testing::Test {
browser_context_(new content::TestBrowserContext),
process_(new content::MockRenderProcessHost(browser_context_.get())) {}
- scoped_ptr<DictionaryValue> CreateHostSuffixFilter(
+ std::unique_ptr<DictionaryValue> CreateHostSuffixFilter(
const std::string& suffix) {
- scoped_ptr<DictionaryValue> filter(new DictionaryValue);
- scoped_ptr<ListValue> filter_list(new ListValue);
- scoped_ptr<DictionaryValue> filter_dict(new DictionaryValue);
+ std::unique_ptr<DictionaryValue> filter(new DictionaryValue);
+ std::unique_ptr<ListValue> filter_list(new ListValue);
+ std::unique_ptr<DictionaryValue> filter_dict(new DictionaryValue);
filter_dict->Set("hostSuffix", new StringValue(suffix));
@@ -57,16 +59,16 @@ class EventListenerMapTest : public testing::Test {
return filter;
}
- scoped_ptr<Event> CreateNamedEvent(const std::string& event_name) {
+ std::unique_ptr<Event> CreateNamedEvent(const std::string& event_name) {
return CreateEvent(event_name, GURL());
}
- scoped_ptr<Event> CreateEvent(const std::string& event_name,
- const GURL& url) {
+ std::unique_ptr<Event> CreateEvent(const std::string& event_name,
+ const GURL& url) {
EventFilteringInfo info;
info.SetURL(url);
- scoped_ptr<Event> result(new Event(
- events::FOR_TEST, event_name, make_scoped_ptr(new ListValue()), NULL,
+ std::unique_ptr<Event> result(new Event(
+ events::FOR_TEST, event_name, base::WrapUnique(new ListValue()), NULL,
GURL(), EventRouter::USER_GESTURE_UNKNOWN, info));
return result;
}
@@ -80,35 +82,35 @@ class EventListenerMapTest : public testing::Test {
const EventListenerConstructor& constructor);
void TestHasListenerForEvent(const EventListenerConstructor& constructor);
- scoped_ptr<EventListenerMap::Delegate> delegate_;
- scoped_ptr<EventListenerMap> listeners_;
- scoped_ptr<content::TestBrowserContext> browser_context_;
- scoped_ptr<content::MockRenderProcessHost> process_;
+ std::unique_ptr<EventListenerMap::Delegate> delegate_;
+ std::unique_ptr<EventListenerMap> listeners_;
+ std::unique_ptr<content::TestBrowserContext> browser_context_;
+ std::unique_ptr<content::MockRenderProcessHost> process_;
};
-scoped_ptr<EventListener> CreateEventListenerForExtension(
+std::unique_ptr<EventListener> CreateEventListenerForExtension(
const std::string& extension_id,
const std::string& event_name,
content::RenderProcessHost* process,
base::DictionaryValue* filter) {
- return EventListener::ForExtension(
- event_name, extension_id, process, make_scoped_ptr(filter));
+ return EventListener::ForExtension(event_name, extension_id, process,
+ base::WrapUnique(filter));
}
-scoped_ptr<EventListener> CreateEventListenerForURL(
+std::unique_ptr<EventListener> CreateEventListenerForURL(
const GURL& listener_url,
const std::string& event_name,
content::RenderProcessHost* process,
base::DictionaryValue* filter) {
- return EventListener::ForURL(
- event_name, listener_url, process, make_scoped_ptr(filter));
+ return EventListener::ForURL(event_name, listener_url, process,
+ base::WrapUnique(filter));
}
void EventListenerMapTest::TestUnfilteredEventsGoToAllListeners(
const EventListenerConstructor& constructor) {
listeners_->AddListener(
constructor.Run(kEvent1Name, NULL, new DictionaryValue()));
- scoped_ptr<Event> event(CreateNamedEvent(kEvent1Name));
+ std::unique_ptr<Event> event(CreateNamedEvent(kEvent1Name));
ASSERT_EQ(1u, listeners_->GetEventListeners(*event).size());
}
@@ -126,12 +128,10 @@ TEST_F(EventListenerMapTest, FilteredEventsGoToAllMatchingListeners) {
listeners_->AddListener(EventListener::ForExtension(
kEvent1Name, kExt1Id, NULL, CreateHostSuffixFilter("google.com")));
listeners_->AddListener(EventListener::ForExtension(
- kEvent1Name,
- kExt1Id,
- NULL,
- scoped_ptr<DictionaryValue>(new DictionaryValue)));
+ kEvent1Name, kExt1Id, NULL,
+ std::unique_ptr<DictionaryValue>(new DictionaryValue)));
- scoped_ptr<Event> event(CreateNamedEvent(kEvent1Name));
+ std::unique_ptr<Event> event(CreateNamedEvent(kEvent1Name));
event->filter_info.SetURL(GURL("http://www.google.com"));
std::set<const EventListener*> targets(listeners_->GetEventListeners(*event));
ASSERT_EQ(2u, targets.size());
@@ -143,7 +143,7 @@ TEST_F(EventListenerMapTest, FilteredEventsOnlyGoToMatchingListeners) {
listeners_->AddListener(EventListener::ForExtension(
kEvent1Name, kExt1Id, NULL, CreateHostSuffixFilter("yahoo.com")));
- scoped_ptr<Event> event(CreateNamedEvent(kEvent1Name));
+ std::unique_ptr<Event> event(CreateNamedEvent(kEvent1Name));
event->filter_info.SetURL(GURL("http://www.google.com"));
std::set<const EventListener*> targets(listeners_->GetEventListeners(*event));
ASSERT_EQ(1u, targets.size());
@@ -159,7 +159,7 @@ TEST_F(EventListenerMapTest, LazyAndUnlazyListenersGetReturned) {
process_.get(),
CreateHostSuffixFilter("google.com")));
- scoped_ptr<Event> event(CreateNamedEvent(kEvent1Name));
+ std::unique_ptr<Event> event(CreateNamedEvent(kEvent1Name));
event->filter_info.SetURL(GURL("http://www.google.com"));
std::set<const EventListener*> targets(listeners_->GetEventListeners(*event));
ASSERT_EQ(2u, targets.size());
@@ -177,7 +177,7 @@ void EventListenerMapTest::TestRemovingByProcess(
listeners_->RemoveListenersForProcess(process_.get());
- scoped_ptr<Event> event(CreateNamedEvent(kEvent1Name));
+ std::unique_ptr<Event> event(CreateNamedEvent(kEvent1Name));
event->filter_info.SetURL(GURL("http://www.google.com"));
ASSERT_EQ(1u, listeners_->GetEventListeners(*event).size());
}
@@ -200,13 +200,12 @@ void EventListenerMapTest::TestRemovingByListener(
process_.get(),
CreateHostSuffixFilter("google.com").release()));
- scoped_ptr<EventListener> listener(
- constructor.Run(kEvent1Name,
- process_.get(),
+ std::unique_ptr<EventListener> listener(
+ constructor.Run(kEvent1Name, process_.get(),
CreateHostSuffixFilter("google.com").release()));
listeners_->RemoveListener(listener.get());
- scoped_ptr<Event> event(CreateNamedEvent(kEvent1Name));
+ std::unique_ptr<Event> event(CreateNamedEvent(kEvent1Name));
event->filter_info.SetURL(GURL("http://www.google.com"));
ASSERT_EQ(1u, listeners_->GetEventListeners(*event).size());
}
@@ -225,19 +224,21 @@ TEST_F(EventListenerMapTest, TestLazyDoubleAddIsUndoneByRemove) {
listeners_->AddListener(EventListener::ForExtension(
kEvent1Name, kExt1Id, NULL, CreateHostSuffixFilter("google.com")));
- scoped_ptr<EventListener> listener(EventListener::ForExtension(
+ std::unique_ptr<EventListener> listener(EventListener::ForExtension(
kEvent1Name, kExt1Id, NULL, CreateHostSuffixFilter("google.com")));
listeners_->RemoveListener(listener.get());
- scoped_ptr<Event> event(CreateNamedEvent(kEvent1Name));
+ std::unique_ptr<Event> event(CreateNamedEvent(kEvent1Name));
event->filter_info.SetURL(GURL("http://www.google.com"));
std::set<const EventListener*> targets(listeners_->GetEventListeners(*event));
ASSERT_EQ(0u, targets.size());
}
TEST_F(EventListenerMapTest, HostSuffixFilterEquality) {
- scoped_ptr<DictionaryValue> filter1(CreateHostSuffixFilter("google.com"));
- scoped_ptr<DictionaryValue> filter2(CreateHostSuffixFilter("google.com"));
+ std::unique_ptr<DictionaryValue> filter1(
+ CreateHostSuffixFilter("google.com"));
+ std::unique_ptr<DictionaryValue> filter2(
+ CreateHostSuffixFilter("google.com"));
ASSERT_TRUE(filter1->Equals(filter2.get()));
}
@@ -249,7 +250,7 @@ TEST_F(EventListenerMapTest, RemoveListenersForExtension) {
listeners_->RemoveListenersForExtension(kExt1Id);
- scoped_ptr<Event> event(CreateNamedEvent(kEvent1Name));
+ std::unique_ptr<Event> event(CreateNamedEvent(kEvent1Name));
event->filter_info.SetURL(GURL("http://www.google.com"));
std::set<const EventListener*> targets(listeners_->GetEventListeners(*event));
ASSERT_EQ(0u, targets.size());
@@ -276,7 +277,7 @@ void EventListenerMapTest::TestAddExistingUnfilteredListener(
bool second_add = listeners_->AddListener(
constructor.Run(kEvent1Name, NULL, new DictionaryValue()));
- scoped_ptr<EventListener> listener(
+ std::unique_ptr<EventListener> listener(
constructor.Run(kEvent1Name, NULL, new DictionaryValue()));
bool first_remove = listeners_->RemoveListener(listener.get());
bool second_remove = listeners_->RemoveListener(listener.get());
@@ -298,10 +299,12 @@ TEST_F(EventListenerMapTest, AddExistingUnfilteredListenerForURLs) {
}
TEST_F(EventListenerMapTest, RemovingRouters) {
- listeners_->AddListener(EventListener::ForExtension(
- kEvent1Name, kExt1Id, process_.get(), scoped_ptr<DictionaryValue>()));
- listeners_->AddListener(EventListener::ForURL(
- kEvent1Name, GURL(kURL), process_.get(), scoped_ptr<DictionaryValue>()));
+ listeners_->AddListener(
+ EventListener::ForExtension(kEvent1Name, kExt1Id, process_.get(),
+ std::unique_ptr<DictionaryValue>()));
+ listeners_->AddListener(
+ EventListener::ForURL(kEvent1Name, GURL(kURL), process_.get(),
+ std::unique_ptr<DictionaryValue>()));
listeners_->RemoveListenersForProcess(process_.get());
ASSERT_FALSE(listeners_->HasListenerForEvent(kEvent1Name));
}
@@ -332,11 +335,12 @@ TEST_F(EventListenerMapTest, HasListenerForExtension) {
ASSERT_FALSE(listeners_->HasListenerForExtension(kExt1Id, kEvent1Name));
// Non-lazy listener.
- listeners_->AddListener(EventListener::ForExtension(
- kEvent1Name, kExt1Id, process_.get(), scoped_ptr<DictionaryValue>()));
+ listeners_->AddListener(
+ EventListener::ForExtension(kEvent1Name, kExt1Id, process_.get(),
+ std::unique_ptr<DictionaryValue>()));
// Lazy listener.
listeners_->AddListener(EventListener::ForExtension(
- kEvent1Name, kExt1Id, NULL, scoped_ptr<DictionaryValue>()));
+ kEvent1Name, kExt1Id, NULL, std::unique_ptr<DictionaryValue>()));
ASSERT_FALSE(listeners_->HasListenerForExtension(kExt1Id, kEvent2Name));
ASSERT_TRUE(listeners_->HasListenerForExtension(kExt1Id, kEvent1Name));
@@ -348,8 +352,9 @@ TEST_F(EventListenerMapTest, HasListenerForExtension) {
}
TEST_F(EventListenerMapTest, AddLazyListenersFromPreferences) {
- scoped_ptr<DictionaryValue> filter1(CreateHostSuffixFilter("google.com"));
- scoped_ptr<DictionaryValue> filter2(CreateHostSuffixFilter("yahoo.com"));
+ std::unique_ptr<DictionaryValue> filter1(
+ CreateHostSuffixFilter("google.com"));
+ std::unique_ptr<DictionaryValue> filter2(CreateHostSuffixFilter("yahoo.com"));
DictionaryValue filtered_listeners;
ListValue* filter_list = new ListValue();
@@ -360,17 +365,18 @@ TEST_F(EventListenerMapTest, AddLazyListenersFromPreferences) {
listeners_->LoadFilteredLazyListeners(kExt1Id, filtered_listeners);
- scoped_ptr<Event> event(CreateEvent(kEvent1Name,
- GURL("http://www.google.com")));
+ std::unique_ptr<Event> event(
+ CreateEvent(kEvent1Name, GURL("http://www.google.com")));
std::set<const EventListener*> targets(listeners_->GetEventListeners(*event));
ASSERT_EQ(1u, targets.size());
- scoped_ptr<EventListener> listener(EventListener::ForExtension(
+ std::unique_ptr<EventListener> listener(EventListener::ForExtension(
kEvent1Name, kExt1Id, NULL, CreateHostSuffixFilter("google.com")));
ASSERT_TRUE((*targets.begin())->Equals(listener.get()));
}
TEST_F(EventListenerMapTest, CorruptedExtensionPrefsShouldntCrash) {
- scoped_ptr<DictionaryValue> filter1(CreateHostSuffixFilter("google.com"));
+ std::unique_ptr<DictionaryValue> filter1(
+ CreateHostSuffixFilter("google.com"));
DictionaryValue filtered_listeners;
// kEvent1Name should be associated with a list, not a dictionary.
@@ -378,8 +384,8 @@ TEST_F(EventListenerMapTest, CorruptedExtensionPrefsShouldntCrash) {
listeners_->LoadFilteredLazyListeners(kExt1Id, filtered_listeners);
- scoped_ptr<Event> event(CreateEvent(kEvent1Name,
- GURL("http://www.google.com")));
+ std::unique_ptr<Event> event(
+ CreateEvent(kEvent1Name, GURL("http://www.google.com")));
std::set<const EventListener*> targets(listeners_->GetEventListeners(*event));
ASSERT_EQ(0u, targets.size());
}
diff --git a/chromium/extensions/browser/event_router.cc b/chromium/extensions/browser/event_router.cc
index 0f56fe73906..6cc2c7b647b 100644
--- a/chromium/extensions/browser/event_router.cc
+++ b/chromium/extensions/browser/event_router.cc
@@ -13,6 +13,7 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/lazy_instance.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram_macros.h"
#include "base/stl_util.h"
@@ -62,7 +63,7 @@ const char kFilteredEvents[] = "filtered_events";
void NotifyEventDispatched(void* browser_context_id,
const std::string& extension_id,
const std::string& event_name,
- scoped_ptr<ListValue> args) {
+ std::unique_ptr<ListValue> args) {
// The ApiActivityMonitor can only be accessed from the UI thread.
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(
@@ -113,7 +114,7 @@ void EventRouter::DispatchExtensionMessage(IPC::Sender* ipc_sender,
UserGestureState user_gesture,
const EventFilteringInfo& info) {
NotifyEventDispatched(browser_context_id, extension_id, event_name,
- make_scoped_ptr(event_args->DeepCopy()));
+ base::WrapUnique(event_args->DeepCopy()));
// TODO(chirantan): Make event dispatch a separate IPC so that it doesn't
// piggyback off MessageInvoke, which is used for other things.
@@ -132,7 +133,7 @@ void EventRouter::DispatchExtensionMessage(IPC::Sender* ipc_sender,
// DispatchExtensionMessage does _not_ take ownership of event_args, so we
// must ensure that the destruction of args does not attempt to free it.
- scoped_ptr<base::Value> removed_event_args;
+ std::unique_ptr<base::Value> removed_event_args;
args.Remove(1, &removed_event_args);
ignore_result(removed_event_args.release());
}
@@ -154,7 +155,7 @@ void EventRouter::DispatchEventToSender(IPC::Sender* ipc_sender,
const std::string& extension_id,
events::HistogramValue histogram_value,
const std::string& event_name,
- scoped_ptr<ListValue> event_args,
+ std::unique_ptr<ListValue> event_args,
UserGestureState user_gesture,
const EventFilteringInfo& info) {
int event_id = g_extension_event_id.GetNext();
@@ -199,14 +200,14 @@ void EventRouter::AddEventListener(const std::string& event_name,
content::RenderProcessHost* process,
const std::string& extension_id) {
listeners_.AddListener(EventListener::ForExtension(
- event_name, extension_id, process, scoped_ptr<DictionaryValue>()));
+ event_name, extension_id, process, std::unique_ptr<DictionaryValue>()));
}
void EventRouter::RemoveEventListener(const std::string& event_name,
content::RenderProcessHost* process,
const std::string& extension_id) {
- scoped_ptr<EventListener> listener = EventListener::ForExtension(
- event_name, extension_id, process, scoped_ptr<DictionaryValue>());
+ std::unique_ptr<EventListener> listener = EventListener::ForExtension(
+ event_name, extension_id, process, std::unique_ptr<DictionaryValue>());
listeners_.RemoveListener(listener.get());
}
@@ -214,14 +215,14 @@ void EventRouter::AddEventListenerForURL(const std::string& event_name,
content::RenderProcessHost* process,
const GURL& listener_url) {
listeners_.AddListener(EventListener::ForURL(
- event_name, listener_url, process, scoped_ptr<DictionaryValue>()));
+ event_name, listener_url, process, std::unique_ptr<DictionaryValue>()));
}
void EventRouter::RemoveEventListenerForURL(const std::string& event_name,
content::RenderProcessHost* process,
const GURL& listener_url) {
- scoped_ptr<EventListener> listener = EventListener::ForURL(
- event_name, listener_url, process, scoped_ptr<DictionaryValue>());
+ std::unique_ptr<EventListener> listener = EventListener::ForURL(
+ event_name, listener_url, process, std::unique_ptr<DictionaryValue>());
listeners_.RemoveListener(listener.get());
}
@@ -289,7 +290,7 @@ void EventRouter::RenderProcessHostDestroyed(content::RenderProcessHost* host) {
void EventRouter::AddLazyEventListener(const std::string& event_name,
const std::string& extension_id) {
bool is_new = listeners_.AddListener(EventListener::ForExtension(
- event_name, extension_id, NULL, scoped_ptr<DictionaryValue>()));
+ event_name, extension_id, NULL, std::unique_ptr<DictionaryValue>()));
if (is_new) {
std::set<std::string> events = GetRegisteredEvents(extension_id);
@@ -301,8 +302,8 @@ void EventRouter::AddLazyEventListener(const std::string& event_name,
void EventRouter::RemoveLazyEventListener(const std::string& event_name,
const std::string& extension_id) {
- scoped_ptr<EventListener> listener = EventListener::ForExtension(
- event_name, extension_id, NULL, scoped_ptr<DictionaryValue>());
+ std::unique_ptr<EventListener> listener = EventListener::ForExtension(
+ event_name, extension_id, NULL, std::unique_ptr<DictionaryValue>());
bool did_exist = listeners_.RemoveListener(listener.get());
if (did_exist) {
@@ -319,17 +320,13 @@ void EventRouter::AddFilteredEventListener(const std::string& event_name,
const base::DictionaryValue& filter,
bool add_lazy_listener) {
listeners_.AddListener(EventListener::ForExtension(
- event_name,
- extension_id,
- process,
- scoped_ptr<DictionaryValue>(filter.DeepCopy())));
+ event_name, extension_id, process,
+ std::unique_ptr<DictionaryValue>(filter.DeepCopy())));
if (add_lazy_listener) {
bool added = listeners_.AddListener(EventListener::ForExtension(
- event_name,
- extension_id,
- NULL,
- scoped_ptr<DictionaryValue>(filter.DeepCopy())));
+ event_name, extension_id, NULL,
+ std::unique_ptr<DictionaryValue>(filter.DeepCopy())));
if (added)
AddFilterToEvent(event_name, extension_id, &filter);
@@ -342,11 +339,9 @@ void EventRouter::RemoveFilteredEventListener(
const std::string& extension_id,
const base::DictionaryValue& filter,
bool remove_lazy_listener) {
- scoped_ptr<EventListener> listener = EventListener::ForExtension(
- event_name,
- extension_id,
- process,
- scoped_ptr<DictionaryValue>(filter.DeepCopy()));
+ std::unique_ptr<EventListener> listener = EventListener::ForExtension(
+ event_name, extension_id, process,
+ std::unique_ptr<DictionaryValue>(filter.DeepCopy()));
listeners_.RemoveListener(listener.get());
@@ -465,18 +460,18 @@ const DictionaryValue* EventRouter::GetFilteredEvents(
return events;
}
-void EventRouter::BroadcastEvent(scoped_ptr<Event> event) {
+void EventRouter::BroadcastEvent(std::unique_ptr<Event> event) {
DispatchEventImpl(std::string(), linked_ptr<Event>(event.release()));
}
void EventRouter::DispatchEventToExtension(const std::string& extension_id,
- scoped_ptr<Event> event) {
+ std::unique_ptr<Event> event) {
DCHECK(!extension_id.empty());
DispatchEventImpl(extension_id, linked_ptr<Event>(event.release()));
}
void EventRouter::DispatchEventWithLazyListener(const std::string& extension_id,
- scoped_ptr<Event> event) {
+ std::unique_ptr<Event> event) {
DCHECK(!extension_id.empty());
std::string event_name = event->event_name;
bool has_listener = ExtensionHasEventListener(extension_id, event_name);
@@ -858,12 +853,12 @@ void EventRouter::OnExtensionUnloaded(content::BrowserContext* browser_context,
Event::Event(events::HistogramValue histogram_value,
const std::string& event_name,
- scoped_ptr<base::ListValue> event_args)
+ std::unique_ptr<base::ListValue> event_args)
: Event(histogram_value, event_name, std::move(event_args), nullptr) {}
Event::Event(events::HistogramValue histogram_value,
const std::string& event_name,
- scoped_ptr<base::ListValue> event_args,
+ std::unique_ptr<base::ListValue> event_args,
BrowserContext* restrict_to_browser_context)
: Event(histogram_value,
event_name,
@@ -875,7 +870,7 @@ Event::Event(events::HistogramValue histogram_value,
Event::Event(events::HistogramValue histogram_value,
const std::string& event_name,
- scoped_ptr<ListValue> event_args_tmp,
+ std::unique_ptr<ListValue> event_args_tmp,
BrowserContext* restrict_to_browser_context,
const GURL& event_url,
EventRouter::UserGestureState user_gesture,
@@ -899,10 +894,10 @@ Event::Event(events::HistogramValue histogram_value,
Event::~Event() {}
Event* Event::DeepCopy() {
- Event* copy = new Event(histogram_value, event_name,
- scoped_ptr<base::ListValue>(event_args->DeepCopy()),
- restrict_to_browser_context, event_url, user_gesture,
- filter_info);
+ Event* copy = new Event(
+ histogram_value, event_name,
+ std::unique_ptr<base::ListValue>(event_args->DeepCopy()),
+ restrict_to_browser_context, event_url, user_gesture, filter_info);
copy->will_dispatch_callback = will_dispatch_callback;
return copy;
}
diff --git a/chromium/extensions/browser/event_router.h b/chromium/extensions/browser/event_router.h
index c90a335b6b1..d84385522b3 100644
--- a/chromium/extensions/browser/event_router.h
+++ b/chromium/extensions/browser/event_router.h
@@ -95,7 +95,7 @@ class EventRouter : public KeyedService,
const std::string& extension_id,
events::HistogramValue histogram_value,
const std::string& event_name,
- scoped_ptr<base::ListValue> event_args,
+ std::unique_ptr<base::ListValue> event_args,
UserGestureState user_gesture,
const EventFilteringInfo& info);
@@ -164,8 +164,8 @@ class EventRouter : public KeyedService,
bool HasEventListener(const std::string& event_name);
// Returns true if the extension is listening to the given event.
- bool ExtensionHasEventListener(const std::string& extension_id,
- const std::string& event_name);
+ virtual bool ExtensionHasEventListener(const std::string& extension_id,
+ const std::string& event_name);
// Return or set the list of events for which the given extension has
// registered.
@@ -174,18 +174,18 @@ class EventRouter : public KeyedService,
const std::set<std::string>& events);
// Broadcasts an event to every listener registered for that event.
- virtual void BroadcastEvent(scoped_ptr<Event> event);
+ virtual void BroadcastEvent(std::unique_ptr<Event> event);
// Dispatches an event to the given extension.
virtual void DispatchEventToExtension(const std::string& extension_id,
- scoped_ptr<Event> event);
+ std::unique_ptr<Event> event);
// Dispatches |event| to the given extension as if the extension has a lazy
// listener for it. NOTE: This should be used rarely, for dispatching events
// to extensions that haven't had a chance to add their own listeners yet, eg:
// newly installed extensions.
void DispatchEventWithLazyListener(const std::string& extension_id,
- scoped_ptr<Event> event);
+ std::unique_ptr<Event> event);
// Record the Event Ack from the renderer. (One less event in-flight.)
void OnEventAck(content::BrowserContext* context,
@@ -368,7 +368,7 @@ struct Event {
std::string event_name;
// Arguments to send to the event listener.
- scoped_ptr<base::ListValue> event_args;
+ std::unique_ptr<base::ListValue> event_args;
// If non-NULL, then the event will not be sent to other BrowserContexts
// unless the extension has permission (e.g. incognito tab update -> normal
@@ -397,16 +397,16 @@ struct Event {
Event(events::HistogramValue histogram_value,
const std::string& event_name,
- scoped_ptr<base::ListValue> event_args);
+ std::unique_ptr<base::ListValue> event_args);
Event(events::HistogramValue histogram_value,
const std::string& event_name,
- scoped_ptr<base::ListValue> event_args,
+ std::unique_ptr<base::ListValue> event_args,
content::BrowserContext* restrict_to_browser_context);
Event(events::HistogramValue histogram_value,
const std::string& event_name,
- scoped_ptr<base::ListValue> event_args,
+ std::unique_ptr<base::ListValue> event_args,
content::BrowserContext* restrict_to_browser_context,
const GURL& event_url,
EventRouter::UserGestureState user_gesture,
diff --git a/chromium/extensions/browser/event_router_unittest.cc b/chromium/extensions/browser/event_router_unittest.cc
index bcc38fbd0e7..eaaab112c63 100644
--- a/chromium/extensions/browser/event_router_unittest.cc
+++ b/chromium/extensions/browser/event_router_unittest.cc
@@ -4,13 +4,14 @@
#include "extensions/browser/event_router.h"
+#include <memory>
#include <string>
#include <utility>
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/test/histogram_tester.h"
#include "base/values.h"
#include "content/public/browser/notification_service.h"
@@ -62,28 +63,29 @@ class MockEventRouterObserver : public EventRouter::Observer {
DISALLOW_COPY_AND_ASSIGN(MockEventRouterObserver);
};
-typedef base::Callback<scoped_ptr<EventListener>(
+typedef base::Callback<std::unique_ptr<EventListener>(
const std::string&, // event_name
content::RenderProcessHost*, // process
base::DictionaryValue* // filter (takes ownership)
- )> EventListenerConstructor;
+ )>
+ EventListenerConstructor;
-scoped_ptr<EventListener> CreateEventListenerForExtension(
+std::unique_ptr<EventListener> CreateEventListenerForExtension(
const std::string& extension_id,
const std::string& event_name,
content::RenderProcessHost* process,
base::DictionaryValue* filter) {
- return EventListener::ForExtension(
- event_name, extension_id, process, make_scoped_ptr(filter));
+ return EventListener::ForExtension(event_name, extension_id, process,
+ base::WrapUnique(filter));
}
-scoped_ptr<EventListener> CreateEventListenerForURL(
+std::unique_ptr<EventListener> CreateEventListenerForURL(
const GURL& listener_url,
const std::string& event_name,
content::RenderProcessHost* process,
base::DictionaryValue* filter) {
- return EventListener::ForURL(
- event_name, listener_url, process, make_scoped_ptr(filter));
+ return EventListener::ForURL(event_name, listener_url, process,
+ base::WrapUnique(filter));
}
// Creates an extension. If |component| is true, it is created as a component
@@ -91,8 +93,8 @@ scoped_ptr<EventListener> CreateEventListenerForURL(
// background page; otherwise it is created with an event page.
scoped_refptr<Extension> CreateExtension(bool component, bool persistent) {
ExtensionBuilder builder;
- scoped_ptr<base::DictionaryValue> manifest =
- make_scoped_ptr(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> manifest =
+ base::WrapUnique(new base::DictionaryValue());
manifest->SetString("name", "foo");
manifest->SetString("version", "1.0.0");
manifest->SetInteger("manifest_version", 2);
@@ -157,7 +159,7 @@ class EventRouterTest : public ExtensionsTest {
}
private:
- scoped_ptr<content::NotificationService> notification_service_;
+ std::unique_ptr<content::NotificationService> notification_service_;
content::TestBrowserThreadBundle thread_bundle_;
base::HistogramTester histogram_tester_;
@@ -176,7 +178,7 @@ TEST_F(EventRouterTest, GetBaseEventName) {
void EventRouterTest::RunEventRouterObserverTest(
const EventListenerConstructor& constructor) {
EventRouter router(NULL, NULL);
- scoped_ptr<EventListener> listener =
+ std::unique_ptr<EventListener> listener =
constructor.Run("event_name", NULL, new base::DictionaryValue());
// Add/remove works without any observers.
@@ -212,7 +214,7 @@ void EventRouterTest::RunEventRouterObserverTest(
// Adding a listener with a sub-event notifies the main observer with
// proper details.
matching_observer.Reset();
- scoped_ptr<EventListener> sub_event_listener =
+ std::unique_ptr<EventListener> sub_event_listener =
constructor.Run("event_name/1", NULL, new base::DictionaryValue());
router.OnListenerAdded(sub_event_listener.get());
EXPECT_EQ(1, matching_observer.listener_added_count());
diff --git a/chromium/extensions/browser/extension_error_test_util.cc b/chromium/extensions/browser/extension_error_test_util.cc
index 0396d8604aa..8f42ec937c8 100644
--- a/chromium/extensions/browser/extension_error_test_util.cc
+++ b/chromium/extensions/browser/extension_error_test_util.cc
@@ -20,12 +20,12 @@ namespace {
const char kDefaultStackTrace[] = "function_name (https://url.com:1:1)";
}
-scoped_ptr<ExtensionError> CreateNewRuntimeError(
+std::unique_ptr<ExtensionError> CreateNewRuntimeError(
const std::string& extension_id,
const std::string& message,
bool from_incognito) {
StackTrace stack_trace;
- scoped_ptr<StackFrame> frame =
+ std::unique_ptr<StackFrame> frame =
StackFrame::CreateFromText(base::ASCIIToUTF16(kDefaultStackTrace));
CHECK(frame.get());
stack_trace.push_back(*frame);
@@ -35,7 +35,7 @@ scoped_ptr<ExtensionError> CreateNewRuntimeError(
url::kStandardSchemeSeparator +
extension_id);
- return scoped_ptr<ExtensionError>(
+ return std::unique_ptr<ExtensionError>(
new RuntimeError(extension_id, from_incognito, source,
base::UTF8ToUTF16(message), stack_trace,
GURL::EmptyGURL(), // no context url
@@ -44,18 +44,18 @@ scoped_ptr<ExtensionError> CreateNewRuntimeError(
0)); // Render process id
}
-scoped_ptr<ExtensionError> CreateNewRuntimeError(
- const std::string& extension_id, const std::string& message) {
+std::unique_ptr<ExtensionError> CreateNewRuntimeError(
+ const std::string& extension_id,
+ const std::string& message) {
return CreateNewRuntimeError(extension_id, message, false);
}
-scoped_ptr<ExtensionError> CreateNewManifestError(
- const std::string& extension_id, const std::string& message) {
- return scoped_ptr<ExtensionError>(
- new ManifestError(extension_id,
- base::UTF8ToUTF16(message),
- base::string16(),
- base::string16()));
+std::unique_ptr<ExtensionError> CreateNewManifestError(
+ const std::string& extension_id,
+ const std::string& message) {
+ return std::unique_ptr<ExtensionError>(
+ new ManifestError(extension_id, base::UTF8ToUTF16(message),
+ base::string16(), base::string16()));
}
} // namespace error_test_util
diff --git a/chromium/extensions/browser/extension_error_test_util.h b/chromium/extensions/browser/extension_error_test_util.h
index 6ea2da65d44..1d5e272cf2a 100644
--- a/chromium/extensions/browser/extension_error_test_util.h
+++ b/chromium/extensions/browser/extension_error_test_util.h
@@ -5,9 +5,9 @@
#ifndef EXTENSIONS_BROWSER_EXTENSION_ERROR_TEST_UTIL_H_
#define EXTENSIONS_BROWSER_EXTENSION_ERROR_TEST_UTIL_H_
+#include <memory>
#include <string>
-#include "base/memory/scoped_ptr.h"
namespace extensions {
@@ -16,17 +16,18 @@ class ExtensionError;
namespace error_test_util {
// Create a new RuntimeError.
-scoped_ptr<ExtensionError> CreateNewRuntimeError(
+std::unique_ptr<ExtensionError> CreateNewRuntimeError(
const std::string& extension_id,
const std::string& message,
bool from_incognito);
// Create a new RuntimeError; incognito defaults to "false".
-scoped_ptr<ExtensionError> CreateNewRuntimeError(
- const std::string& extension_id, const std::string& message);
+std::unique_ptr<ExtensionError> CreateNewRuntimeError(
+ const std::string& extension_id,
+ const std::string& message);
// Create a new ManifestError.
-scoped_ptr<ExtensionError> CreateNewManifestError(
+std::unique_ptr<ExtensionError> CreateNewManifestError(
const std::string& extension_id,
const std::string& message);
diff --git a/chromium/extensions/browser/extension_event_histogram_value.h b/chromium/extensions/browser/extension_event_histogram_value.h
index 479ce7db2f4..cb2b38f2be0 100644
--- a/chromium/extensions/browser/extension_event_histogram_value.h
+++ b/chromium/extensions/browser/extension_event_histogram_value.h
@@ -153,7 +153,7 @@ enum HistogramValue {
GCM_ON_MESSAGE,
GCM_ON_MESSAGES_DELETED,
GCM_ON_SEND_ERROR,
- HANGOUTS_PRIVATE_ON_HANGOUT_REQUESTED,
+ HANGOUTS_PRIVATE_ON_HANGOUT_REQUESTED_DEPRECATED,
HID_ON_DEVICE_ADDED,
HID_ON_DEVICE_REMOVED,
HISTORY_ON_VISITED,
@@ -415,6 +415,11 @@ enum HistogramValue {
INPUT_METHOD_PRIVATE_ON_IME_MENU_ACTIVATION_CHANGED,
INPUT_METHOD_PRIVATE_ON_IME_MENU_LIST_CHANGED,
INPUT_METHOD_PRIVATE_ON_IME_MENU_ITEMS_CHANGED,
+ BLUETOOTH_LOW_ENERGY_ON_CHARACTERISTIC_READ_REQUEST,
+ BLUETOOTH_LOW_ENERGY_ON_CHARACTERISTIC_WRITE_REQUEST,
+ BLUETOOTH_LOW_ENERGY_ON_DESCRIPTOR_READ_REQUEST,
+ BLUETOOTH_LOW_ENERGY_ON_DESCRIPTOR_WRITE_REQUEST,
+ ACCESSIBILITY_PRIVATE_ON_ACCESSIBILITY_GESTURE,
// Last entry: Add new entries above, then run:
// python tools/metrics/histograms/update_extension_histograms.py
ENUM_BOUNDARY
diff --git a/chromium/extensions/browser/extension_function.cc b/chromium/extensions/browser/extension_function.cc
index b11621fa96e..fd7bae96ceb 100644
--- a/chromium/extensions/browser/extension_function.cc
+++ b/chromium/extensions/browser/extension_function.cc
@@ -8,7 +8,9 @@
#include "base/logging.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/singleton.h"
+#include "base/metrics/histogram_macros.h"
#include "base/synchronization/lock.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
@@ -36,7 +38,7 @@ class ArgumentListResponseValue
ArgumentListResponseValue(const std::string& function_name,
const char* title,
ExtensionFunction* function,
- scoped_ptr<base::ListValue> result)
+ std::unique_ptr<base::ListValue> result)
: function_name_(function_name), title_(title) {
if (function->GetResultList()) {
DCHECK_EQ(function->GetResultList(), result.get())
@@ -67,7 +69,7 @@ class ErrorWithArgumentsResponseValue : public ArgumentListResponseValue {
ErrorWithArgumentsResponseValue(const std::string& function_name,
const char* title,
ExtensionFunction* function,
- scoped_ptr<base::ListValue> result,
+ std::unique_ptr<base::ListValue> result,
const std::string& error)
: ArgumentListResponseValue(function_name,
title,
@@ -262,12 +264,13 @@ void ExtensionFunction::SetResult(base::Value* result) {
results_->Append(result);
}
-void ExtensionFunction::SetResult(scoped_ptr<base::Value> result) {
+void ExtensionFunction::SetResult(std::unique_ptr<base::Value> result) {
results_.reset(new base::ListValue());
results_->Append(std::move(result));
}
-void ExtensionFunction::SetResultList(scoped_ptr<base::ListValue> results) {
+void ExtensionFunction::SetResultList(
+ std::unique_ptr<base::ListValue> results) {
results_ = std::move(results);
}
@@ -289,26 +292,26 @@ bool ExtensionFunction::user_gesture() const {
ExtensionFunction::ResponseValue ExtensionFunction::NoArguments() {
return ResponseValue(new ArgumentListResponseValue(
- name(), "NoArguments", this, make_scoped_ptr(new base::ListValue())));
+ name(), "NoArguments", this, base::WrapUnique(new base::ListValue())));
}
ExtensionFunction::ResponseValue ExtensionFunction::OneArgument(
base::Value* arg) {
- scoped_ptr<base::ListValue> args(new base::ListValue());
+ std::unique_ptr<base::ListValue> args(new base::ListValue());
args->Append(arg);
return ResponseValue(new ArgumentListResponseValue(name(), "OneArgument",
this, std::move(args)));
}
ExtensionFunction::ResponseValue ExtensionFunction::OneArgument(
- scoped_ptr<base::Value> arg) {
+ std::unique_ptr<base::Value> arg) {
return OneArgument(arg.release());
}
ExtensionFunction::ResponseValue ExtensionFunction::TwoArguments(
base::Value* arg1,
base::Value* arg2) {
- scoped_ptr<base::ListValue> args(new base::ListValue());
+ std::unique_ptr<base::ListValue> args(new base::ListValue());
args->Append(arg1);
args->Append(arg2);
return ResponseValue(new ArgumentListResponseValue(name(), "TwoArguments",
@@ -316,7 +319,7 @@ ExtensionFunction::ResponseValue ExtensionFunction::TwoArguments(
}
ExtensionFunction::ResponseValue ExtensionFunction::ArgumentList(
- scoped_ptr<base::ListValue> args) {
+ std::unique_ptr<base::ListValue> args) {
return ResponseValue(new ArgumentListResponseValue(name(), "ArgumentList",
this, std::move(args)));
}
@@ -351,7 +354,7 @@ ExtensionFunction::ResponseValue ExtensionFunction::Error(
}
ExtensionFunction::ResponseValue ExtensionFunction::ErrorWithArguments(
- scoped_ptr<base::ListValue> args,
+ std::unique_ptr<base::ListValue> args,
const std::string& error) {
return ResponseValue(new ErrorWithArgumentsResponseValue(
name(), "ErrorWithArguments", this, std::move(args), error));
@@ -404,6 +407,20 @@ void ExtensionFunction::SendResponseImpl(bool success) {
results_.reset(new base::ListValue());
response_callback_.Run(type, *results_, GetError(), histogram_value());
+
+ // TODO(devlin): Once we have a baseline metric for how long functions take,
+ // we can create a handful of buckets and record the function name so that we
+ // can find what the fastest/slowest are. See crbug.com/608561.
+ // Note: Certain functions perform actions that are inherently slow - such as
+ // anything waiting on user action. As such, we can't always assume that a
+ // long execution time equates to a poorly-performing function.
+ if (success) {
+ UMA_HISTOGRAM_TIMES("Extensions.Functions.SucceededTotalExecutionTime",
+ timer_.Elapsed());
+ } else {
+ UMA_HISTOGRAM_TIMES("Extensions.Functions.FailedTotalExecutionTime",
+ timer_.Elapsed());
+ }
}
void ExtensionFunction::OnRespondingLater(ResponseValue value) {
diff --git a/chromium/extensions/browser/extension_function.h b/chromium/extensions/browser/extension_function.h
index cd712e3c316..0bf876410a0 100644
--- a/chromium/extensions/browser/extension_function.h
+++ b/chromium/extensions/browser/extension_function.h
@@ -8,16 +8,17 @@
#include <stddef.h>
#include <list>
+#include <memory>
#include <string>
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/process/process.h"
#include "base/sequenced_task_runner_helpers.h"
+#include "base/timer/elapsed_timer.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/console_message_level.h"
#include "extensions/browser/extension_function_histogram_value.h"
@@ -134,7 +135,7 @@ class ExtensionFunction
// Returns true for success, false for failure.
virtual bool Apply() = 0;
};
- typedef scoped_ptr<ResponseValueObject> ResponseValue;
+ typedef std::unique_ptr<ResponseValueObject> ResponseValue;
// The action to use when returning from RunAsync.
//
@@ -145,7 +146,7 @@ class ExtensionFunction
virtual void Execute() = 0;
};
- typedef scoped_ptr<ResponseActionObject> ResponseAction;
+ typedef std::unique_ptr<ResponseActionObject> ResponseAction;
// Helper class for tests to force all ExtensionFunction::user_gesture()
// calls to return true as long as at least one instance of this class
@@ -203,12 +204,12 @@ class ExtensionFunction
virtual void SetArgs(const base::ListValue* args);
// Sets a single Value as the results of the function.
- void SetResult(scoped_ptr<base::Value> result);
+ void SetResult(std::unique_ptr<base::Value> result);
// As above, but deprecated. TODO(estade): remove.
void SetResult(base::Value* result);
// Sets multiple Values as the results of the function.
- void SetResultList(scoped_ptr<base::ListValue> results);
+ void SetResultList(std::unique_ptr<base::ListValue> results);
// Retrieves the results of the function as a ListValue.
const base::ListValue* GetResultList() const;
@@ -300,17 +301,18 @@ class ExtensionFunction
// to this by hand.
ResponseValue OneArgument(base::Value* arg);
// Success, a single argument |arg| to pass to caller.
- ResponseValue OneArgument(scoped_ptr<base::Value> arg);
+ ResponseValue OneArgument(std::unique_ptr<base::Value> arg);
// Success, two arguments |arg1| and |arg2| to pass to caller. TAKES
// OWNERSHIP - raw pointers for convenience, since callers usually construct
// the argument to this by hand. Note that use of this function may imply you
// should be using the generated Result struct and ArgumentList.
ResponseValue TwoArguments(base::Value* arg1, base::Value* arg2);
// Success, a list of arguments |results| to pass to caller. TAKES OWNERSHIP
- // - a scoped_ptr<> for convenience, since callers usually get this from the
+ // - a std::unique_ptr<> for convenience, since callers usually get this from
+ // the
// result of a Create(...) call on the generated Results struct, for example,
// alarms::Get::Results::Create(alarm).
- ResponseValue ArgumentList(scoped_ptr<base::ListValue> results);
+ ResponseValue ArgumentList(std::unique_ptr<base::ListValue> results);
// Error. chrome.runtime.lastError.message will be set to |error|.
ResponseValue Error(const std::string& error);
// Error with formatting. Args are processed using
@@ -329,7 +331,7 @@ class ExtensionFunction
// Using this ResponseValue indicates something is wrong with the API.
// It shouldn't be possible to have both an error *and* some arguments.
// Some legacy APIs do rely on it though, like webstorePrivate.
- ResponseValue ErrorWithArguments(scoped_ptr<base::ListValue> args,
+ ResponseValue ErrorWithArguments(std::unique_ptr<base::ListValue> args,
const std::string& error);
// Bad message. A ResponseValue equivalent to EXTENSION_FUNCTION_VALIDATE(),
// so this will actually kill the renderer and not respond at all.
@@ -407,11 +409,11 @@ class ExtensionFunction
bool user_gesture_;
// The arguments to the API. Only non-null if argument were specified.
- scoped_ptr<base::ListValue> args_;
+ std::unique_ptr<base::ListValue> args_;
// The results of the API. This should be populated by the derived class
// before SendResponse() is called.
- scoped_ptr<base::ListValue> results_;
+ std::unique_ptr<base::ListValue> results_;
// Any detailed error from the API. This should be populated by the derived
// class before Run() returns.
@@ -439,6 +441,8 @@ class ExtensionFunction
int source_process_id_;
private:
+ base::ElapsedTimer timer_;
+
void OnRespondingLater(ResponseValue response);
DISALLOW_COPY_AND_ASSIGN(ExtensionFunction);
@@ -536,7 +540,7 @@ class UIThreadExtensionFunction : public ExtensionFunction {
// The RenderFrameHost we will send responses to.
content::RenderFrameHost* render_frame_host_;
- scoped_ptr<RenderFrameHostTracker> tracker_;
+ std::unique_ptr<RenderFrameHostTracker> tracker_;
DelegateForTests* delegate_;
diff --git a/chromium/extensions/browser/extension_function_dispatcher.cc b/chromium/extensions/browser/extension_function_dispatcher.cc
index 1ad91613b23..5f4d0df21cd 100644
--- a/chromium/extensions/browser/extension_function_dispatcher.cc
+++ b/chromium/extensions/browser/extension_function_dispatcher.cc
@@ -51,7 +51,7 @@ namespace {
// called. May be called from any thread.
void NotifyApiFunctionCalled(const std::string& extension_id,
const std::string& api_name,
- scoped_ptr<base::ListValue> args,
+ std::unique_ptr<base::ListValue> args,
content::BrowserContext* browser_context) {
// The ApiActivityMonitor can only be accessed from the main (UI) thread. If
// we're running on the wrong thread, re-dispatch from the main thread.
@@ -80,7 +80,7 @@ void NotifyApiFunctionCalled(const std::string& extension_id,
// this once all the extension APIs are updated to the feature system.
struct Static {
Static() : api(ExtensionAPI::CreateWithDefaultConfiguration()) {}
- scoped_ptr<ExtensionAPI> api;
+ std::unique_ptr<ExtensionAPI> api;
};
base::LazyInstance<Static> g_global_io_data = LAZY_INSTANCE_INITIALIZER;
@@ -284,7 +284,7 @@ void ExtensionFunctionDispatcher::DispatchOnIOThread(
&params.arguments,
base::TimeTicks::Now());
if (violation_error.empty()) {
- scoped_ptr<base::ListValue> args(params.arguments.DeepCopy());
+ std::unique_ptr<base::ListValue> args(params.arguments.DeepCopy());
NotifyApiFunctionCalled(extension->id(), params.name, std::move(args),
static_cast<content::BrowserContext*>(profile_id));
UMA_HISTOGRAM_SPARSE_SLOWLY("Extensions.FunctionCalls",
@@ -292,7 +292,16 @@ void ExtensionFunctionDispatcher::DispatchOnIOThread(
tracked_objects::ScopedProfile scoped_profile(
FROM_HERE_WITH_EXPLICIT_FUNCTION(function->name()),
tracked_objects::ScopedProfile::ENABLED);
+ base::ElapsedTimer timer;
function->Run()->Execute();
+ // TODO(devlin): Once we have a baseline metric for how long functions take,
+ // we can create a handful of buckets and record the function name so that
+ // we can find what the fastest/slowest are.
+ // Note: Many functions execute finish asynchronously, so this time is not
+ // always a representation of total time taken. See also
+ // Extensions.Functions.TotalExecutionTime.
+ UMA_HISTOGRAM_TIMES("Extensions.Functions.SynchronousExecutionTime",
+ timer.Elapsed());
} else {
function->OnQuotaExceeded(violation_error);
}
@@ -300,8 +309,7 @@ void ExtensionFunctionDispatcher::DispatchOnIOThread(
ExtensionFunctionDispatcher::ExtensionFunctionDispatcher(
content::BrowserContext* browser_context)
- : browser_context_(browser_context) {
-}
+ : browser_context_(browser_context), delegate_(nullptr) {}
ExtensionFunctionDispatcher::~ExtensionFunctionDispatcher() {
}
@@ -392,7 +400,7 @@ void ExtensionFunctionDispatcher::DispatchWithCallbackInternal(
base::TimeTicks::Now());
if (violation_error.empty()) {
- scoped_ptr<base::ListValue> args(params.arguments.DeepCopy());
+ std::unique_ptr<base::ListValue> args(params.arguments.DeepCopy());
// See crbug.com/39178.
ExtensionsBrowserClient::Get()->PermitExternalProtocolHandler();
@@ -403,7 +411,16 @@ void ExtensionFunctionDispatcher::DispatchWithCallbackInternal(
tracked_objects::ScopedProfile scoped_profile(
FROM_HERE_WITH_EXPLICIT_FUNCTION(function->name()),
tracked_objects::ScopedProfile::ENABLED);
+ base::ElapsedTimer timer;
function->Run()->Execute();
+ // TODO(devlin): Once we have a baseline metric for how long functions take,
+ // we can create a handful of buckets and record the function name so that
+ // we can find what the fastest/slowest are.
+ // Note: Many functions execute finish asynchronously, so this time is not
+ // always a representation of total time taken. See also
+ // Extensions.Functions.TotalExecutionTime.
+ UMA_HISTOGRAM_TIMES("Extensions.Functions.SynchronousExecutionTime",
+ timer.Elapsed());
} else {
function->OnQuotaExceeded(violation_error);
}
diff --git a/chromium/extensions/browser/extension_function_histogram_value.h b/chromium/extensions/browser/extension_function_histogram_value.h
index a36b774aa51..1884272d3b4 100644
--- a/chromium/extensions/browser/extension_function_histogram_value.h
+++ b/chromium/extensions/browser/extension_function_histogram_value.h
@@ -1173,6 +1173,21 @@ enum HistogramValue {
INPUT_IME_HIDEWINDOW,
INPUTMETHODPRIVATE_SHOWINPUTVIEW,
WALLPAPERPRIVATE_RECORDWALLPAPERUMA,
+ AUTOTESTPRIVATE_GETVISIBLENOTIFICATIONS,
+ WEBRTCLOGGINGPRIVATE_STARTRTCEVENTLOGGING,
+ WEBRTCLOGGINGPRIVATE_STOPRTCEVENTLOGGING,
+ PASSWORDSPRIVATE_GETSAVEDPASSWORDLIST,
+ PASSWORDSPRIVATE_GETPASSWORDEXCEPTIONLIST,
+ INPUTMETHODPRIVATE_OPENOPTIONSPAGE,
+ FEEDBACKPRIVATE_LOGSRTPROMPTRESULT,
+ BLUETOOTHLOWENERGY_CREATESERVICE,
+ BLUETOOTHLOWENERGY_CREATECHARACTERISTIC,
+ BLUETOOTHLOWENERGY_CREATEDESCRIPTOR,
+ BLUETOOTHLOWENERGY_REGISTERSERVICE,
+ BLUETOOTHLOWENERGY_UNREGISTERSERVICE,
+ BLUETOOTHLOWENERGY_SENDREQUESTRESPONSE,
+ BLUETOOTHLOWENERGY_NOTIFYCHARACTERISTICVALUECHANGED,
+ BLUETOOTHLOWENERGY_REMOVESERVICE,
// Last entry: Add new entries above, then run:
// python tools/metrics/histograms/update_extension_histograms.py
ENUM_BOUNDARY
diff --git a/chromium/extensions/browser/extension_host.h b/chromium/extensions/browser/extension_host.h
index 50ddf21b4fb..3e30c9abcf8 100644
--- a/chromium/extensions/browser/extension_host.h
+++ b/chromium/extensions/browser/extension_host.h
@@ -7,12 +7,12 @@
#include <stdint.h>
+#include <memory>
#include <set>
#include <string>
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "base/timer/elapsed_timer.h"
#include "content/public/browser/web_contents_delegate.h"
@@ -165,7 +165,7 @@ class ExtensionHost : public DeferredStartRenderHost,
void RecordStopLoadingUMA();
// Delegate for functionality that cannot exist in the extensions module.
- scoped_ptr<ExtensionHostDelegate> delegate_;
+ std::unique_ptr<ExtensionHostDelegate> delegate_;
// The extension that we're hosting in this view.
const Extension* extension_;
@@ -177,7 +177,7 @@ class ExtensionHost : public DeferredStartRenderHost,
content::BrowserContext* browser_context_;
// The host for our HTML content.
- scoped_ptr<content::WebContents> host_contents_;
+ std::unique_ptr<content::WebContents> host_contents_;
// A weak pointer to the current or pending RenderViewHost. We don't access
// this through the host_contents because we want to deal with the pending
@@ -213,7 +213,7 @@ class ExtensionHost : public DeferredStartRenderHost,
// Measures how long since the initial URL started loading. This timer is
// started only once the ExtensionHost has exited the ExtensionHostQueue.
- scoped_ptr<base::ElapsedTimer> load_start_;
+ std::unique_ptr<base::ElapsedTimer> load_start_;
base::ObserverList<ExtensionHostObserver> observer_list_;
base::ObserverList<DeferredStartRenderHostObserver>
diff --git a/chromium/extensions/browser/extension_icon_image_unittest.cc b/chromium/extensions/browser/extension_icon_image_unittest.cc
index dba5e05dbd0..71a3964fd64 100644
--- a/chromium/extensions/browser/extension_icon_image_unittest.cc
+++ b/chromium/extensions/browser/extension_icon_image_unittest.cc
@@ -105,8 +105,9 @@ class ExtensionIconImageTest : public ExtensionsTest,
std::string error;
JSONFileValueDeserializer deserializer(
test_file.AppendASCII("manifest.json"));
- scoped_ptr<base::DictionaryValue> valid_value = base::DictionaryValue::From(
- deserializer.Deserialize(&error_code, &error));
+ std::unique_ptr<base::DictionaryValue> valid_value =
+ base::DictionaryValue::From(
+ deserializer.Deserialize(&error_code, &error));
EXPECT_EQ(0, error_code) << error;
if (error_code != 0)
return NULL;
@@ -143,7 +144,7 @@ class ExtensionIconImageTest : public ExtensionsTest,
content::TestBrowserThread ui_thread_;
content::TestBrowserThread file_thread_;
content::TestBrowserThread io_thread_;
- scoped_ptr<content::NotificationService> notification_service_;
+ std::unique_ptr<content::NotificationService> notification_service_;
DISALLOW_COPY_AND_ASSIGN(ExtensionIconImageTest);
};
@@ -472,13 +473,9 @@ TEST_F(ExtensionIconImageTest, IconImageDestruction) {
TestImageLoader::LoadAndGetExtensionBitmap(extension.get(), "16.png", 16);
ASSERT_FALSE(bitmap_16.empty());
- scoped_ptr<IconImage> image(
- new IconImage(browser_context(),
- extension.get(),
- IconsInfo::GetIcons(extension.get()),
- 16,
- default_icon,
- this));
+ std::unique_ptr<IconImage> image(new IconImage(
+ browser_context(), extension.get(), IconsInfo::GetIcons(extension.get()),
+ 16, default_icon, this));
// Load an image representation.
gfx::ImageSkiaRep representation =
@@ -518,13 +515,9 @@ TEST_F(ExtensionIconImageTest, ImageCachesNewRepresentations) {
CreateExtension("extension_icon_image", Manifest::INVALID_LOCATION));
ASSERT_TRUE(extension.get() != NULL);
gfx::ImageSkia default_icon = GetDefaultIcon();
- scoped_ptr<IconImage> icon_image(
- new IconImage(browser_context(),
- extension.get(),
- IconsInfo::GetIcons(extension.get()),
- 16,
- default_icon,
- this));
+ std::unique_ptr<IconImage> icon_image(new IconImage(
+ browser_context(), extension.get(), IconsInfo::GetIcons(extension.get()),
+ 16, default_icon, this));
// Load an image representation.
gfx::ImageSkiaRep representation =
diff --git a/chromium/extensions/browser/extension_message_filter.h b/chromium/extensions/browser/extension_message_filter.h
index 65900d13848..d804d8f01ae 100644
--- a/chromium/extensions/browser/extension_message_filter.h
+++ b/chromium/extensions/browser/extension_message_filter.h
@@ -86,7 +86,8 @@ class ExtensionMessageFilter : public content::BrowserMessageFilter {
const int render_process_id_;
- scoped_ptr<KeyedServiceShutdownNotifier::Subscription> shutdown_notifier_;
+ std::unique_ptr<KeyedServiceShutdownNotifier::Subscription>
+ shutdown_notifier_;
// Only access from the UI thread.
content::BrowserContext* browser_context_;
diff --git a/chromium/extensions/browser/extension_pref_value_map.cc b/chromium/extensions/browser/extension_pref_value_map.cc
index bb1fde5dd61..4b00bf8bb0d 100644
--- a/chromium/extensions/browser/extension_pref_value_map.cc
+++ b/chromium/extensions/browser/extension_pref_value_map.cc
@@ -4,6 +4,7 @@
#include "extensions/browser/extension_pref_value_map.h"
+#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "components/prefs/pref_value_map.h"
@@ -50,7 +51,7 @@ void ExtensionPrefValueMap::SetExtensionPref(const std::string& ext_id,
base::Value* value) {
PrefValueMap* prefs = GetExtensionPrefValueMap(ext_id, scope);
- if (prefs->SetValue(key, make_scoped_ptr(value)))
+ if (prefs->SetValue(key, base::WrapUnique(value)))
NotifyPrefValueChanged(key);
}
@@ -120,7 +121,7 @@ void ExtensionPrefValueMap::RegisterExtension(const std::string& ext_id,
bool is_enabled,
bool is_incognito_enabled) {
if (entries_.find(ext_id) == entries_.end()) {
- entries_[ext_id] = make_scoped_ptr(new ExtensionEntry);
+ entries_[ext_id] = base::WrapUnique(new ExtensionEntry);
// Only update the install time if the extension is newly installed.
entries_[ext_id]->install_time = install_time;
diff --git a/chromium/extensions/browser/extension_pref_value_map.h b/chromium/extensions/browser/extension_pref_value_map.h
index aed71c5c590..d13609162a6 100644
--- a/chromium/extensions/browser/extension_pref_value_map.h
+++ b/chromium/extensions/browser/extension_pref_value_map.h
@@ -6,11 +6,11 @@
#define EXTENSIONS_BROWSER_EXTENSION_PREF_VALUE_MAP_H_
#include <map>
+#include <memory>
#include <set>
#include <string>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "components/keyed_service/core/keyed_service.h"
#include "extensions/browser/extension_prefs_scope.h"
@@ -164,7 +164,8 @@ class ExtensionPrefValueMap : public KeyedService {
private:
struct ExtensionEntry;
- typedef std::map<std::string, scoped_ptr<ExtensionEntry>> ExtensionEntryMap;
+ typedef std::map<std::string, std::unique_ptr<ExtensionEntry>>
+ ExtensionEntryMap;
const PrefValueMap* GetExtensionPrefValueMap(
const std::string& ext_id,
diff --git a/chromium/extensions/browser/extension_pref_value_map_unittest.cc b/chromium/extensions/browser/extension_pref_value_map_unittest.cc
index 984448ba63b..c2f1fdd4b62 100644
--- a/chromium/extensions/browser/extension_pref_value_map_unittest.cc
+++ b/chromium/extensions/browser/extension_pref_value_map_unittest.cc
@@ -2,14 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "extensions/browser/extension_pref_value_map.h"
+
#include <stdint.h>
+#include <memory>
+
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "components/prefs/pref_store_observer_mock.h"
-#include "extensions/browser/extension_pref_value_map.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/chromium/extensions/browser/extension_prefs.cc b/chromium/extensions/browser/extension_prefs.cc
index df21c374979..5e77c0c250c 100644
--- a/chromium/extensions/browser/extension_prefs.cc
+++ b/chromium/extensions/browser/extension_prefs.cc
@@ -10,7 +10,10 @@
#include <iterator>
#include <utility>
+#include "base/debug/crash_logging.h"
+#include "base/debug/dump_without_crashing.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
@@ -309,8 +312,15 @@ T* ExtensionPrefs::ScopedUpdate<T, type_enum_value>::Create() {
// It would be nice to CHECK that this doesn't happen, but since prefs can
// get into a mangled state, we can't really do that. Instead, handle it
// gracefully (by overwriting whatever was previously there).
+ // TODO(devlin): It's unclear if there's anything we'll ever be able to do
+ // here (corrupted prefs are sometimes a fact of life), but the debug info
+ // might be useful. Remove the dumps after we analyze them.
if (key_value->GetType() != type_enum_value) {
NOTREACHED();
+ base::debug::SetCrashKeyValue(
+ "existing_extension_pref_value_type",
+ base::IntToString(static_cast<int>(key_value->GetType())));
+ base::debug::DumpWithoutCrashing();
value_as_t = new T();
extension->SetWithoutPathExpansion(key_, value_as_t);
} else {
@@ -341,7 +351,7 @@ ExtensionPrefs* ExtensionPrefs::Create(
return ExtensionPrefs::Create(browser_context, prefs, root_dir,
extension_pref_value_map, extensions_disabled,
early_observers,
- make_scoped_ptr(new TimeProvider()));
+ base::WrapUnique(new TimeProvider()));
}
// static
@@ -352,7 +362,7 @@ ExtensionPrefs* ExtensionPrefs::Create(
ExtensionPrefValueMap* extension_pref_value_map,
bool extensions_disabled,
const std::vector<ExtensionPrefsObserver*>& early_observers,
- scoped_ptr<TimeProvider> time_provider) {
+ std::unique_ptr<TimeProvider> time_provider) {
return new ExtensionPrefs(browser_context, pref_service, root_dir,
extension_pref_value_map, std::move(time_provider),
extensions_disabled, early_observers);
@@ -558,7 +568,7 @@ bool ExtensionPrefs::ReadPrefAsBooleanAndReturn(
return ReadPrefAsBoolean(extension_id, pref_key, &out_value) && out_value;
}
-scoped_ptr<const PermissionSet> ExtensionPrefs::ReadPrefAsPermissionSet(
+std::unique_ptr<const PermissionSet> ExtensionPrefs::ReadPrefAsPermissionSet(
const std::string& extension_id,
const std::string& pref_key) const {
if (!GetExtensionPref(extension_id))
@@ -599,8 +609,8 @@ scoped_ptr<const PermissionSet> ExtensionPrefs::ReadPrefAsPermissionSet(
extension_id, JoinPrefs(pref_key, kPrefScriptableHosts),
&scriptable_hosts, UserScript::ValidUserScriptSchemes());
- return make_scoped_ptr(new PermissionSet(apis, manifest_permissions,
- explicit_hosts, scriptable_hosts));
+ return base::WrapUnique(new PermissionSet(apis, manifest_permissions,
+ explicit_hosts, scriptable_hosts));
}
// Set the API or Manifest permissions.
@@ -616,7 +626,7 @@ static base::ListValue* CreatePermissionList(const T& permissions) {
base::ListValue* values = new base::ListValue();
for (typename T::const_iterator i = permissions.begin();
i != permissions.end(); ++i) {
- scoped_ptr<base::Value> detail(i->ToValue());
+ std::unique_ptr<base::Value> detail(i->ToValue());
if (detail) {
base::DictionaryValue* tmp = new base::DictionaryValue();
tmp->Set(i->name(), detail.release());
@@ -946,7 +956,7 @@ void ExtensionPrefs::SetActiveBit(const std::string& extension_id,
new base::FundamentalValue(active));
}
-scoped_ptr<const PermissionSet> ExtensionPrefs::GetGrantedPermissions(
+std::unique_ptr<const PermissionSet> ExtensionPrefs::GetGrantedPermissions(
const std::string& extension_id) const {
CHECK(crx_file::id_util::IdIsValid(extension_id));
return ReadPrefAsPermissionSet(extension_id, kPrefGrantedPermissions);
@@ -955,8 +965,9 @@ scoped_ptr<const PermissionSet> ExtensionPrefs::GetGrantedPermissions(
void ExtensionPrefs::AddGrantedPermissions(const std::string& extension_id,
const PermissionSet& permissions) {
CHECK(crx_file::id_util::IdIsValid(extension_id));
- scoped_ptr<const PermissionSet> granted = GetGrantedPermissions(extension_id);
- scoped_ptr<const PermissionSet> union_set;
+ std::unique_ptr<const PermissionSet> granted =
+ GetGrantedPermissions(extension_id);
+ std::unique_ptr<const PermissionSet> union_set;
if (granted)
union_set = PermissionSet::CreateUnion(permissions, *granted);
// The new granted permissions are the union of the already granted
@@ -978,7 +989,7 @@ void ExtensionPrefs::RemoveGrantedPermissions(
permissions));
}
-scoped_ptr<const PermissionSet> ExtensionPrefs::GetActivePermissions(
+std::unique_ptr<const PermissionSet> ExtensionPrefs::GetActivePermissions(
const std::string& extension_id) const {
CHECK(crx_file::id_util::IdIsValid(extension_id));
return ReadPrefAsPermissionSet(extension_id, kPrefActivePermissions);
@@ -1194,12 +1205,12 @@ void ExtensionPrefs::UpdateManifest(const Extension* extension) {
}
}
-scoped_ptr<ExtensionInfo> ExtensionPrefs::GetInstalledInfoHelper(
+std::unique_ptr<ExtensionInfo> ExtensionPrefs::GetInstalledInfoHelper(
const std::string& extension_id,
const base::DictionaryValue* extension) const {
int location_value;
if (!extension->GetInteger(kPrefLocation, &location_value))
- return scoped_ptr<ExtensionInfo>();
+ return std::unique_ptr<ExtensionInfo>();
Manifest::Location location = static_cast<Manifest::Location>(location_value);
if (location == Manifest::COMPONENT) {
@@ -1208,7 +1219,7 @@ scoped_ptr<ExtensionInfo> ExtensionPrefs::GetInstalledInfoHelper(
// ComponentLoader) and shouldn't be populated into the result of
// GetInstalledExtensionsInfo, otherwise InstalledLoader would also want to
// load them.
- return scoped_ptr<ExtensionInfo>();
+ return std::unique_ptr<ExtensionInfo>();
}
// Only the following extension types have data saved in the preferences.
@@ -1216,7 +1227,7 @@ scoped_ptr<ExtensionInfo> ExtensionPrefs::GetInstalledInfoHelper(
!Manifest::IsUnpackedLocation(location) &&
!Manifest::IsExternalLocation(location)) {
NOTREACHED();
- return scoped_ptr<ExtensionInfo>();
+ return std::unique_ptr<ExtensionInfo>();
}
const base::DictionaryValue* manifest = NULL;
@@ -1228,38 +1239,38 @@ scoped_ptr<ExtensionInfo> ExtensionPrefs::GetInstalledInfoHelper(
base::FilePath::StringType path;
if (!extension->GetString(kPrefPath, &path))
- return scoped_ptr<ExtensionInfo>();
+ return std::unique_ptr<ExtensionInfo>();
// Make path absolute. Most (but not all) extension types have relative paths.
if (!base::FilePath(path).IsAbsolute())
path = install_directory_.Append(path).value();
- return scoped_ptr<ExtensionInfo>(new ExtensionInfo(
+ return std::unique_ptr<ExtensionInfo>(new ExtensionInfo(
manifest, extension_id, base::FilePath(path), location));
}
-scoped_ptr<ExtensionInfo> ExtensionPrefs::GetInstalledExtensionInfo(
+std::unique_ptr<ExtensionInfo> ExtensionPrefs::GetInstalledExtensionInfo(
const std::string& extension_id) const {
const base::DictionaryValue* ext = NULL;
const base::DictionaryValue* extensions =
prefs_->GetDictionary(pref_names::kExtensions);
if (!extensions ||
!extensions->GetDictionaryWithoutPathExpansion(extension_id, &ext))
- return scoped_ptr<ExtensionInfo>();
+ return std::unique_ptr<ExtensionInfo>();
int state_value;
if (ext->GetInteger(kPrefState, &state_value) &&
state_value == Extension::EXTERNAL_EXTENSION_UNINSTALLED) {
LOG(WARNING) << "External extension with id " << extension_id
<< " has been uninstalled by the user";
- return scoped_ptr<ExtensionInfo>();
+ return std::unique_ptr<ExtensionInfo>();
}
return GetInstalledInfoHelper(extension_id, ext);
}
-scoped_ptr<ExtensionPrefs::ExtensionsInfo>
+std::unique_ptr<ExtensionPrefs::ExtensionsInfo>
ExtensionPrefs::GetInstalledExtensionsInfo() const {
- scoped_ptr<ExtensionsInfo> extensions_info(new ExtensionsInfo);
+ std::unique_ptr<ExtensionsInfo> extensions_info(new ExtensionsInfo);
const base::DictionaryValue* extensions =
prefs_->GetDictionary(pref_names::kExtensions);
@@ -1268,7 +1279,7 @@ ExtensionPrefs::GetInstalledExtensionsInfo() const {
if (!crx_file::id_util::IdIsValid(extension_id.key()))
continue;
- scoped_ptr<ExtensionInfo> info =
+ std::unique_ptr<ExtensionInfo> info =
GetInstalledExtensionInfo(extension_id.key());
if (info)
extensions_info->push_back(linked_ptr<ExtensionInfo>(info.release()));
@@ -1277,9 +1288,9 @@ ExtensionPrefs::GetInstalledExtensionsInfo() const {
return extensions_info;
}
-scoped_ptr<ExtensionPrefs::ExtensionsInfo>
+std::unique_ptr<ExtensionPrefs::ExtensionsInfo>
ExtensionPrefs::GetUninstalledExtensionsInfo() const {
- scoped_ptr<ExtensionsInfo> extensions_info(new ExtensionsInfo);
+ std::unique_ptr<ExtensionsInfo> extensions_info(new ExtensionsInfo);
const base::DictionaryValue* extensions =
prefs_->GetDictionary(pref_names::kExtensions);
@@ -1291,7 +1302,7 @@ ExtensionPrefs::GetUninstalledExtensionsInfo() const {
!extension_id.value().GetAsDictionary(&ext))
continue;
- scoped_ptr<ExtensionInfo> info =
+ std::unique_ptr<ExtensionInfo> info =
GetInstalledInfoHelper(extension_id.key(), ext);
if (info)
extensions_info->push_back(linked_ptr<ExtensionInfo>(info.release()));
@@ -1379,16 +1390,16 @@ bool ExtensionPrefs::FinishDelayedInstallInfo(
return true;
}
-scoped_ptr<ExtensionInfo> ExtensionPrefs::GetDelayedInstallInfo(
+std::unique_ptr<ExtensionInfo> ExtensionPrefs::GetDelayedInstallInfo(
const std::string& extension_id) const {
const base::DictionaryValue* extension_prefs =
GetExtensionPref(extension_id);
if (!extension_prefs)
- return scoped_ptr<ExtensionInfo>();
+ return std::unique_ptr<ExtensionInfo>();
const base::DictionaryValue* ext = NULL;
if (!extension_prefs->GetDictionary(kDelayedInstallInfo, &ext))
- return scoped_ptr<ExtensionInfo>();
+ return std::unique_ptr<ExtensionInfo>();
return GetInstalledInfoHelper(extension_id, ext);
}
@@ -1411,9 +1422,9 @@ ExtensionPrefs::DelayReason ExtensionPrefs::GetDelayedInstallReason(
return static_cast<DelayReason>(delay_reason);
}
-scoped_ptr<ExtensionPrefs::ExtensionsInfo> ExtensionPrefs::
- GetAllDelayedInstallInfo() const {
- scoped_ptr<ExtensionsInfo> extensions_info(new ExtensionsInfo);
+std::unique_ptr<ExtensionPrefs::ExtensionsInfo>
+ExtensionPrefs::GetAllDelayedInstallInfo() const {
+ std::unique_ptr<ExtensionsInfo> extensions_info(new ExtensionsInfo);
const base::DictionaryValue* extensions =
prefs_->GetDictionary(pref_names::kExtensions);
@@ -1422,7 +1433,8 @@ scoped_ptr<ExtensionPrefs::ExtensionsInfo> ExtensionPrefs::
if (!crx_file::id_util::IdIsValid(extension_id.key()))
continue;
- scoped_ptr<ExtensionInfo> info = GetDelayedInstallInfo(extension_id.key());
+ std::unique_ptr<ExtensionInfo> info =
+ GetDelayedInstallInfo(extension_id.key());
if (info)
extensions_info->push_back(linked_ptr<ExtensionInfo>(info.release()));
}
@@ -1572,7 +1584,7 @@ void ExtensionPrefs::ClearLastLaunchTimes() {
void ExtensionPrefs::GetExtensions(ExtensionIdList* out) const {
CHECK(out);
- scoped_ptr<ExtensionsInfo> extensions_info(GetInstalledExtensionsInfo());
+ std::unique_ptr<ExtensionsInfo> extensions_info(GetInstalledExtensionsInfo());
for (size_t i = 0; i < extensions_info->size(); ++i) {
ExtensionInfo* info = extensions_info->at(i).get();
@@ -1667,7 +1679,7 @@ const base::DictionaryValue* ExtensionPrefs::GetGeometryCache(
void ExtensionPrefs::SetGeometryCache(
const std::string& extension_id,
- scoped_ptr<base::DictionaryValue> cache) {
+ std::unique_ptr<base::DictionaryValue> cache) {
UpdateExtensionPref(extension_id, kPrefGeometryCache, cache.release());
}
@@ -1728,7 +1740,7 @@ ExtensionPrefs::ExtensionPrefs(
PrefService* prefs,
const base::FilePath& root_dir,
ExtensionPrefValueMap* extension_pref_value_map,
- scoped_ptr<TimeProvider> time_provider,
+ std::unique_ptr<TimeProvider> time_provider,
bool extensions_disabled,
const std::vector<ExtensionPrefsObserver*>& early_observers)
: browser_context_(browser_context),
diff --git a/chromium/extensions/browser/extension_prefs.h b/chromium/extensions/browser/extension_prefs.h
index 80b5e371677..bae2126e755 100644
--- a/chromium/extensions/browser/extension_prefs.h
+++ b/chromium/extensions/browser/extension_prefs.h
@@ -5,13 +5,13 @@
#ifndef EXTENSIONS_BROWSER_EXTENSION_PREFS_H_
#define EXTENSIONS_BROWSER_EXTENSION_PREFS_H_
+#include <memory>
#include <set>
#include <string>
#include <vector>
#include "base/macros.h"
#include "base/memory/linked_ptr.h"
-#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "base/time/time.h"
#include "base/values.h"
@@ -72,6 +72,7 @@ class ExtensionPrefs : public ExtensionScopedPrefs, public KeyedService {
DELAY_REASON_GC = 1,
DELAY_REASON_WAIT_FOR_IDLE = 2,
DELAY_REASON_WAIT_FOR_IMPORTS = 3,
+ DELAY_REASON_WAIT_FOR_OS_UPDATE = 4,
};
// Creates base::Time classes. The default implementation is just to return
@@ -145,7 +146,7 @@ class ExtensionPrefs : public ExtensionScopedPrefs, public KeyedService {
ExtensionPrefValueMap* extension_pref_value_map,
bool extensions_disabled,
const std::vector<ExtensionPrefsObserver*>& early_observers,
- scoped_ptr<TimeProvider> time_provider);
+ std::unique_ptr<TimeProvider> time_provider);
~ExtensionPrefs() override;
@@ -355,7 +356,7 @@ class ExtensionPrefs : public ExtensionScopedPrefs, public KeyedService {
// Returns the granted permission set for the extension with |extension_id|,
// and NULL if no preferences were found for |extension_id|.
// This passes ownership of the returned set to the caller.
- scoped_ptr<const PermissionSet> GetGrantedPermissions(
+ std::unique_ptr<const PermissionSet> GetGrantedPermissions(
const std::string& extension_id) const;
// Adds |permissions| to the granted permissions set for the extension with
@@ -371,7 +372,7 @@ class ExtensionPrefs : public ExtensionScopedPrefs, public KeyedService {
// Gets the active permission set for the specified extension. This may
// differ from the permissions in the manifest due to the optional
// permissions API. This passes ownership of the set to the caller.
- scoped_ptr<const PermissionSet> GetActivePermissions(
+ std::unique_ptr<const PermissionSet> GetActivePermissions(
const std::string& extension_id) const;
// Sets the active |permissions| for the extension with |extension_id|.
@@ -412,15 +413,15 @@ class ExtensionPrefs : public ExtensionScopedPrefs, public KeyedService {
// version directory and the location. Blacklisted extensions won't be saved
// and neither will external extensions the user has explicitly uninstalled.
// Caller takes ownership of returned structure.
- scoped_ptr<ExtensionsInfo> GetInstalledExtensionsInfo() const;
+ std::unique_ptr<ExtensionsInfo> GetInstalledExtensionsInfo() const;
// Same as above, but only includes external extensions the user has
// explicitly uninstalled.
- scoped_ptr<ExtensionsInfo> GetUninstalledExtensionsInfo() const;
+ std::unique_ptr<ExtensionsInfo> GetUninstalledExtensionsInfo() const;
// Returns the ExtensionInfo from the prefs for the given extension. If the
// extension is not present, NULL is returned.
- scoped_ptr<ExtensionInfo> GetInstalledExtensionInfo(
+ std::unique_ptr<ExtensionInfo> GetInstalledExtensionInfo(
const std::string& extension_id) const;
// We've downloaded an updated .crx file for the extension, but are waiting
@@ -443,14 +444,14 @@ class ExtensionPrefs : public ExtensionScopedPrefs, public KeyedService {
// Returns the ExtensionInfo from the prefs for delayed install information
// for |extension_id|, if we have any. Otherwise returns NULL.
- scoped_ptr<ExtensionInfo> GetDelayedInstallInfo(
+ std::unique_ptr<ExtensionInfo> GetDelayedInstallInfo(
const std::string& extension_id) const;
DelayReason GetDelayedInstallReason(const std::string& extension_id) const;
// Returns information about all the extensions that have delayed install
// information.
- scoped_ptr<ExtensionsInfo> GetAllDelayedInstallInfo() const;
+ std::unique_ptr<ExtensionsInfo> GetAllDelayedInstallInfo() const;
// Returns true if the user repositioned the app on the app launcher via drag
// and drop.
@@ -521,7 +522,7 @@ class ExtensionPrefs : public ExtensionScopedPrefs, public KeyedService {
const base::DictionaryValue* GetGeometryCache(
const std::string& extension_id) const;
void SetGeometryCache(const std::string& extension_id,
- scoped_ptr<base::DictionaryValue> cache);
+ std::unique_ptr<base::DictionaryValue> cache);
// Used for verification of installed extension ids. For the Set method, pass
// null to remove the preference.
@@ -561,7 +562,7 @@ class ExtensionPrefs : public ExtensionScopedPrefs, public KeyedService {
PrefService* prefs,
const base::FilePath& root_dir,
ExtensionPrefValueMap* extension_pref_value_map,
- scoped_ptr<TimeProvider> time_provider,
+ std::unique_ptr<TimeProvider> time_provider,
bool extensions_disabled,
const std::vector<ExtensionPrefsObserver*>& early_observers);
@@ -576,7 +577,7 @@ class ExtensionPrefs : public ExtensionScopedPrefs, public KeyedService {
// Helper function used by GetInstalledExtensionInfo() and
// GetDelayedInstallInfo() to construct an ExtensionInfo from the provided
// |extension| dictionary.
- scoped_ptr<ExtensionInfo> GetInstalledInfoHelper(
+ std::unique_ptr<ExtensionInfo> GetInstalledInfoHelper(
const std::string& extension_id,
const base::DictionaryValue* extension) const;
@@ -600,7 +601,7 @@ class ExtensionPrefs : public ExtensionScopedPrefs, public KeyedService {
// Interprets |pref_key| in |extension_id|'s preferences as an
// PermissionSet, and passes ownership of the set to the caller.
- scoped_ptr<const PermissionSet> ReadPrefAsPermissionSet(
+ std::unique_ptr<const PermissionSet> ReadPrefAsPermissionSet(
const std::string& extension_id,
const std::string& pref_key) const;
@@ -681,7 +682,7 @@ class ExtensionPrefs : public ExtensionScopedPrefs, public KeyedService {
// Weak pointer, owned by BrowserContext.
ExtensionPrefValueMap* extension_pref_value_map_;
- scoped_ptr<TimeProvider> time_provider_;
+ std::unique_ptr<TimeProvider> time_provider_;
bool extensions_disabled_;
diff --git a/chromium/extensions/browser/extension_prefs_factory.cc b/chromium/extensions/browser/extension_prefs_factory.cc
index 888d9bd4f9f..1c1df4de49b 100644
--- a/chromium/extensions/browser/extension_prefs_factory.cc
+++ b/chromium/extensions/browser/extension_prefs_factory.cc
@@ -32,7 +32,7 @@ ExtensionPrefsFactory* ExtensionPrefsFactory::GetInstance() {
void ExtensionPrefsFactory::SetInstanceForTesting(
content::BrowserContext* context,
- scoped_ptr<ExtensionPrefs> prefs) {
+ std::unique_ptr<ExtensionPrefs> prefs) {
Disassociate(context);
Associate(context, std::move(prefs));
}
diff --git a/chromium/extensions/browser/extension_prefs_factory.h b/chromium/extensions/browser/extension_prefs_factory.h
index 3ddc2b96399..f53278142aa 100644
--- a/chromium/extensions/browser/extension_prefs_factory.h
+++ b/chromium/extensions/browser/extension_prefs_factory.h
@@ -5,7 +5,8 @@
#ifndef EXTENSIONS_BROWSER_EXTENSION_PREFS_FACTORY_H_
#define EXTENSIONS_BROWSER_EXTENSION_PREFS_FACTORY_H_
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "base/memory/singleton.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
@@ -20,7 +21,7 @@ class ExtensionPrefsFactory : public BrowserContextKeyedServiceFactory {
static ExtensionPrefsFactory* GetInstance();
void SetInstanceForTesting(content::BrowserContext* context,
- scoped_ptr<ExtensionPrefs> prefs);
+ std::unique_ptr<ExtensionPrefs> prefs);
private:
friend struct base::DefaultSingletonTraits<ExtensionPrefsFactory>;
diff --git a/chromium/extensions/browser/extension_protocols.cc b/chromium/extensions/browser/extension_protocols.cc
index 2dbbf31b9dd..c97f172607a 100644
--- a/chromium/extensions/browser/extension_protocols.cc
+++ b/chromium/extensions/browser/extension_protocols.cc
@@ -18,6 +18,7 @@
#include "base/format_macros.h"
#include "base/logging.h"
#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/metrics/field_trial.h"
@@ -282,7 +283,7 @@ class URLRequestExtensionJob : public net::URLRequestFileJob {
scoped_refptr<ContentVerifyJob> verify_job_;
- scoped_ptr<base::ElapsedTimer> request_timer_;
+ std::unique_ptr<base::ElapsedTimer> request_timer_;
// The position we seeked to in the file.
int64_t seek_position_;
@@ -575,10 +576,10 @@ net::HttpResponseHeaders* BuildHttpHeaders(
return new net::HttpResponseHeaders(raw_headers);
}
-scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>
CreateExtensionProtocolHandler(bool is_incognito,
extensions::InfoMap* extension_info_map) {
- return make_scoped_ptr(
+ return base::WrapUnique(
new ExtensionProtocolHandler(is_incognito, extension_info_map));
}
diff --git a/chromium/extensions/browser/extension_protocols.h b/chromium/extensions/browser/extension_protocols.h
index 190b50fca2b..aff38b1caaa 100644
--- a/chromium/extensions/browser/extension_protocols.h
+++ b/chromium/extensions/browser/extension_protocols.h
@@ -5,9 +5,9 @@
#ifndef EXTENSIONS_BROWSER_EXTENSION_PROTOCOLS_H_
#define EXTENSIONS_BROWSER_EXTENSION_PROTOCOLS_H_
+#include <memory>
#include <string>
-#include "base/memory/scoped_ptr.h"
#include "net/url_request/url_request_job_factory.h"
namespace base {
@@ -32,7 +32,7 @@ net::HttpResponseHeaders* BuildHttpHeaders(
// Creates the handlers for the chrome-extension:// scheme. Pass true for
// |is_incognito| only for incognito profiles and not for Chrome OS guest mode
// profiles.
-scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>
CreateExtensionProtocolHandler(bool is_incognito, InfoMap* extension_info_map);
} // namespace extensions
diff --git a/chromium/extensions/browser/extension_registry.cc b/chromium/extensions/browser/extension_registry.cc
index 49c499a005b..7054673ab34 100644
--- a/chromium/extensions/browser/extension_registry.cc
+++ b/chromium/extensions/browser/extension_registry.cc
@@ -19,14 +19,14 @@ ExtensionRegistry* ExtensionRegistry::Get(content::BrowserContext* context) {
return ExtensionRegistryFactory::GetForBrowserContext(context);
}
-scoped_ptr<ExtensionSet> ExtensionRegistry::GenerateInstalledExtensionsSet()
- const {
+std::unique_ptr<ExtensionSet>
+ExtensionRegistry::GenerateInstalledExtensionsSet() const {
return GenerateInstalledExtensionsSet(EVERYTHING);
}
-scoped_ptr<ExtensionSet> ExtensionRegistry::GenerateInstalledExtensionsSet(
+std::unique_ptr<ExtensionSet> ExtensionRegistry::GenerateInstalledExtensionsSet(
int include_mask) const {
- scoped_ptr<ExtensionSet> installed_extensions(new ExtensionSet);
+ std::unique_ptr<ExtensionSet> installed_extensions(new ExtensionSet);
if (include_mask & IncludeFlag::ENABLED)
installed_extensions->InsertAll(enabled_extensions_);
if (include_mask & IncludeFlag::DISABLED)
diff --git a/chromium/extensions/browser/extension_registry.h b/chromium/extensions/browser/extension_registry.h
index 405d07261e6..09c8a70ab4b 100644
--- a/chromium/extensions/browser/extension_registry.h
+++ b/chromium/extensions/browser/extension_registry.h
@@ -70,7 +70,7 @@ class ExtensionRegistry : public KeyedService {
// Returns the set of all installed extensions, regardless of state (enabled,
// disabled, etc). Equivalent to GenerateInstalledExtensionSet(EVERYTHING).
- scoped_ptr<ExtensionSet> GenerateInstalledExtensionsSet() const;
+ std::unique_ptr<ExtensionSet> GenerateInstalledExtensionsSet() const;
// Returns a set of all extensions in the subsets specified by |include_mask|.
// * enabled_extensions() --> ExtensionRegistry::ENABLED
@@ -78,7 +78,7 @@ class ExtensionRegistry : public KeyedService {
// * terminated_extensions() --> ExtensionRegistry::TERMINATED
// * blacklisted_extensions() --> ExtensionRegistry::BLACKLISTED
// * blocked_extensions() --> ExtensionRegistry::BLOCKED
- scoped_ptr<ExtensionSet> GenerateInstalledExtensionsSet(
+ std::unique_ptr<ExtensionSet> GenerateInstalledExtensionsSet(
int include_mask) const;
// The usual observer interface.
diff --git a/chromium/extensions/browser/extension_system.h b/chromium/extensions/browser/extension_system.h
index 5382d3f0c39..b318e964385 100644
--- a/chromium/extensions/browser/extension_system.h
+++ b/chromium/extensions/browser/extension_system.h
@@ -125,7 +125,7 @@ class ExtensionSystem : public KeyedService {
// Get a set of extensions that depend on the given extension.
// TODO(elijahtaylor): Move SharedModuleService out of chrome/browser
// so it can be retrieved from ExtensionSystem directly.
- virtual scoped_ptr<ExtensionSet> GetDependentExtensions(
+ virtual std::unique_ptr<ExtensionSet> GetDependentExtensions(
const Extension* extension) = 0;
// Install an updated version of |extension_id| with the version given in
diff --git a/chromium/extensions/browser/extension_throttle_entry.cc b/chromium/extensions/browser/extension_throttle_entry.cc
index 577ac55d661..e81a7330d22 100644
--- a/chromium/extensions/browser/extension_throttle_entry.cc
+++ b/chromium/extensions/browser/extension_throttle_entry.cc
@@ -46,12 +46,12 @@ const int ExtensionThrottleEntry::kDefaultMaximumBackoffMs = 15 * 60 * 1000;
const int ExtensionThrottleEntry::kDefaultEntryLifetimeMs = 2 * 60 * 1000;
// Returns NetLog parameters when a request is rejected by throttling.
-scoped_ptr<base::Value> NetLogRejectedRequestCallback(
+std::unique_ptr<base::Value> NetLogRejectedRequestCallback(
const std::string* url_id,
int num_failures,
const base::TimeDelta& release_after,
net::NetLogCaptureMode /* capture_mode */) {
- scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
dict->SetString("url", *url_id);
dict->SetInteger("num_failures", num_failures);
dict->SetInteger("release_after_ms",
diff --git a/chromium/extensions/browser/extension_throttle_manager.cc b/chromium/extensions/browser/extension_throttle_manager.cc
index 16d9501b015..449999029b5 100644
--- a/chromium/extensions/browser/extension_throttle_manager.cc
+++ b/chromium/extensions/browser/extension_throttle_manager.cc
@@ -7,6 +7,7 @@
#include <utility>
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
#include "base/strings/string_util.h"
@@ -54,13 +55,13 @@ ExtensionThrottleManager::~ExtensionThrottleManager() {
url_entries_.clear();
}
-scoped_ptr<content::ResourceThrottle>
+std::unique_ptr<content::ResourceThrottle>
ExtensionThrottleManager::MaybeCreateThrottle(const net::URLRequest* request) {
if (request->first_party_for_cookies().scheme() !=
extensions::kExtensionScheme) {
return nullptr;
}
- return make_scoped_ptr(
+ return base::WrapUnique(
new extensions::ExtensionRequestLimitingThrottle(request, this));
}
@@ -118,7 +119,7 @@ ExtensionThrottleManager::RegisterRequestUrl(const GURL& url) {
}
void ExtensionThrottleManager::SetBackoffPolicyForTests(
- scoped_ptr<net::BackoffEntry::Policy> policy) {
+ std::unique_ptr<net::BackoffEntry::Policy> policy) {
backoff_policy_for_tests_ = std::move(policy);
}
diff --git a/chromium/extensions/browser/extension_throttle_manager.h b/chromium/extensions/browser/extension_throttle_manager.h
index 5a5b2845c52..14c37baf4c0 100644
--- a/chromium/extensions/browser/extension_throttle_manager.h
+++ b/chromium/extensions/browser/extension_throttle_manager.h
@@ -6,11 +6,11 @@
#define EXTENSIONS_BROWSER_EXTENSION_THROTTLE_MANAGER_H_
#include <map>
+#include <memory>
#include <string>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/threading/non_thread_safe.h"
#include "base/threading/platform_thread.h"
#include "extensions/browser/extension_throttle_entry.h"
@@ -49,7 +49,7 @@ class ExtensionThrottleManager
// Creates a content::ResourceThrottle for |request| to prevent extensions
// from requesting a URL too often, if such a throttle is needed.
- scoped_ptr<content::ResourceThrottle> MaybeCreateThrottle(
+ std::unique_ptr<content::ResourceThrottle> MaybeCreateThrottle(
const net::URLRequest* request);
// TODO(xunjieli): Remove this method and replace with
@@ -64,7 +64,8 @@ class ExtensionThrottleManager
scoped_refptr<ExtensionThrottleEntryInterface> RegisterRequestUrl(
const GURL& url);
- void SetBackoffPolicyForTests(scoped_ptr<net::BackoffEntry::Policy> policy);
+ void SetBackoffPolicyForTests(
+ std::unique_ptr<net::BackoffEntry::Policy> policy);
// Registers a new entry in this service and overrides the existing entry (if
// any) for the URL. The service will hold a reference to the entry.
@@ -175,7 +176,7 @@ class ExtensionThrottleManager
bool ignore_user_gesture_load_flag_for_tests_;
// This is NULL when it is not set for tests.
- scoped_ptr<net::BackoffEntry::Policy> backoff_policy_for_tests_;
+ std::unique_ptr<net::BackoffEntry::Policy> backoff_policy_for_tests_;
DISALLOW_COPY_AND_ASSIGN(ExtensionThrottleManager);
};
diff --git a/chromium/extensions/browser/extension_throttle_simulation_unittest.cc b/chromium/extensions/browser/extension_throttle_simulation_unittest.cc
index d81ceed3b60..9b415e239d7 100644
--- a/chromium/extensions/browser/extension_throttle_simulation_unittest.cc
+++ b/chromium/extensions/browser/extension_throttle_simulation_unittest.cc
@@ -16,11 +16,12 @@
#include <cmath>
#include <limits>
+#include <memory>
#include <vector>
#include "base/environment.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/rand_util.h"
#include "base/time/time.h"
@@ -54,7 +55,7 @@ void VerboseOut(const char* format, ...) {
static bool should_print = false;
if (!have_checked_environment) {
have_checked_environment = true;
- scoped_ptr<base::Environment> env(base::Environment::Create());
+ std::unique_ptr<base::Environment> env(base::Environment::Create());
if (env->HasVar(kShowSimulationVariableName))
should_print = true;
}
@@ -222,7 +223,7 @@ class Server : public DiscreteTimeSimulation::Actor {
if (num_ticks % ticks_per_column)
++num_columns;
DCHECK_LE(num_columns, terminal_width);
- scoped_ptr<int[]> columns(new int[num_columns]);
+ std::unique_ptr<int[]> columns(new int[num_columns]);
for (int tx = 0; tx < num_ticks; ++tx) {
int cx = tx / ticks_per_column;
if (tx % ticks_per_column == 0)
@@ -293,7 +294,7 @@ class Server : public DiscreteTimeSimulation::Actor {
std::vector<int> requests_per_tick_;
TestURLRequestContext context_;
- scoped_ptr<URLRequest> mock_request_;
+ std::unique_ptr<URLRequest> mock_request_;
DISALLOW_COPY_AND_ASSIGN(Server);
};
@@ -489,7 +490,7 @@ void SimulateAttack(Server* server,
const size_t kNumClients = 50;
DiscreteTimeSimulation simulation;
ExtensionThrottleManager manager;
- std::vector<scoped_ptr<Requester>> requesters;
+ std::vector<std::unique_ptr<Requester>> requesters;
for (size_t i = 0; i < kNumAttackers; ++i) {
// Use a tiny time_between_requests so the attackers will ping the
// server at every tick of the simulation.
@@ -502,7 +503,7 @@ void SimulateAttack(Server* server,
new Requester(throttler_entry.get(), TimeDelta::FromMilliseconds(1),
server, attacker_results);
attacker->SetStartupJitter(TimeDelta::FromSeconds(120));
- requesters.push_back(make_scoped_ptr(attacker));
+ requesters.push_back(base::WrapUnique(attacker));
simulation.AddActor(attacker);
}
for (size_t i = 0; i < kNumClients; ++i) {
@@ -517,7 +518,7 @@ void SimulateAttack(Server* server,
client_results);
client->SetStartupJitter(TimeDelta::FromSeconds(120));
client->SetRequestJitter(TimeDelta::FromMinutes(1));
- requesters.push_back(make_scoped_ptr(client));
+ requesters.push_back(base::WrapUnique(client));
simulation.AddActor(client);
}
simulation.AddActor(server);
diff --git a/chromium/extensions/browser/extension_throttle_unittest.cc b/chromium/extensions/browser/extension_throttle_unittest.cc
index e894ee68367..34ae8234cd1 100644
--- a/chromium/extensions/browser/extension_throttle_unittest.cc
+++ b/chromium/extensions/browser/extension_throttle_unittest.cc
@@ -2,8 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <memory>
+
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/pickle.h"
#include "base/stl_util.h"
@@ -176,7 +177,7 @@ class ExtensionThrottleEntryTest : public testing::Test {
base::MessageLoopForIO message_loop_;
TestURLRequestContext context_;
- scoped_ptr<URLRequest> request_;
+ std::unique_ptr<URLRequest> request_;
};
void ExtensionThrottleEntryTest::SetUp() {
@@ -357,7 +358,7 @@ class ExtensionThrottleManagerTest : public testing::Test {
base::MessageLoopForIO message_loop_;
// context_ must be declared before request_.
TestURLRequestContext context_;
- scoped_ptr<URLRequest> request_;
+ std::unique_ptr<URLRequest> request_;
};
TEST_F(ExtensionThrottleManagerTest, IsUrlStandardised) {
diff --git a/chromium/extensions/browser/extension_user_script_loader.cc b/chromium/extensions/browser/extension_user_script_loader.cc
index 3b3f10cea83..c4be84388a4 100644
--- a/chromium/extensions/browser/extension_user_script_loader.cc
+++ b/chromium/extensions/browser/extension_user_script_loader.cc
@@ -129,7 +129,7 @@ void LoadUserScripts(UserScriptList* user_scripts,
for (UserScript& script : *user_scripts) {
if (added_script_ids.count(script.id()) == 0)
continue;
- scoped_ptr<SubstitutionMap> localization_messages(
+ std::unique_ptr<SubstitutionMap> localization_messages(
GetLocalizationMessages(hosts_info, script.host_id()));
for (UserScript::File& script_file : script.js_scripts()) {
if (script_file.GetContent().empty())
@@ -144,14 +144,14 @@ void LoadUserScripts(UserScriptList* user_scripts,
}
void LoadScriptsOnFileThread(
- scoped_ptr<UserScriptList> user_scripts,
+ std::unique_ptr<UserScriptList> user_scripts,
const ExtensionUserScriptLoader::HostsInfo& hosts_info,
const std::set<int>& added_script_ids,
const scoped_refptr<ContentVerifier>& verifier,
UserScriptLoader::LoadScriptsCallback callback) {
DCHECK(user_scripts.get());
LoadUserScripts(user_scripts.get(), hosts_info, added_script_ids, verifier);
- scoped_ptr<base::SharedMemory> memory =
+ std::unique_ptr<base::SharedMemory> memory =
UserScriptLoader::Serialize(*user_scripts);
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
@@ -196,7 +196,7 @@ void ExtensionUserScriptLoader::LoadScriptsForTest(
}
void ExtensionUserScriptLoader::LoadScripts(
- scoped_ptr<UserScriptList> user_scripts,
+ std::unique_ptr<UserScriptList> user_scripts,
const std::set<HostID>& changed_hosts,
const std::set<int>& added_script_ids,
LoadScriptsCallback callback) {
diff --git a/chromium/extensions/browser/extension_user_script_loader.h b/chromium/extensions/browser/extension_user_script_loader.h
index ff785fcc6ba..05c9d184032 100644
--- a/chromium/extensions/browser/extension_user_script_loader.h
+++ b/chromium/extensions/browser/extension_user_script_loader.h
@@ -40,7 +40,7 @@ class ExtensionUserScriptLoader : public UserScriptLoader,
private:
// UserScriptLoader:
- void LoadScripts(scoped_ptr<UserScriptList> user_scripts,
+ void LoadScripts(std::unique_ptr<UserScriptList> user_scripts,
const std::set<HostID>& changed_hosts,
const std::set<int>& added_script_ids,
LoadScriptsCallback callback) override;
diff --git a/chromium/extensions/browser/extension_web_contents_observer.h b/chromium/extensions/browser/extension_web_contents_observer.h
index 5b86dc08eba..2c15333c47d 100644
--- a/chromium/extensions/browser/extension_web_contents_observer.h
+++ b/chromium/extensions/browser/extension_web_contents_observer.h
@@ -56,6 +56,15 @@ class ExtensionWebContentsObserver
ExtensionFunctionDispatcher* dispatcher() { return &dispatcher_; }
+ // Returns the extension associated with the given |render_frame_host|, or
+ // null if there is none.
+ // If |verify_url| is false, only the SiteInstance is taken into account.
+ // If |verify_url| is true, the frame's last committed URL is also used to
+ // improve the classification of the frame.
+ const Extension* GetExtensionFromFrame(
+ content::RenderFrameHost* render_frame_host,
+ bool verify_url) const;
+
protected:
explicit ExtensionWebContentsObserver(content::WebContents* web_contents);
~ExtensionWebContentsObserver() override;
@@ -99,15 +108,6 @@ class ExtensionWebContentsObserver
std::string GetExtensionIdFromFrame(
content::RenderFrameHost* render_frame_host) const;
- // Returns the extension associated with the given |render_frame_host|, or
- // null if there is none.
- // If |verify_url| is false, only the SiteInstance is taken into account.
- // If |verify_url| is true, the frame's last committed URL is also used to
- // improve the classification of the frame.
- const Extension* GetExtensionFromFrame(
- content::RenderFrameHost* render_frame_host,
- bool verify_url) const;
-
// TODO(devlin): Remove these once callers are updated to use the FromFrame
// equivalents.
// Returns the extension or app associated with a render view host. Returns
diff --git a/chromium/extensions/browser/extension_zoom_request_client.cc b/chromium/extensions/browser/extension_zoom_request_client.cc
index ce8b45ce4ac..c462a2a7f51 100644
--- a/chromium/extensions/browser/extension_zoom_request_client.cc
+++ b/chromium/extensions/browser/extension_zoom_request_client.cc
@@ -5,6 +5,7 @@
#include "extensions/browser/extension_zoom_request_client.h"
#include "extensions/common/features/behavior_feature.h"
+#include "extensions/common/features/feature.h"
#include "extensions/common/features/feature_provider.h"
namespace extensions {
@@ -15,10 +16,9 @@ ExtensionZoomRequestClient::ExtensionZoomRequestClient(
}
bool ExtensionZoomRequestClient::ShouldSuppressBubble() const {
- return FeatureProvider::GetBehaviorFeature(
- BehaviorFeature::kZoomWithoutBubble)
- ->IsAvailableToExtension(extension())
- .is_available();
+ const Feature* feature =
+ FeatureProvider::GetBehaviorFeature(BehaviorFeature::kZoomWithoutBubble);
+ return feature && feature->IsAvailableToExtension(extension()).is_available();
}
ExtensionZoomRequestClient::~ExtensionZoomRequestClient() {
diff --git a/chromium/extensions/browser/extension_zoom_request_client.h b/chromium/extensions/browser/extension_zoom_request_client.h
index 380b6da6b4f..c34820c37bb 100644
--- a/chromium/extensions/browser/extension_zoom_request_client.h
+++ b/chromium/extensions/browser/extension_zoom_request_client.h
@@ -5,8 +5,9 @@
#ifndef EXTENSIONS_BROWSER_EXTENSION_ZOOM_REQUEST_CLIENT_H_
#define EXTENSIONS_BROWSER_EXTENSION_ZOOM_REQUEST_CLIENT_H_
+#include <memory>
+
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "components/ui/zoom/zoom_controller.h"
#include "extensions/common/extension.h"
diff --git a/chromium/extensions/browser/extensions_browser_client.cc b/chromium/extensions/browser/extensions_browser_client.cc
index 5a917879f90..690f5b14c8e 100644
--- a/chromium/extensions/browser/extensions_browser_client.cc
+++ b/chromium/extensions/browser/extensions_browser_client.cc
@@ -29,8 +29,9 @@ ExtensionsBrowserClient::CreateExtensionApiFrameIdMapHelper(
return nullptr;
}
-void ExtensionsBrowserClient::ReportError(content::BrowserContext* context,
- scoped_ptr<ExtensionError> error) {
+void ExtensionsBrowserClient::ReportError(
+ content::BrowserContext* context,
+ std::unique_ptr<ExtensionError> error) {
LOG(ERROR) << error->GetDebugString();
}
diff --git a/chromium/extensions/browser/extensions_browser_client.h b/chromium/extensions/browser/extensions_browser_client.h
index c8dd9ee4a15..03e3e081406 100644
--- a/chromium/extensions/browser/extensions_browser_client.h
+++ b/chromium/extensions/browser/extensions_browser_client.h
@@ -10,7 +10,6 @@
#include <vector>
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "build/build_config.h"
#include "extensions/browser/extension_event_histogram_value.h"
#include "extensions/browser/extension_prefs_observer.h"
@@ -158,7 +157,8 @@ class ExtensionsBrowserClient {
virtual ProcessManagerDelegate* GetProcessManagerDelegate() const = 0;
// Creates a new ExtensionHostDelegate instance.
- virtual scoped_ptr<ExtensionHostDelegate> CreateExtensionHostDelegate() = 0;
+ virtual std::unique_ptr<ExtensionHostDelegate>
+ CreateExtensionHostDelegate() = 0;
// Returns true if the client version has updated since the last run. Called
// once each time the extensions system is loaded per browser_context. The
@@ -196,7 +196,7 @@ class ExtensionsBrowserClient {
// Creates a RuntimeAPIDelegate responsible for handling extensions
// management-related events such as update and installation on behalf of the
// core runtime API implementation.
- virtual scoped_ptr<RuntimeAPIDelegate> CreateRuntimeAPIDelegate(
+ virtual std::unique_ptr<RuntimeAPIDelegate> CreateRuntimeAPIDelegate(
content::BrowserContext* context) const = 0;
// Returns the manager of resource bundles used in extensions. Returns NULL if
@@ -206,9 +206,10 @@ class ExtensionsBrowserClient {
// Propagate a event to all the renderers in every browser context. The
// implementation must be safe to call from any thread.
- virtual void BroadcastEventToRenderers(events::HistogramValue histogram_value,
- const std::string& event_name,
- scoped_ptr<base::ListValue> args) = 0;
+ virtual void BroadcastEventToRenderers(
+ events::HistogramValue histogram_value,
+ const std::string& event_name,
+ std::unique_ptr<base::ListValue> args) = 0;
// Returns the embedder's net::NetLog.
virtual net::NetLog* GetNetLog() = 0;
@@ -227,7 +228,7 @@ class ExtensionsBrowserClient {
// Embedders can override this function to handle extension errors.
virtual void ReportError(content::BrowserContext* context,
- scoped_ptr<ExtensionError> error);
+ std::unique_ptr<ExtensionError> error);
// Returns the ExtensionWebContentsObserver for the given |web_contents|.
virtual ExtensionWebContentsObserver* GetExtensionWebContentsObserver(
diff --git a/chromium/extensions/browser/extensions_test.cc b/chromium/extensions/browser/extensions_test.cc
index c6962ed0566..bb37b3aa5aa 100644
--- a/chromium/extensions/browser/extensions_test.cc
+++ b/chromium/extensions/browser/extensions_test.cc
@@ -55,6 +55,8 @@ void ExtensionsTest::TearDown() {
// cleaned up before the factories are destroyed.
BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(
browser_context_.get());
+ extensions_browser_client_.reset();
+ browser_context_.reset();
}
} // namespace extensions
diff --git a/chromium/extensions/browser/extensions_test.h b/chromium/extensions/browser/extensions_test.h
index e930421a1e1..f4462e2681c 100644
--- a/chromium/extensions/browser/extensions_test.h
+++ b/chromium/extensions/browser/extensions_test.h
@@ -5,9 +5,10 @@
#ifndef EXTENSIONS_BROWSER_EXTENSIONS_TEST_H_
#define EXTENSIONS_BROWSER_EXTENSIONS_TEST_H_
+#include <memory>
+
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "content/public/test/test_renderer_host.h"
#include "extensions/browser/mock_extension_system.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -52,11 +53,11 @@ class ExtensionsTest : public testing::Test {
private:
// TODO(yoz): Add a NotificationService here; it's used widely enough.
- scoped_ptr<content::ContentClient> content_client_;
- scoped_ptr<content::ContentUtilityClient> content_utility_client_;
- scoped_ptr<content::ContentBrowserClient> content_browser_client_;
- scoped_ptr<content::BrowserContext> browser_context_;
- scoped_ptr<TestExtensionsBrowserClient> extensions_browser_client_;
+ std::unique_ptr<content::ContentClient> content_client_;
+ std::unique_ptr<content::ContentUtilityClient> content_utility_client_;
+ std::unique_ptr<content::ContentBrowserClient> content_browser_client_;
+ std::unique_ptr<content::BrowserContext> browser_context_;
+ std::unique_ptr<TestExtensionsBrowserClient> extensions_browser_client_;
// The existence of this object enables tests via
// RenderViewHostTester.
diff --git a/chromium/extensions/browser/external_install_info.cc b/chromium/extensions/browser/external_install_info.cc
index e6da3fa8a2c..d37c0f38d14 100644
--- a/chromium/extensions/browser/external_install_info.cc
+++ b/chromium/extensions/browser/external_install_info.cc
@@ -18,7 +18,7 @@ ExternalInstallInfo::ExternalInstallInfo(const std::string& extension_id,
ExternalInstallInfoFile::ExternalInstallInfoFile(
const std::string& extension_id,
- scoped_ptr<base::Version> version,
+ std::unique_ptr<base::Version> version,
const base::FilePath& path,
Manifest::Location crx_location,
int creation_flags,
@@ -35,7 +35,7 @@ ExternalInstallInfoFile::~ExternalInstallInfoFile() {}
ExternalInstallInfoUpdateUrl::ExternalInstallInfoUpdateUrl(
const std::string& extension_id,
const std::string& install_parameter,
- scoped_ptr<GURL> update_url,
+ std::unique_ptr<GURL> update_url,
Manifest::Location download_location,
int creation_flags,
bool mark_acknowledged)
diff --git a/chromium/extensions/browser/external_install_info.h b/chromium/extensions/browser/external_install_info.h
index 72a19e8b9c9..19124d7531b 100644
--- a/chromium/extensions/browser/external_install_info.h
+++ b/chromium/extensions/browser/external_install_info.h
@@ -35,7 +35,7 @@ struct ExternalInstallInfo {
struct ExternalInstallInfoFile : public ExternalInstallInfo {
ExternalInstallInfoFile(const std::string& extension_id,
- scoped_ptr<base::Version> version,
+ std::unique_ptr<base::Version> version,
const base::FilePath& path,
Manifest::Location crx_location,
int creation_flags,
@@ -43,7 +43,7 @@ struct ExternalInstallInfoFile : public ExternalInstallInfo {
bool install_immediately);
~ExternalInstallInfoFile() override;
- scoped_ptr<base::Version> version;
+ std::unique_ptr<base::Version> version;
base::FilePath path;
Manifest::Location crx_location;
bool install_immediately;
@@ -52,14 +52,14 @@ struct ExternalInstallInfoFile : public ExternalInstallInfo {
struct ExternalInstallInfoUpdateUrl : public ExternalInstallInfo {
ExternalInstallInfoUpdateUrl(const std::string& extension_id,
const std::string& install_parameter,
- scoped_ptr<GURL> update_url,
+ std::unique_ptr<GURL> update_url,
Manifest::Location download_location,
int creation_flags,
bool mark_acknowledged);
~ExternalInstallInfoUpdateUrl() override;
std::string install_parameter;
- scoped_ptr<GURL> update_url;
+ std::unique_ptr<GURL> update_url;
Manifest::Location download_location;
};
diff --git a/chromium/extensions/browser/external_provider_interface.h b/chromium/extensions/browser/external_provider_interface.h
index 19102c045e2..727efdfb848 100644
--- a/chromium/extensions/browser/external_provider_interface.h
+++ b/chromium/extensions/browser/external_provider_interface.h
@@ -89,7 +89,7 @@ class ExternalProviderInterface {
virtual bool GetExtensionDetails(
const std::string& id,
Manifest::Location* location,
- scoped_ptr<base::Version>* version) const = 0;
+ std::unique_ptr<base::Version>* version) const = 0;
// Determines if this provider had loaded the list of external extensions
// from its source.
diff --git a/chromium/extensions/browser/guest_view/app_view/app_view_apitest.cc b/chromium/extensions/browser/guest_view/app_view/app_view_apitest.cc
index ab6323174ca..5360dd5179c 100644
--- a/chromium/extensions/browser/guest_view/app_view/app_view_apitest.cc
+++ b/chromium/extensions/browser/guest_view/app_view/app_view_apitest.cc
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/command_line.h"
#include "base/path_service.h"
#include "base/strings/stringprintf.h"
#include "components/guest_view/browser/guest_view_manager.h"
#include "components/guest_view/browser/guest_view_manager_factory.h"
#include "components/guest_view/browser/test_guest_view_manager.h"
+#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
@@ -23,6 +25,7 @@
#include "extensions/shell/test/shell_test.h"
#include "extensions/test/extension_test_message_listener.h"
#include "net/base/filename_util.h"
+#include "testing/gtest/include/gtest/gtest.h"
using guest_view::GuestViewManager;
using guest_view::TestGuestViewManager;
@@ -89,7 +92,8 @@ class MockExtensionsAPIClient : public extensions::ShellExtensionsAPIClient {
namespace extensions {
-class AppViewTest : public AppShellTest {
+class AppViewTest : public AppShellTest,
+ public testing::WithParamInterface<bool> {
protected:
AppViewTest() { GuestViewManager::set_factory_for_testing(&factory_); }
@@ -141,20 +145,29 @@ class AppViewTest : public AppShellTest {
ASSERT_TRUE(done_listener.WaitUntilSatisfied());
}
- protected:
+ void SetUpCommandLine(base::CommandLine* command_line) override {
+ AppShellTest::SetUpCommandLine(command_line);
+
+ bool use_cross_process_frames_for_guests = GetParam();
+ if (use_cross_process_frames_for_guests)
+ command_line->AppendSwitch(switches::kUseCrossProcessFramesForGuests);
+ }
+
content::WebContents* embedder_web_contents_;
TestGuestViewManagerFactory factory_;
};
+INSTANTIATE_TEST_CASE_P(AppViewTests, AppViewTest, testing::Bool());
+
// Tests that <appview> correctly processes parameters passed on connect.
-IN_PROC_BROWSER_TEST_F(AppViewTest, TestAppViewGoodDataShouldSucceed) {
+IN_PROC_BROWSER_TEST_P(AppViewTest, TestAppViewGoodDataShouldSucceed) {
RunTest("testAppViewGoodDataShouldSucceed",
"app_view/apitest",
"app_view/apitest/skeleton");
}
// Tests that <appview> can handle media permission requests.
-IN_PROC_BROWSER_TEST_F(AppViewTest, TestAppViewMediaRequest) {
+IN_PROC_BROWSER_TEST_P(AppViewTest, TestAppViewMediaRequest) {
static_cast<ShellExtensionsBrowserClient*>(ExtensionsBrowserClient::Get())
->SetAPIClientForTest(nullptr);
static_cast<ShellExtensionsBrowserClient*>(ExtensionsBrowserClient::Get())
@@ -169,14 +182,14 @@ IN_PROC_BROWSER_TEST_F(AppViewTest, TestAppViewMediaRequest) {
// Tests that <appview> correctly processes parameters passed on connect.
// This test should fail to connect because the embedded app (skeleton) will
// refuse the data passed by the embedder app and deny the request.
-IN_PROC_BROWSER_TEST_F(AppViewTest, TestAppViewRefusedDataShouldFail) {
+IN_PROC_BROWSER_TEST_P(AppViewTest, TestAppViewRefusedDataShouldFail) {
RunTest("testAppViewRefusedDataShouldFail",
"app_view/apitest",
"app_view/apitest/skeleton");
}
// Tests that <appview> is able to navigate to another installed app.
-IN_PROC_BROWSER_TEST_F(AppViewTest, TestAppViewWithUndefinedDataShouldSucceed) {
+IN_PROC_BROWSER_TEST_P(AppViewTest, TestAppViewWithUndefinedDataShouldSucceed) {
RunTest("testAppViewWithUndefinedDataShouldSucceed",
"app_view/apitest",
"app_view/apitest/skeleton");
diff --git a/chromium/extensions/browser/guest_view/app_view/app_view_guest.cc b/chromium/extensions/browser/guest_view/app_view/app_view_guest.cc
index d5a4e858b3f..dd5243c7044 100644
--- a/chromium/extensions/browser/guest_view/app_view/app_view_guest.cc
+++ b/chromium/extensions/browser/guest_view/app_view/app_view_guest.cc
@@ -7,6 +7,7 @@
#include <utility>
#include "base/command_line.h"
+#include "base/memory/ptr_util.h"
#include "components/guest_view/browser/guest_view_manager.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/renderer_preferences.h"
@@ -200,13 +201,11 @@ void AppViewGuest::CreateWebContents(
LazyBackgroundTaskQueue* queue =
LazyBackgroundTaskQueue::Get(browser_context());
if (queue->ShouldEnqueueTask(browser_context(), guest_extension)) {
- queue->AddPendingTask(browser_context(),
- guest_extension->id(),
- base::Bind(
- &AppViewGuest::LaunchAppAndFireEvent,
- weak_ptr_factory_.GetWeakPtr(),
- base::Passed(make_scoped_ptr(data->DeepCopy())),
- callback));
+ queue->AddPendingTask(
+ browser_context(), guest_extension->id(),
+ base::Bind(&AppViewGuest::LaunchAppAndFireEvent,
+ weak_ptr_factory_.GetWeakPtr(),
+ base::Passed(base::WrapUnique(data->DeepCopy())), callback));
return;
}
@@ -214,7 +213,7 @@ void AppViewGuest::CreateWebContents(
ExtensionHost* host =
process_manager->GetBackgroundHostForExtension(guest_extension->id());
DCHECK(host);
- LaunchAppAndFireEvent(make_scoped_ptr(data->DeepCopy()), callback, host);
+ LaunchAppAndFireEvent(base::WrapUnique(data->DeepCopy()), callback, host);
}
void AppViewGuest::DidInitialize(const base::DictionaryValue& create_params) {
@@ -255,7 +254,7 @@ void AppViewGuest::CompleteCreateWebContents(
}
void AppViewGuest::LaunchAppAndFireEvent(
- scoped_ptr<base::DictionaryValue> data,
+ std::unique_ptr<base::DictionaryValue> data,
const WebContentsCreatedCallback& callback,
ExtensionHost* extension_host) {
bool has_event_listener = EventRouter::Get(browser_context())
@@ -267,7 +266,8 @@ void AppViewGuest::LaunchAppAndFireEvent(
return;
}
- scoped_ptr<base::DictionaryValue> embed_request(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> embed_request(
+ new base::DictionaryValue());
embed_request->SetInteger(appview::kGuestInstanceID, guest_instance_id());
embed_request->SetString(appview::kEmbedderID, owner_host());
embed_request->Set(appview::kData, data.release());
diff --git a/chromium/extensions/browser/guest_view/app_view/app_view_guest.h b/chromium/extensions/browser/guest_view/app_view/app_view_guest.h
index 20bfdd166da..d1e44dccff3 100644
--- a/chromium/extensions/browser/guest_view/app_view/app_view_guest.h
+++ b/chromium/extensions/browser/guest_view/app_view/app_view_guest.h
@@ -72,14 +72,14 @@ class AppViewGuest : public guest_view::GuestView<AppViewGuest> {
const Extension* guest_extension,
const WebContentsCreatedCallback& callback);
- void LaunchAppAndFireEvent(scoped_ptr<base::DictionaryValue> data,
+ void LaunchAppAndFireEvent(std::unique_ptr<base::DictionaryValue> data,
const WebContentsCreatedCallback& callback,
ExtensionHost* extension_host);
GURL url_;
std::string guest_extension_id_;
- scoped_ptr<AppViewGuestDelegate> app_view_guest_delegate_;
- scoped_ptr<AppDelegate> app_delegate_;
+ std::unique_ptr<AppViewGuestDelegate> app_view_guest_delegate_;
+ std::unique_ptr<AppDelegate> app_delegate_;
// This is used to ensure pending tasks will not fire after this object is
// destroyed.
diff --git a/chromium/extensions/browser/guest_view/extension_options/extension_options_guest.cc b/chromium/extensions/browser/guest_view/extension_options/extension_options_guest.cc
index 57eb9c2f905..eb8eb4dedd2 100644
--- a/chromium/extensions/browser/guest_view/extension_options/extension_options_guest.cc
+++ b/chromium/extensions/browser/guest_view/extension_options/extension_options_guest.cc
@@ -6,6 +6,7 @@
#include <utility>
+#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "components/crx_file/id_util.h"
#include "components/guest_view/browser/guest_view_event.h"
@@ -126,8 +127,8 @@ void ExtensionOptionsGuest::DidInitialize(
}
void ExtensionOptionsGuest::GuestViewDidStopLoading() {
- scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
- DispatchEventToView(make_scoped_ptr(new GuestViewEvent(
+ std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ DispatchEventToView(base::WrapUnique(new GuestViewEvent(
extension_options_internal::OnLoad::kEventName, std::move(args))));
}
@@ -148,7 +149,7 @@ void ExtensionOptionsGuest::OnPreferredSizeChanged(const gfx::Size& pref_size) {
// Convert the size from physical pixels to logical pixels.
options.width = PhysicalPixelsToLogicalPixels(pref_size.width());
options.height = PhysicalPixelsToLogicalPixels(pref_size.height());
- DispatchEventToView(make_scoped_ptr(new GuestViewEvent(
+ DispatchEventToView(base::WrapUnique(new GuestViewEvent(
extension_options_internal::OnPreferredSizeChanged::kEventName,
options.ToValue())));
}
@@ -180,9 +181,9 @@ WebContents* ExtensionOptionsGuest::OpenURLFromTab(
}
void ExtensionOptionsGuest::CloseContents(WebContents* source) {
- DispatchEventToView(make_scoped_ptr(
+ DispatchEventToView(base::WrapUnique(
new GuestViewEvent(extension_options_internal::OnClose::kEventName,
- make_scoped_ptr(new base::DictionaryValue()))));
+ base::WrapUnique(new base::DictionaryValue()))));
}
bool ExtensionOptionsGuest::HandleContextMenu(
diff --git a/chromium/extensions/browser/guest_view/extension_options/extension_options_guest.h b/chromium/extensions/browser/guest_view/extension_options/extension_options_guest.h
index b81fe414624..e0309f75e2f 100644
--- a/chromium/extensions/browser/guest_view/extension_options/extension_options_guest.h
+++ b/chromium/extensions/browser/guest_view/extension_options/extension_options_guest.h
@@ -62,7 +62,7 @@ class ExtensionOptionsGuest
void DidNavigateMainFrame(const content::LoadCommittedDetails& details,
const content::FrameNavigateParams& params) final;
- scoped_ptr<extensions::ExtensionOptionsGuestDelegate>
+ std::unique_ptr<extensions::ExtensionOptionsGuestDelegate>
extension_options_guest_delegate_;
GURL options_page_;
diff --git a/chromium/extensions/browser/guest_view/extension_view/extension_view_guest.cc b/chromium/extensions/browser/guest_view/extension_view/extension_view_guest.cc
index 0c961df1f19..73cfc9d7256 100644
--- a/chromium/extensions/browser/guest_view/extension_view/extension_view_guest.cc
+++ b/chromium/extensions/browser/guest_view/extension_view/extension_view_guest.cc
@@ -6,6 +6,7 @@
#include <utility>
+#include "base/memory/ptr_util.h"
#include "components/crx_file/id_util.h"
#include "components/guest_view/browser/guest_view_event.h"
#include "content/public/browser/render_process_host.h"
@@ -125,9 +126,9 @@ void ExtensionViewGuest::DidCommitProvisionalLoadForFrame(
url_ = url;
- scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
args->SetString(guest_view::kUrl, url_.spec());
- DispatchEventToView(make_scoped_ptr(
+ DispatchEventToView(base::WrapUnique(
new GuestViewEvent(extensionview::kEventLoadCommit, std::move(args))));
}
diff --git a/chromium/extensions/browser/guest_view/extensions_guest_view_manager_delegate.cc b/chromium/extensions/browser/guest_view/extensions_guest_view_manager_delegate.cc
index ec44ed2d595..8c73d37391d 100644
--- a/chromium/extensions/browser/guest_view/extensions_guest_view_manager_delegate.cc
+++ b/chromium/extensions/browser/guest_view/extensions_guest_view_manager_delegate.cc
@@ -39,12 +39,12 @@ ExtensionsGuestViewManagerDelegate::~ExtensionsGuestViewManagerDelegate() {
void ExtensionsGuestViewManagerDelegate::DispatchEvent(
const std::string& event_name,
- scoped_ptr<base::DictionaryValue> args,
+ std::unique_ptr<base::DictionaryValue> args,
GuestViewBase* guest,
int instance_id) {
EventFilteringInfo info;
info.SetInstanceID(instance_id);
- scoped_ptr<base::ListValue> event_args(new base::ListValue());
+ std::unique_ptr<base::ListValue> event_args(new base::ListValue());
event_args->Append(args.release());
// GetEventHistogramValue maps guest view event names to their histogram
@@ -67,7 +67,8 @@ bool ExtensionsGuestViewManagerDelegate::IsGuestAvailableToContext(
GuestViewBase* guest) {
const Feature* feature =
FeatureProvider::GetAPIFeature(guest->GetAPINamespace());
- CHECK(feature);
+ if (!feature)
+ return false;
ProcessMap* process_map = ProcessMap::Get(context_);
CHECK(process_map);
diff --git a/chromium/extensions/browser/guest_view/extensions_guest_view_manager_delegate.h b/chromium/extensions/browser/guest_view/extensions_guest_view_manager_delegate.h
index 8a2d649cf73..8bbdf1d38da 100644
--- a/chromium/extensions/browser/guest_view/extensions_guest_view_manager_delegate.h
+++ b/chromium/extensions/browser/guest_view/extensions_guest_view_manager_delegate.h
@@ -23,7 +23,7 @@ class ExtensionsGuestViewManagerDelegate
// GuestViewManagerDelegate implementation.
void DispatchEvent(const std::string& event_name,
- scoped_ptr<base::DictionaryValue> args,
+ std::unique_ptr<base::DictionaryValue> args,
guest_view::GuestViewBase* guest,
int instance_id) override;
bool IsGuestAvailableToContext(guest_view::GuestViewBase* guest) override;
diff --git a/chromium/extensions/browser/guest_view/mime_handler_view/mime_handler_stream_manager.cc b/chromium/extensions/browser/guest_view/mime_handler_view/mime_handler_stream_manager.cc
index b0b8feb6bef..0ba5b8bdbb4 100644
--- a/chromium/extensions/browser/guest_view/mime_handler_view/mime_handler_stream_manager.cc
+++ b/chromium/extensions/browser/guest_view/mime_handler_view/mime_handler_stream_manager.cc
@@ -4,6 +4,7 @@
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_stream_manager.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/singleton.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
@@ -109,10 +110,11 @@ MimeHandlerStreamManager* MimeHandlerStreamManager::Get(
return MimeHandlerStreamManagerFactory::GetInstance()->Get(context);
}
-void MimeHandlerStreamManager::AddStream(const std::string& view_id,
- scoped_ptr<StreamContainer> stream,
- int render_process_id,
- int render_frame_id) {
+void MimeHandlerStreamManager::AddStream(
+ const std::string& view_id,
+ std::unique_ptr<StreamContainer> stream,
+ int render_process_id,
+ int render_frame_id) {
streams_by_extension_id_[stream->extension_id()].insert(view_id);
auto result = streams_.insert(
std::make_pair(view_id, make_linked_ptr(stream.release())));
@@ -121,14 +123,14 @@ void MimeHandlerStreamManager::AddStream(const std::string& view_id,
new EmbedderObserver(this, render_process_id, render_frame_id, view_id));
}
-scoped_ptr<StreamContainer> MimeHandlerStreamManager::ReleaseStream(
+std::unique_ptr<StreamContainer> MimeHandlerStreamManager::ReleaseStream(
const std::string& view_id) {
auto stream = streams_.find(view_id);
if (stream == streams_.end())
return nullptr;
- scoped_ptr<StreamContainer> result =
- make_scoped_ptr(stream->second.release());
+ std::unique_ptr<StreamContainer> result =
+ base::WrapUnique(stream->second.release());
streams_by_extension_id_[result->extension_id()].erase(view_id);
streams_.erase(stream);
embedder_observers_.erase(view_id);
diff --git a/chromium/extensions/browser/guest_view/mime_handler_view/mime_handler_stream_manager.h b/chromium/extensions/browser/guest_view/mime_handler_view/mime_handler_stream_manager.h
index 5e46ac31054..3f9670117c1 100644
--- a/chromium/extensions/browser/guest_view/mime_handler_view/mime_handler_stream_manager.h
+++ b/chromium/extensions/browser/guest_view/mime_handler_view/mime_handler_stream_manager.h
@@ -36,11 +36,11 @@ class MimeHandlerStreamManager : public KeyedService,
static MimeHandlerStreamManager* Get(content::BrowserContext* context);
void AddStream(const std::string& view_id,
- scoped_ptr<StreamContainer> stream,
+ std::unique_ptr<StreamContainer> stream,
int render_process_id,
int render_frame_id);
- scoped_ptr<StreamContainer> ReleaseStream(const std::string& view_id);
+ std::unique_ptr<StreamContainer> ReleaseStream(const std::string& view_id);
// ExtensionRegistryObserver override.
void OnExtensionUnloaded(content::BrowserContext* browser_context,
diff --git a/chromium/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc b/chromium/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc
index 27297f33a6e..ec15087dcc9 100644
--- a/chromium/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc
+++ b/chromium/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc
@@ -36,7 +36,7 @@ using guest_view::GuestViewBase;
namespace extensions {
-StreamContainer::StreamContainer(scoped_ptr<content::StreamInfo> stream,
+StreamContainer::StreamContainer(std::unique_ptr<content::StreamInfo> stream,
int tab_id,
bool embedded,
const GURL& handler_url,
diff --git a/chromium/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h b/chromium/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h
index 4618d9f86fa..ef91c244b33 100644
--- a/chromium/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h
+++ b/chromium/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h
@@ -22,7 +22,7 @@ class MimeHandlerViewGuestDelegate;
// MimeHandler to handle a resource stream.
class StreamContainer {
public:
- StreamContainer(scoped_ptr<content::StreamInfo> stream,
+ StreamContainer(std::unique_ptr<content::StreamInfo> stream,
int tab_id,
bool embedded,
const GURL& handler_url,
@@ -41,7 +41,7 @@ class StreamContainer {
std::string extension_id() const { return extension_id_; }
private:
- const scoped_ptr<content::StreamInfo> stream_;
+ const std::unique_ptr<content::StreamInfo> stream_;
const bool embedded_;
const int tab_id_;
const GURL handler_url_;
@@ -94,8 +94,8 @@ class MimeHandlerViewGuest :
std::string view_id() const { return view_id_; }
base::WeakPtr<StreamContainer> GetStream() const;
- scoped_ptr<MimeHandlerViewGuestDelegate> delegate_;
- scoped_ptr<StreamContainer> stream_;
+ std::unique_ptr<MimeHandlerViewGuestDelegate> delegate_;
+ std::unique_ptr<StreamContainer> stream_;
std::string view_id_;
DISALLOW_COPY_AND_ASSIGN(MimeHandlerViewGuest);
diff --git a/chromium/extensions/browser/guest_view/mime_handler_view/test_mime_handler_view_guest.cc b/chromium/extensions/browser/guest_view/mime_handler_view/test_mime_handler_view_guest.cc
index ce68bdb589f..d15d1c038c0 100644
--- a/chromium/extensions/browser/guest_view/mime_handler_view/test_mime_handler_view_guest.cc
+++ b/chromium/extensions/browser/guest_view/mime_handler_view/test_mime_handler_view_guest.cc
@@ -43,7 +43,7 @@ void TestMimeHandlerViewGuest::CreateWebContents(
if (delay_) {
auto delta = base::TimeDelta::FromMilliseconds(
delay_);
- scoped_ptr<base::DictionaryValue> params(create_params.DeepCopy());
+ std::unique_ptr<base::DictionaryValue> params(create_params.DeepCopy());
content::BrowserThread::PostDelayedTask(
content::BrowserThread::UI,
FROM_HERE,
@@ -68,7 +68,7 @@ void TestMimeHandlerViewGuest::DidAttachToEmbedder() {
}
void TestMimeHandlerViewGuest::CallBaseCreateWebContents(
- scoped_ptr<base::DictionaryValue> create_params,
+ std::unique_ptr<base::DictionaryValue> create_params,
const WebContentsCreatedCallback& callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
MimeHandlerViewGuest::CreateWebContents(*create_params.get(), callback);
diff --git a/chromium/extensions/browser/guest_view/mime_handler_view/test_mime_handler_view_guest.h b/chromium/extensions/browser/guest_view/mime_handler_view/test_mime_handler_view_guest.h
index aac62c11724..0db76f49195 100644
--- a/chromium/extensions/browser/guest_view/mime_handler_view/test_mime_handler_view_guest.h
+++ b/chromium/extensions/browser/guest_view/mime_handler_view/test_mime_handler_view_guest.h
@@ -42,7 +42,7 @@ class TestMimeHandlerViewGuest : public MimeHandlerViewGuest {
// Used to call MimeHandlerViewGuest::CreateWebContents using a scoped_ptr for
// |create_params|.
void CallBaseCreateWebContents(
- scoped_ptr<base::DictionaryValue> create_params,
+ std::unique_ptr<base::DictionaryValue> create_params,
const WebContentsCreatedCallback& callback);
// A value in milliseconds that the next creation of a guest's WebContents
diff --git a/chromium/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.cc b/chromium/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.cc
index 9c2b738d07e..69319de38e6 100644
--- a/chromium/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.cc
+++ b/chromium/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.cc
@@ -5,6 +5,7 @@
#include "extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h"
#include "content/public/browser/browser_context.h"
+#include "content/public/browser/storage_partition.h"
#include "content/public/common/url_fetcher.h"
#include "net/base/load_flags.h"
#include "net/url_request/url_fetcher.h"
@@ -26,7 +27,9 @@ WebUIURLFetcher::~WebUIURLFetcher() {
void WebUIURLFetcher::Start() {
fetcher_ = net::URLFetcher::Create(url_, net::URLFetcher::GET, this);
- fetcher_->SetRequestContext(context_->GetRequestContext());
+ fetcher_->SetRequestContext(
+ content::BrowserContext::GetDefaultStoragePartition(context_)->
+ GetURLRequestContext());
fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES);
content::AssociateURLFetcherWithRenderFrame(
diff --git a/chromium/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h b/chromium/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h
index 8124fc63779..b8bc7173e5b 100644
--- a/chromium/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h
+++ b/chromium/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h
@@ -5,9 +5,10 @@
#ifndef EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_UI_URL_FETCHER_H
#define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_UI_URL_FETCHER_H
+#include <memory>
+
#include "base/callback.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "net/url_request/url_fetcher_delegate.h"
#include "url/gurl.h"
@@ -48,7 +49,7 @@ class WebUIURLFetcher : public net::URLFetcherDelegate {
int render_view_id_;
GURL url_;
WebUILoadFileCallback callback_;
- scoped_ptr<net::URLFetcher> fetcher_;
+ std::unique_ptr<net::URLFetcher> fetcher_;
DISALLOW_COPY_AND_ASSIGN(WebUIURLFetcher);
};
diff --git a/chromium/extensions/browser/guest_view/web_view/web_view_apitest.cc b/chromium/extensions/browser/guest_view/web_view/web_view_apitest.cc
index 89bbf05e017..babdbf5597c 100644
--- a/chromium/extensions/browser/guest_view/web_view/web_view_apitest.cc
+++ b/chromium/extensions/browser/guest_view/web_view/web_view_apitest.cc
@@ -37,7 +37,7 @@
#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 "ui/gfx/switches.h"
+#include "ui/display/display_switches.h"
using guest_view::GuestViewManager;
using guest_view::TestGuestViewManager;
@@ -55,20 +55,20 @@ const char kIsolateExtensions[] = "isolateExtensions";
// Handles |request| by serving a redirect response if the |User-Agent| is
// foobar.
-static scoped_ptr<net::test_server::HttpResponse> UserAgentResponseHandler(
+static std::unique_ptr<net::test_server::HttpResponse> UserAgentResponseHandler(
const std::string& path,
const GURL& redirect_target,
const net::test_server::HttpRequest& request) {
if (!base::StartsWith(path, request.relative_url,
base::CompareCase::SENSITIVE))
- return scoped_ptr<net::test_server::HttpResponse>();
+ return std::unique_ptr<net::test_server::HttpResponse>();
auto it = request.headers.find("User-Agent");
EXPECT_TRUE(it != request.headers.end());
if (!base::StartsWith("foobar", it->second, base::CompareCase::SENSITIVE))
- return scoped_ptr<net::test_server::HttpResponse>();
+ return std::unique_ptr<net::test_server::HttpResponse>();
- scoped_ptr<net::test_server::BasicHttpResponse> http_response(
+ std::unique_ptr<net::test_server::BasicHttpResponse> http_response(
new net::test_server::BasicHttpResponse);
http_response->set_code(net::HTTP_MOVED_PERMANENTLY);
http_response->AddCustomHeader("Location", redirect_target.spec());
@@ -100,15 +100,15 @@ class WebContentsHiddenObserver : public content::WebContentsObserver {
};
// Handles |request| by serving a redirect response.
-scoped_ptr<net::test_server::HttpResponse> RedirectResponseHandler(
+std::unique_ptr<net::test_server::HttpResponse> RedirectResponseHandler(
const std::string& path,
const GURL& redirect_target,
const net::test_server::HttpRequest& request) {
if (!base::StartsWith(path, request.relative_url,
base::CompareCase::SENSITIVE))
- return scoped_ptr<net::test_server::HttpResponse>();
+ return std::unique_ptr<net::test_server::HttpResponse>();
- scoped_ptr<net::test_server::BasicHttpResponse> http_response(
+ std::unique_ptr<net::test_server::BasicHttpResponse> http_response(
new net::test_server::BasicHttpResponse);
http_response->set_code(net::HTTP_MOVED_PERMANENTLY);
http_response->AddCustomHeader("Location", redirect_target.spec());
@@ -116,16 +116,16 @@ scoped_ptr<net::test_server::HttpResponse> RedirectResponseHandler(
}
// Handles |request| by serving an empty response.
-scoped_ptr<net::test_server::HttpResponse> EmptyResponseHandler(
+std::unique_ptr<net::test_server::HttpResponse> EmptyResponseHandler(
const std::string& path,
const net::test_server::HttpRequest& request) {
if (base::StartsWith(path, request.relative_url,
base::CompareCase::SENSITIVE)) {
- return scoped_ptr<net::test_server::HttpResponse>(
+ return std::unique_ptr<net::test_server::HttpResponse>(
new net::test_server::RawHttpResponse("", ""));
}
- return scoped_ptr<net::test_server::HttpResponse>();
+ return std::unique_ptr<net::test_server::HttpResponse>();
}
} // namespace
@@ -269,7 +269,7 @@ TestGuestViewManager* WebViewAPITest::GetGuestViewManager() {
void WebViewAPITest::SendMessageToGuestAndWait(
const std::string& message,
const std::string& wait_message) {
- scoped_ptr<ExtensionTestMessageListener> listener;
+ std::unique_ptr<ExtensionTestMessageListener> listener;
if (!wait_message.empty())
listener.reset(new ExtensionTestMessageListener(wait_message, false));
diff --git a/chromium/extensions/browser/guest_view/web_view/web_view_find_helper.cc b/chromium/extensions/browser/guest_view/web_view/web_view_find_helper.cc
index f9a315f68f3..c7339e1eda9 100644
--- a/chromium/extensions/browser/guest_view/web_view/web_view_find_helper.cc
+++ b/chromium/extensions/browser/guest_view/web_view/web_view_find_helper.cc
@@ -6,6 +6,7 @@
#include <utility>
+#include "base/memory/ptr_util.h"
#include "components/guest_view/browser/guest_view_event.h"
#include "extensions/browser/api/guest_view/web_view/web_view_internal_api.h"
#include "extensions/browser/guest_view/web_view/web_view_constants.h"
@@ -35,12 +36,12 @@ void WebViewFindHelper::CancelAllFindSessions() {
void WebViewFindHelper::DispatchFindUpdateEvent(bool canceled,
bool final_update) {
DCHECK(find_update_event_.get());
- scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
find_update_event_->PrepareResults(args.get());
args->SetBoolean(webview::kFindCanceled, canceled);
args->SetBoolean(webview::kFindFinalUpdate, final_update);
DCHECK(webview_guest_);
- webview_guest_->DispatchEventToView(make_scoped_ptr(
+ webview_guest_->DispatchEventToView(base::WrapUnique(
new GuestViewEvent(webview::kEventFindReply, std::move(args))));
}
@@ -157,13 +158,13 @@ void WebViewFindHelper::FindReply(int request_id,
DCHECK(current_find_session_);
WebViewFindHelper::FindInfo* find_info = find_iterator->second.get();
-
// Handle canceled find requests.
if (!find_info->options()->findNext &&
find_info_map_.begin()->first < request_id) {
DCHECK_NE(current_find_session_->request_id(),
find_info_map_.begin()->first);
- DispatchFindUpdateEvent(true /* canceled */, true /* final_update */);
+ if (find_update_event_)
+ DispatchFindUpdateEvent(true /* canceled */, true /* final_update */);
EndFindSession(find_info_map_.begin()->first, true /* canceled */);
}
diff --git a/chromium/extensions/browser/guest_view/web_view/web_view_find_helper.h b/chromium/extensions/browser/guest_view/web_view/web_view_find_helper.h
index df93c0c139f..f8940f22875 100644
--- a/chromium/extensions/browser/guest_view/web_view/web_view_find_helper.h
+++ b/chromium/extensions/browser/guest_view/web_view/web_view_find_helper.h
@@ -6,11 +6,11 @@
#define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_FIND_HELPER_H_
#include <map>
+#include <memory>
#include <vector>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/values.h"
#include "content/public/browser/web_contents.h"
@@ -175,7 +175,7 @@ class WebViewFindHelper {
int current_find_request_id_;
// Stores aggregated find results and other info for the |findupdate| event.
- scoped_ptr<FindUpdateEvent> find_update_event_;
+ std::unique_ptr<FindUpdateEvent> find_update_event_;
// Pointer to the first request of the current find session. find_info_map_
// retains ownership.
diff --git a/chromium/extensions/browser/guest_view/web_view/web_view_guest.cc b/chromium/extensions/browser/guest_view/web_view/web_view_guest.cc
index 70336af302e..3da0024b090 100644
--- a/chromium/extensions/browser/guest_view/web_view/web_view_guest.cc
+++ b/chromium/extensions/browser/guest_view/web_view/web_view_guest.cc
@@ -8,6 +8,7 @@
#include <utility>
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
@@ -369,9 +370,9 @@ void WebViewGuest::DidAttachToEmbedder() {
}
void WebViewGuest::DidDropLink(const GURL& url) {
- scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
args->SetString(guest_view::kUrl, url.spec());
- DispatchEventToView(make_scoped_ptr(
+ DispatchEventToView(base::WrapUnique(
new GuestViewEvent(webview::kEventDropLink, std::move(args))));
}
@@ -425,8 +426,8 @@ void WebViewGuest::ClearDataInternal(base::Time remove_since,
}
void WebViewGuest::GuestViewDidStopLoading() {
- scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
- DispatchEventToView(make_scoped_ptr(
+ std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ DispatchEventToView(base::WrapUnique(
new GuestViewEvent(webview::kEventLoadStop, std::move(args))));
}
@@ -476,12 +477,12 @@ void WebViewGuest::GuestReady() {
void WebViewGuest::GuestSizeChangedDueToAutoSize(const gfx::Size& old_size,
const gfx::Size& new_size) {
- scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
args->SetInteger(webview::kOldHeight, old_size.height());
args->SetInteger(webview::kOldWidth, old_size.width());
args->SetInteger(webview::kNewHeight, new_size.height());
args->SetInteger(webview::kNewWidth, new_size.width());
- DispatchEventToView(make_scoped_ptr(
+ DispatchEventToView(base::WrapUnique(
new GuestViewEvent(webview::kEventSizeChanged, std::move(args))));
}
@@ -494,10 +495,10 @@ void WebViewGuest::GuestZoomChanged(double old_zoom_level,
// Dispatch the zoomchange event.
double old_zoom_factor = ConvertZoomLevelToZoomFactor(old_zoom_level);
double new_zoom_factor = ConvertZoomLevelToZoomFactor(new_zoom_level);
- scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
args->SetDouble(webview::kOldZoomFactor, old_zoom_factor);
args->SetDouble(webview::kNewZoomFactor, new_zoom_factor);
- DispatchEventToView(make_scoped_ptr(
+ DispatchEventToView(base::WrapUnique(
new GuestViewEvent(webview::kEventZoomChange, std::move(args))));
}
@@ -511,20 +512,20 @@ bool WebViewGuest::AddMessageToConsole(WebContents* source,
const base::string16& message,
int32_t line_no,
const base::string16& source_id) {
- scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
// Log levels are from base/logging.h: LogSeverity.
args->SetInteger(webview::kLevel, level);
args->SetString(webview::kMessage, message);
args->SetInteger(webview::kLine, line_no);
args->SetString(webview::kSourceId, source_id);
- DispatchEventToView(make_scoped_ptr(
+ DispatchEventToView(base::WrapUnique(
new GuestViewEvent(webview::kEventConsoleMessage, std::move(args))));
return true;
}
void WebViewGuest::CloseContents(WebContents* source) {
- scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
- DispatchEventToView(make_scoped_ptr(
+ std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ DispatchEventToView(base::WrapUnique(
new GuestViewEvent(webview::kEventClose, std::move(args))));
}
@@ -572,10 +573,10 @@ bool WebViewGuest::PreHandleGestureEvent(WebContents* source,
}
void WebViewGuest::LoadProgressChanged(WebContents* source, double progress) {
- scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
args->SetString(guest_view::kUrl, web_contents()->GetURL().spec());
args->SetDouble(webview::kProgress, progress);
- DispatchEventToView(make_scoped_ptr(
+ DispatchEventToView(base::WrapUnique(
new GuestViewEvent(webview::kEventLoadProgress, std::move(args))));
}
@@ -583,12 +584,12 @@ void WebViewGuest::LoadAbort(bool is_top_level,
const GURL& url,
int error_code,
const std::string& error_type) {
- scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
args->SetBoolean(guest_view::kIsTopLevel, is_top_level);
args->SetString(guest_view::kUrl, url.possibly_invalid_spec());
args->SetInteger(guest_view::kCode, error_code);
args->SetString(guest_view::kReason, error_type);
- DispatchEventToView(make_scoped_ptr(
+ DispatchEventToView(base::WrapUnique(
new GuestViewEvent(webview::kEventLoadAbort, std::move(args))));
}
@@ -637,18 +638,18 @@ void WebViewGuest::NewGuestWebViewCallback(const content::OpenURLParams& params,
// TODO(fsamuel): Find a reliable way to test the 'responsive' and
// 'unresponsive' events.
void WebViewGuest::RendererResponsive(WebContents* source) {
- scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
args->SetInteger(webview::kProcessId,
web_contents()->GetRenderProcessHost()->GetID());
- DispatchEventToView(make_scoped_ptr(
+ DispatchEventToView(base::WrapUnique(
new GuestViewEvent(webview::kEventResponsive, std::move(args))));
}
void WebViewGuest::RendererUnresponsive(WebContents* source) {
- scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
args->SetInteger(webview::kProcessId,
web_contents()->GetRenderProcessHost()->GetID());
- DispatchEventToView(make_scoped_ptr(
+ DispatchEventToView(base::WrapUnique(
new GuestViewEvent(webview::kEventUnresponsive, std::move(args))));
}
@@ -801,7 +802,7 @@ void WebViewGuest::DidCommitProvisionalLoadForFrame(
pending_zoom_factor_ = 0.0;
}
}
- scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
args->SetString(guest_view::kUrl, src_.spec());
args->SetBoolean(guest_view::kIsTopLevel, !render_frame_host->GetParent());
args->SetString(webview::kInternalBaseURLForDataURL,
@@ -816,7 +817,7 @@ void WebViewGuest::DidCommitProvisionalLoadForFrame(
web_contents()->GetController().GetEntryCount());
args->SetInteger(webview::kInternalProcessId,
web_contents()->GetRenderProcessHost()->GetID());
- DispatchEventToView(make_scoped_ptr(
+ DispatchEventToView(base::WrapUnique(
new GuestViewEvent(webview::kEventLoadCommit, std::move(args))));
find_helper_.CancelAllFindSessions();
@@ -841,10 +842,10 @@ void WebViewGuest::DidStartProvisionalLoadForFrame(
const GURL& validated_url,
bool is_error_page,
bool is_iframe_srcdoc) {
- scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
args->SetString(guest_view::kUrl, validated_url.spec());
args->SetBoolean(guest_view::kIsTopLevel, !render_frame_host->GetParent());
- DispatchEventToView(make_scoped_ptr(
+ DispatchEventToView(base::WrapUnique(
new GuestViewEvent(webview::kEventLoadStart, std::move(args))));
}
@@ -852,11 +853,11 @@ void WebViewGuest::RenderProcessGone(base::TerminationStatus status) {
// Cancel all find sessions in progress.
find_helper_.CancelAllFindSessions();
- scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
args->SetInteger(webview::kProcessId,
web_contents()->GetRenderProcessHost()->GetID());
args->SetString(webview::kReason, TerminationStatusToString(status));
- DispatchEventToView(make_scoped_ptr(
+ DispatchEventToView(base::WrapUnique(
new GuestViewEvent(webview::kEventExit, std::move(args))));
}
@@ -882,26 +883,26 @@ void WebViewGuest::FrameNameChanged(RenderFrameHost* render_frame_host,
void WebViewGuest::ReportFrameNameChange(const std::string& name) {
name_ = name;
- scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
args->SetString(webview::kName, name);
- DispatchEventToView(make_scoped_ptr(
+ DispatchEventToView(base::WrapUnique(
new GuestViewEvent(webview::kEventFrameNameChanged, std::move(args))));
}
void WebViewGuest::LoadHandlerCalled() {
- scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
- DispatchEventToView(make_scoped_ptr(
+ std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ DispatchEventToView(base::WrapUnique(
new GuestViewEvent(webview::kEventContentLoad, std::move(args))));
}
void WebViewGuest::LoadRedirect(const GURL& old_url,
const GURL& new_url,
bool is_top_level) {
- scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
args->SetBoolean(guest_view::kIsTopLevel, is_top_level);
args->SetString(webview::kNewURL, new_url.spec());
args->SetString(webview::kOldURL, old_url.spec());
- DispatchEventToView(make_scoped_ptr(
+ DispatchEventToView(base::WrapUnique(
new GuestViewEvent(webview::kEventLoadRedirect, std::move(args))));
}
@@ -1494,8 +1495,8 @@ void WebViewGuest::SetFullscreenState(bool is_fullscreen) {
if (was_fullscreen && GuestMadeEmbedderFullscreen()) {
// Dispatch a message so we can call document.webkitCancelFullscreen()
// on the embedder.
- scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
- DispatchEventToView(make_scoped_ptr(
+ std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ DispatchEventToView(base::WrapUnique(
new GuestViewEvent(webview::kEventExitFullscreen, std::move(args))));
}
// Since we changed fullscreen state, sending a Resize message ensures that
diff --git a/chromium/extensions/browser/guest_view/web_view/web_view_guest.h b/chromium/extensions/browser/guest_view/web_view/web_view_guest.h
index d1baac5b64c..88d0f103d3c 100644
--- a/chromium/extensions/browser/guest_view/web_view/web_view_guest.h
+++ b/chromium/extensions/browser/guest_view/web_view/web_view_guest.h
@@ -24,7 +24,7 @@
namespace blink {
struct WebFindOptions;
-} // nanespace blink
+} // namespace blink
namespace content {
struct GlobalRequestID;
@@ -328,7 +328,7 @@ class WebViewGuest : public guest_view::GuestView<WebViewGuest>,
WebViewFindHelper find_helper_;
base::ObserverList<ScriptExecutionObserver> script_observers_;
- scoped_ptr<ScriptExecutor> script_executor_;
+ std::unique_ptr<ScriptExecutor> script_executor_;
content::NotificationRegistrar notification_registrar_;
@@ -348,9 +348,9 @@ class WebViewGuest : public guest_view::GuestView<WebViewGuest>,
JavaScriptDialogHelper javascript_dialog_helper_;
// Handles permission requests.
- scoped_ptr<WebViewPermissionHelper> web_view_permission_helper_;
+ std::unique_ptr<WebViewPermissionHelper> web_view_permission_helper_;
- scoped_ptr<WebViewGuestDelegate> web_view_guest_delegate_;
+ std::unique_ptr<WebViewGuestDelegate> web_view_guest_delegate_;
// Tracks the name, and target URL of the new window. Once the first
// navigation commits, we no longer track this information.
diff --git a/chromium/extensions/browser/guest_view/web_view/web_view_media_access_apitest.cc b/chromium/extensions/browser/guest_view/web_view/web_view_media_access_apitest.cc
index dcf41907cc1..1a0cc806005 100644
--- a/chromium/extensions/browser/guest_view/web_view/web_view_media_access_apitest.cc
+++ b/chromium/extensions/browser/guest_view/web_view/web_view_media_access_apitest.cc
@@ -95,7 +95,7 @@ class WebViewMediaAccessAPITest : public WebViewAPITest {
IN_PROC_BROWSER_TEST_F(WebViewMediaAccessAPITest, TestAllow) {
LaunchApp("web_view/media_access/allow");
- scoped_ptr<MockWebContentsDelegate> mock(new MockWebContentsDelegate());
+ std::unique_ptr<MockWebContentsDelegate> mock(new MockWebContentsDelegate());
embedder_web_contents_->SetDelegate(mock.get());
RunTest("testAllow");
@@ -105,7 +105,7 @@ IN_PROC_BROWSER_TEST_F(WebViewMediaAccessAPITest, TestAllow) {
IN_PROC_BROWSER_TEST_F(WebViewMediaAccessAPITest, TestAllowAndThenDeny) {
LaunchApp("web_view/media_access/allow");
- scoped_ptr<MockWebContentsDelegate> mock(new MockWebContentsDelegate());
+ std::unique_ptr<MockWebContentsDelegate> mock(new MockWebContentsDelegate());
embedder_web_contents_->SetDelegate(mock.get());
RunTest("testAllowAndThenDeny");
@@ -115,7 +115,7 @@ IN_PROC_BROWSER_TEST_F(WebViewMediaAccessAPITest, TestAllowAndThenDeny) {
IN_PROC_BROWSER_TEST_F(WebViewMediaAccessAPITest, TestAllowAsync) {
LaunchApp("web_view/media_access/allow");
- scoped_ptr<MockWebContentsDelegate> mock(new MockWebContentsDelegate());
+ std::unique_ptr<MockWebContentsDelegate> mock(new MockWebContentsDelegate());
embedder_web_contents_->SetDelegate(mock.get());
RunTest("testAllowAsync");
@@ -125,7 +125,7 @@ IN_PROC_BROWSER_TEST_F(WebViewMediaAccessAPITest, TestAllowAsync) {
IN_PROC_BROWSER_TEST_F(WebViewMediaAccessAPITest, TestAllowTwice) {
LaunchApp("web_view/media_access/allow");
- scoped_ptr<MockWebContentsDelegate> mock(new MockWebContentsDelegate());
+ std::unique_ptr<MockWebContentsDelegate> mock(new MockWebContentsDelegate());
embedder_web_contents_->SetDelegate(mock.get());
RunTest("testAllowTwice");
@@ -135,7 +135,7 @@ IN_PROC_BROWSER_TEST_F(WebViewMediaAccessAPITest, TestAllowTwice) {
IN_PROC_BROWSER_TEST_F(WebViewMediaAccessAPITest, TestCheck) {
LaunchApp("web_view/media_access/check");
- scoped_ptr<MockWebContentsDelegate> mock(new MockWebContentsDelegate());
+ std::unique_ptr<MockWebContentsDelegate> mock(new MockWebContentsDelegate());
embedder_web_contents_->SetDelegate(mock.get());
RunTest("testCheck");
diff --git a/chromium/extensions/browser/guest_view/web_view/web_view_permission_helper.cc b/chromium/extensions/browser/guest_view/web_view/web_view_permission_helper.cc
index 822f1312f5c..28142410974 100644
--- a/chromium/extensions/browser/guest_view/web_view/web_view_permission_helper.cc
+++ b/chromium/extensions/browser/guest_view/web_view/web_view_permission_helper.cc
@@ -6,6 +6,7 @@
#include <utility>
+#include "base/memory/ptr_util.h"
#include "components/guest_view/browser/guest_view_event.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
@@ -230,14 +231,14 @@ void WebViewPermissionHelper::OnMediaPermissionResponse(
if (!allow) {
callback.Run(content::MediaStreamDevices(),
content::MEDIA_DEVICE_PERMISSION_DENIED,
- scoped_ptr<content::MediaStreamUI>());
+ std::unique_ptr<content::MediaStreamUI>());
return;
}
if (!web_view_guest()->attached() ||
!web_view_guest()->embedder_web_contents()->GetDelegate()) {
callback.Run(content::MediaStreamDevices(),
content::MEDIA_DEVICE_INVALID_STATE,
- scoped_ptr<content::MediaStreamUI>());
+ std::unique_ptr<content::MediaStreamUI>());
return;
}
@@ -328,24 +329,24 @@ int WebViewPermissionHelper::RequestPermission(
int request_id = next_permission_request_id_++;
pending_permission_requests_[request_id] =
PermissionResponseInfo(callback, permission_type, allowed_by_default);
- scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue());
args->Set(webview::kRequestInfo, request_info.DeepCopy());
args->SetInteger(webview::kRequestId, request_id);
switch (permission_type) {
case WEB_VIEW_PERMISSION_TYPE_NEW_WINDOW: {
- web_view_guest_->DispatchEventToView(make_scoped_ptr(
+ web_view_guest_->DispatchEventToView(base::WrapUnique(
new GuestViewEvent(webview::kEventNewWindow, std::move(args))));
break;
}
case WEB_VIEW_PERMISSION_TYPE_JAVASCRIPT_DIALOG: {
- web_view_guest_->DispatchEventToView(make_scoped_ptr(
+ web_view_guest_->DispatchEventToView(base::WrapUnique(
new GuestViewEvent(webview::kEventDialog, std::move(args))));
break;
}
default: {
args->SetString(webview::kPermission,
PermissionTypeToString(permission_type));
- web_view_guest_->DispatchEventToView(make_scoped_ptr(new GuestViewEvent(
+ web_view_guest_->DispatchEventToView(base::WrapUnique(new GuestViewEvent(
webview::kEventPermissionRequest, std::move(args))));
break;
}
diff --git a/chromium/extensions/browser/guest_view/web_view/web_view_permission_helper.h b/chromium/extensions/browser/guest_view/web_view/web_view_permission_helper.h
index f5d037ddc43..a23623ae4fd 100644
--- a/chromium/extensions/browser/guest_view/web_view/web_view_permission_helper.h
+++ b/chromium/extensions/browser/guest_view/web_view/web_view_permission_helper.h
@@ -153,7 +153,7 @@ class WebViewPermissionHelper
WebViewPermissionHelper::RequestMap pending_permission_requests_;
- scoped_ptr<WebViewPermissionHelperDelegate>
+ std::unique_ptr<WebViewPermissionHelperDelegate>
web_view_permission_helper_delegate_;
WebViewGuest* const web_view_guest_;
diff --git a/chromium/extensions/browser/image_loader_unittest.cc b/chromium/extensions/browser/image_loader_unittest.cc
index 06c48d02d2d..f87aa4da1cc 100644
--- a/chromium/extensions/browser/image_loader_unittest.cc
+++ b/chromium/extensions/browser/image_loader_unittest.cc
@@ -86,8 +86,9 @@ class ImageLoaderTest : public ExtensionsTest {
std::string error;
JSONFileValueDeserializer deserializer(
extension_dir.AppendASCII("manifest.json"));
- scoped_ptr<base::DictionaryValue> valid_value = base::DictionaryValue::From(
- deserializer.Deserialize(&error_code, &error));
+ std::unique_ptr<base::DictionaryValue> valid_value =
+ base::DictionaryValue::From(
+ deserializer.Deserialize(&error_code, &error));
EXPECT_EQ(0, error_code) << error;
if (error_code != 0)
return NULL;
@@ -116,7 +117,7 @@ class ImageLoaderTest : public ExtensionsTest {
content::TestBrowserThread ui_thread_;
content::TestBrowserThread file_thread_;
content::TestBrowserThread io_thread_;
- scoped_ptr<NotificationService> notification_service_;
+ std::unique_ptr<NotificationService> notification_service_;
};
// Tests loading an image works correctly.
diff --git a/chromium/extensions/browser/info_map.h b/chromium/extensions/browser/info_map.h
index c540cef6549..2deafec5e82 100644
--- a/chromium/extensions/browser/info_map.h
+++ b/chromium/extensions/browser/info_map.h
@@ -5,10 +5,10 @@
#ifndef EXTENSIONS_BROWSER_INFO_MAP_H_
#define EXTENSIONS_BROWSER_INFO_MAP_H_
+#include <memory>
#include <string>
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "extensions/browser/process_map.h"
#include "extensions/browser/quota_service.h"
@@ -114,7 +114,7 @@ class InfoMap : public base::RefCountedThreadSafe<InfoMap> {
// Used by dispatchers to limit API quota for individual extensions.
// The QuotaService is not thread safe. We need to create and destroy it on
// the IO thread.
- scoped_ptr<QuotaService> quota_service_;
+ std::unique_ptr<QuotaService> quota_service_;
// Assignment of extensions to renderer processes.
extensions::ProcessMap process_map_;
diff --git a/chromium/extensions/browser/lazy_background_task_queue_unittest.cc b/chromium/extensions/browser/lazy_background_task_queue_unittest.cc
index 02ec3bbedd3..c464c5b1b5c 100644
--- a/chromium/extensions/browser/lazy_background_task_queue_unittest.cc
+++ b/chromium/extensions/browser/lazy_background_task_queue_unittest.cc
@@ -4,9 +4,11 @@
#include "extensions/browser/lazy_background_task_queue.h"
+#include <memory>
+
#include "base/bind.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/pref_registry/testing_pref_service_syncable.h"
#include "components/prefs/testing_pref_service.h"
@@ -55,8 +57,9 @@ class TestProcessManager : public ProcessManager {
DISALLOW_COPY_AND_ASSIGN(TestProcessManager);
};
-scoped_ptr<KeyedService> CreateTestProcessManager(BrowserContext* context) {
- return make_scoped_ptr(new TestProcessManager(context));
+std::unique_ptr<KeyedService> CreateTestProcessManager(
+ BrowserContext* context) {
+ return base::WrapUnique(new TestProcessManager(context));
}
} // namespace
@@ -119,7 +122,7 @@ class LazyBackgroundTaskQueueTest : public ExtensionsTest {
}
private:
- scoped_ptr<content::NotificationService> notification_service_;
+ std::unique_ptr<content::NotificationService> notification_service_;
user_prefs::TestingPrefServiceSyncable testing_pref_service_;
diff --git a/chromium/extensions/browser/load_monitoring_extension_host_queue.cc b/chromium/extensions/browser/load_monitoring_extension_host_queue.cc
index 47e8557abc1..0e9a9b1092e 100644
--- a/chromium/extensions/browser/load_monitoring_extension_host_queue.cc
+++ b/chromium/extensions/browser/load_monitoring_extension_host_queue.cc
@@ -19,7 +19,7 @@
namespace extensions {
LoadMonitoringExtensionHostQueue::LoadMonitoringExtensionHostQueue(
- scoped_ptr<ExtensionHostQueue> delegate,
+ std::unique_ptr<ExtensionHostQueue> delegate,
base::TimeDelta monitor_time,
const FinishedCallback& finished_callback)
: delegate_(std::move(delegate)),
@@ -33,7 +33,7 @@ LoadMonitoringExtensionHostQueue::LoadMonitoringExtensionHostQueue(
weak_ptr_factory_(this) {}
LoadMonitoringExtensionHostQueue::LoadMonitoringExtensionHostQueue(
- scoped_ptr<ExtensionHostQueue> delegate)
+ std::unique_ptr<ExtensionHostQueue> delegate)
: LoadMonitoringExtensionHostQueue(std::move(delegate),
base::TimeDelta::FromMinutes(1),
FinishedCallback()) {}
diff --git a/chromium/extensions/browser/load_monitoring_extension_host_queue.h b/chromium/extensions/browser/load_monitoring_extension_host_queue.h
index 661e80fe6ca..64b9ee3a618 100644
--- a/chromium/extensions/browser/load_monitoring_extension_host_queue.h
+++ b/chromium/extensions/browser/load_monitoring_extension_host_queue.h
@@ -7,11 +7,11 @@
#include <stddef.h>
+#include <memory>
#include <set>
#include "base/callback.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h"
#include "base/time/time.h"
@@ -34,7 +34,7 @@ class LoadMonitoringExtensionHostQueue
size_t, // max_awaiting_loading
size_t // max_active_loading
)>;
- LoadMonitoringExtensionHostQueue(scoped_ptr<ExtensionHostQueue> delegate,
+ LoadMonitoringExtensionHostQueue(std::unique_ptr<ExtensionHostQueue> delegate,
base::TimeDelta monitor_time,
const FinishedCallback& finished_callback);
@@ -43,7 +43,7 @@ class LoadMonitoringExtensionHostQueue
// Monitoring will not start until the first Add()ed
// DeferredStartRenderHost starts loading, or StartMonitoring() is called.
explicit LoadMonitoringExtensionHostQueue(
- scoped_ptr<ExtensionHostQueue> delegate);
+ std::unique_ptr<ExtensionHostQueue> delegate);
~LoadMonitoringExtensionHostQueue() override;
@@ -79,7 +79,7 @@ class LoadMonitoringExtensionHostQueue
void FinishMonitoring();
// Delegate actually loading DeferredStartRenderHosts to another queue.
- scoped_ptr<ExtensionHostQueue> delegate_;
+ std::unique_ptr<ExtensionHostQueue> delegate_;
// The amount of time to monitor for. By default this is 1 minute, but it can
// be overriden by tests.
diff --git a/chromium/extensions/browser/load_monitoring_extension_host_queue_unittest.cc b/chromium/extensions/browser/load_monitoring_extension_host_queue_unittest.cc
index b5ba4468696..a36bdfa5ef1 100644
--- a/chromium/extensions/browser/load_monitoring_extension_host_queue_unittest.cc
+++ b/chromium/extensions/browser/load_monitoring_extension_host_queue_unittest.cc
@@ -2,17 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "extensions/browser/load_monitoring_extension_host_queue.h"
+
#include <stddef.h>
#include <limits>
#include <vector>
#include "base/bind.h"
+#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "extensions/browser/deferred_start_render_host.h"
#include "extensions/browser/extensions_test.h"
-#include "extensions/browser/load_monitoring_extension_host_queue.h"
#include "extensions/browser/serial_extension_host_queue.h"
namespace extensions {
@@ -58,7 +60,7 @@ class LoadMonitoringExtensionHostQueueTest : public ExtensionsTest {
void SetUp() override {
queue_.reset(new LoadMonitoringExtensionHostQueue(
// Use a SerialExtensionHostQueue because it's simple.
- scoped_ptr<ExtensionHostQueue>(new SerialExtensionHostQueue()),
+ std::unique_ptr<ExtensionHostQueue>(new SerialExtensionHostQueue()),
base::TimeDelta(), // no delay, easier to test
base::Bind(&LoadMonitoringExtensionHostQueueTest::Finished,
base::Unretained(this))));
@@ -68,7 +70,7 @@ class LoadMonitoringExtensionHostQueueTest : public ExtensionsTest {
// Creates a new DeferredStartRenderHost. Ownership is held by this class,
// not passed to caller.
StubDeferredStartRenderHost* CreateHost() {
- stubs_.push_back(make_scoped_ptr(new StubDeferredStartRenderHost()));
+ stubs_.push_back(base::WrapUnique(new StubDeferredStartRenderHost()));
return stubs_.back().get();
}
@@ -100,8 +102,8 @@ class LoadMonitoringExtensionHostQueueTest : public ExtensionsTest {
}
content::TestBrowserThreadBundle thread_bundle_;
- scoped_ptr<LoadMonitoringExtensionHostQueue> queue_;
- std::vector<scoped_ptr<StubDeferredStartRenderHost>> stubs_;
+ std::unique_ptr<LoadMonitoringExtensionHostQueue> queue_;
+ std::vector<std::unique_ptr<StubDeferredStartRenderHost>> stubs_;
// Set after the queue has finished monitoring.
bool finished_;
diff --git a/chromium/extensions/browser/mock_extension_system.cc b/chromium/extensions/browser/mock_extension_system.cc
index 6658832e744..621fe93a711 100644
--- a/chromium/extensions/browser/mock_extension_system.cc
+++ b/chromium/extensions/browser/mock_extension_system.cc
@@ -71,9 +71,9 @@ ContentVerifier* MockExtensionSystem::content_verifier() {
return nullptr;
}
-scoped_ptr<ExtensionSet> MockExtensionSystem::GetDependentExtensions(
+std::unique_ptr<ExtensionSet> MockExtensionSystem::GetDependentExtensions(
const Extension* extension) {
- return scoped_ptr<ExtensionSet>();
+ return std::unique_ptr<ExtensionSet>();
}
void MockExtensionSystem::InstallUpdate(const std::string& extension_id,
diff --git a/chromium/extensions/browser/mock_extension_system.h b/chromium/extensions/browser/mock_extension_system.h
index b926baad84b..c8748dfb661 100644
--- a/chromium/extensions/browser/mock_extension_system.h
+++ b/chromium/extensions/browser/mock_extension_system.h
@@ -41,7 +41,7 @@ class MockExtensionSystem : public ExtensionSystem {
AppSorting* app_sorting() override;
const OneShotEvent& ready() const override;
ContentVerifier* content_verifier() override;
- scoped_ptr<ExtensionSet> GetDependentExtensions(
+ std::unique_ptr<ExtensionSet> GetDependentExtensions(
const Extension* extension) override;
void InstallUpdate(const std::string& extension_id,
const base::FilePath& temp_dir) override;
diff --git a/chromium/extensions/browser/mojo/DEPS b/chromium/extensions/browser/mojo/DEPS
index 2273ad20a57..df73043fafe 100644
--- a/chromium/extensions/browser/mojo/DEPS
+++ b/chromium/extensions/browser/mojo/DEPS
@@ -1,4 +1,3 @@
include_rules = [
- "+mojo/message_pump",
- "+mojo/shell/public/interfaces",
+ "+services/shell/public/interfaces",
]
diff --git a/chromium/extensions/browser/mojo/keep_alive_impl_unittest.cc b/chromium/extensions/browser/mojo/keep_alive_impl_unittest.cc
index 5d640e055d3..4a6732d5727 100644
--- a/chromium/extensions/browser/mojo/keep_alive_impl_unittest.cc
+++ b/chromium/extensions/browser/mojo/keep_alive_impl_unittest.cc
@@ -72,8 +72,8 @@ class KeepAliveTest : public ExtensionsTest {
}
private:
- scoped_ptr<base::MessageLoop> message_loop_;
- scoped_ptr<content::NotificationService> notification_service_;
+ std::unique_ptr<base::MessageLoop> message_loop_;
+ std::unique_ptr<content::NotificationService> notification_service_;
scoped_refptr<const Extension> extension_;
DISALLOW_COPY_AND_ASSIGN(KeepAliveTest);
diff --git a/chromium/extensions/browser/mojo/service_registration.cc b/chromium/extensions/browser/mojo/service_registration.cc
index c6367f070f9..d6091eafcdb 100644
--- a/chromium/extensions/browser/mojo/service_registration.cc
+++ b/chromium/extensions/browser/mojo/service_registration.cc
@@ -22,6 +22,7 @@
#include "extensions/common/switches.h"
#if defined(ENABLE_WIFI_DISPLAY)
+#include "extensions/browser/api/display_source/wifi_display/wifi_display_media_service_impl.h"
#include "extensions/browser/api/display_source/wifi_display/wifi_display_session_service_impl.h"
#endif
@@ -65,6 +66,8 @@ void RegisterServicesForFrame(content::RenderFrameHost* render_frame_host,
service_registry->AddService(
base::Bind(WiFiDisplaySessionServiceImpl::BindToRequest,
render_frame_host->GetProcess()->GetBrowserContext()));
+ service_registry->AddService(
+ base::Bind(WiFiDisplayMediaServiceImpl::BindToRequest));
}
#endif
}
diff --git a/chromium/extensions/browser/mojo/stash_backend.cc b/chromium/extensions/browser/mojo/stash_backend.cc
index 8d3eb40dbee..8104c4d09a5 100644
--- a/chromium/extensions/browser/mojo/stash_backend.cc
+++ b/chromium/extensions/browser/mojo/stash_backend.cc
@@ -11,8 +11,9 @@
#include "base/bind.h"
#include "base/macros.h"
-#include "mojo/message_pump/handle_watcher.h"
+#include "base/memory/ptr_util.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
+#include "mojo/public/cpp/system/watcher.h"
namespace extensions {
namespace {
@@ -84,7 +85,7 @@ class StashBackend::StashEntry {
void OnHandleReady(MojoResult result);
// The waiters that are waiting for handles to be readable.
- std::vector<scoped_ptr<mojo::common::HandleWatcher>> waiters_;
+ std::vector<std::unique_ptr<mojo::Watcher>> waiters_;
StashedObjectPtr stashed_object_;
@@ -104,7 +105,7 @@ StashBackend::~StashBackend() {
void StashBackend::AddToStash(mojo::Array<StashedObjectPtr> stashed_objects) {
for (size_t i = 0; i < stashed_objects.size(); i++) {
- stashed_objects_.push_back(make_scoped_ptr(new StashEntry(
+ stashed_objects_.push_back(base::WrapUnique(new StashEntry(
std::move(stashed_objects[i]),
has_notified_ ? base::Closure()
: base::Bind(&StashBackend::OnHandleReady,
@@ -144,10 +145,9 @@ StashBackend::StashEntry::StashEntry(StashedObjectPtr stashed_object,
return;
for (size_t i = 0; i < stashed_object_->stashed_handles.size(); i++) {
- scoped_ptr<mojo::common::HandleWatcher> watcher(
- new mojo::common::HandleWatcher());
+ std::unique_ptr<mojo::Watcher> watcher(new mojo::Watcher);
watcher->Start(stashed_object_->stashed_handles[i].get(),
- MOJO_HANDLE_SIGNAL_READABLE, MOJO_DEADLINE_INDEFINITE,
+ MOJO_HANDLE_SIGNAL_READABLE,
base::Bind(&StashBackend::StashEntry::OnHandleReady,
base::Unretained(this)));
waiters_.push_back(std::move(watcher));
diff --git a/chromium/extensions/browser/mojo/stash_backend.h b/chromium/extensions/browser/mojo/stash_backend.h
index f374e00f957..a6d2515c2ff 100644
--- a/chromium/extensions/browser/mojo/stash_backend.h
+++ b/chromium/extensions/browser/mojo/stash_backend.h
@@ -39,7 +39,7 @@ class StashBackend {
void OnHandleReady();
// The objects that have been stashed.
- std::vector<scoped_ptr<StashEntry>> stashed_objects_;
+ std::vector<std::unique_ptr<StashEntry>> stashed_objects_;
// The callback to call when a handle is readable.
const base::Closure on_handle_readable_;
diff --git a/chromium/extensions/browser/mojo/stash_backend_unittest.cc b/chromium/extensions/browser/mojo/stash_backend_unittest.cc
index cf69f98c43b..48991011825 100644
--- a/chromium/extensions/browser/mojo/stash_backend_unittest.cc
+++ b/chromium/extensions/browser/mojo/stash_backend_unittest.cc
@@ -12,7 +12,7 @@
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
-#include "mojo/shell/public/interfaces/interface_provider.mojom.h"
+#include "services/shell/public/interfaces/interface_provider.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace extensions {
@@ -95,7 +95,7 @@ class StashServiceTest : public testing::Test {
protected:
base::MessageLoop message_loop_;
base::Closure stop_run_loop_;
- scoped_ptr<StashBackend> stash_backend_;
+ std::unique_ptr<StashBackend> stash_backend_;
Event expected_event_;
bool expecting_error_;
mojo::InterfacePtr<StashService> stash_service_;
@@ -191,7 +191,7 @@ TEST_F(StashServiceTest, NotifyOnReadableHandle) {
stashed_object->id = "test type";
stashed_object->data.push_back(0);
stashed_object->monitor_handles = true;
- mojo::shell::mojom::InterfaceProviderPtr service_provider;
+ shell::mojom::InterfaceProviderPtr service_provider;
// Stash the ServiceProvider request. When we make a call on
// |service_provider|, the stashed handle will become readable.
diff --git a/chromium/extensions/browser/process_manager_unittest.cc b/chromium/extensions/browser/process_manager_unittest.cc
index e5336c6736c..aa6b108365b 100644
--- a/chromium/extensions/browser/process_manager_unittest.cc
+++ b/chromium/extensions/browser/process_manager_unittest.cc
@@ -90,7 +90,7 @@ class ProcessManagerTest : public ExtensionsTest {
}
private:
- scoped_ptr<content::NotificationService> notification_service_;
+ std::unique_ptr<content::NotificationService> notification_service_;
TestBrowserContextIncognito incognito_context_;
ExtensionRegistry extension_registry_; // Shared between BrowserContexts.
TestProcessManagerDelegate process_manager_delegate_;
@@ -101,7 +101,7 @@ class ProcessManagerTest : public ExtensionsTest {
// Test that notification registration works properly.
TEST_F(ProcessManagerTest, ExtensionNotificationRegistration) {
// Test for a normal context ProcessManager.
- scoped_ptr<ProcessManager> manager1(ProcessManager::CreateForTesting(
+ std::unique_ptr<ProcessManager> manager1(ProcessManager::CreateForTesting(
original_context(), extension_registry()));
EXPECT_EQ(original_context(), manager1->browser_context());
@@ -116,10 +116,9 @@ TEST_F(ProcessManagerTest, ExtensionNotificationRegistration) {
original_context()));
// Test for an incognito context ProcessManager.
- scoped_ptr<ProcessManager> manager2(
- ProcessManager::CreateIncognitoForTesting(incognito_context(),
- original_context(),
- extension_registry()));
+ std::unique_ptr<ProcessManager> manager2(
+ ProcessManager::CreateIncognitoForTesting(
+ incognito_context(), original_context(), extension_registry()));
EXPECT_EQ(incognito_context(), manager2->browser_context());
EXPECT_EQ(0u, manager2->background_hosts().size());
@@ -143,7 +142,7 @@ TEST_F(ProcessManagerTest, ExtensionNotificationRegistration) {
// because ExtensionHost is tightly coupled to WebContents and can't be
// constructed in unit tests.
TEST_F(ProcessManagerTest, CreateBackgroundHostsOnExtensionsReady) {
- scoped_ptr<ProcessManager> manager(ProcessManager::CreateForTesting(
+ std::unique_ptr<ProcessManager> manager(ProcessManager::CreateForTesting(
original_context(), extension_registry()));
ASSERT_FALSE(manager->startup_background_hosts_created_for_test());
@@ -158,7 +157,7 @@ TEST_F(ProcessManagerTest, CreateBackgroundHostsOnExtensionsReady) {
// Test that startup background hosts can be created explicitly before the
// extension system is ready (this is the normal pattern in Chrome).
TEST_F(ProcessManagerTest, CreateBackgroundHostsExplicitly) {
- scoped_ptr<ProcessManager> manager(ProcessManager::CreateForTesting(
+ std::unique_ptr<ProcessManager> manager(ProcessManager::CreateForTesting(
original_context(), extension_registry()));
ASSERT_FALSE(manager->startup_background_hosts_created_for_test());
@@ -171,7 +170,7 @@ TEST_F(ProcessManagerTest, CreateBackgroundHostsExplicitly) {
// Test that the embedder can defer background host creation. Chrome does this
// when the profile is created asynchronously, which may take a while.
TEST_F(ProcessManagerTest, CreateBackgroundHostsDeferred) {
- scoped_ptr<ProcessManager> manager(ProcessManager::CreateForTesting(
+ std::unique_ptr<ProcessManager> manager(ProcessManager::CreateForTesting(
original_context(), extension_registry()));
ASSERT_FALSE(manager->startup_background_hosts_created_for_test());
@@ -196,7 +195,7 @@ TEST_F(ProcessManagerTest, CreateBackgroundHostsDeferred) {
// Test that the embedder can disallow background host creation.
// Chrome OS does this in guest mode.
TEST_F(ProcessManagerTest, IsBackgroundHostAllowed) {
- scoped_ptr<ProcessManager> manager(ProcessManager::CreateForTesting(
+ std::unique_ptr<ProcessManager> manager(ProcessManager::CreateForTesting(
original_context(), extension_registry()));
ASSERT_FALSE(manager->startup_background_hosts_created_for_test());
@@ -218,13 +217,13 @@ TEST_F(ProcessManagerTest, IsBackgroundHostAllowed) {
TEST_F(ProcessManagerTest, ProcessGrouping) {
// Extensions in different browser contexts should always be different
// SiteInstances.
- scoped_ptr<ProcessManager> manager1(ProcessManager::CreateForTesting(
+ std::unique_ptr<ProcessManager> manager1(ProcessManager::CreateForTesting(
original_context(), extension_registry()));
// NOTE: This context is not associated with the TestExtensionsBrowserClient.
// That's OK because we're not testing regular vs. incognito behavior.
TestBrowserContext another_context;
ExtensionRegistry another_registry(&another_context);
- scoped_ptr<ProcessManager> manager2(
+ std::unique_ptr<ProcessManager> manager2(
ProcessManager::CreateForTesting(&another_context, &another_registry));
// Extensions with common origins ("scheme://id/") should be grouped in the
diff --git a/chromium/extensions/browser/quota_service.h b/chromium/extensions/browser/quota_service.h
index b4079ded513..2ff8a1fab45 100644
--- a/chromium/extensions/browser/quota_service.h
+++ b/chromium/extensions/browser/quota_service.h
@@ -18,12 +18,12 @@
#include <list>
#include <map>
+#include <memory>
#include <string>
#include "base/compiler_specific.h"
#include "base/containers/hash_tables.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/threading/non_thread_safe.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
@@ -192,7 +192,7 @@ class QuotaLimitHeuristic {
const Config config_;
// The mapper used in Map. Cannot be NULL.
- scoped_ptr<BucketMapper> bucket_mapper_;
+ std::unique_ptr<BucketMapper> bucket_mapper_;
// The name of the heuristic for formatting error messages.
std::string name_;
diff --git a/chromium/extensions/browser/quota_service_unittest.cc b/chromium/extensions/browser/quota_service_unittest.cc
index a70e7f2cbe0..dd73849be11 100644
--- a/chromium/extensions/browser/quota_service_unittest.cc
+++ b/chromium/extensions/browser/quota_service_unittest.cc
@@ -30,7 +30,6 @@ namespace {
const char kGenericName[] = "name";
const Config kFrozenConfig = {0, TimeDelta::FromDays(0)};
const Config k2PerMinute = {2, TimeDelta::FromMinutes(1)};
-const Config k20PerHour = {20, TimeDelta::FromHours(1)};
const TimeTicks kStartTime = TimeTicks();
const TimeTicks k1MinuteAfterStart = kStartTime + TimeDelta::FromMinutes(1);
@@ -121,7 +120,7 @@ class QuotaServiceTest : public testing::Test {
std::string extension_a_;
std::string extension_b_;
std::string extension_c_;
- scoped_ptr<QuotaService> service_;
+ std::unique_ptr<QuotaService> service_;
base::MessageLoop loop_;
content::TestBrowserThread ui_thread_;
};
diff --git a/chromium/extensions/browser/sandboxed_unpacker.cc b/chromium/extensions/browser/sandboxed_unpacker.cc
index ab84c2adbd9..e0ae0286a29 100644
--- a/chromium/extensions/browser/sandboxed_unpacker.cc
+++ b/chromium/extensions/browser/sandboxed_unpacker.cc
@@ -431,7 +431,7 @@ void SandboxedUnpacker::OnUnpackExtensionSucceeded(
got_response_ = true;
utility_wrapper_ = nullptr;
- scoped_ptr<base::DictionaryValue> final_manifest(
+ std::unique_ptr<base::DictionaryValue> final_manifest(
RewriteManifestFile(manifest));
if (!final_manifest)
return;
@@ -683,7 +683,7 @@ base::DictionaryValue* SandboxedUnpacker::RewriteManifestFile(
// the original manifest. We do this to ensure the manifest doesn't contain an
// exploitable bug that could be used to compromise the browser.
DCHECK(!public_key_.empty());
- scoped_ptr<base::DictionaryValue> final_manifest(manifest.DeepCopy());
+ std::unique_ptr<base::DictionaryValue> final_manifest(manifest.DeepCopy());
final_manifest->SetString(manifest_keys::kPublicKey, public_key_);
std::string manifest_json;
diff --git a/chromium/extensions/browser/sandboxed_unpacker_unittest.cc b/chromium/extensions/browser/sandboxed_unpacker_unittest.cc
index a66b2fa5423..0e3bf9e7a33 100644
--- a/chromium/extensions/browser/sandboxed_unpacker_unittest.cc
+++ b/chromium/extensions/browser/sandboxed_unpacker_unittest.cc
@@ -10,7 +10,7 @@
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
#include "components/crx_file/id_util.h"
#include "content/public/test/test_browser_thread_bundle.h"
@@ -131,8 +131,8 @@ class SandboxedUnpackerTest : public ExtensionsTest {
base::ScopedTempDir extensions_dir_;
MockSandboxedUnpackerClient* client_;
scoped_refptr<SandboxedUnpacker> sandboxed_unpacker_;
- scoped_ptr<content::TestBrowserThreadBundle> browser_threads_;
- scoped_ptr<content::InProcessUtilityThreadHelper>
+ std::unique_ptr<content::TestBrowserThreadBundle> browser_threads_;
+ std::unique_ptr<content::InProcessUtilityThreadHelper>
in_process_utility_thread_helper_;
};
diff --git a/chromium/extensions/browser/state_store.cc b/chromium/extensions/browser/state_store.cc
index 2c8c9f9f1c8..ae67f895806 100644
--- a/chromium/extensions/browser/state_store.cc
+++ b/chromium/extensions/browser/state_store.cc
@@ -111,7 +111,7 @@ void StateStore::GetExtensionValue(const std::string& extension_id,
void StateStore::SetExtensionValue(const std::string& extension_id,
const std::string& key,
- scoped_ptr<base::Value> value) {
+ std::unique_ptr<base::Value> value) {
task_queue_->InvokeWhenReady(
base::Bind(&ValueStoreFrontend::Set, base::Unretained(store_.get()),
GetFullKey(extension_id, key), base::Passed(&value)));
diff --git a/chromium/extensions/browser/state_store.h b/chromium/extensions/browser/state_store.h
index 5cc0037cdb5..2ad313c3b5d 100644
--- a/chromium/extensions/browser/state_store.h
+++ b/chromium/extensions/browser/state_store.h
@@ -39,7 +39,8 @@ class StateStore : public base::SupportsWeakPtr<StateStore>,
ValueStoreFrontend::BackendType backend_type,
bool deferred_load);
// This variant is useful for testing (using a mock ValueStore).
- StateStore(content::BrowserContext* context, scoped_ptr<ValueStore> store);
+ StateStore(content::BrowserContext* context,
+ std::unique_ptr<ValueStore> store);
~StateStore() override;
// Requests that the state store to be initialized after its usual delay. Can
@@ -60,7 +61,7 @@ class StateStore : public base::SupportsWeakPtr<StateStore>,
// Sets a value for a given extension and key.
void SetExtensionValue(const std::string& extension_id,
const std::string& key,
- scoped_ptr<base::Value> value);
+ std::unique_ptr<base::Value> value);
// Removes a value for a given extension and key.
void RemoveExtensionValue(const std::string& extension_id,
@@ -96,14 +97,14 @@ class StateStore : public base::SupportsWeakPtr<StateStore>,
const std::string& old_name) override;
// The store that holds our key/values.
- scoped_ptr<ValueStoreFrontend> store_;
+ std::unique_ptr<ValueStoreFrontend> store_;
// List of all known keys. They will be cleared for each extension when it is
// (un)installed.
std::set<std::string> registered_keys_;
// Keeps track of tasks we have delayed while starting up.
- scoped_ptr<DelayedTaskQueue> task_queue_;
+ std::unique_ptr<DelayedTaskQueue> task_queue_;
content::NotificationRegistrar registrar_;
diff --git a/chromium/extensions/browser/test_extension_registry_observer.cc b/chromium/extensions/browser/test_extension_registry_observer.cc
index ab53b7a437a..ebdf1a85508 100644
--- a/chromium/extensions/browser/test_extension_registry_observer.cc
+++ b/chromium/extensions/browser/test_extension_registry_observer.cc
@@ -105,7 +105,7 @@ void TestExtensionRegistryObserver::OnExtensionUnloaded(
}
const Extension* TestExtensionRegistryObserver::Wait(
- scoped_ptr<Waiter>* waiter) {
+ std::unique_ptr<Waiter>* waiter) {
waiter->get()->Wait();
const Extension* extension = waiter->get()->extension();
// Reset the waiter for future uses.
diff --git a/chromium/extensions/browser/test_extension_registry_observer.h b/chromium/extensions/browser/test_extension_registry_observer.h
index ce0a3f86e41..30074979f91 100644
--- a/chromium/extensions/browser/test_extension_registry_observer.h
+++ b/chromium/extensions/browser/test_extension_registry_observer.h
@@ -5,10 +5,10 @@
#ifndef EXTENSIONS_BROWSER_TEST_EXTENSION_REGISTRY_OBSERVER_H_
#define EXTENSIONS_BROWSER_TEST_EXTENSION_REGISTRY_OBSERVER_H_
+#include <memory>
#include <string>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/scoped_observer.h"
#include "extensions/browser/extension_registry_observer.h"
@@ -49,12 +49,12 @@ class TestExtensionRegistryObserver : public ExtensionRegistryObserver {
const Extension* extension,
UnloadedExtensionInfo::Reason reason) override;
- const Extension* Wait(scoped_ptr<Waiter>* waiter);
+ const Extension* Wait(std::unique_ptr<Waiter>* waiter);
- scoped_ptr<Waiter> will_be_installed_waiter_;
- scoped_ptr<Waiter> uninstalled_waiter_;
- scoped_ptr<Waiter> loaded_waiter_;
- scoped_ptr<Waiter> unloaded_waiter_;
+ std::unique_ptr<Waiter> will_be_installed_waiter_;
+ std::unique_ptr<Waiter> uninstalled_waiter_;
+ std::unique_ptr<Waiter> loaded_waiter_;
+ std::unique_ptr<Waiter> unloaded_waiter_;
ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
extension_registry_observer_;
diff --git a/chromium/extensions/browser/test_extensions_browser_client.cc b/chromium/extensions/browser/test_extensions_browser_client.cc
index 7ba4dfac65c..293d1feb164 100644
--- a/chromium/extensions/browser/test_extensions_browser_client.cc
+++ b/chromium/extensions/browser/test_extensions_browser_client.cc
@@ -134,9 +134,9 @@ ProcessManagerDelegate* TestExtensionsBrowserClient::GetProcessManagerDelegate()
return process_manager_delegate_;
}
-scoped_ptr<ExtensionHostDelegate>
+std::unique_ptr<ExtensionHostDelegate>
TestExtensionsBrowserClient::CreateExtensionHostDelegate() {
- return scoped_ptr<ExtensionHostDelegate>();
+ return std::unique_ptr<ExtensionHostDelegate>();
}
bool TestExtensionsBrowserClient::DidVersionUpdate(BrowserContext* context) {
@@ -171,10 +171,10 @@ void TestExtensionsBrowserClient::RegisterMojoServices(
const Extension* extension) const {
}
-scoped_ptr<RuntimeAPIDelegate>
+std::unique_ptr<RuntimeAPIDelegate>
TestExtensionsBrowserClient::CreateRuntimeAPIDelegate(
content::BrowserContext* context) const {
- return scoped_ptr<RuntimeAPIDelegate>(new TestRuntimeAPIDelegate());
+ return std::unique_ptr<RuntimeAPIDelegate>(new TestRuntimeAPIDelegate());
}
const ComponentExtensionResourceManager*
@@ -185,7 +185,7 @@ TestExtensionsBrowserClient::GetComponentExtensionResourceManager() {
void TestExtensionsBrowserClient::BroadcastEventToRenderers(
events::HistogramValue histogram_value,
const std::string& event_name,
- scoped_ptr<base::ListValue> args) {}
+ std::unique_ptr<base::ListValue> args) {}
net::NetLog* TestExtensionsBrowserClient::GetNetLog() {
return NULL;
diff --git a/chromium/extensions/browser/test_extensions_browser_client.h b/chromium/extensions/browser/test_extensions_browser_client.h
index 2b0dafb0b7d..e66fe98910e 100644
--- a/chromium/extensions/browser/test_extensions_browser_client.h
+++ b/chromium/extensions/browser/test_extensions_browser_client.h
@@ -35,7 +35,7 @@ class TestExtensionsBrowserClient : public ExtensionsBrowserClient {
void set_extension_system_factory(ExtensionSystemProvider* factory) {
extension_system_factory_ = factory;
}
- void set_extension_cache(scoped_ptr<ExtensionCache> extension_cache) {
+ void set_extension_cache(std::unique_ptr<ExtensionCache> extension_cache) {
extension_cache_ = std::move(extension_cache);
}
@@ -85,7 +85,7 @@ class TestExtensionsBrowserClient : public ExtensionsBrowserClient {
content::BrowserContext* context,
std::vector<ExtensionPrefsObserver*>* observers) const override;
ProcessManagerDelegate* GetProcessManagerDelegate() const override;
- scoped_ptr<ExtensionHostDelegate> CreateExtensionHostDelegate() override;
+ std::unique_ptr<ExtensionHostDelegate> CreateExtensionHostDelegate() override;
bool DidVersionUpdate(content::BrowserContext* context) override;
void PermitExternalProtocolHandler() override;
bool IsRunningInForcedAppMode() override;
@@ -97,13 +97,14 @@ class TestExtensionsBrowserClient : public ExtensionsBrowserClient {
ExtensionFunctionRegistry* registry) const override;
void RegisterMojoServices(content::RenderFrameHost* render_frame_host,
const Extension* extension) const override;
- scoped_ptr<RuntimeAPIDelegate> CreateRuntimeAPIDelegate(
+ std::unique_ptr<RuntimeAPIDelegate> CreateRuntimeAPIDelegate(
content::BrowserContext* context) const override;
const ComponentExtensionResourceManager*
GetComponentExtensionResourceManager() override;
- void BroadcastEventToRenderers(events::HistogramValue histogram_value,
- const std::string& event_name,
- scoped_ptr<base::ListValue> args) override;
+ void BroadcastEventToRenderers(
+ events::HistogramValue histogram_value,
+ const std::string& event_name,
+ std::unique_ptr<base::ListValue> args) override;
net::NetLog* GetNetLog() override;
ExtensionCache* GetExtensionCache() override;
bool IsBackgroundUpdateAllowed() override;
@@ -123,7 +124,7 @@ class TestExtensionsBrowserClient : public ExtensionsBrowserClient {
// Not owned, defaults to NULL.
ExtensionSystemProvider* extension_system_factory_;
- scoped_ptr<ExtensionCache> extension_cache_;
+ std::unique_ptr<ExtensionCache> extension_cache_;
base::Callback<update_client::UpdateClient*(void)> update_client_factory_;
diff --git a/chromium/extensions/browser/updater/extension_downloader.cc b/chromium/extensions/browser/updater/extension_downloader.cc
index 116ef7abb15..66cc2ee2ddf 100644
--- a/chromium/extensions/browser/updater/extension_downloader.cc
+++ b/chromium/extensions/browser/updater/extension_downloader.cc
@@ -27,6 +27,7 @@
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/browser/notification_types.h"
#include "extensions/browser/updater/extension_cache.h"
+#include "extensions/browser/updater/extension_downloader_test_delegate.h"
#include "extensions/browser/updater/request_queue_impl.h"
#include "extensions/browser/updater/safe_manifest_parser.h"
#include "extensions/common/extension_urls.h"
@@ -90,6 +91,8 @@ const char kTokenServiceConsumerId[] = "extension_downloader";
const char kWebstoreOAuth2Scope[] =
"https://www.googleapis.com/auth/chromewebstore.readonly";
+ExtensionDownloaderTestDelegate* g_test_delegate = nullptr;
+
#define RETRY_HISTOGRAM(name, retry_count, url) \
if ((url).DomainIs(kGoogleDotCom)) { \
UMA_HISTOGRAM_CUSTOM_COUNTS("Extensions." name "RetryCountGoogleUrl", \
@@ -190,7 +193,6 @@ ExtensionDownloader::ExtensionDownloader(
base::Bind(&ExtensionDownloader::CreateExtensionFetcher,
base::Unretained(this))),
extension_cache_(NULL),
- enable_extra_update_metrics_(false),
weak_ptr_factory_(this) {
DCHECK(delegate_);
DCHECK(request_context_.get());
@@ -252,7 +254,7 @@ void ExtensionDownloader::DoStartAllPending() {
++it) {
std::vector<linked_ptr<ManifestFetchData>>& list = it->second;
for (size_t i = 0; i < list.size(); ++i) {
- StartUpdateCheck(scoped_ptr<ManifestFetchData>(list[i].release()));
+ StartUpdateCheck(std::unique_ptr<ManifestFetchData>(list[i].release()));
}
}
fetches_preparing_.clear();
@@ -265,7 +267,7 @@ void ExtensionDownloader::StartBlacklistUpdate(
// Note: it is very important that we use the https version of the update
// url here to avoid DNS hijacking of the blacklist, which is not validated
// by a public key signature like .crx files are.
- scoped_ptr<ManifestFetchData> blacklist_fetch(CreateManifestFetchData(
+ std::unique_ptr<ManifestFetchData> blacklist_fetch(CreateManifestFetchData(
extension_urls::GetWebstoreUpdateUrl(), request_id));
DCHECK(blacklist_fetch->base_url().SchemeIsCryptographic());
blacklist_fetch->AddExtension(kBlacklistAppID, version, &ping_data,
@@ -274,10 +276,16 @@ void ExtensionDownloader::StartBlacklistUpdate(
}
void ExtensionDownloader::SetWebstoreIdentityProvider(
- scoped_ptr<IdentityProvider> identity_provider) {
+ std::unique_ptr<IdentityProvider> identity_provider) {
identity_provider_.swap(identity_provider);
}
+// static
+void ExtensionDownloader::set_test_delegate(
+ ExtensionDownloaderTestDelegate* delegate) {
+ g_test_delegate = delegate;
+}
+
bool ExtensionDownloader::AddExtensionData(const std::string& id,
const Version& version,
Manifest::Type extension_type,
@@ -334,53 +342,42 @@ bool ExtensionDownloader::AddExtensionData(const std::string& id,
break;
}
- std::vector<GURL> update_urls;
- update_urls.push_back(update_url);
- // If metrics are enabled, also add to ManifestFetchData for the
- // webstore update URL.
- if (!extension_urls::IsWebstoreUpdateUrl(update_url) &&
- enable_extra_update_metrics_) {
- update_urls.push_back(extension_urls::GetWebstoreUpdateUrl());
- }
-
- for (size_t i = 0; i < update_urls.size(); ++i) {
- DCHECK(!update_urls[i].is_empty());
- DCHECK(update_urls[i].is_valid());
-
- std::string install_source =
- i == 0 ? kDefaultInstallSource : kNotFromWebstoreInstallSource;
-
- ManifestFetchData::PingData ping_data;
- ManifestFetchData::PingData* optional_ping_data = NULL;
- if (delegate_->GetPingDataForExtension(id, &ping_data))
- optional_ping_data = &ping_data;
-
- // Find or create a ManifestFetchData to add this extension to.
- bool added = false;
- FetchMap::iterator existing_iter =
- fetches_preparing_.find(std::make_pair(request_id, update_urls[i]));
- if (existing_iter != fetches_preparing_.end() &&
- !existing_iter->second.empty()) {
- // Try to add to the ManifestFetchData at the end of the list.
- ManifestFetchData* existing_fetch = existing_iter->second.back().get();
- if (existing_fetch->AddExtension(id, version.GetString(),
- optional_ping_data, update_url_data,
- install_source)) {
- added = true;
- }
- }
- if (!added) {
- // Otherwise add a new element to the list, if the list doesn't exist or
- // if its last element is already full.
- linked_ptr<ManifestFetchData> fetch(
- CreateManifestFetchData(update_urls[i], request_id));
- fetches_preparing_[std::make_pair(request_id, update_urls[i])].push_back(
- fetch);
- added = fetch->AddExtension(id, version.GetString(), optional_ping_data,
- update_url_data, install_source);
- DCHECK(added);
+ DCHECK(!update_url.is_empty());
+ DCHECK(update_url.is_valid());
+
+ std::string install_source = extension_urls::IsWebstoreUpdateUrl(update_url)
+ ? kDefaultInstallSource
+ : kNotFromWebstoreInstallSource;
+
+ ManifestFetchData::PingData ping_data;
+ ManifestFetchData::PingData* optional_ping_data = NULL;
+ if (delegate_->GetPingDataForExtension(id, &ping_data))
+ optional_ping_data = &ping_data;
+
+ // Find or create a ManifestFetchData to add this extension to.
+ bool added = false;
+ FetchMap::iterator existing_iter =
+ fetches_preparing_.find(std::make_pair(request_id, update_url));
+ if (existing_iter != fetches_preparing_.end() &&
+ !existing_iter->second.empty()) {
+ // Try to add to the ManifestFetchData at the end of the list.
+ ManifestFetchData* existing_fetch = existing_iter->second.back().get();
+ if (existing_fetch->AddExtension(id, version.GetString(),
+ optional_ping_data, update_url_data,
+ install_source)) {
+ added = true;
}
}
+ if (!added) {
+ // Otherwise add a new element to the list, if the list doesn't exist or
+ // if its last element is already full.
+ linked_ptr<ManifestFetchData> fetch(
+ CreateManifestFetchData(update_url, request_id));
+ fetches_preparing_[std::make_pair(request_id, update_url)].push_back(fetch);
+ added = fetch->AddExtension(id, version.GetString(), optional_ping_data,
+ update_url_data, install_source);
+ DCHECK(added);
+ }
return true;
}
@@ -404,7 +401,12 @@ void ExtensionDownloader::ReportStats() const {
}
void ExtensionDownloader::StartUpdateCheck(
- scoped_ptr<ManifestFetchData> fetch_data) {
+ std::unique_ptr<ManifestFetchData> fetch_data) {
+ if (g_test_delegate) {
+ g_test_delegate->StartUpdateCheck(this, delegate_, std::move(fetch_data));
+ return;
+ }
+
const std::set<std::string>& id_set(fetch_data->extension_ids());
if (!ExtensionsBrowserClient::Get()->IsBackgroundUpdateAllowed()) {
@@ -569,7 +571,7 @@ void ExtensionDownloader::HandleManifestResults(
crx_url = crx_url.ReplaceComponents(replacements);
}
}
- scoped_ptr<ExtensionFetch> fetch(
+ std::unique_ptr<ExtensionFetch> fetch(
new ExtensionFetch(update->extension_id, crx_url, update->package_hash,
update->version, fetch_data->request_ids()));
FetchUpdatedExtension(std::move(fetch));
@@ -656,7 +658,7 @@ void ExtensionDownloader::DetermineUpdates(
// Begins (or queues up) download of an updated extension.
void ExtensionDownloader::FetchUpdatedExtension(
- scoped_ptr<ExtensionFetch> fetch_data) {
+ std::unique_ptr<ExtensionFetch> fetch_data) {
if (!fetch_data->url.is_valid()) {
// TODO(asargent): This can sometimes be invalid. See crbug.com/130881.
DLOG(WARNING) << "Invalid URL: '" << fetch_data->url.possibly_invalid_spec()
@@ -697,7 +699,7 @@ void ExtensionDownloader::FetchUpdatedExtension(
}
void ExtensionDownloader::NotifyDelegateDownloadFinished(
- scoped_ptr<ExtensionFetch> fetch_data,
+ std::unique_ptr<ExtensionFetch> fetch_data,
bool from_cache,
const base::FilePath& crx_path,
bool file_ownership_passed) {
@@ -719,7 +721,7 @@ void ExtensionDownloader::NotifyDelegateDownloadFinished(
}
void ExtensionDownloader::CacheInstallDone(
- scoped_ptr<ExtensionFetch> fetch_data,
+ std::unique_ptr<ExtensionFetch> fetch_data,
bool should_download) {
ping_results_.erase(fetch_data->id);
if (should_download) {
@@ -789,7 +791,7 @@ void ExtensionDownloader::OnCRXFetchComplete(
base::FilePath crx_path;
// Take ownership of the file at |crx_path|.
CHECK(source->GetResponseAsFilePath(true, &crx_path));
- scoped_ptr<ExtensionFetch> fetch_data =
+ std::unique_ptr<ExtensionFetch> fetch_data =
extensions_queue_.reset_active_request();
if (extension_cache_) {
const std::string& version = fetch_data->version;
diff --git a/chromium/extensions/browser/updater/extension_downloader.h b/chromium/extensions/browser/updater/extension_downloader.h
index 81b9134ed0f..b73a92c7185 100644
--- a/chromium/extensions/browser/updater/extension_downloader.h
+++ b/chromium/extensions/browser/updater/extension_downloader.h
@@ -7,6 +7,7 @@
#include <deque>
#include <map>
+#include <memory>
#include <set>
#include <string>
#include <utility>
@@ -15,7 +16,6 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/linked_ptr.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/version.h"
#include "extensions/browser/updater/extension_downloader_delegate.h"
@@ -46,6 +46,7 @@ struct UpdateDetails {
};
class ExtensionCache;
+class ExtensionDownloaderTestDelegate;
class ExtensionUpdaterTest;
// A class that checks for updates of a given list of extensions, and downloads
@@ -57,8 +58,9 @@ class ExtensionDownloader : public net::URLFetcherDelegate,
public:
// A closure which constructs a new ExtensionDownloader to be owned by the
// caller.
- typedef base::Callback<scoped_ptr<ExtensionDownloader>(
- ExtensionDownloaderDelegate* delegate)> Factory;
+ typedef base::Callback<std::unique_ptr<ExtensionDownloader>(
+ ExtensionDownloaderDelegate* delegate)>
+ Factory;
// |delegate| is stored as a raw pointer and must outlive the
// ExtensionDownloader.
@@ -96,7 +98,7 @@ class ExtensionDownloader : public net::URLFetcherDelegate,
// Sets an IdentityProvider to be used for OAuth2 authentication on protected
// Webstore downloads.
void SetWebstoreIdentityProvider(
- scoped_ptr<IdentityProvider> identity_provider);
+ std::unique_ptr<IdentityProvider> identity_provider);
void set_brand_code(const std::string& brand_code) {
brand_code_ = brand_code;
@@ -110,9 +112,9 @@ class ExtensionDownloader : public net::URLFetcherDelegate,
ping_enabled_domain_ = domain;
}
- void set_enable_extra_update_metrics(bool enable) {
- enable_extra_update_metrics_ = enable;
- }
+ // Sets a test delegate to use by any instances of this class. The |delegate|
+ // should outlive all instances.
+ static void set_test_delegate(ExtensionDownloaderTestDelegate* delegate);
// These are needed for unit testing, to help identify the correct mock
// URLFetcher objects.
@@ -188,7 +190,7 @@ class ExtensionDownloader : public net::URLFetcherDelegate,
void ReportStats() const;
// Begins an update check.
- void StartUpdateCheck(scoped_ptr<ManifestFetchData> fetch_data);
+ void StartUpdateCheck(std::unique_ptr<ManifestFetchData> fetch_data);
// Called by RequestQueue when a new manifest fetch request is started.
void CreateManifestFetcher();
@@ -215,7 +217,7 @@ class ExtensionDownloader : public net::URLFetcherDelegate,
std::vector<int>* result);
// Begins (or queues up) download of an updated extension.
- void FetchUpdatedExtension(scoped_ptr<ExtensionFetch> fetch_data);
+ void FetchUpdatedExtension(std::unique_ptr<ExtensionFetch> fetch_data);
// Called by RequestQueue when a new extension fetch request is started.
void CreateExtensionFetcher();
@@ -242,14 +244,16 @@ class ExtensionDownloader : public net::URLFetcherDelegate,
void DoStartAllPending();
// Notify delegate and remove ping results.
- void NotifyDelegateDownloadFinished(scoped_ptr<ExtensionFetch> fetch_data,
- bool from_cache,
- const base::FilePath& crx_path,
- bool file_ownership_passed);
+ void NotifyDelegateDownloadFinished(
+ std::unique_ptr<ExtensionFetch> fetch_data,
+ bool from_cache,
+ const base::FilePath& crx_path,
+ bool file_ownership_passed);
// Cached extension installation completed. If it was not successful, we will
// try to download it from the web store using already fetched manifest.
- void CacheInstallDone(scoped_ptr<ExtensionFetch> fetch_data, bool installed);
+ void CacheInstallDone(std::unique_ptr<ExtensionFetch> fetch_data,
+ bool installed);
// Potentially updates an ExtensionFetch's authentication state and returns
// |true| if the fetch should be retried. Returns |false| if the failure was
@@ -287,8 +291,8 @@ class ExtensionDownloader : public net::URLFetcherDelegate,
FetchMap fetches_preparing_;
// Outstanding url fetch requests for manifests and updates.
- scoped_ptr<net::URLFetcher> manifest_fetcher_;
- scoped_ptr<net::URLFetcher> extension_fetcher_;
+ std::unique_ptr<net::URLFetcher> manifest_fetcher_;
+ std::unique_ptr<net::URLFetcher> extension_fetcher_;
// Pending manifests and extensions to be fetched when the appropriate fetcher
// is available.
@@ -303,14 +307,14 @@ class ExtensionDownloader : public net::URLFetcherDelegate,
// An IdentityProvider which may be used for authentication on protected
// download requests. May be NULL.
- scoped_ptr<IdentityProvider> identity_provider_;
+ std::unique_ptr<IdentityProvider> identity_provider_;
// A Webstore download-scoped access token for the |identity_provider_|'s
// active account, if any.
std::string access_token_;
// A pending token fetch request.
- scoped_ptr<OAuth2TokenService::Request> access_token_request_;
+ std::unique_ptr<OAuth2TokenService::Request> access_token_request_;
// Brand code to include with manifest fetch queries if sending ping data.
std::string brand_code_;
@@ -322,10 +326,6 @@ class ExtensionDownloader : public net::URLFetcherDelegate,
// to update URLs which match this domain. Defaults to empty (no domain).
std::string ping_enabled_domain_;
- // Indicates whether or not extra metrics should be included with ping data.
- // Defaults to |false|.
- bool enable_extra_update_metrics_;
-
// Used to create WeakPtrs to |this|.
base::WeakPtrFactory<ExtensionDownloader> weak_ptr_factory_;
diff --git a/chromium/extensions/browser/updater/extension_downloader_test_delegate.h b/chromium/extensions/browser/updater/extension_downloader_test_delegate.h
new file mode 100644
index 00000000000..64714d6f4d2
--- /dev/null
+++ b/chromium/extensions/browser/updater/extension_downloader_test_delegate.h
@@ -0,0 +1,32 @@
+// 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 EXTENSIONS_BROWSER_UPDATER_EXTENSION_DOWNLOADER_TEST_DELEGATE_H_
+#define EXTENSIONS_BROWSER_UPDATER_EXTENSION_DOWNLOADER_TEST_DELEGATE_H_
+
+#include <memory>
+
+namespace extensions {
+
+class ExtensionDownloader;
+class ExtensionDownloaderDelegate;
+class ManifestFetchData;
+
+// A class for intercepting the work of checking for / downloading extension
+// updates.
+class ExtensionDownloaderTestDelegate {
+ public:
+ // This method gets called when an update check is being started for an
+ // extension. Normally implementors should eventually call either
+ // OnExtensionDownloadFailed or OnExtensionDownloadFinished on
+ // |delegate|.
+ virtual void StartUpdateCheck(
+ ExtensionDownloader* downloader,
+ ExtensionDownloaderDelegate* delegate,
+ std::unique_ptr<ManifestFetchData> fetch_data) = 0;
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_BROWSER_UPDATER_EXTENSION_DOWNLOADER_TEST_DELEGATE_H_
diff --git a/chromium/extensions/browser/updater/request_queue.h b/chromium/extensions/browser/updater/request_queue.h
index cce1a93de1c..1b9c5a45a65 100644
--- a/chromium/extensions/browser/updater/request_queue.h
+++ b/chromium/extensions/browser/updater/request_queue.h
@@ -8,11 +8,11 @@
#include <stddef.h>
#include <deque>
+#include <memory>
#include <utility>
#include "base/callback.h"
#include "base/memory/linked_ptr.h"
-#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "net/base/backoff_entry.h"
@@ -51,11 +51,11 @@ class RequestQueue {
int active_request_failure_count();
// Signals RequestQueue that processing of the current request has completed.
- scoped_ptr<T> reset_active_request();
+ std::unique_ptr<T> reset_active_request();
// Add the given request to the queue, and starts the next request if no
// request is currently being processed.
- void ScheduleRequest(scoped_ptr<T> request);
+ void ScheduleRequest(std::unique_ptr<T> request);
bool empty() const;
size_t size() const;
@@ -93,8 +93,8 @@ class RequestQueue {
static bool CompareRequests(const Request& a, const Request& b);
// Pushes a request with a given backoff entry onto the queue.
- void PushImpl(scoped_ptr<T> request,
- scoped_ptr<net::BackoffEntry> backoff_entry);
+ void PushImpl(std::unique_ptr<T> request,
+ std::unique_ptr<net::BackoffEntry> backoff_entry);
// The backoff policy used to determine backoff delays.
const net::BackoffEntry::Policy* backoff_policy_;
@@ -107,8 +107,8 @@ class RequestQueue {
std::deque<Request> pending_requests_;
// Active request and its associated backoff entry.
- scoped_ptr<T> active_request_;
- scoped_ptr<net::BackoffEntry> active_backoff_entry_;
+ std::unique_ptr<T> active_request_;
+ std::unique_ptr<net::BackoffEntry> active_backoff_entry_;
// Timer to schedule calls to StartNextRequest, if the first pending request
// hasn't passed its release time yet.
diff --git a/chromium/extensions/browser/updater/request_queue_impl.h b/chromium/extensions/browser/updater/request_queue_impl.h
index 24adca6a658..53276398382 100644
--- a/chromium/extensions/browser/updater/request_queue_impl.h
+++ b/chromium/extensions/browser/updater/request_queue_impl.h
@@ -42,21 +42,22 @@ int RequestQueue<T>::active_request_failure_count() {
}
template <typename T>
-scoped_ptr<T> RequestQueue<T>::reset_active_request() {
+std::unique_ptr<T> RequestQueue<T>::reset_active_request() {
active_backoff_entry_.reset();
return std::move(active_request_);
}
template <typename T>
-void RequestQueue<T>::ScheduleRequest(scoped_ptr<T> request) {
- PushImpl(std::move(request), scoped_ptr<net::BackoffEntry>(
+void RequestQueue<T>::ScheduleRequest(std::unique_ptr<T> request) {
+ PushImpl(std::move(request), std::unique_ptr<net::BackoffEntry>(
new net::BackoffEntry(backoff_policy_)));
StartNextRequest();
}
template <typename T>
-void RequestQueue<T>::PushImpl(scoped_ptr<T> request,
- scoped_ptr<net::BackoffEntry> backoff_entry) {
+void RequestQueue<T>::PushImpl(
+ std::unique_ptr<T> request,
+ std::unique_ptr<net::BackoffEntry> backoff_entry) {
pending_requests_.push_back(
Request(backoff_entry.release(), request.release()));
std::push_heap(
diff --git a/chromium/extensions/browser/updater/safe_manifest_parser.h b/chromium/extensions/browser/updater/safe_manifest_parser.h
index b6559834f7e..3f852fe68a5 100644
--- a/chromium/extensions/browser/updater/safe_manifest_parser.h
+++ b/chromium/extensions/browser/updater/safe_manifest_parser.h
@@ -5,11 +5,11 @@
#ifndef EXTENSIONS_BROWSER_UPDATER_SAFE_MANIFEST_PARSER_H_
#define EXTENSIONS_BROWSER_UPDATER_SAFE_MANIFEST_PARSER_H_
+#include <memory>
#include <string>
#include "base/callback.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "content/public/browser/utility_process_host_client.h"
#include "extensions/browser/updater/manifest_fetch_data.h"
#include "extensions/common/update_manifest.h"
diff --git a/chromium/extensions/browser/updater/update_service.h b/chromium/extensions/browser/updater/update_service.h
index 992f55ec4ca..c4c4d77ca3d 100644
--- a/chromium/extensions/browser/updater/update_service.h
+++ b/chromium/extensions/browser/updater/update_service.h
@@ -5,12 +5,12 @@
#ifndef EXTENSIONS_BROWSER_UPDATER_UPDATE_SERVICE_H_
#define EXTENSIONS_BROWSER_UPDATER_UPDATE_SERVICE_H_
+#include <memory>
#include <string>
#include <vector>
#include "base/callback.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "components/keyed_service/core/keyed_service.h"
namespace base {
diff --git a/chromium/extensions/browser/updater/update_service_unittest.cc b/chromium/extensions/browser/updater/update_service_unittest.cc
index eb8213ad6dd..83f42d6c92b 100644
--- a/chromium/extensions/browser/updater/update_service_unittest.cc
+++ b/chromium/extensions/browser/updater/update_service_unittest.cc
@@ -195,7 +195,7 @@ class UpdateServiceTest : public ExtensionsTest {
private:
UpdateService* update_service_;
scoped_refptr<FakeUpdateClient> update_client_;
- scoped_ptr<content::TestBrowserThreadBundle> browser_threads_;
+ std::unique_ptr<content::TestBrowserThreadBundle> browser_threads_;
MockExtensionSystemFactory<FakeExtensionSystem>
fake_extension_system_factory_;
};
@@ -261,7 +261,7 @@ TEST_F(UpdateServiceTest, BasicUpdateOperations) {
// Test the install callback.
base::ScopedTempDir new_version_dir;
ASSERT_TRUE(new_version_dir.CreateUniqueTempDir());
- scoped_ptr<base::DictionaryValue> new_manifest(
+ std::unique_ptr<base::DictionaryValue> new_manifest(
extension1->manifest()->value()->DeepCopy());
new_manifest->SetString("version", "2.0");
diff --git a/chromium/extensions/browser/user_script_loader.cc b/chromium/extensions/browser/user_script_loader.cc
index 91af052718e..b230c4a0bf6 100644
--- a/chromium/extensions/browser/user_script_loader.cc
+++ b/chromium/extensions/browser/user_script_loader.cc
@@ -10,6 +10,7 @@
#include <string>
#include <utility>
+#include "base/memory/ptr_util.h"
#include "base/version.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
@@ -276,7 +277,7 @@ void UserScriptLoader::StartLoad() {
}
// static
-scoped_ptr<base::SharedMemory> UserScriptLoader::Serialize(
+std::unique_ptr<base::SharedMemory> UserScriptLoader::Serialize(
const UserScriptList& scripts) {
base::Pickle pickle;
pickle.WriteUInt32(scripts.size());
@@ -304,10 +305,10 @@ scoped_ptr<base::SharedMemory> UserScriptLoader::Serialize(
options.size = pickle.size();
options.share_read_only = true;
if (!shared_memory.Create(options))
- return scoped_ptr<base::SharedMemory>();
+ return std::unique_ptr<base::SharedMemory>();
if (!shared_memory.Map(pickle.size()))
- return scoped_ptr<base::SharedMemory>();
+ return std::unique_ptr<base::SharedMemory>();
// Copy the pickle to shared memory.
memcpy(shared_memory.memory(), pickle.data(), pickle.size());
@@ -315,10 +316,10 @@ scoped_ptr<base::SharedMemory> UserScriptLoader::Serialize(
base::SharedMemoryHandle readonly_handle;
if (!shared_memory.ShareReadOnlyToProcess(base::GetCurrentProcessHandle(),
&readonly_handle))
- return scoped_ptr<base::SharedMemory>();
+ return std::unique_ptr<base::SharedMemory>();
- return make_scoped_ptr(new base::SharedMemory(readonly_handle,
- /*read_only=*/true));
+ return base::WrapUnique(new base::SharedMemory(readonly_handle,
+ /*read_only=*/true));
}
void UserScriptLoader::AddObserver(Observer* observer) {
@@ -337,8 +338,8 @@ void UserScriptLoader::SetReady(bool ready) {
}
void UserScriptLoader::OnScriptsLoaded(
- scoped_ptr<UserScriptList> user_scripts,
- scoped_ptr<base::SharedMemory> shared_memory) {
+ std::unique_ptr<UserScriptList> user_scripts,
+ std::unique_ptr<base::SharedMemory> shared_memory) {
user_scripts_.reset(user_scripts.release());
if (pending_load_) {
// While we were loading, there were further changes. Don't bother
diff --git a/chromium/extensions/browser/user_script_loader.h b/chromium/extensions/browser/user_script_loader.h
index ff6772aa9b0..daab8a769f8 100644
--- a/chromium/extensions/browser/user_script_loader.h
+++ b/chromium/extensions/browser/user_script_loader.h
@@ -6,11 +6,11 @@
#define EXTENSIONS_BROWSER_USER_SCRIPT_LOADER_H_
#include <map>
+#include <memory>
#include <set>
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/shared_memory.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
@@ -41,8 +41,8 @@ namespace extensions {
class UserScriptLoader : public content::NotificationObserver {
public:
using LoadScriptsCallback =
- base::Callback<void(scoped_ptr<UserScriptList>,
- scoped_ptr<base::SharedMemory>)>;
+ base::Callback<void(std::unique_ptr<UserScriptList>,
+ std::unique_ptr<base::SharedMemory>)>;
class Observer {
public:
virtual void OnScriptsLoaded(UserScriptLoader* loader) = 0;
@@ -83,7 +83,7 @@ class UserScriptLoader : public content::NotificationObserver {
bool scripts_ready() const { return shared_memory_.get() != NULL; }
// Pickle user scripts and return pointer to the shared memory.
- static scoped_ptr<base::SharedMemory> Serialize(
+ static std::unique_ptr<base::SharedMemory> Serialize(
const extensions::UserScriptList& scripts);
// Adds or removes observers.
@@ -92,7 +92,7 @@ class UserScriptLoader : public content::NotificationObserver {
protected:
// Allows the derived classes have different ways to load user scripts.
- virtual void LoadScripts(scoped_ptr<UserScriptList> user_scripts,
+ virtual void LoadScripts(std::unique_ptr<UserScriptList> user_scripts,
const std::set<HostID>& changed_hosts,
const std::set<int>& added_script_ids,
LoadScriptsCallback callback) = 0;
@@ -119,8 +119,8 @@ class UserScriptLoader : public content::NotificationObserver {
void AttemptLoad();
// Called once we have finished loading the scripts on the file thread.
- void OnScriptsLoaded(scoped_ptr<UserScriptList> user_scripts,
- scoped_ptr<base::SharedMemory> shared_memory);
+ void OnScriptsLoaded(std::unique_ptr<UserScriptList> user_scripts,
+ std::unique_ptr<base::SharedMemory> shared_memory);
// Sends the renderer process a new set of user scripts. If
// |changed_hosts| is not empty, this signals that only the scripts from
@@ -139,10 +139,10 @@ class UserScriptLoader : public content::NotificationObserver {
content::NotificationRegistrar registrar_;
// Contains the scripts that were found the last time scripts were updated.
- scoped_ptr<base::SharedMemory> shared_memory_;
+ std::unique_ptr<base::SharedMemory> shared_memory_;
// List of scripts from currently-installed extensions we should load.
- scoped_ptr<UserScriptList> user_scripts_;
+ std::unique_ptr<UserScriptList> user_scripts_;
// The mutually-exclusive sets of scripts that were added or removed since the
// last script load.
diff --git a/chromium/extensions/browser/value_store/lazy_leveldb.cc b/chromium/extensions/browser/value_store/lazy_leveldb.cc
index 6061bd32b1b..8176b8395f2 100644
--- a/chromium/extensions/browser/value_store/lazy_leveldb.cc
+++ b/chromium/extensions/browser/value_store/lazy_leveldb.cc
@@ -6,6 +6,7 @@
#include "base/files/file_util.h"
#include "base/json/json_reader.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/string_util.h"
#include "content/public/browser/browser_thread.h"
#include "third_party/leveldatabase/env_chromium.h"
@@ -90,7 +91,7 @@ LazyLevelDb::~LazyLevelDb() {
}
ValueStore::Status LazyLevelDb::Read(const std::string& key,
- scoped_ptr<base::Value>* value) {
+ std::unique_ptr<base::Value>* value) {
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
DCHECK(value);
@@ -106,7 +107,8 @@ ValueStore::Status LazyLevelDb::Read(const std::string& key,
if (!s.ok())
return ToValueStoreError(s);
- scoped_ptr<base::Value> val = base::JSONReader().ReadToValue(value_as_json);
+ std::unique_ptr<base::Value> val =
+ base::JSONReader().ReadToValue(value_as_json);
if (!val)
return ValueStore::Status(ValueStore::CORRUPTION, FixCorruption(&key),
kInvalidJson);
@@ -274,10 +276,10 @@ bool LazyLevelDb::DeleteDbFile() {
ValueStore::Status LazyLevelDb::CreateIterator(
const leveldb::ReadOptions& read_options,
- scoped_ptr<leveldb::Iterator>* iterator) {
+ std::unique_ptr<leveldb::Iterator>* iterator) {
ValueStore::Status status = EnsureDbIsOpen();
if (!status.ok())
return status;
- *iterator = make_scoped_ptr(db_->NewIterator(read_options));
+ *iterator = base::WrapUnique(db_->NewIterator(read_options));
return ValueStore::Status();
}
diff --git a/chromium/extensions/browser/value_store/lazy_leveldb.h b/chromium/extensions/browser/value_store/lazy_leveldb.h
index 4fb93a63d71..551a6ea23fd 100644
--- a/chromium/extensions/browser/value_store/lazy_leveldb.h
+++ b/chromium/extensions/browser/value_store/lazy_leveldb.h
@@ -5,11 +5,11 @@
#ifndef EXTENSIONS_BROWSER_VALUE_STORE_LAZY_LEVELDB_H_
#define EXTENSIONS_BROWSER_VALUE_STORE_LAZY_LEVELDB_H_
+#include <memory>
#include <string>
#include "base/files/file_path.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram_base.h"
#include "extensions/browser/value_store/value_store.h"
#include "third_party/leveldatabase/src/include/leveldb/db.h"
@@ -26,8 +26,9 @@ class LazyLevelDb {
public:
// Creates a new database iterator. This iterator *must* be deleted before
// this database is closed.
- ValueStore::Status CreateIterator(const leveldb::ReadOptions& read_options,
- scoped_ptr<leveldb::Iterator>* iterator);
+ ValueStore::Status CreateIterator(
+ const leveldb::ReadOptions& read_options,
+ std::unique_ptr<leveldb::Iterator>* iterator);
// Converts a leveldb::Status to a ValueStore::Status. Will also sanitize path
// to eliminate user data path.
@@ -53,7 +54,7 @@ class LazyLevelDb {
// be returned and value will be unchanged. Caller must ensure the database is
// open before calling this method.
ValueStore::Status Read(const std::string& key,
- scoped_ptr<base::Value>* value);
+ std::unique_ptr<base::Value>* value);
// Opens the underlying database if not yet open. If the open fails due to
// corruption will attempt to repair the database. Failing that, will attempt
@@ -75,7 +76,7 @@ class LazyLevelDb {
ValueStore::BackingStoreRestoreStatus restore_status) const;
// The leveldb to which this class reads/writes.
- scoped_ptr<leveldb::DB> db_;
+ std::unique_ptr<leveldb::DB> db_;
// The path to the underlying leveldb.
const base::FilePath db_path_;
// The options to be used when this database is lazily opened.
diff --git a/chromium/extensions/browser/value_store/legacy_value_store_factory.cc b/chromium/extensions/browser/value_store/legacy_value_store_factory.cc
index bafb93ee2a3..d4f054532b9 100644
--- a/chromium/extensions/browser/value_store/legacy_value_store_factory.cc
+++ b/chromium/extensions/browser/value_store/legacy_value_store_factory.cc
@@ -8,6 +8,7 @@
#include "base/files/file_enumerator.h"
#include "base/files/file_util.h"
+#include "base/memory/ptr_util.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/value_store/leveldb_value_store.h"
#include "extensions/common/constants.h"
@@ -167,24 +168,24 @@ bool LegacyValueStoreFactory::StateDBExists() const {
return ValidDBExists(GetStateDBPath());
}
-scoped_ptr<ValueStore> LegacyValueStoreFactory::CreateRulesStore() {
- return make_scoped_ptr(
+std::unique_ptr<ValueStore> LegacyValueStoreFactory::CreateRulesStore() {
+ return base::WrapUnique(
new LeveldbValueStore(kRulesDatabaseUMAClientName, GetRulesDBPath()));
}
-scoped_ptr<ValueStore> LegacyValueStoreFactory::CreateStateStore() {
- return make_scoped_ptr(
+std::unique_ptr<ValueStore> LegacyValueStoreFactory::CreateStateStore() {
+ return base::WrapUnique(
new LeveldbValueStore(kStateDatabaseUMAClientName, GetStateDBPath()));
}
-scoped_ptr<ValueStore> LegacyValueStoreFactory::CreateSettingsStore(
+std::unique_ptr<ValueStore> LegacyValueStoreFactory::CreateSettingsStore(
settings_namespace::Namespace settings_namespace,
ModelType model_type,
const ExtensionId& extension_id) {
const ModelSettings* settings_root =
GetSettingsRoot(settings_namespace).GetModel(model_type);
DCHECK(settings_root != nullptr);
- return make_scoped_ptr(new LeveldbValueStore(
+ return base::WrapUnique(new LeveldbValueStore(
kSettingsDatabaseUMAClientName, settings_root->GetDBPath(extension_id)));
}
diff --git a/chromium/extensions/browser/value_store/legacy_value_store_factory.h b/chromium/extensions/browser/value_store/legacy_value_store_factory.h
index 65db0275a71..59517543b6b 100644
--- a/chromium/extensions/browser/value_store/legacy_value_store_factory.h
+++ b/chromium/extensions/browser/value_store/legacy_value_store_factory.h
@@ -5,12 +5,12 @@
#ifndef EXTENSIONS_BROWSER_VALUE_STORE_LEGACY_VALUE_STORE_FACTORY_H_
#define EXTENSIONS_BROWSER_VALUE_STORE_LEGACY_VALUE_STORE_FACTORY_H_
+#include <memory>
#include <set>
#include <string>
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/browser/value_store/value_store.h"
#include "extensions/browser/value_store/value_store_factory.h"
#include "extensions/common/extension.h"
@@ -28,9 +28,9 @@ class LegacyValueStoreFactory : public ValueStoreFactory {
bool StateDBExists() const;
// ValueStoreFactory:
- scoped_ptr<ValueStore> CreateRulesStore() override;
- scoped_ptr<ValueStore> CreateStateStore() override;
- scoped_ptr<ValueStore> CreateSettingsStore(
+ std::unique_ptr<ValueStore> CreateRulesStore() override;
+ std::unique_ptr<ValueStore> CreateStateStore() override;
+ std::unique_ptr<ValueStore> CreateSettingsStore(
settings_namespace::Namespace settings_namespace,
ModelType model_type,
const ExtensionId& extension_id) override;
@@ -82,8 +82,8 @@ class LegacyValueStoreFactory : public ValueStoreFactory {
ModelSettings* GetModel(ModelType model_type);
private:
- scoped_ptr<ModelSettings> extensions_;
- scoped_ptr<ModelSettings> apps_;
+ std::unique_ptr<ModelSettings> extensions_;
+ std::unique_ptr<ModelSettings> apps_;
DISALLOW_COPY_AND_ASSIGN(SettingsRoot);
};
diff --git a/chromium/extensions/browser/value_store/leveldb_scoped_database.cc b/chromium/extensions/browser/value_store/leveldb_scoped_database.cc
index 2fb8a9b77ea..a66e53aa3d2 100644
--- a/chromium/extensions/browser/value_store/leveldb_scoped_database.cc
+++ b/chromium/extensions/browser/value_store/leveldb_scoped_database.cc
@@ -49,9 +49,10 @@ LeveldbScopedDatabase::LeveldbScopedDatabase(const std::string& uma_client_name,
LeveldbScopedDatabase::~LeveldbScopedDatabase() {}
-ValueStore::Status LeveldbScopedDatabase::Read(const std::string& scope,
- const std::string& key,
- scoped_ptr<base::Value>* value) {
+ValueStore::Status LeveldbScopedDatabase::Read(
+ const std::string& scope,
+ const std::string& key,
+ std::unique_ptr<base::Value>* value) {
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
ValueStore::Status status = EnsureDbIsOpen();
@@ -76,16 +77,16 @@ ValueStore::Status LeveldbScopedDatabase::Read(const std::string& scope,
if (!CreateKey(scope, "", &prefix))
return ValueStore::Status(ValueStore::OTHER_ERROR, kInvalidScope);
- scoped_ptr<leveldb::Iterator> it(db()->NewIterator(read_options()));
+ std::unique_ptr<leveldb::Iterator> it(db()->NewIterator(read_options()));
base::JSONReader json_reader;
- scoped_ptr<base::DictionaryValue> settings(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> settings(new base::DictionaryValue());
for (it->Seek(prefix); it->Valid() && it->key().starts_with(prefix);
it->Next()) {
leveldb::Slice descoped_key(it->key());
descoped_key.remove_prefix(prefix.size());
- scoped_ptr<base::Value> value = json_reader.Read(
+ std::unique_ptr<base::Value> value = json_reader.Read(
base::StringPiece(it->value().data(), it->value().size()));
if (!value) {
return ValueStore::Status(ValueStore::CORRUPTION,
diff --git a/chromium/extensions/browser/value_store/leveldb_scoped_database.h b/chromium/extensions/browser/value_store/leveldb_scoped_database.h
index ef52f1d7769..46f59943ff4 100644
--- a/chromium/extensions/browser/value_store/leveldb_scoped_database.h
+++ b/chromium/extensions/browser/value_store/leveldb_scoped_database.h
@@ -46,7 +46,7 @@ class LeveldbScopedDatabase
// Reads a single |value| from the database for the specified |key|.
ValueStore::Status Read(const std::string& scope,
const std::string& key,
- scoped_ptr<base::Value>* value);
+ std::unique_ptr<base::Value>* value);
// Reads all |values| from the database stored within the specified |scope|.
ValueStore::Status Read(const std::string& scope,
diff --git a/chromium/extensions/browser/value_store/leveldb_scoped_database_unittest.cc b/chromium/extensions/browser/value_store/leveldb_scoped_database_unittest.cc
index 738802bfc98..21cbdbc0fd5 100644
--- a/chromium/extensions/browser/value_store/leveldb_scoped_database_unittest.cc
+++ b/chromium/extensions/browser/value_store/leveldb_scoped_database_unittest.cc
@@ -41,7 +41,7 @@ class LeveldbScopedDatabaseUnitTest : public testing::Test {
values->clear();
leveldb::ReadOptions read_options;
read_options.verify_checksums = true;
- scoped_ptr<leveldb::Iterator> iterator;
+ std::unique_ptr<leveldb::Iterator> iterator;
ValueStore::Status status = db_->CreateIterator(read_options, &iterator);
if (!status.ok())
return status;
@@ -159,7 +159,7 @@ TEST_F(LeveldbScopedDatabaseUnitTest, TestEmptyValue) {
values.SetString("s1_key1", "");
EXPECT_TRUE(db_->Write("scope1", values).ok());
- scoped_ptr<base::Value> value;
+ std::unique_ptr<base::Value> value;
ASSERT_TRUE(db_->Read("scope1", "s1_key1", &value).ok());
std::string str;
EXPECT_TRUE(value->GetAsString(&str));
@@ -171,7 +171,7 @@ TEST_F(LeveldbScopedDatabaseUnitTest, TestValueContainingDelimiter) {
values.SetString("s1_key1", "with:delimiter");
EXPECT_TRUE(db_->Write("scope1", values).ok());
- scoped_ptr<base::Value> value;
+ std::unique_ptr<base::Value> value;
ASSERT_TRUE(db_->Read("scope1", "s1_key1", &value).ok());
std::string str;
EXPECT_TRUE(value->GetAsString(&str));
diff --git a/chromium/extensions/browser/value_store/leveldb_value_store.cc b/chromium/extensions/browser/value_store/leveldb_value_store.cc
index a65aa8b85b9..6610652e3e7 100644
--- a/chromium/extensions/browser/value_store/leveldb_value_store.cc
+++ b/chromium/extensions/browser/value_store/leveldb_value_store.cc
@@ -17,7 +17,7 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/process_memory_dump.h"
#include "content/public/browser/browser_thread.h"
@@ -79,10 +79,10 @@ ValueStore::ReadResult LeveldbValueStore::Get(
if (!status.ok())
return MakeReadResult(status);
- scoped_ptr<base::DictionaryValue> settings(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> settings(new base::DictionaryValue());
for (const std::string& key : keys) {
- scoped_ptr<base::Value> setting;
+ std::unique_ptr<base::Value> setting;
status.Merge(Read(key, &setting));
if (!status.ok())
return MakeReadResult(status);
@@ -101,12 +101,12 @@ ValueStore::ReadResult LeveldbValueStore::Get() {
return MakeReadResult(status);
base::JSONReader json_reader;
- scoped_ptr<base::DictionaryValue> settings(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> settings(new base::DictionaryValue());
- scoped_ptr<leveldb::Iterator> it(db()->NewIterator(read_options()));
+ std::unique_ptr<leveldb::Iterator> it(db()->NewIterator(read_options()));
for (it->SeekToFirst(); it->Valid(); it->Next()) {
std::string key = it->key().ToString();
- scoped_ptr<base::Value> value =
+ std::unique_ptr<base::Value> value =
json_reader.Read(StringPiece(it->value().data(), it->value().size()));
if (!value) {
return MakeReadResult(
@@ -135,7 +135,7 @@ ValueStore::WriteResult LeveldbValueStore::Set(WriteOptions options,
return MakeWriteResult(status);
leveldb::WriteBatch batch;
- scoped_ptr<ValueStoreChangeList> changes(new ValueStoreChangeList());
+ std::unique_ptr<ValueStoreChangeList> changes(new ValueStoreChangeList());
status.Merge(AddToBatch(options, key, value, &batch, changes.get()));
if (!status.ok())
return MakeWriteResult(status);
@@ -155,7 +155,7 @@ ValueStore::WriteResult LeveldbValueStore::Set(
return MakeWriteResult(status);
leveldb::WriteBatch batch;
- scoped_ptr<ValueStoreChangeList> changes(new ValueStoreChangeList());
+ std::unique_ptr<ValueStoreChangeList> changes(new ValueStoreChangeList());
for (base::DictionaryValue::Iterator it(settings);
!it.IsAtEnd(); it.Advance()) {
@@ -184,16 +184,16 @@ ValueStore::WriteResult LeveldbValueStore::Remove(
return MakeWriteResult(status);
leveldb::WriteBatch batch;
- scoped_ptr<ValueStoreChangeList> changes(new ValueStoreChangeList());
+ std::unique_ptr<ValueStoreChangeList> changes(new ValueStoreChangeList());
for (const std::string& key : keys) {
- scoped_ptr<base::Value> old_value;
+ std::unique_ptr<base::Value> old_value;
status.Merge(Read(key, &old_value));
if (!status.ok())
return MakeWriteResult(status);
if (old_value) {
- changes->push_back(ValueStoreChange(key, old_value.release(), NULL));
+ changes->push_back(ValueStoreChange(key, std::move(old_value), nullptr));
batch.Delete(key);
}
}
@@ -209,7 +209,7 @@ ValueStore::WriteResult LeveldbValueStore::Remove(
ValueStore::WriteResult LeveldbValueStore::Clear() {
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
- scoped_ptr<ValueStoreChangeList> changes(new ValueStoreChangeList());
+ std::unique_ptr<ValueStoreChangeList> changes(new ValueStoreChangeList());
ReadResult read_result = Get();
if (!read_result->status().ok())
@@ -218,9 +218,10 @@ ValueStore::WriteResult LeveldbValueStore::Clear() {
base::DictionaryValue& whole_db = read_result->settings();
while (!whole_db.empty()) {
std::string next_key = base::DictionaryValue::Iterator(whole_db).key();
- scoped_ptr<base::Value> next_value;
+ std::unique_ptr<base::Value> next_value;
whole_db.RemoveWithoutPathExpansion(next_key, &next_value);
- changes->push_back(ValueStoreChange(next_key, next_value.release(), NULL));
+ changes->push_back(
+ ValueStoreChange(next_key, std::move(next_value), nullptr));
}
DeleteDbFile();
@@ -274,13 +275,13 @@ ValueStore::Status LeveldbValueStore::AddToBatch(
bool write_new_value = true;
if (!(options & NO_GENERATE_CHANGES)) {
- scoped_ptr<base::Value> old_value;
+ std::unique_ptr<base::Value> old_value;
Status status = Read(key, &old_value);
if (!status.ok())
return status;
if (!old_value || !old_value->Equals(&value)) {
changes->push_back(
- ValueStoreChange(key, old_value.release(), value.DeepCopy()));
+ ValueStoreChange(key, std::move(old_value), value.CreateDeepCopy()));
} else {
write_new_value = false;
}
diff --git a/chromium/extensions/browser/value_store/leveldb_value_store.h b/chromium/extensions/browser/value_store/leveldb_value_store.h
index 41e91a3c3fc..a9f5b59d009 100644
--- a/chromium/extensions/browser/value_store/leveldb_value_store.h
+++ b/chromium/extensions/browser/value_store/leveldb_value_store.h
@@ -7,13 +7,13 @@
#include <stddef.h>
+#include <memory>
#include <string>
#include <vector>
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/trace_event/memory_dump_provider.h"
#include "extensions/browser/value_store/lazy_leveldb.h"
#include "extensions/browser/value_store/value_store.h"
diff --git a/chromium/extensions/browser/value_store/leveldb_value_store_unittest.cc b/chromium/extensions/browser/value_store/leveldb_value_store_unittest.cc
index cf532240417..b8b76c1d027 100644
--- a/chromium/extensions/browser/value_store/leveldb_value_store_unittest.cc
+++ b/chromium/extensions/browser/value_store/leveldb_value_store_unittest.cc
@@ -63,7 +63,7 @@ class LeveldbValueStoreUnitTest : public testing::Test {
const base::FilePath& database_path() { return database_dir_.path(); }
private:
- scoped_ptr<LeveldbValueStore> store_;
+ std::unique_ptr<LeveldbValueStore> store_;
base::ScopedTempDir database_dir_;
content::TestBrowserThreadBundle thread_bundle_;
@@ -75,7 +75,7 @@ TEST_F(LeveldbValueStoreUnitTest, RestoreKeyTest) {
const char kValue[] = "value";
// Insert a valid pair.
- scoped_ptr<base::Value> value(new base::StringValue(kValue));
+ std::unique_ptr<base::Value> value(new base::StringValue(kValue));
ASSERT_TRUE(store()
->Set(ValueStore::DEFAULTS, kNotCorruptKey, *value)
->status().ok());
@@ -117,7 +117,7 @@ TEST_F(LeveldbValueStoreUnitTest, RestoreDoesMinimumNecessary) {
const char kCorruptValue[] = "[{(.*+\"\'\\";
// Insert a collection of non-corrupted pairs.
- scoped_ptr<base::Value> value(new base::StringValue(kValue));
+ std::unique_ptr<base::Value> value(new base::StringValue(kValue));
for (size_t i = 0; i < kNotCorruptKeysSize; ++i) {
ASSERT_TRUE(store()
->Set(ValueStore::DEFAULTS, kNotCorruptKeys[i], *value)
@@ -163,7 +163,7 @@ TEST_F(LeveldbValueStoreUnitTest, RestoreFullDatabase) {
const char kValue[] = "value";
// Generate a database.
- scoped_ptr<base::Value> value(new base::StringValue(kValue));
+ std::unique_ptr<base::Value> value(new base::StringValue(kValue));
for (size_t i = 0; i < kNotCorruptKeysSize; ++i) {
ASSERT_TRUE(store()
->Set(ValueStore::DEFAULTS, kNotCorruptKeys[i], *value)
diff --git a/chromium/extensions/browser/value_store/test_value_store_factory.cc b/chromium/extensions/browser/value_store/test_value_store_factory.cc
index f5135dfa16c..de75f953882 100644
--- a/chromium/extensions/browser/value_store/test_value_store_factory.cc
+++ b/chromium/extensions/browser/value_store/test_value_store_factory.cc
@@ -4,6 +4,7 @@
#include "extensions/browser/value_store/test_value_store_factory.h"
+#include "base/memory/ptr_util.h"
#include "extensions/browser/value_store/leveldb_value_store.h"
#include "extensions/browser/value_store/testing_value_store.h"
@@ -101,15 +102,15 @@ TestValueStoreFactory::TestValueStoreFactory(const base::FilePath& db_path)
TestValueStoreFactory::~TestValueStoreFactory() {}
-scoped_ptr<ValueStore> TestValueStoreFactory::CreateRulesStore() {
+std::unique_ptr<ValueStore> TestValueStoreFactory::CreateRulesStore() {
if (db_path_.empty())
last_created_store_ = new TestingValueStore();
else
last_created_store_ = new LeveldbValueStore(kUMAClientName, db_path_);
- return make_scoped_ptr(last_created_store_);
+ return base::WrapUnique(last_created_store_);
}
-scoped_ptr<ValueStore> TestValueStoreFactory::CreateStateStore() {
+std::unique_ptr<ValueStore> TestValueStoreFactory::CreateStateStore() {
return CreateRulesStore();
}
@@ -129,11 +130,11 @@ TestValueStoreFactory::StorageHelper& TestValueStoreFactory::GetStorageHelper(
return local_helper_;
}
-scoped_ptr<ValueStore> TestValueStoreFactory::CreateSettingsStore(
+std::unique_ptr<ValueStore> TestValueStoreFactory::CreateSettingsStore(
SettingsNamespace settings_namespace,
ModelType model_type,
const ExtensionId& extension_id) {
- scoped_ptr<ValueStore> settings_store(CreateRulesStore());
+ std::unique_ptr<ValueStore> settings_store(CreateRulesStore());
// Note: This factory is purposely keeping the raw pointers to each ValueStore
// created. Tests using TestValueStoreFactory must be careful to keep
// those ValueStore's alive for the duration of their test.
diff --git a/chromium/extensions/browser/value_store/test_value_store_factory.h b/chromium/extensions/browser/value_store/test_value_store_factory.h
index 86fbee77c8a..28cd1ddc9b0 100644
--- a/chromium/extensions/browser/value_store/test_value_store_factory.h
+++ b/chromium/extensions/browser/value_store/test_value_store_factory.h
@@ -6,9 +6,9 @@
#define EXTENSIONS_BROWSER_VALUE_STORE_TEST_VALUE_STORE_FACTORY_H_
#include <map>
+#include <memory>
#include <set>
-#include "base/memory/scoped_ptr.h"
#include "extensions/browser/value_store/value_store_factory.h"
#include "extensions/common/extension.h"
@@ -25,9 +25,9 @@ class TestValueStoreFactory : public ValueStoreFactory {
explicit TestValueStoreFactory(const base::FilePath& db_path);
// ValueStoreFactory
- scoped_ptr<ValueStore> CreateRulesStore() override;
- scoped_ptr<ValueStore> CreateStateStore() override;
- scoped_ptr<ValueStore> CreateSettingsStore(
+ std::unique_ptr<ValueStore> CreateRulesStore() override;
+ std::unique_ptr<ValueStore> CreateStateStore() override;
+ std::unique_ptr<ValueStore> CreateSettingsStore(
settings_namespace::Namespace settings_namespace,
ModelType model_type,
const ExtensionId& extension_id) override;
diff --git a/chromium/extensions/browser/value_store/testing_value_store.cc b/chromium/extensions/browser/value_store/testing_value_store.cc
index fee2aa0f096..039d6c8bbde 100644
--- a/chromium/extensions/browser/value_store/testing_value_store.cc
+++ b/chromium/extensions/browser/value_store/testing_value_store.cc
@@ -7,6 +7,7 @@
#include <utility>
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
namespace {
@@ -56,23 +57,23 @@ ValueStore::ReadResult TestingValueStore::Get(
it != keys.end(); ++it) {
base::Value* value = NULL;
if (storage_.GetWithoutPathExpansion(*it, &value)) {
- settings->SetWithoutPathExpansion(*it, value->DeepCopy());
+ settings->SetWithoutPathExpansion(*it, value->CreateDeepCopy());
}
}
- return MakeReadResult(make_scoped_ptr(settings), status_);
+ return MakeReadResult(base::WrapUnique(settings), status_);
}
ValueStore::ReadResult TestingValueStore::Get() {
read_count_++;
if (!status_.ok())
return MakeReadResult(status_);
- return MakeReadResult(make_scoped_ptr(storage_.DeepCopy()), status_);
+ return MakeReadResult(storage_.CreateDeepCopy(), status_);
}
ValueStore::WriteResult TestingValueStore::Set(
WriteOptions options, const std::string& key, const base::Value& value) {
base::DictionaryValue settings;
- settings.SetWithoutPathExpansion(key, value.DeepCopy());
+ settings.SetWithoutPathExpansion(key, value.CreateDeepCopy());
return Set(options, settings);
}
@@ -82,18 +83,16 @@ ValueStore::WriteResult TestingValueStore::Set(
if (!status_.ok())
return MakeWriteResult(status_);
- scoped_ptr<ValueStoreChangeList> changes(new ValueStoreChangeList());
+ std::unique_ptr<ValueStoreChangeList> changes(new ValueStoreChangeList());
for (base::DictionaryValue::Iterator it(settings);
!it.IsAtEnd(); it.Advance()) {
base::Value* old_value = NULL;
if (!storage_.GetWithoutPathExpansion(it.key(), &old_value) ||
!old_value->Equals(&it.value())) {
- changes->push_back(
- ValueStoreChange(
- it.key(),
- old_value ? old_value->DeepCopy() : old_value,
- it.value().DeepCopy()));
- storage_.SetWithoutPathExpansion(it.key(), it.value().DeepCopy());
+ changes->push_back(ValueStoreChange(
+ it.key(), old_value ? old_value->CreateDeepCopy() : nullptr,
+ it.value().CreateDeepCopy()));
+ storage_.SetWithoutPathExpansion(it.key(), it.value().CreateDeepCopy());
}
}
return MakeWriteResult(std::move(changes), status_);
@@ -109,12 +108,12 @@ ValueStore::WriteResult TestingValueStore::Remove(
if (!status_.ok())
return MakeWriteResult(status_);
- scoped_ptr<ValueStoreChangeList> changes(new ValueStoreChangeList());
+ std::unique_ptr<ValueStoreChangeList> changes(new ValueStoreChangeList());
for (std::vector<std::string>::const_iterator it = keys.begin();
it != keys.end(); ++it) {
- scoped_ptr<base::Value> old_value;
+ std::unique_ptr<base::Value> old_value;
if (storage_.RemoveWithoutPathExpansion(*it, &old_value)) {
- changes->push_back(ValueStoreChange(*it, old_value.release(), NULL));
+ changes->push_back(ValueStoreChange(*it, std::move(old_value), nullptr));
}
}
return MakeWriteResult(std::move(changes), status_);
diff --git a/chromium/extensions/browser/value_store/value_store.cc b/chromium/extensions/browser/value_store/value_store.cc
index c198f105566..aa1588b7eab 100644
--- a/chromium/extensions/browser/value_store/value_store.cc
+++ b/chromium/extensions/browser/value_store/value_store.cc
@@ -34,7 +34,7 @@ void ValueStore::Status::Merge(const Status& status) {
// Implementation of ReadResultType.
ValueStore::ReadResultType::ReadResultType(
- scoped_ptr<base::DictionaryValue> settings,
+ std::unique_ptr<base::DictionaryValue> settings,
const Status& status)
: settings_(std::move(settings)), status_(status) {
CHECK(settings_);
@@ -48,7 +48,7 @@ ValueStore::ReadResultType::~ReadResultType() {}
// Implementation of WriteResultType.
ValueStore::WriteResultType::WriteResultType(
- scoped_ptr<ValueStoreChangeList> changes,
+ std::unique_ptr<ValueStoreChangeList> changes,
const Status& status)
: changes_(std::move(changes)), status_(status) {
CHECK(changes_);
diff --git a/chromium/extensions/browser/value_store/value_store.h b/chromium/extensions/browser/value_store/value_store.h
index b6aa0bab5d7..2e9d1506b70 100644
--- a/chromium/extensions/browser/value_store/value_store.h
+++ b/chromium/extensions/browser/value_store/value_store.h
@@ -7,12 +7,12 @@
#include <stddef.h>
+#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "extensions/browser/value_store/value_store_change.h"
@@ -88,7 +88,7 @@ class ValueStore {
// The result of a read operation (Get).
class ReadResultType {
public:
- ReadResultType(scoped_ptr<base::DictionaryValue> settings,
+ ReadResultType(std::unique_ptr<base::DictionaryValue> settings,
const Status& status);
explicit ReadResultType(const Status& status);
~ReadResultType();
@@ -99,24 +99,24 @@ class ValueStore {
//
// Must only be called if there is no error.
base::DictionaryValue& settings() { return *settings_; }
- scoped_ptr<base::DictionaryValue> PassSettings() {
+ std::unique_ptr<base::DictionaryValue> PassSettings() {
return std::move(settings_);
}
const Status& status() const { return status_; }
private:
- scoped_ptr<base::DictionaryValue> settings_;
+ std::unique_ptr<base::DictionaryValue> settings_;
Status status_;
DISALLOW_COPY_AND_ASSIGN(ReadResultType);
};
- typedef scoped_ptr<ReadResultType> ReadResult;
+ typedef std::unique_ptr<ReadResultType> ReadResult;
// The result of a write operation (Set/Remove/Clear).
class WriteResultType {
public:
- WriteResultType(scoped_ptr<ValueStoreChangeList> changes,
+ WriteResultType(std::unique_ptr<ValueStoreChangeList> changes,
const Status& status);
explicit WriteResultType(const Status& status);
~WriteResultType();
@@ -125,19 +125,19 @@ class ValueStore {
// Won't be present if the NO_GENERATE_CHANGES WriteOptions was given.
// Only call if no error.
ValueStoreChangeList& changes() { return *changes_; }
- scoped_ptr<ValueStoreChangeList> PassChanges() {
+ std::unique_ptr<ValueStoreChangeList> PassChanges() {
return std::move(changes_);
}
const Status& status() const { return status_; }
private:
- scoped_ptr<ValueStoreChangeList> changes_;
+ std::unique_ptr<ValueStoreChangeList> changes_;
Status status_;
DISALLOW_COPY_AND_ASSIGN(WriteResultType);
};
- typedef scoped_ptr<WriteResultType> WriteResult;
+ typedef std::unique_ptr<WriteResultType> WriteResult;
// Options for write operations.
enum WriteOptionsValues {
@@ -156,7 +156,8 @@ class ValueStore {
// Helpers for making a Read/WriteResult.
template <typename T>
- static ReadResult MakeReadResult(scoped_ptr<T> arg, const Status& status) {
+ static ReadResult MakeReadResult(std::unique_ptr<T> arg,
+ const Status& status) {
return ReadResult(new ReadResultType(std::move(arg), status));
}
static ReadResult MakeReadResult(const Status& status) {
@@ -164,7 +165,8 @@ class ValueStore {
}
template <typename T>
- static WriteResult MakeWriteResult(scoped_ptr<T> arg, const Status& status) {
+ static WriteResult MakeWriteResult(std::unique_ptr<T> arg,
+ const Status& status) {
return WriteResult(new WriteResultType(std::move(arg), status));
}
static WriteResult MakeWriteResult(const Status& status) {
diff --git a/chromium/extensions/browser/value_store/value_store_change.cc b/chromium/extensions/browser/value_store/value_store_change.cc
index 3bbad592d06..423eb065ade 100644
--- a/chromium/extensions/browser/value_store/value_store_change.cc
+++ b/chromium/extensions/browser/value_store/value_store_change.cc
@@ -4,8 +4,11 @@
#include "extensions/browser/value_store/value_store_change.h"
+#include <utility>
+
#include "base/json/json_writer.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
// static
std::string ValueStoreChange::ToJson(
@@ -27,9 +30,10 @@ std::string ValueStoreChange::ToJson(
return json;
}
-ValueStoreChange::ValueStoreChange(
- const std::string& key, base::Value* old_value, base::Value* new_value)
- : inner_(new Inner(key, old_value, new_value)) {}
+ValueStoreChange::ValueStoreChange(const std::string& key,
+ std::unique_ptr<base::Value> old_value,
+ std::unique_ptr<base::Value> new_value)
+ : inner_(new Inner(key, std::move(old_value), std::move(new_value))) {}
ValueStoreChange::ValueStoreChange(const ValueStoreChange& other) = default;
@@ -50,8 +54,11 @@ const base::Value* ValueStoreChange::new_value() const {
return inner_->new_value_.get();
}
-ValueStoreChange::Inner::Inner(
- const std::string& key, base::Value* old_value, base::Value* new_value)
- : key_(key), old_value_(old_value), new_value_(new_value) {}
+ValueStoreChange::Inner::Inner(const std::string& key,
+ std::unique_ptr<base::Value> old_value,
+ std::unique_ptr<base::Value> new_value)
+ : key_(key),
+ old_value_(std::move(old_value)),
+ new_value_(std::move(new_value)) {}
ValueStoreChange::Inner::~Inner() {}
diff --git a/chromium/extensions/browser/value_store/value_store_change.h b/chromium/extensions/browser/value_store/value_store_change.h
index a5e6bf5b818..8645b574566 100644
--- a/chromium/extensions/browser/value_store/value_store_change.h
+++ b/chromium/extensions/browser/value_store/value_store_change.h
@@ -5,11 +5,11 @@
#ifndef EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_CHANGE_H_
#define EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_CHANGE_H_
+#include <memory>
#include <string>
#include <vector>
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
class ValueStoreChange;
@@ -22,9 +22,9 @@ class ValueStoreChange {
// { "foo": { "key": "foo", "oldValue": "bar", "newValue": "baz" } }
static std::string ToJson(const ValueStoreChangeList& changes);
- // Ownership of |old_value| and |new_value| taken.
- ValueStoreChange(
- const std::string& key, base::Value* old_value, base::Value* new_value);
+ ValueStoreChange(const std::string& key,
+ std::unique_ptr<base::Value> old_value,
+ std::unique_ptr<base::Value> new_value);
ValueStoreChange(const ValueStoreChange& other);
@@ -44,12 +44,13 @@ class ValueStoreChange {
private:
class Inner : public base::RefCountedThreadSafe<Inner> {
public:
- Inner(
- const std::string& key, base::Value* old_value, base::Value* new_value);
+ Inner(const std::string& key,
+ std::unique_ptr<base::Value> old_value,
+ std::unique_ptr<base::Value> new_value);
const std::string key_;
- const scoped_ptr<base::Value> old_value_;
- const scoped_ptr<base::Value> new_value_;
+ const std::unique_ptr<base::Value> old_value_;
+ const std::unique_ptr<base::Value> new_value_;
private:
friend class base::RefCountedThreadSafe<Inner>;
diff --git a/chromium/extensions/browser/value_store/value_store_change_unittest.cc b/chromium/extensions/browser/value_store/value_store_change_unittest.cc
index 895f1ac71ee..1d92a8a2d32 100644
--- a/chromium/extensions/browser/value_store/value_store_change_unittest.cc
+++ b/chromium/extensions/browser/value_store/value_store_change_unittest.cc
@@ -5,6 +5,7 @@
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "extensions/browser/value_store/value_store_change.h"
#include "extensions/common/value_builder.h"
@@ -18,46 +19,48 @@ using extensions::ListBuilder;
namespace {
TEST(ValueStoreChangeTest, NullOldValue) {
- ValueStoreChange change("key", NULL, new base::StringValue("value"));
+ ValueStoreChange change("key", nullptr,
+ base::WrapUnique(new base::StringValue("value")));
EXPECT_EQ("key", change.key());
EXPECT_EQ(NULL, change.old_value());
{
- scoped_ptr<base::Value> expected(new base::StringValue("value"));
- EXPECT_TRUE(change.new_value()->Equals(expected.get()));
+ base::StringValue expected("value");
+ EXPECT_TRUE(change.new_value()->Equals(&expected));
}
}
TEST(ValueStoreChangeTest, NullNewValue) {
- ValueStoreChange change("key", new base::StringValue("value"), NULL);
+ ValueStoreChange change(
+ "key", base::WrapUnique(new base::StringValue("value")), nullptr);
EXPECT_EQ("key", change.key());
{
- scoped_ptr<base::Value> expected(new base::StringValue("value"));
- EXPECT_TRUE(change.old_value()->Equals(expected.get()));
+ base::StringValue expected("value");
+ EXPECT_TRUE(change.old_value()->Equals(&expected));
}
EXPECT_EQ(NULL, change.new_value());
}
TEST(ValueStoreChangeTest, NonNullValues) {
ValueStoreChange change("key",
- new base::StringValue("old_value"),
- new base::StringValue("new_value"));
+ base::WrapUnique(new base::StringValue("old_value")),
+ base::WrapUnique(new base::StringValue("new_value")));
EXPECT_EQ("key", change.key());
{
- scoped_ptr<base::Value> expected(new base::StringValue("old_value"));
- EXPECT_TRUE(change.old_value()->Equals(expected.get()));
+ base::StringValue expected("old_value");
+ EXPECT_TRUE(change.old_value()->Equals(&expected));
}
{
- scoped_ptr<base::Value> expected(new base::StringValue("new_value"));
- EXPECT_TRUE(change.new_value()->Equals(expected.get()));
+ base::StringValue expected("new_value");
+ EXPECT_TRUE(change.new_value()->Equals(&expected));
}
}
TEST(ValueStoreChangeTest, ToJson) {
// Create a mildly complicated structure that has dots in it.
- scoped_ptr<base::DictionaryValue> value =
+ std::unique_ptr<base::DictionaryValue> value =
DictionaryBuilder()
.Set("key", "value")
.Set("key.with.dots", "value.with.dots")
@@ -66,20 +69,20 @@ TEST(ValueStoreChangeTest, ToJson) {
.Build();
ValueStoreChangeList change_list;
- change_list.push_back(
- ValueStoreChange("key", value->DeepCopy(), value->DeepCopy()));
- change_list.push_back(
- ValueStoreChange("key.with.dots", value->DeepCopy(), value->DeepCopy()));
+ change_list.push_back(ValueStoreChange("key", value->CreateDeepCopy(),
+ value->CreateDeepCopy()));
+ change_list.push_back(ValueStoreChange(
+ "key.with.dots", value->CreateDeepCopy(), value->CreateDeepCopy()));
std::string json = ValueStoreChange::ToJson(change_list);
- scoped_ptr<base::Value> from_json(base::JSONReader::Read(json));
+ std::unique_ptr<base::Value> from_json(base::JSONReader::Read(json));
ASSERT_TRUE(from_json.get());
DictionaryBuilder v1(*value);
DictionaryBuilder v2(*value);
DictionaryBuilder v3(*value);
DictionaryBuilder v4(*value);
- scoped_ptr<base::DictionaryValue> expected_from_json =
+ std::unique_ptr<base::DictionaryValue> expected_from_json =
DictionaryBuilder()
.Set("key", DictionaryBuilder()
.Set("oldValue", v1.Build())
diff --git a/chromium/extensions/browser/value_store/value_store_factory.h b/chromium/extensions/browser/value_store/value_store_factory.h
index ec43547e880..58a73e92ed9 100644
--- a/chromium/extensions/browser/value_store/value_store_factory.h
+++ b/chromium/extensions/browser/value_store/value_store_factory.h
@@ -5,10 +5,10 @@
#ifndef EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_FACTORY_H_
#define EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_FACTORY_H_
+#include <memory>
#include <set>
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/browser/api/storage/settings_namespace.h"
#include "extensions/common/extension.h"
@@ -27,14 +27,14 @@ class ValueStoreFactory : public base::RefCountedThreadSafe<ValueStoreFactory> {
enum class ModelType { APP, EXTENSION };
// Create a |ValueStore| to contain rules data.
- virtual scoped_ptr<ValueStore> CreateRulesStore() = 0;
+ virtual std::unique_ptr<ValueStore> CreateRulesStore() = 0;
// Create a |ValueStore| to contain state data.
- virtual scoped_ptr<ValueStore> CreateStateStore() = 0;
+ virtual std::unique_ptr<ValueStore> CreateStateStore() = 0;
// Create a |ValueStore| to contain settings data for a specific extension
// namespace and model type.
- virtual scoped_ptr<ValueStore> CreateSettingsStore(
+ virtual std::unique_ptr<ValueStore> CreateSettingsStore(
settings_namespace::Namespace settings_namespace,
ModelType model_type,
const ExtensionId& extension_id) = 0;
diff --git a/chromium/extensions/browser/value_store/value_store_factory_impl.cc b/chromium/extensions/browser/value_store/value_store_factory_impl.cc
index 27324fd2bd5..3689421bdf9 100644
--- a/chromium/extensions/browser/value_store/value_store_factory_impl.cc
+++ b/chromium/extensions/browser/value_store/value_store_factory_impl.cc
@@ -15,15 +15,15 @@ ValueStoreFactoryImpl::ValueStoreFactoryImpl(const base::FilePath& profile_path)
ValueStoreFactoryImpl::~ValueStoreFactoryImpl() = default;
-scoped_ptr<ValueStore> ValueStoreFactoryImpl::CreateRulesStore() {
+std::unique_ptr<ValueStore> ValueStoreFactoryImpl::CreateRulesStore() {
return legacy_factory_->CreateRulesStore();
}
-scoped_ptr<ValueStore> ValueStoreFactoryImpl::CreateStateStore() {
+std::unique_ptr<ValueStore> ValueStoreFactoryImpl::CreateStateStore() {
return legacy_factory_->CreateStateStore();
}
-scoped_ptr<ValueStore> ValueStoreFactoryImpl::CreateSettingsStore(
+std::unique_ptr<ValueStore> ValueStoreFactoryImpl::CreateSettingsStore(
SettingsNamespace settings_namespace,
ModelType model_type,
const ExtensionId& extension_id) {
diff --git a/chromium/extensions/browser/value_store/value_store_factory_impl.h b/chromium/extensions/browser/value_store/value_store_factory_impl.h
index d0a0677ec97..193e8450ae2 100644
--- a/chromium/extensions/browser/value_store/value_store_factory_impl.h
+++ b/chromium/extensions/browser/value_store/value_store_factory_impl.h
@@ -5,12 +5,12 @@
#ifndef EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_FACTORY_IMPL_H_
#define EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_FACTORY_IMPL_H_
+#include <memory>
#include <set>
#include <string>
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/browser/value_store/value_store.h"
#include "extensions/browser/value_store/value_store_factory.h"
#include "extensions/common/extension.h"
@@ -26,9 +26,9 @@ class ValueStoreFactoryImpl : public ValueStoreFactory {
explicit ValueStoreFactoryImpl(const base::FilePath& profile_path);
// ValueStoreFactory
- scoped_ptr<ValueStore> CreateRulesStore() override;
- scoped_ptr<ValueStore> CreateStateStore() override;
- scoped_ptr<ValueStore> CreateSettingsStore(
+ std::unique_ptr<ValueStore> CreateRulesStore() override;
+ std::unique_ptr<ValueStore> CreateStateStore() override;
+ std::unique_ptr<ValueStore> CreateSettingsStore(
settings_namespace::Namespace settings_namespace,
ModelType model_type,
const ExtensionId& extension_id) override;
diff --git a/chromium/extensions/browser/value_store/value_store_frontend.cc b/chromium/extensions/browser/value_store/value_store_frontend.cc
index b3912d6febb..ccd50403706 100644
--- a/chromium/extensions/browser/value_store/value_store_frontend.cc
+++ b/chromium/extensions/browser/value_store/value_store_frontend.cc
@@ -32,7 +32,7 @@ class ValueStoreFrontend::Backend : public base::RefCountedThreadSafe<Backend> {
// Extract the value from the ReadResult and pass ownership of it to the
// callback.
- scoped_ptr<base::Value> value;
+ std::unique_ptr<base::Value> value;
if (result->status().ok()) {
result->settings().RemoveWithoutPathExpansion(key, &value);
} else {
@@ -45,7 +45,7 @@ class ValueStoreFrontend::Backend : public base::RefCountedThreadSafe<Backend> {
this, callback, base::Passed(&value)));
}
- void Set(const std::string& key, scoped_ptr<base::Value> value) {
+ void Set(const std::string& key, std::unique_ptr<base::Value> value) {
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
LazyInit();
// We don't need the old value, so skip generating changes.
@@ -88,7 +88,7 @@ class ValueStoreFrontend::Backend : public base::RefCountedThreadSafe<Backend> {
}
void RunCallback(const ValueStoreFrontend::ReadCallback& callback,
- scoped_ptr<base::Value> value) {
+ std::unique_ptr<base::Value> value) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
callback.Run(std::move(value));
}
@@ -100,7 +100,7 @@ class ValueStoreFrontend::Backend : public base::RefCountedThreadSafe<Backend> {
// The actual ValueStore that handles persisting the data to disk. Used
// exclusively on the FILE thread.
- scoped_ptr<ValueStore> storage_;
+ std::unique_ptr<ValueStore> storage_;
base::FilePath db_path_;
@@ -126,7 +126,7 @@ void ValueStoreFrontend::Get(const std::string& key,
}
void ValueStoreFrontend::Set(const std::string& key,
- scoped_ptr<base::Value> value) {
+ std::unique_ptr<base::Value> value) {
DCHECK(CalledOnValidThread());
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
diff --git a/chromium/extensions/browser/value_store/value_store_frontend.h b/chromium/extensions/browser/value_store/value_store_frontend.h
index 55253fb4218..47cab846a83 100644
--- a/chromium/extensions/browser/value_store/value_store_frontend.h
+++ b/chromium/extensions/browser/value_store/value_store_frontend.h
@@ -5,12 +5,12 @@
#ifndef EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_FRONTEND_H_
#define EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_FRONTEND_H_
+#include <memory>
#include <string>
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/non_thread_safe.h"
#include "base/values.h"
@@ -32,7 +32,7 @@ class ValueStoreFrontend
// The kind of extensions data stored in a backend.
enum class BackendType { RULES, STATE };
- typedef base::Callback<void(scoped_ptr<base::Value>)> ReadCallback;
+ typedef base::Callback<void(std::unique_ptr<base::Value>)> ReadCallback;
ValueStoreFrontend(
const scoped_refptr<extensions::ValueStoreFactory>& store_factory,
@@ -44,7 +44,7 @@ class ValueStoreFrontend
void Get(const std::string& key, const ReadCallback& callback);
// Sets a value with the given key.
- void Set(const std::string& key, scoped_ptr<base::Value> value);
+ void Set(const std::string& key, std::unique_ptr<base::Value> value);
// Removes the value with the given key.
void Remove(const std::string& key);
diff --git a/chromium/extensions/browser/value_store/value_store_frontend_unittest.cc b/chromium/extensions/browser/value_store/value_store_frontend_unittest.cc
index 21f95b6153e..f6a2ffaef0e 100644
--- a/chromium/extensions/browser/value_store/value_store_frontend_unittest.cc
+++ b/chromium/extensions/browser/value_store/value_store_frontend_unittest.cc
@@ -4,11 +4,11 @@
#include "extensions/browser/value_store/value_store_frontend.h"
+#include <memory>
#include <utility>
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "content/public/test/test_browser_thread.h"
@@ -50,7 +50,7 @@ class ValueStoreFrontendTest : public testing::Test {
factory_, ValueStoreFrontend::BackendType::RULES));
}
- bool Get(const std::string& key, scoped_ptr<base::Value>* output) {
+ bool Get(const std::string& key, std::unique_ptr<base::Value>* output) {
storage_->Get(key, base::Bind(&ValueStoreFrontendTest::GetAndWait,
base::Unretained(this), output));
base::MessageLoop::current()->Run(); // wait for GetAndWait
@@ -58,14 +58,14 @@ class ValueStoreFrontendTest : public testing::Test {
}
protected:
- void GetAndWait(scoped_ptr<base::Value>* output,
- scoped_ptr<base::Value> result) {
+ void GetAndWait(std::unique_ptr<base::Value>* output,
+ std::unique_ptr<base::Value> result) {
*output = std::move(result);
base::MessageLoop::current()->QuitWhenIdle();
}
scoped_refptr<extensions::TestValueStoreFactory> factory_;
- scoped_ptr<ValueStoreFrontend> storage_;
+ std::unique_ptr<ValueStoreFrontend> storage_;
base::ScopedTempDir temp_dir_;
base::FilePath db_path_;
base::MessageLoop message_loop_;
@@ -74,7 +74,7 @@ class ValueStoreFrontendTest : public testing::Test {
};
TEST_F(ValueStoreFrontendTest, GetExistingData) {
- scoped_ptr<base::Value> value;
+ std::unique_ptr<base::Value> value;
ASSERT_FALSE(Get("key0", &value));
// Test existing keys in the DB.
@@ -94,14 +94,16 @@ TEST_F(ValueStoreFrontendTest, GetExistingData) {
}
TEST_F(ValueStoreFrontendTest, ChangesPersistAfterReload) {
- storage_->Set("key0", scoped_ptr<base::Value>(new base::FundamentalValue(0)));
- storage_->Set("key1", scoped_ptr<base::Value>(new base::StringValue("new1")));
+ storage_->Set("key0",
+ std::unique_ptr<base::Value>(new base::FundamentalValue(0)));
+ storage_->Set("key1",
+ std::unique_ptr<base::Value>(new base::StringValue("new1")));
storage_->Remove("key2");
// Reload the DB and test our changes.
ResetStorage();
- scoped_ptr<base::Value> value;
+ std::unique_ptr<base::Value> value;
{
ASSERT_TRUE(Get("key0", &value));
int result;
diff --git a/chromium/extensions/browser/value_store/value_store_unittest.cc b/chromium/extensions/browser/value_store/value_store_unittest.cc
index 8c5f7aec06c..a6858b2aec1 100644
--- a/chromium/extensions/browser/value_store/value_store_unittest.cc
+++ b/chromium/extensions/browser/value_store/value_store_unittest.cc
@@ -4,6 +4,8 @@
#include "extensions/browser/value_store/value_store_unittest.h"
+#include <utility>
+
#include "base/json/json_writer.h"
#include "base/memory/linked_ptr.h"
#include "base/values.h"
@@ -156,13 +158,13 @@ ValueStoreTest::ValueStoreTest()
set13_.insert(list13_.begin(), list13_.end());
set123_.insert(list123_.begin(), list123_.end());
- dict1_->Set(key1_, val1_->DeepCopy());
- dict3_->Set(key3_, val3_->DeepCopy());
- dict12_->Set(key1_, val1_->DeepCopy());
- dict12_->Set(key2_, val2_->DeepCopy());
- dict123_->Set(key1_, val1_->DeepCopy());
- dict123_->Set(key2_, val2_->DeepCopy());
- dict123_->Set(key3_, val3_->DeepCopy());
+ dict1_->Set(key1_, val1_->CreateDeepCopy());
+ dict3_->Set(key3_, val3_->CreateDeepCopy());
+ dict12_->Set(key1_, val1_->CreateDeepCopy());
+ dict12_->Set(key2_, val2_->CreateDeepCopy());
+ dict123_->Set(key1_, val1_->CreateDeepCopy());
+ dict123_->Set(key2_, val2_->CreateDeepCopy());
+ dict123_->Set(key3_, val3_->CreateDeepCopy());
}
ValueStoreTest::~ValueStoreTest() {}
@@ -187,7 +189,8 @@ TEST_P(ValueStoreTest, GetWhenEmpty) {
TEST_P(ValueStoreTest, GetWithSingleValue) {
{
ValueStoreChangeList changes;
- changes.push_back(ValueStoreChange(key1_, NULL, val1_->DeepCopy()));
+ changes.push_back(
+ ValueStoreChange(key1_, nullptr, val1_->CreateDeepCopy()));
EXPECT_PRED_FORMAT2(ChangesEq,
changes, storage_->Set(DEFAULTS, key1_, *val1_));
}
@@ -203,8 +206,10 @@ TEST_P(ValueStoreTest, GetWithSingleValue) {
TEST_P(ValueStoreTest, GetWithMultipleValues) {
{
ValueStoreChangeList changes;
- changes.push_back(ValueStoreChange(key1_, NULL, val1_->DeepCopy()));
- changes.push_back(ValueStoreChange(key2_, NULL, val2_->DeepCopy()));
+ changes.push_back(
+ ValueStoreChange(key1_, nullptr, val1_->CreateDeepCopy()));
+ changes.push_back(
+ ValueStoreChange(key2_, nullptr, val2_->CreateDeepCopy()));
EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(DEFAULTS, *dict12_));
}
@@ -228,7 +233,8 @@ TEST_P(ValueStoreTest, RemoveWithSingleValue) {
storage_->Set(DEFAULTS, *dict1_);
{
ValueStoreChangeList changes;
- changes.push_back(ValueStoreChange(key1_, val1_->DeepCopy(), NULL));
+ changes.push_back(
+ ValueStoreChange(key1_, val1_->CreateDeepCopy(), nullptr));
EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Remove(key1_));
}
@@ -243,7 +249,8 @@ TEST_P(ValueStoreTest, RemoveWithMultipleValues) {
storage_->Set(DEFAULTS, *dict123_);
{
ValueStoreChangeList changes;
- changes.push_back(ValueStoreChange(key3_, val3_->DeepCopy(), NULL));
+ changes.push_back(
+ ValueStoreChange(key3_, val3_->CreateDeepCopy(), nullptr));
EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Remove(key3_));
}
@@ -258,8 +265,10 @@ TEST_P(ValueStoreTest, RemoveWithMultipleValues) {
{
ValueStoreChangeList changes;
- changes.push_back(ValueStoreChange(key1_, val1_->DeepCopy(), NULL));
- changes.push_back(ValueStoreChange(key2_, val2_->DeepCopy(), NULL));
+ changes.push_back(
+ ValueStoreChange(key1_, val1_->CreateDeepCopy(), nullptr));
+ changes.push_back(
+ ValueStoreChange(key2_, val2_->CreateDeepCopy(), nullptr));
EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Remove(list12_));
}
@@ -277,9 +286,10 @@ TEST_P(ValueStoreTest, SetWhenOverwriting) {
storage_->Set(DEFAULTS, key1_, *val2_);
{
ValueStoreChangeList changes;
+ changes.push_back(ValueStoreChange(key1_, val2_->CreateDeepCopy(),
+ val1_->CreateDeepCopy()));
changes.push_back(
- ValueStoreChange(key1_, val2_->DeepCopy(), val1_->DeepCopy()));
- changes.push_back(ValueStoreChange(key2_, NULL, val2_->DeepCopy()));
+ ValueStoreChange(key2_, nullptr, val2_->CreateDeepCopy()));
EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(DEFAULTS, *dict12_));
}
@@ -306,8 +316,10 @@ TEST_P(ValueStoreTest, ClearWhenNotEmpty) {
storage_->Set(DEFAULTS, *dict12_);
{
ValueStoreChangeList changes;
- changes.push_back(ValueStoreChange(key1_, val1_->DeepCopy(), NULL));
- changes.push_back(ValueStoreChange(key2_, val2_->DeepCopy(), NULL));
+ changes.push_back(
+ ValueStoreChange(key1_, val1_->CreateDeepCopy(), nullptr));
+ changes.push_back(
+ ValueStoreChange(key2_, val2_->CreateDeepCopy(), nullptr));
EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Clear());
}
@@ -325,14 +337,14 @@ TEST_P(ValueStoreTest, DotsInKeyNames) {
std::vector<std::string> dot_list;
dot_list.push_back(dot_key);
base::DictionaryValue dot_dict;
- dot_dict.SetWithoutPathExpansion(dot_key, dot_value.DeepCopy());
+ dot_dict.SetWithoutPathExpansion(dot_key, dot_value.CreateDeepCopy());
EXPECT_PRED_FORMAT2(SettingsEq, *empty_dict_, storage_->Get(dot_key));
{
ValueStoreChangeList changes;
changes.push_back(
- ValueStoreChange(dot_key, NULL, dot_value.DeepCopy()));
+ ValueStoreChange(dot_key, nullptr, dot_value.CreateDeepCopy()));
EXPECT_PRED_FORMAT2(ChangesEq,
changes, storage_->Set(DEFAULTS, dot_key, dot_value));
}
@@ -344,7 +356,7 @@ TEST_P(ValueStoreTest, DotsInKeyNames) {
{
ValueStoreChangeList changes;
changes.push_back(
- ValueStoreChange(dot_key, dot_value.DeepCopy(), NULL));
+ ValueStoreChange(dot_key, dot_value.CreateDeepCopy(), nullptr));
EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Remove(dot_key));
}
EXPECT_PRED_FORMAT2(ChangesEq,
@@ -352,7 +364,7 @@ TEST_P(ValueStoreTest, DotsInKeyNames) {
{
ValueStoreChangeList changes;
changes.push_back(
- ValueStoreChange(dot_key, NULL, dot_value.DeepCopy()));
+ ValueStoreChange(dot_key, nullptr, dot_value.CreateDeepCopy()));
EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(DEFAULTS, dot_dict));
}
@@ -362,7 +374,7 @@ TEST_P(ValueStoreTest, DotsInKeyNames) {
{
ValueStoreChangeList changes;
changes.push_back(
- ValueStoreChange(dot_key, dot_value.DeepCopy(), NULL));
+ ValueStoreChange(dot_key, dot_value.CreateDeepCopy(), nullptr));
EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Remove(dot_list));
}
@@ -372,16 +384,16 @@ TEST_P(ValueStoreTest, DotsInKeyNames) {
TEST_P(ValueStoreTest, DotsInKeyNamesWithDicts) {
base::DictionaryValue outer_dict;
- base::DictionaryValue* inner_dict = new base::DictionaryValue();
- outer_dict.Set("foo", inner_dict);
- inner_dict->SetString("bar", "baz");
+ base::DictionaryValue inner_dict;
+ inner_dict.SetString("bar", "baz");
+ outer_dict.Set("foo", inner_dict.CreateDeepCopy());
{
ValueStoreChangeList changes;
changes.push_back(
- ValueStoreChange("foo", NULL, inner_dict->DeepCopy()));
- EXPECT_PRED_FORMAT2(ChangesEq,
- changes, storage_->Set(DEFAULTS, outer_dict));
+ ValueStoreChange("foo", nullptr, inner_dict.CreateDeepCopy()));
+ EXPECT_PRED_FORMAT2(ChangesEq, changes,
+ storage_->Set(DEFAULTS, outer_dict));
}
EXPECT_PRED_FORMAT2(SettingsEq, outer_dict, storage_->Get("foo"));
@@ -401,63 +413,72 @@ TEST_P(ValueStoreTest, ComplexChangedKeysScenarios) {
ValueStoreChangeList(), storage_->Set(DEFAULTS, key1_, *val1_));
{
ValueStoreChangeList changes;
- changes.push_back(ValueStoreChange(
- key1_, val1_->DeepCopy(), val2_->DeepCopy()));
+ changes.push_back(ValueStoreChange(key1_, val1_->CreateDeepCopy(),
+ val2_->CreateDeepCopy()));
EXPECT_PRED_FORMAT2(ChangesEq,
changes, storage_->Set(DEFAULTS, key1_, *val2_));
}
{
ValueStoreChangeList changes;
- changes.push_back(ValueStoreChange(key1_, val2_->DeepCopy(), NULL));
+ changes.push_back(
+ ValueStoreChange(key1_, val2_->CreateDeepCopy(), nullptr));
EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Remove(key1_));
EXPECT_PRED_FORMAT2(ChangesEq,
ValueStoreChangeList(), storage_->Remove(key1_));
}
{
ValueStoreChangeList changes;
- changes.push_back(ValueStoreChange(key1_, NULL, val1_->DeepCopy()));
+ changes.push_back(
+ ValueStoreChange(key1_, nullptr, val1_->CreateDeepCopy()));
EXPECT_PRED_FORMAT2(ChangesEq,
changes, storage_->Set(DEFAULTS, key1_, *val1_));
}
{
ValueStoreChangeList changes;
- changes.push_back(ValueStoreChange(key1_, val1_->DeepCopy(), NULL));
+ changes.push_back(
+ ValueStoreChange(key1_, val1_->CreateDeepCopy(), nullptr));
EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Clear());
EXPECT_PRED_FORMAT2(ChangesEq, ValueStoreChangeList(), storage_->Clear());
}
{
ValueStoreChangeList changes;
- changes.push_back(ValueStoreChange(key1_, NULL, val1_->DeepCopy()));
- changes.push_back(ValueStoreChange(key2_, NULL, val2_->DeepCopy()));
+ changes.push_back(
+ ValueStoreChange(key1_, nullptr, val1_->CreateDeepCopy()));
+ changes.push_back(
+ ValueStoreChange(key2_, nullptr, val2_->CreateDeepCopy()));
EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(DEFAULTS, *dict12_));
EXPECT_PRED_FORMAT2(ChangesEq,
ValueStoreChangeList(), storage_->Set(DEFAULTS, *dict12_));
}
{
ValueStoreChangeList changes;
- changes.push_back(ValueStoreChange(key3_, NULL, val3_->DeepCopy()));
+ changes.push_back(
+ ValueStoreChange(key3_, nullptr, val3_->CreateDeepCopy()));
EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(DEFAULTS, *dict123_));
}
{
base::DictionaryValue to_set;
- to_set.Set(key1_, val2_->DeepCopy());
- to_set.Set(key2_, val2_->DeepCopy());
- to_set.Set("asdf", val1_->DeepCopy());
- to_set.Set("qwerty", val3_->DeepCopy());
+ to_set.Set(key1_, val2_->CreateDeepCopy());
+ to_set.Set(key2_, val2_->CreateDeepCopy());
+ to_set.Set("asdf", val1_->CreateDeepCopy());
+ to_set.Set("qwerty", val3_->CreateDeepCopy());
ValueStoreChangeList changes;
+ changes.push_back(ValueStoreChange(key1_, val1_->CreateDeepCopy(),
+ val2_->CreateDeepCopy()));
changes.push_back(
- ValueStoreChange(key1_, val1_->DeepCopy(), val2_->DeepCopy()));
- changes.push_back(ValueStoreChange("asdf", NULL, val1_->DeepCopy()));
+ ValueStoreChange("asdf", nullptr, val1_->CreateDeepCopy()));
changes.push_back(
- ValueStoreChange("qwerty", NULL, val3_->DeepCopy()));
+ ValueStoreChange("qwerty", nullptr, val3_->CreateDeepCopy()));
EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Set(DEFAULTS, to_set));
}
{
ValueStoreChangeList changes;
- changes.push_back(ValueStoreChange(key1_, val2_->DeepCopy(), NULL));
- changes.push_back(ValueStoreChange(key2_, val2_->DeepCopy(), NULL));
+ changes.push_back(
+ ValueStoreChange(key1_, val2_->CreateDeepCopy(), nullptr));
+ changes.push_back(
+ ValueStoreChange(key2_, val2_->CreateDeepCopy(), nullptr));
EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Remove(list12_));
}
{
@@ -466,14 +487,16 @@ TEST_P(ValueStoreTest, ComplexChangedKeysScenarios) {
to_remove.push_back("asdf");
ValueStoreChangeList changes;
- changes.push_back(ValueStoreChange("asdf", val1_->DeepCopy(), NULL));
+ changes.push_back(
+ ValueStoreChange("asdf", val1_->CreateDeepCopy(), nullptr));
EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Remove(to_remove));
}
{
ValueStoreChangeList changes;
- changes.push_back(ValueStoreChange(key3_, val3_->DeepCopy(), NULL));
changes.push_back(
- ValueStoreChange("qwerty", val3_->DeepCopy(), NULL));
+ ValueStoreChange(key3_, val3_->CreateDeepCopy(), nullptr));
+ changes.push_back(
+ ValueStoreChange("qwerty", val3_->CreateDeepCopy(), nullptr));
EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Clear());
EXPECT_PRED_FORMAT2(ChangesEq, ValueStoreChangeList(), storage_->Clear());
}
diff --git a/chromium/extensions/browser/value_store/value_store_unittest.h b/chromium/extensions/browser/value_store/value_store_unittest.h
index f50e6902570..d433ab9cc9c 100644
--- a/chromium/extensions/browser/value_store/value_store_unittest.h
+++ b/chromium/extensions/browser/value_store/value_store_unittest.h
@@ -5,9 +5,10 @@
#ifndef EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_UNITTEST_H_
#define EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_UNITTEST_H_
+#include <memory>
+
#include "base/files/scoped_temp_dir.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "content/public/test/test_browser_thread.h"
#include "extensions/browser/value_store/value_store.h"
@@ -28,15 +29,15 @@ class ValueStoreTest : public testing::TestWithParam<ValueStoreTestParam> {
void TearDown() override;
protected:
- scoped_ptr<ValueStore> storage_;
+ std::unique_ptr<ValueStore> storage_;
std::string key1_;
std::string key2_;
std::string key3_;
- scoped_ptr<base::Value> val1_;
- scoped_ptr<base::Value> val2_;
- scoped_ptr<base::Value> val3_;
+ std::unique_ptr<base::Value> val1_;
+ std::unique_ptr<base::Value> val2_;
+ std::unique_ptr<base::Value> val3_;
std::vector<std::string> empty_list_;
std::vector<std::string> list1_;
@@ -54,11 +55,11 @@ class ValueStoreTest : public testing::TestWithParam<ValueStoreTestParam> {
std::set<std::string> set13_;
std::set<std::string> set123_;
- scoped_ptr<base::DictionaryValue> empty_dict_;
- scoped_ptr<base::DictionaryValue> dict1_;
- scoped_ptr<base::DictionaryValue> dict3_;
- scoped_ptr<base::DictionaryValue> dict12_;
- scoped_ptr<base::DictionaryValue> dict123_;
+ std::unique_ptr<base::DictionaryValue> empty_dict_;
+ std::unique_ptr<base::DictionaryValue> dict1_;
+ std::unique_ptr<base::DictionaryValue> dict3_;
+ std::unique_ptr<base::DictionaryValue> dict12_;
+ std::unique_ptr<base::DictionaryValue> dict123_;
private:
base::ScopedTempDir temp_dir_;
diff --git a/chromium/extensions/browser/verified_contents.cc b/chromium/extensions/browser/verified_contents.cc
index fc2471dc79a..6abca5ee7b9 100644
--- a/chromium/extensions/browser/verified_contents.cc
+++ b/chromium/extensions/browser/verified_contents.cc
@@ -96,7 +96,7 @@ bool VerifiedContents::InitFrom(const base::FilePath& path,
if (!GetPayload(path, &payload, ignore_invalid_signature))
return false;
- scoped_ptr<base::Value> value(base::JSONReader::Read(payload));
+ std::unique_ptr<base::Value> value(base::JSONReader::Read(payload));
if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY))
return false;
DictionaryValue* dictionary = static_cast<DictionaryValue*>(value.get());
@@ -235,7 +235,7 @@ bool VerifiedContents::GetPayload(const base::FilePath& path,
std::string contents;
if (!base::ReadFileToString(path, &contents))
return false;
- scoped_ptr<base::Value> value(base::JSONReader::Read(contents));
+ std::unique_ptr<base::Value> value(base::JSONReader::Read(contents));
if (!value.get() || !value->IsType(Value::TYPE_LIST))
return false;
ListValue* top_list = static_cast<ListValue*>(value.get());
diff --git a/chromium/extensions/browser/web_ui_user_script_loader.cc b/chromium/extensions/browser/web_ui_user_script_loader.cc
index 6954f25188e..a16c7f70a89 100644
--- a/chromium/extensions/browser/web_ui_user_script_loader.cc
+++ b/chromium/extensions/browser/web_ui_user_script_loader.cc
@@ -16,9 +16,9 @@
namespace {
void SerializeOnFileThread(
- scoped_ptr<extensions::UserScriptList> user_scripts,
+ std::unique_ptr<extensions::UserScriptList> user_scripts,
extensions::UserScriptLoader::LoadScriptsCallback callback) {
- scoped_ptr<base::SharedMemory> memory =
+ std::unique_ptr<base::SharedMemory> memory =
extensions::UserScriptLoader::Serialize(*user_scripts);
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
@@ -61,7 +61,7 @@ void WebUIUserScriptLoader::AddScripts(
}
void WebUIUserScriptLoader::LoadScripts(
- scoped_ptr<extensions::UserScriptList> user_scripts,
+ std::unique_ptr<extensions::UserScriptList> user_scripts,
const std::set<HostID>& changed_hosts,
const std::set<int>& added_script_ids,
LoadScriptsCallback callback) {
@@ -114,7 +114,7 @@ void WebUIUserScriptLoader::CreateWebUIURLFetchers(
// The WebUIUserScriptLoader owns these WebUIURLFetchers. Once the
// loader is destroyed, all the fetchers will be destroyed. Therefore,
// we are sure it is safe to use base::Unretained(this) here.
- scoped_ptr<WebUIURLFetcher> fetcher(new WebUIURLFetcher(
+ std::unique_ptr<WebUIURLFetcher> fetcher(new WebUIURLFetcher(
browser_context, render_process_id, render_view_id, file.url(),
base::Bind(&WebUIUserScriptLoader::OnSingleWebUIURLFetchComplete,
base::Unretained(this), &file)));
diff --git a/chromium/extensions/browser/web_ui_user_script_loader.h b/chromium/extensions/browser/web_ui_user_script_loader.h
index f0e3c905435..fa75e19afa4 100644
--- a/chromium/extensions/browser/web_ui_user_script_loader.h
+++ b/chromium/extensions/browser/web_ui_user_script_loader.h
@@ -7,11 +7,11 @@
#include <stddef.h>
+#include <memory>
#include <vector>
#include "base/callback.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/browser/user_script_loader.h"
class WebUIURLFetcher;
@@ -35,7 +35,7 @@ class WebUIUserScriptLoader : public extensions::UserScriptLoader {
void AddScripts(const std::set<extensions::UserScript>& scripts,
int render_process_id,
int render_view_id) override;
- void LoadScripts(scoped_ptr<extensions::UserScriptList> user_scripts,
+ void LoadScripts(std::unique_ptr<extensions::UserScriptList> user_scripts,
const std::set<HostID>& changed_hosts,
const std::set<int>& added_script_ids,
LoadScriptsCallback callback) override;
@@ -64,11 +64,11 @@ class WebUIUserScriptLoader : public extensions::UserScriptLoader {
size_t complete_fetchers_;
// Caches |user_scripts_| from UserScriptLoader when loading.
- scoped_ptr<extensions::UserScriptList> user_scripts_cache_;
+ std::unique_ptr<extensions::UserScriptList> user_scripts_cache_;
LoadScriptsCallback scripts_loaded_callback_;
- std::vector<scoped_ptr<WebUIURLFetcher>> fetchers_;
+ std::vector<std::unique_ptr<WebUIURLFetcher>> fetchers_;
DISALLOW_COPY_AND_ASSIGN(WebUIUserScriptLoader);
};
diff --git a/chromium/extensions/common/BUILD.gn b/chromium/extensions/common/BUILD.gn
index 5ed19135b10..488da6695dc 100644
--- a/chromium/extensions/common/BUILD.gn
+++ b/chromium/extensions/common/BUILD.gn
@@ -22,7 +22,7 @@ if (enable_extensions) {
sources = rebase_path(extensions_gypi_values.extensions_common_mojo_sources,
".",
"//extensions")
- if (enable_wifi_display) {
+ if (proprietary_codecs && enable_wifi_display) {
wifi_display_sources = rebase_path(
extensions_gypi_values.extensions_common_mojo_sources_wifi_display,
".",
@@ -75,6 +75,7 @@ if (enable_extensions) {
"//ui/base",
"//ui/gfx/geometry",
"//ui/gfx/ipc",
+ "//ui/gfx/ipc/geometry",
"//ui/gfx/ipc/skia",
"//url",
]
diff --git a/chromium/extensions/common/api/_api_features.json b/chromium/extensions/common/api/_api_features.json
index e57362b175d..45ef8e5192c 100644
--- a/chromium/extensions/common/api/_api_features.json
+++ b/chromium/extensions/common/api/_api_features.json
@@ -103,6 +103,36 @@
"dependencies": ["manifest:bluetooth"],
"contexts": ["blessed_extension"]
},
+ "bluetoothLowEnergy.createService": {
+ "dependencies": ["manifest:bluetooth"],
+ "contexts": ["blessed_extension"],
+ "platforms": ["chromeos", "linux"]
+ },
+ "bluetoothLowEnergy.createCharacteristic": {
+ "dependencies": ["manifest:bluetooth"],
+ "contexts": ["blessed_extension"],
+ "platforms": ["chromeos", "linux"]
+ },
+ "bluetoothLowEnergy.createDescriptor": {
+ "dependencies": ["manifest:bluetooth"],
+ "contexts": ["blessed_extension"],
+ "platforms": ["chromeos", "linux"]
+ },
+ "bluetoothLowEnergy.registerService": {
+ "dependencies": ["manifest:bluetooth"],
+ "contexts": ["blessed_extension"],
+ "platforms": ["chromeos", "linux"]
+ },
+ "bluetoothLowEnergy.unregisterService": {
+ "dependencies": ["manifest:bluetooth"],
+ "contexts": ["blessed_extension"],
+ "platforms": ["chromeos", "linux"]
+ },
+ "bluetoothLowEnergy.sendRequestResponse": {
+ "dependencies": ["manifest:bluetooth"],
+ "contexts": ["blessed_extension"],
+ "platforms": ["chromeos", "linux"]
+ },
"bluetoothPrivate": [{
"dependencies": ["permission:bluetoothPrivate"],
"contexts": ["blessed_extension"]
@@ -184,14 +214,6 @@
"chrome://media-router/*",
"chrome://oobe/*"
]
- },
- // This allows GuestViews to be created on regular web pages for the Worker
- // Thread Frame prototype: http://crbug.com/434226.
- {
- "internal": true,
- "channel": "trunk",
- "contexts": "all",
- "matches": ["<all_urls>"]
}
],
"hid": {
diff --git a/chromium/extensions/common/api/_manifest_features.json b/chromium/extensions/common/api/_manifest_features.json
index a793f935d02..ba922f6d3de 100644
--- a/chromium/extensions/common/api/_manifest_features.json
+++ b/chromium/extensions/common/api/_manifest_features.json
@@ -183,11 +183,11 @@
"extension_types": "all"
},
"kiosk": {
- "channel": "dev",
+ "channel": "stable",
"extension_types": ["platform_app"]
},
"kiosk.required_platform_version": {
- "channel": "dev",
+ "channel": "stable",
"extension_types": ["platform_app"]
},
"kiosk_enabled": {
diff --git a/chromium/extensions/common/api/_permission_features.json b/chromium/extensions/common/api/_permission_features.json
index 2f9d159e981..14fbf181d75 100644
--- a/chromium/extensions/common/api/_permission_features.json
+++ b/chromium/extensions/common/api/_permission_features.json
@@ -150,7 +150,8 @@
"81986D4F846CEDDDB962643FA501D1780DD441BB", // http://crbug.com/407693
"89715614FAA2B4C2853802D70261D2A9D0756FC8", // http://crbug.com/455986
"61FF4757F9420B62B19BA5C96084649339DB31F5", // http://crbug.com/587613
- "F3013F58BED982D1BC75943792FF877E5D458672" // http://crbug.com/587613
+ "F3013F58BED982D1BC75943792FF877E5D458672", // http://crbug.com/587613
+ "2F6F6FDB84E0290ABAB7A9D7571EB344821E5F12" // http://crbug.com/610452
]
},
"cast": {
@@ -281,7 +282,8 @@
"4F25792AF1AA7483936DE29C07806F203C7170A0", // http://crbug.com/407693
"BD8781D757D830FC2E85470A1B6E8A718B7EE0D9", // http://crbug.com/407693
"4AC2B6C63C6480D150DFDA13E4A5956EB1D0DDBB", // http://crbug.com/407693
- "81986D4F846CEDDDB962643FA501D1780DD441BB" // http://crbug.com/407693
+ "81986D4F846CEDDDB962643FA501D1780DD441BB", // http://crbug.com/407693
+ "2F6F6FDB84E0290ABAB7A9D7571EB344821E5F12" // http://crbug.com/610452
]
},
"power": {
diff --git a/chromium/extensions/common/api/bluetooth/bluetooth_manifest_data.cc b/chromium/extensions/common/api/bluetooth/bluetooth_manifest_data.cc
index 94ba7fe3bf2..c5d84205382 100644
--- a/chromium/extensions/common/api/bluetooth/bluetooth_manifest_data.cc
+++ b/chromium/extensions/common/api/bluetooth/bluetooth_manifest_data.cc
@@ -12,7 +12,7 @@
namespace extensions {
BluetoothManifestData::BluetoothManifestData(
- scoped_ptr<BluetoothManifestPermission> permission)
+ std::unique_ptr<BluetoothManifestPermission> permission)
: permission_(std::move(permission)) {
DCHECK(permission_);
}
@@ -56,15 +56,15 @@ bool BluetoothManifestData::CheckPeripheralPermitted(
}
// static
-scoped_ptr<BluetoothManifestData> BluetoothManifestData::FromValue(
+std::unique_ptr<BluetoothManifestData> BluetoothManifestData::FromValue(
const base::Value& value,
base::string16* error) {
- scoped_ptr<BluetoothManifestPermission> permission =
+ std::unique_ptr<BluetoothManifestPermission> permission =
BluetoothManifestPermission::FromValue(value, error);
if (!permission)
- return scoped_ptr<BluetoothManifestData>();
+ return std::unique_ptr<BluetoothManifestData>();
- return scoped_ptr<BluetoothManifestData>(
+ return std::unique_ptr<BluetoothManifestData>(
new BluetoothManifestData(std::move(permission)));
}
diff --git a/chromium/extensions/common/api/bluetooth/bluetooth_manifest_data.h b/chromium/extensions/common/api/bluetooth/bluetooth_manifest_data.h
index b47cf8bdde6..7239751de2e 100644
--- a/chromium/extensions/common/api/bluetooth/bluetooth_manifest_data.h
+++ b/chromium/extensions/common/api/bluetooth/bluetooth_manifest_data.h
@@ -22,7 +22,7 @@ namespace extensions {
class BluetoothManifestData : public Extension::ManifestData {
public:
explicit BluetoothManifestData(
- scoped_ptr<BluetoothManifestPermission> permission);
+ std::unique_ptr<BluetoothManifestPermission> permission);
~BluetoothManifestData() override;
// Gets the BluetoothManifestData for |extension|, or NULL if none was
@@ -38,15 +38,16 @@ class BluetoothManifestData : public Extension::ManifestData {
// Tries to construct the info based on |value|, as it would have appeared in
// the manifest. Sets |error| and returns an empty scoped_ptr on failure.
- static scoped_ptr<BluetoothManifestData> FromValue(const base::Value& value,
- base::string16* error);
+ static std::unique_ptr<BluetoothManifestData> FromValue(
+ const base::Value& value,
+ base::string16* error);
const BluetoothManifestPermission* permission() const {
return permission_.get();
}
private:
- scoped_ptr<BluetoothManifestPermission> permission_;
+ std::unique_ptr<BluetoothManifestPermission> permission_;
};
// Used for checking bluetooth permission.
diff --git a/chromium/extensions/common/api/bluetooth/bluetooth_manifest_handler.cc b/chromium/extensions/common/api/bluetooth/bluetooth_manifest_handler.cc
index da143fa8c2f..6a666d9c46f 100644
--- a/chromium/extensions/common/api/bluetooth/bluetooth_manifest_handler.cc
+++ b/chromium/extensions/common/api/bluetooth/bluetooth_manifest_handler.cc
@@ -19,7 +19,7 @@ bool BluetoothManifestHandler::Parse(Extension* extension,
base::string16* error) {
const base::Value* bluetooth = NULL;
CHECK(extension->manifest()->Get(manifest_keys::kBluetooth, &bluetooth));
- scoped_ptr<BluetoothManifestData> data =
+ std::unique_ptr<BluetoothManifestData> data =
BluetoothManifestData::FromValue(*bluetooth, error);
if (!data)
return false;
diff --git a/chromium/extensions/common/api/bluetooth/bluetooth_manifest_permission.cc b/chromium/extensions/common/api/bluetooth/bluetooth_manifest_permission.cc
index c2c6d2c69a5..bb6e31400b4 100644
--- a/chromium/extensions/common/api/bluetooth/bluetooth_manifest_permission.cc
+++ b/chromium/extensions/common/api/bluetooth/bluetooth_manifest_permission.cc
@@ -4,7 +4,8 @@
#include "extensions/common/api/bluetooth/bluetooth_manifest_permission.h"
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@@ -43,7 +44,7 @@ bool ParseUuid(BluetoothManifestPermission* permission,
}
bool ParseUuidArray(BluetoothManifestPermission* permission,
- const scoped_ptr<std::vector<std::string> >& uuids,
+ const std::unique_ptr<std::vector<std::string>>& uuids,
base::string16* error) {
for (std::vector<std::string>::const_iterator it = uuids->begin();
it != uuids->end();
@@ -64,19 +65,19 @@ BluetoothManifestPermission::BluetoothManifestPermission()
BluetoothManifestPermission::~BluetoothManifestPermission() {}
// static
-scoped_ptr<BluetoothManifestPermission> BluetoothManifestPermission::FromValue(
- const base::Value& value,
- base::string16* error) {
- scoped_ptr<api::extensions_manifest_types::Bluetooth> bluetooth =
+std::unique_ptr<BluetoothManifestPermission>
+BluetoothManifestPermission::FromValue(const base::Value& value,
+ base::string16* error) {
+ std::unique_ptr<api::extensions_manifest_types::Bluetooth> bluetooth =
api::extensions_manifest_types::Bluetooth::FromValue(value, error);
if (!bluetooth)
- return scoped_ptr<BluetoothManifestPermission>();
+ return std::unique_ptr<BluetoothManifestPermission>();
- scoped_ptr<BluetoothManifestPermission> result(
+ std::unique_ptr<BluetoothManifestPermission> result(
new BluetoothManifestPermission());
if (bluetooth->uuids) {
if (!ParseUuidArray(result.get(), bluetooth->uuids, error)) {
- return scoped_ptr<BluetoothManifestPermission>();
+ return std::unique_ptr<BluetoothManifestPermission>();
}
}
if (bluetooth->socket) {
@@ -140,7 +141,7 @@ bool BluetoothManifestPermission::FromValue(const base::Value* value) {
if (!value)
return false;
base::string16 error;
- scoped_ptr<BluetoothManifestPermission> manifest_permission(
+ std::unique_ptr<BluetoothManifestPermission> manifest_permission(
BluetoothManifestPermission::FromValue(*value, &error));
if (!manifest_permission)
@@ -150,7 +151,7 @@ bool BluetoothManifestPermission::FromValue(const base::Value* value) {
return true;
}
-scoped_ptr<base::Value> BluetoothManifestPermission::ToValue() const {
+std::unique_ptr<base::Value> BluetoothManifestPermission::ToValue() const {
api::extensions_manifest_types::Bluetooth bluetooth;
bluetooth.uuids.reset(new std::vector<std::string>(uuids_.begin(),
uuids_.end()));
@@ -162,7 +163,7 @@ ManifestPermission* BluetoothManifestPermission::Diff(
const BluetoothManifestPermission* other =
static_cast<const BluetoothManifestPermission*>(rhs);
- scoped_ptr<BluetoothManifestPermission> result(
+ std::unique_ptr<BluetoothManifestPermission> result(
new BluetoothManifestPermission());
result->uuids_ = base::STLSetDifference<BluetoothUuidSet>(
uuids_, other->uuids_);
@@ -174,7 +175,7 @@ ManifestPermission* BluetoothManifestPermission::Union(
const BluetoothManifestPermission* other =
static_cast<const BluetoothManifestPermission*>(rhs);
- scoped_ptr<BluetoothManifestPermission> result(
+ std::unique_ptr<BluetoothManifestPermission> result(
new BluetoothManifestPermission());
result->uuids_ = base::STLSetUnion<BluetoothUuidSet>(
uuids_, other->uuids_);
@@ -186,7 +187,7 @@ ManifestPermission* BluetoothManifestPermission::Intersect(
const BluetoothManifestPermission* other =
static_cast<const BluetoothManifestPermission*>(rhs);
- scoped_ptr<BluetoothManifestPermission> result(
+ std::unique_ptr<BluetoothManifestPermission> result(
new BluetoothManifestPermission());
result->uuids_ = base::STLSetIntersection<BluetoothUuidSet>(
uuids_, other->uuids_);
diff --git a/chromium/extensions/common/api/bluetooth/bluetooth_manifest_permission.h b/chromium/extensions/common/api/bluetooth/bluetooth_manifest_permission.h
index d72b226efff..859b569987c 100644
--- a/chromium/extensions/common/api/bluetooth/bluetooth_manifest_permission.h
+++ b/chromium/extensions/common/api/bluetooth/bluetooth_manifest_permission.h
@@ -29,7 +29,7 @@ class BluetoothManifestPermission : public ManifestPermission {
// Tries to construct the info based on |value|, as it would have appeared in
// the manifest. Sets |error| and returns an empty scoped_ptr on failure.
- static scoped_ptr<BluetoothManifestPermission> FromValue(
+ static std::unique_ptr<BluetoothManifestPermission> FromValue(
const base::Value& value,
base::string16* error);
@@ -46,7 +46,7 @@ class BluetoothManifestPermission : public ManifestPermission {
std::string id() const override;
PermissionIDSet GetPermissions() const override;
bool FromValue(const base::Value* value) override;
- scoped_ptr<base::Value> ToValue() const override;
+ std::unique_ptr<base::Value> ToValue() const override;
ManifestPermission* Diff(const ManifestPermission* rhs) const override;
ManifestPermission* Union(const ManifestPermission* rhs) const override;
ManifestPermission* Intersect(const ManifestPermission* rhs) const override;
diff --git a/chromium/extensions/common/api/declarative/declarative_manifest_data.cc b/chromium/extensions/common/api/declarative/declarative_manifest_data.cc
index 77460f1a8d5..97bc5ebca36 100644
--- a/chromium/extensions/common/api/declarative/declarative_manifest_data.cc
+++ b/chromium/extensions/common/api/declarative/declarative_manifest_data.cc
@@ -61,8 +61,8 @@ class ErrorBuilder {
bool ConvertManifestRule(const linked_ptr<DeclarativeManifestData::Rule>& rule,
ErrorBuilder* error_builder) {
auto convert_list =
- [error_builder](std::vector<scoped_ptr<base::Value>>& list) {
- for (const scoped_ptr<base::Value>& value : list) {
+ [error_builder](std::vector<std::unique_ptr<base::Value>>& list) {
+ for (const std::unique_ptr<base::Value>& value : list) {
base::DictionaryValue* dictionary = nullptr;
if (!value->GetAsDictionary(&dictionary)) {
error_builder->Append("expected dictionary, got %s",
@@ -98,7 +98,7 @@ DeclarativeManifestData* DeclarativeManifestData::Get(
}
// static
-scoped_ptr<DeclarativeManifestData> DeclarativeManifestData::FromValue(
+std::unique_ptr<DeclarativeManifestData> DeclarativeManifestData::FromValue(
const base::Value& value,
base::string16* error) {
// The following is an example of how an event programmatic rule definition
@@ -134,12 +134,13 @@ scoped_ptr<DeclarativeManifestData> DeclarativeManifestData::FromValue(
// event it applies to.
//
ErrorBuilder error_builder(error);
- scoped_ptr<DeclarativeManifestData> result(new DeclarativeManifestData());
+ std::unique_ptr<DeclarativeManifestData> result(
+ new DeclarativeManifestData());
const base::ListValue* list = nullptr;
if (!value.GetAsList(&list)) {
error_builder.Append("'event_rules' expected list, got %s",
ValueTypeToString(&value));
- return scoped_ptr<DeclarativeManifestData>();
+ return std::unique_ptr<DeclarativeManifestData>();
}
for (size_t i = 0; i < list->GetSize(); ++i) {
@@ -151,22 +152,22 @@ scoped_ptr<DeclarativeManifestData> DeclarativeManifestData::FromValue(
ValueTypeToString(value));
else
error_builder.Append("expected dictionary");
- return scoped_ptr<DeclarativeManifestData>();
+ return std::unique_ptr<DeclarativeManifestData>();
}
std::string event;
if (!dict->GetString("event", &event)) {
error_builder.Append("'event' is required");
- return scoped_ptr<DeclarativeManifestData>();
+ return std::unique_ptr<DeclarativeManifestData>();
}
linked_ptr<Rule> rule(new Rule());
if (!Rule::Populate(*dict, rule.get())) {
error_builder.Append("rule failed to populate");
- return scoped_ptr<DeclarativeManifestData>();
+ return std::unique_ptr<DeclarativeManifestData>();
}
if (!ConvertManifestRule(rule, &error_builder))
- return scoped_ptr<DeclarativeManifestData>();
+ return std::unique_ptr<DeclarativeManifestData>();
result->event_rules_map_[event].push_back(rule);
}
diff --git a/chromium/extensions/common/api/declarative/declarative_manifest_data.h b/chromium/extensions/common/api/declarative/declarative_manifest_data.h
index d3147044d19..dba17438227 100644
--- a/chromium/extensions/common/api/declarative/declarative_manifest_data.h
+++ b/chromium/extensions/common/api/declarative/declarative_manifest_data.h
@@ -30,8 +30,9 @@ class DeclarativeManifestData : public Extension::ManifestData {
// Tries to construct the info based on |value|, as it would have appeared in
// the manifest. Sets |error| and returns an empty scoped_ptr on failure.
- static scoped_ptr<DeclarativeManifestData> FromValue(const base::Value& value,
- base::string16* error);
+ static std::unique_ptr<DeclarativeManifestData> FromValue(
+ const base::Value& value,
+ base::string16* error);
std::vector<linked_ptr<DeclarativeManifestData::Rule>>& RulesForEvent(
const std::string& event);
diff --git a/chromium/extensions/common/api/declarative/declarative_manifest_handler.cc b/chromium/extensions/common/api/declarative/declarative_manifest_handler.cc
index b96ddf68ad6..28b04820537 100644
--- a/chromium/extensions/common/api/declarative/declarative_manifest_handler.cc
+++ b/chromium/extensions/common/api/declarative/declarative_manifest_handler.cc
@@ -20,7 +20,7 @@ bool DeclarativeManifestHandler::Parse(Extension* extension,
base::string16* error) {
const base::Value* event_rules = NULL;
CHECK(extension->manifest()->Get(manifest_keys::kEventRules, &event_rules));
- scoped_ptr<DeclarativeManifestData> data =
+ std::unique_ptr<DeclarativeManifestData> data =
DeclarativeManifestData::FromValue(*event_rules, error);
if (!data)
return false;
diff --git a/chromium/extensions/common/api/declarative/declarative_manifest_unittest.cc b/chromium/extensions/common/api/declarative/declarative_manifest_unittest.cc
index fc785e5c587..cacfa73871a 100644
--- a/chromium/extensions/common/api/declarative/declarative_manifest_unittest.cc
+++ b/chromium/extensions/common/api/declarative/declarative_manifest_unittest.cc
@@ -21,7 +21,7 @@ TEST_F(DeclarativeManifestTest, Valid) {
std::vector<linked_ptr<DeclarativeManifestData::Rule>>& rules =
manifest_data->RulesForEvent("foo");
EXPECT_EQ(1u, rules.size());
- scoped_ptr<base::DictionaryValue> expected_rule = ParseDictionary(
+ std::unique_ptr<base::DictionaryValue> expected_rule = ParseDictionary(
"{"
" \"actions\": [{"
" \"instanceType\": \"action_type\""
@@ -35,7 +35,7 @@ TEST_F(DeclarativeManifestTest, Valid) {
TEST_F(DeclarativeManifestTest, ConditionMissingType) {
// Create extension
- scoped_ptr<base::DictionaryValue> manifest_data = ParseDictionary(
+ std::unique_ptr<base::DictionaryValue> manifest_data = ParseDictionary(
"{"
" \"name\": \"Test\","
" \"version\": \"1\","
@@ -57,7 +57,7 @@ TEST_F(DeclarativeManifestTest, ConditionMissingType) {
TEST_F(DeclarativeManifestTest, ConditionNotDictionary) {
// Create extension
- scoped_ptr<base::DictionaryValue> manifest_data = ParseDictionary(
+ std::unique_ptr<base::DictionaryValue> manifest_data = ParseDictionary(
"{"
" \"name\": \"Test\","
" \"version\": \"1\","
@@ -77,7 +77,7 @@ TEST_F(DeclarativeManifestTest, ConditionNotDictionary) {
TEST_F(DeclarativeManifestTest, ActionMissingType) {
// Create extension
- scoped_ptr<base::DictionaryValue> manifest_data = ParseDictionary(
+ std::unique_ptr<base::DictionaryValue> manifest_data = ParseDictionary(
"{"
" \"name\": \"Test\","
" \"version\": \"1\","
@@ -98,7 +98,7 @@ TEST_F(DeclarativeManifestTest, ActionMissingType) {
TEST_F(DeclarativeManifestTest, ActionNotDictionary) {
// Create extension
- scoped_ptr<base::DictionaryValue> manifest_data = ParseDictionary(
+ std::unique_ptr<base::DictionaryValue> manifest_data = ParseDictionary(
"{"
" \"name\": \"Test\","
" \"version\": \"1\","
@@ -119,7 +119,7 @@ TEST_F(DeclarativeManifestTest, ActionNotDictionary) {
TEST_F(DeclarativeManifestTest, EventRulesNotList) {
// Create extension
- scoped_ptr<base::DictionaryValue> manifest_data = ParseDictionary(
+ std::unique_ptr<base::DictionaryValue> manifest_data = ParseDictionary(
"{"
" \"name\": \"Test\","
" \"version\": \"1\","
@@ -131,7 +131,7 @@ TEST_F(DeclarativeManifestTest, EventRulesNotList) {
TEST_F(DeclarativeManifestTest, EventRuleNotDictionary) {
// Create extension
- scoped_ptr<base::DictionaryValue> manifest_data = ParseDictionary(
+ std::unique_ptr<base::DictionaryValue> manifest_data = ParseDictionary(
"{"
" \"name\": \"Test\","
" \"version\": \"1\","
@@ -143,7 +143,7 @@ TEST_F(DeclarativeManifestTest, EventRuleNotDictionary) {
TEST_F(DeclarativeManifestTest, EventMissingFromRule) {
// Create extension
- scoped_ptr<base::DictionaryValue> manifest_data = ParseDictionary(
+ std::unique_ptr<base::DictionaryValue> manifest_data = ParseDictionary(
"{"
" \"name\": \"Test\","
" \"version\": \"1\","
@@ -165,7 +165,7 @@ TEST_F(DeclarativeManifestTest, EventMissingFromRule) {
TEST_F(DeclarativeManifestTest, RuleFailedToPopulate) {
// Create extension
- scoped_ptr<base::DictionaryValue> manifest_data = ParseDictionary(
+ std::unique_ptr<base::DictionaryValue> manifest_data = ParseDictionary(
"{"
" \"name\": \"Test\","
" \"version\": \"1\","
diff --git a/chromium/extensions/common/api/externs_checker.py b/chromium/extensions/common/api/externs_checker.py
index fd60fdd87df..74906bd4883 100644
--- a/chromium/extensions/common/api/externs_checker.py
+++ b/chromium/extensions/common/api/externs_checker.py
@@ -18,7 +18,8 @@ class ExternsChecker(object):
def RunChecks(self):
bad_files = []
- affected = [f.AbsoluteLocalPath() for f in self._input_api.AffectedFiles()]
+ affected = [f.AbsoluteLocalPath() for f in
+ self._input_api.change.AffectedFiles()]
for path in affected:
pair = self._api_pairs.get(path)
if pair != None and pair not in affected:
diff --git a/chromium/extensions/common/api/externs_checker_test.py b/chromium/extensions/common/api/externs_checker_test.py
index 9bcc651b679..a28deafd61f 100755
--- a/chromium/extensions/common/api/externs_checker_test.py
+++ b/chromium/extensions/common/api/externs_checker_test.py
@@ -12,7 +12,8 @@ from externs_checker import ExternsChecker
sys.path.append(
os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', '..'))
-from PRESUBMIT_test_mocks import MockInputApi, MockOutputApi, MockFile
+from PRESUBMIT_test_mocks import (MockInputApi, MockOutputApi, MockFile,
+ MockChange)
class ExternsCheckerTest(unittest.TestCase):
@@ -22,6 +23,7 @@ class ExternsCheckerTest(unittest.TestCase):
input_api = MockInputApi()
input_api.os_path.exists = exists
input_api.files = [MockFile(f, '') for f in files]
+ input_api.change = MockChange(input_api.files)
output_api = MockOutputApi()
checker = ExternsChecker(input_api, output_api, self.API_PAIRS)
return checker.RunChecks()
diff --git a/chromium/extensions/common/api/printer_provider/usb_printer_manifest_data.cc b/chromium/extensions/common/api/printer_provider/usb_printer_manifest_data.cc
index d8480139edc..e7e7acce170 100644
--- a/chromium/extensions/common/api/printer_provider/usb_printer_manifest_data.cc
+++ b/chromium/extensions/common/api/printer_provider/usb_printer_manifest_data.cc
@@ -28,16 +28,16 @@ const UsbPrinterManifestData* UsbPrinterManifestData::Get(
}
// static
-scoped_ptr<UsbPrinterManifestData> UsbPrinterManifestData::FromValue(
+std::unique_ptr<UsbPrinterManifestData> UsbPrinterManifestData::FromValue(
const base::Value& value,
base::string16* error) {
- scoped_ptr<api::extensions_manifest_types::UsbPrinters> usb_printers =
+ std::unique_ptr<api::extensions_manifest_types::UsbPrinters> usb_printers =
api::extensions_manifest_types::UsbPrinters::FromValue(value, error);
if (!usb_printers) {
return nullptr;
}
- scoped_ptr<UsbPrinterManifestData> result(new UsbPrinterManifestData());
+ std::unique_ptr<UsbPrinterManifestData> result(new UsbPrinterManifestData());
for (const auto& input : usb_printers->filters) {
UsbDeviceFilter output;
output.SetVendorId(input.vendor_id);
diff --git a/chromium/extensions/common/api/printer_provider/usb_printer_manifest_data.h b/chromium/extensions/common/api/printer_provider/usb_printer_manifest_data.h
index ed397f0ede0..007c69b57dd 100644
--- a/chromium/extensions/common/api/printer_provider/usb_printer_manifest_data.h
+++ b/chromium/extensions/common/api/printer_provider/usb_printer_manifest_data.h
@@ -28,8 +28,9 @@ class UsbPrinterManifestData : public Extension::ManifestData {
// Parses the data stored in |value|. Sets |error| and returns an empty
// scoped_ptr on failure.
- static scoped_ptr<UsbPrinterManifestData> FromValue(const base::Value& value,
- base::string16* error);
+ static std::unique_ptr<UsbPrinterManifestData> FromValue(
+ const base::Value& value,
+ base::string16* error);
bool SupportsDevice(const scoped_refptr<device::UsbDevice>& device) const;
diff --git a/chromium/extensions/common/api/printer_provider/usb_printer_manifest_handler.cc b/chromium/extensions/common/api/printer_provider/usb_printer_manifest_handler.cc
index e356050b7e1..eb6468f8201 100644
--- a/chromium/extensions/common/api/printer_provider/usb_printer_manifest_handler.cc
+++ b/chromium/extensions/common/api/printer_provider/usb_printer_manifest_handler.cc
@@ -20,7 +20,7 @@ bool UsbPrinterManifestHandler::Parse(Extension* extension,
base::string16* error) {
const base::Value* usb_printers = nullptr;
CHECK(extension->manifest()->Get(manifest_keys::kUsbPrinters, &usb_printers));
- scoped_ptr<UsbPrinterManifestData> data =
+ std::unique_ptr<UsbPrinterManifestData> data =
UsbPrinterManifestData::FromValue(*usb_printers, error);
if (!data) {
return false;
diff --git a/chromium/extensions/common/api/runtime.json b/chromium/extensions/common/api/runtime.json
index d4a4e5980ca..c36c6c74879 100644
--- a/chromium/extensions/common/api/runtime.json
+++ b/chromium/extensions/common/api/runtime.json
@@ -14,17 +14,35 @@
"id": "Port",
"type": "object",
"nocompile": true,
- "description": "An object which allows two way communication with other pages.",
+ "description": "An object which allows two way communication with other pages. See <a href=\"messaging#connect\">Long-lived connections</a> for more information.",
"properties": {
- "name": {"type": "string"},
- "disconnect": { "type": "function" },
- "onDisconnect": { "$ref": "events.Event" },
- "onMessage": { "$ref": "events.Event" },
- "postMessage": {"type": "function"},
+ "name": {
+ "type": "string",
+ "description": "The name of the port, as specified in the call to $(ref:runtime.connect)."
+ },
+ "disconnect": {
+ "type": "function",
+ "description": "Immediately disconnect the port. Calling <code>disconnect()</code> on an already-disconnected port has no effect. When a port is disconnected, no new events will be dispatched to this port."
+ },
+ "onDisconnect": {
+ "$ref": "events.Event",
+ "description": "Fired when the port is disconnected from the other end(s). $(ref:runtime.lastError) may be set if the port was disconnected by an error. If the port is closed via $(ref:Port.disconnect disconnect), then this event is <em>only</em> fired on the other end. This event is fired at most once (see also <a href=\"messaging#port-lifetime\">Port lifetime</a>). The first and only parameter to the event handler is this disconnected port."
+ },
+ "onMessage": {
+ "$ref": "events.Event",
+ "description": "This event is fired when $(ref:Port.postMessage postMessage) is called by the other end of the port. The first parameter is the message, the second parameter is the port that received the message."
+ },
+ "postMessage": {
+ "type": "function",
+ "description": "Send a message to the other end of the port. If the port is disconnected, an error is thrown.",
+ "parameters": [
+ {"name": "message", "type": "any", "description": "The message to send. This object should be JSON-ifiable."}
+ ]
+ },
"sender": {
"$ref": "MessageSender",
"optional": true,
- "description": "This property will <b>only</b> be present on ports passed to onConnect/onConnectExternal listeners."
+ "description": "This property will <b>only</b> be present on ports passed to $(ref:runtime.onConnect onConnect) / $(ref:runtime.onConnectExternal onConnectExternal) listeners."
}
},
"additionalProperties": { "type": "any"}
@@ -212,7 +230,7 @@
{
"name": "requestUpdateCheck",
"type": "function",
- "description": "Requests an update check for this app/extension.",
+ "description": "<p>Requests an immediate update check be done for this app/extension.</p> <p><b>Important</b>: Most extensions/apps should <b>not</b> use this method, since chrome already does automatic checks every few hours, and you can listen for the $(ref:runtime.onUpdateAvailable) event without needing to call requestUpdateCheck.</p><p>This method is only appropriate to call in very limited circumstances, such as if your extension/app talks to a backend service, and the backend service has determined that the client extension/app version is very far out of date and you'd like to prompt a user to update. Most other uses of requestUpdateCheck, such as calling it unconditionally based on a repeating timer, probably only serve to waste client, network, and server resources.</p>",
"parameters": [
{
"type": "function",
@@ -249,7 +267,7 @@
"name": "connect",
"type": "function",
"nocompile": true,
- "description": "Attempts to connect to connect listeners within an extension/app (such as the background page), or other extensions/apps. This is useful for content scripts connecting to their extension processes, inter-app/extension communication, and <a href=\"manifest/externally_connectable.html\">web messaging</a>. Note that this does not connect to any listeners in a content script. Extensions may connect to content scripts embedded in tabs via <a href=\"extensions/tabs#method-connect\">tabs.connect</a>.",
+ "description": "Attempts to connect to connect listeners within an extension/app (such as the background page), or other extensions/apps. This is useful for content scripts connecting to their extension processes, inter-app/extension communication, and <a href=\"manifest/externally_connectable.html\">web messaging</a>. Note that this does not connect to any listeners in a content script. Extensions may connect to content scripts embedded in tabs via $(ref:tabs.connect).",
"parameters": [
{"type": "string", "name": "extensionId", "optional": true, "description": "The ID of the extension or app to connect to. If omitted, a connection will be attempted with your own extension. Required if sending messages from a web page for <a href=\"manifest/externally_connectable.html\">web messaging</a>."},
{
@@ -264,14 +282,15 @@
],
"returns": {
"$ref": "Port",
- "description": "Port through which messages can be sent and received. The port's $(ref:runtime.Port onDisconnect) event is fired if the extension/app does not exist. "
+ // TODO(robwu): This description should appear in the documentation, but the docserver does not render it.
+ "description": "Port through which messages can be sent and received. The port's $(ref:Port onDisconnect) event is fired if the extension/app does not exist. "
}
},
{
"name": "connectNative",
"type": "function",
"nocompile": true,
- "description": "Connects to a native application in the host machine.",
+ "description": "Connects to a native application in the host machine. See <a href=\"nativeMessaging\">Native Messaging</a> for more information.",
"parameters": [
{
"type": "string",
@@ -289,10 +308,10 @@
"type": "function",
"nocompile": true,
"allowAmbiguousOptionalArguments": true,
- "description": "Sends a single message to event listeners within your extension/app or a different extension/app. Similar to $(ref:runtime.connect) but only sends a single message, with an optional response. If sending to your extension, the $(ref:runtime.onMessage) event will be fired in each page, or $(ref:runtime.onMessageExternal), if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use <a href=\"extensions/tabs#method-sendMessage\">tabs.sendMessage</a>.",
+ "description": "Sends a single message to event listeners within your extension/app or a different extension/app. Similar to $(ref:runtime.connect) but only sends a single message, with an optional response. If sending to your extension, the $(ref:runtime.onMessage) event will be fired in each page, or $(ref:runtime.onMessageExternal), if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use $(ref:tabs.sendMessage).",
"parameters": [
{"type": "string", "name": "extensionId", "optional": true, "description": "The ID of the extension/app to send the message to. If omitted, the message will be sent to your own extension/app. Required if sending messages from a web page for <a href=\"manifest/externally_connectable.html\">web messaging</a>."},
- { "type": "any", "name": "message" },
+ { "type": "any", "name": "message", "description": "The message to send. This message should be a JSON-ifiable object." },
{
"type": "object",
"name": "options",
@@ -467,7 +486,7 @@
"options": {
"unmanaged": true
},
- "description": "Fired when a connection is made from either an extension process or a content script.",
+ "description": "Fired when a connection is made from either an extension process or a content script (by $(ref:runtime.connect)).",
"parameters": [
{"$ref": "Port", "name": "port"}
]
@@ -476,7 +495,7 @@
"name": "onConnectExternal",
"type": "function",
"nocompile": true,
- "description": "Fired when a connection is made from another extension.",
+ "description": "Fired when a connection is made from another extension (by $(ref:runtime.connect)).",
"parameters": [
{"$ref": "Port", "name": "port"}
]
@@ -488,11 +507,11 @@
"options": {
"unmanaged": true
},
- "description": "Fired when a message is sent from either an extension process or a content script.",
+ "description": "Fired when a message is sent from either an extension process (by $(ref:runtime.sendMessage)) or a content script (by $(ref:tabs.sendMessage)).",
"parameters": [
{"name": "message", "type": "any", "optional": true, "description": "The message sent by the calling script."},
{"name": "sender", "$ref": "MessageSender" },
- {"name": "sendResponse", "type": "function", "description": "Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object. If you have more than one <code>onMessage</code> listener in the same document, then only one may send a response. This function becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until <code>sendResponse</code> is called)." }
+ {"name": "sendResponse", "type": "function", "description": "Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object. If you have more than one <code>onMessage</code> listener in the same document, then only one may send a response. This function becomes invalid when the event listener returns, <strong>unless you return true</strong> from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until <code>sendResponse</code> is called)." }
],
"returns": {
"type": "boolean",
@@ -504,11 +523,11 @@
"name": "onMessageExternal",
"type": "function",
"nocompile": true,
- "description": "Fired when a message is sent from another extension/app. Cannot be used in a content script.",
+ "description": "Fired when a message is sent from another extension/app (by $(ref:runtime.sendMessage)). Cannot be used in a content script.",
"parameters": [
{"name": "message", "type": "any", "optional": true, "description": "The message sent by the calling script."},
{"name": "sender", "$ref": "MessageSender" },
- {"name": "sendResponse", "type": "function", "description": "Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object. If you have more than one <code>onMessage</code> listener in the same document, then only one may send a response. This function becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until <code>sendResponse</code> is called)." }
+ {"name": "sendResponse", "type": "function", "description": "Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object. If you have more than one <code>onMessage</code> listener in the same document, then only one may send a response. This function becomes invalid when the event listener returns, <strong>unless you return true</strong> from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until <code>sendResponse</code> is called)." }
],
"returns": {
"type": "boolean",
diff --git a/chromium/extensions/common/api/sockets/sockets_manifest_data.cc b/chromium/extensions/common/api/sockets/sockets_manifest_data.cc
index 9cedcf8c6af..1b877bb867e 100644
--- a/chromium/extensions/common/api/sockets/sockets_manifest_data.cc
+++ b/chromium/extensions/common/api/sockets/sockets_manifest_data.cc
@@ -12,7 +12,7 @@
namespace extensions {
SocketsManifestData::SocketsManifestData(
- scoped_ptr<SocketsManifestPermission> permission)
+ std::unique_ptr<SocketsManifestPermission> permission)
: permission_(std::move(permission)) {
DCHECK(permission_);
}
@@ -37,15 +37,15 @@ bool SocketsManifestData::CheckRequest(
}
// static
-scoped_ptr<SocketsManifestData> SocketsManifestData::FromValue(
+std::unique_ptr<SocketsManifestData> SocketsManifestData::FromValue(
const base::Value& value,
base::string16* error) {
- scoped_ptr<SocketsManifestPermission> permission =
+ std::unique_ptr<SocketsManifestPermission> permission =
SocketsManifestPermission::FromValue(value, error);
if (!permission)
- return scoped_ptr<SocketsManifestData>();
+ return std::unique_ptr<SocketsManifestData>();
- return scoped_ptr<SocketsManifestData>(
+ return std::unique_ptr<SocketsManifestData>(
new SocketsManifestData(std::move(permission)));
}
diff --git a/chromium/extensions/common/api/sockets/sockets_manifest_data.h b/chromium/extensions/common/api/sockets/sockets_manifest_data.h
index de9dd8f5717..08c6f69a4db 100644
--- a/chromium/extensions/common/api/sockets/sockets_manifest_data.h
+++ b/chromium/extensions/common/api/sockets/sockets_manifest_data.h
@@ -25,7 +25,7 @@ namespace extensions {
class SocketsManifestData : public Extension::ManifestData {
public:
explicit SocketsManifestData(
- scoped_ptr<SocketsManifestPermission> permission);
+ std::unique_ptr<SocketsManifestPermission> permission);
~SocketsManifestData() override;
// Gets the SocketsManifestData for |extension|, or NULL if none was
@@ -37,15 +37,16 @@ class SocketsManifestData : public Extension::ManifestData {
// Tries to construct the info based on |value|, as it would have appeared in
// the manifest. Sets |error| and returns an empty scoped_ptr on failure.
- static scoped_ptr<SocketsManifestData> FromValue(const base::Value& value,
- base::string16* error);
+ static std::unique_ptr<SocketsManifestData> FromValue(
+ const base::Value& value,
+ base::string16* error);
const SocketsManifestPermission* permission() const {
return permission_.get();
}
private:
- scoped_ptr<SocketsManifestPermission> permission_;
+ std::unique_ptr<SocketsManifestPermission> permission_;
};
} // namespace extensions
diff --git a/chromium/extensions/common/api/sockets/sockets_manifest_handler.cc b/chromium/extensions/common/api/sockets/sockets_manifest_handler.cc
index 113dc6eca5a..cad731efaa6 100644
--- a/chromium/extensions/common/api/sockets/sockets_manifest_handler.cc
+++ b/chromium/extensions/common/api/sockets/sockets_manifest_handler.cc
@@ -19,7 +19,7 @@ bool SocketsManifestHandler::Parse(Extension* extension,
base::string16* error) {
const base::Value* sockets = NULL;
CHECK(extension->manifest()->Get(manifest_keys::kSockets, &sockets));
- scoped_ptr<SocketsManifestData> data =
+ std::unique_ptr<SocketsManifestData> data =
SocketsManifestData::FromValue(*sockets, error);
if (!data)
return false;
diff --git a/chromium/extensions/common/api/sockets/sockets_manifest_permission.cc b/chromium/extensions/common/api/sockets/sockets_manifest_permission.cc
index fa0c98ac692..aa9041229b5 100644
--- a/chromium/extensions/common/api/sockets/sockets_manifest_permission.cc
+++ b/chromium/extensions/common/api/sockets/sockets_manifest_permission.cc
@@ -4,7 +4,8 @@
#include "extensions/common/api/sockets/sockets_manifest_permission.h"
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "base/stl_util.h"
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
@@ -49,7 +50,7 @@ static bool ParseHostPattern(
static bool ParseHostPatterns(
SocketsManifestPermission* permission,
content::SocketPermissionRequest::OperationType operation_type,
- const scoped_ptr<SocketHostPatterns>& host_patterns,
+ const std::unique_ptr<SocketHostPatterns>& host_patterns,
base::string16* error) {
if (!host_patterns)
return true;
@@ -72,7 +73,7 @@ static bool ParseHostPatterns(
}
static void SetHostPatterns(
- scoped_ptr<SocketHostPatterns>& host_patterns,
+ std::unique_ptr<SocketHostPatterns>& host_patterns,
const SocketsManifestPermission* permission,
content::SocketPermissionRequest::OperationType operation_type) {
host_patterns.reset(new SocketHostPatterns());
@@ -149,32 +150,33 @@ SocketsManifestPermission::SocketsManifestPermission() {}
SocketsManifestPermission::~SocketsManifestPermission() {}
// static
-scoped_ptr<SocketsManifestPermission> SocketsManifestPermission::FromValue(
+std::unique_ptr<SocketsManifestPermission> SocketsManifestPermission::FromValue(
const base::Value& value,
base::string16* error) {
- scoped_ptr<Sockets> sockets = Sockets::FromValue(value, error);
+ std::unique_ptr<Sockets> sockets = Sockets::FromValue(value, error);
if (!sockets)
- return scoped_ptr<SocketsManifestPermission>();
+ return std::unique_ptr<SocketsManifestPermission>();
- scoped_ptr<SocketsManifestPermission> result(new SocketsManifestPermission());
+ std::unique_ptr<SocketsManifestPermission> result(
+ new SocketsManifestPermission());
if (sockets->udp) {
if (!ParseHostPatterns(result.get(),
SocketPermissionRequest::UDP_BIND,
sockets->udp->bind,
error)) {
- return scoped_ptr<SocketsManifestPermission>();
+ return std::unique_ptr<SocketsManifestPermission>();
}
if (!ParseHostPatterns(result.get(),
SocketPermissionRequest::UDP_SEND_TO,
sockets->udp->send,
error)) {
- return scoped_ptr<SocketsManifestPermission>();
+ return std::unique_ptr<SocketsManifestPermission>();
}
if (!ParseHostPatterns(result.get(),
SocketPermissionRequest::UDP_MULTICAST_MEMBERSHIP,
sockets->udp->multicast_membership,
error)) {
- return scoped_ptr<SocketsManifestPermission>();
+ return std::unique_ptr<SocketsManifestPermission>();
}
}
if (sockets->tcp) {
@@ -182,7 +184,7 @@ scoped_ptr<SocketsManifestPermission> SocketsManifestPermission::FromValue(
SocketPermissionRequest::TCP_CONNECT,
sockets->tcp->connect,
error)) {
- return scoped_ptr<SocketsManifestPermission>();
+ return std::unique_ptr<SocketsManifestPermission>();
}
}
if (sockets->tcp_server) {
@@ -190,7 +192,7 @@ scoped_ptr<SocketsManifestPermission> SocketsManifestPermission::FromValue(
SocketPermissionRequest::TCP_LISTEN,
sockets->tcp_server->listen,
error)) {
- return scoped_ptr<SocketsManifestPermission>();
+ return std::unique_ptr<SocketsManifestPermission>();
}
}
return result;
@@ -224,7 +226,7 @@ bool SocketsManifestPermission::FromValue(const base::Value* value) {
if (!value)
return false;
base::string16 error;
- scoped_ptr<SocketsManifestPermission> manifest_permission(
+ std::unique_ptr<SocketsManifestPermission> manifest_permission(
SocketsManifestPermission::FromValue(*value, &error));
if (!manifest_permission)
@@ -234,7 +236,7 @@ bool SocketsManifestPermission::FromValue(const base::Value* value) {
return true;
}
-scoped_ptr<base::Value> SocketsManifestPermission::ToValue() const {
+std::unique_ptr<base::Value> SocketsManifestPermission::ToValue() const {
Sockets sockets;
sockets.udp.reset(new Sockets::Udp());
@@ -264,7 +266,7 @@ scoped_ptr<base::Value> SocketsManifestPermission::ToValue() const {
sockets.tcp_server.reset(NULL);
}
- return scoped_ptr<base::Value>(sockets.ToValue().release());
+ return std::unique_ptr<base::Value>(sockets.ToValue().release());
}
ManifestPermission* SocketsManifestPermission::Diff(
@@ -272,7 +274,8 @@ ManifestPermission* SocketsManifestPermission::Diff(
const SocketsManifestPermission* other =
static_cast<const SocketsManifestPermission*>(rhs);
- scoped_ptr<SocketsManifestPermission> result(new SocketsManifestPermission());
+ std::unique_ptr<SocketsManifestPermission> result(
+ new SocketsManifestPermission());
result->permissions_ = base::STLSetDifference<SocketPermissionEntrySet>(
permissions_, other->permissions_);
return result.release();
@@ -283,7 +286,8 @@ ManifestPermission* SocketsManifestPermission::Union(
const SocketsManifestPermission* other =
static_cast<const SocketsManifestPermission*>(rhs);
- scoped_ptr<SocketsManifestPermission> result(new SocketsManifestPermission());
+ std::unique_ptr<SocketsManifestPermission> result(
+ new SocketsManifestPermission());
result->permissions_ = base::STLSetUnion<SocketPermissionEntrySet>(
permissions_, other->permissions_);
return result.release();
@@ -294,7 +298,8 @@ ManifestPermission* SocketsManifestPermission::Intersect(
const SocketsManifestPermission* other =
static_cast<const SocketsManifestPermission*>(rhs);
- scoped_ptr<SocketsManifestPermission> result(new SocketsManifestPermission());
+ std::unique_ptr<SocketsManifestPermission> result(
+ new SocketsManifestPermission());
result->permissions_ = base::STLSetIntersection<SocketPermissionEntrySet>(
permissions_, other->permissions_);
return result.release();
diff --git a/chromium/extensions/common/api/sockets/sockets_manifest_permission.h b/chromium/extensions/common/api/sockets/sockets_manifest_permission.h
index 555795769a0..3d1b92c693c 100644
--- a/chromium/extensions/common/api/sockets/sockets_manifest_permission.h
+++ b/chromium/extensions/common/api/sockets/sockets_manifest_permission.h
@@ -31,7 +31,7 @@ class SocketsManifestPermission : public ManifestPermission {
// Tries to construct the info based on |value|, as it would have appeared in
// the manifest. Sets |error| and returns an empty scoped_ptr on failure.
- static scoped_ptr<SocketsManifestPermission> FromValue(
+ static std::unique_ptr<SocketsManifestPermission> FromValue(
const base::Value& value,
base::string16* error);
@@ -45,7 +45,7 @@ class SocketsManifestPermission : public ManifestPermission {
std::string id() const override;
PermissionIDSet GetPermissions() const override;
bool FromValue(const base::Value* value) override;
- scoped_ptr<base::Value> ToValue() const override;
+ std::unique_ptr<base::Value> ToValue() const override;
ManifestPermission* Diff(const ManifestPermission* rhs) const override;
ManifestPermission* Union(const ManifestPermission* rhs) const override;
ManifestPermission* Intersect(const ManifestPermission* rhs) const override;
diff --git a/chromium/extensions/common/api/sockets/sockets_manifest_permission_unittest.cc b/chromium/extensions/common/api/sockets/sockets_manifest_permission_unittest.cc
index d0dc6099e8d..fa970cecafc 100644
--- a/chromium/extensions/common/api/sockets/sockets_manifest_permission_unittest.cc
+++ b/chromium/extensions/common/api/sockets/sockets_manifest_permission_unittest.cc
@@ -40,24 +40,25 @@ static void AssertEmptyPermission(const SocketsManifestPermission* permission) {
EXPECT_EQ(0u, permission->entries().size());
}
-static scoped_ptr<base::Value> ParsePermissionJSON(const std::string& json) {
- scoped_ptr<base::Value> result(base::JSONReader::Read(json));
+static std::unique_ptr<base::Value> ParsePermissionJSON(
+ const std::string& json) {
+ std::unique_ptr<base::Value> result(base::JSONReader::Read(json));
EXPECT_TRUE(result) << "Invalid JSON string: " << json;
return result;
}
-static scoped_ptr<SocketsManifestPermission> PermissionFromValue(
+static std::unique_ptr<SocketsManifestPermission> PermissionFromValue(
const base::Value& value) {
base::string16 error16;
- scoped_ptr<SocketsManifestPermission> permission(
+ std::unique_ptr<SocketsManifestPermission> permission(
SocketsManifestPermission::FromValue(value, &error16));
EXPECT_TRUE(permission) << "Error parsing Value into permission: " << error16;
return permission;
}
-static scoped_ptr<SocketsManifestPermission> PermissionFromJSON(
+static std::unique_ptr<SocketsManifestPermission> PermissionFromJSON(
const std::string& json) {
- scoped_ptr<base::Value> value(ParsePermissionJSON(json));
+ std::unique_ptr<base::Value> value(ParsePermissionJSON(json));
return PermissionFromValue(*value);
}
@@ -85,7 +86,8 @@ struct CheckFormatEntry {
static testing::AssertionResult CheckFormat(
std::multiset<CheckFormatEntry> permissions,
const std::string& json) {
- scoped_ptr<SocketsManifestPermission> permission(PermissionFromJSON(json));
+ std::unique_ptr<SocketsManifestPermission> permission(
+ PermissionFromJSON(json));
if (!permission)
return testing::AssertionFailure() << "Invalid permission " << json;
@@ -152,44 +154,44 @@ static testing::AssertionResult CheckFormat(const std::string& json,
TEST(SocketsManifestPermissionTest, Empty) {
// Construction
- scoped_ptr<SocketsManifestPermission> permission(
+ std::unique_ptr<SocketsManifestPermission> permission(
new SocketsManifestPermission());
AssertEmptyPermission(permission.get());
// Clone()/Equal()
- scoped_ptr<SocketsManifestPermission> clone(
+ std::unique_ptr<SocketsManifestPermission> clone(
static_cast<SocketsManifestPermission*>(permission->Clone()));
AssertEmptyPermission(clone.get());
EXPECT_TRUE(permission->Equal(clone.get()));
// ToValue()/FromValue()
- scoped_ptr<const base::Value> value(permission->ToValue());
+ std::unique_ptr<const base::Value> value(permission->ToValue());
EXPECT_TRUE(value.get());
- scoped_ptr<SocketsManifestPermission> permission2(
+ std::unique_ptr<SocketsManifestPermission> permission2(
new SocketsManifestPermission());
EXPECT_TRUE(permission2->FromValue(value.get()));
AssertEmptyPermission(permission2.get());
// Union/Diff/Intersection
- scoped_ptr<SocketsManifestPermission> diff_perm(
+ std::unique_ptr<SocketsManifestPermission> diff_perm(
static_cast<SocketsManifestPermission*>(permission->Diff(clone.get())));
AssertEmptyPermission(diff_perm.get());
- scoped_ptr<SocketsManifestPermission> union_perm(
+ std::unique_ptr<SocketsManifestPermission> union_perm(
static_cast<SocketsManifestPermission*>(permission->Union(clone.get())));
AssertEmptyPermission(union_perm.get());
- scoped_ptr<SocketsManifestPermission> intersect_perm(
+ std::unique_ptr<SocketsManifestPermission> intersect_perm(
static_cast<SocketsManifestPermission*>(
permission->Intersect(clone.get())));
AssertEmptyPermission(intersect_perm.get());
// IPC
- scoped_ptr<SocketsManifestPermission> ipc_perm(
+ std::unique_ptr<SocketsManifestPermission> ipc_perm(
new SocketsManifestPermission());
- scoped_ptr<SocketsManifestPermission> ipc_perm2(
+ std::unique_ptr<SocketsManifestPermission> ipc_perm2(
new SocketsManifestPermission());
IPC::Message m;
@@ -281,76 +283,78 @@ TEST(SocketsManifestPermissionTest, JSONFormats) {
}
TEST(SocketsManifestPermissionTest, FromToValue) {
- scoped_ptr<base::Value> udp_send(ParsePermissionJSON(kUdpBindPermission));
- scoped_ptr<base::Value> udp_bind(ParsePermissionJSON(kUdpSendPermission));
- scoped_ptr<base::Value> tcp_connect(
+ std::unique_ptr<base::Value> udp_send(
+ ParsePermissionJSON(kUdpBindPermission));
+ std::unique_ptr<base::Value> udp_bind(
+ ParsePermissionJSON(kUdpSendPermission));
+ std::unique_ptr<base::Value> tcp_connect(
ParsePermissionJSON(kTcpConnectPermission));
- scoped_ptr<base::Value> tcp_server_listen(
+ std::unique_ptr<base::Value> tcp_server_listen(
ParsePermissionJSON(kTcpServerListenPermission));
// FromValue()
- scoped_ptr<SocketsManifestPermission> permission1(
+ std::unique_ptr<SocketsManifestPermission> permission1(
new SocketsManifestPermission());
EXPECT_TRUE(permission1->FromValue(udp_send.get()));
EXPECT_EQ(2u, permission1->entries().size());
- scoped_ptr<SocketsManifestPermission> permission2(
+ std::unique_ptr<SocketsManifestPermission> permission2(
new SocketsManifestPermission());
EXPECT_TRUE(permission2->FromValue(udp_bind.get()));
EXPECT_EQ(2u, permission2->entries().size());
- scoped_ptr<SocketsManifestPermission> permission3(
+ std::unique_ptr<SocketsManifestPermission> permission3(
new SocketsManifestPermission());
EXPECT_TRUE(permission3->FromValue(tcp_connect.get()));
EXPECT_EQ(2u, permission3->entries().size());
- scoped_ptr<SocketsManifestPermission> permission4(
+ std::unique_ptr<SocketsManifestPermission> permission4(
new SocketsManifestPermission());
EXPECT_TRUE(permission4->FromValue(tcp_server_listen.get()));
EXPECT_EQ(2u, permission4->entries().size());
// ToValue()
- scoped_ptr<base::Value> value1 = permission1->ToValue();
+ std::unique_ptr<base::Value> value1 = permission1->ToValue();
EXPECT_TRUE(value1);
- scoped_ptr<SocketsManifestPermission> permission1_1(
+ std::unique_ptr<SocketsManifestPermission> permission1_1(
new SocketsManifestPermission());
EXPECT_TRUE(permission1_1->FromValue(value1.get()));
EXPECT_TRUE(permission1->Equal(permission1_1.get()));
- scoped_ptr<base::Value> value2 = permission2->ToValue();
+ std::unique_ptr<base::Value> value2 = permission2->ToValue();
EXPECT_TRUE(value2);
- scoped_ptr<SocketsManifestPermission> permission2_1(
+ std::unique_ptr<SocketsManifestPermission> permission2_1(
new SocketsManifestPermission());
EXPECT_TRUE(permission2_1->FromValue(value2.get()));
EXPECT_TRUE(permission2->Equal(permission2_1.get()));
- scoped_ptr<base::Value> value3 = permission3->ToValue();
+ std::unique_ptr<base::Value> value3 = permission3->ToValue();
EXPECT_TRUE(value3);
- scoped_ptr<SocketsManifestPermission> permission3_1(
+ std::unique_ptr<SocketsManifestPermission> permission3_1(
new SocketsManifestPermission());
EXPECT_TRUE(permission3_1->FromValue(value3.get()));
EXPECT_TRUE(permission3->Equal(permission3_1.get()));
- scoped_ptr<base::Value> value4 = permission4->ToValue();
+ std::unique_ptr<base::Value> value4 = permission4->ToValue();
EXPECT_TRUE(value4);
- scoped_ptr<SocketsManifestPermission> permission4_1(
+ std::unique_ptr<SocketsManifestPermission> permission4_1(
new SocketsManifestPermission());
EXPECT_TRUE(permission4_1->FromValue(value4.get()));
EXPECT_TRUE(permission4->Equal(permission4_1.get()));
}
TEST(SocketsManifestPermissionTest, SetOperations) {
- scoped_ptr<SocketsManifestPermission> permission1(
+ std::unique_ptr<SocketsManifestPermission> permission1(
PermissionFromJSON(kUdpBindPermission));
- scoped_ptr<SocketsManifestPermission> permission2(
+ std::unique_ptr<SocketsManifestPermission> permission2(
PermissionFromJSON(kUdpSendPermission));
- scoped_ptr<SocketsManifestPermission> permission3(
+ std::unique_ptr<SocketsManifestPermission> permission3(
PermissionFromJSON(kTcpConnectPermission));
- scoped_ptr<SocketsManifestPermission> permission4(
+ std::unique_ptr<SocketsManifestPermission> permission4(
PermissionFromJSON(kTcpServerListenPermission));
// Union
- scoped_ptr<SocketsManifestPermission> union_perm(
+ std::unique_ptr<SocketsManifestPermission> union_perm(
static_cast<SocketsManifestPermission*>(
permission1->Union(permission2.get())));
EXPECT_TRUE(union_perm);
@@ -362,7 +366,7 @@ TEST(SocketsManifestPermissionTest, SetOperations) {
EXPECT_FALSE(union_perm->Contains(permission4.get()));
// Diff
- scoped_ptr<SocketsManifestPermission> diff_perm1(
+ std::unique_ptr<SocketsManifestPermission> diff_perm1(
static_cast<SocketsManifestPermission*>(
permission1->Diff(permission2.get())));
EXPECT_TRUE(diff_perm1);
@@ -371,14 +375,14 @@ TEST(SocketsManifestPermissionTest, SetOperations) {
EXPECT_TRUE(permission1->Equal(diff_perm1.get()));
EXPECT_TRUE(diff_perm1->Equal(permission1.get()));
- scoped_ptr<SocketsManifestPermission> diff_perm2(
+ std::unique_ptr<SocketsManifestPermission> diff_perm2(
static_cast<SocketsManifestPermission*>(
permission1->Diff(union_perm.get())));
EXPECT_TRUE(diff_perm2);
AssertEmptyPermission(diff_perm2.get());
// Intersection
- scoped_ptr<SocketsManifestPermission> intersect_perm1(
+ std::unique_ptr<SocketsManifestPermission> intersect_perm1(
static_cast<SocketsManifestPermission*>(
union_perm->Intersect(permission1.get())));
EXPECT_TRUE(intersect_perm1);
@@ -389,12 +393,12 @@ TEST(SocketsManifestPermissionTest, SetOperations) {
}
TEST(SocketsManifestPermissionTest, IPC) {
- scoped_ptr<SocketsManifestPermission> permission(
+ std::unique_ptr<SocketsManifestPermission> permission(
PermissionFromJSON(kUdpBindPermission));
- scoped_ptr<SocketsManifestPermission> ipc_perm(
+ std::unique_ptr<SocketsManifestPermission> ipc_perm(
static_cast<SocketsManifestPermission*>(permission->Clone()));
- scoped_ptr<SocketsManifestPermission> ipc_perm2(
+ std::unique_ptr<SocketsManifestPermission> ipc_perm2(
new SocketsManifestPermission());
IPC::Message m;
diff --git a/chromium/extensions/common/api/system_display.idl b/chromium/extensions/common/api/system_display.idl
index 4e3c9e5b63a..ccb4a716dda 100644
--- a/chromium/extensions/common/api/system_display.idl
+++ b/chromium/extensions/common/api/system_display.idl
@@ -33,6 +33,32 @@ namespace system.display {
long bottom;
};
+ dictionary DisplayMode {
+ // The display mode width in device independent (user visible) pixels.
+ long width;
+
+ // The display mode height in device independent (user visible) pixels.
+ long height;
+
+ // The display mode width in native pixels.
+ long widthInNativePixels;
+
+ // The display mode height in native pixels.
+ long heightInNativePixels;
+
+ // The display mode UI scale factor.
+ double uiScale;
+
+ // The display mode device scale factor.
+ double deviceScaleFactor;
+
+ // True if the mode is the display's native mode.
+ boolean isNative;
+
+ // True if the display mode is currently selected.
+ boolean isSelected;
+ };
+
dictionary DisplayUnitInfo {
// The unique identifier of the display.
DOMString id;
@@ -40,10 +66,9 @@ namespace system.display {
// The user-friendly name (e.g. "HP LCD monitor").
DOMString name;
- // Identifier of the display that is being mirrored on the display unit.
- // If mirroring is not in progress, set to an empty string.
- // Currently exposed only on ChromeOS. Will be empty string on other
- // platforms.
+ // Chrome OS only. Identifier of the display that is being mirrored if
+ // mirroring is enabled, otherwise empty. This will be set for all displays
+ // (including the display being mirrored).
DOMString mirroringSourceId;
// True if this is the primary display.
@@ -78,15 +103,18 @@ namespace system.display {
// area excludes areas of the display reserved for OS, for example taskbar
// and launcher.
Bounds workArea;
+
+ // The list of available display modes. The current mode will have
+ // isSelected=true. Only available on Chrome OS. Will be set to an empty
+ // array on other platforms.
+ DisplayMode[] modes;
};
dictionary DisplayProperties {
- // If set and not empty, starts mirroring between this and the display with
- // the provided id (the system will determine which of the displays is
- // actually mirrored).
- // If set and not empty, stops mirroring between this and the display with
- // the specified id (if mirroring is in progress).
- // If set, no other parameter may be set.
+ // Chrome OS only. If set and not empty, enables mirroring for this display.
+ // Otherwise disables mirroring for this display. This value should indicate
+ // the id of the source display to mirror, which must not be the same as the
+ // id passed to setDisplayProperties. If set, no other property may be set.
DOMString? mirroringSourceId;
// If set to true, makes the display primary. No-op if set to false.
@@ -118,6 +146,9 @@ namespace system.display {
// If set, updates the display's logical bounds origin along y-axis.
// See documentation for <code>boundsOriginX</code> parameter.
long? boundsOriginY;
+
+ // If set, updates the display mode to the mode matching this value.
+ DisplayMode? displayMode;
};
callback DisplayInfoCallback = void (DisplayUnitInfo[] displayInfo);
@@ -130,6 +161,7 @@ namespace system.display {
// Updates the properties for the display specified by |id|, according to
// the information provided in |info|. On failure, $(ref:runtime.lastError)
// will be set.
+ // NOTE: This is only available to Chrome OS Kiosk apps and Web UI.
// |id|: The display's unique identifier.
// |info|: The information about display properties that should be changed.
// A property will be changed only if a new value for it is specified in
@@ -145,6 +177,8 @@ namespace system.display {
// Enables/disables the unified desktop feature. Note that this simply
// enables the feature, but will not change the actual desktop mode.
// (That is, if the desktop is in mirror mode, it will stay in mirror mode)
+ // NOTE: This is only available to Chrome OS Kiosk apps and Web UI.
+ // |enabled|: True if unified desktop should be enabled.
static void enableUnifiedDesktop(boolean enabled);
};
diff --git a/chromium/extensions/common/cast/cast_cert_validator.cc b/chromium/extensions/common/cast/cast_cert_validator.cc
deleted file mode 100644
index 2211bb653cf..00000000000
--- a/chromium/extensions/common/cast/cast_cert_validator.cc
+++ /dev/null
@@ -1,383 +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 "extensions/common/cast/cast_cert_validator.h"
-
-#include <stddef.h>
-#include <stdint.h>
-#include <algorithm>
-#include <utility>
-
-#include "net/cert/internal/certificate_policies.h"
-#include "net/cert/internal/extended_key_usage.h"
-#include "net/cert/internal/parse_certificate.h"
-#include "net/cert/internal/parse_name.h"
-#include "net/cert/internal/signature_algorithm.h"
-#include "net/cert/internal/signature_policy.h"
-#include "net/cert/internal/verify_certificate_chain.h"
-#include "net/cert/internal/verify_signed_data.h"
-#include "net/der/input.h"
-
-namespace extensions {
-namespace api {
-namespace cast_crypto {
-namespace {
-
-// -------------------------------------------------------------------------
-// Cast trust anchors.
-// -------------------------------------------------------------------------
-
-// There are two trusted roots for Cast certificate chains:
-//
-// (1) CN=Cast Root CA
-// (2) CN=Eureka Root CA
-//
-// Note that only the subject/spki are saved here, not the full certificate.
-// See the TODO in CreateCastTrustStore().
-
-unsigned char kCastRootCaSubjectDer[119] = {
- 0x30, 0x75, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13,
- 0x02, 0x55, 0x53, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08,
- 0x0C, 0x0A, 0x43, 0x61, 0x6C, 0x69, 0x66, 0x6F, 0x72, 0x6E, 0x69, 0x61,
- 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0C, 0x0D, 0x4D,
- 0x6F, 0x75, 0x6E, 0x74, 0x61, 0x69, 0x6E, 0x20, 0x56, 0x69, 0x65, 0x77,
- 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x0A, 0x47,
- 0x6F, 0x6F, 0x67, 0x6C, 0x65, 0x20, 0x49, 0x6E, 0x63, 0x31, 0x0D, 0x30,
- 0x0B, 0x06, 0x03, 0x55, 0x04, 0x0B, 0x0C, 0x04, 0x43, 0x61, 0x73, 0x74,
- 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x0C, 0x43,
- 0x61, 0x73, 0x74, 0x20, 0x52, 0x6F, 0x6F, 0x74, 0x20, 0x43, 0x41,
-};
-
-unsigned char kCastRootCaSpkiDer[294] = {
- 0x30, 0x82, 0x01, 0x22, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86,
- 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0F, 0x00,
- 0x30, 0x82, 0x01, 0x0A, 0x02, 0x82, 0x01, 0x01, 0x00, 0xBA, 0xD9, 0x65,
- 0x9D, 0xDA, 0x39, 0xD3, 0xC1, 0x77, 0xF6, 0xD4, 0xD0, 0xAE, 0x8F, 0x58,
- 0x08, 0x68, 0x39, 0x4A, 0x95, 0xED, 0x70, 0xCF, 0xFD, 0x79, 0x08, 0xA9,
- 0xAA, 0xE5, 0xE9, 0xB8, 0xA7, 0x2D, 0xA0, 0x67, 0x47, 0x8A, 0x9E, 0xC9,
- 0xCF, 0x70, 0xB3, 0x05, 0x87, 0x69, 0x11, 0xEC, 0x70, 0x98, 0x97, 0xC3,
- 0xE6, 0xC3, 0xC3, 0xEB, 0xBD, 0xC6, 0xB0, 0x3D, 0xFC, 0x4F, 0xC1, 0x5E,
- 0x38, 0x9F, 0xDA, 0xCF, 0x73, 0x30, 0x06, 0x5B, 0x79, 0x37, 0xC1, 0x5E,
- 0x8C, 0x87, 0x47, 0x94, 0x9A, 0x41, 0x92, 0x2A, 0xD6, 0x95, 0xC4, 0x71,
- 0x5C, 0x27, 0x5D, 0x08, 0xB1, 0x80, 0xC6, 0x92, 0xBD, 0x1B, 0xE3, 0x41,
- 0x97, 0xA1, 0xEC, 0x75, 0x9F, 0x55, 0x9E, 0x3E, 0x9F, 0x8F, 0x1C, 0xC7,
- 0x65, 0x64, 0x07, 0xD3, 0xB3, 0x96, 0xA1, 0x04, 0x9F, 0x91, 0xC4, 0xDE,
- 0x0A, 0x7B, 0x6C, 0xD9, 0xC8, 0xC0, 0x78, 0x31, 0xA0, 0x19, 0x42, 0xA9,
- 0xE8, 0x83, 0xE3, 0xCE, 0xFC, 0xF1, 0xCE, 0xC2, 0x2E, 0x24, 0x46, 0x95,
- 0x09, 0x19, 0xCA, 0xC0, 0x46, 0xB2, 0xE5, 0x01, 0xBA, 0xD7, 0x4F, 0xF3,
- 0xBF, 0xF6, 0x69, 0xAD, 0x99, 0x04, 0xFA, 0xA0, 0x07, 0x39, 0x0E, 0xE6,
- 0xDF, 0x51, 0x47, 0x07, 0xC0, 0xE4, 0xA9, 0x5C, 0x4B, 0x94, 0xC5, 0x2F,
- 0xB3, 0xA0, 0x30, 0x7F, 0xE7, 0x95, 0x6B, 0xB2, 0xAF, 0x32, 0x0D, 0xF1,
- 0x8C, 0xD5, 0x6D, 0xCB, 0x7B, 0x47, 0xA7, 0x08, 0xAB, 0xCB, 0x27, 0xA3,
- 0x4D, 0xCF, 0x4A, 0x5A, 0xF1, 0x05, 0xD1, 0xF8, 0x62, 0xC5, 0x10, 0x2A,
- 0x74, 0x69, 0xAA, 0xE6, 0x4B, 0x96, 0xFB, 0x9B, 0xD8, 0x63, 0xE4, 0x58,
- 0x66, 0xD3, 0xAD, 0x8A, 0x6E, 0xFF, 0x7B, 0x5E, 0xF9, 0xA5, 0x56, 0x1E,
- 0x2D, 0x82, 0x31, 0x5B, 0xF0, 0xE2, 0x24, 0xE6, 0x41, 0x4A, 0x1F, 0xAE,
- 0x13, 0x02, 0x03, 0x01, 0x00, 0x01,
-};
-
-unsigned char kEurekaRootCaSubjectDer[126] = {
- 0x30, 0x7C, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13,
- 0x02, 0x55, 0x53, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08,
- 0x0C, 0x0A, 0x43, 0x61, 0x6C, 0x69, 0x66, 0x6F, 0x72, 0x6E, 0x69, 0x61,
- 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0C, 0x0D, 0x4D,
- 0x6F, 0x75, 0x6E, 0x74, 0x61, 0x69, 0x6E, 0x20, 0x56, 0x69, 0x65, 0x77,
- 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x0A, 0x47,
- 0x6F, 0x6F, 0x67, 0x6C, 0x65, 0x20, 0x49, 0x6E, 0x63, 0x31, 0x12, 0x30,
- 0x10, 0x06, 0x03, 0x55, 0x04, 0x0B, 0x0C, 0x09, 0x47, 0x6F, 0x6F, 0x67,
- 0x6C, 0x65, 0x20, 0x54, 0x56, 0x31, 0x17, 0x30, 0x15, 0x06, 0x03, 0x55,
- 0x04, 0x03, 0x0C, 0x0E, 0x45, 0x75, 0x72, 0x65, 0x6B, 0x61, 0x20, 0x52,
- 0x6F, 0x6F, 0x74, 0x20, 0x43, 0x41,
-};
-
-unsigned char kEurekaRootCaSpkiDer[294] = {
- 0x30, 0x82, 0x01, 0x22, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86,
- 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0F, 0x00,
- 0x30, 0x82, 0x01, 0x0A, 0x02, 0x82, 0x01, 0x01, 0x00, 0xB9, 0x11, 0xD0,
- 0xEA, 0x12, 0xDC, 0x32, 0xE1, 0xDF, 0x5C, 0x33, 0x6B, 0x19, 0x73, 0x1D,
- 0x9D, 0x9E, 0xD0, 0x39, 0x76, 0xBF, 0xA5, 0x84, 0x09, 0xA6, 0xFD, 0x6E,
- 0x6D, 0xE9, 0xDC, 0x8F, 0x36, 0x4E, 0xE9, 0x88, 0x02, 0xBD, 0x9F, 0xF4,
- 0xE8, 0x44, 0xFD, 0x4C, 0xF5, 0x9A, 0x02, 0x56, 0x6A, 0x47, 0x2A, 0x63,
- 0x6C, 0x58, 0x45, 0xCC, 0x7C, 0x66, 0x24, 0xDC, 0x79, 0x79, 0xC3, 0x2A,
- 0xA4, 0xB2, 0x8B, 0xA0, 0xF7, 0xA2, 0xB5, 0xCD, 0x06, 0x7E, 0xDB, 0xBE,
- 0xEC, 0x0C, 0x86, 0xF2, 0x0D, 0x24, 0x60, 0x74, 0x84, 0xCA, 0x29, 0x23,
- 0x84, 0x02, 0xD8, 0xA7, 0xED, 0x3B, 0xF1, 0xEC, 0x26, 0x47, 0x54, 0xE3,
- 0xB1, 0x2D, 0xE6, 0x64, 0x0F, 0xF6, 0x72, 0xC5, 0xE9, 0x98, 0x52, 0x17,
- 0xC0, 0xFC, 0xF2, 0x2C, 0x20, 0xC8, 0x40, 0xF8, 0x47, 0xC9, 0x32, 0x9E,
- 0x3B, 0x97, 0xB1, 0x8B, 0xF5, 0x98, 0x24, 0x70, 0x63, 0x66, 0x19, 0xC1,
- 0x52, 0xE8, 0x04, 0x05, 0x3D, 0x5F, 0x8D, 0xBC, 0xD8, 0x4B, 0xAF, 0x77,
- 0x98, 0x6F, 0x1F, 0x78, 0xD1, 0xB6, 0x50, 0x27, 0x4D, 0xE4, 0xEC, 0x14,
- 0x69, 0x67, 0x1F, 0x58, 0xAF, 0xA9, 0xA0, 0x11, 0x26, 0x3C, 0x94, 0x32,
- 0x07, 0x7F, 0xD7, 0xE9, 0x69, 0x1F, 0xAE, 0x3F, 0x4F, 0x63, 0x8A, 0x8F,
- 0x89, 0xD6, 0xF2, 0x19, 0x78, 0x5C, 0x21, 0x8E, 0xB1, 0xB6, 0x57, 0xD8,
- 0xC0, 0xE1, 0xEE, 0x7D, 0x6E, 0xDD, 0xF1, 0x3A, 0x0A, 0x6A, 0xF1, 0xBA,
- 0xFF, 0xF9, 0x83, 0x2F, 0xDC, 0xB5, 0xA4, 0x20, 0x17, 0x63, 0x36, 0xEF,
- 0xC8, 0x62, 0x19, 0xCC, 0x56, 0xCE, 0xB2, 0xEA, 0x31, 0x89, 0x4B, 0x78,
- 0x58, 0xC1, 0xBF, 0x03, 0x13, 0x99, 0xE0, 0x12, 0xF2, 0x88, 0xAA, 0x9B,
- 0x94, 0xDA, 0xDD, 0x76, 0x79, 0x17, 0x1E, 0x34, 0xD1, 0x0A, 0xC4, 0x07,
- 0x45, 0x02, 0x03, 0x01, 0x00, 0x01,
-};
-
-// Helper function that creates and initializes a TrustAnchor struct given
-// arrays for the subject's DER and the SPKI's DER.
-template <size_t SubjectSize, size_t SpkiSize>
-net::TrustAnchor CreateTrustAnchor(const uint8_t (&subject)[SubjectSize],
- const uint8_t (&spki)[SpkiSize]) {
- net::TrustAnchor anchor;
- anchor.name = std::string(subject, subject + SubjectSize);
- anchor.spki = std::string(spki, spki + SpkiSize);
- return anchor;
-}
-
-// Creates a trust store with the two Cast roots.
-//
-// TODO(eroman): The root certificates themselves are not included in the trust
-// store (just their subject/SPKI). The problem with this approach is any
-// restrictions encoded in their (like path length, or policy) are not known
-// when verifying, and hence not enforced.
-net::TrustStore CreateCastTrustStore() {
- net::TrustStore store;
- store.anchors.push_back(
- CreateTrustAnchor(kEurekaRootCaSubjectDer, kEurekaRootCaSpkiDer));
- store.anchors.push_back(
- CreateTrustAnchor(kCastRootCaSubjectDer, kCastRootCaSpkiDer));
- return store;
-}
-
-using ExtensionsMap = std::map<net::der::Input, net::ParsedExtension>;
-
-// Helper that looks up an extension by OID given a map of extensions.
-bool GetExtensionValue(const ExtensionsMap& extensions,
- const net::der::Input& oid,
- net::der::Input* value) {
- auto it = extensions.find(oid);
- if (it == extensions.end())
- return false;
- *value = it->second.value;
- return true;
-}
-
-// Returns the OID for the Audio-Only Cast policy
-// (1.3.6.1.4.1.11129.2.5.2) in DER form.
-net::der::Input AudioOnlyPolicyOid() {
- static const uint8_t kAudioOnlyPolicy[] = {0x2B, 0x06, 0x01, 0x04, 0x01,
- 0xD6, 0x79, 0x02, 0x05, 0x02};
- return net::der::Input(kAudioOnlyPolicy);
-}
-
-// Cast certificates rely on RSASSA-PKCS#1 v1.5 with SHA-1 for signatures.
-//
-// The following signature policy specifies which signature algorithms (and key
-// sizes) are acceptable. It is used when verifying a chain of certificates, as
-// well as when verifying digital signature using the target certificate's
-// SPKI.
-//
-// This particular policy allows for:
-// * ECDSA, RSA-SSA, and RSA-PSS
-// * Supported EC curves: P-256, P-384, P-521.
-// * Hashes: All SHA hashes including SHA-1 (despite being known weak).
-// * RSA keys must have a modulus at least 2048-bits long.
-scoped_ptr<net::SignaturePolicy> CreateCastSignaturePolicy() {
- return make_scoped_ptr(new net::SimpleSignaturePolicy(2048));
-}
-
-class CertVerificationContextImpl : public CertVerificationContext {
- public:
- // Save a copy of the passed in public key (DER) and common name (text).
- CertVerificationContextImpl(const net::der::Input& spki,
- const base::StringPiece& common_name)
- : spki_(spki.AsString()), common_name_(common_name.as_string()) {}
-
- bool VerifySignatureOverData(const base::StringPiece& signature,
- const base::StringPiece& data) const override {
- // This code assumes the signature algorithm was RSASSA PKCS#1 v1.5 with
- // SHA-1.
- // TODO(eroman): Is it possible to use other hash algorithms?
- auto signature_algorithm =
- net::SignatureAlgorithm::CreateRsaPkcs1(net::DigestAlgorithm::Sha1);
-
- // Use the same policy as was used for verifying signatures in
- // certificates. This will ensure for instance that the key used is at
- // least 2048-bits long.
- auto signature_policy = CreateCastSignaturePolicy();
-
- return net::VerifySignedData(
- *signature_algorithm, net::der::Input(data),
- net::der::BitString(net::der::Input(signature), 0),
- net::der::Input(&spki_), signature_policy.get());
- }
-
- std::string GetCommonName() const override { return common_name_; }
-
- private:
- std::string spki_;
- std::string common_name_;
-};
-
-// Helper that extracts the Common Name from a certificate's subject field. On
-// success |common_name| contains the text for the attribute (unescaped, so
-// will depend on the encoding used, but for Cast device certs it should
-// be ASCII).
-bool GetCommonNameFromSubject(const net::der::Input& subject_tlv,
- std::string* common_name) {
- net::RDNSequence rdn_sequence;
- if (!net::ParseName(subject_tlv, &rdn_sequence))
- return false;
-
- for (const net::RelativeDistinguishedName& rdn : rdn_sequence) {
- for (const auto& atv : rdn) {
- if (atv.type == net::TypeCommonNameOid()) {
- return atv.ValueAsStringUnsafe(common_name);
- }
- }
- }
- return false;
-}
-
-// Returns true if the extended key usage list |ekus| contains client auth.
-bool HasClientAuth(const std::vector<net::der::Input>& ekus) {
- for (const auto& oid : ekus) {
- if (oid == net::ClientAuth())
- return true;
- }
- return false;
-}
-
-// Checks properties on the target certificate.
-//
-// * The Key Usage must include Digital Signature
-// * THe Extended Key Usage must includ TLS Client Auth
-// * May have the policy 1.3.6.1.4.1.11129.2.5.2 to indicate it
-// is an audio-only device.
-WARN_UNUSED_RESULT bool CheckTargetCertificate(
- const net::der::Input& cert_der,
- scoped_ptr<CertVerificationContext>* context,
- CastDeviceCertPolicy* policy) {
- // TODO(eroman): Simplify this. The certificate chain verification
- // function already parses this stuff, awkward to re-do it here.
-
- net::ParsedCertificate cert;
- if (!net::ParseCertificate(cert_der, &cert))
- return false;
-
- net::ParsedTbsCertificate tbs;
- if (!net::ParseTbsCertificate(cert.tbs_certificate_tlv, &tbs))
- return false;
-
- // Get the extensions.
- if (!tbs.has_extensions)
- return false;
- ExtensionsMap extensions;
- if (!net::ParseExtensions(tbs.extensions_tlv, &extensions))
- return false;
-
- net::der::Input extension_value;
-
- // Get the Key Usage extension.
- if (!GetExtensionValue(extensions, net::KeyUsageOid(), &extension_value))
- return false;
- net::der::BitString key_usage;
- if (!net::ParseKeyUsage(extension_value, &key_usage))
- return false;
-
- // Ensure Key Usage contains digitalSignature.
- if (!key_usage.AssertsBit(net::KEY_USAGE_BIT_DIGITAL_SIGNATURE))
- return false;
-
- // Get the Extended Key Usage extension.
- if (!GetExtensionValue(extensions, net::ExtKeyUsageOid(), &extension_value))
- return false;
- std::vector<net::der::Input> ekus;
- if (!net::ParseEKUExtension(extension_value, &ekus))
- return false;
-
- // Ensure Extended Key Usage contains client auth.
- if (!HasClientAuth(ekus))
- return false;
-
- // Check for an optional audio-only policy extension.
- *policy = CastDeviceCertPolicy::NONE;
- if (GetExtensionValue(extensions, net::CertificatePoliciesOid(),
- &extension_value)) {
- std::vector<net::der::Input> policies;
- if (!net::ParseCertificatePoliciesExtension(extension_value, &policies))
- return false;
-
- // Look for an audio-only policy. Disregard any other policy found.
- if (std::find(policies.begin(), policies.end(), AudioOnlyPolicyOid()) !=
- policies.end()) {
- *policy = CastDeviceCertPolicy::AUDIO_ONLY;
- }
- }
-
- // Get the Common Name for the certificate.
- std::string common_name;
- if (!GetCommonNameFromSubject(tbs.subject_tlv, &common_name))
- return false;
-
- context->reset(new CertVerificationContextImpl(tbs.spki_tlv, common_name));
- return true;
-}
-
-
-// Converts a base::Time::Exploded to a net::der::GeneralizedTime.
-net::der::GeneralizedTime ConvertExplodedTime(
- const base::Time::Exploded& exploded) {
- net::der::GeneralizedTime result;
- result.year = exploded.year;
- result.month = exploded.month;
- result.day = exploded.day_of_month;
- result.hours = exploded.hour;
- result.minutes = exploded.minute;
- result.seconds = exploded.second;
- return result;
-}
-
-} // namespace
-
-bool VerifyDeviceCert(const std::vector<std::string>& certs,
- const base::Time::Exploded& time,
- scoped_ptr<CertVerificationContext>* context,
- CastDeviceCertPolicy* policy) {
- // Initialize the trust store used for verifying Cast
- // device certificates.
- //
- // Performance: This code is re-building a TrustStore object each
- // time a chain needs to be verified rather than caching it, to
- // avoid memory bloat.
- auto trust_store = CreateCastTrustStore();
-
- // The underlying verification function expects a sequence of
- // der::Input, so wrap the data in it (cheap).
- std::vector<net::der::Input> input_chain;
- for (const auto& cert : certs)
- input_chain.push_back(net::der::Input(&cert));
-
- // Use a signature policy compatible with Cast's PKI.
- auto signature_policy = CreateCastSignaturePolicy();
-
- // Do RFC 5280 compatible certificate verification using the two Cast
- // trust anchors and Cast signature policy.
- if (!net::VerifyCertificateChain(input_chain, trust_store,
- signature_policy.get(),
- ConvertExplodedTime(time))) {
- return false;
- }
-
- // Check properties of the leaf certificate (key usage, policy), and construct
- // a CertVerificationContext that uses its public key.
- return CheckTargetCertificate(input_chain[0], context, policy);
-}
-
-scoped_ptr<CertVerificationContext> CertVerificationContextImplForTest(
- const base::StringPiece& spki) {
- // Use a bogus CommonName, since this is just exposed for testing signature
- // verification by unittests.
- return make_scoped_ptr(
- new CertVerificationContextImpl(net::der::Input(spki), "CommonName"));
-}
-
-} // namespace cast_crypto
-} // namespace api
-} // namespace extensions
diff --git a/chromium/extensions/common/cast/cast_cert_validator.h b/chromium/extensions/common/cast/cast_cert_validator.h
deleted file mode 100644
index c435ebb8776..00000000000
--- a/chromium/extensions/common/cast/cast_cert_validator.h
+++ /dev/null
@@ -1,94 +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 EXTENSIONS_COMMON_CAST_CAST_CERT_VALIDATOR_H_
-#define EXTENSIONS_COMMON_CAST_CAST_CERT_VALIDATOR_H_
-
-#include <string>
-#include <vector>
-
-#include "base/compiler_specific.h"
-#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/strings/string_piece.h"
-#include "base/time/time.h"
-
-namespace extensions {
-namespace api {
-namespace cast_crypto {
-
-// Describes the policy for a Device certificate.
-enum class CastDeviceCertPolicy {
- // The device certificate is unrestricted.
- NONE,
-
- // The device certificate is for an audio-only device.
- AUDIO_ONLY,
-};
-
-// An object of this type is returned by the VerifyDeviceCert function, and can
-// be used for additional certificate-related operations, using the verified
-// certificate.
-class CertVerificationContext {
- public:
- CertVerificationContext() {}
- virtual ~CertVerificationContext() {}
-
- // Use the public key from the verified certificate to verify a
- // sha1WithRSAEncryption |signature| over arbitrary |data|. Both |signature|
- // and |data| hold raw binary data. Returns true if the signature was
- // correct.
- virtual bool VerifySignatureOverData(const base::StringPiece& signature,
- const base::StringPiece& data) const = 0;
-
- // Retrieve the Common Name attribute of the subject's distinguished name from
- // the verified certificate, if present. Returns an empty string if no Common
- // Name is found.
- virtual std::string GetCommonName() const = 0;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(CertVerificationContext);
-};
-
-// Verifies a cast device certficate given a chain of DER-encoded certificates.
-//
-// Inputs:
-//
-// * |certs| is a chain of DER-encoded certificates:
-// * |certs[0]| is the target certificate (i.e. the device certificate)
-// * |certs[i]| is the certificate that issued certs[i-1]
-// * |certs.back()| must be signed by a trust anchor
-//
-// * |time| is the UTC time to use for determining if the certificate
-// is expired.
-//
-// Outputs:
-//
-// Returns true on success, false on failure. On success the output
-// parameters are filled with more details:
-//
-// * |context| is filled with an object that can be used to verify signatures
-// using the device certificate's public key, as well as to extract other
-// properties from the device certificate (Common Name).
-// * |policy| is filled with an indication of the device certificate's policy
-// (i.e. is it for audio-only devices or is it unrestricted?)
-bool VerifyDeviceCert(const std::vector<std::string>& certs,
- const base::Time::Exploded& time,
- scoped_ptr<CertVerificationContext>* context,
- CastDeviceCertPolicy* policy) WARN_UNUSED_RESULT;
-
-// Exposed only for unit-tests, not for use in production code.
-// Production code would get a context from VerifyDeviceCert().
-//
-// Constructs a VerificationContext that uses the provided public key.
-// The common name will be hardcoded to some test value.
-scoped_ptr<CertVerificationContext> CertVerificationContextImplForTest(
- const base::StringPiece& spki);
-
-
-} // namespace cast_crypto
-} // namespace api
-} // namespace extensions
-
-#endif // EXTENSIONS_COMMON_CAST_CAST_CERT_VALIDATOR_H_
diff --git a/chromium/extensions/common/cast/cast_cert_validator_unittest.cc b/chromium/extensions/common/cast/cast_cert_validator_unittest.cc
deleted file mode 100644
index b2bc8ed838c..00000000000
--- a/chromium/extensions/common/cast/cast_cert_validator_unittest.cc
+++ /dev/null
@@ -1,522 +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 "extensions/common/cast/cast_cert_validator.h"
-
-#include "base/files/file_util.h"
-#include "base/path_service.h"
-#include "extensions/common/extension_paths.h"
-#include "net/cert/pem_tokenizer.h"
-#include "net/der/parse_values.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace extensions {
-
-namespace api {
-
-namespace cast_crypto {
-
-namespace {
-
-// Creates an std::string given a uint8_t array.
-template <size_t N>
-std::string CreateString(const uint8_t (&data)[N]) {
- return std::string(reinterpret_cast<const char*>(data), N);
-}
-
-// Reads a file from the cast certificates test data directory:
-// src/extensions/test/data/cast_certificates/
-std::string ReadTestFileToString(const std::string& file_name) {
- base::FilePath filepath;
- if (!PathService::Get(DIR_TEST_DATA, &filepath)) {
- ADD_FAILURE() << "Couldn't retrieve test data root";
- return std::string();
- }
- filepath = filepath.AppendASCII("cast_certificates/" + file_name);
-
- // Read the full contents of the file.
- std::string file_data;
- if (!base::ReadFileToString(filepath, &file_data)) {
- ADD_FAILURE() << "Couldn't read file: " << filepath.value();
- return std::string();
- }
-
- return file_data;
-}
-
-// Indicates the expected result of test verification.
-enum TestResult {
- RESULT_SUCCESS,
- RESULT_FAIL,
-};
-
-// Reads a PEM file containing "CERTIFICATE" blocks to a vector of certificate
-// data.
-std::vector<std::string> ReadCertificateChainFromFile(
- const std::string& file_name) {
- std::string file_data = ReadTestFileToString(file_name);
-
- // Read the certificate chain from the test file, which is comprised of PEM
- // blocks titled "CERTIFICATE".
- std::vector<std::string> pem_headers;
- pem_headers.push_back("CERTIFICATE");
-
- std::vector<std::string> certs;
- net::PEMTokenizer pem_tokenizer(file_data, pem_headers);
- while (pem_tokenizer.GetNext())
- certs.push_back(pem_tokenizer.data());
-
- return certs;
-}
-
-// Reads a test chain from |file_name|, and asserts that verifying it as a Cast
-// device certificate results in |expected_result|.
-//
-// * |expected_policy| - The policy that should have been identified for the
-// device certificate.
-// * |time| - The timestamp to use when verifying the certificate.
-void RunTest(TestResult expected_result,
- const std::string& expected_common_name,
- CastDeviceCertPolicy expected_policy,
- const std::string& file_name,
- const base::Time::Exploded& time) {
- auto certs = ReadCertificateChainFromFile(file_name);
-
- scoped_ptr<CertVerificationContext> context;
- CastDeviceCertPolicy policy;
- bool result = VerifyDeviceCert(certs, time, &context, &policy);
-
- if (expected_result == RESULT_SUCCESS) {
- ASSERT_TRUE(result);
- EXPECT_EQ(expected_policy, policy);
- ASSERT_TRUE(context.get());
-
- // Test that the context is good.
- EXPECT_EQ(expected_common_name, context->GetCommonName());
-
- // Test that an invalid signature fails.
-
- EXPECT_FALSE(
- context->VerifySignatureOverData("bogus signature", "bogus data"));
-
- // Note that testing that a correct signature succeeds would be a natural
- // test to follow with, but we don't have signed data for these device
- // certificates to use. The success case is instead tested separately.
- } else {
- ASSERT_FALSE(result);
- }
-}
-
-// Creates a time in UTC at midnight.
-base::Time::Exploded CreateDate(int year, int month, int day) {
- base::Time::Exploded time = {0};
- time.year = year;
- time.month = month;
- time.day_of_month = day;
- return time;
-}
-
-// Returns 2016-04-01 00:00:00 UTC.
-//
-// This is a time when most of the test certificate paths are
-// valid.
-base::Time::Exploded AprilFirst2016() {
- return CreateDate(2016, 4, 1);
-}
-
-// Returns 2015-01-01 00:00:00 UTC.
-base::Time::Exploded JanuaryFirst2015() {
- return CreateDate(2015, 1, 1);
-}
-
-// Returns 2040-03-01 00:00:00 UTC.
-//
-// This is so far in the future that the test chains in this unit-test
-// should all be invalid.
-base::Time::Exploded MarchFirst2040() {
- return CreateDate(2040, 3, 1);
-}
-
-// Tests verifying a valid certificate chain of length 2:
-//
-// 0: 2ZZBG9 FA8FCA3EF91A
-// 1: Eureka Gen1 ICA
-//
-// Chains to trust anchor:
-// Eureka Root CA (not included)
-TEST(VerifyCastDeviceCertTest, ChromecastGen1) {
- RunTest(RESULT_SUCCESS, "2ZZBG9 FA8FCA3EF91A", CastDeviceCertPolicy::NONE,
- "chromecast_gen1.pem", AprilFirst2016());
-}
-
-// Tests verifying a valid certificate chain of length 2:
-//
-// 0: 2ZZBG9 FA8FCA3EF91A
-// 1: Eureka Gen1 ICA
-//
-// Chains to trust anchor:
-// Cast Root CA (not included)
-TEST(VerifyCastDeviceCertTest, ChromecastGen1Reissue) {
- RunTest(RESULT_SUCCESS, "2ZZBG9 FA8FCA3EF91A", CastDeviceCertPolicy::NONE,
- "chromecast_gen1_reissue.pem", AprilFirst2016());
-}
-
-// Tests verifying a valid certificate chain of length 2:
-//
-// 0: 3ZZAK6 FA8FCA3F0D35
-// 1: Chromecast ICA 3
-//
-// Chains to trust anchor:
-// Cast Root CA (not included)
-TEST(VerifyCastDeviceCertTest, ChromecastGen2) {
- RunTest(RESULT_SUCCESS, "3ZZAK6 FA8FCA3F0D35", CastDeviceCertPolicy::NONE,
- "chromecast_gen2.pem", AprilFirst2016());
-}
-
-// Tests verifying a valid certificate chain of length 3:
-//
-// 0: -6394818897508095075
-// 1: Asus fugu Cast ICA
-// 2: Widevine Cast Subroot
-//
-// Chains to trust anchor:
-// Cast Root CA (not included)
-TEST(VerifyCastDeviceCertTest, Fugu) {
- RunTest(RESULT_SUCCESS, "-6394818897508095075", CastDeviceCertPolicy::NONE,
- "fugu.pem", AprilFirst2016());
-}
-
-// Tests verifying an invalid certificate chain of length 1:
-//
-// 0: Cast Test Untrusted Device
-//
-// Chains to:
-// Cast Test Untrusted ICA (not included)
-//
-// This is invalid because it does not chain to a trust anchor.
-TEST(VerifyCastDeviceCertTest, Unchained) {
- RunTest(RESULT_FAIL, "", CastDeviceCertPolicy::NONE, "unchained.pem",
- AprilFirst2016());
-}
-
-// Tests verifying one of the self-signed trust anchors (chain of length 1):
-//
-// 0: Cast Root CA
-//
-// Chains to trust anchor:
-// Cast Root CA
-//
-// Although this is a valid and trusted certificate (it is one of the
-// trust anchors after all) it fails the test as it is not a *device
-// certificate*.
-TEST(VerifyCastDeviceCertTest, CastRootCa) {
- RunTest(RESULT_FAIL, "", CastDeviceCertPolicy::NONE, "cast_root_ca.pem",
- AprilFirst2016());
-}
-
-// Tests verifying a valid certificate chain of length 2:
-//
-// 0: 4ZZDZJ FA8FCA7EFE3C
-// 1: Chromecast ICA 4 (Audio)
-//
-// Chains to trust anchor:
-// Cast Root CA (not included)
-//
-// This device certificate has a policy that means it is valid only for audio
-// devices.
-TEST(VerifyCastDeviceCertTest, ChromecastAudio) {
- RunTest(RESULT_SUCCESS, "4ZZDZJ FA8FCA7EFE3C",
- CastDeviceCertPolicy::AUDIO_ONLY, "chromecast_audio.pem",
- AprilFirst2016());
-}
-
-// Tests verifying a valid certificate chain of length 3:
-//
-// 0: MediaTek Audio Dev Test
-// 1: MediaTek Audio Dev Model
-// 2: Cast Audio Dev Root CA
-//
-// Chains to trust anchor:
-// Cast Root CA (not included)
-//
-// This device certificate has a policy that means it is valid only for audio
-// devices.
-TEST(VerifyCastDeviceCertTest, MtkAudioDev) {
- RunTest(RESULT_SUCCESS, "MediaTek Audio Dev Test",
- CastDeviceCertPolicy::AUDIO_ONLY, "mtk_audio_dev.pem",
- JanuaryFirst2015());
-}
-
-// Tests verifying a valid certificate chain of length 2:
-//
-// 0: 9V0000VB FA8FCA784D01
-// 1: Cast TV ICA (Vizio)
-//
-// Chains to trust anchor:
-// Cast Root CA (not included)
-TEST(VerifyCastDeviceCertTest, Vizio) {
- RunTest(RESULT_SUCCESS, "9V0000VB FA8FCA784D01", CastDeviceCertPolicy::NONE,
- "vizio.pem", AprilFirst2016());
-}
-
-// Tests verifying a valid certificate chain of length 2 using a date that
-// precedes its notBefore. Must fail.
-TEST(VerifyCastDeviceCertTest, ChromecastGen2NotValidBefore) {
- RunTest(RESULT_FAIL, "", CastDeviceCertPolicy::NONE, "chromecast_gen2.pem",
- JanuaryFirst2015());
-}
-
-// Tests verifying a valid certificate chain of length 2 using a date that
-// is after its notAfter. Must fail.
-TEST(VerifyCastDeviceCertTest, ChromecastGen2NotValidAfter) {
- RunTest(RESULT_FAIL, "", CastDeviceCertPolicy::NONE, "chromecast_gen2.pem",
- MarchFirst2040());
-}
-
-// Tests verifying a valid certificate chain of length 3:
-//
-// 0: Audio Reference Dev Test
-// 1: Audio Reference Dev Model
-// 2: Cast Audio Dev Root CA
-//
-// Chains to trust anchor:
-// Cast Root CA (not included)
-//
-// This device certificate has a policy that means it is valid only for audio
-// devices.
-TEST(VerifyCastDeviceCertTest, AudioRefDevTestChain3) {
- RunTest(RESULT_SUCCESS, "Audio Reference Dev Test",
- CastDeviceCertPolicy::AUDIO_ONLY, "audio_ref_dev_test_chain_3.pem",
- AprilFirst2016());
-}
-
-// This duplicates the certificate verification from the test above, but then
-// additionally uses the context to verify some data.
-TEST(VerifyCastDeviceCertTest, AudioRefDevTestChain3VerifySignedData) {
- auto certs = ReadCertificateChainFromFile("audio_ref_dev_test_chain_3.pem");
-
- scoped_ptr<CertVerificationContext> context;
- CastDeviceCertPolicy policy;
- ASSERT_TRUE(VerifyDeviceCert(certs, AprilFirst2016(), &context, &policy));
-
- unsigned char kData[] = {
- 0x5f, 0x76, 0x0d, 0xc8, 0x4b, 0xe7, 0x6e, 0xcb, 0x31, 0x58, 0xca, 0xd3,
- 0x7d, 0x23, 0x55, 0xbe, 0x8d, 0x52, 0x87, 0x83, 0x27, 0x52, 0x78, 0xfa,
- 0xa6, 0xdd, 0xdf, 0x13, 0x00, 0x51, 0x57, 0x6a, 0x83, 0x15, 0xcc, 0xc5,
- 0xb2, 0x5c, 0xdf, 0xe6, 0x81, 0xdc, 0x13, 0x58, 0x7b, 0x94, 0x0f, 0x69,
- 0xcc, 0xdf, 0x68, 0x41, 0x8a, 0x95, 0xe2, 0xcd, 0xf8, 0xde, 0x0f, 0x2f,
- 0x30, 0xcf, 0x73, 0xbf, 0x37, 0x52, 0x87, 0x23, 0xd7, 0xbe, 0xba, 0x7c,
- 0xde, 0x50, 0xd3, 0x77, 0x9c, 0x06, 0x82, 0x28, 0x67, 0xc1, 0x1a, 0xf5,
- 0x8a, 0xa0, 0xf2, 0x32, 0x09, 0x95, 0x41, 0x41, 0x93, 0x8e, 0x62, 0xaa,
- 0xf3, 0xe3, 0x22, 0x17, 0x43, 0x94, 0x9b, 0x63, 0xfa, 0x68, 0x20, 0x69,
- 0x38, 0xf6, 0x75, 0x6c, 0xe0, 0x3b, 0xe0, 0x8d, 0x63, 0xac, 0x7f, 0xe3,
- 0x09, 0xd8, 0xde, 0x91, 0xc8, 0x1e, 0x07, 0x4a, 0xb2, 0x1e, 0xe1, 0xe3,
- 0xf4, 0x4d, 0x3e, 0x8a, 0xf4, 0xf8, 0x83, 0x39, 0x2b, 0x50, 0x98, 0x61,
- 0x91, 0x50, 0x00, 0x34, 0x57, 0xd2, 0x0d, 0xf7, 0xfa, 0xc9, 0xcc, 0xd9,
- 0x7a, 0x3d, 0x39, 0x7a, 0x1a, 0xbd, 0xf8, 0xbe, 0x65, 0xb6, 0xea, 0x4e,
- 0x86, 0x74, 0xdd, 0x51, 0x74, 0x6e, 0xa6, 0x7f, 0x14, 0x6c, 0x6a, 0x46,
- 0xb8, 0xaf, 0xcd, 0x6c, 0x78, 0x43, 0x76, 0x47, 0x5b, 0xdc, 0xb6, 0xf6,
- 0x4d, 0x1b, 0xe0, 0xb5, 0xf9, 0xa2, 0xb8, 0x26, 0x3f, 0x3f, 0xb8, 0x80,
- 0xed, 0xce, 0xfd, 0x0e, 0xcb, 0x48, 0x7a, 0x3b, 0xdf, 0x92, 0x44, 0x04,
- 0x81, 0xe4, 0xd3, 0x1e, 0x07, 0x9b, 0x02, 0xae, 0x05, 0x5a, 0x11, 0xf2,
- 0xc2, 0x75, 0x85, 0xd5, 0xf1, 0x53, 0x4c, 0x09, 0xd0, 0x99, 0xf8, 0x3e,
- 0xf6, 0x24, 0x46, 0xae, 0x83, 0x35, 0x3e, 0x6c, 0x8c, 0x2a, 0x9f, 0x1c,
- 0x5b, 0xfb, 0x89, 0x56};
-
- unsigned char kSha1Signature[] = {
- 0x52, 0x56, 0xcd, 0x53, 0xfa, 0xd9, 0x44, 0x31, 0x00, 0x2e, 0x85, 0x18,
- 0x56, 0xae, 0xf9, 0xf2, 0x70, 0x16, 0xc9, 0x59, 0x53, 0xc0, 0x17, 0xd9,
- 0x09, 0x65, 0x75, 0xee, 0xba, 0xc8, 0x0d, 0x06, 0x2e, 0xb7, 0x1b, 0xd0,
- 0x6a, 0x4d, 0x58, 0xde, 0x8e, 0xbe, 0x92, 0x22, 0x53, 0x19, 0xbf, 0x74,
- 0x8f, 0xb8, 0xfc, 0x3c, 0x9b, 0x42, 0x14, 0x7d, 0xe1, 0xfc, 0xa3, 0x71,
- 0x91, 0x6c, 0x5d, 0x28, 0x69, 0x8d, 0xd2, 0xde, 0xd1, 0x8f, 0xac, 0x6d,
- 0xf6, 0x48, 0xd8, 0x6f, 0x0e, 0xc9, 0x0a, 0xfa, 0xde, 0x20, 0xe0, 0x9d,
- 0x7a, 0xf8, 0x30, 0xa8, 0xd4, 0x79, 0x15, 0x63, 0xfb, 0x97, 0xa9, 0xef,
- 0x9f, 0x9c, 0xac, 0x16, 0xba, 0x1b, 0x2c, 0x14, 0xb4, 0xa4, 0x54, 0x5e,
- 0xec, 0x04, 0x10, 0x84, 0xc2, 0xa0, 0xd9, 0x6f, 0x05, 0xd4, 0x09, 0x8c,
- 0x85, 0xe9, 0x7a, 0xd1, 0x5a, 0xa3, 0x70, 0x00, 0x30, 0x9b, 0x19, 0x44,
- 0x2a, 0x90, 0x7a, 0xcd, 0x91, 0x94, 0x90, 0x66, 0xf9, 0x2e, 0x5e, 0x43,
- 0x27, 0x33, 0x2c, 0x45, 0xa7, 0xe2, 0x3a, 0x6d, 0xc9, 0x44, 0x58, 0x39,
- 0x45, 0xcb, 0xbd, 0x2f, 0xc5, 0xb4, 0x08, 0x41, 0x4d, 0x45, 0x67, 0x55,
- 0x0d, 0x43, 0x3c, 0xb6, 0x81, 0xbb, 0xb4, 0x34, 0x07, 0x10, 0x28, 0x17,
- 0xc2, 0xad, 0x40, 0x3b, 0xaf, 0xcb, 0xc0, 0xf6, 0x9d, 0x0e, 0x9b, 0xca,
- 0x2b, 0x20, 0xdf, 0xd0, 0xa3, 0xbe, 0xea, 0x3e, 0xe0, 0x82, 0x7b, 0x93,
- 0xfd, 0x9c, 0xaf, 0x97, 0x00, 0x05, 0x44, 0x91, 0x73, 0x68, 0x92, 0x3a,
- 0x8b, 0xbc, 0x0e, 0x96, 0x5e, 0x92, 0x98, 0x70, 0xab, 0xaa, 0x6e, 0x9a,
- 0x8e, 0xb0, 0xf4, 0x92, 0xc5, 0xa0, 0xa0, 0x4b, 0xb3, 0xd5, 0x44, 0x99,
- 0x8e, 0xa1, 0xd1, 0x8f, 0xe3, 0xac, 0x71, 0x1e, 0x3f, 0xc2, 0xfd, 0x0a,
- 0x57, 0xed, 0xea, 0x04};
-
- unsigned char kSha256Signature[] = {
- 0x8d, 0x4b, 0x45, 0xdc, 0x13, 0x0a, 0x79, 0xae, 0x4b, 0x83, 0x99, 0x39,
- 0x2e, 0x58, 0x04, 0x98, 0x7f, 0x0d, 0xc6, 0x57, 0x7f, 0x6c, 0xd7, 0xf8,
- 0x6f, 0x47, 0xd8, 0xb7, 0xaa, 0x07, 0x29, 0x69, 0x0e, 0x05, 0x3b, 0x8c,
- 0x94, 0x53, 0xb2, 0x76, 0x51, 0x23, 0xdc, 0x85, 0xd2, 0x13, 0x37, 0x5e,
- 0x43, 0x9a, 0x4f, 0x38, 0xdd, 0xfc, 0xbb, 0xdf, 0xf0, 0x74, 0xf5, 0x42,
- 0xa1, 0xaa, 0x60, 0x16, 0x24, 0xc3, 0xcd, 0xf3, 0xd2, 0x8e, 0xa9, 0x39,
- 0xc5, 0x85, 0x99, 0xa2, 0x1b, 0xf5, 0x6d, 0xbd, 0x29, 0x77, 0xad, 0xd4,
- 0x3e, 0xbd, 0xa8, 0x34, 0xb3, 0x0a, 0x4f, 0x61, 0xc0, 0x39, 0x9e, 0x50,
- 0x42, 0x22, 0x58, 0xce, 0xb7, 0x74, 0x15, 0x1e, 0xdf, 0x55, 0x8b, 0x9b,
- 0x64, 0x07, 0x4a, 0xc6, 0x71, 0x34, 0x57, 0x17, 0x9a, 0x96, 0xdc, 0x87,
- 0x38, 0x24, 0xb6, 0x48, 0xde, 0x20, 0xa3, 0xb9, 0xae, 0x5f, 0x4e, 0xb4,
- 0x69, 0xe8, 0x24, 0x0f, 0xca, 0xa4, 0x94, 0x14, 0x97, 0x7e, 0xba, 0x2c,
- 0x18, 0x59, 0x13, 0xca, 0x7e, 0x0f, 0x8f, 0x83, 0xbf, 0x29, 0x63, 0x15,
- 0x20, 0xd5, 0x9a, 0xf7, 0xb8, 0x3f, 0xbf, 0x1d, 0x5b, 0xad, 0x13, 0x88,
- 0x29, 0x8f, 0x5f, 0x31, 0x42, 0x5d, 0x8e, 0x69, 0xc0, 0xc7, 0x76, 0xe4,
- 0xee, 0x04, 0x22, 0x23, 0x73, 0xac, 0x14, 0xb4, 0xc1, 0x20, 0x44, 0x80,
- 0x43, 0x41, 0x58, 0x24, 0x1e, 0x2e, 0xcb, 0xa6, 0x97, 0x41, 0x94, 0xaa,
- 0x6a, 0xbe, 0x55, 0x28, 0x8b, 0xe1, 0x97, 0xd5, 0x1b, 0xb8, 0x9b, 0x4b,
- 0xd6, 0xfd, 0x2c, 0x59, 0xcd, 0x8b, 0x6c, 0xf2, 0x1e, 0x31, 0xef, 0xe8,
- 0xb2, 0xcb, 0xaf, 0x4c, 0xfe, 0xea, 0xec, 0x63, 0xb7, 0xf3, 0x3c, 0x2a,
- 0x15, 0x0e, 0xf0, 0x4e, 0x4a, 0x10, 0x99, 0x62, 0xdd, 0xf4, 0x32, 0x6b,
- 0xf6, 0x23, 0x12, 0x90};
-
- EXPECT_TRUE(context->VerifySignatureOverData(CreateString(kSha1Signature),
- CreateString(kData)));
-
- // Verify using a VALID SHA-256 signature. This only fails because it is
- // expecting a SHA-1 signature not a SHA-256 signature.
- EXPECT_FALSE(context->VerifySignatureOverData(CreateString(kSha256Signature),
- CreateString(kData)));
-}
-
-// ------------------------------------------------------
-// Valid signature using 1024-bit RSA key
-// ------------------------------------------------------
-
-// This test vector comes from the NIST test vectors (pkcs1v15sign-vectors.txt),
-// PKCS#1 v1.5 Signature Example 1.2.
-//
-// It is a valid signature using a 1024 bit key and SHA-1.
-
-const uint8_t kEx1Message[] = {
- 0x85, 0x13, 0x84, 0xcd, 0xfe, 0x81, 0x9c, 0x22, 0xed, 0x6c, 0x4c,
- 0xcb, 0x30, 0xda, 0xeb, 0x5c, 0xf0, 0x59, 0xbc, 0x8e, 0x11, 0x66,
- 0xb7, 0xe3, 0x53, 0x0c, 0x4c, 0x23, 0x3e, 0x2b, 0x5f, 0x8f, 0x71,
- 0xa1, 0xcc, 0xa5, 0x82, 0xd4, 0x3e, 0xcc, 0x72, 0xb1, 0xbc, 0xa1,
- 0x6d, 0xfc, 0x70, 0x13, 0x22, 0x6b, 0x9e,
-};
-
-const uint8_t kEx1Signature[] = {
- 0x84, 0xfd, 0x2c, 0xe7, 0x34, 0xec, 0x1d, 0xa8, 0x28, 0xd0, 0xf1, 0x5b,
- 0xf4, 0x9a, 0x87, 0x07, 0xc1, 0x5d, 0x05, 0x94, 0x81, 0x36, 0xde, 0x53,
- 0x7a, 0x3d, 0xb4, 0x21, 0x38, 0x41, 0x67, 0xc8, 0x6f, 0xae, 0x02, 0x25,
- 0x87, 0xee, 0x9e, 0x13, 0x7d, 0xae, 0xe7, 0x54, 0x73, 0x82, 0x62, 0x93,
- 0x2d, 0x27, 0x1c, 0x74, 0x4c, 0x6d, 0x3a, 0x18, 0x9a, 0xd4, 0x31, 0x1b,
- 0xdb, 0x02, 0x04, 0x92, 0xe3, 0x22, 0xfb, 0xdd, 0xc4, 0x04, 0x06, 0xea,
- 0x86, 0x0d, 0x4e, 0x8e, 0xa2, 0xa4, 0x08, 0x4a, 0xa9, 0x8b, 0x96, 0x22,
- 0xa4, 0x46, 0x75, 0x6f, 0xdb, 0x74, 0x0d, 0xdb, 0x3d, 0x91, 0xdb, 0x76,
- 0x70, 0xe2, 0x11, 0x66, 0x1b, 0xbf, 0x87, 0x09, 0xb1, 0x1c, 0x08, 0xa7,
- 0x07, 0x71, 0x42, 0x2d, 0x1a, 0x12, 0xde, 0xf2, 0x9f, 0x06, 0x88, 0xa1,
- 0x92, 0xae, 0xbd, 0x89, 0xe0, 0xf8, 0x96, 0xf8,
-};
-
-const uint8_t kEx1PublicKeySpki[] = {
- 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
- 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81,
- 0x89, 0x02, 0x81, 0x81, 0x00, 0xa5, 0x6e, 0x4a, 0x0e, 0x70, 0x10, 0x17,
- 0x58, 0x9a, 0x51, 0x87, 0xdc, 0x7e, 0xa8, 0x41, 0xd1, 0x56, 0xf2, 0xec,
- 0x0e, 0x36, 0xad, 0x52, 0xa4, 0x4d, 0xfe, 0xb1, 0xe6, 0x1f, 0x7a, 0xd9,
- 0x91, 0xd8, 0xc5, 0x10, 0x56, 0xff, 0xed, 0xb1, 0x62, 0xb4, 0xc0, 0xf2,
- 0x83, 0xa1, 0x2a, 0x88, 0xa3, 0x94, 0xdf, 0xf5, 0x26, 0xab, 0x72, 0x91,
- 0xcb, 0xb3, 0x07, 0xce, 0xab, 0xfc, 0xe0, 0xb1, 0xdf, 0xd5, 0xcd, 0x95,
- 0x08, 0x09, 0x6d, 0x5b, 0x2b, 0x8b, 0x6d, 0xf5, 0xd6, 0x71, 0xef, 0x63,
- 0x77, 0xc0, 0x92, 0x1c, 0xb2, 0x3c, 0x27, 0x0a, 0x70, 0xe2, 0x59, 0x8e,
- 0x6f, 0xf8, 0x9d, 0x19, 0xf1, 0x05, 0xac, 0xc2, 0xd3, 0xf0, 0xcb, 0x35,
- 0xf2, 0x92, 0x80, 0xe1, 0x38, 0x6b, 0x6f, 0x64, 0xc4, 0xef, 0x22, 0xe1,
- 0xe1, 0xf2, 0x0d, 0x0c, 0xe8, 0xcf, 0xfb, 0x22, 0x49, 0xbd, 0x9a, 0x21,
- 0x37, 0x02, 0x03, 0x01, 0x00, 0x01,
-};
-
-// Tests that a valid signature fails, because it uses a 1024-bit RSA key (too
-// weak).
-TEST(VerifyCastDeviceCertTest, VerifySignature1024BitRsa) {
- auto context =
- CertVerificationContextImplForTest(CreateString(kEx1PublicKeySpki));
-
- EXPECT_FALSE(context->VerifySignatureOverData(CreateString(kEx1Signature),
- CreateString(kEx1Message)));
-}
-
-// ------------------------------------------------------
-// Valid signature using 2048-bit RSA key
-// ------------------------------------------------------
-
-// This test vector was generated (using WebCrypto). It is a valid signature
-// using a 2048-bit RSA key, RSASSA PKCS#1 v1.5 with SHA-1.
-
-const uint8_t kEx2Message[] = {
- // "hello"
- 0x68, 0x65, 0x6c, 0x6c, 0x6f,
-};
-
-const uint8_t kEx2Signature[] = {
- 0xc1, 0x21, 0x84, 0xe1, 0x62, 0x0e, 0x59, 0x52, 0x5b, 0xa4, 0x10, 0x1e,
- 0x11, 0x80, 0x5b, 0x9e, 0xcb, 0xa0, 0x20, 0x78, 0x29, 0xfc, 0xc0, 0x9a,
- 0xd9, 0x48, 0x90, 0x81, 0x03, 0xa9, 0xc0, 0x2f, 0x0a, 0xc4, 0x20, 0x34,
- 0xb5, 0xdb, 0x19, 0x04, 0xec, 0x94, 0x9b, 0xba, 0x48, 0x43, 0xf3, 0x5a,
- 0x15, 0x56, 0xfc, 0x4a, 0x87, 0x79, 0xf8, 0x50, 0xff, 0x5d, 0x66, 0x25,
- 0xdc, 0xa5, 0xd8, 0xe8, 0x9f, 0x5a, 0x73, 0x79, 0x6f, 0x5d, 0x99, 0xe0,
- 0xd5, 0xa5, 0x84, 0x49, 0x20, 0x3c, 0xe2, 0xa3, 0xd0, 0x69, 0x31, 0x2c,
- 0x13, 0xaf, 0x15, 0xd9, 0x10, 0x0d, 0x6f, 0xdd, 0x9d, 0x62, 0x5d, 0x7b,
- 0xe1, 0x1a, 0x48, 0x59, 0xaf, 0xf7, 0xbe, 0x87, 0x92, 0x60, 0x5d, 0x1a,
- 0xb5, 0xfe, 0x27, 0x38, 0x02, 0x20, 0xe9, 0xaf, 0x04, 0x57, 0xd3, 0x3b,
- 0x70, 0x04, 0x63, 0x5b, 0xc6, 0x5d, 0x83, 0xe2, 0xaf, 0x02, 0xb4, 0xef,
- 0x1c, 0x33, 0x54, 0x38, 0xf8, 0xb5, 0x19, 0xa8, 0x88, 0xdd, 0x1d, 0x96,
- 0x1c, 0x5e, 0x54, 0x80, 0xde, 0x7b, 0xb6, 0x29, 0xb8, 0x6b, 0xea, 0x47,
- 0xe5, 0xf1, 0x7e, 0xed, 0xe1, 0x91, 0xc8, 0xb8, 0x54, 0xd9, 0x1e, 0xfd,
- 0x07, 0x10, 0xbd, 0xa9, 0xd4, 0x93, 0x5e, 0x65, 0x8b, 0x6b, 0x46, 0x93,
- 0x4b, 0x60, 0x2a, 0x26, 0xf0, 0x1b, 0x4e, 0xca, 0x04, 0x82, 0xc0, 0x8d,
- 0xb1, 0xa5, 0xa8, 0x70, 0xdd, 0x66, 0x68, 0x95, 0x09, 0xb4, 0x85, 0x62,
- 0xf5, 0x17, 0x04, 0x48, 0xb4, 0x9d, 0x66, 0x2b, 0x25, 0x82, 0x7e, 0x99,
- 0x3e, 0xa1, 0x11, 0x63, 0xc3, 0xdf, 0x10, 0x20, 0x52, 0x56, 0x32, 0x35,
- 0xa9, 0x36, 0xde, 0x2a, 0xac, 0x10, 0x0d, 0x75, 0x21, 0xed, 0x5b, 0x38,
- 0xb6, 0xb5, 0x1e, 0xb5, 0x5b, 0x9a, 0x72, 0xd5, 0xf8, 0x1a, 0xd3, 0x91,
- 0xb8, 0x29, 0x0e, 0x58,
-};
-
-const uint8_t kEx2PublicKeySpki[] = {
- 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
- 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00,
- 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xcf, 0xde, 0xa5,
- 0x2e, 0x9d, 0x38, 0x62, 0x72, 0x47, 0x84, 0x8f, 0x2e, 0xa5, 0xe3, 0xd6,
- 0x34, 0xb0, 0xf9, 0x79, 0xa9, 0x10, 0x63, 0xa9, 0x93, 0x5a, 0xa1, 0xb9,
- 0xa3, 0x03, 0xd3, 0xcd, 0x9d, 0x84, 0x7d, 0xb6, 0x92, 0x47, 0xb4, 0x7d,
- 0x4a, 0xe8, 0x3a, 0x4b, 0xc5, 0xf6, 0x35, 0x6f, 0x18, 0x72, 0xf3, 0xbc,
- 0xd2, 0x1c, 0x7a, 0xd2, 0xe5, 0xdf, 0xcf, 0xb9, 0xac, 0x28, 0xd3, 0x49,
- 0x2a, 0x4f, 0x08, 0x62, 0xb9, 0xf1, 0xaa, 0x3d, 0x76, 0xe3, 0xa9, 0x96,
- 0x32, 0x24, 0x94, 0x9e, 0x88, 0xf8, 0x5e, 0xc3, 0x3c, 0x14, 0x32, 0x86,
- 0x72, 0xa2, 0x34, 0x3d, 0x41, 0xd0, 0xb2, 0x01, 0x99, 0x01, 0xf3, 0x93,
- 0xa3, 0x76, 0x5a, 0xff, 0x42, 0x28, 0x54, 0xe0, 0xcc, 0x4c, 0xcd, 0x2d,
- 0x3b, 0x0b, 0x47, 0xcc, 0xc2, 0x75, 0x02, 0xc1, 0xb7, 0x0b, 0x37, 0x65,
- 0xe6, 0x0d, 0xe4, 0xc3, 0x85, 0x86, 0x29, 0x3c, 0x77, 0xce, 0xb0, 0x34,
- 0xa9, 0x03, 0xe9, 0x13, 0xbe, 0x97, 0x1e, 0xfd, 0xeb, 0x0d, 0x60, 0xc2,
- 0xb3, 0x19, 0xa1, 0x75, 0x72, 0x57, 0x3f, 0x5d, 0x0e, 0x75, 0xac, 0x10,
- 0x96, 0xad, 0x95, 0x67, 0x9f, 0xa2, 0x84, 0x15, 0x6a, 0x61, 0xb1, 0x47,
- 0xd1, 0x24, 0x78, 0xb4, 0x40, 0x2b, 0xc3, 0x5c, 0x73, 0xd4, 0xc1, 0x8d,
- 0x12, 0xf1, 0x3f, 0xb4, 0x93, 0x17, 0xfe, 0x5d, 0xbf, 0x39, 0xf2, 0x45,
- 0xf9, 0xcf, 0x38, 0x44, 0x40, 0x5b, 0x47, 0x2a, 0xbf, 0xb9, 0xac, 0xa6,
- 0x14, 0xb6, 0x1b, 0xe3, 0xa8, 0x14, 0xf8, 0xfe, 0x47, 0x67, 0xea, 0x90,
- 0x51, 0x12, 0xcf, 0x5e, 0x28, 0xec, 0x92, 0x83, 0x7c, 0xc6, 0x29, 0x9f,
- 0x12, 0x29, 0x88, 0x49, 0xf7, 0xb7, 0xed, 0x5e, 0x3a, 0x78, 0xd6, 0x8a,
- 0xba, 0x42, 0x6e, 0x0a, 0xf4, 0x0d, 0xc1, 0xc0, 0x8f, 0xdb, 0x26, 0x41,
- 0x57, 0x02, 0x03, 0x01, 0x00, 0x01,
-};
-
-// Tests that a valid signature using 2048-bit key succeeds.
-TEST(VerifyCastDeviceCertTest, VerifySignature2048BitRsa) {
- auto context =
- CertVerificationContextImplForTest(CreateString(kEx2PublicKeySpki));
-
- EXPECT_TRUE(context->VerifySignatureOverData(CreateString(kEx2Signature),
- CreateString(kEx2Message)));
-}
-
-} // namespace
-
-} // namespace cast_crypto
-
-} // namespace api
-
-} // namespace extensions
diff --git a/chromium/extensions/common/event_filter.cc b/chromium/extensions/common/event_filter.cc
index 955671c20c4..2a16678cbdf 100644
--- a/chromium/extensions/common/event_filter.cc
+++ b/chromium/extensions/common/event_filter.cc
@@ -17,7 +17,7 @@ using url_matcher::URLMatcherFactory;
namespace extensions {
EventFilter::EventMatcherEntry::EventMatcherEntry(
- scoped_ptr<EventMatcher> event_matcher,
+ std::unique_ptr<EventMatcher> event_matcher,
URLMatcher* url_matcher,
const URLMatcherConditionSet::Vector& condition_sets)
: event_matcher_(std::move(event_matcher)), url_matcher_(url_matcher) {
@@ -53,9 +53,9 @@ EventFilter::~EventFilter() {
}
}
-EventFilter::MatcherID
-EventFilter::AddEventMatcher(const std::string& event_name,
- scoped_ptr<EventMatcher> matcher) {
+EventFilter::MatcherID EventFilter::AddEventMatcher(
+ const std::string& event_name,
+ std::unique_ptr<EventMatcher> matcher) {
MatcherID id = next_id_++;
URLMatcherConditionSet::Vector condition_sets;
if (!CreateConditionSets(id, matcher.get(), &condition_sets))
diff --git a/chromium/extensions/common/event_filter.h b/chromium/extensions/common/event_filter.h
index 8f6d6040420..567c1d08676 100644
--- a/chromium/extensions/common/event_filter.h
+++ b/chromium/extensions/common/event_filter.h
@@ -28,7 +28,7 @@ class EventFilter {
// Adds an event matcher that will be used in calls to MatchEvent(). Returns
// the id of the matcher, or -1 if there was an error.
MatcherID AddEventMatcher(const std::string& event_name,
- scoped_ptr<EventMatcher> matcher);
+ std::unique_ptr<EventMatcher> matcher);
// Retrieve the EventMatcher with the given id.
EventMatcher* GetEventMatcher(MatcherID id);
@@ -63,7 +63,7 @@ class EventFilter {
// URLMatcherConditionSets that match the URL constraints specified by
// |event_matcher|.
EventMatcherEntry(
- scoped_ptr<EventMatcher> event_matcher,
+ std::unique_ptr<EventMatcher> event_matcher,
url_matcher::URLMatcher* url_matcher,
const url_matcher::URLMatcherConditionSet::Vector& condition_sets);
~EventMatcherEntry();
@@ -79,7 +79,7 @@ class EventFilter {
}
private:
- scoped_ptr<EventMatcher> event_matcher_;
+ std::unique_ptr<EventMatcher> event_matcher_;
// The id sets in url_matcher_ that this EventMatcher owns.
std::vector<url_matcher::URLMatcherConditionSet::ID> condition_set_ids_;
url_matcher::URLMatcher* url_matcher_;
diff --git a/chromium/extensions/common/event_filter_unittest.cc b/chromium/extensions/common/event_filter_unittest.cc
index bb5fe048fd7..8ab266cb680 100644
--- a/chromium/extensions/common/event_filter_unittest.cc
+++ b/chromium/extensions/common/event_filter_unittest.cc
@@ -4,10 +4,10 @@
#include "extensions/common/event_filter.h"
+#include <memory>
#include <string>
#include <utility>
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "extensions/common/event_filtering_info.h"
#include "extensions/common/event_matcher.h"
@@ -30,32 +30,35 @@ class EventFilterUnittest : public testing::Test {
}
protected:
- scoped_ptr<base::Value> HostSuffixDict(const std::string& host_suffix) {
- scoped_ptr<base::DictionaryValue> dict(new DictionaryValue());
+ std::unique_ptr<base::Value> HostSuffixDict(const std::string& host_suffix) {
+ std::unique_ptr<base::DictionaryValue> dict(new DictionaryValue());
dict->Set("hostSuffix", new base::StringValue(host_suffix));
- return scoped_ptr<base::Value>(dict.release());
+ return std::unique_ptr<base::Value>(dict.release());
}
- scoped_ptr<base::ListValue> ValueAsList(scoped_ptr<base::Value> value) {
- scoped_ptr<base::ListValue> result(new base::ListValue());
+ std::unique_ptr<base::ListValue> ValueAsList(
+ std::unique_ptr<base::Value> value) {
+ std::unique_ptr<base::ListValue> result(new base::ListValue());
result->Append(value.release());
return result;
}
- scoped_ptr<EventMatcher> AllURLs() {
- return scoped_ptr<EventMatcher>(new EventMatcher(
- scoped_ptr<DictionaryValue>(new DictionaryValue), MSG_ROUTING_NONE));
+ std::unique_ptr<EventMatcher> AllURLs() {
+ return std::unique_ptr<EventMatcher>(
+ new EventMatcher(std::unique_ptr<DictionaryValue>(new DictionaryValue),
+ MSG_ROUTING_NONE));
}
- scoped_ptr<EventMatcher> HostSuffixMatcher(const std::string& host_suffix) {
+ std::unique_ptr<EventMatcher> HostSuffixMatcher(
+ const std::string& host_suffix) {
return MatcherFromURLFilterList(ValueAsList(HostSuffixDict(host_suffix)));
}
- scoped_ptr<EventMatcher> MatcherFromURLFilterList(
- scoped_ptr<ListValue> url_filter_list) {
- scoped_ptr<DictionaryValue> filter_dict(new DictionaryValue);
+ std::unique_ptr<EventMatcher> MatcherFromURLFilterList(
+ std::unique_ptr<ListValue> url_filter_list) {
+ std::unique_ptr<DictionaryValue> filter_dict(new DictionaryValue);
filter_dict->Set("url", url_filter_list.release());
- return scoped_ptr<EventMatcher>(
+ return std::unique_ptr<EventMatcher>(
new EventMatcher(std::move(filter_dict), MSG_ROUTING_NONE));
}
@@ -135,11 +138,11 @@ TEST_F(EventFilterUnittest, TestURLMatching) {
}
TEST_F(EventFilterUnittest, TestMultipleURLFiltersMatchOnAny) {
- scoped_ptr<base::ListValue> filters(new base::ListValue());
+ std::unique_ptr<base::ListValue> filters(new base::ListValue());
filters->Append(HostSuffixDict("google.com").release());
filters->Append(HostSuffixDict("yahoo.com").release());
- scoped_ptr<EventMatcher> matcher(
+ std::unique_ptr<EventMatcher> matcher(
MatcherFromURLFilterList(std::move(filters)));
int id = event_filter_.AddEventMatcher("event1", std::move(matcher));
@@ -210,9 +213,9 @@ TEST_F(EventFilterUnittest, RemoveEventMatcherReturnsEventName) {
}
TEST_F(EventFilterUnittest, InvalidURLFilterCantBeAdded) {
- scoped_ptr<base::ListValue> filter_list(new base::ListValue());
+ std::unique_ptr<base::ListValue> filter_list(new base::ListValue());
filter_list->Append(new base::ListValue()); // Should be a dict.
- scoped_ptr<EventMatcher> matcher(
+ std::unique_ptr<EventMatcher> matcher(
MatcherFromURLFilterList(std::move(filter_list)));
int id1 = event_filter_.AddEventMatcher("event1", std::move(matcher));
EXPECT_TRUE(event_filter_.IsURLMatcherEmpty());
@@ -220,9 +223,9 @@ TEST_F(EventFilterUnittest, InvalidURLFilterCantBeAdded) {
}
TEST_F(EventFilterUnittest, EmptyListOfURLFiltersMatchesAllURLs) {
- scoped_ptr<base::ListValue> filter_list(new base::ListValue());
- scoped_ptr<EventMatcher> matcher(MatcherFromURLFilterList(
- scoped_ptr<ListValue>(new ListValue)));
+ std::unique_ptr<base::ListValue> filter_list(new base::ListValue());
+ std::unique_ptr<EventMatcher> matcher(
+ MatcherFromURLFilterList(std::unique_ptr<ListValue>(new ListValue)));
int id = event_filter_.AddEventMatcher("event1", std::move(matcher));
std::set<int> matches = event_filter_.MatchEvent("event1",
google_event_, MSG_ROUTING_NONE);
@@ -250,8 +253,8 @@ TEST_F(EventFilterUnittest, EmptyURLsShouldBeMatchedByEmptyURLFilters) {
TEST_F(EventFilterUnittest,
EmptyURLsShouldBeMatchedByEmptyURLFiltersWithAnEmptyItem) {
- scoped_ptr<EventMatcher> matcher(MatcherFromURLFilterList(ValueAsList(
- scoped_ptr<Value>(new DictionaryValue()))));
+ std::unique_ptr<EventMatcher> matcher(MatcherFromURLFilterList(
+ ValueAsList(std::unique_ptr<Value>(new DictionaryValue()))));
int id = event_filter_.AddEventMatcher("event1", std::move(matcher));
std::set<int> matches = event_filter_.MatchEvent(
"event1", empty_url_event_, MSG_ROUTING_NONE);
diff --git a/chromium/extensions/common/event_filtering_info.cc b/chromium/extensions/common/event_filtering_info.cc
index a426e1bb98d..0f2c7230a2f 100644
--- a/chromium/extensions/common/event_filtering_info.cc
+++ b/chromium/extensions/common/event_filtering_info.cc
@@ -44,11 +44,11 @@ void EventFilteringInfo::SetInstanceID(int instance_id) {
has_instance_id_ = true;
}
-scoped_ptr<base::Value> EventFilteringInfo::AsValue() const {
+std::unique_ptr<base::Value> EventFilteringInfo::AsValue() const {
if (IsEmpty())
return base::Value::CreateNullValue();
- scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue);
+ std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue);
if (has_url_)
result->SetString("url", url_.spec());
diff --git a/chromium/extensions/common/event_filtering_info.h b/chromium/extensions/common/event_filtering_info.h
index aaa03a4200c..5578a95c7bc 100644
--- a/chromium/extensions/common/event_filtering_info.h
+++ b/chromium/extensions/common/event_filtering_info.h
@@ -5,7 +5,8 @@
#ifndef EXTENSIONS_COMMON_EVENT_FILTERING_INFO_H_
#define EXTENSIONS_COMMON_EVENT_FILTERING_INFO_H_
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "url/gurl.h"
namespace base {
@@ -59,7 +60,7 @@ class EventFilteringInfo {
bool has_service_type() const { return !service_type_.empty(); }
const std::string& service_type() const { return service_type_; }
- scoped_ptr<base::Value> AsValue() const;
+ std::unique_ptr<base::Value> AsValue() const;
bool IsEmpty() const;
private:
diff --git a/chromium/extensions/common/event_matcher.cc b/chromium/extensions/common/event_matcher.cc
index 05dfdd8df42..25d23ab9f3c 100644
--- a/chromium/extensions/common/event_matcher.cc
+++ b/chromium/extensions/common/event_matcher.cc
@@ -18,7 +18,7 @@ namespace extensions {
const char kEventFilterServiceTypeKey[] = "serviceType";
-EventMatcher::EventMatcher(scoped_ptr<base::DictionaryValue> filter,
+EventMatcher::EventMatcher(std::unique_ptr<base::DictionaryValue> filter,
int routing_id)
: filter_(std::move(filter)), routing_id_(routing_id) {}
diff --git a/chromium/extensions/common/event_matcher.h b/chromium/extensions/common/event_matcher.h
index 3bffd241a54..e7753985e43 100644
--- a/chromium/extensions/common/event_matcher.h
+++ b/chromium/extensions/common/event_matcher.h
@@ -5,8 +5,9 @@
#ifndef EXTENSIONS_COMMON_EVENT_MATCHER_H_
#define EXTENSIONS_COMMON_EVENT_MATCHER_H_
+#include <memory>
+
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
namespace extensions {
@@ -21,8 +22,7 @@ extern const char kEventFilterServiceTypeKey[];
// MatchNonURLCriteria() - URL matching is handled by EventFilter.
class EventMatcher {
public:
- EventMatcher(scoped_ptr<base::DictionaryValue> filter,
- int routing_id);
+ EventMatcher(std::unique_ptr<base::DictionaryValue> filter, int routing_id);
~EventMatcher();
// Returns true if |event_info| satisfies this matcher's criteria, not taking
@@ -55,7 +55,7 @@ class EventMatcher {
// {url: [{hostSuffix: 'google.com'}]}
//
// The valid filter keys are event-specific.
- scoped_ptr<base::DictionaryValue> filter_;
+ std::unique_ptr<base::DictionaryValue> filter_;
int routing_id_;
diff --git a/chromium/extensions/common/extension.cc b/chromium/extensions/common/extension.cc
index 227cb7e515b..fd77aa0ab20 100644
--- a/chromium/extensions/common/extension.cc
+++ b/chromium/extensions/common/extension.cc
@@ -118,9 +118,8 @@ scoped_refptr<Extension> Extension::Create(const base::FilePath& path,
std::string* utf8_error) {
DCHECK(utf8_error);
base::string16 error;
- scoped_ptr<extensions::Manifest> manifest(
- new extensions::Manifest(
- location, scoped_ptr<base::DictionaryValue>(value.DeepCopy())));
+ std::unique_ptr<extensions::Manifest> manifest(new extensions::Manifest(
+ location, std::unique_ptr<base::DictionaryValue>(value.DeepCopy())));
if (!InitExtensionID(manifest.get(), path, explicit_id, flags, &error)) {
*utf8_error = base::UTF16ToUTF8(error);
@@ -384,7 +383,7 @@ Extension::ManifestData* Extension::GetManifestData(const std::string& key)
void Extension::SetManifestData(const std::string& key,
Extension::ManifestData* data) {
DCHECK(!finished_parsing_manifest_ && thread_checker_.CalledOnValidThread());
- manifest_data_[key] = scoped_ptr<ManifestData>(data);
+ manifest_data_[key] = std::unique_ptr<ManifestData>(data);
}
Manifest::Location Extension::location() const {
@@ -493,7 +492,7 @@ bool Extension::InitExtensionID(extensions::Manifest* manifest,
}
Extension::Extension(const base::FilePath& path,
- scoped_ptr<extensions::Manifest> manifest)
+ std::unique_ptr<extensions::Manifest> manifest)
: manifest_version_(0),
converted_from_user_script_(false),
manifest_(manifest.release()),
diff --git a/chromium/extensions/common/extension.h b/chromium/extensions/common/extension.h
index 13a86b74e56..278a8c488bb 100644
--- a/chromium/extensions/common/extension.h
+++ b/chromium/extensions/common/extension.h
@@ -6,6 +6,7 @@
#define EXTENSIONS_COMMON_EXTENSION_H_
#include <map>
+#include <memory>
#include <set>
#include <string>
#include <vector>
@@ -14,7 +15,6 @@
#include "base/macros.h"
#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/threading/thread_checker.h"
#include "extensions/common/extension_resource.h"
#include "extensions/common/install_warning.h"
@@ -359,7 +359,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
base::string16* error);
Extension(const base::FilePath& path,
- scoped_ptr<extensions::Manifest> manifest);
+ std::unique_ptr<extensions::Manifest> manifest);
virtual ~Extension();
// Initialize the extension from a parsed manifest.
@@ -424,10 +424,10 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
// The parser for the manifest's permissions. This is NULL anytime not during
// initialization.
// TODO(rdevlin.cronin): This doesn't really belong here.
- scoped_ptr<PermissionsParser> permissions_parser_;
+ std::unique_ptr<PermissionsParser> permissions_parser_;
// The active permissions for the extension.
- scoped_ptr<PermissionsData> permissions_data_;
+ std::unique_ptr<PermissionsData> permissions_data_;
// Any warnings that occurred when trying to create/parse the extension.
std::vector<InstallWarning> install_warnings_;
@@ -436,7 +436,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
GURL extension_url_;
// The extension's version.
- scoped_ptr<base::Version> version_;
+ std::unique_ptr<base::Version> version_;
// The extension's user visible version name.
std::string version_name_;
@@ -452,10 +452,10 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
std::string public_key_;
// The manifest from which this extension was created.
- scoped_ptr<Manifest> manifest_;
+ std::unique_ptr<Manifest> manifest_;
// Stored parsed manifest data.
- using ManifestDataMap = std::map<std::string, scoped_ptr<ManifestData>>;
+ using ManifestDataMap = std::map<std::string, std::unique_ptr<ManifestData>>;
ManifestDataMap manifest_data_;
// Set to true at the end of InitValue when initialization is finished.
@@ -495,7 +495,7 @@ struct ExtensionInfo {
Manifest::Location location);
~ExtensionInfo();
- scoped_ptr<base::DictionaryValue> extension_manifest;
+ std::unique_ptr<base::DictionaryValue> extension_manifest;
ExtensionId extension_id;
base::FilePath extension_path;
Manifest::Location extension_location;
diff --git a/chromium/extensions/common/extension_api.cc b/chromium/extensions/common/extension_api.cc
index b30af5f28d1..1fee5b3c8b2 100644
--- a/chromium/extensions/common/extension_api.cc
+++ b/chromium/extensions/common/extension_api.cc
@@ -45,15 +45,15 @@ base::StringPiece ReadFromResource(int resource_id) {
resource_id);
}
-scoped_ptr<base::ListValue> LoadSchemaList(const std::string& name,
- const base::StringPiece& schema) {
+std::unique_ptr<base::ListValue> LoadSchemaList(
+ const std::string& name,
+ const base::StringPiece& schema) {
std::string error_message;
- scoped_ptr<base::Value> result(
- base::JSONReader::ReadAndReturnError(
- schema,
- base::JSON_PARSE_RFC | base::JSON_DETACHABLE_CHILDREN, // options
- NULL, // error code
- &error_message));
+ std::unique_ptr<base::Value> result(base::JSONReader::ReadAndReturnError(
+ schema,
+ base::JSON_PARSE_RFC | base::JSON_DETACHABLE_CHILDREN, // options
+ NULL, // error code
+ &error_message));
// Tracking down http://crbug.com/121424
char buf[128];
@@ -102,7 +102,7 @@ struct Static {
Static()
: api(ExtensionAPI::CreateWithDefaultConfiguration()) {
}
- scoped_ptr<ExtensionAPI> api;
+ std::unique_ptr<ExtensionAPI> api;
};
base::LazyInstance<Static> g_lazy_instance = LAZY_INSTANCE_INITIALIZER;
@@ -213,7 +213,7 @@ ExtensionAPI::OverrideSharedInstanceForTest::~OverrideSharedInstanceForTest() {
void ExtensionAPI::LoadSchema(const std::string& name,
const base::StringPiece& schema) {
- scoped_ptr<base::ListValue> schema_list(LoadSchemaList(name, schema));
+ std::unique_ptr<base::ListValue> schema_list(LoadSchemaList(name, schema));
std::string schema_namespace;
extensions::ExtensionsClient* extensions_client =
extensions::ExtensionsClient::Get();
@@ -221,7 +221,7 @@ void ExtensionAPI::LoadSchema(const std::string& name,
while (!schema_list->empty()) {
base::DictionaryValue* schema = NULL;
{
- scoped_ptr<base::Value> value;
+ std::unique_ptr<base::Value> value;
schema_list->Remove(schema_list->GetSize() - 1, &value);
CHECK(value.release()->GetAsDictionary(&schema));
}
diff --git a/chromium/extensions/common/extension_api.h b/chromium/extensions/common/extension_api.h
index fc3e20cde55..b8dee559e4b 100644
--- a/chromium/extensions/common/extension_api.h
+++ b/chromium/extensions/common/extension_api.h
@@ -6,12 +6,12 @@
#define EXTENSIONS_COMMON_EXTENSION_API_H_
#include <map>
+#include <memory>
#include <string>
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/linked_ptr.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "base/strings/string_piece.h"
#include "base/values.h"
diff --git a/chromium/extensions/common/extension_builder.cc b/chromium/extensions/common/extension_builder.cc
index 905ba6b2dfa..e00db3cb3db 100644
--- a/chromium/extensions/common/extension_builder.cc
+++ b/chromium/extensions/common/extension_builder.cc
@@ -56,13 +56,13 @@ ExtensionBuilder& ExtensionBuilder::SetLocation(Manifest::Location location) {
}
ExtensionBuilder& ExtensionBuilder::SetManifest(
- scoped_ptr<base::DictionaryValue> manifest) {
+ std::unique_ptr<base::DictionaryValue> manifest) {
manifest_ = std::move(manifest);
return *this;
}
ExtensionBuilder& ExtensionBuilder::MergeManifest(
- scoped_ptr<base::DictionaryValue> manifest) {
+ std::unique_ptr<base::DictionaryValue> manifest) {
manifest_->MergeDictionary(manifest.get());
return *this;
}
diff --git a/chromium/extensions/common/extension_builder.h b/chromium/extensions/common/extension_builder.h
index 5fe9801a602..c6d5ab6e20b 100644
--- a/chromium/extensions/common/extension_builder.h
+++ b/chromium/extensions/common/extension_builder.h
@@ -5,12 +5,12 @@
#ifndef EXTENSIONS_COMMON_EXTENSION_BUILDER_H_
#define EXTENSIONS_COMMON_EXTENSION_BUILDER_H_
+#include <memory>
#include <string>
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/common/manifest.h"
#include "extensions/common/value_builder.h"
@@ -39,11 +39,13 @@ class ExtensionBuilder {
// Defaults to Manifest::UNPACKED.
ExtensionBuilder& SetLocation(Manifest::Location location);
- ExtensionBuilder& SetManifest(scoped_ptr<base::DictionaryValue> manifest);
+ ExtensionBuilder& SetManifest(
+ std::unique_ptr<base::DictionaryValue> manifest);
// Merge another manifest into the current manifest, with new keys taking
// precedence.
- ExtensionBuilder& MergeManifest(scoped_ptr<base::DictionaryValue> manifest);
+ ExtensionBuilder& MergeManifest(
+ std::unique_ptr<base::DictionaryValue> manifest);
ExtensionBuilder& AddFlags(int init_from_value_flags);
@@ -53,7 +55,7 @@ class ExtensionBuilder {
private:
base::FilePath path_;
Manifest::Location location_;
- scoped_ptr<base::DictionaryValue> manifest_;
+ std::unique_ptr<base::DictionaryValue> manifest_;
int flags_;
std::string id_;
diff --git a/chromium/extensions/common/extension_l10n_util.cc b/chromium/extensions/common/extension_l10n_util.cc
index a423ba59563..492f283231c 100644
--- a/chromium/extensions/common/extension_l10n_util.cc
+++ b/chromium/extensions/common/extension_l10n_util.cc
@@ -41,8 +41,9 @@ base::DictionaryValue* LoadMessageFile(const base::FilePath& locale_path,
base::FilePath file =
locale_path.AppendASCII(locale).Append(extensions::kMessagesFilename);
JSONFileValueDeserializer messages_deserializer(file);
- scoped_ptr<base::DictionaryValue> dictionary = base::DictionaryValue::From(
- messages_deserializer.Deserialize(NULL, error));
+ std::unique_ptr<base::DictionaryValue> dictionary =
+ base::DictionaryValue::From(
+ messages_deserializer.Deserialize(NULL, error));
if (!dictionary) {
if (error->empty()) {
// JSONFileValueSerializer just returns NULL if file cannot be found. It
@@ -265,9 +266,9 @@ bool LocalizeExtension(const base::FilePath& extension_path,
std::string default_locale = GetDefaultLocaleFromManifest(*manifest, error);
- scoped_ptr<extensions::MessageBundle> message_bundle(
- extensions::file_util::LoadMessageBundle(
- extension_path, default_locale, error));
+ std::unique_ptr<extensions::MessageBundle> message_bundle(
+ extensions::file_util::LoadMessageBundle(extension_path, default_locale,
+ error));
if (!message_bundle.get() && !error->empty())
return false;
@@ -415,7 +416,7 @@ bool ValidateExtensionLocales(const base::FilePath& extension_path,
locale != valid_locales.end();
++locale) {
std::string locale_error;
- scoped_ptr<base::DictionaryValue> catalog(
+ std::unique_ptr<base::DictionaryValue> catalog(
LoadMessageFile(locale_path, *locale, &locale_error));
if (!locale_error.empty()) {
diff --git a/chromium/extensions/common/extension_l10n_util_unittest.cc b/chromium/extensions/common/extension_l10n_util_unittest.cc
index d269501058f..89c5ff9d86a 100644
--- a/chromium/extensions/common/extension_l10n_util_unittest.cc
+++ b/chromium/extensions/common/extension_l10n_util_unittest.cc
@@ -4,11 +4,12 @@
#include "extensions/common/extension_l10n_util.h"
+#include <memory>
+
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/linked_ptr.h"
-#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@@ -128,8 +129,9 @@ TEST(ExtensionL10nUtil, LoadMessageCatalogsValidFallback) {
install_dir.AppendASCII("extension_with_locales").Append(kLocaleFolder);
std::string error;
- scoped_ptr<MessageBundle> bundle(extension_l10n_util::LoadMessageCatalogs(
- install_dir, "sr", "en_US", &error));
+ std::unique_ptr<MessageBundle> bundle(
+ extension_l10n_util::LoadMessageCatalogs(install_dir, "sr", "en_US",
+ &error));
ASSERT_FALSE(NULL == bundle.get());
EXPECT_TRUE(error.empty());
EXPECT_EQ("Color", bundle->GetL10nMessage("color"));
@@ -200,7 +202,7 @@ TEST(ExtensionL10nUtil, LoadMessageCatalogsDuplicateKeys) {
std::string error;
// JSON parser hides duplicates. We are going to get only one key/value
// pair at the end.
- scoped_ptr<MessageBundle> message_bundle(
+ std::unique_ptr<MessageBundle> message_bundle(
extension_l10n_util::LoadMessageCatalogs(src_path, "en", "sr", &error));
EXPECT_TRUE(NULL != message_bundle.get());
EXPECT_TRUE(error.empty());
@@ -270,7 +272,7 @@ MessageBundle* CreateManifestBundle() {
TEST(ExtensionL10nUtil, LocalizeEmptyManifest) {
base::DictionaryValue manifest;
std::string error;
- scoped_ptr<MessageBundle> messages(CreateManifestBundle());
+ std::unique_ptr<MessageBundle> messages(CreateManifestBundle());
EXPECT_FALSE(
extension_l10n_util::LocalizeManifest(*messages, &manifest, &error));
@@ -281,7 +283,7 @@ TEST(ExtensionL10nUtil, LocalizeManifestWithoutNameMsgAndEmptyDescription) {
base::DictionaryValue manifest;
manifest.SetString(keys::kName, "no __MSG");
std::string error;
- scoped_ptr<MessageBundle> messages(CreateManifestBundle());
+ std::unique_ptr<MessageBundle> messages(CreateManifestBundle());
EXPECT_TRUE(
extension_l10n_util::LocalizeManifest(*messages, &manifest, &error));
@@ -299,7 +301,7 @@ TEST(ExtensionL10nUtil, LocalizeManifestWithNameMsgAndEmptyDescription) {
base::DictionaryValue manifest;
manifest.SetString(keys::kName, "__MSG_name__");
std::string error;
- scoped_ptr<MessageBundle> messages(CreateManifestBundle());
+ std::unique_ptr<MessageBundle> messages(CreateManifestBundle());
EXPECT_TRUE(
extension_l10n_util::LocalizeManifest(*messages, &manifest, &error));
@@ -318,7 +320,7 @@ TEST(ExtensionL10nUtil, LocalizeManifestWithLocalLaunchURL) {
manifest.SetString(keys::kName, "name");
manifest.SetString(keys::kLaunchLocalPath, "__MSG_launch_local_path__");
std::string error;
- scoped_ptr<MessageBundle> messages(CreateManifestBundle());
+ std::unique_ptr<MessageBundle> messages(CreateManifestBundle());
EXPECT_TRUE(
extension_l10n_util::LocalizeManifest(*messages, &manifest, &error));
@@ -335,7 +337,7 @@ TEST(ExtensionL10nUtil, LocalizeManifestWithHostedLaunchURL) {
manifest.SetString(keys::kName, "name");
manifest.SetString(keys::kLaunchWebURL, "__MSG_launch_web_url__");
std::string error;
- scoped_ptr<MessageBundle> messages(CreateManifestBundle());
+ std::unique_ptr<MessageBundle> messages(CreateManifestBundle());
EXPECT_TRUE(
extension_l10n_util::LocalizeManifest(*messages, &manifest, &error));
@@ -352,7 +354,7 @@ TEST(ExtensionL10nUtil, LocalizeManifestWithBadNameMsg) {
manifest.SetString(keys::kName, "__MSG_name_is_bad__");
manifest.SetString(keys::kDescription, "__MSG_description__");
std::string error;
- scoped_ptr<MessageBundle> messages(CreateManifestBundle());
+ std::unique_ptr<MessageBundle> messages(CreateManifestBundle());
EXPECT_FALSE(
extension_l10n_util::LocalizeManifest(*messages, &manifest, &error));
@@ -377,7 +379,7 @@ TEST(ExtensionL10nUtil, LocalizeManifestWithNameDescriptionDefaultTitleMsgs) {
manifest.SetString(action_title, "__MSG_title__");
std::string error;
- scoped_ptr<MessageBundle> messages(CreateManifestBundle());
+ std::unique_ptr<MessageBundle> messages(CreateManifestBundle());
EXPECT_TRUE(
extension_l10n_util::LocalizeManifest(*messages, &manifest, &error));
@@ -402,7 +404,7 @@ TEST(ExtensionL10nUtil, LocalizeManifestWithNameDescriptionOmniboxMsgs) {
manifest.SetString(keys::kOmniboxKeyword, "__MSG_omnibox_keyword__");
std::string error;
- scoped_ptr<MessageBundle> messages(CreateManifestBundle());
+ std::unique_ptr<MessageBundle> messages(CreateManifestBundle());
EXPECT_TRUE(
extension_l10n_util::LocalizeManifest(*messages, &manifest, &error));
@@ -432,7 +434,7 @@ TEST(ExtensionL10nUtil, LocalizeManifestWithNameDescriptionFileHandlerTitle) {
"__MSG_file_handler_title__");
std::string error;
- scoped_ptr<MessageBundle> messages(CreateManifestBundle());
+ std::unique_ptr<MessageBundle> messages(CreateManifestBundle());
EXPECT_TRUE(
extension_l10n_util::LocalizeManifest(*messages, &manifest, &error));
@@ -469,7 +471,7 @@ TEST(ExtensionL10nUtil, LocalizeManifestWithNameDescriptionCommandDescription) {
"__MSG_second_command_description__");
std::string error;
- scoped_ptr<MessageBundle> messages(CreateManifestBundle());
+ std::unique_ptr<MessageBundle> messages(CreateManifestBundle());
EXPECT_TRUE(
extension_l10n_util::LocalizeManifest(*messages, &manifest, &error));
@@ -498,7 +500,7 @@ TEST(ExtensionL10nUtil, LocalizeManifestWithShortName) {
manifest.SetString(keys::kShortName, "__MSG_short_name__");
std::string error;
- scoped_ptr<MessageBundle> messages(CreateManifestBundle());
+ std::unique_ptr<MessageBundle> messages(CreateManifestBundle());
EXPECT_TRUE(
extension_l10n_util::LocalizeManifest(*messages, &manifest, &error));
@@ -515,7 +517,7 @@ TEST(ExtensionL10nUtil, LocalizeManifestWithBadShortName) {
manifest.SetString(keys::kShortName, "__MSG_short_name_bad__");
std::string error;
- scoped_ptr<MessageBundle> messages(CreateManifestBundle());
+ std::unique_ptr<MessageBundle> messages(CreateManifestBundle());
EXPECT_FALSE(
extension_l10n_util::LocalizeManifest(*messages, &manifest, &error));
@@ -546,7 +548,7 @@ TEST(ExtensionL10nUtil, LocalizeManifestWithSearchProviderMsgs) {
manifest.Set(keys::kOverrideStartupPage, startup_pages);
std::string error;
- scoped_ptr<MessageBundle> messages(CreateManifestBundle());
+ std::unique_ptr<MessageBundle> messages(CreateManifestBundle());
EXPECT_TRUE(
extension_l10n_util::LocalizeManifest(*messages, &manifest, &error));
diff --git a/chromium/extensions/common/extension_message_generator.cc b/chromium/extensions/common/extension_message_generator.cc
index b066c4f6cb8..0ed6784781b 100644
--- a/chromium/extensions/common/extension_message_generator.cc
+++ b/chromium/extensions/common/extension_message_generator.cc
@@ -14,6 +14,12 @@
#include "ipc/struct_destructor_macros.h"
#include "extensions/common/extension_message_generator.h"
+// Generate param traits size methods.
+#include "ipc/param_traits_size_macros.h"
+namespace IPC {
+#include "extensions/common/extension_message_generator.h"
+}
+
// Generate param traits write methods.
#include "ipc/param_traits_write_macros.h"
namespace IPC {
diff --git a/chromium/extensions/common/extension_messages.cc b/chromium/extensions/common/extension_messages.cc
index c648b28a8db..243e4b95024 100644
--- a/chromium/extensions/common/extension_messages.cc
+++ b/chromium/extensions/common/extension_messages.cc
@@ -6,6 +6,9 @@
#include <stddef.h>
+#include <memory>
+
+#include "base/memory/ptr_util.h"
#include "content/public/common/common_param_traits.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest.h"
@@ -41,10 +44,10 @@ ExtensionMsg_PermissionSetStruct::ExtensionMsg_PermissionSetStruct(
ExtensionMsg_PermissionSetStruct::~ExtensionMsg_PermissionSetStruct() {
}
-scoped_ptr<const PermissionSet>
+std::unique_ptr<const PermissionSet>
ExtensionMsg_PermissionSetStruct::ToPermissionSet() const {
- return make_scoped_ptr(new PermissionSet(apis, manifest_permissions,
- explicit_hosts, scriptable_hosts));
+ return base::WrapUnique(new PermissionSet(apis, manifest_permissions,
+ explicit_hosts, scriptable_hosts));
}
ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params()
@@ -118,6 +121,12 @@ struct ParamTraits<Manifest::Location> {
}
};
+void ParamTraits<URLPattern>::GetSize(base::PickleSizer* s,
+ const param_type& p) {
+ GetParamSize(s, p.valid_schemes());
+ GetParamSize(s, p.GetAsString());
+}
+
void ParamTraits<URLPattern>::Write(base::Pickle* m, const param_type& p) {
WriteParam(m, p.valid_schemes());
WriteParam(m, p.GetAsString());
@@ -147,6 +156,11 @@ void ParamTraits<URLPattern>::Log(const param_type& p, std::string* l) {
LogParam(p.GetAsString(), l);
}
+void ParamTraits<URLPatternSet>::GetSize(base::PickleSizer* s,
+ const param_type& p) {
+ GetParamSize(s, p.patterns());
+}
+
void ParamTraits<URLPatternSet>::Write(base::Pickle* m, const param_type& p) {
WriteParam(m, p.patterns());
}
@@ -168,6 +182,11 @@ void ParamTraits<URLPatternSet>::Log(const param_type& p, std::string* l) {
LogParam(p.patterns(), l);
}
+void ParamTraits<APIPermission::ID>::GetSize(base::PickleSizer* s,
+ const param_type& p) {
+ GetParamSize(s, static_cast<int>(p));
+}
+
void ParamTraits<APIPermission::ID>::Write(base::Pickle* m,
const param_type& p) {
WriteParam(m, static_cast<int>(p));
@@ -189,6 +208,17 @@ void ParamTraits<APIPermission::ID>::Log(
LogParam(static_cast<int>(p), l);
}
+void ParamTraits<APIPermissionSet>::GetSize(base::PickleSizer* s,
+ const param_type& p) {
+ APIPermissionSet::const_iterator it = p.begin();
+ const APIPermissionSet::const_iterator end = p.end();
+ GetParamSize(s, static_cast<uint32_t>(p.size()));
+ for (; it != end; ++it) {
+ GetParamSize(s, it->id());
+ it->GetSize(s);
+ }
+}
+
void ParamTraits<APIPermissionSet>::Write(base::Pickle* m,
const param_type& p) {
APIPermissionSet::const_iterator it = p.begin();
@@ -214,7 +244,7 @@ bool ParamTraits<APIPermissionSet>::Read(const base::Pickle* m,
extensions::PermissionsInfo::GetInstance()->GetByID(id);
if (!permission_info)
return false;
- scoped_ptr<APIPermission> p(permission_info->CreateAPIPermission());
+ std::unique_ptr<APIPermission> p(permission_info->CreateAPIPermission());
if (!p->Read(m, iter))
return false;
r->insert(p.release());
@@ -227,6 +257,17 @@ void ParamTraits<APIPermissionSet>::Log(
LogParam(p.map(), l);
}
+void ParamTraits<ManifestPermissionSet>::GetSize(base::PickleSizer* s,
+ const param_type& p) {
+ ManifestPermissionSet::const_iterator it = p.begin();
+ const ManifestPermissionSet::const_iterator end = p.end();
+ GetParamSize(s, static_cast<uint32_t>(p.size()));
+ for (; it != end; ++it) {
+ GetParamSize(s, it->name());
+ it->GetSize(s);
+ }
+}
+
void ParamTraits<ManifestPermissionSet>::Write(base::Pickle* m,
const param_type& p) {
ManifestPermissionSet::const_iterator it = p.begin();
@@ -248,7 +289,8 @@ bool ParamTraits<ManifestPermissionSet>::Read(const base::Pickle* m,
std::string name;
if (!ReadParam(m, iter, &name))
return false;
- scoped_ptr<ManifestPermission> p(ManifestHandler::CreatePermission(name));
+ std::unique_ptr<ManifestPermission> p(
+ ManifestHandler::CreatePermission(name));
if (!p)
return false;
if (!p->Read(m, iter))
@@ -263,6 +305,11 @@ void ParamTraits<ManifestPermissionSet>::Log(
LogParam(p.map(), l);
}
+void ParamTraits<HostID>::GetSize(base::PickleSizer* s, const param_type& p) {
+ GetParamSize(s, p.type());
+ GetParamSize(s, p.id());
+}
+
void ParamTraits<HostID>::Write(base::Pickle* m, const param_type& p) {
WriteParam(m, p.type());
WriteParam(m, p.id());
@@ -287,6 +334,14 @@ void ParamTraits<HostID>::Log(
LogParam(p.id(), l);
}
+void ParamTraits<ExtensionMsg_PermissionSetStruct>::GetSize(
+ base::PickleSizer* s, const param_type& p) {
+ GetParamSize(s, p.apis);
+ GetParamSize(s, p.manifest_permissions);
+ GetParamSize(s, p.explicit_hosts);
+ GetParamSize(s, p.scriptable_hosts);
+}
+
void ParamTraits<ExtensionMsg_PermissionSetStruct>::Write(base::Pickle* m,
const param_type& p) {
WriteParam(m, p.apis);
diff --git a/chromium/extensions/common/extension_messages.h b/chromium/extensions/common/extension_messages.h
index 904c2f98b42..91192213b43 100644
--- a/chromium/extensions/common/extension_messages.h
+++ b/chromium/extensions/common/extension_messages.h
@@ -252,7 +252,7 @@ struct ExtensionMsg_PermissionSetStruct {
const ExtensionMsg_PermissionSetStruct& other);
~ExtensionMsg_PermissionSetStruct();
- scoped_ptr<const extensions::PermissionSet> ToPermissionSet() const;
+ std::unique_ptr<const extensions::PermissionSet> ToPermissionSet() const;
extensions::APIPermissionSet apis;
extensions::ManifestPermissionSet manifest_permissions;
@@ -306,6 +306,7 @@ namespace IPC {
template <>
struct ParamTraits<URLPattern> {
typedef URLPattern param_type;
+ static void GetSize(base::PickleSizer* s, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
@@ -316,6 +317,7 @@ struct ParamTraits<URLPattern> {
template <>
struct ParamTraits<extensions::URLPatternSet> {
typedef extensions::URLPatternSet param_type;
+ static void GetSize(base::PickleSizer* s, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
@@ -326,6 +328,7 @@ struct ParamTraits<extensions::URLPatternSet> {
template <>
struct ParamTraits<extensions::APIPermission::ID> {
typedef extensions::APIPermission::ID param_type;
+ static void GetSize(base::PickleSizer* s, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
@@ -336,6 +339,7 @@ struct ParamTraits<extensions::APIPermission::ID> {
template <>
struct ParamTraits<extensions::APIPermissionSet> {
typedef extensions::APIPermissionSet param_type;
+ static void GetSize(base::PickleSizer* s, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
@@ -346,6 +350,7 @@ struct ParamTraits<extensions::APIPermissionSet> {
template <>
struct ParamTraits<extensions::ManifestPermissionSet> {
typedef extensions::ManifestPermissionSet param_type;
+ static void GetSize(base::PickleSizer* s, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
@@ -356,6 +361,7 @@ struct ParamTraits<extensions::ManifestPermissionSet> {
template <>
struct ParamTraits<HostID> {
typedef HostID param_type;
+ static void GetSize(base::PickleSizer* s, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
@@ -366,6 +372,7 @@ struct ParamTraits<HostID> {
template <>
struct ParamTraits<ExtensionMsg_PermissionSetStruct> {
typedef ExtensionMsg_PermissionSetStruct param_type;
+ static void GetSize(base::PickleSizer* s, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
@@ -661,9 +668,8 @@ IPC_SYNC_MESSAGE_CONTROL4_1(ExtensionHostMsg_OpenChannelToExtension,
bool /* include_tls_channel_id */,
int /* port_id */)
-IPC_SYNC_MESSAGE_CONTROL3_1(ExtensionHostMsg_OpenChannelToNativeApp,
+IPC_SYNC_MESSAGE_CONTROL2_1(ExtensionHostMsg_OpenChannelToNativeApp,
int /* frame_routing_id */,
- std::string /* source_extension_id */,
std::string /* native_app_name */,
int /* port_id */)
diff --git a/chromium/extensions/common/extension_set_unittest.cc b/chromium/extensions/common/extension_set_unittest.cc
index 8674cc7b550..967fadbe23e 100644
--- a/chromium/extensions/common/extension_set_unittest.cc
+++ b/chromium/extensions/common/extension_set_unittest.cc
@@ -2,14 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "extensions/common/extension_set.h"
+
+#include <memory>
+
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "build/build_config.h"
#include "extensions/common/extension.h"
-#include "extensions/common/extension_set.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace extensions {
@@ -131,7 +133,7 @@ TEST(ExtensionSetTest, ExtensionSet) {
CreateTestExtension("e", std::string(), std::string()));
ASSERT_TRUE(ext5.get() && ext6.get());
- scoped_ptr<ExtensionSet> to_add(new ExtensionSet());
+ std::unique_ptr<ExtensionSet> to_add(new ExtensionSet());
// |ext3| is already in |extensions|, should not affect size.
EXPECT_TRUE(to_add->Insert(ext3));
EXPECT_TRUE(to_add->Insert(ext5));
diff --git a/chromium/extensions/common/extensions_client.h b/chromium/extensions/common/extensions_client.h
index 03876dc80ae..7b0e9d3cff2 100644
--- a/chromium/extensions/common/extensions_client.h
+++ b/chromium/extensions/common/extensions_client.h
@@ -5,11 +5,11 @@
#ifndef EXTENSIONS_COMMON_EXTENSIONS_CLIENT_H_
#define EXTENSIONS_COMMON_EXTENSIONS_CLIENT_H_
+#include <memory>
#include <set>
#include <string>
#include <vector>
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_piece.h"
#include "extensions/common/permissions/api_permission_set.h"
@@ -54,15 +54,15 @@ class ExtensionsClient {
virtual const std::string GetProductName() = 0;
// Create a FeatureProvider for a specific feature type, e.g. "permission".
- virtual scoped_ptr<FeatureProvider> CreateFeatureProvider(
+ virtual std::unique_ptr<FeatureProvider> CreateFeatureProvider(
const std::string& name) const = 0;
// Create a JSONFeatureProviderSource for a specific feature type,
// e.g. "permission". Currently, all features are loaded from
// JSONFeatureProviderSources.
// This is used primarily in CreateFeatureProvider, above.
- virtual scoped_ptr<JSONFeatureProviderSource> CreateFeatureProviderSource(
- const std::string& name) const = 0;
+ virtual std::unique_ptr<JSONFeatureProviderSource>
+ CreateFeatureProviderSource(const std::string& name) const = 0;
// Takes the list of all hosts and filters out those with special
// permission strings. Adds the regular hosts to |new_hosts|,
diff --git a/chromium/extensions/common/feature_switch.cc b/chromium/extensions/common/feature_switch.cc
index 36fb385709f..f2bbd7d4769 100644
--- a/chromium/extensions/common/feature_switch.cc
+++ b/chromium/extensions/common/feature_switch.cc
@@ -20,16 +20,8 @@ namespace {
const char kMediaRouterFlag[] = "media-router";
const char kEnableMediaRouterExperiment[] = "EnableMediaRouter";
-const char kEnableMediaRouterWithCastExtensionExperiment[] =
- "EnableMediaRouterWithCastExtension";
const char kExtensionActionRedesignExperiment[] = "ExtensionActionRedesign";
-const char* kMediaRouterRequiredExperiments[] = {
- kEnableMediaRouterExperiment, kExtensionActionRedesignExperiment};
-const char* kMediaRouterWithCastExtensionRequiredExperiments[] = {
- kEnableMediaRouterWithCastExtensionExperiment,
- kExtensionActionRedesignExperiment};
-
class CommonSwitches {
public:
CommonSwitches()
@@ -62,19 +54,8 @@ class CommonSwitches {
trace_app_source(switches::kTraceAppSource,
FeatureSwitch::DEFAULT_ENABLED),
media_router(kMediaRouterFlag,
- std::vector<std::string>(
- kMediaRouterRequiredExperiments,
- kMediaRouterRequiredExperiments +
- arraysize(kMediaRouterRequiredExperiments)),
- FeatureSwitch::DEFAULT_DISABLED),
- media_router_with_cast_extension(
- kMediaRouterFlag,
- std::vector<std::string>(
- kMediaRouterWithCastExtensionRequiredExperiments,
- kMediaRouterWithCastExtensionRequiredExperiments +
- arraysize(
- kMediaRouterWithCastExtensionRequiredExperiments)),
- FeatureSwitch::DEFAULT_DISABLED) {
+ kEnableMediaRouterExperiment,
+ FeatureSwitch::DEFAULT_DISABLED) {
}
// Enables extensions to be easily installed from sites other than the web
@@ -95,7 +76,6 @@ class CommonSwitches {
FeatureSwitch embedded_extension_options;
FeatureSwitch trace_app_source;
FeatureSwitch media_router;
- FeatureSwitch media_router_with_cast_extension;
};
base::LazyInstance<CommonSwitches> g_common_switches =
@@ -143,9 +123,6 @@ FeatureSwitch* FeatureSwitch::trace_app_source() {
FeatureSwitch* FeatureSwitch::media_router() {
return &g_common_switches.Get().media_router;
}
-FeatureSwitch* FeatureSwitch::media_router_with_cast_extension() {
- return &g_common_switches.Get().media_router_with_cast_extension;
-}
FeatureSwitch::ScopedOverride::ScopedOverride(FeatureSwitch* feature,
bool override_value)
@@ -170,39 +147,24 @@ FeatureSwitch::FeatureSwitch(const char* switch_name,
DefaultValue default_value)
: FeatureSwitch(base::CommandLine::ForCurrentProcess(),
switch_name,
- std::vector<std::string>(1, field_trial_name),
- default_value) {}
-
-FeatureSwitch::FeatureSwitch(
- const char* switch_name,
- const std::vector<std::string>& required_field_trials,
- DefaultValue default_value)
- : FeatureSwitch(base::CommandLine::ForCurrentProcess(),
- switch_name,
- required_field_trials,
+ field_trial_name,
default_value) {}
FeatureSwitch::FeatureSwitch(const base::CommandLine* command_line,
const char* switch_name,
DefaultValue default_value)
- : FeatureSwitch(command_line,
- switch_name,
- std::vector<std::string>(),
- default_value) {}
+ : FeatureSwitch(command_line, switch_name, nullptr, default_value) {}
-FeatureSwitch::FeatureSwitch(
- const base::CommandLine* command_line,
- const char* switch_name,
- const std::vector<std::string>& required_field_trials,
- DefaultValue default_value)
+FeatureSwitch::FeatureSwitch(const base::CommandLine* command_line,
+ const char* switch_name,
+ const char* field_trial_name,
+ DefaultValue default_value)
: command_line_(command_line),
switch_name_(switch_name),
- required_field_trials_(required_field_trials),
+ field_trial_name_(field_trial_name),
default_value_(default_value == DEFAULT_ENABLED),
override_value_(OVERRIDE_NONE) {}
-FeatureSwitch::~FeatureSwitch(){};
-
bool FeatureSwitch::IsEnabled() const {
if (override_value_ != OVERRIDE_NONE)
return override_value_ == OVERRIDE_ENABLED;
@@ -229,26 +191,13 @@ bool FeatureSwitch::IsEnabled() const {
if (default_value_ && command_line_->HasSwitch(GetLegacyDisableFlag()))
return false;
- if (!required_field_trials_.empty()) {
- bool enabled_by_field_trial = true;
- bool disabled_by_field_trial = false;
- for (const std::string& field_trial_name : required_field_trials_) {
- std::string group_name =
- base::FieldTrialList::FindFullName(field_trial_name);
- if (!base::StartsWith(group_name, "Enabled",
- base::CompareCase::SENSITIVE)) {
- enabled_by_field_trial = false;
- if (base::StartsWith(group_name, "Disabled",
- base::CompareCase::SENSITIVE)) {
- disabled_by_field_trial = true;
- break;
- }
- }
- }
- if (disabled_by_field_trial)
- return false;
- if (enabled_by_field_trial)
+ if (field_trial_name_) {
+ std::string group_name =
+ base::FieldTrialList::FindFullName(field_trial_name_);
+ if (base::StartsWith(group_name, "Enabled", base::CompareCase::SENSITIVE))
return true;
+ if (base::StartsWith(group_name, "Disabled", base::CompareCase::SENSITIVE))
+ return false;
}
return default_value_;
diff --git a/chromium/extensions/common/feature_switch.h b/chromium/extensions/common/feature_switch.h
index b39cc8c3cf0..c170f9c2fb8 100644
--- a/chromium/extensions/common/feature_switch.h
+++ b/chromium/extensions/common/feature_switch.h
@@ -6,7 +6,6 @@
#define EXTENSIONS_COMMON_FEATURE_SWITCH_H_
#include <string>
-#include <vector>
#include "base/macros.h"
@@ -27,10 +26,8 @@ namespace extensions {
// the finch config).
// 3. If there is a switch name, and the switch is present in the command line,
// the command line value will be used.
-// 4. If there are field trials associated with the feature, and the machine
-// is in the "Enabled" group for all field trials, then the feature is
-// enabled. If the machine is in the "Disabled" group for any field trials,
-// the feature is disabled.
+// 4. If there is a finch experiment associated and applicable to the machine,
+// the finch value will be used.
// 5. Otherwise, the default value is used.
class FeatureSwitch {
public:
@@ -75,17 +72,13 @@ class FeatureSwitch {
FeatureSwitch(const char* switch_name,
const char* field_trial_name,
DefaultValue default_value);
- FeatureSwitch(const char* switch_name,
- const std::vector<std::string>& required_field_trials,
- DefaultValue default_value);
FeatureSwitch(const base::CommandLine* command_line,
const char* switch_name,
DefaultValue default_value);
FeatureSwitch(const base::CommandLine* command_line,
const char* switch_name,
- const std::vector<std::string>& required_field_trials,
+ const char* field_trial_name,
DefaultValue default_value);
- ~FeatureSwitch();
// Consider using ScopedOverride instead.
void SetOverrideValue(OverrideValue value);
@@ -99,7 +92,7 @@ class FeatureSwitch {
const base::CommandLine* command_line_;
const char* switch_name_;
- std::vector<std::string> required_field_trials_;
+ const char* field_trial_name_;
bool default_value_;
OverrideValue override_value_;
diff --git a/chromium/extensions/common/features/base_feature_provider.cc b/chromium/extensions/common/features/base_feature_provider.cc
index 069de389158..4810e9e42b0 100644
--- a/chromium/extensions/common/features/base_feature_provider.cc
+++ b/chromium/extensions/common/features/base_feature_provider.cc
@@ -53,7 +53,7 @@ BaseFeatureProvider::BaseFeatureProvider(const base::DictionaryValue& root,
}
if (iter.value().GetType() == base::Value::TYPE_DICTIONARY) {
- scoped_ptr<SimpleFeature> feature((*factory_)());
+ std::unique_ptr<SimpleFeature> feature((*factory_)());
std::vector<std::string> split = base::SplitString(
iter.key(), ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
@@ -114,7 +114,7 @@ BaseFeatureProvider::BaseFeatureProvider(const base::DictionaryValue& root,
static_cast<const base::ListValue*>(&iter.value());
CHECK_GT(list->GetSize(), 0UL);
- scoped_ptr<ComplexFeature::FeatureList> features(
+ std::unique_ptr<ComplexFeature::FeatureList> features(
new ComplexFeature::FeatureList());
// Parse and add all SimpleFeatures from the list.
@@ -125,7 +125,7 @@ BaseFeatureProvider::BaseFeatureProvider(const base::DictionaryValue& root,
continue;
}
- scoped_ptr<SimpleFeature> feature((*factory_)());
+ std::unique_ptr<SimpleFeature> feature((*factory_)());
if (!ParseFeature(static_cast<const base::DictionaryValue*>(*list_iter),
iter.key(),
feature.get()))
@@ -134,7 +134,7 @@ BaseFeatureProvider::BaseFeatureProvider(const base::DictionaryValue& root,
features->push_back(std::move(feature));
}
- scoped_ptr<ComplexFeature> feature(
+ std::unique_ptr<ComplexFeature> feature(
new ComplexFeature(std::move(features)));
feature->set_name(iter.key());
diff --git a/chromium/extensions/common/features/base_feature_provider.h b/chromium/extensions/common/features/base_feature_provider.h
index 0d6129234c1..503371e0586 100644
--- a/chromium/extensions/common/features/base_feature_provider.h
+++ b/chromium/extensions/common/features/base_feature_provider.h
@@ -6,10 +6,10 @@
#define EXTENSIONS_COMMON_FEATURES_BASE_FEATURE_PROVIDER_H_
#include <map>
+#include <memory>
#include <string>
#include <vector>
-#include "base/memory/scoped_ptr.h"
#include "extensions/common/features/feature_provider.h"
#include "extensions/common/features/simple_feature.h"
@@ -38,7 +38,7 @@ class BaseFeatureProvider : public FeatureProvider {
const FeatureMap& GetAllFeatures() const override;
private:
- std::map<std::string, scoped_ptr<Feature>> features_;
+ std::map<std::string, std::unique_ptr<Feature>> features_;
// Populated on first use.
mutable std::vector<std::string> feature_names_;
diff --git a/chromium/extensions/common/features/behavior_feature.cc b/chromium/extensions/common/features/behavior_feature.cc
index b43dc2e85e1..69c2e3653f5 100644
--- a/chromium/extensions/common/features/behavior_feature.cc
+++ b/chromium/extensions/common/features/behavior_feature.cc
@@ -6,8 +6,6 @@
namespace extensions {
-const char BehaviorFeature::kServiceWorker[] = "service_worker";
-
const char BehaviorFeature::kWhitelistedForIncognito[] =
"whitelisted_for_incognito";
diff --git a/chromium/extensions/common/features/behavior_feature.h b/chromium/extensions/common/features/behavior_feature.h
index 7e9a5f19bb9..c8e0b90c529 100644
--- a/chromium/extensions/common/features/behavior_feature.h
+++ b/chromium/extensions/common/features/behavior_feature.h
@@ -19,7 +19,6 @@ namespace extensions {
class BehaviorFeature : public SimpleFeature {
public:
// Constants corresponding to keys in _behavior_features.json.
- static const char kServiceWorker[];
static const char kWhitelistedForIncognito[];
static const char kDoNotSync[];
static const char kZoomWithoutBubble[];
diff --git a/chromium/extensions/common/features/complex_feature.cc b/chromium/extensions/common/features/complex_feature.cc
index 674b4eea741..9a330c1ff64 100644
--- a/chromium/extensions/common/features/complex_feature.cc
+++ b/chromium/extensions/common/features/complex_feature.cc
@@ -6,7 +6,7 @@
namespace extensions {
-ComplexFeature::ComplexFeature(scoped_ptr<FeatureList> features) {
+ComplexFeature::ComplexFeature(std::unique_ptr<FeatureList> features) {
DCHECK_GT(features->size(), 0UL);
features_.swap(*features);
no_parent_ = features_[0]->no_parent();
diff --git a/chromium/extensions/common/features/complex_feature.h b/chromium/extensions/common/features/complex_feature.h
index a1a0f67a698..901983889ea 100644
--- a/chromium/extensions/common/features/complex_feature.h
+++ b/chromium/extensions/common/features/complex_feature.h
@@ -5,12 +5,12 @@
#ifndef EXTENSIONS_COMMON_FEATURES_COMPLEX_FEATURE_H_
#define EXTENSIONS_COMMON_FEATURES_COMPLEX_FEATURE_H_
+#include <memory>
#include <set>
#include <string>
#include <vector>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/common/extension.h"
#include "extensions/common/features/feature.h"
#include "extensions/common/manifest.h"
@@ -22,9 +22,9 @@ namespace extensions {
// available, but not if only some combination of Features is available.
class ComplexFeature : public Feature {
public:
- using FeatureList = std::vector<scoped_ptr<Feature>>;
+ using FeatureList = std::vector<std::unique_ptr<Feature>>;
- explicit ComplexFeature(scoped_ptr<FeatureList> features);
+ explicit ComplexFeature(std::unique_ptr<FeatureList> features);
~ComplexFeature() override;
// extensions::Feature:
diff --git a/chromium/extensions/common/features/complex_feature_unittest.cc b/chromium/extensions/common/features/complex_feature_unittest.cc
index f60c90026a9..bff752dd854 100644
--- a/chromium/extensions/common/features/complex_feature_unittest.cc
+++ b/chromium/extensions/common/features/complex_feature_unittest.cc
@@ -17,12 +17,12 @@ namespace extensions {
TEST(ComplexFeatureTest, MultipleRulesWhitelist) {
const std::string kIdFoo("fooabbbbccccddddeeeeffffgggghhhh");
const std::string kIdBar("barabbbbccccddddeeeeffffgggghhhh");
- scoped_ptr<ComplexFeature::FeatureList> features(
+ std::unique_ptr<ComplexFeature::FeatureList> features(
new ComplexFeature::FeatureList());
// Rule: "extension", whitelist "foo".
- scoped_ptr<SimpleFeature> simple_feature(new SimpleFeature);
- scoped_ptr<base::DictionaryValue> rule(
+ std::unique_ptr<SimpleFeature> simple_feature(new SimpleFeature);
+ std::unique_ptr<base::DictionaryValue> rule(
DictionaryBuilder()
.Set("whitelist", ListBuilder().Append(kIdFoo).Build())
.Set("extension_types", ListBuilder().Append("extension").Build())
@@ -40,7 +40,8 @@ TEST(ComplexFeatureTest, MultipleRulesWhitelist) {
simple_feature->Parse(rule.get());
features->push_back(std::move(simple_feature));
- scoped_ptr<ComplexFeature> feature(new ComplexFeature(std::move(features)));
+ std::unique_ptr<ComplexFeature> feature(
+ new ComplexFeature(std::move(features)));
// Test match 1st rule.
EXPECT_EQ(
@@ -79,12 +80,12 @@ TEST(ComplexFeatureTest, MultipleRulesWhitelist) {
// Tests that dependencies are correctly checked.
TEST(ComplexFeatureTest, Dependencies) {
- scoped_ptr<ComplexFeature::FeatureList> features(
+ std::unique_ptr<ComplexFeature::FeatureList> features(
new ComplexFeature::FeatureList());
// Rule which depends on an extension-only feature (content_security_policy).
- scoped_ptr<SimpleFeature> simple_feature(new SimpleFeature);
- scoped_ptr<base::DictionaryValue> rule =
+ std::unique_ptr<SimpleFeature> simple_feature(new SimpleFeature);
+ std::unique_ptr<base::DictionaryValue> rule =
DictionaryBuilder()
.Set("dependencies",
ListBuilder().Append("manifest:content_security_policy").Build())
@@ -101,7 +102,8 @@ TEST(ComplexFeatureTest, Dependencies) {
simple_feature->Parse(rule.get());
features->push_back(std::move(simple_feature));
- scoped_ptr<ComplexFeature> feature(new ComplexFeature(std::move(features)));
+ std::unique_ptr<ComplexFeature> feature(
+ new ComplexFeature(std::move(features)));
// Available to extensions because of the content_security_policy rule.
EXPECT_EQ(
diff --git a/chromium/extensions/common/features/feature_provider.cc b/chromium/extensions/common/features/feature_provider.cc
index e420094ae77..6b179dd2c92 100644
--- a/chromium/extensions/common/features/feature_provider.cc
+++ b/chromium/extensions/common/features/feature_provider.cc
@@ -5,14 +5,15 @@
#include "extensions/common/features/feature_provider.h"
#include <map>
+#include <memory>
#include "base/command_line.h"
#include "base/lazy_instance.h"
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/trace_event/trace_event.h"
#include "content/public/common/content_switches.h"
#include "extensions/common/extensions_client.h"
+#include "extensions/common/features/feature.h"
#include "extensions/common/features/feature_util.h"
#include "extensions/common/switches.h"
@@ -58,7 +59,7 @@ class Static {
}
}
- std::map<std::string, scoped_ptr<FeatureProvider>> feature_providers_;
+ std::map<std::string, std::unique_ptr<FeatureProvider>> feature_providers_;
};
base::LazyInstance<Static> g_static = LAZY_INSTANCE_INITIALIZER;
@@ -67,10 +68,10 @@ const Feature* GetFeatureFromProviderByName(const std::string& provider_name,
const std::string& feature_name) {
const Feature* feature =
FeatureProvider::GetByName(provider_name)->GetFeature(feature_name);
- if (!feature) {
- CRASH_WITH_MINIDUMP("Feature \"" + feature_name + "\" not found in " +
- "FeatureProvider \"" + provider_name + "\"");
- }
+ // We should always refer to existing features, but we can't CHECK here
+ // due to flaky JSONReader fails, see: crbug.com/176381, crbug.com/602936
+ DCHECK(feature) << "Feature \"" << feature_name << "\" not found in "
+ << "FeatureProvider \"" << provider_name << "\"";
return feature;
}
diff --git a/chromium/extensions/common/features/feature_provider.h b/chromium/extensions/common/features/feature_provider.h
index ae975137b50..2159bf13f36 100644
--- a/chromium/extensions/common/features/feature_provider.h
+++ b/chromium/extensions/common/features/feature_provider.h
@@ -6,16 +6,16 @@
#define EXTENSIONS_COMMON_FEATURES_FEATURE_PROVIDER_H_
#include <map>
+#include <memory>
#include <string>
#include <vector>
-#include "base/memory/scoped_ptr.h"
namespace extensions {
class Feature;
-using FeatureMap = std::map<std::string, scoped_ptr<Feature>>;
+using FeatureMap = std::map<std::string, std::unique_ptr<Feature>>;
// Implemented by classes that can vend features.
class FeatureProvider {
@@ -39,6 +39,8 @@ class FeatureProvider {
// Directly get Features from the common FeatureProvider types.
// Each is equivalent to GetByName('featuretype')->GetFeature(name).
+ // NOTE: These functions may return |nullptr| in case corresponding JSON file
+ // got corrupted.
static const Feature* GetAPIFeature(const std::string& name);
static const Feature* GetManifestFeature(const std::string& name);
static const Feature* GetPermissionFeature(const std::string& name);
diff --git a/chromium/extensions/common/features/json_feature_provider_source.cc b/chromium/extensions/common/features/json_feature_provider_source.cc
index 4d2f8343a69..94064a171fc 100644
--- a/chromium/extensions/common/features/json_feature_provider_source.cc
+++ b/chromium/extensions/common/features/json_feature_provider_source.cc
@@ -4,6 +4,7 @@
#include "extensions/common/features/json_feature_provider_source.h"
+#include <memory>
#include <utility>
#include "base/json/json_reader.h"
@@ -24,11 +25,11 @@ void JSONFeatureProviderSource::LoadJSON(int resource_id) {
ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id);
int error_code = 0;
std::string error_message;
- scoped_ptr<base::Value> value(base::JSONReader::ReadAndReturnError(
+ std::unique_ptr<base::Value> value(base::JSONReader::ReadAndReturnError(
features_file, base::JSON_PARSE_RFC, &error_code, &error_message));
DCHECK(value) << "Could not load features: " << name_ << " " << error_message;
- scoped_ptr<base::DictionaryValue> value_as_dict;
+ std::unique_ptr<base::DictionaryValue> value_as_dict;
if (value) {
CHECK(value->IsType(base::Value::TYPE_DICTIONARY)) << name_;
value_as_dict = base::DictionaryValue::From(std::move(value));
diff --git a/chromium/extensions/common/features/simple_feature.cc b/chromium/extensions/common/features/simple_feature.cc
index 68c8dfa175f..7caf62425bb 100644
--- a/chromium/extensions/common/features/simple_feature.cc
+++ b/chromium/extensions/common/features/simple_feature.cc
@@ -293,7 +293,7 @@ bool SimpleFeature::HasDependencies() const {
return !dependencies_.empty();
}
-void SimpleFeature::AddFilter(scoped_ptr<SimpleFeatureFilter> filter) {
+void SimpleFeature::AddFilter(std::unique_ptr<SimpleFeatureFilter> filter) {
filters_.push_back(std::move(filter));
}
diff --git a/chromium/extensions/common/features/simple_feature.h b/chromium/extensions/common/features/simple_feature.h
index 4ff2c736651..cefd73067da 100644
--- a/chromium/extensions/common/features/simple_feature.h
+++ b/chromium/extensions/common/features/simple_feature.h
@@ -7,6 +7,7 @@
#include <stddef.h>
+#include <memory>
#include <set>
#include <string>
#include <vector>
@@ -15,7 +16,6 @@
#include "base/gtest_prod_util.h"
#include "base/lazy_instance.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "extensions/common/extension.h"
#include "extensions/common/features/feature.h"
@@ -52,7 +52,7 @@ class SimpleFeature : public Feature {
bool HasDependencies() const;
// Adds a filter to this feature. The feature takes ownership of the filter.
- void AddFilter(scoped_ptr<SimpleFeatureFilter> filter);
+ void AddFilter(std::unique_ptr<SimpleFeatureFilter> filter);
// Parses the JSON representation of a feature into the fields of this object.
// Unspecified values in the JSON are not modified in the object. This allows
@@ -205,7 +205,7 @@ class SimpleFeature : public Feature {
bool component_extensions_auto_granted_;
std::string command_line_switch_;
- std::vector<scoped_ptr<SimpleFeatureFilter>> filters_;
+ std::vector<std::unique_ptr<SimpleFeatureFilter>> filters_;
DISALLOW_COPY_AND_ASSIGN(SimpleFeature);
};
diff --git a/chromium/extensions/common/features/simple_feature_unittest.cc b/chromium/extensions/common/features/simple_feature_unittest.cc
index afe8d7cef5d..e74dc32fb14 100644
--- a/chromium/extensions/common/features/simple_feature_unittest.cc
+++ b/chromium/extensions/common/features/simple_feature_unittest.cc
@@ -11,6 +11,7 @@
#include "base/command_line.h"
#include "base/macros.h"
#include "base/stl_util.h"
+#include "base/test/scoped_command_line.h"
#include "base/values.h"
#include "extensions/common/manifest.h"
#include "extensions/common/value_builder.h"
@@ -29,21 +30,6 @@ struct IsAvailableTestData {
Feature::AvailabilityResult expected_result;
};
-class ScopedCommandLineSwitch {
- public:
- explicit ScopedCommandLineSwitch(const std::string& arg)
- : original_command_line_(*base::CommandLine::ForCurrentProcess()) {
- base::CommandLine::ForCurrentProcess()->AppendSwitch(arg);
- }
-
- ~ScopedCommandLineSwitch() {
- *base::CommandLine::ForCurrentProcess() = original_command_line_;
- }
-
- private:
- base::CommandLine original_command_line_;
-};
-
} // namespace
class SimpleFeatureTest : public testing::Test {
@@ -508,8 +494,8 @@ TEST_F(SimpleFeatureTest, ManifestVersion) {
}
TEST_F(SimpleFeatureTest, ParseNull) {
- scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
- scoped_ptr<SimpleFeature> feature(new SimpleFeature());
+ std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
+ std::unique_ptr<SimpleFeature> feature(new SimpleFeature());
feature->Parse(value.get());
EXPECT_TRUE(feature->whitelist()->empty());
EXPECT_TRUE(feature->extension_types()->empty());
@@ -521,12 +507,12 @@ TEST_F(SimpleFeatureTest, ParseNull) {
}
TEST_F(SimpleFeatureTest, ParseWhitelist) {
- scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
base::ListValue* whitelist = new base::ListValue();
whitelist->Append(new base::StringValue("foo"));
whitelist->Append(new base::StringValue("bar"));
value->Set("whitelist", whitelist);
- scoped_ptr<SimpleFeature> feature(new SimpleFeature());
+ std::unique_ptr<SimpleFeature> feature(new SimpleFeature());
feature->Parse(value.get());
EXPECT_EQ(2u, feature->whitelist()->size());
EXPECT_TRUE(STLCount(*(feature->whitelist()), "foo"));
@@ -534,7 +520,7 @@ TEST_F(SimpleFeatureTest, ParseWhitelist) {
}
TEST_F(SimpleFeatureTest, ParsePackageTypes) {
- scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
base::ListValue* extension_types = new base::ListValue();
extension_types->Append(new base::StringValue("extension"));
extension_types->Append(new base::StringValue("theme"));
@@ -543,7 +529,7 @@ TEST_F(SimpleFeatureTest, ParsePackageTypes) {
extension_types->Append(new base::StringValue("platform_app"));
extension_types->Append(new base::StringValue("shared_module"));
value->Set("extension_types", extension_types);
- scoped_ptr<SimpleFeature> feature(new SimpleFeature());
+ std::unique_ptr<SimpleFeature> feature(new SimpleFeature());
feature->Parse(value.get());
EXPECT_EQ(6u, feature->extension_types()->size());
EXPECT_TRUE(
@@ -561,13 +547,13 @@ TEST_F(SimpleFeatureTest, ParsePackageTypes) {
STLCount(*(feature->extension_types()), Manifest::TYPE_SHARED_MODULE));
value->SetString("extension_types", "all");
- scoped_ptr<SimpleFeature> feature2(new SimpleFeature());
+ std::unique_ptr<SimpleFeature> feature2(new SimpleFeature());
feature2->Parse(value.get());
EXPECT_EQ(*(feature->extension_types()), *(feature2->extension_types()));
}
TEST_F(SimpleFeatureTest, ParseContexts) {
- scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
base::ListValue* contexts = new base::ListValue();
contexts->Append(new base::StringValue("blessed_extension"));
contexts->Append(new base::StringValue("unblessed_extension"));
@@ -576,7 +562,7 @@ TEST_F(SimpleFeatureTest, ParseContexts) {
contexts->Append(new base::StringValue("blessed_web_page"));
contexts->Append(new base::StringValue("webui"));
value->Set("contexts", contexts);
- scoped_ptr<SimpleFeature> feature(new SimpleFeature());
+ std::unique_ptr<SimpleFeature> feature(new SimpleFeature());
feature->Parse(value.get());
EXPECT_EQ(6u, feature->contexts()->size());
EXPECT_TRUE(
@@ -591,22 +577,22 @@ TEST_F(SimpleFeatureTest, ParseContexts) {
STLCount(*(feature->contexts()), Feature::BLESSED_WEB_PAGE_CONTEXT));
value->SetString("contexts", "all");
- scoped_ptr<SimpleFeature> feature2(new SimpleFeature());
+ std::unique_ptr<SimpleFeature> feature2(new SimpleFeature());
feature2->Parse(value.get());
EXPECT_EQ(*(feature->contexts()), *(feature2->contexts()));
}
TEST_F(SimpleFeatureTest, ParseLocation) {
- scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
value->SetString("location", "component");
- scoped_ptr<SimpleFeature> feature(new SimpleFeature());
+ std::unique_ptr<SimpleFeature> feature(new SimpleFeature());
feature->Parse(value.get());
EXPECT_EQ(SimpleFeature::COMPONENT_LOCATION, feature->location());
}
TEST_F(SimpleFeatureTest, ParsePlatforms) {
- scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
- scoped_ptr<SimpleFeature> feature(new SimpleFeature());
+ std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
+ std::unique_ptr<SimpleFeature> feature(new SimpleFeature());
base::ListValue* platforms = new base::ListValue();
value->Set("platforms", platforms);
feature->Parse(value.get());
@@ -636,10 +622,10 @@ TEST_F(SimpleFeatureTest, ParsePlatforms) {
}
TEST_F(SimpleFeatureTest, ParseManifestVersion) {
- scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
value->SetInteger("min_manifest_version", 1);
value->SetInteger("max_manifest_version", 5);
- scoped_ptr<SimpleFeature> feature(new SimpleFeature());
+ std::unique_ptr<SimpleFeature> feature(new SimpleFeature());
feature->Parse(value.get());
EXPECT_EQ(1, feature->min_manifest_version());
EXPECT_EQ(5, feature->max_manifest_version());
@@ -704,27 +690,34 @@ TEST_F(SimpleFeatureTest, CommandLineSwitch) {
feature.IsAvailableToEnvironment().result());
}
{
- ScopedCommandLineSwitch scoped_switch("laser-beams");
+ base::test::ScopedCommandLine scoped_command_line;
+ scoped_command_line.GetProcessCommandLine()->AppendSwitch("laser-beams");
EXPECT_EQ(Feature::MISSING_COMMAND_LINE_SWITCH,
feature.IsAvailableToEnvironment().result());
}
{
- ScopedCommandLineSwitch scoped_switch("enable-laser-beams");
+ base::test::ScopedCommandLine scoped_command_line;
+ scoped_command_line.GetProcessCommandLine()->AppendSwitch(
+ "enable-laser-beams");
EXPECT_EQ(Feature::IS_AVAILABLE,
feature.IsAvailableToEnvironment().result());
}
{
- ScopedCommandLineSwitch scoped_switch("disable-laser-beams");
+ base::test::ScopedCommandLine scoped_command_line;
+ scoped_command_line.GetProcessCommandLine()->AppendSwitch(
+ "disable-laser-beams");
EXPECT_EQ(Feature::MISSING_COMMAND_LINE_SWITCH,
feature.IsAvailableToEnvironment().result());
}
{
- ScopedCommandLineSwitch scoped_switch("laser-beams=1");
+ base::test::ScopedCommandLine scoped_command_line;
+ scoped_command_line.GetProcessCommandLine()->AppendSwitch("laser-beams=1");
EXPECT_EQ(Feature::IS_AVAILABLE,
feature.IsAvailableToEnvironment().result());
}
{
- ScopedCommandLineSwitch scoped_switch("laser-beams=0");
+ base::test::ScopedCommandLine scoped_command_line;
+ scoped_command_line.GetProcessCommandLine()->AppendSwitch("laser-beams=0");
EXPECT_EQ(Feature::MISSING_COMMAND_LINE_SWITCH,
feature.IsAvailableToEnvironment().result());
}
diff --git a/chromium/extensions/common/file_util.cc b/chromium/extensions/common/file_util.cc
index 830cc480cf1..4c9e8d3a82e 100644
--- a/chromium/extensions/common/file_util.cc
+++ b/chromium/extensions/common/file_util.cc
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <map>
+#include <memory>
#include <set>
#include <string>
#include <utility>
@@ -20,7 +21,6 @@
#include "base/json/json_file_value_serializer.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
#include "base/strings/stringprintf.h"
@@ -207,7 +207,7 @@ scoped_refptr<Extension> LoadExtension(const base::FilePath& extension_path,
Manifest::Location location,
int flags,
std::string* error) {
- scoped_ptr<base::DictionaryValue> manifest =
+ std::unique_ptr<base::DictionaryValue> manifest =
LoadManifest(extension_path, error);
if (!manifest.get())
return NULL;
@@ -229,13 +229,13 @@ scoped_refptr<Extension> LoadExtension(const base::FilePath& extension_path,
return extension;
}
-scoped_ptr<base::DictionaryValue> LoadManifest(
+std::unique_ptr<base::DictionaryValue> LoadManifest(
const base::FilePath& extension_path,
std::string* error) {
return LoadManifest(extension_path, kManifestFilename, error);
}
-scoped_ptr<base::DictionaryValue> LoadManifest(
+std::unique_ptr<base::DictionaryValue> LoadManifest(
const base::FilePath& extension_path,
const base::FilePath::CharType* manifest_filename,
std::string* error) {
@@ -246,7 +246,7 @@ scoped_ptr<base::DictionaryValue> LoadManifest(
}
JSONFileValueDeserializer deserializer(manifest_path);
- scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, error));
+ std::unique_ptr<base::Value> root(deserializer.Deserialize(NULL, error));
if (!root.get()) {
if (error->empty()) {
// If |error| is empty, than the file could not be read.
@@ -541,7 +541,7 @@ MessageBundle::SubstitutionMap* LoadMessageBundleSubstitutionMap(
if (!default_locale.empty()) {
// Touch disk only if extension is localized.
std::string error;
- scoped_ptr<MessageBundle> bundle(
+ std::unique_ptr<MessageBundle> bundle(
LoadMessageBundle(extension_path, default_locale, &error));
if (bundle.get())
@@ -582,7 +582,7 @@ MessageBundle::SubstitutionMap* LoadMessageBundleSubstitutionMapWithImports(
}
std::string error;
- scoped_ptr<MessageBundle> bundle(
+ std::unique_ptr<MessageBundle> bundle(
LoadMessageBundle(extension->path(), default_locale, &error));
if (bundle.get()) {
@@ -602,7 +602,7 @@ MessageBundle::SubstitutionMap* LoadMessageBundleSubstitutionMapWithImports(
NOTREACHED() << "Missing shared module " << it->extension_id;
continue;
}
- scoped_ptr<MessageBundle> imported_bundle(
+ std::unique_ptr<MessageBundle> imported_bundle(
LoadMessageBundle(imported_extension->path(), default_locale, &error));
if (imported_bundle.get()) {
diff --git a/chromium/extensions/common/file_util.h b/chromium/extensions/common/file_util.h
index 3fda56ad8f0..5fcf4e9a20d 100644
--- a/chromium/extensions/common/file_util.h
+++ b/chromium/extensions/common/file_util.h
@@ -62,12 +62,12 @@ scoped_refptr<Extension> LoadExtension(const base::FilePath& extension_root,
// Loads an extension manifest from the specified directory. Returns NULL
// on failure, with a description of the error in |error|.
-scoped_ptr<base::DictionaryValue> LoadManifest(
+std::unique_ptr<base::DictionaryValue> LoadManifest(
const base::FilePath& extension_root,
std::string* error);
// Convenience overload for specifying a manifest filename.
-scoped_ptr<base::DictionaryValue> LoadManifest(
+std::unique_ptr<base::DictionaryValue> LoadManifest(
const base::FilePath& extension_root,
const base::FilePath::CharType* manifest_filename,
std::string* error);
diff --git a/chromium/extensions/common/file_util_unittest.cc b/chromium/extensions/common/file_util_unittest.cc
index e63856c3069..62be7d2196c 100644
--- a/chromium/extensions/common/file_util_unittest.cc
+++ b/chromium/extensions/common/file_util_unittest.cc
@@ -49,7 +49,7 @@ scoped_refptr<Extension> LoadExtensionManifest(
int extra_flags,
std::string* error) {
JSONStringValueDeserializer deserializer(manifest_value);
- scoped_ptr<base::Value> result = deserializer.Deserialize(NULL, error);
+ std::unique_ptr<base::Value> result = deserializer.Deserialize(NULL, error);
if (!result.get())
return NULL;
CHECK_EQ(base::Value::TYPE_DICTIONARY, result->GetType());
@@ -284,7 +284,7 @@ TEST_F(FileUtilTest, BackgroundScriptsMustExist) {
base::ScopedTempDir temp;
ASSERT_TRUE(temp.CreateUniqueTempDir());
- scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
+ std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
value->SetString("name", "test");
value->SetString("version", "1");
value->SetInteger("manifest_version", 1);
diff --git a/chromium/extensions/common/manifest.cc b/chromium/extensions/common/manifest.cc
index 8bc2e28ea85..c2e608fc32a 100644
--- a/chromium/extensions/common/manifest.cc
+++ b/chromium/extensions/common/manifest.cc
@@ -109,7 +109,8 @@ Manifest::Location Manifest::GetHigherPriorityLocation(
return (loc1_rank > loc2_rank ? loc1 : loc2 );
}
-Manifest::Manifest(Location location, scoped_ptr<base::DictionaryValue> value)
+Manifest::Manifest(Location location,
+ std::unique_ptr<base::DictionaryValue> value)
: location_(location), value_(std::move(value)), type_(TYPE_UNKNOWN) {
if (value_->HasKey(keys::kTheme)) {
type_ = TYPE_THEME;
@@ -216,7 +217,7 @@ bool Manifest::GetList(
Manifest* Manifest::DeepCopy() const {
Manifest* manifest = new Manifest(
- location_, scoped_ptr<base::DictionaryValue>(value_->DeepCopy()));
+ location_, std::unique_ptr<base::DictionaryValue>(value_->DeepCopy()));
manifest->set_extension_id(extension_id_);
return manifest;
}
diff --git a/chromium/extensions/common/manifest.h b/chromium/extensions/common/manifest.h
index 4ae38d3e247..5455cc6a7ac 100644
--- a/chromium/extensions/common/manifest.h
+++ b/chromium/extensions/common/manifest.h
@@ -6,11 +6,11 @@
#define EXTENSIONS_COMMON_MANIFEST_H_
#include <map>
+#include <memory>
#include <set>
#include <string>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "base/values.h"
@@ -116,7 +116,7 @@ class Manifest {
return IsUnpackedLocation(location);
}
- Manifest(Location location, scoped_ptr<base::DictionaryValue> value);
+ Manifest(Location location, std::unique_ptr<base::DictionaryValue> value);
virtual ~Manifest();
const std::string& extension_id() const { return extension_id_; }
@@ -191,7 +191,7 @@ class Manifest {
Location location_;
// The underlying dictionary representation of the manifest.
- scoped_ptr<base::DictionaryValue> value_;
+ std::unique_ptr<base::DictionaryValue> value_;
Type type_;
diff --git a/chromium/extensions/common/manifest_constants.cc b/chromium/extensions/common/manifest_constants.cc
index 51b5570889c..1c3f94c608b 100644
--- a/chromium/extensions/common/manifest_constants.cc
+++ b/chromium/extensions/common/manifest_constants.cc
@@ -293,6 +293,7 @@ const char kChromeVersionTooLow[] =
const char kDisabledByPolicy[] =
"This extension has been disabled by your administrator.";
const char kExpectString[] = "Expect string value.";
+const char kFileNotFound[] = "File not found: *.";
const char kInvalidAboutPage[] = "Invalid value for 'about_page'.";
const char kInvalidAboutPageExpectRelativePath[] =
"Invalid value for 'about_page'. Value must be a relative path.";
diff --git a/chromium/extensions/common/manifest_constants.h b/chromium/extensions/common/manifest_constants.h
index da7562227a9..186c2d055c6 100644
--- a/chromium/extensions/common/manifest_constants.h
+++ b/chromium/extensions/common/manifest_constants.h
@@ -267,6 +267,7 @@ extern const char kChromeVersionTooLow[];
extern const char kDevToolsExperimental[];
extern const char kDisabledByPolicy[];
extern const char kExpectString[];
+extern const char kFileNotFound[];
extern const char kInvalidAboutPage[];
extern const char kInvalidAboutPageExpectRelativePath[];
extern const char kInvalidAllFrames[];
diff --git a/chromium/extensions/common/manifest_handler_helpers.h b/chromium/extensions/common/manifest_handler_helpers.h
index b0249c30c96..eaa7906bc4d 100644
--- a/chromium/extensions/common/manifest_handler_helpers.h
+++ b/chromium/extensions/common/manifest_handler_helpers.h
@@ -5,9 +5,9 @@
#ifndef EXTENSIONS_COMMON_MANIFEST_HANDLER_HELPERS_H_
#define EXTENSIONS_COMMON_MANIFEST_HANDLER_HELPERS_H_
+#include <memory>
#include <string>
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
class ExtensionIconSet;
diff --git a/chromium/extensions/common/manifest_handler_unittest.cc b/chromium/extensions/common/manifest_handler_unittest.cc
index cbccf1204b2..3452a8749a6 100644
--- a/chromium/extensions/common/manifest_handler_unittest.cc
+++ b/chromium/extensions/common/manifest_handler_unittest.cc
@@ -2,19 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "extensions/common/manifest_handler.h"
+
#include <stddef.h>
+#include <memory>
#include <string>
#include <vector>
#include "base/files/file_path.h"
-#include "base/memory/scoped_ptr.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/install_warning.h"
-#include "extensions/common/manifest_handler.h"
#include "extensions/common/value_builder.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -212,13 +213,13 @@ TEST_F(ManifestHandlerTest, FailingHandlers) {
ScopedTestingManifestHandlerRegistry registry;
// Can't use ExtensionBuilder, because this extension will fail to
// be parsed.
- scoped_ptr<base::DictionaryValue> manifest_a(
+ std::unique_ptr<base::DictionaryValue> manifest_a(
DictionaryBuilder()
- .Set("name", "no name")
- .Set("version", "0")
- .Set("manifest_version", 2)
- .Set("a", 1)
- .Build());
+ .Set("name", "no name")
+ .Set("version", "0")
+ .Set("manifest_version", 2)
+ .Set("a", 1)
+ .Build());
// Succeeds when "a" is not recognized.
std::string error;
diff --git a/chromium/extensions/common/manifest_handlers/app_isolation_info.cc b/chromium/extensions/common/manifest_handlers/app_isolation_info.cc
index 16bd3755f25..3242ca24c89 100644
--- a/chromium/extensions/common/manifest_handlers/app_isolation_info.cc
+++ b/chromium/extensions/common/manifest_handlers/app_isolation_info.cc
@@ -6,7 +6,8 @@
#include <stddef.h>
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
diff --git a/chromium/extensions/common/manifest_handlers/background_info.cc b/chromium/extensions/common/manifest_handlers/background_info.cc
index c33d22c2436..7f39b0090d5 100644
--- a/chromium/extensions/common/manifest_handlers/background_info.cc
+++ b/chromium/extensions/common/manifest_handlers/background_info.cc
@@ -6,11 +6,12 @@
#include <stddef.h>
+#include <memory>
+
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/lazy_instance.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "extensions/common/constants.h"
@@ -249,7 +250,7 @@ BackgroundManifestHandler::~BackgroundManifestHandler() {
bool BackgroundManifestHandler::Parse(Extension* extension,
base::string16* error) {
- scoped_ptr<BackgroundInfo> info(new BackgroundInfo);
+ std::unique_ptr<BackgroundInfo> info(new BackgroundInfo);
if (!info->Parse(extension, error))
return false;
diff --git a/chromium/extensions/common/manifest_handlers/content_capabilities_handler.cc b/chromium/extensions/common/manifest_handlers/content_capabilities_handler.cc
index cfae3120c74..d3040176c0d 100644
--- a/chromium/extensions/common/manifest_handlers/content_capabilities_handler.cc
+++ b/chromium/extensions/common/manifest_handlers/content_capabilities_handler.cc
@@ -4,9 +4,10 @@
#include "extensions/common/manifest_handlers/content_capabilities_handler.h"
+#include <memory>
+
#include "base/command_line.h"
#include "base/lazy_instance.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@@ -50,7 +51,7 @@ ContentCapabilitiesHandler::~ContentCapabilitiesHandler() {
bool ContentCapabilitiesHandler::Parse(Extension* extension,
base::string16* error) {
- scoped_ptr<ContentCapabilitiesInfo> info(new ContentCapabilitiesInfo);
+ std::unique_ptr<ContentCapabilitiesInfo> info(new ContentCapabilitiesInfo);
const base::Value* value = NULL;
if (!extension->manifest()->Get(keys::kContentCapabilities, &value)) {
@@ -58,8 +59,8 @@ bool ContentCapabilitiesHandler::Parse(Extension* extension,
return false;
}
- scoped_ptr<ContentCapabilities> capabilities(ContentCapabilities::FromValue(
- *value, error));
+ std::unique_ptr<ContentCapabilities> capabilities(
+ ContentCapabilities::FromValue(*value, error));
if (!capabilities)
return false;
diff --git a/chromium/extensions/common/manifest_handlers/csp_info.cc b/chromium/extensions/common/manifest_handlers/csp_info.cc
index de984301432..6fe62949cf6 100644
--- a/chromium/extensions/common/manifest_handlers/csp_info.cc
+++ b/chromium/extensions/common/manifest_handlers/csp_info.cc
@@ -4,7 +4,8 @@
#include "extensions/common/manifest_handlers/csp_info.h"
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
diff --git a/chromium/extensions/common/manifest_handlers/default_locale_handler.cc b/chromium/extensions/common/manifest_handlers/default_locale_handler.cc
index debb664ef6c..47fde82d647 100644
--- a/chromium/extensions/common/manifest_handlers/default_locale_handler.cc
+++ b/chromium/extensions/common/manifest_handlers/default_locale_handler.cc
@@ -4,9 +4,10 @@
#include "extensions/common/manifest_handlers/default_locale_handler.h"
+#include <memory>
+
#include "base/files/file_enumerator.h"
#include "base/files/file_util.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
@@ -37,7 +38,7 @@ DefaultLocaleHandler::~DefaultLocaleHandler() {
}
bool DefaultLocaleHandler::Parse(Extension* extension, base::string16* error) {
- scoped_ptr<LocaleInfo> info(new LocaleInfo);
+ std::unique_ptr<LocaleInfo> info(new LocaleInfo);
if (!extension->manifest()->GetString(keys::kDefaultLocale,
&info->default_locale) ||
!l10n_util::IsValidLocaleSyntax(info->default_locale)) {
diff --git a/chromium/extensions/common/manifest_handlers/externally_connectable.cc b/chromium/extensions/common/manifest_handlers/externally_connectable.cc
index 31f96e7222a..7dcdaffcb54 100644
--- a/chromium/extensions/common/manifest_handlers/externally_connectable.cc
+++ b/chromium/extensions/common/manifest_handlers/externally_connectable.cc
@@ -7,7 +7,9 @@
#include <stddef.h>
#include <algorithm>
+#include <memory>
+#include "base/memory/ptr_util.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "components/crx_file/id_util.h"
@@ -69,7 +71,7 @@ bool ExternallyConnectableHandler::Parse(Extension* extension,
extension, APIPermission::kExternallyConnectableAllUrls);
std::vector<InstallWarning> install_warnings;
- scoped_ptr<ExternallyConnectableInfo> info =
+ std::unique_ptr<ExternallyConnectableInfo> info =
ExternallyConnectableInfo::FromValue(
*externally_connectable, allow_all_urls, &install_warnings, error);
if (!info)
@@ -95,15 +97,15 @@ ExternallyConnectableInfo* ExternallyConnectableInfo::Get(
}
// static
-scoped_ptr<ExternallyConnectableInfo> ExternallyConnectableInfo::FromValue(
+std::unique_ptr<ExternallyConnectableInfo> ExternallyConnectableInfo::FromValue(
const base::Value& value,
bool allow_all_urls,
std::vector<InstallWarning>* install_warnings,
base::string16* error) {
- scoped_ptr<ExternallyConnectable> externally_connectable =
+ std::unique_ptr<ExternallyConnectable> externally_connectable =
ExternallyConnectable::FromValue(value, error);
if (!externally_connectable)
- return scoped_ptr<ExternallyConnectableInfo>();
+ return std::unique_ptr<ExternallyConnectableInfo>();
URLPatternSet matches;
@@ -118,7 +120,7 @@ scoped_ptr<ExternallyConnectableInfo> ExternallyConnectableInfo::FromValue(
if (pattern.Parse(*it) != URLPattern::PARSE_SUCCESS) {
*error = ErrorUtils::FormatErrorMessageUTF16(
errors::kErrorInvalidMatchPattern, *it);
- return scoped_ptr<ExternallyConnectableInfo>();
+ return std::unique_ptr<ExternallyConnectableInfo>();
}
if (allow_all_urls && pattern.match_all_urls()) {
@@ -152,7 +154,7 @@ scoped_ptr<ExternallyConnectableInfo> ExternallyConnectableInfo::FromValue(
NOTREACHED() << *it;
*error = ErrorUtils::FormatErrorMessageUTF16(
errors::kErrorInvalidMatchPattern, *it);
- return scoped_ptr<ExternallyConnectableInfo>();
+ return std::unique_ptr<ExternallyConnectableInfo>();
}
// Broad match patterns like "*.com", "*.co.uk", and even "*.appspot.com"
@@ -188,7 +190,7 @@ scoped_ptr<ExternallyConnectableInfo> ExternallyConnectableInfo::FromValue(
} else {
*error =
ErrorUtils::FormatErrorMessageUTF16(errors::kErrorInvalidId, *it);
- return scoped_ptr<ExternallyConnectableInfo>();
+ return std::unique_ptr<ExternallyConnectableInfo>();
}
}
}
@@ -201,7 +203,7 @@ scoped_ptr<ExternallyConnectableInfo> ExternallyConnectableInfo::FromValue(
bool accepts_tls_channel_id =
externally_connectable->accepts_tls_channel_id.get() &&
*externally_connectable->accepts_tls_channel_id;
- return make_scoped_ptr(new ExternallyConnectableInfo(
+ return base::WrapUnique(new ExternallyConnectableInfo(
matches, ids, all_ids, accepts_tls_channel_id));
}
diff --git a/chromium/extensions/common/manifest_handlers/externally_connectable.h b/chromium/extensions/common/manifest_handlers/externally_connectable.h
index ab3b2b5fb02..9f524a8446f 100644
--- a/chromium/extensions/common/manifest_handlers/externally_connectable.h
+++ b/chromium/extensions/common/manifest_handlers/externally_connectable.h
@@ -5,11 +5,11 @@
#ifndef EXTENSIONS_COMMON_MANIFEST_HANDLERS_EXTERNALLY_CONNECTABLE_H_
#define EXTENSIONS_COMMON_MANIFEST_HANDLERS_EXTERNALLY_CONNECTABLE_H_
+#include <memory>
#include <string>
#include <vector>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/common/extension.h"
#include "extensions/common/install_warning.h"
#include "extensions/common/manifest_handler.h"
@@ -56,7 +56,7 @@ struct ExternallyConnectableInfo : public Extension::ManifestData {
// Tries to construct the info based on |value|, as it would have appeared in
// the manifest. Sets |error| and returns an empty scoped_ptr on failure.
- static scoped_ptr<ExternallyConnectableInfo> FromValue(
+ static std::unique_ptr<ExternallyConnectableInfo> FromValue(
const base::Value& value,
bool allow_all_urls,
std::vector<InstallWarning>* install_warnings,
diff --git a/chromium/extensions/common/manifest_handlers/file_handler_info.cc b/chromium/extensions/common/manifest_handlers/file_handler_info.cc
index c95a5e46874..68ef8322fc6 100644
--- a/chromium/extensions/common/manifest_handlers/file_handler_info.cc
+++ b/chromium/extensions/common/manifest_handlers/file_handler_info.cc
@@ -6,7 +6,8 @@
#include <stddef.h>
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
@@ -134,7 +135,7 @@ bool LoadFileHandler(const std::string& handler_id,
}
bool FileHandlersParser::Parse(Extension* extension, base::string16* error) {
- scoped_ptr<FileHandlers> info(new FileHandlers);
+ std::unique_ptr<FileHandlers> info(new FileHandlers);
const base::DictionaryValue* all_handlers = NULL;
if (!extension->manifest()->GetDictionary(keys::kFileHandlers,
&all_handlers)) {
diff --git a/chromium/extensions/common/manifest_handlers/icons_handler.cc b/chromium/extensions/common/manifest_handlers/icons_handler.cc
index 20ad025b25b..dd599e6852e 100644
--- a/chromium/extensions/common/manifest_handlers/icons_handler.cc
+++ b/chromium/extensions/common/manifest_handlers/icons_handler.cc
@@ -4,9 +4,10 @@
#include "extensions/common/manifest_handlers/icons_handler.h"
+#include <memory>
+
#include "base/files/file_util.h"
#include "base/lazy_instance.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@@ -56,7 +57,7 @@ IconsHandler::~IconsHandler() {
}
bool IconsHandler::Parse(Extension* extension, base::string16* error) {
- scoped_ptr<IconsInfo> icons_info(new IconsInfo);
+ std::unique_ptr<IconsInfo> icons_info(new IconsInfo);
const base::DictionaryValue* icons_dict = NULL;
if (!extension->manifest()->GetDictionary(keys::kIcons, &icons_dict)) {
*error = base::ASCIIToUTF16(manifest_errors::kInvalidIcons);
diff --git a/chromium/extensions/common/manifest_handlers/icons_handler_unittest.cc b/chromium/extensions/common/manifest_handlers/icons_handler_unittest.cc
index fa644a940ce..7f31f2f2be2 100644
--- a/chromium/extensions/common/manifest_handlers/icons_handler_unittest.cc
+++ b/chromium/extensions/common/manifest_handlers/icons_handler_unittest.cc
@@ -14,18 +14,19 @@ class ProductIconManifestTest : public ManifestTest {
ProductIconManifestTest() {}
protected:
- scoped_ptr<base::DictionaryValue> CreateManifest(
+ std::unique_ptr<base::DictionaryValue> CreateManifest(
const std::string& extra_icons) {
- scoped_ptr<base::DictionaryValue> manifest = base::DictionaryValue::From(
- base::test::ParseJson("{ \n"
- " \"name\": \"test\", \n"
- " \"version\": \"0.1\", \n"
- " \"manifest_version\": 2, \n"
- " \"icons\": { \n" +
- extra_icons + " \"16\": \"icon1.png\", \n"
- " \"32\": \"icon2.png\" \n"
- " } \n"
- "} \n"));
+ std::unique_ptr<base::DictionaryValue> manifest =
+ base::DictionaryValue::From(
+ base::test::ParseJson("{ \n"
+ " \"name\": \"test\", \n"
+ " \"version\": \"0.1\", \n"
+ " \"manifest_version\": 2, \n"
+ " \"icons\": { \n" +
+ extra_icons + " \"16\": \"icon1.png\", \n"
+ " \"32\": \"icon2.png\" \n"
+ " } \n"
+ "} \n"));
EXPECT_TRUE(manifest);
return manifest;
}
@@ -37,28 +38,28 @@ class ProductIconManifestTest : public ManifestTest {
TEST_F(ProductIconManifestTest, Sizes) {
// Too big.
{
- scoped_ptr<base::DictionaryValue> ext_manifest =
+ std::unique_ptr<base::DictionaryValue> ext_manifest =
CreateManifest("\"100000\": \"icon3.png\", \n");
ManifestData manifest(std::move(ext_manifest), "test");
LoadAndExpectError(manifest, "Invalid key in icons: \"100000\".");
}
// Too small.
{
- scoped_ptr<base::DictionaryValue> ext_manifest =
+ std::unique_ptr<base::DictionaryValue> ext_manifest =
CreateManifest("\"0\": \"icon3.png\", \n");
ManifestData manifest(std::move(ext_manifest), "test");
LoadAndExpectError(manifest, "Invalid key in icons: \"0\".");
}
// NaN.
{
- scoped_ptr<base::DictionaryValue> ext_manifest =
+ std::unique_ptr<base::DictionaryValue> ext_manifest =
CreateManifest("\"sixteen\": \"icon3.png\", \n");
ManifestData manifest(std::move(ext_manifest), "test");
LoadAndExpectError(manifest, "Invalid key in icons: \"sixteen\".");
}
// Just right.
{
- scoped_ptr<base::DictionaryValue> ext_manifest =
+ std::unique_ptr<base::DictionaryValue> ext_manifest =
CreateManifest("\"512\": \"icon3.png\", \n");
ManifestData manifest(std::move(ext_manifest), "test");
scoped_refptr<extensions::Extension> extension =
diff --git a/chromium/extensions/common/manifest_handlers/incognito_info.cc b/chromium/extensions/common/manifest_handlers/incognito_info.cc
index b7dc8b28138..0bae1df2f01 100644
--- a/chromium/extensions/common/manifest_handlers/incognito_info.cc
+++ b/chromium/extensions/common/manifest_handlers/incognito_info.cc
@@ -4,7 +4,8 @@
#include "extensions/common/manifest_handlers/incognito_info.h"
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "extensions/common/extension.h"
diff --git a/chromium/extensions/common/manifest_handlers/kiosk_mode_info.cc b/chromium/extensions/common/manifest_handlers/kiosk_mode_info.cc
index d625bfd7d36..2dd0f9b1844 100644
--- a/chromium/extensions/common/manifest_handlers/kiosk_mode_info.cc
+++ b/chromium/extensions/common/manifest_handlers/kiosk_mode_info.cc
@@ -4,7 +4,8 @@
#include "extensions/common/manifest_handlers/kiosk_mode_info.h"
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -114,7 +115,7 @@ bool KioskModeHandler::Parse(Extension* extension, base::string16* error) {
}
for (const base::Value* value : *list) {
- scoped_ptr<KioskSecondaryAppsType> app =
+ std::unique_ptr<KioskSecondaryAppsType> app =
KioskSecondaryAppsType::FromValue(*value, error);
if (!app) {
*error = base::ASCIIToUTF16(
diff --git a/chromium/extensions/common/manifest_handlers/launcher_page_info.cc b/chromium/extensions/common/manifest_handlers/launcher_page_info.cc
index 0e1afea72b7..d7821453857 100644
--- a/chromium/extensions/common/manifest_handlers/launcher_page_info.cc
+++ b/chromium/extensions/common/manifest_handlers/launcher_page_info.cc
@@ -27,7 +27,7 @@ LauncherPageInfo* LauncherPageHandler::GetInfo(const Extension* extension) {
bool LauncherPageHandler::Parse(Extension* extension, base::string16* error) {
const extensions::Manifest* manifest = extension->manifest();
- scoped_ptr<LauncherPageInfo> launcher_page_info(new LauncherPageInfo);
+ std::unique_ptr<LauncherPageInfo> launcher_page_info(new LauncherPageInfo);
const base::DictionaryValue* launcher_page_dict = NULL;
if (!manifest->GetDictionary(manifest_keys::kLauncherPage,
&launcher_page_dict)) {
diff --git a/chromium/extensions/common/manifest_handlers/mime_types_handler.cc b/chromium/extensions/common/manifest_handlers/mime_types_handler.cc
index 3c90b609500..364305a0413 100644
--- a/chromium/extensions/common/manifest_handlers/mime_types_handler.cc
+++ b/chromium/extensions/common/manifest_handlers/mime_types_handler.cc
@@ -103,7 +103,7 @@ bool MimeTypesHandlerParser::Parse(extensions::Extension* extension,
return false;
}
- scoped_ptr<MimeTypesHandlerInfo> info(new MimeTypesHandlerInfo);
+ std::unique_ptr<MimeTypesHandlerInfo> info(new MimeTypesHandlerInfo);
info->handler_.set_extension_id(extension->id());
for (size_t i = 0; i < mime_types_value->GetSize(); ++i) {
std::string filter;
diff --git a/chromium/extensions/common/manifest_handlers/nacl_modules_handler.cc b/chromium/extensions/common/manifest_handlers/nacl_modules_handler.cc
index 27df6cf4297..148caca6d4b 100644
--- a/chromium/extensions/common/manifest_handlers/nacl_modules_handler.cc
+++ b/chromium/extensions/common/manifest_handlers/nacl_modules_handler.cc
@@ -6,8 +6,9 @@
#include <stddef.h>
+#include <memory>
+
#include "base/lazy_instance.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@@ -49,7 +50,7 @@ bool NaClModulesHandler::Parse(Extension* extension, base::string16* error) {
return false;
}
- scoped_ptr<NaClModuleData> nacl_module_data(new NaClModuleData);
+ std::unique_ptr<NaClModuleData> nacl_module_data(new NaClModuleData);
for (size_t i = 0; i < list_value->GetSize(); ++i) {
const base::DictionaryValue* module_value = NULL;
diff --git a/chromium/extensions/common/manifest_handlers/oauth2_manifest_handler.cc b/chromium/extensions/common/manifest_handlers/oauth2_manifest_handler.cc
index 73a1320158b..7d381b5415a 100644
--- a/chromium/extensions/common/manifest_handlers/oauth2_manifest_handler.cc
+++ b/chromium/extensions/common/manifest_handlers/oauth2_manifest_handler.cc
@@ -6,8 +6,9 @@
#include <stddef.h>
+#include <memory>
+
#include "base/lazy_instance.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "extensions/common/error_utils.h"
@@ -48,7 +49,7 @@ OAuth2ManifestHandler::~OAuth2ManifestHandler() {
bool OAuth2ManifestHandler::Parse(Extension* extension,
base::string16* error) {
- scoped_ptr<OAuth2Info> info(new OAuth2Info);
+ std::unique_ptr<OAuth2Info> info(new OAuth2Info);
const base::DictionaryValue* dict = NULL;
if (!extension->manifest()->GetDictionary(keys::kOAuth2, &dict)) {
*error = base::ASCIIToUTF16(errors::kInvalidOAuth2ClientId);
diff --git a/chromium/extensions/common/manifest_handlers/oauth2_manifest_unittest.cc b/chromium/extensions/common/manifest_handlers/oauth2_manifest_unittest.cc
index f09c97143b1..aaafc62027a 100644
--- a/chromium/extensions/common/manifest_handlers/oauth2_manifest_unittest.cc
+++ b/chromium/extensions/common/manifest_handlers/oauth2_manifest_unittest.cc
@@ -42,19 +42,20 @@ class OAuth2ManifestTest : public ManifestTest {
CLIENT_ID_EMPTY
};
- scoped_ptr<base::DictionaryValue> CreateManifest(
+ std::unique_ptr<base::DictionaryValue> CreateManifest(
AutoApproveValue auto_approve,
bool extension_id_whitelisted,
ClientIdValue client_id) {
- scoped_ptr<base::DictionaryValue> manifest = base::DictionaryValue::From(
- base::test::ParseJson("{ \n"
- " \"name\": \"test\", \n"
- " \"version\": \"0.1\", \n"
- " \"manifest_version\": 2, \n"
- " \"oauth2\": { \n"
- " \"scopes\": [ \"scope1\" ], \n"
- " }, \n"
- "} \n"));
+ std::unique_ptr<base::DictionaryValue> manifest =
+ base::DictionaryValue::From(
+ base::test::ParseJson("{ \n"
+ " \"name\": \"test\", \n"
+ " \"version\": \"0.1\", \n"
+ " \"manifest_version\": 2, \n"
+ " \"oauth2\": { \n"
+ " \"scopes\": [ \"scope1\" ], \n"
+ " }, \n"
+ "} \n"));
EXPECT_TRUE(manifest);
switch (auto_approve) {
case AUTO_APPROVE_NOT_SET:
@@ -156,7 +157,7 @@ TEST_F(OAuth2ManifestTest, OAuth2SectionParsing) {
}
TEST_F(OAuth2ManifestTest, AutoApproveNotSetExtensionNotOnWhitelist) {
- scoped_ptr<base::DictionaryValue> ext_manifest =
+ std::unique_ptr<base::DictionaryValue> ext_manifest =
CreateManifest(AUTO_APPROVE_NOT_SET, false, CLIENT_ID_DEFAULT);
ManifestData manifest(std::move(ext_manifest), "test");
scoped_refptr<extensions::Extension> extension =
@@ -166,7 +167,7 @@ TEST_F(OAuth2ManifestTest, AutoApproveNotSetExtensionNotOnWhitelist) {
}
TEST_F(OAuth2ManifestTest, AutoApproveFalseExtensionNotOnWhitelist) {
- scoped_ptr<base::DictionaryValue> ext_manifest =
+ std::unique_ptr<base::DictionaryValue> ext_manifest =
CreateManifest(AUTO_APPROVE_FALSE, false, CLIENT_ID_DEFAULT);
ManifestData manifest(std::move(ext_manifest), "test");
scoped_refptr<extensions::Extension> extension =
@@ -179,7 +180,7 @@ TEST_F(OAuth2ManifestTest, AutoApproveFalseExtensionNotOnWhitelist) {
}
TEST_F(OAuth2ManifestTest, AutoApproveTrueExtensionNotOnWhitelist) {
- scoped_ptr<base::DictionaryValue> ext_manifest =
+ std::unique_ptr<base::DictionaryValue> ext_manifest =
CreateManifest(AUTO_APPROVE_TRUE, false, CLIENT_ID_DEFAULT);
ManifestData manifest(std::move(ext_manifest), "test");
scoped_refptr<extensions::Extension> extension =
@@ -192,7 +193,7 @@ TEST_F(OAuth2ManifestTest, AutoApproveTrueExtensionNotOnWhitelist) {
}
TEST_F(OAuth2ManifestTest, AutoApproveInvalidExtensionNotOnWhitelist) {
- scoped_ptr<base::DictionaryValue> ext_manifest =
+ std::unique_ptr<base::DictionaryValue> ext_manifest =
CreateManifest(AUTO_APPROVE_INVALID, false, CLIENT_ID_DEFAULT);
ManifestData manifest(std::move(ext_manifest), "test");
scoped_refptr<extensions::Extension> extension =
@@ -205,7 +206,7 @@ TEST_F(OAuth2ManifestTest, AutoApproveInvalidExtensionNotOnWhitelist) {
}
TEST_F(OAuth2ManifestTest, AutoApproveNotSetExtensionOnWhitelist) {
- scoped_ptr<base::DictionaryValue> ext_manifest =
+ std::unique_ptr<base::DictionaryValue> ext_manifest =
CreateManifest(AUTO_APPROVE_NOT_SET, true, CLIENT_ID_DEFAULT);
ManifestData manifest(std::move(ext_manifest), "test");
scoped_refptr<extensions::Extension> extension =
@@ -215,7 +216,7 @@ TEST_F(OAuth2ManifestTest, AutoApproveNotSetExtensionOnWhitelist) {
}
TEST_F(OAuth2ManifestTest, AutoApproveFalseExtensionOnWhitelist) {
- scoped_ptr<base::DictionaryValue> ext_manifest =
+ std::unique_ptr<base::DictionaryValue> ext_manifest =
CreateManifest(AUTO_APPROVE_FALSE, true, CLIENT_ID_DEFAULT);
ManifestData manifest(std::move(ext_manifest), "test");
scoped_refptr<extensions::Extension> extension =
@@ -225,7 +226,7 @@ TEST_F(OAuth2ManifestTest, AutoApproveFalseExtensionOnWhitelist) {
}
TEST_F(OAuth2ManifestTest, AutoApproveTrueExtensionOnWhitelist) {
- scoped_ptr<base::DictionaryValue> ext_manifest =
+ std::unique_ptr<base::DictionaryValue> ext_manifest =
CreateManifest(AUTO_APPROVE_TRUE, true, CLIENT_ID_DEFAULT);
ManifestData manifest(std::move(ext_manifest), "test");
scoped_refptr<extensions::Extension> extension =
@@ -235,7 +236,7 @@ TEST_F(OAuth2ManifestTest, AutoApproveTrueExtensionOnWhitelist) {
}
TEST_F(OAuth2ManifestTest, AutoApproveInvalidExtensionOnWhitelist) {
- scoped_ptr<base::DictionaryValue> ext_manifest =
+ std::unique_ptr<base::DictionaryValue> ext_manifest =
CreateManifest(AUTO_APPROVE_INVALID, true, CLIENT_ID_DEFAULT);
ManifestData manifest(std::move(ext_manifest), "test");
std::string error;
@@ -248,7 +249,7 @@ TEST_F(OAuth2ManifestTest, AutoApproveInvalidExtensionOnWhitelist) {
TEST_F(OAuth2ManifestTest, InvalidClientId) {
{
- scoped_ptr<base::DictionaryValue> ext_manifest =
+ std::unique_ptr<base::DictionaryValue> ext_manifest =
CreateManifest(AUTO_APPROVE_NOT_SET, false, CLIENT_ID_NOT_SET);
ManifestData manifest(std::move(ext_manifest), "test");
std::string error;
@@ -256,7 +257,7 @@ TEST_F(OAuth2ManifestTest, InvalidClientId) {
}
{
- scoped_ptr<base::DictionaryValue> ext_manifest =
+ std::unique_ptr<base::DictionaryValue> ext_manifest =
CreateManifest(AUTO_APPROVE_NOT_SET, false, CLIENT_ID_EMPTY);
ManifestData manifest(std::move(ext_manifest), "test");
std::string error;
@@ -267,7 +268,7 @@ TEST_F(OAuth2ManifestTest, InvalidClientId) {
TEST_F(OAuth2ManifestTest, ComponentInvalidClientId) {
// Component Apps without auto_approve must include a client ID.
{
- scoped_ptr<base::DictionaryValue> ext_manifest =
+ std::unique_ptr<base::DictionaryValue> ext_manifest =
CreateManifest(AUTO_APPROVE_NOT_SET, false, CLIENT_ID_NOT_SET);
ManifestData manifest(std::move(ext_manifest), "test");
std::string error;
@@ -277,7 +278,7 @@ TEST_F(OAuth2ManifestTest, ComponentInvalidClientId) {
}
{
- scoped_ptr<base::DictionaryValue> ext_manifest =
+ std::unique_ptr<base::DictionaryValue> ext_manifest =
CreateManifest(AUTO_APPROVE_NOT_SET, false, CLIENT_ID_EMPTY);
ManifestData manifest(std::move(ext_manifest), "test");
std::string error;
@@ -289,7 +290,7 @@ TEST_F(OAuth2ManifestTest, ComponentInvalidClientId) {
TEST_F(OAuth2ManifestTest, ComponentWithChromeClientId) {
{
- scoped_ptr<base::DictionaryValue> ext_manifest =
+ std::unique_ptr<base::DictionaryValue> ext_manifest =
CreateManifest(AUTO_APPROVE_TRUE, true, CLIENT_ID_NOT_SET);
ManifestData manifest(std::move(ext_manifest), "test");
scoped_refptr<extensions::Extension> extension =
@@ -298,7 +299,7 @@ TEST_F(OAuth2ManifestTest, ComponentWithChromeClientId) {
}
{
- scoped_ptr<base::DictionaryValue> ext_manifest =
+ std::unique_ptr<base::DictionaryValue> ext_manifest =
CreateManifest(AUTO_APPROVE_TRUE, true, CLIENT_ID_EMPTY);
ManifestData manifest(std::move(ext_manifest), "test");
scoped_refptr<extensions::Extension> extension =
@@ -308,7 +309,7 @@ TEST_F(OAuth2ManifestTest, ComponentWithChromeClientId) {
}
TEST_F(OAuth2ManifestTest, ComponentWithStandardClientId) {
- scoped_ptr<base::DictionaryValue> ext_manifest =
+ std::unique_ptr<base::DictionaryValue> ext_manifest =
CreateManifest(AUTO_APPROVE_TRUE, true, CLIENT_ID_DEFAULT);
ManifestData manifest(std::move(ext_manifest), "test");
scoped_refptr<extensions::Extension> extension =
diff --git a/chromium/extensions/common/manifest_handlers/offline_enabled_info.cc b/chromium/extensions/common/manifest_handlers/offline_enabled_info.cc
index 4ce6637f874..fd73099b8f5 100644
--- a/chromium/extensions/common/manifest_handlers/offline_enabled_info.cc
+++ b/chromium/extensions/common/manifest_handlers/offline_enabled_info.cc
@@ -4,7 +4,8 @@
#include "extensions/common/manifest_handlers/offline_enabled_info.h"
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
diff --git a/chromium/extensions/common/manifest_handlers/options_page_info.cc b/chromium/extensions/common/manifest_handlers/options_page_info.cc
index c46a9c1eac3..7e1d1dff05f 100644
--- a/chromium/extensions/common/manifest_handlers/options_page_info.cc
+++ b/chromium/extensions/common/manifest_handlers/options_page_info.cc
@@ -4,9 +4,11 @@
#include "extensions/common/manifest_handlers/options_page_info.h"
+#include <memory>
+
#include "base/files/file_util.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h"
#include "extensions/common/api/extensions_manifest_types.h"
#include "extensions/common/error_utils.h"
@@ -105,7 +107,7 @@ bool OptionsPageInfo::ShouldOpenInTab(const Extension* extension) {
return info && info->open_in_tab_;
}
-scoped_ptr<OptionsPageInfo> OptionsPageInfo::Create(
+std::unique_ptr<OptionsPageInfo> OptionsPageInfo::Create(
Extension* extension,
const base::Value* options_ui_value,
const std::string& options_page_string,
@@ -122,7 +124,7 @@ scoped_ptr<OptionsPageInfo> OptionsPageInfo::Create(
if (options_ui_value) {
base::string16 options_ui_error;
- scoped_ptr<OptionsUI> options_ui =
+ std::unique_ptr<OptionsUI> options_ui =
OptionsUI::FromValue(*options_ui_value, &options_ui_error);
if (!options_ui_error.empty()) {
// OptionsUI::FromValue populates |error| both when there are
@@ -159,11 +161,11 @@ scoped_ptr<OptionsPageInfo> OptionsPageInfo::Create(
keys::kOptionsPage,
error,
&options_page)) {
- return scoped_ptr<OptionsPageInfo>();
+ return std::unique_ptr<OptionsPageInfo>();
}
}
- return make_scoped_ptr(
+ return base::WrapUnique(
new OptionsPageInfo(options_page, chrome_style, open_in_tab));
}
@@ -189,12 +191,9 @@ bool OptionsPageManifestHandler::Parse(Extension* extension,
const base::Value* options_ui_value = NULL;
ignore_result(manifest->Get(keys::kOptionsUI, &options_ui_value));
- scoped_ptr<OptionsPageInfo> info =
- OptionsPageInfo::Create(extension,
- options_ui_value,
- options_page_string,
- &install_warnings,
- error);
+ std::unique_ptr<OptionsPageInfo> info =
+ OptionsPageInfo::Create(extension, options_ui_value, options_page_string,
+ &install_warnings, error);
if (!info)
return false;
diff --git a/chromium/extensions/common/manifest_handlers/options_page_info.h b/chromium/extensions/common/manifest_handlers/options_page_info.h
index fcde3e22e81..aca335bfb26 100644
--- a/chromium/extensions/common/manifest_handlers/options_page_info.h
+++ b/chromium/extensions/common/manifest_handlers/options_page_info.h
@@ -46,7 +46,7 @@ class OptionsPageInfo : public Extension::ManifestData {
// new tab instead of an embedded popup.
static bool ShouldOpenInTab(const Extension* extension);
- static scoped_ptr<OptionsPageInfo> Create(
+ static std::unique_ptr<OptionsPageInfo> Create(
Extension* extension,
const base::Value* options_ui_value,
const std::string& options_page_string,
diff --git a/chromium/extensions/common/manifest_handlers/permissions_parser.cc b/chromium/extensions/common/manifest_handlers/permissions_parser.cc
index 2afdf722fdc..14a2e19490c 100644
--- a/chromium/extensions/common/manifest_handlers/permissions_parser.cc
+++ b/chromium/extensions/common/manifest_handlers/permissions_parser.cc
@@ -34,14 +34,14 @@ namespace keys = manifest_keys;
namespace errors = manifest_errors;
struct ManifestPermissions : public Extension::ManifestData {
- ManifestPermissions(scoped_ptr<const PermissionSet> permissions);
+ ManifestPermissions(std::unique_ptr<const PermissionSet> permissions);
~ManifestPermissions() override;
- scoped_ptr<const PermissionSet> permissions;
+ std::unique_ptr<const PermissionSet> permissions;
};
ManifestPermissions::ManifestPermissions(
- scoped_ptr<const PermissionSet> permissions)
+ std::unique_ptr<const PermissionSet> permissions)
: permissions(std::move(permissions)) {}
ManifestPermissions::~ManifestPermissions() {
@@ -268,7 +268,7 @@ void PermissionsParser::Finalize(Extension* extension) {
ManifestHandler::AddExtensionInitialRequiredPermissions(
extension, &initial_required_permissions_->manifest_permissions);
- scoped_ptr<const PermissionSet> required_permissions(
+ std::unique_ptr<const PermissionSet> required_permissions(
new PermissionSet(initial_required_permissions_->api_permissions,
initial_required_permissions_->manifest_permissions,
initial_required_permissions_->host_permissions,
@@ -277,7 +277,7 @@ void PermissionsParser::Finalize(Extension* extension) {
keys::kPermissions,
new ManifestPermissions(std::move(required_permissions)));
- scoped_ptr<const PermissionSet> optional_permissions(new PermissionSet(
+ std::unique_ptr<const PermissionSet> optional_permissions(new PermissionSet(
initial_optional_permissions_->api_permissions,
initial_optional_permissions_->manifest_permissions,
initial_optional_permissions_->host_permissions, URLPatternSet()));
diff --git a/chromium/extensions/common/manifest_handlers/permissions_parser.h b/chromium/extensions/common/manifest_handlers/permissions_parser.h
index 2844d2ae875..e9d05d853b0 100644
--- a/chromium/extensions/common/manifest_handlers/permissions_parser.h
+++ b/chromium/extensions/common/manifest_handlers/permissions_parser.h
@@ -5,7 +5,8 @@
#ifndef EXTENSIONS_COMMON_MANIFEST_HANDLERS_PERMISSIONS_PARSER_H_
#define EXTENSIONS_COMMON_MANIFEST_HANDLERS_PERMISSIONS_PARSER_H_
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "base/strings/string16.h"
#include "extensions/common/permissions/api_permission.h"
#include "extensions/common/permissions/permission_set.h"
@@ -54,8 +55,8 @@ class PermissionsParser {
struct InitialPermissions;
// The initial permissions for the extension, which can still be modified.
- scoped_ptr<InitialPermissions> initial_required_permissions_;
- scoped_ptr<InitialPermissions> initial_optional_permissions_;
+ std::unique_ptr<InitialPermissions> initial_required_permissions_;
+ std::unique_ptr<InitialPermissions> initial_optional_permissions_;
};
} // namespace extensions
diff --git a/chromium/extensions/common/manifest_handlers/requirements_info.cc b/chromium/extensions/common/manifest_handlers/requirements_info.cc
index 9a2a22b92aa..c89d974bd42 100644
--- a/chromium/extensions/common/manifest_handlers/requirements_info.cc
+++ b/chromium/extensions/common/manifest_handlers/requirements_info.cc
@@ -4,8 +4,9 @@
#include "extensions/common/manifest_handlers/requirements_info.h"
+#include <memory>
+
#include "base/lazy_instance.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "extensions/common/error_utils.h"
@@ -61,7 +62,7 @@ bool RequirementsHandler::AlwaysParseForType(Manifest::Type type) const {
}
bool RequirementsHandler::Parse(Extension* extension, base::string16* error) {
- scoped_ptr<RequirementsInfo> requirements(
+ std::unique_ptr<RequirementsInfo> requirements(
new RequirementsInfo(extension->manifest()));
if (!extension->manifest()->HasKey(keys::kRequirements)) {
diff --git a/chromium/extensions/common/manifest_handlers/requirements_info.h b/chromium/extensions/common/manifest_handlers/requirements_info.h
index 9c87bca8cbf..64d107cd419 100644
--- a/chromium/extensions/common/manifest_handlers/requirements_info.h
+++ b/chromium/extensions/common/manifest_handlers/requirements_info.h
@@ -5,10 +5,10 @@
#ifndef EXTENSIONS_COMMON_MANIFEST_HANDLERS_REQUIREMENTS_INFO_H_
#define EXTENSIONS_COMMON_MANIFEST_HANDLERS_REQUIREMENTS_INFO_H_
+#include <memory>
#include <string>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest.h"
#include "extensions/common/manifest_handler.h"
diff --git a/chromium/extensions/common/manifest_handlers/sandboxed_page_info.cc b/chromium/extensions/common/manifest_handlers/sandboxed_page_info.cc
index bc44851935b..d3c82d5fdc1 100644
--- a/chromium/extensions/common/manifest_handlers/sandboxed_page_info.cc
+++ b/chromium/extensions/common/manifest_handlers/sandboxed_page_info.cc
@@ -6,8 +6,9 @@
#include <stddef.h>
+#include <memory>
+
#include "base/lazy_instance.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@@ -64,7 +65,7 @@ SandboxedPageHandler::~SandboxedPageHandler() {
}
bool SandboxedPageHandler::Parse(Extension* extension, base::string16* error) {
- scoped_ptr<SandboxedPageInfo> sandboxed_info(new SandboxedPageInfo);
+ std::unique_ptr<SandboxedPageInfo> sandboxed_info(new SandboxedPageInfo);
const base::ListValue* list_value = NULL;
if (!extension->manifest()->GetList(keys::kSandboxedPages, &list_value)) {
diff --git a/chromium/extensions/common/manifest_handlers/shared_module_info.cc b/chromium/extensions/common/manifest_handlers/shared_module_info.cc
index 87c8e879d5e..25679e1f778 100644
--- a/chromium/extensions/common/manifest_handlers/shared_module_info.cc
+++ b/chromium/extensions/common/manifest_handlers/shared_module_info.cc
@@ -6,9 +6,10 @@
#include <stddef.h>
+#include <memory>
+
#include "base/lazy_instance.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
@@ -206,7 +207,7 @@ SharedModuleHandler::~SharedModuleHandler() {
}
bool SharedModuleHandler::Parse(Extension* extension, base::string16* error) {
- scoped_ptr<SharedModuleInfo> info(new SharedModuleInfo);
+ std::unique_ptr<SharedModuleInfo> info(new SharedModuleInfo);
if (!info->Parse(extension, error))
return false;
extension->SetManifestData(kSharedModule, info.release());
diff --git a/chromium/extensions/common/manifest_handlers/web_accessible_resources_info.cc b/chromium/extensions/common/manifest_handlers/web_accessible_resources_info.cc
index 2aa7b2b66c4..1a9dc2aaf72 100644
--- a/chromium/extensions/common/manifest_handlers/web_accessible_resources_info.cc
+++ b/chromium/extensions/common/manifest_handlers/web_accessible_resources_info.cc
@@ -6,7 +6,8 @@
#include <stddef.h>
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@@ -65,7 +66,8 @@ WebAccessibleResourcesHandler::~WebAccessibleResourcesHandler() {
bool WebAccessibleResourcesHandler::Parse(Extension* extension,
base::string16* error) {
- scoped_ptr<WebAccessibleResourcesInfo> info(new WebAccessibleResourcesInfo);
+ std::unique_ptr<WebAccessibleResourcesInfo> info(
+ new WebAccessibleResourcesInfo);
const base::ListValue* list_value = NULL;
if (!extension->manifest()->GetList(keys::kWebAccessibleResources,
&list_value)) {
diff --git a/chromium/extensions/common/manifest_handlers/webview_info.cc b/chromium/extensions/common/manifest_handlers/webview_info.cc
index 6775c754dbc..989df762b45 100644
--- a/chromium/extensions/common/manifest_handlers/webview_info.cc
+++ b/chromium/extensions/common/manifest_handlers/webview_info.cc
@@ -6,9 +6,9 @@
#include <stddef.h>
+#include <memory>
#include <utility>
-#include "base/memory/scoped_ptr.h"
#include "base/strings/pattern.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
@@ -86,7 +86,7 @@ bool WebviewInfo::IsResourceWebviewAccessible(
return false;
}
-void WebviewInfo::AddPartitionItem(scoped_ptr<PartitionItem> item) {
+void WebviewInfo::AddPartitionItem(std::unique_ptr<PartitionItem> item) {
partition_items_.push_back(std::move(item));
}
@@ -97,7 +97,7 @@ WebviewHandler::~WebviewHandler() {
}
bool WebviewHandler::Parse(Extension* extension, base::string16* error) {
- scoped_ptr<WebviewInfo> info(new WebviewInfo(extension->id()));
+ std::unique_ptr<WebviewInfo> info(new WebviewInfo(extension->id()));
const base::DictionaryValue* dict_value = NULL;
if (!extension->manifest()->GetDictionary(keys::kWebview,
@@ -148,7 +148,7 @@ bool WebviewHandler::Parse(Extension* extension, base::string16* error) {
return false;
}
- scoped_ptr<PartitionItem> partition_item(
+ std::unique_ptr<PartitionItem> partition_item(
new PartitionItem(partition_pattern));
for (size_t i = 0; i < url_list->GetSize(); ++i) {
diff --git a/chromium/extensions/common/manifest_handlers/webview_info.h b/chromium/extensions/common/manifest_handlers/webview_info.h
index 887394d2dd7..117354ff9dc 100644
--- a/chromium/extensions/common/manifest_handlers/webview_info.h
+++ b/chromium/extensions/common/manifest_handlers/webview_info.h
@@ -5,11 +5,11 @@
#ifndef EXTENSIONS_COMMON_MANIFEST_HANDLERS_WEBVIEW_INFO_H_
#define EXTENSIONS_COMMON_MANIFEST_HANDLERS_WEBVIEW_INFO_H_
+#include <memory>
#include <string>
#include <vector>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest_handler.h"
@@ -32,11 +32,11 @@ class WebviewInfo : public Extension::ManifestData {
WebviewInfo(const std::string& extension_id);
~WebviewInfo() override;
- void AddPartitionItem(scoped_ptr<PartitionItem> item);
+ void AddPartitionItem(std::unique_ptr<PartitionItem> item);
private:
std::string extension_id_;
- std::vector<scoped_ptr<PartitionItem>> partition_items_;
+ std::vector<std::unique_ptr<PartitionItem>> partition_items_;
DISALLOW_COPY_AND_ASSIGN(WebviewInfo);
};
diff --git a/chromium/extensions/common/manifest_test.cc b/chromium/extensions/common/manifest_test.cc
index 771d4b3c4ad..2a43ed8ef25 100644
--- a/chromium/extensions/common/manifest_test.cc
+++ b/chromium/extensions/common/manifest_test.cc
@@ -22,7 +22,7 @@ namespace extensions {
namespace {
// |manifest_path| is an absolute path to a manifest file.
-scoped_ptr<base::DictionaryValue> LoadManifestFile(
+std::unique_ptr<base::DictionaryValue> LoadManifestFile(
const base::FilePath& manifest_path,
std::string* error) {
base::FilePath extension_path = manifest_path.DirName();
@@ -31,7 +31,7 @@ scoped_ptr<base::DictionaryValue> LoadManifestFile(
"Couldn't find " << manifest_path.value();
JSONFileValueDeserializer deserializer(manifest_path);
- scoped_ptr<base::DictionaryValue> manifest =
+ std::unique_ptr<base::DictionaryValue> manifest =
base::DictionaryValue::From(deserializer.Deserialize(NULL, error));
// Most unit tests don't need localization, and they'll fail if we try to
@@ -69,13 +69,13 @@ ManifestTest::ManifestData::ManifestData(base::DictionaryValue* manifest,
}
ManifestTest::ManifestData::ManifestData(
- scoped_ptr<base::DictionaryValue> manifest)
+ std::unique_ptr<base::DictionaryValue> manifest)
: manifest_(manifest.get()), manifest_holder_(std::move(manifest)) {
CHECK(manifest_) << "Manifest NULL";
}
ManifestTest::ManifestData::ManifestData(
- scoped_ptr<base::DictionaryValue> manifest,
+ std::unique_ptr<base::DictionaryValue> manifest,
const char* name)
: name_(name),
manifest_(manifest.get()),
@@ -111,8 +111,9 @@ base::FilePath ManifestTest::GetTestDataDir() {
return path.AppendASCII("manifest_tests");
}
-scoped_ptr<base::DictionaryValue> ManifestTest::LoadManifest(
- char const* manifest_name, std::string* error) {
+std::unique_ptr<base::DictionaryValue> ManifestTest::LoadManifest(
+ char const* manifest_name,
+ std::string* error) {
base::FilePath manifest_path = GetTestDataDir().AppendASCII(manifest_name);
return LoadManifestFile(manifest_path, error);
}
diff --git a/chromium/extensions/common/manifest_test.h b/chromium/extensions/common/manifest_test.h
index 32a5fa53151..be6a5ff5204 100644
--- a/chromium/extensions/common/manifest_test.h
+++ b/chromium/extensions/common/manifest_test.h
@@ -7,9 +7,10 @@
#include <stddef.h>
+#include <memory>
+
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest.h"
@@ -34,8 +35,8 @@ class ManifestTest : public testing::Test {
public:
explicit ManifestData(const char* name);
ManifestData(base::DictionaryValue* manifest, const char* name);
- explicit ManifestData(scoped_ptr<base::DictionaryValue> manifest);
- explicit ManifestData(scoped_ptr<base::DictionaryValue> manifest,
+ explicit ManifestData(std::unique_ptr<base::DictionaryValue> manifest);
+ explicit ManifestData(std::unique_ptr<base::DictionaryValue> manifest,
const char* name);
// C++98 requires the copy constructor for a type to be visible if you
// take a const-ref of a temporary for that type. Since Manifest
@@ -58,7 +59,7 @@ class ManifestTest : public testing::Test {
private:
const std::string name_;
mutable base::DictionaryValue* manifest_;
- mutable scoped_ptr<base::DictionaryValue> manifest_holder_;
+ mutable std::unique_ptr<base::DictionaryValue> manifest_holder_;
};
// Allows the test implementation to override a loaded test manifest's
@@ -69,9 +70,8 @@ class ManifestTest : public testing::Test {
// extensions/test/data/manifest_tests.
virtual base::FilePath GetTestDataDir();
- scoped_ptr<base::DictionaryValue> LoadManifest(
- char const* manifest_name,
- std::string* error);
+ std::unique_ptr<base::DictionaryValue> LoadManifest(char const* manifest_name,
+ std::string* error);
scoped_refptr<extensions::Extension> LoadExtension(
const ManifestData& manifest,
diff --git a/chromium/extensions/common/manifest_url_handlers.cc b/chromium/extensions/common/manifest_url_handlers.cc
index 7d1487344b5..c3bcabab96a 100644
--- a/chromium/extensions/common/manifest_url_handlers.cc
+++ b/chromium/extensions/common/manifest_url_handlers.cc
@@ -4,8 +4,9 @@
#include "extensions/common/manifest_url_handlers.h"
+#include <memory>
+
#include "base/files/file_util.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
@@ -87,7 +88,7 @@ HomepageURLHandler::~HomepageURLHandler() {
}
bool HomepageURLHandler::Parse(Extension* extension, base::string16* error) {
- scoped_ptr<ManifestURL> manifest_url(new ManifestURL);
+ std::unique_ptr<ManifestURL> manifest_url(new ManifestURL);
std::string homepage_url_str;
if (!extension->manifest()->GetString(keys::kHomepageURL,
&homepage_url_str)) {
@@ -117,7 +118,7 @@ UpdateURLHandler::~UpdateURLHandler() {
}
bool UpdateURLHandler::Parse(Extension* extension, base::string16* error) {
- scoped_ptr<ManifestURL> manifest_url(new ManifestURL);
+ std::unique_ptr<ManifestURL> manifest_url(new ManifestURL);
std::string tmp_update_url;
if (!extension->manifest()->GetString(keys::kUpdateURL, &tmp_update_url)) {
@@ -149,7 +150,7 @@ AboutPageHandler::~AboutPageHandler() {
}
bool AboutPageHandler::Parse(Extension* extension, base::string16* error) {
- scoped_ptr<ManifestURL> manifest_url(new ManifestURL);
+ std::unique_ptr<ManifestURL> manifest_url(new ManifestURL);
std::string about_str;
if (!extension->manifest()->GetString(keys::kAboutPage, &about_str)) {
*error = base::ASCIIToUTF16(errors::kInvalidAboutPage);
diff --git a/chromium/extensions/common/message_bundle.cc b/chromium/extensions/common/message_bundle.cc
index ef78a0a7d5c..104bbae1be9 100644
--- a/chromium/extensions/common/message_bundle.cc
+++ b/chromium/extensions/common/message_bundle.cc
@@ -4,6 +4,7 @@
#include "extensions/common/message_bundle.h"
+#include <memory>
#include <string>
#include <vector>
@@ -11,7 +12,6 @@
#include "base/i18n/rtl.h"
#include "base/lazy_instance.h"
#include "base/memory/linked_ptr.h"
-#include "base/memory/scoped_ptr.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
@@ -59,7 +59,7 @@ static bool BadKeyMessage(const std::string& name, std::string* error) {
// static
MessageBundle* MessageBundle::Create(const CatalogVector& locale_catalogs,
std::string* error) {
- scoped_ptr<MessageBundle> message_bundle(new MessageBundle);
+ std::unique_ptr<MessageBundle> message_bundle(new MessageBundle);
if (!message_bundle->Init(locale_catalogs, error))
return NULL;
diff --git a/chromium/extensions/common/message_bundle_unittest.cc b/chromium/extensions/common/message_bundle_unittest.cc
index f80473bfcdb..45bd0e11542 100644
--- a/chromium/extensions/common/message_bundle_unittest.cc
+++ b/chromium/extensions/common/message_bundle_unittest.cc
@@ -6,13 +6,13 @@
#include <stddef.h>
+#include <memory>
#include <string>
#include <vector>
#include "base/i18n/rtl.h"
#include "base/macros.h"
#include "base/memory/linked_ptr.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@@ -160,7 +160,7 @@ class MessageBundleTest : public testing::Test {
handler_->dictionary_.clear();
}
- scoped_ptr<MessageBundle> handler_;
+ std::unique_ptr<MessageBundle> handler_;
std::vector<linked_ptr<base::DictionaryValue> > catalogs_;
};
diff --git a/chromium/extensions/common/mojo/wifi_display_session_service.mojom b/chromium/extensions/common/mojo/wifi_display_session_service.mojom
index f664a5fb8db..edccec89d53 100644
--- a/chromium/extensions/common/mojo/wifi_display_session_service.mojom
+++ b/chromium/extensions/common/mojo/wifi_display_session_service.mojom
@@ -23,7 +23,7 @@ interface WiFiDisplaySessionService {
interface WiFiDisplaySessionServiceClient {
// Notification of a successfull connection to a sink.
- OnConnected(string ip_address);
+ OnConnected(string local_ip_address, string sink_ip_address);
// Notification of a handled connection request.
OnConnectRequestHandled(bool success, string error_message);
@@ -43,3 +43,13 @@ interface WiFiDisplaySessionServiceClient {
// the connected sink.
OnMessage(string data);
};
+
+// This interface is used to send media stream to the
+// connected sink.
+interface WiFiDisplayMediaService {
+ // Sets the destination point for sending media stream.
+ SetDesinationPoint(string ip_address, int32 port) => (bool success);
+
+ // Sends media packet to the destination point.
+ SendMediaPacket(array<uint8> packet);
+};
diff --git a/chromium/extensions/common/one_shot_event.cc b/chromium/extensions/common/one_shot_event.cc
index a61cac8a218..ee8b80a7274 100644
--- a/chromium/extensions/common/one_shot_event.cc
+++ b/chromium/extensions/common/one_shot_event.cc
@@ -11,7 +11,7 @@
#include "base/location.h"
#include "base/single_thread_task_runner.h"
#include "base/task_runner.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
using base::SingleThreadTaskRunner;
@@ -76,10 +76,10 @@ void OneShotEvent::Signal() {
// the order doesn't matter...
for (size_t i = 0; i < tasks_.size(); ++i) {
const TaskInfo& task = tasks_[i];
- if (task.delay != base::TimeDelta())
- task.runner->PostDelayedTask(task.from_here, task.task, task.delay);
- else
+ if (task.delay.is_zero())
task.runner->PostTask(task.from_here, task.task);
+ else
+ task.runner->PostDelayedTask(task.from_here, task.task, task.delay);
}
}
@@ -90,10 +90,10 @@ void OneShotEvent::PostImpl(const tracked_objects::Location& from_here,
DCHECK(thread_checker_.CalledOnValidThread());
if (is_signaled()) {
- if (delay != base::TimeDelta())
- runner->PostDelayedTask(from_here, task, delay);
- else
+ if (delay.is_zero())
runner->PostTask(from_here, task);
+ else
+ runner->PostDelayedTask(from_here, task, delay);
} else {
tasks_.push_back(TaskInfo(from_here, runner, task, delay));
}
diff --git a/chromium/extensions/common/permissions/api_permission.cc b/chromium/extensions/common/permissions/api_permission.cc
index 77a13172cdc..148fc8eb6e1 100644
--- a/chromium/extensions/common/permissions/api_permission.cc
+++ b/chromium/extensions/common/permissions/api_permission.cc
@@ -46,8 +46,8 @@ class SimpleAPIPermission : public APIPermission {
return (value == NULL);
}
- scoped_ptr<base::Value> ToValue() const override {
- return scoped_ptr<base::Value>();
+ std::unique_ptr<base::Value> ToValue() const override {
+ return std::unique_ptr<base::Value>();
}
APIPermission* Clone() const override {
@@ -69,6 +69,8 @@ class SimpleAPIPermission : public APIPermission {
return new SimpleAPIPermission(info());
}
+ void GetSize(base::PickleSizer* s) const override {}
+
void Write(base::Pickle* m) const override {}
bool Read(const base::Pickle* m, base::PickleIterator* iter) override {
diff --git a/chromium/extensions/common/permissions/api_permission.h b/chromium/extensions/common/permissions/api_permission.h
index f6903626f4a..47aa543072b 100644
--- a/chromium/extensions/common/permissions/api_permission.h
+++ b/chromium/extensions/common/permissions/api_permission.h
@@ -5,12 +5,12 @@
#ifndef EXTENSIONS_COMMON_PERMISSIONS_API_PERMISSION_H_
#define EXTENSIONS_COMMON_PERMISSIONS_API_PERMISSION_H_
+#include <memory>
#include <set>
#include <string>
#include <vector>
#include "base/callback.h"
-#include "base/memory/scoped_ptr.h"
#include "base/pickle.h"
#include "base/values.h"
@@ -308,7 +308,7 @@ class APIPermission {
std::vector<std::string>* unhandled_permissions) = 0;
// Stores this into a new created |value|.
- virtual scoped_ptr<base::Value> ToValue() const = 0;
+ virtual std::unique_ptr<base::Value> ToValue() const = 0;
// Clones this.
virtual APIPermission* Clone() const = 0;
@@ -323,6 +323,9 @@ class APIPermission {
virtual APIPermission* Intersect(const APIPermission* rhs) const = 0;
// IPC functions
+ // Gets the size of the data to be written.
+ virtual void GetSize(base::PickleSizer* s) const = 0;
+
// Writes this into the given IPC message |m|.
virtual void Write(base::Pickle* m) const = 0;
diff --git a/chromium/extensions/common/permissions/api_permission_set.cc b/chromium/extensions/common/permissions/api_permission_set.cc
index 0e48d2f4933..d1c7f325b95 100644
--- a/chromium/extensions/common/permissions/api_permission_set.cc
+++ b/chromium/extensions/common/permissions/api_permission_set.cc
@@ -38,7 +38,7 @@ bool CreateAPIPermission(
const APIPermissionInfo* permission_info =
PermissionsInfo::GetInstance()->GetByName(permission_str);
if (permission_info) {
- scoped_ptr<APIPermission> permission(
+ std::unique_ptr<APIPermission> permission(
permission_info->CreateAPIPermission());
if (source != APIPermissionSet::kAllowInternalPermissions &&
permission_info->is_internal()) {
diff --git a/chromium/extensions/common/permissions/api_permission_set_unittest.cc b/chromium/extensions/common/permissions/api_permission_set_unittest.cc
index 78a0161b27b..b0acc83b141 100644
--- a/chromium/extensions/common/permissions/api_permission_set_unittest.cc
+++ b/chromium/extensions/common/permissions/api_permission_set_unittest.cc
@@ -44,7 +44,7 @@ TEST(APIPermissionSetTest, CreateUnion) {
PermissionsInfo::GetInstance()->GetByID(APIPermission::kSocket);
permission = permission_info->CreateAPIPermission();
{
- scoped_ptr<base::ListValue> value(new base::ListValue());
+ std::unique_ptr<base::ListValue> value(new base::ListValue());
value->Append(new base::StringValue("tcp-connect:*.example.com:80"));
value->Append(new base::StringValue("udp-bind::8080"));
value->Append(new base::StringValue("udp-send-to::8888"));
@@ -79,7 +79,7 @@ TEST(APIPermissionSetTest, CreateUnion) {
permission = permission_info->CreateAPIPermission();
{
- scoped_ptr<base::ListValue> value(new base::ListValue());
+ std::unique_ptr<base::ListValue> value(new base::ListValue());
value->Append(new base::StringValue("tcp-connect:*.example.com:80"));
value->Append(new base::StringValue("udp-send-to::8899"));
ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL));
@@ -93,7 +93,7 @@ TEST(APIPermissionSetTest, CreateUnion) {
permission = permission_info->CreateAPIPermission();
{
- scoped_ptr<base::ListValue> value(new base::ListValue());
+ std::unique_ptr<base::ListValue> value(new base::ListValue());
value->Append(new base::StringValue("tcp-connect:*.example.com:80"));
value->Append(new base::StringValue("udp-bind::8080"));
value->Append(new base::StringValue("udp-send-to::8888"));
@@ -131,7 +131,7 @@ TEST(APIPermissionSetTest, CreateIntersection) {
apis1.insert(APIPermission::kDns);
permission = permission_info->CreateAPIPermission();
{
- scoped_ptr<base::ListValue> value(new base::ListValue());
+ std::unique_ptr<base::ListValue> value(new base::ListValue());
value->Append(new base::StringValue("tcp-connect:*.example.com:80"));
value->Append(new base::StringValue("udp-bind::8080"));
value->Append(new base::StringValue("udp-send-to::8888"));
@@ -159,7 +159,7 @@ TEST(APIPermissionSetTest, CreateIntersection) {
apis2.insert(APIPermission::kSerial);
permission = permission_info->CreateAPIPermission();
{
- scoped_ptr<base::ListValue> value(new base::ListValue());
+ std::unique_ptr<base::ListValue> value(new base::ListValue());
value->Append(new base::StringValue("udp-bind::8080"));
value->Append(new base::StringValue("udp-send-to::8888"));
value->Append(new base::StringValue("udp-send-to::8899"));
@@ -170,7 +170,7 @@ TEST(APIPermissionSetTest, CreateIntersection) {
expected_apis.insert(APIPermission::kAudioCapture);
permission = permission_info->CreateAPIPermission();
{
- scoped_ptr<base::ListValue> value(new base::ListValue());
+ std::unique_ptr<base::ListValue> value(new base::ListValue());
value->Append(new base::StringValue("udp-bind::8080"));
value->Append(new base::StringValue("udp-send-to::8888"));
ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL));
@@ -205,7 +205,7 @@ TEST(APIPermissionSetTest, CreateDifference) {
apis1.insert(APIPermission::kDns);
permission = permission_info->CreateAPIPermission();
{
- scoped_ptr<base::ListValue> value(new base::ListValue());
+ std::unique_ptr<base::ListValue> value(new base::ListValue());
value->Append(new base::StringValue("tcp-connect:*.example.com:80"));
value->Append(new base::StringValue("udp-bind::8080"));
value->Append(new base::StringValue("udp-send-to::8888"));
@@ -225,7 +225,7 @@ TEST(APIPermissionSetTest, CreateDifference) {
apis2.insert(APIPermission::kSerial);
permission = permission_info->CreateAPIPermission();
{
- scoped_ptr<base::ListValue> value(new base::ListValue());
+ std::unique_ptr<base::ListValue> value(new base::ListValue());
value->Append(new base::StringValue("tcp-connect:*.example.com:80"));
value->Append(new base::StringValue("udp-send-to::8899"));
ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL));
@@ -235,7 +235,7 @@ TEST(APIPermissionSetTest, CreateDifference) {
expected_apis.insert(APIPermission::kDns);
permission = permission_info->CreateAPIPermission();
{
- scoped_ptr<base::ListValue> value(new base::ListValue());
+ std::unique_ptr<base::ListValue> value(new base::ListValue());
value->Append(new base::StringValue("udp-bind::8080"));
value->Append(new base::StringValue("udp-send-to::8888"));
ASSERT_TRUE(permission->FromValue(value.get(), NULL, NULL));
@@ -268,7 +268,7 @@ TEST(APIPermissionSetTest, IPC) {
apis.insert(APIPermission::kDns);
permission = permission_info->CreateAPIPermission();
{
- scoped_ptr<base::ListValue> value(new base::ListValue());
+ std::unique_ptr<base::ListValue> value(new base::ListValue());
value->Append(new base::StringValue("tcp-connect:*.example.com:80"));
value->Append(new base::StringValue("udp-bind::8080"));
value->Append(new base::StringValue("udp-send-to::8888"));
diff --git a/chromium/extensions/common/permissions/manifest_permission.cc b/chromium/extensions/common/permissions/manifest_permission.cc
index 97421385169..9315d1d0418 100644
--- a/chromium/extensions/common/permissions/manifest_permission.cc
+++ b/chromium/extensions/common/permissions/manifest_permission.cc
@@ -20,13 +20,20 @@ ManifestPermission* ManifestPermission::Clone() const {
}
bool ManifestPermission::Contains(const ManifestPermission* rhs) const {
- return scoped_ptr<ManifestPermission>(Intersect(rhs))->Equal(rhs);
+ return std::unique_ptr<ManifestPermission>(Intersect(rhs))->Equal(rhs);
}
bool ManifestPermission::Equal(const ManifestPermission* rhs) const {
return ToValue()->Equals(rhs->ToValue().get());
}
+void ManifestPermission::GetSize(base::PickleSizer* s) const {
+ base::ListValue singleton;
+ base::Value* value = ToValue().release();
+ singleton.Append(value);
+ IPC::GetParamSize(s, singleton);
+}
+
void ManifestPermission::Write(base::Pickle* m) const {
base::ListValue singleton;
base::Value* value = ToValue().release();
diff --git a/chromium/extensions/common/permissions/manifest_permission.h b/chromium/extensions/common/permissions/manifest_permission.h
index db8f07c2594..aa05d5fbdee 100644
--- a/chromium/extensions/common/permissions/manifest_permission.h
+++ b/chromium/extensions/common/permissions/manifest_permission.h
@@ -5,10 +5,10 @@
#ifndef EXTENSIONS_COMMON_PERMISSIONS_MANIFEST_PERMISSION_H_
#define EXTENSIONS_COMMON_PERMISSIONS_MANIFEST_PERMISSION_H_
+#include <memory>
#include <string>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/pickle.h"
#include "extensions/common/permissions/api_permission_set.h"
@@ -45,7 +45,7 @@ class ManifestPermission {
virtual bool FromValue(const base::Value* value) = 0;
// Stores this into a new created Value.
- virtual scoped_ptr<base::Value> ToValue() const = 0;
+ virtual std::unique_ptr<base::Value> ToValue() const = 0;
// Clones this.
ManifestPermission* Clone() const;
@@ -68,6 +68,9 @@ class ManifestPermission {
bool Equal(const ManifestPermission* rhs) const;
// IPC functions
+ // Gets the size of the data to be written.
+ void GetSize(base::PickleSizer* s) const;
+
// Writes this into the given IPC message |m|.
void Write(base::Pickle* m) const;
diff --git a/chromium/extensions/common/permissions/manifest_permission_set.cc b/chromium/extensions/common/permissions/manifest_permission_set.cc
index 39e2ba673d7..383d125736d 100644
--- a/chromium/extensions/common/permissions/manifest_permission_set.cc
+++ b/chromium/extensions/common/permissions/manifest_permission_set.cc
@@ -28,8 +28,7 @@ bool CreateManifestPermission(
ManifestPermissionSet* manifest_permissions,
base::string16* error,
std::vector<std::string>* unhandled_permissions) {
-
- scoped_ptr<ManifestPermission> permission(
+ std::unique_ptr<ManifestPermission> permission(
ManifestHandler::CreatePermission(permission_name));
if (!permission) {
diff --git a/chromium/extensions/common/permissions/manifest_permission_set_unittest.cc b/chromium/extensions/common/permissions/manifest_permission_set_unittest.cc
index f3660363f9a..e0da1af8a07 100644
--- a/chromium/extensions/common/permissions/manifest_permission_set_unittest.cc
+++ b/chromium/extensions/common/permissions/manifest_permission_set_unittest.cc
@@ -25,7 +25,7 @@ class MockManifestPermission : public ManifestPermission {
bool FromValue(const base::Value* value) override { return true; }
- scoped_ptr<base::Value> ToValue() const override {
+ std::unique_ptr<base::Value> ToValue() const override {
return base::Value::CreateNullValue();
}
diff --git a/chromium/extensions/common/permissions/media_galleries_permission.cc b/chromium/extensions/common/permissions/media_galleries_permission.cc
index 4ac5ae6c0c9..d3b245f4963 100644
--- a/chromium/extensions/common/permissions/media_galleries_permission.cc
+++ b/chromium/extensions/common/permissions/media_galleries_permission.cc
@@ -40,58 +40,6 @@ bool IsValidPermissionSet(bool has_read, bool has_copy_to, bool has_delete,
return true;
}
-// Adds the permissions from the |data_set| to |ids|.
-void AddPermissionsToLists(
- const std::set<MediaGalleriesPermissionData>& data_set,
- PermissionIDSet* ids) {
- // TODO(sashab): Once GetMessages() is deprecated, move this logic back into
- // GetPermissions().
- bool has_all_auto_detected = false;
- bool has_read = false;
- bool has_copy_to = false;
- bool has_delete = false;
-
- for (std::set<MediaGalleriesPermissionData>::const_iterator it =
- data_set.begin();
- it != data_set.end(); ++it) {
- if (it->permission() ==
- MediaGalleriesPermission::kAllAutoDetectedPermission)
- has_all_auto_detected = true;
- else if (it->permission() == MediaGalleriesPermission::kReadPermission)
- has_read = true;
- else if (it->permission() == MediaGalleriesPermission::kCopyToPermission)
- has_copy_to = true;
- else if (it->permission() == MediaGalleriesPermission::kDeletePermission)
- has_delete = true;
- }
-
- if (!IsValidPermissionSet(has_read, has_copy_to, has_delete, NULL)) {
- NOTREACHED();
- return;
- }
-
- // If |has_all_auto_detected| is false, then Chrome will prompt the user at
- // runtime when the extension call the getMediaGalleries API.
- if (!has_all_auto_detected)
- return;
- // No access permission case.
- if (!has_read)
- return;
-
- // Separate PermissionMessage IDs for read, copyTo, and delete. Otherwise an
- // extension can silently gain new access capabilities.
- ids->insert(APIPermission::kMediaGalleriesAllGalleriesRead);
-
- // For copyTo and delete, the proper combined permission message will be
- // derived in ChromePermissionMessageProvider::GetWarningMessages(), such
- // that the user get 1 entry for all media galleries access permissions,
- // rather than several separate entries.
- if (has_copy_to)
- ids->insert(APIPermission::kMediaGalleriesAllGalleriesCopyTo);
- if (has_delete)
- ids->insert(APIPermission::kMediaGalleriesAllGalleriesDelete);
-}
-
} // namespace
const char MediaGalleriesPermission::kAllAutoDetectedPermission[] =
@@ -164,7 +112,49 @@ bool MediaGalleriesPermission::FromValue(
PermissionIDSet MediaGalleriesPermission::GetPermissions() const {
PermissionIDSet result;
- AddPermissionsToLists(data_set_, &result);
+
+ bool has_all_auto_detected = false;
+ bool has_read = false;
+ bool has_copy_to = false;
+ bool has_delete = false;
+
+ for (const MediaGalleriesPermissionData& data : data_set_) {
+ if (data.permission() == kAllAutoDetectedPermission)
+ has_all_auto_detected = true;
+ else if (data.permission() == kReadPermission)
+ has_read = true;
+ else if (data.permission() == kCopyToPermission)
+ has_copy_to = true;
+ else if (data.permission() == kDeletePermission)
+ has_delete = true;
+ }
+
+ if (!IsValidPermissionSet(has_read, has_copy_to, has_delete, nullptr)) {
+ NOTREACHED();
+ return result;
+ }
+
+ // If |has_all_auto_detected| is false, then Chrome will prompt the user at
+ // runtime when the extension calls the getMediaGalleries API.
+ if (!has_all_auto_detected)
+ return result;
+ // No access permission case.
+ if (!has_read)
+ return result;
+
+ // Separate PermissionMessage IDs for read, copyTo, and delete. Otherwise an
+ // extension can silently gain new access capabilities.
+ result.insert(APIPermission::kMediaGalleriesAllGalleriesRead);
+
+ // For copyTo and delete, the proper combined permission message will be
+ // derived in ChromePermissionMessageProvider::GetWarningMessages(), such
+ // that the user get 1 entry for all media galleries access permissions,
+ // rather than several separate entries.
+ if (has_copy_to)
+ result.insert(APIPermission::kMediaGalleriesAllGalleriesCopyTo);
+ if (has_delete)
+ result.insert(APIPermission::kMediaGalleriesAllGalleriesDelete);
+
return result;
}
diff --git a/chromium/extensions/common/permissions/media_galleries_permission_data.cc b/chromium/extensions/common/permissions/media_galleries_permission_data.cc
index 495c1f917eb..13f7d93d38c 100644
--- a/chromium/extensions/common/permissions/media_galleries_permission_data.cc
+++ b/chromium/extensions/common/permissions/media_galleries_permission_data.cc
@@ -23,8 +23,8 @@ bool MediaGalleriesPermissionData::Check(
return permission_ == specific_param.permission;
}
-scoped_ptr<base::Value> MediaGalleriesPermissionData::ToValue() const {
- return scoped_ptr<base::Value>(new base::StringValue(permission_));
+std::unique_ptr<base::Value> MediaGalleriesPermissionData::ToValue() const {
+ return std::unique_ptr<base::Value>(new base::StringValue(permission_));
}
bool MediaGalleriesPermissionData::FromValue(const base::Value* value) {
diff --git a/chromium/extensions/common/permissions/media_galleries_permission_data.h b/chromium/extensions/common/permissions/media_galleries_permission_data.h
index 05ae5789416..db8df8394da 100644
--- a/chromium/extensions/common/permissions/media_galleries_permission_data.h
+++ b/chromium/extensions/common/permissions/media_galleries_permission_data.h
@@ -5,9 +5,9 @@
#ifndef EXTENSIONS_COMMON_PERMISSIONS_MEDIA_GALLERIES_PERMISSION_DATA_H_
#define EXTENSIONS_COMMON_PERMISSIONS_MEDIA_GALLERIES_PERMISSION_DATA_H_
+#include <memory>
#include <string>
-#include "base/memory/scoped_ptr.h"
#include "extensions/common/permissions/api_permission.h"
namespace base {
@@ -27,7 +27,7 @@ class MediaGalleriesPermissionData {
bool Check(const APIPermission::CheckParam* param) const;
// Convert |this| into a base::Value.
- scoped_ptr<base::Value> ToValue() const;
+ std::unique_ptr<base::Value> ToValue() const;
// Populate |this| from a base::Value.
bool FromValue(const base::Value* value);
diff --git a/chromium/extensions/common/permissions/permission_set.cc b/chromium/extensions/common/permissions/permission_set.cc
index a3e3f4144f6..39f353c80b4 100644
--- a/chromium/extensions/common/permissions/permission_set.cc
+++ b/chromium/extensions/common/permissions/permission_set.cc
@@ -4,6 +4,9 @@
#include "extensions/common/permissions/permission_set.h"
+#include <memory>
+
+#include "base/memory/ptr_util.h"
#include "extensions/common/permissions/permissions_info.h"
#include "extensions/common/url_pattern.h"
#include "url/gurl.h"
@@ -46,7 +49,7 @@ PermissionSet::PermissionSet(
PermissionSet::~PermissionSet() {}
// static
-scoped_ptr<const PermissionSet> PermissionSet::CreateDifference(
+std::unique_ptr<const PermissionSet> PermissionSet::CreateDifference(
const PermissionSet& set1,
const PermissionSet& set2) {
APIPermissionSet apis;
@@ -63,12 +66,12 @@ scoped_ptr<const PermissionSet> PermissionSet::CreateDifference(
URLPatternSet scriptable_hosts = URLPatternSet::CreateDifference(
set1.scriptable_hosts(), set2.scriptable_hosts());
- return make_scoped_ptr(new PermissionSet(apis, manifest_permissions,
- explicit_hosts, scriptable_hosts));
+ return base::WrapUnique(new PermissionSet(apis, manifest_permissions,
+ explicit_hosts, scriptable_hosts));
}
// static
-scoped_ptr<const PermissionSet> PermissionSet::CreateIntersection(
+std::unique_ptr<const PermissionSet> PermissionSet::CreateIntersection(
const PermissionSet& set1,
const PermissionSet& set2) {
APIPermissionSet apis;
@@ -84,12 +87,12 @@ scoped_ptr<const PermissionSet> PermissionSet::CreateIntersection(
URLPatternSet scriptable_hosts = URLPatternSet::CreateSemanticIntersection(
set1.scriptable_hosts(), set2.scriptable_hosts());
- return make_scoped_ptr(new PermissionSet(apis, manifest_permissions,
- explicit_hosts, scriptable_hosts));
+ return base::WrapUnique(new PermissionSet(apis, manifest_permissions,
+ explicit_hosts, scriptable_hosts));
}
// static
-scoped_ptr<const PermissionSet> PermissionSet::CreateUnion(
+std::unique_ptr<const PermissionSet> PermissionSet::CreateUnion(
const PermissionSet& set1,
const PermissionSet& set2) {
APIPermissionSet apis;
@@ -106,8 +109,8 @@ scoped_ptr<const PermissionSet> PermissionSet::CreateUnion(
URLPatternSet scriptable_hosts = URLPatternSet::CreateUnion(
set1.scriptable_hosts(), set2.scriptable_hosts());
- return make_scoped_ptr(new PermissionSet(apis, manifest_permissions,
- explicit_hosts, scriptable_hosts));
+ return base::WrapUnique(new PermissionSet(apis, manifest_permissions,
+ explicit_hosts, scriptable_hosts));
}
bool PermissionSet::operator==(
@@ -122,8 +125,8 @@ bool PermissionSet::operator!=(const PermissionSet& rhs) const {
return !(*this == rhs);
}
-scoped_ptr<const PermissionSet> PermissionSet::Clone() const {
- return make_scoped_ptr(new PermissionSet(*this));
+std::unique_ptr<const PermissionSet> PermissionSet::Clone() const {
+ return base::WrapUnique(new PermissionSet(*this));
}
bool PermissionSet::Contains(const PermissionSet& set) const {
diff --git a/chromium/extensions/common/permissions/permission_set.h b/chromium/extensions/common/permissions/permission_set.h
index b03a8697f8d..af5f6475928 100644
--- a/chromium/extensions/common/permissions/permission_set.h
+++ b/chromium/extensions/common/permissions/permission_set.h
@@ -42,25 +42,26 @@ class PermissionSet {
~PermissionSet();
// Creates a new permission set equal to |set1| - |set2|.
- static scoped_ptr<const PermissionSet> CreateDifference(
+ static std::unique_ptr<const PermissionSet> CreateDifference(
const PermissionSet& set1,
const PermissionSet& set2);
// Creates a new permission set equal to the intersection of |set1| and
// |set2|.
- static scoped_ptr<const PermissionSet> CreateIntersection(
+ static std::unique_ptr<const PermissionSet> CreateIntersection(
const PermissionSet& set1,
const PermissionSet& set2);
// Creates a new permission set equal to the union of |set1| and |set2|.
- static scoped_ptr<const PermissionSet> CreateUnion(const PermissionSet& set1,
- const PermissionSet& set2);
+ static std::unique_ptr<const PermissionSet> CreateUnion(
+ const PermissionSet& set1,
+ const PermissionSet& set2);
bool operator==(const PermissionSet& rhs) const;
bool operator!=(const PermissionSet& rhs) const;
// Returns a copy of this PermissionSet.
- scoped_ptr<const PermissionSet> Clone() const;
+ std::unique_ptr<const PermissionSet> Clone() const;
// Returns true if every API or host permission available to |set| is also
// available to this. In other words, if the API permissions of |set| are a
diff --git a/chromium/extensions/common/permissions/permissions_data.cc b/chromium/extensions/common/permissions/permissions_data.cc
index c77c4ee511b..4025d23c0ff 100644
--- a/chromium/extensions/common/permissions/permissions_data.cc
+++ b/chromium/extensions/common/permissions/permissions_data.cc
@@ -133,15 +133,15 @@ void PermissionsData::BindToCurrentThread() const {
}
void PermissionsData::SetPermissions(
- scoped_ptr<const PermissionSet> active,
- scoped_ptr<const PermissionSet> withheld) const {
+ std::unique_ptr<const PermissionSet> active,
+ std::unique_ptr<const PermissionSet> withheld) const {
AutoLockOnValidThread lock(runtime_lock_, thread_checker_.get());
active_permissions_unsafe_ = std::move(active);
withheld_permissions_unsafe_ = std::move(withheld);
}
void PermissionsData::SetActivePermissions(
- scoped_ptr<const PermissionSet> active) const {
+ std::unique_ptr<const PermissionSet> active) const {
AutoLockOnValidThread lock(runtime_lock_, thread_checker_.get());
active_permissions_unsafe_ = std::move(active);
}
@@ -153,11 +153,12 @@ void PermissionsData::UpdateTabSpecificPermissions(
CHECK_GE(tab_id, 0);
TabPermissionsMap::const_iterator iter =
tab_specific_permissions_.find(tab_id);
- scoped_ptr<const PermissionSet> new_permissions = PermissionSet::CreateUnion(
- iter == tab_specific_permissions_.end()
- ? static_cast<const PermissionSet&>(PermissionSet())
- : *iter->second,
- permissions);
+ std::unique_ptr<const PermissionSet> new_permissions =
+ PermissionSet::CreateUnion(
+ iter == tab_specific_permissions_.end()
+ ? static_cast<const PermissionSet&>(PermissionSet())
+ : *iter->second,
+ permissions);
tab_specific_permissions_[tab_id] = std::move(new_permissions);
}
diff --git a/chromium/extensions/common/permissions/permissions_data.h b/chromium/extensions/common/permissions/permissions_data.h
index bb8e51e9b78..681a7ee4269 100644
--- a/chromium/extensions/common/permissions/permissions_data.h
+++ b/chromium/extensions/common/permissions/permissions_data.h
@@ -6,12 +6,12 @@
#define EXTENSIONS_COMMON_PERMISSIONS_PERMISSIONS_DATA_H_
#include <map>
+#include <memory>
#include <string>
#include <vector>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread_checker.h"
@@ -46,7 +46,7 @@ class PermissionsData {
// the given page.
};
- using TabPermissionsMap = std::map<int, scoped_ptr<const PermissionSet>>;
+ using TabPermissionsMap = std::map<int, std::unique_ptr<const PermissionSet>>;
// Delegate class to allow different contexts (e.g. browser vs renderer) to
// have control over policy decisions.
@@ -88,11 +88,11 @@ class PermissionsData {
// Sets the runtime permissions of the given |extension| to |active| and
// |withheld|.
- void SetPermissions(scoped_ptr<const PermissionSet> active,
- scoped_ptr<const PermissionSet> withheld) const;
+ void SetPermissions(std::unique_ptr<const PermissionSet> active,
+ std::unique_ptr<const PermissionSet> withheld) const;
// Sets the active permissions, leaving withheld the same.
- void SetActivePermissions(scoped_ptr<const PermissionSet> active) const;
+ void SetActivePermissions(std::unique_ptr<const PermissionSet> active) const;
// Updates the tab-specific permissions of |tab_id| to include those from
// |permissions|.
@@ -246,18 +246,18 @@ class PermissionsData {
// Unsafe indicates that we must lock anytime this is directly accessed.
// Unless you need to change |active_permissions_unsafe_|, use the (safe)
// active_permissions() accessor.
- mutable scoped_ptr<const PermissionSet> active_permissions_unsafe_;
+ mutable std::unique_ptr<const PermissionSet> active_permissions_unsafe_;
// The permissions the extension requested, but was not granted due because
// they are too powerful. This includes things like all_hosts.
// Unsafe indicates that we must lock anytime this is directly accessed.
// Unless you need to change |withheld_permissions_unsafe_|, use the (safe)
// withheld_permissions() accessor.
- mutable scoped_ptr<const PermissionSet> withheld_permissions_unsafe_;
+ mutable std::unique_ptr<const PermissionSet> withheld_permissions_unsafe_;
mutable TabPermissionsMap tab_specific_permissions_;
- mutable scoped_ptr<base::ThreadChecker> thread_checker_;
+ mutable std::unique_ptr<base::ThreadChecker> thread_checker_;
DISALLOW_COPY_AND_ASSIGN(PermissionsData);
};
diff --git a/chromium/extensions/common/permissions/set_disjunction_permission.h b/chromium/extensions/common/permissions/set_disjunction_permission.h
index ce1c6ee1dd1..fedcf2c8aea 100644
--- a/chromium/extensions/common/permissions/set_disjunction_permission.h
+++ b/chromium/extensions/common/permissions/set_disjunction_permission.h
@@ -7,11 +7,11 @@
#include <stddef.h>
+#include <memory>
#include <set>
#include <string>
#include "base/json/json_writer.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "extensions/common/extension_messages.h"
#include "extensions/common/permissions/api_permission.h"
@@ -72,7 +72,7 @@ class SetDisjunctionPermission : public APIPermission {
CHECK(rhs->info() == info());
const SetDisjunctionPermission* perm =
static_cast<const SetDisjunctionPermission*>(rhs);
- scoped_ptr<SetDisjunctionPermission> result(new DerivedType(info()));
+ std::unique_ptr<SetDisjunctionPermission> result(new DerivedType(info()));
result->data_set_ = base::STLSetDifference<std::set<PermissionDataType> >(
data_set_, perm->data_set_);
return result->data_set_.empty() ? NULL : result.release();
@@ -82,7 +82,7 @@ class SetDisjunctionPermission : public APIPermission {
CHECK(rhs->info() == info());
const SetDisjunctionPermission* perm =
static_cast<const SetDisjunctionPermission*>(rhs);
- scoped_ptr<SetDisjunctionPermission> result(new DerivedType(info()));
+ std::unique_ptr<SetDisjunctionPermission> result(new DerivedType(info()));
result->data_set_ = base::STLSetUnion<std::set<PermissionDataType> >(
data_set_, perm->data_set_);
return result.release();
@@ -92,7 +92,7 @@ class SetDisjunctionPermission : public APIPermission {
CHECK(rhs->info() == info());
const SetDisjunctionPermission* perm =
static_cast<const SetDisjunctionPermission*>(rhs);
- scoped_ptr<SetDisjunctionPermission> result(new DerivedType(info()));
+ std::unique_ptr<SetDisjunctionPermission> result(new DerivedType(info()));
result->data_set_ = base::STLSetIntersection<std::set<PermissionDataType> >(
data_set_, perm->data_set_);
return result->data_set_.empty() ? NULL : result.release();
@@ -142,14 +142,18 @@ class SetDisjunctionPermission : public APIPermission {
return true;
}
- scoped_ptr<base::Value> ToValue() const override {
+ std::unique_ptr<base::Value> ToValue() const override {
base::ListValue* list = new base::ListValue();
typename std::set<PermissionDataType>::const_iterator i;
for (i = data_set_.begin(); i != data_set_.end(); ++i) {
- scoped_ptr<base::Value> item_value(i->ToValue());
+ std::unique_ptr<base::Value> item_value(i->ToValue());
list->Append(item_value.release());
}
- return scoped_ptr<base::Value>(list);
+ return std::unique_ptr<base::Value>(list);
+ }
+
+ void GetSize(base::PickleSizer* s) const override {
+ IPC::GetParamSize(s, data_set_);
}
void Write(base::Pickle* m) const override { IPC::WriteParam(m, data_set_); }
diff --git a/chromium/extensions/common/permissions/settings_override_permission.cc b/chromium/extensions/common/permissions/settings_override_permission.cc
index 69318d82939..b44d8810684 100644
--- a/chromium/extensions/common/permissions/settings_override_permission.cc
+++ b/chromium/extensions/common/permissions/settings_override_permission.cc
@@ -4,6 +4,9 @@
#include "extensions/common/permissions/settings_override_permission.h"
+#include <memory>
+
+#include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h"
#include "extensions/common/permissions/api_permission_set.h"
#include "grit/extensions_strings.h"
@@ -48,11 +51,18 @@ bool SettingsOverrideAPIPermission::FromValue(
const base::Value* value,
std::string* /*error*/,
std::vector<std::string>* unhandled_permissions) {
- return value && value->GetAsString(&setting_value_);
+ // Ugly hack: |value| being null should be an error. But before M46 beta, we
+ // didn't store the parameter for settings override permissions in prefs.
+ // See crbug.com/533086 and crbug.com/619759.
+ // TODO(treib,devlin): Remove this for M56, when hopefully all users will have
+ // updated prefs.
+ // This should read:
+ // return value && value->GetAsString(&setting_value_);
+ return !value || value->GetAsString(&setting_value_);
}
-scoped_ptr<base::Value> SettingsOverrideAPIPermission::ToValue() const {
- return make_scoped_ptr(new base::StringValue(setting_value_));
+std::unique_ptr<base::Value> SettingsOverrideAPIPermission::ToValue() const {
+ return base::WrapUnique(new base::StringValue(setting_value_));
}
APIPermission* SettingsOverrideAPIPermission::Clone() const {
@@ -77,6 +87,8 @@ APIPermission* SettingsOverrideAPIPermission::Intersect(
return new SettingsOverrideAPIPermission(info(), setting_value_);
}
+void SettingsOverrideAPIPermission::GetSize(base::PickleSizer* s) const {}
+
void SettingsOverrideAPIPermission::Write(base::Pickle* m) const {}
bool SettingsOverrideAPIPermission::Read(const base::Pickle* m,
diff --git a/chromium/extensions/common/permissions/settings_override_permission.h b/chromium/extensions/common/permissions/settings_override_permission.h
index 81a27305177..66e92d66750 100644
--- a/chromium/extensions/common/permissions/settings_override_permission.h
+++ b/chromium/extensions/common/permissions/settings_override_permission.h
@@ -28,11 +28,12 @@ class SettingsOverrideAPIPermission : public APIPermission {
bool FromValue(const base::Value* value,
std::string* error,
std::vector<std::string>* unhandled_permissions) override;
- scoped_ptr<base::Value> ToValue() const override;
+ std::unique_ptr<base::Value> ToValue() const override;
APIPermission* Clone() const override;
APIPermission* Diff(const APIPermission* rhs) const override;
APIPermission* Union(const APIPermission* rhs) const override;
APIPermission* Intersect(const APIPermission* rhs) const override;
+ void GetSize(base::PickleSizer* s) const override;
void Write(base::Pickle* m) const override;
bool Read(const base::Pickle* m, base::PickleIterator* iter) override;
void Log(std::string* log) const override;
diff --git a/chromium/extensions/common/permissions/socket_permission.cc b/chromium/extensions/common/permissions/socket_permission.cc
index a8e5c18f5ec..cee281b9cf5 100644
--- a/chromium/extensions/common/permissions/socket_permission.cc
+++ b/chromium/extensions/common/permissions/socket_permission.cc
@@ -5,9 +5,9 @@
#include "extensions/common/permissions/socket_permission.h"
#include <algorithm>
+#include <memory>
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "extensions/common/api/sockets/sockets_manifest_permission.h"
#include "extensions/common/permissions/permissions_info.h"
diff --git a/chromium/extensions/common/permissions/socket_permission_data.cc b/chromium/extensions/common/permissions/socket_permission_data.cc
index f22f14a1eb5..e4dbbdcc560 100644
--- a/chromium/extensions/common/permissions/socket_permission_data.cc
+++ b/chromium/extensions/common/permissions/socket_permission_data.cc
@@ -5,11 +5,11 @@
#include "extensions/common/permissions/socket_permission_data.h"
#include <cstdlib>
+#include <memory>
#include <sstream>
#include <vector>
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
@@ -102,8 +102,8 @@ bool SocketPermissionData::Check(const APIPermission::CheckParam* param) const {
return entry_.Check(request);
}
-scoped_ptr<base::Value> SocketPermissionData::ToValue() const {
- return scoped_ptr<base::Value>(new base::StringValue(GetAsString()));
+std::unique_ptr<base::Value> SocketPermissionData::ToValue() const {
+ return std::unique_ptr<base::Value>(new base::StringValue(GetAsString()));
}
bool SocketPermissionData::FromValue(const base::Value* value) {
diff --git a/chromium/extensions/common/permissions/socket_permission_data.h b/chromium/extensions/common/permissions/socket_permission_data.h
index f227f8d4c28..78518624545 100644
--- a/chromium/extensions/common/permissions/socket_permission_data.h
+++ b/chromium/extensions/common/permissions/socket_permission_data.h
@@ -55,7 +55,7 @@ class SocketPermissionData {
bool Check(const APIPermission::CheckParam* param) const;
// Convert |this| into a base::Value.
- scoped_ptr<base::Value> ToValue() const;
+ std::unique_ptr<base::Value> ToValue() const;
// Populate |this| from a base::Value.
bool FromValue(const base::Value* value);
diff --git a/chromium/extensions/common/permissions/socket_permission_entry.cc b/chromium/extensions/common/permissions/socket_permission_entry.cc
index a6fbb3b5b11..0bc963ea103 100644
--- a/chromium/extensions/common/permissions/socket_permission_entry.cc
+++ b/chromium/extensions/common/permissions/socket_permission_entry.cc
@@ -7,12 +7,12 @@
#include <stdint.h>
#include <cstdlib>
+#include <memory>
#include <sstream>
#include <tuple>
#include <vector>
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
diff --git a/chromium/extensions/common/permissions/socket_permission_unittest.cc b/chromium/extensions/common/permissions/socket_permission_unittest.cc
index 1ed207e814c..e6ac7dfddfb 100644
--- a/chromium/extensions/common/permissions/socket_permission_unittest.cc
+++ b/chromium/extensions/common/permissions/socket_permission_unittest.cc
@@ -125,7 +125,7 @@ TEST(SocketPermissionTest, Parse) {
TEST(SocketPermissionTest, Match) {
SocketPermissionData data;
- scoped_ptr<SocketPermission::CheckParam> param;
+ std::unique_ptr<SocketPermission::CheckParam> param;
CHECK(data.ParseForTest("tcp-connect"));
param.reset(new SocketPermission::CheckParam(
@@ -269,9 +269,9 @@ TEST(SocketPermissionTest, IPC) {
{
IPC::Message m;
- scoped_ptr<APIPermission> permission1(
+ std::unique_ptr<APIPermission> permission1(
permission_info->CreateAPIPermission());
- scoped_ptr<APIPermission> permission2(
+ std::unique_ptr<APIPermission> permission2(
permission_info->CreateAPIPermission());
permission1->Write(&m);
@@ -284,12 +284,12 @@ TEST(SocketPermissionTest, IPC) {
{
IPC::Message m;
- scoped_ptr<APIPermission> permission1(
+ std::unique_ptr<APIPermission> permission1(
permission_info->CreateAPIPermission());
- scoped_ptr<APIPermission> permission2(
+ std::unique_ptr<APIPermission> permission2(
permission_info->CreateAPIPermission());
- scoped_ptr<base::ListValue> value(new base::ListValue());
+ std::unique_ptr<base::ListValue> value(new base::ListValue());
value->AppendString("tcp-connect:*.example.com:80");
value->AppendString("udp-bind::8080");
value->AppendString("udp-send-to::8888");
@@ -308,10 +308,12 @@ TEST(SocketPermissionTest, Value) {
const APIPermissionInfo* permission_info =
PermissionsInfo::GetInstance()->GetByID(APIPermission::kSocket);
- scoped_ptr<APIPermission> permission1(permission_info->CreateAPIPermission());
- scoped_ptr<APIPermission> permission2(permission_info->CreateAPIPermission());
+ std::unique_ptr<APIPermission> permission1(
+ permission_info->CreateAPIPermission());
+ std::unique_ptr<APIPermission> permission2(
+ permission_info->CreateAPIPermission());
- scoped_ptr<base::ListValue> value(new base::ListValue());
+ std::unique_ptr<base::ListValue> value(new base::ListValue());
value->AppendString("tcp-connect:*.example.com:80");
value->AppendString("udp-bind::8080");
value->AppendString("udp-send-to::8888");
@@ -319,7 +321,7 @@ TEST(SocketPermissionTest, Value) {
EXPECT_FALSE(permission1->Equal(permission2.get()));
- scoped_ptr<base::Value> vtmp(permission1->ToValue());
+ std::unique_ptr<base::Value> vtmp(permission1->ToValue());
ASSERT_TRUE(vtmp);
ASSERT_TRUE(permission2->FromValue(vtmp.get(), NULL, NULL));
EXPECT_TRUE(permission1->Equal(permission2.get()));
diff --git a/chromium/extensions/common/permissions/usb_device_permission_data.cc b/chromium/extensions/common/permissions/usb_device_permission_data.cc
index 3d6817b72ca..eef44a68692 100644
--- a/chromium/extensions/common/permissions/usb_device_permission_data.cc
+++ b/chromium/extensions/common/permissions/usb_device_permission_data.cc
@@ -5,11 +5,11 @@
#include "extensions/common/permissions/usb_device_permission_data.h"
#include <limits>
+#include <memory>
#include <string>
#include <tuple>
#include <vector>
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/values.h"
@@ -49,12 +49,12 @@ bool UsbDevicePermissionData::Check(
interface_id_ == specific_param.interface_id);
}
-scoped_ptr<base::Value> UsbDevicePermissionData::ToValue() const {
+std::unique_ptr<base::Value> UsbDevicePermissionData::ToValue() const {
base::DictionaryValue* result = new base::DictionaryValue();
result->SetInteger(kVendorIdKey, vendor_id_);
result->SetInteger(kProductIdKey, product_id_);
result->SetInteger(kInterfaceIdKey, interface_id_);
- return scoped_ptr<base::Value>(result);
+ return std::unique_ptr<base::Value>(result);
}
bool UsbDevicePermissionData::FromValue(const base::Value* value) {
diff --git a/chromium/extensions/common/permissions/usb_device_permission_data.h b/chromium/extensions/common/permissions/usb_device_permission_data.h
index e72cc6c2b2a..a3e81299162 100644
--- a/chromium/extensions/common/permissions/usb_device_permission_data.h
+++ b/chromium/extensions/common/permissions/usb_device_permission_data.h
@@ -6,9 +6,9 @@
#include <stdint.h>
+#include <memory>
#include <string>
-#include "base/memory/scoped_ptr.h"
#include "extensions/common/permissions/api_permission.h"
namespace base {
@@ -45,7 +45,7 @@ class UsbDevicePermissionData {
bool Check(const APIPermission::CheckParam* param) const;
// Convert |this| into a base::Value.
- scoped_ptr<base::Value> ToValue() const;
+ std::unique_ptr<base::Value> ToValue() const;
// Populate |this| from a base::Value.
bool FromValue(const base::Value* value);
diff --git a/chromium/extensions/common/stack_frame.cc b/chromium/extensions/common/stack_frame.cc
index 046a2652250..497edac45ea 100644
--- a/chromium/extensions/common/stack_frame.cc
+++ b/chromium/extensions/common/stack_frame.cc
@@ -45,7 +45,7 @@ StackFrame::~StackFrame() {
// (We have to recognize two formats because V8 will report stack traces in
// both ways. If we reconcile this, we can clean this up.)
// static
-scoped_ptr<StackFrame> StackFrame::CreateFromText(
+std::unique_ptr<StackFrame> StackFrame::CreateFromText(
const base::string16& frame_text) {
// We need to use utf8 for re2 matching.
std::string text = base::UTF16ToUTF8(frame_text);
@@ -60,13 +60,11 @@ scoped_ptr<StackFrame> StackFrame::CreateFromText(
!re2::RE2::FullMatch(text,
"([^\\(\\)]+):(\\d+):(\\d+)",
&source, &line, &column)) {
- return scoped_ptr<StackFrame>();
+ return std::unique_ptr<StackFrame>();
}
- return scoped_ptr<StackFrame>(new StackFrame(line,
- column,
- base::UTF8ToUTF16(source),
- base::UTF8ToUTF16(function)));
+ return std::unique_ptr<StackFrame>(new StackFrame(
+ line, column, base::UTF8ToUTF16(source), base::UTF8ToUTF16(function)));
}
bool StackFrame::operator==(const StackFrame& rhs) const {
diff --git a/chromium/extensions/common/stack_frame.h b/chromium/extensions/common/stack_frame.h
index a55b8d82863..96b21fa5ad5 100644
--- a/chromium/extensions/common/stack_frame.h
+++ b/chromium/extensions/common/stack_frame.h
@@ -7,9 +7,9 @@
#include <stddef.h>
+#include <memory>
#include <vector>
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
namespace extensions {
@@ -24,7 +24,7 @@ struct StackFrame {
~StackFrame();
// Construct a stack frame from a reported plain-text frame.
- static scoped_ptr<StackFrame> CreateFromText(
+ static std::unique_ptr<StackFrame> CreateFromText(
const base::string16& frame_text);
bool operator==(const StackFrame& rhs) const;
diff --git a/chromium/extensions/common/stack_frame_unittest.cc b/chromium/extensions/common/stack_frame_unittest.cc
index 51f886774e5..2fba51b9211 100644
--- a/chromium/extensions/common/stack_frame_unittest.cc
+++ b/chromium/extensions/common/stack_frame_unittest.cc
@@ -6,8 +6,9 @@
#include <stddef.h>
+#include <memory>
+
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -24,7 +25,7 @@ void AssertStackFrameValid(const std::string& text,
const std::string& source,
const std::string& function) {
base::string16 utf16_text = base::UTF8ToUTF16(text);
- scoped_ptr<StackFrame> frame = StackFrame::CreateFromText(utf16_text);
+ std::unique_ptr<StackFrame> frame = StackFrame::CreateFromText(utf16_text);
ASSERT_TRUE(frame.get()) << "Failed to create frame from '" << text << "'";
EXPECT_EQ(line, frame->line_number);
@@ -35,7 +36,7 @@ void AssertStackFrameValid(const std::string& text,
void AssertStackFrameInvalid(const std::string& text) {
base::string16 utf16_text = base::UTF8ToUTF16(text);
- scoped_ptr<StackFrame> frame = StackFrame::CreateFromText(utf16_text);
+ std::unique_ptr<StackFrame> frame = StackFrame::CreateFromText(utf16_text);
ASSERT_FALSE(frame.get()) << "Errantly created frame from '" << text << "'";
}
diff --git a/chromium/extensions/common/switches.cc b/chromium/extensions/common/switches.cc
index 9f60f9619f6..793f1b4f5aa 100644
--- a/chromium/extensions/common/switches.cc
+++ b/chromium/extensions/common/switches.cc
@@ -58,6 +58,10 @@ const char kEnableOverrideBookmarksUI[] = "enable-override-bookmarks-ui";
const char kDisableTabForDesktopShare[] = "disable-tab-for-desktop-share";
const char kEnableTabForDesktopShare[] = "enable-tab-for-desktop-share";
+// Disable old UI for desktop capture picker window.
+const char kDisableDesktopCapturePickerOldUI[] =
+ "disable-desktop-capture-picker-old-ui";
+
// Allows the ErrorConsole to collect runtime and manifest errors, and display
// them in the chrome:extensions page.
const char kErrorConsole[] = "error-console";
diff --git a/chromium/extensions/common/switches.h b/chromium/extensions/common/switches.h
index a812c12d62f..72067619bfd 100644
--- a/chromium/extensions/common/switches.h
+++ b/chromium/extensions/common/switches.h
@@ -14,6 +14,7 @@ namespace switches {
extern const char kAllowHTTPBackgroundPage[];
extern const char kAllowLegacyExtensionManifests[];
extern const char kDisableDesktopCaptureAudio[];
+extern const char kDisableDesktopCapturePickerOldUI[];
extern const char kDisableTabForDesktopShare[];
extern const char kEmbeddedExtensionOptions[];
extern const char kEnableAppsShowOnFirstPaint[];
diff --git a/chromium/extensions/common/update_manifest.cc b/chromium/extensions/common/update_manifest.cc
index c8ebdf7961b..548bbe5b099 100644
--- a/chromium/extensions/common/update_manifest.cc
+++ b/chromium/extensions/common/update_manifest.cc
@@ -5,8 +5,8 @@
#include "extensions/common/update_manifest.h"
#include <algorithm>
+#include <memory>
-#include "base/memory/scoped_ptr.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
diff --git a/chromium/extensions/common/url_pattern_set.cc b/chromium/extensions/common/url_pattern_set.cc
index 5f09564f9f4..8a2de4a76d1 100644
--- a/chromium/extensions/common/url_pattern_set.cc
+++ b/chromium/extensions/common/url_pattern_set.cc
@@ -229,8 +229,8 @@ bool URLPatternSet::OverlapsWith(const URLPatternSet& other) const {
return false;
}
-scoped_ptr<base::ListValue> URLPatternSet::ToValue() const {
- scoped_ptr<base::ListValue> value(new base::ListValue);
+std::unique_ptr<base::ListValue> URLPatternSet::ToValue() const {
+ std::unique_ptr<base::ListValue> value(new base::ListValue);
for (URLPatternSet::const_iterator i = patterns_.begin();
i != patterns_.end(); ++i)
value->AppendIfNotPresent(new base::StringValue(i->GetAsString()));
@@ -262,8 +262,9 @@ bool URLPatternSet::Populate(const std::vector<std::string>& patterns,
return true;
}
-scoped_ptr<std::vector<std::string> > URLPatternSet::ToStringVector() const {
- scoped_ptr<std::vector<std::string> > value(new std::vector<std::string>);
+std::unique_ptr<std::vector<std::string>> URLPatternSet::ToStringVector()
+ const {
+ std::unique_ptr<std::vector<std::string>> value(new std::vector<std::string>);
for (URLPatternSet::const_iterator i = patterns_.begin();
i != patterns_.end();
++i) {
diff --git a/chromium/extensions/common/url_pattern_set.h b/chromium/extensions/common/url_pattern_set.h
index 717779ced5d..90b50f8bb36 100644
--- a/chromium/extensions/common/url_pattern_set.h
+++ b/chromium/extensions/common/url_pattern_set.h
@@ -8,9 +8,9 @@
#include <stddef.h>
#include <iosfwd>
+#include <memory>
#include <set>
-#include "base/memory/scoped_ptr.h"
#include "extensions/common/url_pattern.h"
class GURL;
@@ -99,14 +99,14 @@ class URLPatternSet {
bool OverlapsWith(const URLPatternSet& other) const;
// Converts to and from Value for serialization to preferences.
- scoped_ptr<base::ListValue> ToValue() const;
+ std::unique_ptr<base::ListValue> ToValue() const;
bool Populate(const base::ListValue& value,
int valid_schemes,
bool allow_file_access,
std::string* error);
// Converts to and from a vector of strings.
- scoped_ptr<std::vector<std::string> > ToStringVector() const;
+ std::unique_ptr<std::vector<std::string>> ToStringVector() const;
bool Populate(const std::vector<std::string>& patterns,
int valid_schemes,
bool allow_file_access,
diff --git a/chromium/extensions/common/url_pattern_set_unittest.cc b/chromium/extensions/common/url_pattern_set_unittest.cc
index 4d3af98bf68..bbb72aa7c5d 100644
--- a/chromium/extensions/common/url_pattern_set_unittest.cc
+++ b/chromium/extensions/common/url_pattern_set_unittest.cc
@@ -286,7 +286,7 @@ TEST(URLPatternSetTest, ToValueAndPopulate) {
std::string error;
bool allow_file_access = false;
- scoped_ptr<base::ListValue> value(set1.ToValue());
+ std::unique_ptr<base::ListValue> value(set1.ToValue());
set2.Populate(*value, URLPattern::SCHEME_ALL, allow_file_access, &error);
EXPECT_EQ(set1, set2);
@@ -463,7 +463,7 @@ TEST(URLPatternSetTest, ToStringVector) {
AddPattern(&set, "https://google.com/");
AddPattern(&set, "https://yahoo.com/");
- scoped_ptr<std::vector<std::string>> string_vector(set.ToStringVector());
+ std::unique_ptr<std::vector<std::string>> string_vector(set.ToStringVector());
EXPECT_EQ(2UL, string_vector->size());
diff --git a/chromium/extensions/common/url_pattern_unittest.cc b/chromium/extensions/common/url_pattern_unittest.cc
index f0965cace3a..87ce1a1d778 100644
--- a/chromium/extensions/common/url_pattern_unittest.cc
+++ b/chromium/extensions/common/url_pattern_unittest.cc
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "extensions/common/url_pattern.h"
+
#include <stddef.h>
+#include <memory>
+
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
-#include "extensions/common/url_pattern.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
diff --git a/chromium/extensions/common/user_script.h b/chromium/extensions/common/user_script.h
index 40ad3303a4e..d6b33770f7c 100644
--- a/chromium/extensions/common/user_script.h
+++ b/chromium/extensions/common/user_script.h
@@ -220,8 +220,6 @@ class UserScript {
bool is_incognito_enabled() const { return incognito_enabled_; }
void set_incognito_enabled(bool enabled) { incognito_enabled_ = enabled; }
- bool is_standalone() const { return extension_id().empty(); }
-
// Returns true if the script should be applied to the specified URL, false
// otherwise.
bool MatchesURL(const GURL& url) const;
diff --git a/chromium/extensions/common/value_builder.cc b/chromium/extensions/common/value_builder.cc
index efc2e44fad3..449fee9da3b 100644
--- a/chromium/extensions/common/value_builder.cc
+++ b/chromium/extensions/common/value_builder.cc
@@ -51,8 +51,9 @@ DictionaryBuilder& DictionaryBuilder::Set(const std::string& path,
return *this;
}
-DictionaryBuilder& DictionaryBuilder::Set(const std::string& path,
- scoped_ptr<base::Value> in_value) {
+DictionaryBuilder& DictionaryBuilder::Set(
+ const std::string& path,
+ std::unique_ptr<base::Value> in_value) {
dict_->SetWithoutPathExpansion(path, std::move(in_value));
return *this;
}
@@ -90,7 +91,7 @@ ListBuilder& ListBuilder::Append(const base::string16& in_value) {
return *this;
}
-ListBuilder& ListBuilder::Append(scoped_ptr<base::Value> in_value) {
+ListBuilder& ListBuilder::Append(std::unique_ptr<base::Value> in_value) {
list_->Append(std::move(in_value));
return *this;
}
diff --git a/chromium/extensions/common/value_builder.h b/chromium/extensions/common/value_builder.h
index 27c4e0165c6..4b4061bfe23 100644
--- a/chromium/extensions/common/value_builder.h
+++ b/chromium/extensions/common/value_builder.h
@@ -8,7 +8,7 @@
//
// The pattern is to write:
//
-// scoped_ptr<BuiltType> result(FooBuilder()
+// std::unique_ptr<BuiltType> result(FooBuilder()
// .Set(args)
// .Set(args)
// .Build());
@@ -23,11 +23,11 @@
#ifndef EXTENSIONS_COMMON_VALUE_BUILDER_H_
#define EXTENSIONS_COMMON_VALUE_BUILDER_H_
+#include <memory>
#include <string>
#include <utility>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
namespace base {
@@ -47,7 +47,7 @@ class DictionaryBuilder {
~DictionaryBuilder();
// Can only be called once, after which it's invalid to use the builder.
- scoped_ptr<base::DictionaryValue> Build() { return std::move(dict_); }
+ std::unique_ptr<base::DictionaryValue> Build() { return std::move(dict_); }
// Immediately serializes the current state to JSON. Can be called as many
// times as you like.
@@ -59,14 +59,14 @@ class DictionaryBuilder {
DictionaryBuilder& Set(const std::string& path,
const base::string16& in_value);
DictionaryBuilder& Set(const std::string& path,
- scoped_ptr<base::Value> in_value);
+ std::unique_ptr<base::Value> in_value);
// Named differently because overload resolution is too eager to
// convert implicitly to bool.
DictionaryBuilder& SetBoolean(const std::string& path, bool in_value);
private:
- scoped_ptr<base::DictionaryValue> dict_;
+ std::unique_ptr<base::DictionaryValue> dict_;
};
class ListBuilder {
@@ -76,20 +76,20 @@ class ListBuilder {
~ListBuilder();
// Can only be called once, after which it's invalid to use the builder.
- scoped_ptr<base::ListValue> Build() { return std::move(list_); }
+ std::unique_ptr<base::ListValue> Build() { return std::move(list_); }
ListBuilder& Append(int in_value);
ListBuilder& Append(double in_value);
ListBuilder& Append(const std::string& in_value);
ListBuilder& Append(const base::string16& in_value);
- ListBuilder& Append(scoped_ptr<base::Value> in_value);
+ ListBuilder& Append(std::unique_ptr<base::Value> in_value);
// Named differently because overload resolution is too eager to
// convert implicitly to bool.
ListBuilder& AppendBoolean(bool in_value);
private:
- scoped_ptr<base::ListValue> list_;
+ std::unique_ptr<base::ListValue> list_;
DISALLOW_COPY_AND_ASSIGN(ListBuilder);
};
diff --git a/chromium/extensions/common/value_builder_unittest.cc b/chromium/extensions/common/value_builder_unittest.cc
index 1f1c14e1abd..79267f0ccd3 100644
--- a/chromium/extensions/common/value_builder_unittest.cc
+++ b/chromium/extensions/common/value_builder_unittest.cc
@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "extensions/common/value_builder.h"
+
+#include <memory>
#include <utility>
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
-#include "extensions/common/value_builder.h"
#include "testing/gtest/include/gtest/gtest.h"
using ValueBuilderTest = testing::Test;
@@ -17,7 +18,7 @@ TEST(ValueBuilderTest, Basic) {
ListBuilder permission_list;
permission_list.Append("tabs").Append("history");
- scoped_ptr<base::DictionaryValue> settings(new base::DictionaryValue);
+ std::unique_ptr<base::DictionaryValue> settings(new base::DictionaryValue);
ASSERT_FALSE(settings->GetList("permissions", nullptr));
settings =
diff --git a/chromium/extensions/common/value_counter.cc b/chromium/extensions/common/value_counter.cc
index a4e49e0aab1..4bf04e138e0 100644
--- a/chromium/extensions/common/value_counter.cc
+++ b/chromium/extensions/common/value_counter.cc
@@ -5,17 +5,19 @@
#include "extensions/common/value_counter.h"
#include <algorithm>
+#include <memory>
#include <utility>
+#include "base/memory/ptr_util.h"
#include "base/values.h"
namespace extensions {
struct ValueCounter::Entry {
- explicit Entry(scoped_ptr<base::Value> value)
+ explicit Entry(std::unique_ptr<base::Value> value)
: value(std::move(value)), count(1) {}
- scoped_ptr<base::Value> value;
+ std::unique_ptr<base::Value> value;
int count;
};
@@ -32,7 +34,7 @@ bool ValueCounter::Add(const base::Value& value) {
return false;
}
}
- entries_.push_back(make_scoped_ptr(new Entry(value.CreateDeepCopy())));
+ entries_.push_back(base::WrapUnique(new Entry(value.CreateDeepCopy())));
return true;
}
diff --git a/chromium/extensions/common/value_counter.h b/chromium/extensions/common/value_counter.h
index b1137013fa9..f0a401d357d 100644
--- a/chromium/extensions/common/value_counter.h
+++ b/chromium/extensions/common/value_counter.h
@@ -5,10 +5,10 @@
#ifndef EXTENSIONS_COMMON_VALUE_COUNTER_H_
#define EXTENSIONS_COMMON_VALUE_COUNTER_H_
+#include <memory>
#include <vector>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
namespace base {
class Value;
@@ -42,7 +42,7 @@ class ValueCounter {
private:
struct Entry;
- std::vector<scoped_ptr<Entry>> entries_;
+ std::vector<std::unique_ptr<Entry>> entries_;
DISALLOW_COPY_AND_ASSIGN(ValueCounter);
};
diff --git a/chromium/extensions/components/javascript_dialog_extensions_client/javascript_dialog_extension_client_impl.cc b/chromium/extensions/components/javascript_dialog_extensions_client/javascript_dialog_extension_client_impl.cc
index d2f5d50518a..7d5f4a2c8c1 100644
--- a/chromium/extensions/components/javascript_dialog_extensions_client/javascript_dialog_extension_client_impl.cc
+++ b/chromium/extensions/components/javascript_dialog_extensions_client/javascript_dialog_extension_client_impl.cc
@@ -5,6 +5,7 @@
#include "extensions/components/javascript_dialog_extensions_client/javascript_dialog_extension_client_impl.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "components/app_modal/javascript_dialog_extensions_client.h"
#include "components/app_modal/javascript_dialog_manager.h"
#include "content/public/browser/web_contents.h"
@@ -80,7 +81,7 @@ class JavaScriptDialogExtensionsClientImpl
void InstallClient() {
app_modal::JavaScriptDialogManager::GetInstance()->
SetExtensionsClient(
- make_scoped_ptr(new JavaScriptDialogExtensionsClientImpl));
+ base::WrapUnique(new JavaScriptDialogExtensionsClientImpl));
}
} // namespace javascript_dialog_extensions_client
diff --git a/chromium/extensions/components/native_app_window/native_app_window_views.cc b/chromium/extensions/components/native_app_window/native_app_window_views.cc
index 1b6fa9e13aa..bcbe1f9d27e 100644
--- a/chromium/extensions/components/native_app_window/native_app_window_views.cc
+++ b/chromium/extensions/components/native_app_window/native_app_window_views.cc
@@ -374,7 +374,7 @@ SkRegion* NativeAppWindowViews::GetDraggableRegion() {
return draggable_region_.get();
}
-void NativeAppWindowViews::UpdateShape(scoped_ptr<SkRegion> region) {
+void NativeAppWindowViews::UpdateShape(std::unique_ptr<SkRegion> region) {
// Stub implementation. See also ChromeNativeAppWindowViews.
}
diff --git a/chromium/extensions/components/native_app_window/native_app_window_views.h b/chromium/extensions/components/native_app_window/native_app_window_views.h
index 0fa319653d1..fa35ef0141a 100644
--- a/chromium/extensions/components/native_app_window/native_app_window_views.h
+++ b/chromium/extensions/components/native_app_window/native_app_window_views.h
@@ -5,6 +5,8 @@
#ifndef EXTENSIONS_COMPONENTS_NATIVE_APP_WINDOW_NATIVE_APP_WINDOW_VIEWS_H_
#define EXTENSIONS_COMPONENTS_NATIVE_APP_WINDOW_NATIVE_APP_WINDOW_VIEWS_H_
+#include <memory>
+
#include "base/macros.h"
#include "base/observer_list.h"
#include "content/public/browser/web_contents_observer.h"
@@ -141,7 +143,7 @@ class NativeAppWindowViews : public extensions::NativeAppWindow,
void UpdateDraggableRegions(
const std::vector<extensions::DraggableRegion>& regions) override;
SkRegion* GetDraggableRegion() override;
- void UpdateShape(scoped_ptr<SkRegion> region) override;
+ void UpdateShape(std::unique_ptr<SkRegion> region) override;
void HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) override;
bool IsFrameless() const override;
@@ -173,7 +175,7 @@ class NativeAppWindowViews : public extensions::NativeAppWindow,
views::WebView* web_view_;
views::Widget* widget_;
- scoped_ptr<SkRegion> draggable_region_;
+ std::unique_ptr<SkRegion> draggable_region_;
bool frameless_;
bool resizable_;
diff --git a/chromium/extensions/extensions.gyp b/chromium/extensions/extensions.gyp
index 79deee14e07..a280a0ed1d1 100644
--- a/chromium/extensions/extensions.gyp
+++ b/chromium/extensions/extensions.gyp
@@ -38,7 +38,7 @@
'<@(extensions_common_mojo_sources)',
],
'conditions': [
- ['enable_wifi_display==1', {
+ ['proprietary_codecs==1 and enable_wifi_display==1', {
'sources': [
'<@(extensions_common_mojo_sources_wifi_display)',
],
@@ -64,6 +64,7 @@
'../third_party/re2/re2.gyp:re2',
'../ui/base/ui_base.gyp:ui_base',
'../ui/gfx/gfx.gyp:gfx_geometry',
+ '../ui/gfx/ipc/geometry/gfx_ipc_geometry.gyp:gfx_ipc_geometry',
'../ui/gfx/ipc/gfx_ipc.gyp:gfx_ipc',
'../ui/gfx/ipc/skia/gfx_ipc_skia.gyp:gfx_ipc_skia',
'../url/url.gyp:url_lib',
@@ -110,6 +111,7 @@
'../base/base.gyp:base',
'../base/base.gyp:base_i18n',
'../components/components.gyp:browsing_data',
+ '../components/components.gyp:cast_certificate',
'../components/components.gyp:device_event_log_component',
'../components/components.gyp:guest_view_browser',
'../components/components.gyp:keyed_service_content',
@@ -186,7 +188,7 @@
'<@(extensions_browser_sources_linux_nonchromeos)',
],
}],
- ['enable_wifi_display == 1', {
+ ['proprietary_codecs==1 and enable_wifi_display == 1', {
'sources': [
'<@(extensions_browser_sources_wifi_display)',
'<(SHARED_INTERMEDIATE_DIR)/extensions/common/mojo/wifi_display_session_service.mojom.cc',
@@ -219,8 +221,9 @@
# Disable c4267 warnings until we fix size_t to int truncations.
'msvs_disabled_warnings': [ 4267, ],
'conditions': [
- ['enable_wifi_display==1', {
+ ['proprietary_codecs==1 and enable_wifi_display==1', {
'dependencies': [
+ '../third_party/openh264/openh264.gyp:openh264_encoder',
'../third_party/wds/wds.gyp:libwds',
],
'sources': [
@@ -262,6 +265,7 @@
'../content/content_shell_and_tests.gyp:test_support_content',
'../net/net.gyp:net_test_support',
'../testing/gtest.gyp:gtest',
+ '../third_party/cld_2/cld_2.gyp:cld2_static',
'browser/api/api_registration.gyp:extensions_api_registration',
'common/api/api.gyp:cast_channel_proto',
'common/api/api.gyp:extensions_api',
@@ -278,12 +282,6 @@
],
# Disable c4267 warnings until we fix size_t to int truncations.
'msvs_disabled_warnings': [ 4267, ],
- 'conditions': [
- [ 'cld_version==2', {
- 'dependencies': [
- '<(DEPTH)/third_party/cld_2/cld_2.gyp:cld2_static', ],
- }],
- ],
},
{
# The pak file generated by this target is intended to be shared by
diff --git a/chromium/extensions/extensions.gypi b/chromium/extensions/extensions.gypi
index 7f00e251976..90fa39718ae 100644
--- a/chromium/extensions/extensions.gypi
+++ b/chromium/extensions/extensions.gypi
@@ -37,8 +37,6 @@
'common/api/sockets/sockets_manifest_handler.h',
'common/api/sockets/sockets_manifest_permission.cc',
'common/api/sockets/sockets_manifest_permission.h',
- 'common/cast/cast_cert_validator.cc',
- 'common/cast/cast_cert_validator.h',
'common/common_manifest_handlers.cc',
'common/common_manifest_handlers.h',
'common/csp_validator.cc',
@@ -761,6 +759,7 @@
'browser/updater/extension_downloader.h',
'browser/updater/extension_downloader_delegate.cc',
'browser/updater/extension_downloader_delegate.h',
+ 'browser/updater/extension_downloader_test_delegate.h',
'browser/updater/manifest_fetch_data.cc',
'browser/updater/manifest_fetch_data.h',
'browser/updater/null_extension_cache.cc',
@@ -861,6 +860,8 @@
'browser/api/networking_private/networking_private_linux.h',
],
'extensions_browser_sources_wifi_display': [
+ 'browser/api/display_source/wifi_display/wifi_display_media_service_impl.cc',
+ 'browser/api/display_source/wifi_display/wifi_display_media_service_impl.h',
'browser/api/display_source/wifi_display/wifi_display_session_service_impl.cc',
'browser/api/display_source/wifi_display/wifi_display_session_service_impl.h',
],
@@ -941,8 +942,6 @@
'renderer/native_handler.h',
'renderer/object_backed_native_handler.cc',
'renderer/object_backed_native_handler.h',
- 'renderer/print_native_handler.cc',
- 'renderer/print_native_handler.h',
'renderer/process_info_native_handler.cc',
'renderer/process_info_native_handler.h',
'renderer/programmatic_script_injector.cc',
@@ -1040,21 +1039,32 @@
'renderer/worker_script_context_set.h',
],
'extensions_renderer_sources_wifi_display': [
+ 'renderer/api/display_source/wifi_display/wifi_display_audio_encoder.cc',
+ 'renderer/api/display_source/wifi_display/wifi_display_audio_encoder.h',
+ 'renderer/api/display_source/wifi_display/wifi_display_audio_encoder_lpcm.cc',
'renderer/api/display_source/wifi_display/wifi_display_elementary_stream_descriptor.cc',
'renderer/api/display_source/wifi_display/wifi_display_elementary_stream_descriptor.h',
'renderer/api/display_source/wifi_display/wifi_display_elementary_stream_info.cc',
'renderer/api/display_source/wifi_display/wifi_display_elementary_stream_info.h',
'renderer/api/display_source/wifi_display/wifi_display_elementary_stream_packetizer.cc',
'renderer/api/display_source/wifi_display/wifi_display_elementary_stream_packetizer.h',
+ 'renderer/api/display_source/wifi_display/wifi_display_media_encoder.cc',
+ 'renderer/api/display_source/wifi_display/wifi_display_media_encoder.h',
'renderer/api/display_source/wifi_display/wifi_display_media_manager.cc',
'renderer/api/display_source/wifi_display/wifi_display_media_manager.h',
'renderer/api/display_source/wifi_display/wifi_display_media_packetizer.cc',
'renderer/api/display_source/wifi_display/wifi_display_media_packetizer.h',
+ 'renderer/api/display_source/wifi_display/wifi_display_media_pipeline.cc',
+ 'renderer/api/display_source/wifi_display/wifi_display_media_pipeline.h',
'renderer/api/display_source/wifi_display/wifi_display_session.cc',
'renderer/api/display_source/wifi_display/wifi_display_session.h',
'renderer/api/display_source/wifi_display/wifi_display_stream_packet_part.h',
'renderer/api/display_source/wifi_display/wifi_display_transport_stream_packetizer.cc',
'renderer/api/display_source/wifi_display/wifi_display_transport_stream_packetizer.h',
+ 'renderer/api/display_source/wifi_display/wifi_display_video_encoder.cc',
+ 'renderer/api/display_source/wifi_display/wifi_display_video_encoder.h',
+ 'renderer/api/display_source/wifi_display/wifi_display_video_encoder_svc.cc',
+ 'renderer/api/display_source/wifi_display/wifi_display_video_encoder_vea.cc',
],
'extensions_utility_sources': [
'utility/unpacker.cc',
diff --git a/chromium/extensions/extensions_tests.gyp b/chromium/extensions/extensions_tests.gyp
index bd131e025dd..1beb183822e 100644
--- a/chromium/extensions/extensions_tests.gyp
+++ b/chromium/extensions/extensions_tests.gyp
@@ -17,6 +17,7 @@
'dependencies': [
'../base/base.gyp:base',
'../base/base.gyp:test_support_base',
+ '../components/components.gyp:cast_certificate_test_support',
'../components/components.gyp:keyed_service_content',
'../components/components.gyp:pref_registry_test_support',
'../components/components.gyp:user_prefs',
@@ -26,10 +27,10 @@
'../device/hid/hid.gyp:device_hid',
'../device/serial/serial.gyp:device_serial',
'../device/serial/serial.gyp:device_serial_test_util',
- '../mojo/mojo_base.gyp:mojo_application_bindings',
'../mojo/mojo_edk.gyp:mojo_js_lib',
'../mojo/mojo_edk.gyp:mojo_system_impl',
'../mojo/mojo_public.gyp:mojo_cpp_bindings',
+ '../services/shell/shell_public.gyp:shell_public',
'../testing/gmock.gyp:gmock',
'../testing/gtest.gyp:gtest',
'../third_party/leveldatabase/leveldatabase.gyp:leveldatabase',
@@ -61,7 +62,7 @@
'browser/api/webcam_private/visca_webcam_unittest.cc',
],
}],
- ['enable_wifi_display==1', {
+ ['proprietary_codecs==1 and enable_wifi_display==1', {
'sources': [
'<@(extensions_unittests_sources_wifi_display)',
],
diff --git a/chromium/extensions/extensions_tests.gypi b/chromium/extensions/extensions_tests.gypi
index 4fa5de561d5..703b822ec78 100644
--- a/chromium/extensions/extensions_tests.gypi
+++ b/chromium/extensions/extensions_tests.gypi
@@ -8,6 +8,8 @@
'browser/api/audio/audio_apitest.cc',
'browser/api/bluetooth_socket/bluetooth_socket_apitest.cc',
'browser/api/display_source/display_source_apitest.cc',
+ 'browser/api/display_source/display_source_apitestbase.h',
+ 'browser/api/display_source/display_source_apitestbase.cc',
'browser/api/dns/dns_apitest.cc',
'browser/api/hid/hid_apitest.cc',
'browser/api/printer_provider/printer_provider_apitest.cc',
@@ -111,7 +113,6 @@
'common/api/declarative/declarative_manifest_unittest.cc',
'common/api/printer_provider/usb_printer_manifest_unittest.cc',
'common/api/sockets/sockets_manifest_permission_unittest.cc',
- 'common/cast/cast_cert_validator_unittest.cc',
'common/csp_validator_unittest.cc',
'common/event_filter_unittest.cc',
'common/extension_l10n_util_unittest.cc',
diff --git a/chromium/extensions/extensions_unittests.isolate b/chromium/extensions/extensions_unittests.isolate
index 8c10cccce62..6bfaba26191 100644
--- a/chromium/extensions/extensions_unittests.isolate
+++ b/chromium/extensions/extensions_unittests.isolate
@@ -38,6 +38,7 @@
'variables': {
'files': [
'../chrome/test/data/extensions/',
+ '../components/test/data/cast_certificate/',
'../testing/test_env.py',
'<(PRODUCT_DIR)/extensions_shell_and_test.pak',
'test/data/',
diff --git a/chromium/extensions/renderer/BUILD.gn b/chromium/extensions/renderer/BUILD.gn
index 1b8f7d0efbe..cdc9353ba8f 100644
--- a/chromium/extensions/renderer/BUILD.gn
+++ b/chromium/extensions/renderer/BUILD.gn
@@ -32,13 +32,16 @@ source_set("renderer") {
"//third_party/WebKit/public:blink",
]
- if (enable_wifi_display) {
+ if (proprietary_codecs && enable_wifi_display) {
wifi_display_sources = rebase_path(
extensions_gypi_values.extensions_renderer_sources_wifi_display,
".",
"//extensions")
sources += wifi_display_sources
- deps += [ "//third_party/wds:libwds" ]
+ deps += [
+ "//third_party/openh264:encoder",
+ "//third_party/wds:libwds",
+ ]
}
}
diff --git a/chromium/extensions/renderer/DEPS b/chromium/extensions/renderer/DEPS
index 6d1446295a6..bd0ed5251fc 100644
--- a/chromium/extensions/renderer/DEPS
+++ b/chromium/extensions/renderer/DEPS
@@ -13,8 +13,6 @@ include_rules = [
"+third_party/WebKit/public/platform",
"+third_party/WebKit/public/web",
- "+third_party/wds/src/libwds/public",
-
"+tools/json_schema_compiler",
"-v8",
diff --git a/chromium/extensions/renderer/activity_log_converter_strategy.cc b/chromium/extensions/renderer/activity_log_converter_strategy.cc
index f76f9558e84..301f2e2c24a 100644
--- a/chromium/extensions/renderer/activity_log_converter_strategy.cc
+++ b/chromium/extensions/renderer/activity_log_converter_strategy.cc
@@ -4,8 +4,9 @@
#include "extensions/renderer/activity_log_converter_strategy.h"
+#include <memory>
+
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "v8/include/v8.h"
@@ -16,8 +17,8 @@ namespace {
// Summarize a V8 value. This performs a shallow conversion in all cases, and
// returns only a string with a description of the value (e.g.,
// "[HTMLElement]").
-scoped_ptr<base::Value> SummarizeV8Value(v8::Isolate* isolate,
- v8::Local<v8::Object> object) {
+std::unique_ptr<base::Value> SummarizeV8Value(v8::Isolate* isolate,
+ v8::Local<v8::Object> object) {
v8::TryCatch try_catch(isolate);
v8::Isolate::DisallowJavascriptExecutionScope scope(
isolate, v8::Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE);
@@ -38,11 +39,11 @@ scoped_ptr<base::Value> SummarizeV8Value(v8::Isolate* isolate,
name = v8::String::Concat(name, v8::String::NewFromUtf8(isolate, "]"));
if (try_catch.HasCaught()) {
- return scoped_ptr<base::Value>(
+ return std::unique_ptr<base::Value>(
new base::StringValue("[JS Execution Exception]"));
}
- return scoped_ptr<base::Value>(
+ return std::unique_ptr<base::Value>(
new base::StringValue(std::string(*v8::String::Utf8Value(name))));
}
@@ -73,7 +74,7 @@ bool ActivityLogConverterStrategy::FromV8Internal(
base::Value** out,
v8::Isolate* isolate,
const FromV8ValueCallback& callback) const {
- scoped_ptr<base::Value> parsed_value;
+ std::unique_ptr<base::Value> parsed_value;
parsed_value = SummarizeV8Value(isolate, value);
*out = parsed_value.release();
diff --git a/chromium/extensions/renderer/activity_log_converter_strategy_unittest.cc b/chromium/extensions/renderer/activity_log_converter_strategy_unittest.cc
index fbb9597d661..33f0a5138d3 100644
--- a/chromium/extensions/renderer/activity_log_converter_strategy_unittest.cc
+++ b/chromium/extensions/renderer/activity_log_converter_strategy_unittest.cc
@@ -2,9 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/memory/scoped_ptr.h"
-#include "base/values.h"
#include "extensions/renderer/activity_log_converter_strategy.h"
+
+#include <memory>
+
+#include "base/values.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "v8/include/v8.h"
@@ -29,7 +31,7 @@ class ActivityLogConverterStrategyTest : public testing::Test {
}
testing::AssertionResult VerifyNull(v8::Local<v8::Value> v8_value) {
- scoped_ptr<base::Value> value(
+ std::unique_ptr<base::Value> value(
converter_->FromV8Value(v8_value, context()));
if (value->IsType(base::Value::TYPE_NULL))
return testing::AssertionSuccess();
@@ -39,7 +41,7 @@ class ActivityLogConverterStrategyTest : public testing::Test {
testing::AssertionResult VerifyBoolean(v8::Local<v8::Value> v8_value,
bool expected) {
bool out;
- scoped_ptr<base::Value> value(
+ std::unique_ptr<base::Value> value(
converter_->FromV8Value(v8_value, context()));
if (value->IsType(base::Value::TYPE_BOOLEAN)
&& value->GetAsBoolean(&out)
@@ -51,7 +53,7 @@ class ActivityLogConverterStrategyTest : public testing::Test {
testing::AssertionResult VerifyInteger(v8::Local<v8::Value> v8_value,
int expected) {
int out;
- scoped_ptr<base::Value> value(
+ std::unique_ptr<base::Value> value(
converter_->FromV8Value(v8_value, context()));
if (value->IsType(base::Value::TYPE_INTEGER)
&& value->GetAsInteger(&out)
@@ -63,7 +65,7 @@ class ActivityLogConverterStrategyTest : public testing::Test {
testing::AssertionResult VerifyDouble(v8::Local<v8::Value> v8_value,
double expected) {
double out;
- scoped_ptr<base::Value> value(
+ std::unique_ptr<base::Value> value(
converter_->FromV8Value(v8_value, context()));
if (value->IsType(base::Value::TYPE_DOUBLE)
&& value->GetAsDouble(&out)
@@ -75,7 +77,7 @@ class ActivityLogConverterStrategyTest : public testing::Test {
testing::AssertionResult VerifyString(v8::Local<v8::Value> v8_value,
const std::string& expected) {
std::string out;
- scoped_ptr<base::Value> value(
+ std::unique_ptr<base::Value> value(
converter_->FromV8Value(v8_value, context()));
if (value->IsType(base::Value::TYPE_STRING)
&& value->GetAsString(&out)
@@ -92,8 +94,8 @@ class ActivityLogConverterStrategyTest : public testing::Test {
v8::HandleScope handle_scope_;
v8::Global<v8::Context> context_;
v8::Context::Scope context_scope_;
- scoped_ptr<V8ValueConverter> converter_;
- scoped_ptr<ActivityLogConverterStrategy> strategy_;
+ std::unique_ptr<V8ValueConverter> converter_;
+ std::unique_ptr<ActivityLogConverterStrategy> strategy_;
};
TEST_F(ActivityLogConverterStrategyTest, ConversionTest) {
diff --git a/chromium/extensions/renderer/api/automation/automation_api_helper.cc b/chromium/extensions/renderer/api/automation/automation_api_helper.cc
index ab10682f6db..6123c3533ea 100644
--- a/chromium/extensions/renderer/api/automation/automation_api_helper.cc
+++ b/chromium/extensions/renderer/api/automation/automation_api_helper.cc
@@ -71,10 +71,9 @@ void AutomationApiHelper::OnQuerySelector(int request_id,
}
}
blink::WebString web_selector(selector);
- blink::WebExceptionCode ec = 0;
- blink::WebElement result_element = start_node.querySelector(web_selector, ec);
+ blink::WebElement result_element = start_node.querySelector(web_selector);
int result_acc_obj_id = 0;
- if (!ec && !result_element.isNull()) {
+ if (!result_element.isNull()) {
blink::WebAXObject result_acc_obj = result_element.accessibilityObject();
if (!result_acc_obj.isDetached()) {
while (result_acc_obj.accessibilityIsIgnored())
diff --git a/chromium/extensions/renderer/api/display_source/OWNERS b/chromium/extensions/renderer/api/display_source/OWNERS
index f7e4f6f8751..74b9e7de2e6 100644
--- a/chromium/extensions/renderer/api/display_source/OWNERS
+++ b/chromium/extensions/renderer/api/display_source/OWNERS
@@ -1,2 +1,3 @@
alexander.shalamov@intel.com
+eero.hakkinen@intel.com
mikhail.pozdnyakov@intel.com
diff --git a/chromium/extensions/renderer/api/display_source/display_source_session.cc b/chromium/extensions/renderer/api/display_source/display_source_session.cc
index 20b14420dd9..ae2b6754838 100644
--- a/chromium/extensions/renderer/api/display_source/display_source_session.cc
+++ b/chromium/extensions/renderer/api/display_source/display_source_session.cc
@@ -14,6 +14,9 @@ DisplaySourceSessionParams::DisplaySourceSessionParams()
: auth_method(api::display_source::AUTHENTICATION_METHOD_NONE) {
}
+DisplaySourceSessionParams::DisplaySourceSessionParams(
+ const DisplaySourceSessionParams&) = default;
+
DisplaySourceSessionParams::~DisplaySourceSessionParams() = default;
DisplaySourceSession::DisplaySourceSession()
@@ -32,12 +35,14 @@ void DisplaySourceSession::SetNotificationCallbacks(
error_callback_ = error_callback;
}
-scoped_ptr<DisplaySourceSession> DisplaySourceSessionFactory::CreateSession(
+std::unique_ptr<DisplaySourceSession>
+DisplaySourceSessionFactory::CreateSession(
const DisplaySourceSessionParams& params) {
#if defined(ENABLE_WIFI_DISPLAY)
- return scoped_ptr<DisplaySourceSession>(new WiFiDisplaySession(params));
-#endif
+ return std::unique_ptr<DisplaySourceSession>(new WiFiDisplaySession(params));
+#else
return nullptr;
+#endif
}
} // namespace extensions
diff --git a/chromium/extensions/renderer/api/display_source/display_source_session.h b/chromium/extensions/renderer/api/display_source/display_source_session.h
index 922126d994b..8758aa5e25d 100644
--- a/chromium/extensions/renderer/api/display_source/display_source_session.h
+++ b/chromium/extensions/renderer/api/display_source/display_source_session.h
@@ -5,9 +5,11 @@
#ifndef EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_SESSION_H_
#define EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_SESSION_H_
+#include <memory>
+#include <string>
+
#include "base/callback.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/common/api/display_source.h"
#include "third_party/WebKit/public/web/WebDOMMediaStreamTrack.h"
@@ -93,6 +95,7 @@ class DisplaySourceSession {
struct DisplaySourceSessionParams {
DisplaySourceSessionParams();
+ DisplaySourceSessionParams(const DisplaySourceSessionParams&);
~DisplaySourceSessionParams();
int sink_id;
@@ -105,8 +108,9 @@ struct DisplaySourceSessionParams {
class DisplaySourceSessionFactory {
public:
- static scoped_ptr<DisplaySourceSession> CreateSession(
+ static std::unique_ptr<DisplaySourceSession> CreateSession(
const DisplaySourceSessionParams& params);
+
private:
DISALLOW_COPY_AND_ASSIGN(DisplaySourceSessionFactory);
};
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/DEPS b/chromium/extensions/renderer/api/display_source/wifi_display/DEPS
new file mode 100644
index 00000000000..4e30f49a30a
--- /dev/null
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/DEPS
@@ -0,0 +1,7 @@
+include_rules = [
+ # TODO(Mikhail): Consider removing when https://crbug.com/432381 is fixed.
+ "+media/base",
+ "+media/video",
+ "+third_party/openh264/src/codec/api",
+ "+third_party/wds/src/libwds/public",
+]
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_audio_encoder.cc b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_audio_encoder.cc
new file mode 100644
index 00000000000..9ea450b6dd0
--- /dev/null
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_audio_encoder.cc
@@ -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.
+
+#include "extensions/renderer/api/display_source/wifi_display/wifi_display_audio_encoder.h"
+
+#include "base/logging.h"
+
+namespace extensions {
+
+WiFiDisplayAudioEncoder::WiFiDisplayAudioEncoder(
+ const wds::AudioCodec& audio_codec)
+ : audio_codec_(audio_codec) {}
+
+WiFiDisplayAudioEncoder::~WiFiDisplayAudioEncoder() = default;
+
+void WiFiDisplayAudioEncoder::Create(
+ const wds::AudioCodec& audio_codec,
+ const AudioEncoderCallback& encoder_callback) {
+ // Create a format specific encoder.
+ switch (audio_codec.format) {
+ case wds::LPCM:
+ CreateLPCM(audio_codec, encoder_callback);
+ return;
+ default:
+ break;
+ }
+
+ // Report failure.
+ encoder_callback.Run(nullptr);
+}
+
+size_t WiFiDisplayAudioEncoder::GetAudioCodecMode() const {
+ DCHECK_EQ(1u, audio_codec_.modes.count());
+ for (size_t mode = 0u; mode < audio_codec_.modes.size(); ++mode) {
+ if (audio_codec_.modes.test(mode))
+ return mode;
+ }
+ NOTREACHED();
+ return kInvalidCodecModeValue;
+}
+
+} // namespace extensions
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_audio_encoder.h b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_audio_encoder.h
new file mode 100644
index 00000000000..51c7aa73278
--- /dev/null
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_audio_encoder.h
@@ -0,0 +1,44 @@
+// 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 EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_AUDIO_ENCODER_H_
+#define EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_AUDIO_ENCODER_H_
+
+#include "content/public/renderer/media_stream_audio_sink.h"
+#include "extensions/renderer/api/display_source/wifi_display/wifi_display_media_encoder.h"
+#include "third_party/wds/src/libwds/public/audio_codec.h"
+
+namespace extensions {
+
+// This interface is a base class for audio used by the Wi-Fi Display media
+// pipeline.
+// Threading: the client code should belong to a single thread.
+class WiFiDisplayAudioEncoder : public WiFiDisplayMediaEncoder,
+ public content::MediaStreamAudioSink {
+ public:
+ using AudioEncoderCallback =
+ base::Callback<void(scoped_refptr<WiFiDisplayAudioEncoder>)>;
+
+ static void Create(const wds::AudioCodec& audio_codec,
+ const AudioEncoderCallback& encoder_callback);
+
+ protected:
+ static const size_t kInvalidCodecModeValue = ~static_cast<size_t>(0u);
+
+ // A factory method that creates a new encoder instance for Linear Pulse-Code
+ // Modulation (LPCM) audio encoding.
+ static void CreateLPCM(const wds::AudioCodec& audio_codec,
+ const AudioEncoderCallback& encoder_callback);
+
+ explicit WiFiDisplayAudioEncoder(const wds::AudioCodec& audio_codec);
+ ~WiFiDisplayAudioEncoder() override;
+
+ size_t GetAudioCodecMode() const;
+
+ const wds::AudioCodec audio_codec_;
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_AUDIO_ENCODER_H_
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_audio_encoder_lpcm.cc b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_audio_encoder_lpcm.cc
new file mode 100644
index 00000000000..4e91de25f99
--- /dev/null
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_audio_encoder_lpcm.cc
@@ -0,0 +1,237 @@
+// 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 "extensions/renderer/api/display_source/wifi_display/wifi_display_audio_encoder.h"
+
+#include <memory>
+#include <vector>
+
+#include "base/logging.h"
+#include "base/stl_util.h"
+#include "base/sys_byteorder.h"
+#include "extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_descriptor.h"
+#include "extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_info.h"
+#include "extensions/renderer/api/display_source/wifi_display/wifi_display_media_packetizer.h"
+#include "media/base/audio_bus.h"
+#include "media/base/audio_converter.h"
+#include "media/base/audio_parameters.h"
+
+namespace extensions {
+
+namespace {
+
+using LPCMAudioStreamDescriptor =
+ WiFiDisplayElementaryStreamDescriptor::LPCMAudioStream;
+
+// This audio encoder implements Linear Pulse-Code Modulation (LPCM) audio
+// encoding.
+class WiFiDisplayAudioEncoderLPCM final
+ : public WiFiDisplayAudioEncoder,
+ private media::AudioConverter::InputCallback {
+ public:
+ enum {
+ kOutputBitsPerSample = 16,
+ kOutputBytesPerSample = kOutputBitsPerSample / 8,
+ kOutputChannels = 2
+ };
+
+ explicit WiFiDisplayAudioEncoderLPCM(const wds::AudioCodec& audio_codec);
+
+ protected:
+ ~WiFiDisplayAudioEncoderLPCM() override = default;
+
+ // WiFiDisplayMediaEncoder
+ WiFiDisplayElementaryStreamInfo CreateElementaryStreamInfo() const override;
+
+ // content::MediaStreamAudioSink
+ void OnData(const media::AudioBus& input_bus,
+ base::TimeTicks estimated_capture_time) override;
+ void OnSetFormat(const media::AudioParameters& params) override;
+
+ // media::AudioConverter::InputCallback
+ double ProvideInput(media::AudioBus* audio_bus,
+ base::TimeDelta buffer_delay) override;
+
+ LPCMAudioStreamDescriptor::SamplingFrequency GetOutputSamplingFrequency()
+ const;
+
+ private:
+ const int output_sample_rate_;
+
+ // These members are accessed on the real-time audio time only.
+ std::unique_ptr<media::AudioConverter> converter_;
+ const media::AudioBus* current_input_bus_;
+ int64_t input_frames_in_;
+ media::AudioParameters input_params_;
+ std::unique_ptr<media::AudioBus> fifo_bus_;
+ int fifo_end_frame_;
+ int64_t fifo_frames_out_;
+};
+
+WiFiDisplayAudioEncoderLPCM::WiFiDisplayAudioEncoderLPCM(
+ const wds::AudioCodec& audio_codec)
+ : WiFiDisplayAudioEncoder(audio_codec),
+ output_sample_rate_(
+ GetOutputSamplingFrequency() ==
+ LPCMAudioStreamDescriptor::SAMPLING_FREQUENCY_48K
+ ? 48000
+ : 44100),
+ current_input_bus_(nullptr),
+ input_frames_in_(0),
+ fifo_end_frame_(0),
+ fifo_frames_out_(0) {}
+
+WiFiDisplayElementaryStreamInfo
+WiFiDisplayAudioEncoderLPCM::CreateElementaryStreamInfo() const {
+ DCHECK(client_thread_checker_.CalledOnValidThread());
+ std::vector<WiFiDisplayElementaryStreamDescriptor> descriptors;
+ descriptors.push_back(LPCMAudioStreamDescriptor::Create(
+ GetOutputSamplingFrequency(),
+ LPCMAudioStreamDescriptor::BITS_PER_SAMPLE_16,
+ false, // emphasis_flag
+ LPCMAudioStreamDescriptor::NUMBER_OF_CHANNELS_STEREO));
+ return WiFiDisplayElementaryStreamInfo(
+ WiFiDisplayElementaryStreamInfo::AUDIO_LPCM, std::move(descriptors));
+}
+
+// Called on real-time audio thread.
+void WiFiDisplayAudioEncoderLPCM::OnData(
+ const media::AudioBus& input_bus,
+ base::TimeTicks estimated_capture_time) {
+ DCHECK(input_params_.IsValid());
+ DCHECK_EQ(input_bus.channels(), input_params_.channels());
+ DCHECK_EQ(input_bus.frames(), input_params_.frames_per_buffer());
+ DCHECK(!estimated_capture_time.is_null());
+
+ const media::AudioBus* source_bus = &input_bus;
+
+ std::unique_ptr<media::AudioBus> converted_input_bus;
+ if (converter_) {
+ // Convert the entire input signal.
+ // Note that while the number of sample frames provided as input is always
+ // the same, the chunk size (and the size of the |converted_input_bus|
+ // here) can be variable.
+ converted_input_bus =
+ media::AudioBus::Create(kOutputChannels, converter_->ChunkSize());
+ current_input_bus_ = &input_bus;
+ converter_->Convert(converted_input_bus.get());
+ DCHECK(!current_input_bus_);
+ source_bus = converted_input_bus.get();
+ }
+
+ // Loop in order to handle frame number differences between |source_bus| and
+ // |fifo_bus_|.
+ int source_start_frame = 0;
+ do {
+ // Copy as many source frames (either raw or converted input frames) as
+ // possible to |fifo_bus_|.
+ int frame_count = std::min(source_bus->frames() - source_start_frame,
+ fifo_bus_->frames() - fifo_end_frame_);
+ DCHECK_GT(frame_count, 0);
+ source_bus->CopyPartialFramesTo(source_start_frame, frame_count,
+ fifo_end_frame_, fifo_bus_.get());
+ fifo_end_frame_ += frame_count;
+ source_start_frame += frame_count;
+
+ if (fifo_end_frame_ == fifo_bus_->frames()) {
+ // There are enough frames in |fifo_bus_| for one encoded unit.
+
+ // Determine the duration of the audio signal enqueued within
+ // |converter_| and |fifo_bus_|.
+ const base::TimeDelta signal_duration_already_buffered =
+ (input_frames_in_ * base::TimeDelta::FromSeconds(1) /
+ input_params_.sample_rate()) -
+ (fifo_frames_out_ * base::TimeDelta::FromSeconds(1) /
+ output_sample_rate_);
+ DVLOG(2) << "Audio reference time adjustment: -("
+ << signal_duration_already_buffered.InMicroseconds() << " us)";
+ const base::TimeTicks capture_time_of_first_converted_sample =
+ estimated_capture_time - signal_duration_already_buffered;
+
+ // Encode frames in |fifo_bus_|.
+ std::string data;
+ int sample_count = fifo_bus_->channels() * fifo_bus_->frames();
+ data.resize(sample_count * sizeof(uint16_t));
+ uint16_t* encoded_samples =
+ reinterpret_cast<uint16_t*>(string_as_array(&data));
+ fifo_bus_->ToInterleaved(fifo_bus_->frames(), kOutputBytesPerSample,
+ encoded_samples);
+ for (int i = 0; i < sample_count; ++i)
+ encoded_samples[i] = base::HostToNet16(encoded_samples[i]);
+ fifo_end_frame_ = 0;
+ fifo_frames_out_ += fifo_bus_->frames();
+
+ // Pass the encoded unit to the client.
+ encoded_callback_.Run(
+ std::unique_ptr<WiFiDisplayEncodedUnit>(new WiFiDisplayEncodedUnit(
+ std::move(data), capture_time_of_first_converted_sample, true)));
+ }
+ } while (source_start_frame < source_bus->frames());
+}
+
+// Called on real-time audio thread.
+void WiFiDisplayAudioEncoderLPCM::OnSetFormat(
+ const media::AudioParameters& params) {
+ if (input_params_.Equals(params))
+ return;
+ input_params_ = params;
+
+ if (output_sample_rate_ != input_params_.sample_rate()) {
+ const media::AudioParameters output_params(
+ media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
+ media::CHANNEL_LAYOUT_STEREO, output_sample_rate_, kOutputBitsPerSample,
+ WiFiDisplayMediaPacketizer::LPCM::kChannelSamplesPerUnit);
+ DVLOG(2) << "Setting up audio resampling: "
+ << input_params_.sample_rate() << " Hz --> "
+ << output_sample_rate_ << " Hz";
+ converter_.reset(
+ new media::AudioConverter(input_params_, output_params, false));
+ converter_->AddInput(this);
+ } else {
+ // Do not use an AudioConverter if that is not needed in order to avoid
+ // additional copyings caused by additional intermediate audio busses
+ // needed for capturing enough samples for each encoded unit.
+ converter_.reset();
+ }
+
+ fifo_bus_ = media::AudioBus::Create(
+ kOutputChannels,
+ WiFiDisplayMediaPacketizer::LPCM::kChannelSamplesPerUnit);
+ fifo_end_frame_ = 0;
+ fifo_frames_out_ = 0;
+ input_frames_in_ = 0;
+}
+
+// Called on real-time audio thread by |converter_| invoked by |OnData|.
+double WiFiDisplayAudioEncoderLPCM::ProvideInput(media::AudioBus* audio_bus,
+ base::TimeDelta buffer_delay) {
+ DCHECK(current_input_bus_);
+ current_input_bus_->CopyTo(audio_bus);
+ current_input_bus_ = nullptr;
+ return 1.0;
+}
+
+LPCMAudioStreamDescriptor::SamplingFrequency
+WiFiDisplayAudioEncoderLPCM::GetOutputSamplingFrequency() const {
+ switch (GetAudioCodecMode()) {
+ case wds::LPCM_44_1K_16B_2CH:
+ return LPCMAudioStreamDescriptor::SAMPLING_FREQUENCY_44_1K;
+ case wds::LPCM_48K_16B_2CH:
+ return LPCMAudioStreamDescriptor::SAMPLING_FREQUENCY_48K;
+ default:
+ NOTREACHED();
+ return LPCMAudioStreamDescriptor::SAMPLING_FREQUENCY_44_1K;
+ }
+}
+
+} // namespace
+
+void WiFiDisplayAudioEncoder::CreateLPCM(
+ const wds::AudioCodec& audio_codec,
+ const AudioEncoderCallback& encoder_callback) {
+ encoder_callback.Run(
+ make_scoped_refptr(new WiFiDisplayAudioEncoderLPCM(audio_codec)));
+}
+
+} // namespace extensions
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_descriptor.cc b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_descriptor.cc
index d17ca85056b..d14f7fe5d7c 100644
--- a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_descriptor.cc
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_descriptor.cc
@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/logging.h"
#include "extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_descriptor.h"
#include <cstring>
+#include "base/logging.h"
+
namespace extensions {
WiFiDisplayElementaryStreamDescriptor::WiFiDisplayElementaryStreamDescriptor(
@@ -69,12 +70,12 @@ WiFiDisplayElementaryStreamDescriptor::AVCTimingAndHRD::Create() {
WiFiDisplayElementaryStreamDescriptor
WiFiDisplayElementaryStreamDescriptor::AVCVideo::Create(
- uint8_t profile_idc,
+ Profile profile_idc,
bool constraint_set0_flag,
bool constraint_set1_flag,
bool constraint_set2_flag,
uint8_t avc_compatible_flags,
- uint8_t level_idc,
+ Level level_idc,
bool avc_still_present) {
const bool avc_24_hour_picture_flag = false;
WiFiDisplayElementaryStreamDescriptor descriptor(DESCRIPTOR_TAG_AVC_VIDEO,
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_descriptor.h b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_descriptor.h
index c149af851f8..c54305c8c2c 100644
--- a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_descriptor.h
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_descriptor.h
@@ -6,9 +6,10 @@
#define EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_ELEMENTARY_STREAM_DESCRIPTOR_H_
#include <stdint.h>
+
+#include <memory>
#include <type_traits>
-#include "base/memory/scoped_ptr.h"
namespace extensions {
@@ -57,13 +58,25 @@ class WiFiDisplayElementaryStreamDescriptor {
// AVC (Advanced Video Coding) video descriptor provides basic coding
// parameters for a video stream.
struct AVCVideo {
+ enum Level : uint8_t {
+ LEVEL_3_1 = 31u,
+ LEVEL_3_2 = 32u,
+ LEVEL_4 = 40u,
+ LEVEL_4_1 = 41u,
+ LEVEL_4_2 = 42u
+ };
+ enum Profile : uint8_t {
+ PROFILE_BASELINE = 66u,
+ PROFILE_MAIN = 77u,
+ PROFILE_HIGH = 100u
+ };
static WiFiDisplayElementaryStreamDescriptor Create(
- uint8_t profile_idc,
+ Profile profile_idc,
bool constraint_set0_flag,
bool constraint_set1_flag,
bool constraint_set2_flag,
uint8_t avc_compatible_flags,
- uint8_t level_idc,
+ Level level_idc,
bool avc_still_present);
};
@@ -77,7 +90,7 @@ class WiFiDisplayElementaryStreamDescriptor {
uint8_t* private_data() { return data() + kHeaderSize; }
private:
- scoped_ptr<uint8_t[]> data_;
+ std::unique_ptr<uint8_t[]> data_;
};
// LPCM (Linear pulse-code modulation) audio stream descriptor provides basic
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_descriptor_unittest.cc b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_descriptor_unittest.cc
index 4e049db9ba7..47a88762923 100644
--- a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_descriptor_unittest.cc
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_descriptor_unittest.cc
@@ -48,33 +48,42 @@ TEST(WiFiDisplayElementaryStreamDescriptorTest, AVCTimingAndHRDDescriptor) {
TEST(WiFiDisplayElementaryStreamDescriptorTest, AVCVideoDescriptor) {
using AVCVideoDescriptor = WiFiDisplayElementaryStreamDescriptor::AVCVideo;
- EXPECT_EQ(
- Data("\x28\x04\x00\x00\x00\x3F"),
- AVCVideoDescriptor::Create(0x0u, false, false, false, 0x0u, 0x0u, false));
- EXPECT_EQ(Data("\x28\x04\x00\x00\x00\x3F"),
- Copy(AVCVideoDescriptor::Create(0x0u, false, false, false, 0x0u,
- 0x0u, false)));
- EXPECT_EQ(Data("\x28\x04\xFF\x00\x00\x3F"),
- AVCVideoDescriptor::Create(0xFFu, false, false, false, 0x0u, 0x0u,
- false));
- EXPECT_EQ(
- Data("\x28\x04\x00\x80\x00\x3F"),
- AVCVideoDescriptor::Create(0x0u, true, false, false, 0x0u, 0x0u, false));
- EXPECT_EQ(
- Data("\x28\x04\x00\x40\x00\x3F"),
- AVCVideoDescriptor::Create(0x0u, false, true, false, 0x0u, 0x0u, false));
- EXPECT_EQ(
- Data("\x28\x04\x00\x20\x00\x3F"),
- AVCVideoDescriptor::Create(0x0u, false, false, true, 0x0u, 0x0u, false));
- EXPECT_EQ(Data("\x28\x04\x00\x1F\x00\x3F"),
- AVCVideoDescriptor::Create(0x0u, false, false, false, 0x1Fu, 0x0u,
- false));
- EXPECT_EQ(Data("\x28\x04\x00\x00\xFF\x3F"),
- AVCVideoDescriptor::Create(0x0u, false, false, false, 0x0u, 0xFFu,
- false));
- EXPECT_EQ(
- Data("\x28\x04\x00\x00\x00\xBF"),
- AVCVideoDescriptor::Create(0x0u, false, false, false, 0x0u, 0x0u, true));
+ EXPECT_EQ(Data("\x28\x04\x42\x00\x2A\x3F"),
+ AVCVideoDescriptor::Create(AVCVideoDescriptor::PROFILE_BASELINE,
+ false, false, false, 0x0u,
+ AVCVideoDescriptor::LEVEL_4_2, false));
+ EXPECT_EQ(Data("\x28\x04\x42\x00\x2A\x3F"),
+ Copy(AVCVideoDescriptor::Create(
+ AVCVideoDescriptor::PROFILE_BASELINE, false, false, false, 0x0u,
+ AVCVideoDescriptor::LEVEL_4_2, false)));
+ EXPECT_EQ(Data("\x28\x04\x64\x00\x2A\x3F"),
+ AVCVideoDescriptor::Create(AVCVideoDescriptor::PROFILE_HIGH, false,
+ false, false, 0x0u,
+ AVCVideoDescriptor::LEVEL_4_2, false));
+ EXPECT_EQ(Data("\x28\x04\x42\x80\x2A\x3F"),
+ AVCVideoDescriptor::Create(AVCVideoDescriptor::PROFILE_BASELINE,
+ true, false, false, 0x0u,
+ AVCVideoDescriptor::LEVEL_4_2, false));
+ EXPECT_EQ(Data("\x28\x04\x42\x40\x2A\x3F"),
+ AVCVideoDescriptor::Create(AVCVideoDescriptor::PROFILE_BASELINE,
+ false, true, false, 0x0u,
+ AVCVideoDescriptor::LEVEL_4_2, false));
+ EXPECT_EQ(Data("\x28\x04\x42\x20\x2A\x3F"),
+ AVCVideoDescriptor::Create(AVCVideoDescriptor::PROFILE_BASELINE,
+ false, false, true, 0x0u,
+ AVCVideoDescriptor::LEVEL_4_2, false));
+ EXPECT_EQ(Data("\x28\x04\x42\x1F\x2A\x3F"),
+ AVCVideoDescriptor::Create(AVCVideoDescriptor::PROFILE_BASELINE,
+ false, false, false, 0x1Fu,
+ AVCVideoDescriptor::LEVEL_4_2, false));
+ EXPECT_EQ(Data("\x28\x04\x42\x00\x1F\x3F"),
+ AVCVideoDescriptor::Create(AVCVideoDescriptor::PROFILE_BASELINE,
+ false, false, false, 0x0u,
+ AVCVideoDescriptor::LEVEL_3_1, false));
+ EXPECT_EQ(Data("\x28\x04\x42\x00\x2A\xBF"),
+ AVCVideoDescriptor::Create(AVCVideoDescriptor::PROFILE_BASELINE,
+ false, false, false, 0x0u,
+ AVCVideoDescriptor::LEVEL_4_2, true));
}
class LPCMAudioStreamDescriptorTest
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_packetizer.cc b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_packetizer.cc
index 39a6e3fcaf8..87c3d5c26df 100644
--- a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_packetizer.cc
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_packetizer.cc
@@ -15,13 +15,15 @@ namespace {
// specification.
namespace pes {
+const size_t kUnitDataAlignment = 4u;
+
const size_t kOptionalHeaderBaseSize = 3u;
const size_t kPacketHeaderBaseSize = 6u;
+const size_t kStuffingBytesMaxSize = kUnitDataAlignment - 1u;
const size_t kTimeStampSize = 5u;
const size_t kPacketHeaderMaxSize =
- kPacketHeaderBaseSize + kOptionalHeaderBaseSize + 2u * kTimeStampSize;
-
-const size_t kUnitDataAlignment = 4u;
+ kPacketHeaderBaseSize + kOptionalHeaderBaseSize + 2u * kTimeStampSize +
+ kStuffingBytesMaxSize;
size_t FillInTimeStamp(uint8_t* dst,
uint8_t pts_dts_indicator,
@@ -85,6 +87,7 @@ size_t FillInOptionalHeader(uint8_t* dst,
(kPacketHeaderBaseSize + i + unit_header_size) % kUnitDataAlignment;
if (remainder) {
const size_t n = kUnitDataAlignment - remainder;
+ DCHECK_LE(n, kStuffingBytesMaxSize);
std::memset(&dst[i], 0xFF, n);
i += n;
}
@@ -154,13 +157,12 @@ WiFiDisplayElementaryStreamPacket::WiFiDisplayElementaryStreamPacket(
WiFiDisplayElementaryStreamPacket::WiFiDisplayElementaryStreamPacket(
WiFiDisplayElementaryStreamPacket&& other)
- : header_(header_buffer_, other.header().size()),
- unit_header_(other.unit_header().data(), other.unit_header().size()),
- unit_(other.unit().data(), other.unit().size()) {
- // Copy the actual header data bytes from |other.header().data()| to
- // the |header_buffer_| member buffer used in the member initialization list.
- std::memcpy(header_buffer_, other.header().data(), header_.size());
-}
+ : WiFiDisplayElementaryStreamPacket(other.header_buffer_,
+ other.header_.size(),
+ other.unit_header_.data(),
+ other.unit_header_.size(),
+ other.unit_.data(),
+ other.unit_.size()) {}
// static
WiFiDisplayElementaryStreamPacket
@@ -180,6 +182,7 @@ WiFiDisplayElementaryStreamPacketizer::EncodeElementaryStreamUnit(
uint8_t header_data[pes::kPacketHeaderMaxSize];
size_t header_size = pes::FillInPacketHeader(header_data, stream_id, pts, dts,
unit_header_size, unit_size);
+ DCHECK_LE(header_size, sizeof(header_data));
return WiFiDisplayElementaryStreamPacket(header_data, header_size,
unit_header_data, unit_header_size,
unit_data, unit_size);
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_packetizer.h b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_packetizer.h
index 4201a58287d..d417eb31342 100644
--- a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_packetizer.h
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_packetizer.h
@@ -14,7 +14,7 @@ namespace extensions {
// Stream (PES) packet containing WiFi Display elementary stream unit data.
class WiFiDisplayElementaryStreamPacket {
public:
- using HeaderBuffer = uint8_t[19];
+ using HeaderBuffer = uint8_t[22];
WiFiDisplayElementaryStreamPacket(const HeaderBuffer& header_data,
size_t header_size,
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_encoder.cc b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_encoder.cc
new file mode 100644
index 00000000000..760f57b56ce
--- /dev/null
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_encoder.cc
@@ -0,0 +1,44 @@
+// 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 "extensions/renderer/api/display_source/wifi_display/wifi_display_media_encoder.h"
+
+#include "base/logging.h"
+#include "media/base/bind_to_current_loop.h"
+
+namespace extensions {
+
+WiFiDisplayEncodedUnit::WiFiDisplayEncodedUnit(
+ std::string data,
+ base::TimeTicks reference_timestamp,
+ bool key_frame)
+ : data(std::move(data)), pts(reference_timestamp), key_frame(key_frame) {}
+
+WiFiDisplayEncodedUnit::WiFiDisplayEncodedUnit(
+ std::string data,
+ base::TimeTicks reference_timestamp,
+ base::TimeTicks encode_timestamp,
+ bool key_frame)
+ : WiFiDisplayEncodedUnit(std::move(data), reference_timestamp, key_frame) {
+ if (encode_timestamp >= reference_timestamp) {
+ dts = reference_timestamp - (encode_timestamp - reference_timestamp);
+ DCHECK_LE(dts, pts);
+ }
+}
+
+WiFiDisplayMediaEncoder::WiFiDisplayMediaEncoder() = default;
+WiFiDisplayMediaEncoder::~WiFiDisplayMediaEncoder() = default;
+
+void WiFiDisplayMediaEncoder::SetCallbacks(
+ const EncodedUnitCallback& encoded_callback,
+ const base::Closure& error_callback) {
+ DCHECK(client_thread_checker_.CalledOnValidThread());
+ // This is not thread-safe if encoding has been started thus allow
+ // this to be called only once.
+ DCHECK(encoded_callback_.is_null() && error_callback_.is_null());
+ encoded_callback_ = media::BindToCurrentLoop(encoded_callback);
+ error_callback_ = media::BindToCurrentLoop(error_callback);
+}
+
+} // namespace extensions
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_encoder.h b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_encoder.h
new file mode 100644
index 00000000000..d205719a310
--- /dev/null
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_encoder.h
@@ -0,0 +1,81 @@
+// 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 EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_ENCODER_H_
+#define EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_ENCODER_H_
+
+#include <memory>
+#include <string>
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/move.h"
+#include "base/single_thread_task_runner.h"
+#include "base/threading/thread_checker.h"
+#include "extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_info.h"
+
+namespace extensions {
+
+// This structure represents an encoded media unit such as a video frame or
+// a number of audio frames.
+struct WiFiDisplayEncodedUnit {
+ WiFiDisplayEncodedUnit(std::string data,
+ base::TimeTicks reference_timestamp,
+ bool key_frame);
+ WiFiDisplayEncodedUnit(std::string data,
+ base::TimeTicks reference_timestamp,
+ base::TimeTicks encode_timestamp,
+ bool key_frame);
+
+ const uint8_t* bytes() const {
+ return reinterpret_cast<const uint8_t*>(data.data());
+ }
+ size_t size() const { return data.size(); }
+
+ std::string data;
+ base::TimeTicks pts; // Presentation timestamp.
+ base::TimeTicks dts; // Decoder timestamp.
+ bool key_frame;
+
+ DISALLOW_ASSIGN(WiFiDisplayEncodedUnit);
+ DISALLOW_COPY(WiFiDisplayEncodedUnit);
+};
+
+// This interface is a base class for audio and video encoders used by the
+// Wi-Fi Display media pipeline.
+// Threading: the client code should belong to a single thread.
+class WiFiDisplayMediaEncoder
+ : public base::RefCountedThreadSafe<WiFiDisplayMediaEncoder> {
+ public:
+ using EncodedUnitCallback =
+ base::Callback<void(std::unique_ptr<WiFiDisplayEncodedUnit>)>;
+
+ // Creates an elementary stream info describing the stream of encoded units
+ // which this encoder generates and passes to a callback set using
+ // |SetCallbacks|. The created elementary stream info should be passed to
+ // a Wi-Fi Display media packetizer.
+ virtual WiFiDisplayElementaryStreamInfo CreateElementaryStreamInfo()
+ const = 0;
+
+ // Sets callbacks for the obtained encoder instance:
+ // |encoded_callback| is invoked to return the next encoded unit
+ // |error_callback| is invoked to report a fatal encoder error
+ void SetCallbacks(const EncodedUnitCallback& encoded_callback,
+ const base::Closure& error_callback);
+
+ protected:
+ friend class base::RefCountedThreadSafe<WiFiDisplayMediaEncoder>;
+
+ WiFiDisplayMediaEncoder();
+ virtual ~WiFiDisplayMediaEncoder();
+
+ base::ThreadChecker client_thread_checker_;
+ EncodedUnitCallback encoded_callback_;
+ base::Closure error_callback_;
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_ENCODER_H_
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.cc b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.cc
index f77571d58a2..9895bb0db26 100644
--- a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.cc
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.cc
@@ -6,7 +6,16 @@
#include "base/logging.h"
#include "base/rand_util.h"
+#include "base/task_runner_util.h"
+#include "content/public/common/service_registry.h"
#include "content/public/renderer/media_stream_utils.h"
+#include "content/public/renderer/media_stream_video_sink.h"
+#include "content/public/renderer/render_thread.h"
+#include "content/public/renderer/video_encode_accelerator.h"
+#include "extensions/common/mojo/wifi_display_session_service.mojom.h"
+#include "extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_info.h"
+#include "extensions/renderer/api/display_source/wifi_display/wifi_display_media_pipeline.h"
+#include "media/base/bind_to_current_loop.h"
namespace extensions {
@@ -18,37 +27,147 @@ const char kErrorSinkCannotPlayVideo[] =
"The sink cannot play video from the given MediaStreamTrack object";
const char kErrorSinkCannotPlayAudio[] =
"The sink cannot play audio from the given MediaStreamTrack object";
+const char kErrorMediaPipelineFailure[] =
+ "Failed to initialize media pipeline for the session";
} // namespace
+class WiFiDisplayAudioSink {
+ public:
+ WiFiDisplayAudioSink(const blink::WebMediaStreamTrack& track,
+ content::MediaStreamAudioSink* delegate)
+ : track_(track), delegate_(delegate), sink_added_(false) {}
+
+ ~WiFiDisplayAudioSink() { Stop(); }
+
+ void Start() {
+ DCHECK(!sink_added_);
+ sink_added_ = true;
+ delegate_->AddToAudioTrack(delegate_, track_);
+ }
+
+ void Stop() {
+ if (sink_added_) {
+ delegate_->RemoveFromAudioTrack(delegate_, track_);
+ sink_added_ = false;
+ }
+ }
+
+ private:
+ blink::WebMediaStreamTrack track_;
+ content::MediaStreamAudioSink* delegate_;
+ bool sink_added_;
+};
+
+class WiFiDisplayVideoSink : public content::MediaStreamVideoSink {
+ public:
+ WiFiDisplayVideoSink(
+ const blink::WebMediaStreamTrack& track,
+ const content::VideoCaptureDeliverFrameCB& callback)
+ : track_(track),
+ callback_(callback) {
+ }
+
+ ~WiFiDisplayVideoSink() override {
+ DisconnectFromTrack();
+ }
+
+ void Start() {
+ // Callback is invoked on IO thread.
+ ConnectToTrack(track_, callback_);
+ }
+
+ private:
+ blink::WebMediaStreamTrack track_;
+ content::VideoCaptureDeliverFrameCB callback_;
+ DISALLOW_COPY_AND_ASSIGN(WiFiDisplayVideoSink);
+};
+
WiFiDisplayMediaManager::WiFiDisplayMediaManager(
const blink::WebMediaStreamTrack& video_track,
const blink::WebMediaStreamTrack& audio_track,
+ const std::string& sink_ip_address,
+ content::ServiceRegistry* service_registry,
const ErrorCallback& error_callback)
: video_track_(video_track),
audio_track_(audio_track),
- error_callback_(error_callback) {
+ service_registry_(service_registry),
+ sink_ip_address_(sink_ip_address),
+ player_(nullptr),
+ io_task_runner_(content::RenderThread::Get()->GetIOMessageLoopProxy()),
+ error_callback_(error_callback),
+ is_playing_(false),
+ is_initialized_(false),
+ weak_factory_(this) {
DCHECK(!video_track.isNull() || !audio_track.isNull());
+ DCHECK(service_registry_);
DCHECK(!error_callback_.is_null());
}
WiFiDisplayMediaManager::~WiFiDisplayMediaManager() {
+ Teardown();
}
void WiFiDisplayMediaManager::Play() {
- NOTIMPLEMENTED();
+ is_playing_ = true;
+ if (!player_) {
+ auto service_callback = base::Bind(
+ &WiFiDisplayMediaManager::RegisterMediaService,
+ base::Unretained(this),
+ base::ThreadTaskRunnerHandle::Get());
+ base::PostTaskAndReplyWithResult(io_task_runner_.get(), FROM_HERE,
+ base::Bind(
+ &WiFiDisplayMediaPipeline::Create,
+ GetSessionType(),
+ video_encoder_parameters_,
+ optimal_audio_codec_,
+ sink_ip_address_,
+ sink_rtp_ports_,
+ service_callback, // To be invoked on IO thread.
+ media::BindToCurrentLoop(error_callback_)),
+ base::Bind(&WiFiDisplayMediaManager::OnPlayerCreated,
+ weak_factory_.GetWeakPtr()));
+ return;
+ }
+
+ if (!is_initialized_) {
+ return; // Waiting for initialization being completed.
+ }
+
+ if (!audio_track_.isNull()) {
+ audio_sink_.reset(
+ new WiFiDisplayAudioSink(audio_track_, player_->audio_sink()));
+ audio_sink_->Start();
+ }
+
+ if (!video_track_.isNull()) {
+ // To be called on IO thread.
+ auto on_raw_video_frame = base::Bind(
+ &WiFiDisplayMediaPipeline::InsertRawVideoFrame,
+ base::Unretained(player_));
+ video_sink_.reset(
+ new WiFiDisplayVideoSink(video_track_, on_raw_video_frame));
+ video_sink_->Start();
+ }
}
void WiFiDisplayMediaManager::Teardown() {
- NOTIMPLEMENTED();
+ Pause();
+ if (player_) {
+ io_task_runner_->DeleteSoon(FROM_HERE, player_);
+ player_ = nullptr;
+ }
+ is_initialized_ = false;
+ session_id_.clear();
}
void WiFiDisplayMediaManager::Pause() {
- NOTIMPLEMENTED();
+ is_playing_ = false;
+ audio_sink_.reset();
+ video_sink_.reset();
}
bool WiFiDisplayMediaManager::IsPaused() const {
- NOTIMPLEMENTED();
- return true;
+ return !is_playing_;
}
wds::SessionType WiFiDisplayMediaManager::GetSessionType() const {
@@ -165,26 +284,26 @@ bool FindRateResolution(const media::VideoCaptureFormat* format,
return false;
}
-bool FindOptimalFormat(
+void FindCompatibleFormats(
const media::VideoCaptureFormat* capture_format,
const std::vector<wds::H264VideoCodec>& sink_supported_codecs,
- wds::H264VideoFormat* result /*out*/) {
+ std::vector<wds::H264VideoFormat>* result /*out*/) {
DCHECK(result);
for (const wds::H264VideoCodec& codec : sink_supported_codecs) {
+ wds::H264VideoFormat format;
bool found =
FindRateResolution<wds::CEA>(
- capture_format, codec.cea_rr, cea_table, result) ||
+ capture_format, codec.cea_rr, cea_table, &format) ||
FindRateResolution<wds::VESA>(
- capture_format, codec.vesa_rr, vesa_table, result) ||
+ capture_format, codec.vesa_rr, vesa_table, &format) ||
FindRateResolution<wds::HH>(
- capture_format, codec.hh_rr, hh_table, result);
+ capture_format, codec.hh_rr, hh_table, &format);
if (found) {
- result->profile = codec.profile;
- result->level = codec.level;
- return true;
+ format.profile = codec.profile;
+ format.level = codec.level;
+ result->emplace_back(format);
}
}
- return false;
}
} // namespace
@@ -193,14 +312,32 @@ wds::H264VideoFormat WiFiDisplayMediaManager::GetOptimalVideoFormat() const {
return optimal_video_format_;
}
-void WiFiDisplayMediaManager::SendIDRPicture() {
- NOTIMPLEMENTED();
+namespace {
+
+int GetBitRate(const gfx::Size& frame_size) {
+ DCHECK_GE(frame_size.height(), 360);
+ if (frame_size.height() < 720)
+ return 2500000;
+ if (frame_size.height() < 1080)
+ return 5000000;
+ return 8000000;
}
-std::string WiFiDisplayMediaManager::GetSessionId() const {
- return base::RandBytesAsString(8);
+void CreateVideoEncodeMemory(
+ size_t size,
+ const WiFiDisplayVideoEncoder::ReceiveEncodeMemoryCallback& callback) {
+ DCHECK(content::RenderThread::Get());
+
+ std::unique_ptr<base::SharedMemory> shm =
+ content::RenderThread::Get()->HostAllocateSharedMemoryBuffer(size);
+ if (!shm || !shm->Map(size)) {
+ NOTREACHED() << "Shared memory allocation or map failed";
+ }
+ callback.Run(std::move(shm));
}
+} // namespace
+
bool WiFiDisplayMediaManager::InitOptimalVideoFormat(
const wds::NativeVideoFormat& sink_native_format,
const std::vector<wds::H264VideoCodec>& sink_supported_codecs) {
@@ -211,12 +348,60 @@ bool WiFiDisplayMediaManager::InitOptimalVideoFormat(
return false;
}
- if (!FindOptimalFormat(
- capture_format, sink_supported_codecs, &optimal_video_format_)) {
+ std::vector<wds::H264VideoFormat> compatible_formats;
+
+ FindCompatibleFormats(
+ capture_format, sink_supported_codecs, &compatible_formats);
+
+ if (compatible_formats.empty()) {
+ error_callback_.Run(kErrorSinkCannotPlayVideo);
+ return false;
+ }
+
+ // The found compatible formats have the same frame rate and resolution but
+ // different video encoder profiles. Pick the appropriate profile from the
+ // supported by video encoder.
+ std::vector<wds::H264Profile> supported_profiles =
+ WiFiDisplayVideoEncoder::FindSupportedProfiles(
+ capture_format->frame_size,
+ capture_format->frame_rate);
+
+ if (supported_profiles.empty()) {
error_callback_.Run(kErrorSinkCannotPlayVideo);
return false;
}
+ bool profile_found = false;
+ for (wds::H264Profile profile : supported_profiles) {
+ if (profile_found)
+ break;
+
+ for (const auto& format : compatible_formats) {
+ if (format.profile == profile) {
+ optimal_video_format_ = format;
+ profile_found = true;
+ break;
+ }
+ }
+ }
+
+ if (!profile_found) {
+ error_callback_.Run(kErrorSinkCannotPlayVideo);
+ return false;
+ }
+
+ video_encoder_parameters_.frame_size = capture_format->frame_size;
+ video_encoder_parameters_.frame_rate =
+ static_cast<int>(capture_format->frame_rate);
+ video_encoder_parameters_.bit_rate = GetBitRate(capture_format->frame_size);
+ video_encoder_parameters_.profile = optimal_video_format_.profile;
+ video_encoder_parameters_.level = optimal_video_format_.level;
+ video_encoder_parameters_.create_memory_callback =
+ media::BindToCurrentLoop(base::Bind(&CreateVideoEncodeMemory));
+ video_encoder_parameters_.vea_create_callback =
+ media::BindToCurrentLoop(
+ base::Bind(&content::CreateVideoEncodeAccelerator));
+
return true;
}
@@ -244,4 +429,66 @@ wds::AudioCodec WiFiDisplayMediaManager::GetOptimalAudioFormat() const {
return optimal_audio_codec_;
}
+void WiFiDisplayMediaManager::SendIDRPicture() {
+ DCHECK(player_);
+ io_task_runner_->PostTask(FROM_HERE,
+ base::Bind(&WiFiDisplayMediaPipeline::RequestIDRPicture,
+ base::Unretained(player_)));
+}
+
+std::string WiFiDisplayMediaManager::GetSessionId() const {
+ if (session_id_.empty())
+ session_id_ = base::RandBytesAsString(8);
+ return session_id_;
+}
+
+void WiFiDisplayMediaManager::OnPlayerCreated(
+ std::unique_ptr<WiFiDisplayMediaPipeline> player) {
+ DCHECK(player);
+ DCHECK(content::RenderThread::Get());
+ player_ = player.release();
+
+ auto completion_callback = base::Bind(
+ &WiFiDisplayMediaManager::OnMediaPipelineInitialized,
+ weak_factory_.GetWeakPtr());
+
+ io_task_runner_->PostTask(FROM_HERE,
+ base::Bind(&WiFiDisplayMediaPipeline::Initialize,
+ base::Unretained(player_),
+ media::BindToCurrentLoop(completion_callback)));
+}
+
+void WiFiDisplayMediaManager::OnMediaPipelineInitialized(bool success) {
+ DCHECK(content::RenderThread::Get());
+ is_initialized_ = success;
+
+ if (!is_initialized_) {
+ error_callback_.Run(kErrorMediaPipelineFailure);
+ return;
+ }
+
+ if (is_playing_)
+ Play();
+}
+
+// Note: invoked on IO thread
+void WiFiDisplayMediaManager::RegisterMediaService(
+ const scoped_refptr<base::SingleThreadTaskRunner>& main_runner,
+ WiFiDisplayMediaServiceRequest request,
+ const base::Closure& on_completed) {
+ auto connect_service_callback =
+ base::Bind(&WiFiDisplayMediaManager::ConnectToRemoteService,
+ base::Unretained(this),
+ base::Passed(&request));
+ main_runner->PostTaskAndReply(FROM_HERE,
+ connect_service_callback,
+ media::BindToCurrentLoop(on_completed));
+}
+
+void WiFiDisplayMediaManager::ConnectToRemoteService(
+ WiFiDisplayMediaServiceRequest request) {
+ DCHECK(content::RenderThread::Get());
+ service_registry_->ConnectToRemoteService(std::move(request));
+}
+
} // namespace extensions
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.h b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.h
index 277771cb2bc..4506ff7564a 100644
--- a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.h
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_manager.h
@@ -2,19 +2,31 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_MANAGER_H_
-#define EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_MANAGER_H_
+#ifndef EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_MANAGER_H_
+#define EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_MANAGER_H_
+#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/callback.h"
-#include "base/macros.h"
-#include "third_party/WebKit/public/web/WebDOMMediaStreamTrack.h"
+#include "base/memory/weak_ptr.h"
+#include "extensions/common/mojo/wifi_display_session_service.mojom.h"
+#include "extensions/renderer/api/display_source/wifi_display/wifi_display_media_packetizer.h"
+#include "extensions/renderer/api/display_source/wifi_display/wifi_display_video_encoder.h"
+#include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
#include "third_party/wds/src/libwds/public/media_manager.h"
+namespace content {
+class ServiceRegistry;
+} // namespace content
+
namespace extensions {
+class WiFiDisplayAudioSink;
+class WiFiDisplayVideoSink;
+class WiFiDisplayMediaPipeline;
+class WiFiDisplaySessionService;
class WiFiDisplayMediaManager : public wds::SourceMediaManager {
public:
@@ -23,6 +35,8 @@ class WiFiDisplayMediaManager : public wds::SourceMediaManager {
WiFiDisplayMediaManager(
const blink::WebMediaStreamTrack& video_track,
const blink::WebMediaStreamTrack& audio_track,
+ const std::string& sink_ip_address,
+ content::ServiceRegistry* service_registry,
const ErrorCallback& error_callback);
~WiFiDisplayMediaManager() override;
@@ -52,18 +66,38 @@ class WiFiDisplayMediaManager : public wds::SourceMediaManager {
std::string GetSessionId() const override;
private:
+ void OnPlayerCreated(std::unique_ptr<WiFiDisplayMediaPipeline> player);
+ void OnMediaPipelineInitialized(bool success);
+ void RegisterMediaService(
+ const scoped_refptr<base::SingleThreadTaskRunner>& main_runner,
+ WiFiDisplayMediaServiceRequest service,
+ const base::Closure& on_completed);
+ void ConnectToRemoteService(WiFiDisplayMediaServiceRequest request);
blink::WebMediaStreamTrack video_track_;
blink::WebMediaStreamTrack audio_track_;
+ std::unique_ptr<WiFiDisplayAudioSink> audio_sink_;
+ std::unique_ptr<WiFiDisplayVideoSink> video_sink_;
+
+ content::ServiceRegistry* service_registry_;
+ std::string sink_ip_address_;
std::pair<int, int> sink_rtp_ports_;
wds::H264VideoFormat optimal_video_format_;
wds::AudioCodec optimal_audio_codec_;
+ WiFiDisplayVideoEncoder::InitParameters video_encoder_parameters_;
+ WiFiDisplayMediaPipeline* player_; // Owned on IO thread.
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
ErrorCallback error_callback_;
+ bool is_playing_;
+ bool is_initialized_;
+ mutable std::string session_id_; // Lazily initialized.
+
+ base::WeakPtrFactory<WiFiDisplayMediaManager> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(WiFiDisplayMediaManager);
};
} // namespace extensions
-#endif // EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_MANAGER_H_
+#endif // EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_MANAGER_H_
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_packetizer.cc b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_packetizer.cc
index f8f9cf23b5d..54c20ee591a 100644
--- a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_packetizer.cc
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_packetizer.cc
@@ -25,10 +25,10 @@ WiFiDisplayMediaDatagramPacket::WiFiDisplayMediaDatagramPacket(
WiFiDisplayMediaPacketizer::WiFiDisplayMediaPacketizer(
const base::TimeDelta& delay_for_unit_time_stamps,
- std::vector<WiFiDisplayElementaryStreamInfo> stream_infos,
+ const std::vector<WiFiDisplayElementaryStreamInfo>& stream_infos,
const PacketizedCallback& on_packetized)
: WiFiDisplayTransportStreamPacketizer(delay_for_unit_time_stamps,
- std::move(stream_infos)),
+ stream_infos),
on_packetized_media_datagram_packet_(on_packetized) {
// Sequence numbers are mainly used for detecting lossed packets within one
// RTP session. The initial value SHOULD be random (unpredictable) to make
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_packetizer.h b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_packetizer.h
index 23c07e08119..038ee2244e3 100644
--- a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_packetizer.h
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_packetizer.h
@@ -38,7 +38,7 @@ class WiFiDisplayMediaPacketizer : public WiFiDisplayTransportStreamPacketizer {
WiFiDisplayMediaPacketizer(
const base::TimeDelta& delay_for_unit_time_stamps,
- std::vector<WiFiDisplayElementaryStreamInfo> stream_infos,
+ const std::vector<WiFiDisplayElementaryStreamInfo>& stream_infos,
const PacketizedCallback& on_packetized);
~WiFiDisplayMediaPacketizer() override;
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_packetizer_unittest.cc b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_packetizer_unittest.cc
index 5253a1baa76..eae5c270f91 100644
--- a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_packetizer_unittest.cc
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_packetizer_unittest.cc
@@ -105,11 +105,12 @@ class FakeMediaPacketizer
: public WiFiDisplayMediaPacketizer,
public PacketCollector<std::vector<std::vector<uint8_t>>> {
public:
- FakeMediaPacketizer(const base::TimeDelta& delay_for_unit_time_stamps,
- std::vector<WiFiDisplayElementaryStreamInfo> stream_infos)
+ FakeMediaPacketizer(
+ const base::TimeDelta& delay_for_unit_time_stamps,
+ const std::vector<WiFiDisplayElementaryStreamInfo>& stream_infos)
: WiFiDisplayMediaPacketizer(
delay_for_unit_time_stamps,
- std::move(stream_infos),
+ stream_infos,
base::Bind(&FakeMediaPacketizer::OnPacketizedMediaDatagramPacket,
base::Unretained(this))) {}
@@ -137,9 +138,9 @@ class FakeTransportStreamPacketizer
public:
FakeTransportStreamPacketizer(
const base::TimeDelta& delay_for_unit_time_stamps,
- std::vector<WiFiDisplayElementaryStreamInfo> stream_infos)
+ const std::vector<WiFiDisplayElementaryStreamInfo>& stream_infos)
: WiFiDisplayTransportStreamPacketizer(delay_for_unit_time_stamps,
- std::move(stream_infos)) {}
+ stream_infos) {}
using WiFiDisplayTransportStreamPacketizer::NormalizeUnitTimeStamps;
@@ -151,12 +152,9 @@ class FakeTransportStreamPacketizer
headers_.emplace_back(transport_stream_packet.header().begin(),
transport_stream_packet.header().end());
const auto& header = headers_.back();
- if (transport_stream_packet.payload().empty()) {
- packets_.emplace_back(header.data(), header.size());
- } else {
- packets_.emplace_back(header.data(), header.size(),
- transport_stream_packet.payload().begin());
- }
+ const auto& payload = transport_stream_packet.payload();
+ packets_.emplace_back(header.data(), header.size(), payload.data(),
+ payload.size());
EXPECT_EQ(transport_stream_packet.header().size(),
packets_.back().header().size());
EXPECT_EQ(transport_stream_packet.payload().size(),
@@ -171,7 +169,8 @@ class FakeTransportStreamPacketizer
};
struct ProgramClockReference {
- enum { kInvalidBase = ~static_cast<uint64_t>(0u) };
+ static const uint64_t kInvalidBase = ~static_cast<uint64_t>(0u);
+
uint64_t base;
uint16_t extension;
};
@@ -400,18 +399,12 @@ class WiFiDisplayElementaryStreamUnitPacketizationTest
base::BigEndianReader header_reader(
reinterpret_cast<const char*>(packet.header().begin()),
packet.header().size());
-
CheckTransportStreamPacketHeader(
&header_reader, true, widi::kProgramAssociationTablePacketId, nullptr,
continuity_.program_assication_table++);
-
- EXPECT_EQ(PacketPart(kProgramAssicationTable),
- PacketPart(packet.header().end() - header_reader.remaining(),
- static_cast<size_t>(header_reader.remaining())));
- EXPECT_TRUE(header_reader.Skip(header_reader.remaining()));
-
EXPECT_EQ(0, header_reader.remaining());
- EXPECT_EQ(0u, packet.payload().size());
+
+ EXPECT_EQ(PacketPart(kProgramAssicationTable), packet.payload());
}
void CheckTransportStreamProgramMapTablePacket(
@@ -420,18 +413,12 @@ class WiFiDisplayElementaryStreamUnitPacketizationTest
base::BigEndianReader header_reader(
reinterpret_cast<const char*>(packet.header().begin()),
packet.header().size());
-
CheckTransportStreamPacketHeader(&header_reader, true,
widi::kProgramMapTablePacketId, nullptr,
continuity_.program_map_table++);
-
- EXPECT_EQ(program_map_table,
- PacketPart(packet.header().end() - header_reader.remaining(),
- static_cast<size_t>(header_reader.remaining())));
- EXPECT_TRUE(header_reader.Skip(header_reader.remaining()));
-
EXPECT_EQ(0, header_reader.remaining());
- EXPECT_EQ(0u, packet.payload().size());
+
+ EXPECT_EQ(program_map_table, packet.payload());
}
void CheckTransportStreamProgramClockReferencePacket(
@@ -574,14 +561,13 @@ TEST_P(WiFiDisplayElementaryStreamUnitPacketizationTest,
? WiFiDisplayElementaryStreamPacketizer::kFirstVideoStreamId
: WiFiDisplayElementaryStreamPacketizer::kFirstAudioStreamId;
- WiFiDisplayElementaryStreamPacketizer packetizer;
uint8_t unit_header_data[kMaxUnitHeaderSize];
for (size_t unit_header_size = 0u; unit_header_size <= kMaxUnitHeaderSize;
++unit_header_size) {
WiFiDisplayElementaryStreamPacket packet =
- packetizer.EncodeElementaryStreamUnit(stream_id, unit_header_data,
- unit_header_size, unit_.data(),
- unit_.size(), pts_, dts_);
+ WiFiDisplayElementaryStreamPacketizer::EncodeElementaryStreamUnit(
+ stream_id, unit_header_data, unit_header_size, unit_.data(),
+ unit_.size(), pts_, dts_);
CheckElementaryStreamPacketHeader(packet, stream_id);
CheckElementaryStreamPacketUnitHeader(packet, unit_header_data,
unit_header_size);
@@ -634,8 +620,8 @@ TEST_P(WiFiDisplayElementaryStreamUnitPacketizationTest,
10u, //
0x28u, // AVC video descriptor tag
4u, // Descriptor length
- 0xA5u,
- 0xF5u, 0xBDu, 0xBFu,
+ 0x42u,
+ 0xF5u, 0x2Au, 0xBFu,
0x2Au, // AVC timing and HRD descriptor tag
2u, // Descriptor length
0x7Eu, 0x1Fu,
@@ -662,8 +648,8 @@ TEST_P(WiFiDisplayElementaryStreamUnitPacketizationTest,
0u, // Elementary stream info length (10 bits)
0u, //
// CRC:
- 0x4Fu,
- 0x63u, 0xABu, 0x6Eu};
+ 0x3Du,
+ 0xAAu, 0x9Eu, 0x45u};
static const uint8_t kStreamIds[] = {
WiFiDisplayElementaryStreamPacketizer::kFirstVideoStreamId,
WiFiDisplayElementaryStreamPacketizer::kPrivateStream1Id,
@@ -677,7 +663,8 @@ TEST_P(WiFiDisplayElementaryStreamUnitPacketizationTest,
ESDescriptor::LPCMAudioStream::NUMBER_OF_CHANNELS_STEREO));
std::vector<ESDescriptor> video_desciptors;
video_desciptors.emplace_back(ESDescriptor::AVCVideo::Create(
- 0xA5u, true, true, true, 0x15u, 0xBDu, true));
+ ESDescriptor::AVCVideo::PROFILE_BASELINE, true, true, true, 0x15u,
+ ESDescriptor::AVCVideo::LEVEL_4_2, true));
video_desciptors.emplace_back(ESDescriptor::AVCTimingAndHRD::Create());
std::vector<WiFiDisplayElementaryStreamInfo> stream_infos;
stream_infos.emplace_back(WiFiDisplayElementaryStreamInfo::VIDEO_H264,
@@ -685,9 +672,8 @@ TEST_P(WiFiDisplayElementaryStreamUnitPacketizationTest,
stream_infos.emplace_back(WiFiDisplayElementaryStreamInfo::AUDIO_LPCM,
std::move(lpcm_descriptors));
stream_infos.emplace_back(WiFiDisplayElementaryStreamInfo::AUDIO_AAC);
- WiFiDisplayElementaryStreamPacketizer elementary_stream_packetizer;
FakeTransportStreamPacketizer packetizer(
- base::TimeDelta::FromMilliseconds(200), std::move(stream_infos));
+ base::TimeDelta::FromMilliseconds(200), stream_infos);
size_t packet_index = 0u;
for (unsigned stream_index = 0; stream_index < kStreamCount; ++stream_index) {
@@ -709,7 +695,7 @@ TEST_P(WiFiDisplayElementaryStreamUnitPacketizationTest,
auto normalized_dts = dts_;
packetizer.NormalizeUnitTimeStamps(&normalized_pts, &normalized_dts);
WiFiDisplayElementaryStreamPacket elementary_stream_packet =
- elementary_stream_packetizer.EncodeElementaryStreamUnit(
+ WiFiDisplayElementaryStreamPacketizer::EncodeElementaryStreamUnit(
kStreamIds[stream_index], unit_header_data, unit_header_size,
unit_.data(), unit_.size(), normalized_pts, normalized_dts);
@@ -771,7 +757,7 @@ TEST(WiFiDisplayTransportStreamPacketizationTest, EncodeToMediaDatagramPacket) {
std::vector<WiFiDisplayElementaryStreamInfo> stream_infos;
stream_infos.emplace_back(WiFiDisplayElementaryStreamInfo::VIDEO_H264);
FakeTransportStreamPacketizer transport_stream_packetizer(
- base::TimeDelta::FromMilliseconds(0), std::move(stream_infos));
+ base::TimeDelta::FromMilliseconds(0), stream_infos);
for (const auto& unit : units) {
EXPECT_TRUE(transport_stream_packetizer.EncodeElementaryStreamUnit(
0u, unit.data(), unit.size(), false, base::TimeTicks(),
@@ -796,7 +782,7 @@ TEST(WiFiDisplayTransportStreamPacketizationTest, EncodeToMediaDatagramPacket) {
// Check datagram packets.
ProgramClockReference pcr = {ProgramClockReference::kInvalidBase, 0u};
- uint16_t sequence_number;
+ uint16_t sequence_number = 0u;
uint32_t synchronization_source_identifier;
auto transport_stream_packet_it = transport_stream_packets.cbegin();
for (const auto& packet : packets) {
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_pipeline.cc b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_pipeline.cc
new file mode 100644
index 00000000000..c0c2048d349
--- /dev/null
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_pipeline.cc
@@ -0,0 +1,242 @@
+// 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 "extensions/renderer/api/display_source/wifi_display/wifi_display_media_pipeline.h"
+
+#include "base/logging.h"
+#include "content/public/renderer/render_thread.h"
+#include "content/public/renderer/video_encode_accelerator.h"
+
+namespace extensions {
+
+namespace {
+
+const char kErrorAudioEncoderError[] = "Unrepairable audio encoder error";
+const char kErrorVideoEncoderError[] = "Unrepairable video encoder error";
+const char kErrorUnableSendMedia[] = "Unable to send media";
+
+} // namespace
+
+WiFiDisplayMediaPipeline::WiFiDisplayMediaPipeline(
+ wds::SessionType type,
+ const WiFiDisplayVideoEncoder::InitParameters& video_parameters,
+ const wds::AudioCodec& audio_codec,
+ const std::string& sink_ip_address,
+ const std::pair<int, int>& sink_rtp_ports,
+ const RegisterMediaServiceCallback& service_callback,
+ const ErrorCallback& error_callback)
+ : type_(type),
+ video_parameters_(video_parameters),
+ audio_codec_(audio_codec),
+ sink_ip_address_(sink_ip_address),
+ sink_rtp_ports_(sink_rtp_ports),
+ service_callback_(service_callback),
+ error_callback_(error_callback),
+ weak_factory_(this) {
+}
+
+// static
+std::unique_ptr<WiFiDisplayMediaPipeline> WiFiDisplayMediaPipeline::Create(
+ wds::SessionType type,
+ const WiFiDisplayVideoEncoder::InitParameters& video_parameters,
+ const wds::AudioCodec& audio_codec,
+ const std::string& sink_ip_address,
+ const std::pair<int, int>& sink_rtp_ports,
+ const RegisterMediaServiceCallback& service_callback,
+ const ErrorCallback& error_callback) {
+ return std::unique_ptr<WiFiDisplayMediaPipeline>(
+ new WiFiDisplayMediaPipeline(type,
+ video_parameters,
+ audio_codec,
+ sink_ip_address,
+ sink_rtp_ports,
+ service_callback,
+ error_callback));
+}
+
+WiFiDisplayMediaPipeline::~WiFiDisplayMediaPipeline() {
+}
+
+void WiFiDisplayMediaPipeline::InsertRawVideoFrame(
+ const scoped_refptr<media::VideoFrame>& video_frame,
+ base::TimeTicks reference_time) {
+ DCHECK(video_encoder_);
+ video_encoder_->InsertRawVideoFrame(video_frame, reference_time);
+}
+
+void WiFiDisplayMediaPipeline::RequestIDRPicture() {
+ DCHECK(video_encoder_);
+ video_encoder_->RequestIDRPicture();
+}
+
+enum class WiFiDisplayMediaPipeline::InitializationStep : unsigned {
+ FIRST,
+ AUDIO_ENCODER = FIRST,
+ VIDEO_ENCODER,
+ MEDIA_PACKETIZER,
+ MEDIA_SERVICE,
+ LAST = MEDIA_SERVICE
+};
+
+void WiFiDisplayMediaPipeline::Initialize(
+ const InitCompletionCallback& callback) {
+ DCHECK(!audio_encoder_ && !video_encoder_ && !packetizer_);
+ OnInitialize(callback, InitializationStep::FIRST, true);
+}
+
+void WiFiDisplayMediaPipeline::OnInitialize(
+ const InitCompletionCallback& callback,
+ InitializationStep current_step,
+ bool success) {
+ if (!success) {
+ callback.Run(false);
+ return;
+ }
+
+ InitStepCompletionCallback init_step_callback;
+ if (current_step < InitializationStep::LAST) {
+ InitializationStep next_step = static_cast<InitializationStep>(
+ static_cast<unsigned>(current_step) + 1u);
+ init_step_callback =
+ base::Bind(&WiFiDisplayMediaPipeline::OnInitialize,
+ weak_factory_.GetWeakPtr(), callback, next_step);
+ }
+
+ switch (current_step) {
+ case InitializationStep::AUDIO_ENCODER:
+ DCHECK(!audio_encoder_);
+ if (type_ & wds::AudioSession) {
+ auto result_callback =
+ base::Bind(&WiFiDisplayMediaPipeline::OnAudioEncoderCreated,
+ weak_factory_.GetWeakPtr(), init_step_callback);
+ WiFiDisplayAudioEncoder::Create(audio_codec_, result_callback);
+ } else {
+ init_step_callback.Run(true);
+ }
+ break;
+ case InitializationStep::VIDEO_ENCODER:
+ DCHECK(!video_encoder_);
+ if (type_ & wds::VideoSession) {
+ auto result_callback =
+ base::Bind(&WiFiDisplayMediaPipeline::OnVideoEncoderCreated,
+ weak_factory_.GetWeakPtr(), init_step_callback);
+ WiFiDisplayVideoEncoder::Create(video_parameters_, result_callback);
+ } else {
+ init_step_callback.Run(true);
+ }
+ break;
+ case InitializationStep::MEDIA_PACKETIZER:
+ DCHECK(!packetizer_);
+ CreateMediaPacketizer();
+ init_step_callback.Run(true);
+ break;
+ case InitializationStep::MEDIA_SERVICE:
+ service_callback_.Run(
+ mojo::GetProxy(&media_service_),
+ base::Bind(&WiFiDisplayMediaPipeline::OnMediaServiceRegistered,
+ weak_factory_.GetWeakPtr(), callback));
+ break;
+ }
+}
+
+void WiFiDisplayMediaPipeline::CreateMediaPacketizer() {
+ DCHECK(!packetizer_);
+ std::vector<WiFiDisplayElementaryStreamInfo> stream_infos;
+
+ if (type_ & wds::VideoSession) {
+ DCHECK(video_encoder_);
+ stream_infos.push_back(video_encoder_->CreateElementaryStreamInfo());
+ }
+
+ if (type_ & wds::AudioSession) {
+ DCHECK(audio_encoder_);
+ stream_infos.push_back(audio_encoder_->CreateElementaryStreamInfo());
+ }
+
+ packetizer_.reset(new WiFiDisplayMediaPacketizer(
+ base::TimeDelta::FromMilliseconds(200), stream_infos,
+ base::Bind(&WiFiDisplayMediaPipeline::OnPacketizedMediaDatagramPacket,
+ base::Unretained(this))));
+}
+
+void WiFiDisplayMediaPipeline::OnAudioEncoderCreated(
+ const InitStepCompletionCallback& callback,
+ scoped_refptr<WiFiDisplayAudioEncoder> audio_encoder) {
+ DCHECK(!audio_encoder_);
+
+ if (!audio_encoder) {
+ callback.Run(false);
+ return;
+ }
+
+ audio_encoder_ = std::move(audio_encoder);
+ auto encoded_callback =
+ base::Bind(&WiFiDisplayMediaPipeline::OnEncodedAudioUnit,
+ weak_factory_.GetWeakPtr());
+ auto error_callback = base::Bind(error_callback_, kErrorAudioEncoderError);
+ audio_encoder_->SetCallbacks(encoded_callback, error_callback);
+
+ callback.Run(true);
+}
+
+void WiFiDisplayMediaPipeline::OnVideoEncoderCreated(
+ const InitStepCompletionCallback& callback,
+ scoped_refptr<WiFiDisplayVideoEncoder> video_encoder) {
+ DCHECK(!video_encoder_);
+
+ if (!video_encoder) {
+ callback.Run(false);
+ return;
+ }
+
+ video_encoder_ = std::move(video_encoder);
+ auto encoded_callback = base::Bind(
+ &WiFiDisplayMediaPipeline::OnEncodedVideoFrame,
+ weak_factory_.GetWeakPtr());
+ auto error_callback = base::Bind(error_callback_, kErrorVideoEncoderError);
+ video_encoder_->SetCallbacks(encoded_callback, error_callback);
+
+ callback.Run(true);
+}
+
+void WiFiDisplayMediaPipeline::OnMediaServiceRegistered(
+ const InitCompletionCallback& callback) {
+ DCHECK(media_service_);
+ auto error_callback = base::Bind(error_callback_, kErrorUnableSendMedia);
+ media_service_.set_connection_error_handler(error_callback);
+ media_service_->SetDesinationPoint(
+ sink_ip_address_,
+ static_cast<int32_t>(sink_rtp_ports_.first),
+ callback);
+}
+
+void WiFiDisplayMediaPipeline::OnEncodedAudioUnit(
+ std::unique_ptr<WiFiDisplayEncodedFrame> unit) {
+ DCHECK(packetizer_);
+ const unsigned stream_index = (type_ & wds::VideoSession) ? 1u : 0u;
+ if (!packetizer_->EncodeElementaryStreamUnit(stream_index, unit->bytes(),
+ unit->size(), unit->key_frame,
+ unit->pts, unit->dts, true)) {
+ DVLOG(1) << "Couldn't write audio mpegts packet";
+ }
+}
+
+void WiFiDisplayMediaPipeline::OnEncodedVideoFrame(
+ std::unique_ptr<WiFiDisplayEncodedFrame> frame) {
+ DCHECK(packetizer_);
+ if (!packetizer_->EncodeElementaryStreamUnit(0u, frame->bytes(),
+ frame->size(), frame->key_frame,
+ frame->pts, frame->dts, true)) {
+ DVLOG(1) << "Couldn't write video mpegts packet";
+ }
+}
+
+bool WiFiDisplayMediaPipeline::OnPacketizedMediaDatagramPacket(
+ WiFiDisplayMediaDatagramPacket media_datagram_packet) {
+ DCHECK(media_service_);
+ media_service_->SendMediaPacket(std::move(media_datagram_packet));
+ return true;
+}
+
+} // namespace extensions
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_pipeline.h b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_pipeline.h
new file mode 100644
index 00000000000..1ce9ab04cef
--- /dev/null
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_media_pipeline.h
@@ -0,0 +1,114 @@
+// 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 EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_PIPELINE_H_
+#define EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_PIPELINE_H_
+
+#include <memory>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "base/callback.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "base/synchronization/lock.h"
+#include "extensions/common/mojo/wifi_display_session_service.mojom.h"
+#include "extensions/renderer/api/display_source/wifi_display/wifi_display_audio_encoder.h"
+#include "extensions/renderer/api/display_source/wifi_display/wifi_display_media_packetizer.h"
+#include "extensions/renderer/api/display_source/wifi_display/wifi_display_video_encoder.h"
+#include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
+#include "third_party/wds/src/libwds/public/media_manager.h"
+
+namespace media {
+class AudioBus;
+} // namespace media
+
+namespace extensions {
+
+// This class encapsulates the WiFi Display media pipeline including
+// - encoding
+// - AV multiplexing/packetization
+// - sending
+// Threading: should belong to IO thread.
+class WiFiDisplayMediaPipeline {
+ public:
+ using ErrorCallback = base::Callback<void(const std::string&)>;
+ using InitCompletionCallback = base::Callback<void(bool)>;
+ using RegisterMediaServiceCallback =
+ base::Callback<void(WiFiDisplayMediaServiceRequest, const base::Closure&)>;
+
+ static std::unique_ptr<WiFiDisplayMediaPipeline> Create(
+ wds::SessionType type,
+ const WiFiDisplayVideoEncoder::InitParameters& video_parameters,
+ const wds::AudioCodec& audio_codec,
+ const std::string& sink_ip_address,
+ const std::pair<int, int>& sink_rtp_ports,
+ const RegisterMediaServiceCallback& service_callback,
+ const ErrorCallback& error_callback);
+ ~WiFiDisplayMediaPipeline();
+ // Note: to be called only once.
+ void Initialize(const InitCompletionCallback& callback);
+
+ void InsertRawVideoFrame(
+ const scoped_refptr<media::VideoFrame>& video_frame,
+ base::TimeTicks reference_time);
+
+ void RequestIDRPicture();
+
+ WiFiDisplayAudioEncoder* audio_sink() { return audio_encoder_.get(); }
+
+ private:
+ using InitStepCompletionCallback = InitCompletionCallback;
+ enum class InitializationStep : unsigned;
+
+ WiFiDisplayMediaPipeline(
+ wds::SessionType type,
+ const WiFiDisplayVideoEncoder::InitParameters& video_parameters,
+ const wds::AudioCodec& audio_codec,
+ const std::string& sink_ip_address,
+ const std::pair<int, int>& sink_rtp_ports,
+ const RegisterMediaServiceCallback& service_callback,
+ const ErrorCallback& error_callback);
+
+ void CreateMediaPacketizer();
+ void OnInitialize(const InitCompletionCallback& callback,
+ InitializationStep current_step,
+ bool success);
+ void OnAudioEncoderCreated(
+ const InitStepCompletionCallback& callback,
+ scoped_refptr<WiFiDisplayAudioEncoder> audio_encoder);
+ void OnVideoEncoderCreated(
+ const InitStepCompletionCallback& callback,
+ scoped_refptr<WiFiDisplayVideoEncoder> video_encoder);
+ void OnMediaServiceRegistered(const InitCompletionCallback& callback);
+
+ void OnEncodedAudioUnit(std::unique_ptr<WiFiDisplayEncodedUnit> unit);
+ void OnEncodedVideoFrame(std::unique_ptr<WiFiDisplayEncodedFrame> frame);
+
+ bool OnPacketizedMediaDatagramPacket(
+ WiFiDisplayMediaDatagramPacket media_datagram_packet);
+
+ scoped_refptr<WiFiDisplayAudioEncoder> audio_encoder_;
+ scoped_refptr<WiFiDisplayVideoEncoder> video_encoder_;
+ std::unique_ptr<WiFiDisplayMediaPacketizer> packetizer_;
+
+ wds::SessionType type_;
+ WiFiDisplayVideoEncoder::InitParameters video_parameters_;
+ wds::AudioCodec audio_codec_;
+ std::string sink_ip_address_;
+ std::pair<int, int> sink_rtp_ports_;
+
+ RegisterMediaServiceCallback service_callback_;
+ ErrorCallback error_callback_;
+ WiFiDisplayMediaServicePtr media_service_;
+
+ base::WeakPtrFactory<WiFiDisplayMediaPipeline> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(WiFiDisplayMediaPipeline);
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_PIPELINE_H_
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_session.cc b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_session.cc
index f1bfe4cbea7..93e9c4d263b 100644
--- a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_session.cc
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_session.cc
@@ -75,13 +75,16 @@ void WiFiDisplaySession::Terminate(const CompletionCallback& callback) {
teminate_completion_callback_ = callback;
}
-void WiFiDisplaySession::OnConnected(const mojo::String& ip_address) {
+void WiFiDisplaySession::OnConnected(const mojo::String& local_ip_address,
+ const mojo::String& sink_ip_address) {
DCHECK_EQ(DisplaySourceSession::Established, state_);
- ip_address_ = ip_address;
+ local_ip_address_ = local_ip_address;
media_manager_.reset(
new WiFiDisplayMediaManager(
params_.video_track,
params_.audio_track,
+ sink_ip_address,
+ params_.render_frame->GetServiceRegistry(),
base::Bind(
&WiFiDisplaySession::OnMediaError,
weak_factory_.GetWeakPtr())));
@@ -125,7 +128,7 @@ void WiFiDisplaySession::OnMessage(const mojo::String& data) {
}
std::string WiFiDisplaySession::GetLocalIPAddress() const {
- return ip_address_;
+ return local_ip_address_;
}
int WiFiDisplaySession::GetNextCSeq(int* initial_peer_cseq) const {
@@ -137,10 +140,9 @@ void WiFiDisplaySession::SendRTSPData(const std::string& message) {
}
unsigned WiFiDisplaySession::CreateTimer(int seconds) {
- scoped_ptr<base::Timer> timer(new base::Timer(true, true));
- auto insert_ret = timers_.insert(
- std::pair<int, scoped_ptr<base::Timer>>(
- ++timer_id_, std::move(timer)));
+ std::unique_ptr<base::Timer> timer(new base::Timer(true, true));
+ auto insert_ret = timers_.insert(std::pair<int, std::unique_ptr<base::Timer>>(
+ ++timer_id_, std::move(timer)));
DCHECK(insert_ret.second);
insert_ret.first->second->Start(FROM_HERE,
base::TimeDelta::FromSeconds(seconds),
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_session.h b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_session.h
index bacb875dbac..d3da802a2a9 100644
--- a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_session.h
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_session.h
@@ -40,7 +40,8 @@ class WiFiDisplaySession: public DisplaySourceSession,
void Terminate(const CompletionCallback& callback) override;
// WiFiDisplaySessionServiceClient overrides.
- void OnConnected(const mojo::String& ip_address) override;
+ void OnConnected(const mojo::String& local_ip_address,
+ const mojo::String& sink_ip_address) override;
void OnConnectRequestHandled(bool success,
const mojo::String& error) override;
void OnTerminated() override;
@@ -72,12 +73,12 @@ class WiFiDisplaySession: public DisplaySourceSession,
void RunTerminateCallback(bool success, const std::string& error = "");
private:
- scoped_ptr<wds::Source> wfd_source_;
- scoped_ptr<WiFiDisplayMediaManager> media_manager_;
+ std::unique_ptr<wds::Source> wfd_source_;
+ std::unique_ptr<WiFiDisplayMediaManager> media_manager_;
WiFiDisplaySessionServicePtr service_;
mojo::Binding<WiFiDisplaySessionServiceClient> binding_;
- std::string ip_address_;
- std::map<int, scoped_ptr<base::Timer>> timers_;
+ std::string local_ip_address_;
+ std::map<int, std::unique_ptr<base::Timer>> timers_;
DisplaySourceSessionParams params_;
CompletionCallback start_completion_callback_;
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_transport_stream_packetizer.cc b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_transport_stream_packetizer.cc
index eee0a52c55a..22e1bcfa9a5 100644
--- a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_transport_stream_packetizer.cc
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_transport_stream_packetizer.cc
@@ -14,6 +14,27 @@
#include "extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_packetizer.h"
namespace extensions {
+
+struct WiFiDisplayTransportStreamPacketizer::ElementaryStreamState {
+ using ElementaryStreamType =
+ WiFiDisplayElementaryStreamInfo::ElementaryStreamType;
+
+ ElementaryStreamState(const WiFiDisplayElementaryStreamInfo& stream_info,
+ uint16_t packet_id,
+ uint8_t stream_id);
+
+ struct {
+ uint8_t continuity;
+ } counters;
+ uint16_t packet_id;
+ uint8_t stream_id;
+ ElementaryStreamType type;
+ struct {
+ uint8_t data[4];
+ uint8_t size;
+ } unit_header;
+};
+
namespace {
uint32_t crc32(uint32_t crc, const uint8_t* data, size_t len) {
@@ -73,127 +94,111 @@ namespace psi {
const uint8_t kProgramAssociationTableId = 0x00u;
const uint8_t kProgramMapTableId = 0x02u;
-const uint16_t kFirstProgramNumber = 0x0001u;
-
-const size_t kCrcSize = 4u;
-const size_t kProgramMapTableElementaryStreamEntryBaseSize = 5u;
const size_t kTableHeaderSize = 3u;
-size_t FillInTablePointer(uint8_t* dst, size_t min_size) {
- size_t i = 1u;
- if (i < min_size) {
- std::memset(&dst[i], 0xFF, min_size - i); // Pointer filler bytes
- i = min_size;
- }
- dst[0] = i - 1u; // Pointer field
- return i;
+void AppendTablePointer(std::vector<uint8_t>* dst, uint8_t min_size) {
+ const uint8_t kPointerFieldSize = 1u;
+ const uint8_t length =
+ std::max(min_size, kPointerFieldSize) - kPointerFieldSize;
+ dst->push_back(length); // Pointer field
+ dst->insert(dst->end(), length, 0xFFu); // Pointer filler bytes
}
-size_t FillInTableHeaderAndCrc(uint8_t* header_dst,
- uint8_t* crc_dst,
- uint8_t table_id) {
- size_t i;
- const uint8_t* const header_end = header_dst + kTableHeaderSize;
- const uint8_t* const crc_end = crc_dst + kCrcSize;
- const size_t section_length = static_cast<size_t>(crc_end - header_end);
+size_t FillInTableHeader(uint8_t* dst, uint8_t table_id, size_t table_size) {
+ const size_t section_length = table_size - kTableHeaderSize;
DCHECK_LE(section_length, 1021u);
- // Table header.
- i = 0u;
- header_dst[i++] = table_id;
- header_dst[i++] =
- (0x1u << 7) | // Section syntax indicator (1 for PAT and PMT)
- (0x0u << 6) | // Private bit (0 for PAT and PMT)
- (0x3u << 4) | // Reserved bits (both bits on)
- (0x0u << 2) | // Section length unused bits (both bits off)
- ((section_length >> 8) & 0x03u); // Section length (10 bits)
- header_dst[i++] = section_length & 0xFFu; //
+ size_t i = 0u;
+ dst[i++] = table_id;
+ dst[i++] = (0x1u << 7) | // Section syntax indicator (1 for PAT and PMT)
+ (0x0u << 6) | // Private bit (0 for PAT and PMT)
+ (0x3u << 4) | // Reserved bits (both bits on)
+ (0x0u << 2) | // Section length unused bits (both bits off)
+ ((section_length >> 8) & 0x03u); // Section length (10 bits)
+ dst[i++] = section_length & 0xFFu; //
DCHECK_EQ(kTableHeaderSize, i);
-
- // CRC.
- uint32_t crc =
- crc32(0xFFFFFFFFu, header_dst, static_cast<size_t>(crc_dst - header_dst));
- i = 0u;
- // Avoid swapping the crc by reversing write order.
- crc_dst[i++] = crc & 0xFFu;
- crc_dst[i++] = (crc >> 8) & 0xFFu;
- crc_dst[i++] = (crc >> 16) & 0xFFu;
- crc_dst[i++] = (crc >> 24) & 0xFFu;
- DCHECK_EQ(kCrcSize, i);
return i;
}
-size_t FillInTableSyntax(uint8_t* dst,
- uint16_t table_id_extension,
- uint8_t version_number) {
- size_t i = 0u;
- dst[i++] = table_id_extension >> 8;
- dst[i++] = table_id_extension & 0xFFu;
- dst[i++] = (0x3u << 6) | // Reserved bits (both bits on)
- ((version_number & 0x1Fu) << 1) | // Version number (5 bits)
- (0x1u << 0); // Current indicator
- dst[i++] = 0u; // Section number
- dst[i++] = 0u; // Last section number
- return i;
+void FillInTableHeaderAndAppendCrc(std::vector<uint8_t>* dst,
+ size_t table_pos,
+ uint8_t table_id) {
+ const size_t kCrcSize = 4u;
+
+ // Fill in a table header.
+ const size_t table_size = dst->size() + kCrcSize - table_pos;
+ uint8_t* table_data = &(*dst)[table_pos];
+ FillInTableHeader(table_data, table_id, table_size);
+
+ // Append a CRC. Avoid swapping crc_value by reversing write order.
+ uint32_t crc_value = crc32(0xFFFFFFFFu, table_data, table_size - kCrcSize);
+ const uint8_t crc[kCrcSize] = {crc_value & 0xFFu, (crc_value >> 8) & 0xFFu,
+ (crc_value >> 16) & 0xFFu,
+ (crc_value >> 24) & 0xFFu};
+ DCHECK_EQ(kCrcSize, sizeof(crc));
+ dst->insert(dst->end(), std::begin(crc), std::end(crc));
}
-size_t FillInProgramAssociationTableEntry(uint8_t* dst,
- uint16_t program_number,
- unsigned pmt_packet_id) {
- size_t i = 0u;
- dst[i++] = program_number >> 8;
- dst[i++] = program_number & 0xFFu;
- dst[i++] = (0x7u << 5) | // Reserved bits (all 3 bits on)
- ((pmt_packet_id >> 8) & 0x1Fu); // Packet identifier (13 bits)
- dst[i++] = pmt_packet_id & 0xFFu; //
- return i;
+void AppendTableSyntax(std::vector<uint8_t>* dst,
+ uint16_t table_id_extension,
+ uint8_t version_number) {
+ const uint8_t table_syntax[] = {
+ table_id_extension >> 8, table_id_extension & 0xFFu,
+ ((0x3u << 6) | // Reserved bits (both bits on)
+ ((version_number & 0x1Fu) << 1) | // Version number (5 bits)
+ (true << 0)), // Current indicator
+ 0u, // Section number
+ 0u}; // Last section number
+ dst->insert(dst->end(), std::begin(table_syntax), std::end(table_syntax));
}
-size_t FillInProgramMapTableData(uint8_t* dst, unsigned pcr_packet_id) {
- size_t i = 0u;
- dst[i++] = (0x7u << 5) | // Reserved bits (all 3 bits on)
- ((pcr_packet_id >> 8) & 0x1Fu); // Packet identifier (13 bits)
- dst[i++] = pcr_packet_id & 0xFFu; //
- dst[i++] = (0xFu << 4) | // Reserved bits (all 4 bits on)
- (0x0u << 2) | // Program info length unused bits (both bits off)
- ((0u >> 8) & 0x3u); // Program info length (10 bits)
- dst[i++] = 0u & 0xFFu; //
- // No program descriptors
- return i;
+void AppendProgramAssociationTableEntry(std::vector<uint8_t>* dst,
+ uint16_t program_number,
+ unsigned pmt_packet_id) {
+ const uint8_t entry[] = {
+ program_number >> 8, program_number & 0xFFu,
+ ((0x7u << 5) | // Reserved bits (all 3 bits on)
+ ((pmt_packet_id >> 8) & 0x1Fu)), // Packet identifier (13 bits)
+ pmt_packet_id & 0xFFu}; //
+ dst->insert(dst->end(), std::begin(entry), std::end(entry));
}
-size_t CalculateElementaryStreamInfoLength(
- const std::vector<WiFiDisplayElementaryStreamDescriptor>& es_descriptors) {
- size_t es_info_length = 0u;
- for (const auto& es_descriptor : es_descriptors)
- es_info_length += es_descriptor.size();
- DCHECK_EQ(0u, es_info_length >> 8);
- return es_info_length;
+void AppendProgramMapTableDataWithoutElementaryStreamEntries(
+ std::vector<uint8_t>* dst,
+ unsigned pcr_packet_id) {
+ const uint8_t data[] = {
+ ((0x7u << 5) | // Reserved bits (all 3 bits on)
+ ((pcr_packet_id >> 8) & 0x1Fu)), // Packet identifier (13 bits)
+ pcr_packet_id & 0xFFu, //
+ ((0xFu << 4) | // Reserved bits (all 4 bits on)
+ (0x0u << 2) | // Program info length unused bits (both bits off)
+ ((0u >> 8) & 0x3u)), // Program info length (10 bits)
+ 0u & 0xFFu}; //
+ // No program descriptors
+ dst->insert(dst->end(), std::begin(data), std::end(data));
}
-size_t FillInProgramMapTableElementaryStreamEntry(
- uint8_t* dst,
+void AppendProgramMapTableElementaryStreamEntry(
+ std::vector<uint8_t>* dst,
uint8_t stream_type,
unsigned es_packet_id,
- size_t es_info_length,
const std::vector<WiFiDisplayElementaryStreamDescriptor>& es_descriptors) {
- DCHECK_EQ(CalculateElementaryStreamInfoLength(es_descriptors),
- es_info_length);
+ size_t es_info_length = 0u;
+ for (const auto& es_descriptor : es_descriptors)
+ es_info_length += es_descriptor.size();
DCHECK_EQ(0u, es_info_length >> 10);
- size_t i = 0u;
- dst[i++] = stream_type;
- dst[i++] = (0x7u << 5) | // Reserved bits (all 3 bits on)
- ((es_packet_id >> 8) & 0x1Fu); // Packet identifier (13 bits)
- dst[i++] = es_packet_id & 0xFFu; //
- dst[i++] = (0xFu << 4) | // Reserved bits (all 4 bits on)
- (0x0u << 2) | // ES info length unused bits (both bits off)
- ((es_info_length >> 8) & 0x3u); // ES info length (10 bits)
- dst[i++] = es_info_length & 0xFFu; //
- for (const auto& es_descriptor : es_descriptors) {
- std::memcpy(&dst[i], es_descriptor.data(), es_descriptor.size());
- i += es_descriptor.size();
- }
- return i;
+ const uint8_t data[] = {
+ stream_type,
+ ((0x7u << 5) | // Reserved bits (all 3 bits on)
+ ((es_packet_id >> 8) & 0x1Fu)), // Packet identifier (13 bits)
+ es_packet_id & 0xFFu, //
+ ((0xFu << 4) | // Reserved bits (all 4 bits on)
+ (0x0u << 2) | // ES info length unused bits (both bits off)
+ ((es_info_length >> 8) & 0x3u)), // ES info length (10 bits)
+ es_info_length & 0xFFu}; //
+ dst->insert(dst->end(), std::begin(data), std::end(data));
+ for (const auto& es_descriptor : es_descriptors)
+ dst->insert(dst->end(), es_descriptor.begin(), es_descriptor.end());
}
} // namespace psi
@@ -299,8 +304,6 @@ size_t FillInPacketHeader(uint8_t* dst,
// Code and parameters related to the WiFi Display specification.
namespace widi {
-const size_t kUnitHeaderMaxSize = 4u;
-
// Maximum interval between meta information which includes:
// * Program Association Table (PAT)
// * Program Map Table (PMT)
@@ -313,6 +316,9 @@ const unsigned kProgramClockReferencePacketId = 0x1000u;
const unsigned kVideoStreamPacketId = 0x1011u;
const unsigned kFirstAudioStreamPacketId = 0x1100u;
+const uint16_t kProgramNumber = 0x0001u;
+const uint16_t kTransportStreamId = 0x0001u;
+
size_t FillInUnitHeader(uint8_t* dst,
const WiFiDisplayElementaryStreamInfo& stream_info) {
size_t i = 0u;
@@ -324,63 +330,108 @@ size_t FillInUnitHeader(uint8_t* dst,
WiFiDisplayElementaryStreamDescriptor::LPCMAudioStream>()) {
dst[i++] = 0xA0u; // Sub stream ID (0th sub stream)
dst[i++] = WiFiDisplayTransportStreamPacketizer::LPCM::kFramesPerUnit;
- dst[i++] = ((0x00u << 1) | // Reserved (all 7 bits off)
- (lpcm_descriptor->emphasis_flag() << 0));
- dst[i++] = ((lpcm_descriptor->bits_per_sample() << 6) |
- (lpcm_descriptor->sampling_frequency() << 3) |
- (lpcm_descriptor->number_of_channels() << 0));
+ dst[i++] = (0x00u << 1) | // Reserved (all 7 bits off)
+ (lpcm_descriptor->emphasis_flag() << 0);
+ dst[i++] = (lpcm_descriptor->bits_per_sample() << 6) |
+ (lpcm_descriptor->sampling_frequency() << 3) |
+ (lpcm_descriptor->number_of_channels() << 0);
}
}
- DCHECK_LE(i, kUnitHeaderMaxSize);
return i;
}
} // namespace widi
-} // namespace
+std::vector<uint8_t> BuildProgramAssociationTable(uint8_t version_number) {
+ std::vector<uint8_t> table;
-WiFiDisplayTransportStreamPacket::WiFiDisplayTransportStreamPacket(
- const uint8_t* header_data,
- size_t header_size)
- : header_(header_data, header_size),
- payload_(header_.end(), 0u),
- filler_(kPacketSize - header_size) {}
+ // Append a minimal table pointer.
+ psi::AppendTablePointer(&table, 0u);
+
+ // Reserve space for a table header.
+ const size_t table_header_index = table.size();
+ table.resize(table.size() + psi::kTableHeaderSize);
+
+ // Append a table syntax.
+ psi::AppendTableSyntax(&table, widi::kTransportStreamId, version_number);
+
+ // Append program association table data consisting of one entry.
+ psi::AppendProgramAssociationTableEntry(&table, widi::kProgramNumber,
+ widi::kProgramMapTablePacketId);
+
+ // Fill in a table header and a CRC now that table size is known.
+ psi::FillInTableHeaderAndAppendCrc(&table, table_header_index,
+ psi::kProgramAssociationTableId);
+
+ return table;
+}
+
+std::vector<uint8_t> BuildProgramMapTable(
+ uint8_t version_number,
+ const std::vector<WiFiDisplayElementaryStreamInfo>& stream_infos,
+ const std::vector<
+ WiFiDisplayTransportStreamPacketizer::ElementaryStreamState>&
+ stream_states) {
+ DCHECK_EQ(stream_infos.size(), stream_states.size());
+
+ std::vector<uint8_t> table;
+
+ // Append a minimal table pointer.
+ psi::AppendTablePointer(&table, 0u);
+
+ // Reserve space for a table header.
+ const size_t table_header_index = table.size();
+ table.resize(table.size() + psi::kTableHeaderSize);
+
+ // Append a table syntax.
+ psi::AppendTableSyntax(&table, widi::kProgramNumber, version_number);
+
+ // Append program map table data.
+ psi::AppendProgramMapTableDataWithoutElementaryStreamEntries(
+ &table, widi::kProgramClockReferencePacketId);
+ for (size_t i = 0; i < stream_infos.size(); ++i) {
+ psi::AppendProgramMapTableElementaryStreamEntry(
+ &table, stream_states[i].type, stream_states[i].packet_id,
+ stream_infos[i].descriptors());
+ }
+
+ // Fill in a table header and a CRC now that table size is known.
+ psi::FillInTableHeaderAndAppendCrc(&table, table_header_index,
+ psi::kProgramMapTableId);
+
+ return table;
+}
+
+} // namespace
WiFiDisplayTransportStreamPacket::WiFiDisplayTransportStreamPacket(
const uint8_t* header_data,
size_t header_size,
- const uint8_t* payload_data)
+ const uint8_t* payload_data,
+ size_t payload_size)
: header_(header_data, header_size),
- payload_(payload_data, kPacketSize - header_size),
- filler_(0u) {}
-
-struct WiFiDisplayTransportStreamPacketizer::ElementaryStreamState {
- ElementaryStreamState(WiFiDisplayElementaryStreamInfo info,
- uint16_t packet_id,
- uint8_t stream_id)
- : info(std::move(info)),
- info_length(
- psi::CalculateElementaryStreamInfoLength(this->info.descriptors())),
- packet_id(packet_id),
- stream_id(stream_id) {}
-
- WiFiDisplayElementaryStreamInfo info;
- uint8_t info_length;
- struct {
- uint8_t continuity = 0u;
- } counters;
- uint16_t packet_id;
- uint8_t stream_id;
-};
+ payload_(payload_data, payload_size),
+ filler_(kPacketSize - header_size - payload_size) {}
+
+WiFiDisplayTransportStreamPacketizer::ElementaryStreamState::
+ ElementaryStreamState(const WiFiDisplayElementaryStreamInfo& stream_info,
+ uint16_t packet_id,
+ uint8_t stream_id)
+ : packet_id(packet_id), stream_id(stream_id), type(stream_info.type()) {
+ std::memset(&counters, 0x00, sizeof(counters));
+ unit_header.size = widi::FillInUnitHeader(unit_header.data, stream_info);
+ DCHECK_LE(unit_header.data + unit_header.size, std::end(unit_header.data));
+}
WiFiDisplayTransportStreamPacketizer::WiFiDisplayTransportStreamPacketizer(
const base::TimeDelta& delay_for_unit_time_stamps,
- std::vector<WiFiDisplayElementaryStreamInfo> stream_infos)
- : delay_for_unit_time_stamps_(delay_for_unit_time_stamps) {
+ const std::vector<WiFiDisplayElementaryStreamInfo>& stream_infos)
+ : delay_for_unit_time_stamps_(delay_for_unit_time_stamps),
+ program_association_table_(BuildProgramAssociationTable(0u)) {
std::memset(&counters_, 0x00, sizeof(counters_));
if (!stream_infos.empty())
- CHECK(SetElementaryStreams(std::move(stream_infos)));
+ CHECK(SetElementaryStreams(stream_infos));
}
WiFiDisplayTransportStreamPacketizer::~WiFiDisplayTransportStreamPacketizer() {}
@@ -406,22 +457,16 @@ bool WiFiDisplayTransportStreamPacketizer::EncodeElementaryStreamUnit(
return false;
}
- uint8_t unit_header_data[widi::kUnitHeaderMaxSize];
- const size_t unit_header_size =
- widi::FillInUnitHeader(unit_header_data, stream_state.info);
-
UpdateDelayForUnitTimeStamps(pts, dts);
NormalizeUnitTimeStamps(&pts, &dts);
- WiFiDisplayElementaryStreamPacketizer elementary_stream_packetizer;
WiFiDisplayElementaryStreamPacket elementary_stream_packet =
- elementary_stream_packetizer.EncodeElementaryStreamUnit(
- stream_state.stream_id, unit_header_data, unit_header_size, unit_data,
- unit_size, pts, dts);
+ WiFiDisplayElementaryStreamPacketizer::EncodeElementaryStreamUnit(
+ stream_state.stream_id, stream_state.unit_header.data,
+ stream_state.unit_header.size, unit_data, unit_size, pts, dts);
size_t adaptation_field_min_size = 0u;
uint8_t header_data[WiFiDisplayTransportStreamPacket::kPacketSize];
- bool is_payload_unit_end;
bool is_payload_unit_start = true;
size_t remaining_unit_size = elementary_stream_packet.unit().size();
do {
@@ -431,15 +476,15 @@ bool WiFiDisplayTransportStreamPacketizer::EncodeElementaryStreamUnit(
// (only for the first and/or the last packet):
// - for the first packet to hold flags
// - for the last packet to hold padding
- // * PES packet header (only for the first packet):
- // - PES packet header base
- // - Optional PES header base
- // - Optional PES header optional fields:
- // - Presentation time stamp
- // - Decoding time stamp
+ // * Elementary stream packet header (only for the first packet)
+ // * Elementary stream packet unit header (only for the first packet)
bool adaptation_field_flag = false;
- size_t header_min_size;
- if (is_payload_unit_start || is_payload_unit_end) {
+ size_t header_min_size = 0u;
+ const bool is_payload_unit_start_or_end =
+ is_payload_unit_start ||
+ remaining_unit_size <= WiFiDisplayTransportStreamPacket::kPacketSize -
+ ts::kPacketHeaderSize;
+ if (is_payload_unit_start_or_end) {
header_min_size = ts::kPacketHeaderSize;
if (is_payload_unit_start) {
header_min_size += elementary_stream_packet.header().size() +
@@ -473,7 +518,7 @@ bool WiFiDisplayTransportStreamPacketizer::EncodeElementaryStreamUnit(
elementary_stream_packet.unit_header().size());
i += elementary_stream_packet.unit_header().size();
DCHECK_EQ(header_min_size + adaptation_field_size, i);
- } else if (is_payload_unit_end) {
+ } else if (is_payload_unit_start_or_end) { // Payload unit end
if (adaptation_field_flag) {
// Fill in an adaptation field only for padding.
i += ts::FillInAdaptationField(&header_data[i], false,
@@ -483,9 +528,10 @@ bool WiFiDisplayTransportStreamPacketizer::EncodeElementaryStreamUnit(
}
// Delegate the packet.
- WiFiDisplayTransportStreamPacket packet(
+ const WiFiDisplayTransportStreamPacket packet(
header_data, i,
- elementary_stream_packet.unit().end() - remaining_unit_size);
+ elementary_stream_packet.unit().end() - remaining_unit_size,
+ WiFiDisplayTransportStreamPacket::kPacketSize - i);
DCHECK_LE(packet.payload().size(), remaining_unit_size);
remaining_unit_size -= packet.payload().size();
if (!OnPacketizedTransportStreamPacket(
@@ -494,9 +540,6 @@ bool WiFiDisplayTransportStreamPacketizer::EncodeElementaryStreamUnit(
}
// Prepare for the next packet.
- is_payload_unit_end =
- remaining_unit_size <=
- WiFiDisplayTransportStreamPacket::kPacketSize - ts::kPacketHeaderSize;
is_payload_unit_start = false;
} while (remaining_unit_size > 0u);
@@ -516,41 +559,19 @@ bool WiFiDisplayTransportStreamPacketizer::EncodeProgramAssociationTable(
bool flush) {
DCHECK(CalledOnValidThread());
- const uint16_t transport_stream_id = 0x0001u;
-
- uint8_t header_data[WiFiDisplayTransportStreamPacket::kPacketSize];
- size_t i = 0u;
-
// Fill in a packet header.
- i += ts::FillInPacketHeader(&header_data[i], true,
- widi::kProgramAssociationTablePacketId, false,
- counters_.program_association_table_continuity++);
-
- // Fill in a minimal table pointer.
- i += psi::FillInTablePointer(&header_data[i], 0u);
-
- // Reserve space for a table header.
- const size_t table_header_index = i;
- i += psi::kTableHeaderSize;
-
- // Fill in a table syntax.
- const uint8_t version_number = 0u;
- i += psi::FillInTableSyntax(&header_data[i], transport_stream_id,
- version_number);
-
- // Fill in program association table data.
- i += psi::FillInProgramAssociationTableEntry(&header_data[i],
- psi::kFirstProgramNumber,
- widi::kProgramMapTablePacketId);
-
- // Fill in a table header and a CRC now that the table size is known.
- i += psi::FillInTableHeaderAndCrc(&header_data[table_header_index],
- &header_data[i],
- psi::kProgramAssociationTableId);
+ uint8_t header_data[ts::kPacketHeaderSize];
+ size_t i = ts::FillInPacketHeader(
+ header_data, true, widi::kProgramAssociationTablePacketId, false,
+ counters_.program_association_table_continuity++);
+ DCHECK_EQ(ts::kPacketHeaderSize, i);
// Delegate the packet.
return OnPacketizedTransportStreamPacket(
- WiFiDisplayTransportStreamPacket(header_data, i), flush);
+ WiFiDisplayTransportStreamPacket(header_data, i,
+ program_association_table_.data(),
+ program_association_table_.size()),
+ flush);
}
bool WiFiDisplayTransportStreamPacketizer::EncodeProgramClockReference(
@@ -581,53 +602,32 @@ bool WiFiDisplayTransportStreamPacketizer::EncodeProgramClockReference(
// Delegate the packet.
return OnPacketizedTransportStreamPacket(
- WiFiDisplayTransportStreamPacket(header_data, i), flush);
+ WiFiDisplayTransportStreamPacket(header_data, i, header_data + i, 0u),
+ flush);
}
bool WiFiDisplayTransportStreamPacketizer::EncodeProgramMapTables(bool flush) {
DCHECK(CalledOnValidThread());
- DCHECK(!stream_states_.empty());
-
- const uint16_t program_number = psi::kFirstProgramNumber;
-
- uint8_t header_data[WiFiDisplayTransportStreamPacket::kPacketSize];
- size_t i = 0u;
+ DCHECK(!program_map_table_.empty());
// Fill in a packet header.
- i += ts::FillInPacketHeader(&header_data[i], true,
- widi::kProgramMapTablePacketId, false,
- counters_.program_map_table_continuity++);
-
- // Fill in a minimal table pointer.
- i += psi::FillInTablePointer(&header_data[i], 0u);
-
- // Reserve space for a table header.
- const size_t table_header_index = i;
- i += psi::kTableHeaderSize;
-
- // Fill in a table syntax.
- i += psi::FillInTableSyntax(&header_data[i], program_number,
- counters_.program_map_table_version);
-
- // Fill in program map table data.
- i += psi::FillInProgramMapTableData(&header_data[i],
- widi::kProgramClockReferencePacketId);
- for (const auto& stream_state : stream_states_) {
- DCHECK_LE(i + psi::kProgramMapTableElementaryStreamEntryBaseSize +
- stream_state.info_length + psi::kCrcSize,
- WiFiDisplayTransportStreamPacket::kPacketSize);
- i += psi::FillInProgramMapTableElementaryStreamEntry(
- &header_data[i], stream_state.info.type(), stream_state.packet_id,
- stream_state.info_length, stream_state.info.descriptors());
- }
-
- // Fill in a table header and a CRC now that the table size is known.
- i += psi::FillInTableHeaderAndCrc(&header_data[table_header_index],
- &header_data[i], psi::kProgramMapTableId);
+ uint8_t header_data[ts::kPacketHeaderSize];
+ size_t i =
+ ts::FillInPacketHeader(header_data, true, widi::kProgramMapTablePacketId,
+ false, counters_.program_map_table_continuity++);
+ DCHECK_EQ(ts::kPacketHeaderSize, i);
// Delegate the packet.
return OnPacketizedTransportStreamPacket(
- WiFiDisplayTransportStreamPacket(header_data, i), flush);
+ WiFiDisplayTransportStreamPacket(header_data, ts::kPacketHeaderSize,
+ program_map_table_.data(),
+ program_map_table_.size()),
+ flush);
+}
+
+void WiFiDisplayTransportStreamPacketizer::
+ ForceEncodeMetaInformationBeforeNextUnit() {
+ program_clock_reference_ = base::TimeTicks();
}
void WiFiDisplayTransportStreamPacketizer::NormalizeUnitTimeStamps(
@@ -650,20 +650,22 @@ void WiFiDisplayTransportStreamPacketizer::NormalizeUnitTimeStamps(
}
bool WiFiDisplayTransportStreamPacketizer::SetElementaryStreams(
- std::vector<WiFiDisplayElementaryStreamInfo> stream_infos) {
+ const std::vector<WiFiDisplayElementaryStreamInfo>& stream_infos) {
DCHECK(CalledOnValidThread());
std::vector<ElementaryStreamState> new_stream_states;
new_stream_states.reserve(stream_infos.size());
+ // Allocate packet and stream IDs.
uint8_t audio_stream_id =
WiFiDisplayElementaryStreamPacketizer::kFirstAudioStreamId;
uint16_t audio_stream_packet_id = widi::kFirstAudioStreamPacketId;
uint8_t private_stream_1_id =
WiFiDisplayElementaryStreamPacketizer::kPrivateStream1Id;
- uint16_t video_stream_packet_id = widi::kVideoStreamPacketId;
+ uint8_t video_stream_id =
+ WiFiDisplayElementaryStreamPacketizer::kFirstVideoStreamId;
- for (auto& stream_info : stream_infos) {
+ for (const auto& stream_info : stream_infos) {
uint16_t packet_id;
uint8_t stream_id;
@@ -682,25 +684,33 @@ bool WiFiDisplayTransportStreamPacketizer::SetElementaryStreams(
stream_id = private_stream_1_id++;
break;
case VIDEO_H264:
- if (video_stream_packet_id != widi::kVideoStreamPacketId)
+ if (video_stream_id !=
+ WiFiDisplayElementaryStreamPacketizer::kFirstVideoStreamId) {
return false;
- packet_id = video_stream_packet_id++;
- stream_id = WiFiDisplayElementaryStreamPacketizer::kFirstVideoStreamId;
+ }
+ packet_id = widi::kVideoStreamPacketId;
+ stream_id = video_stream_id++;
break;
}
- new_stream_states.emplace_back(std::move(stream_info), packet_id,
- stream_id);
+ new_stream_states.emplace_back(stream_info, packet_id, stream_id);
}
- // If there are no previous states, there is no previous program map table
- // to change, either. This ensures that the first encoded program map table
- // has version 0.
- if (!stream_states_.empty())
- ++counters_.program_map_table_version;
+ // Build a new program map table.
+ std::vector<uint8_t> new_program_map_table = BuildProgramMapTable(
+ counters_.program_map_table_version, stream_infos, new_stream_states);
+ if (new_program_map_table.size() >
+ WiFiDisplayTransportStreamPacket::kPacketSize - ts::kPacketHeaderSize) {
+ return false;
+ }
+ // Activate the new program map table and the new states.
+ ++counters_.program_map_table_version;
+ program_map_table_.swap(new_program_map_table);
stream_states_.swap(new_stream_states);
+ ForceEncodeMetaInformationBeforeNextUnit();
+
return true;
}
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_transport_stream_packetizer.h b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_transport_stream_packetizer.h
index 0cdeb6a750d..49d37dae127 100644
--- a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_transport_stream_packetizer.h
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_transport_stream_packetizer.h
@@ -41,10 +41,9 @@ class WiFiDisplayTransportStreamPacket {
};
WiFiDisplayTransportStreamPacket(const uint8_t* header_data,
- size_t header_size);
- WiFiDisplayTransportStreamPacket(const uint8_t* header_data,
size_t header_size,
- const uint8_t* payload_data);
+ const uint8_t* payload_data,
+ size_t payload_size);
const Part& header() const { return header_; }
const Part& payload() const { return payload_; }
@@ -67,6 +66,8 @@ class WiFiDisplayTransportStreamPacket {
// |OnPacketizedTransportStreamPacket| is called.
class WiFiDisplayTransportStreamPacketizer : public base::NonThreadSafe {
public:
+ struct ElementaryStreamState;
+
enum ElementaryStreamType : uint8_t {
AUDIO_AAC = 0x0Fu,
AUDIO_AC3 = 0x81u,
@@ -87,7 +88,7 @@ class WiFiDisplayTransportStreamPacketizer : public base::NonThreadSafe {
WiFiDisplayTransportStreamPacketizer(
const base::TimeDelta& delay_for_unit_time_stamps,
- std::vector<WiFiDisplayElementaryStreamInfo> stream_infos);
+ const std::vector<WiFiDisplayElementaryStreamInfo>& stream_infos);
virtual ~WiFiDisplayTransportStreamPacketizer();
// Encodes one elementary stream unit buffer (such as one video frame or
@@ -132,7 +133,7 @@ class WiFiDisplayTransportStreamPacketizer : public base::NonThreadSafe {
bool EncodeMetaInformation(bool flush);
bool SetElementaryStreams(
- std::vector<WiFiDisplayElementaryStreamInfo> stream_infos);
+ const std::vector<WiFiDisplayElementaryStreamInfo>& stream_infos);
void DetachFromThread() { base::NonThreadSafe::DetachFromThread(); }
@@ -140,6 +141,7 @@ class WiFiDisplayTransportStreamPacketizer : public base::NonThreadSafe {
bool EncodeProgramAssociationTable(bool flush);
bool EncodeProgramClockReference(bool flush);
bool EncodeProgramMapTables(bool flush);
+ void ForceEncodeMetaInformationBeforeNextUnit();
// Normalizes unit time stamps by delaying them in order to ensure that unit
// time stamps are never smaller than a program clock reference.
@@ -158,8 +160,6 @@ class WiFiDisplayTransportStreamPacketizer : public base::NonThreadSafe {
bool flush) = 0;
private:
- struct ElementaryStreamState;
-
struct {
uint8_t program_association_table_continuity;
uint8_t program_map_table_continuity;
@@ -169,6 +169,8 @@ class WiFiDisplayTransportStreamPacketizer : public base::NonThreadSafe {
base::TimeDelta delay_for_unit_time_stamps_;
base::TimeTicks program_clock_reference_;
std::vector<ElementaryStreamState> stream_states_;
+ std::vector<uint8_t> program_association_table_;
+ std::vector<uint8_t> program_map_table_;
};
} // namespace extensions
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_video_encoder.cc b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_video_encoder.cc
new file mode 100644
index 00000000000..941ecab199b
--- /dev/null
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_video_encoder.cc
@@ -0,0 +1,99 @@
+// 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 "extensions/renderer/api/display_source/wifi_display/wifi_display_video_encoder.h"
+
+#include "base/bind.h"
+#include "base/logging.h"
+#include "content/public/renderer/video_encode_accelerator.h"
+#include "extensions/renderer/api/display_source/wifi_display/wifi_display_elementary_stream_descriptor.h"
+
+namespace extensions {
+
+WiFiDisplayVideoEncoder::InitParameters::InitParameters() = default;
+WiFiDisplayVideoEncoder::InitParameters::InitParameters(const InitParameters&) =
+ default;
+WiFiDisplayVideoEncoder::InitParameters::~InitParameters() = default;
+
+WiFiDisplayVideoEncoder::WiFiDisplayVideoEncoder(
+ scoped_refptr<base::SingleThreadTaskRunner> media_task_runner)
+ : media_task_runner_(std::move(media_task_runner)), send_idr_(false) {
+ DCHECK(media_task_runner_);
+
+ // Add descriptors common to all H.264 video encoders.
+ descriptors_.push_back(
+ WiFiDisplayElementaryStreamDescriptor::AVCTimingAndHRD::Create());
+}
+
+WiFiDisplayVideoEncoder::~WiFiDisplayVideoEncoder() = default;
+
+// static
+std::vector<wds::H264Profile> WiFiDisplayVideoEncoder::FindSupportedProfiles(
+ const gfx::Size& frame_size,
+ int32_t frame_rate) {
+ std::vector<wds::H264Profile> result;
+ media::VideoEncodeAccelerator::SupportedProfiles profiles =
+ content::GetSupportedVideoEncodeAcceleratorProfiles();
+ for (const auto& supported : profiles) {
+ if (supported.profile == media::H264PROFILE_HIGH &&
+ supported.max_resolution.width() >= frame_size.width() &&
+ supported.max_resolution.height() >= frame_size.height() &&
+ supported.max_framerate_numerator >= uint32_t(frame_rate)) {
+ result.push_back(wds::CHP);
+ break;
+ }
+ }
+
+ // Constrained profile is provided in any case (by the software encoder
+ // implementation).
+ result.push_back(wds::CBP);
+
+ return result;
+}
+
+// static
+void WiFiDisplayVideoEncoder::Create(
+ const InitParameters& params,
+ const VideoEncoderCallback& encoder_callback) {
+ CreateVEA(params, base::Bind(&OnCreatedVEA, params, encoder_callback));
+}
+
+// static
+void WiFiDisplayVideoEncoder::OnCreatedVEA(
+ const InitParameters& params,
+ const VideoEncoderCallback& encoder_callback,
+ scoped_refptr<WiFiDisplayVideoEncoder> vea_encoder) {
+ if (vea_encoder) {
+ // An accelerated encoder was created successfully. Pass it on.
+ encoder_callback.Run(vea_encoder);
+ } else {
+ // An accelerated encoder was not created. Fall back to a software encoder.
+ CreateSVC(params, encoder_callback);
+ }
+}
+
+WiFiDisplayElementaryStreamInfo
+WiFiDisplayVideoEncoder::CreateElementaryStreamInfo() const {
+ DCHECK(client_thread_checker_.CalledOnValidThread());
+ return WiFiDisplayElementaryStreamInfo(
+ WiFiDisplayElementaryStreamInfo::VIDEO_H264, descriptors_);
+}
+
+void WiFiDisplayVideoEncoder::InsertRawVideoFrame(
+ const scoped_refptr<media::VideoFrame>& video_frame,
+ base::TimeTicks reference_time) {
+ DCHECK(client_thread_checker_.CalledOnValidThread());
+ DCHECK(!encoded_callback_.is_null());
+ media_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&WiFiDisplayVideoEncoder::InsertFrameOnMediaThread,
+ this, video_frame, reference_time, send_idr_));
+ send_idr_ = false;
+}
+
+void WiFiDisplayVideoEncoder::RequestIDRPicture() {
+ DCHECK(client_thread_checker_.CalledOnValidThread());
+ send_idr_ = true;
+}
+
+} // namespace extensions
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_video_encoder.h b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_video_encoder.h
new file mode 100644
index 00000000000..28b0a43acd8
--- /dev/null
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_video_encoder.h
@@ -0,0 +1,111 @@
+// 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 EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_VIDEO_ENCODER_H_
+#define EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_VIDEO_ENCODER_H_
+
+#include <vector>
+
+#include "base/memory/shared_memory.h"
+#include "extensions/renderer/api/display_source/wifi_display/wifi_display_media_encoder.h"
+#include "media/base/video_frame.h"
+#include "media/video/video_encode_accelerator.h"
+#include "third_party/wds/src/libwds/public/video_format.h"
+
+namespace extensions {
+
+class WiFiDisplayElementaryStreamDescriptor;
+
+using WiFiDisplayEncodedFrame = WiFiDisplayEncodedUnit;
+
+// This interface represents H.264 video encoder used by the
+// Wi-Fi Display media pipeline.
+// Threading: the client code should belong to a single thread.
+class WiFiDisplayVideoEncoder : public WiFiDisplayMediaEncoder {
+ public:
+ using VideoEncoderCallback =
+ base::Callback<void(scoped_refptr<WiFiDisplayVideoEncoder>)>;
+
+ using ReceiveVideoEncodeAcceleratorCallback =
+ base::Callback<void(scoped_refptr<base::SingleThreadTaskRunner>,
+ std::unique_ptr<media::VideoEncodeAccelerator>)>;
+ using CreateVideoEncodeAcceleratorCallback =
+ base::Callback<void(const ReceiveVideoEncodeAcceleratorCallback&)>;
+
+ using ReceiveEncodeMemoryCallback =
+ base::Callback<void(std::unique_ptr<base::SharedMemory>)>;
+ using CreateEncodeMemoryCallback =
+ base::Callback<void(size_t size, const ReceiveEncodeMemoryCallback&)>;
+
+ struct InitParameters {
+ InitParameters();
+ InitParameters(const InitParameters&);
+ ~InitParameters();
+ gfx::Size frame_size;
+ int frame_rate;
+ int bit_rate;
+ wds::H264Profile profile;
+ wds::H264Level level;
+ // Video Encode Accelerator (VEA) specific parameters.
+ CreateEncodeMemoryCallback create_memory_callback;
+ CreateVideoEncodeAcceleratorCallback vea_create_callback;
+ };
+
+ // Returns the list of supported video encoder profiles
+ // for the given frame size and frame rate.
+ // If hight profile is supported it is to be first in the list.
+ static std::vector<wds::H264Profile> FindSupportedProfiles(
+ const gfx::Size& frame_size,
+ int32_t frame_rate);
+
+ // A factory method that creates a new encoder instance from the given
+ // |params|, the encoder instance is returned as an argument of
+ // |result_callback| ('nullptr' argument means encoder creation failure).
+ static void Create(const InitParameters& params,
+ const VideoEncoderCallback& encoder_callback);
+
+ // WiFiDisplayMediaEncoder
+ WiFiDisplayElementaryStreamInfo CreateElementaryStreamInfo() const final;
+
+ // Encodes the given raw frame. The resulting encoded frame is passed
+ // as an |encoded_callback|'s argument which is set via 'SetCallbacks'
+ // method.
+ void InsertRawVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame,
+ base::TimeTicks reference_time);
+
+ // Requests the next encoded frame to be an instantaneous decoding refresh
+ // (IDR) picture.
+ void RequestIDRPicture();
+
+ protected:
+ // A factory method that creates a new encoder instance which uses OpenH264
+ // SVC encoder for encoding.
+ static void CreateSVC(const InitParameters& params,
+ const VideoEncoderCallback& encoder_callback);
+
+ // A factory method that creates a new encoder instance which uses Video
+ // Encode Accelerator (VEA) for encoding.
+ static void CreateVEA(const InitParameters& params,
+ const VideoEncoderCallback& encoder_callback);
+ static void OnCreatedVEA(const InitParameters& params,
+ const VideoEncoderCallback& encoder_callback,
+ scoped_refptr<WiFiDisplayVideoEncoder> vea_encoder);
+
+ explicit WiFiDisplayVideoEncoder(
+ scoped_refptr<base::SingleThreadTaskRunner> media_task_runner);
+ ~WiFiDisplayVideoEncoder() override;
+
+ virtual void InsertFrameOnMediaThread(
+ scoped_refptr<media::VideoFrame> video_frame,
+ base::TimeTicks reference_time,
+ bool send_idr) = 0;
+
+ std::vector<WiFiDisplayElementaryStreamDescriptor> descriptors_;
+ scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
+ bool send_idr_;
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_VIDEO_ENCODER_H_
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_video_encoder_svc.cc b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_video_encoder_svc.cc
new file mode 100644
index 00000000000..cf81ae5f0cb
--- /dev/null
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_video_encoder_svc.cc
@@ -0,0 +1,208 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <memory>
+
+#include "base/bind.h"
+#include "base/task_runner_util.h"
+#include "base/threading/thread_task_runner_handle.h"
+#include "extensions/renderer/api/display_source/wifi_display/wifi_display_video_encoder.h"
+#include "third_party/openh264/src/codec/api/svc/codec_api.h"
+#include "third_party/openh264/src/codec/api/svc/codec_app_def.h"
+#include "third_party/openh264/src/codec/api/svc/codec_def.h"
+
+namespace extensions {
+
+namespace {
+
+size_t CalculateLayerBitStreamLength(const SLayerBSInfo& layer_info) {
+ size_t length = 0u;
+ for (int i = 0; i < layer_info.iNalCount; ++i)
+ length += static_cast<size_t>(layer_info.pNalLengthInByte[i]);
+ return length;
+}
+
+size_t CalculateFrameBitStreamLength(const SFrameBSInfo& frame_info) {
+ size_t length = 0u;
+ for (int i = 0; i < frame_info.iLayerNum; ++i)
+ length += CalculateLayerBitStreamLength(frame_info.sLayerInfo[i]);
+ return length;
+}
+
+// This video encoder implements software H.264 video encoding using OpenH264
+// library.
+class WiFiDisplayVideoEncoderSVC final : public WiFiDisplayVideoEncoder {
+ public:
+ static void Create(const InitParameters& params,
+ const VideoEncoderCallback& encoder_callback);
+
+ private:
+ WiFiDisplayVideoEncoderSVC(
+ scoped_refptr<base::SingleThreadTaskRunner> client_task_runner,
+ std::unique_ptr<base::Thread> media_thread);
+ ~WiFiDisplayVideoEncoderSVC() override;
+
+ scoped_refptr<WiFiDisplayVideoEncoder> InitOnMediaThread(
+ const InitParameters& params);
+ void InsertFrameOnMediaThread(scoped_refptr<media::VideoFrame> video_frame,
+ base::TimeTicks reference_time,
+ bool send_idr) override;
+
+ scoped_refptr<base::SingleThreadTaskRunner> client_task_runner_;
+ std::unique_ptr<base::Thread> media_thread_;
+ ISVCEncoder* openh264_encoder_;
+ base::TimeTicks start_time_;
+};
+
+// static
+void WiFiDisplayVideoEncoderSVC::Create(
+ const InitParameters& params,
+ const VideoEncoderCallback& encoder_callback) {
+ // TODO(e_hakkinen): Use normal media thread once it is exposed to extensions
+ // and can be passed to this class.
+ std::unique_ptr<base::Thread> media_thread(
+ new base::Thread("WiFiDisplaySVCMedia"));
+ media_thread->Start();
+
+ base::PostTaskAndReplyWithResult(
+ media_thread->task_runner().get(), FROM_HERE,
+ base::Bind(
+ &WiFiDisplayVideoEncoderSVC::InitOnMediaThread,
+ make_scoped_refptr(new WiFiDisplayVideoEncoderSVC(
+ base::ThreadTaskRunnerHandle::Get(), std::move(media_thread))),
+ params),
+ encoder_callback);
+}
+
+WiFiDisplayVideoEncoderSVC::WiFiDisplayVideoEncoderSVC(
+ scoped_refptr<base::SingleThreadTaskRunner> client_task_runner,
+ std::unique_ptr<base::Thread> media_thread)
+ : WiFiDisplayVideoEncoder(media_thread->task_runner()),
+ client_task_runner_(std::move(client_task_runner)),
+ media_thread_(std::move(media_thread)),
+ openh264_encoder_(nullptr) {}
+
+WiFiDisplayVideoEncoderSVC::~WiFiDisplayVideoEncoderSVC() {
+ if (openh264_encoder_) {
+ if (int err = openh264_encoder_->Uninitialize()) {
+ DVLOG(1) << "Failed to uninit OpenH264 encoder: error=" << err;
+ }
+ WelsDestroySVCEncoder(openh264_encoder_);
+ }
+ client_task_runner_->DeleteSoon(FROM_HERE, media_thread_.release());
+}
+
+scoped_refptr<WiFiDisplayVideoEncoder>
+WiFiDisplayVideoEncoderSVC::InitOnMediaThread(const InitParameters& params) {
+ DCHECK(!openh264_encoder_);
+
+ if (int err = WelsCreateSVCEncoder(&openh264_encoder_)) {
+ DVLOG(1) << "Failed to create OpenH264 encoder: error=" << err;
+ return nullptr;
+ }
+
+ SEncParamExt svc_params;
+ if (int err = openh264_encoder_->GetDefaultParams(&svc_params)) {
+ DVLOG(1) << "Failed to get default OpenH264 parameters: error=" << err;
+ return nullptr;
+ }
+
+ svc_params.fMaxFrameRate = params.frame_rate;
+ svc_params.iPicHeight = params.frame_size.height();
+ svc_params.iPicWidth = params.frame_size.width();
+ svc_params.iTargetBitrate = params.bit_rate;
+ svc_params.iUsageType = SCREEN_CONTENT_REAL_TIME;
+ svc_params.sSpatialLayers[0].fFrameRate = svc_params.fMaxFrameRate;
+ svc_params.sSpatialLayers[0].iMaxSpatialBitrate = svc_params.iTargetBitrate;
+ svc_params.sSpatialLayers[0].iSpatialBitrate = svc_params.iTargetBitrate;
+ svc_params.sSpatialLayers[0].iVideoHeight = svc_params.iPicHeight;
+ svc_params.sSpatialLayers[0].iVideoWidth = svc_params.iPicWidth;
+
+ if (int err = openh264_encoder_->InitializeExt(&svc_params)) {
+ DVLOG(1) << "Failed to init OpenH264 encoder: error=" << err;
+ return nullptr;
+ }
+
+ int video_format = EVideoFormatType::videoFormatI420;
+ if (int err = openh264_encoder_->SetOption(ENCODER_OPTION_DATAFORMAT,
+ &video_format)) {
+ DVLOG(1) << "Failed to set data format for OpenH264 encoder: error=" << err;
+ return nullptr;
+ }
+
+ return this;
+}
+
+void WiFiDisplayVideoEncoderSVC::InsertFrameOnMediaThread(
+ scoped_refptr<media::VideoFrame> video_frame,
+ base::TimeTicks reference_time,
+ bool send_idr) {
+ DCHECK_EQ(media::PIXEL_FORMAT_I420, video_frame->format());
+
+ if (start_time_.is_null())
+ start_time_ = reference_time;
+
+ SSourcePicture picture;
+ std::memset(&picture, 0, sizeof(picture));
+ picture.iColorFormat = EVideoFormatType::videoFormatI420;
+ picture.iPicHeight = video_frame->coded_size().height();
+ picture.iPicWidth = video_frame->coded_size().width();
+ picture.uiTimeStamp = (reference_time - start_time_).InMilliseconds();
+ for (size_t plane_count = video_frame->NumPlanes(video_frame->format()),
+ plane = 0u;
+ plane < plane_count; ++plane) {
+ picture.pData[plane] = video_frame->data(plane);
+ picture.iStride[plane] = video_frame->stride(plane);
+ }
+
+ if (send_idr) {
+ if (int err = openh264_encoder_->ForceIntraFrame(true)) {
+ DVLOG(1) << "Failed to force intra frame using OpenH264 encoder: error="
+ << err;
+ }
+ }
+
+ SFrameBSInfo info;
+ std::memset(&info, 0, sizeof(info));
+ if (int err = openh264_encoder_->EncodeFrame(&picture, &info)) {
+ DVLOG(1) << "Failed to encode frame using OpenH264 encoder: error=" << err;
+ return;
+ }
+
+ if (encoded_callback_.is_null())
+ return;
+
+ switch (info.eFrameType) {
+ case EVideoFrameType::videoFrameTypeInvalid:
+ case EVideoFrameType::videoFrameTypeSkip:
+ return;
+ default:
+ break;
+ }
+
+ std::string data;
+ data.reserve(CalculateFrameBitStreamLength(info));
+
+ for (int i = 0; i < info.iLayerNum; ++i) {
+ const SLayerBSInfo& layer_info = info.sLayerInfo[i];
+ data.append(reinterpret_cast<const char*>(layer_info.pBsBuf),
+ CalculateLayerBitStreamLength(layer_info));
+ }
+
+ const bool key_frame = info.eFrameType == EVideoFrameType::videoFrameTypeIDR;
+ encoded_callback_.Run(
+ std::unique_ptr<WiFiDisplayEncodedFrame>(new WiFiDisplayEncodedFrame(
+ std::move(data), reference_time, base::TimeTicks::Now(), key_frame)));
+}
+
+} // namespace
+
+// static
+void WiFiDisplayVideoEncoder::CreateSVC(
+ const InitParameters& params,
+ const VideoEncoderCallback& encoder_callback) {
+ WiFiDisplayVideoEncoderSVC::Create(params, encoder_callback);
+}
+
+} // namespace extensions
diff --git a/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_video_encoder_vea.cc b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_video_encoder_vea.cc
new file mode 100644
index 00000000000..b77dcfbe1fc
--- /dev/null
+++ b/chromium/extensions/renderer/api/display_source/wifi_display/wifi_display_video_encoder_vea.cc
@@ -0,0 +1,237 @@
+// 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 "extensions/renderer/api/display_source/wifi_display/wifi_display_video_encoder.h"
+
+#include <list>
+#include <memory>
+#include <string>
+
+#include "base/bind.h"
+#include "base/task_runner_util.h"
+#include "content/public/renderer/video_encode_accelerator.h"
+#include "media/base/bind_to_current_loop.h"
+
+namespace extensions {
+
+namespace {
+
+// This video encoder implements hardware accelerated H.264 video encoding
+// using media::VideoEncodeAccelerator.
+class WiFiDisplayVideoEncoderVEA final
+ : public WiFiDisplayVideoEncoder,
+ public media::VideoEncodeAccelerator::Client {
+ public:
+ static void Create(
+ const InitParameters& params,
+ const VideoEncoderCallback& encoder_callback,
+ scoped_refptr<base::SingleThreadTaskRunner> media_task_runner,
+ std::unique_ptr<media::VideoEncodeAccelerator> vea);
+
+ private:
+ WiFiDisplayVideoEncoderVEA(
+ scoped_refptr<base::SingleThreadTaskRunner> media_task_runner,
+ media::VideoEncodeAccelerator* vea,
+ const CreateEncodeMemoryCallback& create_memory_callback);
+ ~WiFiDisplayVideoEncoderVEA() override;
+
+ // media::VideoEncodeAccelerator::Client
+ void RequireBitstreamBuffers(unsigned int input_count,
+ const gfx::Size& input_coded_size,
+ size_t output_buffer_size) override;
+
+ void BitstreamBufferReady(int32_t bitstream_buffer_id,
+ size_t payload_size,
+ bool key_frame) override;
+ void NotifyError(media::VideoEncodeAccelerator::Error error) override;
+
+ scoped_refptr<WiFiDisplayVideoEncoder> InitOnMediaThread(
+ const InitParameters& params);
+ void InsertFrameOnMediaThread(scoped_refptr<media::VideoFrame> video_frame,
+ base::TimeTicks reference_time,
+ bool send_idr) override;
+ void OnCreateSharedMemory(std::unique_ptr<base::SharedMemory> memory);
+ void OnReceivedSharedMemory(std::unique_ptr<base::SharedMemory> memory);
+
+ private:
+ struct InProgressFrameEncode {
+ InProgressFrameEncode(scoped_refptr<media::VideoFrame> video_frame,
+ base::TimeTicks reference_time);
+ ~InProgressFrameEncode();
+ // The source content to encode.
+ const scoped_refptr<media::VideoFrame> video_frame;
+
+ // The reference time for this frame.
+ const base::TimeTicks reference_time;
+ };
+ // FIFO list.
+ std::list<InProgressFrameEncode> in_progress_frame_encodes_;
+ media::VideoEncodeAccelerator* vea_; // Owned on media thread.
+ ScopedVector<base::SharedMemory> output_buffers_;
+ size_t output_buffers_count_;
+ CreateEncodeMemoryCallback create_video_encode_memory_cb_;
+};
+
+WiFiDisplayVideoEncoderVEA::InProgressFrameEncode::InProgressFrameEncode(
+ scoped_refptr<media::VideoFrame> video_frame,
+ base::TimeTicks reference_time)
+ : video_frame(std::move(video_frame)), reference_time(reference_time) {}
+
+WiFiDisplayVideoEncoderVEA::InProgressFrameEncode::~InProgressFrameEncode() =
+ default;
+
+// static
+void WiFiDisplayVideoEncoderVEA::Create(
+ const InitParameters& params,
+ const VideoEncoderCallback& encoder_callback,
+ scoped_refptr<base::SingleThreadTaskRunner> media_task_runner,
+ std::unique_ptr<media::VideoEncodeAccelerator> vea) {
+ if (!vea || !media_task_runner) {
+ encoder_callback.Run(nullptr);
+ return;
+ }
+
+ base::PostTaskAndReplyWithResult(
+ media_task_runner.get(), FROM_HERE,
+ base::Bind(&WiFiDisplayVideoEncoderVEA::InitOnMediaThread,
+ make_scoped_refptr(new WiFiDisplayVideoEncoderVEA(
+ std::move(media_task_runner), vea.release(),
+ params.create_memory_callback)),
+ params),
+ encoder_callback);
+}
+
+WiFiDisplayVideoEncoderVEA::WiFiDisplayVideoEncoderVEA(
+ scoped_refptr<base::SingleThreadTaskRunner> media_task_runner,
+ media::VideoEncodeAccelerator* vea,
+ const CreateEncodeMemoryCallback& create_video_encode_memory_cb)
+ : WiFiDisplayVideoEncoder(std::move(media_task_runner)),
+ vea_(vea),
+ output_buffers_count_(0),
+ create_video_encode_memory_cb_(create_video_encode_memory_cb) {}
+
+WiFiDisplayVideoEncoderVEA::~WiFiDisplayVideoEncoderVEA() {
+ media_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&media::VideoEncodeAccelerator::Destroy,
+ base::Unretained(vea_)));
+}
+
+scoped_refptr<WiFiDisplayVideoEncoder>
+WiFiDisplayVideoEncoderVEA::InitOnMediaThread(const InitParameters& params) {
+ media::VideoCodecProfile profile = (params.profile == wds::CHP)
+ ? media::H264PROFILE_HIGH : media::H264PROFILE_BASELINE;
+ bool success =
+ vea_->Initialize(media::PIXEL_FORMAT_I420, params.frame_size,
+ profile, params.bit_rate, this);
+ if (success)
+ return this;
+
+ DVLOG(1) << "Failed to init VEA";
+ return nullptr;
+}
+
+// Called to allocate the input and output buffers.
+void WiFiDisplayVideoEncoderVEA::RequireBitstreamBuffers(
+ unsigned int input_count,
+ const gfx::Size& input_coded_size,
+ size_t output_buffer_size) {
+ DCHECK(media_task_runner_->BelongsToCurrentThread());
+ output_buffers_count_ = input_count;
+ for (size_t i = 0; i < input_count; ++i) {
+ create_video_encode_memory_cb_.Run(
+ output_buffer_size,
+ base::Bind(&WiFiDisplayVideoEncoderVEA::OnCreateSharedMemory, this));
+ }
+}
+
+// Note: This method can be called on any thread.
+void WiFiDisplayVideoEncoderVEA::OnCreateSharedMemory(
+ std::unique_ptr<base::SharedMemory> memory) {
+ media_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&WiFiDisplayVideoEncoderVEA::OnReceivedSharedMemory,
+ this, base::Passed(&memory)));
+}
+
+void WiFiDisplayVideoEncoderVEA::OnReceivedSharedMemory(
+ std::unique_ptr<base::SharedMemory> memory) {
+ DCHECK(media_task_runner_->BelongsToCurrentThread());
+
+ output_buffers_.push_back(std::move(memory));
+
+ // Wait until all requested buffers are received.
+ if (output_buffers_.size() < output_buffers_count_)
+ return;
+
+ // Immediately provide all output buffers to the VEA.
+ for (size_t i = 0; i < output_buffers_.size(); ++i) {
+ vea_->UseOutputBitstreamBuffer(media::BitstreamBuffer(
+ static_cast<int32_t>(i), output_buffers_[i]->handle(),
+ output_buffers_[i]->mapped_size()));
+ }
+}
+
+void WiFiDisplayVideoEncoderVEA::InsertFrameOnMediaThread(
+ scoped_refptr<media::VideoFrame> video_frame,
+ base::TimeTicks reference_time,
+ bool send_idr) {
+ in_progress_frame_encodes_.emplace_back(video_frame, reference_time);
+ DCHECK(vea_);
+ vea_->Encode(video_frame, send_idr);
+}
+
+void WiFiDisplayVideoEncoderVEA::BitstreamBufferReady(
+ int32_t bitstream_buffer_id,
+ size_t payload_size,
+ bool key_frame) {
+ if (bitstream_buffer_id >= static_cast<int>(output_buffers_.size())) {
+ DVLOG(1) << "WiFiDisplayVideoEncoderVEA::BitstreamBufferReady()"
+ << ": invalid bitstream_buffer_id=" << bitstream_buffer_id;
+ return;
+ }
+ base::SharedMemory* output_buffer = output_buffers_[bitstream_buffer_id];
+ if (payload_size > output_buffer->mapped_size()) {
+ DVLOG(1) << "WiFiDisplayVideoEncoderVEA::BitstreamBufferReady()"
+ << ": invalid payload_size=" << payload_size;
+ return;
+ }
+ if (in_progress_frame_encodes_.empty()) {
+ DVLOG(1) << "WiFiDisplayVideoEncoderVEA::BitstreamBufferReady()"
+ << ": unexpected frame";
+ return;
+ }
+ const InProgressFrameEncode& request = in_progress_frame_encodes_.front();
+
+ if (!encoded_callback_.is_null()) {
+ encoded_callback_.Run(
+ std::unique_ptr<WiFiDisplayEncodedFrame>(new WiFiDisplayEncodedFrame(
+ std::string(reinterpret_cast<const char*>(output_buffer->memory()),
+ payload_size),
+ request.reference_time, base::TimeTicks::Now(), key_frame)));
+ }
+ DCHECK(vea_);
+ vea_->UseOutputBitstreamBuffer(
+ media::BitstreamBuffer(bitstream_buffer_id, output_buffer->handle(),
+ output_buffer->mapped_size()));
+
+ in_progress_frame_encodes_.pop_front();
+}
+
+void WiFiDisplayVideoEncoderVEA::NotifyError(
+ media::VideoEncodeAccelerator::Error error) {
+ if (!error_callback_.is_null())
+ error_callback_.Run();
+}
+
+} // namespace
+
+// static
+void WiFiDisplayVideoEncoder::CreateVEA(
+ const InitParameters& params,
+ const VideoEncoderCallback& encoder_callback) {
+ auto on_vea_cb =
+ base::Bind(&WiFiDisplayVideoEncoderVEA::Create, params, encoder_callback);
+ params.vea_create_callback.Run(media::BindToCurrentLoop(on_vea_cb));
+}
+
+} // namespace extensions
diff --git a/chromium/extensions/renderer/api/serial/data_receiver_unittest.cc b/chromium/extensions/renderer/api/serial/data_receiver_unittest.cc
index 0c7dc000d8a..95a19fdc75b 100644
--- a/chromium/extensions/renderer/api/serial/data_receiver_unittest.cc
+++ b/chromium/extensions/renderer/api/serial/data_receiver_unittest.cc
@@ -99,7 +99,7 @@ class DataReceiverTest : public ApiTestBase {
base::Bind(base::DoNothing));
}
- void ReadyToSend(scoped_ptr<device::WritableBuffer> buffer) {
+ void ReadyToSend(std::unique_ptr<device::WritableBuffer> buffer) {
if (data_to_send_.empty() && error_to_send_.empty())
return;
diff --git a/chromium/extensions/renderer/api/serial/data_sender_unittest.cc b/chromium/extensions/renderer/api/serial/data_sender_unittest.cc
index a38dd10f201..457e25ce777 100644
--- a/chromium/extensions/renderer/api/serial/data_sender_unittest.cc
+++ b/chromium/extensions/renderer/api/serial/data_sender_unittest.cc
@@ -49,7 +49,7 @@ class DataSenderTest : public ApiTestBase {
base::Bind(base::DoNothing));
}
- void ReadyToReceive(scoped_ptr<device::ReadOnlyBuffer> buffer) {
+ void ReadyToReceive(std::unique_ptr<device::ReadOnlyBuffer> buffer) {
std::string data(buffer->GetData(), buffer->GetSize());
if (expected_data_.empty()) {
buffer_ = std::move(buffer);
@@ -85,7 +85,7 @@ class DataSenderTest : public ApiTestBase {
}
scoped_refptr<device::DataSinkReceiver> receiver_;
- scoped_ptr<device::ReadOnlyBuffer> buffer_;
+ std::unique_ptr<device::ReadOnlyBuffer> buffer_;
DISALLOW_COPY_AND_ASSIGN(DataSenderTest);
};
diff --git a/chromium/extensions/renderer/api/serial/serial_api_unittest.cc b/chromium/extensions/renderer/api/serial/serial_api_unittest.cc
index 82f8f2a36f1..8f745ec4ea0 100644
--- a/chromium/extensions/renderer/api/serial/serial_api_unittest.cc
+++ b/chromium/extensions/renderer/api/serial/serial_api_unittest.cc
@@ -8,7 +8,7 @@
#include <utility>
#include "base/macros.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "device/serial/serial_device_enumerator.h"
#include "device/serial/serial_service_impl.h"
#include "device/serial/test_serial_io_handler.h"
@@ -422,7 +422,7 @@ class SerialApiTest : public ApiTestBase {
scoped_refptr<TestIoHandlerBase> io_handler_;
- scoped_ptr<StashBackend> stash_backend_;
+ std::unique_ptr<StashBackend> stash_backend_;
private:
scoped_refptr<device::SerialIoHandler> GetIoHandler() {
@@ -437,7 +437,7 @@ class SerialApiTest : public ApiTestBase {
new device::SerialConnectionFactory(
base::Bind(&SerialApiTest::GetIoHandler, base::Unretained(this)),
base::ThreadTaskRunnerHandle::Get()),
- scoped_ptr<device::SerialDeviceEnumerator>(
+ std::unique_ptr<device::SerialDeviceEnumerator>(
new FakeSerialDeviceEnumerator),
std::move(request));
}
@@ -702,7 +702,7 @@ TEST_F(SerialApiTest, SendUnknownConnectionId) {
// https://crbug.com/538774
TEST_F(SerialApiTest, DISABLED_StashAndRestoreDuringEcho) {
ASSERT_NO_FATAL_FAILURE(RunTest("serial_unittest.js", "testSendAndStash"));
- scoped_ptr<ModuleSystemTestEnvironment> new_env(CreateEnvironment());
+ std::unique_ptr<ModuleSystemTestEnvironment> new_env(CreateEnvironment());
ApiTestEnvironment new_api_test_env(new_env.get());
PrepareEnvironment(&new_api_test_env, stash_backend_.get());
new_api_test_env.RunTest("serial_unittest.js", "testRestoreAndReceive");
@@ -713,7 +713,7 @@ TEST_F(SerialApiTest, DISABLED_StashAndRestoreDuringEchoError) {
new ReceiveErrorTestIoHandler(device::serial::ReceiveError::DEVICE_LOST);
ASSERT_NO_FATAL_FAILURE(
RunTest("serial_unittest.js", "testRestoreAndReceiveErrorSetUp"));
- scoped_ptr<ModuleSystemTestEnvironment> new_env(CreateEnvironment());
+ std::unique_ptr<ModuleSystemTestEnvironment> new_env(CreateEnvironment());
ApiTestEnvironment new_api_test_env(new_env.get());
PrepareEnvironment(&new_api_test_env, stash_backend_.get());
new_api_test_env.RunTest("serial_unittest.js", "testRestoreAndReceiveError");
@@ -729,7 +729,7 @@ TEST_F(SerialApiTest, MAYBE_StashAndRestoreNoConnections) {
ASSERT_NO_FATAL_FAILURE(
RunTest("serial_unittest.js", "testStashNoConnections"));
io_handler_ = nullptr;
- scoped_ptr<ModuleSystemTestEnvironment> new_env(CreateEnvironment());
+ std::unique_ptr<ModuleSystemTestEnvironment> new_env(CreateEnvironment());
ApiTestEnvironment new_api_test_env(new_env.get());
PrepareEnvironment(&new_api_test_env, stash_backend_.get());
new_api_test_env.RunTest("serial_unittest.js", "testRestoreNoConnections");
diff --git a/chromium/extensions/renderer/api_activity_logger.cc b/chromium/extensions/renderer/api_activity_logger.cc
index e78c27452f1..ab4c67e4dc3 100644
--- a/chromium/extensions/renderer/api_activity_logger.cc
+++ b/chromium/extensions/renderer/api_activity_logger.cc
@@ -56,11 +56,11 @@ void APIActivityLogger::LogInternal(
// Get the array of api call arguments.
v8::Local<v8::Array> arg_array = v8::Local<v8::Array>::Cast(args[2]);
if (arg_array->Length() > 0) {
- scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
+ std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create());
ActivityLogConverterStrategy strategy;
converter->SetFunctionAllowed(true);
converter->SetStrategy(&strategy);
- scoped_ptr<base::ListValue> arg_list(new base::ListValue());
+ std::unique_ptr<base::ListValue> arg_list(new base::ListValue());
for (size_t i = 0; i < arg_array->Length(); ++i) {
arg_list->Set(
i,
diff --git a/chromium/extensions/renderer/api_definitions_natives.cc b/chromium/extensions/renderer/api_definitions_natives.cc
index 96f1f2c6eb8..1db01d0470f 100644
--- a/chromium/extensions/renderer/api_definitions_natives.cc
+++ b/chromium/extensions/renderer/api_definitions_natives.cc
@@ -15,7 +15,7 @@ ApiDefinitionsNatives::ApiDefinitionsNatives(Dispatcher* dispatcher,
ScriptContext* context)
: ObjectBackedNativeHandler(context), dispatcher_(dispatcher) {
RouteFunction(
- "GetExtensionAPIDefinitionsForTest",
+ "GetExtensionAPIDefinitionsForTest", "test",
base::Bind(&ApiDefinitionsNatives::GetExtensionAPIDefinitionsForTest,
base::Unretained(this)));
}
diff --git a/chromium/extensions/renderer/api_test_base.cc b/chromium/extensions/renderer/api_test_base.cc
index 81ec07f18d6..0a5e458aba8 100644
--- a/chromium/extensions/renderer/api_test_base.cc
+++ b/chromium/extensions/renderer/api_test_base.cc
@@ -128,15 +128,10 @@ void ApiTestEnvironment::RegisterModules() {
NULL,
v8_schema_registry_.get());
env()->module_system()->RegisterNativeHandler(
- "process",
- scoped_ptr<NativeHandler>(new ProcessInfoNativeHandler(
- env()->context(),
- env()->context()->GetExtensionID(),
- env()->context()->GetContextTypeDescription(),
- false,
- false,
- 2,
- false)));
+ "process", std::unique_ptr<NativeHandler>(new ProcessInfoNativeHandler(
+ env()->context(), env()->context()->GetExtensionID(),
+ env()->context()->GetContextTypeDescription(), false,
+ false, 2, false)));
env()->RegisterTestFile("test_environment_specific_bindings",
"unit_test_environment_specific_bindings.js");
diff --git a/chromium/extensions/renderer/api_test_base.h b/chromium/extensions/renderer/api_test_base.h
index 8b62049924c..9d86818b1e3 100644
--- a/chromium/extensions/renderer/api_test_base.h
+++ b/chromium/extensions/renderer/api_test_base.h
@@ -91,7 +91,7 @@ class ApiTestEnvironment {
ModuleSystemTestEnvironment* env_;
TestServiceProvider* service_provider_;
- scoped_ptr<V8SchemaRegistry> v8_schema_registry_;
+ std::unique_ptr<V8SchemaRegistry> v8_schema_registry_;
};
// A base class for unit testing apps/extensions API custom bindings implemented
@@ -116,7 +116,7 @@ class ApiTestBase : public ModuleSystemTest {
private:
base::MessageLoop message_loop_;
- scoped_ptr<ApiTestEnvironment> test_env_;
+ std::unique_ptr<ApiTestEnvironment> test_env_;
};
} // namespace extensions
diff --git a/chromium/extensions/renderer/app_window_custom_bindings.cc b/chromium/extensions/renderer/app_window_custom_bindings.cc
index 492731d1a82..6553e5e3071 100644
--- a/chromium/extensions/renderer/app_window_custom_bindings.cc
+++ b/chromium/extensions/renderer/app_window_custom_bindings.cc
@@ -72,7 +72,7 @@ void AppWindowCustomBindings::GetWindowControlsHtmlTemplate(
ResourceBundle::GetSharedInstance()
.GetRawDataResource(IDR_WINDOW_CONTROLS_TEMPLATE_HTML)
.as_string());
- scoped_ptr<content::V8ValueConverter> converter(
+ std::unique_ptr<content::V8ValueConverter> converter(
content::V8ValueConverter::create());
result = converter->ToV8Value(&value, context()->v8_context());
}
diff --git a/chromium/extensions/renderer/css_native_handler.cc b/chromium/extensions/renderer/css_native_handler.cc
index d7cdc39f164..f8adfa0c9a6 100644
--- a/chromium/extensions/renderer/css_native_handler.cc
+++ b/chromium/extensions/renderer/css_native_handler.cc
@@ -15,7 +15,7 @@ using blink::WebString;
CssNativeHandler::CssNativeHandler(ScriptContext* context)
: ObjectBackedNativeHandler(context) {
- RouteFunction("CanonicalizeCompoundSelector",
+ RouteFunction("CanonicalizeCompoundSelector", "declarativeContent",
base::Bind(&CssNativeHandler::CanonicalizeCompoundSelector,
base::Unretained(this)));
}
diff --git a/chromium/extensions/renderer/dispatcher.cc b/chromium/extensions/renderer/dispatcher.cc
index 60a4a11bfec..f78382297e1 100644
--- a/chromium/extensions/renderer/dispatcher.cc
+++ b/chromium/extensions/renderer/dispatcher.cc
@@ -6,6 +6,7 @@
#include <stddef.h>
+#include <memory>
#include <utility>
#include "base/bind.h"
@@ -15,7 +16,7 @@
#include "base/debug/alias.h"
#include "base/lazy_instance.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics_action.h"
#include "base/strings/string_piece.h"
@@ -59,7 +60,6 @@
#include "extensions/renderer/blob_native_handler.h"
#include "extensions/renderer/content_watcher.h"
#include "extensions/renderer/context_menus_custom_bindings.h"
-#include "extensions/renderer/css_native_handler.h"
#include "extensions/renderer/dispatcher_delegate.h"
#include "extensions/renderer/display_source_custom_bindings.h"
#include "extensions/renderer/document_custom_bindings.h"
@@ -70,13 +70,10 @@
#include "extensions/renderer/extensions_renderer_client.h"
#include "extensions/renderer/file_system_natives.h"
#include "extensions/renderer/guest_view/guest_view_internal_custom_bindings.h"
-#include "extensions/renderer/i18n_custom_bindings.h"
#include "extensions/renderer/id_generator_custom_bindings.h"
-#include "extensions/renderer/lazy_background_page_native_handler.h"
#include "extensions/renderer/logging_native_handler.h"
#include "extensions/renderer/messaging_bindings.h"
#include "extensions/renderer/module_system.h"
-#include "extensions/renderer/print_native_handler.h"
#include "extensions/renderer/process_info_native_handler.h"
#include "extensions/renderer/render_frame_observer_natives.h"
#include "extensions/renderer/renderer_extension_registry.h"
@@ -171,7 +168,7 @@ void CallModuleMethod(const std::string& module_name,
v8::HandleScope handle_scope(context->isolate());
v8::Context::Scope context_scope(context->v8_context());
- scoped_ptr<content::V8ValueConverter> converter(
+ std::unique_ptr<content::V8ValueConverter> converter(
content::V8ValueConverter::create());
std::vector<v8::Local<v8::Value>> arguments;
@@ -229,7 +226,7 @@ Dispatcher::Dispatcher(DispatcherDelegate* delegate)
script_injection_manager_.reset(
new ScriptInjectionManager(user_script_set_manager_.get()));
user_script_set_manager_observer_.Add(user_script_set_manager_.get());
- request_sender_.reset(new RequestSender(this));
+ request_sender_.reset(new RequestSender());
PopulateSourceMap();
WakeEventPage::Get()->Init(RenderThread::Get());
@@ -321,7 +318,7 @@ void Dispatcher::DidCreateScriptContext(
InitOriginPermissions(context->extension());
{
- scoped_ptr<ModuleSystem> module_system(
+ std::unique_ptr<ModuleSystem> module_system(
new ModuleSystem(context, &source_map_));
context->set_module_system(std::move(module_system));
}
@@ -435,7 +432,7 @@ void Dispatcher::DidInitializeServiceWorkerContextOnWorkerThread(
extension, Feature::SERVICE_WORKER_CONTEXT);
context->set_url(url);
- g_worker_script_context_set.Get().Insert(make_scoped_ptr(context));
+ g_worker_script_context_set.Get().Insert(base::WrapUnique(context));
v8::Isolate* isolate = context->isolate();
@@ -599,7 +596,7 @@ void Dispatcher::InvokeModuleSystemMethod(content::RenderFrame* render_frame,
const std::string& function_name,
const base::ListValue& args,
bool user_gesture) {
- scoped_ptr<WebScopedUserGesture> web_user_gesture;
+ std::unique_ptr<WebScopedUserGesture> web_user_gesture;
if (user_gesture)
web_user_gesture.reset(new WebScopedUserGesture);
@@ -822,87 +819,78 @@ void Dispatcher::RegisterNativeHandlers(ModuleSystem* module_system,
RequestSender* request_sender,
V8SchemaRegistry* v8_schema_registry) {
module_system->RegisterNativeHandler(
- "chrome", scoped_ptr<NativeHandler>(new ChromeNativeHandler(context)));
+ "chrome",
+ std::unique_ptr<NativeHandler>(new ChromeNativeHandler(context)));
module_system->RegisterNativeHandler(
- "lazy_background_page",
- scoped_ptr<NativeHandler>(new LazyBackgroundPageNativeHandler(context)));
- module_system->RegisterNativeHandler(
- "logging", scoped_ptr<NativeHandler>(new LoggingNativeHandler(context)));
+ "logging",
+ std::unique_ptr<NativeHandler>(new LoggingNativeHandler(context)));
module_system->RegisterNativeHandler("schema_registry",
v8_schema_registry->AsNativeHandler());
module_system->RegisterNativeHandler(
- "print", scoped_ptr<NativeHandler>(new PrintNativeHandler(context)));
- module_system->RegisterNativeHandler(
"test_features",
- scoped_ptr<NativeHandler>(new TestFeaturesNativeHandler(context)));
+ std::unique_ptr<NativeHandler>(new TestFeaturesNativeHandler(context)));
module_system->RegisterNativeHandler(
"test_native_handler",
- scoped_ptr<NativeHandler>(new TestNativeHandler(context)));
+ std::unique_ptr<NativeHandler>(new TestNativeHandler(context)));
module_system->RegisterNativeHandler(
"user_gestures",
- scoped_ptr<NativeHandler>(new UserGesturesNativeHandler(context)));
+ std::unique_ptr<NativeHandler>(new UserGesturesNativeHandler(context)));
module_system->RegisterNativeHandler(
- "utils", scoped_ptr<NativeHandler>(new UtilsNativeHandler(context)));
+ "utils", std::unique_ptr<NativeHandler>(new UtilsNativeHandler(context)));
module_system->RegisterNativeHandler(
"v8_context",
- scoped_ptr<NativeHandler>(new V8ContextNativeHandler(context)));
+ std::unique_ptr<NativeHandler>(new V8ContextNativeHandler(context)));
module_system->RegisterNativeHandler(
- "event_natives", scoped_ptr<NativeHandler>(new EventBindings(context)));
+ "event_natives",
+ std::unique_ptr<NativeHandler>(new EventBindings(context)));
module_system->RegisterNativeHandler(
- "messaging_natives",
- scoped_ptr<NativeHandler>(MessagingBindings::Get(dispatcher, context)));
+ "messaging_natives", std::unique_ptr<NativeHandler>(
+ MessagingBindings::Get(dispatcher, context)));
module_system->RegisterNativeHandler(
- "apiDefinitions",
- scoped_ptr<NativeHandler>(
- new ApiDefinitionsNatives(dispatcher, context)));
+ "apiDefinitions", std::unique_ptr<NativeHandler>(
+ new ApiDefinitionsNatives(dispatcher, context)));
module_system->RegisterNativeHandler(
- "sendRequest",
- scoped_ptr<NativeHandler>(
- new SendRequestNatives(request_sender, context)));
+ "sendRequest", std::unique_ptr<NativeHandler>(
+ new SendRequestNatives(request_sender, context)));
module_system->RegisterNativeHandler(
- "setIcon",
- scoped_ptr<NativeHandler>(new SetIconNatives(context)));
+ "setIcon", std::unique_ptr<NativeHandler>(new SetIconNatives(context)));
module_system->RegisterNativeHandler(
"activityLogger",
- scoped_ptr<NativeHandler>(new APIActivityLogger(context)));
+ std::unique_ptr<NativeHandler>(new APIActivityLogger(context)));
module_system->RegisterNativeHandler(
"renderFrameObserverNatives",
- scoped_ptr<NativeHandler>(new RenderFrameObserverNatives(context)));
+ std::unique_ptr<NativeHandler>(new RenderFrameObserverNatives(context)));
// Natives used by multiple APIs.
module_system->RegisterNativeHandler(
"file_system_natives",
- scoped_ptr<NativeHandler>(new FileSystemNatives(context)));
+ std::unique_ptr<NativeHandler>(new FileSystemNatives(context)));
// Custom bindings.
module_system->RegisterNativeHandler(
"app_window_natives",
- scoped_ptr<NativeHandler>(new AppWindowCustomBindings(context)));
+ std::unique_ptr<NativeHandler>(new AppWindowCustomBindings(context)));
module_system->RegisterNativeHandler(
"blob_natives",
- scoped_ptr<NativeHandler>(new BlobNativeHandler(context)));
+ std::unique_ptr<NativeHandler>(new BlobNativeHandler(context)));
module_system->RegisterNativeHandler(
"context_menus",
- scoped_ptr<NativeHandler>(new ContextMenusCustomBindings(context)));
- module_system->RegisterNativeHandler(
- "css_natives", scoped_ptr<NativeHandler>(new CssNativeHandler(context)));
+ std::unique_ptr<NativeHandler>(new ContextMenusCustomBindings(context)));
module_system->RegisterNativeHandler(
"document_natives",
- scoped_ptr<NativeHandler>(new DocumentCustomBindings(context)));
- module_system->RegisterNativeHandler(
- "guest_view_internal",
- scoped_ptr<NativeHandler>(
- new GuestViewInternalCustomBindings(context)));
+ std::unique_ptr<NativeHandler>(new DocumentCustomBindings(context)));
module_system->RegisterNativeHandler(
- "i18n", scoped_ptr<NativeHandler>(new I18NCustomBindings(context)));
+ "guest_view_internal", std::unique_ptr<NativeHandler>(
+ new GuestViewInternalCustomBindings(context)));
module_system->RegisterNativeHandler(
"id_generator",
- scoped_ptr<NativeHandler>(new IdGeneratorCustomBindings(context)));
+ std::unique_ptr<NativeHandler>(new IdGeneratorCustomBindings(context)));
module_system->RegisterNativeHandler(
- "runtime", scoped_ptr<NativeHandler>(new RuntimeCustomBindings(context)));
+ "runtime",
+ std::unique_ptr<NativeHandler>(new RuntimeCustomBindings(context)));
module_system->RegisterNativeHandler(
"display_source",
- scoped_ptr<NativeHandler>(new DisplaySourceCustomBindings(context)));
+ std::unique_ptr<NativeHandler>(new DisplaySourceCustomBindings(context)));
}
bool Dispatcher::OnControlMessageReceived(const IPC::Message& message) {
@@ -1005,7 +993,7 @@ void Dispatcher::OnCancelSuspend(const std::string& extension_id) {
}
void Dispatcher::OnDeliverMessage(int target_port_id, const Message& message) {
- scoped_ptr<RequestSender::ScopedTabID> scoped_tab_id;
+ std::unique_ptr<RequestSender::ScopedTabID> scoped_tab_id;
std::map<int, int>::const_iterator it =
port_to_tab_id_map_.find(target_port_id);
if (it != port_to_tab_id_map_.end()) {
@@ -1171,9 +1159,9 @@ void Dispatcher::OnUpdatePermissions(
if (!extension)
return;
- scoped_ptr<const PermissionSet> active =
+ std::unique_ptr<const PermissionSet> active =
params.active_permissions.ToPermissionSet();
- scoped_ptr<const PermissionSet> withheld =
+ std::unique_ptr<const PermissionSet> withheld =
params.withheld_permissions.ToPermissionSet();
UpdateOriginPermissions(
@@ -1411,8 +1399,8 @@ void Dispatcher::RegisterBinding(const std::string& api_name,
if (!source_map_.Contains(api_name)) {
module_system->RegisterNativeHandler(
api_name,
- scoped_ptr<NativeHandler>(new BindingGeneratingNativeHandler(
- context, api_name, "binding")));
+ std::unique_ptr<NativeHandler>(
+ new BindingGeneratingNativeHandler(context, api_name, "binding")));
module_system->SetNativeLazyField(
bind_object, bind_name, api_name, "binding");
} else {
@@ -1437,14 +1425,11 @@ void Dispatcher::RegisterNativeHandlers(ModuleSystem* module_system,
BackgroundInfo::HasLazyBackgroundPage(extension));
module_system->RegisterNativeHandler(
"process",
- scoped_ptr<NativeHandler>(new ProcessInfoNativeHandler(
- context,
- context->GetExtensionID(),
+ std::unique_ptr<NativeHandler>(new ProcessInfoNativeHandler(
+ context, context->GetExtensionID(),
context->GetContextTypeDescription(),
ExtensionsRendererClient::Get()->IsIncognitoProcess(),
- is_component_extension,
- manifest_version,
- send_request_disabled)));
+ is_component_extension, manifest_version, send_request_disabled)));
delegate_->RegisterNativeHandlers(this, module_system, context);
}
@@ -1464,9 +1449,15 @@ void Dispatcher::UpdateContentCapabilities(ScriptContext* context) {
APIPermissionSet permissions;
for (const auto& extension :
*RendererExtensionRegistry::Get()->GetMainThreadExtensionSet()) {
+ blink::WebLocalFrame* web_frame = context->web_frame();
+ GURL url = context->url();
+ // We allow about:blank pages to take on the privileges of their parents if
+ // they aren't sandboxed.
+ if (web_frame && !web_frame->getSecurityOrigin().isUnique())
+ url = ScriptContext::GetEffectiveDocumentURL(web_frame, url, true);
const ContentCapabilitiesInfo& info =
ContentCapabilitiesInfo::Get(extension.get());
- if (info.url_patterns.MatchesURL(context->url())) {
+ if (info.url_patterns.MatchesURL(url)) {
APIPermissionSet new_permissions;
APIPermissionSet::Union(permissions, info.permissions, &new_permissions);
permissions = new_permissions;
@@ -1573,26 +1564,24 @@ v8::Local<v8::Object> Dispatcher::GetOrCreateBindObjectIfAvailable(
void Dispatcher::RequireGuestViewModules(ScriptContext* context) {
Feature::Context context_type = context->context_type();
ModuleSystem* module_system = context->module_system();
-
- // Only set if |context| is capable of running guests in OOPIF. Used to
- // require additional module overrides.
- bool guest_view_required = false;
+ bool requires_guest_view_module = false;
// Require AppView.
if (context->GetAvailability("appViewEmbedderInternal").is_available()) {
+ requires_guest_view_module = true;
module_system->Require("appView");
}
// Require ExtensionOptions.
if (context->GetAvailability("extensionOptionsInternal").is_available()) {
+ requires_guest_view_module = true;
module_system->Require("extensionOptions");
module_system->Require("extensionOptionsAttributes");
-
- guest_view_required = true;
}
// Require ExtensionView.
if (context->GetAvailability("extensionViewInternal").is_available()) {
+ requires_guest_view_module = true;
module_system->Require("extensionView");
module_system->Require("extensionViewApiMethods");
module_system->Require("extensionViewAttributes");
@@ -1600,6 +1589,7 @@ void Dispatcher::RequireGuestViewModules(ScriptContext* context) {
// Require WebView.
if (context->GetAvailability("webViewInternal").is_available()) {
+ requires_guest_view_module = true;
module_system->Require("webView");
module_system->Require("webViewApiMethods");
module_system->Require("webViewAttributes");
@@ -1607,11 +1597,9 @@ void Dispatcher::RequireGuestViewModules(ScriptContext* context) {
.is_available()) {
module_system->Require("webViewExperimental");
}
-
- guest_view_required = true;
}
- if (guest_view_required &&
+ if (requires_guest_view_module &&
content::BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) {
module_system->Require("guestViewIframe");
module_system->Require("guestViewIframeContainer");
diff --git a/chromium/extensions/renderer/dispatcher.h b/chromium/extensions/renderer/dispatcher.h
index 37ab0a312dc..6438d64f13e 100644
--- a/chromium/extensions/renderer/dispatcher.h
+++ b/chromium/extensions/renderer/dispatcher.h
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <map>
+#include <memory>
#include <set>
#include <string>
#include <utility>
@@ -15,10 +16,9 @@
#include "base/gtest_prod_util.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/scoped_observer.h"
#include "base/timer/timer.h"
-#include "content/public/renderer/render_process_observer.h"
+#include "content/public/renderer/render_thread_observer.h"
#include "extensions/common/event_filter.h"
#include "extensions/common/extension.h"
#include "extensions/common/extensions_client.h"
@@ -67,7 +67,7 @@ struct Message;
// Dispatches extension control messages sent to the renderer and stores
// renderer extension related state.
-class Dispatcher : public content::RenderProcessObserver,
+class Dispatcher : public content::RenderThreadObserver,
public UserScriptSetManager::Observer {
public:
explicit Dispatcher(DispatcherDelegate* delegate);
@@ -153,7 +153,7 @@ class Dispatcher : public content::RenderProcessObserver,
FRIEND_TEST_ALL_PREFIXES(RendererPermissionsPolicyDelegateTest,
CannotScriptWebstore);
- // RenderProcessObserver implementation:
+ // RenderThreadObserver implementation:
bool OnControlMessageReceived(const IPC::Message& message) override;
void IdleNotification() override;
void OnRenderProcessShutdown() override;
@@ -267,17 +267,17 @@ class Dispatcher : public content::RenderProcessObserver,
// All the bindings contexts that are currently loaded for this renderer.
// There is zero or one for each v8 context.
- scoped_ptr<ScriptContextSet> script_context_set_;
+ std::unique_ptr<ScriptContextSet> script_context_set_;
- scoped_ptr<ContentWatcher> content_watcher_;
+ std::unique_ptr<ContentWatcher> content_watcher_;
- scoped_ptr<UserScriptSetManager> user_script_set_manager_;
+ std::unique_ptr<UserScriptSetManager> user_script_set_manager_;
- scoped_ptr<ScriptInjectionManager> script_injection_manager_;
+ std::unique_ptr<ScriptInjectionManager> script_injection_manager_;
// Same as above, but on a longer timer and will run even if the process is
// not idle, to ensure that IdleHandle gets called eventually.
- scoped_ptr<base::RepeatingTimer> forced_idle_timer_;
+ std::unique_ptr<base::RepeatingTimer> forced_idle_timer_;
// The extensions and apps that are active in this process.
ExtensionIdSet active_extension_ids_;
@@ -285,10 +285,10 @@ class Dispatcher : public content::RenderProcessObserver,
ResourceBundleSourceMap source_map_;
// Cache for the v8 representation of extension API schemas.
- scoped_ptr<V8SchemaRegistry> v8_schema_registry_;
+ std::unique_ptr<V8SchemaRegistry> v8_schema_registry_;
// Sends API requests to the extension host.
- scoped_ptr<RequestSender> request_sender_;
+ std::unique_ptr<RequestSender> request_sender_;
// The platforms system font family and size;
std::string system_font_family_;
diff --git a/chromium/extensions/renderer/display_source_custom_bindings.cc b/chromium/extensions/renderer/display_source_custom_bindings.cc
index 1a021c157b3..c2772ebb026 100644
--- a/chromium/extensions/renderer/display_source_custom_bindings.cc
+++ b/chromium/extensions/renderer/display_source_custom_bindings.cc
@@ -29,10 +29,10 @@ const char kSessionNotFound[] = "Session not found";
DisplaySourceCustomBindings::DisplaySourceCustomBindings(ScriptContext* context)
: ObjectBackedNativeHandler(context),
weak_factory_(this) {
- RouteFunction("StartSession",
+ RouteFunction("StartSession", "displaySource",
base::Bind(&DisplaySourceCustomBindings::StartSession,
weak_factory_.GetWeakPtr()));
- RouteFunction("TerminateSession",
+ RouteFunction("TerminateSession", "displaySource",
base::Bind(&DisplaySourceCustomBindings::TerminateSession,
weak_factory_.GetWeakPtr()));
}
@@ -129,13 +129,13 @@ void DisplaySourceCustomBindings::StartSession(
}
}
- scoped_ptr<DisplaySourceAuthInfo> auth_info;
+ std::unique_ptr<DisplaySourceAuthInfo> auth_info;
v8::Local<v8::Value> auth_info_v8_val =
GetChildValue(start_info, "authenticationInfo", isolate);
if (!auth_info_v8_val->IsNull()) {
CHECK(auth_info_v8_val->IsObject());
- scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
- scoped_ptr<base::Value> auth_info_val(
+ std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create());
+ std::unique_ptr<base::Value> auth_info_val(
converter->FromV8Value(auth_info_v8_val, context()->v8_context()));
CHECK(auth_info_val);
auth_info = DisplaySourceAuthInfo::FromValue(*auth_info_val);
@@ -150,7 +150,7 @@ void DisplaySourceCustomBindings::StartSession(
session_params.auth_method = auth_info->method;
session_params.auth_data = auth_info->data ? *auth_info->data : "";
}
- scoped_ptr<DisplaySourceSession> session =
+ std::unique_ptr<DisplaySourceSession> session =
DisplaySourceSessionFactory::CreateSession(session_params);
if (!session) {
isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(
@@ -271,7 +271,7 @@ void DisplaySourceCustomBindings::DispatchSessionError(
if (!message.empty())
error_info.description.reset(new std::string(message));
- scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
+ std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create());
v8::Local<v8::Value> info_arg =
converter->ToV8Value(error_info.ToValue().get(),
context()->v8_context());
diff --git a/chromium/extensions/renderer/display_source_custom_bindings.h b/chromium/extensions/renderer/display_source_custom_bindings.h
index b7e5e967ac7..13fb45ee19b 100644
--- a/chromium/extensions/renderer/display_source_custom_bindings.h
+++ b/chromium/extensions/renderer/display_source_custom_bindings.h
@@ -5,8 +5,9 @@
#ifndef EXTENSIONS_RENDERER_DISPLAY_SOURCE_CUSTOM_BINDINGS_H_
#define EXTENSIONS_RENDERER_DISPLAY_SOURCE_CUSTOM_BINDINGS_H_
+#include <memory>
+
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/common/api/display_source.h"
#include "extensions/renderer/api/display_source/display_source_session.h"
#include "extensions/renderer/object_backed_native_handler.h"
@@ -52,7 +53,7 @@ class DisplaySourceCustomBindings : public ObjectBackedNativeHandler {
DisplaySourceSession* GetDisplaySession(int sink_id) const;
- std::map<int, scoped_ptr<DisplaySourceSession>> session_map_;
+ std::map<int, std::unique_ptr<DisplaySourceSession>> session_map_;
base::WeakPtrFactory<DisplaySourceCustomBindings> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(DisplaySourceCustomBindings);
diff --git a/chromium/extensions/renderer/event_bindings.cc b/chromium/extensions/renderer/event_bindings.cc
index 87b8349d098..de99257c382 100644
--- a/chromium/extensions/renderer/event_bindings.cc
+++ b/chromium/extensions/renderer/event_bindings.cc
@@ -7,11 +7,12 @@
#include <stdint.h>
#include <map>
+#include <memory>
#include <utility>
#include "base/bind.h"
#include "base/lazy_instance.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "components/crx_file/id_util.h"
#include "content/public/child/v8_value_converter.h"
#include "content/public/renderer/render_frame.h"
@@ -44,7 +45,7 @@ base::LazyInstance<std::map<std::string, EventListenerCounts>>
// we transition between 0 and 1.
using FilteredEventListenerKey = std::pair<std::string, std::string>;
using FilteredEventListenerCounts =
- std::map<FilteredEventListenerKey, scoped_ptr<ValueCounter>>;
+ std::map<FilteredEventListenerKey, std::unique_ptr<ValueCounter>>;
base::LazyInstance<FilteredEventListenerCounts> g_filtered_listener_counts =
LAZY_INSTANCE_INITIALIZER;
@@ -124,9 +125,10 @@ bool AddFilter(const std::string& event_name,
FilteredEventListenerCounts& all_counts = g_filtered_listener_counts.Get();
FilteredEventListenerCounts::const_iterator counts = all_counts.find(key);
if (counts == all_counts.end()) {
- counts = all_counts.insert(std::make_pair(
- key, make_scoped_ptr(new ValueCounter())))
- .first;
+ counts =
+ all_counts
+ .insert(std::make_pair(key, base::WrapUnique(new ValueCounter())))
+ .first;
}
return counts->second->Add(filter);
}
@@ -257,11 +259,11 @@ void EventBindings::AttachFilteredEvent(
if (!context()->HasAccessOrThrowError(event_name))
return;
- scoped_ptr<base::DictionaryValue> filter;
+ std::unique_ptr<base::DictionaryValue> filter;
{
- scoped_ptr<content::V8ValueConverter> converter(
+ std::unique_ptr<content::V8ValueConverter> converter(
content::V8ValueConverter::create());
- scoped_ptr<base::Value> filter_value(converter->FromV8Value(
+ std::unique_ptr<base::Value> filter_value(converter->FromV8Value(
v8::Local<v8::Object>::Cast(args[1]), context()->v8_context()));
if (!filter_value || !filter_value->IsType(base::Value::TYPE_DICTIONARY)) {
args.GetReturnValue().Set(static_cast<int32_t>(-1));
@@ -339,9 +341,9 @@ void EventBindings::MatchAgainstEventFilter(
args.GetReturnValue().Set(array);
}
-scoped_ptr<EventMatcher> EventBindings::ParseEventMatcher(
- scoped_ptr<base::DictionaryValue> filter) {
- return make_scoped_ptr(new EventMatcher(
+std::unique_ptr<EventMatcher> EventBindings::ParseEventMatcher(
+ std::unique_ptr<base::DictionaryValue> filter) {
+ return base::WrapUnique(new EventMatcher(
std::move(filter), context()->GetRenderFrame()->GetRoutingID()));
}
diff --git a/chromium/extensions/renderer/event_bindings.h b/chromium/extensions/renderer/event_bindings.h
index 8c179983717..f2d1ad77a72 100644
--- a/chromium/extensions/renderer/event_bindings.h
+++ b/chromium/extensions/renderer/event_bindings.h
@@ -5,11 +5,11 @@
#ifndef EXTENSIONS_RENDERER_EVENT_BINDINGS_H_
#define EXTENSIONS_RENDERER_EVENT_BINDINGS_H_
+#include <memory>
#include <set>
#include <string>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/renderer/object_backed_native_handler.h"
#include "v8/include/v8.h"
@@ -70,8 +70,8 @@ class EventBindings : public ObjectBackedNativeHandler {
void MatchAgainstEventFilter(const v8::FunctionCallbackInfo<v8::Value>& args);
- scoped_ptr<EventMatcher> ParseEventMatcher(
- scoped_ptr<base::DictionaryValue> filter);
+ std::unique_ptr<EventMatcher> ParseEventMatcher(
+ std::unique_ptr<base::DictionaryValue> filter);
// Called when our context, and therefore us, is invalidated. Run any cleanup.
void OnInvalidated();
diff --git a/chromium/extensions/renderer/extension_injection_host.cc b/chromium/extensions/renderer/extension_injection_host.cc
index 6e5b0422871..85207c3a549 100644
--- a/chromium/extensions/renderer/extension_injection_host.cc
+++ b/chromium/extensions/renderer/extension_injection_host.cc
@@ -23,13 +23,13 @@ ExtensionInjectionHost::~ExtensionInjectionHost() {
}
// static
-scoped_ptr<const InjectionHost> ExtensionInjectionHost::Create(
+std::unique_ptr<const InjectionHost> ExtensionInjectionHost::Create(
const std::string& extension_id) {
const Extension* extension =
RendererExtensionRegistry::Get()->GetByID(extension_id);
if (!extension)
- return scoped_ptr<const ExtensionInjectionHost>();
- return scoped_ptr<const ExtensionInjectionHost>(
+ return std::unique_ptr<const ExtensionInjectionHost>();
+ return std::unique_ptr<const ExtensionInjectionHost>(
new ExtensionInjectionHost(extension));
}
diff --git a/chromium/extensions/renderer/extension_injection_host.h b/chromium/extensions/renderer/extension_injection_host.h
index a3c9d320dfd..e8db0311939 100644
--- a/chromium/extensions/renderer/extension_injection_host.h
+++ b/chromium/extensions/renderer/extension_injection_host.h
@@ -21,7 +21,7 @@ class ExtensionInjectionHost : public InjectionHost {
// Create an ExtensionInjectionHost object. If the extension is gone, returns
// a null scoped ptr.
- static scoped_ptr<const InjectionHost> Create(
+ static std::unique_ptr<const InjectionHost> Create(
const std::string& extension_id);
private:
diff --git a/chromium/extensions/renderer/extensions_render_frame_observer.cc b/chromium/extensions/renderer/extensions_render_frame_observer.cc
index 3f66f46256a..ce410630f55 100644
--- a/chromium/extensions/renderer/extensions_render_frame_observer.cc
+++ b/chromium/extensions/renderer/extensions_render_frame_observer.cc
@@ -54,7 +54,8 @@ StackTrace GetStackTraceFromMessage(base::string16* message,
// If we got a stack trace, parse each frame from the text.
if (index < pieces.size()) {
for (; index < pieces.size(); ++index) {
- scoped_ptr<StackFrame> frame = StackFrame::CreateFromText(pieces[index]);
+ std::unique_ptr<StackFrame> frame =
+ StackFrame::CreateFromText(pieces[index]);
if (frame.get())
result.push_back(*frame);
}
diff --git a/chromium/extensions/renderer/gc_callback_unittest.cc b/chromium/extensions/renderer/gc_callback_unittest.cc
index f1b70ba3e24..06bfb81171a 100644
--- a/chromium/extensions/renderer/gc_callback_unittest.cc
+++ b/chromium/extensions/renderer/gc_callback_unittest.cc
@@ -76,7 +76,7 @@ class GCCallbackTest : public testing::Test {
ExtensionIdSet active_extensions_;
ScriptContextSet script_context_set_;
v8::Global<v8::Context> v8_context_;
- scoped_ptr<gin::ContextHolder> gin_context_holder_;
+ std::unique_ptr<gin::ContextHolder> gin_context_holder_;
DISALLOW_COPY_AND_ASSIGN(GCCallbackTest);
};
diff --git a/chromium/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc b/chromium/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc
index f54c87891c7..ee7c11e6dd8 100644
--- a/chromium/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc
+++ b/chromium/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc
@@ -147,10 +147,10 @@ void GuestViewInternalCustomBindings::AttachGuest(
int guest_instance_id = args[1]->Int32Value();
- scoped_ptr<base::DictionaryValue> params;
+ std::unique_ptr<base::DictionaryValue> params;
{
- scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
- scoped_ptr<base::Value> params_as_value(
+ std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create());
+ std::unique_ptr<base::Value> params_as_value(
converter->FromV8Value(args[2], context()->v8_context()));
params = base::DictionaryValue::From(std::move(params_as_value));
CHECK(params);
@@ -221,10 +221,10 @@ void GuestViewInternalCustomBindings::AttachIframeGuest(
int element_instance_id = args[0]->Int32Value();
int guest_instance_id = args[1]->Int32Value();
- scoped_ptr<base::DictionaryValue> params;
+ std::unique_ptr<base::DictionaryValue> params;
{
- scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
- scoped_ptr<base::Value> params_as_value(
+ std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create());
+ std::unique_ptr<base::Value> params_as_value(
converter->FromV8Value(args[2], context()->v8_context()));
params = base::DictionaryValue::From(std::move(params_as_value));
CHECK(params);
diff --git a/chromium/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc b/chromium/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc
index 91f8197e853..8750242efb7 100644
--- a/chromium/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc
+++ b/chromium/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc
@@ -275,7 +275,7 @@ void MimeHandlerViewContainer::PostMessageFromValue(
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope handle_scope(isolate);
v8::Context::Scope context_scope(frame->mainWorldScriptContext());
- scoped_ptr<content::V8ValueConverter> converter(
+ std::unique_ptr<content::V8ValueConverter> converter(
content::V8ValueConverter::create());
PostMessage(isolate,
converter->ToV8Value(&message, frame->mainWorldScriptContext()));
diff --git a/chromium/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.h b/chromium/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.h
index 6c98abefabf..dd0f1c01d0f 100644
--- a/chromium/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.h
+++ b/chromium/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.h
@@ -105,7 +105,7 @@ class MimeHandlerViewContainer : public guest_view::GuestViewContainer,
// A URL loader to load the |original_url_| when the plugin is embedded. In
// the embedded case, no URL request is made automatically.
- scoped_ptr<blink::WebURLLoader> loader_;
+ std::unique_ptr<blink::WebURLLoader> loader_;
// The scriptable object that backs the plugin.
v8::Global<v8::Object> scriptable_object_;
diff --git a/chromium/extensions/renderer/i18n_custom_bindings.cc b/chromium/extensions/renderer/i18n_custom_bindings.cc
index 08d9e75aac3..d17e94b6045 100644
--- a/chromium/extensions/renderer/i18n_custom_bindings.cc
+++ b/chromium/extensions/renderer/i18n_custom_bindings.cc
@@ -11,6 +11,7 @@
#include "base/bind.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "content/public/child/v8_value_converter.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_thread.h"
@@ -37,7 +38,7 @@ struct DetectedLanguage {
// Returns a new v8::Local<v8::Value> representing the serialized form of
// this DetectedLanguage object.
- scoped_ptr<base::DictionaryValue> ToDictionary() const;
+ std::unique_ptr<base::DictionaryValue> ToDictionary() const;
std::string language;
int percentage;
@@ -62,14 +63,15 @@ struct LanguageDetectionResult {
// Array of detectedLanguage of size 1-3. The null is returned if
// there were no languages detected
- std::vector<scoped_ptr<DetectedLanguage>> languages;
+ std::vector<std::unique_ptr<DetectedLanguage>> languages;
private:
DISALLOW_COPY_AND_ASSIGN(LanguageDetectionResult);
};
-scoped_ptr<base::DictionaryValue> DetectedLanguage::ToDictionary() const {
- scoped_ptr<base::DictionaryValue> dict_value(new base::DictionaryValue());
+std::unique_ptr<base::DictionaryValue> DetectedLanguage::ToDictionary() const {
+ std::unique_ptr<base::DictionaryValue> dict_value(
+ new base::DictionaryValue());
dict_value->SetString("language", language.c_str());
dict_value->SetInteger("percentage", percentage);
return dict_value;
@@ -78,7 +80,7 @@ scoped_ptr<base::DictionaryValue> DetectedLanguage::ToDictionary() const {
v8::Local<v8::Value> LanguageDetectionResult::ToValue(ScriptContext* context) {
base::DictionaryValue dict_value;
dict_value.SetBoolean("isReliable", is_reliable);
- scoped_ptr<base::ListValue> languages_list(new base::ListValue());
+ std::unique_ptr<base::ListValue> languages_list(new base::ListValue());
for (const auto& language : languages)
languages_list->Append(language->ToDictionary());
dict_value.Set("languages", std::move(languages_list));
@@ -87,7 +89,7 @@ v8::Local<v8::Value> LanguageDetectionResult::ToValue(ScriptContext* context) {
v8::Isolate* isolate = v8_context->GetIsolate();
v8::EscapableHandleScope handle_scope(isolate);
- scoped_ptr<content::V8ValueConverter> converter(
+ std::unique_ptr<content::V8ValueConverter> converter(
content::V8ValueConverter::create());
v8::Local<v8::Value> result = converter->ToV8Value(&dict_value, v8_context);
return handle_scope.Escape(result);
@@ -96,7 +98,7 @@ v8::Local<v8::Value> LanguageDetectionResult::ToValue(ScriptContext* context) {
void InitDetectedLanguages(
CLD2::Language* languages,
int* percents,
- std::vector<scoped_ptr<DetectedLanguage>>* detected_languages) {
+ std::vector<std::unique_ptr<DetectedLanguage>>* detected_languages) {
for (int i = 0; i < kCldNumLangs; i++) {
std::string language_code;
// Convert LanguageCode 'zh' to 'zh-CN' and 'zh-Hant' to 'zh-TW' for
@@ -111,7 +113,7 @@ void InitDetectedLanguages(
CLD2::LanguageCode(static_cast<CLD2::Language>(languages[i]));
}
detected_languages->push_back(
- make_scoped_ptr(new DetectedLanguage(language_code, percents[i])));
+ base::WrapUnique(new DetectedLanguage(language_code, percents[i])));
}
}
@@ -120,12 +122,12 @@ void InitDetectedLanguages(
I18NCustomBindings::I18NCustomBindings(ScriptContext* context)
: ObjectBackedNativeHandler(context) {
RouteFunction(
- "GetL10nMessage",
+ "GetL10nMessage", "i18n",
base::Bind(&I18NCustomBindings::GetL10nMessage, base::Unretained(this)));
- RouteFunction("GetL10nUILanguage",
+ RouteFunction("GetL10nUILanguage", "i18n",
base::Bind(&I18NCustomBindings::GetL10nUILanguage,
base::Unretained(this)));
- RouteFunction("DetectTextLanguage",
+ RouteFunction("DetectTextLanguage", "i18n",
base::Bind(&I18NCustomBindings::DetectTextLanguage,
base::Unretained(this)));
}
diff --git a/chromium/extensions/renderer/json_schema_unittest.cc b/chromium/extensions/renderer/json_schema_unittest.cc
index 3a2191cad0f..b5e878fb350 100644
--- a/chromium/extensions/renderer/json_schema_unittest.cc
+++ b/chromium/extensions/renderer/json_schema_unittest.cc
@@ -79,7 +79,7 @@ TEST_F(JsonSchemaTest, TestType) {
{
// Create an ArrayBuffer in another v8 context and pass it to the test
// through a global.
- scoped_ptr<ModuleSystemTestEnvironment> other_env(CreateEnvironment());
+ std::unique_ptr<ModuleSystemTestEnvironment> other_env(CreateEnvironment());
v8::Context::Scope scope(other_env->context()->v8_context());
v8::Local<v8::ArrayBuffer> array_buffer(
v8::ArrayBuffer::New(env()->isolate(), 1));
diff --git a/chromium/extensions/renderer/lazy_background_page_native_handler.cc b/chromium/extensions/renderer/lazy_background_page_native_handler.cc
index f09beec7a7f..b7307776cfc 100644
--- a/chromium/extensions/renderer/lazy_background_page_native_handler.cc
+++ b/chromium/extensions/renderer/lazy_background_page_native_handler.cc
@@ -16,11 +16,11 @@ LazyBackgroundPageNativeHandler::LazyBackgroundPageNativeHandler(
ScriptContext* context)
: ObjectBackedNativeHandler(context) {
RouteFunction(
- "IncrementKeepaliveCount",
+ "IncrementKeepaliveCount", "tts",
base::Bind(&LazyBackgroundPageNativeHandler::IncrementKeepaliveCount,
base::Unretained(this)));
RouteFunction(
- "DecrementKeepaliveCount",
+ "DecrementKeepaliveCount", "tts",
base::Bind(&LazyBackgroundPageNativeHandler::DecrementKeepaliveCount,
base::Unretained(this)));
}
diff --git a/chromium/extensions/renderer/messaging_bindings.cc b/chromium/extensions/renderer/messaging_bindings.cc
index 95bf59a4b67..c1da6263306 100644
--- a/chromium/extensions/renderer/messaging_bindings.cc
+++ b/chromium/extensions/renderer/messaging_bindings.cc
@@ -288,7 +288,7 @@ void DispatchOnConnectToScriptContext(
v8::Isolate* isolate = script_context->isolate();
v8::HandleScope handle_scope(isolate);
- scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
+ std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create());
const std::string& source_url_spec = info.source_url.spec();
std::string target_extension_id = script_context->GetExtensionID();
@@ -395,8 +395,9 @@ void DeliverMessageToScriptContext(const Message& message,
arguments.push_back(v8_data);
arguments.push_back(port_id_handle);
- scoped_ptr<blink::WebScopedUserGesture> web_user_gesture;
- scoped_ptr<blink::WebScopedWindowFocusAllowedIndicator> allow_window_focus;
+ std::unique_ptr<blink::WebScopedUserGesture> web_user_gesture;
+ std::unique_ptr<blink::WebScopedWindowFocusAllowedIndicator>
+ allow_window_focus;
if (message.user_gesture) {
web_user_gesture.reset(new blink::WebScopedUserGesture);
diff --git a/chromium/extensions/renderer/module_system.cc b/chromium/extensions/renderer/module_system.cc
index 4ff9b5c5f51..dd13786f198 100644
--- a/chromium/extensions/renderer/module_system.cc
+++ b/chromium/extensions/renderer/module_system.cc
@@ -131,15 +131,18 @@ std::string ModuleSystem::ExceptionHandler::CreateExceptionString(
error_message.assign(*error_message_v8, error_message_v8.length());
}
- auto maybe = message->GetLineNumber(context_->v8_context());
- int line_number = maybe.IsJust() ? maybe.FromJust() : 0;
+ int line_number = 0;
+ if (context_) { // |context_| can be null in unittests.
+ auto maybe = message->GetLineNumber(context_->v8_context());
+ line_number = maybe.IsJust() ? maybe.FromJust() : 0;
+ }
return base::StringPrintf("%s:%d: %s",
resource_name.c_str(),
line_number,
error_message.c_str());
}
-ModuleSystem::ModuleSystem(ScriptContext* context, SourceMap* source_map)
+ModuleSystem::ModuleSystem(ScriptContext* context, const SourceMap* source_map)
: ObjectBackedNativeHandler(context),
context_(context),
source_map_(source_map),
@@ -334,7 +337,7 @@ v8::Local<v8::Value> ModuleSystem::CallModuleMethod(
void ModuleSystem::RegisterNativeHandler(
const std::string& name,
- scoped_ptr<NativeHandler> native_handler) {
+ std::unique_ptr<NativeHandler> native_handler) {
ClobberExistingNativeHandler(name);
native_handler_map_[name] = std::move(native_handler);
}
@@ -563,7 +566,7 @@ void ModuleSystem::RequireAsync(
v8::Local<v8::Promise::Resolver> resolver(
v8::Promise::Resolver::New(v8_context).ToLocalChecked());
args.GetReturnValue().Set(resolver->GetPromise());
- scoped_ptr<v8::Global<v8::Promise::Resolver>> global_resolver(
+ std::unique_ptr<v8::Global<v8::Promise::Resolver>> global_resolver(
new v8::Global<v8::Promise::Resolver>(GetIsolate(), resolver));
gin::ModuleRegistry* module_registry =
gin::ModuleRegistry::From(v8_context);
@@ -736,7 +739,7 @@ void ModuleSystem::OnDidAddPendingModule(
}
void ModuleSystem::OnModuleLoaded(
- scoped_ptr<v8::Global<v8::Promise::Resolver>> resolver,
+ std::unique_ptr<v8::Global<v8::Promise::Resolver>> resolver,
v8::Local<v8::Value> value) {
if (!is_valid())
return;
diff --git a/chromium/extensions/renderer/module_system.h b/chromium/extensions/renderer/module_system.h
index 134d2baa05f..4ce545860f0 100644
--- a/chromium/extensions/renderer/module_system.h
+++ b/chromium/extensions/renderer/module_system.h
@@ -6,6 +6,7 @@
#define EXTENSIONS_RENDERER_MODULE_SYSTEM_H_
#include <map>
+#include <memory>
#include <set>
#include <string>
#include <utility>
@@ -13,7 +14,6 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/renderer/native_handler.h"
#include "extensions/renderer/object_backed_native_handler.h"
#include "gin/modules/module_registry_observer.h"
@@ -46,8 +46,8 @@ class ModuleSystem : public ObjectBackedNativeHandler,
public:
virtual ~SourceMap() {}
virtual v8::Local<v8::Value> GetSource(v8::Isolate* isolate,
- const std::string& name) = 0;
- virtual bool Contains(const std::string& name) = 0;
+ const std::string& name) const = 0;
+ virtual bool Contains(const std::string& name) const = 0;
};
class ExceptionHandler {
@@ -76,7 +76,7 @@ class ModuleSystem : public ObjectBackedNativeHandler,
};
// |source_map| is a weak pointer.
- ModuleSystem(ScriptContext* context, SourceMap* source_map);
+ ModuleSystem(ScriptContext* context, const SourceMap* source_map);
~ModuleSystem() override;
// Require the specified module. This is the equivalent of calling
@@ -106,7 +106,7 @@ class ModuleSystem : public ObjectBackedNativeHandler,
// calls to requireNative(|name|) from JS will return a new object created by
// |native_handler|.
void RegisterNativeHandler(const std::string& name,
- scoped_ptr<NativeHandler> native_handler);
+ std::unique_ptr<NativeHandler> native_handler);
// Causes requireNative(|name|) to look for its module in |source_map_|
// instead of using a registered native handler. This can be used in unit
@@ -142,7 +142,7 @@ class ModuleSystem : public ObjectBackedNativeHandler,
const std::string& module_field);
// Passes exceptions to |handler| rather than console::Fatal.
- void SetExceptionHandlerForTest(scoped_ptr<ExceptionHandler> handler) {
+ void SetExceptionHandlerForTest(std::unique_ptr<ExceptionHandler> handler) {
exception_handler_ = std::move(handler);
}
@@ -152,7 +152,8 @@ class ModuleSystem : public ObjectBackedNativeHandler,
void Invalidate() override;
private:
- typedef std::map<std::string, scoped_ptr<NativeHandler>> NativeHandlerMap;
+ typedef std::map<std::string, std::unique_ptr<NativeHandler>>
+ NativeHandlerMap;
// Retrieves the lazily defined field specified by |property|.
static void LazyFieldGetter(v8::Local<v8::Name> property,
@@ -204,8 +205,9 @@ class ModuleSystem : public ObjectBackedNativeHandler,
// Invoked when a module is loaded in response to a requireAsync call.
// Resolves |resolver| with |value|.
- void OnModuleLoaded(scoped_ptr<v8::Global<v8::Promise::Resolver>> resolver,
- v8::Local<v8::Value> value);
+ void OnModuleLoaded(
+ std::unique_ptr<v8::Global<v8::Promise::Resolver>> resolver,
+ v8::Local<v8::Value> value);
// gin::ModuleRegistryObserver overrides.
void OnDidAddPendingModule(
@@ -220,7 +222,7 @@ class ModuleSystem : public ObjectBackedNativeHandler,
// A map from module names to the JS source for that module. GetSource()
// performs a lookup on this map.
- SourceMap* source_map_;
+ const SourceMap* const source_map_;
// A map from native handler names to native handlers.
NativeHandlerMap native_handler_map_;
@@ -231,7 +233,7 @@ class ModuleSystem : public ObjectBackedNativeHandler,
// Called when an exception is thrown but not caught in JS. Overridable by
// tests.
- scoped_ptr<ExceptionHandler> exception_handler_;
+ std::unique_ptr<ExceptionHandler> exception_handler_;
// A set of native handlers that should actually be require()d as non-native
// handlers. This is used for tests to mock out native handlers in JS.
@@ -241,7 +243,7 @@ class ModuleSystem : public ObjectBackedNativeHandler,
// registering a NativeHandler when one was already registered with the same
// name, or due to OverrideNativeHandlerForTest. This is needed so that they
// can be later Invalidated. It should only happen in tests.
- std::vector<scoped_ptr<NativeHandler>> clobbered_native_handlers_;
+ std::vector<std::unique_ptr<NativeHandler>> clobbered_native_handlers_;
base::WeakPtrFactory<ModuleSystem> weak_factory_;
diff --git a/chromium/extensions/renderer/module_system_test.cc b/chromium/extensions/renderer/module_system_test.cc
index 3386ff010c1..87f6786bb25 100644
--- a/chromium/extensions/renderer/module_system_test.cc
+++ b/chromium/extensions/renderer/module_system_test.cc
@@ -7,6 +7,7 @@
#include <stddef.h>
#include <map>
+#include <memory>
#include <string>
#include <utility>
@@ -15,7 +16,7 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/lazy_instance.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/path_service.h"
#include "base/strings/string_piece.h"
#include "extensions/common/extension_paths.h"
@@ -52,9 +53,9 @@ class V8ExtensionConfigurator {
}
private:
- scoped_ptr<v8::Extension> safe_builtins_;
+ std::unique_ptr<v8::Extension> safe_builtins_;
std::vector<const char*> names_;
- scoped_ptr<v8::ExtensionConfiguration> configuration_;
+ std::unique_ptr<v8::ExtensionConfiguration> configuration_;
};
base::LazyInstance<V8ExtensionConfigurator>::Leaky g_v8_extension_configurator =
@@ -106,13 +107,14 @@ class ModuleSystemTestEnvironment::StringSourceMap
~StringSourceMap() override {}
v8::Local<v8::Value> GetSource(v8::Isolate* isolate,
- const std::string& name) override {
- if (source_map_.count(name) == 0)
+ const std::string& name) const override {
+ const auto& source_map_iter = source_map_.find(name);
+ if (source_map_iter == source_map_.end())
return v8::Undefined(isolate);
- return v8::String::NewFromUtf8(isolate, source_map_[name].c_str());
+ return v8::String::NewFromUtf8(isolate, source_map_iter->second.c_str());
}
- bool Contains(const std::string& name) override {
+ bool Contains(const std::string& name) const override {
return source_map_.count(name);
}
@@ -142,21 +144,21 @@ ModuleSystemTestEnvironment::ModuleSystemTestEnvironment(v8::Isolate* isolate)
assert_natives_ = new AssertNatives(context_.get());
{
- scoped_ptr<ModuleSystem> module_system(
+ std::unique_ptr<ModuleSystem> module_system(
new ModuleSystem(context_.get(), source_map_.get()));
context_->set_module_system(std::move(module_system));
}
ModuleSystem* module_system = context_->module_system();
module_system->RegisterNativeHandler(
- "assert", scoped_ptr<NativeHandler>(assert_natives_));
+ "assert", std::unique_ptr<NativeHandler>(assert_natives_));
module_system->RegisterNativeHandler(
"logging",
- scoped_ptr<NativeHandler>(new LoggingNativeHandler(context_.get())));
+ std::unique_ptr<NativeHandler>(new LoggingNativeHandler(context_.get())));
module_system->RegisterNativeHandler(
"utils",
- scoped_ptr<NativeHandler>(new UtilsNativeHandler(context_.get())));
+ std::unique_ptr<NativeHandler>(new UtilsNativeHandler(context_.get())));
module_system->SetExceptionHandlerForTest(
- scoped_ptr<ModuleSystem::ExceptionHandler>(new FailsOnException));
+ std::unique_ptr<ModuleSystem::ExceptionHandler>(new FailsOnException));
}
ModuleSystemTestEnvironment::~ModuleSystemTestEnvironment() {
@@ -246,8 +248,9 @@ void ModuleSystemTest::TearDown() {
}
}
-scoped_ptr<ModuleSystemTestEnvironment> ModuleSystemTest::CreateEnvironment() {
- return make_scoped_ptr(new ModuleSystemTestEnvironment(isolate_));
+std::unique_ptr<ModuleSystemTestEnvironment>
+ModuleSystemTest::CreateEnvironment() {
+ return base::WrapUnique(new ModuleSystemTestEnvironment(isolate_));
}
void ModuleSystemTest::ExpectNoAssertionsMade() {
diff --git a/chromium/extensions/renderer/module_system_test.h b/chromium/extensions/renderer/module_system_test.h
index 517c3080c00..495048e472f 100644
--- a/chromium/extensions/renderer/module_system_test.h
+++ b/chromium/extensions/renderer/module_system_test.h
@@ -55,11 +55,11 @@ class ModuleSystemTestEnvironment {
private:
v8::Isolate* isolate_;
- scoped_ptr<gin::ContextHolder> context_holder_;
+ std::unique_ptr<gin::ContextHolder> context_holder_;
v8::HandleScope handle_scope_;
- scoped_ptr<ScriptContext> context_;
+ std::unique_ptr<ScriptContext> context_;
AssertNatives* assert_natives_;
- scoped_ptr<StringSourceMap> source_map_;
+ std::unique_ptr<StringSourceMap> source_map_;
DISALLOW_COPY_AND_ASSIGN(ModuleSystemTestEnvironment);
};
@@ -87,7 +87,7 @@ class ModuleSystemTest : public testing::Test {
protected:
ModuleSystemTestEnvironment* env() { return env_.get(); }
- scoped_ptr<ModuleSystemTestEnvironment> CreateEnvironment();
+ std::unique_ptr<ModuleSystemTestEnvironment> CreateEnvironment();
// Make the test fail if any asserts are called. By default a test will fail
// if no asserts are called.
@@ -99,7 +99,7 @@ class ModuleSystemTest : public testing::Test {
private:
v8::Isolate* isolate_;
- scoped_ptr<ModuleSystemTestEnvironment> env_;
+ std::unique_ptr<ModuleSystemTestEnvironment> env_;
bool should_assertions_be_made_;
private:
diff --git a/chromium/extensions/renderer/module_system_unittest.cc b/chromium/extensions/renderer/module_system_unittest.cc
index 5803ad0d694..b91715b1a33 100644
--- a/chromium/extensions/renderer/module_system_unittest.cc
+++ b/chromium/extensions/renderer/module_system_unittest.cc
@@ -6,9 +6,9 @@
#include <stdint.h>
+#include <memory>
#include <utility>
-#include "base/memory/scoped_ptr.h"
#include "extensions/renderer/module_system_test.h"
#include "gin/modules/module_registry.h"
@@ -56,7 +56,7 @@ TEST_F(ModuleSystemTest, TestExceptionHandling) {
ModuleSystem::NativesEnabledScope natives_enabled_scope(
env()->module_system());
TestExceptionHandler* handler = new TestExceptionHandler;
- scoped_ptr<ModuleSystem::ExceptionHandler> scoped_handler(handler);
+ std::unique_ptr<ModuleSystem::ExceptionHandler> scoped_handler(handler);
ASSERT_FALSE(handler->handled_exception());
env()->module_system()->SetExceptionHandlerForTest(std::move(scoped_handler));
@@ -188,7 +188,7 @@ TEST_F(ModuleSystemTest, TestLazyFieldIsOnlyEvaledOnce) {
env()->module_system());
env()->module_system()->RegisterNativeHandler(
"counter",
- scoped_ptr<NativeHandler>(new CounterNatives(env()->context())));
+ std::unique_ptr<NativeHandler>(new CounterNatives(env()->context())));
env()->RegisterModule("lazy",
"requireNative('counter').Increment();"
"exports.$set('x', 5);");
@@ -243,7 +243,7 @@ TEST_F(ModuleSystemTest, TestModulesOnlyGetEvaledOnce) {
env()->module_system());
env()->module_system()->RegisterNativeHandler(
"counter",
- scoped_ptr<NativeHandler>(new CounterNatives(env()->context())));
+ std::unique_ptr<NativeHandler>(new CounterNatives(env()->context())));
env()->RegisterModule("incrementsWhenEvaled",
"requireNative('counter').Increment();");
@@ -408,7 +408,7 @@ TEST_F(ModuleSystemTest, TestRequireAsyncFromAnotherContext) {
" requireNative('assert').AssertTrue(result == 'pong');"
" });"
"});");
- scoped_ptr<ModuleSystemTestEnvironment> other_env = CreateEnvironment();
+ std::unique_ptr<ModuleSystemTestEnvironment> other_env = CreateEnvironment();
other_env->RegisterModule("ping",
"define('ping', ['natives'], function(natives) {"
" return function() {"
@@ -445,7 +445,7 @@ TEST_F(ModuleSystemTest, TestRequireAsyncBetweenContexts) {
" requireNative('assert').AssertTrue(result == 'done');"
" });"
"});");
- scoped_ptr<ModuleSystemTestEnvironment> other_env = CreateEnvironment();
+ std::unique_ptr<ModuleSystemTestEnvironment> other_env = CreateEnvironment();
other_env->RegisterModule("ping",
"define('ping', ['natives'], function(natives) {"
" return function() {"
@@ -477,7 +477,7 @@ TEST_F(ModuleSystemTest, TestRequireAsyncFromContextWithNoModuleRegistry) {
" 'Extension view no longer exists');"
" });"
"});");
- scoped_ptr<ModuleSystemTestEnvironment> other_env = CreateEnvironment();
+ std::unique_ptr<ModuleSystemTestEnvironment> other_env = CreateEnvironment();
gin::ModuleRegistry::From(env()->context()->v8_context())
->AddBuiltinModule(
env()->isolate(), "natives",
@@ -495,7 +495,7 @@ TEST_F(ModuleSystemTest, TestRequireAsyncFromContextWithNoModuleSystem) {
" requireNative('assert').AssertTrue("
" natives.requireAsync('foo') === undefined);"
"});");
- scoped_ptr<ModuleSystemTestEnvironment> other_env = CreateEnvironment();
+ std::unique_ptr<ModuleSystemTestEnvironment> other_env = CreateEnvironment();
gin::ModuleRegistry::From(env()->context()->v8_context())
->AddBuiltinModule(
env()->isolate(), "natives",
diff --git a/chromium/extensions/renderer/mojo/stash_client_unittest.cc b/chromium/extensions/renderer/mojo/stash_client_unittest.cc
index 3f361cc2535..a672c977e44 100644
--- a/chromium/extensions/renderer/mojo/stash_client_unittest.cc
+++ b/chromium/extensions/renderer/mojo/stash_client_unittest.cc
@@ -31,7 +31,7 @@ class StashClientTest : public ApiTestBase {
&StashBackend::BindToRequest, base::Unretained(stash_backend_.get())));
}
- scoped_ptr<StashBackend> stash_backend_;
+ std::unique_ptr<StashBackend> stash_backend_;
private:
DISALLOW_COPY_AND_ASSIGN(StashClientTest);
@@ -46,7 +46,8 @@ class StashClientTest : public ApiTestBase {
// Test that stashing and restoring work correctly.
TEST_F(StashClientTest, MAYBE_StashAndRestore) {
ASSERT_NO_FATAL_FAILURE(RunTest("stash_client_unittest.js", "testStash"));
- scoped_ptr<ModuleSystemTestEnvironment> restore_test_env(CreateEnvironment());
+ std::unique_ptr<ModuleSystemTestEnvironment> restore_test_env(
+ CreateEnvironment());
ApiTestEnvironment restore_environment(restore_test_env.get());
PrepareEnvironment(&restore_environment);
restore_environment.RunTest("stash_client_unittest.js", "testRetrieve");
diff --git a/chromium/extensions/renderer/object_backed_native_handler.cc b/chromium/extensions/renderer/object_backed_native_handler.cc
index 1ffc355cc48..3728543d2be 100644
--- a/chromium/extensions/renderer/object_backed_native_handler.cc
+++ b/chromium/extensions/renderer/object_backed_native_handler.cc
@@ -74,10 +74,14 @@ void ObjectBackedNativeHandler::Router(
std::string feature_name = *v8::String::Utf8Value(feature_name_string);
// TODO(devlin): Eventually, we should fail if either script_context is null
// or feature_name is empty.
- if (script_context &&
- !feature_name.empty() &&
- !script_context->GetAvailability(feature_name).is_available()) {
- return;
+ if (script_context && !feature_name.empty()) {
+ Feature::Availability availability =
+ script_context->GetAvailability(feature_name);
+ if (!availability.is_available()) {
+ DVLOG(1) << feature_name
+ << " is not available: " << availability.message();
+ return;
+ }
}
}
// This CHECK is *important*. Otherwise, we'll go around happily executing
diff --git a/chromium/extensions/renderer/print_native_handler.cc b/chromium/extensions/renderer/print_native_handler.cc
deleted file mode 100644
index b6ee63a7e59..00000000000
--- a/chromium/extensions/renderer/print_native_handler.cc
+++ /dev/null
@@ -1,32 +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 "extensions/renderer/print_native_handler.h"
-
-#include <string>
-
-#include "base/bind.h"
-#include "base/strings/string_util.h"
-
-namespace extensions {
-
-PrintNativeHandler::PrintNativeHandler(ScriptContext* context)
- : ObjectBackedNativeHandler(context) {
- RouteFunction("Print",
- base::Bind(&PrintNativeHandler::Print, base::Unretained(this)));
-}
-
-void PrintNativeHandler::Print(
- const v8::FunctionCallbackInfo<v8::Value>& args) {
- if (args.Length() < 1)
- return;
-
- std::vector<std::string> components;
- for (int i = 0; i < args.Length(); ++i)
- components.push_back(*v8::String::Utf8Value(args[i]));
-
- LOG(ERROR) << base::JoinString(components, ",");
-}
-
-} // namespace extensions
diff --git a/chromium/extensions/renderer/print_native_handler.h b/chromium/extensions/renderer/print_native_handler.h
deleted file mode 100644
index b2e5d375d7f..00000000000
--- a/chromium/extensions/renderer/print_native_handler.h
+++ /dev/null
@@ -1,21 +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 EXTENSIONS_RENDERER_PRINT_NATIVE_HANDLER_H_
-#define EXTENSIONS_RENDERER_PRINT_NATIVE_HANDLER_H_
-
-#include "extensions/renderer/object_backed_native_handler.h"
-
-namespace extensions {
-
-class PrintNativeHandler : public ObjectBackedNativeHandler {
- public:
- explicit PrintNativeHandler(ScriptContext* context);
-
- void Print(const v8::FunctionCallbackInfo<v8::Value>& args);
-};
-
-} // namespace extensions
-
-#endif // EXTENSIONS_RENDERER_PRINT_NATIVE_HANDLER_H_
diff --git a/chromium/extensions/renderer/programmatic_script_injector.cc b/chromium/extensions/renderer/programmatic_script_injector.cc
index eea394b0aa8..e52885eee74 100644
--- a/chromium/extensions/renderer/programmatic_script_injector.cc
+++ b/chromium/extensions/renderer/programmatic_script_injector.cc
@@ -118,7 +118,7 @@ void ProgrammaticScriptInjector::GetRunInfo(
}
void ProgrammaticScriptInjector::OnInjectionComplete(
- scoped_ptr<base::Value> execution_result,
+ std::unique_ptr<base::Value> execution_result,
UserScript::RunLocation run_location,
content::RenderFrame* render_frame) {
DCHECK(results_.empty());
diff --git a/chromium/extensions/renderer/programmatic_script_injector.h b/chromium/extensions/renderer/programmatic_script_injector.h
index a7af9ff3818..885c3b12151 100644
--- a/chromium/extensions/renderer/programmatic_script_injector.h
+++ b/chromium/extensions/renderer/programmatic_script_injector.h
@@ -5,8 +5,9 @@
#ifndef EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_
#define EXTENSIONS_RENDERER_PROGRAMMATIC_SCRIPT_INJECTOR_H_
+#include <memory>
+
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "extensions/renderer/script_injection.h"
#include "url/gurl.h"
@@ -44,7 +45,7 @@ class ProgrammaticScriptInjector : public ScriptInjector {
UserScript::RunLocation run_location) const override;
void GetRunInfo(ScriptsRunInfo* scripts_run_info,
UserScript::RunLocation run_location) const override;
- void OnInjectionComplete(scoped_ptr<base::Value> execution_result,
+ void OnInjectionComplete(std::unique_ptr<base::Value> execution_result,
UserScript::RunLocation run_location,
content::RenderFrame* render_frame) override;
void OnWillNotInject(InjectFailureReason reason,
@@ -61,7 +62,7 @@ class ProgrammaticScriptInjector : public ScriptInjector {
void Finish(const std::string& error, content::RenderFrame* render_frame);
// The parameters for injecting the script.
- scoped_ptr<ExtensionMsg_ExecuteCode_Params> params_;
+ std::unique_ptr<ExtensionMsg_ExecuteCode_Params> params_;
// The url of the frame into which we are injecting.
GURL url_;
diff --git a/chromium/extensions/renderer/render_frame_observer_natives.cc b/chromium/extensions/renderer/render_frame_observer_natives.cc
index 7c507b37993..bd5d2377fad 100644
--- a/chromium/extensions/renderer/render_frame_observer_natives.cc
+++ b/chromium/extensions/renderer/render_frame_observer_natives.cc
@@ -50,7 +50,7 @@ class LoadWatcher : public content::RenderFrameObserver {
RenderFrameObserverNatives::RenderFrameObserverNatives(ScriptContext* context)
: ObjectBackedNativeHandler(context), weak_ptr_factory_(this) {
RouteFunction(
- "OnDocumentElementCreated",
+ "OnDocumentElementCreated", "app.window",
base::Bind(&RenderFrameObserverNatives::OnDocumentElementCreated,
base::Unretained(this)));
}
diff --git a/chromium/extensions/renderer/request_sender.cc b/chromium/extensions/renderer/request_sender.cc
index 6f3cf51a8f1..607d25ab3b2 100644
--- a/chromium/extensions/renderer/request_sender.cc
+++ b/chromium/extensions/renderer/request_sender.cc
@@ -7,7 +7,6 @@
#include "base/values.h"
#include "content/public/renderer/render_frame.h"
#include "extensions/common/extension_messages.h"
-#include "extensions/renderer/dispatcher.h"
#include "extensions/renderer/script_context.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
@@ -43,8 +42,7 @@ RequestSender::ScopedTabID::~ScopedTabID() {
request_sender_->source_tab_id_ = previous_tab_id_;
}
-RequestSender::RequestSender(Dispatcher* dispatcher)
- : dispatcher_(dispatcher), source_tab_id_(-1) {}
+RequestSender::RequestSender() : source_tab_id_(-1) {}
RequestSender::~RequestSender() {}
diff --git a/chromium/extensions/renderer/request_sender.h b/chromium/extensions/renderer/request_sender.h
index 245c0feb67e..85a7ef3ed27 100644
--- a/chromium/extensions/renderer/request_sender.h
+++ b/chromium/extensions/renderer/request_sender.h
@@ -17,7 +17,6 @@ class ListValue;
}
namespace extensions {
-class Dispatcher;
class ScriptContext;
struct PendingRequest;
@@ -57,7 +56,7 @@ class RequestSender {
DISALLOW_COPY_AND_ASSIGN(ScopedTabID);
};
- explicit RequestSender(Dispatcher* dispatcher);
+ RequestSender();
~RequestSender();
// In order to avoid collision, all |request_id|s passed into StartRequest()
@@ -94,7 +93,6 @@ class RequestSender {
void InsertRequest(int request_id, PendingRequest* pending_request);
linked_ptr<PendingRequest> RemoveRequest(int request_id);
- Dispatcher* dispatcher_;
PendingRequestMap pending_requests_;
int source_tab_id_; // Id of the tab sending the request, or -1 if no tab.
diff --git a/chromium/extensions/renderer/resource_bundle_source_map.cc b/chromium/extensions/renderer/resource_bundle_source_map.cc
index 88fc5372185..a260b543f34 100644
--- a/chromium/extensions/renderer/resource_bundle_source_map.cc
+++ b/chromium/extensions/renderer/resource_bundle_source_map.cc
@@ -5,10 +5,24 @@
#include "extensions/renderer/resource_bundle_source_map.h"
#include "base/logging.h"
+#include "base/strings/string_piece.h"
+#include "extensions/renderer/static_v8_external_one_byte_string_resource.h"
#include "ui/base/resource/resource_bundle.h"
namespace extensions {
+namespace {
+
+v8::Local<v8::String> ConvertString(v8::Isolate* isolate,
+ const base::StringPiece& string) {
+ // v8 takes ownership of the StaticV8ExternalOneByteStringResource (see
+ // v8::String::NewExternal()).
+ return v8::String::NewExternal(
+ isolate, new StaticV8ExternalOneByteStringResource(string));
+}
+
+} // namespace
+
ResourceBundleSourceMap::ResourceBundleSourceMap(
const ui::ResourceBundle* resource_bundle)
: resource_bundle_(resource_bundle) {
@@ -24,13 +38,14 @@ void ResourceBundleSourceMap::RegisterSource(const std::string& name,
v8::Local<v8::Value> ResourceBundleSourceMap::GetSource(
v8::Isolate* isolate,
- const std::string& name) {
- if (!Contains(name)) {
+ const std::string& name) const {
+ const auto& resource_id_iter = resource_id_map_.find(name);
+ if (resource_id_iter == resource_id_map_.end()) {
NOTREACHED() << "No module is registered with name \"" << name << "\"";
return v8::Undefined(isolate);
}
base::StringPiece resource =
- resource_bundle_->GetRawDataResource(resource_id_map_[name]);
+ resource_bundle_->GetRawDataResource(resource_id_iter->second);
if (resource.empty()) {
NOTREACHED()
<< "Module resource registered as \"" << name << "\" not found";
@@ -39,17 +54,8 @@ v8::Local<v8::Value> ResourceBundleSourceMap::GetSource(
return ConvertString(isolate, resource);
}
-bool ResourceBundleSourceMap::Contains(const std::string& name) {
+bool ResourceBundleSourceMap::Contains(const std::string& name) const {
return !!resource_id_map_.count(name);
}
-v8::Local<v8::String> ResourceBundleSourceMap::ConvertString(
- v8::Isolate* isolate,
- const base::StringPiece& string) {
- // v8 takes ownership of the StaticV8ExternalOneByteStringResource (see
- // v8::String::NewExternal()).
- return v8::String::NewExternal(
- isolate, new StaticV8ExternalOneByteStringResource(string));
-}
-
} // namespace extensions
diff --git a/chromium/extensions/renderer/resource_bundle_source_map.h b/chromium/extensions/renderer/resource_bundle_source_map.h
index 13f8f216697..9b7fd70737a 100644
--- a/chromium/extensions/renderer/resource_bundle_source_map.h
+++ b/chromium/extensions/renderer/resource_bundle_source_map.h
@@ -10,9 +10,7 @@
#include "base/compiler_specific.h"
#include "base/memory/linked_ptr.h"
-#include "base/strings/string_piece.h"
#include "extensions/renderer/module_system.h"
-#include "extensions/renderer/static_v8_external_one_byte_string_resource.h"
#include "v8/include/v8.h"
namespace ui {
@@ -27,17 +25,16 @@ class ResourceBundleSourceMap : public extensions::ModuleSystem::SourceMap {
~ResourceBundleSourceMap() override;
v8::Local<v8::Value> GetSource(v8::Isolate* isolate,
- const std::string& name) override;
- bool Contains(const std::string& name) override;
+ const std::string& name) const override;
+ bool Contains(const std::string& name) const override;
void RegisterSource(const std::string& name, int resource_id);
private:
- v8::Local<v8::String> ConvertString(v8::Isolate* isolate,
- const base::StringPiece& string);
-
const ui::ResourceBundle* resource_bundle_;
std::map<std::string, int> resource_id_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(ResourceBundleSourceMap);
};
} // namespace extensions
diff --git a/chromium/extensions/renderer/resources/binding.js b/chromium/extensions/renderer/resources/binding.js
index c5690907f40..22f3f583ca9 100644
--- a/chromium/extensions/renderer/resources/binding.js
+++ b/chromium/extensions/renderer/resources/binding.js
@@ -26,11 +26,15 @@ var sendRequest = sendRequestHandler.sendRequest;
// modify their behaviour (such as a custom way to handle requests to the
// API, a custom callback, etc).
function APIFunctions(namespace) {
- this.apiFunctions_ = {};
- this.unavailableApiFunctions_ = {};
+ this.apiFunctions_ = { __proto__: null };
+ this.unavailableApiFunctions_ = { __proto__: null };
this.namespace = namespace;
}
+APIFunctions.prototype = {
+ __proto__: null,
+};
+
APIFunctions.prototype.register = function(apiName, apiFunction) {
this.apiFunctions_[apiName] = apiFunction;
};
@@ -113,22 +117,6 @@ APIFunctions.prototype.setCustomCallback =
return this.setHook_(apiName, 'customCallback', customizedFunction);
};
-function CustomBindingsObject() {
-}
-
-CustomBindingsObject.prototype.setSchema = function(schema) {
- // The functions in the schema are in list form, so we move them into a
- // dictionary for easier access.
- var self = this;
- self.functionSchemas = {};
- $Array.forEach(schema.functions, function(f) {
- self.functionSchemas[f.name] = {
- name: f.name,
- definition: f
- }
- });
-};
-
// Get the platform from navigator.appVersion.
function getPlatform() {
var platforms = [
@@ -184,8 +172,6 @@ function createCustomType(type) {
type.id + '.');
var customType = jsModule[jsModuleName];
logging.CHECK(customType, jsModuleName + ' must export itself.');
- customType.prototype = new CustomBindingsObject();
- customType.prototype.setSchema(type);
return customType;
}
@@ -194,15 +180,29 @@ var platform = getPlatform();
function Binding(apiName) {
this.apiName_ = apiName;
this.apiFunctions_ = new APIFunctions(apiName);
- this.customEvent_ = null;
this.customHooks_ = [];
};
-Binding.create = function(apiName) {
- return new Binding(apiName);
-};
+$Object.defineProperty(Binding, 'create', {
+ __proto__: null,
+ configurable: false,
+ enumerable: false,
+ value: function(apiName) { return new Binding(apiName); },
+ writable: false,
+});
Binding.prototype = {
+ // Sneaky workaround for Object.prototype getters/setters - our prototype
+ // isn't Object.prototype. SafeBuiltins (e.g. $Object.hasOwnProperty())
+ // should still work.
+ __proto__: null,
+
+ // Forward-declare properties.
+ apiName_: undefined,
+ apiFunctions_: undefined,
+ customEvent_: undefined,
+ customHooks_: undefined,
+
// The API through which the ${api_name}_custom_bindings.js files customize
// their API bindings beyond what can be generated.
//
@@ -235,6 +235,7 @@ Binding.prototype = {
return;
hook({
+ __proto__: null,
apiFunctions: this.apiFunctions_,
schema: schema,
compiledApi: api
@@ -379,12 +380,11 @@ Binding.prototype = {
return;
}
- var apiFunction = {};
+ var apiFunction = { __proto__: null };
apiFunction.definition = functionDef;
- var apiFunctionName = schema.namespace + '.' + functionDef.name;
- apiFunction.name = apiFunctionName;
+ apiFunction.name = schema.namespace + '.' + functionDef.name;
- if (!GetAvailability(apiFunctionName).is_available ||
+ if (!GetAvailability(apiFunction.name).is_available ||
(checkUnprivileged && !isSchemaAccessAllowed(functionDef))) {
this.apiFunctions_.registerUnavailable(functionDef.name);
return;
@@ -422,6 +422,7 @@ Binding.prototype = {
retval = $Function.apply(this.handleRequest, this, args);
} else {
var optArgs = {
+ __proto__: null,
customCallback: this.customCallback
};
retval = sendRequest(this.name, args,
@@ -511,6 +512,8 @@ Binding.prototype = {
logging.CHECK(type, 'Schema for $ref type ' + ref + ' not found');
var constructor = createCustomType(type);
var args = value;
+ logging.DCHECK($Array.isArray(args));
+ $Array.push(args, type);
// For an object propertyDef, |value| is an array of constructor
// arguments, but we want to pass the arguments directly (i.e.
// not as an array), so we have to fake calling |new| on the
diff --git a/chromium/extensions/renderer/resources/context_menus_handlers.js b/chromium/extensions/renderer/resources/context_menus_handlers.js
index aef6889d7a3..4f72a8019f8 100644
--- a/chromium/extensions/renderer/resources/context_menus_handlers.js
+++ b/chromium/extensions/renderer/resources/context_menus_handlers.js
@@ -88,14 +88,15 @@ function createContextMenusHandlers(isWebview) {
};
// To be used with apiFunctions.setHandleRequest
- var requestHandlers = {};
+ var requestHandlers = { __proto__: null };
// To be used with apiFunctions.setCustomCallback
- var callbacks = {};
+ var callbacks = { __proto__: null };
requestHandlers.create = function() {
var createProperties = isWebview ? arguments[1] : arguments[0];
createProperties.generatedId = contextMenuNatives.GetNextContextMenuId();
var optArgs = {
+ __proto__: null,
customCallback: this.customCallback,
};
sendRequest(this.name, arguments, this.definition.parameters, optArgs);
diff --git a/chromium/extensions/renderer/resources/json_schema.js b/chromium/extensions/renderer/resources/json_schema.js
index 447d1ea21c2..ca351b4619a 100644
--- a/chromium/extensions/renderer/resources/json_schema.js
+++ b/chromium/extensions/renderer/resources/json_schema.js
@@ -38,8 +38,11 @@
// additional properties will be validated.
//==============================================================================
-var loadTypeSchema = require('utils').loadTypeSchema;
-var CHECK = requireNative('logging').CHECK;
+var utils = require('utils');
+var loggingNative = requireNative('logging');
+var getObjectType = requireNative('schema_registry').GetObjectType;
+var CHECK = loggingNative.CHECK;
+var DCHECK = loggingNative.DCHECK;
function isInstanceOfClass(instance, className) {
while ((instance = instance.__proto__)) {
@@ -50,7 +53,7 @@ function isInstanceOfClass(instance, className) {
}
function isOptionalValue(value) {
- return typeof(value) === 'undefined' || value === null;
+ return value === undefined || value === null;
}
function enumToString(enumValue) {
@@ -79,71 +82,68 @@ function JSONSchemaValidator() {
this.errors = [];
this.types = [];
}
-
-JSONSchemaValidator.messages = {
- invalidEnum: "Value must be one of: [*].",
- propertyRequired: "Property is required.",
- unexpectedProperty: "Unexpected property.",
- arrayMinItems: "Array must have at least * items.",
- arrayMaxItems: "Array must not have more than * items.",
- itemRequired: "Item is required.",
- stringMinLength: "String must be at least * characters long.",
- stringMaxLength: "String must not be more than * characters long.",
- stringPattern: "String must match the pattern: *.",
- numberFiniteNotNan: "Value must not be *.",
- numberMinValue: "Value must not be less than *.",
- numberMaxValue: "Value must not be greater than *.",
- numberIntValue: "Value must fit in a 32-bit signed integer.",
- numberMaxDecimal: "Value must not have more than * decimal places.",
+$Object.setPrototypeOf(JSONSchemaValidator.prototype, null);
+
+var messages = {
+ __proto__: null,
+
+ invalidEnum: 'Value must be one of: [*].',
+ propertyRequired: 'Property is required.',
+ unexpectedProperty: 'Unexpected property.',
+ arrayMinItems: 'Array must have at least * items.',
+ arrayMaxItems: 'Array must not have more than * items.',
+ itemRequired: 'Item is required.',
+ stringMinLength: 'String must be at least * characters long.',
+ stringMaxLength: 'String must not be more than * characters long.',
+ stringPattern: 'String must match the pattern: *.',
+ numberFiniteNotNan: 'Value must not be *.',
+ numberMinValue: 'Value must not be less than *.',
+ numberMaxValue: 'Value must not be greater than *.',
+ numberIntValue: 'Value must fit in a 32-bit signed integer.',
+ numberMaxDecimal: 'Value must not have more than * decimal places.',
invalidType: "Expected '*' but got '*'.",
invalidTypeIntegerNumber:
"Expected 'integer' but got 'number', consider using Math.round().",
- invalidChoice: "Value does not match any valid type choices.",
- invalidPropertyType: "Missing property type.",
- schemaRequired: "Schema value required.",
- unknownSchemaReference: "Unknown schema reference: *.",
- notInstance: "Object must be an instance of *."
+ invalidChoice: 'Value does not match any valid type choices.',
+ invalidPropertyType: 'Missing property type.',
+ schemaRequired: 'Schema value required.',
+ unknownSchemaReference: 'Unknown schema reference: *.',
+ notInstance: 'Object must be an instance of *.',
};
/**
* Builds an error message. Key is the property in the |errors| object, and
* |opt_replacements| is an array of values to replace "*" characters with.
*/
-JSONSchemaValidator.formatError = function(key, opt_replacements) {
- var message = this.messages[key];
+utils.defineProperty(JSONSchemaValidator, 'formatError',
+ function(key, opt_replacements) {
+ var message = messages[key];
if (opt_replacements) {
- for (var i = 0; i < opt_replacements.length; i++) {
- message = message.replace("*", opt_replacements[i]);
+ for (var i = 0; i < opt_replacements.length; ++i) {
+ DCHECK($String.indexOf(message, '*') != -1, message);
+ message = $String.replace(message, '*', opt_replacements[i]);
}
}
+ DCHECK($String.indexOf(message, '*') == -1)
return message;
-};
+});
/**
* Classifies a value as one of the JSON schema primitive types. Note that we
* don't explicitly disallow 'function', because we want to allow functions in
* the input values.
*/
-JSONSchemaValidator.getType = function(value) {
+utils.defineProperty(JSONSchemaValidator, 'getType', function(value) {
+ // If we can determine the type safely in JS, it's fastest to do it here.
+ // However, Object types are difficult to classify, so we have to do it in
+ // C++.
var s = typeof value;
-
- if (s == "object") {
- if (value === null) {
- return "null";
- } else if (Object.prototype.toString.call(value) == "[object Array]") {
- return "array";
- } else if (Object.prototype.toString.call(value) ==
- "[object ArrayBuffer]") {
- return "binary";
- }
- } else if (s == "number") {
- if (value % 1 == 0) {
- return "integer";
- }
- }
-
+ if (s === 'object')
+ return value === null ? 'null' : getObjectType(value);
+ if (s === 'number')
+ return value % 1 === 0 ? 'integer' : 'number';
return s;
-};
+});
/**
* Add types that may be referenced by validated schemas that reference them
@@ -157,8 +157,8 @@ JSONSchemaValidator.prototype.addTypes = function(typeOrTypeList) {
validator.types[type.id] = type;
}
- if (typeOrTypeList instanceof Array) {
- for (var i = 0; i < typeOrTypeList.length; i++) {
+ if ($Array.isArray(typeOrTypeList)) {
+ for (var i = 0; i < typeOrTypeList.length; ++i) {
addType(this, typeOrTypeList[i]);
}
} else {
@@ -174,7 +174,7 @@ JSONSchemaValidator.prototype.getAllTypesForSchema = function(schema) {
if (schema.type)
$Array.push(schemaTypes, schema.type);
if (schema.choices) {
- for (var i = 0; i < schema.choices.length; i++) {
+ for (var i = 0; i < schema.choices.length; ++i) {
var choiceTypes = this.getAllTypesForSchema(schema.choices[i]);
schemaTypes = $Array.concat(schemaTypes, choiceTypes);
}
@@ -190,7 +190,7 @@ JSONSchemaValidator.prototype.getAllTypesForSchema = function(schema) {
JSONSchemaValidator.prototype.getOrAddType = function(typeName) {
if (!this.types[typeName])
- this.types[typeName] = loadTypeSchema(typeName);
+ this.types[typeName] = utils.loadTypeSchema(typeName);
return this.types[typeName];
};
@@ -202,13 +202,13 @@ JSONSchemaValidator.prototype.isValidSchemaType = function(type, schema) {
return true;
// TODO(kalman): I don't understand this code. How can type be "null"?
- if (schema.optional && (type == "null" || type == "undefined"))
+ if (schema.optional && (type == 'null' || type == 'undefined'))
return true;
var schemaTypes = this.getAllTypesForSchema(schema);
- for (var i = 0; i < schemaTypes.length; i++) {
- if (schemaTypes[i] == "any" || type == schemaTypes[i] ||
- (type == "integer" && schemaTypes[i] == "number"))
+ for (var i = 0; i < schemaTypes.length; ++i) {
+ if (schemaTypes[i] == 'any' || type == schemaTypes[i] ||
+ (type == 'integer' && schemaTypes[i] == 'number'))
return true;
}
@@ -221,7 +221,7 @@ JSONSchemaValidator.prototype.isValidSchemaType = function(type, schema) {
*/
JSONSchemaValidator.prototype.checkSchemaOverlap = function(schema1, schema2) {
var schema1Types = this.getAllTypesForSchema(schema1);
- for (var i = 0; i < schema1Types.length; i++) {
+ for (var i = 0; i < schema1Types.length; ++i) {
if (this.isValidSchemaType(schema1Types[i], schema2))
return true;
}
@@ -234,10 +234,10 @@ JSONSchemaValidator.prototype.checkSchemaOverlap = function(schema1, schema2) {
* |errors| property will contain a list of errors, if any.
*/
JSONSchemaValidator.prototype.validate = function(instance, schema, opt_path) {
- var path = opt_path || "";
+ var path = opt_path || '';
if (!schema) {
- this.addError(path, "schemaRequired");
+ this.addError(path, 'schemaRequired');
return;
}
@@ -252,10 +252,10 @@ JSONSchemaValidator.prototype.validate = function(instance, schema, opt_path) {
// If the schema has a $ref property, the instance must validate against
// that schema too. It must be present in this.types to be referenced.
- var ref = schema["$ref"];
+ var ref = schema.$ref;
if (ref) {
if (!this.getOrAddType(ref))
- this.addError(path, "unknownSchemaReference", [ ref ]);
+ this.addError(path, 'unknownSchemaReference', [ref]);
else
this.validate(instance, this.getOrAddType(ref), path)
}
@@ -274,23 +274,23 @@ JSONSchemaValidator.prototype.validate = function(instance, schema, opt_path) {
return;
}
- if (schema.type && schema.type != "any") {
+ if (schema.type && schema.type != 'any') {
if (!this.validateType(instance, schema, path))
return;
// Type-specific validation.
switch (schema.type) {
- case "object":
+ case 'object':
this.validateObject(instance, schema, path);
break;
- case "array":
+ case 'array':
this.validateArray(instance, schema, path);
break;
- case "string":
+ case 'string':
this.validateString(instance, schema, path);
break;
- case "number":
- case "integer":
+ case 'number':
+ case 'integer':
this.validateNumber(instance, schema, path);
break;
}
@@ -305,7 +305,7 @@ JSONSchemaValidator.prototype.validateChoices =
function(instance, schema, path) {
var originalErrors = this.errors;
- for (var i = 0; i < schema.choices.length; i++) {
+ for (var i = 0; i < schema.choices.length; ++i) {
this.errors = [];
this.validate(instance, schema.choices[i], path);
if (this.errors.length == 0) {
@@ -315,7 +315,7 @@ JSONSchemaValidator.prototype.validateChoices =
}
this.errors = originalErrors;
- this.addError(path, "invalidChoice");
+ this.addError(path, 'invalidChoice');
};
/**
@@ -324,13 +324,13 @@ JSONSchemaValidator.prototype.validateChoices =
* validates.
*/
JSONSchemaValidator.prototype.validateEnum = function(instance, schema, path) {
- for (var i = 0; i < schema.enum.length; i++) {
+ for (var i = 0; i < schema.enum.length; ++i) {
if (instance === enumToString(schema.enum[i]))
return true;
}
- this.addError(path, "invalidEnum",
- [$Array.join($Array.map(schema.enum, enumToString), ", ")]);
+ this.addError(path, 'invalidEnum',
+ [$Array.join($Array.map(schema.enum, enumToString), ', ')]);
return false;
};
@@ -341,58 +341,45 @@ JSONSchemaValidator.prototype.validateEnum = function(instance, schema, path) {
JSONSchemaValidator.prototype.validateObject =
function(instance, schema, path) {
if (schema.properties) {
- for (var prop in schema.properties) {
- // It is common in JavaScript to add properties to Object.prototype. This
- // check prevents such additions from being interpreted as required
- // schema properties.
- // TODO(aa): If it ever turns out that we actually want this to work,
- // there are other checks we could put here, like requiring that schema
- // properties be objects that have a 'type' property.
- if (!$Object.hasOwnProperty(schema.properties, prop))
- continue;
-
- var propPath = path ? path + "." + prop : prop;
+ $Array.forEach($Object.keys(schema.properties), function(prop) {
+ var propPath = path ? path + '.' + prop : prop;
if (schema.properties[prop] == undefined) {
- this.addError(propPath, "invalidPropertyType");
- } else if (prop in instance && !isOptionalValue(instance[prop])) {
+ this.addError(propPath, 'invalidPropertyType');
+ } else if (instance[prop] !== undefined && instance[prop] !== null) {
this.validate(instance[prop], schema.properties[prop], propPath);
} else if (!schema.properties[prop].optional) {
- this.addError(propPath, "propertyRequired");
+ this.addError(propPath, 'propertyRequired');
}
- }
+ }, this);
}
// If "instanceof" property is set, check that this object inherits from
// the specified constructor (function).
if (schema.isInstanceOf) {
if (!isInstanceOfClass(instance, schema.isInstanceOf))
- this.addError(propPath, "notInstance", [schema.isInstanceOf]);
+ this.addError(path || '', 'notInstance', [schema.isInstanceOf]);
}
// Exit early from additional property check if "type":"any" is defined.
if (schema.additionalProperties &&
schema.additionalProperties.type &&
- schema.additionalProperties.type == "any") {
+ schema.additionalProperties.type == 'any') {
return;
}
// By default, additional properties are not allowed on instance objects. This
// can be overridden by setting the additionalProperties property to a schema
// which any additional properties must validate against.
- for (var prop in instance) {
- if (schema.properties && prop in schema.properties)
- continue;
-
- // Any properties inherited through the prototype are ignored.
- if (!$Object.hasOwnProperty(instance, prop))
- continue;
+ $Array.forEach($Object.keys(instance), function(prop) {
+ if (schema.properties && $Object.hasOwnProperty(schema.properties, prop))
+ return;
- var propPath = path ? path + "." + prop : prop;
+ var propPath = path ? path + '.' + prop : prop;
if (schema.additionalProperties)
this.validate(instance[prop], schema.additionalProperties, propPath);
else
- this.addError(propPath, "unexpectedProperty");
- }
+ this.addError(propPath, 'unexpectedProperty');
+ }, this);
};
/**
@@ -404,40 +391,39 @@ JSONSchemaValidator.prototype.validateArray = function(instance, schema, path) {
if (typeOfItems == 'object') {
if (schema.minItems && instance.length < schema.minItems) {
- this.addError(path, "arrayMinItems", [schema.minItems]);
+ this.addError(path, 'arrayMinItems', [schema.minItems]);
}
- if (typeof schema.maxItems != "undefined" &&
+ if (typeof schema.maxItems != 'undefined' &&
instance.length > schema.maxItems) {
- this.addError(path, "arrayMaxItems", [schema.maxItems]);
+ this.addError(path, 'arrayMaxItems', [schema.maxItems]);
}
// If the items property is a single schema, each item in the array must
// have that schema.
- for (var i = 0; i < instance.length; i++) {
- this.validate(instance[i], schema.items, path + "." + i);
+ for (var i = 0; i < instance.length; ++i) {
+ this.validate(instance[i], schema.items, path + '.' + i);
}
} else if (typeOfItems == 'array') {
// If the items property is an array of schemas, each item in the array must
// validate against the corresponding schema.
- for (var i = 0; i < schema.items.length; i++) {
- var itemPath = path ? path + "." + i : String(i);
- if (i in instance && !isOptionalValue(instance[i])) {
+ for (var i = 0; i < schema.items.length; ++i) {
+ var itemPath = path ? path + '.' + i : $String.self(i);
+ if ($Object.hasOwnProperty(instance, i) &&
+ !isOptionalValue(instance[i])) {
this.validate(instance[i], schema.items[i], itemPath);
} else if (!schema.items[i].optional) {
- this.addError(itemPath, "itemRequired");
+ this.addError(itemPath, 'itemRequired');
}
}
if (schema.additionalProperties) {
- for (var i = schema.items.length; i < instance.length; i++) {
- var itemPath = path ? path + "." + i : String(i);
+ for (var i = schema.items.length; i < instance.length; ++i) {
+ var itemPath = path ? path + '.' + i : $String.self(i);
this.validate(instance[i], schema.additionalProperties, itemPath);
}
- } else {
- if (instance.length > schema.items.length) {
- this.addError(path, "arrayMaxItems", [schema.items.length]);
- }
+ } else if (instance.length > schema.items.length) {
+ this.addError(path, 'arrayMaxItems', [schema.items.length]);
}
}
};
@@ -448,13 +434,13 @@ JSONSchemaValidator.prototype.validateArray = function(instance, schema, path) {
JSONSchemaValidator.prototype.validateString =
function(instance, schema, path) {
if (schema.minLength && instance.length < schema.minLength)
- this.addError(path, "stringMinLength", [schema.minLength]);
+ this.addError(path, 'stringMinLength', [schema.minLength]);
if (schema.maxLength && instance.length > schema.maxLength)
- this.addError(path, "stringMaxLength", [schema.maxLength]);
+ this.addError(path, 'stringMaxLength', [schema.maxLength]);
if (schema.pattern && !schema.pattern.test(instance))
- this.addError(path, "stringPattern", [schema.pattern]);
+ this.addError(path, 'stringPattern', [schema.pattern]);
};
/**
@@ -469,20 +455,35 @@ JSONSchemaValidator.prototype.validateNumber =
if (isNaN(instance) ||
instance == Number.POSITIVE_INFINITY ||
instance == Number.NEGATIVE_INFINITY )
- this.addError(path, "numberFiniteNotNan", [instance]);
+ this.addError(path, 'numberFiniteNotNan', [instance]);
if (schema.minimum !== undefined && instance < schema.minimum)
- this.addError(path, "numberMinValue", [schema.minimum]);
+ this.addError(path, 'numberMinValue', [schema.minimum]);
if (schema.maximum !== undefined && instance > schema.maximum)
- this.addError(path, "numberMaxValue", [schema.maximum]);
+ this.addError(path, 'numberMaxValue', [schema.maximum]);
// Check for integer values outside of -2^31..2^31-1.
- if (schema.type === "integer" && (instance | 0) !== instance)
- this.addError(path, "numberIntValue", []);
-
- if (schema.maxDecimal && instance * Math.pow(10, schema.maxDecimal) % 1)
- this.addError(path, "numberMaxDecimal", [schema.maxDecimal]);
+ if (schema.type === 'integer' && (instance | 0) !== instance)
+ this.addError(path, 'numberIntValue', []);
+
+ // We don't have a saved copy of Math, and it's not worth it just for a
+ // 10^x function.
+ var getPowerOfTen = function(pow) {
+ // '10' is kind of an arbitrary number of maximum decimal places, but it
+ // ensures we don't do anything crazy, and we should never need to restrict
+ // decimals to a number higher than that.
+ DCHECK(pow >= 1 && pow <= 10);
+ DCHECK(pow % 1 === 0);
+ var multiplier = 10;
+ while (--pow)
+ multiplier *= 10;
+ return multiplier;
+ };
+ if (schema.maxDecimal &&
+ (instance * getPowerOfTen(schema.maxDecimal)) % 1) {
+ this.addError(path, 'numberMaxDecimal', [schema.maxDecimal]);
+ }
};
/**
@@ -492,13 +493,13 @@ JSONSchemaValidator.prototype.validateNumber =
JSONSchemaValidator.prototype.validateType = function(instance, schema, path) {
var actualType = JSONSchemaValidator.getType(instance);
if (schema.type == actualType ||
- (schema.type == "number" && actualType == "integer")) {
+ (schema.type == 'number' && actualType == 'integer')) {
return true;
- } else if (schema.type == "integer" && actualType == "number") {
- this.addError(path, "invalidTypeIntegerNumber");
+ } else if (schema.type == 'integer' && actualType == 'number') {
+ this.addError(path, 'invalidTypeIntegerNumber');
return false;
} else {
- this.addError(path, "invalidType", [schema.type, actualType]);
+ this.addError(path, 'invalidType', [schema.type, actualType]);
return false;
}
};
@@ -510,6 +511,7 @@ JSONSchemaValidator.prototype.validateType = function(instance, schema, path) {
*/
JSONSchemaValidator.prototype.addError = function(path, key, replacements) {
$Array.push(this.errors, {
+ __proto__: null,
path: path,
message: JSONSchemaValidator.formatError(key, replacements)
});
diff --git a/chromium/extensions/renderer/resources/last_error.js b/chromium/extensions/renderer/resources/last_error.js
index fc0c7b5e4d3..14836b70067 100644
--- a/chromium/extensions/renderer/resources/last_error.js
+++ b/chromium/extensions/renderer/resources/last_error.js
@@ -68,10 +68,7 @@ function hasError(targetChrome) {
throw new Error('No target chrome to check');
assertRuntimeIsAvailable();
- if ('lastError' in targetChrome.runtime)
- return true;
-
- return false;
+ return $Object.hasOwnProperty(targetChrome.runtime, 'lastError');
};
/**
diff --git a/chromium/extensions/renderer/resources/media_router_bindings.js b/chromium/extensions/renderer/resources/media_router_bindings.js
index 4eaee9f0286..cf27b60af36 100644
--- a/chromium/extensions/renderer/resources/media_router_bindings.js
+++ b/chromium/extensions/renderer/resources/media_router_bindings.js
@@ -275,6 +275,20 @@ define('media_router_bindings', [
};
/**
+ * Called by the provider manager when a sink is found to notify the MR of the
+ * sink's ID. The actual sink will be returned through the normal sink list
+ * update process, so this helps the MR identify the search result in the
+ * list.
+ * @param {string} pseudoSinkId ID of the pseudo sink that started the
+ * search.
+ * @param {string} sinkId ID of the newly-found sink.
+ */
+ MediaRouter.prototype.onSearchSinkIdReceived = function(
+ pseudoSinkId, sinkId) {
+ this.service_.onSearchSinkIdReceived(pseudoSinkId, sinkId);
+ };
+
+ /**
* Called by the provider manager to keep the extension from suspending
* if it enters a state where suspension is undesirable (e.g. there is an
* active MediaRoute.)
@@ -339,7 +353,7 @@ define('media_router_bindings', [
'message': issue.message,
'default_action': issueActionToMojo_(issue.defaultAction),
'secondary_actions': secondaryActions,
- 'help_url': issue.helpUrl,
+ 'help_page_id': issue.helpPageId,
'is_blocking': issue.isBlocking
}));
};
@@ -409,7 +423,7 @@ define('media_router_bindings', [
*/
function MediaRouterHandlers() {
/**
- * @type {function(!string, !string, !string, !string, !number}
+ * @type {function(!string, !string, !string, !string, !number)}
*/
this.createRoute = null;
@@ -483,6 +497,11 @@ define('media_router_bindings', [
* @type {function()}
*/
this.updateMediaSinks = null;
+
+ /**
+ * @type {function(!string, !string, !SinkSearchCriteria): !string}
+ */
+ this.searchSinks = null;
};
/**
@@ -533,6 +552,7 @@ define('media_router_bindings', [
'connectRouteByRouteId',
'enableMdnsDiscovery',
'updateMediaSinks',
+ 'searchSinks',
];
requiredHandlers.forEach(function(nextHandler) {
if (handlers[nextHandler] === undefined) {
@@ -767,6 +787,32 @@ define('media_router_bindings', [
this.handlers_.updateMediaSinks(sourceUrn);
};
+ /**
+ * Requests that the provider manager search its providers for a sink matching
+ * |searchCriteria| that is compatible with |sourceUrn|. If a sink is found
+ * that can be used immediately for route creation, its ID is returned.
+ * Otherwise the empty string is returned.
+ *
+ * @param {string} sinkId Sink ID of the pseudo sink generating the request.
+ * @param {string} sourceUrn Media source to be used with the sink.
+ * @param {!SinkSearchCriteria} searchCriteria Search criteria for the route
+ * providers.
+ * @return {!Promise.<!{sink_id: !string}>} A Promise resolving to either the
+ * sink ID of the sink found by the search that can be used for route
+ * creation, or the empty string if no route can be immediately created.
+ */
+ MediaRouteProvider.prototype.searchSinks = function(
+ sinkId, sourceUrn, searchCriteria) {
+ // TODO(btolsch): Remove this check when we no longer expect old extensions
+ // to be missing this API.
+ if (!this.handlers_.searchSinks) {
+ return Promise.resolve({'sink_id': ''});
+ }
+ return Promise.resolve({
+ 'sink_id': this.handlers_.searchSinks(sinkId, sourceUrn, searchCriteria)
+ });
+ };
+
mediaRouter = new MediaRouter(connector.bindHandleToProxy(
serviceProvider.connectToService(
mediaRouterMojom.MediaRouter.name),
diff --git a/chromium/extensions/renderer/resources/runtime_custom_bindings.js b/chromium/extensions/renderer/resources/runtime_custom_bindings.js
index 1f829d4deb1..bbadf32f265 100644
--- a/chromium/extensions/renderer/resources/runtime_custom_bindings.js
+++ b/chromium/extensions/renderer/resources/runtime_custom_bindings.js
@@ -9,11 +9,12 @@ var binding = require('binding').Binding.create('runtime');
var messaging = require('messaging');
var runtimeNatives = requireNative('runtime');
var process = requireNative('process');
-var forEach = require('utils').forEach;
+var utils = require('utils');
var backgroundPage = window;
var backgroundRequire = require;
var contextType = process.GetContextType();
+
if (contextType == 'BLESSED_EXTENSION' ||
contextType == 'UNBLESSED_EXTENSION') {
var manifest = runtimeNatives.GetManifest();
@@ -71,8 +72,8 @@ if (window == backgroundPage) {
// backgroundPageModuleSystem.require('runtime') is insufficient as
// requireNative is only allowed while lazily loading an API.
backgroundPage.chrome.runtime;
- var bindDirectoryEntryCallback = backgroundRequire(
- 'runtime').bindDirectoryEntryCallback;
+ var bindDirectoryEntryCallback =
+ backgroundRequire('runtime').bindDirectoryEntryCallback;
}
binding.registerCustomHook(function(binding, id, contextType) {
@@ -84,34 +85,37 @@ binding.registerCustomHook(function(binding, id, contextType) {
//
if (id != '')
- runtime.id = id;
+ utils.defineProperty(runtime, 'id', id);
apiFunctions.setHandleRequest('getManifest', function() {
return runtimeNatives.GetManifest();
});
apiFunctions.setHandleRequest('getURL', function(path) {
- path = String(path);
+ path = $String.self(path);
if (!path.length || path[0] != '/')
path = '/' + path;
return 'chrome-extension://' + id + path;
});
var sendMessageUpdateArguments = messaging.sendMessageUpdateArguments;
- apiFunctions.setUpdateArgumentsPreValidate('sendMessage',
+ apiFunctions.setUpdateArgumentsPreValidate(
+ 'sendMessage',
$Function.bind(sendMessageUpdateArguments, null, 'sendMessage',
true /* hasOptionsArgument */));
- apiFunctions.setUpdateArgumentsPreValidate('sendNativeMessage',
+ apiFunctions.setUpdateArgumentsPreValidate(
+ 'sendNativeMessage',
$Function.bind(sendMessageUpdateArguments, null, 'sendNativeMessage',
false /* hasOptionsArgument */));
- apiFunctions.setHandleRequest('sendMessage',
+ apiFunctions.setHandleRequest(
+ 'sendMessage',
function(targetId, message, options, responseCallback) {
- var connectOptions = {name: messaging.kMessageChannel};
- forEach(options, function(k, v) {
- connectOptions[k] = v;
- });
- var port = runtime.connect(targetId || runtime.id, connectOptions);
+ var connectOptions = $Object.assign({
+ __proto__: null,
+ name: messaging.kMessageChannel,
+ }, options);
+ var port = runtime.connect(targetId, connectOptions);
messaging.sendMessageImpl(port, message, responseCallback);
});
@@ -121,46 +125,16 @@ binding.registerCustomHook(function(binding, id, contextType) {
messaging.sendMessageImpl(port, message, responseCallback);
});
- apiFunctions.setUpdateArgumentsPreValidate('connect', function() {
- // Align missing (optional) function arguments with the arguments that
- // schema validation is expecting, e.g.
- // runtime.connect() -> runtime.connect(null, null)
- // runtime.connect({}) -> runtime.connect(null, {})
- var nextArg = 0;
-
- // targetId (first argument) is optional.
- var targetId = null;
- if (typeof(arguments[nextArg]) == 'string')
- targetId = arguments[nextArg++];
-
- // connectInfo (second argument) is optional.
- var connectInfo = null;
- if (typeof(arguments[nextArg]) == 'object')
- connectInfo = arguments[nextArg++];
-
- if (nextArg != arguments.length)
- throw new Error('Invalid arguments to connect.');
- return [targetId, connectInfo];
- });
-
- apiFunctions.setUpdateArgumentsPreValidate('connectNative',
- function(appName) {
- if (typeof(appName) !== 'string') {
- throw new Error('Invalid arguments to connectNative.');
- }
- return [appName];
- });
-
apiFunctions.setHandleRequest('connect', function(targetId, connectInfo) {
if (!targetId) {
- // runtime.id is only defined inside extensions. If we're in a webpage,
- // the best we can do at this point is to fail.
- if (!runtime.id) {
+ // id is only defined inside extensions. If we're in a webpage, the best
+ // we can do at this point is to fail.
+ if (!id) {
throw new Error('chrome.runtime.connect() called from a webpage must ' +
'specify an Extension ID (string) for its first ' +
'argument');
}
- targetId = runtime.id;
+ targetId = id;
}
var name = '';
@@ -184,8 +158,7 @@ binding.registerCustomHook(function(binding, id, contextType) {
apiFunctions.setHandleRequest('connectNative',
function(nativeAppName) {
- var portId = runtimeNatives.OpenChannelToNativeApp(runtime.id,
- nativeAppName);
+ var portId = runtimeNatives.OpenChannelToNativeApp(nativeAppName);
if (portId >= 0)
return messaging.createPort(portId, '');
throw new Error('Error connecting to native app: ' + nativeAppName);
diff --git a/chromium/extensions/renderer/resources/schema_utils.js b/chromium/extensions/renderer/resources/schema_utils.js
index b14d2eb548d..1d1023a00b2 100644
--- a/chromium/extensions/renderer/resources/schema_utils.js
+++ b/chromium/extensions/renderer/resources/schema_utils.js
@@ -12,29 +12,29 @@ var schemaValidator = new JSONSchemaValidator();
// Validate arguments.
function validate(args, parameterSchemas) {
if (args.length > parameterSchemas.length)
- throw new Error("Too many arguments.");
- for (var i = 0; i < parameterSchemas.length; i++) {
- if (i in args && args[i] !== null && args[i] !== undefined) {
+ throw new Error('Too many arguments.');
+ for (var i = 0; i < parameterSchemas.length; ++i) {
+ if ($Object.hasOwnProperty(args, i) && args[i] !== null &&
+ args[i] !== undefined) {
schemaValidator.resetErrors();
schemaValidator.validate(args[i], parameterSchemas[i]);
if (schemaValidator.errors.length == 0)
continue;
- var message = "Invalid value for argument " + (i + 1) + ". ";
- for (var i = 0, err;
- err = schemaValidator.errors[i]; i++) {
+ var message = 'Invalid value for argument ' + (i + 1) + '. ';
+ $Array.forEach(schemaValidator.errors, function(err) {
if (err.path) {
message += "Property '" + err.path + "': ";
}
message += err.message;
message = message.substring(0, message.length - 1);
- message += ", ";
- }
+ message += ', ';
+ });
message = message.substring(0, message.length - 2);
- message += ".";
+ message += '.';
throw new Error(message);
} else if (!parameterSchemas[i].optional) {
- throw new Error("Parameter " + (i + 1) + " (" +
- parameterSchemas[i].name + ") is required.");
+ throw new Error('Parameter ' + (i + 1) + ' (' +
+ parameterSchemas[i].name + ') is required.');
}
}
}
@@ -45,7 +45,7 @@ function getSignatures(parameterSchemas) {
return [[]];
var signatures = [];
var remaining = getSignatures($Array.slice(parameterSchemas, 1));
- for (var i = 0; i < remaining.length; i++)
+ for (var i = 0; i < remaining.length; ++i)
$Array.push(signatures, $Array.concat([parameterSchemas[0]], remaining[i]))
if (parameterSchemas[0].optional)
return $Array.concat(signatures, remaining);
@@ -56,10 +56,9 @@ function getSignatures(parameterSchemas) {
function argumentsMatchSignature(args, candidateSignature) {
if (args.length != candidateSignature.length)
return false;
- for (var i = 0; i < candidateSignature.length; i++) {
+ for (var i = 0; i < candidateSignature.length; ++i) {
var argType = JSONSchemaValidator.getType(args[i]);
- if (!schemaValidator.isValidSchemaType(argType,
- candidateSignature[i]))
+ if (!schemaValidator.isValidSchemaType(argType, candidateSignature[i]))
return false;
}
return true;
@@ -68,7 +67,7 @@ function argumentsMatchSignature(args, candidateSignature) {
// Finds the function signature for the given arguments.
function resolveSignature(args, definedSignature) {
var candidateSignatures = getSignatures(definedSignature);
- for (var i = 0; i < candidateSignatures.length; i++) {
+ for (var i = 0; i < candidateSignatures.length; ++i) {
if (argumentsMatchSignature(args, candidateSignatures[i]))
return candidateSignatures[i];
}
@@ -81,13 +80,13 @@ function resolveSignature(args, definedSignature) {
function getParameterSignatureString(name, definedSignature) {
var getSchemaTypeString = function(schema) {
var schemaTypes = schemaValidator.getAllTypesForSchema(schema);
- var typeName = schemaTypes.join(" or ") + " " + schema.name;
+ var typeName = $Array.join(schemaTypes, ' or ') + ' ' + schema.name;
if (schema.optional)
- return "optional " + typeName;
+ return 'optional ' + typeName;
return typeName;
};
var typeNames = $Array.map(definedSignature, getSchemaTypeString);
- return name + "(" + typeNames.join(", ") + ")";
+ return name + '(' + $Array.join(typeNames, ', ') + ')';
};
// Returns a string representing a call to an API function.
@@ -95,7 +94,7 @@ function getParameterSignatureString(name, definedSignature) {
// "windows.get(int, function)"
function getArgumentSignatureString(name, args) {
var typeNames = $Array.map(args, JSONSchemaValidator.getType);
- return name + "(" + typeNames.join(", ") + ")";
+ return name + '(' + $Array.join(typeNames, ', ') + ')';
};
// Finds the correct signature for the given arguments, then validates the
@@ -110,16 +109,16 @@ function normalizeArgumentsAndValidate(args, funDef) {
var definedSignature = funDef.definition.parameters;
var resolvedSignature = resolveSignature(args, definedSignature);
if (!resolvedSignature)
- throw new Error("Invocation of form " +
+ throw new Error('Invocation of form ' +
getArgumentSignatureString(funDef.name, args) +
" doesn't match definition " +
getParameterSignatureString(funDef.name, definedSignature));
validate(args, resolvedSignature);
var normalizedArgs = [];
var ai = 0;
- for (var si = 0; si < definedSignature.length; si++) {
+ for (var si = 0; si < definedSignature.length; ++si) {
// Handle integer -0 as 0.
- if (JSONSchemaValidator.getType(args[ai]) === "integer" && args[ai] === 0)
+ if (JSONSchemaValidator.getType(args[ai]) === 'integer' && args[ai] === 0)
args[ai] = 0;
if (definedSignature[si] === resolvedSignature[ai])
$Array.push(normalizedArgs, args[ai++]);
@@ -144,8 +143,8 @@ function isFunctionSignatureAmbiguous(functionDef) {
return true;
};
var candidateSignatures = getSignatures(functionDef.parameters);
- for (var i = 0; i < candidateSignatures.length; i++) {
- for (var j = i + 1; j < candidateSignatures.length; j++) {
+ for (var i = 0; i < candidateSignatures.length; ++i) {
+ for (var j = i + 1; j < candidateSignatures.length; ++j) {
if (signaturesAmbiguous(candidateSignatures[i], candidateSignatures[j]))
return true;
}
diff --git a/chromium/extensions/renderer/resources/send_request.js b/chromium/extensions/renderer/resources/send_request.js
index 9fed10e7f42..5a9fa965e3e 100644
--- a/chromium/extensions/renderer/resources/send_request.js
+++ b/chromium/extensions/renderer/resources/send_request.js
@@ -9,7 +9,7 @@ var natives = requireNative('sendRequest');
var validate = require('schemaUtils').validate;
// All outstanding requests from sendRequest().
-var requests = {};
+var requests = { __proto__: null };
// Used to prevent double Activity Logging for API calls that use both custom
// bindings and ExtensionFunctions (via sendRequest).
@@ -88,7 +88,7 @@ function handleResponse(requestId, name, success, responseList, error) {
}
function prepareRequest(args, argSchemas) {
- var request = {};
+ var request = { __proto__: null };
var argCount = args.length;
// Look for callback param.
@@ -99,11 +99,7 @@ function prepareRequest(args, argSchemas) {
--argCount;
}
- request.args = [];
- for (var k = 0; k < argCount; k++) {
- request.args[k] = args[k];
- }
-
+ request.args = $Array.slice(args, 0, argCount);
return request;
}
@@ -119,7 +115,8 @@ function prepareRequest(args, argSchemas) {
function sendRequest(functionName, args, argSchemas, optArgs) {
calledSendRequest = true;
if (!optArgs)
- optArgs = {};
+ optArgs = { __proto__: null };
+ logging.DCHECK(optArgs.__proto__ == null);
var request = prepareRequest(args, argSchemas);
request.stack = optArgs.stack || exceptionHandler.getExtensionStackTrace();
if (optArgs.customCallback) {
diff --git a/chromium/extensions/renderer/resources/storage_area.js b/chromium/extensions/renderer/resources/storage_area.js
index 4ff6bbdb6d0..ff9fafb7ee4 100644
--- a/chromium/extensions/renderer/resources/storage_area.js
+++ b/chromium/extensions/renderer/resources/storage_area.js
@@ -12,25 +12,32 @@ function extendSchema(schema) {
return extendedSchema;
}
+// TODO(devlin): Combine parts of this and other custom types (ChromeSetting,
+// ContentSetting, etc).
function StorageArea(namespace, schema) {
// Binds an API function for a namespace to its browser-side call, e.g.
// storage.sync.get('foo') -> (binds to) ->
// storage.get('sync', 'foo').
- //
- // TODO(kalman): Put as a method on CustombindingObject and re-use (or
- // even generate) for other APIs that need to do this. Same for other
- // callers of registerCustomType().
var self = this;
function bindApiFunction(functionName) {
+ var rawFunSchema =
+ $Array.filter(schema.functions,
+ function(f) { return f.name === functionName; })[0];
+ // normalizeArgumentsAndValidate expects a function schema of the form
+ // { name: <name>, definition: <definition> }.
+ var funSchema = {
+ __proto__: null,
+ name: rawFunSchema.name,
+ definition: rawFunSchema
+ };
self[functionName] = function() {
- var funSchema = this.functionSchemas[functionName];
var args = $Array.slice(arguments);
args = normalizeArgumentsAndValidate(args, funSchema);
return sendRequest(
'storage.' + functionName,
$Array.concat([namespace], args),
extendSchema(funSchema.definition.parameters),
- {preserveNullInObjects: true});
+ {__proto__: null, preserveNullInObjects: true});
};
}
var apiFunctions = ['get', 'set', 'remove', 'clear', 'getBytesInUse'];
diff --git a/chromium/extensions/renderer/resources/web_request_custom_bindings.js b/chromium/extensions/renderer/resources/web_request_custom_bindings.js
index 2dd7ce4f048..26ba84fcf91 100644
--- a/chromium/extensions/renderer/resources/web_request_custom_bindings.js
+++ b/chromium/extensions/renderer/resources/web_request_custom_bindings.js
@@ -14,7 +14,7 @@ binding.registerCustomHook(function(api) {
apiFunctions.setHandleRequest('handlerBehaviorChanged', function() {
var args = $Array.slice(arguments);
sendRequest(this.name, args, this.definition.parameters,
- {forIOThread: true});
+ {__proto__: null, forIOThread: true});
});
});
diff --git a/chromium/extensions/renderer/resources/web_request_internal_custom_bindings.js b/chromium/extensions/renderer/resources/web_request_internal_custom_bindings.js
index 32ad33b9b47..3c74a6781c9 100644
--- a/chromium/extensions/renderer/resources/web_request_internal_custom_bindings.js
+++ b/chromium/extensions/renderer/resources/web_request_internal_custom_bindings.js
@@ -166,13 +166,13 @@ binding.registerCustomHook(function(api) {
apiFunctions.setHandleRequest('addEventListener', function() {
var args = $Array.slice(arguments);
sendRequest(this.name, args, this.definition.parameters,
- {forIOThread: true});
+ {__proto__: null, forIOThread: true});
});
apiFunctions.setHandleRequest('eventHandled', function() {
var args = $Array.slice(arguments);
sendRequest(this.name, args, this.definition.parameters,
- {forIOThread: true});
+ {__proto__: null, forIOThread: true});
});
});
diff --git a/chromium/extensions/renderer/runtime_custom_bindings.cc b/chromium/extensions/renderer/runtime_custom_bindings.cc
index 8c6f2705e7e..6efae5f182d 100644
--- a/chromium/extensions/renderer/runtime_custom_bindings.cc
+++ b/chromium/extensions/renderer/runtime_custom_bindings.cc
@@ -6,24 +6,18 @@
#include <stdint.h>
+#include <memory>
+
#include "base/bind.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "content/public/child/v8_value_converter.h"
#include "content/public/renderer/render_frame.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_messages.h"
-#include "extensions/common/features/feature.h"
-#include "extensions/common/features/feature_provider.h"
#include "extensions/common/manifest.h"
-#include "extensions/renderer/api_activity_logger.h"
#include "extensions/renderer/extension_frame_helper.h"
#include "extensions/renderer/script_context.h"
-#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
-#include "third_party/WebKit/public/web/WebView.h"
-
-using content::V8ValueConverter;
namespace extensions {
@@ -32,10 +26,10 @@ RuntimeCustomBindings::RuntimeCustomBindings(ScriptContext* context)
RouteFunction(
"GetManifest",
base::Bind(&RuntimeCustomBindings::GetManifest, base::Unretained(this)));
- RouteFunction("OpenChannelToExtension",
+ RouteFunction("OpenChannelToExtension", "runtime.connect",
base::Bind(&RuntimeCustomBindings::OpenChannelToExtension,
base::Unretained(this)));
- RouteFunction("OpenChannelToNativeApp",
+ RouteFunction("OpenChannelToNativeApp", "runtime.connectNative",
base::Bind(&RuntimeCustomBindings::OpenChannelToNativeApp,
base::Unretained(this)));
RouteFunction("GetExtensionViews",
@@ -72,6 +66,7 @@ void RuntimeCustomBindings::OpenChannelToExtension(
bool include_tls_channel_id =
args.Length() > 2 ? args[2]->BooleanValue() : false;
int port_id = -1;
+ // TODO(devlin): This file is littered with sync IPCs. Yuck.
renderframe->Send(new ExtensionHostMsg_OpenChannelToExtension(
renderframe->GetRoutingID(), info, channel_name, include_tls_channel_id,
&port_id));
@@ -80,28 +75,23 @@ void RuntimeCustomBindings::OpenChannelToExtension(
void RuntimeCustomBindings::OpenChannelToNativeApp(
const v8::FunctionCallbackInfo<v8::Value>& args) {
+ // The Javascript code should validate/fill the arguments.
+ CHECK_EQ(args.Length(), 1);
+ CHECK(args[0]->IsString());
+
// Verify that the extension has permission to use native messaging.
- Feature::Availability availability =
- FeatureProvider::GetPermissionFeatures()
- ->GetFeature("nativeMessaging")
- ->IsAvailableToContext(context()->extension(),
- context()->context_type(), context()->url());
- if (!availability.is_available())
+ if (!context()->GetAvailability("runtime.connectNative").is_available())
return;
content::RenderFrame* render_frame = context()->GetRenderFrame();
if (!render_frame)
return;
- // The Javascript code should validate/fill the arguments.
- CHECK(args.Length() >= 2 && args[0]->IsString() && args[1]->IsString());
-
- std::string extension_id = *v8::String::Utf8Value(args[0]);
- std::string native_app_name = *v8::String::Utf8Value(args[1]);
+ std::string native_app_name = *v8::String::Utf8Value(args[0]);
int port_id = -1;
render_frame->Send(new ExtensionHostMsg_OpenChannelToNativeApp(
- render_frame->GetRoutingID(), extension_id, native_app_name, &port_id));
+ render_frame->GetRoutingID(), native_app_name, &port_id));
args.GetReturnValue().Set(static_cast<int32_t>(port_id));
}
@@ -109,18 +99,17 @@ void RuntimeCustomBindings::GetManifest(
const v8::FunctionCallbackInfo<v8::Value>& args) {
CHECK(context()->extension());
- scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
+ std::unique_ptr<content::V8ValueConverter> converter(
+ content::V8ValueConverter::create());
args.GetReturnValue().Set(converter->ToV8Value(
context()->extension()->manifest()->value(), context()->v8_context()));
}
void RuntimeCustomBindings::GetExtensionViews(
const v8::FunctionCallbackInfo<v8::Value>& args) {
- if (args.Length() != 2)
- return;
-
- if (!args[0]->IsInt32() || !args[1]->IsString())
- return;
+ CHECK_EQ(args.Length(), 2);
+ CHECK(args[0]->IsInt32());
+ CHECK(args[1]->IsString());
// |browser_window_id| == extension_misc::kUnknownWindowId means getting
// all views for the current extension.
@@ -145,11 +134,11 @@ void RuntimeCustomBindings::GetExtensionViews(
view_type = VIEW_TYPE_LAUNCHER_PAGE;
} else if (view_type_string == kViewTypePanel) {
view_type = VIEW_TYPE_PANEL;
- } else if (view_type_string != kViewTypeAll) {
- return;
+ } else {
+ CHECK_EQ(view_type_string, kViewTypeAll);
}
- std::string extension_id = context()->GetExtensionID();
+ const std::string& extension_id = context()->GetExtensionID();
if (extension_id.empty())
return;
@@ -164,17 +153,20 @@ void RuntimeCustomBindings::GetExtensionViews(
// main views, not any subframes. (Returning subframes can cause broken
// behavior by treating an app window's iframe as its main frame, and maybe
// other nastiness).
- if (frame->GetWebFrame()->top() != frame->GetWebFrame())
+ blink::WebFrame* web_frame = frame->GetWebFrame();
+ if (web_frame->top() != web_frame)
+ continue;
+
+ if (!blink::WebFrame::scriptCanAccess(web_frame))
continue;
- v8::Local<v8::Context> context =
- frame->GetWebFrame()->mainWorldScriptContext();
+ v8::Local<v8::Context> context = web_frame->mainWorldScriptContext();
if (!context.IsEmpty()) {
v8::Local<v8::Value> window = context->Global();
- DCHECK(!window.IsEmpty());
+ CHECK(!window.IsEmpty());
v8::Maybe<bool> maybe =
- v8_views->CreateDataProperty(v8_context, v8_index++, window);
- DCHECK(maybe.IsJust() && maybe.FromJust());
+ v8_views->CreateDataProperty(v8_context, v8_index++, window);
+ CHECK(maybe.IsJust() && maybe.FromJust());
}
}
diff --git a/chromium/extensions/renderer/safe_builtins.cc b/chromium/extensions/renderer/safe_builtins.cc
index 914f4eaf940..c079b4038ec 100644
--- a/chromium/extensions/renderer/safe_builtins.cc
+++ b/chromium/extensions/renderer/safe_builtins.cc
@@ -21,14 +21,14 @@ const char kClassName[] = "extensions::SafeBuiltins";
// Documentation for makeCallback in the JavaScript, out here to reduce the
// (very small) amount of effort that the v8 parser needs to do:
//
-// Returns a new object with every function on |obj| configured to call()\n"
-// itself with the given arguments.\n"
-// E.g. given\n"
-// var result = makeCallable(Function.prototype)\n"
-// |result| will be a object including 'bind' such that\n"
-// result.bind(foo, 1, 2, 3);\n"
-// is equivalent to Function.prototype.bind.call(foo, 1, 2, 3), and so on.\n"
-// This is a convenient way to save functions that user scripts may clobber.\n"
+// Returns a new object with every function on |obj| configured to call()
+// itself with the given arguments.
+// E.g. given
+// var result = makeCallable(Function.prototype)
+// |result| will be a object including 'bind' such that
+// result.bind(foo, 1, 2, 3);
+// is equivalent to Function.prototype.bind.call(foo, 1, 2, 3), and so on.
+// This is a convenient way to save functions that user scripts may clobber.
const char kScript[] =
"(function() {\n"
"'use strict';\n"
@@ -196,7 +196,8 @@ class ExtensionImpl : public v8::Extension {
v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
int argc = args_length - first_arg_index;
- scoped_ptr<v8::Local<v8::Value> []> argv(new v8::Local<v8::Value>[argc]);
+ std::unique_ptr<v8::Local<v8::Value>[]> argv(
+ new v8::Local<v8::Value>[argc]);
for (int i = 0; i < argc; ++i) {
CHECK(IsTrue(args->Has(context, i + first_arg_index)));
// Getting a property value could throw an exception.
diff --git a/chromium/extensions/renderer/safe_builtins.h b/chromium/extensions/renderer/safe_builtins.h
index 83aaca9e537..cf2432434d6 100644
--- a/chromium/extensions/renderer/safe_builtins.h
+++ b/chromium/extensions/renderer/safe_builtins.h
@@ -5,12 +5,13 @@
#ifndef EXTENSIONS_RENDERER_SAFE_BUILTINS_H_
#define EXTENSIONS_RENDERER_SAFE_BUILTINS_H_
+#include "base/macros.h"
#include "v8/include/v8.h"
namespace extensions {
class ScriptContext;
-// A collection of safe builtin objects, in that they won't be tained by
+// A collection of safe builtin objects, in that they won't be tainted by
// extensions overriding methods on them.
class SafeBuiltins {
public:
@@ -18,8 +19,7 @@ class SafeBuiltins {
static v8::Extension* CreateV8Extension();
explicit SafeBuiltins(ScriptContext* context);
-
- virtual ~SafeBuiltins();
+ ~SafeBuiltins();
// Each method returns an object with methods taken from their respective
// builtin object's prototype, adapted to automatically call() themselves.
@@ -40,6 +40,8 @@ class SafeBuiltins {
private:
ScriptContext* context_;
+
+ DISALLOW_COPY_AND_ASSIGN(SafeBuiltins);
};
} // namespace extensions
diff --git a/chromium/extensions/renderer/script_context.cc b/chromium/extensions/renderer/script_context.cc
index a1d8996a5da..529c5fcd40c 100644
--- a/chromium/extensions/renderer/script_context.cc
+++ b/chromium/extensions/renderer/script_context.cc
@@ -4,10 +4,11 @@
#include "extensions/renderer/script_context.h"
+#include <memory>
+
#include "base/command_line.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
@@ -323,7 +324,7 @@ void ScriptContext::OnResponseReceived(const std::string& name,
DCHECK(thread_checker_.CalledOnValidThread());
v8::HandleScope handle_scope(isolate());
- scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
+ std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create());
v8::Local<v8::Value> argv[] = {
v8::Integer::New(isolate(), request_id),
v8::String::NewFromUtf8(isolate(), name.c_str()),
diff --git a/chromium/extensions/renderer/script_context.h b/chromium/extensions/renderer/script_context.h
index 48c873ce1fc..bbfd2f6b90e 100644
--- a/chromium/extensions/renderer/script_context.h
+++ b/chromium/extensions/renderer/script_context.h
@@ -89,7 +89,7 @@ class ScriptContext : public RequestSender::Source {
return effective_context_type_;
}
- void set_module_system(scoped_ptr<ModuleSystem> module_system) {
+ void set_module_system(std::unique_ptr<ModuleSystem> module_system) {
module_system_ = std::move(module_system);
}
@@ -231,7 +231,7 @@ class ScriptContext : public RequestSender::Source {
Feature::Context effective_context_type_;
// Owns and structures the JS that is injected to set up extension bindings.
- scoped_ptr<ModuleSystem> module_system_;
+ std::unique_ptr<ModuleSystem> module_system_;
// Contains safe copies of builtin objects like Function.prototype.
SafeBuiltins safe_builtins_;
@@ -247,7 +247,7 @@ class ScriptContext : public RequestSender::Source {
GURL url_;
- scoped_ptr<Runner> runner_;
+ std::unique_ptr<Runner> runner_;
base::ThreadChecker thread_checker_;
diff --git a/chromium/extensions/renderer/script_injection.cc b/chromium/extensions/renderer/script_injection.cc
index 70464b646c4..8933f664d20 100644
--- a/chromium/extensions/renderer/script_injection.cc
+++ b/chromium/extensions/renderer/script_injection.cc
@@ -115,10 +115,11 @@ void ScriptInjection::RemoveIsolatedWorld(const std::string& host_id) {
g_isolated_worlds.Get().erase(host_id);
}
-ScriptInjection::ScriptInjection(scoped_ptr<ScriptInjector> injector,
- content::RenderFrame* render_frame,
- scoped_ptr<const InjectionHost> injection_host,
- UserScript::RunLocation run_location)
+ScriptInjection::ScriptInjection(
+ std::unique_ptr<ScriptInjector> injector,
+ content::RenderFrame* render_frame,
+ std::unique_ptr<const InjectionHost> injection_host,
+ UserScript::RunLocation run_location)
: injector_(std::move(injector)),
render_frame_(render_frame),
injection_host_(std::move(injection_host)),
@@ -246,7 +247,7 @@ void ScriptInjection::InjectJs() {
web_frame);
bool is_user_gesture = injector_->IsUserGesture();
- scoped_ptr<blink::WebScriptExecutionCallback> callback(
+ std::unique_ptr<blink::WebScriptExecutionCallback> callback(
new ScriptInjectionCallback(
base::Bind(&ScriptInjection::OnJsInjectionCompleted,
weak_ptr_factory_.GetWeakPtr())));
@@ -283,7 +284,7 @@ void ScriptInjection::OnJsInjectionCompleted(
if (expects_results) {
if (!results.isEmpty() && !results[0].IsEmpty()) {
// Right now, we only support returning single results (per frame).
- scoped_ptr<content::V8ValueConverter> v8_converter(
+ std::unique_ptr<content::V8ValueConverter> v8_converter(
content::V8ValueConverter::create());
// It's safe to always use the main world context when converting
// here. V8ValueConverterImpl shouldn't actually care about the
diff --git a/chromium/extensions/renderer/script_injection.h b/chromium/extensions/renderer/script_injection.h
index 6b3679573c3..a7a44b62721 100644
--- a/chromium/extensions/renderer/script_injection.h
+++ b/chromium/extensions/renderer/script_injection.h
@@ -7,9 +7,10 @@
#include <stdint.h>
+#include <memory>
+
#include "base/callback.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "extensions/common/user_script.h"
#include "extensions/renderer/injection_host.h"
@@ -51,9 +52,9 @@ class ScriptInjection {
// Remove the isolated world associated with the given injection host.
static void RemoveIsolatedWorld(const std::string& host_id);
- ScriptInjection(scoped_ptr<ScriptInjector> injector,
+ ScriptInjection(std::unique_ptr<ScriptInjector> injector,
content::RenderFrame* render_frame,
- scoped_ptr<const InjectionHost> injection_host,
+ std::unique_ptr<const InjectionHost> injection_host,
UserScript::RunLocation run_location);
~ScriptInjection();
@@ -109,13 +110,13 @@ class ScriptInjection {
void NotifyWillNotInject(ScriptInjector::InjectFailureReason reason);
// The injector for this injection.
- scoped_ptr<ScriptInjector> injector_;
+ std::unique_ptr<ScriptInjector> injector_;
// The RenderFrame into which this should inject the script.
content::RenderFrame* render_frame_;
// The associated injection host.
- scoped_ptr<const InjectionHost> injection_host_;
+ std::unique_ptr<const InjectionHost> injection_host_;
// The location in the document load at which we inject the script.
UserScript::RunLocation run_location_;
@@ -132,13 +133,13 @@ class ScriptInjection {
bool did_inject_js_;
// Results storage.
- scoped_ptr<base::Value> execution_result_;
+ std::unique_ptr<base::Value> execution_result_;
// The callback to run upon completing asynchronously.
CompletionCallback async_completion_callback_;
// A helper class to hold the render frame and watch for its deletion.
- scoped_ptr<FrameWatcher> frame_watcher_;
+ std::unique_ptr<FrameWatcher> frame_watcher_;
base::WeakPtrFactory<ScriptInjection> weak_ptr_factory_;
diff --git a/chromium/extensions/renderer/script_injection_manager.cc b/chromium/extensions/renderer/script_injection_manager.cc
index 0e234d0906b..eddd599f919 100644
--- a/chromium/extensions/renderer/script_injection_manager.cc
+++ b/chromium/extensions/renderer/script_injection_manager.cc
@@ -4,11 +4,12 @@
#include "extensions/renderer/script_injection_manager.h"
+#include <memory>
#include <utility>
#include "base/auto_reset.h"
#include "base/bind.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/weak_ptr.h"
#include "base/values.h"
#include "content/public/renderer/render_frame.h"
@@ -270,7 +271,7 @@ ScriptInjectionManager::~ScriptInjectionManager() {
void ScriptInjectionManager::OnRenderFrameCreated(
content::RenderFrame* render_frame) {
- rfo_helpers_.push_back(make_scoped_ptr(new RFOHelper(render_frame, this)));
+ rfo_helpers_.push_back(base::WrapUnique(new RFOHelper(render_frame, this)));
}
void ScriptInjectionManager::OnExtensionUnloaded(
@@ -290,7 +291,7 @@ void ScriptInjectionManager::OnInjectionFinished(
ScriptInjection* injection) {
auto iter =
std::find_if(running_injections_.begin(), running_injections_.end(),
- [injection](const scoped_ptr<ScriptInjection>& mode) {
+ [injection](const std::unique_ptr<ScriptInjection>& mode) {
return injection == mode.get();
});
if (iter != running_injections_.end())
@@ -398,7 +399,7 @@ void ScriptInjectionManager::InjectScripts(
// (if a script removes its own frame, for example). If this happens, abort.
if (!active_injection_frames_.count(frame))
break;
- scoped_ptr<ScriptInjection> injection(std::move(*iter));
+ std::unique_ptr<ScriptInjection> injection(std::move(*iter));
iter = frame_injections.erase(iter);
TryToInject(std::move(injection), run_location, &scripts_run_info);
}
@@ -410,7 +411,7 @@ void ScriptInjectionManager::InjectScripts(
}
void ScriptInjectionManager::TryToInject(
- scoped_ptr<ScriptInjection> injection,
+ std::unique_ptr<ScriptInjection> injection,
UserScript::RunLocation run_location,
ScriptsRunInfo* scripts_run_info) {
// Try to inject the script. If the injection is waiting (i.e., for
@@ -437,7 +438,7 @@ void ScriptInjectionManager::TryToInject(
void ScriptInjectionManager::HandleExecuteCode(
const ExtensionMsg_ExecuteCode_Params& params,
content::RenderFrame* render_frame) {
- scoped_ptr<const InjectionHost> injection_host;
+ std::unique_ptr<const InjectionHost> injection_host;
if (params.host_id.type() == HostID::EXTENSIONS) {
injection_host = ExtensionInjectionHost::Create(params.host_id.id());
if (!injection_host)
@@ -447,8 +448,8 @@ void ScriptInjectionManager::HandleExecuteCode(
new WebUIInjectionHost(params.host_id));
}
- scoped_ptr<ScriptInjection> injection(new ScriptInjection(
- scoped_ptr<ScriptInjector>(
+ std::unique_ptr<ScriptInjection> injection(new ScriptInjection(
+ std::unique_ptr<ScriptInjector>(
new ProgrammaticScriptInjector(params, render_frame)),
render_frame, std::move(injection_host),
static_cast<UserScript::RunLocation>(params.run_at)));
@@ -467,13 +468,9 @@ void ScriptInjectionManager::HandleExecuteDeclarativeScript(
const ExtensionId& extension_id,
int script_id,
const GURL& url) {
- scoped_ptr<ScriptInjection> injection =
+ std::unique_ptr<ScriptInjection> injection =
user_script_set_manager_->GetInjectionForDeclarativeScript(
- script_id,
- render_frame,
- tab_id,
- url,
- extension_id);
+ script_id, render_frame, tab_id, url, extension_id);
if (injection.get()) {
ScriptsRunInfo scripts_run_info(render_frame, UserScript::BROWSER_DRIVEN);
// TODO(markdittmer): Use return value of TryToInject for error handling.
@@ -499,7 +496,7 @@ void ScriptInjectionManager::HandlePermitScriptInjection(int64_t request_id) {
// know that this is the same page that issued the request (otherwise,
// RFOHelper::InvalidateAndResetFrame would have caused it to be cleared out).
- scoped_ptr<ScriptInjection> injection(std::move(*iter));
+ std::unique_ptr<ScriptInjection> injection(std::move(*iter));
pending_injections_.erase(iter);
ScriptsRunInfo scripts_run_info(injection->render_frame(),
diff --git a/chromium/extensions/renderer/script_injection_manager.h b/chromium/extensions/renderer/script_injection_manager.h
index c0f5da82cce..814a8fee452 100644
--- a/chromium/extensions/renderer/script_injection_manager.h
+++ b/chromium/extensions/renderer/script_injection_manager.h
@@ -53,7 +53,7 @@ class ScriptInjectionManager : public UserScriptSetManager::Observer {
using FrameStatusMap =
std::map<content::RenderFrame*, UserScript::RunLocation>;
- using ScriptInjectionVector = std::vector<scoped_ptr<ScriptInjection>>;
+ using ScriptInjectionVector = std::vector<std::unique_ptr<ScriptInjection>>;
// Notifies that an injection has been finished.
void OnInjectionFinished(ScriptInjection* injection);
@@ -77,7 +77,7 @@ class ScriptInjectionManager : public UserScriptSetManager::Observer {
UserScript::RunLocation run_location);
// Try to inject and store injection if it has not finished.
- void TryToInject(scoped_ptr<ScriptInjection> injection,
+ void TryToInject(std::unique_ptr<ScriptInjection> injection,
UserScript::RunLocation run_location,
ScriptsRunInfo* scripts_run_info);
@@ -103,7 +103,7 @@ class ScriptInjectionManager : public UserScriptSetManager::Observer {
std::set<content::RenderFrame*> active_injection_frames_;
// The collection of RFOHelpers.
- std::vector<scoped_ptr<RFOHelper>> rfo_helpers_;
+ std::vector<std::unique_ptr<RFOHelper>> rfo_helpers_;
// The set of UserScripts associated with extensions. Owned by the Dispatcher.
UserScriptSetManager* user_script_set_manager_;
diff --git a/chromium/extensions/renderer/script_injector.h b/chromium/extensions/renderer/script_injector.h
index a51e1d5a9a0..2443942e652 100644
--- a/chromium/extensions/renderer/script_injector.h
+++ b/chromium/extensions/renderer/script_injector.h
@@ -5,9 +5,9 @@
#ifndef EXTENSIONS_RENDERER_SCRIPT_INJECTOR_H_
#define EXTENSIONS_RENDERER_SCRIPT_INJECTOR_H_
+#include <memory>
#include <vector>
-#include "base/memory/scoped_ptr.h"
#include "extensions/common/permissions/permissions_data.h"
#include "extensions/common/user_script.h"
#include "third_party/WebKit/public/web/WebScriptSource.h"
@@ -82,7 +82,7 @@ class ScriptInjector {
// |render_frame| contains the render frame, or null if the frame was
// invalidated.
virtual void OnInjectionComplete(
- scoped_ptr<base::Value> execution_result,
+ std::unique_ptr<base::Value> execution_result,
UserScript::RunLocation run_location,
content::RenderFrame* render_frame) = 0;
diff --git a/chromium/extensions/renderer/send_request_natives.cc b/chromium/extensions/renderer/send_request_natives.cc
index ef3e93be9d9..2f9d2f5c08a 100644
--- a/chromium/extensions/renderer/send_request_natives.cc
+++ b/chromium/extensions/renderer/send_request_natives.cc
@@ -39,7 +39,7 @@ void SendRequestNatives::StartRequest(
int request_id = request_sender_->GetNextRequestId();
args.GetReturnValue().Set(static_cast<int32_t>(request_id));
- scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
+ std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create());
// See http://crbug.com/149880. The context menus APIs relies on this, but
// we shouldn't really be doing it (e.g. for the sake of the storage API).
@@ -48,7 +48,7 @@ void SendRequestNatives::StartRequest(
if (!preserve_null_in_objects)
converter->SetStripNullFromObjects(true);
- scoped_ptr<base::Value> value_args(
+ std::unique_ptr<base::Value> value_args(
converter->FromV8Value(args[1], context()->v8_context()));
if (!value_args.get() || !value_args->IsType(base::Value::TYPE_LIST)) {
NOTREACHED() << "Unable to convert args passed to StartRequest";
diff --git a/chromium/extensions/renderer/set_icon_natives.cc b/chromium/extensions/renderer/set_icon_natives.cc
index 0df21459cb4..6df53c1be80 100644
--- a/chromium/extensions/renderer/set_icon_natives.cc
+++ b/chromium/extensions/renderer/set_icon_natives.cc
@@ -8,9 +8,9 @@
#include <stdint.h>
#include <limits>
+#include <memory>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "content/public/common/common_param_traits.h"
#include "extensions/renderer/request_sender.h"
diff --git a/chromium/extensions/renderer/test_features_native_handler.cc b/chromium/extensions/renderer/test_features_native_handler.cc
index 0f228555809..3ecde95a42b 100644
--- a/chromium/extensions/renderer/test_features_native_handler.cc
+++ b/chromium/extensions/renderer/test_features_native_handler.cc
@@ -14,16 +14,16 @@ namespace extensions {
TestFeaturesNativeHandler::TestFeaturesNativeHandler(ScriptContext* context)
: ObjectBackedNativeHandler(context) {
- RouteFunction("GetAPIFeatures",
+ RouteFunction("GetAPIFeatures", "test",
base::Bind(&TestFeaturesNativeHandler::GetAPIFeatures,
base::Unretained(this)));
}
void TestFeaturesNativeHandler::GetAPIFeatures(
const v8::FunctionCallbackInfo<v8::Value>& args) {
- scoped_ptr<JSONFeatureProviderSource> source(
+ std::unique_ptr<JSONFeatureProviderSource> source(
ExtensionsClient::Get()->CreateFeatureProviderSource("api"));
- scoped_ptr<content::V8ValueConverter> converter(
+ std::unique_ptr<content::V8ValueConverter> converter(
content::V8ValueConverter::create());
args.GetReturnValue().Set(
converter->ToV8Value(&source->dictionary(), context()->v8_context()));
diff --git a/chromium/extensions/renderer/test_native_handler.cc b/chromium/extensions/renderer/test_native_handler.cc
index 31e7dcb9d75..7684c477b57 100644
--- a/chromium/extensions/renderer/test_native_handler.cc
+++ b/chromium/extensions/renderer/test_native_handler.cc
@@ -11,7 +11,7 @@ namespace extensions {
TestNativeHandler::TestNativeHandler(ScriptContext* context)
: ObjectBackedNativeHandler(context) {
RouteFunction(
- "GetWakeEventPage",
+ "GetWakeEventPage", "test",
base::Bind(&TestNativeHandler::GetWakeEventPage, base::Unretained(this)));
}
diff --git a/chromium/extensions/renderer/user_script_injector.cc b/chromium/extensions/renderer/user_script_injector.cc
index 9885b4ea8d3..71b41eb2e1d 100644
--- a/chromium/extensions/renderer/user_script_injector.cc
+++ b/chromium/extensions/renderer/user_script_injector.cc
@@ -195,19 +195,15 @@ std::vector<blink::WebScriptSource> UserScriptInjector::GetJsSources(
std::vector<blink::WebScriptSource> sources;
const UserScript::FileList& js_scripts = script_->js_scripts();
- bool is_standalone_or_emulate_greasemonkey =
- script_->is_standalone() || script_->emulate_greasemonkey();
for (UserScript::FileList::const_iterator iter = js_scripts.begin();
iter != js_scripts.end();
++iter) {
std::string content = iter->GetContent().as_string();
- // We add this dumb function wrapper for standalone user script to
- // emulate what Greasemonkey does.
- // TODO(aa): I think that maybe "is_standalone" scripts don't exist
- // anymore. Investigate.
- if (is_standalone_or_emulate_greasemonkey) {
+ // We add this dumb function wrapper for user scripts to emulate what
+ // Greasemonkey does.
+ if (script_->emulate_greasemonkey()) {
content.insert(0, kUserScriptHead);
content += kUserScriptTail;
}
@@ -215,9 +211,9 @@ std::vector<blink::WebScriptSource> UserScriptInjector::GetJsSources(
blink::WebString::fromUTF8(content), iter->url()));
}
- // Emulate Greasemonkey API for scripts that were converted to extensions
- // and "standalone" user scripts.
- if (is_standalone_or_emulate_greasemonkey)
+ // Emulate Greasemonkey API for scripts that were converted to extension
+ // user scripts.
+ if (script_->emulate_greasemonkey())
sources.insert(sources.begin(), g_greasemonkey_api.Get().GetSource());
return sources;
@@ -256,10 +252,9 @@ void UserScriptInjector::GetRunInfo(
}
void UserScriptInjector::OnInjectionComplete(
- scoped_ptr<base::Value> execution_result,
+ std::unique_ptr<base::Value> execution_result,
UserScript::RunLocation run_location,
- content::RenderFrame* render_frame) {
-}
+ content::RenderFrame* render_frame) {}
void UserScriptInjector::OnWillNotInject(InjectFailureReason reason,
content::RenderFrame* render_frame) {
diff --git a/chromium/extensions/renderer/user_script_injector.h b/chromium/extensions/renderer/user_script_injector.h
index 61909894e31..3ab1c1f827a 100644
--- a/chromium/extensions/renderer/user_script_injector.h
+++ b/chromium/extensions/renderer/user_script_injector.h
@@ -5,10 +5,10 @@
#ifndef EXTENSIONS_RENDERER_USER_SCRIPT_INJECTOR_H_
#define EXTENSIONS_RENDERER_USER_SCRIPT_INJECTOR_H_
+#include <memory>
#include <string>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/scoped_observer.h"
#include "extensions/common/user_script.h"
#include "extensions/renderer/script_injection.h"
@@ -53,7 +53,7 @@ class UserScriptInjector : public ScriptInjector,
UserScript::RunLocation run_location) const override;
void GetRunInfo(ScriptsRunInfo* scripts_run_info,
UserScript::RunLocation run_location) const override;
- void OnInjectionComplete(scoped_ptr<base::Value> execution_result,
+ void OnInjectionComplete(std::unique_ptr<base::Value> execution_result,
UserScript::RunLocation run_location,
content::RenderFrame* render_frame) override;
void OnWillNotInject(InjectFailureReason reason,
diff --git a/chromium/extensions/renderer/user_script_set.cc b/chromium/extensions/renderer/user_script_set.cc
index e289f3fc56a..2596ad804e9 100644
--- a/chromium/extensions/renderer/user_script_set.cc
+++ b/chromium/extensions/renderer/user_script_set.cc
@@ -67,19 +67,15 @@ void UserScriptSet::GetActiveExtensionIds(
}
void UserScriptSet::GetInjections(
- std::vector<scoped_ptr<ScriptInjection>>* injections,
+ std::vector<std::unique_ptr<ScriptInjection>>* injections,
content::RenderFrame* render_frame,
int tab_id,
UserScript::RunLocation run_location) {
GURL document_url = GetDocumentUrlForFrame(render_frame->GetWebFrame());
for (const UserScript* script : scripts_) {
- scoped_ptr<ScriptInjection> injection = GetInjectionForScript(
- script,
- render_frame,
- tab_id,
- run_location,
- document_url,
- false /* is_declarative */);
+ std::unique_ptr<ScriptInjection> injection =
+ GetInjectionForScript(script, render_frame, tab_id, run_location,
+ document_url, false /* is_declarative */);
if (injection.get())
injections->push_back(std::move(injection));
}
@@ -118,7 +114,7 @@ bool UserScriptSet::UpdateUserScripts(base::SharedMemoryHandle shared_memory,
scripts_.clear();
scripts_.reserve(num_scripts);
for (uint32_t i = 0; i < num_scripts; ++i) {
- scoped_ptr<UserScript> script(new UserScript());
+ std::unique_ptr<UserScript> script(new UserScript());
script->Unpickle(pickle, &iter);
// Note that this is a pointer into shared memory. We don't own it. It gets
@@ -159,7 +155,7 @@ bool UserScriptSet::UpdateUserScripts(base::SharedMemoryHandle shared_memory,
return true;
}
-scoped_ptr<ScriptInjection> UserScriptSet::GetDeclarativeScriptInjection(
+std::unique_ptr<ScriptInjection> UserScriptSet::GetDeclarativeScriptInjection(
int script_id,
content::RenderFrame* render_frame,
int tab_id,
@@ -175,18 +171,18 @@ scoped_ptr<ScriptInjection> UserScriptSet::GetDeclarativeScriptInjection(
true /* is_declarative */);
}
}
- return scoped_ptr<ScriptInjection>();
+ return std::unique_ptr<ScriptInjection>();
}
-scoped_ptr<ScriptInjection> UserScriptSet::GetInjectionForScript(
+std::unique_ptr<ScriptInjection> UserScriptSet::GetInjectionForScript(
const UserScript* script,
content::RenderFrame* render_frame,
int tab_id,
UserScript::RunLocation run_location,
const GURL& document_url,
bool is_declarative) {
- scoped_ptr<ScriptInjection> injection;
- scoped_ptr<const InjectionHost> injection_host;
+ std::unique_ptr<ScriptInjection> injection;
+ std::unique_ptr<const InjectionHost> injection_host;
blink::WebLocalFrame* web_frame = render_frame->GetWebFrame();
const HostID& host_id = script->host_id();
@@ -208,9 +204,8 @@ scoped_ptr<ScriptInjection> UserScriptSet::GetInjectionForScript(
if (!script->MatchesURL(effective_document_url))
return injection;
- scoped_ptr<ScriptInjector> injector(new UserScriptInjector(script,
- this,
- is_declarative));
+ std::unique_ptr<ScriptInjector> injector(
+ new UserScriptInjector(script, this, is_declarative));
if (injector->CanExecuteOnFrame(
injection_host.get(),
diff --git a/chromium/extensions/renderer/user_script_set.h b/chromium/extensions/renderer/user_script_set.h
index 128b33f0be9..53800d35328 100644
--- a/chromium/extensions/renderer/user_script_set.h
+++ b/chromium/extensions/renderer/user_script_set.h
@@ -5,16 +5,15 @@
#ifndef EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_
#define EXTENSIONS_RENDERER_USER_SCRIPT_SET_H_
+#include <memory>
#include <set>
#include <string>
#include <vector>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/shared_memory.h"
#include "base/observer_list.h"
-#include "content/public/renderer/render_process_observer.h"
#include "extensions/common/user_script.h"
class GURL;
@@ -52,12 +51,12 @@ class UserScriptSet {
// |tab_id|, at the given |run_location|, to |injections|.
// |extensions| is passed in to verify the corresponding extension is still
// valid.
- void GetInjections(std::vector<scoped_ptr<ScriptInjection>>* injections,
+ void GetInjections(std::vector<std::unique_ptr<ScriptInjection>>* injections,
content::RenderFrame* render_frame,
int tab_id,
UserScript::RunLocation run_location);
- scoped_ptr<ScriptInjection> GetDeclarativeScriptInjection(
+ std::unique_ptr<ScriptInjection> GetDeclarativeScriptInjection(
int script_id,
content::RenderFrame* render_frame,
int tab_id,
@@ -75,7 +74,7 @@ class UserScriptSet {
private:
// Returns a new ScriptInjection for the given |script| to execute in the
// |render_frame|, or NULL if the script should not execute.
- scoped_ptr<ScriptInjection> GetInjectionForScript(
+ std::unique_ptr<ScriptInjection> GetInjectionForScript(
const UserScript* script,
content::RenderFrame* render_frame,
int tab_id,
@@ -84,7 +83,7 @@ class UserScriptSet {
bool is_declarative);
// Shared memory containing raw script data.
- scoped_ptr<base::SharedMemory> shared_memory_;
+ std::unique_ptr<base::SharedMemory> shared_memory_;
// The UserScripts this injector manages.
ScopedVector<UserScript> scripts_;
diff --git a/chromium/extensions/renderer/user_script_set_manager.cc b/chromium/extensions/renderer/user_script_set_manager.cc
index 0404e0552b9..23a7eb8ff1d 100644
--- a/chromium/extensions/renderer/user_script_set_manager.cc
+++ b/chromium/extensions/renderer/user_script_set_manager.cc
@@ -30,7 +30,7 @@ void UserScriptSetManager::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer);
}
-scoped_ptr<ScriptInjection>
+std::unique_ptr<ScriptInjection>
UserScriptSetManager::GetInjectionForDeclarativeScript(
int script_id,
content::RenderFrame* render_frame,
@@ -40,7 +40,7 @@ UserScriptSetManager::GetInjectionForDeclarativeScript(
UserScriptSet* user_script_set =
GetProgrammaticScriptsByHostID(HostID(HostID::EXTENSIONS, extension_id));
if (!user_script_set)
- return scoped_ptr<ScriptInjection>();
+ return std::unique_ptr<ScriptInjection>();
return user_script_set->GetDeclarativeScriptInjection(
script_id,
@@ -61,7 +61,7 @@ bool UserScriptSetManager::OnControlMessageReceived(
}
void UserScriptSetManager::GetAllInjections(
- std::vector<scoped_ptr<ScriptInjection>>* injections,
+ std::vector<std::unique_ptr<ScriptInjection>>* injections,
content::RenderFrame* render_frame,
int tab_id,
UserScript::RunLocation run_location) {
diff --git a/chromium/extensions/renderer/user_script_set_manager.h b/chromium/extensions/renderer/user_script_set_manager.h
index 5cba81e7bc2..af7611e19ca 100644
--- a/chromium/extensions/renderer/user_script_set_manager.h
+++ b/chromium/extensions/renderer/user_script_set_manager.h
@@ -14,7 +14,7 @@
#include "base/memory/linked_ptr.h"
#include "base/memory/shared_memory.h"
#include "base/observer_list.h"
-#include "content/public/renderer/render_process_observer.h"
+#include "content/public/renderer/render_thread_observer.h"
#include "extensions/common/extension.h"
#include "extensions/common/user_script.h"
#include "extensions/renderer/user_script_set.h"
@@ -39,7 +39,7 @@ class ScriptInjection;
// only programmatically-declared scripts, instantiated
// when an extension first creates a declarative rule
// that would, if triggered, request a script injection.
-class UserScriptSetManager : public content::RenderProcessObserver {
+class UserScriptSetManager : public content::RenderThreadObserver {
public:
// Like a UserScriptSet::Observer, but automatically subscribes to all sets
// associated with the manager.
@@ -60,7 +60,7 @@ class UserScriptSetManager : public content::RenderProcessObserver {
// Looks up the script injection associated with |script_id| and
// |extension_id| in the context of the given |web_frame|, |tab_id|,
// and |url|.
- scoped_ptr<ScriptInjection> GetInjectionForDeclarativeScript(
+ std::unique_ptr<ScriptInjection> GetInjectionForDeclarativeScript(
int script_id,
content::RenderFrame* render_frame,
int tab_id,
@@ -69,10 +69,11 @@ class UserScriptSetManager : public content::RenderProcessObserver {
// Append all injections from |static_scripts| and each of
// |programmatic_scripts_| to |injections|.
- void GetAllInjections(std::vector<scoped_ptr<ScriptInjection>>* injections,
- content::RenderFrame* render_frame,
- int tab_id,
- UserScript::RunLocation run_location);
+ void GetAllInjections(
+ std::vector<std::unique_ptr<ScriptInjection>>* injections,
+ content::RenderFrame* render_frame,
+ int tab_id,
+ UserScript::RunLocation run_location);
// Get active extension IDs from |static_scripts| and each of
// |programmatic_scripts_|.
@@ -84,7 +85,7 @@ class UserScriptSetManager : public content::RenderProcessObserver {
// Map for per-extension sets that may be defined programmatically.
typedef std::map<HostID, linked_ptr<UserScriptSet> > UserScriptSetMap;
- // content::RenderProcessObserver implementation.
+ // content::RenderThreadObserver implementation.
bool OnControlMessageReceived(const IPC::Message& message) override;
UserScriptSet* GetProgrammaticScriptsByHostID(const HostID& host_id);
diff --git a/chromium/extensions/renderer/v8_context_native_handler.cc b/chromium/extensions/renderer/v8_context_native_handler.cc
index 1ac53c5be00..6124311e561 100644
--- a/chromium/extensions/renderer/v8_context_native_handler.cc
+++ b/chromium/extensions/renderer/v8_context_native_handler.cc
@@ -20,10 +20,9 @@ V8ContextNativeHandler::V8ContextNativeHandler(ScriptContext* context)
RouteFunction("GetModuleSystem",
base::Bind(&V8ContextNativeHandler::GetModuleSystem,
base::Unretained(this)));
- RouteFunction(
- "RunWithNativesEnabled",
- base::Bind(&V8ContextNativeHandler::RunWithNativesEnabled,
- base::Unretained(this)));
+ RouteFunction("RunWithNativesEnabled", "test",
+ base::Bind(&V8ContextNativeHandler::RunWithNativesEnabled,
+ base::Unretained(this)));
}
void V8ContextNativeHandler::GetAvailability(
@@ -34,6 +33,9 @@ void V8ContextNativeHandler::GetAvailability(
Feature::Availability availability = context_->GetAvailability(api_name);
v8::Local<v8::Object> ret = v8::Object::New(isolate);
+ v8::Maybe<bool> maybe =
+ ret->SetPrototype(context_->v8_context(), v8::Null(isolate));
+ CHECK(maybe.IsJust() && maybe.FromJust());
ret->Set(v8::String::NewFromUtf8(isolate, "is_available"),
v8::Boolean::New(isolate, availability.is_available()));
ret->Set(v8::String::NewFromUtf8(isolate, "message"),
diff --git a/chromium/extensions/renderer/v8_schema_registry.cc b/chromium/extensions/renderer/v8_schema_registry.cc
index 3bd7c479122..2db2bb30dae 100644
--- a/chromium/extensions/renderer/v8_schema_registry.cc
+++ b/chromium/extensions/renderer/v8_schema_registry.cc
@@ -14,6 +14,7 @@
#include "extensions/common/extension_api.h"
#include "extensions/renderer/object_backed_native_handler.h"
#include "extensions/renderer/script_context.h"
+#include "extensions/renderer/v8_helpers.h"
using content::V8ValueConverter;
@@ -40,13 +41,16 @@ void DeepFreeze(const v8::Local<v8::Object>& object,
class SchemaRegistryNativeHandler : public ObjectBackedNativeHandler {
public:
SchemaRegistryNativeHandler(V8SchemaRegistry* registry,
- scoped_ptr<ScriptContext> context)
+ std::unique_ptr<ScriptContext> context)
: ObjectBackedNativeHandler(context.get()),
context_(std::move(context)),
registry_(registry) {
RouteFunction("GetSchema",
base::Bind(&SchemaRegistryNativeHandler::GetSchema,
base::Unretained(this)));
+ RouteFunction("GetObjectType",
+ base::Bind(&SchemaRegistryNativeHandler::GetObjectType,
+ base::Unretained(this)));
}
~SchemaRegistryNativeHandler() override { context_->Invalidate(); }
@@ -57,7 +61,20 @@ class SchemaRegistryNativeHandler : public ObjectBackedNativeHandler {
registry_->GetSchema(*v8::String::Utf8Value(args[0])));
}
- scoped_ptr<ScriptContext> context_;
+ void GetObjectType(const v8::FunctionCallbackInfo<v8::Value>& args) {
+ CHECK(args.Length() == 1 && args[0]->IsObject());
+ std::string type;
+ if (args[0]->IsArray())
+ type = "array";
+ else if (args[0]->IsArrayBuffer())
+ type = "binary";
+ else
+ type = "object";
+ args.GetReturnValue().Set(
+ v8_helpers::ToV8StringUnsafe(context()->isolate(), type.c_str()));
+ }
+
+ std::unique_ptr<ScriptContext> context_;
V8SchemaRegistry* registry_;
};
@@ -69,15 +86,15 @@ V8SchemaRegistry::V8SchemaRegistry() {
V8SchemaRegistry::~V8SchemaRegistry() {
}
-scoped_ptr<NativeHandler> V8SchemaRegistry::AsNativeHandler() {
- scoped_ptr<ScriptContext> context(
+std::unique_ptr<NativeHandler> V8SchemaRegistry::AsNativeHandler() {
+ std::unique_ptr<ScriptContext> context(
new ScriptContext(GetOrCreateContext(v8::Isolate::GetCurrent()),
NULL, // no frame
NULL, // no extension
Feature::UNSPECIFIED_CONTEXT,
NULL, // no effective extension
Feature::UNSPECIFIED_CONTEXT));
- return scoped_ptr<NativeHandler>(
+ return std::unique_ptr<NativeHandler>(
new SchemaRegistryNativeHandler(this, std::move(context)));
}
@@ -115,7 +132,8 @@ v8::Local<v8::Object> V8SchemaRegistry::GetSchema(const std::string& api) {
const base::DictionaryValue* schema =
ExtensionAPI::GetSharedInstance()->GetSchema(api);
CHECK(schema) << api;
- scoped_ptr<V8ValueConverter> v8_value_converter(V8ValueConverter::create());
+ std::unique_ptr<V8ValueConverter> v8_value_converter(
+ V8ValueConverter::create());
v8::Local<v8::Value> value = v8_value_converter->ToV8Value(schema, context);
CHECK(!value.IsEmpty());
diff --git a/chromium/extensions/renderer/v8_schema_registry.h b/chromium/extensions/renderer/v8_schema_registry.h
index 08f54b62658..749aa1c081c 100644
--- a/chromium/extensions/renderer/v8_schema_registry.h
+++ b/chromium/extensions/renderer/v8_schema_registry.h
@@ -6,11 +6,11 @@
#define EXTENSIONS_RENDERER_V8_SCHEMA_REGISTRY_H_
#include <map>
+#include <memory>
#include <string>
#include <vector>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "gin/public/context_holder.h"
#include "v8/include/v8-util.h"
#include "v8/include/v8.h"
@@ -26,7 +26,7 @@ class V8SchemaRegistry {
~V8SchemaRegistry();
// Creates a NativeHandler wrapper |this|. Supports GetSchema.
- scoped_ptr<NativeHandler> AsNativeHandler();
+ std::unique_ptr<NativeHandler> AsNativeHandler();
// Returns a v8::Array with all the schemas for the APIs in |apis|.
v8::Local<v8::Array> GetSchemas(const std::vector<std::string>& apis);
@@ -41,11 +41,11 @@ class V8SchemaRegistry {
// Cache of schemas. Created lazily by GetOrCreateContext.
typedef v8::StdGlobalValueMap<std::string, v8::Object> SchemaCache;
- scoped_ptr<SchemaCache> schema_cache_;
+ std::unique_ptr<SchemaCache> schema_cache_;
// Single per-instance gin::ContextHolder to create v8::Values.
// Created lazily via GetOrCreateContext.
- scoped_ptr<gin::ContextHolder> context_holder_;
+ std::unique_ptr<gin::ContextHolder> context_holder_;
DISALLOW_COPY_AND_ASSIGN(V8SchemaRegistry);
};
diff --git a/chromium/extensions/renderer/wake_event_page.cc b/chromium/extensions/renderer/wake_event_page.cc
index e3e21899bef..a6f18838471 100644
--- a/chromium/extensions/renderer/wake_event_page.cc
+++ b/chromium/extensions/renderer/wake_event_page.cc
@@ -4,6 +4,7 @@
#include "extensions/renderer/wake_event_page.h"
+#include <memory>
#include <utility>
#include "base/atomic_sequence_num.h"
@@ -12,7 +13,6 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "content/public/child/worker_thread.h"
#include "content/public/renderer/render_thread.h"
#include "extensions/common/extension_messages.h"
@@ -160,7 +160,7 @@ void WakeEventPage::MakeRequest(const std::string& extension_id,
static base::AtomicSequenceNumber sequence_number;
int request_id = sequence_number.GetNext();
{
- scoped_ptr<RequestData> request_data(
+ std::unique_ptr<RequestData> request_data(
new RequestData(content::WorkerThread::GetCurrentId(), on_response));
base::AutoLock lock(requests_lock_);
requests_.set(request_id, std::move(request_data));
@@ -180,7 +180,7 @@ bool WakeEventPage::OnControlMessageReceived(const IPC::Message& message) {
}
void WakeEventPage::OnWakeEventPageResponse(int request_id, bool success) {
- scoped_ptr<RequestData> request_data;
+ std::unique_ptr<RequestData> request_data;
{
base::AutoLock lock(requests_lock_);
request_data = requests_.take(request_id);
diff --git a/chromium/extensions/renderer/wake_event_page.h b/chromium/extensions/renderer/wake_event_page.h
index 48bfd4bedb4..0eec285b681 100644
--- a/chromium/extensions/renderer/wake_event_page.h
+++ b/chromium/extensions/renderer/wake_event_page.h
@@ -5,16 +5,16 @@
#ifndef EXTENSIONS_RENDERER_WAKE_EVENT_PAGE_H_
#define EXTENSIONS_RENDERER_WAKE_EVENT_PAGE_H_
+#include <memory>
#include <string>
#include "base/callback.h"
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/synchronization/lock.h"
-#include "content/public/renderer/render_process_observer.h"
+#include "content/public/renderer/render_thread_observer.h"
#include "ipc/ipc_sync_message_filter.h"
#include "v8/include/v8.h"
@@ -30,7 +30,7 @@ class ScriptContext;
//
// Note, the function will do a round trip to the browser even if event page is
// open. Any optimisation to prevent this must be at the JavaScript level.
-class WakeEventPage : public content::RenderProcessObserver {
+class WakeEventPage : public content::RenderThreadObserver {
public:
WakeEventPage();
~WakeEventPage() override;
@@ -92,7 +92,7 @@ class WakeEventPage : public content::RenderProcessObserver {
void MakeRequest(const std::string& extension_id,
const OnResponseCallback& on_response);
- // content::RenderProcessObserver:
+ // content::RenderThreadObserver:
bool OnControlMessageReceived(const IPC::Message& message) override;
// OnControlMessageReceived handlers:
@@ -103,7 +103,7 @@ class WakeEventPage : public content::RenderProcessObserver {
// All in-flight requests, keyed by request ID. Used on multiple threads, so
// must be guarded by |requests_lock_|.
- base::ScopedPtrHashMap<int, scoped_ptr<RequestData>> requests_;
+ base::ScopedPtrHashMap<int, std::unique_ptr<RequestData>> requests_;
// Lock for |requests_|.
base::Lock requests_lock_;
diff --git a/chromium/extensions/renderer/worker_script_context_set.cc b/chromium/extensions/renderer/worker_script_context_set.cc
index a05fdbc77c6..c928351985d 100644
--- a/chromium/extensions/renderer/worker_script_context_set.cc
+++ b/chromium/extensions/renderer/worker_script_context_set.cc
@@ -33,7 +33,7 @@ WorkerScriptContextSet::WorkerScriptContextSet() {}
WorkerScriptContextSet::~WorkerScriptContextSet() {}
-void WorkerScriptContextSet::Insert(scoped_ptr<ScriptContext> context) {
+void WorkerScriptContextSet::Insert(std::unique_ptr<ScriptContext> context) {
DCHECK_GT(content::WorkerThread::GetCurrentId(), 0)
<< "Must be called on a worker thread";
ContextVector* contexts = contexts_tls_.Get();
diff --git a/chromium/extensions/renderer/worker_script_context_set.h b/chromium/extensions/renderer/worker_script_context_set.h
index dd33a77d6a7..ef063b2fc90 100644
--- a/chromium/extensions/renderer/worker_script_context_set.h
+++ b/chromium/extensions/renderer/worker_script_context_set.h
@@ -5,8 +5,9 @@
#ifndef EXTENSIONS_RENDERER_WORKER_SCRIPT_CONTEXT_SET_H_
#define EXTENSIONS_RENDERER_WORKER_SCRIPT_CONTEXT_SET_H_
+#include <memory>
+
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/threading/thread_local.h"
#include "content/public/child/worker_thread.h"
@@ -25,7 +26,7 @@ class WorkerScriptContextSet : public content::WorkerThread::Observer {
~WorkerScriptContextSet() override;
// Inserts |context| into the set. Contexts are stored in TLS.
- void Insert(scoped_ptr<ScriptContext> context);
+ void Insert(std::unique_ptr<ScriptContext> context);
// Removes the ScriptContext associated with |v8_context| which was added for
// |url| (used for sanity checking).
diff --git a/chromium/extensions/shell/BUILD.gn b/chromium/extensions/shell/BUILD.gn
index fca3ec3e927..6a6654c99fe 100644
--- a/chromium/extensions/shell/BUILD.gn
+++ b/chromium/extensions/shell/BUILD.gn
@@ -57,6 +57,7 @@ source_set("app_shell_lib") {
"//mojo/edk/system",
"//skia",
"//third_party/WebKit/public:blink",
+ "//third_party/cld_2:cld2_platform_impl",
"//ui/base",
"//ui/base/ime",
"//v8",
@@ -109,10 +110,6 @@ source_set("app_shell_lib") {
]
}
}
-
- if (cld_version == 2) {
- deps += [ "//third_party/cld_2:cld2_platform_impl" ]
- }
}
if (!(is_chromeos && !use_ozone)) {
@@ -125,6 +122,7 @@ if (!(is_chromeos && !use_ozone)) {
deps = [
":app_shell_lib",
"//build/config/sanitizers:deps",
+ "//build/win:default_exe_manifest",
"//extensions:shell_and_test_pak",
]
@@ -134,11 +132,12 @@ if (!(is_chromeos && !use_ozone)) {
}
if (is_mac) {
- # TODO(GYP) bug 546894: Fix GN and toolchains to handle spaces here.
- #output_name = "App Shell"
+ output_name = "App Shell"
+
# TODO(GYP): Mac bundling. See also content_shell which this is basically
# a copy-paste of.
deps += [ ":app_shell_framework" ]
+
# TODO(GYP): Mac app_shell_helper stuff.
}
}
@@ -192,15 +191,11 @@ test("app_shell_unittests") {
sources += chromeos_sources
}
- # TODO(GYP): Enable this when //components/nacl GN is done.
- if (false) {
- if (use_nacl) {
- nacl_sources =
- rebase_path(app_shell_gypi_values.app_shell_unittests_sources_nacl,
- ".",
- "//extensions/shell")
- sources += nacl_sources
- }
+ if (enable_nacl) {
+ sources +=
+ rebase_path(app_shell_gypi_values.app_shell_unittests_sources_nacl,
+ ".",
+ "//extensions/shell")
}
}
diff --git a/chromium/extensions/shell/app/shell_main_delegate.h b/chromium/extensions/shell/app/shell_main_delegate.h
index 335307ad45f..0fa018f6455 100644
--- a/chromium/extensions/shell/app/shell_main_delegate.h
+++ b/chromium/extensions/shell/app/shell_main_delegate.h
@@ -5,9 +5,10 @@
#ifndef EXTENSIONS_SHELL_APP_SHELL_MAIN_DELEGATE_H_
#define EXTENSIONS_SHELL_APP_SHELL_MAIN_DELEGATE_H_
+#include <memory>
+
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "build/build_config.h"
#include "content/public/app/content_main_delegate.h"
@@ -53,10 +54,10 @@ class ShellMainDelegate : public content::ContentMainDelegate {
// process needs data from resources.pak.
static bool ProcessNeedsResourceBundle(const std::string& process_type);
- scoped_ptr<content::ContentClient> content_client_;
- scoped_ptr<content::ContentBrowserClient> browser_client_;
- scoped_ptr<content::ContentRendererClient> renderer_client_;
- scoped_ptr<content::ContentUtilityClient> utility_client_;
+ std::unique_ptr<content::ContentClient> content_client_;
+ std::unique_ptr<content::ContentBrowserClient> browser_client_;
+ std::unique_ptr<content::ContentRendererClient> renderer_client_;
+ std::unique_ptr<content::ContentUtilityClient> utility_client_;
DISALLOW_COPY_AND_ASSIGN(ShellMainDelegate);
};
diff --git a/chromium/extensions/shell/app_shell.gyp b/chromium/extensions/shell/app_shell.gyp
index fb8f0544691..7a334f242a0 100644
--- a/chromium/extensions/shell/app_shell.gyp
+++ b/chromium/extensions/shell/app_shell.gyp
@@ -49,9 +49,10 @@
'<(DEPTH)/mojo/mojo_edk.gyp:mojo_system_impl',
'<(DEPTH)/skia/skia.gyp:skia',
'<(DEPTH)/third_party/WebKit/public/blink.gyp:blink',
+ '<(DEPTH)/third_party/cld_2/cld_2.gyp:cld2_platform_impl',
'<(DEPTH)/ui/base/ime/ui_base_ime.gyp:ui_base_ime',
'<(DEPTH)/ui/base/ui_base.gyp:ui_base',
- '<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
+ '<(DEPTH)/v8/src/v8.gyp:v8',
],
'export_dependent_settings': [
'<(DEPTH)/content/content.gyp:content_browser',
@@ -65,10 +66,6 @@
'<@(app_shell_lib_sources)',
],
'conditions': [
- [ 'cld_version==2', {
- 'dependencies': [
- '<(DEPTH)/third_party/cld_2/cld_2.gyp:cld2_platform_impl', ],
- }],
['use_aura==1', {
'dependencies': [
'<(DEPTH)/ui/wm/wm.gyp:wm',
@@ -172,6 +169,7 @@
# Modify the Info.plist as needed.
'postbuild_name': 'Tweak Info.plist',
'action': ['../../build/mac/tweak_info_plist.py',
+ '--plist=${TARGET_BUILD_DIR}/${INFOPLIST_PATH}',
'--scm=1',
'--version=<(app_shell_version)'],
},
@@ -307,6 +305,7 @@
# but this seems like a really good place to store them.
'postbuild_name': 'Tweak Info.plist',
'action': ['../../build/mac/tweak_info_plist.py',
+ '--plist=${TARGET_BUILD_DIR}/${INFOPLIST_PATH}',
'--breakpad=1',
'--keystone=0',
'--scm=1',
@@ -379,6 +378,7 @@
# never placed into the helper.
'postbuild_name': 'Tweak Info.plist',
'action': ['../../build/mac/tweak_info_plist.py',
+ '--plist=${TARGET_BUILD_DIR}/${INFOPLIST_PATH}',
'--breakpad=0',
'--keystone=0',
'--scm=0',
diff --git a/chromium/extensions/shell/browser/DEPS b/chromium/extensions/shell/browser/DEPS
index bdc975fe5de..4a47a89e142 100644
--- a/chromium/extensions/shell/browser/DEPS
+++ b/chromium/extensions/shell/browser/DEPS
@@ -40,6 +40,7 @@ include_rules = [
"+ui/aura",
"+ui/chromeos",
"+ui/display",
+ "+ui/ozone/public",
"+ui/wm",
"+third_party/cros_system_api",
diff --git a/chromium/extensions/shell/browser/api/identity/identity_api.cc b/chromium/extensions/shell/browser/api/identity/identity_api.cc
index bf8ad1f8fda..15564d6e51b 100644
--- a/chromium/extensions/shell/browser/api/identity/identity_api.cc
+++ b/chromium/extensions/shell/browser/api/identity/identity_api.cc
@@ -9,6 +9,7 @@
#include "base/guid.h"
#include "content/public/browser/browser_context.h"
+#include "content/public/browser/storage_partition.h"
#include "extensions/common/manifest_handlers/oauth2_manifest_handler.h"
#include "extensions/shell/browser/shell_oauth2_token_service.h"
#include "extensions/shell/common/api/identity.h"
@@ -60,7 +61,7 @@ void IdentityGetAuthTokenFunction::SetMintTokenFlowForTesting(
}
ExtensionFunction::ResponseAction IdentityGetAuthTokenFunction::Run() {
- scoped_ptr<api::identity::GetAuthToken::Params> params(
+ std::unique_ptr<api::identity::GetAuthToken::Params> params(
api::identity::GetAuthToken::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -109,7 +110,10 @@ void IdentityGetAuthTokenFunction::OnGetTokenSuccess(
}
// Use the logging-in-user access token to mint an access token for this app.
- mint_token_flow_->Start(browser_context()->GetRequestContext(), access_token);
+ mint_token_flow_->Start(
+ content::BrowserContext::GetDefaultStoragePartition(browser_context())->
+ GetURLRequestContext(),
+ access_token);
}
void IdentityGetAuthTokenFunction::OnGetTokenFailure(
@@ -148,7 +152,7 @@ IdentityRemoveCachedAuthTokenFunction::
}
ExtensionFunction::ResponseAction IdentityRemoveCachedAuthTokenFunction::Run() {
- scoped_ptr<api::identity::RemoveCachedAuthToken::Params> params(
+ std::unique_ptr<api::identity::RemoveCachedAuthToken::Params> params(
api::identity::RemoveCachedAuthToken::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
// This stub identity API does not maintain a token cache, so there is nothing
diff --git a/chromium/extensions/shell/browser/api/identity/identity_api.h b/chromium/extensions/shell/browser/api/identity/identity_api.h
index a3343aded23..1523aa2d5d1 100644
--- a/chromium/extensions/shell/browser/api/identity/identity_api.h
+++ b/chromium/extensions/shell/browser/api/identity/identity_api.h
@@ -74,10 +74,10 @@ class IdentityGetAuthTokenFunction : public UIThreadExtensionFunction,
private:
// A pending token fetch request to get a login-scoped access token for the
// current user for the Chrome project id.
- scoped_ptr<OAuth2TokenService::Request> access_token_request_;
+ std::unique_ptr<OAuth2TokenService::Request> access_token_request_;
// A request for an access token for the current app and its scopes.
- scoped_ptr<OAuth2MintTokenFlow> mint_token_flow_;
+ std::unique_ptr<OAuth2MintTokenFlow> mint_token_flow_;
DISALLOW_COPY_AND_ASSIGN(IdentityGetAuthTokenFunction);
};
diff --git a/chromium/extensions/shell/browser/api/identity/identity_api_unittest.cc b/chromium/extensions/shell/browser/api/identity/identity_api_unittest.cc
index 0af6e4b13bb..122b979636e 100644
--- a/chromium/extensions/shell/browser/api/identity/identity_api_unittest.cc
+++ b/chromium/extensions/shell/browser/api/identity/identity_api_unittest.cc
@@ -4,10 +4,10 @@
#include "extensions/shell/browser/api/identity/identity_api.h"
+#include <memory>
#include <string>
#include <utility>
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "extensions/browser/api_unittest.h"
@@ -26,9 +26,9 @@ class MockShellOAuth2TokenService : public ShellOAuth2TokenService {
~MockShellOAuth2TokenService() override {}
// OAuth2TokenService:
- scoped_ptr<Request> StartRequest(const std::string& account_id,
- const ScopeSet& scopes,
- Consumer* consumer) override {
+ std::unique_ptr<Request> StartRequest(const std::string& account_id,
+ const ScopeSet& scopes,
+ Consumer* consumer) override {
// Immediately return success.
consumer->OnGetTokenSuccess(nullptr, "logged-in-user-token", base::Time());
return nullptr;
@@ -108,7 +108,8 @@ TEST_F(IdentityApiTest, GetAuthToken) {
function->SetMintTokenFlowForTesting(new MockOAuth2MintTokenFlow(function));
// Function succeeds and returns a token (for its callback).
- scoped_ptr<base::Value> result = RunFunctionAndReturnValue(function, "[{}]");
+ std::unique_ptr<base::Value> result =
+ RunFunctionAndReturnValue(function, "[{}]");
ASSERT_TRUE(result.get());
std::string value;
result->GetAsString(&value);
@@ -122,7 +123,7 @@ TEST_F(IdentityApiTest, RemoveCachedAuthToken) {
MockShellOAuth2TokenService token_service;
// Function succeeds and returns nothing (for its callback).
- scoped_ptr<base::Value> result = RunFunctionAndReturnValue(
+ std::unique_ptr<base::Value> result = RunFunctionAndReturnValue(
new IdentityRemoveCachedAuthTokenFunction, "[{}]");
EXPECT_FALSE(result.get());
}
diff --git a/chromium/extensions/shell/browser/media_capture_util.cc b/chromium/extensions/shell/browser/media_capture_util.cc
index 6f4660c84f0..fe2db183f0b 100644
--- a/chromium/extensions/shell/browser/media_capture_util.cc
+++ b/chromium/extensions/shell/browser/media_capture_util.cc
@@ -64,7 +64,7 @@ void GrantMediaStreamRequest(content::WebContents* web_contents,
}
// TODO(jamescook): Should we show a recording icon somewhere? If so, where?
- scoped_ptr<MediaStreamUI> ui;
+ std::unique_ptr<MediaStreamUI> ui;
callback.Run(devices, devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE
: content::MEDIA_DEVICE_OK,
std::move(ui));
diff --git a/chromium/extensions/shell/browser/shell_audio_controller_chromeos_unittest.cc b/chromium/extensions/shell/browser/shell_audio_controller_chromeos_unittest.cc
index 15b1e5f006b..ec011910d32 100644
--- a/chromium/extensions/shell/browser/shell_audio_controller_chromeos_unittest.cc
+++ b/chromium/extensions/shell/browser/shell_audio_controller_chromeos_unittest.cc
@@ -6,8 +6,10 @@
#include <stdint.h>
+#include <memory>
+
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "chromeos/audio/audio_device.h"
#include "chromeos/audio/audio_devices_pref_handler.h"
#include "chromeos/audio/cras_audio_handler.h"
@@ -26,12 +28,12 @@ class ShellAudioControllerTest : public testing::Test {
public:
ShellAudioControllerTest() : next_node_id_(1) {
// This also initializes DBusThreadManager.
- scoped_ptr<chromeos::DBusThreadManagerSetter> dbus_setter =
+ std::unique_ptr<chromeos::DBusThreadManagerSetter> dbus_setter =
chromeos::DBusThreadManager::GetSetterForTesting();
audio_client_ = new chromeos::FakeCrasAudioClient();
audio_client_->SetAudioNodesForTesting(AudioNodeList());
- dbus_setter->SetCrasAudioClient(make_scoped_ptr(audio_client_));
+ dbus_setter->SetCrasAudioClient(base::WrapUnique(audio_client_));
chromeos::CrasAudioHandler::InitializeForTesting();
audio_handler_ = chromeos::CrasAudioHandler::Get();
@@ -72,7 +74,7 @@ class ShellAudioControllerTest : public testing::Test {
chromeos::FakeCrasAudioClient* audio_client_; // Not owned.
chromeos::CrasAudioHandler* audio_handler_; // Not owned.
- scoped_ptr<ShellAudioController> controller_;
+ std::unique_ptr<ShellAudioController> controller_;
// Next audio node ID to be returned by CreateNode().
uint64_t next_node_id_;
diff --git a/chromium/extensions/shell/browser/shell_browser_main_parts.h b/chromium/extensions/shell/browser/shell_browser_main_parts.h
index 0525cbbdaf7..e52abc4a252 100644
--- a/chromium/extensions/shell/browser/shell_browser_main_parts.h
+++ b/chromium/extensions/shell/browser/shell_browser_main_parts.h
@@ -5,9 +5,10 @@
#ifndef EXTENSIONS_SHELL_BROWSER_SHELL_BROWSER_MAIN_PARTS_H_
#define EXTENSIONS_SHELL_BROWSER_SHELL_BROWSER_MAIN_PARTS_H_
+#include <memory>
+
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/task/cancelable_task_tracker.h"
#include "build/build_config.h"
#include "content/public/browser/browser_main_parts.h"
@@ -81,20 +82,21 @@ class ShellBrowserMainParts : public content::BrowserMainParts {
void CreateExtensionSystem();
#if defined(OS_CHROMEOS)
- scoped_ptr<ShellNetworkController> network_controller_;
- scoped_ptr<ShellAudioController> audio_controller_;
+ std::unique_ptr<ShellNetworkController> network_controller_;
+ std::unique_ptr<ShellAudioController> audio_controller_;
#endif
- scoped_ptr<DesktopController> desktop_controller_;
- scoped_ptr<ShellBrowserContext> browser_context_;
- scoped_ptr<PrefService> local_state_;
- scoped_ptr<PrefService> user_pref_service_;
- scoped_ptr<ShellDeviceClient> device_client_;
- scoped_ptr<AppWindowClient> app_window_client_;
- scoped_ptr<ExtensionsClient> extensions_client_;
- scoped_ptr<ExtensionsBrowserClient> extensions_browser_client_;
- scoped_ptr<devtools_http_handler::DevToolsHttpHandler> devtools_http_handler_;
- scoped_ptr<ShellUpdateQueryParamsDelegate> update_query_params_delegate_;
- scoped_ptr<ShellOAuth2TokenService> oauth2_token_service_;
+ std::unique_ptr<DesktopController> desktop_controller_;
+ std::unique_ptr<ShellBrowserContext> browser_context_;
+ std::unique_ptr<PrefService> local_state_;
+ std::unique_ptr<PrefService> user_pref_service_;
+ std::unique_ptr<ShellDeviceClient> device_client_;
+ std::unique_ptr<AppWindowClient> app_window_client_;
+ std::unique_ptr<ExtensionsClient> extensions_client_;
+ std::unique_ptr<ExtensionsBrowserClient> extensions_browser_client_;
+ std::unique_ptr<devtools_http_handler::DevToolsHttpHandler>
+ devtools_http_handler_;
+ std::unique_ptr<ShellUpdateQueryParamsDelegate> update_query_params_delegate_;
+ std::unique_ptr<ShellOAuth2TokenService> oauth2_token_service_;
// Owned by the KeyedService system.
ShellExtensionSystem* extension_system_;
@@ -106,7 +108,7 @@ class ShellBrowserMainParts : public content::BrowserMainParts {
// in MainMessageLoopRun. If false, it has already been run.
bool run_message_loop_;
- scoped_ptr<ShellBrowserMainDelegate> browser_main_delegate_;
+ std::unique_ptr<ShellBrowserMainDelegate> browser_main_delegate_;
#if !defined(DISABLE_NACL)
base::CancelableTaskTracker task_tracker_;
diff --git a/chromium/extensions/shell/browser/shell_desktop_controller_aura.cc b/chromium/extensions/shell/browser/shell_desktop_controller_aura.cc
index 18474de0b0b..5be4fd0ba67 100644
--- a/chromium/extensions/shell/browser/shell_desktop_controller_aura.cc
+++ b/chromium/extensions/shell/browser/shell_desktop_controller_aura.cc
@@ -27,9 +27,9 @@
#include "ui/base/cursor/image_cursors.h"
#include "ui/base/ime/input_method_initializer.h"
#include "ui/base/user_activity/user_activity_detector.h"
+#include "ui/display/screen.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/native_widget_types.h"
-#include "ui/gfx/screen.h"
#include "ui/wm/core/base_focus_rules.h"
#include "ui/wm/core/compound_event_filter.h"
#include "ui/wm/core/cursor_manager.h"
@@ -42,8 +42,18 @@
#include "ui/chromeos/user_activity_power_manager_notifier.h"
#include "ui/display/types/display_mode.h"
#include "ui/display/types/display_snapshot.h"
+
+#if defined(USE_X11)
+#include "ui/display/chromeos/x11/native_display_delegate_x11.h"
+#endif
+
+#if defined(USE_OZONE)
+#include "ui/display/types/native_display_delegate.h"
+#include "ui/ozone/public/ozone_platform.h"
#endif
+#endif // defined(OS_CHROMEOS)
+
namespace extensions {
namespace {
@@ -90,7 +100,7 @@ class ShellNativeCursorManager : public wm::NativeCursorManager {
~ShellNativeCursorManager() override {}
// wm::NativeCursorManager overrides.
- void SetDisplay(const gfx::Display& display,
+ void SetDisplay(const display::Display& display,
wm::NativeCursorManagerDelegate* delegate) override {
if (image_cursors_->SetDisplay(display, display.device_scale_factor()))
SetCursor(delegate->GetCursor(), delegate);
@@ -140,7 +150,7 @@ class ShellNativeCursorManager : public wm::NativeCursorManager {
aura::WindowTreeHost* host_; // Not owned.
- scoped_ptr<ui::ImageCursors> image_cursors_;
+ std::unique_ptr<ui::ImageCursors> image_cursors_;
DISALLOW_COPY_AND_ASSIGN(ShellNativeCursorManager);
};
@@ -168,7 +178,13 @@ ShellDesktopControllerAura::ShellDesktopControllerAura()
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(
this);
display_configurator_.reset(new ui::DisplayConfigurator);
- display_configurator_->Init(false);
+#if defined(USE_OZONE)
+ display_configurator_->Init(
+ ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(), false);
+#elif defined(USE_X11)
+ display_configurator_->Init(
+ base::WrapUnique(new ui::NativeDisplayDelegateX11()), false);
+#endif
display_configurator_->ForceInitialConfigure(0);
display_configurator_->AddObserver(this);
#endif
@@ -267,9 +283,10 @@ void ShellDesktopControllerAura::InitWindowManager() {
host_->window()->SetLayoutManager(new FillLayout);
cursor_manager_.reset(
- new wm::CursorManager(scoped_ptr<wm::NativeCursorManager>(
+ new wm::CursorManager(std::unique_ptr<wm::NativeCursorManager>(
new ShellNativeCursorManager(host_.get()))));
- cursor_manager_->SetDisplay(gfx::Screen::GetScreen()->GetPrimaryDisplay());
+ cursor_manager_->SetDisplay(
+ display::Screen::GetScreen()->GetPrimaryDisplay());
cursor_manager_->SetCursor(ui::kCursorPointer);
aura::client::SetCursorClient(host_->window(), cursor_manager_.get());
@@ -297,7 +314,7 @@ void ShellDesktopControllerAura::CreateRootWindow() {
size = gfx::Size(1920, 1080);
screen_.reset(new ShellScreen(size));
- gfx::Screen::SetScreenInstance(screen_.get());
+ display::Screen::SetScreenInstance(screen_.get());
// TODO(mukai): Set up input method.
host_.reset(screen_->CreateHostForPrimaryDisplay());
diff --git a/chromium/extensions/shell/browser/shell_desktop_controller_aura.h b/chromium/extensions/shell/browser/shell_desktop_controller_aura.h
index 74595250bf2..27fae3b82a9 100644
--- a/chromium/extensions/shell/browser/shell_desktop_controller_aura.h
+++ b/chromium/extensions/shell/browser/shell_desktop_controller_aura.h
@@ -5,11 +5,11 @@
#ifndef EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_AURA_H_
#define EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_AURA_H_
+#include <memory>
#include <vector>
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "build/build_config.h"
#include "extensions/shell/browser/desktop_controller.h"
#include "ui/aura/client/window_tree_client.h"
@@ -110,27 +110,27 @@ class ShellDesktopControllerAura
gfx::Size GetPrimaryDisplaySize();
#if defined(OS_CHROMEOS)
- scoped_ptr<ui::DisplayConfigurator> display_configurator_;
+ std::unique_ptr<ui::DisplayConfigurator> display_configurator_;
#endif
- scoped_ptr<ShellScreen> screen_;
+ std::unique_ptr<ShellScreen> screen_;
- scoped_ptr<aura::WindowTreeHost> host_;
+ std::unique_ptr<aura::WindowTreeHost> host_;
- scoped_ptr<wm::CompoundEventFilter> root_window_event_filter_;
+ std::unique_ptr<wm::CompoundEventFilter> root_window_event_filter_;
- scoped_ptr<aura::client::DefaultCaptureClient> capture_client_;
+ std::unique_ptr<aura::client::DefaultCaptureClient> capture_client_;
- scoped_ptr<aura::client::FocusClient> focus_client_;
+ std::unique_ptr<aura::client::FocusClient> focus_client_;
- scoped_ptr<wm::CursorManager> cursor_manager_;
+ std::unique_ptr<wm::CursorManager> cursor_manager_;
- scoped_ptr<ui::UserActivityDetector> user_activity_detector_;
+ std::unique_ptr<ui::UserActivityDetector> user_activity_detector_;
#if defined(OS_CHROMEOS)
- scoped_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_;
+ std::unique_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_;
#endif
- scoped_ptr<AppWindowClient> app_window_client_;
+ std::unique_ptr<AppWindowClient> app_window_client_;
// NativeAppWindow::Close() deletes the AppWindow.
std::vector<AppWindow*> app_windows_;
diff --git a/chromium/extensions/shell/browser/shell_desktop_controller_aura_unittest.cc b/chromium/extensions/shell/browser/shell_desktop_controller_aura_unittest.cc
index 8bcfc4ad334..d83b97757cb 100644
--- a/chromium/extensions/shell/browser/shell_desktop_controller_aura_unittest.cc
+++ b/chromium/extensions/shell/browser/shell_desktop_controller_aura_unittest.cc
@@ -4,8 +4,10 @@
#include "extensions/shell/browser/shell_desktop_controller_aura.h"
+#include <memory>
+
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "ui/aura/test/aura_test_base.h"
@@ -29,10 +31,10 @@ class ShellDesktopControllerAuraTest : public aura::test::AuraTestBase {
void SetUp() override {
#if defined(OS_CHROMEOS)
- scoped_ptr<chromeos::DBusThreadManagerSetter> dbus_setter =
+ std::unique_ptr<chromeos::DBusThreadManagerSetter> dbus_setter =
chromeos::DBusThreadManager::GetSetterForTesting();
power_manager_client_ = new chromeos::FakePowerManagerClient();
- dbus_setter->SetPowerManagerClient(make_scoped_ptr(power_manager_client_));
+ dbus_setter->SetPowerManagerClient(base::WrapUnique(power_manager_client_));
#endif
aura::test::AuraTestBase::SetUp();
controller_.reset(new ShellDesktopControllerAura());
@@ -47,7 +49,7 @@ class ShellDesktopControllerAuraTest : public aura::test::AuraTestBase {
}
protected:
- scoped_ptr<ShellDesktopControllerAura> controller_;
+ std::unique_ptr<ShellDesktopControllerAura> controller_;
#if defined(OS_CHROMEOS)
chromeos::FakePowerManagerClient* power_manager_client_; // Not owned.
diff --git a/chromium/extensions/shell/browser/shell_desktop_controller_mac.h b/chromium/extensions/shell/browser/shell_desktop_controller_mac.h
index dda610c7fe7..b3e7e750604 100644
--- a/chromium/extensions/shell/browser/shell_desktop_controller_mac.h
+++ b/chromium/extensions/shell/browser/shell_desktop_controller_mac.h
@@ -5,10 +5,10 @@
#ifndef EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_MAC_H_
#define EXTENSIONS_SHELL_BROWSER_SHELL_DESKTOP_CONTROLLER_MAC_H_
-#include "extensions/shell/browser/desktop_controller.h"
+#include <memory>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
+#include "extensions/shell/browser/desktop_controller.h"
namespace extensions {
@@ -31,7 +31,7 @@ class ShellDesktopControllerMac : public DesktopController {
void CloseAppWindows() override;
private:
- scoped_ptr<AppWindowClient> app_window_client_;
+ std::unique_ptr<AppWindowClient> app_window_client_;
// The desktop only supports a single app window.
// TODO(yoz): Support multiple app windows, as we do in Aura.
diff --git a/chromium/extensions/shell/browser/shell_desktop_controller_mac.mm b/chromium/extensions/shell/browser/shell_desktop_controller_mac.mm
index 7731b0a58f8..29dd014306d 100644
--- a/chromium/extensions/shell/browser/shell_desktop_controller_mac.mm
+++ b/chromium/extensions/shell/browser/shell_desktop_controller_mac.mm
@@ -7,9 +7,9 @@
#include "extensions/browser/app_window/native_app_window.h"
#include "extensions/shell/browser/shell_app_delegate.h"
#include "extensions/shell/browser/shell_app_window_client.h"
-#include "ui/gfx/display.h"
+#include "ui/display/display.h"
+#include "ui/display/screen.h"
#include "ui/gfx/geometry/size.h"
-#include "ui/gfx/screen.h"
namespace extensions {
@@ -26,7 +26,7 @@ ShellDesktopControllerMac::~ShellDesktopControllerMac() {
gfx::Size ShellDesktopControllerMac::GetWindowSize() {
// This is the full screen size.
- return gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds().size();
+ return display::Screen::GetScreen()->GetPrimaryDisplay().bounds().size();
}
AppWindow* ShellDesktopControllerMac::CreateAppWindow(
diff --git a/chromium/extensions/shell/browser/shell_device_client.h b/chromium/extensions/shell/browser/shell_device_client.h
index 2a5e717c95a..7da2dbae728 100644
--- a/chromium/extensions/shell/browser/shell_device_client.h
+++ b/chromium/extensions/shell/browser/shell_device_client.h
@@ -5,11 +5,11 @@
#ifndef EXTENSIONS_SHELL_BROWSER_SHELL_DEVICE_CLIENT_H_
#define EXTENSIONS_SHELL_BROWSER_SHELL_DEVICE_CLIENT_H_
-#include "device/core/device_client.h"
+#include <memory>
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
+#include "device/core/device_client.h"
namespace extensions {
@@ -25,8 +25,8 @@ class ShellDeviceClient : device::DeviceClient {
device::HidService* GetHidService() override;
private:
- scoped_ptr<device::HidService> hid_service_;
- scoped_ptr<device::UsbService> usb_service_;
+ std::unique_ptr<device::HidService> hid_service_;
+ std::unique_ptr<device::UsbService> usb_service_;
DISALLOW_COPY_AND_ASSIGN(ShellDeviceClient);
};
diff --git a/chromium/extensions/shell/browser/shell_display_info_provider.cc b/chromium/extensions/shell/browser/shell_display_info_provider.cc
index db9cbf53b19..4ab6e1f4eb9 100644
--- a/chromium/extensions/shell/browser/shell_display_info_provider.cc
+++ b/chromium/extensions/shell/browser/shell_display_info_provider.cc
@@ -23,7 +23,7 @@ bool ShellDisplayInfoProvider::SetInfo(
}
void ShellDisplayInfoProvider::UpdateDisplayUnitInfoForPlatform(
- const gfx::Display& display,
+ const display::Display& display,
extensions::api::system_display::DisplayUnitInfo* unit) {
static bool logged_once = false;
if (!logged_once) {
diff --git a/chromium/extensions/shell/browser/shell_display_info_provider.h b/chromium/extensions/shell/browser/shell_display_info_provider.h
index 65137f80e8e..40c768e000a 100644
--- a/chromium/extensions/shell/browser/shell_display_info_provider.h
+++ b/chromium/extensions/shell/browser/shell_display_info_provider.h
@@ -20,7 +20,7 @@ class ShellDisplayInfoProvider : public DisplayInfoProvider {
const api::system_display::DisplayProperties& info,
std::string* error) override;
void UpdateDisplayUnitInfoForPlatform(
- const gfx::Display& display,
+ const display::Display& display,
extensions::api::system_display::DisplayUnitInfo* unit) override;
private:
diff --git a/chromium/extensions/shell/browser/shell_extension_system.cc b/chromium/extensions/shell/browser/shell_extension_system.cc
index 3fbbf14e42b..5c144018829 100644
--- a/chromium/extensions/shell/browser/shell_extension_system.cc
+++ b/chromium/extensions/shell/browser/shell_extension_system.cc
@@ -8,6 +8,7 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
+#include "base/memory/ptr_util.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_details.h"
@@ -178,9 +179,9 @@ ContentVerifier* ShellExtensionSystem::content_verifier() {
return nullptr;
}
-scoped_ptr<ExtensionSet> ShellExtensionSystem::GetDependentExtensions(
+std::unique_ptr<ExtensionSet> ShellExtensionSystem::GetDependentExtensions(
const Extension* extension) {
- return make_scoped_ptr(new ExtensionSet());
+ return base::WrapUnique(new ExtensionSet());
}
void ShellExtensionSystem::InstallUpdate(const std::string& extension_id,
diff --git a/chromium/extensions/shell/browser/shell_extension_system.h b/chromium/extensions/shell/browser/shell_extension_system.h
index 4448fb9385e..7b6b444114d 100644
--- a/chromium/extensions/shell/browser/shell_extension_system.h
+++ b/chromium/extensions/shell/browser/shell_extension_system.h
@@ -66,7 +66,7 @@ class ShellExtensionSystem : public ExtensionSystem {
const UnloadedExtensionInfo::Reason reason) override;
const OneShotEvent& ready() const override;
ContentVerifier* content_verifier() override;
- scoped_ptr<ExtensionSet> GetDependentExtensions(
+ std::unique_ptr<ExtensionSet> GetDependentExtensions(
const Extension* extension) override;
void InstallUpdate(const std::string& extension_id,
const base::FilePath& temp_dir) override;
@@ -79,10 +79,10 @@ class ShellExtensionSystem : public ExtensionSystem {
// Data to be accessed on the IO thread. Must outlive process_manager_.
scoped_refptr<InfoMap> info_map_;
- scoped_ptr<ServiceWorkerManager> service_worker_manager_;
- scoped_ptr<RuntimeData> runtime_data_;
- scoped_ptr<QuotaService> quota_service_;
- scoped_ptr<AppSorting> app_sorting_;
+ std::unique_ptr<ServiceWorkerManager> service_worker_manager_;
+ std::unique_ptr<RuntimeData> runtime_data_;
+ std::unique_ptr<QuotaService> quota_service_;
+ std::unique_ptr<AppSorting> app_sorting_;
scoped_refptr<ValueStoreFactory> store_factory_;
diff --git a/chromium/extensions/shell/browser/shell_extensions_browser_client.cc b/chromium/extensions/shell/browser/shell_extensions_browser_client.cc
index fd6bfd4c0b2..85204a35185 100644
--- a/chromium/extensions/shell/browser/shell_extensions_browser_client.cc
+++ b/chromium/extensions/shell/browser/shell_extensions_browser_client.cc
@@ -6,6 +6,7 @@
#include <utility>
+#include "base/memory/ptr_util.h"
#include "build/build_config.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
@@ -145,9 +146,9 @@ ShellExtensionsBrowserClient::GetProcessManagerDelegate() const {
return NULL;
}
-scoped_ptr<ExtensionHostDelegate>
+std::unique_ptr<ExtensionHostDelegate>
ShellExtensionsBrowserClient::CreateExtensionHostDelegate() {
- return scoped_ptr<ExtensionHostDelegate>(new ShellExtensionHostDelegate);
+ return base::WrapUnique(new ShellExtensionHostDelegate);
}
bool ShellExtensionsBrowserClient::DidVersionUpdate(BrowserContext* context) {
@@ -192,10 +193,10 @@ void ShellExtensionsBrowserClient::RegisterMojoServices(
RegisterServicesForFrame(render_frame_host, extension);
}
-scoped_ptr<RuntimeAPIDelegate>
+std::unique_ptr<RuntimeAPIDelegate>
ShellExtensionsBrowserClient::CreateRuntimeAPIDelegate(
content::BrowserContext* context) const {
- return scoped_ptr<RuntimeAPIDelegate>(new ShellRuntimeAPIDelegate());
+ return base::WrapUnique(new ShellRuntimeAPIDelegate());
}
const ComponentExtensionResourceManager*
@@ -206,7 +207,7 @@ ShellExtensionsBrowserClient::GetComponentExtensionResourceManager() {
void ShellExtensionsBrowserClient::BroadcastEventToRenderers(
events::HistogramValue histogram_value,
const std::string& event_name,
- scoped_ptr<base::ListValue> args) {
+ std::unique_ptr<base::ListValue> args) {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
@@ -216,7 +217,7 @@ void ShellExtensionsBrowserClient::BroadcastEventToRenderers(
return;
}
- scoped_ptr<Event> event(
+ std::unique_ptr<Event> event(
new Event(histogram_value, event_name, std::move(args)));
EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event));
}
diff --git a/chromium/extensions/shell/browser/shell_extensions_browser_client.h b/chromium/extensions/shell/browser/shell_extensions_browser_client.h
index da3e8be60df..0ef529ccf7b 100644
--- a/chromium/extensions/shell/browser/shell_extensions_browser_client.h
+++ b/chromium/extensions/shell/browser/shell_extensions_browser_client.h
@@ -5,6 +5,8 @@
#ifndef EXTENSIONS_SHELL_BROWSER_SHELL_EXTENSIONS_BROWSER_CLIENT_H_
#define EXTENSIONS_SHELL_BROWSER_SHELL_EXTENSIONS_BROWSER_CLIENT_H_
+#include <memory>
+
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "build/build_config.h"
@@ -65,7 +67,7 @@ class ShellExtensionsBrowserClient : public ExtensionsBrowserClient {
content::BrowserContext* context,
std::vector<ExtensionPrefsObserver*>* observers) const override;
ProcessManagerDelegate* GetProcessManagerDelegate() const override;
- scoped_ptr<ExtensionHostDelegate> CreateExtensionHostDelegate() override;
+ std::unique_ptr<ExtensionHostDelegate> CreateExtensionHostDelegate() override;
bool DidVersionUpdate(content::BrowserContext* context) override;
void PermitExternalProtocolHandler() override;
bool IsRunningInForcedAppMode() override;
@@ -77,13 +79,14 @@ class ShellExtensionsBrowserClient : public ExtensionsBrowserClient {
ExtensionFunctionRegistry* registry) const override;
void RegisterMojoServices(content::RenderFrameHost* render_frame_host,
const Extension* extension) const override;
- scoped_ptr<RuntimeAPIDelegate> CreateRuntimeAPIDelegate(
+ std::unique_ptr<RuntimeAPIDelegate> CreateRuntimeAPIDelegate(
content::BrowserContext* context) const override;
const ComponentExtensionResourceManager*
GetComponentExtensionResourceManager() override;
- void BroadcastEventToRenderers(events::HistogramValue histogram_value,
- const std::string& event_name,
- scoped_ptr<base::ListValue> args) override;
+ void BroadcastEventToRenderers(
+ events::HistogramValue histogram_value,
+ const std::string& event_name,
+ std::unique_ptr<base::ListValue> args) override;
net::NetLog* GetNetLog() override;
ExtensionCache* GetExtensionCache() override;
bool IsBackgroundUpdateAllowed() override;
@@ -102,10 +105,10 @@ class ShellExtensionsBrowserClient : public ExtensionsBrowserClient {
PrefService* pref_service_;
// Support for extension APIs.
- scoped_ptr<ExtensionsAPIClient> api_client_;
+ std::unique_ptr<ExtensionsAPIClient> api_client_;
// The extension cache used for download and installation.
- scoped_ptr<ExtensionCache> extension_cache_;
+ std::unique_ptr<ExtensionCache> extension_cache_;
DISALLOW_COPY_AND_ASSIGN(ShellExtensionsBrowserClient);
};
diff --git a/chromium/extensions/shell/browser/shell_native_app_window.cc b/chromium/extensions/shell/browser/shell_native_app_window.cc
index 83e76a7d4f8..cee27aabbe3 100644
--- a/chromium/extensions/shell/browser/shell_native_app_window.cc
+++ b/chromium/extensions/shell/browser/shell_native_app_window.cc
@@ -132,7 +132,7 @@ SkRegion* ShellNativeAppWindow::GetDraggableRegion() {
return NULL;
}
-void ShellNativeAppWindow::UpdateShape(scoped_ptr<SkRegion> region) {
+void ShellNativeAppWindow::UpdateShape(std::unique_ptr<SkRegion> region) {
NOTIMPLEMENTED();
}
diff --git a/chromium/extensions/shell/browser/shell_native_app_window.h b/chromium/extensions/shell/browser/shell_native_app_window.h
index 775473cff92..f3ff7be6d40 100644
--- a/chromium/extensions/shell/browser/shell_native_app_window.h
+++ b/chromium/extensions/shell/browser/shell_native_app_window.h
@@ -52,7 +52,7 @@ class ShellNativeAppWindow : public NativeAppWindow {
void UpdateDraggableRegions(
const std::vector<DraggableRegion>& regions) override;
SkRegion* GetDraggableRegion() override;
- void UpdateShape(scoped_ptr<SkRegion> region) override;
+ void UpdateShape(std::unique_ptr<SkRegion> region) override;
void HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) override;
bool IsFrameless() const override;
diff --git a/chromium/extensions/shell/browser/shell_native_app_window_aura_unittest.cc b/chromium/extensions/shell/browser/shell_native_app_window_aura_unittest.cc
index be7df4b8017..67eef83c935 100644
--- a/chromium/extensions/shell/browser/shell_native_app_window_aura_unittest.cc
+++ b/chromium/extensions/shell/browser/shell_native_app_window_aura_unittest.cc
@@ -4,7 +4,9 @@
#include "extensions/shell/browser/shell_native_app_window_aura.h"
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
+#include "base/memory/ptr_util.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h"
@@ -33,14 +35,14 @@ class ShellNativeAppWindowAuraTest : public ExtensionsTest {
protected:
content::TestBrowserThreadBundle thread_bundle_;
- scoped_ptr<content::NotificationService> notification_service_;
+ std::unique_ptr<content::NotificationService> notification_service_;
ShellAppWindowClient app_window_client_;
};
TEST_F(ShellNativeAppWindowAuraTest, Bounds) {
// The BrowserContext used here must be destroyed before the thread bundle,
// because of destructors of things spawned from creating a WebContents.
- scoped_ptr<content::BrowserContext> browser_context(
+ std::unique_ptr<content::BrowserContext> browser_context(
new content::TestBrowserContext);
scoped_refptr<Extension> extension =
ExtensionBuilder()
@@ -56,7 +58,7 @@ TEST_F(ShellNativeAppWindowAuraTest, Bounds) {
content::WebContents* web_contents = content::WebContents::Create(
content::WebContents::CreateParams(browser_context.get()));
app_window->SetAppWindowContentsForTesting(
- make_scoped_ptr(new TestAppWindowContents(web_contents)));
+ base::WrapUnique(new TestAppWindowContents(web_contents)));
AppWindow::BoundsSpecification window_spec;
window_spec.bounds = gfx::Rect(100, 200, 300, 400);
diff --git a/chromium/extensions/shell/browser/shell_network_controller_chromeos.cc b/chromium/extensions/shell/browser/shell_network_controller_chromeos.cc
index 4ff45c70b62..ab3cdab8a1d 100644
--- a/chromium/extensions/shell/browser/shell_network_controller_chromeos.cc
+++ b/chromium/extensions/shell/browser/shell_network_controller_chromeos.cc
@@ -26,7 +26,7 @@ namespace {
const int kScanIntervalSec = 10;
void HandleEnableWifiError(const std::string& error_name,
- scoped_ptr<base::DictionaryValue> error_data) {
+ std::unique_ptr<base::DictionaryValue> error_data) {
LOG(WARNING) << "Unable to enable wifi: " << error_name;
}
@@ -207,7 +207,7 @@ void ShellNetworkController::HandleConnectionSuccess() {
void ShellNetworkController::HandleConnectionError(
const std::string& error_name,
- scoped_ptr<base::DictionaryValue> error_data) {
+ std::unique_ptr<base::DictionaryValue> error_data) {
LOG(WARNING) << "Unable to connect to network: " << error_name;
state_ = STATE_IDLE;
}
diff --git a/chromium/extensions/shell/browser/shell_network_controller_chromeos.h b/chromium/extensions/shell/browser/shell_network_controller_chromeos.h
index 36b73d77e29..6ce75af8370 100644
--- a/chromium/extensions/shell/browser/shell_network_controller_chromeos.h
+++ b/chromium/extensions/shell/browser/shell_network_controller_chromeos.h
@@ -5,11 +5,11 @@
#ifndef EXTENSIONS_SHELL_BROWSER_SHELL_NETWORK_CONTROLLER_CHROMEOS_H_
#define EXTENSIONS_SHELL_BROWSER_SHELL_NETWORK_CONTROLLER_CHROMEOS_H_
+#include <memory>
#include <string>
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/timer/timer.h"
#include "base/values.h"
@@ -63,7 +63,7 @@ class ShellNetworkController : public chromeos::NetworkStateHandlerObserver {
// Handles a successful or failed connection attempt.
void HandleConnectionSuccess();
void HandleConnectionError(const std::string& error_name,
- scoped_ptr<base::DictionaryValue> error_data);
+ std::unique_ptr<base::DictionaryValue> error_data);
// Current status of communication with the chromeos::NetworkStateHandler.
// This is tracked to avoid sending duplicate requests before the handler has
diff --git a/chromium/extensions/shell/browser/shell_oauth2_token_service_delegate.cc b/chromium/extensions/shell/browser/shell_oauth2_token_service_delegate.cc
index 89eb2120447..759f3e2f24c 100644
--- a/chromium/extensions/shell/browser/shell_oauth2_token_service_delegate.cc
+++ b/chromium/extensions/shell/browser/shell_oauth2_token_service_delegate.cc
@@ -6,6 +6,8 @@
#include <vector>
+#include "content/public/browser/storage_partition.h"
+
namespace extensions {
ShellOAuth2TokenServiceDelegate::ShellOAuth2TokenServiceDelegate(
@@ -40,7 +42,8 @@ ShellOAuth2TokenServiceDelegate::CreateAccessTokenFetcher(
net::URLRequestContextGetter*
ShellOAuth2TokenServiceDelegate::GetRequestContext() const {
- return browser_context_->GetRequestContext();
+ return content::BrowserContext::GetDefaultStoragePartition(browser_context_)->
+ GetURLRequestContext();
}
std::vector<std::string> ShellOAuth2TokenServiceDelegate::GetAccounts() {
diff --git a/chromium/extensions/shell/browser/shell_prefs.cc b/chromium/extensions/shell/browser/shell_prefs.cc
index 82185cfcbd6..eea12aee1ef 100644
--- a/chromium/extensions/shell/browser/shell_prefs.cc
+++ b/chromium/extensions/shell/browser/shell_prefs.cc
@@ -39,7 +39,7 @@ scoped_refptr<JsonPrefStore> CreateAndLoadPrefStore(const FilePath& filepath) {
JsonPrefStore::GetTaskRunnerForFile(
filepath, content::BrowserThread::GetBlockingPool());
scoped_refptr<JsonPrefStore> pref_store =
- new JsonPrefStore(filepath, task_runner, scoped_ptr<PrefFilter>());
+ new JsonPrefStore(filepath, task_runner, std::unique_ptr<PrefFilter>());
pref_store->ReadPrefs(); // Synchronous.
return pref_store;
}
@@ -48,7 +48,7 @@ scoped_refptr<JsonPrefStore> CreateAndLoadPrefStore(const FilePath& filepath) {
namespace shell_prefs {
-scoped_ptr<PrefService> CreateLocalState(const FilePath& data_dir) {
+std::unique_ptr<PrefService> CreateLocalState(const FilePath& data_dir) {
FilePath filepath = data_dir.AppendASCII("local_state.json");
scoped_refptr<JsonPrefStore> pref_store = CreateAndLoadPrefStore(filepath);
@@ -63,7 +63,7 @@ scoped_ptr<PrefService> CreateLocalState(const FilePath& data_dir) {
return factory.Create(registry);
}
-scoped_ptr<PrefService> CreateUserPrefService(
+std::unique_ptr<PrefService> CreateUserPrefService(
content::BrowserContext* browser_context) {
FilePath filepath = browser_context->GetPath().AppendASCII("user_prefs.json");
scoped_refptr<JsonPrefStore> pref_store = CreateAndLoadPrefStore(filepath);
@@ -81,7 +81,7 @@ scoped_ptr<PrefService> CreateUserPrefService(
PrefRegistrySyncable* pref_registry = new PrefRegistrySyncable;
ExtensionPrefs::RegisterProfilePrefs(pref_registry);
- scoped_ptr<PrefService> pref_service = factory.Create(pref_registry);
+ std::unique_ptr<PrefService> pref_service = factory.Create(pref_registry);
user_prefs::UserPrefs::Set(browser_context, pref_service.get());
return pref_service;
}
diff --git a/chromium/extensions/shell/browser/shell_prefs.h b/chromium/extensions/shell/browser/shell_prefs.h
index 1e94c0e6bad..5cc02bf94c5 100644
--- a/chromium/extensions/shell/browser/shell_prefs.h
+++ b/chromium/extensions/shell/browser/shell_prefs.h
@@ -5,7 +5,7 @@
#ifndef EXTENSIONS_SHELL_BROWSER_SHELL_PREFS_H_
#define EXTENSIONS_SHELL_BROWSER_SHELL_PREFS_H_
-#include "base/memory/scoped_ptr.h"
+#include <memory>
class PrefService;
@@ -23,10 +23,10 @@ namespace extensions {
namespace shell_prefs {
// Creates a pref service for device-wide preferences stored in |data_dir|.
-scoped_ptr<PrefService> CreateLocalState(const base::FilePath& data_dir);
+std::unique_ptr<PrefService> CreateLocalState(const base::FilePath& data_dir);
// Creates a pref service that loads user preferences for |browser_context|.
-scoped_ptr<PrefService> CreateUserPrefService(
+std::unique_ptr<PrefService> CreateUserPrefService(
content::BrowserContext* browser_context);
} // namespace shell_prefs
diff --git a/chromium/extensions/shell/browser/shell_prefs_unittest.cc b/chromium/extensions/shell/browser/shell_prefs_unittest.cc
index 3f91f171a50..a2fbe3a1d0f 100644
--- a/chromium/extensions/shell/browser/shell_prefs_unittest.cc
+++ b/chromium/extensions/shell/browser/shell_prefs_unittest.cc
@@ -45,7 +45,7 @@ class ShellPrefsTest : public testing::Test {
};
TEST_F(ShellPrefsTest, CreateLocalState) {
- scoped_ptr<PrefService> local_state =
+ std::unique_ptr<PrefService> local_state =
shell_prefs::CreateLocalState(browser_context_.GetPath());
ASSERT_TRUE(local_state);
@@ -60,7 +60,7 @@ TEST_F(ShellPrefsTest, CreateLocalState) {
TEST_F(ShellPrefsTest, CreateUserPrefService) {
// Create the pref service. This loads the test pref file.
- scoped_ptr<PrefService> service =
+ std::unique_ptr<PrefService> service =
shell_prefs::CreateUserPrefService(&browser_context_);
// Some basic extension preferences are registered.
diff --git a/chromium/extensions/shell/browser/shell_screen.cc b/chromium/extensions/shell/browser/shell_screen.cc
index 14c54015b14..157750871cc 100644
--- a/chromium/extensions/shell/browser/shell_screen.cc
+++ b/chromium/extensions/shell/browser/shell_screen.cc
@@ -57,14 +57,14 @@ void ShellScreen::OnWindowDestroying(aura::Window* window) {
host_ = nullptr;
}
-// gfx::Screen overrides:
+// display::Screen overrides:
gfx::Point ShellScreen::GetCursorScreenPoint() {
return aura::Env::GetInstance()->last_mouse_location();
}
-gfx::NativeWindow ShellScreen::GetWindowUnderCursor() {
- return GetWindowAtScreenPoint(GetCursorScreenPoint());
+bool ShellScreen::IsWindowUnderCursor(gfx::NativeWindow window) {
+ return GetWindowAtScreenPoint(GetCursorScreenPoint()) == window;
}
gfx::NativeWindow ShellScreen::GetWindowAtScreenPoint(const gfx::Point& point) {
@@ -75,33 +75,31 @@ int ShellScreen::GetNumDisplays() const {
return 1;
}
-std::vector<gfx::Display> ShellScreen::GetAllDisplays() const {
- return std::vector<gfx::Display>(1, display_);
+std::vector<display::Display> ShellScreen::GetAllDisplays() const {
+ return std::vector<display::Display>(1, display_);
}
-gfx::Display ShellScreen::GetDisplayNearestWindow(
+display::Display ShellScreen::GetDisplayNearestWindow(
gfx::NativeWindow window) const {
return display_;
}
-gfx::Display ShellScreen::GetDisplayNearestPoint(
+display::Display ShellScreen::GetDisplayNearestPoint(
const gfx::Point& point) const {
return display_;
}
-gfx::Display ShellScreen::GetDisplayMatching(
+display::Display ShellScreen::GetDisplayMatching(
const gfx::Rect& match_rect) const {
return display_;
}
-gfx::Display ShellScreen::GetPrimaryDisplay() const {
+display::Display ShellScreen::GetPrimaryDisplay() const {
return display_;
}
-void ShellScreen::AddObserver(gfx::DisplayObserver* observer) {
-}
+void ShellScreen::AddObserver(display::DisplayObserver* observer) {}
-void ShellScreen::RemoveObserver(gfx::DisplayObserver* observer) {
-}
+void ShellScreen::RemoveObserver(display::DisplayObserver* observer) {}
} // namespace extensions
diff --git a/chromium/extensions/shell/browser/shell_screen.h b/chromium/extensions/shell/browser/shell_screen.h
index 4d24891785c..fed63dfd58f 100644
--- a/chromium/extensions/shell/browser/shell_screen.h
+++ b/chromium/extensions/shell/browser/shell_screen.h
@@ -7,8 +7,8 @@
#include "base/macros.h"
#include "ui/aura/window_observer.h"
-#include "ui/gfx/display.h"
-#include "ui/gfx/screen.h"
+#include "ui/display/display.h"
+#include "ui/display/screen.h"
namespace aura {
class WindowTreeHost;
@@ -22,7 +22,7 @@ namespace extensions {
// A minimal Aura implementation of a screen. Scale factor is locked at 1.0.
// When running on a Linux desktop resizing the main window resizes the screen.
-class ShellScreen : public gfx::Screen, public aura::WindowObserver {
+class ShellScreen : public display::Screen, public aura::WindowObserver {
public:
// Creates a screen occupying |size| physical pixels.
explicit ShellScreen(const gfx::Size& size);
@@ -37,22 +37,24 @@ class ShellScreen : public gfx::Screen, public aura::WindowObserver {
const gfx::Rect& new_bounds) override;
void OnWindowDestroying(aura::Window* window) override;
- // gfx::Screen overrides:
+ // display::Screen overrides:
gfx::Point GetCursorScreenPoint() override;
- gfx::NativeWindow GetWindowUnderCursor() override;
+ bool IsWindowUnderCursor(gfx::NativeWindow window) override;
gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override;
int GetNumDisplays() const override;
- std::vector<gfx::Display> GetAllDisplays() const override;
- gfx::Display GetDisplayNearestWindow(gfx::NativeView view) const override;
- gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override;
- gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override;
- gfx::Display GetPrimaryDisplay() const override;
- void AddObserver(gfx::DisplayObserver* observer) override;
- void RemoveObserver(gfx::DisplayObserver* observer) override;
+ std::vector<display::Display> GetAllDisplays() const override;
+ display::Display GetDisplayNearestWindow(gfx::NativeView view) const override;
+ display::Display GetDisplayNearestPoint(
+ const gfx::Point& point) const override;
+ display::Display GetDisplayMatching(
+ const gfx::Rect& match_rect) const override;
+ display::Display GetPrimaryDisplay() const override;
+ void AddObserver(display::DisplayObserver* observer) override;
+ void RemoveObserver(display::DisplayObserver* observer) override;
private:
aura::WindowTreeHost* host_; // Not owned.
- gfx::Display display_;
+ display::Display display_;
DISALLOW_COPY_AND_ASSIGN(ShellScreen);
};
diff --git a/chromium/extensions/shell/browser/shell_screen_unittest.cc b/chromium/extensions/shell/browser/shell_screen_unittest.cc
index 691a85fee10..75a5cd161ae 100644
--- a/chromium/extensions/shell/browser/shell_screen_unittest.cc
+++ b/chromium/extensions/shell/browser/shell_screen_unittest.cc
@@ -4,12 +4,13 @@
#include "extensions/shell/browser/shell_screen.h"
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
-#include "ui/gfx/display.h"
+#include "ui/display/display.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
@@ -31,7 +32,8 @@ TEST_F(ShellScreenTest, ShellScreen) {
// Tests that reshaping the host window reshapes the display.
// NOTE: AuraTestBase already has its own WindowTreeHost. This is creating a
// second one.
- scoped_ptr<aura::WindowTreeHost> host(screen.CreateHostForPrimaryDisplay());
+ std::unique_ptr<aura::WindowTreeHost> host(
+ screen.CreateHostForPrimaryDisplay());
EXPECT_TRUE(host->window());
host->window()->SetBounds(gfx::Rect(0, 0, 800, 600));
EXPECT_EQ("800x600", screen.GetPrimaryDisplay().size().ToString());
diff --git a/chromium/extensions/shell/browser/shell_speech_recognition_manager_delegate.cc b/chromium/extensions/shell/browser/shell_speech_recognition_manager_delegate.cc
index c4ce068cce7..25d1b871faa 100644
--- a/chromium/extensions/shell/browser/shell_speech_recognition_manager_delegate.cc
+++ b/chromium/extensions/shell/browser/shell_speech_recognition_manager_delegate.cc
@@ -64,11 +64,6 @@ void ShellSpeechRecognitionManagerDelegate::OnAudioLevelsChange(
float noise_volume) {
}
-void ShellSpeechRecognitionManagerDelegate::GetDiagnosticInformation(
- bool* can_report_metrics,
- std::string* hardware_info) {
-}
-
void ShellSpeechRecognitionManagerDelegate::CheckRecognitionIsAllowed(
int session_id,
base::Callback<void(bool ask_user, bool is_allowed)> callback) {
diff --git a/chromium/extensions/shell/browser/shell_speech_recognition_manager_delegate.h b/chromium/extensions/shell/browser/shell_speech_recognition_manager_delegate.h
index 5d00dc01eac..3ee126c352e 100644
--- a/chromium/extensions/shell/browser/shell_speech_recognition_manager_delegate.h
+++ b/chromium/extensions/shell/browser/shell_speech_recognition_manager_delegate.h
@@ -39,8 +39,6 @@ class ShellSpeechRecognitionManagerDelegate
float noise_volume) override;
// SpeechRecognitionManagerDelegate methods.
- void GetDiagnosticInformation(bool* can_report_metrics,
- std::string* hardware_info) override;
void CheckRecognitionIsAllowed(
int session_id,
base::Callback<void(bool ask_user, bool is_allowed)> callback) override;
diff --git a/chromium/extensions/shell/browser/shell_url_request_context_getter.cc b/chromium/extensions/shell/browser/shell_url_request_context_getter.cc
index 54f223741c3..6e6f2b5eaf8 100644
--- a/chromium/extensions/shell/browser/shell_url_request_context_getter.cc
+++ b/chromium/extensions/shell/browser/shell_url_request_context_getter.cc
@@ -6,7 +6,7 @@
#include <utility>
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "content/public/browser/resource_request_info.h"
#include "extensions/browser/info_map.h"
#include "extensions/shell/browser/shell_network_delegate.h"
@@ -36,9 +36,9 @@ ShellURLRequestContextGetter::ShellURLRequestContextGetter(
ShellURLRequestContextGetter::~ShellURLRequestContextGetter() {
}
-scoped_ptr<net::NetworkDelegate>
+std::unique_ptr<net::NetworkDelegate>
ShellURLRequestContextGetter::CreateNetworkDelegate() {
- return make_scoped_ptr(
+ return base::WrapUnique(
new ShellNetworkDelegate(browser_context_, extension_info_map_));
}
diff --git a/chromium/extensions/shell/browser/shell_url_request_context_getter.h b/chromium/extensions/shell/browser/shell_url_request_context_getter.h
index ca678eadf7b..cefef3f3a2c 100644
--- a/chromium/extensions/shell/browser/shell_url_request_context_getter.h
+++ b/chromium/extensions/shell/browser/shell_url_request_context_getter.h
@@ -26,8 +26,8 @@ namespace extensions {
class InfoMap;
-class ShellURLRequestContextGetter :
- public content::ShellURLRequestContextGetter {
+class ShellURLRequestContextGetter
+ : public content::ShellURLRequestContextGetter {
public:
ShellURLRequestContextGetter(
content::BrowserContext* browser_context,
@@ -41,16 +41,16 @@ class ShellURLRequestContextGetter :
InfoMap* extension_info_map);
// content::ShellURLRequestContextGetter implementation.
- scoped_ptr<net::NetworkDelegate> CreateNetworkDelegate() override;
+ std::unique_ptr<net::NetworkDelegate> CreateNetworkDelegate() override;
-protected:
- ~ShellURLRequestContextGetter() override;
+ protected:
+ ~ShellURLRequestContextGetter() override;
-private:
+ private:
content::BrowserContext* browser_context_;
InfoMap* extension_info_map_;
-private:
+ private:
DISALLOW_COPY_AND_ASSIGN(ShellURLRequestContextGetter);
};
diff --git a/chromium/extensions/shell/common/shell_extensions_client.cc b/chromium/extensions/shell/common/shell_extensions_client.cc
index 58a2e2fa341..76f5a5835e8 100644
--- a/chromium/extensions/shell/common/shell_extensions_client.cc
+++ b/chromium/extensions/shell/common/shell_extensions_client.cc
@@ -96,10 +96,10 @@ const std::string ShellExtensionsClient::GetProductName() {
return "app_shell";
}
-scoped_ptr<FeatureProvider> ShellExtensionsClient::CreateFeatureProvider(
+std::unique_ptr<FeatureProvider> ShellExtensionsClient::CreateFeatureProvider(
const std::string& name) const {
- scoped_ptr<FeatureProvider> provider;
- scoped_ptr<JSONFeatureProviderSource> source(
+ std::unique_ptr<FeatureProvider> provider;
+ std::unique_ptr<JSONFeatureProviderSource> source(
CreateFeatureProviderSource(name));
if (name == "api") {
provider.reset(new BaseFeatureProvider(source->dictionary(),
@@ -119,10 +119,10 @@ scoped_ptr<FeatureProvider> ShellExtensionsClient::CreateFeatureProvider(
return provider;
}
-scoped_ptr<JSONFeatureProviderSource>
+std::unique_ptr<JSONFeatureProviderSource>
ShellExtensionsClient::CreateFeatureProviderSource(
const std::string& name) const {
- scoped_ptr<JSONFeatureProviderSource> source(
+ std::unique_ptr<JSONFeatureProviderSource> source(
new JSONFeatureProviderSource(name));
if (name == "api") {
source->LoadJSON(IDR_EXTENSION_API_FEATURES);
diff --git a/chromium/extensions/shell/common/shell_extensions_client.h b/chromium/extensions/shell/common/shell_extensions_client.h
index 8c14d067d59..9f0624950ae 100644
--- a/chromium/extensions/shell/common/shell_extensions_client.h
+++ b/chromium/extensions/shell/common/shell_extensions_client.h
@@ -23,9 +23,9 @@ class ShellExtensionsClient : public ExtensionsClient {
const PermissionMessageProvider& GetPermissionMessageProvider()
const override;
const std::string GetProductName() override;
- scoped_ptr<FeatureProvider> CreateFeatureProvider(
+ std::unique_ptr<FeatureProvider> CreateFeatureProvider(
const std::string& name) const override;
- scoped_ptr<JSONFeatureProviderSource> CreateFeatureProviderSource(
+ std::unique_ptr<JSONFeatureProviderSource> CreateFeatureProviderSource(
const std::string& name) const override;
void FilterHostPermissions(const URLPatternSet& hosts,
URLPatternSet* new_hosts,
diff --git a/chromium/extensions/shell/renderer/shell_content_renderer_client.h b/chromium/extensions/shell/renderer/shell_content_renderer_client.h
index 639da37e63a..d7f81b42d47 100644
--- a/chromium/extensions/shell/renderer/shell_content_renderer_client.h
+++ b/chromium/extensions/shell/renderer/shell_content_renderer_client.h
@@ -5,9 +5,10 @@
#ifndef EXTENSIONS_SHELL_RENDERER_SHELL_CONTENT_RENDERER_CLIENT_H_
#define EXTENSIONS_SHELL_RENDERER_SHELL_CONTENT_RENDERER_CLIENT_H_
+#include <memory>
+
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "content/public/renderer/content_renderer_client.h"
namespace extensions {
@@ -56,11 +57,11 @@ class ShellContentRendererClient : public content::ContentRendererClient {
virtual ExtensionsClient* CreateExtensionsClient();
private:
- scoped_ptr<ExtensionsClient> extensions_client_;
- scoped_ptr<ShellExtensionsRendererClient> extensions_renderer_client_;
- scoped_ptr<DispatcherDelegate> extension_dispatcher_delegate_;
- scoped_ptr<Dispatcher> extension_dispatcher_;
- scoped_ptr<ExtensionsGuestViewContainerDispatcher>
+ std::unique_ptr<ExtensionsClient> extensions_client_;
+ std::unique_ptr<ShellExtensionsRendererClient> extensions_renderer_client_;
+ std::unique_ptr<DispatcherDelegate> extension_dispatcher_delegate_;
+ std::unique_ptr<Dispatcher> extension_dispatcher_;
+ std::unique_ptr<ExtensionsGuestViewContainerDispatcher>
guest_view_container_dispatcher_;
DISALLOW_COPY_AND_ASSIGN(ShellContentRendererClient);
diff --git a/chromium/extensions/strings/extensions_strings_gu.xtb b/chromium/extensions/strings/extensions_strings_gu.xtb
index a18253bf73b..6a69975a768 100644
--- a/chromium/extensions/strings/extensions_strings_gu.xtb
+++ b/chromium/extensions/strings/extensions_strings_gu.xtb
@@ -33,7 +33,7 @@
<translation id="6027032947578871493"><ph name="VENDOR_NAME" /> વિક્રેતાનું અજાણ્યું ઉત્પાદન <ph name="PRODUCT_ID" /> (શૃંખલા ક્રમાંક <ph name="SERIAL_NUMBER" />)</translation>
<translation id="6068932090455285721"><ph name="VENDOR_ID" /> વિક્રેતા તરફથી <ph name="PRODUCT_NAME" /></translation>
<translation id="6143635259298204954">એક્સ્ટેંશન અનપૅક કરી શકાતું નથી. એક્સ્ટેંશનને સુરક્ષિત રીતે અનપૅક કરવા માટે, તમારી પ્રોફાઇલ નિર્દેશિકાનો પાથ હોવો જોઈએ જે સિમલિંક ધરાવતો ન હોય. આવો કોઈ પાથ તમારી પ્રોફાઇલ માટે અસ્તિત્વમાં નથી.</translation>
-<translation id="616804573177634438">{0,select, single{એપ્લિકેશન "<ph name="APP_NAME" />" તમારા ઉપકરણો પૈકી એક પરની ઍક્સેસની વિનંતી કરી રહી છે.}multiple{એપ્લિકેશન "<ph name="APP_NAME" />" તમારા ઉપકરણો પૈકી એક પરની ઍક્સેસની વિનંતી કરી રહી છે.}other{UNUSED}}</translation>
+<translation id="616804573177634438">{0,select, single{ઍપ્લિકેશન "<ph name="APP_NAME" />" તમારા ઉપકરણો પૈકી એક પરની ઍક્સેસની વિનંતી કરી રહી છે.}multiple{ઍપ્લિકેશન "<ph name="APP_NAME" />" તમારા ઉપકરણો પૈકી એક પરની ઍક્સેસની વિનંતી કરી રહી છે.}other{UNUSED}}</translation>
<translation id="641087317769093025">એક્સ્ટેન્શન અનઝિપ કરી શકાયું નથી</translation>
<translation id="657064425229075395">પૃષ્ઠભૂમિ સ્ક્રિપ્ટ '<ph name="BACKGROUND_SCRIPT" />' લોડ કરી શકાઈ નથી.</translation>
<translation id="6580950983454333167"><ph name="VENDOR_NAME" /> નું <ph name="PRODUCT_NAME" /> (સીરિયલ નંબર <ph name="SERIAL_NUMBER" />)</translation>
diff --git a/chromium/extensions/strings/extensions_strings_kn.xtb b/chromium/extensions/strings/extensions_strings_kn.xtb
index b9ba94c53ee..1067ac9edd4 100644
--- a/chromium/extensions/strings/extensions_strings_kn.xtb
+++ b/chromium/extensions/strings/extensions_strings_kn.xtb
@@ -7,7 +7,7 @@
<translation id="149347756975725155">'<ph name="ICON" />' ಎಕ್ಸ್‌ಟೆನ್ಷನ್ ಐಕಾನ್ ಲೋಡ್ ಮಾಡಲಾಗಲಿಲ್ಲ.</translation>
<translation id="1803557475693955505">'<ph name="BACKGROUND_PAGE" />' ಹಿನ್ನಲೆ ಪುಟವನ್ನು ಲೋಡ್ ಮಾಡಲಾಗುವುದಿಲ್ಲ.</translation>
<translation id="2159915644201199628">ಚಿತ್ರವನ್ನು ಡಿಕೋಡ್ ಮಾಡಲು ಸಾಧ್ಯವಿಲ್ಲ: '<ph name="IMAGE_NAME" />'</translation>
-<translation id="2350172092385603347">ಲೋಕಲೈಜೇಷನ್ ಬಳಸಲಾಗಿದೆ, ಆದರೆ ಡೀಫಾಲ್ಟ್ _ಲೋಕಲ್ ಅನ್ನು ಮ್ಯಾನಿಫಾಸ್ಟ್‌ನಲ್ಲಿ ನಿರ್ದಿಷ್ಟಪಡಿಸಲಾಗಿಲ್ಲ.</translation>
+<translation id="2350172092385603347">ಲೋಕಲೈಜೇಷನ್ ಬಳಸಲಾಗಿದೆ, ಆದರೆ ಡಿಫಾಲ್ಟ್ _ಲೋಕಲ್ ಅನ್ನು ಮ್ಯಾನಿಫಾಸ್ಟ್‌ನಲ್ಲಿ ನಿರ್ದಿಷ್ಟಪಡಿಸಲಾಗಿಲ್ಲ.</translation>
<translation id="2753617847762399167">ಕಾನೂನು ಬಾಹಿರ ಪಾಥ್ ('..' ರೊಂದಿಗೆ ಸಮಗ್ರ ಅಥವಾ ಸಂಬಂಧಿತ... ): '<ph name="IMAGE_PATH" />'</translation>
<translation id="27822970480436970">ನೆಟ್‌ವರ್ಕ್ ವಿನಂತಿಯನ್ನು ಮಾರ್ಪಡಿಸಲು ಈ ವಿಸ್ತರಣೆಯು ವಿಫಲವಾಗಿದೆ ಏಕೆಂದರೆ ಮಾರ್ಪಡಿಸುವಿಕೆಯು ಮತ್ತೊಂದು ವಿಸ್ತರಣೆಯೊಂದಿಗೆ ಸಂಘರ್ಷಗೊಂಡಿದೆ.</translation>
<translation id="2857834222104759979">ಮ್ಯಾನಿಫೆಸ್ಟ್ ಫೈಲ್ ಮಾನ್ಯತೆ ಪಡೆದಿಲ್ಲ.</translation>
diff --git a/chromium/extensions/utility/unpacker.cc b/chromium/extensions/utility/unpacker.cc
index 837a0d8a7bb..4c3dbd48a94 100644
--- a/chromium/extensions/utility/unpacker.cc
+++ b/chromium/extensions/utility/unpacker.cc
@@ -115,7 +115,7 @@ Unpacker::Unpacker(const base::FilePath& working_dir,
Unpacker::~Unpacker() {
}
-scoped_ptr<base::DictionaryValue> Unpacker::ReadManifest() {
+std::unique_ptr<base::DictionaryValue> Unpacker::ReadManifest() {
base::FilePath manifest_path = extension_dir_.Append(kManifestFilename);
if (!base::PathExists(manifest_path)) {
SetError(errors::kInvalidManifest);
@@ -124,7 +124,7 @@ scoped_ptr<base::DictionaryValue> Unpacker::ReadManifest() {
JSONFileValueDeserializer deserializer(manifest_path);
std::string error;
- scoped_ptr<base::Value> root = deserializer.Deserialize(NULL, &error);
+ std::unique_ptr<base::Value> root = deserializer.Deserialize(NULL, &error);
if (!root.get()) {
SetError(error);
return NULL;
@@ -255,7 +255,7 @@ bool Unpacker::AddDecodedImage(const base::FilePath& path) {
bool Unpacker::ReadMessageCatalog(const base::FilePath& message_path) {
std::string error;
JSONFileValueDeserializer deserializer(message_path);
- scoped_ptr<base::DictionaryValue> root =
+ std::unique_ptr<base::DictionaryValue> root =
base::DictionaryValue::From(deserializer.Deserialize(NULL, &error));
if (!root.get()) {
base::string16 messages_file = message_path.LossyDisplayName();
diff --git a/chromium/extensions/utility/unpacker.h b/chromium/extensions/utility/unpacker.h
index b05cf3cc08a..cc2bbca1ff6 100644
--- a/chromium/extensions/utility/unpacker.h
+++ b/chromium/extensions/utility/unpacker.h
@@ -5,12 +5,12 @@
#ifndef EXTENSIONS_UTILITY_UNPACKER_H_
#define EXTENSIONS_UTILITY_UNPACKER_H_
+#include <memory>
#include <string>
#include <vector>
#include "base/files/file_path.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "extensions/common/manifest.h"
class SkBitmap;
@@ -56,7 +56,7 @@ class Unpacker {
bool DumpMessageCatalogsToFile();
// Parse the manifest.json file inside the extension (not in the header).
- scoped_ptr<base::DictionaryValue> ReadManifest();
+ std::unique_ptr<base::DictionaryValue> ReadManifest();
// Parse all _locales/*/messages.json files inside the extension.
bool ReadAllMessageCatalogs(const std::string& default_locale);
@@ -89,16 +89,16 @@ class Unpacker {
int creation_flags_;
// The parsed version of the manifest JSON contained in the extension.
- scoped_ptr<base::DictionaryValue> parsed_manifest_;
+ std::unique_ptr<base::DictionaryValue> parsed_manifest_;
// A list of decoded images and the paths where those images came from. Paths
// are relative to the manifest file.
struct InternalData;
- scoped_ptr<InternalData> internal_data_;
+ std::unique_ptr<InternalData> internal_data_;
// Dictionary of relative paths and catalogs per path. Paths are in the form
// of _locales/locale, without messages.json base part.
- scoped_ptr<base::DictionaryValue> parsed_catalogs_;
+ std::unique_ptr<base::DictionaryValue> parsed_catalogs_;
// The last error message that was set. Empty if there were no errors.
base::string16 error_message_;
diff --git a/chromium/extensions/utility/unpacker_unittest.cc b/chromium/extensions/utility/unpacker_unittest.cc
index 82e5a1f7dc1..890fb547ec4 100644
--- a/chromium/extensions/utility/unpacker_unittest.cc
+++ b/chromium/extensions/utility/unpacker_unittest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <memory>
+
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/path_service.h"
@@ -54,7 +56,7 @@ class UnpackerTest : public testing::Test {
protected:
base::ScopedTempDir temp_dir_;
- scoped_ptr<Unpacker> unpacker_;
+ std::unique_ptr<Unpacker> unpacker_;
};
TEST_F(UnpackerTest, EmptyDefaultLocale) {