summaryrefslogtreecommitdiff
path: root/chromium/content/common
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-07-12 14:07:37 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-07-17 10:29:26 +0000
commitec02ee4181c49b61fce1c8fb99292dbb8139cc90 (patch)
tree25cde714b2b71eb639d1cd53f5a22e9ba76e14ef /chromium/content/common
parentbb09965444b5bb20b096a291445170876225268d (diff)
downloadqtwebengine-chromium-ec02ee4181c49b61fce1c8fb99292dbb8139cc90.tar.gz
BASELINE: Update Chromium to 59.0.3071.134
Change-Id: Id02ef6fb2204c5fd21668a1c3e6911c83b17585a Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/content/common')
-rw-r--r--chromium/content/common/BUILD.gn45
-rw-r--r--chromium/content/common/DEPS2
-rw-r--r--chromium/content/common/accessibility_messages.h13
-rw-r--r--chromium/content/common/accessibility_mode.h93
-rw-r--r--chromium/content/common/accessibility_mode_enums.h68
-rw-r--r--chromium/content/common/android/address_parser.cc228
-rw-r--r--chromium/content/common/android/address_parser.h37
-rw-r--r--chromium/content/common/android/address_parser_internal.cc640
-rw-r--r--chromium/content/common/android/address_parser_internal.h90
-rw-r--r--chromium/content/common/android/address_parser_unittest.cc610
-rw-r--r--chromium/content/common/android/gin_java_bridge_value.cc15
-rw-r--r--chromium/content/common/android/gin_java_bridge_value.h15
-rw-r--r--chromium/content/common/android/gin_java_bridge_value_unittest.cc13
-rw-r--r--chromium/content/common/associated_interface_provider_impl.cc2
-rw-r--r--chromium/content/common/background_fetch/DEPS3
-rw-r--r--chromium/content/common/background_fetch/OWNERS10
-rw-r--r--chromium/content/common/background_fetch/background_fetch_struct_traits.cc59
-rw-r--r--chromium/content/common/background_fetch/background_fetch_struct_traits.h105
-rw-r--r--chromium/content/common/background_fetch/background_fetch_struct_traits_unittest.cc99
-rw-r--r--chromium/content/common/background_fetch/background_fetch_types.cc36
-rw-r--r--chromium/content/common/background_fetch/background_fetch_types.h77
-rw-r--r--chromium/content/common/background_fetch/background_fetch_types.typemap19
-rw-r--r--chromium/content/common/browser_plugin/browser_plugin_messages.h27
-rw-r--r--chromium/content/common/cache_storage/cache_storage_messages.h2
-rw-r--r--chromium/content/common/child.mojom9
-rw-r--r--chromium/content/common/child_process_host_impl.cc22
-rw-r--r--chromium/content/common/child_process_host_impl.h7
-rw-r--r--chromium/content/common/common_param_traits_unittest.cc13
-rw-r--r--chromium/content/common/content_message_generator.h2
-rw-r--r--chromium/content/common/content_param_traits.cc29
-rw-r--r--chromium/content/common/content_param_traits.h13
-rw-r--r--chromium/content/common/content_param_traits_macros.h20
-rw-r--r--chromium/content/common/content_security_policy/OWNERS1
-rw-r--r--chromium/content/common/content_security_policy/content_security_policy.cc67
-rw-r--r--chromium/content/common/content_security_policy/content_security_policy.h14
-rw-r--r--chromium/content/common/content_security_policy/content_security_policy_unittest.cc163
-rw-r--r--chromium/content/common/content_security_policy/csp_context.cc59
-rw-r--r--chromium/content/common/content_security_policy/csp_context.h95
-rw-r--r--chromium/content/common/content_security_policy/csp_context_unittest.cc63
-rw-r--r--chromium/content/common/content_security_policy/csp_disposition_enum.h19
-rw-r--r--chromium/content/common/content_security_policy/csp_source.cc109
-rw-r--r--chromium/content/common/content_security_policy/csp_source_list.cc29
-rw-r--r--chromium/content/common/content_security_policy/csp_source_list_unittest.cc95
-rw-r--r--chromium/content/common/content_security_policy/csp_source_unittest.cc27
-rw-r--r--chromium/content/common/content_security_policy_header.cc20
-rw-r--r--chromium/content/common/content_security_policy_header.h9
-rw-r--r--chromium/content/common/cursors/webcursor.cc10
-rw-r--r--chromium/content/common/cursors/webcursor.h19
-rw-r--r--chromium/content/common/cursors/webcursor_aura.cc88
-rw-r--r--chromium/content/common/cursors/webcursor_mac.mm124
-rw-r--r--chromium/content/common/cursors/webcursor_unittest.cc34
-rw-r--r--chromium/content/common/dom_storage/dom_storage_messages.h2
-rw-r--r--chromium/content/common/establish_channel_params.cc18
-rw-r--r--chromium/content/common/establish_channel_params.h27
-rw-r--r--chromium/content/common/feature_policy/feature_policy.cc167
-rw-r--r--chromium/content/common/feature_policy/feature_policy.h49
-rw-r--r--chromium/content/common/feature_policy/feature_policy_unittest.cc171
-rw-r--r--chromium/content/common/features.gni8
-rw-r--r--chromium/content/common/field_trial_recorder.mojom11
-rw-r--r--chromium/content/common/font_list_mac.mm13
-rw-r--r--chromium/content/common/font_list_win.cc4
-rw-r--r--chromium/content/common/frame_message_enums.h2
-rw-r--r--chromium/content/common/frame_messages.h130
-rw-r--r--chromium/content/common/frame_owner_properties.cc11
-rw-r--r--chromium/content/common/frame_owner_properties.h3
-rw-r--r--chromium/content/common/frame_replication_state.cc4
-rw-r--r--chromium/content/common/frame_sink_provider.mojom10
-rw-r--r--chromium/content/common/gpu/OWNERS11
-rw-r--r--chromium/content/common/gpu_host_messages.h193
-rw-r--r--chromium/content/common/host_shared_bitmap_manager.cc248
-rw-r--r--chromium/content/common/host_shared_bitmap_manager.h111
-rw-r--r--chromium/content/common/host_shared_bitmap_manager_unittest.cc165
-rw-r--r--chromium/content/common/indexed_db/indexed_db_key.cc49
-rw-r--r--chromium/content/common/indexed_db/indexed_db_key.h10
-rw-r--r--chromium/content/common/indexed_db/indexed_db_key_path.cc22
-rw-r--r--chromium/content/common/indexed_db/indexed_db_key_path.h2
-rw-r--r--chromium/content/common/indexed_db/indexed_db_key_range.h4
-rw-r--r--chromium/content/common/indexed_db/indexed_db_key_unittest.cc8
-rw-r--r--chromium/content/common/indexed_db/indexed_db_struct_traits.cc102
-rw-r--r--chromium/content/common/input/event_with_latency_info.h8
-rw-r--r--chromium/content/common/input/event_with_latency_info_unittest.cc236
-rw-r--r--chromium/content/common/input/gesture_event_stream_validator.cc40
-rw-r--r--chromium/content/common/input/gesture_event_stream_validator_unittest.cc92
-rw-r--r--chromium/content/common/input/input_event.h2
-rw-r--r--chromium/content/common/input/input_event_ack.cc2
-rw-r--r--chromium/content/common/input/input_event_ack.h2
-rw-r--r--chromium/content/common/input/input_event_stream_validator.cc6
-rw-r--r--chromium/content/common/input/input_param_traits_unittest.cc57
-rw-r--r--chromium/content/common/input/synthetic_pointer_action_params.cc16
-rw-r--r--chromium/content/common/input/synthetic_web_input_event_builders.cc153
-rw-r--r--chromium/content/common/input/synthetic_web_input_event_builders.h5
-rw-r--r--chromium/content/common/input/touch_event_stream_validator.cc50
-rw-r--r--chromium/content/common/input/touch_event_stream_validator_unittest.cc29
-rw-r--r--chromium/content/common/input/web_input_event_queue.h64
-rw-r--r--chromium/content/common/input/web_touch_event_traits.cc60
-rw-r--r--chromium/content/common/input_messages.h15
-rw-r--r--chromium/content/common/manifest_manager_messages.h4
-rw-r--r--chromium/content/common/manifest_util_unittest.cc36
-rw-r--r--chromium/content/common/media/aec_dump_messages.h5
-rw-r--r--chromium/content/common/media/audio_messages.h4
-rw-r--r--chromium/content/common/media/cdm_host_file.cc33
-rw-r--r--chromium/content/common/media/cdm_host_files.cc123
-rw-r--r--chromium/content/common/media/cdm_host_files.h18
-rw-r--r--chromium/content/common/media/media_devices.cc15
-rw-r--r--chromium/content/common/media/media_devices.h2
-rw-r--r--chromium/content/common/media/media_player_messages_android.h2
-rw-r--r--chromium/content/common/media/media_stream_messages.h3
-rw-r--r--chromium/content/common/media/renderer_audio_output_stream_factory.mojom25
-rw-r--r--chromium/content/common/media/video_capture.h1
-rw-r--r--chromium/content/common/message_port.cc164
-rw-r--r--chromium/content/common/message_port.h37
-rw-r--r--chromium/content/common/native_types.typemap1
-rw-r--r--chromium/content/common/navigation_params.cc45
-rw-r--r--chromium/content/common/navigation_params.h39
-rw-r--r--chromium/content/common/origin_trials/trial_token.cc28
-rw-r--r--chromium/content/common/origin_trials/trial_token_unittest.cc48
-rw-r--r--chromium/content/common/origin_trials/trial_token_validator.cc20
-rw-r--r--chromium/content/common/origin_trials/trial_token_validator_unittest.cc22
-rw-r--r--chromium/content/common/page_state_serialization.cc22
-rw-r--r--chromium/content/common/page_state_serialization_unittest.cc10
-rw-r--r--chromium/content/common/plugin_list.cc3
-rw-r--r--chromium/content/common/plugin_list.h2
-rw-r--r--chromium/content/common/presentation/presentation.typemap12
-rw-r--r--chromium/content/common/presentation/presentation_struct_traits.cc63
-rw-r--r--chromium/content/common/presentation/presentation_struct_traits.h79
-rw-r--r--chromium/content/common/push_messaging.mojom21
-rw-r--r--chromium/content/common/push_messaging_param_traits.cc59
-rw-r--r--chromium/content/common/render_message_filter.mojom12
-rw-r--r--chromium/content/common/resize_params.cc2
-rw-r--r--chromium/content/common/resource_messages.h12
-rw-r--r--chromium/content/common/resource_request.h6
-rw-r--r--chromium/content/common/sandbox_linux/android/sandbox_bpf_base_policy_android.cc2
-rw-r--r--chromium/content/common/sandbox_linux/bpf_gpu_policy_linux.cc4
-rw-r--r--chromium/content/common/sandbox_mac_diraccess_unittest.mm6
-rw-r--r--chromium/content/common/sandbox_mac_unittest_helper.mm6
-rw-r--r--chromium/content/common/sandbox_win.cc8
-rw-r--r--chromium/content/common/screen_orientation_messages.h21
-rw-r--r--chromium/content/common/service_manager/child_connection.cc65
-rw-r--r--chromium/content/common/service_manager/child_connection.h10
-rw-r--r--chromium/content/common/service_manager/service_manager_connection_impl.cc211
-rw-r--r--chromium/content/common/service_manager/service_manager_connection_impl.h24
-rw-r--r--chromium/content/common/service_manager/service_manager_connection_impl_unittest.cc58
-rw-r--r--chromium/content/common/service_worker/service_worker_client_info.cc11
-rw-r--r--chromium/content/common/service_worker/service_worker_event_dispatcher.mojom46
-rw-r--r--chromium/content/common/service_worker/service_worker_event_dispatcher.typemap1
-rw-r--r--chromium/content/common/service_worker/service_worker_fetch_request.typemap24
-rw-r--r--chromium/content/common/service_worker/service_worker_fetch_request_struct_traits.cc460
-rw-r--r--chromium/content/common/service_worker/service_worker_fetch_request_struct_traits.h156
-rw-r--r--chromium/content/common/service_worker/service_worker_messages.h19
-rw-r--r--chromium/content/common/service_worker/service_worker_types.cc11
-rw-r--r--chromium/content/common/service_worker/service_worker_types_struct_traits.cc52
-rw-r--r--chromium/content/common/service_worker/service_worker_utils_unittest.cc4
-rw-r--r--chromium/content/common/set_process_title.cc95
-rw-r--r--chromium/content/common/set_process_title.h27
-rw-r--r--chromium/content/common/set_process_title_linux.cc116
-rw-r--r--chromium/content/common/set_process_title_linux.h22
-rw-r--r--chromium/content/common/swapped_out_messages.cc1
-rw-r--r--chromium/content/common/typemaps.gni2
-rw-r--r--chromium/content/common/url_schemes.cc3
-rw-r--r--chromium/content/common/user_agent.cc6
-rw-r--r--chromium/content/common/view_messages.h82
161 files changed, 3696 insertions, 4695 deletions
diff --git a/chromium/content/common/BUILD.gn b/chromium/content/common/BUILD.gn
index 3eece6b31ef..fd5c0dc435b 100644
--- a/chromium/content/common/BUILD.gn
+++ b/chromium/content/common/BUILD.gn
@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("features.gni")
+import("//build/buildflag_header.gni")
import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//media/media_options.gni")
@@ -13,6 +15,14 @@ if (is_mac) {
import("//build/config/mac/mac_sdk.gni")
}
+# For feature flags internal to content. See content/public/common:features
+# for feature flags that clients of contents need to know about.
+buildflag_header("features") {
+ header = "features.h"
+
+ flags = [ "USE_EXTERNAL_POPUP_MENU=$use_external_popup_menu" ]
+}
+
source_set("common") {
# Targets external to content should always link to the public API.
# In addition, targets outside of the content component (shell and tests)
@@ -23,10 +33,6 @@ source_set("common") {
sources = [
"accessibility_messages.h",
"all_messages.h",
- "android/address_parser.cc",
- "android/address_parser.h",
- "android/address_parser_internal.cc",
- "android/address_parser_internal.h",
"android/common_jni_registrar.cc",
"android/common_jni_registrar.h",
"android/gin_java_bridge_errors.cc",
@@ -52,6 +58,10 @@ source_set("common") {
"associated_interface_registry_impl.h",
"ax_content_node_data.cc",
"ax_content_node_data.h",
+ "background_fetch/background_fetch_struct_traits.cc",
+ "background_fetch/background_fetch_struct_traits.h",
+ "background_fetch/background_fetch_types.cc",
+ "background_fetch/background_fetch_types.h",
"bluetooth/web_bluetooth_device_id.cc",
"bluetooth/web_bluetooth_device_id.h",
"browser_plugin/browser_plugin_constants.cc",
@@ -86,6 +96,7 @@ source_set("common") {
"content_security_policy/csp_source.h",
"content_security_policy/csp_source_list.cc",
"content_security_policy/csp_source_list.h",
+ "content_security_policy_header.cc",
"content_security_policy_header.h",
"content_switches_internal.cc",
"content_switches_internal.h",
@@ -112,8 +123,6 @@ source_set("common") {
"drag_traits.h",
"dwrite_font_proxy_messages.h",
"edit_command.h",
- "establish_channel_params.cc",
- "establish_channel_params.h",
"feature_policy/feature_policy.cc",
"feature_policy/feature_policy.h",
"file_utilities_messages.h",
@@ -137,9 +146,6 @@ source_set("common") {
"generic_shared_memory_id_generator.cc",
"generic_shared_memory_id_generator.h",
"gin_java_bridge_messages.h",
- "gpu_host_messages.h",
- "host_shared_bitmap_manager.cc",
- "host_shared_bitmap_manager.h",
"in_process_child_thread_params.cc",
"in_process_child_thread_params.h",
"indexed_db/indexed_db_constants.h",
@@ -187,7 +193,6 @@ source_set("common") {
"input/synthetic_web_input_event_builders.h",
"input/touch_event_stream_validator.cc",
"input/touch_event_stream_validator.h",
- "input/web_input_event_queue.h",
"input/web_touch_event_traits.cc",
"input/web_touch_event_traits.h",
"input_messages.h",
@@ -247,6 +252,8 @@ source_set("common") {
"platform_notification_messages.h",
"plugin_list.cc",
"plugin_list.h",
+ "presentation/presentation_struct_traits.cc",
+ "presentation/presentation_struct_traits.h",
"process_type.cc",
"quarantine/quarantine.cc",
"quarantine/quarantine_constants_linux.h",
@@ -294,7 +301,6 @@ source_set("common") {
"sandbox_win.cc",
"sandbox_win.h",
"savable_subframe.h",
- "screen_orientation_messages.h",
"send_zygote_child_ping_linux.cc",
"service_manager/embedded_service_runner.cc",
"service_manager/embedded_service_runner.h",
@@ -315,10 +321,6 @@ source_set("common") {
"service_worker/service_worker_types.h",
"service_worker/service_worker_utils.cc",
"service_worker/service_worker_utils.h",
- "set_process_title.cc",
- "set_process_title.h",
- "set_process_title_linux.cc",
- "set_process_title_linux.h",
"site_isolation_policy.cc",
"site_isolation_policy.h",
"speech_recognition_messages.h",
@@ -354,6 +356,7 @@ source_set("common") {
"//third_party/WebKit/public:blink_headers",
]
deps = [
+ ":features",
"//base",
"//base/third_party/dynamic_annotations",
"//build/util:webkit_version",
@@ -392,7 +395,9 @@ source_set("common") {
"//ppapi/features",
"//sandbox",
"//sandbox:sandbox_features",
+ "//services/resource_coordinator/public/interfaces",
"//services/service_manager",
+ "//services/service_manager/embedder",
"//services/service_manager/public/cpp",
"//services/service_manager/public/interfaces",
"//services/service_manager/runner/common",
@@ -409,7 +414,6 @@ source_set("common") {
"//ui/base/ime",
"//ui/display",
"//ui/events/blink",
- "//ui/events/ipc",
"//ui/gfx",
"//ui/gfx/geometry",
"//ui/gfx/ipc",
@@ -417,6 +421,7 @@ source_set("common") {
"//ui/gfx/ipc/geometry",
"//ui/gfx/ipc/skia",
"//ui/gl",
+ "//ui/latency/ipc",
"//ui/shell_dialogs",
"//url",
"//url/ipc:url_ipc",
@@ -539,7 +544,7 @@ source_set("common") {
]
}
- if (enable_pepper_cdms) {
+ if (enable_cdm_host_verification) {
sources += [
"media/cdm_host_file.cc",
"media/cdm_host_file.h",
@@ -576,13 +581,17 @@ mojom("mojo_bindings") {
sources = [
"associated_interfaces.mojom",
+ "child.mojom",
"child_memory_coordinator.mojom",
+ "field_trial_recorder.mojom",
"frame.mojom",
+ "frame_sink_provider.mojom",
"host_zoom.mojom",
"image_downloader/image_downloader.mojom",
"indexed_db/indexed_db.mojom",
"leveldb_wrapper.mojom",
"media/media_devices.mojom",
+ "media/renderer_audio_output_stream_factory.mojom",
"memory_coordinator.mojom",
"native_types.mojom",
"push_messaging.mojom",
@@ -605,7 +614,7 @@ mojom("mojo_bindings") {
public_deps = [
"//components/leveldb/public/interfaces",
- "//components/payments/content:payment_app",
+ "//components/payments/content:mojom_payment_app",
"//content/public/common:interfaces",
# TODO(mcasas): remove the following dep after https://crbug.com/653994
diff --git a/chromium/content/common/DEPS b/chromium/content/common/DEPS
index 52f6fd1bea5..48fd8c4b36a 100644
--- a/chromium/content/common/DEPS
+++ b/chromium/content/common/DEPS
@@ -4,6 +4,7 @@ include_rules = [
"+components/discardable_memory/common",
"+components/payments",
"+device/base/synchronization",
+ "+services/resource_coordinator/public/interfaces",
"+services/service_manager/public/cpp",
"+services/video_capture/public/interfaces",
@@ -39,6 +40,7 @@ include_rules = [
"+third_party/WebKit/public/platform/modules/bluetooth/web_bluetooth.mojom.h",
"+third_party/WebKit/public/platform/modules/device_orientation/WebDeviceMotionData.h",
"+third_party/WebKit/public/platform/modules/device_orientation/WebDeviceOrientationData.h",
+ "+third_party/WebKit/public/platform/modules/fetch/fetch_api_request.mojom.h",
"+third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h",
"+third_party/WebKit/public/platform/modules/mediasession/media_session.mojom.h",
"+third_party/WebKit/public/platform/modules/permissions/permission.mojom.h",
diff --git a/chromium/content/common/accessibility_messages.h b/chromium/content/common/accessibility_messages.h
index 261efd4c0d2..19ea0fdfae8 100644
--- a/chromium/content/common/accessibility_messages.h
+++ b/chromium/content/common/accessibility_messages.h
@@ -39,6 +39,7 @@ IPC_STRUCT_TRAITS_BEGIN(ui::AXActionData)
IPC_STRUCT_TRAITS_MEMBER(target_rect)
IPC_STRUCT_TRAITS_MEMBER(target_point)
IPC_STRUCT_TRAITS_MEMBER(value)
+ IPC_STRUCT_TRAITS_MEMBER(hit_test_event_to_fire)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(content::AXContentNodeData)
@@ -142,9 +143,10 @@ IPC_MESSAGE_ROUTED1(AccessibilityMsg_PerformAction,
// result is an iframe element), it responds with
// AccessibilityHostMsg_ChildFrameHitTestResult so that the
// hit test can be performed recursively on the child frame. Otherwise
-// it fires an accessibility event of type ui::AX_EVENT_HOVER on the target.
-IPC_MESSAGE_ROUTED1(AccessibilityMsg_HitTest,
- gfx::Point /* location to test */)
+// it fires an accessibility event of type |event_to_fire| on the target.
+IPC_MESSAGE_ROUTED2(AccessibilityMsg_HitTest,
+ gfx::Point /* location to test */,
+ ui::AXEvent /* event to fire */)
// Relay a request from assistive technology to set accessibility focus
// to a given node. On platforms where this is used (currently Android),
@@ -205,9 +207,10 @@ IPC_MESSAGE_ROUTED1(
AccessibilityHostMsg_FindInPageResultParams)
// Sent in response to AccessibilityMsg_HitTest.
-IPC_MESSAGE_ROUTED2(AccessibilityHostMsg_ChildFrameHitTestResult,
+IPC_MESSAGE_ROUTED3(AccessibilityHostMsg_ChildFrameHitTestResult,
gfx::Point /* location tested */,
- int /* node id of result */)
+ int /* node id of result */,
+ ui::AXEvent /* event to fire */)
// Sent in response to AccessibilityMsg_SnapshotTree. The callback id that was
// passed to the request will be returned in |callback_id|, along with
diff --git a/chromium/content/common/accessibility_mode.h b/chromium/content/common/accessibility_mode.h
new file mode 100644
index 00000000000..c23410c6024
--- /dev/null
+++ b/chromium/content/common/accessibility_mode.h
@@ -0,0 +1,93 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_ACCESSIBILITY_MODE_ENUMS_H_
+#define CONTENT_COMMON_ACCESSIBILITY_MODE_ENUMS_H_
+
+namespace content {
+
+class AccessibilityMode {
+ public:
+ // Native accessibility APIs, specific to each platform, are enabled.
+ // When this mode is set that indicates the presence of a third-party
+ // client accessing Chrome via accessibility APIs. However, unless one
+ // of the modes below is set, the contents of web pages will not be
+ // accessible.
+ static constexpr uint32_t kNativeAPIs = 1 << 0;
+
+ // The renderer process will generate an accessibility tree containing
+ // basic information about all nodes, including role, name, value,
+ // state, and location. This is the minimum mode required in order for
+ // web contents to be accessible, and the remaining modes are meaningless
+ // unless this one is set.
+ //
+ // Note that sometimes this mode will be set when kNativeAPI is not, when the
+ // content layer embedder is providing accessibility support via some other
+ // mechanism other than what's implemented in content/browser.
+ static constexpr uint32_t kWebContents = 1 << 1;
+
+ // The accessibility tree will contain inline text boxes, which are
+ // necessary to expose information about line breaks and word boundaries.
+ // Without this mode, you can retrieve the plaintext value of a text field
+ // but not the information about how it's broken down into lines.
+ //
+ // Note that when this mode is off it's still possible to request inline
+ // text boxes for a specific node on-demand, asynchronously.
+ static constexpr uint32_t kInlineTextBoxes = 1 << 2;
+
+ // The accessibility tree will contain extra accessibility
+ // attributes typically only needed by screen readers and other
+ // assistive technology for blind users. Examples include text style
+ // attributes, table cell information, live region properties, range
+ // values, and relationship attributes.
+ static constexpr uint32_t kScreenReader = 1 << 3;
+
+ // The accessibility tree will contain the HTML tag name and HTML attributes
+ // for all accessibility nodes that come from web content.
+ static constexpr uint32_t kHTML = 1 << 4;
+
+ constexpr AccessibilityMode() : flags_(0) {}
+ constexpr AccessibilityMode(uint32_t flags) : flags_(flags) {}
+
+ bool has_mode(uint32_t flag) const { return (flags_ & flag) > 0; }
+
+ void set_mode(uint32_t flag, bool value) {
+ flags_ = value ? (flags_ | flag) : (flags_ & ~flag);
+ }
+
+ uint32_t mode() const { return flags_; }
+
+ bool operator==(AccessibilityMode rhs) const {
+ if (flags_ == rhs.flags_)
+ return true;
+ return false;
+ }
+
+ bool is_mode_off() const { return flags_ == 0; }
+
+ bool operator!=(AccessibilityMode rhs) const { return !(*this == rhs); }
+
+ AccessibilityMode& operator|=(const AccessibilityMode& rhs) {
+ flags_ |= rhs.flags_;
+ return *this;
+ }
+
+ private:
+ uint32_t flags_;
+};
+
+static constexpr AccessibilityMode kAccessibilityModeWebContentsOnly(
+ AccessibilityMode::kWebContents | AccessibilityMode::kInlineTextBoxes |
+ AccessibilityMode::kScreenReader |
+ AccessibilityMode::kHTML);
+
+static constexpr AccessibilityMode kAccessibilityModeComplete(
+ AccessibilityMode::kNativeAPIs | AccessibilityMode::kWebContents |
+ AccessibilityMode::kInlineTextBoxes |
+ AccessibilityMode::kScreenReader |
+ AccessibilityMode::kHTML);
+
+} // namespace content
+
+#endif // CONTENT_COMMON_ACCESSIBILITY_MODE_ENUMS_H_
diff --git a/chromium/content/common/accessibility_mode_enums.h b/chromium/content/common/accessibility_mode_enums.h
deleted file mode 100644
index 46f8b4bb1ed..00000000000
--- a/chromium/content/common/accessibility_mode_enums.h
+++ /dev/null
@@ -1,68 +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 CONTENT_COMMON_ACCESSIBILITY_MODE_ENUMS_H_
-#define CONTENT_COMMON_ACCESSIBILITY_MODE_ENUMS_H_
-
-// Note: keep enums in content/browser/resources/accessibility/accessibility.js
-// in sync with these two enums.
-enum AccessibilityModeFlag {
- // Native accessibility APIs, specific to each platform, are enabled.
- // When this flag is set that indicates the presence of a third-party
- // client accessing Chrome via accessibility APIs. However, unless one
- // of the flags below is set, the contents of web pages will not be
- // accessible.
- ACCESSIBILITY_MODE_FLAG_NATIVE_APIS = 1 << 0,
-
- // The renderer process will generate an accessibility tree containing
- // basic information about all nodes, including role, name, value,
- // state, and location. This is the minimum flag required in order for
- // web contents to be accessible, and the remaining flags are meaningless
- // unless this one is set.
- //
- // Note that sometimes this flag will be set when
- // ACCESSIBILITY_MODE_FLAG_NATIVE_APIS is not, when the content layer embedder
- // is providing accessibility support via some other mechanism other than
- // what's implemented in content/browser.
- ACCESSIBILITY_MODE_FLAG_WEB_CONTENTS = 1 << 1,
-
- // The accessibility tree will contain inline text boxes, which are
- // necessary to expose information about line breaks and word boundaries.
- // Without this flag, you can retrieve the plaintext value of a text field
- // but not the information about how it's broken down into lines.
- //
- // Note that when this flag is off it's still possible to request inline
- // text boxes for a specific node on-demand, asynchronously.
- ACCESSIBILITY_MODE_FLAG_INLINE_TEXT_BOXES = 1 << 2,
-
- // The accessibility tree will contain extra accessibility
- // attributes typically only needed by screen readers and other
- // assistive technology for blind users. Examples include text style
- // attributes, table cell information, live region properties, range
- // values, and relationship attributes.
- ACCESSIBILITY_MODE_FLAG_SCREEN_READER = 1 << 3,
-
- // The accessibility tree will contain the HTML tag name and HTML attributes
- // for all accessibility nodes that come from web content.
- ACCESSIBILITY_MODE_FLAG_HTML = 1 << 4,
-};
-
-typedef int AccessibilityMode;
-
-const AccessibilityMode AccessibilityModeOff = 0;
-
-const AccessibilityMode ACCESSIBILITY_MODE_COMPLETE =
- ACCESSIBILITY_MODE_FLAG_NATIVE_APIS |
- ACCESSIBILITY_MODE_FLAG_WEB_CONTENTS |
- ACCESSIBILITY_MODE_FLAG_INLINE_TEXT_BOXES |
- ACCESSIBILITY_MODE_FLAG_SCREEN_READER |
- ACCESSIBILITY_MODE_FLAG_HTML;
-
-const AccessibilityMode ACCESSIBILITY_MODE_WEB_CONTENTS_ONLY =
- ACCESSIBILITY_MODE_FLAG_WEB_CONTENTS |
- ACCESSIBILITY_MODE_FLAG_INLINE_TEXT_BOXES |
- ACCESSIBILITY_MODE_FLAG_SCREEN_READER |
- ACCESSIBILITY_MODE_FLAG_HTML;
-
-#endif // CONTENT_COMMON_ACCESSIBILITY_MODE_ENUMS_H_
diff --git a/chromium/content/common/android/address_parser.cc b/chromium/content/common/android/address_parser.cc
deleted file mode 100644
index bed843d160c..00000000000
--- a/chromium/content/common/android/address_parser.cc
+++ /dev/null
@@ -1,228 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/common/android/address_parser.h"
-
-#include "base/logging.h"
-#include "base/strings/string_util.h"
-#include "content/common/android/address_parser_internal.h"
-
-namespace {
-
-// Minimum number of words in an address after the house number
-// before a state is expected to be found.
-// A value too high can miss short addresses.
-const size_t kMinAddressWords = 3;
-
-// Maximum number of words allowed in an address between the house number
-// and the state, both not included.
-const size_t kMaxAddressWords = 12;
-
-// Maximum number of lines allowed in an address between the house number
-// and the state, both not included.
-const size_t kMaxAddressLines = 5;
-
-// Maximum length allowed for any address word between the house number
-// and the state, both not included.
-const size_t kMaxAddressNameWordLength = 25;
-
-// Maximum number of words after the house number in which the location name
-// should be found.
-const size_t kMaxLocationNameDistance = 4;
-
-// Additional characters used as new line delimiters.
-const base::char16 kNewlineDelimiters[] = {
- '\n',
- ',',
- '*',
- 0x2022, // Unicode bullet
- 0,
-};
-
-} // anonymous namespace
-
-namespace content {
-
-namespace address_parser {
-
-using namespace internal;
-
-bool FindAddress(const base::string16& text, base::string16* address) {
- size_t start, end;
- if (FindAddress(text.begin(), text.end(), &start, &end)) {
- size_t len = end >= start ? end - start : 0;
- address->assign(text.substr(start, len));
- return true;
- }
- return false;
-}
-
-bool FindAddress(const base::string16::const_iterator& begin,
- const base::string16::const_iterator& end,
- size_t* start_pos,
- size_t* end_pos) {
- HouseNumberParser house_number_parser;
-
- // Keep going through the input string until a potential house number is
- // detected. Start tokenizing the following words to find a valid
- // street name within a word range. Then, find a state name followed
- // by a valid zip code for that state. Also keep a look for any other
- // possible house numbers to continue from in case of no match and for
- // state names not followed by a zip code (e.g. New York, NY 10000).
- const base::string16 newline_delimiters = kNewlineDelimiters;
- const base::string16 delimiters = base::kWhitespaceUTF16 + newline_delimiters;
- for (base::string16::const_iterator it = begin; it != end; ) {
- Word house_number;
- if (!house_number_parser.Parse(it, end, &house_number))
- return false;
-
- String16Tokenizer tokenizer(house_number.end, end, delimiters);
- tokenizer.set_options(String16Tokenizer::RETURN_DELIMS);
-
- WordList words;
- words.push_back(house_number);
-
- bool found_location_name = false;
- bool continue_on_house_number = true;
- bool consecutive_house_numbers = true;
- size_t next_house_number_word = 0;
- size_t num_lines = 1;
-
- // Don't include the house number in the word count.
- size_t next_word = 1;
- for (; next_word <= kMaxAddressWords + 1; ++next_word) {
-
- // Extract a new word from the tokenizer.
- if (next_word == words.size()) {
- do {
- if (!tokenizer.GetNext())
- return false;
-
- // Check the number of address lines.
- if (tokenizer.token_is_delim() && newline_delimiters.find(
- *tokenizer.token_begin()) != base::string16::npos) {
- ++num_lines;
- }
- } while (tokenizer.token_is_delim());
-
- if (num_lines > kMaxAddressLines)
- break;
-
- words.push_back(Word(tokenizer.token_begin(), tokenizer.token_end()));
- }
-
- // Check the word length. If too long, don't try to continue from
- // the next house number as no address can hold this word.
- const Word& current_word = words[next_word];
- DCHECK_GT(std::distance(current_word.begin, current_word.end), 0);
- size_t current_word_length = std::distance(
- current_word.begin, current_word.end);
- if (current_word_length > kMaxAddressNameWordLength) {
- continue_on_house_number = false;
- break;
- }
-
- // Check if the new word is a valid house number.
- if (house_number_parser.Parse(current_word.begin, current_word.end,
- NULL)) {
- // Increase the number of consecutive house numbers since the beginning.
- if (consecutive_house_numbers) {
- // Check if there is a new line between consecutive house numbers.
- // This avoids false positives of the form "Cafe 21\n 750 Fifth Ave.."
- if (num_lines > 1) {
- next_house_number_word = next_word;
- break;
- }
- }
-
- // Keep the next candidate to resume parsing from in case of failure.
- if (next_house_number_word == 0) {
- next_house_number_word = next_word;
- continue;
- }
- } else {
- consecutive_house_numbers = false;
- }
-
- // Look for location names in the words after the house number.
- // A range limitation is introduced to avoid matching
- // anything that starts with a number before a legitimate address.
- if (next_word <= kMaxLocationNameDistance &&
- IsValidLocationName(current_word)) {
- found_location_name = true;
- continue;
- }
-
- // Don't count the house number.
- if (next_word > kMinAddressWords) {
- // Looking for the state is likely to add new words to the list while
- // checking for multi-word state names.
- size_t state_first_word = next_word;
- size_t state_last_word, state_index;
- if (FindStateStartingInWord(&words, state_first_word, &state_last_word,
- &tokenizer, &state_index)) {
-
- // A location name should have been found at this point.
- if (!found_location_name)
- break;
-
- // Explicitly exclude "et al", as "al" is a valid state code.
- if (current_word_length == 2 && words.size() > 2) {
- const Word& previous_word = words[state_first_word - 1];
- if (previous_word.end - previous_word.begin == 2 &&
- base::LowerCaseEqualsASCII(
- base::StringPiece16(previous_word.begin, previous_word.end),
- "et") &&
- base::LowerCaseEqualsASCII(
- base::StringPiece16(current_word.begin, current_word.end),
- "al"))
- break;
- }
-
- // Extract one more word from the tokenizer if not already available.
- size_t zip_word = state_last_word + 1;
- if (zip_word == words.size()) {
- do {
- if (!tokenizer.GetNext()) {
- // The address ends with a state name without a zip code. This
- // is legal according to WebView#findAddress public
- // documentation.
- *start_pos = words[0].begin - begin;
- *end_pos = words[state_last_word].end - begin;
- return true;
- }
- } while (tokenizer.token_is_delim());
- words.push_back(Word(tokenizer.token_begin(),
- tokenizer.token_end()));
- }
-
- // Check the parsing validity and state range of the zip code.
- next_word = state_last_word;
- if (!IsZipValid(words[zip_word], state_index))
- continue;
-
- *start_pos = words[0].begin - begin;
- *end_pos = words[zip_word].end - begin;
- return true;
- }
- }
- }
-
- // Avoid skipping too many words because of a non-address number
- // at the beginning of the contents to parse.
- if (continue_on_house_number && next_house_number_word > 0) {
- it = words[next_house_number_word].begin;
- } else {
- DCHECK(!words.empty());
- next_word = std::min(next_word, words.size() - 1);
- it = words[next_word].end;
- }
- }
-
- return false;
-}
-
-} // namespace address_parser
-
-} // namespace content
diff --git a/chromium/content/common/android/address_parser.h b/chromium/content/common/android/address_parser.h
deleted file mode 100644
index cff7f5cf710..00000000000
--- a/chromium/content/common/android/address_parser.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_COMMON_ANDROID_ADDRESS_PARSER_H_
-#define CONTENT_COMMON_ANDROID_ADDRESS_PARSER_H_
-
-#include <stddef.h>
-
-#include "base/strings/string16.h"
-#include "content/common/content_export.h"
-
-namespace content {
-
-// Provides methods to find a geographical address (currently US only)
-// in a given text string.
-namespace address_parser {
-
-// Find the first address in some chunk of text. If an address is found in
-// |text| true is returned and the address is copied into |address|.
-// Otherwise, false is returned.
-bool FindAddress(const base::string16& text, base::string16* address);
-
-// Find the first address in some chunk of test. |begin| is the starting
-// position to search from, |end| is the position to search to. |start_pos|
-// and |end_pos| are set to the starting and ending position of the address,
-// if found.
-CONTENT_EXPORT bool FindAddress(const base::string16::const_iterator& begin,
- const base::string16::const_iterator& end,
- size_t* start_pos,
- size_t* end_pos);
-
-} // namespace address_parser
-
-} // namespace content
-
-#endif // CONTENT_COMMON_ANDROID_ADDRESS_PARSER_H_
diff --git a/chromium/content/common/android/address_parser_internal.cc b/chromium/content/common/android/address_parser_internal.cc
deleted file mode 100644
index 9892bd853fb..00000000000
--- a/chromium/content/common/android/address_parser_internal.cc
+++ /dev/null
@@ -1,640 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/common/android/address_parser_internal.h"
-
-#include <bitset>
-
-#include "base/logging.h"
-#include "base/macros.h"
-#include "base/strings/string_util.h"
-
-namespace {
-
-// Number of digits for a valid zip code.
-const size_t kZipDigits = 5;
-
-// Number of digits for a valid zip code in the Zip Plus 4 format.
-const size_t kZipPlus4Digits = 9;
-
-// Maximum number of digits of a house number, including possible hyphens.
-const size_t kMaxHouseDigits = 5;
-
-base::char16 SafePreviousChar(const base::string16::const_iterator& it,
- const base::string16::const_iterator& begin) {
- if (it == begin)
- return ' ';
- return *(it - 1);
-}
-
-base::char16 SafeNextChar(const base::string16::const_iterator& it,
- const base::string16::const_iterator& end) {
- if (it == end)
- return ' ';
- return *(it + 1);
-}
-
-bool WordLowerCaseEqualsASCII(base::string16::const_iterator word_begin,
- base::string16::const_iterator word_end, const char* ascii_to_match) {
- for (base::string16::const_iterator it = word_begin; it != word_end;
- ++it, ++ascii_to_match) {
- if (!*ascii_to_match || base::ToLowerASCII(*it) != *ascii_to_match)
- return false;
- }
- return *ascii_to_match == 0 || *ascii_to_match == ' ';
-}
-
-bool LowerCaseEqualsASCIIWithPlural(base::string16::const_iterator word_begin,
- base::string16::const_iterator word_end, const char* ascii_to_match,
- bool allow_plural) {
- for (base::string16::const_iterator it = word_begin; it != word_end;
- ++it, ++ascii_to_match) {
- if (!*ascii_to_match && allow_plural && *it == 's' && it + 1 == word_end)
- return true;
-
- if (!*ascii_to_match || base::ToLowerASCII(*it) != *ascii_to_match)
- return false;
- }
- return *ascii_to_match == 0;
-}
-
-} // anonymous namespace
-
-namespace content {
-
-namespace address_parser {
-
-namespace internal {
-
-Word::Word() {
-}
-
-Word::Word(const base::string16::const_iterator& begin,
- const base::string16::const_iterator& end)
- : begin(begin),
- end(end) {
- DCHECK(begin <= end);
-}
-
-Word::Word(const Word& other) = default;
-
-HouseNumberParser::HouseNumberParser() {
-}
-
-bool HouseNumberParser::IsPreDelimiter(base::char16 character) {
- return character == ':' || IsPostDelimiter(character);
-}
-
-bool HouseNumberParser::IsPostDelimiter(base::char16 character) {
- return base::IsUnicodeWhitespace(character) || strchr(",\"'", character);
-}
-
-void HouseNumberParser::RestartOnNextDelimiter() {
- ResetState();
- for (; it_ != end_ && !IsPreDelimiter(*it_); ++it_) {}
-}
-
-void HouseNumberParser::AcceptChars(size_t num_chars) {
- size_t offset = std::min(static_cast<size_t>(std::distance(it_, end_)),
- num_chars);
- it_ += offset;
- result_chars_ += offset;
-}
-
-void HouseNumberParser::SkipChars(size_t num_chars) {
- it_ += std::min(static_cast<size_t>(std::distance(it_, end_)), num_chars);
-}
-
-void HouseNumberParser::ResetState() {
- num_digits_ = 0;
- result_chars_ = 0;
-}
-
-bool HouseNumberParser::CheckFinished(Word* word) const {
- // There should always be a number after a hyphen.
- if (result_chars_ == 0 || SafePreviousChar(it_, begin_) == '-')
- return false;
-
- if (word) {
- word->begin = it_ - result_chars_;
- word->end = it_;
- }
- return true;
-}
-
-bool HouseNumberParser::Parse(
- const base::string16::const_iterator& begin,
- const base::string16::const_iterator& end, Word* word) {
- it_ = begin_ = begin;
- end_ = end;
- ResetState();
-
- // Iterations only used as a fail-safe against any buggy infinite loops.
- size_t iterations = 0;
- size_t max_iterations = end - begin + 1;
- for (; it_ != end_ && iterations < max_iterations; ++iterations) {
-
- // Word finished case.
- if (IsPostDelimiter(*it_)) {
- if (CheckFinished(word))
- return true;
- else if (result_chars_)
- ResetState();
-
- SkipChars(1);
- continue;
- }
-
- // More digits. There should be no more after a letter was found.
- if (base::IsAsciiDigit(*it_)) {
- if (num_digits_ >= kMaxHouseDigits) {
- RestartOnNextDelimiter();
- } else {
- AcceptChars(1);
- ++num_digits_;
- }
- continue;
- }
-
- if (base::IsAsciiAlpha(*it_)) {
- // Handle special case 'one'.
- if (result_chars_ == 0) {
- if (it_ + 3 <= end_ &&
- base::LowerCaseEqualsASCII(base::StringPiece16(it_, it_ + 3),
- "one"))
- AcceptChars(3);
- else
- RestartOnNextDelimiter();
- continue;
- }
-
- // There should be more than 1 character because of result_chars.
- DCHECK_GT(result_chars_, 0U);
- DCHECK(it_ != begin_);
- base::char16 previous = SafePreviousChar(it_, begin_);
- if (base::IsAsciiDigit(previous)) {
- // Check cases like '12A'.
- base::char16 next = SafeNextChar(it_, end_);
- if (IsPostDelimiter(next)) {
- AcceptChars(1);
- continue;
- }
-
- // Handle cases like 12a, 1st, 2nd, 3rd, 7th.
- if (base::IsAsciiAlpha(next)) {
- base::char16 last_digit = previous;
- base::char16 first_letter = base::ToLowerASCII(*it_);
- base::char16 second_letter = base::ToLowerASCII(next);
- bool is_teen = SafePreviousChar(it_ - 1, begin_) == '1' &&
- num_digits_ == 2;
-
- switch (last_digit - '0') {
- case 1:
- if ((first_letter == 's' && second_letter == 't') ||
- (first_letter == 't' && second_letter == 'h' && is_teen)) {
- AcceptChars(2);
- continue;
- }
- break;
-
- case 2:
- if ((first_letter == 'n' && second_letter == 'd') ||
- (first_letter == 't' && second_letter == 'h' && is_teen)) {
- AcceptChars(2);
- continue;
- }
- break;
-
- case 3:
- if ((first_letter == 'r' && second_letter == 'd') ||
- (first_letter == 't' && second_letter == 'h' && is_teen)) {
- AcceptChars(2);
- continue;
- }
- break;
-
- case 0:
- // Explicitly exclude '0th'.
- if (num_digits_ == 1)
- break;
-
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- if (first_letter == 't' && second_letter == 'h') {
- AcceptChars(2);
- continue;
- }
- break;
-
- default:
- NOTREACHED();
- }
- }
- }
-
- RestartOnNextDelimiter();
- continue;
- }
-
- if (*it_ == '-' && num_digits_ > 0) {
- AcceptChars(1);
- ++num_digits_;
- continue;
- }
-
- RestartOnNextDelimiter();
- SkipChars(1);
- }
-
- if (iterations >= max_iterations)
- return false;
-
- return CheckFinished(word);
-}
-
-bool FindStateStartingInWord(WordList* words,
- size_t state_first_word,
- size_t* state_last_word,
- String16Tokenizer* tokenizer,
- size_t* state_index) {
-
- // Bitmasks containing the allowed suffixes for 2-letter state codes.
- static const int state_two_letter_suffix[23] = {
- 0x02060c00, // A followed by: [KLRSZ].
- 0x00000000, // B.
- 0x00084001, // C followed by: [AOT].
- 0x00000014, // D followed by: [CE].
- 0x00000000, // E.
- 0x00001800, // F followed by: [LM].
- 0x00100001, // G followed by: [AU].
- 0x00000100, // H followed by: [I].
- 0x00002809, // I followed by: [ADLN].
- 0x00000000, // J.
- 0x01040000, // K followed by: [SY].
- 0x00000001, // L followed by: [A].
- 0x000ce199, // M followed by: [ADEHINOPST].
- 0x0120129c, // N followed by: [CDEHJMVY].
- 0x00020480, // O followed by: [HKR].
- 0x00420001, // P followed by: [ARW].
- 0x00000000, // Q.
- 0x00000100, // R followed by: [I].
- 0x0000000c, // S followed by: [CD].
- 0x00802000, // T followed by: [NX].
- 0x00080000, // U followed by: [T].
- 0x00080101, // V followed by: [AIT].
- 0x01200101 // W followed by: [AIVY].
- };
-
- // Accumulative number of states for the 2-letter code indexed by the first.
- static const int state_two_letter_accumulative[24] = {
- 0, 5, 5, 8, 10, 10, 12, 14,
- 15, 19, 19, 21, 22, 32, 40, 43,
- 46, 46, 47, 49, 51, 52, 55, 59
- };
-
- // State names sorted alphabetically with their lengths.
- // There can be more than one possible name for a same state if desired.
- static const struct StateNameInfo {
- const char* string;
- char first_word_length;
- char length;
- char state_index; // Relative to two-character code alphabetical order.
- } state_names[59] = {
- { "alabama", 7, 7, 1 }, { "alaska", 6, 6, 0 },
- { "american samoa", 8, 14, 3 }, { "arizona", 7, 7, 4 },
- { "arkansas", 8, 8, 2 },
- { "california", 10, 10, 5 }, { "colorado", 8, 8, 6 },
- { "connecticut", 11, 11, 7 }, { "delaware", 8, 8, 9 },
- { "district of columbia", 8, 20, 8 },
- { "federated states of micronesia", 9, 30, 11 }, { "florida", 7, 7, 10 },
- { "guam", 4, 4, 13 }, { "georgia", 7, 7, 12 },
- { "hawaii", 6, 6, 14 },
- { "idaho", 5, 5, 16 }, { "illinois", 8, 8, 17 }, { "indiana", 7, 7, 18 },
- { "iowa", 4, 4, 15 },
- { "kansas", 6, 6, 19 }, { "kentucky", 8, 8, 20 },
- { "louisiana", 9, 9, 21 },
- { "maine", 5, 5, 24 }, { "marshall islands", 8, 16, 25 },
- { "maryland", 8, 8, 23 }, { "massachusetts", 13, 13, 22 },
- { "michigan", 8, 8, 26 }, { "minnesota", 9, 9, 27 },
- { "mississippi", 11, 11, 30 }, { "missouri", 8, 8, 28 },
- { "montana", 7, 7, 31 },
- { "nebraska", 8, 8, 34 }, { "nevada", 6, 6, 38 },
- { "new hampshire", 3, 13, 35 }, { "new jersey", 3, 10, 36 },
- { "new mexico", 3, 10, 37 }, { "new york", 3, 8, 39 },
- { "north carolina", 5, 14, 32 }, { "north dakota", 5, 12, 33 },
- { "northern mariana islands", 8, 24, 29 },
- { "ohio", 4, 4, 40 }, { "oklahoma", 8, 8, 41 }, { "oregon", 6, 6, 42 },
- { "palau", 5, 5, 45 }, { "pennsylvania", 12, 12, 43 },
- { "puerto rico", 6, 11, 44 },
- { "rhode island", 5, 5, 46 },
- { "south carolina", 5, 14, 47 }, { "south dakota", 5, 12, 48 },
- { "tennessee", 9, 9, 49 }, { "texas", 5, 5, 50 },
- { "utah", 4, 4, 51 },
- { "vermont", 7, 7, 54 }, { "virgin islands", 6, 14, 53 },
- { "virginia", 8, 8, 52 },
- { "washington", 10, 10, 55 }, { "west virginia", 4, 13, 57 },
- { "wisconsin", 9, 9, 56 }, { "wyoming", 7, 7, 58 }
- };
-
- // Accumulative number of states for sorted names indexed by the first letter.
- // Required a different one since there are codes that don't share their
- // first letter with the name of their state (MP = Northern Mariana Islands).
- static const int state_names_accumulative[24] = {
- 0, 5, 5, 8, 10, 10, 12, 14,
- 15, 19, 19, 21, 22, 31, 40, 43,
- 46, 46, 47, 49, 51, 52, 55, 59
- };
-
- DCHECK_EQ(state_names_accumulative[arraysize(state_names_accumulative) - 1],
- static_cast<int>(arraysize(state_names)));
-
- const Word& first_word = words->at(state_first_word);
- int length = first_word.end - first_word.begin;
- if (length < 2 || !base::IsAsciiAlpha(*first_word.begin))
- return false;
-
- // No state names start with x, y, z.
- base::char16 first_letter = base::ToLowerASCII(*first_word.begin);
- if (first_letter > 'w')
- return false;
-
- DCHECK(first_letter >= 'a');
- int first_index = first_letter - 'a';
-
- // Look for two-letter state names.
- if (length == 2 && base::IsAsciiAlpha(*(first_word.begin + 1))) {
- base::char16 second_letter = base::ToLowerASCII(*(first_word.begin + 1));
- DCHECK(second_letter >= 'a');
-
- int second_index = second_letter - 'a';
- if (!(state_two_letter_suffix[first_index] & (1 << second_index)))
- return false;
-
- std::bitset<32> previous_suffixes = state_two_letter_suffix[first_index] &
- ((1 << second_index) - 1);
- *state_last_word = state_first_word;
- *state_index = state_two_letter_accumulative[first_index] +
- previous_suffixes.count();
- return true;
- }
-
- // Look for full state names by their first letter. Discard by length.
- for (int state = state_names_accumulative[first_index];
- state < state_names_accumulative[first_index + 1]; ++state) {
- if (state_names[state].first_word_length != length)
- continue;
-
- bool state_match = false;
- size_t state_word = state_first_word;
- for (int pos = 0; true; ) {
- if (!WordLowerCaseEqualsASCII(words->at(state_word).begin,
- words->at(state_word).end, &state_names[state].string[pos]))
- break;
-
- pos += words->at(state_word).end - words->at(state_word).begin + 1;
- if (pos >= state_names[state].length) {
- state_match = true;
- break;
- }
-
- // Ran out of words, extract more from the tokenizer.
- if (++state_word == words->size()) {
- do {
- if (!tokenizer->GetNext())
- break;
- } while (tokenizer->token_is_delim());
- words->push_back(
- Word(tokenizer->token_begin(), tokenizer->token_end()));
- }
- }
-
- if (state_match) {
- *state_last_word = state_word;
- *state_index = state_names[state].state_index;
- return true;
- }
- }
-
- return false;
-}
-
-bool IsZipValid(const Word& word, size_t state_index) {
- size_t length = word.end - word.begin;
- if (length != kZipDigits && length != kZipPlus4Digits + 1)
- return false;
-
- for (base::string16::const_iterator it = word.begin; it != word.end; ++it) {
- size_t pos = it - word.begin;
- if (base::IsAsciiDigit(*it) || (*it == '-' && pos == kZipDigits))
- continue;
- return false;
- }
- return IsZipValidForState(word, state_index);
-}
-
-bool IsZipValidForState(const Word& word, size_t state_index) {
- // List of valid zip code ranges.
- static const struct {
- signed char low;
- signed char high;
- signed char exception1;
- signed char exception2;
- } zip_range[] = {
- { 99, 99, -1, -1 }, // AK Alaska.
- { 35, 36, -1, -1 }, // AL Alabama.
- { 71, 72, -1, -1 }, // AR Arkansas.
- { 96, 96, -1, -1 }, // AS American Samoa.
- { 85, 86, -1, -1 }, // AZ Arizona.
- { 90, 96, -1, -1 }, // CA California.
- { 80, 81, -1, -1 }, // CO Colorado.
- { 6, 6, -1, -1 }, // CT Connecticut.
- { 20, 20, -1, -1 }, // DC District of Columbia.
- { 19, 19, -1, -1 }, // DE Delaware.
- { 32, 34, -1, -1 }, // FL Florida.
- { 96, 96, -1, -1 }, // FM Federated States of Micronesia.
- { 30, 31, -1, -1 }, // GA Georgia.
- { 96, 96, -1, -1 }, // GU Guam.
- { 96, 96, -1, -1 }, // HI Hawaii.
- { 50, 52, -1, -1 }, // IA Iowa.
- { 83, 83, -1, -1 }, // ID Idaho.
- { 60, 62, -1, -1 }, // IL Illinois.
- { 46, 47, -1, -1 }, // IN Indiana.
- { 66, 67, 73, -1 }, // KS Kansas.
- { 40, 42, -1, -1 }, // KY Kentucky.
- { 70, 71, -1, -1 }, // LA Louisiana.
- { 1, 2, -1, -1 }, // MA Massachusetts.
- { 20, 21, -1, -1 }, // MD Maryland.
- { 3, 4, -1, -1 }, // ME Maine.
- { 96, 96, -1, -1 }, // MH Marshall Islands.
- { 48, 49, -1, -1 }, // MI Michigan.
- { 55, 56, -1, -1 }, // MN Minnesota.
- { 63, 65, -1, -1 }, // MO Missouri.
- { 96, 96, -1, -1 }, // MP Northern Mariana Islands.
- { 38, 39, -1, -1 }, // MS Mississippi.
- { 55, 56, -1, -1 }, // MT Montana.
- { 27, 28, -1, -1 }, // NC North Carolina.
- { 58, 58, -1, -1 }, // ND North Dakota.
- { 68, 69, -1, -1 }, // NE Nebraska.
- { 3, 4, -1, -1 }, // NH New Hampshire.
- { 7, 8, -1, -1 }, // NJ New Jersey.
- { 87, 88, 86, -1 }, // NM New Mexico.
- { 88, 89, 96, -1 }, // NV Nevada.
- { 10, 14, 0, 6 }, // NY New York.
- { 43, 45, -1, -1 }, // OH Ohio.
- { 73, 74, -1, -1 }, // OK Oklahoma.
- { 97, 97, -1, -1 }, // OR Oregon.
- { 15, 19, -1, -1 }, // PA Pennsylvania.
- { 6, 6, 0, 9 }, // PR Puerto Rico.
- { 96, 96, -1, -1 }, // PW Palau.
- { 2, 2, -1, -1 }, // RI Rhode Island.
- { 29, 29, -1, -1 }, // SC South Carolina.
- { 57, 57, -1, -1 }, // SD South Dakota.
- { 37, 38, -1, -1 }, // TN Tennessee.
- { 75, 79, 87, 88 }, // TX Texas.
- { 84, 84, -1, -1 }, // UT Utah.
- { 22, 24, 20, -1 }, // VA Virginia.
- { 6, 9, -1, -1 }, // VI Virgin Islands.
- { 5, 5, -1, -1 }, // VT Vermont.
- { 98, 99, -1, -1 }, // WA Washington.
- { 53, 54, -1, -1 }, // WI Wisconsin.
- { 24, 26, -1, -1 }, // WV West Virginia.
- { 82, 83, -1, -1 } // WY Wyoming.
- };
-
- // Zip numeric value for the first two characters.
- DCHECK(word.begin != word.end);
- DCHECK(base::IsAsciiDigit(*word.begin));
- DCHECK(base::IsAsciiDigit(*(word.begin + 1)));
- int zip_prefix = (*word.begin - '0') * 10 + (*(word.begin + 1) - '0');
-
- if ((zip_prefix >= zip_range[state_index].low &&
- zip_prefix <= zip_range[state_index].high) ||
- zip_prefix == zip_range[state_index].exception1 ||
- zip_prefix == zip_range[state_index].exception2) {
- return true;
- }
- return false;
-}
-
-bool IsValidLocationName(const Word& word) {
- // Supported location names sorted alphabetically and grouped by first letter.
- static const struct LocationNameInfo {
- const char* string;
- char length;
- bool allow_plural;
- } location_names[159] = {
- { "alley", 5, false }, { "annex", 5, false }, { "arcade", 6, false },
- { "ave", 3, false }, { "ave.", 4, false }, { "avenue", 6, false },
- { "alameda", 7, false },
- { "bayou", 5, false }, { "beach", 5, false }, { "bend", 4, false },
- { "bluff", 5, true }, { "bottom", 6, false }, { "boulevard", 9, false },
- { "branch", 6, false }, { "bridge", 6, false }, { "brook", 5, true },
- { "burg", 4, true }, { "bypass", 6, false }, { "broadway", 8, false },
- { "camino", 6, false }, { "camp", 4, false }, { "canyon", 6, false },
- { "cape", 4, false }, { "causeway", 8, false }, { "center", 6, true },
- { "circle", 6, true }, { "cliff", 5, true }, { "club", 4, false },
- { "common", 6, false }, { "corner", 6, true }, { "course", 6, false },
- { "court", 5, true }, { "cove", 4, true }, { "creek", 5, false },
- { "crescent", 8, false }, { "crest", 5, false }, { "crossing", 8, false },
- { "crossroad", 9, false }, { "curve", 5, false }, { "circulo", 7, false },
- { "dale", 4, false }, { "dam", 3, false }, { "divide", 6, false },
- { "drive", 5, true },
- { "estate", 6, true }, { "expressway", 10, false },
- { "extension", 9, true },
- { "fall", 4, true }, { "ferry", 5, false }, { "field", 5, true },
- { "flat", 4, true }, { "ford", 4, true }, { "forest", 6, false },
- { "forge", 5, true }, { "fork", 4, true }, { "fort", 4, false },
- { "freeway", 7, false },
- { "garden", 6, true }, { "gateway", 7, false }, { "glen", 4, true },
- { "green", 5, true }, { "grove", 5, true },
- { "harbor", 6, true }, { "haven", 5, false }, { "heights", 7, false },
- { "highway", 7, false }, { "hill", 4, true }, { "hollow", 6, false },
- { "inlet", 5, false }, { "island", 6, true }, { "isle", 4, false },
- { "junction", 8, true },
- { "key", 3, true }, { "knoll", 5, true },
- { "lake", 4, true }, { "land", 4, false }, { "landing", 7, false },
- { "lane", 4, false }, { "light", 5, true }, { "loaf", 4, false },
- { "lock", 4, true }, { "lodge", 5, false }, { "loop", 4, false },
- { "mall", 4, false }, { "manor", 5, true }, { "meadow", 6, true },
- { "mews", 4, false }, { "mill", 4, true }, { "mission", 7, false },
- { "motorway", 8, false }, { "mount", 5, false }, { "mountain", 8, true },
- { "neck", 4, false },
- { "orchard", 7, false }, { "oval", 4, false }, { "overpass", 8, false },
- { "park", 4, true }, { "parkway", 7, true }, { "pass", 4, false },
- { "passage", 7, false }, { "path", 4, false }, { "pike", 4, false },
- { "pine", 4, true }, { "plain", 5, true }, { "plaza", 5, false },
- { "point", 5, true }, { "port", 4, true }, { "prairie", 7, false },
- { "privada", 7, false },
- { "radial", 6, false }, { "ramp", 4, false }, { "ranch", 5, false },
- { "rapid", 5, true }, { "rd", 2, false }, { "rd.", 3, false },
- { "rest", 4, false }, { "ridge", 5, true }, { "river", 5, false },
- { "road", 4, true }, { "route", 5, false }, { "row", 3, false },
- { "rue", 3, false }, { "run", 3, false },
- { "shoal", 5, true }, { "shore", 5, true }, { "skyway", 6, false },
- { "spring", 6, true }, { "spur", 4, true }, { "square", 6, true },
- { "station", 7, false }, { "stravenue", 9, false }, { "stream", 6, false },
- { "st", 2, false }, { "st.", 3, false }, { "street", 6, true },
- { "summit", 6, false }, { "speedway", 8, false },
- { "terrace", 7, false }, { "throughway", 10, false }, { "trace", 5, false },
- { "track", 5, false }, { "trafficway", 10, false }, { "trail", 5, false },
- { "tunnel", 6, false }, { "turnpike", 8, false },
- { "underpass", 9, false }, { "union", 5, true },
- { "valley", 6, true }, { "viaduct", 7, false }, { "view", 4, true },
- { "village", 7, true }, { "ville", 5, false }, { "vista", 5, false },
- { "walk", 4, true }, { "wall", 4, false }, { "way", 3, true },
- { "well", 4, true },
- { "xing", 4, false }, { "xrd", 3, false }
- };
-
- // Accumulative number of location names for each starting letter.
- static const int location_names_accumulative[25] = {
- 0, 7, 19, 40, 44,
- 47, 57, 62, 68, 71,
- 72, 74, 83, 92, 93,
- 96, 109, 109, 123, 137,
- 145, 147, 153, 157, 159
- };
-
- DCHECK_EQ(
- location_names_accumulative[arraysize(location_names_accumulative) - 1],
- static_cast<int>(arraysize(location_names)));
-
- if (!base::IsAsciiAlpha(*word.begin))
- return false;
-
- // No location names start with y, z.
- base::char16 first_letter = base::ToLowerASCII(*word.begin);
- if (first_letter > 'x')
- return false;
-
- DCHECK(first_letter >= 'a');
- int index = first_letter - 'a';
- int length = std::distance(word.begin, word.end);
- for (int i = location_names_accumulative[index];
- i < location_names_accumulative[index + 1]; ++i) {
- if (location_names[i].length != length &&
- (location_names[i].allow_plural &&
- location_names[i].length + 1 != length)) {
- continue;
- }
-
- if (LowerCaseEqualsASCIIWithPlural(word.begin, word.end,
- location_names[i].string,
- location_names[i].allow_plural)) {
- return true;
- }
- }
-
- return false;
-}
-
-} // namespace internal
-
-} // namespace address_parser
-
-} // namespace content
diff --git a/chromium/content/common/android/address_parser_internal.h b/chromium/content/common/android/address_parser_internal.h
deleted file mode 100644
index 60c1483fc03..00000000000
--- a/chromium/content/common/android/address_parser_internal.h
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_COMMON_ANDROID_ADDRESS_PARSER_INTERNAL_H_
-#define CONTENT_COMMON_ANDROID_ADDRESS_PARSER_INTERNAL_H_
-
-#include <stddef.h>
-
-#include <vector>
-
-#include "base/macros.h"
-#include "base/strings/string_tokenizer.h"
-#include "content/common/content_export.h"
-
-namespace content {
-
-namespace address_parser {
-
-// Internal classes and functions for address parsing.
-namespace internal {
-
-// Exposed for tests.
-struct CONTENT_EXPORT Word {
- base::string16::const_iterator begin;
- base::string16::const_iterator end;
-
- Word();
- Word(const base::string16::const_iterator& begin,
- const base::string16::const_iterator& end);
- Word(const Word& other);
-};
-
-// Exposed for tests.
-class CONTENT_EXPORT HouseNumberParser {
- public:
- HouseNumberParser();
-
- bool Parse(const base::string16::const_iterator& begin,
- const base::string16::const_iterator& end,
- Word* word);
-
- private:
- static inline bool IsPreDelimiter(base::char16 character);
- static inline bool IsPostDelimiter(base::char16 character);
- inline void RestartOnNextDelimiter();
-
- inline bool CheckFinished(Word* word) const;
- inline void AcceptChars(size_t num_chars);
- inline void SkipChars(size_t num_chars);
- inline void ResetState();
-
- // Iterators to the beginning, current position and ending of the string
- // being currently parsed.
- base::string16::const_iterator begin_;
- base::string16::const_iterator it_;
- base::string16::const_iterator end_;
-
- // Number of digits found in the current result candidate.
- size_t num_digits_;
-
- // Number of characters previous to the current iterator that belong
- // to the current result candidate.
- size_t result_chars_;
-
- DISALLOW_COPY_AND_ASSIGN(HouseNumberParser);
-};
-
-typedef std::vector<Word> WordList;
-typedef base::StringTokenizerT<base::string16, base::string16::const_iterator>
- String16Tokenizer;
-
-// These are exposed for tests.
-CONTENT_EXPORT bool FindStateStartingInWord(WordList* words,
- size_t state_first_word,
- size_t* state_last_word,
- String16Tokenizer* tokenizer,
- size_t* state_index);
-
-CONTENT_EXPORT bool IsValidLocationName(const Word& word);
-CONTENT_EXPORT bool IsZipValid(const Word& word, size_t state_index);
-CONTENT_EXPORT bool IsZipValidForState(const Word& word, size_t state_index);
-
-} // namespace internal
-
-} // namespace address_parser
-
-} // namespace content
-
-#endif // CONTENT_COMMON_ANDROID_ADDRESS_PARSER_INTERNAL_H_
diff --git a/chromium/content/common/android/address_parser_unittest.cc b/chromium/content/common/android/address_parser_unittest.cc
deleted file mode 100644
index c67fd490a99..00000000000
--- a/chromium/content/common/android/address_parser_unittest.cc
+++ /dev/null
@@ -1,610 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/common/android/address_parser.h"
-
-#include <stddef.h>
-
-#include <memory>
-
-#include "base/macros.h"
-#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "content/common/android/address_parser_internal.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-using namespace content::address_parser;
-using namespace content::address_parser::internal;
-
-class AddressParserTest : public testing::Test {
- public:
- AddressParserTest() {}
-
- void TokenizeWords(const base::string16& content, WordList* words) const {
- String16Tokenizer tokenizer(content.begin(), content.end(),
- base::kWhitespaceUTF16);
- while (tokenizer.GetNext()) {
- words->push_back(Word(tokenizer.token_begin(), tokenizer.token_end()));
- }
- }
-
- std::string GetHouseNumber(const std::string& content) const {
- base::string16 content_16 = base::UTF8ToUTF16(content);
- base::string16 result;
-
- HouseNumberParser parser;
- Word word;
- if (parser.Parse(content_16.begin(), content_16.end(), &word))
- result = base::string16(word.begin, word.end);
- return base::UTF16ToUTF8(result);
- }
-
- bool ContainsHouseNumber(const std::string& content) const {
- return !GetHouseNumber(content).empty();
- }
-
- bool GetState(const std::string& state, size_t* state_index) const {
- base::string16 state_16 = base::UTF8ToUTF16(state);
- String16Tokenizer tokenizer(state_16.begin(), state_16.end(),
- base::kWhitespaceUTF16);
- if (!tokenizer.GetNext())
- return false;
-
- size_t state_last_word;
- WordList words;
- words.push_back(Word(tokenizer.token_begin(), tokenizer.token_end()));
- return FindStateStartingInWord(&words, 0, &state_last_word, &tokenizer,
- state_index);
- }
-
- bool IsState(const std::string& state) const {
- size_t state_index;
- return GetState(state, &state_index);
- }
-
- bool IsZipValid(const std::string& zip, const std::string& state) const {
- size_t state_index;
- EXPECT_TRUE(GetState(state, &state_index));
-
- base::string16 zip_16 = base::UTF8ToUTF16(zip);
- WordList words;
- TokenizeWords(zip_16, &words);
- EXPECT_TRUE(words.size() == 1);
- return ::IsZipValid(words.front(), state_index);
- }
-
- bool IsLocationName(const std::string& street) const {
- base::string16 street_16 = base::UTF8ToUTF16(street);
- WordList words;
- TokenizeWords(street_16, &words);
- EXPECT_TRUE(words.size() == 1);
- return IsValidLocationName(words.front());
- }
-
- std::string FindAddress(const std::string& content) const {
- base::string16 content_16 = base::UTF8ToUTF16(content);
- base::string16 result_16;
- size_t start, end;
- if (::FindAddress(content_16.begin(), content_16.end(), &start, &end))
- result_16 = content_16.substr(start, end - start);
- return base::UTF16ToUTF8(result_16);
- }
-
- bool ContainsAddress(const std::string& content) const {
- return !FindAddress(content).empty();
- }
-
- bool IsAddress(const std::string& content) const {
- return FindAddress(content) == content;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(AddressParserTest);
-};
-
-TEST_F(AddressParserTest, HouseNumber) {
- // Tests cases with valid home numbers.
- EXPECT_EQ(GetHouseNumber("4 my house"), "4");
- EXPECT_EQ(GetHouseNumber("Something 4 my house"), "4");
- EXPECT_EQ(GetHouseNumber("4"), "4");
- EXPECT_EQ(GetHouseNumber(" 4,5"), "4");
- EXPECT_EQ(GetHouseNumber("one"), "one");
- EXPECT_EQ(GetHouseNumber("Number One somewhere"), "One");
- EXPECT_EQ(GetHouseNumber("Testing \n4\n"), "4");
- EXPECT_EQ(GetHouseNumber("Foo 1ST"), "1ST");
- EXPECT_EQ(GetHouseNumber("Bar 2nd"), "2nd");
- EXPECT_EQ(GetHouseNumber("Blah 3rd"), "3rd");
- EXPECT_EQ(GetHouseNumber("4th"), "4th");
- EXPECT_EQ(GetHouseNumber("Blah 11th"), "11th");
- EXPECT_EQ(GetHouseNumber("Blah 12th meh"), "12th");
- EXPECT_EQ(GetHouseNumber("Blah 13th moo"), "13th");
- EXPECT_EQ(GetHouseNumber("211st"), "211st");
- EXPECT_EQ(GetHouseNumber("1A"), "1A");
- EXPECT_EQ(GetHouseNumber("number:35"), "35");
- EXPECT_EQ(GetHouseNumber("five digits at most: 12345"), "12345");
- EXPECT_EQ(GetHouseNumber("'123'"), "123");
- EXPECT_EQ(GetHouseNumber("\"123\""), "123");
- EXPECT_EQ(GetHouseNumber("\"123, something\""), "123");
- EXPECT_EQ(GetHouseNumber("Testing 12-34"), "12-34");
- EXPECT_EQ(GetHouseNumber("Testing 12-34c,d"), "12-34c");
- EXPECT_EQ(GetHouseNumber("住所は:76 Buckingham Palace Roadです"), "76");
-
- // Tests cases without valid home numbers.
- EXPECT_FALSE(ContainsHouseNumber("0th"));
- EXPECT_FALSE(ContainsHouseNumber("25st"));
- EXPECT_FALSE(ContainsHouseNumber("111th"));
- EXPECT_FALSE(ContainsHouseNumber("011th"));
- EXPECT_FALSE(ContainsHouseNumber("27AZ"));
- EXPECT_FALSE(ContainsHouseNumber("22ºC"));
- EXPECT_FALSE(ContainsHouseNumber("3.141592"));
- EXPECT_FALSE(ContainsHouseNumber("more than five digits: 123456"));
- EXPECT_FALSE(ContainsHouseNumber("kjhdfkajsdhf98uf93h"));
- EXPECT_FALSE(ContainsHouseNumber("これはテストです。"));
- EXPECT_FALSE(ContainsHouseNumber("Number On"));
- EXPECT_FALSE(ContainsHouseNumber("2: foo"));
- EXPECT_FALSE(ContainsHouseNumber("12-"));
- EXPECT_FALSE(ContainsHouseNumber("\n\"' \t, "));
- EXPECT_FALSE(ContainsHouseNumber(""));
-}
-
-TEST_F(AddressParserTest, FindState) {
- // The complete set of state codes and names is tested together with their
- // returned state indices in the zip code test.
- EXPECT_TRUE(IsState("CALIFORNIA"));
- EXPECT_TRUE(IsState("ca"));
-
- EXPECT_FALSE(IsState("californi"));
- EXPECT_FALSE(IsState("northern mariana"));
- EXPECT_FALSE(IsState("northern mariana island"));
- EXPECT_FALSE(IsState("zz"));
-}
-
-TEST_F(AddressParserTest, ZipCode) {
- EXPECT_TRUE(IsZipValid("90000", "CA"));
- EXPECT_TRUE(IsZipValid("01234", "MA"));
- EXPECT_TRUE(IsZipValid("99999-9999", "Alaska"));
-
- EXPECT_FALSE(IsZipValid("999999999", "Alaska"));
- EXPECT_FALSE(IsZipValid("9999-99999", "Alaska"));
- EXPECT_FALSE(IsZipValid("999999999-", "Alaska"));
- EXPECT_FALSE(IsZipValid("99999-999a", "Alaska"));
- EXPECT_FALSE(IsZipValid("99999--9999", "Alaska"));
- EXPECT_FALSE(IsZipValid("90000o", "CA"));
- EXPECT_FALSE(IsZipValid("01234", "CA"));
- EXPECT_FALSE(IsZipValid("01234-", "MA"));
-
- // Test the state index against the zip range table.
- EXPECT_TRUE(IsZipValid("99000", "AK"));
- EXPECT_TRUE(IsZipValid("99000", "Alaska"));
- EXPECT_TRUE(IsZipValid("35000", "AL"));
- EXPECT_TRUE(IsZipValid("36000", "Alabama"));
- EXPECT_TRUE(IsZipValid("71000", "AR"));
- EXPECT_TRUE(IsZipValid("72000", "Arkansas"));
- EXPECT_TRUE(IsZipValid("96000", "AS"));
- EXPECT_TRUE(IsZipValid("96000", "American Samoa"));
- EXPECT_TRUE(IsZipValid("85000", "AZ"));
- EXPECT_TRUE(IsZipValid("86000", "Arizona"));
- EXPECT_TRUE(IsZipValid("90000", "CA"));
- EXPECT_TRUE(IsZipValid("96000", "California"));
- EXPECT_TRUE(IsZipValid("80000", "CO"));
- EXPECT_TRUE(IsZipValid("81000", "Colorado"));
- EXPECT_TRUE(IsZipValid("06000", "CT"));
- EXPECT_TRUE(IsZipValid("06000", "Connecticut"));
- EXPECT_TRUE(IsZipValid("20000", "DC"));
- EXPECT_TRUE(IsZipValid("20000", "District of Columbia"));
- EXPECT_TRUE(IsZipValid("19000", "DE"));
- EXPECT_TRUE(IsZipValid("19000", "Delaware"));
- EXPECT_TRUE(IsZipValid("32000", "FL"));
- EXPECT_TRUE(IsZipValid("34000", "Florida"));
- EXPECT_TRUE(IsZipValid("96000", "FM"));
- EXPECT_TRUE(IsZipValid("96000", "Federated States of Micronesia"));
- EXPECT_TRUE(IsZipValid("30000", "GA"));
- EXPECT_TRUE(IsZipValid("31000", "Georgia"));
- EXPECT_TRUE(IsZipValid("96000", "GU"));
- EXPECT_TRUE(IsZipValid("96000", "Guam"));
- EXPECT_TRUE(IsZipValid("96000", "HI"));
- EXPECT_TRUE(IsZipValid("96000", "Hawaii"));
- EXPECT_TRUE(IsZipValid("50000", "IA"));
- EXPECT_TRUE(IsZipValid("52000", "Iowa"));
- EXPECT_TRUE(IsZipValid("83000", "ID"));
- EXPECT_TRUE(IsZipValid("83000", "Idaho"));
- EXPECT_TRUE(IsZipValid("60000", "IL"));
- EXPECT_TRUE(IsZipValid("62000", "Illinois"));
- EXPECT_TRUE(IsZipValid("46000", "IN"));
- EXPECT_TRUE(IsZipValid("47000", "Indiana"));
- EXPECT_TRUE(IsZipValid("66000", "KS"));
- EXPECT_TRUE(IsZipValid("67000", "Kansas"));
- EXPECT_TRUE(IsZipValid("40000", "KY"));
- EXPECT_TRUE(IsZipValid("42000", "Kentucky"));
- EXPECT_TRUE(IsZipValid("70000", "LA"));
- EXPECT_TRUE(IsZipValid("71000", "Louisiana"));
- EXPECT_TRUE(IsZipValid("01000", "MA"));
- EXPECT_TRUE(IsZipValid("02000", "Massachusetts"));
- EXPECT_TRUE(IsZipValid("20000", "MD"));
- EXPECT_TRUE(IsZipValid("21000", "Maryland"));
- EXPECT_TRUE(IsZipValid("03000", "ME"));
- EXPECT_TRUE(IsZipValid("04000", "Maine"));
- EXPECT_TRUE(IsZipValid("96000", "MH"));
- EXPECT_TRUE(IsZipValid("96000", "Marshall Islands"));
- EXPECT_TRUE(IsZipValid("48000", "MI"));
- EXPECT_TRUE(IsZipValid("49000", "Michigan"));
- EXPECT_TRUE(IsZipValid("55000", "MN"));
- EXPECT_TRUE(IsZipValid("56000", "Minnesota"));
- EXPECT_TRUE(IsZipValid("63000", "MO"));
- EXPECT_TRUE(IsZipValid("65000", "Missouri"));
- EXPECT_TRUE(IsZipValid("96000", "MP"));
- EXPECT_TRUE(IsZipValid("96000", "Northern Mariana Islands"));
- EXPECT_TRUE(IsZipValid("38000", "MS"));
- EXPECT_TRUE(IsZipValid("39000", "Mississippi"));
- EXPECT_TRUE(IsZipValid("55000", "MT"));
- EXPECT_TRUE(IsZipValid("56000", "Montana"));
- EXPECT_TRUE(IsZipValid("27000", "NC"));
- EXPECT_TRUE(IsZipValid("28000", "North Carolina"));
- EXPECT_TRUE(IsZipValid("58000", "ND"));
- EXPECT_TRUE(IsZipValid("58000", "North Dakota"));
- EXPECT_TRUE(IsZipValid("68000", "NE"));
- EXPECT_TRUE(IsZipValid("69000", "Nebraska"));
- EXPECT_TRUE(IsZipValid("03000", "NH"));
- EXPECT_TRUE(IsZipValid("04000", "New Hampshire"));
- EXPECT_TRUE(IsZipValid("07000", "NJ"));
- EXPECT_TRUE(IsZipValid("08000", "New Jersey"));
- EXPECT_TRUE(IsZipValid("87000", "NM"));
- EXPECT_TRUE(IsZipValid("88000", "New Mexico"));
- EXPECT_TRUE(IsZipValid("88000", "NV"));
- EXPECT_TRUE(IsZipValid("89000", "Nevada"));
- EXPECT_TRUE(IsZipValid("10000", "NY"));
- EXPECT_TRUE(IsZipValid("14000", "New York"));
- EXPECT_TRUE(IsZipValid("43000", "OH"));
- EXPECT_TRUE(IsZipValid("45000", "Ohio"));
- EXPECT_TRUE(IsZipValid("73000", "OK"));
- EXPECT_TRUE(IsZipValid("74000", "Oklahoma"));
- EXPECT_TRUE(IsZipValid("97000", "OR"));
- EXPECT_TRUE(IsZipValid("97000", "Oregon"));
- EXPECT_TRUE(IsZipValid("15000", "PA"));
- EXPECT_TRUE(IsZipValid("19000", "Pennsylvania"));
- EXPECT_TRUE(IsZipValid("06000", "PR"));
- EXPECT_TRUE(IsZipValid("06000", "Puerto Rico"));
- EXPECT_TRUE(IsZipValid("96000", "PW"));
- EXPECT_TRUE(IsZipValid("96000", "Palau"));
- EXPECT_TRUE(IsZipValid("02000", "RI"));
- EXPECT_TRUE(IsZipValid("02000", "Rhode Island"));
- EXPECT_TRUE(IsZipValid("29000", "SC"));
- EXPECT_TRUE(IsZipValid("29000", "South Carolina"));
- EXPECT_TRUE(IsZipValid("57000", "SD"));
- EXPECT_TRUE(IsZipValid("57000", "South Dakota"));
- EXPECT_TRUE(IsZipValid("37000", "TN"));
- EXPECT_TRUE(IsZipValid("38000", "Tennessee"));
- EXPECT_TRUE(IsZipValid("75000", "TX"));
- EXPECT_TRUE(IsZipValid("79000", "Texas"));
- EXPECT_TRUE(IsZipValid("84000", "UT"));
- EXPECT_TRUE(IsZipValid("84000", "Utah"));
- EXPECT_TRUE(IsZipValid("22000", "VA"));
- EXPECT_TRUE(IsZipValid("24000", "Virginia"));
- EXPECT_TRUE(IsZipValid("06000", "VI"));
- EXPECT_TRUE(IsZipValid("09000", "Virgin Islands"));
- EXPECT_TRUE(IsZipValid("05000", "VT"));
- EXPECT_TRUE(IsZipValid("05000", "Vermont"));
- EXPECT_TRUE(IsZipValid("98000", "WA"));
- EXPECT_TRUE(IsZipValid("99000", "Washington"));
- EXPECT_TRUE(IsZipValid("53000", "WI"));
- EXPECT_TRUE(IsZipValid("54000", "Wisconsin"));
- EXPECT_TRUE(IsZipValid("24000", "WV"));
- EXPECT_TRUE(IsZipValid("26000", "West Virginia"));
- EXPECT_TRUE(IsZipValid("82000", "WY"));
- EXPECT_TRUE(IsZipValid("83000", "Wyoming"));
-}
-
-TEST_F(AddressParserTest, LocationName) {
- EXPECT_FALSE(IsLocationName("str-eet"));
- EXPECT_FALSE(IsLocationName("somewhere"));
-
- // Test all supported street names and expected plural cases.
- EXPECT_TRUE(IsLocationName("alley"));
- EXPECT_TRUE(IsLocationName("annex"));
- EXPECT_TRUE(IsLocationName("arcade"));
- EXPECT_TRUE(IsLocationName("ave."));
- EXPECT_TRUE(IsLocationName("avenue"));
- EXPECT_TRUE(IsLocationName("alameda"));
- EXPECT_TRUE(IsLocationName("bayou"));
- EXPECT_TRUE(IsLocationName("beach"));
- EXPECT_TRUE(IsLocationName("bend"));
- EXPECT_TRUE(IsLocationName("bluff"));
- EXPECT_TRUE(IsLocationName("bluffs"));
- EXPECT_TRUE(IsLocationName("bottom"));
- EXPECT_TRUE(IsLocationName("boulevard"));
- EXPECT_TRUE(IsLocationName("branch"));
- EXPECT_TRUE(IsLocationName("bridge"));
- EXPECT_TRUE(IsLocationName("brook"));
- EXPECT_TRUE(IsLocationName("brooks"));
- EXPECT_TRUE(IsLocationName("burg"));
- EXPECT_TRUE(IsLocationName("burgs"));
- EXPECT_TRUE(IsLocationName("bypass"));
- EXPECT_TRUE(IsLocationName("broadway"));
- EXPECT_TRUE(IsLocationName("camino"));
- EXPECT_TRUE(IsLocationName("camp"));
- EXPECT_TRUE(IsLocationName("canyon"));
- EXPECT_TRUE(IsLocationName("cape"));
- EXPECT_TRUE(IsLocationName("causeway"));
- EXPECT_TRUE(IsLocationName("center"));
- EXPECT_TRUE(IsLocationName("centers"));
- EXPECT_TRUE(IsLocationName("circle"));
- EXPECT_TRUE(IsLocationName("circles"));
- EXPECT_TRUE(IsLocationName("cliff"));
- EXPECT_TRUE(IsLocationName("cliffs"));
- EXPECT_TRUE(IsLocationName("club"));
- EXPECT_TRUE(IsLocationName("common"));
- EXPECT_TRUE(IsLocationName("corner"));
- EXPECT_TRUE(IsLocationName("corners"));
- EXPECT_TRUE(IsLocationName("course"));
- EXPECT_TRUE(IsLocationName("court"));
- EXPECT_TRUE(IsLocationName("courts"));
- EXPECT_TRUE(IsLocationName("cove"));
- EXPECT_TRUE(IsLocationName("coves"));
- EXPECT_TRUE(IsLocationName("creek"));
- EXPECT_TRUE(IsLocationName("crescent"));
- EXPECT_TRUE(IsLocationName("crest"));
- EXPECT_TRUE(IsLocationName("crossing"));
- EXPECT_TRUE(IsLocationName("crossroad"));
- EXPECT_TRUE(IsLocationName("curve"));
- EXPECT_TRUE(IsLocationName("circulo"));
- EXPECT_TRUE(IsLocationName("dale"));
- EXPECT_TRUE(IsLocationName("dam"));
- EXPECT_TRUE(IsLocationName("divide"));
- EXPECT_TRUE(IsLocationName("drive"));
- EXPECT_TRUE(IsLocationName("drives"));
- EXPECT_TRUE(IsLocationName("estate"));
- EXPECT_TRUE(IsLocationName("estates"));
- EXPECT_TRUE(IsLocationName("expressway"));
- EXPECT_TRUE(IsLocationName("extension"));
- EXPECT_TRUE(IsLocationName("extensions"));
- EXPECT_TRUE(IsLocationName("fall"));
- EXPECT_TRUE(IsLocationName("falls"));
- EXPECT_TRUE(IsLocationName("ferry"));
- EXPECT_TRUE(IsLocationName("field"));
- EXPECT_TRUE(IsLocationName("fields"));
- EXPECT_TRUE(IsLocationName("flat"));
- EXPECT_TRUE(IsLocationName("flats"));
- EXPECT_TRUE(IsLocationName("ford"));
- EXPECT_TRUE(IsLocationName("fords"));
- EXPECT_TRUE(IsLocationName("forest"));
- EXPECT_TRUE(IsLocationName("forge"));
- EXPECT_TRUE(IsLocationName("forges"));
- EXPECT_TRUE(IsLocationName("fork"));
- EXPECT_TRUE(IsLocationName("forks"));
- EXPECT_TRUE(IsLocationName("fort"));
- EXPECT_TRUE(IsLocationName("freeway"));
- EXPECT_TRUE(IsLocationName("garden"));
- EXPECT_TRUE(IsLocationName("gardens"));
- EXPECT_TRUE(IsLocationName("gateway"));
- EXPECT_TRUE(IsLocationName("glen"));
- EXPECT_TRUE(IsLocationName("glens"));
- EXPECT_TRUE(IsLocationName("green"));
- EXPECT_TRUE(IsLocationName("greens"));
- EXPECT_TRUE(IsLocationName("grove"));
- EXPECT_TRUE(IsLocationName("groves"));
- EXPECT_TRUE(IsLocationName("harbor"));
- EXPECT_TRUE(IsLocationName("harbors"));
- EXPECT_TRUE(IsLocationName("haven"));
- EXPECT_TRUE(IsLocationName("heights"));
- EXPECT_TRUE(IsLocationName("highway"));
- EXPECT_TRUE(IsLocationName("hill"));
- EXPECT_TRUE(IsLocationName("hills"));
- EXPECT_TRUE(IsLocationName("hollow"));
- EXPECT_TRUE(IsLocationName("inlet"));
- EXPECT_TRUE(IsLocationName("island"));
- EXPECT_TRUE(IsLocationName("islands"));
- EXPECT_TRUE(IsLocationName("isle"));
- EXPECT_TRUE(IsLocationName("junction"));
- EXPECT_TRUE(IsLocationName("junctions"));
- EXPECT_TRUE(IsLocationName("key"));
- EXPECT_TRUE(IsLocationName("keys"));
- EXPECT_TRUE(IsLocationName("knoll"));
- EXPECT_TRUE(IsLocationName("knolls"));
- EXPECT_TRUE(IsLocationName("lake"));
- EXPECT_TRUE(IsLocationName("lakes"));
- EXPECT_TRUE(IsLocationName("land"));
- EXPECT_TRUE(IsLocationName("landing"));
- EXPECT_TRUE(IsLocationName("lane"));
- EXPECT_TRUE(IsLocationName("light"));
- EXPECT_TRUE(IsLocationName("lights"));
- EXPECT_TRUE(IsLocationName("loaf"));
- EXPECT_TRUE(IsLocationName("lock"));
- EXPECT_TRUE(IsLocationName("locks"));
- EXPECT_TRUE(IsLocationName("lodge"));
- EXPECT_TRUE(IsLocationName("loop"));
- EXPECT_TRUE(IsLocationName("mall"));
- EXPECT_TRUE(IsLocationName("manor"));
- EXPECT_TRUE(IsLocationName("manors"));
- EXPECT_TRUE(IsLocationName("meadow"));
- EXPECT_TRUE(IsLocationName("meadows"));
- EXPECT_TRUE(IsLocationName("mews"));
- EXPECT_TRUE(IsLocationName("mill"));
- EXPECT_TRUE(IsLocationName("mills"));
- EXPECT_TRUE(IsLocationName("mission"));
- EXPECT_TRUE(IsLocationName("motorway"));
- EXPECT_TRUE(IsLocationName("mount"));
- EXPECT_TRUE(IsLocationName("mountain"));
- EXPECT_TRUE(IsLocationName("mountains"));
- EXPECT_TRUE(IsLocationName("neck"));
- EXPECT_TRUE(IsLocationName("orchard"));
- EXPECT_TRUE(IsLocationName("oval"));
- EXPECT_TRUE(IsLocationName("overpass"));
- EXPECT_TRUE(IsLocationName("park"));
- EXPECT_TRUE(IsLocationName("parks"));
- EXPECT_TRUE(IsLocationName("parkway"));
- EXPECT_TRUE(IsLocationName("parkways"));
- EXPECT_TRUE(IsLocationName("pass"));
- EXPECT_TRUE(IsLocationName("passage"));
- EXPECT_TRUE(IsLocationName("path"));
- EXPECT_TRUE(IsLocationName("pike"));
- EXPECT_TRUE(IsLocationName("pine"));
- EXPECT_TRUE(IsLocationName("pines"));
- EXPECT_TRUE(IsLocationName("plain"));
- EXPECT_TRUE(IsLocationName("plains"));
- EXPECT_TRUE(IsLocationName("plaza"));
- EXPECT_TRUE(IsLocationName("point"));
- EXPECT_TRUE(IsLocationName("points"));
- EXPECT_TRUE(IsLocationName("port"));
- EXPECT_TRUE(IsLocationName("ports"));
- EXPECT_TRUE(IsLocationName("prairie"));
- EXPECT_TRUE(IsLocationName("privada"));
- EXPECT_TRUE(IsLocationName("radial"));
- EXPECT_TRUE(IsLocationName("ramp"));
- EXPECT_TRUE(IsLocationName("ranch"));
- EXPECT_TRUE(IsLocationName("rapid"));
- EXPECT_TRUE(IsLocationName("rapids"));
- EXPECT_TRUE(IsLocationName("rd"));
- EXPECT_TRUE(IsLocationName("rd."));
- EXPECT_TRUE(IsLocationName("rest"));
- EXPECT_TRUE(IsLocationName("ridge"));
- EXPECT_TRUE(IsLocationName("ridges"));
- EXPECT_TRUE(IsLocationName("river"));
- EXPECT_TRUE(IsLocationName("road"));
- EXPECT_TRUE(IsLocationName("roads"));
- EXPECT_TRUE(IsLocationName("route"));
- EXPECT_TRUE(IsLocationName("row"));
- EXPECT_TRUE(IsLocationName("rue"));
- EXPECT_TRUE(IsLocationName("run"));
- EXPECT_TRUE(IsLocationName("shoal"));
- EXPECT_TRUE(IsLocationName("shoals"));
- EXPECT_TRUE(IsLocationName("shore"));
- EXPECT_TRUE(IsLocationName("shores"));
- EXPECT_TRUE(IsLocationName("skyway"));
- EXPECT_TRUE(IsLocationName("spring"));
- EXPECT_TRUE(IsLocationName("springs"));
- EXPECT_TRUE(IsLocationName("spur"));
- EXPECT_TRUE(IsLocationName("spurs"));
- EXPECT_TRUE(IsLocationName("square"));
- EXPECT_TRUE(IsLocationName("squares"));
- EXPECT_TRUE(IsLocationName("station"));
- EXPECT_TRUE(IsLocationName("stravenue"));
- EXPECT_TRUE(IsLocationName("stream"));
- EXPECT_TRUE(IsLocationName("st."));
- EXPECT_TRUE(IsLocationName("street"));
- EXPECT_TRUE(IsLocationName("streets"));
- EXPECT_TRUE(IsLocationName("summit"));
- EXPECT_TRUE(IsLocationName("speedway"));
- EXPECT_TRUE(IsLocationName("terrace"));
- EXPECT_TRUE(IsLocationName("throughway"));
- EXPECT_TRUE(IsLocationName("trace"));
- EXPECT_TRUE(IsLocationName("track"));
- EXPECT_TRUE(IsLocationName("trafficway"));
- EXPECT_TRUE(IsLocationName("trail"));
- EXPECT_TRUE(IsLocationName("tunnel"));
- EXPECT_TRUE(IsLocationName("turnpike"));
- EXPECT_TRUE(IsLocationName("underpass"));
- EXPECT_TRUE(IsLocationName("union"));
- EXPECT_TRUE(IsLocationName("unions"));
- EXPECT_TRUE(IsLocationName("valley"));
- EXPECT_TRUE(IsLocationName("valleys"));
- EXPECT_TRUE(IsLocationName("viaduct"));
- EXPECT_TRUE(IsLocationName("view"));
- EXPECT_TRUE(IsLocationName("views"));
- EXPECT_TRUE(IsLocationName("village"));
- EXPECT_TRUE(IsLocationName("villages"));
- EXPECT_TRUE(IsLocationName("ville"));
- EXPECT_TRUE(IsLocationName("vista"));
- EXPECT_TRUE(IsLocationName("walk"));
- EXPECT_TRUE(IsLocationName("walks"));
- EXPECT_TRUE(IsLocationName("wall"));
- EXPECT_TRUE(IsLocationName("way"));
- EXPECT_TRUE(IsLocationName("ways"));
- EXPECT_TRUE(IsLocationName("well"));
- EXPECT_TRUE(IsLocationName("wells"));
- EXPECT_TRUE(IsLocationName("xing"));
- EXPECT_TRUE(IsLocationName("xrd"));
-}
-
-TEST_F(AddressParserTest, NumberPrefixCases) {
- EXPECT_EQ(FindAddress("Cafe 21\n750 Fifth Ave. San Diego, California 92101"),
- "750 Fifth Ave. San Diego, California 92101");
- EXPECT_EQ(FindAddress(
- "Century City 15\n 10250 Santa Monica Boulevard Los Angeles, CA 90067"),
- "10250 Santa Monica Boulevard Los Angeles, CA 90067");
- EXPECT_EQ(FindAddress("123 45\n67 My Street, Somewhere, NY 10000"),
- "67 My Street, Somewhere, NY 10000");
- EXPECT_TRUE(IsAddress("123 4th Avenue, Somewhere in NY 10000"));
-}
-
-TEST_F(AddressParserTest, FullAddress) {
- // Test US Google corporate addresses. Expects a full string match.
- EXPECT_TRUE(IsAddress("1600 Amphitheatre Parkway Mountain View, CA 94043"));
- EXPECT_TRUE(IsAddress("201 S. Division St. Suite 500 Ann Arbor, MI 48104"));
- EXPECT_TRUE(ContainsAddress(
- "Millennium at Midtown 10 10th Street NE Suite 600 Atlanta, GA 30309"));
- EXPECT_TRUE(IsAddress(
- "9606 North MoPac Expressway Suite 400 Austin, TX 78759"));
- EXPECT_TRUE(IsAddress("2590 Pearl Street Suite 100 Boulder, CO 80302"));
- EXPECT_TRUE(IsAddress("5 Cambridge Center, Floors 3-6 Cambridge, MA 02142"));
- EXPECT_TRUE(IsAddress("410 Market St Suite 415 Chapel Hill, NC 27516"));
- EXPECT_TRUE(IsAddress("20 West Kinzie St. Chicago, IL 60654"));
- EXPECT_TRUE(IsAddress("114 Willits Street Birmingham, MI 48009"));
- EXPECT_TRUE(IsAddress("19540 Jamboree Road 2nd Floor Irvine, CA 92612"));
- EXPECT_TRUE(IsAddress("747 6th Street South, Kirkland, WA 98033"));
- EXPECT_TRUE(IsAddress("301 S. Blount St. Suite 301 Madison, WI 53703"));
- EXPECT_TRUE(IsAddress("76 Ninth Avenue 4th Floor New York, NY 10011"));
- EXPECT_TRUE(ContainsAddress(
- "Chelsea Markset Space, 75 Ninth Avenue 2nd and 4th Floors New York, \
- NY 10011"));
- EXPECT_TRUE(IsAddress("6425 Penn Ave. Suite 700 Pittsburgh, PA 15206"));
- EXPECT_TRUE(IsAddress("1818 Library Street Suite 400 Reston, VA 20190"));
- EXPECT_TRUE(IsAddress("345 Spear Street Floors 2-4 San Francisco, CA 94105"));
- EXPECT_TRUE(IsAddress("604 Arizona Avenue Santa Monica, CA 90401"));
- EXPECT_TRUE(IsAddress("651 N. 34th St. Seattle, WA 98103"));
- EXPECT_TRUE(IsAddress(
- "1101 New York Avenue, N.W. Second Floor Washington, DC 20005"));
-
- // Other tests.
- EXPECT_TRUE(IsAddress("57th Street and Lake Shore Drive\nChicago, IL 60637"));
- EXPECT_TRUE(IsAddress("308 Congress Street Boston, MA 02210"));
- EXPECT_TRUE(ContainsAddress(
- "Central Park West at 79th Street, New York, NY, 10024-5192"));
- EXPECT_TRUE(ContainsAddress(
- "Lincoln Park | 100 34th Avenue • San Francisco, CA 94121 | 41575036"));
-
- EXPECT_EQ(FindAddress("Lorem ipsum dolor sit amet, consectetur adipisicing " \
- "elit, sed do 1600 Amphitheatre Parkway Mountain View, CA 94043 " \
- "eiusmod tempor incididunt ut labore et dolore magna aliqua."),
- "1600 Amphitheatre Parkway Mountain View, CA 94043");
-
- EXPECT_EQ(FindAddress("2590 Pearl Street Suite 100 Boulder, CO 80302 6425 " \
- "Penn Ave. Suite 700 Pittsburgh, PA 15206"),
- "2590 Pearl Street Suite 100 Boulder, CO 80302");
-
- EXPECT_TRUE(IsAddress("5400 Preston Oaks Rd Dallas TX 75254"));
- EXPECT_TRUE(IsAddress("5400 Preston Oaks Road Dallas TX 75254"));
- EXPECT_TRUE(IsAddress("5400 Preston Oaks Ave Dallas TX 75254"));
-
- EXPECT_TRUE(ContainsAddress(
- "住所は 1600 Amphitheatre Parkway Mountain View, CA 94043 です。"));
-
- EXPECT_FALSE(ContainsAddress("1 st. too-short, CA 90000"));
- EXPECT_TRUE(ContainsAddress("1 st. long enough, CA 90000"));
-
- EXPECT_TRUE(ContainsAddress("1 st. some city in al 35000"));
- EXPECT_FALSE(ContainsAddress("1 book st Aquinas et al 35000"));
-
- EXPECT_FALSE(ContainsAddress("1 this comes too late: street, CA 90000"));
- EXPECT_TRUE(ContainsAddress("1 this is ok: street, CA 90000"));
-
- EXPECT_FALSE(ContainsAddress(
- "1 street I love verbosity, so I'm writing an address with too many " \
- "words CA 90000"));
- EXPECT_TRUE(ContainsAddress("1 street 2 3 4 5 6 7 8 9 10 11 12, CA 90000"));
-
- EXPECT_TRUE(IsAddress("79th Street 1st Floor New York City, NY 10024-5192"));
-
- EXPECT_FALSE(ContainsAddress("123 Fake Street, Springfield, Springfield"));
- EXPECT_FALSE(ContainsAddress("999 Street Avenue, City, ZZ 98765"));
- EXPECT_FALSE(ContainsAddress("76 Here be dragons, CA 94043"));
- EXPECT_FALSE(ContainsAddress("1 This, has, too* many, lines, to, be* valid"));
- EXPECT_FALSE(ContainsAddress(
- "1 Supercalifragilisticexpialidocious is too long, CA 90000"));
- EXPECT_FALSE(ContainsAddress(""));
-}
-
-TEST_F(AddressParserTest, FullAddressWithoutZipCode) {
- EXPECT_TRUE(IsAddress("1600 Amphitheatre Parkway Mountain View, CA"));
- EXPECT_TRUE(IsAddress("201 S. Division St. Suite 500 Ann Arbor, MI"));
-}
diff --git a/chromium/content/common/android/gin_java_bridge_value.cc b/chromium/content/common/android/gin_java_bridge_value.cc
index ed3fd7e4c7b..e745ce81bca 100644
--- a/chromium/content/common/android/gin_java_bridge_value.cc
+++ b/chromium/content/common/android/gin_java_bridge_value.cc
@@ -26,13 +26,13 @@ struct Header : public base::Pickle::Header {
}
// static
-std::unique_ptr<base::BinaryValue> GinJavaBridgeValue::CreateUndefinedValue() {
+std::unique_ptr<base::Value> GinJavaBridgeValue::CreateUndefinedValue() {
GinJavaBridgeValue gin_value(TYPE_UNDEFINED);
return gin_value.SerializeToBinaryValue();
}
// static
-std::unique_ptr<base::BinaryValue> GinJavaBridgeValue::CreateNonFiniteValue(
+std::unique_ptr<base::Value> GinJavaBridgeValue::CreateNonFiniteValue(
float in_value) {
GinJavaBridgeValue gin_value(TYPE_NONFINITE);
gin_value.pickle_.WriteFloat(in_value);
@@ -40,13 +40,13 @@ std::unique_ptr<base::BinaryValue> GinJavaBridgeValue::CreateNonFiniteValue(
}
// static
-std::unique_ptr<base::BinaryValue> GinJavaBridgeValue::CreateNonFiniteValue(
+std::unique_ptr<base::Value> GinJavaBridgeValue::CreateNonFiniteValue(
double in_value) {
return CreateNonFiniteValue(static_cast<float>(in_value));
}
// static
-std::unique_ptr<base::BinaryValue> GinJavaBridgeValue::CreateObjectIDValue(
+std::unique_ptr<base::Value> GinJavaBridgeValue::CreateObjectIDValue(
int32_t in_value) {
GinJavaBridgeValue gin_value(TYPE_OBJECT_ID);
gin_value.pickle_.WriteInt(in_value);
@@ -111,14 +111,13 @@ GinJavaBridgeValue::GinJavaBridgeValue(Type type) :
header->type = type;
}
-GinJavaBridgeValue::GinJavaBridgeValue(const base::BinaryValue* value)
+GinJavaBridgeValue::GinJavaBridgeValue(const base::Value* value)
: pickle_(value->GetBuffer(), value->GetSize()) {
DCHECK(ContainsGinJavaBridgeValue(value));
}
-std::unique_ptr<base::BinaryValue>
-GinJavaBridgeValue::SerializeToBinaryValue() {
- return base::BinaryValue::CreateWithCopiedBuffer(
+std::unique_ptr<base::Value> GinJavaBridgeValue::SerializeToBinaryValue() {
+ return base::Value::CreateWithCopiedBuffer(
reinterpret_cast<const char*>(pickle_.data()), pickle_.size());
}
diff --git a/chromium/content/common/android/gin_java_bridge_value.h b/chromium/content/common/android/gin_java_bridge_value.h
index 1cd92d8b767..167123a9607 100644
--- a/chromium/content/common/android/gin_java_bridge_value.h
+++ b/chromium/content/common/android/gin_java_bridge_value.h
@@ -16,7 +16,7 @@
// In Java Bridge, we need to pass some kinds of values that can't
// be put into base::Value. And since base::Value is not extensible,
-// we transfer these special values via base::BinaryValue.
+// we transfer these special values via base::Value.
namespace content {
@@ -34,13 +34,12 @@ class GinJavaBridgeValue {
};
// Serialization
- CONTENT_EXPORT static std::unique_ptr<base::BinaryValue>
- CreateUndefinedValue();
- CONTENT_EXPORT static std::unique_ptr<base::BinaryValue> CreateNonFiniteValue(
+ CONTENT_EXPORT static std::unique_ptr<base::Value> CreateUndefinedValue();
+ CONTENT_EXPORT static std::unique_ptr<base::Value> CreateNonFiniteValue(
float in_value);
- CONTENT_EXPORT static std::unique_ptr<base::BinaryValue> CreateNonFiniteValue(
+ CONTENT_EXPORT static std::unique_ptr<base::Value> CreateNonFiniteValue(
double in_value);
- CONTENT_EXPORT static std::unique_ptr<base::BinaryValue> CreateObjectIDValue(
+ CONTENT_EXPORT static std::unique_ptr<base::Value> CreateObjectIDValue(
int32_t in_value);
// De-serialization
@@ -57,8 +56,8 @@ class GinJavaBridgeValue {
private:
explicit GinJavaBridgeValue(Type type);
- explicit GinJavaBridgeValue(const base::BinaryValue* value);
- std::unique_ptr<base::BinaryValue> SerializeToBinaryValue();
+ explicit GinJavaBridgeValue(const base::Value* value);
+ std::unique_ptr<base::Value> SerializeToBinaryValue();
base::Pickle pickle_;
diff --git a/chromium/content/common/android/gin_java_bridge_value_unittest.cc b/chromium/content/common/android/gin_java_bridge_value_unittest.cc
index 0dc27d24f5c..bf5f613ccea 100644
--- a/chromium/content/common/android/gin_java_bridge_value_unittest.cc
+++ b/chromium/content/common/android/gin_java_bridge_value_unittest.cc
@@ -20,7 +20,7 @@ TEST_F(GinJavaBridgeValueTest, BasicValues) {
float native_float;
int32_t native_object_id;
- std::unique_ptr<base::BinaryValue> undefined(
+ std::unique_ptr<base::Value> undefined(
GinJavaBridgeValue::CreateUndefinedValue());
ASSERT_TRUE(undefined.get());
EXPECT_TRUE(GinJavaBridgeValue::ContainsGinJavaBridgeValue(undefined.get()));
@@ -32,7 +32,7 @@ TEST_F(GinJavaBridgeValueTest, BasicValues) {
EXPECT_FALSE(undefined_value->GetAsNonFinite(&native_float));
EXPECT_FALSE(undefined_value->GetAsObjectID(&native_object_id));
- std::unique_ptr<base::BinaryValue> float_infinity(
+ std::unique_ptr<base::Value> float_infinity(
GinJavaBridgeValue::CreateNonFiniteValue(
std::numeric_limits<float>::infinity()));
ASSERT_TRUE(float_infinity.get());
@@ -47,7 +47,7 @@ TEST_F(GinJavaBridgeValueTest, BasicValues) {
EXPECT_FALSE(undefined_value->GetAsObjectID(&native_object_id));
- std::unique_ptr<base::BinaryValue> double_infinity(
+ std::unique_ptr<base::Value> double_infinity(
GinJavaBridgeValue::CreateNonFiniteValue(
std::numeric_limits<double>::infinity()));
ASSERT_TRUE(double_infinity.get());
@@ -63,7 +63,7 @@ TEST_F(GinJavaBridgeValueTest, BasicValues) {
EXPECT_FALSE(undefined_value->GetAsObjectID(&native_object_id));
- std::unique_ptr<base::BinaryValue> object_id(
+ std::unique_ptr<base::Value> object_id(
GinJavaBridgeValue::CreateObjectIDValue(42));
ASSERT_TRUE(object_id.get());
EXPECT_TRUE(GinJavaBridgeValue::ContainsGinJavaBridgeValue(object_id.get()));
@@ -83,9 +83,8 @@ TEST_F(GinJavaBridgeValueTest, BrokenValues) {
GinJavaBridgeValue::ContainsGinJavaBridgeValue(non_binary.get()));
const char dummy_data[] = "\000\001\002\003\004\005\006\007\010\011\012\013";
- std::unique_ptr<base::BinaryValue> broken_binary(
- base::BinaryValue::CreateWithCopiedBuffer(dummy_data,
- sizeof(dummy_data)));
+ std::unique_ptr<base::Value> broken_binary(
+ base::Value::CreateWithCopiedBuffer(dummy_data, sizeof(dummy_data)));
EXPECT_FALSE(
GinJavaBridgeValue::ContainsGinJavaBridgeValue(broken_binary.get()));
}
diff --git a/chromium/content/common/associated_interface_provider_impl.cc b/chromium/content/common/associated_interface_provider_impl.cc
index 7284e43549e..647ba6a1614 100644
--- a/chromium/content/common/associated_interface_provider_impl.cc
+++ b/chromium/content/common/associated_interface_provider_impl.cc
@@ -13,7 +13,7 @@ class AssociatedInterfaceProviderImpl::LocalProvider
explicit LocalProvider(mojom::AssociatedInterfaceProviderAssociatedPtr* proxy)
: associated_interface_provider_binding_(this) {
associated_interface_provider_binding_.Bind(
- mojo::MakeRequestForTesting(proxy));
+ mojo::MakeIsolatedRequest(proxy));
}
~LocalProvider() override {}
diff --git a/chromium/content/common/background_fetch/DEPS b/chromium/content/common/background_fetch/DEPS
new file mode 100644
index 00000000000..c0c3af0fbea
--- /dev/null
+++ b/chromium/content/common/background_fetch/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+third_party/WebKit/public/platform/modules/background_fetch/background_fetch.mojom.h",
+]
diff --git a/chromium/content/common/background_fetch/OWNERS b/chromium/content/common/background_fetch/OWNERS
new file mode 100644
index 00000000000..37596626d80
--- /dev/null
+++ b/chromium/content/common/background_fetch/OWNERS
@@ -0,0 +1,10 @@
+file://content/browser/background_fetch/OWNERS
+
+per-file *_struct_traits*.*=set noparent
+per-file *_struct_traits*.*=file://ipc/SECURITY_OWNERS
+
+per-file *.typemap=set noparent
+per-file *.typemap=file://ipc/SECURITY_OWNERS
+
+# TEAM: platform-capabilities@chromium.org
+# COMPONENT: Blink>BackgroundFetch
diff --git a/chromium/content/common/background_fetch/background_fetch_struct_traits.cc b/chromium/content/common/background_fetch/background_fetch_struct_traits.cc
new file mode 100644
index 00000000000..c0f5f30e602
--- /dev/null
+++ b/chromium/content/common/background_fetch/background_fetch_struct_traits.cc
@@ -0,0 +1,59 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/background_fetch/background_fetch_struct_traits.h"
+
+#include "content/common/service_worker/service_worker_event_dispatcher.mojom.h"
+#include "content/common/service_worker/service_worker_fetch_request_struct_traits.h"
+#include "content/common/service_worker/service_worker_messages.h"
+#include "mojo/public/cpp/bindings/array_data_view.h"
+
+namespace mojo {
+
+// static
+bool StructTraits<blink::mojom::BackgroundFetchOptionsDataView,
+ content::BackgroundFetchOptions>::
+ Read(blink::mojom::BackgroundFetchOptionsDataView data,
+ content::BackgroundFetchOptions* options) {
+ if (!data.ReadIcons(&options->icons) || !data.ReadTitle(&options->title))
+ return false;
+
+ options->total_download_size = data.total_download_size();
+ return true;
+}
+
+// static
+bool StructTraits<blink::mojom::BackgroundFetchRegistrationDataView,
+ content::BackgroundFetchRegistration>::
+ Read(blink::mojom::BackgroundFetchRegistrationDataView data,
+ content::BackgroundFetchRegistration* registration) {
+ if (!data.ReadTag(&registration->tag) ||
+ !data.ReadIcons(&registration->icons) ||
+ !data.ReadTitle(&registration->title)) {
+ return false;
+ }
+
+ registration->total_download_size = data.total_download_size();
+ return true;
+}
+
+// static
+bool StructTraits<content::mojom::BackgroundFetchSettledFetchDataView,
+ content::BackgroundFetchSettledFetch>::
+ Read(content::mojom::BackgroundFetchSettledFetchDataView data,
+ content::BackgroundFetchSettledFetch* fetch) {
+ return data.ReadRequest(&fetch->request) &&
+ data.ReadResponse(&fetch->response);
+}
+
+// static
+bool StructTraits<
+ blink::mojom::IconDefinitionDataView,
+ content::IconDefinition>::Read(blink::mojom::IconDefinitionDataView data,
+ content::IconDefinition* definition) {
+ return data.ReadSrc(&definition->src) && data.ReadSizes(&definition->sizes) &&
+ data.ReadType(&definition->type);
+}
+
+} // namespace mojo
diff --git a/chromium/content/common/background_fetch/background_fetch_struct_traits.h b/chromium/content/common/background_fetch/background_fetch_struct_traits.h
new file mode 100644
index 00000000000..d1d3ee3549d
--- /dev/null
+++ b/chromium/content/common/background_fetch/background_fetch_struct_traits.h
@@ -0,0 +1,105 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_STRUCT_TRAITS_H_
+#define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_STRUCT_TRAITS_H_
+
+#include <string>
+#include <vector>
+
+#include "content/common/background_fetch/background_fetch_types.h"
+#include "content/common/content_export.h"
+#include "mojo/public/cpp/bindings/struct_traits.h"
+#include "third_party/WebKit/public/platform/modules/background_fetch/background_fetch.mojom.h"
+
+namespace content {
+namespace mojom {
+class BackgroundFetchSettledFetchDataView;
+}
+}
+
+namespace mojo {
+
+template <>
+struct CONTENT_EXPORT StructTraits<blink::mojom::BackgroundFetchOptionsDataView,
+ content::BackgroundFetchOptions> {
+ static const std::vector<content::IconDefinition>& icons(
+ const content::BackgroundFetchOptions& options) {
+ return options.icons;
+ }
+ static const std::string& title(
+ const content::BackgroundFetchOptions& options) {
+ return options.title;
+ }
+ static int64_t total_download_size(
+ const content::BackgroundFetchOptions& options) {
+ return options.total_download_size;
+ }
+
+ static bool Read(blink::mojom::BackgroundFetchOptionsDataView data,
+ content::BackgroundFetchOptions* options);
+};
+
+template <>
+struct CONTENT_EXPORT
+ StructTraits<blink::mojom::BackgroundFetchRegistrationDataView,
+ content::BackgroundFetchRegistration> {
+ static const std::string& tag(
+ const content::BackgroundFetchRegistration& registration) {
+ return registration.tag;
+ }
+ static const std::vector<content::IconDefinition>& icons(
+ const content::BackgroundFetchRegistration& registration) {
+ return registration.icons;
+ }
+ static const std::string& title(
+ const content::BackgroundFetchRegistration& registration) {
+ return registration.title;
+ }
+ static int64_t total_download_size(
+ const content::BackgroundFetchRegistration& registration) {
+ return registration.total_download_size;
+ }
+
+ static bool Read(blink::mojom::BackgroundFetchRegistrationDataView data,
+ content::BackgroundFetchRegistration* registration);
+};
+
+template <>
+struct CONTENT_EXPORT
+ StructTraits<content::mojom::BackgroundFetchSettledFetchDataView,
+ content::BackgroundFetchSettledFetch> {
+ static const content::ServiceWorkerFetchRequest& request(
+ const content::BackgroundFetchSettledFetch& fetch) {
+ return fetch.request;
+ }
+ static const content::ServiceWorkerResponse& response(
+ const content::BackgroundFetchSettledFetch& fetch) {
+ return fetch.response;
+ }
+
+ static bool Read(content::mojom::BackgroundFetchSettledFetchDataView data,
+ content::BackgroundFetchSettledFetch* definition);
+};
+
+template <>
+struct CONTENT_EXPORT StructTraits<blink::mojom::IconDefinitionDataView,
+ content::IconDefinition> {
+ static const std::string& src(const content::IconDefinition& definition) {
+ return definition.src;
+ }
+ static const std::string& sizes(const content::IconDefinition& definition) {
+ return definition.sizes;
+ }
+ static const std::string& type(const content::IconDefinition& definition) {
+ return definition.type;
+ }
+
+ static bool Read(blink::mojom::IconDefinitionDataView data,
+ content::IconDefinition* definition);
+};
+
+} // namespace mojo
+
+#endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_STRUCT_TRAITS_H_
diff --git a/chromium/content/common/background_fetch/background_fetch_struct_traits_unittest.cc b/chromium/content/common/background_fetch/background_fetch_struct_traits_unittest.cc
new file mode 100644
index 00000000000..92a6aa9ba4b
--- /dev/null
+++ b/chromium/content/common/background_fetch/background_fetch_struct_traits_unittest.cc
@@ -0,0 +1,99 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/background_fetch/background_fetch_struct_traits.h"
+
+#include <utility>
+
+#include "content/common/background_fetch/background_fetch_types.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace content {
+
+namespace {
+
+// Creates a new IconDefinition object for the given arguments.
+IconDefinition CreateIconDefinition(std::string src,
+ std::string sizes,
+ std::string type) {
+ IconDefinition definition;
+ definition.src = std::move(src);
+ definition.sizes = std::move(sizes);
+ definition.type = std::move(type);
+
+ return definition;
+}
+
+// Returns whether the given IconDefinition objects are identical.
+bool IconDefinitionsAreIdentical(const IconDefinition& left,
+ const IconDefinition& right) {
+ return left.src == right.src && left.sizes == right.sizes &&
+ left.type == right.type;
+}
+
+} // namespace
+
+TEST(BackgroundFetchStructTraitsTest, BackgroundFetchOptionsRoundtrip) {
+ BackgroundFetchOptions options;
+ options.icons = {
+ CreateIconDefinition("my_icon.png", "256x256", "image/png"),
+ CreateIconDefinition("my_small_icon.jpg", "128x128", "image/jpg")};
+ options.title = "My Background Fetch";
+ options.total_download_size = 9001;
+
+ BackgroundFetchOptions roundtrip_options;
+ ASSERT_TRUE(blink::mojom::BackgroundFetchOptions::Deserialize(
+ blink::mojom::BackgroundFetchOptions::Serialize(&options),
+ &roundtrip_options));
+
+ ASSERT_EQ(roundtrip_options.icons.size(), options.icons.size());
+ for (size_t i = 0; i < options.icons.size(); ++i) {
+ EXPECT_TRUE(IconDefinitionsAreIdentical(options.icons[i],
+ roundtrip_options.icons[i]));
+ }
+
+ EXPECT_EQ(roundtrip_options.title, options.title);
+ EXPECT_EQ(roundtrip_options.total_download_size, options.total_download_size);
+}
+
+TEST(BackgroundFetchStructTraitsTest, BackgroundFetchRegistrationRoundTrip) {
+ BackgroundFetchRegistration registration;
+ registration.tag = "my_tag";
+ registration.icons = {
+ CreateIconDefinition("my_icon.png", "256x256", "image/png"),
+ CreateIconDefinition("my_small_icon.jpg", "128x128", "image/jpg")};
+ registration.title = "My Background Fetch";
+ registration.total_download_size = 9001;
+
+ BackgroundFetchRegistration roundtrip_registration;
+ ASSERT_TRUE(blink::mojom::BackgroundFetchRegistration::Deserialize(
+ blink::mojom::BackgroundFetchRegistration::Serialize(&registration),
+ &roundtrip_registration));
+
+ EXPECT_EQ(roundtrip_registration.tag, registration.tag);
+
+ ASSERT_EQ(roundtrip_registration.icons.size(), registration.icons.size());
+ for (size_t i = 0; i < registration.icons.size(); ++i) {
+ EXPECT_TRUE(IconDefinitionsAreIdentical(registration.icons[i],
+ roundtrip_registration.icons[i]));
+ }
+
+ EXPECT_EQ(roundtrip_registration.title, registration.title);
+ EXPECT_EQ(roundtrip_registration.total_download_size,
+ registration.total_download_size);
+}
+
+TEST(BackgroundFetchStructTraitsTest, IconDefinitionRoundtrip) {
+ IconDefinition definition =
+ CreateIconDefinition("my_icon.png", "256x256", "image/png");
+
+ IconDefinition roundtrip_definition;
+ ASSERT_TRUE(blink::mojom::IconDefinition::Deserialize(
+ blink::mojom::IconDefinition::Serialize(&definition),
+ &roundtrip_definition));
+
+ EXPECT_TRUE(IconDefinitionsAreIdentical(definition, roundtrip_definition));
+}
+
+} // namespace content
diff --git a/chromium/content/common/background_fetch/background_fetch_types.cc b/chromium/content/common/background_fetch/background_fetch_types.cc
new file mode 100644
index 00000000000..13325ef1752
--- /dev/null
+++ b/chromium/content/common/background_fetch/background_fetch_types.cc
@@ -0,0 +1,36 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/background_fetch/background_fetch_types.h"
+
+namespace content {
+
+IconDefinition::IconDefinition() = default;
+
+IconDefinition::IconDefinition(const IconDefinition& other) = default;
+
+IconDefinition::~IconDefinition() = default;
+
+BackgroundFetchOptions::BackgroundFetchOptions() = default;
+
+BackgroundFetchOptions::BackgroundFetchOptions(
+ const BackgroundFetchOptions& other) = default;
+
+BackgroundFetchOptions::~BackgroundFetchOptions() = default;
+
+BackgroundFetchRegistration::BackgroundFetchRegistration() = default;
+
+BackgroundFetchRegistration::BackgroundFetchRegistration(
+ const BackgroundFetchRegistration& other) = default;
+
+BackgroundFetchRegistration::~BackgroundFetchRegistration() = default;
+
+BackgroundFetchSettledFetch::BackgroundFetchSettledFetch() = default;
+
+BackgroundFetchSettledFetch::BackgroundFetchSettledFetch(
+ const BackgroundFetchSettledFetch& other) = default;
+
+BackgroundFetchSettledFetch::~BackgroundFetchSettledFetch() = default;
+
+} // namespace content
diff --git a/chromium/content/common/background_fetch/background_fetch_types.h b/chromium/content/common/background_fetch/background_fetch_types.h
new file mode 100644
index 00000000000..263cfa618fa
--- /dev/null
+++ b/chromium/content/common/background_fetch/background_fetch_types.h
@@ -0,0 +1,77 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_BACKGROUND_FETCH_BACKGROUND_FETCH_TYPES_H_
+#define CONTENT_COMMON_BACKGROUND_FETCH_BACKGROUND_FETCH_TYPES_H_
+
+#include <stdint.h>
+#include <string>
+#include <vector>
+
+#include "content/common/content_export.h"
+#include "content/common/service_worker/service_worker_types.h"
+
+namespace content {
+
+// Represents the definition of an icon developers can optionally provide with a
+// Background Fetch fetch. Analogous to the following structure in the spec:
+// https://wicg.github.io/background-fetch/#background-fetch-manager
+//
+// Parsing of the icon definitions as well as fetching an appropriate icon will
+// be done by Blink in the renderer process. The browser process is expected to
+// treat these values as opaque strings.
+struct CONTENT_EXPORT IconDefinition {
+ IconDefinition();
+ IconDefinition(const IconDefinition& other);
+ ~IconDefinition();
+
+ std::string src;
+ std::string sizes;
+ std::string type;
+};
+
+// Represents the optional options a developer can provide when starting a new
+// Background Fetch fetch. Analogous to the following structure in the spec:
+// https://wicg.github.io/background-fetch/#background-fetch-manager
+struct CONTENT_EXPORT BackgroundFetchOptions {
+ BackgroundFetchOptions();
+ BackgroundFetchOptions(const BackgroundFetchOptions& other);
+ ~BackgroundFetchOptions();
+
+ std::vector<IconDefinition> icons;
+ std::string title;
+ int64_t total_download_size = 0;
+};
+
+// Represents the information associated with a Background Fetch registration.
+// Analogous to the following structure in the spec:
+// https://wicg.github.io/background-fetch/#background-fetch-registration
+struct CONTENT_EXPORT BackgroundFetchRegistration {
+ BackgroundFetchRegistration();
+ BackgroundFetchRegistration(const BackgroundFetchRegistration& other);
+ ~BackgroundFetchRegistration();
+
+ std::string tag;
+ std::vector<IconDefinition> icons;
+ std::string title;
+ int64_t total_download_size = 0;
+
+ // TODO(peter): Support the `activeFetches` member of the specification.
+};
+
+// Represents a request/response pair for a settled Background Fetch fetch.
+// Analogous to the following structure in the spec:
+// http://wicg.github.io/background-fetch/#backgroundfetchsettledfetch
+struct CONTENT_EXPORT BackgroundFetchSettledFetch {
+ BackgroundFetchSettledFetch();
+ BackgroundFetchSettledFetch(const BackgroundFetchSettledFetch& other);
+ ~BackgroundFetchSettledFetch();
+
+ ServiceWorkerFetchRequest request;
+ ServiceWorkerResponse response;
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_BACKGROUND_FETCH_BACKGROUND_FETCH_TYPES_H_
diff --git a/chromium/content/common/background_fetch/background_fetch_types.typemap b/chromium/content/common/background_fetch/background_fetch_types.typemap
new file mode 100644
index 00000000000..9fce85f3b10
--- /dev/null
+++ b/chromium/content/common/background_fetch/background_fetch_types.typemap
@@ -0,0 +1,19 @@
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+mojom = "//third_party/WebKit/public/platform/modules/background_fetch/background_fetch.mojom"
+public_headers =
+ [ "//content/common/background_fetch/background_fetch_types.h" ]
+traits_headers =
+ [ "//content/common/background_fetch/background_fetch_struct_traits.h" ]
+deps = [
+ "//mojo/public/cpp/bindings",
+ "//third_party/WebKit/public:blink_headers",
+]
+type_mappings = [
+ "blink.mojom.BackgroundFetchOptions=content::BackgroundFetchOptions",
+ "blink.mojom.BackgroundFetchRegistration=content::BackgroundFetchRegistration",
+ "content.mojom.BackgroundFetchSettledFetch=::content::BackgroundFetchSettledFetch",
+ "blink.mojom.IconDefinition=content::IconDefinition",
+]
diff --git a/chromium/content/common/browser_plugin/browser_plugin_messages.h b/chromium/content/common/browser_plugin/browser_plugin_messages.h
index 8c4ebd94cab..0ddd402aafd 100644
--- a/chromium/content/common/browser_plugin/browser_plugin_messages.h
+++ b/chromium/content/common/browser_plugin/browser_plugin_messages.h
@@ -26,14 +26,14 @@
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/ipc/gfx_param_traits.h"
#include "ui/gfx/ipc/skia/gfx_skia_param_traits.h"
+#include "ui/gfx/range/range.h"
#undef IPC_MESSAGE_EXPORT
#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
#define IPC_MESSAGE_START BrowserPluginMsgStart
-
-IPC_ENUM_TRAITS_MAX_VALUE(blink::WebDragStatus, blink::WebDragStatusLast)
+IPC_ENUM_TRAITS_MAX_VALUE(blink::WebDragStatus, blink::kWebDragStatusLast)
IPC_STRUCT_BEGIN(BrowserPluginHostMsg_Attach_Params)
IPC_STRUCT_MEMBER(bool, focused)
@@ -44,6 +44,14 @@ IPC_STRUCT_BEGIN(BrowserPluginHostMsg_Attach_Params)
IPC_STRUCT_MEMBER(bool, is_full_page_plugin)
IPC_STRUCT_END()
+IPC_STRUCT_BEGIN(BrowserPluginHostMsg_SetComposition_Params)
+ IPC_STRUCT_MEMBER(base::string16, text)
+ IPC_STRUCT_MEMBER(std::vector<blink::WebCompositionUnderline>, underlines)
+ IPC_STRUCT_MEMBER(gfx::Range, replacement_range)
+ IPC_STRUCT_MEMBER(int, selection_start)
+ IPC_STRUCT_MEMBER(int, selection_end)
+IPC_STRUCT_END()
+
// Browser plugin messages
// -----------------------------------------------------------------------------
@@ -65,21 +73,18 @@ IPC_MESSAGE_CONTROL2(BrowserPluginHostMsg_SetEditCommandsForNextKeyEvent,
// This message is sent from BrowserPlugin to BrowserPluginGuest whenever IME
// composition state is updated.
-IPC_MESSAGE_CONTROL5(
- BrowserPluginHostMsg_ImeSetComposition,
- int /* browser_plugin_instance_id */,
- std::string /* text */,
- std::vector<blink::WebCompositionUnderline> /* underlines */,
- int /* selectiont_start */,
- int /* selection_end */)
+IPC_MESSAGE_CONTROL2(BrowserPluginHostMsg_ImeSetComposition,
+ int /* browser_plugin_instance_id */,
+ BrowserPluginHostMsg_SetComposition_Params /* params */)
// This message is sent from BrowserPlugin to BrowserPluginGuest to notify that
// deleting the current composition and inserting specified text is requested.
-IPC_MESSAGE_CONTROL4(
+IPC_MESSAGE_CONTROL5(
BrowserPluginHostMsg_ImeCommitText,
int /* browser_plugin_instance_id */,
- std::string /* text */,
+ base::string16 /* text */,
std::vector<blink::WebCompositionUnderline> /* underlines */,
+ gfx::Range /* replacement_range */,
int /* relative_cursor_pos */)
// This message is sent from BrowserPlugin to BrowserPluginGuest to notify that
diff --git a/chromium/content/common/cache_storage/cache_storage_messages.h b/chromium/content/common/cache_storage/cache_storage_messages.h
index 80a4ff8a0ef..5f2584f3502 100644
--- a/chromium/content/common/cache_storage/cache_storage_messages.h
+++ b/chromium/content/common/cache_storage/cache_storage_messages.h
@@ -42,7 +42,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::CacheStorageBatchOperation)
IPC_STRUCT_TRAITS_END()
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerCacheError,
- blink::WebServiceWorkerCacheErrorLast)
+ blink::kWebServiceWorkerCacheErrorLast)
//---------------------------------------------------------------------------
// Messages sent from the child process to the browser.
diff --git a/chromium/content/common/child.mojom b/chromium/content/common/child.mojom
new file mode 100644
index 00000000000..15524dded27
--- /dev/null
+++ b/chromium/content/common/child.mojom
@@ -0,0 +1,9 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module content.mojom;
+
+// This interface encapsulates a pipe between a child and browser processes
+// that each side uses to monitor the lifetime of the connection.
+interface Child {};
diff --git a/chromium/content/common/child_process_host_impl.cc b/chromium/content/common/child_process_host_impl.cc
index 082906f5b6f..9689c72d6fb 100644
--- a/chromium/content/common/child_process_host_impl.cc
+++ b/chromium/content/common/child_process_host_impl.cc
@@ -32,6 +32,7 @@
#include "ipc/ipc_logging.h"
#include "ipc/message_filter.h"
#include "mojo/edk/embedder/embedder.h"
+#include "services/resource_coordinator/public/interfaces/memory/constants.mojom.h"
#include "services/service_manager/public/cpp/interface_provider.h"
#if defined(OS_LINUX)
@@ -51,9 +52,6 @@ namespace content {
int ChildProcessHost::kInvalidUniqueID = -1;
-uint64_t ChildProcessHost::kBrowserTracingProcessId =
- std::numeric_limits<uint64_t>::max();
-
// static
ChildProcessHost* ChildProcessHost::Create(ChildProcessHostDelegate* delegate) {
return new ChildProcessHostImpl(delegate);
@@ -111,9 +109,10 @@ void ChildProcessHostImpl::AddFilter(IPC::MessageFilter* filter) {
filter->OnFilterAdded(channel_.get());
}
-service_manager::InterfaceProvider*
-ChildProcessHostImpl::GetRemoteInterfaces() {
- return delegate_->GetRemoteInterfaces();
+void ChildProcessHostImpl::BindInterface(
+ const std::string& interface_name,
+ mojo::ScopedMessagePipeHandle interface_pipe) {
+ return delegate_->BindInterface(interface_name, std::move(interface_pipe));
}
void ChildProcessHostImpl::ForceShutdown() {
@@ -138,12 +137,9 @@ void ChildProcessHostImpl::CreateChannelMojo() {
DCHECK(channel_id_.empty());
channel_id_ = "ChannelMojo";
- service_manager::InterfaceProvider* remote_interfaces = GetRemoteInterfaces();
- DCHECK(remote_interfaces);
-
- IPC::mojom::ChannelBootstrapPtr bootstrap;
- remote_interfaces->GetInterface(&bootstrap);
- channel_ = IPC::ChannelMojo::Create(bootstrap.PassInterface().PassHandle(),
+ mojo::MessagePipe pipe;
+ BindInterface(IPC::mojom::ChannelBootstrap::Name_, std::move(pipe.handle1));
+ channel_ = IPC::ChannelMojo::Create(std::move(pipe.handle0),
IPC::Channel::MODE_SERVER, this);
DCHECK(channel_);
@@ -205,7 +201,7 @@ uint64_t ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId(
// tracing process ids.
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kSingleProcess))
- return ChildProcessHost::kBrowserTracingProcessId;
+ return memory_instrumentation::mojom::kServiceTracingProcessId;
// The hash value is incremented so that the tracing id is never equal to
// MemoryDumpManager::kInvalidTracingProcessId.
diff --git a/chromium/content/common/child_process_host_impl.h b/chromium/content/common/child_process_host_impl.h
index ebeb8aa645a..e6e813636c3 100644
--- a/chromium/content/common/child_process_host_impl.h
+++ b/chromium/content/common/child_process_host_impl.h
@@ -57,8 +57,8 @@ class CONTENT_EXPORT ChildProcessHostImpl : public ChildProcessHost,
// process.
//
// Never returns MemoryDumpManager::kInvalidTracingProcessId.
- // Returns only ChildProcessHost::kBrowserTracingProcessId in single-process
- // mode.
+ // Returns only memory_instrumentation::mojom::kServiceTracingProcessId in
+ // single-process mode.
static uint64_t ChildProcessUniqueIdToTracingProcessId(int child_process_id);
// ChildProcessHost implementation
@@ -69,7 +69,8 @@ class CONTENT_EXPORT ChildProcessHostImpl : public ChildProcessHost,
void CreateChannelMojo() override;
bool IsChannelOpening() override;
void AddFilter(IPC::MessageFilter* filter) override;
- service_manager::InterfaceProvider* GetRemoteInterfaces() override;
+ void BindInterface(const std::string& interface_name,
+ mojo::ScopedMessagePipeHandle interface_pipe) override;
private:
friend class ChildProcessHost;
diff --git a/chromium/content/common/common_param_traits_unittest.cc b/chromium/content/common/common_param_traits_unittest.cc
index 4756e22b50b..c9006cf39b5 100644
--- a/chromium/content/common/common_param_traits_unittest.cc
+++ b/chromium/content/common/common_param_traits_unittest.cc
@@ -11,6 +11,7 @@
#include <utility>
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "content/public/common/content_constants.h"
#include "ipc/ipc_message.h"
@@ -83,8 +84,8 @@ TEST(IPCMessageTest, Bitmap) {
TEST(IPCMessageTest, ListValue) {
base::ListValue input;
input.Set(0, new base::Value(42.42));
- input.Set(1, new base::StringValue("forty"));
- input.Set(2, base::Value::CreateNullValue());
+ input.Set(1, new base::Value("forty"));
+ input.Set(2, base::MakeUnique<base::Value>());
IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
IPC::WriteParam(&msg, input);
@@ -104,18 +105,18 @@ TEST(IPCMessageTest, ListValue) {
TEST(IPCMessageTest, DictionaryValue) {
base::DictionaryValue input;
- input.Set("null", base::Value::CreateNullValue());
+ input.Set("null", base::MakeUnique<base::Value>());
input.Set("bool", new base::Value(true));
input.Set("int", new base::Value(42));
std::unique_ptr<base::DictionaryValue> subdict(new base::DictionaryValue());
- subdict->Set("str", new base::StringValue("forty two"));
+ subdict->Set("str", new base::Value("forty two"));
subdict->Set("bool", new base::Value(false));
std::unique_ptr<base::ListValue> sublist(new base::ListValue());
sublist->Set(0, new base::Value(42.42));
- sublist->Set(1, new base::StringValue("forty"));
- sublist->Set(2, new base::StringValue("two"));
+ sublist->Set(1, new base::Value("forty"));
+ sublist->Set(2, new base::Value("two"));
subdict->Set("list", sublist.release());
input.Set("dict", subdict.release());
diff --git a/chromium/content/common/content_message_generator.h b/chromium/content/common/content_message_generator.h
index 84ea1c050f6..420b4243ca2 100644
--- a/chromium/content/common/content_message_generator.h
+++ b/chromium/content/common/content_message_generator.h
@@ -21,7 +21,6 @@
#include "content/common/fileapi/file_system_messages.h"
#include "content/common/fileapi/webblob_messages.h"
#include "content/common/frame_messages.h"
-#include "content/common/gpu_host_messages.h"
#include "content/common/input_messages.h"
#include "content/common/manifest_manager_messages.h"
#include "content/common/media/aec_dump_messages.h"
@@ -37,7 +36,6 @@
#include "content/common/quota_messages.h"
#include "content/common/render_process_messages.h"
#include "content/common/resource_messages.h"
-#include "content/common/screen_orientation_messages.h"
#include "content/common/service_worker/embedded_worker_messages.h"
#include "content/common/service_worker/service_worker_messages.h"
#include "content/common/speech_recognition_messages.h"
diff --git a/chromium/content/common/content_param_traits.cc b/chromium/content/common/content_param_traits.cc
index 2960f78727f..514473020a1 100644
--- a/chromium/content/common/content_param_traits.cc
+++ b/chromium/content/common/content_param_traits.cc
@@ -7,6 +7,7 @@
#include <stddef.h>
#include "base/strings/string_number_conversions.h"
+#include "content/common/accessibility_mode.h"
#include "content/common/message_port.h"
#include "ipc/ipc_mojo_param_traits.h"
#include "net/base/ip_endpoint.h"
@@ -44,7 +45,7 @@ bool ParamTraits<WebInputEventPointer>::Read(const base::Pickle* m,
return false;
}
const size_t expected_size_for_type =
- ui::WebInputEventTraits::GetSize(event->type());
+ ui::WebInputEventTraits::GetSize(event->GetType());
if (data_length != static_cast<int>(expected_size_for_type)) {
NOTREACHED();
return false;
@@ -58,9 +59,9 @@ void ParamTraits<WebInputEventPointer>::Log(const param_type& p,
l->append("(");
LogParam(p->size(), l);
l->append(", ");
- LogParam(p->type(), l);
+ LogParam(p->GetType(), l);
l->append(", ");
- LogParam(p->timeStampSeconds(), l);
+ LogParam(p->TimeStampSeconds(), l);
l->append(")");
}
@@ -89,6 +90,28 @@ void ParamTraits<content::MessagePort>::Log(const param_type& p,
std::string* l) {
}
+void ParamTraits<content::AccessibilityMode>::GetSize(base::PickleSizer* s,
+ const param_type& p) {
+ IPC::GetParamSize(s, p.mode());
+}
+
+void ParamTraits<content::AccessibilityMode>::Write(base::Pickle* m,
+ const param_type& p) {
+ IPC::WriteParam(m, p.mode());
+}
+
+bool ParamTraits<content::AccessibilityMode>::Read(const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* r) {
+ uint32_t value;
+ if (!IPC::ReadParam(m, iter, &value))
+ return false;
+ *r = content::AccessibilityMode(value);
+ return true;
+}
+
+void ParamTraits<content::AccessibilityMode>::Log(const param_type& p,
+ std::string* l) {}
} // namespace IPC
// Generate param traits size methods.
diff --git a/chromium/content/common/content_param_traits.h b/chromium/content/common/content_param_traits.h
index c20b75d1b8a..6cd7d9251a9 100644
--- a/chromium/content/common/content_param_traits.h
+++ b/chromium/content/common/content_param_traits.h
@@ -16,9 +16,11 @@
#include "content/common/content_param_traits_macros.h"
#include "content/common/cursors/webcursor.h"
+#include "ipc/ipc_mojo_param_traits.h"
#include "third_party/WebKit/public/platform/WebInputEvent.h"
namespace content {
+class AccessibilityMode;
class MessagePort;
}
@@ -61,6 +63,17 @@ struct CONTENT_EXPORT ParamTraits<content::MessagePort> {
static void Log(const param_type& p, std::string* l);
};
+template <>
+struct CONTENT_EXPORT ParamTraits<content::AccessibilityMode> {
+ typedef content::AccessibilityMode param_type;
+ static void GetSize(base::PickleSizer* sizer, const param_type& p);
+ static void Write(base::Pickle* m, const param_type& p);
+ static bool Read(const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* r);
+ static void Log(const param_type& p, std::string* l);
+};
+
} // namespace IPC
#endif // CONTENT_COMMON_CONTENT_PARAM_TRAITS_H_
diff --git a/chromium/content/common/content_param_traits_macros.h b/chromium/content/common/content_param_traits_macros.h
index 00e83838657..1f3597a732c 100644
--- a/chromium/content/common/content_param_traits_macros.h
+++ b/chromium/content/common/content_param_traits_macros.h
@@ -37,24 +37,24 @@ IPC_ENUM_TRAITS_MAX_VALUE(content::RequestContextFrameType,
IPC_ENUM_TRAITS_MAX_VALUE(content::MhtmlSaveStatus,
content::MhtmlSaveStatus::LAST)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebContentSecurityPolicySource,
- blink::WebContentSecurityPolicySourceLast)
+ blink::kWebContentSecurityPolicySourceLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebContentSecurityPolicyType,
- blink::WebContentSecurityPolicyTypeLast)
-IPC_ENUM_TRAITS_MAX_VALUE(blink::WebAddressSpace, blink::WebAddressSpaceLast)
+ blink::kWebContentSecurityPolicyTypeLast)
+IPC_ENUM_TRAITS_MAX_VALUE(blink::WebAddressSpace, blink::kWebAddressSpaceLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebSharedWorkerCreationContextType,
- blink::WebSharedWorkerCreationContextTypeLast)
+ blink::kWebSharedWorkerCreationContextTypeLast)
IPC_ENUM_TRAITS_MIN_MAX_VALUE(blink::WebInputEvent::Type,
- blink::WebInputEvent::TypeFirst,
- blink::WebInputEvent::TypeLast)
+ blink::WebInputEvent::kTypeFirst,
+ blink::WebInputEvent::kTypeLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebPageVisibilityState,
- blink::WebPageVisibilityStateLast)
+ blink::kWebPageVisibilityStateLast)
IPC_STRUCT_TRAITS_BEGIN(blink::WebCompositionUnderline)
- IPC_STRUCT_TRAITS_MEMBER(startOffset)
- IPC_STRUCT_TRAITS_MEMBER(endOffset)
+ IPC_STRUCT_TRAITS_MEMBER(start_offset)
+ IPC_STRUCT_TRAITS_MEMBER(end_offset)
IPC_STRUCT_TRAITS_MEMBER(color)
IPC_STRUCT_TRAITS_MEMBER(thick)
- IPC_STRUCT_TRAITS_MEMBER(backgroundColor)
+ IPC_STRUCT_TRAITS_MEMBER(background_color)
IPC_STRUCT_TRAITS_END()
#endif // CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_
diff --git a/chromium/content/common/content_security_policy/OWNERS b/chromium/content/common/content_security_policy/OWNERS
new file mode 100644
index 00000000000..3f8456354bd
--- /dev/null
+++ b/chromium/content/common/content_security_policy/OWNERS
@@ -0,0 +1 @@
+mkwst@chromium.org
diff --git a/chromium/content/common/content_security_policy/content_security_policy.cc b/chromium/content/common/content_security_policy/content_security_policy.cc
index b091744bd5a..87b035eb1c2 100644
--- a/chromium/content/common/content_security_policy/content_security_policy.cc
+++ b/chromium/content/common/content_security_policy/content_security_policy.cc
@@ -41,7 +41,9 @@ void ReportViolation(CSPContext* context,
const ContentSecurityPolicy& policy,
const CSPDirective& directive,
const CSPDirective::Name directive_name,
- const GURL& url) {
+ const GURL& url,
+ bool is_redirect,
+ const SourceLocation& source_location) {
// We should never have a violation against `child-src` or `default-src`
// directly; the effective directive should always be one of the explicit
// fetch directives.
@@ -50,7 +52,7 @@ void ReportViolation(CSPContext* context,
std::stringstream message;
- if (policy.disposition == blink::WebContentSecurityPolicyTypeReport)
+ if (policy.header.type == blink::kWebContentSecurityPolicyTypeReport)
message << "[Report Only] ";
if (directive_name == CSPDirective::FormAction)
@@ -71,11 +73,11 @@ void ReportViolation(CSPContext* context,
message << "\n";
- context->LogToConsole(message.str());
- context->ReportViolation(CSPDirective::NameToString(directive.name),
- CSPDirective::NameToString(directive_name),
- message.str(), url, policy.report_endpoints,
- policy.header, policy.disposition);
+ context->ReportContentSecurityPolicyViolation(CSPViolationParams(
+ CSPDirective::NameToString(directive.name),
+ CSPDirective::NameToString(directive_name), message.str(), url,
+ policy.report_endpoints, policy.header.header_value, policy.header.type,
+ is_redirect, source_location));
}
bool AllowDirective(CSPContext* context,
@@ -83,31 +85,46 @@ bool AllowDirective(CSPContext* context,
const CSPDirective& directive,
CSPDirective::Name directive_name,
const GURL& url,
- bool is_redirect) {
+ bool is_redirect,
+ const SourceLocation& source_location) {
if (CSPSourceList::Allow(directive.source_list, url, context, is_redirect))
return true;
- ReportViolation(context, policy, directive, directive_name, url);
+ ReportViolation(context, policy, directive, directive_name, url, is_redirect,
+ source_location);
return false;
}
+const GURL ExtractInnerURL(const GURL& url) {
+ if (const GURL* inner_url = url.inner_url())
+ return *inner_url;
+ else
+ // TODO(arthursonzogni): revisit this once GURL::inner_url support blob-URL.
+ return GURL(url.path());
+}
+
+bool ShouldBypassContentSecurityPolicy(CSPContext* context, const GURL& url) {
+ if (url.SchemeIsFileSystem() || url.SchemeIsBlob()) {
+ return context->SchemeShouldBypassCSP(ExtractInnerURL(url).scheme());
+ } else {
+ return context->SchemeShouldBypassCSP(url.scheme());
+ }
+}
+
} // namespace
ContentSecurityPolicy::ContentSecurityPolicy()
- : disposition(blink::WebContentSecurityPolicyTypeEnforce),
- source(blink::WebContentSecurityPolicySourceHTTP) {}
+ : header(std::string(),
+ blink::kWebContentSecurityPolicyTypeEnforce,
+ blink::kWebContentSecurityPolicySourceHTTP) {}
ContentSecurityPolicy::ContentSecurityPolicy(
- blink::WebContentSecurityPolicyType disposition,
- blink::WebContentSecurityPolicySource source,
+ const ContentSecurityPolicyHeader& header,
const std::vector<CSPDirective>& directives,
- const std::vector<std::string>& report_endpoints,
- const std::string& header)
- : disposition(disposition),
- source(source),
+ const std::vector<std::string>& report_endpoints)
+ : header(header),
directives(directives),
- report_endpoints(report_endpoints),
- header(header) {}
+ report_endpoints(report_endpoints) {}
ContentSecurityPolicy::ContentSecurityPolicy(const ContentSecurityPolicy&) =
default;
@@ -117,16 +134,20 @@ ContentSecurityPolicy::~ContentSecurityPolicy() = default;
bool ContentSecurityPolicy::Allow(const ContentSecurityPolicy& policy,
CSPDirective::Name directive_name,
const GURL& url,
+ bool is_redirect,
CSPContext* context,
- bool is_redirect) {
+ const SourceLocation& source_location) {
+ if (ShouldBypassContentSecurityPolicy(context, url)) return true;
+
CSPDirective::Name current_directive_name = directive_name;
do {
for (const CSPDirective& directive : policy.directives) {
if (directive.name == current_directive_name) {
- bool allowed = AllowDirective(context, policy, directive,
- directive_name, url, is_redirect);
+ bool allowed =
+ AllowDirective(context, policy, directive, directive_name, url,
+ is_redirect, source_location);
return allowed ||
- policy.disposition == blink::WebContentSecurityPolicyTypeReport;
+ policy.header.type == blink::kWebContentSecurityPolicyTypeReport;
}
}
current_directive_name = CSPFallback(current_directive_name);
diff --git a/chromium/content/common/content_security_policy/content_security_policy.h b/chromium/content/common/content_security_policy/content_security_policy.h
index 56454ed27b6..d4de5237033 100644
--- a/chromium/content/common/content_security_policy/content_security_policy.h
+++ b/chromium/content/common/content_security_policy/content_security_policy.h
@@ -16,6 +16,7 @@
namespace content {
class CSPContext;
+struct SourceLocation;
// https://www.w3.org/TR/CSP3/#framework-policy
//
@@ -23,19 +24,15 @@ class CSPContext;
// enforced upon requests.
struct CONTENT_EXPORT ContentSecurityPolicy {
ContentSecurityPolicy();
- ContentSecurityPolicy(blink::WebContentSecurityPolicyType disposition,
- blink::WebContentSecurityPolicySource source,
+ ContentSecurityPolicy(const ContentSecurityPolicyHeader& header,
const std::vector<CSPDirective>& directives,
- const std::vector<std::string>& report_endpoints,
- const std::string& header);
+ const std::vector<std::string>& report_endpoints);
ContentSecurityPolicy(const ContentSecurityPolicy&);
~ContentSecurityPolicy();
- blink::WebContentSecurityPolicyType disposition;
- blink::WebContentSecurityPolicySource source;
+ ContentSecurityPolicyHeader header;
std::vector<CSPDirective> directives;
std::vector<std::string> report_endpoints;
- std::string header;
std::string ToString() const;
@@ -45,8 +42,9 @@ struct CONTENT_EXPORT ContentSecurityPolicy {
static bool Allow(const ContentSecurityPolicy& policy,
CSPDirective::Name directive,
const GURL& url,
+ bool is_redirect,
CSPContext* context,
- bool is_redirect = false);
+ const SourceLocation& source_location);
};
} // namespace content
diff --git a/chromium/content/common/content_security_policy/content_security_policy_unittest.cc b/chromium/content/common/content_security_policy/content_security_policy_unittest.cc
index 6a6c02c995f..0ac8a44b3ff 100644
--- a/chromium/content/common/content_security_policy/content_security_policy_unittest.cc
+++ b/chromium/content/common/content_security_policy/content_security_policy_unittest.cc
@@ -4,6 +4,7 @@
#include "content/common/content_security_policy/csp_context.h"
#include "content/common/content_security_policy_header.h"
+#include "content/common/navigation_params.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace content {
@@ -11,28 +12,47 @@ namespace content {
namespace {
class CSPContextTest : public CSPContext {
public:
+ CSPContextTest() : CSPContext() {}
+
const std::string& LastConsoleMessage() { return console_message_; }
+ void AddSchemeToBypassCSP(const std::string& scheme) {
+ scheme_to_bypass_.push_back(scheme);
+ }
+
+ bool SchemeShouldBypassCSP(const base::StringPiece& scheme) override {
+ return std::find(scheme_to_bypass_.begin(), scheme_to_bypass_.end(),
+ scheme) != scheme_to_bypass_.end();
+ }
+
private:
- void LogToConsole(const std::string& message) override {
- console_message_ = message;
+ void ReportContentSecurityPolicyViolation(
+ const CSPViolationParams& violation_params) override {
+ console_message_ = violation_params.console_message;
}
std::string console_message_;
+ std::vector<std::string> scheme_to_bypass_;
+
+ DISALLOW_COPY_AND_ASSIGN(CSPContextTest);
};
+ContentSecurityPolicyHeader EmptyCspHeader() {
+ return ContentSecurityPolicyHeader(
+ std::string(), blink::kWebContentSecurityPolicyTypeEnforce,
+ blink::kWebContentSecurityPolicySourceHTTP);
+}
+
} // namespace
TEST(ContentSecurityPolicy, NoDirective) {
CSPContextTest context;
std::vector<std::string> report_end_points; // empty
- ContentSecurityPolicy policy(blink::WebContentSecurityPolicyTypeEnforce,
- blink::WebContentSecurityPolicySourceHTTP,
- std::vector<CSPDirective>(), report_end_points,
- "" /* header */);
+ ContentSecurityPolicy policy(EmptyCspHeader(), std::vector<CSPDirective>(),
+ report_end_points);
EXPECT_TRUE(ContentSecurityPolicy::Allow(policy, CSPDirective::FormAction,
GURL("http://www.example.com"),
- &context));
+ false, &context, SourceLocation()));
EXPECT_EQ("", context.LastConsoleMessage());
}
@@ -45,13 +65,12 @@ TEST(ContentSecurityPolicy, ReportViolation) {
CSPSourceList source_list(false, false, {source});
CSPDirective directive(CSPDirective::FormAction, source_list);
std::vector<std::string> report_end_points; // empty
- ContentSecurityPolicy policy(blink::WebContentSecurityPolicyTypeEnforce,
- blink::WebContentSecurityPolicySourceHTTP,
- {directive}, report_end_points, "" /* header */);
+ ContentSecurityPolicy policy(EmptyCspHeader(), {directive},
+ report_end_points);
EXPECT_FALSE(ContentSecurityPolicy::Allow(policy, CSPDirective::FormAction,
GURL("http://www.not-example.com"),
- &context));
+ false, &context, SourceLocation()));
const char console_message[] =
"Refused to send form data to 'http://www.not-example.com/' because it "
@@ -71,12 +90,12 @@ TEST(ContentSecurityPolicy, DirectiveFallback) {
{
CSPContextTest context;
ContentSecurityPolicy policy(
- blink::WebContentSecurityPolicyTypeEnforce,
- blink::WebContentSecurityPolicySourceHTTP,
+ EmptyCspHeader(),
{CSPDirective(CSPDirective::DefaultSrc, source_list_a)},
- report_end_points, "" /* header */);
+ report_end_points);
EXPECT_FALSE(ContentSecurityPolicy::Allow(policy, CSPDirective::FrameSrc,
- GURL("http://b.com"), &context));
+ GURL("http://b.com"), false,
+ &context, SourceLocation()));
const char console_message[] =
"Refused to frame 'http://b.com/' because it violates "
"the following Content Security Policy directive: \"default-src "
@@ -84,17 +103,17 @@ TEST(ContentSecurityPolicy, DirectiveFallback) {
"set, so 'default-src' is used as a fallback.\n";
EXPECT_EQ(console_message, context.LastConsoleMessage());
EXPECT_TRUE(ContentSecurityPolicy::Allow(policy, CSPDirective::FrameSrc,
- GURL("http://a.com"), &context));
+ GURL("http://a.com"), false,
+ &context, SourceLocation()));
}
{
CSPContextTest context;
ContentSecurityPolicy policy(
- blink::WebContentSecurityPolicyTypeEnforce,
- blink::WebContentSecurityPolicySourceHTTP,
- {CSPDirective(CSPDirective::ChildSrc, source_list_a)},
- report_end_points, "" /* header */);
+ EmptyCspHeader(), {CSPDirective(CSPDirective::ChildSrc, source_list_a)},
+ report_end_points);
EXPECT_FALSE(ContentSecurityPolicy::Allow(policy, CSPDirective::FrameSrc,
- GURL("http://b.com"), &context));
+ GURL("http://b.com"), false,
+ &context, SourceLocation()));
const char console_message[] =
"Refused to frame 'http://b.com/' because it violates "
"the following Content Security Policy directive: \"child-src "
@@ -102,21 +121,23 @@ TEST(ContentSecurityPolicy, DirectiveFallback) {
"set, so 'child-src' is used as a fallback.\n";
EXPECT_EQ(console_message, context.LastConsoleMessage());
EXPECT_TRUE(ContentSecurityPolicy::Allow(policy, CSPDirective::FrameSrc,
- GURL("http://a.com"), &context));
+ GURL("http://a.com"), false,
+ &context, SourceLocation()));
}
{
CSPContextTest context;
CSPSourceList source_list(false, false, {source_a, source_b});
ContentSecurityPolicy policy(
- blink::WebContentSecurityPolicyTypeEnforce,
- blink::WebContentSecurityPolicySourceHTTP,
+ EmptyCspHeader(),
{CSPDirective(CSPDirective::FrameSrc, {source_list_a}),
CSPDirective(CSPDirective::ChildSrc, {source_list_b})},
- report_end_points, "" /* header */);
+ report_end_points);
EXPECT_TRUE(ContentSecurityPolicy::Allow(policy, CSPDirective::FrameSrc,
- GURL("http://a.com"), &context));
+ GURL("http://a.com"), false,
+ &context, SourceLocation()));
EXPECT_FALSE(ContentSecurityPolicy::Allow(policy, CSPDirective::FrameSrc,
- GURL("http://b.com"), &context));
+ GURL("http://b.com"), false,
+ &context, SourceLocation()));
const char console_message[] =
"Refused to frame 'http://b.com/' because it violates "
"the following Content Security Policy directive: \"frame-src "
@@ -125,4 +146,92 @@ TEST(ContentSecurityPolicy, DirectiveFallback) {
}
}
+TEST(ContentSecurityPolicy, RequestsAllowedWhenBypassingCSP) {
+ CSPContextTest context;
+ std::vector<std::string> report_end_points; // empty
+ CSPSource source("https", "example.com", false, url::PORT_UNSPECIFIED, false,
+ "");
+ CSPSourceList source_list(false, false, {source});
+ ContentSecurityPolicy policy(
+ EmptyCspHeader(), {CSPDirective(CSPDirective::DefaultSrc, source_list)},
+ report_end_points);
+
+ EXPECT_TRUE(ContentSecurityPolicy::Allow(policy, CSPDirective::FrameSrc,
+ GURL("https://example.com/"), false,
+ &context, SourceLocation()));
+ EXPECT_FALSE(ContentSecurityPolicy::Allow(policy, CSPDirective::FrameSrc,
+ GURL("https://not-example.com/"),
+ false, &context, SourceLocation()));
+
+ // Register 'https' as bypassing CSP, which should now bypass is entirely.
+ context.AddSchemeToBypassCSP("https");
+
+ EXPECT_TRUE(ContentSecurityPolicy::Allow(policy, CSPDirective::FrameSrc,
+ GURL("https://example.com/"), false,
+ &context, SourceLocation()));
+ EXPECT_TRUE(ContentSecurityPolicy::Allow(policy, CSPDirective::FrameSrc,
+ GURL("https://not-example.com/"),
+ false, &context, SourceLocation()));
+}
+
+TEST(ContentSecurityPolicy, FilesystemAllowedWhenBypassingCSP) {
+ CSPContextTest context;
+ std::vector<std::string> report_end_points; // empty
+ CSPSource source("https", "example.com", false, url::PORT_UNSPECIFIED, false,
+ "");
+ CSPSourceList source_list(false, false, {source});
+ ContentSecurityPolicy policy(
+ EmptyCspHeader(), {CSPDirective(CSPDirective::DefaultSrc, source_list)},
+ report_end_points);
+
+ EXPECT_FALSE(ContentSecurityPolicy::Allow(
+ policy, CSPDirective::FrameSrc,
+ GURL("filesystem:https://example.com/file.txt"), false, &context,
+ SourceLocation()));
+ EXPECT_FALSE(ContentSecurityPolicy::Allow(
+ policy, CSPDirective::FrameSrc,
+ GURL("filesystem:https://not-example.com/file.txt"), false, &context,
+ SourceLocation()));
+
+ // Register 'https' as bypassing CSP, which should now bypass is entirely.
+ context.AddSchemeToBypassCSP("https");
+
+ EXPECT_TRUE(ContentSecurityPolicy::Allow(
+ policy, CSPDirective::FrameSrc,
+ GURL("filesystem:https://example.com/file.txt"), false, &context,
+ SourceLocation()));
+ EXPECT_TRUE(ContentSecurityPolicy::Allow(
+ policy, CSPDirective::FrameSrc,
+ GURL("filesystem:https://not-example.com/file.txt"), false, &context,
+ SourceLocation()));
+}
+
+TEST(ContentSecurityPolicy, BlobAllowedWhenBypassingCSP) {
+ CSPContextTest context;
+ std::vector<std::string> report_end_points; // empty
+ CSPSource source("https", "example.com", false, url::PORT_UNSPECIFIED, false,
+ "");
+ CSPSourceList source_list(false, false, {source});
+ ContentSecurityPolicy policy(
+ EmptyCspHeader(), {CSPDirective(CSPDirective::DefaultSrc, source_list)},
+ report_end_points);
+
+ EXPECT_FALSE(ContentSecurityPolicy::Allow(policy, CSPDirective::FrameSrc,
+ GURL("blob:https://example.com/"),
+ false, &context, SourceLocation()));
+ EXPECT_FALSE(ContentSecurityPolicy::Allow(
+ policy, CSPDirective::FrameSrc, GURL("blob:https://not-example.com/"),
+ false, &context, SourceLocation()));
+
+ // Register 'https' as bypassing CSP, which should now bypass is entirely.
+ context.AddSchemeToBypassCSP("https");
+
+ EXPECT_TRUE(ContentSecurityPolicy::Allow(policy, CSPDirective::FrameSrc,
+ GURL("blob:https://example.com/"),
+ false, &context, SourceLocation()));
+ EXPECT_TRUE(ContentSecurityPolicy::Allow(
+ policy, CSPDirective::FrameSrc, GURL("blob:https://not-example.com/"),
+ false, &context, SourceLocation()));
+}
+
} // namespace content
diff --git a/chromium/content/common/content_security_policy/csp_context.cc b/chromium/content/common/content_security_policy/csp_context.cc
index b7edf25b470..ab249dd3f25 100644
--- a/chromium/content/common/content_security_policy/csp_context.cc
+++ b/chromium/content/common/content_security_policy/csp_context.cc
@@ -10,16 +10,16 @@ CSPContext::CSPContext() : has_self_(false) {}
CSPContext::~CSPContext() {}
-bool CSPContext::Allow(const std::vector<ContentSecurityPolicy>& policies,
- CSPDirective::Name directive_name,
- const GURL& url,
- bool is_redirect) {
+bool CSPContext::IsAllowedByCsp(CSPDirective::Name directive_name,
+ const GURL& url,
+ bool is_redirect,
+ const SourceLocation& source_location) {
if (SchemeShouldBypassCSP(url.scheme_piece()))
return true;
- for (const auto& policy : policies) {
- if (!ContentSecurityPolicy::Allow(policy, directive_name, url, this,
- is_redirect))
+ for (const auto& policy : policies_) {
+ if (!ContentSecurityPolicy::Allow(policy, directive_name, url, is_redirect,
+ this, source_location))
return false;
}
return true;
@@ -52,37 +52,56 @@ bool CSPContext::AllowSelf(const GURL& url) {
return has_self_ && CSPSource::Allow(self_source_, url, this);
}
-bool CSPContext::ProtocolMatchesSelf(const GURL& url) {
+bool CSPContext::ProtocolIsSelf(const GURL& url) {
if (!has_self_)
return false;
- if (self_scheme_ == url::kHttpScheme)
- return url.SchemeIsHTTPOrHTTPS() || url.SchemeIsSuborigin();
return url.SchemeIs(self_scheme_);
}
-void CSPContext::LogToConsole(const std::string& message) {
- return;
+const std::string& CSPContext::GetSelfScheme() {
+ return self_scheme_;
}
bool CSPContext::SchemeShouldBypassCSP(const base::StringPiece& scheme) {
return false;
}
-bool CSPContext::SelfSchemeShouldBypassCSP() {
+bool CSPContext::SelfSchemeShouldBypassCsp() {
if (!has_self_)
return false;
return SchemeShouldBypassCSP(self_scheme_);
}
-void CSPContext::ReportViolation(
- const std::string& directive_text,
+void CSPContext::ReportContentSecurityPolicyViolation(
+ const CSPViolationParams& violation_params) {
+ return;
+}
+
+CSPViolationParams::CSPViolationParams() = default;
+
+CSPViolationParams::CSPViolationParams(
+ const std::string& directive,
const std::string& effective_directive,
- const std::string& message,
+ const std::string& console_message,
const GURL& blocked_url,
- const std::vector<std::string>& report_end_points,
+ const std::vector<std::string>& report_endpoints,
const std::string& header,
- blink::WebContentSecurityPolicyType disposition) {
- return;
-}
+ const blink::WebContentSecurityPolicyType& disposition,
+ bool after_redirect,
+ const SourceLocation& source_location)
+ : directive(directive),
+ effective_directive(effective_directive),
+ console_message(console_message),
+ blocked_url(blocked_url),
+ report_endpoints(report_endpoints),
+ header(header),
+ disposition(disposition),
+ after_redirect(after_redirect),
+ source_location(source_location) {}
+
+CSPViolationParams::CSPViolationParams(const CSPViolationParams& other) =
+ default;
+
+CSPViolationParams::~CSPViolationParams() {}
} // namespace content
diff --git a/chromium/content/common/content_security_policy/csp_context.h b/chromium/content/common/content_security_policy/csp_context.h
index bbc03017f23..cc5f3b50873 100644
--- a/chromium/content/common/content_security_policy/csp_context.h
+++ b/chromium/content/common/content_security_policy/csp_context.h
@@ -10,51 +10,106 @@
#include "content/common/content_export.h"
#include "content/common/content_security_policy/content_security_policy.h"
#include "content/common/content_security_policy_header.h"
+#include "content/common/navigation_params.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace content {
+struct CSPViolationParams;
+
// A CSPContext represents the system on which the Content-Security-Policy are
-// enforced. One must define via its virtual methods how to report violations,
-// how to log messages on the console and what is the set of scheme that bypass
-// the CSP.
-// Its main implementation is in content/browser/frame_host/csp_context_impl.h
+// enforced. One must define via its virtual methods how to report violations
+// and what is the set of scheme that bypass the CSP. Its main implementation
+// is in content/browser/frame_host/render_frame_host_impl.h
class CONTENT_EXPORT CSPContext {
public:
CSPContext();
virtual ~CSPContext();
- bool Allow(const std::vector<ContentSecurityPolicy>& policies,
- CSPDirective::Name directive_name,
- const GURL& url,
- bool is_redirect = false);
+ // Check if an |url| is allowed by the set of Content-Security-Policy. It will
+ // report any violation by:
+ // * displaying a console message.
+ // * triggering the "SecurityPolicyViolation" javascript event.
+ // * sending a JSON report to any uri defined with the "report-uri" directive.
+ // Returns true when the request can proceed, false otherwise.
+ bool IsAllowedByCsp(CSPDirective::Name directive_name,
+ const GURL& url,
+ bool is_redirect,
+ const SourceLocation& source_location);
void SetSelf(const url::Origin origin);
bool AllowSelf(const GURL& url);
- bool ProtocolMatchesSelf(const GURL& url);
+ bool ProtocolIsSelf(const GURL& url);
+ const std::string& GetSelfScheme();
- virtual void LogToConsole(const std::string& message);
- virtual void ReportViolation(
- const std::string& directive_text,
- const std::string& effective_directive,
- const std::string& message,
- const GURL& blocked_url,
- const std::vector<std::string>& report_end_points,
- const std::string& header,
- blink::WebContentSecurityPolicyType disposition);
+ virtual void ReportContentSecurityPolicyViolation(
+ const CSPViolationParams& violation_params);
- bool SelfSchemeShouldBypassCSP();
+ bool SelfSchemeShouldBypassCsp();
+
+ void ResetContentSecurityPolicies() { policies_.clear(); }
+ void AddContentSecurityPolicy(const ContentSecurityPolicy& policy) {
+ policies_.push_back(policy);
+ }
- private:
virtual bool SchemeShouldBypassCSP(const base::StringPiece& scheme);
+ private:
bool has_self_ = false;
std::string self_scheme_;
CSPSource self_source_;
+ std::vector<ContentSecurityPolicy> policies_;
+
DISALLOW_COPY_AND_ASSIGN(CSPContext);
};
+// Used in CSPContext::ReportViolation()
+struct CONTENT_EXPORT CSPViolationParams {
+ CSPViolationParams();
+ CSPViolationParams(const std::string& directive,
+ const std::string& effective_directive,
+ const std::string& console_message,
+ const GURL& blocked_url,
+ const std::vector<std::string>& report_endpoints,
+ const std::string& header,
+ const blink::WebContentSecurityPolicyType& disposition,
+ bool after_redirect,
+ const SourceLocation& source_location);
+ CSPViolationParams(const CSPViolationParams& other);
+ ~CSPViolationParams();
+
+ // The name of the directive that violates the policy. |directive| might be a
+ // directive that serves as a fallback to the |effective_directive|.
+ std::string directive;
+
+ // The name the effective directive that was checked against.
+ std::string effective_directive;
+
+ // The console message to be displayed to the user.
+ std::string console_message;
+
+ // The URL that was blocked by the policy.
+ GURL blocked_url;
+
+ // The set of URI where a JSON-formatted report of the violation should be
+ // sent.
+ std::vector<std::string> report_endpoints;
+
+ // The raw content security policy header that was violated.
+ std::string header;
+
+ // Each policy has an associated disposition, which is either "enforce" or
+ // "report".
+ blink::WebContentSecurityPolicyType disposition;
+
+ // Whether or not the violation happens after a redirect.
+ bool after_redirect;
+
+ // The source code location that triggered the blocked navigation.
+ SourceLocation source_location;
+};
+
} // namespace content
#endif // CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_CONTEXT_H_
diff --git a/chromium/content/common/content_security_policy/csp_context_unittest.cc b/chromium/content/common/content_security_policy/csp_context_unittest.cc
index dd508e00b53..c0fdfd99f7f 100644
--- a/chromium/content/common/content_security_policy/csp_context_unittest.cc
+++ b/chromium/content/common/content_security_policy/csp_context_unittest.cc
@@ -4,6 +4,7 @@
#include "content/common/content_security_policy/csp_context.h"
#include "content/common/content_security_policy_header.h"
+#include "content/common/navigation_params.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace content {
@@ -24,8 +25,9 @@ class CSPContextTest : public CSPContext {
}
private:
- void LogToConsole(const std::string& message) override {
- console_message_ = message;
+ void ReportContentSecurityPolicyViolation(
+ const CSPViolationParams& violation_params) override {
+ console_message_ = violation_params.console_message;
}
std::string console_message_;
std::vector<std::string> scheme_to_bypass_;
@@ -35,25 +37,30 @@ class CSPContextTest : public CSPContext {
ContentSecurityPolicy BuildPolicy(CSPDirective::Name directive_name,
std::vector<CSPSource> sources) {
return ContentSecurityPolicy(
- blink::WebContentSecurityPolicyTypeEnforce,
- blink::WebContentSecurityPolicySourceHTTP,
+ ContentSecurityPolicyHeader(std::string(), // header
+ blink::kWebContentSecurityPolicyTypeEnforce,
+ blink::kWebContentSecurityPolicySourceHTTP),
{CSPDirective(directive_name, CSPSourceList(false, false, sources))},
- std::vector<std::string>(), // report_end_points
- std::string()); // header
+ std::vector<std::string>()); // report_end_points
}
-} // namespace;
+} // namespace
TEST(CSPContextTest, SchemeShouldBypassCSP) {
- CSPContextTest context;
CSPSource source("", "example.com", false, url::PORT_UNSPECIFIED, false, "");
- ContentSecurityPolicy policy =
- BuildPolicy(CSPDirective::DefaultSrc, {source});
- EXPECT_FALSE(context.Allow({policy}, CSPDirective::FrameSrc,
- GURL("data:text/html,<html></html>")));
+ CSPContextTest context;
+ context.AddContentSecurityPolicy(
+ BuildPolicy(CSPDirective::DefaultSrc, {source}));
+
+ EXPECT_FALSE(context.IsAllowedByCsp(CSPDirective::FrameSrc,
+ GURL("data:text/html,<html></html>"),
+ false, SourceLocation()));
+
context.AddSchemeToBypassCSP("data");
- EXPECT_TRUE(context.Allow({policy}, CSPDirective::FrameSrc,
- GURL("data:text/html,<html></html>")));
+
+ EXPECT_TRUE(context.IsAllowedByCsp(CSPDirective::FrameSrc,
+ GURL("data:text/html,<html></html>"),
+ false, SourceLocation()));
}
TEST(CSPContextTest, MultiplePolicies) {
@@ -64,21 +71,19 @@ TEST(CSPContextTest, MultiplePolicies) {
CSPSource source_b("", "b.com", false, url::PORT_UNSPECIFIED, false, "");
CSPSource source_c("", "c.com", false, url::PORT_UNSPECIFIED, false, "");
- ContentSecurityPolicy policy1 =
- BuildPolicy(CSPDirective::FrameSrc, {source_a, source_b});
- ContentSecurityPolicy policy2 =
- BuildPolicy(CSPDirective::FrameSrc, {source_a, source_c});
-
- std::vector<ContentSecurityPolicy> policies = {policy1, policy2};
-
- EXPECT_TRUE(
- context.Allow(policies, CSPDirective::FrameSrc, GURL("http://a.com")));
- EXPECT_FALSE(
- context.Allow(policies, CSPDirective::FrameSrc, GURL("http://b.com")));
- EXPECT_FALSE(
- context.Allow(policies, CSPDirective::FrameSrc, GURL("http://c.com")));
- EXPECT_FALSE(
- context.Allow(policies, CSPDirective::FrameSrc, GURL("http://d.com")));
+ context.AddContentSecurityPolicy(
+ BuildPolicy(CSPDirective::FrameSrc, {source_a, source_b}));
+ context.AddContentSecurityPolicy(
+ BuildPolicy(CSPDirective::FrameSrc, {source_a, source_c}));
+
+ EXPECT_TRUE(context.IsAllowedByCsp(
+ CSPDirective::FrameSrc, GURL("http://a.com"), false, SourceLocation()));
+ EXPECT_FALSE(context.IsAllowedByCsp(
+ CSPDirective::FrameSrc, GURL("http://b.com"), false, SourceLocation()));
+ EXPECT_FALSE(context.IsAllowedByCsp(
+ CSPDirective::FrameSrc, GURL("http://c.com"), false, SourceLocation()));
+ EXPECT_FALSE(context.IsAllowedByCsp(
+ CSPDirective::FrameSrc, GURL("http://d.com"), false, SourceLocation()));
}
} // namespace content
diff --git a/chromium/content/common/content_security_policy/csp_disposition_enum.h b/chromium/content/common/content_security_policy/csp_disposition_enum.h
new file mode 100644
index 00000000000..8faf3d9863c
--- /dev/null
+++ b/chromium/content/common/content_security_policy/csp_disposition_enum.h
@@ -0,0 +1,19 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_DISPOSITION_ENUM_
+#define CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_DISPOSITION_ENUM_
+
+namespace content {
+
+// Whether or not the Content Security Policy should be enforced.
+enum class CSPDisposition {
+ DO_NOT_CHECK,
+ CHECK,
+
+ LAST = CHECK
+};
+
+} // namespace content
+#endif // CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_DISPOSITION_ENUM_
diff --git a/chromium/content/common/content_security_policy/csp_source.cc b/chromium/content/common/content_security_policy/csp_source.cc
index 59657d16d2b..7ebd7e75506 100644
--- a/chromium/content/common/content_security_policy/csp_source.cc
+++ b/chromium/content/common/content_security_policy/csp_source.cc
@@ -24,16 +24,46 @@ int DefaultPortForScheme(const std::string& scheme) {
return url::DefaultPortForScheme(scheme.data(), scheme.size());
}
-bool SourceAllowScheme(const CSPSource& source,
- const GURL& url,
- CSPContext* context) {
- if (source.scheme.empty())
- return context->ProtocolMatchesSelf(url);
- if (source.scheme == url::kHttpScheme)
- return url.SchemeIsHTTPOrHTTPS();
- if (source.scheme == url::kWsScheme)
- return url.SchemeIsWSOrWSS();
- return url.SchemeIs(source.scheme);
+// NotMatching is the only negative member, the rest are different types of
+// matches. NotMatching should always be 0 to let if statements work nicely
+enum class PortMatchingResult {
+ NotMatching,
+ MatchingWildcard,
+ MatchingUpgrade,
+ MatchingExact
+};
+enum class SchemeMatchingResult { NotMatching, MatchingUpgrade, MatchingExact };
+
+SchemeMatchingResult SourceAllowScheme(const CSPSource& source,
+ const GURL& url,
+ CSPContext* context) {
+ const std::string& source_scheme =
+ source.scheme.empty() ? context->GetSelfScheme() : source.scheme;
+
+ if (source_scheme.empty()) {
+ if (context->ProtocolIsSelf(url))
+ return SchemeMatchingResult::MatchingExact;
+ return SchemeMatchingResult::NotMatching;
+ }
+
+ if (url.SchemeIs(source_scheme))
+ return SchemeMatchingResult::MatchingExact;
+
+ if ((source_scheme == url::kHttpScheme && url.SchemeIs(url::kHttpsScheme)) ||
+ (source_scheme == url::kHttpScheme &&
+ url.SchemeIs(url::kHttpsSuboriginScheme)) ||
+ (source_scheme == url::kWsScheme && url.SchemeIs(url::kWssScheme))) {
+ return SchemeMatchingResult::MatchingUpgrade;
+ }
+
+ if ((source_scheme == url::kHttpScheme &&
+ url.SchemeIs(url::kHttpSuboriginScheme)) ||
+ (source_scheme == url::kHttpsScheme &&
+ url.SchemeIs(url::kHttpsSuboriginScheme))) {
+ return SchemeMatchingResult::MatchingExact;
+ }
+
+ return SchemeMatchingResult::NotMatching;
}
bool SourceAllowHost(const CSPSource& source, const GURL& url) {
@@ -50,22 +80,33 @@ bool SourceAllowHost(const CSPSource& source, const GURL& url) {
return url.host() == source.host;
}
-bool SourceAllowPort(const CSPSource& source, const GURL& url) {
+PortMatchingResult SourceAllowPort(const CSPSource& source, const GURL& url) {
int url_port = url.EffectiveIntPort();
if (source.is_port_wildcard)
- return true;
+ return PortMatchingResult::MatchingWildcard;
- if (source.port == url::PORT_UNSPECIFIED)
- return DefaultPortForScheme(url.scheme()) == url_port;
+ if (source.port == url_port) {
+ if (source.port == url::PORT_UNSPECIFIED)
+ return PortMatchingResult::MatchingWildcard;
+ return PortMatchingResult::MatchingExact;
+ }
- if (source.port == url_port)
- return true;
+ if (source.port == url::PORT_UNSPECIFIED) {
+ if (DefaultPortForScheme(url.scheme()) == url_port) {
+ return PortMatchingResult::MatchingWildcard;
+ }
+ return PortMatchingResult::NotMatching;
+ }
- if (source.port == 80 && url_port == 443)
- return true;
+ int source_port = source.port;
+ if (source_port == url::PORT_UNSPECIFIED)
+ source_port = DefaultPortForScheme(source.scheme);
+
+ if (source_port == 80 && url_port == 443)
+ return PortMatchingResult::MatchingUpgrade;
- return false;
+ return PortMatchingResult::NotMatching;
}
bool SourceAllowPath(const CSPSource& source,
@@ -93,6 +134,20 @@ bool SourceAllowPath(const CSPSource& source,
return source.path == url_path;
}
+bool inline requiresUpgrade(const PortMatchingResult result) {
+ return result == PortMatchingResult::MatchingUpgrade;
+}
+bool inline requiresUpgrade(const SchemeMatchingResult result) {
+ return result == SchemeMatchingResult::MatchingUpgrade;
+}
+bool inline canUpgrade(const PortMatchingResult result) {
+ return result == PortMatchingResult::MatchingUpgrade ||
+ result == PortMatchingResult::MatchingWildcard;
+}
+bool inline canUpgrade(const SchemeMatchingResult result) {
+ return result == SchemeMatchingResult::MatchingUpgrade;
+}
+
} // namespace
CSPSource::CSPSource()
@@ -129,10 +184,20 @@ bool CSPSource::Allow(const CSPSource& source,
CSPContext* context,
bool is_redirect) {
if (source.IsSchemeOnly())
- return SourceAllowScheme(source, url, context);
+ return SourceAllowScheme(source, url, context) !=
+ SchemeMatchingResult::NotMatching;
+
+ PortMatchingResult portResult = SourceAllowPort(source, url);
+ SchemeMatchingResult schemeResult = SourceAllowScheme(source, url, context);
+
+ if (requiresUpgrade(schemeResult) && !canUpgrade(portResult))
+ return false;
+ if (requiresUpgrade(portResult) && !canUpgrade(schemeResult))
+ return false;
- return SourceAllowScheme(source, url, context) &&
- SourceAllowHost(source, url) && SourceAllowPort(source, url) &&
+ return schemeResult != SchemeMatchingResult::NotMatching &&
+ SourceAllowHost(source, url) &&
+ portResult != PortMatchingResult::NotMatching &&
SourceAllowPath(source, url, is_redirect);
}
diff --git a/chromium/content/common/content_security_policy/csp_source_list.cc b/chromium/content/common/content_security_policy/csp_source_list.cc
index 5f6511aa764..be6ba9c4b06 100644
--- a/chromium/content/common/content_security_policy/csp_source_list.cc
+++ b/chromium/content/common/content_security_policy/csp_source_list.cc
@@ -8,25 +8,6 @@ namespace content {
namespace {
-const GURL ExtractInnerURL(const GURL& url) {
- if (const GURL* inner_url = url.inner_url())
- return *inner_url;
- else
- // TODO(arthursonzogni): revisit this once GURL::inner_url support blob-URL.
- return GURL(url.path());
-}
-
-const GURL GetEffectiveURL(CSPContext* context, const GURL& url) {
- // Due to backwards-compatibility concerns, we allow 'self' to match blob and
- // filesystem inner URLs if we are in a context that bypasses
- // ContentSecurityPolicy in the main world.
- if (context->SelfSchemeShouldBypassCSP()) {
- if (url.SchemeIsFileSystem() || url.SchemeIsBlob())
- return ExtractInnerURL(url);
- }
- return url;
-}
-
bool AllowFromSources(const GURL& url,
const std::vector<CSPSource>& sources,
CSPContext* context,
@@ -64,19 +45,15 @@ bool CSPSourceList::Allow(const CSPSourceList& source_list,
if (source_list.allow_star) {
if (url.SchemeIsHTTPOrHTTPS() || url.SchemeIsSuborigin() ||
url.SchemeIsWSOrWSS() || url.SchemeIs("ftp") ||
- context->ProtocolMatchesSelf(url))
+ context->ProtocolIsSelf(url))
return true;
return AllowFromSources(url, source_list.sources, context, is_redirect);
}
- const GURL effective_url = GetEffectiveURL(context, url);
-
- if (source_list.allow_self && context->AllowSelf(effective_url))
- return true;
+ if (source_list.allow_self && context->AllowSelf(url)) return true;
- return AllowFromSources(effective_url, source_list.sources, context,
- is_redirect);
+ return AllowFromSources(url, source_list.sources, context, is_redirect);
}
std::string CSPSourceList::ToString() const {
diff --git a/chromium/content/common/content_security_policy/csp_source_list_unittest.cc b/chromium/content/common/content_security_policy/csp_source_list_unittest.cc
index cbec246f867..43a5cadf579 100644
--- a/chromium/content/common/content_security_policy/csp_source_list_unittest.cc
+++ b/chromium/content/common/content_security_policy/csp_source_list_unittest.cc
@@ -10,21 +10,6 @@ namespace content {
namespace {
-class CSPContextTest : public CSPContext {
- public:
- void AddSchemeToBypassCSP(const std::string& scheme) {
- scheme_to_bypass_.push_back(scheme);
- }
-
- bool SchemeShouldBypassCSP(const base::StringPiece& scheme) override {
- return std::find(scheme_to_bypass_.begin(), scheme_to_bypass_.end(),
- scheme) != scheme_to_bypass_.end();
- }
-
- private:
- std::vector<std::string> scheme_to_bypass_;
-};
-
// Allow() is an abbreviation of CSPSourceList::Allow(). Useful for writting
// test expectations on one line.
bool Allow(const CSPSourceList& source_list,
@@ -36,8 +21,8 @@ bool Allow(const CSPSourceList& source_list,
} // namespace
-TEST(CSPSourceListTest, MultipleSource) {
- CSPContextTest context;
+TEST(CSPSourceList, MultipleSource) {
+ CSPContext context;
context.SetSelf(url::Origin(GURL("http://example.com")));
CSPSourceList source_list(
false, // allow_self
@@ -50,7 +35,7 @@ TEST(CSPSourceListTest, MultipleSource) {
}
TEST(CSPSourceList, AllowStar) {
- CSPContextTest context;
+ CSPContext context;
context.SetSelf(url::Origin(GURL("http://example.com")));
CSPSourceList source_list(false, // allow_self
true, // allow_star:
@@ -73,7 +58,7 @@ TEST(CSPSourceList, AllowStar) {
}
TEST(CSPSourceList, AllowSelf) {
- CSPContextTest context;
+ CSPContext context;
context.SetSelf(url::Origin(GURL("http://example.com")));
CSPSourceList source_list(true, // allow_self
false, // allow_star:
@@ -84,76 +69,6 @@ TEST(CSPSourceList, AllowSelf) {
EXPECT_FALSE(Allow(source_list, GURL("ws://example.com"), &context));
}
-TEST(CSPSourceList, AllowSelfWithFilesystem) {
- CSPContextTest context;
- context.SetSelf(url::Origin(GURL("https://a.test")));
- CSPSourceList source_list(true, // allow_self
- false, // allow_star:
- std::vector<CSPSource>()); // source_list
-
- GURL filesystem_url("filesystem:https://a.test/file.txt");
-
- EXPECT_TRUE(Allow(source_list, GURL("https://a.test/"), &context));
- EXPECT_FALSE(Allow(source_list, filesystem_url, &context));
-
- // Register 'https' as bypassing CSP, which should trigger the inner URL
- // behavior.
- context.AddSchemeToBypassCSP("https");
-
- EXPECT_TRUE(Allow(source_list, GURL("https://a.test/"), &context));
- EXPECT_TRUE(Allow(source_list, filesystem_url, &context));
-}
-
-TEST(CSPSourceList, BlobDisallowedWhenBypassingSelfScheme) {
- CSPContextTest context;
- context.SetSelf(url::Origin(GURL("https://a.test")));
- CSPSource blob(
- CSPSource("blob", "", false, url::PORT_UNSPECIFIED, false, ""));
- CSPSourceList source_list(true, // allow_self
- false, // allow_star:
- {blob}); // source_list
-
- GURL blob_url_self("blob:https://a.test/1be95204-93d6-4GUID");
- GURL blob_url_not_self("blob:https://b.test/1be95204-93d6-4GUID");
-
- EXPECT_TRUE(Allow(source_list, blob_url_self, &context));
- EXPECT_TRUE(Allow(source_list, blob_url_not_self, &context));
-
- // Register 'https' as bypassing CSP, which should trigger the inner URL
- // behavior.
- context.AddSchemeToBypassCSP("https");
-
- EXPECT_TRUE(Allow(source_list, blob_url_self, &context));
- // TODO(arthursonzogni, mkwst): This should be true
- // see http://crbug.com/692046
- EXPECT_FALSE(Allow(source_list, blob_url_not_self, &context));
-}
-
-TEST(CSPSourceList, FilesystemDisallowedWhenBypassingSelfScheme) {
- CSPContextTest context;
- context.SetSelf(url::Origin(GURL("https://a.test")));
- CSPSource filesystem(
- CSPSource("filesystem", "", false, url::PORT_UNSPECIFIED, false, ""));
- CSPSourceList source_list(true, // allow_self
- false, // allow_star:
- {filesystem}); // source_list
-
- GURL filesystem_url_self("filesystem:https://a.test/file.txt");
- GURL filesystem_url_not_self("filesystem:https://b.test/file.txt");
-
- EXPECT_TRUE(Allow(source_list, filesystem_url_self, &context));
- EXPECT_TRUE(Allow(source_list, filesystem_url_not_self, &context));
-
- // Register 'https' as bypassing CSP, which should trigger the inner URL
- // behavior.
- context.AddSchemeToBypassCSP("https");
-
- EXPECT_TRUE(Allow(source_list, filesystem_url_self, &context));
- // TODO(arthursonzogni, mkwst): This should be true
- // see http://crbug.com/692046
- EXPECT_FALSE(Allow(source_list, filesystem_url_not_self, &context));
-}
-
TEST(CSPSourceList, AllowSelfWithUnspecifiedPort) {
CSPContext context;
context.SetSelf(url::Origin(GURL("chrome://print")));
@@ -168,7 +83,7 @@ TEST(CSPSourceList, AllowSelfWithUnspecifiedPort) {
}
TEST(CSPSourceList, AllowNone) {
- CSPContextTest context;
+ CSPContext context;
context.SetSelf(url::Origin(GURL("http://example.com")));
CSPSourceList source_list(false, // allow_self
false, // allow_star:
diff --git a/chromium/content/common/content_security_policy/csp_source_unittest.cc b/chromium/content/common/content_security_policy/csp_source_unittest.cc
index 1e8a2a4b82a..50879f2719f 100644
--- a/chromium/content/common/content_security_policy/csp_source_unittest.cc
+++ b/chromium/content/common/content_security_policy/csp_source_unittest.cc
@@ -46,8 +46,8 @@ TEST(CSPSourceTest, AllowScheme) {
CSPSource source("http", "", false, url::PORT_UNSPECIFIED, false, "");
EXPECT_TRUE(Allow(source, GURL("http://a.com"), &context));
EXPECT_TRUE(Allow(source, GURL("https://a.com"), &context));
- // TODO(mkwst, arthursonzogni): It is weird to upgrade the scheme without
- // the port. See http://crbug.com/692499
+ // This passes because the source is "scheme only" so the upgrade is
+ // allowed.
EXPECT_TRUE(Allow(source, GURL("https://a.com:80"), &context));
EXPECT_FALSE(Allow(source, GURL("ftp://a.com"), &context));
EXPECT_FALSE(Allow(source, GURL("ws://a.com"), &context));
@@ -103,9 +103,8 @@ TEST(CSPSourceTest, AllowScheme) {
EXPECT_FALSE(Allow(source, GURL("http://a.com"), &context));
EXPECT_TRUE(Allow(source, GURL("https://a.com"), &context));
EXPECT_FALSE(Allow(source, GURL("http-so://a.com"), &context));
- // TODO(mkwst, arthursonzogni): Maybe it should return true.
- // See http://crbug.com/692442:
- EXPECT_FALSE(Allow(source, GURL("https-so://a.com"), &context));
+ // TODO(jochen): Maybe it should return false?
+ EXPECT_TRUE(Allow(source, GURL("https-so://a.com"), &context));
EXPECT_FALSE(Allow(source, GURL("ftp://a.com"), &context));
// Self's scheme is not in the http familly.
@@ -203,9 +202,9 @@ TEST(CSPSourceTest, AllowPort) {
{
CSPSource source("", "a.com", false, 80, false, "");
EXPECT_TRUE(Allow(source, GURL("https://a.com:443"), &context));
- // TODO(mkwst, arthursonzogni): It is weird to upgrade the port without the
- // sheme. See http://crbug.com/692499
- EXPECT_TRUE(Allow(source, GURL("http://a.com:443"), &context));
+ // Should not allow scheme upgrades unless both port and scheme are
+ // upgraded.
+ EXPECT_FALSE(Allow(source, GURL("http://a.com:443"), &context));
}
// Host is * but port is specified
@@ -284,7 +283,7 @@ TEST(CSPSourceTest, RedirectMatching) {
CSPSource source("http", "a.com", false, 8000, false, "/bar/");
EXPECT_TRUE(Allow(source, GURL("http://a.com:8000/"), &context, true));
EXPECT_TRUE(Allow(source, GURL("http://a.com:8000/foo"), &context, true));
- EXPECT_TRUE(Allow(source, GURL("https://a.com:8000/foo"), &context, true));
+ EXPECT_FALSE(Allow(source, GURL("https://a.com:8000/foo"), &context, true));
EXPECT_FALSE(
Allow(source, GURL("http://not-a.com:8000/foo"), &context, true));
EXPECT_FALSE(Allow(source, GURL("http://a.com:9000/foo/"), &context, false));
@@ -325,4 +324,14 @@ TEST(CSPSourceTest, ToString) {
}
}
+TEST(CSPSourceTest, UpgradeRequests) {
+ CSPContext context;
+ CSPSource source("http", "a.com", false, 80, false, "");
+ EXPECT_TRUE(Allow(source, GURL("http://a.com:80"), &context, true));
+ EXPECT_FALSE(Allow(source, GURL("https://a.com:80"), &context, true));
+ EXPECT_FALSE(Allow(source, GURL("http://a.com:443"), &context, true));
+ EXPECT_TRUE(Allow(source, GURL("https://a.com:443"), &context, true));
+ EXPECT_TRUE(Allow(source, GURL("https://a.com"), &context, true));
+}
+
} // namespace content
diff --git a/chromium/content/common/content_security_policy_header.cc b/chromium/content/common/content_security_policy_header.cc
new file mode 100644
index 00000000000..fcad2fa1358
--- /dev/null
+++ b/chromium/content/common/content_security_policy_header.cc
@@ -0,0 +1,20 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/content_security_policy_header.h"
+
+namespace content {
+
+ContentSecurityPolicyHeader::ContentSecurityPolicyHeader()
+ : header_value(std::string()),
+ type(blink::kWebContentSecurityPolicyTypeEnforce),
+ source(blink::kWebContentSecurityPolicySourceHTTP) {}
+
+ContentSecurityPolicyHeader::ContentSecurityPolicyHeader(
+ const std::string& header_value,
+ blink::WebContentSecurityPolicyType type,
+ blink::WebContentSecurityPolicySource source)
+ : header_value(header_value), type(type), source(source) {}
+
+} // namespace content
diff --git a/chromium/content/common/content_security_policy_header.h b/chromium/content/common/content_security_policy_header.h
index cef4e066417..e4b65d38c88 100644
--- a/chromium/content/common/content_security_policy_header.h
+++ b/chromium/content/common/content_security_policy_header.h
@@ -6,6 +6,8 @@
#define CONTENT_COMMON_CONTENT_SECURITY_POLICY_HEADER_
#include <string>
+
+#include "content/common/content_export.h"
#include "third_party/WebKit/public/platform/WebContentSecurityPolicy.h"
namespace content {
@@ -13,7 +15,12 @@ namespace content {
// Represents a single Content Security Policy header (i.e. coming from
// a single Content-Security-Policy header in an HTTP response, or from
// a single <meta http-equiv="Content-Security-Policy"...> element).
-struct ContentSecurityPolicyHeader {
+struct CONTENT_EXPORT ContentSecurityPolicyHeader {
+ ContentSecurityPolicyHeader();
+ ContentSecurityPolicyHeader(const std::string& header_value,
+ blink::WebContentSecurityPolicyType type,
+ blink::WebContentSecurityPolicySource source);
+
std::string header_value;
blink::WebContentSecurityPolicyType type;
blink::WebContentSecurityPolicySource source;
diff --git a/chromium/content/common/cursors/webcursor.cc b/chromium/content/common/cursors/webcursor.cc
index 98addd7a4c1..a85d6a8775f 100644
--- a/chromium/content/common/cursors/webcursor.cc
+++ b/chromium/content/common/cursors/webcursor.cc
@@ -15,9 +15,7 @@ static const int kMaxCursorDimension = 1024;
namespace content {
-WebCursor::WebCursor()
- : type_(WebCursorInfo::TypePointer),
- custom_scale_(1) {
+WebCursor::WebCursor() : type_(WebCursorInfo::kTypePointer), custom_scale_(1) {
InitPlatformData();
}
@@ -86,7 +84,7 @@ bool WebCursor::Deserialize(base::PickleIterator* iter) {
type_ = type;
- if (type == WebCursorInfo::TypeCustom) {
+ if (type == WebCursorInfo::kTypeCustom) {
if (size_x > 0 && size_y > 0) {
// The * 4 is because the expected format is an array of RGBA pixel
// values.
@@ -133,7 +131,7 @@ bool WebCursor::Serialize(base::Pickle* pickle) const {
}
bool WebCursor::IsCustom() const {
- return type_ == WebCursorInfo::TypeCustom;
+ return type_ == WebCursorInfo::kTypeCustom;
}
bool WebCursor::IsEqual(const WebCursor& other) const {
@@ -150,7 +148,7 @@ bool WebCursor::IsEqual(const WebCursor& other) const {
}
void WebCursor::Clear() {
- type_ = WebCursorInfo::TypePointer;
+ type_ = WebCursorInfo::kTypePointer;
hotspot_.set_x(0);
hotspot_.set_y(0);
custom_size_.set_width(0);
diff --git a/chromium/content/common/cursors/webcursor.h b/chromium/content/common/cursors/webcursor.h
index 07d2bca472b..4f7bd59f41f 100644
--- a/chromium/content/common/cursors/webcursor.h
+++ b/chromium/content/common/cursors/webcursor.h
@@ -9,7 +9,7 @@
#include "build/build_config.h"
#include "content/common/content_export.h"
-#include "third_party/WebKit/public/platform/WebCursorInfo.h"
+#include "content/public/common/cursor_info.h"
#include "ui/display/display.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/size.h"
@@ -44,23 +44,6 @@ namespace content {
// WebCursor.
class CONTENT_EXPORT WebCursor {
public:
- struct CursorInfo {
- explicit CursorInfo(blink::WebCursorInfo::Type cursor_type)
- : type(cursor_type),
- image_scale_factor(1) {
- }
-
- CursorInfo()
- : type(blink::WebCursorInfo::TypePointer),
- image_scale_factor(1) {
- }
-
- blink::WebCursorInfo::Type type;
- gfx::Point hotspot;
- float image_scale_factor;
- SkBitmap custom_image;
- };
-
WebCursor();
~WebCursor();
diff --git a/chromium/content/common/cursors/webcursor_aura.cc b/chromium/content/common/cursors/webcursor_aura.cc
index 6aad277c0ad..dd43fe85efc 100644
--- a/chromium/content/common/cursors/webcursor_aura.cc
+++ b/chromium/content/common/cursors/webcursor_aura.cc
@@ -15,93 +15,93 @@ namespace content {
gfx::NativeCursor WebCursor::GetNativeCursor() {
switch (type_) {
- case WebCursorInfo::TypePointer:
+ case WebCursorInfo::kTypePointer:
return ui::kCursorPointer;
- case WebCursorInfo::TypeCross:
+ case WebCursorInfo::kTypeCross:
return ui::kCursorCross;
- case WebCursorInfo::TypeHand:
+ case WebCursorInfo::kTypeHand:
return ui::kCursorHand;
- case WebCursorInfo::TypeIBeam:
+ case WebCursorInfo::kTypeIBeam:
return ui::kCursorIBeam;
- case WebCursorInfo::TypeWait:
+ case WebCursorInfo::kTypeWait:
return ui::kCursorWait;
- case WebCursorInfo::TypeHelp:
+ case WebCursorInfo::kTypeHelp:
return ui::kCursorHelp;
- case WebCursorInfo::TypeEastResize:
+ case WebCursorInfo::kTypeEastResize:
return ui::kCursorEastResize;
- case WebCursorInfo::TypeNorthResize:
+ case WebCursorInfo::kTypeNorthResize:
return ui::kCursorNorthResize;
- case WebCursorInfo::TypeNorthEastResize:
+ case WebCursorInfo::kTypeNorthEastResize:
return ui::kCursorNorthEastResize;
- case WebCursorInfo::TypeNorthWestResize:
+ case WebCursorInfo::kTypeNorthWestResize:
return ui::kCursorNorthWestResize;
- case WebCursorInfo::TypeSouthResize:
+ case WebCursorInfo::kTypeSouthResize:
return ui::kCursorSouthResize;
- case WebCursorInfo::TypeSouthEastResize:
+ case WebCursorInfo::kTypeSouthEastResize:
return ui::kCursorSouthEastResize;
- case WebCursorInfo::TypeSouthWestResize:
+ case WebCursorInfo::kTypeSouthWestResize:
return ui::kCursorSouthWestResize;
- case WebCursorInfo::TypeWestResize:
+ case WebCursorInfo::kTypeWestResize:
return ui::kCursorWestResize;
- case WebCursorInfo::TypeNorthSouthResize:
+ case WebCursorInfo::kTypeNorthSouthResize:
return ui::kCursorNorthSouthResize;
- case WebCursorInfo::TypeEastWestResize:
+ case WebCursorInfo::kTypeEastWestResize:
return ui::kCursorEastWestResize;
- case WebCursorInfo::TypeNorthEastSouthWestResize:
+ case WebCursorInfo::kTypeNorthEastSouthWestResize:
return ui::kCursorNorthEastSouthWestResize;
- case WebCursorInfo::TypeNorthWestSouthEastResize:
+ case WebCursorInfo::kTypeNorthWestSouthEastResize:
return ui::kCursorNorthWestSouthEastResize;
- case WebCursorInfo::TypeColumnResize:
+ case WebCursorInfo::kTypeColumnResize:
return ui::kCursorColumnResize;
- case WebCursorInfo::TypeRowResize:
+ case WebCursorInfo::kTypeRowResize:
return ui::kCursorRowResize;
- case WebCursorInfo::TypeMiddlePanning:
+ case WebCursorInfo::kTypeMiddlePanning:
return ui::kCursorMiddlePanning;
- case WebCursorInfo::TypeEastPanning:
+ case WebCursorInfo::kTypeEastPanning:
return ui::kCursorEastPanning;
- case WebCursorInfo::TypeNorthPanning:
+ case WebCursorInfo::kTypeNorthPanning:
return ui::kCursorNorthPanning;
- case WebCursorInfo::TypeNorthEastPanning:
+ case WebCursorInfo::kTypeNorthEastPanning:
return ui::kCursorNorthEastPanning;
- case WebCursorInfo::TypeNorthWestPanning:
+ case WebCursorInfo::kTypeNorthWestPanning:
return ui::kCursorNorthWestPanning;
- case WebCursorInfo::TypeSouthPanning:
+ case WebCursorInfo::kTypeSouthPanning:
return ui::kCursorSouthPanning;
- case WebCursorInfo::TypeSouthEastPanning:
+ case WebCursorInfo::kTypeSouthEastPanning:
return ui::kCursorSouthEastPanning;
- case WebCursorInfo::TypeSouthWestPanning:
+ case WebCursorInfo::kTypeSouthWestPanning:
return ui::kCursorSouthWestPanning;
- case WebCursorInfo::TypeWestPanning:
+ case WebCursorInfo::kTypeWestPanning:
return ui::kCursorWestPanning;
- case WebCursorInfo::TypeMove:
+ case WebCursorInfo::kTypeMove:
return ui::kCursorMove;
- case WebCursorInfo::TypeVerticalText:
+ case WebCursorInfo::kTypeVerticalText:
return ui::kCursorVerticalText;
- case WebCursorInfo::TypeCell:
+ case WebCursorInfo::kTypeCell:
return ui::kCursorCell;
- case WebCursorInfo::TypeContextMenu:
+ case WebCursorInfo::kTypeContextMenu:
return ui::kCursorContextMenu;
- case WebCursorInfo::TypeAlias:
+ case WebCursorInfo::kTypeAlias:
return ui::kCursorAlias;
- case WebCursorInfo::TypeProgress:
+ case WebCursorInfo::kTypeProgress:
return ui::kCursorProgress;
- case WebCursorInfo::TypeNoDrop:
+ case WebCursorInfo::kTypeNoDrop:
return ui::kCursorNoDrop;
- case WebCursorInfo::TypeCopy:
+ case WebCursorInfo::kTypeCopy:
return ui::kCursorCopy;
- case WebCursorInfo::TypeNone:
+ case WebCursorInfo::kTypeNone:
return ui::kCursorNone;
- case WebCursorInfo::TypeNotAllowed:
+ case WebCursorInfo::kTypeNotAllowed:
return ui::kCursorNotAllowed;
- case WebCursorInfo::TypeZoomIn:
+ case WebCursorInfo::kTypeZoomIn:
return ui::kCursorZoomIn;
- case WebCursorInfo::TypeZoomOut:
+ case WebCursorInfo::kTypeZoomOut:
return ui::kCursorZoomOut;
- case WebCursorInfo::TypeGrab:
+ case WebCursorInfo::kTypeGrab:
return ui::kCursorGrab;
- case WebCursorInfo::TypeGrabbing:
+ case WebCursorInfo::kTypeGrabbing:
return ui::kCursorGrabbing;
- case WebCursorInfo::TypeCustom: {
+ case WebCursorInfo::kTypeCustom: {
ui::Cursor cursor(ui::kCursorCustom);
cursor.SetPlatformCursor(GetPlatformCursor());
return cursor;
diff --git a/chromium/content/common/cursors/webcursor_mac.mm b/chromium/content/common/cursors/webcursor_mac.mm
index 05e3ec2fbbd..00d1748599c 100644
--- a/chromium/content/common/cursors/webcursor_mac.mm
+++ b/chromium/content/common/cursors/webcursor_mac.mm
@@ -184,109 +184,109 @@ namespace content {
// Match Safari's cursor choices; see platform/mac/CursorMac.mm .
gfx::NativeCursor WebCursor::GetNativeCursor() {
switch (type_) {
- case WebCursorInfo::TypePointer:
+ case WebCursorInfo::kTypePointer:
return [NSCursor arrowCursor];
- case WebCursorInfo::TypeCross:
+ case WebCursorInfo::kTypeCross:
return [NSCursor crosshairCursor];
- case WebCursorInfo::TypeHand:
+ case WebCursorInfo::kTypeHand:
return [NSCursor pointingHandCursor];
- case WebCursorInfo::TypeIBeam:
+ case WebCursorInfo::kTypeIBeam:
return [NSCursor IBeamCursor];
- case WebCursorInfo::TypeWait:
+ case WebCursorInfo::kTypeWait:
return GetCoreCursorWithFallback(kBusyButClickableCursor,
IDR_WAIT_CURSOR, 7, 7);
- case WebCursorInfo::TypeHelp:
+ case WebCursorInfo::kTypeHelp:
return GetCoreCursorWithFallback(kHelpCursor,
IDR_HELP_CURSOR, 8, 8);
- case WebCursorInfo::TypeEastResize:
- case WebCursorInfo::TypeEastPanning:
+ case WebCursorInfo::kTypeEastResize:
+ case WebCursorInfo::kTypeEastPanning:
return GetCoreCursorWithFallback(kResizeEastCursor,
IDR_EAST_RESIZE_CURSOR, 14, 7);
- case WebCursorInfo::TypeNorthResize:
- case WebCursorInfo::TypeNorthPanning:
+ case WebCursorInfo::kTypeNorthResize:
+ case WebCursorInfo::kTypeNorthPanning:
return GetCoreCursorWithFallback(kResizeNorthCursor,
IDR_NORTH_RESIZE_CURSOR, 7, 1);
- case WebCursorInfo::TypeNorthEastResize:
- case WebCursorInfo::TypeNorthEastPanning:
+ case WebCursorInfo::kTypeNorthEastResize:
+ case WebCursorInfo::kTypeNorthEastPanning:
return GetCoreCursorWithFallback(kResizeNortheastCursor,
IDR_NORTHEAST_RESIZE_CURSOR, 14, 1);
- case WebCursorInfo::TypeNorthWestResize:
- case WebCursorInfo::TypeNorthWestPanning:
+ case WebCursorInfo::kTypeNorthWestResize:
+ case WebCursorInfo::kTypeNorthWestPanning:
return GetCoreCursorWithFallback(kResizeNorthwestCursor,
IDR_NORTHWEST_RESIZE_CURSOR, 0, 0);
- case WebCursorInfo::TypeSouthResize:
- case WebCursorInfo::TypeSouthPanning:
+ case WebCursorInfo::kTypeSouthResize:
+ case WebCursorInfo::kTypeSouthPanning:
return GetCoreCursorWithFallback(kResizeSouthCursor,
IDR_SOUTH_RESIZE_CURSOR, 7, 14);
- case WebCursorInfo::TypeSouthEastResize:
- case WebCursorInfo::TypeSouthEastPanning:
+ case WebCursorInfo::kTypeSouthEastResize:
+ case WebCursorInfo::kTypeSouthEastPanning:
return GetCoreCursorWithFallback(kResizeSoutheastCursor,
IDR_SOUTHEAST_RESIZE_CURSOR, 14, 14);
- case WebCursorInfo::TypeSouthWestResize:
- case WebCursorInfo::TypeSouthWestPanning:
+ case WebCursorInfo::kTypeSouthWestResize:
+ case WebCursorInfo::kTypeSouthWestPanning:
return GetCoreCursorWithFallback(kResizeSouthwestCursor,
IDR_SOUTHWEST_RESIZE_CURSOR, 1, 14);
- case WebCursorInfo::TypeWestResize:
- case WebCursorInfo::TypeWestPanning:
+ case WebCursorInfo::kTypeWestResize:
+ case WebCursorInfo::kTypeWestPanning:
return GetCoreCursorWithFallback(kResizeWestCursor,
IDR_WEST_RESIZE_CURSOR, 1, 7);
- case WebCursorInfo::TypeNorthSouthResize:
+ case WebCursorInfo::kTypeNorthSouthResize:
return GetCoreCursorWithFallback(kResizeNorthSouthCursor,
IDR_NORTHSOUTH_RESIZE_CURSOR, 7, 7);
- case WebCursorInfo::TypeEastWestResize:
+ case WebCursorInfo::kTypeEastWestResize:
return GetCoreCursorWithFallback(kResizeEastWestCursor,
IDR_EASTWEST_RESIZE_CURSOR, 7, 7);
- case WebCursorInfo::TypeNorthEastSouthWestResize:
+ case WebCursorInfo::kTypeNorthEastSouthWestResize:
return GetCoreCursorWithFallback(kResizeNortheastSouthwestCursor,
IDR_NORTHEASTSOUTHWEST_RESIZE_CURSOR,
7, 7);
- case WebCursorInfo::TypeNorthWestSouthEastResize:
+ case WebCursorInfo::kTypeNorthWestSouthEastResize:
return GetCoreCursorWithFallback(kResizeNorthwestSoutheastCursor,
IDR_NORTHWESTSOUTHEAST_RESIZE_CURSOR,
7, 7);
- case WebCursorInfo::TypeColumnResize:
+ case WebCursorInfo::kTypeColumnResize:
return [NSCursor resizeLeftRightCursor];
- case WebCursorInfo::TypeRowResize:
+ case WebCursorInfo::kTypeRowResize:
return [NSCursor resizeUpDownCursor];
- case WebCursorInfo::TypeMiddlePanning:
- case WebCursorInfo::TypeMove:
+ case WebCursorInfo::kTypeMiddlePanning:
+ case WebCursorInfo::kTypeMove:
return GetCoreCursorWithFallback(kMoveCursor,
IDR_MOVE_CURSOR, 7, 7);
- case WebCursorInfo::TypeVerticalText:
+ case WebCursorInfo::kTypeVerticalText:
// IBeamCursorForVerticalLayout is >= 10.7.
if ([NSCursor respondsToSelector:@selector(IBeamCursorForVerticalLayout)])
return [NSCursor IBeamCursorForVerticalLayout];
else
return LoadCursor(IDR_VERTICALTEXT_CURSOR, 7, 7);
- case WebCursorInfo::TypeCell:
+ case WebCursorInfo::kTypeCell:
return GetCoreCursorWithFallback(kCellCursor,
IDR_CELL_CURSOR, 7, 7);
- case WebCursorInfo::TypeContextMenu:
+ case WebCursorInfo::kTypeContextMenu:
return [NSCursor contextualMenuCursor];
- case WebCursorInfo::TypeAlias:
+ case WebCursorInfo::kTypeAlias:
return GetCoreCursorWithFallback(kMakeAliasCursor,
IDR_ALIAS_CURSOR, 11, 3);
- case WebCursorInfo::TypeProgress:
+ case WebCursorInfo::kTypeProgress:
return GetCoreCursorWithFallback(kBusyButClickableCursor,
IDR_PROGRESS_CURSOR, 3, 2);
- case WebCursorInfo::TypeNoDrop:
- case WebCursorInfo::TypeNotAllowed:
+ case WebCursorInfo::kTypeNoDrop:
+ case WebCursorInfo::kTypeNotAllowed:
return [NSCursor operationNotAllowedCursor];
- case WebCursorInfo::TypeCopy:
+ case WebCursorInfo::kTypeCopy:
return [NSCursor dragCopyCursor];
- case WebCursorInfo::TypeNone:
+ case WebCursorInfo::kTypeNone:
return LoadCursor(IDR_NONE_CURSOR, 7, 7);
- case WebCursorInfo::TypeZoomIn:
+ case WebCursorInfo::kTypeZoomIn:
return GetCoreCursorWithFallback(kZoomInCursor,
IDR_ZOOMIN_CURSOR, 7, 7);
- case WebCursorInfo::TypeZoomOut:
+ case WebCursorInfo::kTypeZoomOut:
return GetCoreCursorWithFallback(kZoomOutCursor,
IDR_ZOOMOUT_CURSOR, 7, 7);
- case WebCursorInfo::TypeGrab:
+ case WebCursorInfo::kTypeGrab:
return [NSCursor openHandCursor];
- case WebCursorInfo::TypeGrabbing:
+ case WebCursorInfo::kTypeGrabbing:
return [NSCursor closedHandCursor];
- case WebCursorInfo::TypeCustom:
+ case WebCursorInfo::kTypeCustom:
return CreateCustomCursor(
custom_data_, custom_size_, custom_scale_, hotspot_);
}
@@ -298,39 +298,39 @@ void WebCursor::InitFromNSCursor(NSCursor* cursor) {
CursorInfo cursor_info;
if ([cursor isEqual:[NSCursor arrowCursor]]) {
- cursor_info.type = WebCursorInfo::TypePointer;
+ cursor_info.type = WebCursorInfo::kTypePointer;
} else if ([cursor isEqual:[NSCursor IBeamCursor]]) {
- cursor_info.type = WebCursorInfo::TypeIBeam;
+ cursor_info.type = WebCursorInfo::kTypeIBeam;
} else if ([cursor isEqual:[NSCursor crosshairCursor]]) {
- cursor_info.type = WebCursorInfo::TypeCross;
+ cursor_info.type = WebCursorInfo::kTypeCross;
} else if ([cursor isEqual:[NSCursor pointingHandCursor]]) {
- cursor_info.type = WebCursorInfo::TypeHand;
+ cursor_info.type = WebCursorInfo::kTypeHand;
} else if ([cursor isEqual:[NSCursor resizeLeftCursor]]) {
- cursor_info.type = WebCursorInfo::TypeWestResize;
+ cursor_info.type = WebCursorInfo::kTypeWestResize;
} else if ([cursor isEqual:[NSCursor resizeRightCursor]]) {
- cursor_info.type = WebCursorInfo::TypeEastResize;
+ cursor_info.type = WebCursorInfo::kTypeEastResize;
} else if ([cursor isEqual:[NSCursor resizeLeftRightCursor]]) {
- cursor_info.type = WebCursorInfo::TypeEastWestResize;
+ cursor_info.type = WebCursorInfo::kTypeEastWestResize;
} else if ([cursor isEqual:[NSCursor resizeUpCursor]]) {
- cursor_info.type = WebCursorInfo::TypeNorthResize;
+ cursor_info.type = WebCursorInfo::kTypeNorthResize;
} else if ([cursor isEqual:[NSCursor resizeDownCursor]]) {
- cursor_info.type = WebCursorInfo::TypeSouthResize;
+ cursor_info.type = WebCursorInfo::kTypeSouthResize;
} else if ([cursor isEqual:[NSCursor resizeUpDownCursor]]) {
- cursor_info.type = WebCursorInfo::TypeNorthSouthResize;
+ cursor_info.type = WebCursorInfo::kTypeNorthSouthResize;
} else if ([cursor isEqual:[NSCursor openHandCursor]]) {
- cursor_info.type = WebCursorInfo::TypeGrab;
+ cursor_info.type = WebCursorInfo::kTypeGrab;
} else if ([cursor isEqual:[NSCursor closedHandCursor]]) {
- cursor_info.type = WebCursorInfo::TypeGrabbing;
+ cursor_info.type = WebCursorInfo::kTypeGrabbing;
} else if ([cursor isEqual:[NSCursor operationNotAllowedCursor]]) {
- cursor_info.type = WebCursorInfo::TypeNotAllowed;
+ cursor_info.type = WebCursorInfo::kTypeNotAllowed;
} else if ([cursor isEqual:[NSCursor dragCopyCursor]]) {
- cursor_info.type = WebCursorInfo::TypeCopy;
+ cursor_info.type = WebCursorInfo::kTypeCopy;
} else if ([cursor isEqual:[NSCursor contextualMenuCursor]]) {
- cursor_info.type = WebCursorInfo::TypeContextMenu;
+ cursor_info.type = WebCursorInfo::kTypeContextMenu;
} else if (
[NSCursor respondsToSelector:@selector(IBeamCursorForVerticalLayout)] &&
[cursor isEqual:[NSCursor IBeamCursorForVerticalLayout]]) {
- cursor_info.type = WebCursorInfo::TypeVerticalText;
+ cursor_info.type = WebCursorInfo::kTypeVerticalText;
} else {
// Also handles the [NSCursor disappearingItemCursor] case. Quick-and-dirty
// image conversion; TODO(avi): do better.
@@ -344,12 +344,12 @@ void WebCursor::InitFromNSCursor(NSCursor* cursor) {
}
if (cg_image) {
- cursor_info.type = WebCursorInfo::TypeCustom;
+ cursor_info.type = WebCursorInfo::kTypeCustom;
NSPoint hot_spot = [cursor hotSpot];
cursor_info.hotspot = gfx::Point(hot_spot.x, hot_spot.y);
cursor_info.custom_image = skia::CGImageToSkBitmap(cg_image);
} else {
- cursor_info.type = WebCursorInfo::TypePointer;
+ cursor_info.type = WebCursorInfo::kTypePointer;
}
}
diff --git a/chromium/content/common/cursors/webcursor_unittest.cc b/chromium/content/common/cursors/webcursor_unittest.cc
index e261a80cfa7..7af1eb56398 100644
--- a/chromium/content/common/cursors/webcursor_unittest.cc
+++ b/chromium/content/common/cursors/webcursor_unittest.cc
@@ -24,7 +24,7 @@ TEST(WebCursorTest, OKCursorSerialization) {
// This is a valid custom cursor.
base::Pickle ok_custom_pickle;
// Type and hotspots.
- ok_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
+ ok_custom_pickle.WriteInt(WebCursorInfo::kTypeCustom);
ok_custom_pickle.WriteInt(0);
ok_custom_pickle.WriteInt(0);
// X & Y
@@ -46,7 +46,7 @@ TEST(WebCursorTest, BrokenCursorSerialization) {
// This custom cursor has not been send with enough data.
base::Pickle short_custom_pickle;
// Type and hotspots.
- short_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
+ short_custom_pickle.WriteInt(WebCursorInfo::kTypeCustom);
short_custom_pickle.WriteInt(0);
short_custom_pickle.WriteInt(0);
// X & Y
@@ -63,7 +63,7 @@ TEST(WebCursorTest, BrokenCursorSerialization) {
// This custom cursor has enough data but is too big.
base::Pickle large_custom_pickle;
// Type and hotspots.
- large_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
+ large_custom_pickle.WriteInt(WebCursorInfo::kTypeCustom);
large_custom_pickle.WriteInt(0);
large_custom_pickle.WriteInt(0);
// X & Y
@@ -82,7 +82,7 @@ TEST(WebCursorTest, BrokenCursorSerialization) {
// This custom cursor uses negative lengths.
base::Pickle neg_custom_pickle;
// Type and hotspots.
- neg_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
+ neg_custom_pickle.WriteInt(WebCursorInfo::kTypeCustom);
neg_custom_pickle.WriteInt(0);
neg_custom_pickle.WriteInt(0);
// X & Y
@@ -101,7 +101,7 @@ TEST(WebCursorTest, BrokenCursorSerialization) {
// This custom cursor uses zero scale.
base::Pickle scale_zero_custom_pickle;
// Type and hotspots.
- scale_zero_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
+ scale_zero_custom_pickle.WriteInt(WebCursorInfo::kTypeCustom);
scale_zero_custom_pickle.WriteInt(0);
scale_zero_custom_pickle.WriteInt(0);
// X & Y
@@ -120,7 +120,7 @@ TEST(WebCursorTest, BrokenCursorSerialization) {
// This custom cursor uses tiny scale.
base::Pickle scale_tiny_custom_pickle;
// Type and hotspots.
- scale_tiny_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
+ scale_tiny_custom_pickle.WriteInt(WebCursorInfo::kTypeCustom);
scale_tiny_custom_pickle.WriteInt(0);
scale_tiny_custom_pickle.WriteInt(0);
// X & Y
@@ -142,7 +142,7 @@ TEST(WebCursorTest, ClampHotspot) {
// This is a valid custom cursor.
base::Pickle ok_custom_pickle;
// Type and hotspots.
- ok_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
+ ok_custom_pickle.WriteInt(WebCursorInfo::kTypeCustom);
// Hotspot is invalid --- outside the bounds of the image.
ok_custom_pickle.WriteInt(5);
ok_custom_pickle.WriteInt(5);
@@ -161,7 +161,7 @@ TEST(WebCursorTest, ClampHotspot) {
EXPECT_TRUE(custom_cursor.Deserialize(&iter));
// Convert to WebCursorInfo, make sure the hotspot got clamped.
- WebCursor::CursorInfo info;
+ CursorInfo info;
custom_cursor.GetCursorInfo(&info);
EXPECT_EQ(gfx::Point(1, 1), info.hotspot);
@@ -176,7 +176,7 @@ TEST(WebCursorTest, ClampHotspot) {
TEST(WebCursorTest, EmptyImage) {
WebCursor custom_cursor;
base::Pickle broken_cursor_pickle;
- broken_cursor_pickle.WriteInt(WebCursorInfo::TypeCustom);
+ broken_cursor_pickle.WriteInt(WebCursorInfo::kTypeCustom);
// Hotspot is at origin
broken_cursor_pickle.WriteInt(0);
broken_cursor_pickle.WriteInt(0);
@@ -201,7 +201,7 @@ TEST(WebCursorTest, Scale2) {
// This is a valid custom cursor.
base::Pickle ok_custom_pickle;
// Type and hotspots.
- ok_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
+ ok_custom_pickle.WriteInt(WebCursorInfo::kTypeCustom);
ok_custom_pickle.WriteInt(0);
ok_custom_pickle.WriteInt(0);
// X & Y
@@ -224,8 +224,8 @@ TEST(WebCursorTest, AlphaConversion) {
bitmap.allocN32Pixels(1,1);
SkAutoLockPixels bitmap_lock(bitmap);
*bitmap.getAddr32(0, 0) = testColor;
- WebCursor::CursorInfo cursor_info;
- cursor_info.type = WebCursorInfo::TypeCustom;
+ CursorInfo cursor_info;
+ cursor_info.type = WebCursorInfo::kTypeCustom;
cursor_info.custom_image = bitmap;
cursor_info.image_scale_factor = 1;
WebCursor custom_cursor;
@@ -270,7 +270,7 @@ TEST(WebCursorTest, CursorScaleFactor) {
display::Display display;
display.set_device_scale_factor(80.2f);
- WebCursor::CursorInfo info;
+ CursorInfo info;
info.image_scale_factor = 2.0f;
WebCursor cursor;
@@ -281,8 +281,8 @@ TEST(WebCursorTest, CursorScaleFactor) {
}
TEST(WebCursorTest, UnscaledImageCopy) {
- WebCursor::CursorInfo info;
- info.type = WebCursorInfo::TypeCustom;
+ CursorInfo info;
+ info.type = WebCursorInfo::kTypeCustom;
info.hotspot = gfx::Point(0, 1);
SkImageInfo image_info = SkImageInfo::MakeN32(2, 2, kUnpremul_SkAlphaType);
@@ -325,8 +325,8 @@ void ScaleCursor(float scale_factor, int hotspot_x, int hotspot_y) {
display::Display display;
display.set_device_scale_factor(scale_factor);
- WebCursor::CursorInfo info;
- info.type = WebCursorInfo::TypeCustom;
+ CursorInfo info;
+ info.type = WebCursorInfo::kTypeCustom;
info.hotspot = gfx::Point(hotspot_x, hotspot_y);
info.custom_image = SkBitmap();
diff --git a/chromium/content/common/dom_storage/dom_storage_messages.h b/chromium/content/common/dom_storage/dom_storage_messages.h
index 59d22c9641b..3325bf9b124 100644
--- a/chromium/content/common/dom_storage/dom_storage_messages.h
+++ b/chromium/content/common/dom_storage/dom_storage_messages.h
@@ -16,7 +16,7 @@
#define IPC_MESSAGE_START DOMStorageMsgStart
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebStorageArea::Result,
- blink::WebStorageArea::ResultLast)
+ blink::WebStorageArea::kResultLast)
// Signals a local storage event.
IPC_STRUCT_BEGIN(DOMStorageMsg_Event_Params)
diff --git a/chromium/content/common/establish_channel_params.cc b/chromium/content/common/establish_channel_params.cc
deleted file mode 100644
index 6ca5ac6a7bc..00000000000
--- a/chromium/content/common/establish_channel_params.cc
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/common/establish_channel_params.h"
-
-namespace content {
-
-EstablishChannelParams::EstablishChannelParams()
- : client_id(0),
- client_tracing_id(0),
- preempts(false),
- allow_view_command_buffers(false),
- allow_real_time_streams(false) {}
-
-EstablishChannelParams::~EstablishChannelParams() {}
-
-} // namespace content
diff --git a/chromium/content/common/establish_channel_params.h b/chromium/content/common/establish_channel_params.h
deleted file mode 100644
index f77b1bd8e48..00000000000
--- a/chromium/content/common/establish_channel_params.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_COMMON_ESTABLISH_CHANNEL_PARAMS_H_
-#define CONTENT_COMMON_ESTABLISH_CHANNEL_PARAMS_H_
-
-#include <stdint.h>
-
-#include "content/common/content_export.h"
-
-namespace content {
-
-struct CONTENT_EXPORT EstablishChannelParams {
- EstablishChannelParams();
- ~EstablishChannelParams();
-
- int client_id;
- uint64_t client_tracing_id;
- bool preempts;
- bool allow_view_command_buffers;
- bool allow_real_time_streams;
-};
-
-} // namespace content
-
-#endif // CONTENT_COMMON_ESTABLISH_CHANNEL_PARAMS_H_
diff --git a/chromium/content/common/feature_policy/feature_policy.cc b/chromium/content/common/feature_policy/feature_policy.cc
index f8ffc3db14e..c96e59aaa30 100644
--- a/chromium/content/common/feature_policy/feature_policy.cc
+++ b/chromium/content/common/feature_policy/feature_policy.cc
@@ -12,48 +12,6 @@ namespace content {
namespace {
-// Given a string name, return the matching feature struct, or nullptr if it is
-// not the name of a policy-controlled feature.
-blink::WebFeaturePolicyFeature FeatureForName(
- const std::string& feature_name,
- const FeaturePolicy::FeatureList& features) {
- for (const auto& feature_mapping : features) {
- if (feature_name == feature_mapping.second->feature_name)
- return feature_mapping.first;
- }
- return blink::WebFeaturePolicyFeature::NotFound;
-}
-
-// Definitions of all features controlled by Feature Policy should appear here.
-const FeaturePolicy::Feature kDocumentCookie{
- "cookie", FeaturePolicy::FeatureDefault::EnableForAll};
-const FeaturePolicy::Feature kDocumentDomain{
- "domain", FeaturePolicy::FeatureDefault::EnableForAll};
-const FeaturePolicy::Feature kDocumentWrite{
- "docwrite", FeaturePolicy::FeatureDefault::EnableForAll};
-const FeaturePolicy::Feature kFullscreenFeature{
- "fullscreen", FeaturePolicy::FeatureDefault::EnableForSelf};
-const FeaturePolicy::Feature kGeolocationFeature{
- "geolocation", FeaturePolicy::FeatureDefault::EnableForSelf};
-const FeaturePolicy::Feature kMidiFeature{
- "midi", FeaturePolicy::FeatureDefault::EnableForAll};
-const FeaturePolicy::Feature kNotificationsFeature{
- "notifications", FeaturePolicy::FeatureDefault::EnableForAll};
-const FeaturePolicy::Feature kPaymentFeature{
- "payment", FeaturePolicy::FeatureDefault::EnableForSelf};
-const FeaturePolicy::Feature kPushFeature{
- "push", FeaturePolicy::FeatureDefault::EnableForAll};
-const FeaturePolicy::Feature kSyncScript{
- "sync-script", FeaturePolicy::FeatureDefault::EnableForAll};
-const FeaturePolicy::Feature kSyncXHR{
- "sync-xhr", FeaturePolicy::FeatureDefault::EnableForAll};
-const FeaturePolicy::Feature kUsermedia{
- "usermedia", FeaturePolicy::FeatureDefault::EnableForAll};
-const FeaturePolicy::Feature kVibrateFeature{
- "vibrate", FeaturePolicy::FeatureDefault::EnableForSelf};
-const FeaturePolicy::Feature kWebRTC{
- "webrtc", FeaturePolicy::FeatureDefault::EnableForAll};
-
// Extracts a Whitelist from a ParsedFeaturePolicyDeclaration.
std::unique_ptr<FeaturePolicy::Whitelist> WhitelistFromDeclaration(
const ParsedFeaturePolicyDeclaration& parsed_declaration) {
@@ -72,10 +30,10 @@ ParsedFeaturePolicyDeclaration::ParsedFeaturePolicyDeclaration()
: matches_all_origins(false) {}
ParsedFeaturePolicyDeclaration::ParsedFeaturePolicyDeclaration(
- std::string feature_name,
+ blink::WebFeaturePolicyFeature feature,
bool matches_all_origins,
std::vector<url::Origin> origins)
- : feature_name(feature_name),
+ : feature(feature),
matches_all_origins(matches_all_origins),
origins(origins) {}
@@ -86,6 +44,8 @@ ParsedFeaturePolicyDeclaration::~ParsedFeaturePolicyDeclaration() {}
FeaturePolicy::Whitelist::Whitelist() : matches_all_origins_(false) {}
+FeaturePolicy::Whitelist::Whitelist(const Whitelist& rhs) = default;
+
FeaturePolicy::Whitelist::~Whitelist() = default;
void FeaturePolicy::Whitelist::Add(const url::Origin& origin) {
@@ -97,6 +57,12 @@ void FeaturePolicy::Whitelist::AddAll() {
}
bool FeaturePolicy::Whitelist::Contains(const url::Origin& origin) const {
+ // This does not handle the case where origin is an opaque origin, which is
+ // also supposed to exist in the whitelist. (The identical opaque origins
+ // should match in that case)
+ // TODO(iclelland): Fix that, possibly by having another flag for
+ // 'matches_self', which will explicitly match the policy's origin.
+ // https://crbug.com/690520
if (matches_all_origins_)
return true;
for (const auto& targetOrigin : origins_) {
@@ -109,48 +75,62 @@ bool FeaturePolicy::Whitelist::Contains(const url::Origin& origin) const {
// static
std::unique_ptr<FeaturePolicy> FeaturePolicy::CreateFromParentPolicy(
const FeaturePolicy* parent_policy,
- const ParsedFeaturePolicyHeader* container_policy,
+ const ParsedFeaturePolicyHeader& container_policy,
const url::Origin& origin) {
return CreateFromParentPolicy(parent_policy, container_policy, origin,
GetDefaultFeatureList());
}
+// static
+std::unique_ptr<FeaturePolicy> FeaturePolicy::CreateFromPolicyWithOrigin(
+ const FeaturePolicy& policy,
+ const url::Origin& origin) {
+ std::unique_ptr<FeaturePolicy> new_policy =
+ base::WrapUnique(new FeaturePolicy(origin, policy.feature_list_));
+ new_policy->inherited_policies_ = policy.inherited_policies_;
+ for (const auto& feature : policy.whitelists_) {
+ new_policy->whitelists_[feature.first] =
+ base::WrapUnique(new Whitelist(*feature.second));
+ }
+ return new_policy;
+}
+
+bool FeaturePolicy::IsFeatureEnabled(
+ blink::WebFeaturePolicyFeature feature) const {
+ return IsFeatureEnabledForOrigin(feature, origin_);
+}
+
bool FeaturePolicy::IsFeatureEnabledForOrigin(
blink::WebFeaturePolicyFeature feature,
const url::Origin& origin) const {
DCHECK(base::ContainsKey(feature_list_, feature));
- const FeaturePolicy::Feature* feature_definition = feature_list_.at(feature);
+ const FeaturePolicy::FeatureDefault default_policy =
+ feature_list_.at(feature);
DCHECK(base::ContainsKey(inherited_policies_, feature));
if (!inherited_policies_.at(feature))
return false;
auto whitelist = whitelists_.find(feature);
if (whitelist != whitelists_.end())
return whitelist->second->Contains(origin);
- if (feature_definition->default_policy ==
- FeaturePolicy::FeatureDefault::EnableForAll) {
+ if (default_policy == FeaturePolicy::FeatureDefault::EnableForAll) {
return true;
}
- if (feature_definition->default_policy ==
- FeaturePolicy::FeatureDefault::EnableForSelf) {
- return origin_.IsSameOriginWith(origin);
+ if (default_policy == FeaturePolicy::FeatureDefault::EnableForSelf) {
+ // TODO(iclelland): Remove the pointer equality check once it is possible to
+ // compare opaque origins successfully against themselves.
+ // https://crbug.com/690520
+ return (&origin_ == &origin) || origin_.IsSameOriginWith(origin);
}
return false;
}
-bool FeaturePolicy::IsFeatureEnabled(
- blink::WebFeaturePolicyFeature feature) const {
- return IsFeatureEnabledForOrigin(feature, origin_);
-}
-
void FeaturePolicy::SetHeaderPolicy(
const ParsedFeaturePolicyHeader& parsed_header) {
DCHECK(whitelists_.empty());
for (const ParsedFeaturePolicyDeclaration& parsed_declaration :
parsed_header) {
- blink::WebFeaturePolicyFeature feature =
- FeatureForName(parsed_declaration.feature_name, feature_list_);
- if (feature == blink::WebFeaturePolicyFeature::NotFound)
- continue;
+ blink::WebFeaturePolicyFeature feature = parsed_declaration.feature;
+ DCHECK(feature != blink::WebFeaturePolicyFeature::kNotFound);
whitelists_[feature] = WhitelistFromDeclaration(parsed_declaration);
}
}
@@ -167,7 +147,7 @@ FeaturePolicy::~FeaturePolicy() {}
// static
std::unique_ptr<FeaturePolicy> FeaturePolicy::CreateFromParentPolicy(
const FeaturePolicy* parent_policy,
- const ParsedFeaturePolicyHeader* container_policy,
+ const ParsedFeaturePolicyHeader& container_policy,
const url::Origin& origin,
const FeaturePolicy::FeatureList& features) {
std::unique_ptr<FeaturePolicy> new_policy =
@@ -179,25 +159,23 @@ std::unique_ptr<FeaturePolicy> FeaturePolicy::CreateFromParentPolicy(
} else {
new_policy->inherited_policies_[feature.first] = false;
}
- if (container_policy)
+ if (!container_policy.empty())
new_policy->AddContainerPolicy(container_policy, parent_policy);
}
return new_policy;
}
void FeaturePolicy::AddContainerPolicy(
- const ParsedFeaturePolicyHeader* container_policy,
+ const ParsedFeaturePolicyHeader& container_policy,
const FeaturePolicy* parent_policy) {
- DCHECK(container_policy);
DCHECK(parent_policy);
for (const ParsedFeaturePolicyDeclaration& parsed_declaration :
- *container_policy) {
+ container_policy) {
// If a feature is enabled in the parent frame, and the parent chooses to
// delegate it to the child frame, using the iframe attribute, then the
// feature should be enabled in the child frame.
- blink::WebFeaturePolicyFeature feature =
- FeatureForName(parsed_declaration.feature_name, feature_list_);
- if (feature == blink::WebFeaturePolicyFeature::NotFound)
+ blink::WebFeaturePolicyFeature feature = parsed_declaration.feature;
+ if (feature == blink::WebFeaturePolicyFeature::kNotFound)
continue;
if (WhitelistFromDeclaration(parsed_declaration)->Contains(origin_) &&
parent_policy->IsFeatureEnabled(feature)) {
@@ -209,23 +187,44 @@ void FeaturePolicy::AddContainerPolicy(
}
// static
+// See third_party/WebKit/public/platform/WebFeaturePolicy.h for status of each
+// features (in spec, implemented, etc).
const FeaturePolicy::FeatureList& FeaturePolicy::GetDefaultFeatureList() {
- CR_DEFINE_STATIC_LOCAL(
- FeatureList, default_feature_list,
- ({{blink::WebFeaturePolicyFeature::DocumentCookie, &kDocumentCookie},
- {blink::WebFeaturePolicyFeature::DocumentDomain, &kDocumentDomain},
- {blink::WebFeaturePolicyFeature::DocumentWrite, &kDocumentWrite},
- {blink::WebFeaturePolicyFeature::Fullscreen, &kFullscreenFeature},
- {blink::WebFeaturePolicyFeature::Geolocation, &kGeolocationFeature},
- {blink::WebFeaturePolicyFeature::MidiFeature, &kMidiFeature},
- {blink::WebFeaturePolicyFeature::Notifications, &kNotificationsFeature},
- {blink::WebFeaturePolicyFeature::Payment, &kPaymentFeature},
- {blink::WebFeaturePolicyFeature::Push, &kPushFeature},
- {blink::WebFeaturePolicyFeature::SyncScript, &kSyncScript},
- {blink::WebFeaturePolicyFeature::SyncXHR, &kSyncXHR},
- {blink::WebFeaturePolicyFeature::Usermedia, &kUsermedia},
- {blink::WebFeaturePolicyFeature::Vibrate, &kVibrateFeature},
- {blink::WebFeaturePolicyFeature::WebRTC, &kWebRTC}}));
+ CR_DEFINE_STATIC_LOCAL(FeatureList, default_feature_list,
+ ({{blink::WebFeaturePolicyFeature::kCamera,
+ FeaturePolicy::FeatureDefault::EnableForSelf},
+ {blink::WebFeaturePolicyFeature::kEme,
+ FeaturePolicy::FeatureDefault::EnableForSelf},
+ {blink::WebFeaturePolicyFeature::kFullscreen,
+ FeaturePolicy::FeatureDefault::EnableForSelf},
+ {blink::WebFeaturePolicyFeature::kGeolocation,
+ FeaturePolicy::FeatureDefault::EnableForSelf},
+ {blink::WebFeaturePolicyFeature::kMicrophone,
+ FeaturePolicy::FeatureDefault::EnableForSelf},
+ {blink::WebFeaturePolicyFeature::kMidiFeature,
+ FeaturePolicy::FeatureDefault::EnableForSelf},
+ {blink::WebFeaturePolicyFeature::kPayment,
+ FeaturePolicy::FeatureDefault::EnableForSelf},
+ {blink::WebFeaturePolicyFeature::kSpeaker,
+ FeaturePolicy::FeatureDefault::EnableForSelf},
+ {blink::WebFeaturePolicyFeature::kVibrate,
+ FeaturePolicy::FeatureDefault::EnableForSelf},
+ {blink::WebFeaturePolicyFeature::kDocumentCookie,
+ FeaturePolicy::FeatureDefault::EnableForAll},
+ {blink::WebFeaturePolicyFeature::kDocumentDomain,
+ FeaturePolicy::FeatureDefault::EnableForAll},
+ {blink::WebFeaturePolicyFeature::kDocumentWrite,
+ FeaturePolicy::FeatureDefault::EnableForAll},
+ {blink::WebFeaturePolicyFeature::kNotifications,
+ FeaturePolicy::FeatureDefault::EnableForAll},
+ {blink::WebFeaturePolicyFeature::kPush,
+ FeaturePolicy::FeatureDefault::EnableForAll},
+ {blink::WebFeaturePolicyFeature::kSyncScript,
+ FeaturePolicy::FeatureDefault::EnableForAll},
+ {blink::WebFeaturePolicyFeature::kSyncXHR,
+ FeaturePolicy::FeatureDefault::EnableForAll},
+ {blink::WebFeaturePolicyFeature::kWebRTC,
+ FeaturePolicy::FeatureDefault::EnableForAll}}));
return default_feature_list;
}
diff --git a/chromium/content/common/feature_policy/feature_policy.h b/chromium/content/common/feature_policy/feature_policy.h
index fc156dd3b28..9f3c2a1c17a 100644
--- a/chromium/content/common/feature_policy/feature_policy.h
+++ b/chromium/content/common/feature_policy/feature_policy.h
@@ -33,9 +33,8 @@ namespace content {
//
// Features
// --------
-// Features which can be controlled by policy are defined by instances of the
-// FeaturePolicy::Feature struct. The features are referenced by the
-// |WebFeaturePolicyFeature| enum, declared in |WebFeaturePolicy.h|.
+// Features which can be controlled by policy are defined by instances of enum
+// blink::WebFeaturePolicyFeature, declared in |WebFeaturePolicy.h|.
//
// Whitelists
// ----------
@@ -90,20 +89,20 @@ namespace content {
// They exist only because we can't transfer WebVectors directly over IPC.
struct CONTENT_EXPORT ParsedFeaturePolicyDeclaration {
ParsedFeaturePolicyDeclaration();
- ParsedFeaturePolicyDeclaration(std::string feature_name,
+ ParsedFeaturePolicyDeclaration(blink::WebFeaturePolicyFeature feature,
bool matches_all_origins,
std::vector<url::Origin> origins);
ParsedFeaturePolicyDeclaration(const ParsedFeaturePolicyDeclaration& rhs);
~ParsedFeaturePolicyDeclaration();
- std::string feature_name;
+ blink::WebFeaturePolicyFeature feature;
bool matches_all_origins;
std::vector<url::Origin> origins;
};
using ParsedFeaturePolicyHeader = std::vector<ParsedFeaturePolicyDeclaration>;
-class CONTENT_EXPORT FeaturePolicy {
+class CONTENT_EXPORT FeaturePolicy : public blink::WebFeaturePolicy {
public:
// Represents a collection of origins which make up a whitelist in a feature
// policy. This collection may be set to match every origin (corresponding to
@@ -112,6 +111,7 @@ class CONTENT_EXPORT FeaturePolicy {
class Whitelist final {
public:
Whitelist();
+ Whitelist(const Whitelist& rhs);
~Whitelist();
// Adds a single origin to the whitelist.
@@ -147,36 +147,27 @@ class CONTENT_EXPORT FeaturePolicy {
EnableForAll
};
- // The FeaturePolicy::Feature struct is used to define all features under
- // control of Feature Policy. There should only be one instance of this struct
- // for any given feature (declared below).
- struct Feature {
- // The name of the feature, as it should appear in a policy string
- const char* const feature_name;
+ using FeatureList = std::map<blink::WebFeaturePolicyFeature, FeatureDefault>;
- // Controls whether the feature should be available in the platform by
- // default, in the absence of any declared policy.
- FeatureDefault default_policy;
- };
-
- using FeatureList =
- std::map<blink::WebFeaturePolicyFeature, const FeaturePolicy::Feature*>;
-
- ~FeaturePolicy();
+ ~FeaturePolicy() override;
static std::unique_ptr<FeaturePolicy> CreateFromParentPolicy(
const FeaturePolicy* parent_policy,
- const ParsedFeaturePolicyHeader* container_policy,
+ const ParsedFeaturePolicyHeader& container_policy,
const url::Origin& origin);
- // Returns whether or not the given feature is enabled by this policy.
+ static std::unique_ptr<FeaturePolicy> CreateFromPolicyWithOrigin(
+ const FeaturePolicy& policy,
+ const url::Origin& origin);
+
+ // WebFeaturePolicy implementation
+ bool IsFeatureEnabled(blink::WebFeaturePolicyFeature feature) const override;
+
+ // Returns whether or not the given feature is enabled by this policy for a
+ // specific origin.
bool IsFeatureEnabledForOrigin(blink::WebFeaturePolicyFeature feature,
const url::Origin& origin) const;
- // Returns whether or not the given feature is enabled for the origin of the
- // document that owns the policy.
- bool IsFeatureEnabled(blink::WebFeaturePolicyFeature feature) const;
-
// Sets the declared policy from the parsed Feature-Policy HTTP header.
// Unrecognized features will be ignored.
void SetHeaderPolicy(const ParsedFeaturePolicyHeader& parsed_header);
@@ -188,13 +179,13 @@ class CONTENT_EXPORT FeaturePolicy {
FeaturePolicy(url::Origin origin, const FeatureList& feature_list);
static std::unique_ptr<FeaturePolicy> CreateFromParentPolicy(
const FeaturePolicy* parent_policy,
- const ParsedFeaturePolicyHeader* container_policy,
+ const ParsedFeaturePolicyHeader& container_policy,
const url::Origin& origin,
const FeatureList& features);
// Updates the inherited policy with the declarations from the iframe allow*
// attributes.
- void AddContainerPolicy(const ParsedFeaturePolicyHeader* container_policy,
+ void AddContainerPolicy(const ParsedFeaturePolicyHeader& container_policy,
const FeaturePolicy* parent_policy);
// Returns the list of features which can be controlled by Feature Policy.
diff --git a/chromium/content/common/feature_policy/feature_policy_unittest.cc b/chromium/content/common/feature_policy/feature_policy_unittest.cc
index cb69f3303e7..1be6290d33e 100644
--- a/chromium/content/common/feature_policy/feature_policy_unittest.cc
+++ b/chromium/content/common/feature_policy/feature_policy_unittest.cc
@@ -11,23 +11,6 @@ namespace content {
namespace {
-// This is an example of a feature which should be enabled by default in all
-// frames.
-const FeaturePolicy::Feature kDefaultOnFeatureDfn{
- "default-on", FeaturePolicy::FeatureDefault::EnableForAll};
-
-// This is an example of a feature which should be enabled in top-level frames,
-// and same-origin child-frames, but must be delegated to all cross-origin
-// frames explicitly.
-const FeaturePolicy::Feature kDefaultSelfFeatureDfn{
- "default-self", FeaturePolicy::FeatureDefault::EnableForSelf};
-
-// This is an example of a feature which should be disabled by default, both in
-// top-level and nested frames.
-const FeaturePolicy::Feature kDefaultOffFeatureDfn{
- "default-off", FeaturePolicy::FeatureDefault::DisableForAll};
-
-// Define the three new features for testing
blink::WebFeaturePolicyFeature kDefaultOnFeature =
static_cast<blink::WebFeaturePolicyFeature>(
static_cast<int>(blink::WebFeaturePolicyFeature::LAST_FEATURE) + 1);
@@ -45,22 +28,26 @@ blink::WebFeaturePolicyFeature kDefaultOffFeature =
class FeaturePolicyTest : public ::testing::Test {
protected:
FeaturePolicyTest()
- : feature_list_({{kDefaultOnFeature, &kDefaultOnFeatureDfn},
- {kDefaultSelfFeature, &kDefaultSelfFeatureDfn},
- {kDefaultOffFeature, &kDefaultOffFeatureDfn}}) {}
+ : feature_list_(
+ {{kDefaultOnFeature, FeaturePolicy::FeatureDefault::EnableForAll},
+ {kDefaultSelfFeature,
+ FeaturePolicy::FeatureDefault::EnableForSelf},
+ {kDefaultOffFeature,
+ FeaturePolicy::FeatureDefault::DisableForAll}}) {}
~FeaturePolicyTest() override {}
std::unique_ptr<FeaturePolicy> CreateFromParentPolicy(
const FeaturePolicy* parent,
const url::Origin& origin) {
- return FeaturePolicy::CreateFromParentPolicy(parent, nullptr, origin,
- feature_list_);
+ ParsedFeaturePolicyHeader empty_container_policy;
+ return FeaturePolicy::CreateFromParentPolicy(parent, empty_container_policy,
+ origin, feature_list_);
}
std::unique_ptr<FeaturePolicy> CreateFromParentWithFramePolicy(
const FeaturePolicy* parent,
- const ParsedFeaturePolicyHeader* frame_policy,
+ const ParsedFeaturePolicyHeader& frame_policy,
const url::Origin& origin) {
return FeaturePolicy::CreateFromParentPolicy(parent, frame_policy, origin,
feature_list_);
@@ -144,7 +131,7 @@ TEST_F(FeaturePolicyTest, TestCrossOriginChildCannotEnableFeature) {
CreateFromParentPolicy(nullptr, origin_a_);
std::unique_ptr<FeaturePolicy> policy2 =
CreateFromParentPolicy(policy1.get(), origin_b_);
- policy2->SetHeaderPolicy({{{"default-self", false, {origin_b_}}}});
+ policy2->SetHeaderPolicy({{{kDefaultSelfFeature, false, {origin_b_}}}});
EXPECT_FALSE(policy2->IsFeatureEnabled(kDefaultSelfFeature));
}
@@ -166,7 +153,7 @@ TEST_F(FeaturePolicyTest, TestFrameSelfInheritance) {
// they are at a different origin.
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
- policy1->SetHeaderPolicy({{{"default-self", false, {origin_a_}}}});
+ policy1->SetHeaderPolicy({{{kDefaultSelfFeature, false, {origin_a_}}}});
std::unique_ptr<FeaturePolicy> policy2 =
CreateFromParentPolicy(policy1.get(), origin_a_);
std::unique_ptr<FeaturePolicy> policy3 =
@@ -198,7 +185,7 @@ TEST_F(FeaturePolicyTest, TestReflexiveFrameSelfInheritance) {
// it is embedded by frame 2, for which the feature is not enabled.
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
- policy1->SetHeaderPolicy({{{"default-self", false, {origin_a_}}}});
+ policy1->SetHeaderPolicy({{{kDefaultSelfFeature, false, {origin_a_}}}});
std::unique_ptr<FeaturePolicy> policy2 =
CreateFromParentPolicy(policy1.get(), origin_b_);
std::unique_ptr<FeaturePolicy> policy3 =
@@ -225,7 +212,7 @@ TEST_F(FeaturePolicyTest, TestSelectiveFrameInheritance) {
// enabled.
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
- policy1->SetHeaderPolicy({{{"default-self", false, {origin_b_}}}});
+ policy1->SetHeaderPolicy({{{kDefaultSelfFeature, false, {origin_b_}}}});
std::unique_ptr<FeaturePolicy> policy2 =
CreateFromParentPolicy(policy1.get(), origin_b_);
std::unique_ptr<FeaturePolicy> policy3 =
@@ -246,7 +233,7 @@ TEST_F(FeaturePolicyTest, TestPolicyCanBlockSelf) {
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
policy1->SetHeaderPolicy(
- {{{"default-on", false, std::vector<url::Origin>()}}});
+ {{{kDefaultOnFeature, false, std::vector<url::Origin>()}}});
EXPECT_FALSE(policy1->IsFeatureEnabled(kDefaultOnFeature));
}
@@ -263,7 +250,7 @@ TEST_F(FeaturePolicyTest, TestParentPolicyBlocksSameOriginChildPolicy) {
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
policy1->SetHeaderPolicy(
- {{{"default-on", false, std::vector<url::Origin>()}}});
+ {{{kDefaultOnFeature, false, std::vector<url::Origin>()}}});
std::unique_ptr<FeaturePolicy> policy2 =
CreateFromParentPolicy(policy1.get(), origin_a_);
EXPECT_FALSE(policy2->IsFeatureEnabled(kDefaultOnFeature));
@@ -284,7 +271,7 @@ TEST_F(FeaturePolicyTest, TestChildPolicyCanBlockSelf) {
std::unique_ptr<FeaturePolicy> policy2 =
CreateFromParentPolicy(policy1.get(), origin_b_);
policy2->SetHeaderPolicy(
- {{{"default-on", false, std::vector<url::Origin>()}}});
+ {{{kDefaultOnFeature, false, std::vector<url::Origin>()}}});
EXPECT_FALSE(policy2->IsFeatureEnabled(kDefaultOnFeature));
}
@@ -307,7 +294,7 @@ TEST_F(FeaturePolicyTest, TestChildPolicyCanBlockChildren) {
CreateFromParentPolicy(nullptr, origin_a_);
std::unique_ptr<FeaturePolicy> policy2 =
CreateFromParentPolicy(policy1.get(), origin_b_);
- policy2->SetHeaderPolicy({{{"default-on", false, {origin_b_}}}});
+ policy2->SetHeaderPolicy({{{kDefaultOnFeature, false, {origin_b_}}}});
std::unique_ptr<FeaturePolicy> policy3 =
CreateFromParentPolicy(policy2.get(), origin_c_);
EXPECT_TRUE(policy2->IsFeatureEnabled(kDefaultOnFeature));
@@ -327,7 +314,7 @@ TEST_F(FeaturePolicyTest, TestParentPolicyBlocksCrossOriginChildPolicy) {
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
policy1->SetHeaderPolicy(
- {{{"default-on", false, std::vector<url::Origin>()}}});
+ {{{kDefaultOnFeature, false, std::vector<url::Origin>()}}});
std::unique_ptr<FeaturePolicy> policy2 =
CreateFromParentPolicy(policy1.get(), origin_b_);
EXPECT_FALSE(policy2->IsFeatureEnabled(kDefaultOnFeature));
@@ -350,7 +337,7 @@ TEST_F(FeaturePolicyTest, TestEnableForAllOrigins) {
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
policy1->SetHeaderPolicy(
- {{{"default-self", true, std::vector<url::Origin>()}}});
+ {{{kDefaultSelfFeature, true, std::vector<url::Origin>()}}});
std::unique_ptr<FeaturePolicy> policy2 =
CreateFromParentPolicy(policy1.get(), origin_b_);
std::unique_ptr<FeaturePolicy> policy3 =
@@ -376,7 +363,7 @@ TEST_F(FeaturePolicyTest, TestDefaultOnEnablesForAllAncestors) {
// Feature should be disabled in frame 1; enabled in frames 2, 3 and 4.
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
- policy1->SetHeaderPolicy({{{"default-on", false, {origin_b_}}}});
+ policy1->SetHeaderPolicy({{{kDefaultOnFeature, false, {origin_b_}}}});
std::unique_ptr<FeaturePolicy> policy2 =
CreateFromParentPolicy(policy1.get(), origin_b_);
std::unique_ptr<FeaturePolicy> policy3 =
@@ -405,7 +392,7 @@ TEST_F(FeaturePolicyTest, TestDefaultSelfRespectsSameOriginEmbedding) {
// Feature should be disabled in frames 1 and 4; enabled in frames 2 and 3.
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
- policy1->SetHeaderPolicy({{{"default-self", false, {origin_b_}}}});
+ policy1->SetHeaderPolicy({{{kDefaultSelfFeature, false, {origin_b_}}}});
std::unique_ptr<FeaturePolicy> policy2 =
CreateFromParentPolicy(policy1.get(), origin_b_);
std::unique_ptr<FeaturePolicy> policy3 =
@@ -434,15 +421,15 @@ TEST_F(FeaturePolicyTest, TestDefaultOffMustBeDelegatedToAllCrossOriginFrames) {
// Feature should be disabled in frames 1, 3 and 4; enabled in frame 2 only.
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
- policy1->SetHeaderPolicy({{{"default-off", false, {origin_b_}}}});
+ policy1->SetHeaderPolicy({{{kDefaultOffFeature, false, {origin_b_}}}});
std::unique_ptr<FeaturePolicy> policy2 =
CreateFromParentPolicy(policy1.get(), origin_b_);
- policy2->SetHeaderPolicy({{{"default-off", false, {origin_b_}}}});
+ policy2->SetHeaderPolicy({{{kDefaultOffFeature, false, {origin_b_}}}});
std::unique_ptr<FeaturePolicy> policy3 =
CreateFromParentPolicy(policy2.get(), origin_b_);
std::unique_ptr<FeaturePolicy> policy4 =
CreateFromParentPolicy(policy2.get(), origin_c_);
- policy4->SetHeaderPolicy({{{"default-off", false, {origin_c_}}}});
+ policy4->SetHeaderPolicy({{{kDefaultOffFeature, false, {origin_c_}}}});
EXPECT_FALSE(policy1->IsFeatureEnabled(kDefaultOffFeature));
EXPECT_TRUE(policy2->IsFeatureEnabled(kDefaultOffFeature));
EXPECT_FALSE(policy3->IsFeatureEnabled(kDefaultOffFeature));
@@ -466,11 +453,11 @@ TEST_F(FeaturePolicyTest, TestReenableForAllOrigins) {
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
policy1->SetHeaderPolicy(
- {{{"default-self", true, std::vector<url::Origin>()}}});
+ {{{kDefaultSelfFeature, true, std::vector<url::Origin>()}}});
std::unique_ptr<FeaturePolicy> policy2 =
CreateFromParentPolicy(policy1.get(), origin_b_);
policy2->SetHeaderPolicy(
- {{{"default-self", true, std::vector<url::Origin>()}}});
+ {{{kDefaultSelfFeature, true, std::vector<url::Origin>()}}});
std::unique_ptr<FeaturePolicy> policy3 =
CreateFromParentPolicy(policy2.get(), origin_a_);
EXPECT_TRUE(policy1->IsFeatureEnabled(kDefaultSelfFeature));
@@ -494,11 +481,11 @@ TEST_F(FeaturePolicyTest, TestBlockedFrameCannotReenable) {
// Feature should be enabled at the top level; disabled in all other frames.
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
- policy1->SetHeaderPolicy({{{"default-self", false, {origin_a_}}}});
+ policy1->SetHeaderPolicy({{{kDefaultSelfFeature, false, {origin_a_}}}});
std::unique_ptr<FeaturePolicy> policy2 =
CreateFromParentPolicy(policy1.get(), origin_b_);
policy2->SetHeaderPolicy(
- {{{"default-self", true, std::vector<url::Origin>()}}});
+ {{{kDefaultSelfFeature, true, std::vector<url::Origin>()}}});
std::unique_ptr<FeaturePolicy> policy3 =
CreateFromParentPolicy(policy2.get(), origin_a_);
std::unique_ptr<FeaturePolicy> policy4 =
@@ -525,10 +512,12 @@ TEST_F(FeaturePolicyTest, TestEnabledFrameCanDelegate) {
// Feature should be enabled in all frames.
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
- policy1->SetHeaderPolicy({{{"default-self", false, {origin_a_, origin_b_}}}});
+ policy1->SetHeaderPolicy(
+ {{{kDefaultSelfFeature, false, {origin_a_, origin_b_}}}});
std::unique_ptr<FeaturePolicy> policy2 =
CreateFromParentPolicy(policy1.get(), origin_b_);
- policy2->SetHeaderPolicy({{{"default-self", false, {origin_b_, origin_c_}}}});
+ policy2->SetHeaderPolicy(
+ {{{kDefaultSelfFeature, false, {origin_b_, origin_c_}}}});
std::unique_ptr<FeaturePolicy> policy3 =
CreateFromParentPolicy(policy2.get(), origin_c_);
EXPECT_TRUE(policy1->IsFeatureEnabled(kDefaultSelfFeature));
@@ -552,7 +541,8 @@ TEST_F(FeaturePolicyTest, TestEnabledFrameCanDelegateByDefault) {
// Feature should be enabled in frames 1, 2, and 3, and disabled in frame 4.
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
- policy1->SetHeaderPolicy({{{"default-on", false, {origin_a_, origin_b_}}}});
+ policy1->SetHeaderPolicy(
+ {{{kDefaultOnFeature, false, {origin_a_, origin_b_}}}});
std::unique_ptr<FeaturePolicy> policy2 =
CreateFromParentPolicy(policy1.get(), origin_b_);
std::unique_ptr<FeaturePolicy> policy3 =
@@ -582,7 +572,8 @@ TEST_F(FeaturePolicyTest, TestNonNestedFeaturesDontDelegateByDefault) {
// 4.
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
- policy1->SetHeaderPolicy({{{"default-self", false, {origin_a_, origin_b_}}}});
+ policy1->SetHeaderPolicy(
+ {{{kDefaultSelfFeature, false, {origin_a_, origin_b_}}}});
std::unique_ptr<FeaturePolicy> policy2 =
CreateFromParentPolicy(policy1.get(), origin_b_);
std::unique_ptr<FeaturePolicy> policy3 =
@@ -614,13 +605,14 @@ TEST_F(FeaturePolicyTest, TestFeaturesAreIndependent) {
// should be enabled in frame 1, and disabled in frames 2 and 3.
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
- policy1->SetHeaderPolicy({{{"default-self", false, {origin_a_, origin_b_}},
- {"default-on", false, {origin_a_}}}});
+ policy1->SetHeaderPolicy(
+ {{{kDefaultSelfFeature, false, {origin_a_, origin_b_}},
+ {kDefaultOnFeature, false, {origin_a_}}}});
std::unique_ptr<FeaturePolicy> policy2 =
CreateFromParentPolicy(policy1.get(), origin_b_);
policy2->SetHeaderPolicy(
- {{{"default-self", true, std::vector<url::Origin>()},
- {"default-on", true, std::vector<url::Origin>()}}});
+ {{{kDefaultSelfFeature, true, std::vector<url::Origin>()},
+ {kDefaultOnFeature, true, std::vector<url::Origin>()}}});
std::unique_ptr<FeaturePolicy> policy3 =
CreateFromParentPolicy(policy2.get(), origin_c_);
EXPECT_TRUE(policy1->IsFeatureEnabled(kDefaultSelfFeature));
@@ -640,7 +632,8 @@ TEST_F(FeaturePolicyTest, TestFeatureEnabledForOrigin) {
// and disabled for origin C.
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
- policy1->SetHeaderPolicy({{{"default-off", false, {origin_a_, origin_b_}}}});
+ policy1->SetHeaderPolicy(
+ {{{kDefaultOffFeature, false, {origin_a_, origin_b_}}}});
EXPECT_TRUE(
policy1->IsFeatureEnabledForOrigin(kDefaultOffFeature, origin_a_));
EXPECT_TRUE(
@@ -669,9 +662,9 @@ TEST_F(FeaturePolicyTest, TestSimpleFramePolicy) {
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
ParsedFeaturePolicyHeader frame_policy = {
- {{"default-self", false, {origin_b_}}}};
+ {{kDefaultSelfFeature, false, {origin_b_}}}};
std::unique_ptr<FeaturePolicy> policy2 =
- CreateFromParentWithFramePolicy(policy1.get(), &frame_policy, origin_b_);
+ CreateFromParentWithFramePolicy(policy1.get(), frame_policy, origin_b_);
EXPECT_TRUE(
policy1->IsFeatureEnabledForOrigin(kDefaultSelfFeature, origin_a_));
EXPECT_FALSE(
@@ -704,9 +697,9 @@ TEST_F(FeaturePolicyTest, TestAllOriginFramePolicy) {
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
ParsedFeaturePolicyHeader frame_policy = {
- {{"default-self", true, std::vector<url::Origin>()}}};
+ {{kDefaultSelfFeature, true, std::vector<url::Origin>()}}};
std::unique_ptr<FeaturePolicy> policy2 =
- CreateFromParentWithFramePolicy(policy1.get(), &frame_policy, origin_b_);
+ CreateFromParentWithFramePolicy(policy1.get(), frame_policy, origin_b_);
EXPECT_TRUE(
policy1->IsFeatureEnabledForOrigin(kDefaultSelfFeature, origin_a_));
EXPECT_FALSE(
@@ -750,15 +743,15 @@ TEST_F(FeaturePolicyTest, TestFramePolicyCanBeFurtherDelegated) {
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
ParsedFeaturePolicyHeader frame_policy1 = {
- {{"default-self", false, {origin_b_}}}};
+ {{kDefaultSelfFeature, false, {origin_b_}}}};
std::unique_ptr<FeaturePolicy> policy2 =
- CreateFromParentWithFramePolicy(policy1.get(), &frame_policy1, origin_b_);
+ CreateFromParentWithFramePolicy(policy1.get(), frame_policy1, origin_b_);
ParsedFeaturePolicyHeader frame_policy2 = {
- {{"default-self", false, {origin_c_}}}};
+ {{kDefaultSelfFeature, false, {origin_c_}}}};
std::unique_ptr<FeaturePolicy> policy3 =
- CreateFromParentWithFramePolicy(policy2.get(), &frame_policy2, origin_c_);
+ CreateFromParentWithFramePolicy(policy2.get(), frame_policy2, origin_c_);
std::unique_ptr<FeaturePolicy> policy4 =
- CreateFromParentWithFramePolicy(policy2.get(), nullptr, origin_c_);
+ CreateFromParentPolicy(policy2.get(), origin_c_);
EXPECT_FALSE(
policy3->IsFeatureEnabledForOrigin(kDefaultSelfFeature, origin_a_));
EXPECT_FALSE(
@@ -795,13 +788,13 @@ TEST_F(FeaturePolicyTest, TestDefaultOnCanBeDisabledByFramePolicy) {
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
ParsedFeaturePolicyHeader frame_policy1 = {
- {{"default-on", false, std::vector<url::Origin>()}}};
+ {{kDefaultOnFeature, false, std::vector<url::Origin>()}}};
std::unique_ptr<FeaturePolicy> policy2 =
- CreateFromParentWithFramePolicy(policy1.get(), &frame_policy1, origin_a_);
+ CreateFromParentWithFramePolicy(policy1.get(), frame_policy1, origin_a_);
ParsedFeaturePolicyHeader frame_policy2 = {
- {{"default-on", false, std::vector<url::Origin>()}}};
+ {{kDefaultOnFeature, false, std::vector<url::Origin>()}}};
std::unique_ptr<FeaturePolicy> policy3 =
- CreateFromParentWithFramePolicy(policy1.get(), &frame_policy2, origin_b_);
+ CreateFromParentWithFramePolicy(policy1.get(), frame_policy2, origin_b_);
EXPECT_TRUE(policy1->IsFeatureEnabledForOrigin(kDefaultOnFeature, origin_a_));
EXPECT_TRUE(policy1->IsFeatureEnabledForOrigin(kDefaultOnFeature, origin_b_));
EXPECT_TRUE(policy1->IsFeatureEnabledForOrigin(kDefaultOnFeature, origin_c_));
@@ -840,15 +833,15 @@ TEST_F(FeaturePolicyTest, TestDefaultOffMustBeEnabledByChildFrame) {
// child frames because they did not declare their own policy to enable it.
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
- policy1->SetHeaderPolicy({{{"default-off", false, {origin_a_}}}});
+ policy1->SetHeaderPolicy({{{kDefaultOffFeature, false, {origin_a_}}}});
ParsedFeaturePolicyHeader frame_policy1 = {
- {{"default-off", false, {origin_a_}}}};
+ {{kDefaultOffFeature, false, {origin_a_}}}};
std::unique_ptr<FeaturePolicy> policy2 =
- CreateFromParentWithFramePolicy(policy1.get(), &frame_policy1, origin_a_);
+ CreateFromParentWithFramePolicy(policy1.get(), frame_policy1, origin_a_);
ParsedFeaturePolicyHeader frame_policy2 = {
- {{"default-off", false, {origin_b_}}}};
+ {{kDefaultOffFeature, false, {origin_b_}}}};
std::unique_ptr<FeaturePolicy> policy3 =
- CreateFromParentWithFramePolicy(policy1.get(), &frame_policy2, origin_b_);
+ CreateFromParentWithFramePolicy(policy1.get(), frame_policy2, origin_b_);
EXPECT_TRUE(
policy1->IsFeatureEnabledForOrigin(kDefaultOffFeature, origin_a_));
EXPECT_FALSE(
@@ -891,17 +884,17 @@ TEST_F(FeaturePolicyTest, TestDefaultOffCanBeEnabledByChildFrame) {
// they declare their own policy to enable it.
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
- policy1->SetHeaderPolicy({{{"default-off", false, {origin_a_}}}});
+ policy1->SetHeaderPolicy({{{kDefaultOffFeature, false, {origin_a_}}}});
ParsedFeaturePolicyHeader frame_policy1 = {
- {{"default-off", false, {origin_a_}}}};
+ {{kDefaultOffFeature, false, {origin_a_}}}};
std::unique_ptr<FeaturePolicy> policy2 =
- CreateFromParentWithFramePolicy(policy1.get(), &frame_policy1, origin_a_);
- policy2->SetHeaderPolicy({{{"default-off", false, {origin_a_}}}});
+ CreateFromParentWithFramePolicy(policy1.get(), frame_policy1, origin_a_);
+ policy2->SetHeaderPolicy({{{kDefaultOffFeature, false, {origin_a_}}}});
ParsedFeaturePolicyHeader frame_policy2 = {
- {{"default-off", false, {origin_b_}}}};
+ {{kDefaultOffFeature, false, {origin_b_}}}};
std::unique_ptr<FeaturePolicy> policy3 =
- CreateFromParentWithFramePolicy(policy1.get(), &frame_policy2, origin_b_);
- policy3->SetHeaderPolicy({{{"default-off", false, {origin_b_}}}});
+ CreateFromParentWithFramePolicy(policy1.get(), frame_policy2, origin_b_);
+ policy3->SetHeaderPolicy({{{kDefaultOffFeature, false, {origin_b_}}}});
EXPECT_TRUE(
policy1->IsFeatureEnabledForOrigin(kDefaultOffFeature, origin_a_));
EXPECT_FALSE(
@@ -945,16 +938,17 @@ TEST_F(FeaturePolicyTest, TestFramePolicyModifiesHeaderPolicy) {
// policy.
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
- policy1->SetHeaderPolicy({{{"default-self", false, {origin_a_, origin_b_}}}});
+ policy1->SetHeaderPolicy(
+ {{{kDefaultSelfFeature, false, {origin_a_, origin_b_}}}});
ParsedFeaturePolicyHeader frame_policy1 = {
- {{"default-self", false, std::vector<url::Origin>()}}};
+ {{kDefaultSelfFeature, false, std::vector<url::Origin>()}}};
std::unique_ptr<FeaturePolicy> policy2 =
- CreateFromParentWithFramePolicy(policy1.get(), &frame_policy1, origin_b_);
+ CreateFromParentWithFramePolicy(policy1.get(), frame_policy1, origin_b_);
ParsedFeaturePolicyHeader frame_policy2 = {
- {{"default-self", false, std::vector<url::Origin>()}}};
+ {{kDefaultSelfFeature, false, std::vector<url::Origin>()}}};
std::unique_ptr<FeaturePolicy> policy3 =
- CreateFromParentWithFramePolicy(policy1.get(), &frame_policy2, origin_b_);
- policy3->SetHeaderPolicy({{{"default-self", false, {origin_b_}}}});
+ CreateFromParentWithFramePolicy(policy1.get(), frame_policy2, origin_b_);
+ policy3->SetHeaderPolicy({{{kDefaultSelfFeature, false, {origin_b_}}}});
EXPECT_FALSE(
policy2->IsFeatureEnabledForOrigin(kDefaultSelfFeature, origin_b_));
EXPECT_FALSE(
@@ -989,17 +983,17 @@ TEST_F(FeaturePolicyTest, TestCombineFrameAndHeaderPolicies) {
std::unique_ptr<FeaturePolicy> policy1 =
CreateFromParentPolicy(nullptr, origin_a_);
ParsedFeaturePolicyHeader frame_policy1 = {
- {{"default-self", false, {origin_b_}}}};
+ {{kDefaultSelfFeature, false, {origin_b_}}}};
std::unique_ptr<FeaturePolicy> policy2 =
- CreateFromParentWithFramePolicy(policy1.get(), &frame_policy1, origin_b_);
+ CreateFromParentWithFramePolicy(policy1.get(), frame_policy1, origin_b_);
policy2->SetHeaderPolicy(
- {{{"default-self", true, std::vector<url::Origin>()}}});
+ {{{kDefaultSelfFeature, true, std::vector<url::Origin>()}}});
ParsedFeaturePolicyHeader frame_policy2 = {
- {{"default-self", false, std::vector<url::Origin>()}}};
+ {{kDefaultSelfFeature, false, std::vector<url::Origin>()}}};
std::unique_ptr<FeaturePolicy> policy3 =
- CreateFromParentWithFramePolicy(policy2.get(), &frame_policy2, origin_c_);
+ CreateFromParentWithFramePolicy(policy2.get(), frame_policy2, origin_c_);
std::unique_ptr<FeaturePolicy> policy4 =
- CreateFromParentWithFramePolicy(policy2.get(), nullptr, origin_c_);
+ CreateFromParentPolicy(policy2.get(), origin_c_);
EXPECT_TRUE(
policy1->IsFeatureEnabledForOrigin(kDefaultSelfFeature, origin_a_));
EXPECT_TRUE(
@@ -1009,4 +1003,5 @@ TEST_F(FeaturePolicyTest, TestCombineFrameAndHeaderPolicies) {
EXPECT_TRUE(
policy4->IsFeatureEnabledForOrigin(kDefaultSelfFeature, origin_c_));
}
+
} // namespace content
diff --git a/chromium/content/common/features.gni b/chromium/content/common/features.gni
new file mode 100644
index 00000000000..c43056ad924
--- /dev/null
+++ b/chromium/content/common/features.gni
@@ -0,0 +1,8 @@
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+declare_args() {
+ # Whether or not to use external popup menu.
+ use_external_popup_menu = is_android || is_mac
+}
diff --git a/chromium/content/common/field_trial_recorder.mojom b/chromium/content/common/field_trial_recorder.mojom
new file mode 100644
index 00000000000..ef2db86f4f8
--- /dev/null
+++ b/chromium/content/common/field_trial_recorder.mojom
@@ -0,0 +1,11 @@
+// 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.
+
+module content.mojom;
+
+// Records field trial activations from the renderers.
+interface FieldTrialRecorder {
+ // Indicates that a field trial has been activated.
+ FieldTrialActivated(string trial_name);
+};
diff --git a/chromium/content/common/font_list_mac.mm b/chromium/content/common/font_list_mac.mm
index d4768ae25b9..2648a32c070 100644
--- a/chromium/content/common/font_list_mac.mm
+++ b/chromium/content/common/font_list_mac.mm
@@ -6,7 +6,10 @@
#import <Cocoa/Cocoa.h>
+#include <utility>
+
#include "base/mac/scoped_nsautorelease_pool.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/sys_string_conversions.h"
#include "base/values.h"
@@ -31,12 +34,10 @@ std::unique_ptr<base::ListValue> GetFontList_SlowBlocking() {
for (NSString* family_name in sortedFonts) {
NSString* localized_family_name = fonts_dict[family_name];
- base::ListValue* font_item = new base::ListValue();
- base::string16 family = base::SysNSStringToUTF16(family_name);
- base::string16 loc_family = base::SysNSStringToUTF16(localized_family_name);
- font_item->Append(new base::StringValue(family));
- font_item->Append(new base::StringValue(loc_family));
- font_list->Append(font_item);
+ auto font_item = base::MakeUnique<base::ListValue>();
+ font_item->AppendString(base::SysNSStringToUTF16(family_name));
+ font_item->AppendString(base::SysNSStringToUTF16(localized_family_name));
+ font_list->Append(std::move(font_item));
}
return font_list;
diff --git a/chromium/content/common/font_list_win.cc b/chromium/content/common/font_list_win.cc
index 8d00e0a75fc..38402c528ea 100644
--- a/chromium/content/common/font_list_win.cc
+++ b/chromium/content/common/font_list_win.cc
@@ -46,8 +46,8 @@ std::unique_ptr<base::ListValue> GetFontList_SlowBlocking() {
std::set<base::string16>::iterator iter;
for (iter = font_names.begin(); iter != font_names.end(); ++iter) {
base::ListValue* font_item = new base::ListValue();
- font_item->Append(new base::StringValue(*iter));
- font_item->Append(new base::StringValue(*iter));
+ font_item->Append(new base::Value(*iter));
+ font_item->Append(new base::Value(*iter));
font_list->Append(font_item);
}
return font_list;
diff --git a/chromium/content/common/frame_message_enums.h b/chromium/content/common/frame_message_enums.h
index ef1d22d0b18..8472a84a75a 100644
--- a/chromium/content/common/frame_message_enums.h
+++ b/chromium/content/common/frame_message_enums.h
@@ -5,7 +5,7 @@
#ifndef CONTENT_COMMON_FRAME_MESSAGE_ENUMS_H_
#define CONTENT_COMMON_FRAME_MESSAGE_ENUMS_H_
-#include "content/common/accessibility_mode_enums.h"
+#include "content/common/accessibility_mode.h"
struct FrameMsg_Navigate_Type {
public:
diff --git a/chromium/content/common/frame_messages.h b/chromium/content/common/frame_messages.h
index 0442702b443..b8be34e0b6f 100644
--- a/chromium/content/common/frame_messages.h
+++ b/chromium/content/common/frame_messages.h
@@ -19,9 +19,10 @@
#include "cc/surfaces/surface_sequence.h"
#include "content/common/content_export.h"
#include "content/common/content_param_traits.h"
-#include "content/common/content_security_policy/content_security_policy.h"
+#include "content/common/content_security_policy/csp_context.h"
#include "content/common/content_security_policy_header.h"
#include "content/common/download/mhtml_save_status.h"
+#include "content/common/features.h"
#include "content/common/frame_message_enums.h"
#include "content/common/frame_owner_properties.h"
#include "content/common/frame_replication_state.h"
@@ -94,17 +95,17 @@ IPC_ENUM_TRAITS_MAX_VALUE(FrameMsg_Navigate_Type::Value,
IPC_ENUM_TRAITS_MAX_VALUE(FrameMsg_UILoadMetricsReportType::Value,
FrameMsg_UILoadMetricsReportType::REPORT_TYPE_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebContextMenuData::MediaType,
- blink::WebContextMenuData::MediaTypeLast)
+ blink::WebContextMenuData::kMediaTypeLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebContextMenuData::InputFieldType,
- blink::WebContextMenuData::InputFieldTypeLast)
-IPC_ENUM_TRAITS_MAX_VALUE(blink::WebFocusType, blink::WebFocusTypeLast)
+ blink::WebContextMenuData::kInputFieldTypeLast)
+IPC_ENUM_TRAITS_MAX_VALUE(blink::WebFocusType, blink::kWebFocusTypeLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebFrameOwnerProperties::ScrollingMode,
- blink::WebFrameOwnerProperties::ScrollingMode::Last)
+ blink::WebFrameOwnerProperties::ScrollingMode::kLast)
IPC_ENUM_TRAITS_MAX_VALUE(content::StopFindAction,
content::STOP_FIND_ACTION_LAST)
IPC_ENUM_TRAITS(blink::WebSandboxFlags) // Bitmask.
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebTreeScopeType,
- blink::WebTreeScopeType::Last)
+ blink::WebTreeScopeType::kLast)
IPC_ENUM_TRAITS_MAX_VALUE(ui::MenuSourceType, ui::MENU_SOURCE_TYPE_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(content::FileChooserParams::Mode,
content::FileChooserParams::Save)
@@ -112,11 +113,13 @@ IPC_ENUM_TRAITS_MAX_VALUE(content::CSPDirective::Name,
content::CSPDirective::NameLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebFeaturePolicyFeature,
blink::WebFeaturePolicyFeature::LAST_FEATURE)
+IPC_ENUM_TRAITS_MAX_VALUE(content::CSPDisposition,
+ content::CSPDisposition::LAST)
IPC_STRUCT_TRAITS_BEGIN(blink::WebFindOptions)
IPC_STRUCT_TRAITS_MEMBER(forward)
- IPC_STRUCT_TRAITS_MEMBER(matchCase)
- IPC_STRUCT_TRAITS_MEMBER(findNext)
+ IPC_STRUCT_TRAITS_MEMBER(match_case)
+ IPC_STRUCT_TRAITS_MEMBER(find_next)
IPC_STRUCT_TRAITS_MEMBER(force)
IPC_STRUCT_TRAITS_END()
@@ -177,6 +180,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::FrameOwnerProperties)
IPC_STRUCT_TRAITS_MEMBER(margin_height)
IPC_STRUCT_TRAITS_MEMBER(allow_fullscreen)
IPC_STRUCT_TRAITS_MEMBER(allow_payment_request)
+ IPC_STRUCT_TRAITS_MEMBER(is_display_none)
IPC_STRUCT_TRAITS_MEMBER(required_csp)
IPC_STRUCT_TRAITS_MEMBER(allowed_features)
IPC_STRUCT_TRAITS_END()
@@ -243,10 +247,10 @@ IPC_STRUCT_BEGIN_WITH_PARENT(FrameHostMsg_DidCommitProvisionalLoad_Params,
// The POST body identifier. -1 if it doesn't exist.
IPC_STRUCT_MEMBER(int64_t, post_id)
- // Whether the frame navigation resulted in no change to the documents within
- // the page. For example, the navigation may have just resulted in scrolling
- // to a named anchor.
- IPC_STRUCT_MEMBER(bool, was_within_same_page)
+ // Whether the frame navigation resulted in no change of the document within
+ // the frame. For example, the navigation may have just resulted in
+ // scrolling to a named anchor.
+ IPC_STRUCT_MEMBER(bool, was_within_same_document)
// The status code of the HTTP request.
IPC_STRUCT_MEMBER(int, http_status_code)
@@ -332,6 +336,12 @@ IPC_STRUCT_BEGIN(FrameMsg_PostMessage_Params)
IPC_STRUCT_MEMBER(std::vector<content::MessagePort>, message_ports)
IPC_STRUCT_END()
+IPC_STRUCT_TRAITS_BEGIN(content::SourceLocation)
+ IPC_STRUCT_TRAITS_MEMBER(url)
+ IPC_STRUCT_TRAITS_MEMBER(line_number)
+ IPC_STRUCT_TRAITS_MEMBER(column_number)
+IPC_STRUCT_TRAITS_END()
+
IPC_STRUCT_TRAITS_BEGIN(content::CommonNavigationParams)
IPC_STRUCT_TRAITS_MEMBER(url)
IPC_STRUCT_TRAITS_MEMBER(referrer)
@@ -347,6 +357,8 @@ IPC_STRUCT_TRAITS_BEGIN(content::CommonNavigationParams)
IPC_STRUCT_TRAITS_MEMBER(navigation_start)
IPC_STRUCT_TRAITS_MEMBER(method)
IPC_STRUCT_TRAITS_MEMBER(post_data)
+ IPC_STRUCT_TRAITS_MEMBER(source_location)
+ IPC_STRUCT_TRAITS_MEMBER(should_check_main_world_csp)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(content::BeginNavigationParams)
@@ -360,6 +372,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::BeginNavigationParams)
IPC_STRUCT_TRAITS_MEMBER(searchable_form_encoding)
IPC_STRUCT_TRAITS_MEMBER(initiator_origin)
IPC_STRUCT_TRAITS_MEMBER(client_side_redirect_url)
+ IPC_STRUCT_TRAITS_MEMBER(is_form_submission)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(content::StartNavigationParams)
@@ -404,7 +417,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::RequestNavigationParams)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(content::ParsedFeaturePolicyDeclaration)
- IPC_STRUCT_TRAITS_MEMBER(feature_name)
+ IPC_STRUCT_TRAITS_MEMBER(feature)
IPC_STRUCT_TRAITS_MEMBER(matches_all_origins)
IPC_STRUCT_TRAITS_MEMBER(origins)
IPC_STRUCT_TRAITS_END()
@@ -515,9 +528,6 @@ IPC_STRUCT_BEGIN(FrameMsg_SerializeAsMHTML_Params)
// Salt used for |digests_of_uris_to_skip|.
IPC_STRUCT_MEMBER(std::string, salt)
-
- // If |is_last_frame| is true, then an MHTML footer will be generated.
- IPC_STRUCT_MEMBER(bool, is_last_frame)
IPC_STRUCT_END()
// This message is used to send hittesting data from the renderer in order
@@ -561,11 +571,9 @@ IPC_STRUCT_TRAITS_BEGIN(content::CSPDirective)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(content::ContentSecurityPolicy)
- IPC_STRUCT_TRAITS_MEMBER(disposition)
- IPC_STRUCT_TRAITS_MEMBER(source)
+ IPC_STRUCT_TRAITS_MEMBER(header)
IPC_STRUCT_TRAITS_MEMBER(directives)
IPC_STRUCT_TRAITS_MEMBER(report_endpoints)
- IPC_STRUCT_TRAITS_MEMBER(header)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(content::ContentSecurityPolicyHeader)
@@ -574,6 +582,18 @@ IPC_STRUCT_TRAITS_BEGIN(content::ContentSecurityPolicyHeader)
IPC_STRUCT_TRAITS_MEMBER(source)
IPC_STRUCT_TRAITS_END()
+IPC_STRUCT_TRAITS_BEGIN(content::CSPViolationParams)
+ IPC_STRUCT_TRAITS_MEMBER(directive)
+ IPC_STRUCT_TRAITS_MEMBER(effective_directive)
+ IPC_STRUCT_TRAITS_MEMBER(console_message)
+ IPC_STRUCT_TRAITS_MEMBER(blocked_url)
+ IPC_STRUCT_TRAITS_MEMBER(report_endpoints)
+ IPC_STRUCT_TRAITS_MEMBER(header)
+ IPC_STRUCT_TRAITS_MEMBER(disposition)
+ IPC_STRUCT_TRAITS_MEMBER(after_redirect)
+ IPC_STRUCT_TRAITS_MEMBER(source_location)
+IPC_STRUCT_TRAITS_END()
+
IPC_STRUCT_TRAITS_BEGIN(content::FileChooserFileInfo)
IPC_STRUCT_TRAITS_MEMBER(file_path)
IPC_STRUCT_TRAITS_MEMBER(display_name)
@@ -595,7 +615,16 @@ IPC_STRUCT_TRAITS_BEGIN(content::FileChooserParams)
IPC_STRUCT_TRAITS_MEMBER(requestor)
IPC_STRUCT_TRAITS_END()
-#if defined(USE_EXTERNAL_POPUP_MENU)
+IPC_STRUCT_BEGIN(FrameMsg_MixedContentFound_Params)
+ IPC_STRUCT_MEMBER(GURL, main_resource_url)
+ IPC_STRUCT_MEMBER(GURL, mixed_content_url)
+ IPC_STRUCT_MEMBER(content::RequestContextType, request_context_type)
+ IPC_STRUCT_MEMBER(bool, was_allowed)
+ IPC_STRUCT_MEMBER(bool, had_redirect)
+ IPC_STRUCT_MEMBER(content::SourceLocation, source_location)
+IPC_STRUCT_END()
+
+#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
// This message is used for supporting popup menus on Mac OS X and Android using
// native controls. See the FrameHostMsg_ShowPopup message.
IPC_STRUCT_BEGIN(FrameHostMsg_ShowPopup_Params)
@@ -779,8 +808,7 @@ IPC_MESSAGE_ROUTED2(FrameMsg_ExtractSmartClipData,
gfx::Rect /* rect */)
// Change the accessibility mode in the renderer process.
-IPC_MESSAGE_ROUTED1(FrameMsg_SetAccessibilityMode,
- AccessibilityMode)
+IPC_MESSAGE_ROUTED1(FrameMsg_SetAccessibilityMode, content::AccessibilityMode)
// Dispatch a load event in the iframe element containing this frame.
IPC_MESSAGE_ROUTED0(FrameMsg_DispatchLoad)
@@ -795,8 +823,8 @@ IPC_MESSAGE_ROUTED2(FrameMsg_DidUpdateName,
std::string /* unique_name */)
// Updates replicated ContentSecurityPolicy in a frame proxy.
-IPC_MESSAGE_ROUTED1(FrameMsg_AddContentSecurityPolicy,
- content::ContentSecurityPolicyHeader)
+IPC_MESSAGE_ROUTED1(FrameMsg_AddContentSecurityPolicies,
+ std::vector<content::ContentSecurityPolicyHeader>)
// Resets ContentSecurityPolicy in a frame proxy / in RemoteSecurityContext.
IPC_MESSAGE_ROUTED0(FrameMsg_ResetContentSecurityPolicy)
@@ -865,7 +893,7 @@ IPC_MESSAGE_ROUTED3(FrameMsg_ActivateNearestFindResult,
IPC_MESSAGE_ROUTED1(FrameMsg_FindMatchRects, int /* current_version */)
#endif
-#if defined(USE_EXTERNAL_POPUP_MENU)
+#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
#if defined(OS_MACOSX)
IPC_MESSAGE_ROUTED1(FrameMsg_SelectPopupMenuItem,
int /* selected index, -1 means no selection */)
@@ -879,12 +907,14 @@ IPC_MESSAGE_ROUTED2(FrameMsg_SelectPopupMenuItems,
// PlzNavigate
// Tells the renderer that a navigation is ready to commit. The renderer should
// request |stream_url| to get access to the stream containing the body of the
-// response.
-IPC_MESSAGE_ROUTED4(FrameMsg_CommitNavigation,
- content::ResourceResponseHead, /* response */
- GURL, /* stream_url */
- content::CommonNavigationParams, /* common_params */
- content::RequestNavigationParams /* request_params */)
+// response. When --enable-network-service is in effect, |stream_url| is not
+// used, and instead the data is passed to the renderer in |handle|.
+IPC_MESSAGE_ROUTED5(FrameMsg_CommitNavigation,
+ content::ResourceResponseHead, /* response */
+ GURL, /* stream_url */
+ mojo::DataPipeConsumerHandle, /* handle */
+ content::CommonNavigationParams, /* common_params */
+ content::RequestNavigationParams /* request_params */)
// PlzNavigate
// Tells the renderer that a navigation failed with the error code |error_code|
@@ -895,6 +925,12 @@ IPC_MESSAGE_ROUTED4(FrameMsg_FailedNavigation,
bool, /* stale_copy_in_cache */
int /* error_code */)
+// PlzNavigate
+// Tells the renderer that a navigation was blocked because a content security
+// policy was violated.
+IPC_MESSAGE_ROUTED1(FrameMsg_ReportContentSecurityPolicyViolation,
+ content::CSPViolationParams /* violation_params */)
+
// Request to enumerate and return links to all savable resources in the frame
// Note: this covers only the immediate frame / doesn't cover subframes.
IPC_MESSAGE_ROUTED0(FrameMsg_GetSavableResourceLinks)
@@ -986,12 +1022,8 @@ IPC_MESSAGE_ROUTED1(FrameMsg_BlinkFeatureUsageReport,
// Informs the renderer that mixed content was found by the browser. The
// included data is used for instance to report to the CSP policy and to log to
// the frame console.
-IPC_MESSAGE_ROUTED5(FrameMsg_MixedContentFound,
- GURL, /* main_resource_url */
- GURL, /* mixed_content_url */
- content::RequestContextType, /* request_context_type */
- bool, /* was_allowed */
- bool) /* had_redirect */
+IPC_MESSAGE_ROUTED1(FrameMsg_MixedContentFound,
+ FrameMsg_MixedContentFound_Params)
// -----------------------------------------------------------------------------
// Messages sent from the renderer to the browser.
@@ -1079,9 +1111,8 @@ IPC_MESSAGE_ROUTED1(FrameHostMsg_DidSetFeaturePolicyHeader,
// headers and/or policies that might have been inherited from the parent frame)
// or when a new policy has been discovered afterwards (i.e. found in a
// dynamically added or a static <meta> element).
-IPC_MESSAGE_ROUTED2(FrameHostMsg_DidAddContentSecurityPolicy,
- content::ContentSecurityPolicyHeader,
- std::vector<content::ContentSecurityPolicy>)
+IPC_MESSAGE_ROUTED1(FrameHostMsg_DidAddContentSecurityPolicies,
+ std::vector<content::ContentSecurityPolicy> /* policies */)
// Sent when the frame starts enforcing an insecure request policy. Sending
// this information in DidCommitProvisionalLoad isn't sufficient; this
@@ -1364,12 +1395,6 @@ IPC_MESSAGE_ROUTED3(FrameHostMsg_BeforeUnload_ACK,
// Indicates that the current frame has swapped out, after a SwapOut message.
IPC_MESSAGE_ROUTED0(FrameHostMsg_SwapOut_ACK)
-// Forwards an input event to a child.
-// TODO(nick): Temporary bridge, revisit once the browser process can route
-// input directly to subframes. http://crbug.com/339659
-IPC_MESSAGE_ROUTED1(FrameHostMsg_ForwardInputEvent,
- IPC::WebInputEventPointer /* event */)
-
// Tells the parent that a child's frame rect has changed (or the rect/scroll
// position of a child's ancestor has changed).
IPC_MESSAGE_ROUTED1(FrameHostMsg_FrameRectChanged, gfx::Rect /* frame_rect */)
@@ -1481,6 +1506,11 @@ IPC_MESSAGE_ROUTED2(FrameHostMsg_BeginNavigation,
content::CommonNavigationParams,
content::BeginNavigationParams)
+// PlzNavigate
+// Tells the browser to abort an ongoing renderer-initiated navigation. This is
+// used when the page calls document.open.
+IPC_MESSAGE_ROUTED0(FrameHostMsg_AbortNavigation)
+
// Sent as a response to FrameMsg_VisualStateRequest.
// The message is delivered using RenderWidget::QueueMessage.
IPC_MESSAGE_ROUTED1(FrameHostMsg_VisualStateResponse, uint64_t /* id */)
@@ -1507,6 +1537,10 @@ IPC_MESSAGE_ROUTED1(FrameHostMsg_RouteMessageEvent,
// Sent when the renderer displays insecure content in a secure origin.
IPC_MESSAGE_ROUTED0(FrameHostMsg_DidDisplayInsecureContent)
+// Sent when the renderer displays a form containing a non-secure action target
+// url on a page in a secure origin.
+IPC_MESSAGE_ROUTED0(FrameHostMsg_DidContainInsecureFormAction)
+
// Sent when the renderer runs insecure content in a secure origin.
IPC_MESSAGE_ROUTED2(FrameHostMsg_DidRunInsecureContent,
GURL /* security_origin */,
@@ -1579,7 +1613,7 @@ IPC_MESSAGE_ROUTED1(FrameHostMsg_HittestData, FrameHostMsg_HittestData_Params)
// FrameMsg_RunFileChooserResponse message.
IPC_MESSAGE_ROUTED1(FrameHostMsg_RunFileChooser, content::FileChooserParams)
-#if defined(USE_EXTERNAL_POPUP_MENU)
+#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
// Message to show/hide a popup menu using native controls.
IPC_MESSAGE_ROUTED1(FrameHostMsg_ShowPopup,
@@ -1614,6 +1648,8 @@ IPC_MESSAGE_ROUTED3(FrameHostMsg_FindMatchRects_Reply,
IPC_MESSAGE_ROUTED2(FrameHostMsg_GetNearestFindResult_Reply,
int /* nfr_request_id */,
float /* distance */)
+
+IPC_MESSAGE_ROUTED0(FrameHostMsg_NavigationHandledByEmbedder)
#endif
// Adding a new message? Stick to the sort order above: first platform
diff --git a/chromium/content/common/frame_owner_properties.cc b/chromium/content/common/frame_owner_properties.cc
index 8e0f7ead13a..bbe376459ea 100644
--- a/chromium/content/common/frame_owner_properties.cc
+++ b/chromium/content/common/frame_owner_properties.cc
@@ -7,11 +7,12 @@
namespace content {
FrameOwnerProperties::FrameOwnerProperties()
- : scrolling_mode(blink::WebFrameOwnerProperties::ScrollingMode::Auto),
+ : scrolling_mode(blink::WebFrameOwnerProperties::ScrollingMode::kAuto),
margin_width(-1),
margin_height(-1),
allow_fullscreen(false),
- allow_payment_request(false) {}
+ allow_payment_request(false),
+ is_display_none(false) {}
FrameOwnerProperties::FrameOwnerProperties(const FrameOwnerProperties& other) =
default;
@@ -24,11 +25,9 @@ bool FrameOwnerProperties::operator==(const FrameOwnerProperties& other) const {
margin_height == other.margin_height &&
allow_fullscreen == other.allow_fullscreen &&
allow_payment_request == other.allow_payment_request &&
+ is_display_none == other.is_display_none &&
required_csp == other.required_csp &&
- std::equal(delegated_permissions.begin(), delegated_permissions.end(),
- other.delegated_permissions.begin()) &&
- std::equal(allowed_features.begin(), allowed_features.end(),
- other.allowed_features.begin());
+ allowed_features == other.allowed_features;
}
} // namespace content
diff --git a/chromium/content/common/frame_owner_properties.h b/chromium/content/common/frame_owner_properties.h
index 20d3510c866..693d4827e3b 100644
--- a/chromium/content/common/frame_owner_properties.h
+++ b/chromium/content/common/frame_owner_properties.h
@@ -9,7 +9,6 @@
#include "content/common/content_export.h"
#include "third_party/WebKit/public/platform/WebFeaturePolicy.h"
-#include "third_party/WebKit/public/platform/modules/permissions/permission.mojom.h"
#include "third_party/WebKit/public/web/WebFrameOwnerProperties.h"
namespace content {
@@ -33,6 +32,7 @@ struct CONTENT_EXPORT FrameOwnerProperties {
int margin_height;
bool allow_fullscreen;
bool allow_payment_request;
+ bool is_display_none;
// An experimental attribute to be used by a parent frame to enforce CSP on a
// subframe. This is different from replicated CSP headers kept in
@@ -41,7 +41,6 @@ struct CONTENT_EXPORT FrameOwnerProperties {
// https://www.w3.org/TR/csp-embedded-enforcement/#required-csp
std::string required_csp;
- std::vector<blink::mojom::PermissionName> delegated_permissions;
std::vector<blink::WebFeaturePolicyFeature> allowed_features;
};
diff --git a/chromium/content/common/frame_replication_state.cc b/chromium/content/common/frame_replication_state.cc
index c7def2a9f7c..b4feb5e4a3a 100644
--- a/chromium/content/common/frame_replication_state.cc
+++ b/chromium/content/common/frame_replication_state.cc
@@ -10,8 +10,8 @@
namespace content {
FrameReplicationState::FrameReplicationState()
- : sandbox_flags(blink::WebSandboxFlags::None),
- scope(blink::WebTreeScopeType::Document),
+ : sandbox_flags(blink::WebSandboxFlags::kNone),
+ scope(blink::WebTreeScopeType::kDocument),
insecure_request_policy(blink::kLeaveInsecureRequestsAlone),
has_potentially_trustworthy_unique_origin(false),
has_received_user_gesture(false) {}
diff --git a/chromium/content/common/frame_sink_provider.mojom b/chromium/content/common/frame_sink_provider.mojom
new file mode 100644
index 00000000000..5c2b1299f3b
--- /dev/null
+++ b/chromium/content/common/frame_sink_provider.mojom
@@ -0,0 +1,10 @@
+module content.mojom;
+
+import "cc/ipc/mojo_compositor_frame_sink.mojom";
+
+// This interface provides MojoCompositorFrameSink for the renderer.
+interface FrameSinkProvider {
+ CreateForWidget(
+ int32 widget_id, cc.mojom.MojoCompositorFrameSink& request,
+ cc.mojom.MojoCompositorFrameSinkClient client);
+};
diff --git a/chromium/content/common/gpu/OWNERS b/chromium/content/common/gpu/OWNERS
deleted file mode 100644
index 2afc34bb734..00000000000
--- a/chromium/content/common/gpu/OWNERS
+++ /dev/null
@@ -1,11 +0,0 @@
-ccameron@chromium.org
-jbauman@chromium.org
-kbr@chromium.org
-
-# GPU memory manager.
-per-file *gpu_memory_manager*=ccameron@chromium.org
-
-per-file *_messages*.h=set noparent
-per-file *_messages*.h=file://ipc/SECURITY_OWNERS
-
-# COMPONENT: Internals>GPU
diff --git a/chromium/content/common/gpu_host_messages.h b/chromium/content/common/gpu_host_messages.h
deleted file mode 100644
index 01bf3d7f29d..00000000000
--- a/chromium/content/common/gpu_host_messages.h
+++ /dev/null
@@ -1,193 +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.
-
-// Multiply-included message file, hence no include guard here, but see below
-// for a much smaller-than-usual include guard section.
-
-#include "build/build_config.h"
-#include "content/common/content_export.h"
-#include "content/common/establish_channel_params.h"
-#include "gpu/command_buffer/common/sync_token.h"
-#include "gpu/command_buffer/service/gpu_preferences.h"
-#include "gpu/config/gpu_feature_info.h"
-#include "gpu/config/gpu_info.h"
-#include "gpu/ipc/common/gpu_command_buffer_traits.h"
-#include "gpu/ipc/common/gpu_param_traits.h"
-#include "gpu/ipc/common/memory_stats.h"
-#include "gpu/ipc/common/surface_handle.h"
-#include "ipc/ipc_channel_handle.h"
-#include "ipc/ipc_message_macros.h"
-#include "ipc/ipc_message_start.h"
-#include "media/media_features.h"
-#include "ui/events/ipc/latency_info_param_traits.h"
-#include "ui/gfx/gpu_memory_buffer.h"
-#include "ui/gfx/ipc/gfx_param_traits.h"
-#include "ui/gfx/ipc/skia/gfx_skia_param_traits.h"
-#include "url/gurl.h"
-#include "url/ipc/url_param_traits.h"
-
-#undef IPC_MESSAGE_EXPORT
-#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
-
-#define IPC_MESSAGE_START GpuMsgStart
-
-IPC_ENUM_TRAITS_VALIDATE(gpu::GpuPreferences::VpxDecodeVendors,
- ((value >= gpu::GpuPreferences::VPX_VENDOR_NONE) &&
- (value <= gpu::GpuPreferences::VPX_VENDOR_ALL)))
-
-IPC_STRUCT_BEGIN(GpuMsg_CreateGpuMemoryBuffer_Params)
- IPC_STRUCT_MEMBER(gfx::GpuMemoryBufferId, id)
- IPC_STRUCT_MEMBER(gfx::Size, size)
- IPC_STRUCT_MEMBER(gfx::BufferFormat, format)
- IPC_STRUCT_MEMBER(gfx::BufferUsage, usage)
- IPC_STRUCT_MEMBER(int32_t, client_id)
- IPC_STRUCT_MEMBER(gpu::SurfaceHandle, surface_handle)
-IPC_STRUCT_END()
-
-IPC_STRUCT_TRAITS_BEGIN(content::EstablishChannelParams)
- IPC_STRUCT_TRAITS_MEMBER(client_id)
- IPC_STRUCT_TRAITS_MEMBER(client_tracing_id)
- IPC_STRUCT_TRAITS_MEMBER(preempts)
- IPC_STRUCT_TRAITS_MEMBER(allow_view_command_buffers)
- IPC_STRUCT_TRAITS_MEMBER(allow_real_time_streams)
-IPC_STRUCT_TRAITS_END()
-
-IPC_STRUCT_TRAITS_BEGIN(gpu::GpuPreferences)
- IPC_STRUCT_TRAITS_MEMBER(single_process)
- IPC_STRUCT_TRAITS_MEMBER(in_process_gpu)
- IPC_STRUCT_TRAITS_MEMBER(ui_prioritize_in_gpu_process)
- IPC_STRUCT_TRAITS_MEMBER(disable_accelerated_video_decode)
-#if defined(OS_CHROMEOS)
- IPC_STRUCT_TRAITS_MEMBER(disable_vaapi_accelerated_video_encode)
-#endif
-#if BUILDFLAG(ENABLE_WEBRTC)
- IPC_STRUCT_TRAITS_MEMBER(disable_web_rtc_hw_encoding)
-#endif
-#if defined(OS_WIN)
- IPC_STRUCT_TRAITS_MEMBER(enable_accelerated_vpx_decode)
- IPC_STRUCT_TRAITS_MEMBER(enable_low_latency_dxva)
- IPC_STRUCT_TRAITS_MEMBER(enable_zero_copy_dxgi_video)
- IPC_STRUCT_TRAITS_MEMBER(enable_nv12_dxgi_video)
-#endif
- IPC_STRUCT_TRAITS_MEMBER(compile_shader_always_succeeds)
- IPC_STRUCT_TRAITS_MEMBER(disable_gl_error_limit)
- IPC_STRUCT_TRAITS_MEMBER(disable_glsl_translator)
- IPC_STRUCT_TRAITS_MEMBER(disable_gpu_driver_bug_workarounds)
- IPC_STRUCT_TRAITS_MEMBER(disable_shader_name_hashing)
- IPC_STRUCT_TRAITS_MEMBER(enable_gpu_command_logging)
- IPC_STRUCT_TRAITS_MEMBER(enable_gpu_debugging)
- IPC_STRUCT_TRAITS_MEMBER(enable_gpu_service_logging_gpu)
- IPC_STRUCT_TRAITS_MEMBER(enable_gpu_driver_debug_logging)
- IPC_STRUCT_TRAITS_MEMBER(disable_gpu_program_cache)
- IPC_STRUCT_TRAITS_MEMBER(enforce_gl_minimums)
- IPC_STRUCT_TRAITS_MEMBER(force_gpu_mem_available)
- IPC_STRUCT_TRAITS_MEMBER(gpu_program_cache_size)
- IPC_STRUCT_TRAITS_MEMBER(disable_gpu_shader_disk_cache)
- IPC_STRUCT_TRAITS_MEMBER(enable_threaded_texture_mailboxes)
- IPC_STRUCT_TRAITS_MEMBER(gl_shader_interm_output)
- IPC_STRUCT_TRAITS_MEMBER(emulate_shader_precision)
- IPC_STRUCT_TRAITS_MEMBER(enable_gpu_service_logging)
- IPC_STRUCT_TRAITS_MEMBER(enable_gpu_service_tracing)
- IPC_STRUCT_TRAITS_MEMBER(enable_es3_apis)
- IPC_STRUCT_TRAITS_MEMBER(use_passthrough_cmd_decoder)
-IPC_STRUCT_TRAITS_END()
-
-//------------------------------------------------------------------------------
-// GPU Messages
-// These are messages from the browser to the GPU process.
-
-// Tells the GPU process to shutdown itself.
-IPC_MESSAGE_CONTROL0(GpuMsg_Finalize)
-
-// Tells the GPU process to create a new channel for communication with a
-// given client. The channel name is returned in a
-// GpuHostMsg_ChannelEstablished message. The client ID is passed so
-// that the GPU process reuses an existing channel to that process if it exists.
-// This ID is a unique opaque identifier generated by the browser process.
-// The client_tracing_id is a unique ID used for the purposes of tracing.
-IPC_MESSAGE_CONTROL1(GpuMsg_EstablishChannel,
- content::EstablishChannelParams /* params */)
-
-// Tells the GPU process to close the channel identified by |client_id|.
-// If no channel can be identified, do nothing.
-IPC_MESSAGE_CONTROL1(GpuMsg_CloseChannel, int32_t /* client_id */)
-
-// Tells the GPU process to create a new gpu memory buffer.
-IPC_MESSAGE_CONTROL1(GpuMsg_CreateGpuMemoryBuffer,
- GpuMsg_CreateGpuMemoryBuffer_Params)
-
-// Tells the GPU process to destroy buffer.
-IPC_MESSAGE_CONTROL3(GpuMsg_DestroyGpuMemoryBuffer,
- gfx::GpuMemoryBufferId, /* id */
- int32_t, /* client_id */
- gpu::SyncToken /* sync_token */)
-
-// Tells the GPU process to create a context for collecting graphics card
-// information.
-IPC_MESSAGE_CONTROL0(GpuMsg_CollectGraphicsInfo)
-
-#if defined(OS_ANDROID)
-// Tells the GPU process to wake up the GPU because we're about to draw.
-IPC_MESSAGE_CONTROL0(GpuMsg_WakeUpGpu)
-
-// Tells the GPU process to release the surface because it's being destroyed.
-IPC_MESSAGE_CONTROL1(GpuMsg_DestroyingVideoSurface, int /* surface_id */)
-#endif
-
-// Tells the GPU process to remove all contexts.
-IPC_MESSAGE_CONTROL0(GpuMsg_Clean)
-
-// Tells the GPU process to crash.
-IPC_MESSAGE_CONTROL0(GpuMsg_Crash)
-
-// Tells the GPU process to hang.
-IPC_MESSAGE_CONTROL0(GpuMsg_Hang)
-
-#if defined(OS_ANDROID)
-// Tells the GPU process to throw a java exception
-IPC_MESSAGE_CONTROL0(GpuMsg_JavaCrash)
-#endif
-
-// Tells the GPU process that the browser has seen a GPU switch.
-IPC_MESSAGE_CONTROL0(GpuMsg_GpuSwitched)
-
-//------------------------------------------------------------------------------
-// GPU Host Messages
-// These are messages to the browser.
-
-// Response from GPU to a GputMsg_Initialize message.
-IPC_MESSAGE_CONTROL3(GpuHostMsg_Initialized,
- bool /* result */,
- ::gpu::GPUInfo /* gpu_info */,
- ::gpu::GpuFeatureInfo /* gpu_feature_info */)
-
-// Response from GPU to a GpuHostMsg_EstablishChannel message.
-IPC_MESSAGE_CONTROL1(GpuHostMsg_ChannelEstablished,
- IPC::ChannelHandle /* channel_handle */)
-
-// Message to the GPU that a shader was loaded from disk.
-IPC_MESSAGE_CONTROL1(GpuMsg_LoadedShader, std::string /* encoded shader */)
-
-// Response from GPU to a GpuMsg_CreateGpuMemoryBuffer message.
-IPC_MESSAGE_CONTROL1(GpuHostMsg_GpuMemoryBufferCreated,
- gfx::GpuMemoryBufferHandle /* handle */)
-
-// Response from GPU to a GpuMsg_CollectGraphicsInfo.
-IPC_MESSAGE_CONTROL1(GpuHostMsg_GraphicsInfoCollected,
- gpu::GPUInfo /* GPU logging stats */)
-
-#if defined(OS_ANDROID)
-// Response to a GpuMsg_DestroyingVideoSurface message.
-IPC_MESSAGE_CONTROL1(GpuHostMsg_DestroyingVideoSurfaceAck,
- int /* surface_id */)
-#endif
-
-// Message from GPU to add a GPU log message to the about:gpu page.
-IPC_MESSAGE_CONTROL3(GpuHostMsg_OnLogMessage,
- int /*severity*/,
- std::string /* header */,
- std::string /* message */)
-
-// Sent by the GPU process to indicate that a fields trial has been activated.
-IPC_MESSAGE_CONTROL1(GpuHostMsg_FieldTrialActivated, std::string /* name */)
diff --git a/chromium/content/common/host_shared_bitmap_manager.cc b/chromium/content/common/host_shared_bitmap_manager.cc
deleted file mode 100644
index 51f4fc79160..00000000000
--- a/chromium/content/common/host_shared_bitmap_manager.cc
+++ /dev/null
@@ -1,248 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/common/host_shared_bitmap_manager.h"
-
-#include <stdint.h>
-
-#include <utility>
-
-#include "base/lazy_instance.h"
-#include "base/macros.h"
-#include "base/memory/ptr_util.h"
-#include "base/memory/ref_counted.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/trace_event/process_memory_dump.h"
-#include "build/build_config.h"
-#include "content/common/view_messages.h"
-#include "ui/gfx/geometry/size.h"
-
-namespace content {
-
-class BitmapData : public base::RefCountedThreadSafe<BitmapData> {
- public:
- explicit BitmapData(size_t buffer_size) : buffer_size(buffer_size) {}
- std::unique_ptr<base::SharedMemory> memory;
- std::unique_ptr<uint8_t[]> pixels;
- size_t buffer_size;
-
- private:
- friend class base::RefCountedThreadSafe<BitmapData>;
- ~BitmapData() {}
- DISALLOW_COPY_AND_ASSIGN(BitmapData);
-};
-
-namespace {
-
-class HostSharedBitmap : public cc::SharedBitmap {
- public:
- HostSharedBitmap(uint8_t* pixels,
- scoped_refptr<BitmapData> bitmap_data,
- const cc::SharedBitmapId& id,
- HostSharedBitmapManager* manager)
- : SharedBitmap(pixels, id),
- bitmap_data_(bitmap_data),
- manager_(manager) {}
-
- ~HostSharedBitmap() override {
- if (manager_)
- manager_->FreeSharedMemoryFromMap(id());
- }
-
- private:
- scoped_refptr<BitmapData> bitmap_data_;
- HostSharedBitmapManager* manager_;
-};
-
-} // namespace
-
-base::LazyInstance<HostSharedBitmapManager> g_shared_memory_manager =
- LAZY_INSTANCE_INITIALIZER;
-
-HostSharedBitmapManagerClient::HostSharedBitmapManagerClient(
- HostSharedBitmapManager* manager)
- : manager_(manager) {
-}
-
-HostSharedBitmapManagerClient::~HostSharedBitmapManagerClient() {
- for (const auto& id : owned_bitmaps_)
- manager_->ChildDeletedSharedBitmap(id);
-}
-
-void HostSharedBitmapManagerClient::AllocateSharedBitmapForChild(
- base::ProcessHandle process_handle,
- size_t buffer_size,
- const cc::SharedBitmapId& id,
- base::SharedMemoryHandle* shared_memory_handle) {
- manager_->AllocateSharedBitmapForChild(process_handle, buffer_size, id,
- shared_memory_handle);
- if (*shared_memory_handle != base::SharedMemory::NULLHandle()) {
- base::AutoLock lock(lock_);
- owned_bitmaps_.insert(id);
- }
-}
-
-void HostSharedBitmapManagerClient::ChildAllocatedSharedBitmap(
- size_t buffer_size,
- const base::SharedMemoryHandle& handle,
- const cc::SharedBitmapId& id) {
- if (manager_->ChildAllocatedSharedBitmap(buffer_size, handle, id)) {
- base::AutoLock lock(lock_);
- owned_bitmaps_.insert(id);
- }
-}
-
-void HostSharedBitmapManagerClient::ChildDeletedSharedBitmap(
- const cc::SharedBitmapId& id) {
- manager_->ChildDeletedSharedBitmap(id);
- {
- base::AutoLock lock(lock_);
- owned_bitmaps_.erase(id);
- }
-}
-
-HostSharedBitmapManager::HostSharedBitmapManager() {}
-HostSharedBitmapManager::~HostSharedBitmapManager() {
- DCHECK(handle_map_.empty());
-}
-
-HostSharedBitmapManager* HostSharedBitmapManager::current() {
- return g_shared_memory_manager.Pointer();
-}
-
-std::unique_ptr<cc::SharedBitmap> HostSharedBitmapManager::AllocateSharedBitmap(
- const gfx::Size& size) {
- base::AutoLock lock(lock_);
- size_t bitmap_size;
- if (!cc::SharedBitmap::SizeInBytes(size, &bitmap_size))
- return std::unique_ptr<cc::SharedBitmap>();
-
- scoped_refptr<BitmapData> data(new BitmapData(bitmap_size));
- // Bitmaps allocated in host don't need to be shared to other processes, so
- // allocate them with new instead.
- data->pixels = std::unique_ptr<uint8_t[]>(new uint8_t[bitmap_size]);
-
- cc::SharedBitmapId id = cc::SharedBitmap::GenerateId();
- handle_map_[id] = data;
- return base::MakeUnique<HostSharedBitmap>(data->pixels.get(), data, id, this);
-}
-
-std::unique_ptr<cc::SharedBitmap>
-HostSharedBitmapManager::GetSharedBitmapFromId(const gfx::Size& size,
- const cc::SharedBitmapId& id) {
- base::AutoLock lock(lock_);
- BitmapMap::iterator it = handle_map_.find(id);
- if (it == handle_map_.end())
- return std::unique_ptr<cc::SharedBitmap>();
-
- BitmapData* data = it->second.get();
-
- size_t bitmap_size;
- if (!cc::SharedBitmap::SizeInBytes(size, &bitmap_size) ||
- bitmap_size > data->buffer_size)
- return std::unique_ptr<cc::SharedBitmap>();
-
- if (data->pixels) {
- return base::MakeUnique<HostSharedBitmap>(data->pixels.get(), data, id,
- nullptr);
- }
- if (!data->memory->memory()) {
- return std::unique_ptr<cc::SharedBitmap>();
- }
-
- return base::MakeUnique<HostSharedBitmap>(
- static_cast<uint8_t*>(data->memory->memory()), data, id, nullptr);
-}
-
-bool HostSharedBitmapManager::OnMemoryDump(
- const base::trace_event::MemoryDumpArgs& args,
- base::trace_event::ProcessMemoryDump* pmd) {
- base::AutoLock lock(lock_);
-
- for (const auto& bitmap : handle_map_) {
- base::trace_event::MemoryAllocatorDump* dump =
- pmd->CreateAllocatorDump(base::StringPrintf(
- "sharedbitmap/%s",
- base::HexEncode(bitmap.first.name, sizeof(bitmap.first.name))
- .c_str()));
- if (!dump)
- return false;
-
- dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
- base::trace_event::MemoryAllocatorDump::kUnitsBytes,
- bitmap.second->buffer_size);
-
- // Generate a global GUID used to share this allocation with renderer
- // processes.
- auto guid = cc::GetSharedBitmapGUIDForTracing(bitmap.first);
- pmd->CreateSharedGlobalAllocatorDump(guid);
- pmd->AddOwnershipEdge(dump->guid(), guid);
- }
-
- return true;
-}
-
-bool HostSharedBitmapManager::ChildAllocatedSharedBitmap(
- size_t buffer_size,
- const base::SharedMemoryHandle& handle,
- const cc::SharedBitmapId& id) {
- base::AutoLock lock(lock_);
- if (handle_map_.find(id) != handle_map_.end())
- return false;
- scoped_refptr<BitmapData> data(new BitmapData(buffer_size));
-
- handle_map_[id] = data;
- data->memory = base::MakeUnique<base::SharedMemory>(handle, false);
- data->memory->Map(data->buffer_size);
- data->memory->Close();
- return true;
-}
-
-void HostSharedBitmapManager::AllocateSharedBitmapForChild(
- base::ProcessHandle process_handle,
- size_t buffer_size,
- const cc::SharedBitmapId& id,
- base::SharedMemoryHandle* shared_memory_handle) {
- base::AutoLock lock(lock_);
- if (handle_map_.find(id) != handle_map_.end()) {
- *shared_memory_handle = base::SharedMemory::NULLHandle();
- return;
- }
- std::unique_ptr<base::SharedMemory> shared_memory(new base::SharedMemory);
- if (!shared_memory->CreateAndMapAnonymous(buffer_size)) {
- LOG(ERROR) << "Cannot create shared memory buffer";
- *shared_memory_handle = base::SharedMemory::NULLHandle();
- return;
- }
-
- scoped_refptr<BitmapData> data(new BitmapData(buffer_size));
- data->memory = std::move(shared_memory);
-
- handle_map_[id] = data;
- if (!data->memory->ShareToProcess(process_handle, shared_memory_handle)) {
- LOG(ERROR) << "Cannot share shared memory buffer";
- *shared_memory_handle = base::SharedMemory::NULLHandle();
- return;
- }
- data->memory->Close();
-}
-
-void HostSharedBitmapManager::ChildDeletedSharedBitmap(
- const cc::SharedBitmapId& id) {
- base::AutoLock lock(lock_);
- handle_map_.erase(id);
-}
-
-size_t HostSharedBitmapManager::AllocatedBitmapCount() const {
- base::AutoLock lock(lock_);
- return handle_map_.size();
-}
-
-void HostSharedBitmapManager::FreeSharedMemoryFromMap(
- const cc::SharedBitmapId& id) {
- base::AutoLock lock(lock_);
- handle_map_.erase(id);
-}
-
-} // namespace content
diff --git a/chromium/content/common/host_shared_bitmap_manager.h b/chromium/content/common/host_shared_bitmap_manager.h
deleted file mode 100644
index d2abcd46d0a..00000000000
--- a/chromium/content/common/host_shared_bitmap_manager.h
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_COMMON_HOST_SHARED_BITMAP_MANAGER_H_
-#define CONTENT_COMMON_HOST_SHARED_BITMAP_MANAGER_H_
-
-#include <stddef.h>
-
-#include <map>
-#include <memory>
-#include <set>
-
-#include "base/containers/hash_tables.h"
-#include "base/hash.h"
-#include "base/macros.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/shared_memory.h"
-#include "base/synchronization/lock.h"
-#include "base/trace_event/memory_dump_provider.h"
-#include "cc/resources/shared_bitmap_manager.h"
-#include "content/common/content_export.h"
-
-namespace BASE_HASH_NAMESPACE {
-template <>
-struct hash<cc::SharedBitmapId> {
- size_t operator()(const cc::SharedBitmapId& id) const {
- return base::Hash(reinterpret_cast<const char*>(id.name), sizeof(id.name));
- }
-};
-} // namespace BASE_HASH_NAMESPACE
-
-namespace content {
-class BitmapData;
-class HostSharedBitmapManager;
-
-class CONTENT_EXPORT HostSharedBitmapManagerClient {
- public:
- explicit HostSharedBitmapManagerClient(HostSharedBitmapManager* manager);
-
- ~HostSharedBitmapManagerClient();
-
- void AllocateSharedBitmapForChild(
- base::ProcessHandle process_handle,
- size_t buffer_size,
- const cc::SharedBitmapId& id,
- base::SharedMemoryHandle* shared_memory_handle);
- void ChildAllocatedSharedBitmap(size_t buffer_size,
- const base::SharedMemoryHandle& handle,
- const cc::SharedBitmapId& id);
- void ChildDeletedSharedBitmap(const cc::SharedBitmapId& id);
-
- private:
- HostSharedBitmapManager* manager_;
-
- // Lock must be held around access to owned_bitmaps_.
- base::Lock lock_;
- base::hash_set<cc::SharedBitmapId> owned_bitmaps_;
-
- DISALLOW_COPY_AND_ASSIGN(HostSharedBitmapManagerClient);
-};
-
-class CONTENT_EXPORT HostSharedBitmapManager
- : public cc::SharedBitmapManager,
- public base::trace_event::MemoryDumpProvider {
- public:
- HostSharedBitmapManager();
- ~HostSharedBitmapManager() override;
-
- static HostSharedBitmapManager* current();
-
- // cc::SharedBitmapManager implementation.
- std::unique_ptr<cc::SharedBitmap> AllocateSharedBitmap(
- const gfx::Size& size) override;
- std::unique_ptr<cc::SharedBitmap> GetSharedBitmapFromId(
- const gfx::Size& size,
- const cc::SharedBitmapId&) override;
-
- // base::trace_event::MemoryDumpProvider implementation.
- bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
- base::trace_event::ProcessMemoryDump* pmd) override;
-
- size_t AllocatedBitmapCount() const;
-
- void FreeSharedMemoryFromMap(const cc::SharedBitmapId& id);
-
- private:
- friend class HostSharedBitmapManagerClient;
-
- void AllocateSharedBitmapForChild(
- base::ProcessHandle process_handle,
- size_t buffer_size,
- const cc::SharedBitmapId& id,
- base::SharedMemoryHandle* shared_memory_handle);
- bool ChildAllocatedSharedBitmap(size_t buffer_size,
- const base::SharedMemoryHandle& handle,
- const cc::SharedBitmapId& id);
- void ChildDeletedSharedBitmap(const cc::SharedBitmapId& id);
-
- mutable base::Lock lock_;
-
- typedef base::hash_map<cc::SharedBitmapId, scoped_refptr<BitmapData> >
- BitmapMap;
- BitmapMap handle_map_;
-
- DISALLOW_COPY_AND_ASSIGN(HostSharedBitmapManager);
-};
-
-} // namespace content
-
-#endif // CONTENT_COMMON_HOST_SHARED_BITMAP_MANAGER_H_
diff --git a/chromium/content/common/host_shared_bitmap_manager_unittest.cc b/chromium/content/common/host_shared_bitmap_manager_unittest.cc
deleted file mode 100644
index e1f5feebfcb..00000000000
--- a/chromium/content/common/host_shared_bitmap_manager_unittest.cc
+++ /dev/null
@@ -1,165 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <stddef.h>
-#include <string.h>
-
-#include "content/common/host_shared_bitmap_manager.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace content {
-namespace {
-
-class HostSharedBitmapManagerTest : public testing::Test {
- protected:
- void SetUp() override { manager_.reset(new HostSharedBitmapManager()); }
- std::unique_ptr<HostSharedBitmapManager> manager_;
-};
-
-TEST_F(HostSharedBitmapManagerTest, TestCreate) {
- gfx::Size bitmap_size(1, 1);
- size_t size_in_bytes;
- EXPECT_TRUE(cc::SharedBitmap::SizeInBytes(bitmap_size, &size_in_bytes));
- std::unique_ptr<base::SharedMemory> bitmap(new base::SharedMemory());
- bitmap->CreateAndMapAnonymous(size_in_bytes);
- memset(bitmap->memory(), 0xff, size_in_bytes);
- cc::SharedBitmapId id = cc::SharedBitmap::GenerateId();
-
- HostSharedBitmapManagerClient client(manager_.get());
- base::SharedMemoryHandle handle;
- bitmap->ShareToProcess(base::GetCurrentProcessHandle(), &handle);
- client.ChildAllocatedSharedBitmap(size_in_bytes, handle, id);
-
- std::unique_ptr<cc::SharedBitmap> large_bitmap;
- large_bitmap = manager_->GetSharedBitmapFromId(gfx::Size(1024, 1024), id);
- EXPECT_TRUE(large_bitmap.get() == NULL);
-
- std::unique_ptr<cc::SharedBitmap> very_large_bitmap;
- very_large_bitmap =
- manager_->GetSharedBitmapFromId(gfx::Size(1, (1 << 30) | 1), id);
- EXPECT_TRUE(very_large_bitmap.get() == NULL);
-
- std::unique_ptr<cc::SharedBitmap> negative_size_bitmap;
- negative_size_bitmap =
- manager_->GetSharedBitmapFromId(gfx::Size(-1, 1024), id);
- EXPECT_TRUE(negative_size_bitmap.get() == NULL);
-
- cc::SharedBitmapId id2 = cc::SharedBitmap::GenerateId();
- std::unique_ptr<cc::SharedBitmap> invalid_bitmap;
- invalid_bitmap = manager_->GetSharedBitmapFromId(bitmap_size, id2);
- EXPECT_TRUE(invalid_bitmap.get() == NULL);
-
- std::unique_ptr<cc::SharedBitmap> shared_bitmap;
- shared_bitmap = manager_->GetSharedBitmapFromId(bitmap_size, id);
- ASSERT_TRUE(shared_bitmap.get() != NULL);
- EXPECT_EQ(memcmp(shared_bitmap->pixels(), bitmap->memory(), 4), 0);
-
- std::unique_ptr<cc::SharedBitmap> large_bitmap2;
- large_bitmap2 = manager_->GetSharedBitmapFromId(gfx::Size(1024, 1024), id);
- EXPECT_TRUE(large_bitmap2.get() == NULL);
-
- std::unique_ptr<cc::SharedBitmap> shared_bitmap2;
- shared_bitmap2 = manager_->GetSharedBitmapFromId(bitmap_size, id);
- EXPECT_TRUE(shared_bitmap2->pixels() == shared_bitmap->pixels());
- shared_bitmap2.reset();
- EXPECT_EQ(memcmp(shared_bitmap->pixels(), bitmap->memory(), size_in_bytes),
- 0);
-
- client.ChildDeletedSharedBitmap(id);
-
- memset(bitmap->memory(), 0, size_in_bytes);
-
- EXPECT_EQ(memcmp(shared_bitmap->pixels(), bitmap->memory(), size_in_bytes),
- 0);
- bitmap.reset();
- shared_bitmap.reset();
-}
-
-TEST_F(HostSharedBitmapManagerTest, TestCreateForChild) {
- gfx::Size bitmap_size(1, 1);
- size_t size_in_bytes;
- EXPECT_TRUE(cc::SharedBitmap::SizeInBytes(bitmap_size, &size_in_bytes));
- cc::SharedBitmapId id = cc::SharedBitmap::GenerateId();
- HostSharedBitmapManagerClient client(manager_.get());
- base::SharedMemoryHandle handle;
- client.AllocateSharedBitmapForChild(base::GetCurrentProcessHandle(),
- size_in_bytes, id, &handle);
-
- EXPECT_TRUE(base::SharedMemory::IsHandleValid(handle));
- std::unique_ptr<base::SharedMemory> bitmap(
- new base::SharedMemory(handle, false));
- EXPECT_TRUE(bitmap->Map(size_in_bytes));
- memset(bitmap->memory(), 0xff, size_in_bytes);
-
- std::unique_ptr<cc::SharedBitmap> shared_bitmap;
- shared_bitmap = manager_->GetSharedBitmapFromId(bitmap_size, id);
- EXPECT_TRUE(shared_bitmap);
- EXPECT_TRUE(
- memcmp(bitmap->memory(), shared_bitmap->pixels(), size_in_bytes) == 0);
-
- client.ChildDeletedSharedBitmap(id);
-}
-
-TEST_F(HostSharedBitmapManagerTest, RemoveProcess) {
- gfx::Size bitmap_size(1, 1);
- size_t size_in_bytes;
- EXPECT_TRUE(cc::SharedBitmap::SizeInBytes(bitmap_size, &size_in_bytes));
- std::unique_ptr<base::SharedMemory> bitmap(new base::SharedMemory());
- bitmap->CreateAndMapAnonymous(size_in_bytes);
- memset(bitmap->memory(), 0xff, size_in_bytes);
- cc::SharedBitmapId id = cc::SharedBitmap::GenerateId();
-
- base::SharedMemoryHandle handle;
- std::unique_ptr<HostSharedBitmapManagerClient> client(
- new HostSharedBitmapManagerClient(manager_.get()));
- bitmap->ShareToProcess(base::GetCurrentProcessHandle(), &handle);
- client->ChildAllocatedSharedBitmap(size_in_bytes, handle, id);
-
- std::unique_ptr<cc::SharedBitmap> shared_bitmap;
- shared_bitmap = manager_->GetSharedBitmapFromId(bitmap_size, id);
- ASSERT_TRUE(shared_bitmap.get() != NULL);
-
- EXPECT_EQ(1u, manager_->AllocatedBitmapCount());
- client.reset();
- EXPECT_EQ(0u, manager_->AllocatedBitmapCount());
-
- std::unique_ptr<cc::SharedBitmap> shared_bitmap2;
- shared_bitmap2 = manager_->GetSharedBitmapFromId(bitmap_size, id);
- EXPECT_TRUE(shared_bitmap2.get() == NULL);
- EXPECT_EQ(memcmp(shared_bitmap->pixels(), bitmap->memory(), size_in_bytes),
- 0);
-
- shared_bitmap.reset();
-}
-
-TEST_F(HostSharedBitmapManagerTest, AddDuplicate) {
- gfx::Size bitmap_size(1, 1);
- size_t size_in_bytes;
- EXPECT_TRUE(cc::SharedBitmap::SizeInBytes(bitmap_size, &size_in_bytes));
- std::unique_ptr<base::SharedMemory> bitmap(new base::SharedMemory());
- bitmap->CreateAndMapAnonymous(size_in_bytes);
- memset(bitmap->memory(), 0xff, size_in_bytes);
- cc::SharedBitmapId id = cc::SharedBitmap::GenerateId();
- HostSharedBitmapManagerClient client(manager_.get());
-
- base::SharedMemoryHandle handle;
- bitmap->ShareToProcess(base::GetCurrentProcessHandle(), &handle);
- client.ChildAllocatedSharedBitmap(size_in_bytes, handle, id);
-
- std::unique_ptr<base::SharedMemory> bitmap2(new base::SharedMemory());
- bitmap2->CreateAndMapAnonymous(size_in_bytes);
- memset(bitmap2->memory(), 0x00, size_in_bytes);
-
- client.ChildAllocatedSharedBitmap(size_in_bytes, bitmap2->handle(), id);
-
- std::unique_ptr<cc::SharedBitmap> shared_bitmap;
- shared_bitmap = manager_->GetSharedBitmapFromId(bitmap_size, id);
- ASSERT_TRUE(shared_bitmap.get() != NULL);
- EXPECT_EQ(memcmp(shared_bitmap->pixels(), bitmap->memory(), size_in_bytes),
- 0);
- client.ChildDeletedSharedBitmap(id);
-}
-
-} // namespace
-} // namespace content
diff --git a/chromium/content/common/indexed_db/indexed_db_key.cc b/chromium/content/common/indexed_db/indexed_db_key.cc
index eb657b311b0..740569e40af 100644
--- a/chromium/content/common/indexed_db/indexed_db_key.cc
+++ b/chromium/content/common/indexed_db/indexed_db_key.cc
@@ -9,14 +9,14 @@
namespace content {
using blink::WebIDBKeyType;
-using blink::WebIDBKeyTypeArray;
-using blink::WebIDBKeyTypeBinary;
-using blink::WebIDBKeyTypeDate;
-using blink::WebIDBKeyTypeInvalid;
-using blink::WebIDBKeyTypeMin;
-using blink::WebIDBKeyTypeNull;
-using blink::WebIDBKeyTypeNumber;
-using blink::WebIDBKeyTypeString;
+using blink::kWebIDBKeyTypeArray;
+using blink::kWebIDBKeyTypeBinary;
+using blink::kWebIDBKeyTypeDate;
+using blink::kWebIDBKeyTypeInvalid;
+using blink::kWebIDBKeyTypeMin;
+using blink::kWebIDBKeyTypeNull;
+using blink::kWebIDBKeyTypeNumber;
+using blink::kWebIDBKeyTypeString;
namespace {
@@ -53,34 +53,33 @@ static IndexedDBKey::KeyArray CopyKeyArray(const T& array) {
} // namespace
IndexedDBKey::IndexedDBKey()
- : type_(WebIDBKeyTypeNull),
- size_estimate_(kOverheadSize) {}
+ : type_(kWebIDBKeyTypeNull), size_estimate_(kOverheadSize) {}
IndexedDBKey::IndexedDBKey(WebIDBKeyType type)
: type_(type), size_estimate_(kOverheadSize) {
- DCHECK(type == WebIDBKeyTypeNull || type == WebIDBKeyTypeInvalid);
+ DCHECK(type == kWebIDBKeyTypeNull || type == kWebIDBKeyTypeInvalid);
}
IndexedDBKey::IndexedDBKey(double number, WebIDBKeyType type)
: type_(type),
number_(number),
size_estimate_(kOverheadSize + sizeof(number)) {
- DCHECK(type == WebIDBKeyTypeNumber || type == WebIDBKeyTypeDate);
+ DCHECK(type == kWebIDBKeyTypeNumber || type == kWebIDBKeyTypeDate);
}
IndexedDBKey::IndexedDBKey(const KeyArray& array)
- : type_(WebIDBKeyTypeArray),
+ : type_(kWebIDBKeyTypeArray),
array_(CopyKeyArray(array)),
size_estimate_(kOverheadSize + CalculateArraySize(array)) {}
IndexedDBKey::IndexedDBKey(const std::string& binary)
- : type_(WebIDBKeyTypeBinary),
+ : type_(kWebIDBKeyTypeBinary),
binary_(binary),
size_estimate_(kOverheadSize +
(binary.length() * sizeof(std::string::value_type))) {}
IndexedDBKey::IndexedDBKey(const base::string16& string)
- : type_(WebIDBKeyTypeString),
+ : type_(kWebIDBKeyTypeString),
string_(string),
size_estimate_(kOverheadSize +
(string.length() * sizeof(base::string16::value_type))) {}
@@ -90,10 +89,10 @@ IndexedDBKey::~IndexedDBKey() = default;
IndexedDBKey& IndexedDBKey::operator=(const IndexedDBKey& other) = default;
bool IndexedDBKey::IsValid() const {
- if (type_ == WebIDBKeyTypeInvalid || type_ == WebIDBKeyTypeNull)
+ if (type_ == kWebIDBKeyTypeInvalid || type_ == kWebIDBKeyTypeNull)
return false;
- if (type_ == WebIDBKeyTypeArray) {
+ if (type_ == kWebIDBKeyTypeArray) {
for (size_t i = 0; i < array_.size(); i++) {
if (!array_[i].IsValid())
return false;
@@ -118,23 +117,23 @@ int IndexedDBKey::CompareTo(const IndexedDBKey& other) const {
return type_ > other.type_ ? -1 : 1;
switch (type_) {
- case WebIDBKeyTypeArray:
+ case kWebIDBKeyTypeArray:
for (size_t i = 0; i < array_.size() && i < other.array_.size(); ++i) {
int result = array_[i].CompareTo(other.array_[i]);
if (result != 0)
return result;
}
return Compare(array_.size(), other.array_.size());
- case WebIDBKeyTypeBinary:
+ case kWebIDBKeyTypeBinary:
return binary_.compare(other.binary_);
- case WebIDBKeyTypeString:
+ case kWebIDBKeyTypeString:
return string_.compare(other.string_);
- case WebIDBKeyTypeDate:
- case WebIDBKeyTypeNumber:
+ case kWebIDBKeyTypeDate:
+ case kWebIDBKeyTypeNumber:
return Compare(number_, other.number_);
- case WebIDBKeyTypeInvalid:
- case WebIDBKeyTypeNull:
- case WebIDBKeyTypeMin:
+ case kWebIDBKeyTypeInvalid:
+ case kWebIDBKeyTypeNull:
+ case kWebIDBKeyTypeMin:
default:
NOTREACHED();
return 0;
diff --git a/chromium/content/common/indexed_db/indexed_db_key.h b/chromium/content/common/indexed_db/indexed_db_key.h
index ce48455f332..5668f1a2f3f 100644
--- a/chromium/content/common/indexed_db/indexed_db_key.h
+++ b/chromium/content/common/indexed_db/indexed_db_key.h
@@ -39,23 +39,23 @@ class CONTENT_EXPORT IndexedDBKey {
blink::WebIDBKeyType type() const { return type_; }
const std::vector<IndexedDBKey>& array() const {
- DCHECK_EQ(type_, blink::WebIDBKeyTypeArray);
+ DCHECK_EQ(type_, blink::kWebIDBKeyTypeArray);
return array_;
}
const std::string& binary() const {
- DCHECK_EQ(type_, blink::WebIDBKeyTypeBinary);
+ DCHECK_EQ(type_, blink::kWebIDBKeyTypeBinary);
return binary_;
}
const base::string16& string() const {
- DCHECK_EQ(type_, blink::WebIDBKeyTypeString);
+ DCHECK_EQ(type_, blink::kWebIDBKeyTypeString);
return string_;
}
double date() const {
- DCHECK_EQ(type_, blink::WebIDBKeyTypeDate);
+ DCHECK_EQ(type_, blink::kWebIDBKeyTypeDate);
return number_;
}
double number() const {
- DCHECK_EQ(type_, blink::WebIDBKeyTypeNumber);
+ DCHECK_EQ(type_, blink::kWebIDBKeyTypeNumber);
return number_;
}
diff --git a/chromium/content/common/indexed_db/indexed_db_key_path.cc b/chromium/content/common/indexed_db/indexed_db_key_path.cc
index a5756b51418..8644b872ad7 100644
--- a/chromium/content/common/indexed_db/indexed_db_key_path.cc
+++ b/chromium/content/common/indexed_db/indexed_db_key_path.cc
@@ -8,17 +8,17 @@
namespace content {
-using blink::WebIDBKeyPathTypeArray;
-using blink::WebIDBKeyPathTypeNull;
-using blink::WebIDBKeyPathTypeString;
+using blink::kWebIDBKeyPathTypeArray;
+using blink::kWebIDBKeyPathTypeNull;
+using blink::kWebIDBKeyPathTypeString;
-IndexedDBKeyPath::IndexedDBKeyPath() : type_(WebIDBKeyPathTypeNull) {}
+IndexedDBKeyPath::IndexedDBKeyPath() : type_(kWebIDBKeyPathTypeNull) {}
IndexedDBKeyPath::IndexedDBKeyPath(const base::string16& string)
- : type_(WebIDBKeyPathTypeString), string_(string) {}
+ : type_(kWebIDBKeyPathTypeString), string_(string) {}
IndexedDBKeyPath::IndexedDBKeyPath(const std::vector<base::string16>& array)
- : type_(WebIDBKeyPathTypeArray), array_(array) {}
+ : type_(kWebIDBKeyPathTypeArray), array_(array) {}
IndexedDBKeyPath::IndexedDBKeyPath(const IndexedDBKeyPath& other) = default;
IndexedDBKeyPath::~IndexedDBKeyPath() = default;
@@ -26,12 +26,12 @@ IndexedDBKeyPath& IndexedDBKeyPath::operator=(const IndexedDBKeyPath& other) =
default;
const std::vector<base::string16>& IndexedDBKeyPath::array() const {
- DCHECK(type_ == blink::WebIDBKeyPathTypeArray);
+ DCHECK(type_ == blink::kWebIDBKeyPathTypeArray);
return array_;
}
const base::string16& IndexedDBKeyPath::string() const {
- DCHECK(type_ == blink::WebIDBKeyPathTypeString);
+ DCHECK(type_ == blink::kWebIDBKeyPathTypeString);
return string_;
}
@@ -40,11 +40,11 @@ bool IndexedDBKeyPath::operator==(const IndexedDBKeyPath& other) const {
return false;
switch (type_) {
- case WebIDBKeyPathTypeNull:
+ case kWebIDBKeyPathTypeNull:
return true;
- case WebIDBKeyPathTypeString:
+ case kWebIDBKeyPathTypeString:
return string_ == other.string_;
- case WebIDBKeyPathTypeArray:
+ case kWebIDBKeyPathTypeArray:
return array_ == other.array_;
}
NOTREACHED();
diff --git a/chromium/content/common/indexed_db/indexed_db_key_path.h b/chromium/content/common/indexed_db/indexed_db_key_path.h
index c4ae73ec3f3..0d0ab6a82c4 100644
--- a/chromium/content/common/indexed_db/indexed_db_key_path.h
+++ b/chromium/content/common/indexed_db/indexed_db_key_path.h
@@ -24,7 +24,7 @@ class CONTENT_EXPORT IndexedDBKeyPath {
~IndexedDBKeyPath();
IndexedDBKeyPath& operator=(const IndexedDBKeyPath& other);
- bool IsNull() const { return type_ == blink::WebIDBKeyPathTypeNull; }
+ bool IsNull() const { return type_ == blink::kWebIDBKeyPathTypeNull; }
bool operator==(const IndexedDBKeyPath& other) const;
blink::WebIDBKeyPathType type() const { return type_; }
diff --git a/chromium/content/common/indexed_db/indexed_db_key_range.h b/chromium/content/common/indexed_db/indexed_db_key_range.h
index 4a0249149fd..ac334de12dc 100644
--- a/chromium/content/common/indexed_db/indexed_db_key_range.h
+++ b/chromium/content/common/indexed_db/indexed_db_key_range.h
@@ -31,8 +31,8 @@ class CONTENT_EXPORT IndexedDBKeyRange {
bool IsEmpty() const;
private:
- IndexedDBKey lower_ = IndexedDBKey(blink::WebIDBKeyTypeNull);
- IndexedDBKey upper_ = IndexedDBKey(blink::WebIDBKeyTypeNull);
+ IndexedDBKey lower_ = IndexedDBKey(blink::kWebIDBKeyTypeNull);
+ IndexedDBKey upper_ = IndexedDBKey(blink::kWebIDBKeyTypeNull);
bool lower_open_ = false;
bool upper_open_ = false;
};
diff --git a/chromium/content/common/indexed_db/indexed_db_key_unittest.cc b/chromium/content/common/indexed_db/indexed_db_key_unittest.cc
index c7a566ba887..30f1c815c26 100644
--- a/chromium/content/common/indexed_db/indexed_db_key_unittest.cc
+++ b/chromium/content/common/indexed_db/indexed_db_key_unittest.cc
@@ -21,15 +21,15 @@ TEST(IndexedDBKeyTest, KeySizeEstimates) {
keys.push_back(IndexedDBKey());
estimates.push_back(16u); // Overhead.
- keys.push_back(IndexedDBKey(blink::WebIDBKeyTypeNull));
+ keys.push_back(IndexedDBKey(blink::kWebIDBKeyTypeNull));
estimates.push_back(16u);
double number = 3.14159;
- keys.push_back(IndexedDBKey(number, blink::WebIDBKeyTypeNumber));
+ keys.push_back(IndexedDBKey(number, blink::kWebIDBKeyTypeNumber));
estimates.push_back(24u); // Overhead + sizeof(double).
double date = 1370884329.0;
- keys.push_back(IndexedDBKey(date, blink::WebIDBKeyTypeDate));
+ keys.push_back(IndexedDBKey(date, blink::kWebIDBKeyTypeDate));
estimates.push_back(24u); // Overhead + sizeof(double).
const base::string16 string(1024, static_cast<base::char16>('X'));
@@ -41,7 +41,7 @@ TEST(IndexedDBKeyTest, KeySizeEstimates) {
IndexedDBKey::KeyArray array;
double value = 123.456;
for (size_t i = 0; i < array_size; ++i) {
- array.push_back(IndexedDBKey(value, blink::WebIDBKeyTypeNumber));
+ array.push_back(IndexedDBKey(value, blink::kWebIDBKeyTypeNumber));
}
keys.push_back(IndexedDBKey(array));
// Overhead + array length * (Overhead + sizeof(double)).
diff --git a/chromium/content/common/indexed_db/indexed_db_struct_traits.cc b/chromium/content/common/indexed_db/indexed_db_struct_traits.cc
index 85d5fe602f7..618213cdcdb 100644
--- a/chromium/content/common/indexed_db/indexed_db_struct_traits.cc
+++ b/chromium/content/common/indexed_db/indexed_db_struct_traits.cc
@@ -25,29 +25,29 @@ StructTraits<indexed_db::mojom::KeyDataView, IndexedDBKey>::data(
const IndexedDBKey& key) {
auto data = indexed_db::mojom::KeyData::New();
switch (key.type()) {
- case blink::WebIDBKeyTypeInvalid:
+ case blink::kWebIDBKeyTypeInvalid:
data->set_other(indexed_db::mojom::DatalessKeyType::Invalid);
return data;
- case blink::WebIDBKeyTypeArray:
+ case blink::kWebIDBKeyTypeArray:
data->set_key_array(key.array());
return data;
- case blink::WebIDBKeyTypeBinary:
+ case blink::kWebIDBKeyTypeBinary:
data->set_binary(std::vector<uint8_t>(
key.binary().data(), key.binary().data() + key.binary().size()));
return data;
- case blink::WebIDBKeyTypeString:
+ case blink::kWebIDBKeyTypeString:
data->set_string(key.string());
return data;
- case blink::WebIDBKeyTypeDate:
+ case blink::kWebIDBKeyTypeDate:
data->set_date(key.date());
return data;
- case blink::WebIDBKeyTypeNumber:
+ case blink::kWebIDBKeyTypeNumber:
data->set_number(key.number());
return data;
- case blink::WebIDBKeyTypeNull:
+ case blink::kWebIDBKeyTypeNull:
data->set_other(indexed_db::mojom::DatalessKeyType::Null);
return data;
- case blink::WebIDBKeyTypeMin:
+ case blink::kWebIDBKeyTypeMin:
break;
}
NOTREACHED();
@@ -85,18 +85,18 @@ bool StructTraits<indexed_db::mojom::KeyDataView, IndexedDBKey>::Read(
return true;
}
case indexed_db::mojom::KeyDataDataView::Tag::DATE:
- *out = IndexedDBKey(data_view.date(), blink::WebIDBKeyTypeDate);
+ *out = IndexedDBKey(data_view.date(), blink::kWebIDBKeyTypeDate);
return true;
case indexed_db::mojom::KeyDataDataView::Tag::NUMBER:
- *out = IndexedDBKey(data_view.number(), blink::WebIDBKeyTypeNumber);
+ *out = IndexedDBKey(data_view.number(), blink::kWebIDBKeyTypeNumber);
return true;
case indexed_db::mojom::KeyDataDataView::Tag::OTHER:
switch (data_view.other()) {
case indexed_db::mojom::DatalessKeyType::Invalid:
- *out = IndexedDBKey(blink::WebIDBKeyTypeInvalid);
+ *out = IndexedDBKey(blink::kWebIDBKeyTypeInvalid);
return true;
case indexed_db::mojom::DatalessKeyType::Null:
- *out = IndexedDBKey(blink::WebIDBKeyTypeNull);
+ *out = IndexedDBKey(blink::kWebIDBKeyTypeNull);
return true;
}
}
@@ -113,10 +113,10 @@ StructTraits<indexed_db::mojom::KeyPathDataView, IndexedDBKeyPath>::data(
auto data = indexed_db::mojom::KeyPathData::New();
switch (key_path.type()) {
- case blink::WebIDBKeyPathTypeString:
+ case blink::kWebIDBKeyPathTypeString:
data->set_string(key_path.string());
return data;
- case blink::WebIDBKeyPathTypeArray:
+ case blink::kWebIDBKeyPathTypeArray:
data->set_string_array(key_path.array());
return data;
default:
@@ -250,13 +250,13 @@ CursorDirection
EnumTraits<CursorDirection, blink::WebIDBCursorDirection>::ToMojom(
blink::WebIDBCursorDirection input) {
switch (input) {
- case blink::WebIDBCursorDirectionNext:
+ case blink::kWebIDBCursorDirectionNext:
return CursorDirection::Next;
- case blink::WebIDBCursorDirectionNextNoDuplicate:
+ case blink::kWebIDBCursorDirectionNextNoDuplicate:
return CursorDirection::NextNoDuplicate;
- case blink::WebIDBCursorDirectionPrev:
+ case blink::kWebIDBCursorDirectionPrev:
return CursorDirection::Prev;
- case blink::WebIDBCursorDirectionPrevNoDuplicate:
+ case blink::kWebIDBCursorDirectionPrevNoDuplicate:
return CursorDirection::PrevNoDuplicate;
}
NOTREACHED();
@@ -269,16 +269,16 @@ bool EnumTraits<CursorDirection, blink::WebIDBCursorDirection>::FromMojom(
blink::WebIDBCursorDirection* output) {
switch (input) {
case CursorDirection::Next:
- *output = blink::WebIDBCursorDirectionNext;
+ *output = blink::kWebIDBCursorDirectionNext;
return true;
case CursorDirection::NextNoDuplicate:
- *output = blink::WebIDBCursorDirectionNextNoDuplicate;
+ *output = blink::kWebIDBCursorDirectionNextNoDuplicate;
return true;
case CursorDirection::Prev:
- *output = blink::WebIDBCursorDirectionPrev;
+ *output = blink::kWebIDBCursorDirectionPrev;
return true;
case CursorDirection::PrevNoDuplicate:
- *output = blink::WebIDBCursorDirectionPrevNoDuplicate;
+ *output = blink::kWebIDBCursorDirectionPrevNoDuplicate;
return true;
}
return false;
@@ -288,9 +288,9 @@ bool EnumTraits<CursorDirection, blink::WebIDBCursorDirection>::FromMojom(
DataLoss EnumTraits<DataLoss, blink::WebIDBDataLoss>::ToMojom(
blink::WebIDBDataLoss input) {
switch (input) {
- case blink::WebIDBDataLossNone:
+ case blink::kWebIDBDataLossNone:
return DataLoss::None;
- case blink::WebIDBDataLossTotal:
+ case blink::kWebIDBDataLossTotal:
return DataLoss::Total;
}
NOTREACHED();
@@ -303,10 +303,10 @@ bool EnumTraits<DataLoss, blink::WebIDBDataLoss>::FromMojom(
blink::WebIDBDataLoss* output) {
switch (input) {
case DataLoss::None:
- *output = blink::WebIDBDataLossNone;
+ *output = blink::kWebIDBDataLossNone;
return true;
case DataLoss::Total:
- *output = blink::WebIDBDataLossTotal;
+ *output = blink::kWebIDBDataLossTotal;
return true;
}
return false;
@@ -316,15 +316,15 @@ bool EnumTraits<DataLoss, blink::WebIDBDataLoss>::FromMojom(
OperationType EnumTraits<OperationType, blink::WebIDBOperationType>::ToMojom(
blink::WebIDBOperationType input) {
switch (input) {
- case blink::WebIDBAdd:
+ case blink::kWebIDBAdd:
return OperationType::Add;
- case blink::WebIDBPut:
+ case blink::kWebIDBPut:
return OperationType::Put;
- case blink::WebIDBDelete:
+ case blink::kWebIDBDelete:
return OperationType::Delete;
- case blink::WebIDBClear:
+ case blink::kWebIDBClear:
return OperationType::Clear;
- case blink::WebIDBOperationTypeCount:
+ case blink::kWebIDBOperationTypeCount:
// WebIDBOperationTypeCount is not a valid option.
break;
}
@@ -338,16 +338,16 @@ bool EnumTraits<OperationType, blink::WebIDBOperationType>::FromMojom(
blink::WebIDBOperationType* output) {
switch (input) {
case OperationType::Add:
- *output = blink::WebIDBAdd;
+ *output = blink::kWebIDBAdd;
return true;
case OperationType::Put:
- *output = blink::WebIDBPut;
+ *output = blink::kWebIDBPut;
return true;
case OperationType::Delete:
- *output = blink::WebIDBDelete;
+ *output = blink::kWebIDBDelete;
return true;
case OperationType::Clear:
- *output = blink::WebIDBClear;
+ *output = blink::kWebIDBClear;
return true;
}
return false;
@@ -357,11 +357,11 @@ bool EnumTraits<OperationType, blink::WebIDBOperationType>::FromMojom(
PutMode EnumTraits<PutMode, blink::WebIDBPutMode>::ToMojom(
blink::WebIDBPutMode input) {
switch (input) {
- case blink::WebIDBPutModeAddOrUpdate:
+ case blink::kWebIDBPutModeAddOrUpdate:
return PutMode::AddOrUpdate;
- case blink::WebIDBPutModeAddOnly:
+ case blink::kWebIDBPutModeAddOnly:
return PutMode::AddOnly;
- case blink::WebIDBPutModeCursorUpdate:
+ case blink::kWebIDBPutModeCursorUpdate:
return PutMode::CursorUpdate;
}
NOTREACHED();
@@ -374,13 +374,13 @@ bool EnumTraits<PutMode, blink::WebIDBPutMode>::FromMojom(
blink::WebIDBPutMode* output) {
switch (input) {
case PutMode::AddOrUpdate:
- *output = blink::WebIDBPutModeAddOrUpdate;
+ *output = blink::kWebIDBPutModeAddOrUpdate;
return true;
case PutMode::AddOnly:
- *output = blink::WebIDBPutModeAddOnly;
+ *output = blink::kWebIDBPutModeAddOnly;
return true;
case PutMode::CursorUpdate:
- *output = blink::WebIDBPutModeCursorUpdate;
+ *output = blink::kWebIDBPutModeCursorUpdate;
return true;
}
return false;
@@ -390,9 +390,9 @@ bool EnumTraits<PutMode, blink::WebIDBPutMode>::FromMojom(
TaskType EnumTraits<TaskType, blink::WebIDBTaskType>::ToMojom(
blink::WebIDBTaskType input) {
switch (input) {
- case blink::WebIDBTaskTypeNormal:
+ case blink::kWebIDBTaskTypeNormal:
return TaskType::Normal;
- case blink::WebIDBTaskTypePreemptive:
+ case blink::kWebIDBTaskTypePreemptive:
return TaskType::Preemptive;
}
NOTREACHED();
@@ -405,10 +405,10 @@ bool EnumTraits<TaskType, blink::WebIDBTaskType>::FromMojom(
blink::WebIDBTaskType* output) {
switch (input) {
case TaskType::Normal:
- *output = blink::WebIDBTaskTypeNormal;
+ *output = blink::kWebIDBTaskTypeNormal;
return true;
case TaskType::Preemptive:
- *output = blink::WebIDBTaskTypePreemptive;
+ *output = blink::kWebIDBTaskTypePreemptive;
return true;
}
return false;
@@ -419,11 +419,11 @@ TransactionMode
EnumTraits<TransactionMode, blink::WebIDBTransactionMode>::ToMojom(
blink::WebIDBTransactionMode input) {
switch (input) {
- case blink::WebIDBTransactionModeReadOnly:
+ case blink::kWebIDBTransactionModeReadOnly:
return TransactionMode::ReadOnly;
- case blink::WebIDBTransactionModeReadWrite:
+ case blink::kWebIDBTransactionModeReadWrite:
return TransactionMode::ReadWrite;
- case blink::WebIDBTransactionModeVersionChange:
+ case blink::kWebIDBTransactionModeVersionChange:
return TransactionMode::VersionChange;
}
NOTREACHED();
@@ -436,13 +436,13 @@ bool EnumTraits<TransactionMode, blink::WebIDBTransactionMode>::FromMojom(
blink::WebIDBTransactionMode* output) {
switch (input) {
case TransactionMode::ReadOnly:
- *output = blink::WebIDBTransactionModeReadOnly;
+ *output = blink::kWebIDBTransactionModeReadOnly;
return true;
case TransactionMode::ReadWrite:
- *output = blink::WebIDBTransactionModeReadWrite;
+ *output = blink::kWebIDBTransactionModeReadWrite;
return true;
case TransactionMode::VersionChange:
- *output = blink::WebIDBTransactionModeVersionChange;
+ *output = blink::kWebIDBTransactionModeVersionChange;
return true;
}
return false;
diff --git a/chromium/content/common/input/event_with_latency_info.h b/chromium/content/common/input/event_with_latency_info.h
index 1613ee81409..3ac2bdd3a32 100644
--- a/chromium/content/common/input/event_with_latency_info.h
+++ b/chromium/content/common/input/event_with_latency_info.h
@@ -13,7 +13,7 @@
#include "third_party/WebKit/public/platform/WebTouchEvent.h"
#include "ui/events/blink/blink_event_util.h"
#include "ui/events/blink/web_input_event_traits.h"
-#include "ui/events/latency_info.h"
+#include "ui/latency/latency_info.h"
namespace content {
@@ -38,7 +38,7 @@ class EventWithLatencyInfo {
bool CanCoalesceWith(const EventWithLatencyInfo& other)
const WARN_UNUSED_RESULT {
- if (other.event.type() != event.type())
+ if (other.event.GetType() != event.GetType())
return false;
DCHECK_EQ(sizeof(T), event.size());
@@ -54,9 +54,9 @@ class EventWithLatencyInfo {
// New events get coalesced into older events, and the newer timestamp
// should always be preserved.
- const double time_stamp_seconds = other.event.timeStampSeconds();
+ const double time_stamp_seconds = other.event.TimeStampSeconds();
ui::Coalesce(other.event, &event);
- event.setTimeStampSeconds(time_stamp_seconds);
+ event.SetTimeStampSeconds(time_stamp_seconds);
// When coalescing two input events, we keep the oldest LatencyInfo
// for Telemetry latency tests, since it will represent the longest
diff --git a/chromium/content/common/input/event_with_latency_info_unittest.cc b/chromium/content/common/input/event_with_latency_info_unittest.cc
index 7afd3a3c29e..0e2f6ff5a6e 100644
--- a/chromium/content/common/input/event_with_latency_info_unittest.cc
+++ b/chromium/content/common/input/event_with_latency_info_unittest.cc
@@ -25,15 +25,15 @@ using EventWithLatencyInfoTest = testing::Test;
TouchEventWithLatencyInfo CreateTouchEvent(WebInputEvent::Type type,
double timestamp,
unsigned touch_count = 1) {
- TouchEventWithLatencyInfo touch(type, WebInputEvent::NoModifiers, timestamp,
+ TouchEventWithLatencyInfo touch(type, WebInputEvent::kNoModifiers, timestamp,
ui::LatencyInfo());
- touch.event.touchesLength = touch_count;
+ touch.event.touches_length = touch_count;
return touch;
}
MouseEventWithLatencyInfo CreateMouseEvent(WebInputEvent::Type type,
double timestamp) {
- return MouseEventWithLatencyInfo(type, WebInputEvent::NoModifiers, timestamp,
+ return MouseEventWithLatencyInfo(type, WebInputEvent::kNoModifiers, timestamp,
ui::LatencyInfo());
}
@@ -41,11 +41,11 @@ MouseWheelEventWithLatencyInfo CreateMouseWheelEvent(
double timestamp,
float deltaX = 0.0f,
float deltaY = 0.0f,
- int modifiers = WebInputEvent::NoModifiers) {
+ int modifiers = WebInputEvent::kNoModifiers) {
MouseWheelEventWithLatencyInfo mouse_wheel(
- WebInputEvent::MouseWheel, modifiers, timestamp, ui::LatencyInfo());
- mouse_wheel.event.deltaX = deltaX;
- mouse_wheel.event.deltaY = deltaY;
+ WebInputEvent::kMouseWheel, modifiers, timestamp, ui::LatencyInfo());
+ mouse_wheel.event.delta_x = deltaX;
+ mouse_wheel.event.delta_y = deltaY;
return mouse_wheel;
}
@@ -53,7 +53,7 @@ GestureEventWithLatencyInfo CreateGestureEvent(WebInputEvent::Type type,
double timestamp,
float x = 0.0f,
float y = 0.0f) {
- GestureEventWithLatencyInfo gesture(type, WebInputEvent::NoModifiers,
+ GestureEventWithLatencyInfo gesture(type, WebInputEvent::kNoModifiers,
timestamp, ui::LatencyInfo());
gesture.event.x = x;
gesture.event.y = y;
@@ -61,15 +61,15 @@ GestureEventWithLatencyInfo CreateGestureEvent(WebInputEvent::Type type,
}
TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForMouseEvent) {
- MouseEventWithLatencyInfo mouse_0 = CreateMouseEvent(
- WebInputEvent::MouseMove, 5.0);
- MouseEventWithLatencyInfo mouse_1 = CreateMouseEvent(
- WebInputEvent::MouseMove, 10.0);
+ MouseEventWithLatencyInfo mouse_0 =
+ CreateMouseEvent(WebInputEvent::kMouseMove, 5.0);
+ MouseEventWithLatencyInfo mouse_1 =
+ CreateMouseEvent(WebInputEvent::kMouseMove, 10.0);
ASSERT_TRUE(mouse_0.CanCoalesceWith(mouse_1));
mouse_0.CoalesceWith(mouse_1);
// Coalescing WebMouseEvent preserves newer timestamp.
- EXPECT_EQ(10.0, mouse_0.event.timeStampSeconds());
+ EXPECT_EQ(10.0, mouse_0.event.TimeStampSeconds());
}
TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForMouseWheelEvent) {
@@ -79,40 +79,40 @@ TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForMouseWheelEvent) {
ASSERT_TRUE(mouse_wheel_0.CanCoalesceWith(mouse_wheel_1));
mouse_wheel_0.CoalesceWith(mouse_wheel_1);
// Coalescing WebMouseWheelEvent preserves newer timestamp.
- EXPECT_EQ(10.0, mouse_wheel_0.event.timeStampSeconds());
+ EXPECT_EQ(10.0, mouse_wheel_0.event.TimeStampSeconds());
}
TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForTouchEvent) {
- TouchEventWithLatencyInfo touch_0 = CreateTouchEvent(
- WebInputEvent::TouchMove, 5.0);
- TouchEventWithLatencyInfo touch_1 = CreateTouchEvent(
- WebInputEvent::TouchMove, 10.0);
+ TouchEventWithLatencyInfo touch_0 =
+ CreateTouchEvent(WebInputEvent::kTouchMove, 5.0);
+ TouchEventWithLatencyInfo touch_1 =
+ CreateTouchEvent(WebInputEvent::kTouchMove, 10.0);
ASSERT_TRUE(touch_0.CanCoalesceWith(touch_1));
touch_0.CoalesceWith(touch_1);
// Coalescing WebTouchEvent preserves newer timestamp.
- EXPECT_EQ(10.0, touch_0.event.timeStampSeconds());
+ EXPECT_EQ(10.0, touch_0.event.TimeStampSeconds());
}
TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForGestureEvent) {
- GestureEventWithLatencyInfo scroll_0 = CreateGestureEvent(
- WebInputEvent::GestureScrollUpdate, 5.0);
- GestureEventWithLatencyInfo scroll_1 = CreateGestureEvent(
- WebInputEvent::GestureScrollUpdate, 10.0);
+ GestureEventWithLatencyInfo scroll_0 =
+ CreateGestureEvent(WebInputEvent::kGestureScrollUpdate, 5.0);
+ GestureEventWithLatencyInfo scroll_1 =
+ CreateGestureEvent(WebInputEvent::kGestureScrollUpdate, 10.0);
ASSERT_TRUE(scroll_0.CanCoalesceWith(scroll_1));
scroll_0.CoalesceWith(scroll_1);
// Coalescing WebGestureEvent preserves newer timestamp.
- EXPECT_EQ(10.0, scroll_0.event.timeStampSeconds());
+ EXPECT_EQ(10.0, scroll_0.event.TimeStampSeconds());
}
TEST_F(EventWithLatencyInfoTest, LatencyInfoCoalescing) {
- MouseEventWithLatencyInfo mouse_0 = CreateMouseEvent(
- WebInputEvent::MouseMove, 5.0);
+ MouseEventWithLatencyInfo mouse_0 =
+ CreateMouseEvent(WebInputEvent::kMouseMove, 5.0);
mouse_0.latency.AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, base::TimeTicks(), 1);
- MouseEventWithLatencyInfo mouse_1 = CreateMouseEvent(
- WebInputEvent::MouseMove, 10.0);
+ MouseEventWithLatencyInfo mouse_1 =
+ CreateMouseEvent(WebInputEvent::kMouseMove, 10.0);
ASSERT_TRUE(mouse_0.CanCoalesceWith(mouse_1));
@@ -160,8 +160,8 @@ void Coalesce(const T& event_to_coalesce, T* event) {
}
TEST_F(EventWithLatencyInfoTest, TouchEventCoalescing) {
- TouchEventWithLatencyInfo touch0 = CreateTouch(WebInputEvent::TouchStart);
- TouchEventWithLatencyInfo touch1 = CreateTouch(WebInputEvent::TouchMove);
+ TouchEventWithLatencyInfo touch0 = CreateTouch(WebInputEvent::kTouchStart);
+ TouchEventWithLatencyInfo touch1 = CreateTouch(WebInputEvent::kTouchMove);
// Non touch-moves won't coalesce.
EXPECT_FALSE(CanCoalesce(touch0, touch0));
@@ -173,87 +173,89 @@ TEST_F(EventWithLatencyInfoTest, TouchEventCoalescing) {
EXPECT_TRUE(CanCoalesce(touch1, touch1));
// Touch moves with different touch ids should not coalesce.
- touch0 = CreateTouch(WebInputEvent::TouchMove);
- touch1 = CreateTouch(WebInputEvent::TouchMove);
+ touch0 = CreateTouch(WebInputEvent::kTouchMove);
+ touch1 = CreateTouch(WebInputEvent::kTouchMove);
touch0.event.touches[0].id = 7;
EXPECT_FALSE(CanCoalesce(touch0, touch1));
- touch0 = CreateTouch(WebInputEvent::TouchMove, 2);
- touch1 = CreateTouch(WebInputEvent::TouchMove, 2);
+ touch0 = CreateTouch(WebInputEvent::kTouchMove, 2);
+ touch1 = CreateTouch(WebInputEvent::kTouchMove, 2);
touch0.event.touches[0].id = 1;
touch1.event.touches[0].id = 0;
EXPECT_FALSE(CanCoalesce(touch0, touch1));
// Touch moves with different touch lengths should not coalesce.
- touch0 = CreateTouch(WebInputEvent::TouchMove, 1);
- touch1 = CreateTouch(WebInputEvent::TouchMove, 2);
+ touch0 = CreateTouch(WebInputEvent::kTouchMove, 1);
+ touch1 = CreateTouch(WebInputEvent::kTouchMove, 2);
EXPECT_FALSE(CanCoalesce(touch0, touch1));
// Touch moves with identical touch ids in different orders should coalesce.
- touch0 = CreateTouch(WebInputEvent::TouchMove, 2);
- touch1 = CreateTouch(WebInputEvent::TouchMove, 2);
+ touch0 = CreateTouch(WebInputEvent::kTouchMove, 2);
+ touch1 = CreateTouch(WebInputEvent::kTouchMove, 2);
touch0.event.touches[0] = touch1.event.touches[1] =
- CreateTouchPoint(WebTouchPoint::StateMoved, 1);
+ CreateTouchPoint(WebTouchPoint::kStateMoved, 1);
touch0.event.touches[1] = touch1.event.touches[0] =
- CreateTouchPoint(WebTouchPoint::StateMoved, 0);
+ CreateTouchPoint(WebTouchPoint::kStateMoved, 0);
EXPECT_TRUE(CanCoalesce(touch0, touch1));
// Pointers with the same ID's should coalesce.
- touch0 = CreateTouch(WebInputEvent::TouchMove, 2);
- touch1 = CreateTouch(WebInputEvent::TouchMove, 2);
+ touch0 = CreateTouch(WebInputEvent::kTouchMove, 2);
+ touch1 = CreateTouch(WebInputEvent::kTouchMove, 2);
touch0.event.touches[0] = touch1.event.touches[1] =
- CreateTouchPoint(WebTouchPoint::StateMoved, 1);
+ CreateTouchPoint(WebTouchPoint::kStateMoved, 1);
Coalesce(touch0, &touch1);
ASSERT_EQ(1, touch1.event.touches[0].id);
ASSERT_EQ(0, touch1.event.touches[1].id);
- EXPECT_EQ(WebTouchPoint::StateUndefined, touch1.event.touches[1].state);
- EXPECT_EQ(WebTouchPoint::StateMoved, touch1.event.touches[0].state);
+ EXPECT_EQ(WebTouchPoint::kStateUndefined, touch1.event.touches[1].state);
+ EXPECT_EQ(WebTouchPoint::kStateMoved, touch1.event.touches[0].state);
// Movement from now-stationary pointers should be preserved.
- touch0 = touch1 = CreateTouch(WebInputEvent::TouchMove, 2);
- touch0.event.touches[0] = CreateTouchPoint(WebTouchPoint::StateMoved, 1);
- touch1.event.touches[1] = CreateTouchPoint(WebTouchPoint::StateStationary, 1);
- touch0.event.touches[1] = CreateTouchPoint(WebTouchPoint::StateStationary, 0);
- touch1.event.touches[0] = CreateTouchPoint(WebTouchPoint::StateMoved, 0);
+ touch0 = touch1 = CreateTouch(WebInputEvent::kTouchMove, 2);
+ touch0.event.touches[0] = CreateTouchPoint(WebTouchPoint::kStateMoved, 1);
+ touch1.event.touches[1] =
+ CreateTouchPoint(WebTouchPoint::kStateStationary, 1);
+ touch0.event.touches[1] =
+ CreateTouchPoint(WebTouchPoint::kStateStationary, 0);
+ touch1.event.touches[0] = CreateTouchPoint(WebTouchPoint::kStateMoved, 0);
Coalesce(touch0, &touch1);
ASSERT_EQ(1, touch1.event.touches[0].id);
ASSERT_EQ(0, touch1.event.touches[1].id);
- EXPECT_EQ(WebTouchPoint::StateMoved, touch1.event.touches[0].state);
- EXPECT_EQ(WebTouchPoint::StateMoved, touch1.event.touches[1].state);
+ EXPECT_EQ(WebTouchPoint::kStateMoved, touch1.event.touches[0].state);
+ EXPECT_EQ(WebTouchPoint::kStateMoved, touch1.event.touches[1].state);
// Touch moves with different dispatchTypes coalesce.
- touch0 = CreateTouch(WebInputEvent::TouchMove, 2);
- touch0.event.dispatchType = WebInputEvent::DispatchType::Blocking;
- touch1 = CreateTouch(WebInputEvent::TouchMove, 2);
- touch1.event.dispatchType = WebInputEvent::DispatchType::EventNonBlocking;
+ touch0 = CreateTouch(WebInputEvent::kTouchMove, 2);
+ touch0.event.dispatch_type = WebInputEvent::DispatchType::kBlocking;
+ touch1 = CreateTouch(WebInputEvent::kTouchMove, 2);
+ touch1.event.dispatch_type = WebInputEvent::DispatchType::kEventNonBlocking;
touch0.event.touches[0] = touch1.event.touches[1] =
- CreateTouchPoint(WebTouchPoint::StateMoved, 1);
+ CreateTouchPoint(WebTouchPoint::kStateMoved, 1);
touch0.event.touches[1] = touch1.event.touches[0] =
- CreateTouchPoint(WebTouchPoint::StateMoved, 0);
+ CreateTouchPoint(WebTouchPoint::kStateMoved, 0);
EXPECT_TRUE(CanCoalesce(touch0, touch1));
Coalesce(touch0, &touch1);
- ASSERT_EQ(WebInputEvent::DispatchType::Blocking, touch1.event.dispatchType);
-
- touch0 = CreateTouch(WebInputEvent::TouchMove, 2);
- touch0.event.dispatchType =
- WebInputEvent::DispatchType::ListenersForcedNonBlockingDueToFling;
- touch1 = CreateTouch(WebInputEvent::TouchMove, 2);
- touch1.event.dispatchType =
- WebInputEvent::DispatchType::ListenersNonBlockingPassive;
+ ASSERT_EQ(WebInputEvent::DispatchType::kBlocking, touch1.event.dispatch_type);
+
+ touch0 = CreateTouch(WebInputEvent::kTouchMove, 2);
+ touch0.event.dispatch_type =
+ WebInputEvent::DispatchType::kListenersForcedNonBlockingDueToFling;
+ touch1 = CreateTouch(WebInputEvent::kTouchMove, 2);
+ touch1.event.dispatch_type =
+ WebInputEvent::DispatchType::kListenersNonBlockingPassive;
touch0.event.touches[0] = touch1.event.touches[1] =
- CreateTouchPoint(WebTouchPoint::StateMoved, 1);
+ CreateTouchPoint(WebTouchPoint::kStateMoved, 1);
touch0.event.touches[1] = touch1.event.touches[0] =
- CreateTouchPoint(WebTouchPoint::StateMoved, 0);
+ CreateTouchPoint(WebTouchPoint::kStateMoved, 0);
EXPECT_TRUE(CanCoalesce(touch0, touch1));
Coalesce(touch0, &touch1);
- ASSERT_EQ(WebInputEvent::DispatchType::ListenersNonBlockingPassive,
- touch1.event.dispatchType);
+ ASSERT_EQ(WebInputEvent::DispatchType::kListenersNonBlockingPassive,
+ touch1.event.dispatch_type);
}
TEST_F(EventWithLatencyInfoTest, PinchEventCoalescing) {
GestureEventWithLatencyInfo pinch0 =
- CreateGesture(WebInputEvent::GesturePinchBegin, 1, 1);
+ CreateGesture(WebInputEvent::kGesturePinchBegin, 1, 1);
GestureEventWithLatencyInfo pinch1 =
- CreateGesture(WebInputEvent::GesturePinchUpdate, 2, 2);
+ CreateGesture(WebInputEvent::kGesturePinchUpdate, 2, 2);
// Only GesturePinchUpdate's coalesce.
EXPECT_FALSE(CanCoalesce(pinch0, pinch0));
@@ -262,38 +264,38 @@ TEST_F(EventWithLatencyInfoTest, PinchEventCoalescing) {
EXPECT_FALSE(CanCoalesce(pinch0, pinch1));
// Pinches with different focal points should not coalesce.
- pinch0 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
- pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 2, 2);
+ pinch0 = CreateGesture(WebInputEvent::kGesturePinchUpdate, 1, 1);
+ pinch1 = CreateGesture(WebInputEvent::kGesturePinchUpdate, 2, 2);
EXPECT_FALSE(CanCoalesce(pinch0, pinch1));
EXPECT_TRUE(CanCoalesce(pinch0, pinch0));
// Coalesced scales are multiplicative.
- pinch0 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
- pinch0.event.data.pinchUpdate.scale = 2.f;
- pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
- pinch1.event.data.pinchUpdate.scale = 3.f;
+ pinch0 = CreateGesture(WebInputEvent::kGesturePinchUpdate, 1, 1);
+ pinch0.event.data.pinch_update.scale = 2.f;
+ pinch1 = CreateGesture(WebInputEvent::kGesturePinchUpdate, 1, 1);
+ pinch1.event.data.pinch_update.scale = 3.f;
EXPECT_TRUE(CanCoalesce(pinch0, pinch0));
Coalesce(pinch0, &pinch1);
- EXPECT_EQ(2.f * 3.f, pinch1.event.data.pinchUpdate.scale);
+ EXPECT_EQ(2.f * 3.f, pinch1.event.data.pinch_update.scale);
// Scales have a minimum value and can never reach 0.
ASSERT_GT(numeric_limits<float>::min(), 0);
- pinch0 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
- pinch0.event.data.pinchUpdate.scale = numeric_limits<float>::min() * 2.0f;
- pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
- pinch1.event.data.pinchUpdate.scale = numeric_limits<float>::min() * 5.0f;
+ pinch0 = CreateGesture(WebInputEvent::kGesturePinchUpdate, 1, 1);
+ pinch0.event.data.pinch_update.scale = numeric_limits<float>::min() * 2.0f;
+ pinch1 = CreateGesture(WebInputEvent::kGesturePinchUpdate, 1, 1);
+ pinch1.event.data.pinch_update.scale = numeric_limits<float>::min() * 5.0f;
EXPECT_TRUE(CanCoalesce(pinch0, pinch1));
Coalesce(pinch0, &pinch1);
- EXPECT_EQ(numeric_limits<float>::min(), pinch1.event.data.pinchUpdate.scale);
+ EXPECT_EQ(numeric_limits<float>::min(), pinch1.event.data.pinch_update.scale);
// Scales have a maximum value and can never reach Infinity.
- pinch0 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
- pinch0.event.data.pinchUpdate.scale = numeric_limits<float>::max() / 2.0f;
- pinch1 = CreateGesture(WebInputEvent::GesturePinchUpdate, 1, 1);
- pinch1.event.data.pinchUpdate.scale = 10.0f;
+ pinch0 = CreateGesture(WebInputEvent::kGesturePinchUpdate, 1, 1);
+ pinch0.event.data.pinch_update.scale = numeric_limits<float>::max() / 2.0f;
+ pinch1 = CreateGesture(WebInputEvent::kGesturePinchUpdate, 1, 1);
+ pinch1.event.data.pinch_update.scale = 10.0f;
EXPECT_TRUE(CanCoalesce(pinch0, pinch1));
Coalesce(pinch0, &pinch1);
- EXPECT_EQ(numeric_limits<float>::max(), pinch1.event.data.pinchUpdate.scale);
+ EXPECT_EQ(numeric_limits<float>::max(), pinch1.event.data.pinch_update.scale);
}
TEST_F(EventWithLatencyInfoTest, WebMouseWheelEventCoalescing) {
@@ -304,48 +306,50 @@ TEST_F(EventWithLatencyInfoTest, WebMouseWheelEventCoalescing) {
EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
// WebMouseWheelEvent objects with different modifiers should not coalesce.
- mouse_wheel_0 = CreateMouseWheelEvent(2.0, 1, 1, WebInputEvent::ControlKey);
- mouse_wheel_1 = CreateMouseWheelEvent(2.0, 1, 1, WebInputEvent::ShiftKey);
+ mouse_wheel_0 = CreateMouseWheelEvent(2.0, 1, 1, WebInputEvent::kControlKey);
+ mouse_wheel_1 = CreateMouseWheelEvent(2.0, 1, 1, WebInputEvent::kShiftKey);
EXPECT_FALSE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
// Coalesce old and new events.
mouse_wheel_0 = CreateMouseWheel(1, 1);
- mouse_wheel_0.event.x = 1;
- mouse_wheel_0.event.y = 1;
+ mouse_wheel_0.event.SetPositionInWidget(1, 1);
mouse_wheel_1 = CreateMouseWheel(2, 2);
- mouse_wheel_1.event.x = 2;
- mouse_wheel_1.event.y = 2;
+ mouse_wheel_1.event.SetPositionInWidget(2, 2);
MouseWheelEventWithLatencyInfo mouse_wheel_1_copy = mouse_wheel_1;
EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
- EXPECT_EQ(mouse_wheel_0.event.modifiers(), mouse_wheel_1.event.modifiers());
- EXPECT_EQ(mouse_wheel_0.event.scrollByPage, mouse_wheel_1.event.scrollByPage);
+ EXPECT_EQ(mouse_wheel_0.event.GetModifiers(),
+ mouse_wheel_1.event.GetModifiers());
+ EXPECT_EQ(mouse_wheel_0.event.scroll_by_page,
+ mouse_wheel_1.event.scroll_by_page);
EXPECT_EQ(mouse_wheel_0.event.phase, mouse_wheel_1.event.phase);
- EXPECT_EQ(mouse_wheel_0.event.momentumPhase,
- mouse_wheel_1.event.momentumPhase);
- EXPECT_EQ(mouse_wheel_0.event.hasPreciseScrollingDeltas,
- mouse_wheel_1.event.hasPreciseScrollingDeltas);
+ EXPECT_EQ(mouse_wheel_0.event.momentum_phase,
+ mouse_wheel_1.event.momentum_phase);
+ EXPECT_EQ(mouse_wheel_0.event.has_precise_scrolling_deltas,
+ mouse_wheel_1.event.has_precise_scrolling_deltas);
Coalesce(mouse_wheel_0, &mouse_wheel_1);
// Coalesced event has the position of the most recent event.
- EXPECT_EQ(1, mouse_wheel_1.event.x);
- EXPECT_EQ(1, mouse_wheel_1.event.y);
+ EXPECT_EQ(1, mouse_wheel_1.event.PositionInWidget().x);
+ EXPECT_EQ(1, mouse_wheel_1.event.PositionInWidget().y);
// deltaX/Y, wheelTicksX/Y, and movementX/Y of the coalesced event are
// calculated properly.
- EXPECT_EQ(mouse_wheel_1_copy.event.deltaX + mouse_wheel_0.event.deltaX,
- mouse_wheel_1.event.deltaX);
- EXPECT_EQ(mouse_wheel_1_copy.event.deltaY + mouse_wheel_0.event.deltaY,
- mouse_wheel_1.event.deltaY);
+ EXPECT_EQ(mouse_wheel_1_copy.event.delta_x + mouse_wheel_0.event.delta_x,
+ mouse_wheel_1.event.delta_x);
+ EXPECT_EQ(mouse_wheel_1_copy.event.delta_y + mouse_wheel_0.event.delta_y,
+ mouse_wheel_1.event.delta_y);
+ EXPECT_EQ(mouse_wheel_1_copy.event.wheel_ticks_x +
+ mouse_wheel_0.event.wheel_ticks_x,
+ mouse_wheel_1.event.wheel_ticks_x);
+ EXPECT_EQ(mouse_wheel_1_copy.event.wheel_ticks_y +
+ mouse_wheel_0.event.wheel_ticks_y,
+ mouse_wheel_1.event.wheel_ticks_y);
EXPECT_EQ(
- mouse_wheel_1_copy.event.wheelTicksX + mouse_wheel_0.event.wheelTicksX,
- mouse_wheel_1.event.wheelTicksX);
+ mouse_wheel_1_copy.event.movement_x + mouse_wheel_0.event.movement_x,
+ mouse_wheel_1.event.movement_x);
EXPECT_EQ(
- mouse_wheel_1_copy.event.wheelTicksY + mouse_wheel_0.event.wheelTicksY,
- mouse_wheel_1.event.wheelTicksY);
- EXPECT_EQ(mouse_wheel_1_copy.event.movementX + mouse_wheel_0.event.movementX,
- mouse_wheel_1.event.movementX);
- EXPECT_EQ(mouse_wheel_1_copy.event.movementY + mouse_wheel_0.event.movementY,
- mouse_wheel_1.event.movementY);
+ mouse_wheel_1_copy.event.movement_y + mouse_wheel_0.event.movement_y,
+ mouse_wheel_1.event.movement_y);
}
// Coalescing preserves the newer timestamp.
@@ -357,7 +361,7 @@ TEST_F(EventWithLatencyInfoTest, TimestampCoalescing) {
EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1));
Coalesce(mouse_wheel_1, &mouse_wheel_0);
- EXPECT_EQ(10.0, mouse_wheel_0.event.timeStampSeconds());
+ EXPECT_EQ(10.0, mouse_wheel_0.event.TimeStampSeconds());
}
} // namespace
diff --git a/chromium/content/common/input/gesture_event_stream_validator.cc b/chromium/content/common/input/gesture_event_stream_validator.cc
index 2bcb8b0d5b0..5338ce8603d 100644
--- a/chromium/content/common/input/gesture_event_stream_validator.cc
+++ b/chromium/content/common/input/gesture_event_stream_validator.cc
@@ -25,26 +25,26 @@ bool GestureEventStreamValidator::Validate(const blink::WebGestureEvent& event,
std::string* error_msg) {
DCHECK(error_msg);
error_msg->clear();
- if (!WebInputEvent::isGestureEventType(event.type())) {
- error_msg->append(base::StringPrintf("Invalid gesture type: %s",
- WebInputEvent::GetName(event.type())));
+ if (!WebInputEvent::IsGestureEventType(event.GetType())) {
+ error_msg->append(base::StringPrintf(
+ "Invalid gesture type: %s", WebInputEvent::GetName(event.GetType())));
}
- switch (event.type()) {
- case WebInputEvent::GestureScrollBegin:
+ switch (event.GetType()) {
+ case WebInputEvent::kGestureScrollBegin:
if (scrolling_)
error_msg->append("Scroll begin during scroll\n");
if (pinching_)
error_msg->append("Scroll begin during pinch\n");
scrolling_ = true;
break;
- case WebInputEvent::GestureScrollUpdate:
+ case WebInputEvent::kGestureScrollUpdate:
if (!scrolling_)
error_msg->append("Scroll update outside of scroll\n");
break;
- case WebInputEvent::GestureFlingStart:
- if (event.sourceDevice == blink::WebGestureDeviceTouchscreen &&
- !event.data.flingStart.velocityX &&
- !event.data.flingStart.velocityY) {
+ case WebInputEvent::kGestureFlingStart:
+ if (event.source_device == blink::kWebGestureDeviceTouchscreen &&
+ !event.data.fling_start.velocity_x &&
+ !event.data.fling_start.velocity_y) {
error_msg->append("Zero velocity touchscreen fling\n");
}
if (!scrolling_)
@@ -53,47 +53,47 @@ bool GestureEventStreamValidator::Validate(const blink::WebGestureEvent& event,
error_msg->append("Flinging while pinching\n");
scrolling_ = false;
break;
- case WebInputEvent::GestureScrollEnd:
+ case WebInputEvent::kGestureScrollEnd:
if (!scrolling_)
error_msg->append("Scroll end outside of scroll\n");
if (pinching_)
error_msg->append("Ending scroll while pinching\n");
scrolling_ = false;
break;
- case WebInputEvent::GesturePinchBegin:
+ case WebInputEvent::kGesturePinchBegin:
if (pinching_)
error_msg->append("Pinch begin during pinch\n");
pinching_ = true;
break;
- case WebInputEvent::GesturePinchUpdate:
+ case WebInputEvent::kGesturePinchUpdate:
if (!pinching_)
error_msg->append("Pinch update outside of pinch\n");
break;
- case WebInputEvent::GesturePinchEnd:
+ case WebInputEvent::kGesturePinchEnd:
if (!pinching_)
error_msg->append("Pinch end outside of pinch\n");
pinching_ = false;
break;
- case WebInputEvent::GestureTapDown:
+ case WebInputEvent::kGestureTapDown:
if (waiting_for_tap_end_)
error_msg->append("Missing tap ending event before TapDown\n");
waiting_for_tap_end_ = true;
break;
- case WebInputEvent::GestureTapUnconfirmed:
+ case WebInputEvent::kGestureTapUnconfirmed:
if (!waiting_for_tap_end_)
error_msg->append("Missing TapDown event before TapUnconfirmed\n");
break;
- case WebInputEvent::GestureTapCancel:
+ case WebInputEvent::kGestureTapCancel:
if (!waiting_for_tap_end_)
error_msg->append("Missing TapDown event before TapCancel\n");
waiting_for_tap_end_ = false;
break;
- case WebInputEvent::GestureTap:
+ case WebInputEvent::kGestureTap:
if (!waiting_for_tap_end_)
error_msg->append("Missing TapDown event before Tap\n");
waiting_for_tap_end_ = false;
break;
- case WebInputEvent::GestureDoubleTap:
+ case WebInputEvent::kGestureDoubleTap:
// DoubleTap gestures may be synthetically inserted, and do not require a
// preceding TapDown.
waiting_for_tap_end_ = false;
@@ -105,7 +105,7 @@ bool GestureEventStreamValidator::Validate(const blink::WebGestureEvent& event,
// 'continuity check', requiring that all events between an initial tap-down
// and whatever terminates the sequence to have the same source device type,
// and that touchpad gestures are only found on ScrollEvents.
- if (event.sourceDevice == blink::WebGestureDeviceUninitialized)
+ if (event.source_device == blink::kWebGestureDeviceUninitialized)
error_msg->append("Gesture event source is uninitialized.\n");
return error_msg->empty();
diff --git a/chromium/content/common/input/gesture_event_stream_validator_unittest.cc b/chromium/content/common/input/gesture_event_stream_validator_unittest.cc
index 88484ef372f..6ad92703855 100644
--- a/chromium/content/common/input/gesture_event_stream_validator_unittest.cc
+++ b/chromium/content/common/input/gesture_event_stream_validator_unittest.cc
@@ -14,14 +14,14 @@ namespace content {
namespace {
const blink::WebGestureDevice kDefaultGestureDevice =
- blink::WebGestureDeviceTouchscreen;
+ blink::kWebGestureDeviceTouchscreen;
blink::WebGestureEvent Build(WebInputEvent::Type type) {
blink::WebGestureEvent event =
SyntheticWebGestureEventBuilder::Build(type, kDefaultGestureDevice);
// Default to providing a (valid) non-zero fling velocity.
- if (type == WebInputEvent::GestureFlingStart)
- event.data.flingStart.velocityX = 5;
+ if (type == WebInputEvent::kGestureFlingStart)
+ event.data.fling_start.velocity_x = 5;
return event;
}
@@ -32,15 +32,15 @@ TEST(GestureEventStreamValidator, ValidScroll) {
std::string error_msg;
WebGestureEvent event;
- event = Build(WebInputEvent::GestureScrollBegin);
+ event = Build(WebInputEvent::kGestureScrollBegin);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
- event = Build(WebInputEvent::GestureScrollUpdate);
+ event = Build(WebInputEvent::kGestureScrollUpdate);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
- event = Build(WebInputEvent::GestureScrollEnd);
+ event = Build(WebInputEvent::kGestureScrollEnd);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
}
@@ -51,30 +51,30 @@ TEST(GestureEventStreamValidator, InvalidScroll) {
WebGestureEvent event;
// No preceding ScrollBegin.
- event = Build(WebInputEvent::GestureScrollUpdate);
+ event = Build(WebInputEvent::kGestureScrollUpdate);
EXPECT_FALSE(validator.Validate(event, &error_msg));
EXPECT_FALSE(error_msg.empty());
// No preceding ScrollBegin.
- event = Build(WebInputEvent::GestureScrollEnd);
+ event = Build(WebInputEvent::kGestureScrollEnd);
EXPECT_FALSE(validator.Validate(event, &error_msg));
EXPECT_FALSE(error_msg.empty());
- event = Build(WebInputEvent::GestureScrollBegin);
+ event = Build(WebInputEvent::kGestureScrollBegin);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
// Already scrolling.
- event = Build(WebInputEvent::GestureScrollBegin);
+ event = Build(WebInputEvent::kGestureScrollBegin);
EXPECT_FALSE(validator.Validate(event, &error_msg));
EXPECT_FALSE(error_msg.empty());
- event = Build(WebInputEvent::GestureScrollEnd);
+ event = Build(WebInputEvent::kGestureScrollEnd);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
// Scroll already ended.
- event = Build(WebInputEvent::GestureScrollEnd);
+ event = Build(WebInputEvent::kGestureScrollEnd);
EXPECT_FALSE(validator.Validate(event, &error_msg));
EXPECT_FALSE(error_msg.empty());
}
@@ -84,11 +84,11 @@ TEST(GestureEventStreamValidator, ValidFling) {
std::string error_msg;
WebGestureEvent event;
- event = Build(WebInputEvent::GestureScrollBegin);
+ event = Build(WebInputEvent::kGestureScrollBegin);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
- event = Build(WebInputEvent::GestureFlingStart);
+ event = Build(WebInputEvent::kGestureFlingStart);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
}
@@ -99,18 +99,18 @@ TEST(GestureEventStreamValidator, InvalidFling) {
WebGestureEvent event;
// No preceding ScrollBegin.
- event = Build(WebInputEvent::GestureFlingStart);
+ event = Build(WebInputEvent::kGestureFlingStart);
EXPECT_FALSE(validator.Validate(event, &error_msg));
EXPECT_FALSE(error_msg.empty());
// Zero velocity.
- event = Build(WebInputEvent::GestureScrollBegin);
+ event = Build(WebInputEvent::kGestureScrollBegin);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
- event = Build(WebInputEvent::GestureFlingStart);
- event.data.flingStart.velocityX = 0;
- event.data.flingStart.velocityY = 0;
+ event = Build(WebInputEvent::kGestureFlingStart);
+ event.data.fling_start.velocity_x = 0;
+ event.data.fling_start.velocity_y = 0;
EXPECT_FALSE(validator.Validate(event, &error_msg));
EXPECT_FALSE(error_msg.empty());
}
@@ -120,15 +120,15 @@ TEST(GestureEventStreamValidator, ValidPinch) {
std::string error_msg;
WebGestureEvent event;
- event = Build(WebInputEvent::GesturePinchBegin);
+ event = Build(WebInputEvent::kGesturePinchBegin);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
- event = Build(WebInputEvent::GesturePinchUpdate);
+ event = Build(WebInputEvent::kGesturePinchUpdate);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
- event = Build(WebInputEvent::GesturePinchEnd);
+ event = Build(WebInputEvent::kGesturePinchEnd);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
}
@@ -139,35 +139,35 @@ TEST(GestureEventStreamValidator, InvalidPinch) {
WebGestureEvent event;
// No preceding PinchBegin.
- event = Build(WebInputEvent::GesturePinchUpdate);
+ event = Build(WebInputEvent::kGesturePinchUpdate);
EXPECT_FALSE(validator.Validate(event, &error_msg));
EXPECT_FALSE(error_msg.empty());
- event = Build(WebInputEvent::GesturePinchBegin);
+ event = Build(WebInputEvent::kGesturePinchBegin);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
// ScrollBegin while pinching.
- event = Build(WebInputEvent::GestureScrollBegin);
+ event = Build(WebInputEvent::kGestureScrollBegin);
EXPECT_FALSE(validator.Validate(event, &error_msg));
EXPECT_FALSE(error_msg.empty());
// ScrollEnd while pinching.
- event = Build(WebInputEvent::GestureScrollEnd);
+ event = Build(WebInputEvent::kGestureScrollEnd);
EXPECT_FALSE(validator.Validate(event, &error_msg));
EXPECT_FALSE(error_msg.empty());
// Pinch already begun.
- event = Build(WebInputEvent::GesturePinchBegin);
+ event = Build(WebInputEvent::kGesturePinchBegin);
EXPECT_FALSE(validator.Validate(event, &error_msg));
EXPECT_FALSE(error_msg.empty());
- event = Build(WebInputEvent::GesturePinchEnd);
+ event = Build(WebInputEvent::kGesturePinchEnd);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
// Pinch already ended.
- event = Build(WebInputEvent::GesturePinchEnd);
+ event = Build(WebInputEvent::kGesturePinchEnd);
EXPECT_FALSE(validator.Validate(event, &error_msg));
EXPECT_FALSE(error_msg.empty());
}
@@ -177,37 +177,37 @@ TEST(GestureEventStreamValidator, ValidTap) {
std::string error_msg;
WebGestureEvent event;
- event = Build(WebInputEvent::GestureTapDown);
+ event = Build(WebInputEvent::kGestureTapDown);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
- event = Build(WebInputEvent::GestureTapCancel);
+ event = Build(WebInputEvent::kGestureTapCancel);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
- event = Build(WebInputEvent::GestureTapDown);
+ event = Build(WebInputEvent::kGestureTapDown);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
- event = Build(WebInputEvent::GestureTapUnconfirmed);
+ event = Build(WebInputEvent::kGestureTapUnconfirmed);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
- event = Build(WebInputEvent::GestureTapCancel);
+ event = Build(WebInputEvent::kGestureTapCancel);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
- event = Build(WebInputEvent::GestureTapDown);
+ event = Build(WebInputEvent::kGestureTapDown);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
- event = Build(WebInputEvent::GestureTap);
+ event = Build(WebInputEvent::kGestureTap);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
// DoubleTap does not require a TapDown (unlike Tap, TapUnconfirmed and
// TapCancel).
- event = Build(WebInputEvent::GestureDoubleTap);
+ event = Build(WebInputEvent::kGestureDoubleTap);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
}
@@ -218,41 +218,41 @@ TEST(GestureEventStreamValidator, InvalidTap) {
WebGestureEvent event;
// No preceding TapDown.
- event = Build(WebInputEvent::GestureTapUnconfirmed);
+ event = Build(WebInputEvent::kGestureTapUnconfirmed);
EXPECT_FALSE(validator.Validate(event, &error_msg));
EXPECT_FALSE(error_msg.empty());
- event = Build(WebInputEvent::GestureTapCancel);
+ event = Build(WebInputEvent::kGestureTapCancel);
EXPECT_FALSE(validator.Validate(event, &error_msg));
EXPECT_FALSE(error_msg.empty());
- event = Build(WebInputEvent::GestureTap);
+ event = Build(WebInputEvent::kGestureTap);
EXPECT_FALSE(validator.Validate(event, &error_msg));
EXPECT_FALSE(error_msg.empty());
// TapDown already terminated.
- event = Build(WebInputEvent::GestureTapDown);
+ event = Build(WebInputEvent::kGestureTapDown);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
- event = Build(WebInputEvent::GestureDoubleTap);
+ event = Build(WebInputEvent::kGestureDoubleTap);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
- event = Build(WebInputEvent::GestureTapCancel);
+ event = Build(WebInputEvent::kGestureTapCancel);
EXPECT_FALSE(validator.Validate(event, &error_msg));
EXPECT_FALSE(error_msg.empty());
// TapDown already terminated.
- event = Build(WebInputEvent::GestureTapDown);
+ event = Build(WebInputEvent::kGestureTapDown);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
- event = Build(WebInputEvent::GestureTap);
+ event = Build(WebInputEvent::kGestureTap);
EXPECT_TRUE(validator.Validate(event, &error_msg));
EXPECT_TRUE(error_msg.empty());
- event = Build(WebInputEvent::GestureTapCancel);
+ event = Build(WebInputEvent::kGestureTapCancel);
EXPECT_FALSE(validator.Validate(event, &error_msg));
EXPECT_FALSE(error_msg.empty());
}
diff --git a/chromium/content/common/input/input_event.h b/chromium/content/common/input/input_event.h
index 7e29509417a..fd10e4ede92 100644
--- a/chromium/content/common/input/input_event.h
+++ b/chromium/content/common/input/input_event.h
@@ -10,7 +10,7 @@
#include "base/macros.h"
#include "content/common/content_export.h"
#include "ui/events/blink/web_input_event_traits.h"
-#include "ui/events/latency_info.h"
+#include "ui/latency/latency_info.h"
namespace blink {
class WebInputEvent;
diff --git a/chromium/content/common/input/input_event_ack.cc b/chromium/content/common/input/input_event_ack.cc
index 92cf5eaed0c..c067e91a04d 100644
--- a/chromium/content/common/input/input_event_ack.cc
+++ b/chromium/content/common/input/input_event_ack.cc
@@ -51,7 +51,7 @@ InputEventAck::InputEventAck(InputEventAckSource source,
InputEventAck::InputEventAck()
: InputEventAck(InputEventAckSource::UNKNOWN,
- blink::WebInputEvent::Undefined,
+ blink::WebInputEvent::kUndefined,
INPUT_EVENT_ACK_STATE_UNKNOWN) {}
InputEventAck::~InputEventAck() {
diff --git a/chromium/content/common/input/input_event_ack.h b/chromium/content/common/input/input_event_ack.h
index 132ce7e9bea..f94b5e1bc30 100644
--- a/chromium/content/common/input/input_event_ack.h
+++ b/chromium/content/common/input/input_event_ack.h
@@ -14,7 +14,7 @@
#include "content/common/input/input_event_ack_state.h"
#include "third_party/WebKit/public/platform/WebInputEvent.h"
#include "ui/events/blink/did_overscroll_params.h"
-#include "ui/events/latency_info.h"
+#include "ui/latency/latency_info.h"
namespace content {
diff --git a/chromium/content/common/input/input_event_stream_validator.cc b/chromium/content/common/input/input_event_stream_validator.cc
index bb178ed8af0..9206718012d 100644
--- a/chromium/content/common/input/input_event_stream_validator.cc
+++ b/chromium/content/common/input/input_event_stream_validator.cc
@@ -37,12 +37,12 @@ void InputEventStreamValidator::Validate(const WebInputEvent& event) {
bool InputEventStreamValidator::ValidateImpl(const blink::WebInputEvent& event,
std::string* error_msg) {
DCHECK(error_msg);
- if (WebInputEvent::isGestureEventType(event.type())) {
+ if (WebInputEvent::IsGestureEventType(event.GetType())) {
const WebGestureEvent& gesture = static_cast<const WebGestureEvent&>(event);
// TODO(jdduke): Validate touchpad gesture streams.
- if (gesture.sourceDevice == blink::WebGestureDeviceTouchscreen)
+ if (gesture.source_device == blink::kWebGestureDeviceTouchscreen)
return gesture_validator_.Validate(gesture, error_msg);
- } else if (WebInputEvent::isTouchEventType(event.type())) {
+ } else if (WebInputEvent::IsTouchEventType(event.GetType())) {
const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(event);
return touch_validator_.Validate(touch, error_msg);
}
diff --git a/chromium/content/common/input/input_param_traits_unittest.cc b/chromium/content/common/input/input_param_traits_unittest.cc
index c5c70a3b32f..a652472d6aa 100644
--- a/chromium/content/common/input/input_param_traits_unittest.cc
+++ b/chromium/content/common/input/input_param_traits_unittest.cc
@@ -5,7 +5,10 @@
#include "content/common/input/input_param_traits.h"
#include <stddef.h>
+
+#include <memory>
#include <utility>
+#include <vector>
#include "base/memory/ptr_util.h"
#include "content/common/input/input_event.h"
@@ -27,7 +30,7 @@
namespace content {
namespace {
-typedef ScopedVector<InputEvent> InputEvents;
+typedef std::vector<std::unique_ptr<InputEvent>> InputEvents;
class InputParamTraitsTest : public testing::Test {
protected:
@@ -44,7 +47,7 @@ class InputParamTraitsTest : public testing::Test {
static void Compare(const InputEvents* a, const InputEvents* b) {
for (size_t i = 0; i < a->size(); ++i)
- Compare((*a)[i], (*b)[i]);
+ Compare((*a)[i].get(), (*b)[i].get());
}
static void Compare(const SyntheticSmoothScrollGestureParams* a,
@@ -197,39 +200,39 @@ TEST_F(InputParamTraitsTest, InitializedEvents) {
ui::LatencyInfo latency;
- blink::WebKeyboardEvent key_event(blink::WebInputEvent::RawKeyDown,
- blink::WebInputEvent::NoModifiers,
- blink::WebInputEvent::TimeStampForTesting);
- key_event.nativeKeyCode = 5;
- events.push_back(new InputEvent(key_event, latency));
+ blink::WebKeyboardEvent key_event(blink::WebInputEvent::kRawKeyDown,
+ blink::WebInputEvent::kNoModifiers,
+ blink::WebInputEvent::kTimeStampForTesting);
+ key_event.native_key_code = 5;
+ events.push_back(base::MakeUnique<InputEvent>(key_event, latency));
blink::WebMouseWheelEvent wheel_event(
- blink::WebInputEvent::MouseWheel, blink::WebInputEvent::NoModifiers,
- blink::WebInputEvent::TimeStampForTesting);
- wheel_event.deltaX = 10;
+ blink::WebInputEvent::kMouseWheel, blink::WebInputEvent::kNoModifiers,
+ blink::WebInputEvent::kTimeStampForTesting);
+ wheel_event.delta_x = 10;
latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1, 1);
- events.push_back(new InputEvent(wheel_event, latency));
+ events.push_back(base::MakeUnique<InputEvent>(wheel_event, latency));
- blink::WebMouseEvent mouse_event(blink::WebInputEvent::MouseDown,
- blink::WebInputEvent::NoModifiers,
- blink::WebInputEvent::TimeStampForTesting);
- mouse_event.x = 10;
+ blink::WebMouseEvent mouse_event(blink::WebInputEvent::kMouseDown,
+ blink::WebInputEvent::kNoModifiers,
+ blink::WebInputEvent::kTimeStampForTesting);
+ mouse_event.SetPositionInWidget(10, 0);
latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 2, 2);
- events.push_back(new InputEvent(mouse_event, latency));
+ events.push_back(base::MakeUnique<InputEvent>(mouse_event, latency));
blink::WebGestureEvent gesture_event(
- blink::WebInputEvent::GestureScrollBegin,
- blink::WebInputEvent::NoModifiers,
- blink::WebInputEvent::TimeStampForTesting);
+ blink::WebInputEvent::kGestureScrollBegin,
+ blink::WebInputEvent::kNoModifiers,
+ blink::WebInputEvent::kTimeStampForTesting);
gesture_event.x = -1;
- events.push_back(new InputEvent(gesture_event, latency));
-
- blink::WebTouchEvent touch_event(blink::WebInputEvent::TouchStart,
- blink::WebInputEvent::NoModifiers,
- blink::WebInputEvent::TimeStampForTesting);
- touch_event.touchesLength = 1;
- touch_event.touches[0].radiusX = 1;
- events.push_back(new InputEvent(touch_event, latency));
+ events.push_back(base::MakeUnique<InputEvent>(gesture_event, latency));
+
+ blink::WebTouchEvent touch_event(blink::WebInputEvent::kTouchStart,
+ blink::WebInputEvent::kNoModifiers,
+ blink::WebInputEvent::kTimeStampForTesting);
+ touch_event.touches_length = 1;
+ touch_event.touches[0].radius_x = 1;
+ events.push_back(base::MakeUnique<InputEvent>(touch_event, latency));
Verify(events);
}
diff --git a/chromium/content/common/input/synthetic_pointer_action_params.cc b/chromium/content/common/input/synthetic_pointer_action_params.cc
index 7b858d6dcc6..23a42ec2e1c 100644
--- a/chromium/content/common/input/synthetic_pointer_action_params.cc
+++ b/chromium/content/common/input/synthetic_pointer_action_params.cc
@@ -22,14 +22,14 @@ unsigned SyntheticPointerActionParams::GetWebMouseEventModifier(
SyntheticPointerActionParams::Button button) {
switch (button) {
case SyntheticPointerActionParams::Button::LEFT:
- return blink::WebMouseEvent::LeftButtonDown;
+ return blink::WebMouseEvent::kLeftButtonDown;
case SyntheticPointerActionParams::Button::MIDDLE:
- return blink::WebMouseEvent::MiddleButtonDown;
+ return blink::WebMouseEvent::kMiddleButtonDown;
case SyntheticPointerActionParams::Button::RIGHT:
- return blink::WebMouseEvent::RightButtonDown;
+ return blink::WebMouseEvent::kRightButtonDown;
}
NOTREACHED();
- return blink::WebMouseEvent::NoModifiers;
+ return blink::WebMouseEvent::kNoModifiers;
}
// static
@@ -38,14 +38,14 @@ SyntheticPointerActionParams::GetWebMouseEventButton(
SyntheticPointerActionParams::Button button) {
switch (button) {
case SyntheticPointerActionParams::Button::LEFT:
- return blink::WebMouseEvent::Button::Left;
+ return blink::WebMouseEvent::Button::kLeft;
case SyntheticPointerActionParams::Button::MIDDLE:
- return blink::WebMouseEvent::Button::Middle;
+ return blink::WebMouseEvent::Button::kMiddle;
case SyntheticPointerActionParams::Button::RIGHT:
- return blink::WebMouseEvent::Button::Right;
+ return blink::WebMouseEvent::Button::kRight;
}
NOTREACHED();
- return blink::WebMouseEvent::Button::NoButton;
+ return blink::WebMouseEvent::Button::kNoButton;
}
} // namespace content \ No newline at end of file
diff --git a/chromium/content/common/input/synthetic_web_input_event_builders.cc b/chromium/content/common/input/synthetic_web_input_event_builders.cc
index 6533863a2b1..5e5638e6c3b 100644
--- a/chromium/content/common/input/synthetic_web_input_event_builders.cc
+++ b/chromium/content/common/input/synthetic_web_input_event_builders.cc
@@ -22,7 +22,7 @@ using blink::WebTouchPoint;
WebMouseEvent SyntheticWebMouseEventBuilder::Build(
blink::WebInputEvent::Type type) {
- return WebMouseEvent(type, WebInputEvent::NoModifiers,
+ return WebMouseEvent(type, WebInputEvent::kNoModifiers,
ui::EventTimeStampToSeconds(ui::EventTimeForNow()));
}
@@ -32,23 +32,20 @@ WebMouseEvent SyntheticWebMouseEventBuilder::Build(
int window_y,
int modifiers,
blink::WebPointerProperties::PointerType pointer_type) {
- DCHECK(WebInputEvent::isMouseEventType(type));
+ DCHECK(WebInputEvent::IsMouseEventType(type));
WebMouseEvent result(type, modifiers,
ui::EventTimeStampToSeconds(ui::EventTimeForNow()));
- result.x = window_x;
- result.y = window_y;
- result.windowX = window_x;
- result.windowY = window_y;
- result.setModifiers(modifiers);
- result.pointerType = pointer_type;
- result.id = ui::PointerEvent::kMousePointerId;
+ result.SetPositionInWidget(window_x, window_y);
+ result.SetModifiers(modifiers);
+ result.pointer_type = pointer_type;
+ result.id = ui::MouseEvent::kMousePointerId;
return result;
}
WebMouseWheelEvent SyntheticWebMouseWheelEventBuilder::Build(
WebMouseWheelEvent::Phase phase) {
- WebMouseWheelEvent result(WebInputEvent::MouseWheel,
- WebInputEvent::NoModifiers,
+ WebMouseWheelEvent result(WebInputEvent::kMouseWheel,
+ WebInputEvent::kNoModifiers,
ui::EventTimeStampToSeconds(ui::EventTimeForNow()));
result.phase = phase;
return result;
@@ -71,28 +68,26 @@ WebMouseWheelEvent SyntheticWebMouseWheelEventBuilder::Build(float x,
float dy,
int modifiers,
bool precise) {
- WebMouseWheelEvent result(WebInputEvent::MouseWheel, modifiers,
+ WebMouseWheelEvent result(WebInputEvent::kMouseWheel, modifiers,
ui::EventTimeStampToSeconds(ui::EventTimeForNow()));
- result.globalX = global_x;
- result.globalY = global_y;
- result.x = x;
- result.y = y;
- result.deltaX = dx;
- result.deltaY = dy;
+ result.SetPositionInScreen(global_x, global_y);
+ result.SetPositionInWidget(x, y);
+ result.delta_x = dx;
+ result.delta_y = dy;
if (dx)
- result.wheelTicksX = dx > 0.0f ? 1.0f : -1.0f;
+ result.wheel_ticks_x = dx > 0.0f ? 1.0f : -1.0f;
if (dy)
- result.wheelTicksY = dy > 0.0f ? 1.0f : -1.0f;
- result.hasPreciseScrollingDeltas = precise;
+ result.wheel_ticks_y = dy > 0.0f ? 1.0f : -1.0f;
+ result.has_precise_scrolling_deltas = precise;
return result;
}
WebKeyboardEvent SyntheticWebKeyboardEventBuilder::Build(
WebInputEvent::Type type) {
- DCHECK(WebInputEvent::isKeyboardEventType(type));
- WebKeyboardEvent result(type, WebInputEvent::NoModifiers,
+ DCHECK(WebInputEvent::IsKeyboardEventType(type));
+ WebKeyboardEvent result(type, WebInputEvent::kNoModifiers,
ui::EventTimeStampToSeconds(ui::EventTimeForNow()));
- result.windowsKeyCode = ui::VKEY_L; // non-null made up value.
+ result.windows_key_code = ui::VKEY_L; // non-null made up value.
return result;
}
@@ -100,14 +95,14 @@ WebGestureEvent SyntheticWebGestureEventBuilder::Build(
WebInputEvent::Type type,
blink::WebGestureDevice source_device,
int modifiers) {
- DCHECK(WebInputEvent::isGestureEventType(type));
+ DCHECK(WebInputEvent::IsGestureEventType(type));
WebGestureEvent result(type, modifiers,
ui::EventTimeStampToSeconds(ui::EventTimeForNow()));
- result.sourceDevice = source_device;
- if (type == WebInputEvent::GestureTap ||
- type == WebInputEvent::GestureTapUnconfirmed ||
- type == WebInputEvent::GestureDoubleTap) {
- result.data.tap.tapCount = 1;
+ result.source_device = source_device;
+ if (type == WebInputEvent::kGestureTap ||
+ type == WebInputEvent::kGestureTapUnconfirmed ||
+ type == WebInputEvent::kGestureDoubleTap) {
+ result.data.tap.tap_count = 1;
result.data.tap.width = 10;
result.data.tap.height = 10;
}
@@ -117,11 +112,13 @@ WebGestureEvent SyntheticWebGestureEventBuilder::Build(
WebGestureEvent SyntheticWebGestureEventBuilder::BuildScrollBegin(
float dx_hint,
float dy_hint,
- blink::WebGestureDevice source_device) {
+ blink::WebGestureDevice source_device,
+ int pointer_count) {
WebGestureEvent result =
- Build(WebInputEvent::GestureScrollBegin, source_device);
- result.data.scrollBegin.deltaXHint = dx_hint;
- result.data.scrollBegin.deltaYHint = dy_hint;
+ Build(WebInputEvent::kGestureScrollBegin, source_device);
+ result.data.scroll_begin.delta_x_hint = dx_hint;
+ result.data.scroll_begin.delta_y_hint = dy_hint;
+ result.data.scroll_begin.pointer_count = pointer_count;
return result;
}
@@ -131,9 +128,9 @@ WebGestureEvent SyntheticWebGestureEventBuilder::BuildScrollUpdate(
int modifiers,
blink::WebGestureDevice source_device) {
WebGestureEvent result =
- Build(WebInputEvent::GestureScrollUpdate, source_device, modifiers);
- result.data.scrollUpdate.deltaX = dx;
- result.data.scrollUpdate.deltaY = dy;
+ Build(WebInputEvent::kGestureScrollUpdate, source_device, modifiers);
+ result.data.scroll_update.delta_x = dx;
+ result.data.scroll_update.delta_y = dy;
return result;
}
@@ -144,12 +141,12 @@ WebGestureEvent SyntheticWebGestureEventBuilder::BuildPinchUpdate(
int modifiers,
blink::WebGestureDevice source_device) {
WebGestureEvent result =
- Build(WebInputEvent::GesturePinchUpdate, source_device, modifiers);
- result.data.pinchUpdate.scale = scale;
+ Build(WebInputEvent::kGesturePinchUpdate, source_device, modifiers);
+ result.data.pinch_update.scale = scale;
result.x = anchor_x;
result.y = anchor_y;
- result.globalX = anchor_x;
- result.globalY = anchor_y;
+ result.global_x = anchor_x;
+ result.global_y = anchor_y;
return result;
}
@@ -157,40 +154,40 @@ WebGestureEvent SyntheticWebGestureEventBuilder::BuildFling(
float velocity_x,
float velocity_y,
blink::WebGestureDevice source_device) {
- WebGestureEvent result = Build(WebInputEvent::GestureFlingStart,
- source_device);
- result.data.flingStart.velocityX = velocity_x;
- result.data.flingStart.velocityY = velocity_y;
+ WebGestureEvent result =
+ Build(WebInputEvent::kGestureFlingStart, source_device);
+ result.data.fling_start.velocity_x = velocity_x;
+ result.data.fling_start.velocity_y = velocity_y;
return result;
}
SyntheticWebTouchEvent::SyntheticWebTouchEvent() : WebTouchEvent() {
- uniqueTouchEventId = ui::GetNextTouchEventId();
+ unique_touch_event_id = ui::GetNextTouchEventId();
SetTimestamp(ui::EventTimeForNow());
}
void SyntheticWebTouchEvent::ResetPoints() {
int activePointCount = 0;
- for (unsigned int i = 0; i < touchesLength; ++i) {
+ for (unsigned int i = 0; i < touches_length; ++i) {
switch (touches[i].state) {
- case WebTouchPoint::StatePressed:
- case WebTouchPoint::StateMoved:
- case WebTouchPoint::StateStationary:
- touches[i].state = WebTouchPoint::StateStationary;
+ case WebTouchPoint::kStatePressed:
+ case WebTouchPoint::kStateMoved:
+ case WebTouchPoint::kStateStationary:
+ touches[i].state = WebTouchPoint::kStateStationary;
++activePointCount;
break;
- case WebTouchPoint::StateReleased:
- case WebTouchPoint::StateCancelled:
+ case WebTouchPoint::kStateReleased:
+ case WebTouchPoint::kStateCancelled:
touches[i] = WebTouchPoint();
break;
- case WebTouchPoint::StateUndefined:
+ case WebTouchPoint::kStateUndefined:
break;
}
}
- touchesLength = activePointCount;
- m_type = WebInputEvent::Undefined;
- movedBeyondSlopRegion = false;
- uniqueTouchEventId = ui::GetNextTouchEventId();
+ touches_length = activePointCount;
+ type_ = WebInputEvent::kUndefined;
+ moved_beyond_slop_region = false;
+ unique_touch_event_id = ui::GetNextTouchEventId();
}
int SyntheticWebTouchEvent::PressPoint(float x, float y) {
@@ -199,15 +196,15 @@ int SyntheticWebTouchEvent::PressPoint(float x, float y) {
return -1;
WebTouchPoint& point = touches[index];
point.id = index;
- point.position.x = point.screenPosition.x = x;
- point.position.y = point.screenPosition.y = y;
- point.state = WebTouchPoint::StatePressed;
- point.radiusX = point.radiusY = 1.f;
- point.rotationAngle = 1.f;
+ point.position.x = point.screen_position.x = x;
+ point.position.y = point.screen_position.y = y;
+ point.state = WebTouchPoint::kStatePressed;
+ point.radius_x = point.radius_y = 1.f;
+ point.rotation_angle = 1.f;
point.force = 1.f;
- point.tiltX = point.tiltY = 0;
- ++touchesLength;
- WebTouchEventTraits::ResetType(WebInputEvent::TouchStart, timeStampSeconds(),
+ point.tilt_x = point.tilt_y = 0;
+ ++touches_length;
+ WebTouchEventTraits::ResetType(WebInputEvent::kTouchStart, TimeStampSeconds(),
this);
return point.id;
}
@@ -217,39 +214,39 @@ void SyntheticWebTouchEvent::MovePoint(int index, float x, float y) {
CHECK_LT(index, kTouchesLengthCap);
// Always set this bit to avoid otherwise unexpected touchmove suppression.
// The caller can opt-out explicitly, if necessary.
- movedBeyondSlopRegion = true;
+ moved_beyond_slop_region = true;
WebTouchPoint& point = touches[index];
- point.position.x = point.screenPosition.x = x;
- point.position.y = point.screenPosition.y = y;
- touches[index].state = WebTouchPoint::StateMoved;
- WebTouchEventTraits::ResetType(WebInputEvent::TouchMove, timeStampSeconds(),
+ point.position.x = point.screen_position.x = x;
+ point.position.y = point.screen_position.y = y;
+ touches[index].state = WebTouchPoint::kStateMoved;
+ WebTouchEventTraits::ResetType(WebInputEvent::kTouchMove, TimeStampSeconds(),
this);
}
void SyntheticWebTouchEvent::ReleasePoint(int index) {
CHECK_GE(index, 0);
CHECK_LT(index, kTouchesLengthCap);
- touches[index].state = WebTouchPoint::StateReleased;
+ touches[index].state = WebTouchPoint::kStateReleased;
touches[index].force = 0.f;
- WebTouchEventTraits::ResetType(WebInputEvent::TouchEnd, timeStampSeconds(),
+ WebTouchEventTraits::ResetType(WebInputEvent::kTouchEnd, TimeStampSeconds(),
this);
}
void SyntheticWebTouchEvent::CancelPoint(int index) {
CHECK_GE(index, 0);
CHECK_LT(index, kTouchesLengthCap);
- touches[index].state = WebTouchPoint::StateCancelled;
- WebTouchEventTraits::ResetType(WebInputEvent::TouchCancel, timeStampSeconds(),
- this);
+ touches[index].state = WebTouchPoint::kStateCancelled;
+ WebTouchEventTraits::ResetType(WebInputEvent::kTouchCancel,
+ TimeStampSeconds(), this);
}
void SyntheticWebTouchEvent::SetTimestamp(base::TimeTicks timestamp) {
- setTimeStampSeconds(ui::EventTimeStampToSeconds(timestamp));
+ SetTimeStampSeconds(ui::EventTimeStampToSeconds(timestamp));
}
int SyntheticWebTouchEvent::FirstFreeIndex() {
for (size_t i = 0; i < kTouchesLengthCap; ++i) {
- if (touches[i].state == WebTouchPoint::StateUndefined)
+ if (touches[i].state == WebTouchPoint::kStateUndefined)
return i;
}
return -1;
diff --git a/chromium/content/common/input/synthetic_web_input_event_builders.h b/chromium/content/common/input/synthetic_web_input_event_builders.h
index 58620d30029..782260cdba2 100644
--- a/chromium/content/common/input/synthetic_web_input_event_builders.h
+++ b/chromium/content/common/input/synthetic_web_input_event_builders.h
@@ -26,7 +26,7 @@ class CONTENT_EXPORT SyntheticWebMouseEventBuilder {
int window_y,
int modifiers,
blink::WebPointerProperties::PointerType pointer_type =
- blink::WebPointerProperties::PointerType::Mouse);
+ blink::WebPointerProperties::PointerType::kMouse);
};
class CONTENT_EXPORT SyntheticWebMouseWheelEventBuilder {
@@ -62,7 +62,8 @@ class CONTENT_EXPORT SyntheticWebGestureEventBuilder {
static blink::WebGestureEvent BuildScrollBegin(
float dx_hint,
float dy_hint,
- blink::WebGestureDevice source_device);
+ blink::WebGestureDevice source_device,
+ int pointer_count = 1);
static blink::WebGestureEvent BuildScrollUpdate(
float dx,
float dy,
diff --git a/chromium/content/common/input/touch_event_stream_validator.cc b/chromium/content/common/input/touch_event_stream_validator.cc
index 64cc80e5a00..b5e70902792 100644
--- a/chromium/content/common/input/touch_event_stream_validator.cc
+++ b/chromium/content/common/input/touch_event_stream_validator.cc
@@ -19,7 +19,7 @@ namespace content {
namespace {
const WebTouchPoint* FindTouchPoint(const WebTouchEvent& event, int id) {
- for (unsigned i = 0; i < event.touchesLength; ++i) {
+ for (unsigned i = 0; i < event.touches_length; ++i) {
if (event.touches[i].id == id)
return &event.touches[i];
}
@@ -28,7 +28,7 @@ const WebTouchPoint* FindTouchPoint(const WebTouchEvent& event, int id) {
std::string TouchPointIdsToString(const WebTouchEvent& event) {
std::stringstream ss;
- for (unsigned i = 0; i < event.touchesLength; ++i) {
+ for (unsigned i = 0; i < event.touches_length; ++i) {
if (i)
ss << ",";
ss << event.touches[i].id;
@@ -50,20 +50,20 @@ bool TouchEventStreamValidator::Validate(const WebTouchEvent& event,
error_msg->clear();
// TouchScrollStarted is not part of a regular touch event stream.
- if (event.type() == WebInputEvent::TouchScrollStarted)
+ if (event.GetType() == WebInputEvent::kTouchScrollStarted)
return true;
WebTouchEvent previous_event = previous_event_;
previous_event_ = event;
- if (!event.touchesLength) {
+ if (!event.touches_length) {
error_msg->append("Touch event is empty.\n");
return false;
}
- if (!WebInputEvent::isTouchEventType(event.type())) {
+ if (!WebInputEvent::IsTouchEventType(event.GetType())) {
error_msg->append(StringPrintf("Touch event has invalid type: %s\n",
- WebInputEvent::GetName(event.type())));
+ WebInputEvent::GetName(event.GetType())));
}
// Allow "hard" restarting of touch stream validation. This is necessary
@@ -73,10 +73,10 @@ bool TouchEventStreamValidator::Validate(const WebTouchEvent& event,
previous_event = WebTouchEvent();
// Unreleased points from the previous event should exist in the latest event.
- for (unsigned i = 0; i < previous_event.touchesLength; ++i) {
+ for (unsigned i = 0; i < previous_event.touches_length; ++i) {
const WebTouchPoint& previous_point = previous_event.touches[i];
- if (previous_point.state == WebTouchPoint::StateCancelled ||
- previous_point.state == WebTouchPoint::StateReleased)
+ if (previous_point.state == WebTouchPoint::kStateCancelled ||
+ previous_point.state == WebTouchPoint::kStateReleased)
continue;
const WebTouchPoint* point = FindTouchPoint(event, previous_point.id);
@@ -88,21 +88,21 @@ bool TouchEventStreamValidator::Validate(const WebTouchEvent& event,
}
bool found_valid_state_for_type = false;
- for (unsigned i = 0; i < event.touchesLength; ++i) {
+ for (unsigned i = 0; i < event.touches_length; ++i) {
const WebTouchPoint& point = event.touches[i];
const WebTouchPoint* previous_point =
FindTouchPoint(previous_event, point.id);
// The point should exist in the previous event if it is not a new point.
if (!previous_point) {
- if (point.state != WebTouchPoint::StatePressed)
+ if (point.state != WebTouchPoint::kStatePressed)
error_msg->append(StringPrintf(
"Active touch point (id=%d) not in previous event (ids=%s).\n",
point.id, TouchPointIdsToString(previous_event).c_str()));
} else {
- if (point.state == WebTouchPoint::StatePressed &&
- previous_point->state != WebTouchPoint::StateCancelled &&
- previous_point->state != WebTouchPoint::StateReleased) {
+ if (point.state == WebTouchPoint::kStatePressed &&
+ previous_point->state != WebTouchPoint::kStateCancelled &&
+ previous_point->state != WebTouchPoint::kStateReleased) {
error_msg->append(StringPrintf(
"Pressed touch point (id=%d) already exists in previous event "
"(ids=%s).\n",
@@ -111,13 +111,13 @@ bool TouchEventStreamValidator::Validate(const WebTouchEvent& event,
}
switch (point.state) {
- case WebTouchPoint::StateUndefined:
+ case WebTouchPoint::kStateUndefined:
error_msg->append(
StringPrintf("Undefined touch point state (id=%d).\n", point.id));
break;
- case WebTouchPoint::StateReleased:
- if (event.type() != WebInputEvent::TouchEnd) {
+ case WebTouchPoint::kStateReleased:
+ if (event.GetType() != WebInputEvent::kTouchEnd) {
error_msg->append(StringPrintf(
"Released touch point (id=%d) outside touchend.\n", point.id));
} else {
@@ -125,8 +125,8 @@ bool TouchEventStreamValidator::Validate(const WebTouchEvent& event,
}
break;
- case WebTouchPoint::StatePressed:
- if (event.type() != WebInputEvent::TouchStart) {
+ case WebTouchPoint::kStatePressed:
+ if (event.GetType() != WebInputEvent::kTouchStart) {
error_msg->append(StringPrintf(
"Pressed touch point (id=%d) outside touchstart.\n", point.id));
} else {
@@ -134,8 +134,8 @@ bool TouchEventStreamValidator::Validate(const WebTouchEvent& event,
}
break;
- case WebTouchPoint::StateMoved:
- if (event.type() != WebInputEvent::TouchMove) {
+ case WebTouchPoint::kStateMoved:
+ if (event.GetType() != WebInputEvent::kTouchMove) {
error_msg->append(StringPrintf(
"Moved touch point (id=%d) outside touchmove.\n", point.id));
} else {
@@ -143,11 +143,11 @@ bool TouchEventStreamValidator::Validate(const WebTouchEvent& event,
}
break;
- case WebTouchPoint::StateStationary:
+ case WebTouchPoint::kStateStationary:
break;
- case WebTouchPoint::StateCancelled:
- if (event.type() != WebInputEvent::TouchCancel) {
+ case WebTouchPoint::kStateCancelled:
+ if (event.GetType() != WebInputEvent::kTouchCancel) {
error_msg->append(StringPrintf(
"Cancelled touch point (id=%d) outside touchcancel.\n",
point.id));
@@ -161,7 +161,7 @@ bool TouchEventStreamValidator::Validate(const WebTouchEvent& event,
if (!found_valid_state_for_type) {
error_msg->append(
StringPrintf("No valid touch point corresponding to event type: %s\n",
- WebInputEvent::GetName(event.type())));
+ WebInputEvent::GetName(event.GetType())));
}
return error_msg->empty();
diff --git a/chromium/content/common/input/touch_event_stream_validator_unittest.cc b/chromium/content/common/input/touch_event_stream_validator_unittest.cc
index 0384dc99fb7..e031f615eaf 100644
--- a/chromium/content/common/input/touch_event_stream_validator_unittest.cc
+++ b/chromium/content/common/input/touch_event_stream_validator_unittest.cc
@@ -122,13 +122,13 @@ TEST(TouchEventStreamValidator, EmptyEvent) {
TEST(TouchEventStreamValidator, InvalidEventType) {
TouchEventStreamValidator validator;
- WebTouchEvent event(WebInputEvent::GestureScrollBegin,
- WebInputEvent::NoModifiers,
- WebInputEvent::TimeStampForTesting);
+ WebTouchEvent event(WebInputEvent::kGestureScrollBegin,
+ WebInputEvent::kNoModifiers,
+ WebInputEvent::kTimeStampForTesting);
std::string error_msg;
- event.touchesLength = 1;
- event.touches[0].state = WebTouchPoint::StatePressed;
+ event.touches_length = 1;
+ event.touches[0].state = WebTouchPoint::kStatePressed;
EXPECT_FALSE(validator.Validate(event, &error_msg));
EXPECT_FALSE(error_msg.empty());
@@ -139,13 +139,13 @@ TEST(TouchEventStreamValidator, InvalidPointStates) {
std::string error_msg;
WebInputEvent::Type kTouchTypes[4] = {
- WebInputEvent::TouchStart, WebInputEvent::TouchMove,
- WebInputEvent::TouchEnd, WebInputEvent::TouchCancel,
+ WebInputEvent::kTouchStart, WebInputEvent::kTouchMove,
+ WebInputEvent::kTouchEnd, WebInputEvent::kTouchCancel,
};
WebTouchPoint::State kValidTouchPointStatesForType[4] = {
- WebTouchPoint::StatePressed, WebTouchPoint::StateMoved,
- WebTouchPoint::StateReleased, WebTouchPoint::StateCancelled,
+ WebTouchPoint::kStatePressed, WebTouchPoint::kStateMoved,
+ WebTouchPoint::kStateReleased, WebTouchPoint::kStateCancelled,
};
SyntheticWebTouchEvent start;
@@ -155,12 +155,11 @@ TEST(TouchEventStreamValidator, InvalidPointStates) {
EXPECT_TRUE(validator.Validate(start, &error_msg));
EXPECT_TRUE(error_msg.empty());
- WebTouchEvent event(kTouchTypes[i], WebInputEvent::NoModifiers,
- WebInputEvent::TimeStampForTesting);
- event.touchesLength = 1;
- for (size_t j = WebTouchPoint::StateUndefined;
- j <= WebTouchPoint::StateCancelled;
- ++j) {
+ WebTouchEvent event(kTouchTypes[i], WebInputEvent::kNoModifiers,
+ WebInputEvent::kTimeStampForTesting);
+ event.touches_length = 1;
+ for (size_t j = WebTouchPoint::kStateUndefined;
+ j <= WebTouchPoint::kStateCancelled; ++j) {
event.touches[0].state = static_cast<WebTouchPoint::State>(j);
if (event.touches[0].state == kValidTouchPointStatesForType[i]) {
EXPECT_TRUE(validator.Validate(event, &error_msg));
diff --git a/chromium/content/common/input/web_input_event_queue.h b/chromium/content/common/input/web_input_event_queue.h
deleted file mode 100644
index 59a4d9a9c42..00000000000
--- a/chromium/content/common/input/web_input_event_queue.h
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_COMMON_INPUT_WEB_INPUT_EVENT_QUEUE_H_
-#define CONTENT_COMMON_INPUT_WEB_INPUT_EVENT_QUEUE_H_
-
-#include <deque>
-#include <memory>
-
-namespace content {
-
-// WebInputEventQueue is a coalescing queue. It will examine
-// the current events in the queue and will attempt to coalesce with
-// the last event of the same class type.
-template <typename T>
-class WebInputEventQueue {
- public:
- WebInputEventQueue() {}
-
- // Adds an event to the queue. The event may be coalesced with previously
- // queued events.
- void Queue(std::unique_ptr<T> event) {
- for (auto last_event_iter = queue_.rbegin();
- last_event_iter != queue_.rend(); ++last_event_iter) {
- if (!(*last_event_iter)->event().isSameEventClass(event->event())) {
- continue;
- }
-
- if ((*last_event_iter)->CanCoalesceWith(*event.get())) {
- (*last_event_iter)->CoalesceWith(*event.get());
- return;
- }
- break;
- }
- queue_.emplace_back(std::move(event));
- }
-
- const std::unique_ptr<T>& front() const { return queue_.front(); }
- const std::unique_ptr<T>& at(size_t pos) const { return queue_.at(pos); }
-
- std::unique_ptr<T> Pop() {
- std::unique_ptr<T> result;
- if (!queue_.empty()) {
- result.reset(queue_.front().release());
- queue_.pop_front();
- }
- return result;
- }
-
- bool empty() const { return queue_.empty(); }
-
- size_t size() const { return queue_.size(); }
-
- private:
- typedef std::deque<std::unique_ptr<T>> EventQueue;
- EventQueue queue_;
-
- DISALLOW_COPY_AND_ASSIGN(WebInputEventQueue);
-};
-
-} // namespace content
-
-#endif // CONTENT_COMMON_INPUT_WEB_INPUT_EVENT_QUEUE_H_
diff --git a/chromium/content/common/input/web_touch_event_traits.cc b/chromium/content/common/input/web_touch_event_traits.cc
index 81da13690f5..e041b2042c5 100644
--- a/chromium/content/common/input/web_touch_event_traits.cc
+++ b/chromium/content/common/input/web_touch_event_traits.cc
@@ -18,9 +18,9 @@ namespace content {
bool WebTouchEventTraits::AllTouchPointsHaveState(
const WebTouchEvent& event,
blink::WebTouchPoint::State state) {
- if (!event.touchesLength)
+ if (!event.touches_length)
return false;
- for (size_t i = 0; i < event.touchesLength; ++i) {
+ for (size_t i = 0; i < event.touches_length; ++i) {
if (event.touches[i].state != state)
return false;
}
@@ -28,22 +28,22 @@ bool WebTouchEventTraits::AllTouchPointsHaveState(
}
bool WebTouchEventTraits::IsTouchSequenceStart(const WebTouchEvent& event) {
- DCHECK(event.touchesLength ||
- event.type() == WebInputEvent::TouchScrollStarted);
- if (event.type() != WebInputEvent::TouchStart)
+ DCHECK(event.touches_length ||
+ event.GetType() == WebInputEvent::kTouchScrollStarted);
+ if (event.GetType() != WebInputEvent::kTouchStart)
return false;
- return AllTouchPointsHaveState(event, blink::WebTouchPoint::StatePressed);
+ return AllTouchPointsHaveState(event, blink::WebTouchPoint::kStatePressed);
}
bool WebTouchEventTraits::IsTouchSequenceEnd(const WebTouchEvent& event) {
- if (event.type() != WebInputEvent::TouchEnd &&
- event.type() != WebInputEvent::TouchCancel)
+ if (event.GetType() != WebInputEvent::kTouchEnd &&
+ event.GetType() != WebInputEvent::kTouchCancel)
return false;
- if (!event.touchesLength)
+ if (!event.touches_length)
return true;
- for (size_t i = 0; i < event.touchesLength; ++i) {
- if (event.touches[i].state != blink::WebTouchPoint::StateReleased &&
- event.touches[i].state != blink::WebTouchPoint::StateCancelled)
+ for (size_t i = 0; i < event.touches_length; ++i) {
+ if (event.touches[i].state != blink::WebTouchPoint::kStateReleased &&
+ event.touches[i].state != blink::WebTouchPoint::kStateCancelled)
return false;
}
return true;
@@ -52,14 +52,14 @@ bool WebTouchEventTraits::IsTouchSequenceEnd(const WebTouchEvent& event) {
void WebTouchEventTraits::ResetType(WebInputEvent::Type type,
double timestamp_sec,
WebTouchEvent* event) {
- DCHECK(WebInputEvent::isTouchEventType(type));
- DCHECK(type != WebInputEvent::TouchScrollStarted);
+ DCHECK(WebInputEvent::IsTouchEventType(type));
+ DCHECK(type != WebInputEvent::kTouchScrollStarted);
- event->setType(type);
- event->dispatchType = type == WebInputEvent::TouchCancel
- ? WebInputEvent::EventNonBlocking
- : WebInputEvent::Blocking;
- event->setTimeStampSeconds(timestamp_sec);
+ event->SetType(type);
+ event->dispatch_type = type == WebInputEvent::kTouchCancel
+ ? WebInputEvent::kEventNonBlocking
+ : WebInputEvent::kBlocking;
+ event->SetTimeStampSeconds(timestamp_sec);
}
void WebTouchEventTraits::ResetTypeAndTouchStates(WebInputEvent::Type type,
@@ -67,25 +67,25 @@ void WebTouchEventTraits::ResetTypeAndTouchStates(WebInputEvent::Type type,
WebTouchEvent* event) {
ResetType(type, timestamp_sec, event);
- WebTouchPoint::State newState = WebTouchPoint::StateUndefined;
- switch (event->type()) {
- case WebInputEvent::TouchStart:
- newState = WebTouchPoint::StatePressed;
+ WebTouchPoint::State newState = WebTouchPoint::kStateUndefined;
+ switch (event->GetType()) {
+ case WebInputEvent::kTouchStart:
+ newState = WebTouchPoint::kStatePressed;
break;
- case WebInputEvent::TouchMove:
- newState = WebTouchPoint::StateMoved;
+ case WebInputEvent::kTouchMove:
+ newState = WebTouchPoint::kStateMoved;
break;
- case WebInputEvent::TouchEnd:
- newState = WebTouchPoint::StateReleased;
+ case WebInputEvent::kTouchEnd:
+ newState = WebTouchPoint::kStateReleased;
break;
- case WebInputEvent::TouchCancel:
- newState = WebTouchPoint::StateCancelled;
+ case WebInputEvent::kTouchCancel:
+ newState = WebTouchPoint::kStateCancelled;
break;
default:
NOTREACHED();
break;
}
- for (size_t i = 0; i < event->touchesLength; ++i)
+ for (size_t i = 0; i < event->touches_length; ++i)
event->touches[i].state = newState;
}
diff --git a/chromium/content/common/input_messages.h b/chromium/content/common/input_messages.h
index 62b876eb791..3f942c2b292 100644
--- a/chromium/content/common/input_messages.h
+++ b/chromium/content/common/input_messages.h
@@ -29,13 +29,13 @@
#include "ipc/ipc_message_macros.h"
#include "third_party/WebKit/public/platform/WebInputEvent.h"
#include "ui/events/blink/did_overscroll_params.h"
-#include "ui/events/ipc/latency_info_param_traits.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/vector2d_f.h"
#include "ui/gfx/ipc/gfx_param_traits.h"
#include "ui/gfx/ipc/skia/gfx_skia_param_traits.h"
#include "ui/gfx/range/range.h"
+#include "ui/latency/ipc/latency_info_param_traits.h"
#undef IPC_MESSAGE_EXPORT
#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
@@ -289,10 +289,15 @@ IPC_MESSAGE_ROUTED1(InputMsg_MoveCaret,
IPC_MESSAGE_ROUTED0(InputMsg_RequestTextInputStateUpdate)
#endif
-// Request from browser to update the cursor and composition information.
-IPC_MESSAGE_ROUTED2(InputMsg_RequestCompositionUpdate,
- bool /* immediate request */,
- bool /* monitor request */)
+// Request from browser to update the cursor and composition information which
+// will be sent through InputHostMsg_ImeCompositionRangeChanged. Setting
+// |immediate_request| to true will lead to an immediate update. If
+// |monitor_updates| is set to true then changes to text selection or regular
+// updates in each compositor frame (when there is a change in composition info)
+// will lead to updates being sent to the browser.
+IPC_MESSAGE_ROUTED2(InputMsg_RequestCompositionUpdates,
+ bool /* immediate_request */,
+ bool /* monitor_updates */)
IPC_MESSAGE_ROUTED0(InputMsg_SyntheticGestureCompleted)
diff --git a/chromium/content/common/manifest_manager_messages.h b/chromium/content/common/manifest_manager_messages.h
index ba067740d71..532fd82473b 100644
--- a/chromium/content/common/manifest_manager_messages.h
+++ b/chromium/content/common/manifest_manager_messages.h
@@ -8,12 +8,16 @@
#include "content/common/content_export.h"
#include "content/public/common/manifest.h"
#include "ipc/ipc_message_macros.h"
+#include "third_party/WebKit/public/platform/modules/screen_orientation/WebScreenOrientationLockType.h"
#undef IPC_MESSAGE_EXPORT
#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
#define IPC_MESSAGE_START ManifestManagerMsgStart
+IPC_ENUM_TRAITS_MIN_MAX_VALUE(blink::WebScreenOrientationLockType,
+ blink::kWebScreenOrientationLockDefault,
+ blink::kWebScreenOrientationLockNatural)
IPC_ENUM_TRAITS_MAX_VALUE(
content::Manifest::Icon::IconPurpose,
content::Manifest::Icon::IconPurpose::ICON_PURPOSE_LAST)
diff --git a/chromium/content/common/manifest_util_unittest.cc b/chromium/content/common/manifest_util_unittest.cc
index b4f1a0c5919..a8fca044581 100644
--- a/chromium/content/common/manifest_util_unittest.cc
+++ b/chromium/content/common/manifest_util_unittest.cc
@@ -13,11 +13,11 @@ TEST(ManifestUtilTest, WebDisplayModeConversions) {
blink::WebDisplayMode display_mode;
std::string lowercase_display_mode_string;
} reversible_conversions[] = {
- {blink::WebDisplayModeUndefined, ""},
- {blink::WebDisplayModeBrowser, "browser"},
- {blink::WebDisplayModeMinimalUi, "minimal-ui"},
- {blink::WebDisplayModeStandalone, "standalone"},
- {blink::WebDisplayModeFullscreen, "fullscreen"},
+ {blink::kWebDisplayModeUndefined, ""},
+ {blink::kWebDisplayModeBrowser, "browser"},
+ {blink::kWebDisplayModeMinimalUi, "minimal-ui"},
+ {blink::kWebDisplayModeStandalone, "standalone"},
+ {blink::kWebDisplayModeFullscreen, "fullscreen"},
};
for (const ReversibleConversion& conversion : reversible_conversions) {
@@ -29,12 +29,12 @@ TEST(ManifestUtilTest, WebDisplayModeConversions) {
}
// WebDisplayModeFromString() should work with non-lowercase strings.
- EXPECT_EQ(blink::WebDisplayModeFullscreen,
+ EXPECT_EQ(blink::kWebDisplayModeFullscreen,
WebDisplayModeFromString("Fullscreen"));
// WebDisplayModeFromString() should return
// blink::WebDisplayModeUndefined if the string isn't known.
- EXPECT_EQ(blink::WebDisplayModeUndefined,
+ EXPECT_EQ(blink::kWebDisplayModeUndefined,
WebDisplayModeFromString("random"));
}
@@ -43,16 +43,16 @@ TEST(ManifestUtilTest, WebScreenOrientationLockTypeConversions) {
blink::WebScreenOrientationLockType orientation;
std::string lowercase_orientation_string;
} reversible_conversions[] = {
- {blink::WebScreenOrientationLockDefault, ""},
- {blink::WebScreenOrientationLockPortraitPrimary, "portrait-primary"},
- {blink::WebScreenOrientationLockPortraitSecondary, "portrait-secondary"},
- {blink::WebScreenOrientationLockLandscapePrimary, "landscape-primary"},
- {blink::WebScreenOrientationLockLandscapeSecondary,
+ {blink::kWebScreenOrientationLockDefault, ""},
+ {blink::kWebScreenOrientationLockPortraitPrimary, "portrait-primary"},
+ {blink::kWebScreenOrientationLockPortraitSecondary, "portrait-secondary"},
+ {blink::kWebScreenOrientationLockLandscapePrimary, "landscape-primary"},
+ {blink::kWebScreenOrientationLockLandscapeSecondary,
"landscape-secondary"},
- {blink::WebScreenOrientationLockAny, "any"},
- {blink::WebScreenOrientationLockLandscape, "landscape"},
- {blink::WebScreenOrientationLockPortrait, "portrait"},
- {blink::WebScreenOrientationLockNatural, "natural"},
+ {blink::kWebScreenOrientationLockAny, "any"},
+ {blink::kWebScreenOrientationLockLandscape, "landscape"},
+ {blink::kWebScreenOrientationLockPortrait, "portrait"},
+ {blink::kWebScreenOrientationLockNatural, "natural"},
};
for (const ReversibleConversion& conversion : reversible_conversions) {
@@ -65,12 +65,12 @@ TEST(ManifestUtilTest, WebScreenOrientationLockTypeConversions) {
// WebScreenOrientationLockTypeFromString() should work with non-lowercase
// strings.
- EXPECT_EQ(blink::WebScreenOrientationLockNatural,
+ EXPECT_EQ(blink::kWebScreenOrientationLockNatural,
WebScreenOrientationLockTypeFromString("Natural"));
// WebScreenOrientationLockTypeFromString() should return
// blink::WebScreenOrientationLockDefault if the string isn't known.
- EXPECT_EQ(blink::WebScreenOrientationLockDefault,
+ EXPECT_EQ(blink::kWebScreenOrientationLockDefault,
WebScreenOrientationLockTypeFromString("random"));
}
diff --git a/chromium/content/common/media/aec_dump_messages.h b/chromium/content/common/media/aec_dump_messages.h
index 0f98f272334..33e727d2dab 100644
--- a/chromium/content/common/media/aec_dump_messages.h
+++ b/chromium/content/common/media/aec_dump_messages.h
@@ -34,3 +34,8 @@ IPC_MESSAGE_CONTROL1(AecDumpMsg_RegisterAecDumpConsumer,
// Unregisters a consumer with the browser.
IPC_MESSAGE_CONTROL1(AecDumpMsg_UnregisterAecDumpConsumer,
int /* id */)
+
+// TODO(hlundin): Rename file to reflect expanded use; http://crbug.com/709919.
+IPC_MESSAGE_CONTROL2(AudioProcessingMsg_EnableAec3,
+ int /* id */,
+ bool /* enable */)
diff --git a/chromium/content/common/media/audio_messages.h b/chromium/content/common/media/audio_messages.h
index aed29734983..773b16c8218 100644
--- a/chromium/content/common/media/audio_messages.h
+++ b/chromium/content/common/media/audio_messages.h
@@ -16,6 +16,7 @@
#include "media/audio/audio_input_ipc.h"
#include "media/audio/audio_output_ipc.h"
#include "media/base/ipc/media_param_traits.h"
+#include "media/base/ipc/media_param_traits_macros.h"
#include "media/gpu/ipc/common/media_param_traits.h"
#include "url/origin.h"
@@ -23,9 +24,6 @@
#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
#define IPC_MESSAGE_START AudioMsgStart
-IPC_ENUM_TRAITS_MAX_VALUE(media::OutputDeviceStatus,
- media::OUTPUT_DEVICE_STATUS_MAX)
-
IPC_STRUCT_BEGIN(AudioInputHostMsg_CreateStream_Config)
IPC_STRUCT_MEMBER(media::AudioParameters, params)
IPC_STRUCT_MEMBER(bool, automatic_gain_control)
diff --git a/chromium/content/common/media/cdm_host_file.cc b/chromium/content/common/media/cdm_host_file.cc
index 99d5cca24a8..ff023839cea 100644
--- a/chromium/content/common/media/cdm_host_file.cc
+++ b/chromium/content/common/media/cdm_host_file.cc
@@ -10,41 +10,25 @@
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
-#include "media/base/media_switches.h"
#include "media/cdm/api/content_decryption_module_ext.h"
namespace content {
-namespace {
-
-bool IgnoreMissingCdmHostFile() {
- return base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kIgnoreMissingCdmHostFile);
-}
-
-} // namespace
-
// static
std::unique_ptr<CdmHostFile> CdmHostFile::Create(
const base::FilePath& file_path,
const base::FilePath& sig_file_path) {
+ DVLOG(1) << __func__;
+
// Open file at |file_path|.
base::File file(file_path, base::File::FLAG_OPEN | base::File::FLAG_READ);
- if (!file.IsValid()) {
- DVLOG(1) << "Failed to open file at " << file_path.MaybeAsASCII();
- return nullptr;
- }
+ DVLOG(1) << " " << file.IsValid() << ": " << file_path.MaybeAsASCII();
// Also open the sig file at |sig_file_path|.
base::File sig_file(sig_file_path,
base::File::FLAG_OPEN | base::File::FLAG_READ);
- if (!sig_file.IsValid()) {
- DVLOG(1) << "Failed to open sig file at " << sig_file_path.MaybeAsASCII();
- if (!IgnoreMissingCdmHostFile())
- return nullptr;
-
- DVLOG(1) << "Ignoring sig file failure at " << sig_file_path.MaybeAsASCII();
- }
+ DVLOG(1) << " " << sig_file.IsValid() << ": "
+ << sig_file_path.MaybeAsASCII();
return std::unique_ptr<CdmHostFile>(
new CdmHostFile(file_path, std::move(file), std::move(sig_file)));
@@ -61,12 +45,7 @@ CdmHostFile::CdmHostFile(const base::FilePath& file_path,
: file_path_(file_path),
file_(std::move(file)),
sig_file_(std::move(sig_file)) {
- DVLOG(1) << __func__ << ": " << file_path_.value();
- DCHECK(!file_path_.empty()) << "File path is empty.";
- DCHECK(file_.IsValid()) << "Invalid file.";
-
- if (!IgnoreMissingCdmHostFile())
- DCHECK(sig_file_.IsValid()) << "Invalid signature file.";
+ DCHECK(!file_path_.empty());
}
} // namespace content
diff --git a/chromium/content/common/media/cdm_host_files.cc b/chromium/content/common/media/cdm_host_files.cc
index 637891e8166..0315117699f 100644
--- a/chromium/content/common/media/cdm_host_files.cc
+++ b/chromium/content/common/media/cdm_host_files.cc
@@ -21,7 +21,6 @@
#include "content/common/media/cdm_host_file.h"
#include "content/public/common/cdm_info.h"
#include "content/public/common/content_client.h"
-#include "media/base/media_switches.h"
#include "media/cdm/api/content_decryption_module_ext.h"
#include "media/cdm/cdm_paths.h"
@@ -36,11 +35,6 @@ namespace content {
namespace {
-bool IgnoreMissingCdmHostFile() {
- return base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kIgnoreMissingCdmHostFile);
-}
-
// TODO(xhwang): Move this to a common place if needed.
const base::FilePath::CharType kSignatureFileExtension[] =
FILE_PATH_LITERAL(".sig");
@@ -98,8 +92,8 @@ void GetRegisteredCdms(std::vector<base::FilePath>* cdm_adapter_paths) {
// A global instance used on platforms where we have to open the files in the
// Zygote process.
-base::LazyInstance<std::unique_ptr<CdmHostFiles>> g_cdm_host_files =
- LAZY_INSTANCE_INITIALIZER;
+base::LazyInstance<std::unique_ptr<CdmHostFiles>>::DestructorAtExit
+ g_cdm_host_files = LAZY_INSTANCE_INITIALIZER;
#endif
} // namespace
@@ -120,12 +114,7 @@ void CdmHostFiles::CreateGlobalInstance() {
std::unique_ptr<CdmHostFiles> cdm_host_files =
base::MakeUnique<CdmHostFiles>();
- if (!cdm_host_files->OpenFilesForAllRegisteredCdms()) {
- DVLOG(1) << __func__ << " failed.";
- cdm_host_files.reset();
- return;
- }
-
+ cdm_host_files->OpenFilesForAllRegisteredCdms();
g_cdm_host_files.Get().reset(cdm_host_files.release());
}
@@ -141,11 +130,7 @@ std::unique_ptr<CdmHostFiles> CdmHostFiles::Create(
DVLOG(1) << __func__;
std::unique_ptr<CdmHostFiles> cdm_host_files =
base::MakeUnique<CdmHostFiles>();
- if (!cdm_host_files->OpenFiles(cdm_adapter_path)) {
- cdm_host_files.reset();
- return nullptr;
- }
-
+ cdm_host_files->OpenFiles(cdm_adapter_path);
return cdm_host_files;
}
@@ -193,17 +178,24 @@ bool CdmHostFiles::VerifyFiles(base::NativeLibrary cdm_adapter_library,
// Fills |cdm_host_files| with common and CDM specific files for
// |cdm_adapter_path|.
std::vector<cdm::HostFile> cdm_host_files;
- if (!TakePlatformFiles(cdm_adapter_path, &cdm_host_files)) {
- DVLOG(1) << "Failed to take platform files.";
- CloseAllFiles();
- return true;
- }
+ TakePlatformFiles(cdm_adapter_path, &cdm_host_files);
+
+ // std::vector::data() is not guaranteed to be nullptr when empty().
+ const cdm::HostFile* cdm_host_files_ptr =
+ cdm_host_files.empty() ? nullptr : cdm_host_files.data();
// Call |verify_cdm_host_func| on the CDM with |cdm_host_files|. Note that
// the ownership of these files are transferred to the CDM, which will close
// the files immediately after use.
- DVLOG(1) << __func__ << ": Calling " << kVerifyCdmHostFuncName << "().";
- if (!verify_cdm_host_func(cdm_host_files.data(), cdm_host_files.size())) {
+ DVLOG(1) << __func__ << ": Calling " << kVerifyCdmHostFuncName << "() with "
+ << cdm_host_files.size() << " files.";
+ for (const auto& host_file : cdm_host_files) {
+ DVLOG(1) << " - File Path: " << host_file.file_path;
+ DVLOG(1) << " - File: " << host_file.file;
+ DVLOG(1) << " - Sig File: " << host_file.sig_file;
+ }
+
+ if (!verify_cdm_host_func(cdm_host_files_ptr, cdm_host_files.size())) {
DVLOG(1) << "Failed to verify CDM host.";
CloseAllFiles();
return false;
@@ -215,39 +207,27 @@ bool CdmHostFiles::VerifyFiles(base::NativeLibrary cdm_adapter_library,
}
#if defined(POSIX_WITH_ZYGOTE)
-bool CdmHostFiles::OpenFilesForAllRegisteredCdms() {
+void CdmHostFiles::OpenFilesForAllRegisteredCdms() {
std::vector<base::FilePath> cdm_adapter_paths;
GetRegisteredCdms(&cdm_adapter_paths);
if (cdm_adapter_paths.empty()) {
DVLOG(1) << "No CDM registered.";
- return false;
- }
-
- // Ignore
- for (auto& cdm_adapter_path : cdm_adapter_paths) {
- bool result = OpenCdmFiles(cdm_adapter_path);
- if (!result)
- DVLOG(1) << "CDM files cannot be opened for " << cdm_adapter_path.value();
- // Ignore the failure and try other registered CDM.
+ return;
}
- if (cdm_specific_files_map_.empty()) {
- DVLOG(1) << "CDM specific files cannot be opened for any registered CDM.";
- return false;
- }
+ for (auto& cdm_adapter_path : cdm_adapter_paths)
+ OpenCdmFiles(cdm_adapter_path);
- return OpenCommonFiles();
+ OpenCommonFiles();
}
#endif
-bool CdmHostFiles::OpenFiles(const base::FilePath& cdm_adapter_path) {
- if (!OpenCdmFiles(cdm_adapter_path))
- return false;
-
- return OpenCommonFiles();
+void CdmHostFiles::OpenFiles(const base::FilePath& cdm_adapter_path) {
+ OpenCdmFiles(cdm_adapter_path);
+ OpenCommonFiles();
}
-bool CdmHostFiles::OpenCommonFiles() {
+void CdmHostFiles::OpenCommonFiles() {
DCHECK(common_files_.empty());
std::vector<CdmHostFilePath> cdm_host_file_paths;
@@ -255,34 +235,21 @@ bool CdmHostFiles::OpenCommonFiles() {
&cdm_host_file_paths);
for (const CdmHostFilePath& value : cdm_host_file_paths) {
- std::unique_ptr<CdmHostFile> cdm_host_file =
- CdmHostFile::Create(value.file_path, value.sig_file_path);
- if (cdm_host_file) {
- common_files_.push_back(std::move(cdm_host_file));
- continue;
- }
-
- if (!IgnoreMissingCdmHostFile())
- return false;
+ common_files_.push_back(
+ CdmHostFile::Create(value.file_path, value.sig_file_path));
}
-
- return true;
}
-bool CdmHostFiles::OpenCdmFiles(const base::FilePath& cdm_adapter_path) {
+void CdmHostFiles::OpenCdmFiles(const base::FilePath& cdm_adapter_path) {
DCHECK(!cdm_adapter_path.empty());
DCHECK(!cdm_specific_files_map_.count(cdm_adapter_path));
std::unique_ptr<CdmHostFile> cdm_adapter_file =
CdmHostFile::Create(cdm_adapter_path, GetSigFilePath(cdm_adapter_path));
- if (!cdm_adapter_file)
- return false;
base::FilePath cdm_path = GetCdmPath(cdm_adapter_path);
std::unique_ptr<CdmHostFile> cdm_file =
CdmHostFile::Create(cdm_path, GetSigFilePath(cdm_path));
- if (!cdm_file)
- return false;
ScopedFileVector cdm_specific_files;
cdm_specific_files.reserve(2);
@@ -290,38 +257,26 @@ bool CdmHostFiles::OpenCdmFiles(const base::FilePath& cdm_adapter_path) {
cdm_specific_files.push_back(std::move(cdm_file));
cdm_specific_files_map_[cdm_adapter_path] = std::move(cdm_specific_files);
- return true;
}
-bool CdmHostFiles::TakePlatformFiles(
+void CdmHostFiles::TakePlatformFiles(
const base::FilePath& cdm_adapter_path,
std::vector<cdm::HostFile>* cdm_host_files) {
DCHECK(cdm_host_files->empty());
- if (!IgnoreMissingCdmHostFile())
- DCHECK(!common_files_.empty());
+ // Populate an array of cdm::HostFile.
+ for (const auto& file : common_files_)
+ cdm_host_files->push_back(file->TakePlatformFile());
// Check whether CDM specific files exist.
const auto& iter = cdm_specific_files_map_.find(cdm_adapter_path);
if (iter == cdm_specific_files_map_.end()) {
- // This could happen on Linux where CDM files fail to open for Foo CDM, but
- // now we hit Bar CDM.
- DVLOG(1) << "No CDM specific files for " << cdm_adapter_path.value();
- return false;
+ NOTREACHED() << "No CDM specific files for " << cdm_adapter_path.value();
+ } else {
+ const ScopedFileVector& cdm_specific_files = iter->second;
+ for (const auto& file : cdm_specific_files)
+ cdm_host_files->push_back(file->TakePlatformFile());
}
-
- const ScopedFileVector& cdm_specific_files = iter->second;
-
- cdm_host_files->reserve(common_files_.size() + cdm_specific_files.size());
-
- // Populate an array of cdm::HostFile.
- for (const auto& file : common_files_)
- cdm_host_files->push_back(file->TakePlatformFile());
-
- for (const auto& file : cdm_specific_files)
- cdm_host_files->push_back(file->TakePlatformFile());
-
- return true;
}
void CdmHostFiles::CloseAllFiles() {
diff --git a/chromium/content/common/media/cdm_host_files.h b/chromium/content/common/media/cdm_host_files.h
index 5ec1dafcc83..75430d556c9 100644
--- a/chromium/content/common/media/cdm_host_files.h
+++ b/chromium/content/common/media/cdm_host_files.h
@@ -72,27 +72,23 @@ class CdmHostFiles {
private:
#if defined(POSIX_WITH_ZYGOTE)
// Opens all common files and CDM specific files for all registered CDMs.
- bool OpenFilesForAllRegisteredCdms();
+ void OpenFilesForAllRegisteredCdms();
#endif
// Opens all common files and CDM specific files for the CDM adapter
// registered at |cdm_adapter_path|.
- bool OpenFiles(const base::FilePath& cdm_adapter_path);
+ void OpenFiles(const base::FilePath& cdm_adapter_path);
- // Opens common CDM host files shared by all CDMs. Upon failure, close all
- // files opened.
- bool OpenCommonFiles();
+ // Opens common CDM host files shared by all CDMs.
+ void OpenCommonFiles();
// Opens CDM specific files for the CDM adapter registered at
- // |cdm_adapter_path|. Returns whether all CDM specific files are opened.
- // Upon failure, close all files opened.
- bool OpenCdmFiles(const base::FilePath& cdm_adapter_path);
+ // |cdm_adapter_path|.
+ void OpenCdmFiles(const base::FilePath& cdm_adapter_path);
// Fills |cdm_host_files| with common and CDM specific files for
// |cdm_adapter_path|. The ownership of those files are also transferred.
- // Returns true upon success where the remaining files will be closed.
- // Returns false upon any failure and all files will be closed.
- bool TakePlatformFiles(const base::FilePath& cdm_adapter_path,
+ void TakePlatformFiles(const base::FilePath& cdm_adapter_path,
std::vector<cdm::HostFile>* cdm_host_files);
void CloseAllFiles();
diff --git a/chromium/content/common/media/media_devices.cc b/chromium/content/common/media/media_devices.cc
index 80661916fe8..5eb8a1843be 100644
--- a/chromium/content/common/media/media_devices.cc
+++ b/chromium/content/common/media/media_devices.cc
@@ -8,7 +8,8 @@
namespace content {
-MediaDeviceInfo::MediaDeviceInfo() = default;
+MediaDeviceInfo::MediaDeviceInfo()
+ : video_facing(media::VideoFacingMode::MEDIA_VIDEO_FACING_NONE) {}
MediaDeviceInfo::MediaDeviceInfo(const MediaDeviceInfo& other) = default;
@@ -17,17 +18,23 @@ MediaDeviceInfo::MediaDeviceInfo(MediaDeviceInfo&& other) = default;
MediaDeviceInfo::MediaDeviceInfo(const std::string& device_id,
const std::string& label,
const std::string& group_id)
- : device_id(device_id), label(label), group_id(group_id) {}
+ : device_id(device_id),
+ label(label),
+ group_id(group_id),
+ video_facing(media::VideoFacingMode::MEDIA_VIDEO_FACING_NONE) {}
MediaDeviceInfo::MediaDeviceInfo(
const media::AudioDeviceDescription& device_description)
: device_id(device_description.unique_id),
label(device_description.device_name),
- group_id(device_description.group_id) {}
+ group_id(device_description.group_id),
+ video_facing(media::VideoFacingMode::MEDIA_VIDEO_FACING_NONE) {}
MediaDeviceInfo::MediaDeviceInfo(
const media::VideoCaptureDeviceDescriptor& descriptor)
- : device_id(descriptor.device_id), label(descriptor.GetNameAndModel()) {}
+ : device_id(descriptor.device_id),
+ label(descriptor.GetNameAndModel()),
+ video_facing(descriptor.facing) {}
MediaDeviceInfo::~MediaDeviceInfo() = default;
diff --git a/chromium/content/common/media/media_devices.h b/chromium/content/common/media/media_devices.h
index a7bf705cd48..c0cd354d258 100644
--- a/chromium/content/common/media/media_devices.h
+++ b/chromium/content/common/media/media_devices.h
@@ -9,6 +9,7 @@
#include <vector>
#include "content/common/content_export.h"
+#include "media/base/video_facing.h"
namespace media {
struct AudioDeviceDescription;
@@ -41,6 +42,7 @@ struct CONTENT_EXPORT MediaDeviceInfo {
std::string device_id;
std::string label;
std::string group_id;
+ media::VideoFacingMode video_facing;
};
using MediaDeviceInfoArray = std::vector<MediaDeviceInfo>;
diff --git a/chromium/content/common/media/media_player_messages_android.h b/chromium/content/common/media/media_player_messages_android.h
index d7b93e61654..713d9709532 100644
--- a/chromium/content/common/media/media_player_messages_android.h
+++ b/chromium/content/common/media/media_player_messages_android.h
@@ -22,7 +22,7 @@ IPC_ENUM_TRAITS_MAX_VALUE(MediaPlayerHostMsg_Initialize_Type,
MEDIA_PLAYER_TYPE_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebRemotePlaybackAvailability,
- blink::WebRemotePlaybackAvailability::Last)
+ blink::WebRemotePlaybackAvailability::kLast)
// Parameters to describe a media player
IPC_STRUCT_BEGIN(MediaPlayerHostMsg_Initialize_Params)
diff --git a/chromium/content/common/media/media_stream_messages.h b/chromium/content/common/media/media_stream_messages.h
index c888f8c2d37..85fdb5fda03 100644
--- a/chromium/content/common/media/media_stream_messages.h
+++ b/chromium/content/common/media/media_stream_messages.h
@@ -133,3 +133,6 @@ IPC_MESSAGE_CONTROL3(MediaStreamHostMsg_SetCapturingLinkSecured,
int, /* session_id */
content::MediaStreamType, /* type */
bool /* is_secure */)
+
+// Tell the browser process that the stream has been started successfully.
+IPC_MESSAGE_CONTROL1(MediaStreamHostMsg_StreamStarted, std::string /* label */)
diff --git a/chromium/content/common/media/renderer_audio_output_stream_factory.mojom b/chromium/content/common/media/renderer_audio_output_stream_factory.mojom
new file mode 100644
index 00000000000..d0992782fc5
--- /dev/null
+++ b/chromium/content/common/media/renderer_audio_output_stream_factory.mojom
@@ -0,0 +1,25 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module content.mojom;
+
+import "media/mojo/interfaces/audio_output_stream.mojom";
+import "media/mojo/interfaces/audio_parameters.mojom";
+import "media/mojo/interfaces/media_types.mojom";
+
+// This interface is used to create output streams. The client supplies a
+// request for a stream provider, and then supplies the desired audio
+// parameters to that to create the stream.
+interface RendererAudioOutputStreamFactory {
+ // Used to request a device. The AudioOutputStreamProviderRequest will be
+ // bound to an AudioOutputStreamProvider implementation or closed
+ // (in case of an error).
+ RequestDeviceAuthorization(
+ media.mojom.AudioOutputStreamProvider& stream_provider_request,
+ int64 session_id,
+ string device_id) =>
+ (media.mojom.OutputDeviceStatus state,
+ media.mojom.AudioParameters output_params,
+ string matched_device_id);
+};
diff --git a/chromium/content/common/media/video_capture.h b/chromium/content/common/media/video_capture.h
index 298d575a8c5..3605bafe54e 100644
--- a/chromium/content/common/media/video_capture.h
+++ b/chromium/content/common/media/video_capture.h
@@ -23,6 +23,7 @@ using VideoCaptureDeliverFrameCB =
// browser process and renderer process. Browser process sends information about
// the current capture state and error to the renderer process using this type.
enum VideoCaptureState {
+ VIDEO_CAPTURE_STATE_STARTING,
VIDEO_CAPTURE_STATE_STARTED,
VIDEO_CAPTURE_STATE_PAUSED,
VIDEO_CAPTURE_STATE_RESUMED,
diff --git a/chromium/content/common/message_port.cc b/chromium/content/common/message_port.cc
index c89d7b5a0d0..9353516a1cb 100644
--- a/chromium/content/common/message_port.cc
+++ b/chromium/content/common/message_port.cc
@@ -4,7 +4,9 @@
#include "content/common/message_port.h"
+#include "base/bind.h"
#include "base/logging.h"
+#include "base/threading/thread_task_runner_handle.h"
namespace content {
@@ -27,12 +29,12 @@ MessagePort::MessagePort(mojo::ScopedMessagePipeHandle handle)
}
const mojo::ScopedMessagePipeHandle& MessagePort::GetHandle() const {
- return state_->handle_;
+ return state_->handle();
}
mojo::ScopedMessagePipeHandle MessagePort::ReleaseHandle() const {
- state_->CancelWatch();
- return std::move(state_->handle_);
+ state_->StopWatching();
+ return state_->TakeHandle();
}
// static
@@ -46,7 +48,7 @@ std::vector<mojo::ScopedMessagePipeHandle> MessagePort::ReleaseHandles(
void MessagePort::PostMessage(const base::string16& encoded_message,
std::vector<MessagePort> ports) {
- DCHECK(state_->handle_.is_valid());
+ DCHECK(state_->handle().is_valid());
uint32_t num_bytes = encoded_message.size() * sizeof(base::char16);
@@ -54,39 +56,29 @@ void MessagePort::PostMessage(const base::string16& encoded_message,
// MessagePorts have no way of reporting when the peer is gone.
if (ports.empty()) {
- MojoWriteMessage(state_->handle_.get().value(),
- encoded_message.data(),
- num_bytes,
- nullptr,
- 0,
- MOJO_WRITE_MESSAGE_FLAG_NONE);
+ MojoWriteMessage(state_->handle().get().value(), encoded_message.data(),
+ num_bytes, nullptr, 0, MOJO_WRITE_MESSAGE_FLAG_NONE);
} else {
uint32_t num_handles = static_cast<uint32_t>(ports.size());
std::unique_ptr<MojoHandle[]> handles(new MojoHandle[num_handles]);
for (uint32_t i = 0; i < num_handles; ++i)
handles[i] = ports[i].ReleaseHandle().release().value();
- MojoWriteMessage(state_->handle_.get().value(),
- encoded_message.data(),
- num_bytes,
- handles.get(),
- num_handles,
+ MojoWriteMessage(state_->handle().get().value(), encoded_message.data(),
+ num_bytes, handles.get(), num_handles,
MOJO_WRITE_MESSAGE_FLAG_NONE);
}
}
bool MessagePort::GetMessage(base::string16* encoded_message,
std::vector<MessagePort>* ports) {
- DCHECK(state_->handle_.is_valid());
+ DCHECK(state_->handle().is_valid());
uint32_t num_bytes = 0;
uint32_t num_handles = 0;
- MojoResult rv = MojoReadMessage(state_->handle_.get().value(),
- nullptr,
- &num_bytes,
- nullptr,
- &num_handles,
- MOJO_READ_MESSAGE_FLAG_NONE);
+ MojoResult rv =
+ MojoReadMessage(state_->handle().get().value(), nullptr, &num_bytes,
+ nullptr, &num_handles, MOJO_READ_MESSAGE_FLAG_NONE);
if (rv == MOJO_RESULT_OK) {
encoded_message->clear();
ports->clear();
@@ -104,12 +96,9 @@ bool MessagePort::GetMessage(base::string16* encoded_message,
if (num_handles)
handles.reset(new MojoHandle[num_handles]);
- rv = MojoReadMessage(state_->handle_.get().value(),
- num_bytes ? &buffer[0] : nullptr,
- &num_bytes,
- handles.get(),
- &num_handles,
- MOJO_READ_MESSAGE_FLAG_NONE);
+ rv = MojoReadMessage(
+ state_->handle().get().value(), num_bytes ? &buffer[0] : nullptr,
+ &num_bytes, handles.get(), &num_handles, MOJO_READ_MESSAGE_FLAG_NONE);
if (rv != MOJO_RESULT_OK)
return false;
@@ -126,14 +115,12 @@ bool MessagePort::GetMessage(base::string16* encoded_message,
}
void MessagePort::SetCallback(const base::Closure& callback) {
- state_->CancelWatch();
- state_->callback_ = callback;
- state_->AddWatch();
+ state_->StopWatching();
+ state_->StartWatching(callback);
}
void MessagePort::ClearCallback() {
- state_->CancelWatch();
- state_->callback_.Reset();
+ state_->StopWatching();
}
MessagePort::State::State() {
@@ -143,44 +130,107 @@ MessagePort::State::State(mojo::ScopedMessagePipeHandle handle)
: handle_(std::move(handle)) {
}
-void MessagePort::State::AddWatch() {
- if (!callback_)
- return;
+void MessagePort::State::StartWatching(const base::Closure& callback) {
+ base::AutoLock lock(lock_);
+ DCHECK(!callback_);
+ DCHECK(handle_.is_valid());
+ callback_ = callback;
+
+ DCHECK(!watcher_handle_.is_valid());
+ MojoResult rv = CreateWatcher(&State::CallOnHandleReady, &watcher_handle_);
+ DCHECK_EQ(MOJO_RESULT_OK, rv);
+
+ // Balanced in CallOnHandleReady when MOJO_RESULT_CANCELLED is received.
+ AddRef();
// NOTE: An HTML MessagePort does not receive an event to tell it when the
// peer has gone away, so we only watch for readability here.
- MojoResult rv = MojoWatch(handle_.get().value(),
- MOJO_HANDLE_SIGNAL_READABLE,
- &MessagePort::State::OnHandleReady,
- reinterpret_cast<uintptr_t>(this));
- if (rv != MOJO_RESULT_OK)
- DVLOG(1) << this << " MojoWatch failed: " << rv;
+ rv =
+ MojoWatch(watcher_handle_.get().value(), handle_.get().value(),
+ MOJO_HANDLE_SIGNAL_READABLE, reinterpret_cast<uintptr_t>(this));
+ DCHECK_EQ(MOJO_RESULT_OK, rv);
+
+ ArmWatcher();
+}
+
+void MessagePort::State::StopWatching() {
+ mojo::ScopedWatcherHandle watcher_handle;
+
+ {
+ // NOTE: Resetting the watcher handle may synchronously invoke
+ // OnHandleReady(), so we don't hold |lock_| while doing that.
+ base::AutoLock lock(lock_);
+ watcher_handle = std::move(watcher_handle_);
+ callback_.Reset();
+ }
}
-void MessagePort::State::CancelWatch() {
- if (!callback_)
+mojo::ScopedMessagePipeHandle MessagePort::State::TakeHandle() {
+ base::AutoLock lock(lock_);
+ DCHECK(!watcher_handle_.is_valid());
+ return std::move(handle_);
+}
+
+MessagePort::State::~State() = default;
+
+void MessagePort::State::ArmWatcher() {
+ lock_.AssertAcquired();
+
+ if (!watcher_handle_.is_valid())
return;
- // NOTE: This synchronizes with the thread where OnHandleReady runs so we are
- // sure to not be racing with it.
- MojoCancelWatch(handle_.get().value(), reinterpret_cast<uintptr_t>(this));
+ uint32_t num_ready_contexts = 1;
+ uintptr_t ready_context;
+ MojoResult ready_result;
+ MojoHandleSignalsState ready_state;
+ MojoResult rv =
+ MojoArmWatcher(watcher_handle_.get().value(), &num_ready_contexts,
+ &ready_context, &ready_result, &ready_state);
+ if (rv == MOJO_RESULT_OK)
+ return;
+
+ // The watcher could not be armed because it would notify immediately.
+ DCHECK_EQ(MOJO_RESULT_FAILED_PRECONDITION, rv);
+ DCHECK_EQ(1u, num_ready_contexts);
+ DCHECK_EQ(reinterpret_cast<uintptr_t>(this), ready_context);
+
+ if (ready_result == MOJO_RESULT_OK) {
+ // The handle is already signaled, so we trigger a callback now.
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&State::OnHandleReady, this, MOJO_RESULT_OK));
+ return;
+ }
+
+ if (ready_result == MOJO_RESULT_FAILED_PRECONDITION) {
+ DVLOG(1) << this << " MojoArmWatcher failed because of a broken pipe.";
+ return;
+ }
+
+ NOTREACHED();
}
-// static
-void MessagePort::State::OnHandleReady(
- uintptr_t context,
- MojoResult result,
- MojoHandleSignalsState signals_state,
- MojoWatchNotificationFlags flags) {
- if (result == MOJO_RESULT_OK) {
- reinterpret_cast<MessagePort::State*>(context)->callback_.Run();
+void MessagePort::State::OnHandleReady(MojoResult result) {
+ base::AutoLock lock(lock_);
+ if (result == MOJO_RESULT_OK && callback_) {
+ callback_.Run();
+ ArmWatcher();
} else {
// And now his watch is ended.
}
}
-MessagePort::State::~State() {
- CancelWatch();
+// static
+void MessagePort::State::CallOnHandleReady(uintptr_t context,
+ MojoResult result,
+ MojoHandleSignalsState signals_state,
+ MojoWatcherNotificationFlags flags) {
+ auto* state = reinterpret_cast<State*>(context);
+ if (result == MOJO_RESULT_CANCELLED) {
+ // Balanced in MessagePort::State::StartWatching().
+ state->Release();
+ } else {
+ state->OnHandleReady(result);
+ }
}
} // namespace content
diff --git a/chromium/content/common/message_port.h b/chromium/content/common/message_port.h
index e63d0205fc1..31f6c16f6d0 100644
--- a/chromium/content/common/message_port.h
+++ b/chromium/content/common/message_port.h
@@ -11,8 +11,10 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/strings/string16.h"
+#include "base/synchronization/lock.h"
#include "content/common/content_export.h"
#include "mojo/public/cpp/system/message_pipe.h"
+#include "mojo/public/cpp/system/watcher.h"
namespace content {
@@ -68,7 +70,8 @@ class CONTENT_EXPORT MessagePort {
std::vector<MessagePort>* ports);
// This callback will be invoked on a background thread when messages are
- // available to be read via GetMessage.
+ // available to be read via GetMessage. It must not synchronously call back
+ // into the MessagePort instance.
void SetCallback(const base::Closure& callback);
// Clears any callback specified by a prior call to SetCallback.
@@ -80,19 +83,35 @@ class CONTENT_EXPORT MessagePort {
State();
State(mojo::ScopedMessagePipeHandle handle);
- void AddWatch();
- void CancelWatch();
- static void OnHandleReady(uintptr_t context,
- MojoResult result,
- MojoHandleSignalsState signals_state,
- MojoWatchNotificationFlags flags);
+ void StartWatching(const base::Closure& callback);
+ void StopWatching();
- mojo::ScopedMessagePipeHandle handle_;
- base::Closure callback_;
+ mojo::ScopedMessagePipeHandle TakeHandle();
+
+ const mojo::ScopedMessagePipeHandle& handle() const { return handle_; }
private:
friend class base::RefCountedThreadSafe<State>;
+
~State();
+
+ void ArmWatcher();
+ void OnHandleReady(MojoResult result);
+
+ static void CallOnHandleReady(uintptr_t context,
+ MojoResult result,
+ MojoHandleSignalsState signals_state,
+ MojoWatcherNotificationFlags flags);
+
+ // Guards access to the fields below.
+ base::Lock lock_;
+
+ mojo::ScopedWatcherHandle watcher_handle_;
+ mojo::ScopedMessagePipeHandle handle_;
+
+ // Callback to invoke when the State is notified about a change to
+ // |handle_|'s signaling state.
+ base::Closure callback_;
};
mutable scoped_refptr<State> state_;
};
diff --git a/chromium/content/common/native_types.typemap b/chromium/content/common/native_types.typemap
index 9d0b405411a..7321bd1c0de 100644
--- a/chromium/content/common/native_types.typemap
+++ b/chromium/content/common/native_types.typemap
@@ -25,6 +25,7 @@ public_deps = [
# transitive allowance, so those targets' own public_deps aren't included in
# the set of implied dependencies.
"//cc/ipc",
+ "//content/common:features",
"//media",
"//media/base/ipc",
"//net",
diff --git a/chromium/content/common/navigation_params.cc b/chromium/content/common/navigation_params.cc
index 613918e74ab..e2148964f89 100644
--- a/chromium/content/common/navigation_params.cc
+++ b/chromium/content/common/navigation_params.cc
@@ -12,6 +12,7 @@
#include "content/public/common/url_constants.h"
#include "url/gurl.h"
#include "url/url_constants.h"
+#include "url/url_util.h"
namespace content {
@@ -19,13 +20,30 @@ namespace content {
bool ShouldMakeNetworkRequestForURL(const GURL& url) {
CHECK(IsBrowserSideNavigationEnabled());
- // Javascript URLs, about:blank, srcdoc should not send a request
- // to the network stack.
- return !url.IsAboutBlank() && !url.SchemeIs(url::kJavaScriptScheme) &&
- !url.is_empty() && !url.SchemeIs(url::kContentIDScheme) &&
- url != content::kAboutSrcDocURL;
+ // Javascript URLs, srcdoc, schemes that don't load data should not send a
+ // request to the network stack.
+ if (url.SchemeIs(url::kJavaScriptScheme) || url.is_empty() ||
+ url.SchemeIs(url::kContentIDScheme) || url == content::kAboutSrcDocURL) {
+ return false;
+ }
+
+ for (const auto& scheme : url::GetEmptyDocumentSchemes()) {
+ if (url.SchemeIs(scheme))
+ return false;
+ }
+
+ return true;
}
+SourceLocation::SourceLocation() : line_number(0), column_number(0) {}
+
+SourceLocation::SourceLocation(const std::string& url,
+ unsigned int line_number,
+ unsigned int column_number)
+ : url(url), line_number(line_number), column_number(column_number) {}
+
+SourceLocation::~SourceLocation() {}
+
CommonNavigationParams::CommonNavigationParams()
: transition(ui::PAGE_TRANSITION_LINK),
navigation_type(FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT),
@@ -34,7 +52,8 @@ CommonNavigationParams::CommonNavigationParams()
report_type(FrameMsg_UILoadMetricsReportType::NO_REPORT),
previews_state(PREVIEWS_UNSPECIFIED),
navigation_start(base::TimeTicks::Now()),
- method("GET") {}
+ method("GET"),
+ should_check_main_world_csp(CSPDisposition::CHECK) {}
CommonNavigationParams::CommonNavigationParams(
const GURL& url,
@@ -50,7 +69,9 @@ CommonNavigationParams::CommonNavigationParams(
PreviewsState previews_state,
const base::TimeTicks& navigation_start,
std::string method,
- const scoped_refptr<ResourceRequestBodyImpl>& post_data)
+ const scoped_refptr<ResourceRequestBodyImpl>& post_data,
+ base::Optional<SourceLocation> source_location,
+ CSPDisposition should_check_main_world_csp)
: url(url),
referrer(referrer),
transition(transition),
@@ -64,7 +85,9 @@ CommonNavigationParams::CommonNavigationParams(
previews_state(previews_state),
navigation_start(navigation_start),
method(method),
- post_data(post_data) {
+ post_data(post_data),
+ source_location(source_location),
+ should_check_main_world_csp(should_check_main_world_csp) {
// |method != "POST"| should imply absence of |post_data|.
if (method != "POST" && post_data) {
NOTREACHED();
@@ -83,8 +106,8 @@ BeginNavigationParams::BeginNavigationParams()
has_user_gesture(false),
skip_service_worker(false),
request_context_type(REQUEST_CONTEXT_TYPE_LOCATION),
- mixed_content_context_type(blink::WebMixedContentContextType::Blockable) {
-}
+ mixed_content_context_type(blink::WebMixedContentContextType::kBlockable),
+ is_form_submission(false) {}
BeginNavigationParams::BeginNavigationParams(
std::string headers,
@@ -93,6 +116,7 @@ BeginNavigationParams::BeginNavigationParams(
bool skip_service_worker,
RequestContextType request_context_type,
blink::WebMixedContentContextType mixed_content_context_type,
+ bool is_form_submission,
const base::Optional<url::Origin>& initiator_origin)
: headers(headers),
load_flags(load_flags),
@@ -100,6 +124,7 @@ BeginNavigationParams::BeginNavigationParams(
skip_service_worker(skip_service_worker),
request_context_type(request_context_type),
mixed_content_context_type(mixed_content_context_type),
+ is_form_submission(is_form_submission),
initiator_origin(initiator_origin) {}
BeginNavigationParams::BeginNavigationParams(
diff --git a/chromium/content/common/navigation_params.h b/chromium/content/common/navigation_params.h
index 105130740e3..449003595cb 100644
--- a/chromium/content/common/navigation_params.h
+++ b/chromium/content/common/navigation_params.h
@@ -15,6 +15,7 @@
#include "base/time/time.h"
#include "build/build_config.h"
#include "content/common/content_export.h"
+#include "content/common/content_security_policy/csp_disposition_enum.h"
#include "content/common/frame_message_enums.h"
#include "content/common/resource_request_body_impl.h"
#include "content/public/common/page_state.h"
@@ -36,6 +37,21 @@ namespace content {
// about:blank. In these cases, no request needs to be sent.
bool CONTENT_EXPORT ShouldMakeNetworkRequestForURL(const GURL& url);
+// PlzNavigate
+// Struct keeping track of the Javascript SourceLocation that triggered the
+// navigation. This is initialized based on information from Blink at the start
+// of navigation, and passed back to Blink when the navigation commits.
+struct CONTENT_EXPORT SourceLocation {
+ SourceLocation();
+ SourceLocation(const std::string& url,
+ unsigned int line_number,
+ unsigned int column_number);
+ ~SourceLocation();
+ std::string url;
+ unsigned int line_number;
+ unsigned int column_number;
+};
+
// The following structures hold parameters used during a navigation. In
// particular they are used by FrameMsg_Navigate, FrameMsg_CommitNavigation and
// FrameHostMsg_BeginNavigation.
@@ -59,7 +75,9 @@ struct CONTENT_EXPORT CommonNavigationParams {
PreviewsState previews_state,
const base::TimeTicks& navigation_start,
std::string method,
- const scoped_refptr<ResourceRequestBodyImpl>& post_data);
+ const scoped_refptr<ResourceRequestBodyImpl>& post_data,
+ base::Optional<SourceLocation> source_location,
+ CSPDisposition should_check_main_world_csp);
CommonNavigationParams(const CommonNavigationParams& other);
~CommonNavigationParams();
@@ -120,6 +138,21 @@ struct CONTENT_EXPORT CommonNavigationParams {
// Body of HTTP POST request.
scoped_refptr<ResourceRequestBodyImpl> post_data;
+
+ // PlzNavigate
+ // Information about the Javascript source for this navigation. Used for
+ // providing information in console error messages triggered by the
+ // navigation. If the navigation was not caused by Javascript, this should
+ // not be set.
+ base::Optional<SourceLocation> source_location;
+
+ // Whether or not the CSP of the main world should apply. When the navigation
+ // is initiated from a content script in an isolated world, the CSP defined
+ // in the main world should not apply.
+ // TODO(arthursonzogni): Instead of this boolean, the origin of the isolated
+ // world which has initiated the navigation should be passed.
+ // See https://crbug.com/702540
+ CSPDisposition should_check_main_world_csp;
};
// Provided by the renderer ----------------------------------------------------
@@ -142,6 +175,7 @@ struct CONTENT_EXPORT BeginNavigationParams {
bool skip_service_worker,
RequestContextType request_context_type,
blink::WebMixedContentContextType mixed_content_context_type,
+ bool is_form_submission,
const base::Optional<url::Origin>& initiator_origin);
BeginNavigationParams(const BeginNavigationParams& other);
~BeginNavigationParams();
@@ -164,6 +198,9 @@ struct CONTENT_EXPORT BeginNavigationParams {
// The mixed content context type for potential mixed content checks.
blink::WebMixedContentContextType mixed_content_context_type;
+ // Whether or not the navigation has been initiated by a form submission.
+ bool is_form_submission;
+
// See WebSearchableFormData for a description of these.
GURL searchable_form_url;
std::string searchable_form_encoding;
diff --git a/chromium/content/common/origin_trials/trial_token.cc b/chromium/content/common/origin_trials/trial_token.cc
index ecb8608c263..c8f8cdda617 100644
--- a/chromium/content/common/origin_trials/trial_token.cc
+++ b/chromium/content/common/origin_trials/trial_token.cc
@@ -53,15 +53,15 @@ std::unique_ptr<TrialToken> TrialToken::From(
std::string token_signature;
*out_status =
Extract(token_text, public_key, &token_payload, &token_signature);
- if (*out_status != blink::WebOriginTrialTokenStatus::Success) {
+ if (*out_status != blink::WebOriginTrialTokenStatus::kSuccess) {
return nullptr;
}
std::unique_ptr<TrialToken> token = Parse(token_payload);
if (token) {
token->signature_ = token_signature;
- *out_status = blink::WebOriginTrialTokenStatus::Success;
+ *out_status = blink::WebOriginTrialTokenStatus::kSuccess;
} else {
- *out_status = blink::WebOriginTrialTokenStatus::Malformed;
+ *out_status = blink::WebOriginTrialTokenStatus::kMalformed;
}
return token;
}
@@ -72,12 +72,12 @@ blink::WebOriginTrialTokenStatus TrialToken::IsValid(
// The order of these checks is intentional. For example, will only report a
// token as expired if it is valid for the origin.
if (!ValidateOrigin(origin)) {
- return blink::WebOriginTrialTokenStatus::WrongOrigin;
+ return blink::WebOriginTrialTokenStatus::kWrongOrigin;
}
if (!ValidateDate(now)) {
- return blink::WebOriginTrialTokenStatus::Expired;
+ return blink::WebOriginTrialTokenStatus::kExpired;
}
- return blink::WebOriginTrialTokenStatus::Success;
+ return blink::WebOriginTrialTokenStatus::kSuccess;
}
// static
@@ -87,28 +87,28 @@ blink::WebOriginTrialTokenStatus TrialToken::Extract(
std::string* out_token_payload,
std::string* out_token_signature) {
if (token_text.empty()) {
- return blink::WebOriginTrialTokenStatus::Malformed;
+ return blink::WebOriginTrialTokenStatus::kMalformed;
}
// Token is base64-encoded; decode first.
std::string token_contents;
if (!base::Base64Decode(token_text, &token_contents)) {
- return blink::WebOriginTrialTokenStatus::Malformed;
+ return blink::WebOriginTrialTokenStatus::kMalformed;
}
// Only version 2 currently supported.
if (token_contents.length() < (kVersionOffset + kVersionSize)) {
- return blink::WebOriginTrialTokenStatus::Malformed;
+ return blink::WebOriginTrialTokenStatus::kMalformed;
}
uint8_t version = token_contents[kVersionOffset];
if (version != kVersion2) {
- return blink::WebOriginTrialTokenStatus::WrongVersion;
+ return blink::WebOriginTrialTokenStatus::kWrongVersion;
}
// Token must be large enough to contain a version, signature, and payload
// length.
if (token_contents.length() < (kPayloadLengthOffset + kPayloadLengthSize)) {
- return blink::WebOriginTrialTokenStatus::Malformed;
+ return blink::WebOriginTrialTokenStatus::kMalformed;
}
// Extract the length of the signed data (Big-endian).
@@ -117,7 +117,7 @@ blink::WebOriginTrialTokenStatus TrialToken::Extract(
// Validate that the stated length matches the actual payload length.
if (payload_length != token_contents.length() - kPayloadOffset) {
- return blink::WebOriginTrialTokenStatus::Malformed;
+ return blink::WebOriginTrialTokenStatus::kMalformed;
}
// Extract the version-specific contents of the token.
@@ -133,13 +133,13 @@ blink::WebOriginTrialTokenStatus TrialToken::Extract(
// Validate the signature on the data before proceeding.
if (!TrialToken::ValidateSignature(signature, signed_data, public_key)) {
- return blink::WebOriginTrialTokenStatus::InvalidSignature;
+ return blink::WebOriginTrialTokenStatus::kInvalidSignature;
}
// Return the payload and signature, as new strings.
*out_token_payload = token_contents.substr(kPayloadOffset, payload_length);
*out_token_signature = signature.as_string();
- return blink::WebOriginTrialTokenStatus::Success;
+ return blink::WebOriginTrialTokenStatus::kSuccess;
}
// static
diff --git a/chromium/content/common/origin_trials/trial_token_unittest.cc b/chromium/content/common/origin_trials/trial_token_unittest.cc
index bffb88dd6ba..b1c5bc154fd 100644
--- a/chromium/content/common/origin_trials/trial_token_unittest.cc
+++ b/chromium/content/common/origin_trials/trial_token_unittest.cc
@@ -304,7 +304,7 @@ TEST_F(TrialTokenTest, ValidateValidSignature) {
std::string token_signature;
blink::WebOriginTrialTokenStatus status = Extract(
kSampleToken, correct_public_key(), &token_payload, &token_signature);
- ASSERT_EQ(blink::WebOriginTrialTokenStatus::Success, status);
+ ASSERT_EQ(blink::WebOriginTrialTokenStatus::kSuccess, status);
EXPECT_STREQ(kSampleTokenJSON, token_payload.c_str());
EXPECT_EQ(expected_signature_, token_signature);
}
@@ -315,7 +315,7 @@ TEST_F(TrialTokenTest, ValidateSubdomainValidSignature) {
blink::WebOriginTrialTokenStatus status =
Extract(kSampleSubdomainToken, correct_public_key(), &token_payload,
&token_signature);
- ASSERT_EQ(blink::WebOriginTrialTokenStatus::Success, status);
+ ASSERT_EQ(blink::WebOriginTrialTokenStatus::kSuccess, status);
EXPECT_STREQ(kSampleSubdomainTokenJSON, token_payload.c_str());
EXPECT_EQ(expected_subdomain_signature_, token_signature);
}
@@ -326,7 +326,7 @@ TEST_F(TrialTokenTest, ValidateNonSubdomainValidSignature) {
blink::WebOriginTrialTokenStatus status =
Extract(kSampleNonSubdomainToken, correct_public_key(), &token_payload,
&token_signature);
- ASSERT_EQ(blink::WebOriginTrialTokenStatus::Success, status);
+ ASSERT_EQ(blink::WebOriginTrialTokenStatus::kSuccess, status);
EXPECT_STREQ(kSampleNonSubdomainTokenJSON, token_payload.c_str());
EXPECT_EQ(expected_nonsubdomain_signature_, token_signature);
}
@@ -334,37 +334,37 @@ TEST_F(TrialTokenTest, ValidateNonSubdomainValidSignature) {
TEST_F(TrialTokenTest, ValidateInvalidSignature) {
blink::WebOriginTrialTokenStatus status =
ExtractIgnorePayload(kInvalidSignatureToken, correct_public_key());
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::InvalidSignature, status);
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kInvalidSignature, status);
}
TEST_F(TrialTokenTest, ValidateSignatureWithIncorrectKey) {
blink::WebOriginTrialTokenStatus status =
ExtractIgnorePayload(kSampleToken, incorrect_public_key());
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::InvalidSignature, status);
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kInvalidSignature, status);
}
TEST_F(TrialTokenTest, ValidateEmptyToken) {
blink::WebOriginTrialTokenStatus status =
ExtractIgnorePayload("", correct_public_key());
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::Malformed, status);
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kMalformed, status);
}
TEST_F(TrialTokenTest, ValidateShortToken) {
blink::WebOriginTrialTokenStatus status =
ExtractIgnorePayload(kTruncatedToken, correct_public_key());
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::Malformed, status);
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kMalformed, status);
}
TEST_F(TrialTokenTest, ValidateUnsupportedVersion) {
blink::WebOriginTrialTokenStatus status =
ExtractIgnorePayload(kIncorrectVersionToken, correct_public_key());
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::WrongVersion, status);
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kWrongVersion, status);
}
TEST_F(TrialTokenTest, ValidateSignatureWithIncorrectLength) {
blink::WebOriginTrialTokenStatus status =
ExtractIgnorePayload(kIncorrectLengthToken, correct_public_key());
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::Malformed, status);
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kMalformed, status);
}
// Test parsing of fields from JSON token.
@@ -443,35 +443,35 @@ TEST_F(TrialTokenTest, ValidateValidSubdomainToken) {
TEST_F(TrialTokenTest, TokenIsValid) {
std::unique_ptr<TrialToken> token = Parse(kSampleTokenJSON);
ASSERT_TRUE(token);
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::Success,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kSuccess,
token->IsValid(expected_origin_, valid_timestamp_));
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::WrongOrigin,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kWrongOrigin,
token->IsValid(invalid_origin_, valid_timestamp_));
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::WrongOrigin,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kWrongOrigin,
token->IsValid(insecure_origin_, valid_timestamp_));
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::WrongOrigin,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kWrongOrigin,
token->IsValid(incorrect_port_origin_, valid_timestamp_));
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::Expired,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kExpired,
token->IsValid(expected_origin_, invalid_timestamp_));
}
TEST_F(TrialTokenTest, SubdomainTokenIsValid) {
std::unique_ptr<TrialToken> token = Parse(kSampleSubdomainTokenJSON);
ASSERT_TRUE(token);
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::Success,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kSuccess,
token->IsValid(expected_origin_, valid_timestamp_));
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::Success,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kSuccess,
token->IsValid(expected_subdomain_origin_, valid_timestamp_));
EXPECT_EQ(
- blink::WebOriginTrialTokenStatus::Success,
+ blink::WebOriginTrialTokenStatus::kSuccess,
token->IsValid(expected_multiple_subdomain_origin_, valid_timestamp_));
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::WrongOrigin,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kWrongOrigin,
token->IsValid(incorrect_domain_origin_, valid_timestamp_));
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::WrongOrigin,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kWrongOrigin,
token->IsValid(insecure_origin_, valid_timestamp_));
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::WrongOrigin,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kWrongOrigin,
token->IsValid(incorrect_port_origin_, valid_timestamp_));
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::Expired,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kExpired,
token->IsValid(expected_origin_, invalid_timestamp_));
}
@@ -482,7 +482,7 @@ TEST_F(TrialTokenTest, ExtractValidToken) {
std::unique_ptr<TrialToken> token =
TrialToken::From(kSampleToken, correct_public_key(), &status);
EXPECT_TRUE(token);
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::Success, status);
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kSuccess, status);
EXPECT_EQ(expected_signature_, token->signature());
}
@@ -491,7 +491,7 @@ TEST_F(TrialTokenTest, ExtractInvalidSignature) {
std::unique_ptr<TrialToken> token =
TrialToken::From(kSampleToken, incorrect_public_key(), &status);
EXPECT_FALSE(token);
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::InvalidSignature, status);
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kInvalidSignature, status);
}
TEST_F(TrialTokenTest, ExtractMalformedToken) {
@@ -499,7 +499,7 @@ TEST_F(TrialTokenTest, ExtractMalformedToken) {
std::unique_ptr<TrialToken> token =
TrialToken::From(kIncorrectLengthToken, correct_public_key(), &status);
EXPECT_FALSE(token);
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::Malformed, status);
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kMalformed, status);
}
} // namespace content
diff --git a/chromium/content/common/origin_trials/trial_token_validator.cc b/chromium/content/common/origin_trials/trial_token_validator.cc
index e3130dc902c..bb1c232a6b8 100644
--- a/chromium/content/common/origin_trials/trial_token_validator.cc
+++ b/chromium/content/common/origin_trials/trial_token_validator.cc
@@ -26,32 +26,32 @@ blink::WebOriginTrialTokenStatus TrialTokenValidator::ValidateToken(
const OriginTrialPolicy* origin_trial_policy =
content_client->GetOriginTrialPolicy();
if (!origin_trial_policy)
- return blink::WebOriginTrialTokenStatus::NotSupported;
+ return blink::WebOriginTrialTokenStatus::kNotSupported;
// TODO(iclelland): Allow for multiple signing keys, and iterate over all
// active keys here. https://crbug.com/543220
base::StringPiece public_key = origin_trial_policy->GetPublicKey();
if (public_key.empty())
- return blink::WebOriginTrialTokenStatus::NotSupported;
+ return blink::WebOriginTrialTokenStatus::kNotSupported;
blink::WebOriginTrialTokenStatus status;
std::unique_ptr<TrialToken> trial_token =
TrialToken::From(token, public_key, &status);
- if (status != blink::WebOriginTrialTokenStatus::Success)
+ if (status != blink::WebOriginTrialTokenStatus::kSuccess)
return status;
status = trial_token->IsValid(origin, base::Time::Now());
- if (status != blink::WebOriginTrialTokenStatus::Success)
+ if (status != blink::WebOriginTrialTokenStatus::kSuccess)
return status;
if (origin_trial_policy->IsFeatureDisabled(trial_token->feature_name()))
- return blink::WebOriginTrialTokenStatus::FeatureDisabled;
+ return blink::WebOriginTrialTokenStatus::kFeatureDisabled;
if (origin_trial_policy->IsTokenDisabled(trial_token->signature()))
- return blink::WebOriginTrialTokenStatus::TokenDisabled;
+ return blink::WebOriginTrialTokenStatus::kTokenDisabled;
*feature_name = trial_token->feature_name();
- return blink::WebOriginTrialTokenStatus::Success;
+ return blink::WebOriginTrialTokenStatus::kSuccess;
}
bool TrialTokenValidator::RequestEnablesFeature(
@@ -80,7 +80,7 @@ bool TrialTokenValidator::RequestEnablesFeature(
std::string token_feature;
// TODO(mek): Log the validation errors to histograms?
if (ValidateToken(token, origin, &token_feature) ==
- blink::WebOriginTrialTokenStatus::Success)
+ blink::WebOriginTrialTokenStatus::kSuccess)
if (token_feature == feature_name)
return true;
}
@@ -104,7 +104,7 @@ TrialTokenValidator::GetValidTokensFromHeaders(
while (headers->EnumerateHeader(&iter, "Origin-Trial", &token)) {
std::string token_feature;
if (TrialTokenValidator::ValidateToken(token, origin, &token_feature) ==
- blink::WebOriginTrialTokenStatus::Success) {
+ blink::WebOriginTrialTokenStatus::kSuccess) {
(*tokens)[token_feature].push_back(token);
}
}
@@ -126,7 +126,7 @@ TrialTokenValidator::GetValidTokens(const url::Origin& origin,
for (const std::string& token : feature.second) {
std::string token_feature;
if (TrialTokenValidator::ValidateToken(token, origin, &token_feature) ==
- blink::WebOriginTrialTokenStatus::Success) {
+ blink::WebOriginTrialTokenStatus::kSuccess) {
DCHECK_EQ(token_feature, feature.first);
(*out_tokens)[feature.first].push_back(token);
}
diff --git a/chromium/content/common/origin_trials/trial_token_validator_unittest.cc b/chromium/content/common/origin_trials/trial_token_validator_unittest.cc
index b82ca80b052..e49f02e3c06 100644
--- a/chromium/content/common/origin_trials/trial_token_validator_unittest.cc
+++ b/chromium/content/common/origin_trials/trial_token_validator_unittest.cc
@@ -232,7 +232,7 @@ class TrialTokenValidatorTest : public testing::Test {
#endif
TEST_F(TrialTokenValidatorTest, MAYBE_ValidateValidToken) {
std::string feature;
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::Success,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kSuccess,
TrialTokenValidator::ValidateToken(kSampleToken,
appropriate_origin_, &feature));
EXPECT_EQ(kAppropriateFeatureName, feature);
@@ -240,31 +240,31 @@ TEST_F(TrialTokenValidatorTest, MAYBE_ValidateValidToken) {
TEST_F(TrialTokenValidatorTest, ValidateInappropriateOrigin) {
std::string feature;
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::WrongOrigin,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kWrongOrigin,
TrialTokenValidator::ValidateToken(
kSampleToken, inappropriate_origin_, &feature));
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::WrongOrigin,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kWrongOrigin,
TrialTokenValidator::ValidateToken(kSampleToken, insecure_origin_,
&feature));
}
TEST_F(TrialTokenValidatorTest, ValidateInvalidSignature) {
std::string feature;
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::InvalidSignature,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kInvalidSignature,
TrialTokenValidator::ValidateToken(kInvalidSignatureToken,
appropriate_origin_, &feature));
}
TEST_F(TrialTokenValidatorTest, ValidateUnparsableToken) {
std::string feature;
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::Malformed,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kMalformed,
TrialTokenValidator::ValidateToken(kUnparsableToken,
appropriate_origin_, &feature));
}
TEST_F(TrialTokenValidatorTest, ValidateExpiredToken) {
std::string feature;
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::Expired,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kExpired,
TrialTokenValidator::ValidateToken(kExpiredToken,
appropriate_origin_, &feature));
}
@@ -272,7 +272,7 @@ TEST_F(TrialTokenValidatorTest, ValidateExpiredToken) {
TEST_F(TrialTokenValidatorTest, ValidateValidTokenWithIncorrectKey) {
std::string feature;
SetPublicKey(kTestPublicKey2);
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::InvalidSignature,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kInvalidSignature,
TrialTokenValidator::ValidateToken(kSampleToken,
appropriate_origin_, &feature));
}
@@ -287,13 +287,13 @@ TEST_F(TrialTokenValidatorTest, MAYBE_ValidatorRespectsDisabledFeatures) {
std::string feature;
// Disable an irrelevant feature; token should still validate
DisableFeature(kInappropriateFeatureName);
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::Success,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kSuccess,
TrialTokenValidator::ValidateToken(kSampleToken,
appropriate_origin_, &feature));
EXPECT_EQ(kAppropriateFeatureName, feature);
// Disable the token's feature; it should no longer be valid
DisableFeature(kAppropriateFeatureName);
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::FeatureDisabled,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kFeatureDisabled,
TrialTokenValidator::ValidateToken(kSampleToken,
appropriate_origin_, &feature));
}
@@ -302,13 +302,13 @@ TEST_F(TrialTokenValidatorTest, ValidatorRespectsDisabledTokens) {
std::string feature;
// Disable an irrelevant token; token should still validate
DisableToken(expired_token_signature_);
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::Success,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kSuccess,
TrialTokenValidator::ValidateToken(kSampleToken,
appropriate_origin_, &feature));
EXPECT_EQ(kAppropriateFeatureName, feature);
// Disable the token; it should no longer be valid
DisableToken(valid_token_signature_);
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::TokenDisabled,
+ EXPECT_EQ(blink::WebOriginTrialTokenStatus::kTokenDisabled,
TrialTokenValidator::ValidateToken(kSampleToken,
appropriate_origin_, &feature));
}
diff --git a/chromium/content/common/page_state_serialization.cc b/chromium/content/common/page_state_serialization.cc
index 52ed1a192a4..41da9238988 100644
--- a/chromium/content/common/page_state_serialization.cc
+++ b/chromium/content/common/page_state_serialization.cc
@@ -191,7 +191,7 @@ struct SerializeObject {
// 18: Add referrer policy.
// 19: Remove target frame id, which was a bad idea, and original url string,
// which is no longer used.
-// 20: Add pinch viewport scroll offset, the offset of the pinched zoomed
+// 20: Add visual viewport scroll offset, the offset of the pinched zoomed
// viewport within the unzoomed main frame.
// 21: Add frame sequence number.
// 22: Add scroll restoration type.
@@ -399,11 +399,11 @@ void WriteResourceRequestBody(const ResourceRequestBodyImpl& request_body,
for (const auto& element : *request_body.elements()) {
switch (element.type()) {
case ResourceRequestBodyImpl::Element::TYPE_BYTES:
- WriteInteger(blink::WebHTTPBody::Element::TypeData, obj);
+ WriteInteger(blink::WebHTTPBody::Element::kTypeData, obj);
WriteData(element.bytes(), static_cast<int>(element.length()), obj);
break;
case ResourceRequestBodyImpl::Element::TYPE_FILE:
- WriteInteger(blink::WebHTTPBody::Element::TypeFile, obj);
+ WriteInteger(blink::WebHTTPBody::Element::kTypeFile, obj);
WriteString(
base::NullableString16(element.path().AsUTF16Unsafe(), false), obj);
WriteInteger64(static_cast<int64_t>(element.offset()), obj);
@@ -411,14 +411,14 @@ void WriteResourceRequestBody(const ResourceRequestBodyImpl& request_body,
WriteReal(element.expected_modification_time().ToDoubleT(), obj);
break;
case ResourceRequestBodyImpl::Element::TYPE_FILE_FILESYSTEM:
- WriteInteger(blink::WebHTTPBody::Element::TypeFileSystemURL, obj);
+ WriteInteger(blink::WebHTTPBody::Element::kTypeFileSystemURL, obj);
WriteGURL(element.filesystem_url(), obj);
WriteInteger64(static_cast<int64_t>(element.offset()), obj);
WriteInteger64(static_cast<int64_t>(element.length()), obj);
WriteReal(element.expected_modification_time().ToDoubleT(), obj);
break;
case ResourceRequestBodyImpl::Element::TYPE_BLOB:
- WriteInteger(blink::WebHTTPBody::Element::TypeBlob, obj);
+ WriteInteger(blink::WebHTTPBody::Element::kTypeBlob, obj);
WriteStdString(element.blob_uuid(), obj);
break;
case ResourceRequestBodyImpl::Element::TYPE_BYTES_DESCRIPTION:
@@ -437,7 +437,7 @@ void ReadResourceRequestBody(
int num_elements = ReadInteger(obj);
for (int i = 0; i < num_elements; ++i) {
int type = ReadInteger(obj);
- if (type == blink::WebHTTPBody::Element::TypeData) {
+ if (type == blink::WebHTTPBody::Element::kTypeData) {
const void* data;
int length = -1;
ReadData(obj, &data, &length);
@@ -445,21 +445,21 @@ void ReadResourceRequestBody(
AppendDataToRequestBody(request_body, static_cast<const char*>(data),
length);
}
- } else if (type == blink::WebHTTPBody::Element::TypeFile) {
+ } else if (type == blink::WebHTTPBody::Element::kTypeFile) {
base::NullableString16 file_path = ReadString(obj);
int64_t file_start = ReadInteger64(obj);
int64_t file_length = ReadInteger64(obj);
double file_modification_time = ReadReal(obj);
AppendFileRangeToRequestBody(request_body, file_path, file_start,
file_length, file_modification_time);
- } else if (type == blink::WebHTTPBody::Element::TypeFileSystemURL) {
+ } else if (type == blink::WebHTTPBody::Element::kTypeFileSystemURL) {
GURL url = ReadGURL(obj);
int64_t file_start = ReadInteger64(obj);
int64_t file_length = ReadInteger64(obj);
double file_modification_time = ReadReal(obj);
AppendURLRangeToRequestBody(request_body, url, file_start, file_length,
file_modification_time);
- } else if (type == blink::WebHTTPBody::Element::TypeBlob) {
+ } else if (type == blink::WebHTTPBody::Element::kTypeBlob) {
if (obj->version >= 16) {
std::string blob_uuid = ReadStdString(obj);
AppendBlobToRequestBody(request_body, blob_uuid);
@@ -709,12 +709,12 @@ ExplodedHttpBody::~ExplodedHttpBody() {
}
ExplodedFrameState::ExplodedFrameState()
- : scroll_restoration_type(blink::WebHistoryScrollRestorationAuto),
+ : scroll_restoration_type(blink::kWebHistoryScrollRestorationAuto),
did_save_scroll_or_scale_state(true),
item_sequence_number(0),
document_sequence_number(0),
page_scale_factor(0.0),
- referrer_policy(blink::WebReferrerPolicyDefault) {}
+ referrer_policy(blink::kWebReferrerPolicyDefault) {}
ExplodedFrameState::ExplodedFrameState(const ExplodedFrameState& other) {
assign(other);
diff --git a/chromium/content/common/page_state_serialization_unittest.cc b/chromium/content/common/page_state_serialization_unittest.cc
index 43b801dd511..e5c42a22916 100644
--- a/chromium/content/common/page_state_serialization_unittest.cc
+++ b/chromium/content/common/page_state_serialization_unittest.cc
@@ -101,7 +101,7 @@ class PageStateSerializationTest : public testing::Test {
// Invent some data for the various fields.
frame_state->url_string = NS16("http://dev.chromium.org/");
frame_state->referrer = NS16("https://www.google.com/search?q=dev.chromium.org");
- frame_state->referrer_policy = blink::WebReferrerPolicyAlways;
+ frame_state->referrer_policy = blink::kWebReferrerPolicyAlways;
frame_state->target = NS16("foo");
frame_state->state_object = NS16(NULL);
frame_state->document_state.push_back(NS16("1"));
@@ -109,7 +109,7 @@ class PageStateSerializationTest : public testing::Test {
frame_state->document_state.push_back(NS16("text"));
frame_state->document_state.push_back(NS16("dev.chromium.org"));
frame_state->scroll_restoration_type =
- blink::WebHistoryScrollRestorationManual;
+ blink::kWebHistoryScrollRestorationManual;
frame_state->visual_viewport_scroll_offset = gfx::PointF(10, 15);
frame_state->scroll_offset = gfx::Point(0, 100);
frame_state->item_sequence_number = 1;
@@ -140,11 +140,11 @@ class PageStateSerializationTest : public testing::Test {
bool is_child) {
frame_state->url_string = NS16("http://chromium.org/");
frame_state->referrer = NS16("http://google.com/");
- frame_state->referrer_policy = blink::WebReferrerPolicyDefault;
+ frame_state->referrer_policy = blink::kWebReferrerPolicyDefault;
if (!is_child)
frame_state->target = NS16("target");
frame_state->scroll_restoration_type =
- blink::WebHistoryScrollRestorationAuto;
+ blink::kWebHistoryScrollRestorationAuto;
frame_state->visual_viewport_scroll_offset = gfx::PointF(-1, -1);
frame_state->scroll_offset = gfx::Point(42, -42);
frame_state->item_sequence_number = 123;
@@ -355,7 +355,7 @@ TEST_F(PageStateSerializationTest, BadMessagesTest2) {
p.WriteInt(0);
// WebForm
p.WriteInt(1);
- p.WriteInt(blink::WebHTTPBody::Element::TypeData);
+ p.WriteInt(blink::WebHTTPBody::Element::kTypeData);
std::string s(static_cast<const char*>(p.data()), p.size());
diff --git a/chromium/content/common/plugin_list.cc b/chromium/content/common/plugin_list.cc
index 9d650aac1d1..76a44b440e7 100644
--- a/chromium/content/common/plugin_list.cc
+++ b/chromium/content/common/plugin_list.cc
@@ -24,7 +24,8 @@ namespace content {
namespace {
-base::LazyInstance<PluginList> g_singleton = LAZY_INSTANCE_INITIALIZER;
+base::LazyInstance<PluginList>::DestructorAtExit g_singleton =
+ LAZY_INSTANCE_INITIALIZER;
} // namespace
diff --git a/chromium/content/common/plugin_list.h b/chromium/content/common/plugin_list.h
index e96fca34140..0504985133c 100644
--- a/chromium/content/common/plugin_list.h
+++ b/chromium/content/common/plugin_list.h
@@ -132,7 +132,7 @@ class CONTENT_EXPORT PluginList {
};
friend class PluginListTest;
- friend struct base::DefaultLazyInstanceTraits<PluginList>;
+ friend struct base::LazyInstanceTraitsBase<PluginList>;
PluginList();
diff --git a/chromium/content/common/presentation/presentation.typemap b/chromium/content/common/presentation/presentation.typemap
index bcfa2998d27..33ac3db53a6 100644
--- a/chromium/content/common/presentation/presentation.typemap
+++ b/chromium/content/common/presentation/presentation.typemap
@@ -3,16 +3,20 @@
# found in the LICENSE file.
mojom = "//third_party/WebKit/public/platform/modules/presentation/presentation.mojom"
-public_headers = [ "//content/public/common/presentation_session.h" ]
+public_headers = [
+ "//content/public/common/presentation_connection_message.h",
+ "//content/public/common/presentation_info.h",
+]
traits_headers =
[ "//content/common/presentation/presentation_struct_traits.h" ]
deps = [
"//url",
]
type_mappings = [
- "blink.mojom.PresentationErrorType=content::PresentationErrorType",
- "blink.mojom.PresentationConnectionState=content::PresentationConnectionState",
"blink.mojom.PresentationConnectionCloseReason=content::PresentationConnectionCloseReason",
- "blink.mojom.PresentationSessionInfo=content::PresentationSessionInfo",
+ "blink.mojom.PresentationConnectionMessage=content::PresentationConnectionMessage[move_only]",
+ "blink.mojom.PresentationConnectionState=content::PresentationConnectionState",
"blink.mojom.PresentationError=content::PresentationError",
+ "blink.mojom.PresentationErrorType=content::PresentationErrorType",
+ "blink.mojom.PresentationInfo=content::PresentationInfo",
]
diff --git a/chromium/content/common/presentation/presentation_struct_traits.cc b/chromium/content/common/presentation/presentation_struct_traits.cc
new file mode 100644
index 00000000000..13b5b388b7e
--- /dev/null
+++ b/chromium/content/common/presentation/presentation_struct_traits.cc
@@ -0,0 +1,63 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/presentation/presentation_struct_traits.h"
+
+#include "url/mojo/url_gurl_struct_traits.h"
+
+namespace mojo {
+
+bool StructTraits<blink::mojom::PresentationInfoDataView,
+ content::PresentationInfo>::
+ Read(blink::mojom::PresentationInfoDataView data,
+ content::PresentationInfo* out) {
+ if (!data.ReadUrl(&(out->presentation_url)) ||
+ !data.ReadId(&(out->presentation_id))) {
+ return false;
+ }
+
+ if (out->presentation_id.empty() ||
+ !base::IsStringASCII(out->presentation_id) ||
+ out->presentation_id.length() > content::PresentationInfo::kMaxIdLength) {
+ return false;
+ }
+ return true;
+}
+
+bool StructTraits<blink::mojom::PresentationErrorDataView,
+ content::PresentationError>::
+ Read(blink::mojom::PresentationErrorDataView data,
+ content::PresentationError* out) {
+ if (!data.ReadErrorType(&(out->error_type)) ||
+ !data.ReadMessage(&(out->message))) {
+ return false;
+ }
+
+ if (!base::IsStringUTF8(out->message) ||
+ out->message.length() > content::PresentationError::kMaxMessageLength) {
+ return false;
+ }
+
+ return true;
+}
+
+bool UnionTraits<blink::mojom::PresentationConnectionMessageDataView,
+ content::PresentationConnectionMessage>::
+ Read(blink::mojom::PresentationConnectionMessageDataView data,
+ content::PresentationConnectionMessage* out) {
+ if (data.is_message()) {
+ if (!data.ReadMessage(&(out->message)) ||
+ out->message->length() >
+ content::kMaxPresentationConnectionMessageSize) {
+ return false;
+ }
+ } else {
+ if (!data.ReadData(&(out->data)) ||
+ out->data->size() > content::kMaxPresentationConnectionMessageSize) {
+ return false;
+ }
+ }
+ return true;
+}
+}
diff --git a/chromium/content/common/presentation/presentation_struct_traits.h b/chromium/content/common/presentation/presentation_struct_traits.h
index 7bf19a97e33..81c1f6ca783 100644
--- a/chromium/content/common/presentation/presentation_struct_traits.h
+++ b/chromium/content/common/presentation/presentation_struct_traits.h
@@ -6,11 +6,13 @@
#define CONTENT_COMMON_PRESENTATION_PRESENTATION_STRUCT_TRAITS_H_
#include <string>
+#include <vector>
#include "base/macros.h"
+#include "base/optional.h"
#include "base/strings/string_util.h"
-#include "content/public/common/presentation_session.h"
-#include "mojo/common/common_custom_types_struct_traits.h"
+#include "content/public/common/presentation_connection_message.h"
+#include "content/public/common/presentation_info.h"
#include "third_party/WebKit/public/platform/modules/presentation/presentation.mojom.h"
#include "url/mojo/url.mojom.h"
@@ -24,8 +26,9 @@ struct EnumTraits<blink::mojom::PresentationErrorType,
switch (input) {
case content::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS:
return blink::mojom::PresentationErrorType::NO_AVAILABLE_SCREENS;
- case content::PRESENTATION_ERROR_SESSION_REQUEST_CANCELLED:
- return blink::mojom::PresentationErrorType::SESSION_REQUEST_CANCELLED;
+ case content::PRESENTATION_ERROR_PRESENTATION_REQUEST_CANCELLED:
+ return blink::mojom::PresentationErrorType::
+ PRESENTATION_REQUEST_CANCELLED;
case content::PRESENTATION_ERROR_NO_PRESENTATION_FOUND:
return blink::mojom::PresentationErrorType::NO_PRESENTATION_FOUND;
case content::PRESENTATION_ERROR_PREVIOUS_START_IN_PROGRESS:
@@ -44,8 +47,8 @@ struct EnumTraits<blink::mojom::PresentationErrorType,
case blink::mojom::PresentationErrorType::NO_AVAILABLE_SCREENS:
*output = content::PRESENTATION_ERROR_NO_AVAILABLE_SCREENS;
return true;
- case blink::mojom::PresentationErrorType::SESSION_REQUEST_CANCELLED:
- *output = content::PRESENTATION_ERROR_SESSION_REQUEST_CANCELLED;
+ case blink::mojom::PresentationErrorType::PRESENTATION_REQUEST_CANCELLED:
+ *output = content::PRESENTATION_ERROR_PRESENTATION_REQUEST_CANCELLED;
return true;
case blink::mojom::PresentationErrorType::NO_PRESENTATION_FOUND:
*output = content::PRESENTATION_ERROR_NO_PRESENTATION_FOUND;
@@ -139,34 +142,19 @@ struct EnumTraits<blink::mojom::PresentationConnectionCloseReason,
};
template <>
-struct StructTraits<blink::mojom::PresentationSessionInfoDataView,
- content::PresentationSessionInfo> {
- static const GURL& url(const content::PresentationSessionInfo& session_info) {
- return session_info.presentation_url;
+struct StructTraits<blink::mojom::PresentationInfoDataView,
+ content::PresentationInfo> {
+ static const GURL& url(const content::PresentationInfo& presentation_info) {
+ return presentation_info.presentation_url;
}
static const std::string& id(
- const content::PresentationSessionInfo& session_info) {
- return session_info.presentation_id;
+ const content::PresentationInfo& presentation_info) {
+ return presentation_info.presentation_id;
}
- static bool Read(blink::mojom::PresentationSessionInfoDataView data,
- content::PresentationSessionInfo* out) {
- if (!data.ReadUrl(&(out->presentation_url)))
- return false;
-
- if (!data.ReadId(&(out->presentation_id)))
- return false;
-
- if (out->presentation_id.empty() ||
- !base::IsStringASCII(out->presentation_id) ||
- out->presentation_id.length() >
- content::PresentationSessionInfo::kMaxIdLength) {
- return false;
- }
-
- return true;
- }
+ static bool Read(blink::mojom::PresentationInfoDataView data,
+ content::PresentationInfo* out);
};
template <>
@@ -182,19 +170,34 @@ struct StructTraits<blink::mojom::PresentationErrorDataView,
}
static bool Read(blink::mojom::PresentationErrorDataView data,
- content::PresentationError* out) {
- if (!data.ReadErrorType(&(out->error_type)))
- return false;
+ content::PresentationError* out);
+};
- if (!data.ReadMessage(&(out->message)))
- return false;
+template <>
+struct UnionTraits<blink::mojom::PresentationConnectionMessageDataView,
+ content::PresentationConnectionMessage> {
+ static blink::mojom::PresentationConnectionMessageDataView::Tag GetTag(
+ const content::PresentationConnectionMessage& message) {
+ return message.is_binary()
+ ? blink::mojom::PresentationConnectionMessageDataView::Tag::DATA
+ : blink::mojom::PresentationConnectionMessageDataView::Tag::
+ MESSAGE;
+ }
- if (!base::IsStringUTF8(out->message) ||
- out->message.length() > content::PresentationError::kMaxMessageLength)
- return false;
+ static const std::string& message(
+ const content::PresentationConnectionMessage& message) {
+ DCHECK(!message.is_binary());
+ return message.message.value();
+ }
- return true;
+ static const std::vector<uint8_t>& data(
+ const content::PresentationConnectionMessage& message) {
+ DCHECK(message.is_binary());
+ return message.data.value();
}
+
+ static bool Read(blink::mojom::PresentationConnectionMessageDataView data,
+ content::PresentationConnectionMessage* out);
};
} // namespace mojo
diff --git a/chromium/content/common/push_messaging.mojom b/chromium/content/common/push_messaging.mojom
index db435ad9a27..e9973b0db5a 100644
--- a/chromium/content/common/push_messaging.mojom
+++ b/chromium/content/common/push_messaging.mojom
@@ -68,12 +68,19 @@ enum PushRegistrationStatus {
// already exists.
SENDER_ID_MISMATCH = 13,
+ // Registration failed because storage was corrupt. It will be retried
+ // automatically after unsubscribing to fix the corruption.
+ STORAGE_CORRUPT = 14,
+
+ // Registration failed because the renderer was shut down.
+ RENDERER_SHUTDOWN = 15,
+
// NOTE: Do not renumber these as that would confuse interpretation of
// previously logged data. When making changes, also update the enum list
// in tools/metrics/histograms/histograms.xml to keep it in sync, and
// update LAST below.
- LAST = SENDER_ID_MISMATCH
+ LAST = RENDERER_SHUTDOWN
};
enum PushErrorType {
@@ -106,15 +113,21 @@ enum PushGetRegistrationStatus {
// incognito, but we tell JS registration not found to not reveal incognito.
INCOGNITO_REGISTRATION_NOT_FOUND = 4,
- // Registration failed because the public key could not be retrieved.
- PUBLIC_KEY_UNAVAILABLE = 5,
+ // Getting the registration failed because public key could not be retrieved.
+ // PUBLIC_KEY_UNAVAILABLE = 5,
+
+ // Getting the registration failed because storage was corrupt.
+ STORAGE_CORRUPT = 6,
+
+ // Getting the registration failed because the renderer was shut down.
+ RENDERER_SHUTDOWN = 7,
// NOTE: Do not renumber these as that would confuse interpretation of
// previously logged data. When making changes, also update the enum list
// in tools/metrics/histograms/histograms.xml to keep it in sync, and
// update LAST below.
- LAST = PUBLIC_KEY_UNAVAILABLE
+ LAST = RENDERER_SHUTDOWN
};
enum PushPermissionStatus {
diff --git a/chromium/content/common/push_messaging_param_traits.cc b/chromium/content/common/push_messaging_param_traits.cc
index d336d0c4ac6..e5efafdc499 100644
--- a/chromium/content/common/push_messaging_param_traits.cc
+++ b/chromium/content/common/push_messaging_param_traits.cc
@@ -101,48 +101,61 @@ static_assert(
content::mojom::PushRegistrationStatus::SENDER_ID_MISMATCH),
"PushRegistrationStatus enums must match, SENDER_ID_MISMATCH");
+static_assert(
+ content::PushRegistrationStatus::PUSH_REGISTRATION_STATUS_STORAGE_CORRUPT ==
+ static_cast<content::PushRegistrationStatus>(
+ content::mojom::PushRegistrationStatus::STORAGE_CORRUPT),
+ "PushRegistrationStatus enums must match, STORAGE_CORRUPT");
+
+static_assert(
+ content::PushRegistrationStatus::
+ PUSH_REGISTRATION_STATUS_RENDERER_SHUTDOWN ==
+ static_cast<content::PushRegistrationStatus>(
+ content::mojom::PushRegistrationStatus::RENDERER_SHUTDOWN),
+ "PushRegistrationStatus enums must match, RENDERER_SHUTDOWN");
+
static_assert(content::PushRegistrationStatus::PUSH_REGISTRATION_STATUS_LAST ==
static_cast<content::PushRegistrationStatus>(
content::mojom::PushRegistrationStatus::LAST),
"PushRegistrationStatus enums must match, LAST");
// PushErrorType
-static_assert(blink::WebPushError::ErrorType::ErrorTypeAbort ==
+static_assert(blink::WebPushError::ErrorType::kErrorTypeAbort ==
static_cast<blink::WebPushError::ErrorType>(
content::mojom::PushErrorType::ABORT),
"PushErrorType enums must match, ABORT");
-static_assert(blink::WebPushError::ErrorType::ErrorTypeNetwork ==
+static_assert(blink::WebPushError::ErrorType::kErrorTypeNetwork ==
static_cast<blink::WebPushError::ErrorType>(
content::mojom::PushErrorType::NETWORK),
"PushErrorType enums must match, NETWORK");
-static_assert(blink::WebPushError::ErrorType::ErrorTypeNone ==
+static_assert(blink::WebPushError::ErrorType::kErrorTypeNone ==
static_cast<blink::WebPushError::ErrorType>(
content::mojom::PushErrorType::NONE),
"PushErrorType enums must match, NONE");
-static_assert(blink::WebPushError::ErrorType::ErrorTypeNotAllowed ==
+static_assert(blink::WebPushError::ErrorType::kErrorTypeNotAllowed ==
static_cast<blink::WebPushError::ErrorType>(
content::mojom::PushErrorType::NOT_ALLOWED),
"PushErrorType enums must match, NOT_ALLOWED");
-static_assert(blink::WebPushError::ErrorType::ErrorTypeNotFound ==
+static_assert(blink::WebPushError::ErrorType::kErrorTypeNotFound ==
static_cast<blink::WebPushError::ErrorType>(
content::mojom::PushErrorType::NOT_FOUND),
"PushErrorType enums must match, NOT_FOUND");
-static_assert(blink::WebPushError::ErrorType::ErrorTypeNotSupported ==
+static_assert(blink::WebPushError::ErrorType::kErrorTypeNotSupported ==
static_cast<blink::WebPushError::ErrorType>(
content::mojom::PushErrorType::NOT_SUPPORTED),
"PushErrorType enums must match, NOT_SUPPORTED");
-static_assert(blink::WebPushError::ErrorType::ErrorTypeInvalidState ==
+static_assert(blink::WebPushError::ErrorType::kErrorTypeInvalidState ==
static_cast<blink::WebPushError::ErrorType>(
content::mojom::PushErrorType::INVALID_STATE),
"PushErrorType enums must match, INVALID_STATE");
-static_assert(blink::WebPushError::ErrorType::ErrorTypeLast ==
+static_assert(blink::WebPushError::ErrorType::kErrorTypeLast ==
static_cast<blink::WebPushError::ErrorType>(
content::mojom::PushErrorType::LAST),
"PushErrorType enums must match, LAST");
@@ -185,10 +198,17 @@ static_assert(
static_assert(
content::PushGetRegistrationStatus::
- PUSH_GETREGISTRATION_STATUS_PUBLIC_KEY_UNAVAILABLE ==
+ PUSH_GETREGISTRATION_STATUS_STORAGE_CORRUPT ==
+ static_cast<content::PushGetRegistrationStatus>(
+ content::mojom::PushGetRegistrationStatus::STORAGE_CORRUPT),
+ "PushGetRegistrationStatus enums must match, STORAGE_CORRUPT");
+
+static_assert(
+ content::PushGetRegistrationStatus::
+ PUSH_GETREGISTRATION_STATUS_RENDERER_SHUTDOWN ==
static_cast<content::PushGetRegistrationStatus>(
- content::mojom::PushGetRegistrationStatus::PUBLIC_KEY_UNAVAILABLE),
- "PushGetRegistrationStatus enums must match, PUBLIC_KEY_UNAVAILABLE");
+ content::mojom::PushGetRegistrationStatus::RENDERER_SHUTDOWN),
+ "PushGetRegistrationStatus enums must match, RENDERER_SHUTDOWN");
static_assert(
content::PushGetRegistrationStatus::PUSH_GETREGISTRATION_STATUS_LAST ==
@@ -197,22 +217,22 @@ static_assert(
"PushGetRegistrationStatus enums must match, LAST");
// PushPermissionStatus
-static_assert(blink::WebPushPermissionStatus::WebPushPermissionStatusGranted ==
+static_assert(blink::WebPushPermissionStatus::kWebPushPermissionStatusGranted ==
static_cast<blink::WebPushPermissionStatus>(
content::mojom::PushPermissionStatus::GRANTED),
"PushPermissionStatus enums must match, GRANTED");
-static_assert(blink::WebPushPermissionStatus::WebPushPermissionStatusDenied ==
+static_assert(blink::WebPushPermissionStatus::kWebPushPermissionStatusDenied ==
static_cast<blink::WebPushPermissionStatus>(
content::mojom::PushPermissionStatus::DENIED),
"PushPermissionStatus enums must match, DENIED");
-static_assert(blink::WebPushPermissionStatus::WebPushPermissionStatusPrompt ==
+static_assert(blink::WebPushPermissionStatus::kWebPushPermissionStatusPrompt ==
static_cast<blink::WebPushPermissionStatus>(
content::mojom::PushPermissionStatus::PROMPT),
"PushPermissionStatus enums must match, PROMPT");
-static_assert(blink::WebPushPermissionStatus::WebPushPermissionStatusLast ==
+static_assert(blink::WebPushPermissionStatus::kWebPushPermissionStatusLast ==
static_cast<blink::WebPushPermissionStatus>(
content::mojom::PushPermissionStatus::LAST),
"PushPermissionStatus enums must match, LAST");
@@ -264,8 +284,8 @@ bool EnumTraits<content::mojom::PushRegistrationStatus,
content::mojom::PushErrorType
EnumTraits<content::mojom::PushErrorType, blink::WebPushError::ErrorType>::
ToMojom(blink::WebPushError::ErrorType input) {
- if (input >= blink::WebPushError::ErrorType::ErrorTypeAbort &&
- input <= blink::WebPushError::ErrorType::ErrorTypeInvalidState) {
+ if (input >= blink::WebPushError::ErrorType::kErrorTypeAbort &&
+ input <= blink::WebPushError::ErrorType::kErrorTypeInvalidState) {
return static_cast<content::mojom::PushErrorType>(input);
}
@@ -323,8 +343,9 @@ content::mojom::PushPermissionStatus EnumTraits<
content::mojom::PushPermissionStatus,
blink::WebPushPermissionStatus>::ToMojom(blink::WebPushPermissionStatus
input) {
- if (input >= blink::WebPushPermissionStatus::WebPushPermissionStatusGranted &&
- input <= blink::WebPushPermissionStatus::WebPushPermissionStatusLast) {
+ if (input >=
+ blink::WebPushPermissionStatus::kWebPushPermissionStatusGranted &&
+ input <= blink::WebPushPermissionStatus::kWebPushPermissionStatusLast) {
return static_cast<content::mojom::PushPermissionStatus>(input);
}
diff --git a/chromium/content/common/render_message_filter.mojom b/chromium/content/common/render_message_filter.mojom
index 78c93efe1f5..0e6cfc3c85c 100644
--- a/chromium/content/common/render_message_filter.mojom
+++ b/chromium/content/common/render_message_filter.mojom
@@ -4,6 +4,7 @@
module content.mojom;
+import "cc/ipc/shared_bitmap_manager.mojom";
import "content/common/native_types.mojom";
import "content/public/common/window_container_type.mojom";
import "gpu/ipc/common/mailbox.mojom";
@@ -94,14 +95,5 @@ interface RenderMessageFilter {
[Sync] CreateFullscreenWidget(int32 opener_id)
=> (int32 route_id);
- // The 2 following methods belong to a future CC related mojom.
- // For now they need to be part of this channel associated interface to
- // prevent running into message ordering issues (CC trying to access a shared
- // bitmap before the registration message below made it to the browser).
- //
- // Informs the browser that the child allocated a shared bitmap.
- AllocatedSharedBitmap(handle<shared_buffer> buffer, gpu.mojom.Mailbox id);
-
- // Informs the browser that the child deleted a shared bitmap.
- DeletedSharedBitmap(gpu.mojom.Mailbox id);
+ GetSharedBitmapManager(associated cc.mojom.SharedBitmapManager& bitmap_manager);
};
diff --git a/chromium/content/common/resize_params.cc b/chromium/content/common/resize_params.cc
index 49199a7d851..24d499aba0b 100644
--- a/chromium/content/common/resize_params.cc
+++ b/chromium/content/common/resize_params.cc
@@ -11,7 +11,7 @@ ResizeParams::ResizeParams()
top_controls_height(0.f),
bottom_controls_height(0.f),
is_fullscreen_granted(false),
- display_mode(blink::WebDisplayModeUndefined),
+ display_mode(blink::kWebDisplayModeUndefined),
needs_resize_ack(false) {}
ResizeParams::ResizeParams(const ResizeParams& other) = default;
diff --git a/chromium/content/common/resource_messages.h b/chromium/content/common/resource_messages.h
index 882b6db372d..64a696621e6 100644
--- a/chromium/content/common/resource_messages.h
+++ b/chromium/content/common/resource_messages.h
@@ -137,7 +137,7 @@ IPC_ENUM_TRAITS_MAX_VALUE(net::EffectiveConnectionType,
net::EFFECTIVE_CONNECTION_TYPE_LAST - 1)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebMixedContentContextType,
- blink::WebMixedContentContextType::Last)
+ blink::WebMixedContentContextType::kLast)
IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseHead)
IPC_STRUCT_TRAITS_PARENT(content::ResourceResponseInfo)
@@ -279,7 +279,7 @@ IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedResponse,
// Sent when cached metadata from a resource request is ready.
IPC_MESSAGE_CONTROL2(ResourceMsg_ReceivedCachedMetadata,
int /* request_id */,
- std::vector<char> /* data */)
+ std::vector<uint8_t> /* data */)
// Sent as upload progress is being made.
IPC_MESSAGE_CONTROL3(ResourceMsg_UploadProgress,
@@ -312,14 +312,6 @@ IPC_MESSAGE_CONTROL4(ResourceMsg_SetDataBuffer,
int /* shm_size */,
base::ProcessId /* renderer_pid */)
-// Sent when a chunk of data from a resource request is ready, and the resource
-// is expected to be small enough to fit in the inlined buffer.
-// The data is sent as a part of IPC message.
-IPC_MESSAGE_CONTROL3(ResourceMsg_InlinedDataChunkReceived,
- int /* request_id */,
- std::vector<char> /* data */,
- int /* encoded_data_length */)
-
// Sent when some data from a resource request is ready. The data offset and
// length specify a byte range into the shared memory buffer provided by the
// SetDataBuffer message.
diff --git a/chromium/content/common/resource_request.h b/chromium/content/common/resource_request.h
index 2cf0ee50a2b..21219fbd007 100644
--- a/chromium/content/common/resource_request.h
+++ b/chromium/content/common/resource_request.h
@@ -56,11 +56,11 @@ struct CONTENT_EXPORT ResourceRequest {
GURL referrer;
// The referrer policy to use.
- blink::WebReferrerPolicy referrer_policy = blink::WebReferrerPolicyAlways;
+ blink::WebReferrerPolicy referrer_policy = blink::kWebReferrerPolicyAlways;
// The frame's visibility state.
blink::WebPageVisibilityState visibility_state =
- blink::WebPageVisibilityStateVisible;
+ blink::kWebPageVisibilityStateVisible;
// Additional HTTP request headers.
//
@@ -121,7 +121,7 @@ struct CONTENT_EXPORT ResourceRequest {
// The mixed content context type to be used for mixed content checks.
blink::WebMixedContentContextType fetch_mixed_content_context_type =
- blink::WebMixedContentContextType::Blockable;
+ blink::WebMixedContentContextType::kBlockable;
// The frame type passed to the ServiceWorker.
RequestContextFrameType fetch_frame_type =
diff --git a/chromium/content/common/sandbox_linux/android/sandbox_bpf_base_policy_android.cc b/chromium/content/common/sandbox_linux/android/sandbox_bpf_base_policy_android.cc
index 79116a0580b..aad26f63f79 100644
--- a/chromium/content/common/sandbox_linux/android/sandbox_bpf_base_policy_android.cc
+++ b/chromium/content/common/sandbox_linux/android/sandbox_bpf_base_policy_android.cc
@@ -80,8 +80,10 @@ ResultExpr SandboxBPFBasePolicyAndroid::EvaluateSyscall(int sysno) const {
#endif
#if defined(__x86_64__) || defined(__aarch64__)
case __NR_newfstatat:
+ case __NR_fstatfs:
#elif defined(__i386__) || defined(__arm__) || defined(__mips__)
case __NR_fstatat64:
+ case __NR_fstatfs64:
case __NR_getdents:
#endif
case __NR_getdents64:
diff --git a/chromium/content/common/sandbox_linux/bpf_gpu_policy_linux.cc b/chromium/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
index 09eedbb37e5..daace41ca7b 100644
--- a/chromium/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
+++ b/chromium/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
@@ -27,7 +27,6 @@
#include "build/build_config.h"
#include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h"
#include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h"
-#include "content/common/set_process_title.h"
#include "content/public/common/content_switches.h"
#include "sandbox/linux/bpf_dsl/bpf_dsl.h"
#include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h"
@@ -35,6 +34,7 @@
#include "sandbox/linux/syscall_broker/broker_file_permission.h"
#include "sandbox/linux/syscall_broker/broker_process.h"
#include "sandbox/linux/system_headers/linux_syscalls.h"
+#include "services/service_manager/embedder/set_process_title.h"
using sandbox::arch_seccomp_data;
using sandbox::bpf_dsl::Allow;
@@ -224,7 +224,7 @@ void UpdateProcessTypeToGpuBroker() {
// Update the process title. The argv was already cached by the call to
// SetProcessTitleFromCommandLine in content_main_runner.cc, so we can pass
// NULL here (we don't have the original argv at this point).
- SetProcessTitleFromCommandLine(NULL);
+ service_manager::SetProcessTitleFromCommandLine(nullptr);
}
bool UpdateProcessTypeAndEnableSandbox(
diff --git a/chromium/content/common/sandbox_mac_diraccess_unittest.mm b/chromium/content/common/sandbox_mac_diraccess_unittest.mm
index 828395fc744..5cf973f0f59 100644
--- a/chromium/content/common/sandbox_mac_diraccess_unittest.mm
+++ b/chromium/content/common/sandbox_mac_diraccess_unittest.mm
@@ -39,13 +39,13 @@ class MacDirAccessSandboxTest : public base::MultiProcessTest {
public:
bool CheckSandbox(const std::string& directory_to_try) {
setenv(kSandboxAccessPathKey, directory_to_try.c_str(), 1);
- base::Process child_process = SpawnChild("mac_sandbox_path_access");
- if (!child_process.IsValid()) {
+ base::SpawnChildResult spawn_child = SpawnChild("mac_sandbox_path_access");
+ if (!spawn_child.process.IsValid()) {
LOG(WARNING) << "SpawnChild failed";
return false;
}
int code = -1;
- if (!child_process.WaitForExit(&code)) {
+ if (!spawn_child.process.WaitForExit(&code)) {
LOG(WARNING) << "Process::WaitForExit failed";
return false;
}
diff --git a/chromium/content/common/sandbox_mac_unittest_helper.mm b/chromium/content/common/sandbox_mac_unittest_helper.mm
index 5988ffe6cfa..9d8ddd45afe 100644
--- a/chromium/content/common/sandbox_mac_unittest_helper.mm
+++ b/chromium/content/common/sandbox_mac_unittest_helper.mm
@@ -77,13 +77,13 @@ bool MacSandboxTest::RunTestInSandbox(SandboxType sandbox_type,
if (test_data)
setenv(kTestDataKey, test_data, 1);
- base::Process child_process = SpawnChild("mac_sandbox_test_runner");
- if (!child_process.IsValid()) {
+ base::SpawnChildResult spawn_child = SpawnChild("mac_sandbox_test_runner");
+ if (!spawn_child.process.IsValid()) {
LOG(WARNING) << "SpawnChild failed";
return false;
}
int code = -1;
- if (!child_process.WaitForExit(&code)) {
+ if (!spawn_child.process.WaitForExit(&code)) {
LOG(WARNING) << "Process::WaitForExit failed";
return false;
}
diff --git a/chromium/content/common/sandbox_win.cc b/chromium/content/common/sandbox_win.cc
index 1b139b06f59..c1ab69baa8f 100644
--- a/chromium/content/common/sandbox_win.cc
+++ b/chromium/content/common/sandbox_win.cc
@@ -10,6 +10,7 @@
#include "base/base_switches.h"
#include "base/command_line.h"
+#include "base/debug/activity_tracker.h"
#include "base/debug/profiler.h"
#include "base/files/file_util.h"
#include "base/hash.h"
@@ -838,6 +839,13 @@ sandbox::ResultCode StartSandboxedProcess(
TRACE_EVENT_END0("startup", "StartProcessWithAccess::LAUNCHPROCESS");
+ base::debug::GlobalActivityTracker* tracker =
+ base::debug::GlobalActivityTracker::Get();
+ if (tracker) {
+ tracker->RecordProcessLaunch(target.process_id(),
+ cmd_line->GetCommandLineString());
+ }
+
if (sandbox::SBOX_ALL_OK != result) {
UMA_HISTOGRAM_SPARSE_SLOWLY("Process.Sandbox.Launch.Error", last_error);
if (result == sandbox::SBOX_ERROR_GENERIC)
diff --git a/chromium/content/common/screen_orientation_messages.h b/chromium/content/common/screen_orientation_messages.h
deleted file mode 100644
index fd456622f12..00000000000
--- a/chromium/content/common/screen_orientation_messages.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.
-
-// IPC messages for screen orientation.
-// Multiply-included message file, hence no include guard.
-
-#include "content/common/content_export.h"
-#include "ipc/ipc_message_macros.h"
-#include "third_party/WebKit/public/platform/modules/screen_orientation/WebLockOrientationError.h"
-#include "third_party/WebKit/public/platform/modules/screen_orientation/WebScreenOrientationLockType.h"
-
-#undef IPC_MESSAGE_EXPORT
-#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
-
-#define IPC_MESSAGE_START ScreenOrientationMsgStart
-
-// Only used by content/common/manifest_manager_messages.h.
-IPC_ENUM_TRAITS_MIN_MAX_VALUE(blink::WebScreenOrientationLockType,
- blink::WebScreenOrientationLockDefault,
- blink::WebScreenOrientationLockNatural)
diff --git a/chromium/content/common/service_manager/child_connection.cc b/chromium/content/common/service_manager/child_connection.cc
index 42faac05185..63bea119e43 100644
--- a/chromium/content/common/service_manager/child_connection.cc
+++ b/chromium/content/common/service_manager/child_connection.cc
@@ -8,6 +8,7 @@
#include <utility>
#include "base/macros.h"
+#include "content/common/child.mojom.h"
#include "content/public/common/service_manager_connection.h"
#include "mojo/edk/embedder/embedder.h"
#include "mojo/public/cpp/system/message_pipe.h"
@@ -18,20 +19,6 @@
namespace content {
-namespace {
-
-void CallBinderOnTaskRunner(
- const service_manager::InterfaceRegistry::Binder& binder,
- scoped_refptr<base::SequencedTaskRunner> task_runner,
- const std::string& interface_name,
- mojo::ScopedMessagePipeHandle request_handle) {
- task_runner->PostTask(
- FROM_HERE,
- base::Bind(binder, interface_name, base::Passed(&request_handle)));
-}
-
-} // namespace
-
class ChildConnection::IOThreadContext
: public base::RefCountedThreadSafe<IOThreadContext> {
public:
@@ -45,15 +32,22 @@ class ChildConnection::IOThreadContext
io_task_runner_ = io_task_runner;
std::unique_ptr<service_manager::Connector> io_thread_connector;
if (connector)
- io_thread_connector = connector->Clone();
+ connector_ = connector->Clone();
+ child_identity_ = child_identity;
io_task_runner_->PostTask(
FROM_HERE,
base::Bind(&IOThreadContext::InitializeOnIOThread, this,
child_identity,
- base::Passed(&io_thread_connector),
base::Passed(&service_pipe)));
}
+ void BindInterface(const std::string& interface_name,
+ mojo::ScopedMessagePipeHandle interface_pipe) {
+ io_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&IOThreadContext::BindInterfaceOnIOThread, this,
+ interface_name, base::Passed(&interface_pipe)));
+ }
+
void ShutDown() {
if (!io_task_runner_)
return;
@@ -63,12 +57,11 @@ class ChildConnection::IOThreadContext
DCHECK(posted);
}
- void GetRemoteInterfaceOnIOThread(
- const std::string& interface_name,
- mojo::ScopedMessagePipeHandle request_handle) {
- if (connection_) {
- connection_->GetRemoteInterfaces()->GetInterface(
- interface_name, std::move(request_handle));
+ void BindInterfaceOnIOThread(const std::string& interface_name,
+ mojo::ScopedMessagePipeHandle request_handle) {
+ if (connector_) {
+ connector_->BindInterface(child_identity_, interface_name,
+ std::move(request_handle));
}
}
@@ -86,7 +79,6 @@ class ChildConnection::IOThreadContext
void InitializeOnIOThread(
const service_manager::Identity& child_identity,
- std::unique_ptr<service_manager::Connector> connector,
mojo::ScopedMessagePipeHandle service_pipe) {
service_manager::mojom::ServicePtr service;
service.Bind(mojo::InterfacePtrInfo<service_manager::mojom::Service>(
@@ -94,16 +86,15 @@ class ChildConnection::IOThreadContext
service_manager::mojom::PIDReceiverRequest pid_receiver_request(
&pid_receiver_);
- if (connector) {
- connector->StartService(child_identity,
- std::move(service),
- std::move(pid_receiver_request));
- connection_ = connector->Connect(child_identity);
+ if (connector_) {
+ connector_->StartService(child_identity, std::move(service),
+ std::move(pid_receiver_request));
+ connector_->BindInterface(child_identity, &child_);
}
}
void ShutDownOnIOThread() {
- connection_.reset();
+ connector_.reset();
pid_receiver_.reset();
}
@@ -114,7 +105,11 @@ class ChildConnection::IOThreadContext
}
scoped_refptr<base::SequencedTaskRunner> io_task_runner_;
- std::unique_ptr<service_manager::Connection> connection_;
+ // Usable from the IO thread only.
+ std::unique_ptr<service_manager::Connector> connector_;
+ service_manager::Identity child_identity_;
+ // ServiceManagerConnection in the child monitors the lifetime of this pipe.
+ mojom::ChildPtr child_;
service_manager::mojom::PIDReceiverPtr pid_receiver_;
DISALLOW_COPY_AND_ASSIGN(IOThreadContext);
@@ -134,16 +129,18 @@ ChildConnection::ChildConnection(
context_->Initialize(child_identity_, connector,
process_connection->CreateMessagePipe(&service_token_),
io_task_runner);
- remote_interfaces_.Forward(
- base::Bind(&CallBinderOnTaskRunner,
- base::Bind(&IOThreadContext::GetRemoteInterfaceOnIOThread,
- context_), io_task_runner));
}
ChildConnection::~ChildConnection() {
context_->ShutDown();
}
+void ChildConnection::BindInterface(
+ const std::string& interface_name,
+ mojo::ScopedMessagePipeHandle interface_pipe) {
+ context_->BindInterface(interface_name, std::move(interface_pipe));
+}
+
void ChildConnection::SetProcessHandle(base::ProcessHandle handle) {
process_handle_ = handle;
context_->SetProcessHandle(handle);
diff --git a/chromium/content/common/service_manager/child_connection.h b/chromium/content/common/service_manager/child_connection.h
index 01ece56b70b..4799df57dd8 100644
--- a/chromium/content/common/service_manager/child_connection.h
+++ b/chromium/content/common/service_manager/child_connection.h
@@ -16,7 +16,6 @@
#include "content/common/content_export.h"
#include "mojo/edk/embedder/pending_process_connection.h"
#include "services/service_manager/public/cpp/identity.h"
-#include "services/service_manager/public/cpp/interface_provider.h"
#include "services/service_manager/public/interfaces/connector.mojom.h"
namespace service_manager {
@@ -41,9 +40,10 @@ class CONTENT_EXPORT ChildConnection {
scoped_refptr<base::SequencedTaskRunner> io_task_runner);
~ChildConnection();
- service_manager::InterfaceProvider* GetRemoteInterfaces() {
- return &remote_interfaces_;
- }
+ // Binds an implementation of |interface_name| to |interface_pipe| in the
+ // child.
+ void BindInterface(const std::string& interface_name,
+ mojo::ScopedMessagePipeHandle interface_pipe);
const service_manager::Identity& child_identity() const {
return child_identity_;
@@ -67,8 +67,6 @@ class CONTENT_EXPORT ChildConnection {
std::string service_token_;
base::ProcessHandle process_handle_ = base::kNullProcessHandle;
- service_manager::InterfaceProvider remote_interfaces_;
-
base::WeakPtrFactory<ChildConnection> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(ChildConnection);
diff --git a/chromium/content/common/service_manager/service_manager_connection_impl.cc b/chromium/content/common/service_manager/service_manager_connection_impl.cc
index 212ec813940..9e81238aa0a 100644
--- a/chromium/content/common/service_manager/service_manager_connection_impl.cc
+++ b/chromium/content/common/service_manager/service_manager_connection_impl.cc
@@ -16,6 +16,7 @@
#include "base/message_loop/message_loop.h"
#include "base/threading/thread_checker.h"
#include "base/threading/thread_task_runner_handle.h"
+#include "content/common/child.mojom.h"
#include "content/common/service_manager/embedded_service_runner.h"
#include "content/public/common/connection_filter.h"
#include "mojo/public/cpp/bindings/binding_set.h"
@@ -43,15 +44,11 @@ ServiceManagerConnection::Factory* service_manager_connection_factory = nullptr;
class ServiceManagerConnectionImpl::IOThreadContext
: public base::RefCountedThreadSafe<IOThreadContext>,
public service_manager::Service,
- public service_manager::InterfaceFactory<
- service_manager::mojom::ServiceFactory>,
- public service_manager::mojom::ServiceFactory {
+ public service_manager::mojom::ServiceFactory,
+ public mojom::Child {
public:
using InitializeCallback =
- base::Callback<void(const service_manager::Identity&)>;
- using ServiceFactoryCallback =
- base::Callback<void(service_manager::mojom::ServiceRequest,
- const std::string&)>;
+ base::Callback<void(const service_manager::ServiceInfo&)>;
IOThreadContext(
service_manager::mojom::ServiceRequest service_request,
@@ -62,24 +59,22 @@ class ServiceManagerConnectionImpl::IOThreadContext
io_task_runner_(io_task_runner),
io_thread_connector_(std::move(io_thread_connector)),
pending_connector_request_(std::move(connector_request)),
+ child_binding_(this),
weak_factory_(this) {
// This will be reattached by any of the IO thread functions on first call.
io_thread_checker_.DetachFromThread();
}
// Safe to call from any thread.
- void Start(
- const InitializeCallback& initialize_callback,
- const ServiceManagerConnection::OnConnectHandler& on_connect_callback,
- const ServiceFactoryCallback& create_service_callback,
- const base::Closure& stop_callback) {
+ void Start(const InitializeCallback& local_info_available_callback,
+ const InitializeCallback& browser_info_available_callback,
+ const base::Closure& stop_callback) {
DCHECK(!started_);
started_ = true;
callback_task_runner_ = base::ThreadTaskRunnerHandle::Get();
- initialize_handler_ = initialize_callback;
- on_connect_callback_ = on_connect_callback;
- create_service_callback_ = create_service_callback;
+ local_info_available_callback_ = local_info_available_callback;
+ browser_info_available_callback_ = browser_info_available_callback;
stop_callback_ = stop_callback;
io_task_runner_->PostTask(
FROM_HERE, base::Bind(&IOThreadContext::StartOnIOThread, this));
@@ -126,6 +121,21 @@ class ServiceManagerConnectionImpl::IOThreadContext
base::ThreadTaskRunnerHandle::Get(), binder);
}
+ void AddEmbeddedService(const std::string& name, const ServiceInfo& info) {
+ io_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&ServiceManagerConnectionImpl::IOThreadContext::
+ AddEmbeddedServiceRequestHandlerOnIoThread,
+ this, name, info));
+ }
+
+ void AddServiceRequestHandler(const std::string& name,
+ const ServiceRequestHandler& handler) {
+ io_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&ServiceManagerConnectionImpl::IOThreadContext::
+ AddServiceRequestHandlerOnIoThread,
+ this, name, handler));
+ }
+
private:
friend class base::RefCountedThreadSafe<IOThreadContext>;
@@ -203,6 +213,9 @@ class ServiceManagerConnectionImpl::IOThreadContext
service_context_.reset();
ClearConnectionFiltersOnIOThread();
+
+ request_handlers_.clear();
+ embedded_services_.clear();
}
void ClearConnectionFiltersOnIOThread() {
@@ -224,53 +237,83 @@ class ServiceManagerConnectionImpl::IOThreadContext
has_browser_connection_ = false;
}
+ void AddEmbeddedServiceRequestHandlerOnIoThread(const std::string& name,
+ const ServiceInfo& info) {
+ DCHECK(io_thread_checker_.CalledOnValidThread());
+ std::unique_ptr<EmbeddedServiceRunner> service(
+ new EmbeddedServiceRunner(name, info));
+ AddServiceRequestHandlerOnIoThread(
+ name, base::Bind(&EmbeddedServiceRunner::BindServiceRequest,
+ base::Unretained(service.get())));
+ auto result =
+ embedded_services_.insert(std::make_pair(name, std::move(service)));
+ DCHECK(result.second);
+ }
+
+ void AddServiceRequestHandlerOnIoThread(
+ const std::string& name,
+ const ServiceRequestHandler& handler) {
+ DCHECK(io_thread_checker_.CalledOnValidThread());
+ auto result = request_handlers_.insert(std::make_pair(name, handler));
+ DCHECK(result.second);
+ }
+
/////////////////////////////////////////////////////////////////////////////
// service_manager::Service implementation
void OnStart() override {
DCHECK(io_thread_checker_.CalledOnValidThread());
- DCHECK(!initialize_handler_.is_null());
+ DCHECK(!local_info_available_callback_.is_null());
local_info_ = context()->local_info();
- InitializeCallback handler = base::ResetAndReturn(&initialize_handler_);
+ InitializeCallback handler =
+ base::ResetAndReturn(&local_info_available_callback_);
callback_task_runner_->PostTask(FROM_HERE,
- base::Bind(handler, local_info_.identity));
+ base::Bind(handler, local_info_));
}
- bool OnConnect(const service_manager::ServiceInfo& remote_info,
- service_manager::InterfaceRegistry* registry) override {
+ void OnBindInterface(const service_manager::ServiceInfo& source_info,
+ const std::string& interface_name,
+ mojo::ScopedMessagePipeHandle interface_pipe) override {
DCHECK(io_thread_checker_.CalledOnValidThread());
- callback_task_runner_->PostTask(
- FROM_HERE, base::Bind(on_connect_callback_, local_info_, remote_info));
-
- std::string remote_service = remote_info.identity.name();
- if (remote_service == service_manager::mojom::kServiceName) {
- // Only expose the ServiceFactory interface to the Service Manager.
- registry->AddInterface<service_manager::mojom::ServiceFactory>(this);
- return true;
+ std::string remote_service = source_info.identity.name();
+ // Only expose the ServiceFactory interface to the Service Manager.
+ if (remote_service == service_manager::mojom::kServiceName &&
+ interface_name == service_manager::mojom::ServiceFactory::Name_) {
+ factory_bindings_.AddBinding(
+ this, mojo::MakeRequest<service_manager::mojom::ServiceFactory>(
+ std::move(interface_pipe)));
+ return;
}
- bool accept = false;
{
base::AutoLock lock(lock_);
for (auto& entry : connection_filters_) {
- accept |= entry.second->OnConnect(remote_info.identity, registry,
- service_context_->connector());
+ entry.second->OnBindInterface(source_info, interface_name,
+ &interface_pipe,
+ service_context_->connector());
+ // A filter may have bound the interface, claiming the pipe.
+ if (!interface_pipe.is_valid())
+ return;
}
}
- if (remote_service == "content_browser" &&
- !has_browser_connection_) {
- has_browser_connection_ = true;
- registry->set_default_binder(default_browser_binder_);
- registry->AddConnectionLostClosure(
- base::Bind(&IOThreadContext::OnBrowserConnectionLost, this));
- return true;
+ if (remote_service == "content_browser") {
+ if (interface_name == mojom::Child::Name_ && !has_browser_connection_) {
+ has_browser_connection_ = true;
+ InitializeCallback handler =
+ base::ResetAndReturn(&browser_info_available_callback_);
+ callback_task_runner_->PostTask(FROM_HERE,
+ base::Bind(handler, source_info));
+
+ child_binding_.Bind(std::move(interface_pipe));
+ child_binding_.set_connection_error_handler(
+ base::Bind(&IOThreadContext::OnBrowserConnectionLost, this));
+ } else {
+ default_browser_binder_.Run(interface_name, std::move(interface_pipe));
+ }
}
-
- // If no filters were interested, reject the connection.
- return accept;
}
bool OnServiceManagerConnectionLost() override {
@@ -280,24 +323,15 @@ class ServiceManagerConnectionImpl::IOThreadContext
}
/////////////////////////////////////////////////////////////////////////////
- // service_manager::InterfaceFactory<service_manager::mojom::ServiceFactory>
- // implementation
-
- void Create(const service_manager::Identity& remote_identity,
- service_manager::mojom::ServiceFactoryRequest request) override {
- DCHECK(io_thread_checker_.CalledOnValidThread());
- factory_bindings_.AddBinding(this, std::move(request));
- }
-
- /////////////////////////////////////////////////////////////////////////////
// service_manager::mojom::ServiceFactory implementation
void CreateService(service_manager::mojom::ServiceRequest request,
const std::string& name) override {
DCHECK(io_thread_checker_.CalledOnValidThread());
- callback_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(create_service_callback_, base::Passed(&request), name));
+ auto it = request_handlers_.find(name);
+ DCHECK(it != request_handlers_.end())
+ << "Can't create service " << name << ". No handler found.";
+ it->second.Run(std::move(request));
}
static void CallBinderOnTaskRunner(
@@ -324,13 +358,8 @@ class ServiceManagerConnectionImpl::IOThreadContext
scoped_refptr<base::SequencedTaskRunner> callback_task_runner_;
// Callback to run once Service::OnStart is invoked.
- InitializeCallback initialize_handler_;
-
- // Callback to run when a connection request is received.
- ServiceManagerConnection::OnConnectHandler on_connect_callback_;
-
- // Callback to run when a new Service request is received.
- ServiceFactoryCallback create_service_callback_;
+ InitializeCallback local_info_available_callback_;
+ InitializeCallback browser_info_available_callback_;
// Callback to run if the service is stopped by the service manager.
base::Closure stop_callback_;
@@ -359,6 +388,12 @@ class ServiceManagerConnectionImpl::IOThreadContext
base::Lock lock_;
std::map<int, std::unique_ptr<ConnectionFilter>> connection_filters_;
+ std::unordered_map<std::string, std::unique_ptr<EmbeddedServiceRunner>>
+ embedded_services_;
+ std::unordered_map<std::string, ServiceRequestHandler> request_handlers_;
+
+ mojo::Binding<mojom::Child> child_binding_;
+
base::WeakPtrFactory<IOThreadContext> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(IOThreadContext);
@@ -429,11 +464,9 @@ ServiceManagerConnectionImpl::~ServiceManagerConnectionImpl() {
void ServiceManagerConnectionImpl::Start() {
context_->Start(
- base::Bind(&ServiceManagerConnectionImpl::OnContextInitialized,
+ base::Bind(&ServiceManagerConnectionImpl::OnLocalServiceInfoAvailable,
weak_factory_.GetWeakPtr()),
- base::Bind(&ServiceManagerConnectionImpl::OnConnect,
- weak_factory_.GetWeakPtr()),
- base::Bind(&ServiceManagerConnectionImpl::CreateService,
+ base::Bind(&ServiceManagerConnectionImpl::OnBrowserServiceInfoAvailable,
weak_factory_.GetWeakPtr()),
base::Bind(&ServiceManagerConnectionImpl::OnConnectionLost,
weak_factory_.GetWeakPtr()));
@@ -443,9 +476,14 @@ service_manager::Connector* ServiceManagerConnectionImpl::GetConnector() {
return connector_.get();
}
-const service_manager::Identity& ServiceManagerConnectionImpl::GetIdentity()
+const service_manager::ServiceInfo& ServiceManagerConnectionImpl::GetLocalInfo()
const {
- return identity_;
+ return local_info_;
+}
+
+const service_manager::ServiceInfo&
+ServiceManagerConnectionImpl::GetBrowserInfo() const {
+ return browser_info_;
}
void ServiceManagerConnectionImpl::SetConnectionLostClosure(
@@ -476,21 +514,13 @@ void ServiceManagerConnectionImpl::RemoveConnectionFilter(int filter_id) {
void ServiceManagerConnectionImpl::AddEmbeddedService(const std::string& name,
const ServiceInfo& info) {
- std::unique_ptr<EmbeddedServiceRunner> service(
- new EmbeddedServiceRunner(name, info));
- AddServiceRequestHandler(
- name, base::Bind(&EmbeddedServiceRunner::BindServiceRequest,
- base::Unretained(service.get())));
- auto result =
- embedded_services_.insert(std::make_pair(name, std::move(service)));
- DCHECK(result.second);
+ context_->AddEmbeddedService(name, info);
}
void ServiceManagerConnectionImpl::AddServiceRequestHandler(
const std::string& name,
const ServiceRequestHandler& handler) {
- auto result = request_handlers_.insert(std::make_pair(name, handler));
- DCHECK(result.second);
+ context_->AddServiceRequestHandler(name, handler);
}
int ServiceManagerConnectionImpl::AddOnConnectHandler(
@@ -506,19 +536,16 @@ void ServiceManagerConnectionImpl::RemoveOnConnectHandler(int id) {
on_connect_handlers_.erase(it);
}
-void ServiceManagerConnectionImpl::CreateService(
- service_manager::mojom::ServiceRequest request,
- const std::string& name) {
- auto it = request_handlers_.find(name);
- DCHECK(it != request_handlers_.end())
- << "Can't create service " << name << ". No handler found.";
- if (it != request_handlers_.end())
- it->second.Run(std::move(request));
+void ServiceManagerConnectionImpl::OnLocalServiceInfoAvailable(
+ const service_manager::ServiceInfo& local_info) {
+ local_info_ = local_info;
}
-void ServiceManagerConnectionImpl::OnContextInitialized(
- const service_manager::Identity& identity) {
- identity_ = identity;
+void ServiceManagerConnectionImpl::OnBrowserServiceInfoAvailable(
+ const service_manager::ServiceInfo& browser_info) {
+ browser_info_ = browser_info;
+ for (auto& handler : on_connect_handlers_)
+ handler.second.Run(local_info_, browser_info_);
}
void ServiceManagerConnectionImpl::OnConnectionLost() {
@@ -526,14 +553,6 @@ void ServiceManagerConnectionImpl::OnConnectionLost() {
connection_lost_handler_.Run();
}
-void ServiceManagerConnectionImpl::OnConnect(
- const service_manager::ServiceInfo& local_info,
- const service_manager::ServiceInfo& remote_info) {
- local_info_ = local_info;
- for (auto& handler : on_connect_handlers_)
- handler.second.Run(local_info, remote_info);
-}
-
void ServiceManagerConnectionImpl::GetInterface(
service_manager::mojom::InterfaceProvider* provider,
const std::string& interface_name,
diff --git a/chromium/content/common/service_manager/service_manager_connection_impl.h b/chromium/content/common/service_manager/service_manager_connection_impl.h
index 8f4f9bd5c7a..c950283b81b 100644
--- a/chromium/content/common/service_manager/service_manager_connection_impl.h
+++ b/chromium/content/common/service_manager/service_manager_connection_impl.h
@@ -11,6 +11,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/sequenced_task_runner.h"
+#include "content/common/content_export.h"
#include "content/public/common/service_manager_connection.h"
#include "mojo/public/cpp/system/message_pipe.h"
#include "services/service_manager/public/cpp/identity.h"
@@ -22,9 +23,8 @@ class Connector;
namespace content {
-class EmbeddedServiceRunner;
-
-class ServiceManagerConnectionImpl : public ServiceManagerConnection {
+class CONTENT_EXPORT ServiceManagerConnectionImpl
+ : public ServiceManagerConnection {
public:
explicit ServiceManagerConnectionImpl(
service_manager::mojom::ServiceRequest request,
@@ -37,7 +37,8 @@ class ServiceManagerConnectionImpl : public ServiceManagerConnection {
// ServiceManagerConnection:
void Start() override;
service_manager::Connector* GetConnector() override;
- const service_manager::Identity& GetIdentity() const override;
+ const service_manager::ServiceInfo& GetLocalInfo() const override;
+ const service_manager::ServiceInfo& GetBrowserInfo() const override;
void SetConnectionLostClosure(const base::Closure& closure) override;
void SetupInterfaceRequestProxies(
service_manager::InterfaceRegistry* registry,
@@ -52,28 +53,23 @@ class ServiceManagerConnectionImpl : public ServiceManagerConnection {
int AddOnConnectHandler(const OnConnectHandler& handler) override;
void RemoveOnConnectHandler(int id) override;
- void OnContextInitialized(const service_manager::Identity& identity);
+ void OnLocalServiceInfoAvailable(
+ const service_manager::ServiceInfo& local_info);
+ void OnBrowserServiceInfoAvailable(
+ const service_manager::ServiceInfo& browser_info);
void OnConnectionLost();
- void OnConnect(const service_manager::ServiceInfo& local_info,
- const service_manager::ServiceInfo& remote_info);
- void CreateService(service_manager::mojom::ServiceRequest request,
- const std::string& name);
void GetInterface(service_manager::mojom::InterfaceProvider* provider,
const std::string& interface_name,
mojo::ScopedMessagePipeHandle request_handle);
- service_manager::Identity identity_;
service_manager::ServiceInfo local_info_;
- service_manager::ServiceInfo last_remote_info_;
+ service_manager::ServiceInfo browser_info_;
std::unique_ptr<service_manager::Connector> connector_;
scoped_refptr<IOThreadContext> context_;
base::Closure connection_lost_handler_;
- std::unordered_map<std::string, std::unique_ptr<EmbeddedServiceRunner>>
- embedded_services_;
- std::unordered_map<std::string, ServiceRequestHandler> request_handlers_;
int next_on_connect_handler_id_ = 0;
std::map<int, OnConnectHandler> on_connect_handlers_;
diff --git a/chromium/content/common/service_manager/service_manager_connection_impl_unittest.cc b/chromium/content/common/service_manager/service_manager_connection_impl_unittest.cc
new file mode 100644
index 00000000000..ecca7a6b7e4
--- /dev/null
+++ b/chromium/content/common/service_manager/service_manager_connection_impl_unittest.cc
@@ -0,0 +1,58 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/service_manager/service_manager_connection_impl.h"
+
+#include "base/message_loop/message_loop.h"
+#include "base/synchronization/waitable_event.h"
+#include "base/threading/thread.h"
+#include "services/service_manager/public/cpp/identity.h"
+#include "services/service_manager/public/cpp/service.h"
+#include "services/service_manager/public/interfaces/constants.mojom.h"
+#include "services/service_manager/public/interfaces/service_factory.mojom.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace content {
+namespace {
+
+constexpr char kTestServiceName[] = "test service";
+
+std::unique_ptr<service_manager::Service> LaunchService(
+ base::WaitableEvent* event) {
+ event->Signal();
+ return base::MakeUnique<service_manager::Service>();
+}
+
+} // namespace
+
+TEST(ServiceManagerConnectionImplTest, ServiceLaunchThreading) {
+ base::MessageLoop message_loop;
+ base::Thread io_thread("ServiceManagerConnectionImplTest IO Thread");
+ io_thread.Start();
+ service_manager::mojom::ServicePtr service;
+ ServiceManagerConnectionImpl connection_impl(mojo::MakeRequest(&service),
+ io_thread.task_runner());
+ ServiceManagerConnection& connection = connection_impl;
+ ServiceInfo info;
+ base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL,
+ base::WaitableEvent::InitialState::NOT_SIGNALED);
+ info.factory = base::Bind(&LaunchService, &event);
+ info.task_runner = io_thread.task_runner();
+ connection.AddEmbeddedService(kTestServiceName, info);
+ connection.Start();
+ service_manager::ServiceInfo source_info(
+ {service_manager::mojom::kServiceName,
+ service_manager::mojom::kRootUserID},
+ service_manager::InterfaceProviderSpecMap{});
+ service_manager::mojom::ServiceFactoryPtr factory;
+ service->OnBindInterface(source_info,
+ service_manager::mojom::ServiceFactory::Name_,
+ mojo::MakeRequest(&factory).PassMessagePipe(),
+ base::Bind(&base::DoNothing));
+ service_manager::mojom::ServicePtr created_service;
+ factory->CreateService(mojo::MakeRequest(&created_service), kTestServiceName);
+ event.Wait();
+}
+
+} // namespace content
diff --git a/chromium/content/common/service_worker/service_worker_client_info.cc b/chromium/content/common/service_worker/service_worker_client_info.cc
index a412fa0b7de..1a6ba5513dc 100644
--- a/chromium/content/common/service_worker/service_worker_client_info.cc
+++ b/chromium/content/common/service_worker/service_worker_client_info.cc
@@ -11,12 +11,12 @@ namespace content {
ServiceWorkerClientInfo::ServiceWorkerClientInfo()
: ServiceWorkerClientInfo(std::string(),
- blink::WebPageVisibilityStateLast,
+ blink::kWebPageVisibilityStateLast,
false,
GURL(),
REQUEST_CONTEXT_FRAME_TYPE_LAST,
base::TimeTicks(),
- blink::WebServiceWorkerClientTypeLast) {}
+ blink::kWebServiceWorkerClientTypeLast) {}
ServiceWorkerClientInfo::ServiceWorkerClientInfo(
const std::string& client_uuid,
@@ -38,11 +38,10 @@ ServiceWorkerClientInfo::ServiceWorkerClientInfo(
const ServiceWorkerClientInfo& other) = default;
bool ServiceWorkerClientInfo::IsEmpty() const {
- return page_visibility_state == blink::WebPageVisibilityStateLast &&
- is_focused == false &&
- url.is_empty() &&
+ return page_visibility_state == blink::kWebPageVisibilityStateLast &&
+ is_focused == false && url.is_empty() &&
frame_type == REQUEST_CONTEXT_FRAME_TYPE_LAST &&
- client_type == blink::WebServiceWorkerClientTypeLast;
+ client_type == blink::kWebServiceWorkerClientTypeLast;
}
bool ServiceWorkerClientInfo::IsValid() const {
diff --git a/chromium/content/common/service_worker/service_worker_event_dispatcher.mojom b/chromium/content/common/service_worker/service_worker_event_dispatcher.mojom
index e47c085b9d9..2f309bb3bd2 100644
--- a/chromium/content/common/service_worker/service_worker_event_dispatcher.mojom
+++ b/chromium/content/common/service_worker/service_worker_event_dispatcher.mojom
@@ -9,6 +9,7 @@ import "content/common/url_loader.mojom";
import "mojo/common/string16.mojom";
import "mojo/common/time.mojom";
import "third_party/WebKit/public/platform/modules/background_sync/background_sync.mojom";
+import "third_party/WebKit/public/platform/modules/fetch/fetch_api_request.mojom";
import "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom";
import "url/mojo/origin.mojom";
@@ -19,11 +20,24 @@ struct PlatformNotificationData;
struct PushEventPayload;
[Native]
-struct ServiceWorkerFetchRequest;
+struct ServiceWorkerResponse;
[Native]
struct ExtendableMessageEventSource;
+// TODO(peter): Move this to Blink when ServiceWorkerResponse has a Mojo
+// counterpart.
+struct BackgroundFetchSettledFetch {
+ blink.mojom.FetchAPIRequest request;
+ ServiceWorkerResponse response;
+};
+
+enum BackgroundFetchState {
+ PENDING,
+ SUCCEEDED,
+ FAILED
+};
+
struct FetchEventPreloadHandle {
URLLoader url_loader;
URLLoaderClient& url_loader_client_request;
@@ -38,13 +52,31 @@ struct ExtendableMessageEvent {
// Renderer-side interface bound to ServiceWorkerContextClient for dispatching
// events.
+// Those events expecting such response
+// (blink.mojom.ServiceWorkerEventStatus, mojo.common.mojom.Time) are considered
+// 'simple events'. ServiceWorkerVersion::CreateSimpleEventCallback can be used
+// to create the callback for these.
interface ServiceWorkerEventDispatcher {
DispatchActivateEvent()
=> (blink.mojom.ServiceWorkerEventStatus status,
mojo.common.mojom.Time dispatch_event_time);
+ DispatchBackgroundFetchAbortEvent(string tag)
+ => (blink.mojom.ServiceWorkerEventStatus status,
+ mojo.common.mojom.Time dispatch_event_time);
+ DispatchBackgroundFetchClickEvent(string tag, BackgroundFetchState state)
+ => (blink.mojom.ServiceWorkerEventStatus status,
+ mojo.common.mojom.Time dispatch_event_time);
+ DispatchBackgroundFetchFailEvent(string tag,
+ array<BackgroundFetchSettledFetch> fetches)
+ => (blink.mojom.ServiceWorkerEventStatus status,
+ mojo.common.mojom.Time dispatch_event_time);
+ DispatchBackgroundFetchedEvent(string tag,
+ array<BackgroundFetchSettledFetch> fetches)
+ => (blink.mojom.ServiceWorkerEventStatus status,
+ mojo.common.mojom.Time dispatch_event_time);
// |fetch_event_id| is used internally when sending the response back to the
// browser process.
- DispatchFetchEvent(int32 fetch_event_id, ServiceWorkerFetchRequest request,
+ DispatchFetchEvent(int32 fetch_event_id, blink.mojom.FetchAPIRequest request,
FetchEventPreloadHandle? preload_handle)
=> (blink.mojom.ServiceWorkerEventStatus status,
mojo.common.mojom.Time dispatch_event_time);
@@ -67,10 +99,18 @@ interface ServiceWorkerEventDispatcher {
blink.mojom.BackgroundSyncEventLastChance last_chance)
=> (blink.mojom.ServiceWorkerEventStatus status,
mojo.common.mojom.Time dispatch_event_time);
- DispatchPaymentRequestEvent(payments.mojom.PaymentAppRequest app_request)
+ DispatchPaymentRequestEvent(int32 payment_request_id,
+ payments.mojom.PaymentAppRequest app_request,
+ payments.mojom.PaymentAppResponseCallback response_callback)
=> (blink.mojom.ServiceWorkerEventStatus status,
mojo.common.mojom.Time dispatch_event_time);
DispatchExtendableMessageEvent(ExtendableMessageEvent event)
=> (blink.mojom.ServiceWorkerEventStatus status,
mojo.common.mojom.Time dispatch_event_time);
+
+ // Pings the service worker to check if it is responsive. If the callback is
+ // not called within a certain period of time, the browser will terminate the
+ // worker. Unlike the other functions in this interface, Ping() does not
+ // dispatch an event.
+ Ping() => ();
};
diff --git a/chromium/content/common/service_worker/service_worker_event_dispatcher.typemap b/chromium/content/common/service_worker/service_worker_event_dispatcher.typemap
index a342581c18e..3cc80860b8d 100644
--- a/chromium/content/common/service_worker/service_worker_event_dispatcher.typemap
+++ b/chromium/content/common/service_worker/service_worker_event_dispatcher.typemap
@@ -4,6 +4,7 @@
mojom = "//content/common/service_worker/service_worker_event_dispatcher.mojom"
public_headers = [
+ "//content/common/background_fetch/background_fetch_types.h",
"//content/common/service_worker/service_worker_status_code.h",
"//content/common/service_worker/service_worker_types.h",
"//content/public/common/platform_notification_data.h",
diff --git a/chromium/content/common/service_worker/service_worker_fetch_request.typemap b/chromium/content/common/service_worker/service_worker_fetch_request.typemap
new file mode 100644
index 00000000000..716ddcf6f53
--- /dev/null
+++ b/chromium/content/common/service_worker/service_worker_fetch_request.typemap
@@ -0,0 +1,24 @@
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+mojom =
+ "//third_party/WebKit/public/platform/modules/fetch/fetch_api_request.mojom"
+public_headers = [
+ "//content/common/service_worker/service_worker_types.h",
+ "//content/public/common/request_context_frame_type.h",
+ "//content/public/common/request_context_type.h",
+]
+traits_headers = [ "//content/common/service_worker/service_worker_fetch_request_struct_traits.h" ]
+sources = [
+ "//content/common/service_worker/service_worker_fetch_request_struct_traits.cc",
+]
+type_mappings = [
+ "blink.mojom.FetchCredentialsMode=::content::FetchCredentialsMode",
+ "blink.mojom.FetchRedirectMode=::content::FetchRedirectMode",
+ "blink.mojom.FetchRequestMode=::content::FetchRequestMode",
+ "blink.mojom.FetchAPIRequest=::content::ServiceWorkerFetchRequest",
+ "blink.mojom.RequestContextFrameType=::content::RequestContextFrameType",
+ "blink.mojom.RequestContextType=::content::RequestContextType",
+ "blink.mojom.ServiceWorkerFetchType=::content::ServiceWorkerFetchType",
+]
diff --git a/chromium/content/common/service_worker/service_worker_fetch_request_struct_traits.cc b/chromium/content/common/service_worker/service_worker_fetch_request_struct_traits.cc
new file mode 100644
index 00000000000..cab80997f4b
--- /dev/null
+++ b/chromium/content/common/service_worker/service_worker_fetch_request_struct_traits.cc
@@ -0,0 +1,460 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/service_worker/service_worker_fetch_request_struct_traits.h"
+
+#include "base/logging.h"
+#include "content/public/common/referrer_struct_traits.h"
+#include "url/mojo/url_gurl_struct_traits.h"
+
+namespace mojo {
+
+namespace {
+
+// Struct traits context for the FetchAPIRequest type. Since getters are invoked
+// twice when serializing the type, this reduces the load for heavy members.
+struct ServiceWorkerFetchRequestStructTraitsContext {
+ ServiceWorkerFetchRequestStructTraitsContext() = default;
+ ~ServiceWorkerFetchRequestStructTraitsContext() = default;
+
+ std::map<std::string, std::string> headers;
+};
+
+} // namespace
+
+using blink::mojom::FetchCredentialsMode;
+using blink::mojom::FetchRedirectMode;
+using blink::mojom::FetchRequestMode;
+using blink::mojom::RequestContextFrameType;
+using blink::mojom::RequestContextType;
+using blink::mojom::ServiceWorkerFetchType;
+
+FetchCredentialsMode
+EnumTraits<FetchCredentialsMode, content::FetchCredentialsMode>::ToMojom(
+ content::FetchCredentialsMode input) {
+ switch (input) {
+ case content::FETCH_CREDENTIALS_MODE_OMIT:
+ return FetchCredentialsMode::OMIT;
+ case content::FETCH_CREDENTIALS_MODE_SAME_ORIGIN:
+ return FetchCredentialsMode::SAME_ORIGIN;
+ case content::FETCH_CREDENTIALS_MODE_INCLUDE:
+ return FetchCredentialsMode::INCLUDE;
+ case content::FETCH_CREDENTIALS_MODE_PASSWORD:
+ return FetchCredentialsMode::PASSWORD;
+ }
+
+ NOTREACHED();
+ return FetchCredentialsMode::OMIT;
+}
+
+bool EnumTraits<FetchCredentialsMode, content::FetchCredentialsMode>::FromMojom(
+ FetchCredentialsMode input,
+ content::FetchCredentialsMode* out) {
+ switch (input) {
+ case FetchCredentialsMode::OMIT:
+ *out = content::FETCH_CREDENTIALS_MODE_OMIT;
+ return true;
+ case FetchCredentialsMode::SAME_ORIGIN:
+ *out = content::FETCH_CREDENTIALS_MODE_SAME_ORIGIN;
+ return true;
+ case FetchCredentialsMode::INCLUDE:
+ *out = content::FETCH_CREDENTIALS_MODE_INCLUDE;
+ return true;
+ case FetchCredentialsMode::PASSWORD:
+ *out = content::FETCH_CREDENTIALS_MODE_PASSWORD;
+ return true;
+ }
+
+ return false;
+}
+
+FetchRedirectMode
+EnumTraits<FetchRedirectMode, content::FetchRedirectMode>::ToMojom(
+ content::FetchRedirectMode input) {
+ switch (input) {
+ case content::FetchRedirectMode::FOLLOW_MODE:
+ return FetchRedirectMode::FOLLOW;
+ case content::FetchRedirectMode::ERROR_MODE:
+ return FetchRedirectMode::ERROR_MODE;
+ case content::FetchRedirectMode::MANUAL_MODE:
+ return FetchRedirectMode::MANUAL;
+ }
+
+ NOTREACHED();
+ return FetchRedirectMode::ERROR_MODE;
+}
+
+bool EnumTraits<FetchRedirectMode, content::FetchRedirectMode>::FromMojom(
+ FetchRedirectMode input,
+ content::FetchRedirectMode* out) {
+ switch (input) {
+ case FetchRedirectMode::FOLLOW:
+ *out = content::FetchRedirectMode::FOLLOW_MODE;
+ return true;
+ case FetchRedirectMode::ERROR_MODE:
+ *out = content::FetchRedirectMode::ERROR_MODE;
+ return true;
+ case FetchRedirectMode::MANUAL:
+ *out = content::FetchRedirectMode::MANUAL_MODE;
+ return true;
+ }
+
+ return false;
+}
+
+FetchRequestMode
+EnumTraits<FetchRequestMode, content::FetchRequestMode>::ToMojom(
+ content::FetchRequestMode input) {
+ switch (input) {
+ case content::FETCH_REQUEST_MODE_SAME_ORIGIN:
+ return FetchRequestMode::SAME_ORIGIN;
+ case content::FETCH_REQUEST_MODE_NO_CORS:
+ return FetchRequestMode::NO_CORS;
+ case content::FETCH_REQUEST_MODE_CORS:
+ return FetchRequestMode::CORS;
+ case content::FETCH_REQUEST_MODE_CORS_WITH_FORCED_PREFLIGHT:
+ return FetchRequestMode::CORS_WITH_FORCED_PREFLIGHT;
+ case content::FETCH_REQUEST_MODE_NAVIGATE:
+ return FetchRequestMode::NAVIGATE;
+ }
+
+ NOTREACHED();
+ return FetchRequestMode::NO_CORS;
+}
+
+bool EnumTraits<FetchRequestMode, content::FetchRequestMode>::FromMojom(
+ FetchRequestMode input,
+ content::FetchRequestMode* out) {
+ switch (input) {
+ case FetchRequestMode::SAME_ORIGIN:
+ *out = content::FETCH_REQUEST_MODE_SAME_ORIGIN;
+ return true;
+ case FetchRequestMode::NO_CORS:
+ *out = content::FETCH_REQUEST_MODE_NO_CORS;
+ return true;
+ case FetchRequestMode::CORS:
+ *out = content::FETCH_REQUEST_MODE_CORS;
+ return true;
+ case FetchRequestMode::CORS_WITH_FORCED_PREFLIGHT:
+ *out = content::FETCH_REQUEST_MODE_CORS_WITH_FORCED_PREFLIGHT;
+ return true;
+ case FetchRequestMode::NAVIGATE:
+ *out = content::FETCH_REQUEST_MODE_NAVIGATE;
+ return true;
+ }
+
+ return false;
+}
+
+RequestContextFrameType
+EnumTraits<RequestContextFrameType, content::RequestContextFrameType>::ToMojom(
+ content::RequestContextFrameType input) {
+ switch (input) {
+ case content::REQUEST_CONTEXT_FRAME_TYPE_AUXILIARY:
+ return RequestContextFrameType::AUXILIARY;
+ case content::REQUEST_CONTEXT_FRAME_TYPE_NESTED:
+ return RequestContextFrameType::NESTED;
+ case content::REQUEST_CONTEXT_FRAME_TYPE_NONE:
+ return RequestContextFrameType::NONE;
+ case content::REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL:
+ return RequestContextFrameType::TOP_LEVEL;
+ }
+
+ NOTREACHED();
+ return RequestContextFrameType::NONE;
+}
+
+bool EnumTraits<RequestContextFrameType, content::RequestContextFrameType>::
+ FromMojom(RequestContextFrameType input,
+ content::RequestContextFrameType* out) {
+ switch (input) {
+ case RequestContextFrameType::AUXILIARY:
+ *out = content::REQUEST_CONTEXT_FRAME_TYPE_AUXILIARY;
+ return true;
+ case RequestContextFrameType::NESTED:
+ *out = content::REQUEST_CONTEXT_FRAME_TYPE_NESTED;
+ return true;
+ case RequestContextFrameType::NONE:
+ *out = content::REQUEST_CONTEXT_FRAME_TYPE_NONE;
+ return true;
+ case RequestContextFrameType::TOP_LEVEL:
+ *out = content::REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL;
+ return true;
+ }
+
+ return false;
+}
+
+RequestContextType
+EnumTraits<RequestContextType, content::RequestContextType>::ToMojom(
+ content::RequestContextType input) {
+ switch (input) {
+ case content::REQUEST_CONTEXT_TYPE_UNSPECIFIED:
+ return RequestContextType::UNSPECIFIED;
+ case content::REQUEST_CONTEXT_TYPE_AUDIO:
+ return RequestContextType::AUDIO;
+ case content::REQUEST_CONTEXT_TYPE_BEACON:
+ return RequestContextType::BEACON;
+ case content::REQUEST_CONTEXT_TYPE_CSP_REPORT:
+ return RequestContextType::CSP_REPORT;
+ case content::REQUEST_CONTEXT_TYPE_DOWNLOAD:
+ return RequestContextType::DOWNLOAD;
+ case content::REQUEST_CONTEXT_TYPE_EMBED:
+ return RequestContextType::EMBED;
+ case content::REQUEST_CONTEXT_TYPE_EVENT_SOURCE:
+ return RequestContextType::EVENT_SOURCE;
+ case content::REQUEST_CONTEXT_TYPE_FAVICON:
+ return RequestContextType::FAVICON;
+ case content::REQUEST_CONTEXT_TYPE_FETCH:
+ return RequestContextType::FETCH;
+ case content::REQUEST_CONTEXT_TYPE_FONT:
+ return RequestContextType::FONT;
+ case content::REQUEST_CONTEXT_TYPE_FORM:
+ return RequestContextType::FORM;
+ case content::REQUEST_CONTEXT_TYPE_FRAME:
+ return RequestContextType::FRAME;
+ case content::REQUEST_CONTEXT_TYPE_HYPERLINK:
+ return RequestContextType::HYPERLINK;
+ case content::REQUEST_CONTEXT_TYPE_IFRAME:
+ return RequestContextType::IFRAME;
+ case content::REQUEST_CONTEXT_TYPE_IMAGE:
+ return RequestContextType::IMAGE;
+ case content::REQUEST_CONTEXT_TYPE_IMAGE_SET:
+ return RequestContextType::IMAGE_SET;
+ case content::REQUEST_CONTEXT_TYPE_IMPORT:
+ return RequestContextType::IMPORT;
+ case content::REQUEST_CONTEXT_TYPE_INTERNAL:
+ return RequestContextType::INTERNAL;
+ case content::REQUEST_CONTEXT_TYPE_LOCATION:
+ return RequestContextType::LOCATION;
+ case content::REQUEST_CONTEXT_TYPE_MANIFEST:
+ return RequestContextType::MANIFEST;
+ case content::REQUEST_CONTEXT_TYPE_OBJECT:
+ return RequestContextType::OBJECT;
+ case content::REQUEST_CONTEXT_TYPE_PING:
+ return RequestContextType::PING;
+ case content::REQUEST_CONTEXT_TYPE_PLUGIN:
+ return RequestContextType::PLUGIN;
+ case content::REQUEST_CONTEXT_TYPE_PREFETCH:
+ return RequestContextType::PREFETCH;
+ case content::REQUEST_CONTEXT_TYPE_SCRIPT:
+ return RequestContextType::SCRIPT;
+ case content::REQUEST_CONTEXT_TYPE_SERVICE_WORKER:
+ return RequestContextType::SERVICE_WORKER;
+ case content::REQUEST_CONTEXT_TYPE_SHARED_WORKER:
+ return RequestContextType::SHARED_WORKER;
+ case content::REQUEST_CONTEXT_TYPE_SUBRESOURCE:
+ return RequestContextType::SUBRESOURCE;
+ case content::REQUEST_CONTEXT_TYPE_STYLE:
+ return RequestContextType::STYLE;
+ case content::REQUEST_CONTEXT_TYPE_TRACK:
+ return RequestContextType::TRACK;
+ case content::REQUEST_CONTEXT_TYPE_VIDEO:
+ return RequestContextType::VIDEO;
+ case content::REQUEST_CONTEXT_TYPE_WORKER:
+ return RequestContextType::WORKER;
+ case content::REQUEST_CONTEXT_TYPE_XML_HTTP_REQUEST:
+ return RequestContextType::XML_HTTP_REQUEST;
+ case content::REQUEST_CONTEXT_TYPE_XSLT:
+ return RequestContextType::XSLT;
+ }
+
+ NOTREACHED();
+ return RequestContextType::UNSPECIFIED;
+}
+
+bool EnumTraits<RequestContextType, content::RequestContextType>::FromMojom(
+ RequestContextType input,
+ content::RequestContextType* out) {
+ switch (input) {
+ case RequestContextType::UNSPECIFIED:
+ *out = content::REQUEST_CONTEXT_TYPE_UNSPECIFIED;
+ return true;
+ case RequestContextType::AUDIO:
+ *out = content::REQUEST_CONTEXT_TYPE_AUDIO;
+ return true;
+ case RequestContextType::BEACON:
+ *out = content::REQUEST_CONTEXT_TYPE_BEACON;
+ return true;
+ case RequestContextType::CSP_REPORT:
+ *out = content::REQUEST_CONTEXT_TYPE_CSP_REPORT;
+ return true;
+ case RequestContextType::DOWNLOAD:
+ *out = content::REQUEST_CONTEXT_TYPE_DOWNLOAD;
+ return true;
+ case RequestContextType::EMBED:
+ *out = content::REQUEST_CONTEXT_TYPE_EMBED;
+ return true;
+ case RequestContextType::EVENT_SOURCE:
+ *out = content::REQUEST_CONTEXT_TYPE_EVENT_SOURCE;
+ return true;
+ case RequestContextType::FAVICON:
+ *out = content::REQUEST_CONTEXT_TYPE_FAVICON;
+ return true;
+ case RequestContextType::FETCH:
+ *out = content::REQUEST_CONTEXT_TYPE_FETCH;
+ return true;
+ case RequestContextType::FONT:
+ *out = content::REQUEST_CONTEXT_TYPE_FONT;
+ return true;
+ case RequestContextType::FORM:
+ *out = content::REQUEST_CONTEXT_TYPE_FORM;
+ return true;
+ case RequestContextType::FRAME:
+ *out = content::REQUEST_CONTEXT_TYPE_FRAME;
+ return true;
+ case RequestContextType::HYPERLINK:
+ *out = content::REQUEST_CONTEXT_TYPE_HYPERLINK;
+ return true;
+ case RequestContextType::IFRAME:
+ *out = content::REQUEST_CONTEXT_TYPE_IFRAME;
+ return true;
+ case RequestContextType::IMAGE:
+ *out = content::REQUEST_CONTEXT_TYPE_IMAGE;
+ return true;
+ case RequestContextType::IMAGE_SET:
+ *out = content::REQUEST_CONTEXT_TYPE_IMAGE_SET;
+ return true;
+ case RequestContextType::IMPORT:
+ *out = content::REQUEST_CONTEXT_TYPE_IMPORT;
+ return true;
+ case RequestContextType::INTERNAL:
+ *out = content::REQUEST_CONTEXT_TYPE_INTERNAL;
+ return true;
+ case RequestContextType::LOCATION:
+ *out = content::REQUEST_CONTEXT_TYPE_LOCATION;
+ return true;
+ case RequestContextType::MANIFEST:
+ *out = content::REQUEST_CONTEXT_TYPE_MANIFEST;
+ return true;
+ case RequestContextType::OBJECT:
+ *out = content::REQUEST_CONTEXT_TYPE_OBJECT;
+ return true;
+ case RequestContextType::PING:
+ *out = content::REQUEST_CONTEXT_TYPE_PING;
+ return true;
+ case RequestContextType::PLUGIN:
+ *out = content::REQUEST_CONTEXT_TYPE_PLUGIN;
+ return true;
+ case RequestContextType::PREFETCH:
+ *out = content::REQUEST_CONTEXT_TYPE_PREFETCH;
+ return true;
+ case RequestContextType::SCRIPT:
+ *out = content::REQUEST_CONTEXT_TYPE_SCRIPT;
+ return true;
+ case RequestContextType::SERVICE_WORKER:
+ *out = content::REQUEST_CONTEXT_TYPE_SERVICE_WORKER;
+ return true;
+ case RequestContextType::SHARED_WORKER:
+ *out = content::REQUEST_CONTEXT_TYPE_SHARED_WORKER;
+ return true;
+ case RequestContextType::SUBRESOURCE:
+ *out = content::REQUEST_CONTEXT_TYPE_SUBRESOURCE;
+ return true;
+ case RequestContextType::STYLE:
+ *out = content::REQUEST_CONTEXT_TYPE_STYLE;
+ return true;
+ case RequestContextType::TRACK:
+ *out = content::REQUEST_CONTEXT_TYPE_TRACK;
+ return true;
+ case RequestContextType::VIDEO:
+ *out = content::REQUEST_CONTEXT_TYPE_VIDEO;
+ return true;
+ case RequestContextType::WORKER:
+ *out = content::REQUEST_CONTEXT_TYPE_WORKER;
+ return true;
+ case RequestContextType::XML_HTTP_REQUEST:
+ *out = content::REQUEST_CONTEXT_TYPE_XML_HTTP_REQUEST;
+ return true;
+ case RequestContextType::XSLT:
+ *out = content::REQUEST_CONTEXT_TYPE_XSLT;
+ return true;
+ }
+
+ return false;
+}
+
+ServiceWorkerFetchType
+EnumTraits<ServiceWorkerFetchType, content::ServiceWorkerFetchType>::ToMojom(
+ content::ServiceWorkerFetchType input) {
+ switch (input) {
+ case content::ServiceWorkerFetchType::FETCH:
+ return ServiceWorkerFetchType::FETCH;
+ case content::ServiceWorkerFetchType::FOREIGN_FETCH:
+ return ServiceWorkerFetchType::FOREIGN_FETCH;
+ }
+
+ NOTREACHED();
+ return ServiceWorkerFetchType::FETCH;
+}
+
+bool EnumTraits<ServiceWorkerFetchType, content::ServiceWorkerFetchType>::
+ FromMojom(ServiceWorkerFetchType input,
+ content::ServiceWorkerFetchType* out) {
+ switch (input) {
+ case ServiceWorkerFetchType::FETCH:
+ *out = content::ServiceWorkerFetchType::FETCH;
+ return true;
+ case ServiceWorkerFetchType::FOREIGN_FETCH:
+ *out = content::ServiceWorkerFetchType::FOREIGN_FETCH;
+ return true;
+ }
+
+ return false;
+}
+
+void* StructTraits<blink::mojom::FetchAPIRequestDataView,
+ content::ServiceWorkerFetchRequest>::
+ SetUpContext(const content::ServiceWorkerFetchRequest& request) {
+ ServiceWorkerFetchRequestStructTraitsContext* context =
+ new ServiceWorkerFetchRequestStructTraitsContext();
+ context->headers.insert(request.headers.begin(), request.headers.end());
+
+ return context;
+}
+
+void StructTraits<blink::mojom::FetchAPIRequestDataView,
+ content::ServiceWorkerFetchRequest>::
+ TearDownContext(const content::ServiceWorkerFetchRequest& request,
+ void* context) {
+ delete static_cast<ServiceWorkerFetchRequestStructTraitsContext*>(context);
+}
+
+const std::map<std::string, std::string>&
+StructTraits<blink::mojom::FetchAPIRequestDataView,
+ content::ServiceWorkerFetchRequest>::
+ headers(const content::ServiceWorkerFetchRequest& request, void* context) {
+ return static_cast<ServiceWorkerFetchRequestStructTraitsContext*>(context)
+ ->headers;
+}
+
+bool StructTraits<blink::mojom::FetchAPIRequestDataView,
+ content::ServiceWorkerFetchRequest>::
+ Read(blink::mojom::FetchAPIRequestDataView data,
+ content::ServiceWorkerFetchRequest* out) {
+ std::unordered_map<std::string, std::string> headers;
+ base::Optional<std::string> blob_uuid;
+ if (!data.ReadMode(&out->mode) ||
+ !data.ReadRequestContextType(&out->request_context_type) ||
+ !data.ReadFrameType(&out->frame_type) || !data.ReadUrl(&out->url) ||
+ !data.ReadMethod(&out->method) || !data.ReadHeaders(&headers) ||
+ !data.ReadBlobUuid(&blob_uuid) || !data.ReadReferrer(&out->referrer) ||
+ !data.ReadCredentialsMode(&out->credentials_mode) ||
+ !data.ReadRedirectMode(&out->redirect_mode) ||
+ !data.ReadClientId(&out->client_id) ||
+ !data.ReadFetchType(&out->fetch_type)) {
+ return false;
+ }
+
+ out->is_main_resource_load = data.is_main_resource_load();
+ out->headers.insert(headers.begin(), headers.end());
+ if (blob_uuid) {
+ out->blob_uuid = blob_uuid.value();
+ out->blob_size = data.blob_size();
+ }
+ out->is_reload = data.is_reload();
+ return true;
+}
+
+} // namespace mojo
diff --git a/chromium/content/common/service_worker/service_worker_fetch_request_struct_traits.h b/chromium/content/common/service_worker/service_worker_fetch_request_struct_traits.h
new file mode 100644
index 00000000000..20ea9671e41
--- /dev/null
+++ b/chromium/content/common/service_worker/service_worker_fetch_request_struct_traits.h
@@ -0,0 +1,156 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_FETCH_REQUEST_STRUCT_TRAITS_H_
+#define CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_FETCH_REQUEST_STRUCT_TRAITS_H_
+
+#include "base/numerics/safe_conversions.h"
+#include "content/public/common/referrer.h"
+#include "third_party/WebKit/public/platform/modules/fetch/fetch_api_request.mojom.h"
+
+namespace mojo {
+
+template <>
+struct EnumTraits<blink::mojom::FetchCredentialsMode,
+ content::FetchCredentialsMode> {
+ static blink::mojom::FetchCredentialsMode ToMojom(
+ content::FetchCredentialsMode input);
+
+ static bool FromMojom(blink::mojom::FetchCredentialsMode input,
+ content::FetchCredentialsMode* out);
+};
+
+template <>
+struct EnumTraits<blink::mojom::FetchRedirectMode, content::FetchRedirectMode> {
+ static blink::mojom::FetchRedirectMode ToMojom(
+ content::FetchRedirectMode input);
+
+ static bool FromMojom(blink::mojom::FetchRedirectMode input,
+ content::FetchRedirectMode* out);
+};
+
+template <>
+struct EnumTraits<blink::mojom::FetchRequestMode, content::FetchRequestMode> {
+ static blink::mojom::FetchRequestMode ToMojom(
+ content::FetchRequestMode input);
+
+ static bool FromMojom(blink::mojom::FetchRequestMode input,
+ content::FetchRequestMode* out);
+};
+
+template <>
+struct EnumTraits<blink::mojom::RequestContextFrameType,
+ content::RequestContextFrameType> {
+ static blink::mojom::RequestContextFrameType ToMojom(
+ content::RequestContextFrameType input);
+
+ static bool FromMojom(blink::mojom::RequestContextFrameType input,
+ content::RequestContextFrameType* out);
+};
+
+template <>
+struct EnumTraits<blink::mojom::RequestContextType,
+ content::RequestContextType> {
+ static blink::mojom::RequestContextType ToMojom(
+ content::RequestContextType input);
+
+ static bool FromMojom(blink::mojom::RequestContextType input,
+ content::RequestContextType* out);
+};
+
+template <>
+struct EnumTraits<blink::mojom::ServiceWorkerFetchType,
+ content::ServiceWorkerFetchType> {
+ static blink::mojom::ServiceWorkerFetchType ToMojom(
+ content::ServiceWorkerFetchType input);
+
+ static bool FromMojom(blink::mojom::ServiceWorkerFetchType input,
+ content::ServiceWorkerFetchType* out);
+};
+
+template <>
+struct StructTraits<blink::mojom::FetchAPIRequestDataView,
+ content::ServiceWorkerFetchRequest> {
+ static void* SetUpContext(const content::ServiceWorkerFetchRequest& request);
+ static void TearDownContext(const content::ServiceWorkerFetchRequest& request,
+ void* context);
+
+ static content::FetchRequestMode mode(
+ const content::ServiceWorkerFetchRequest& request) {
+ return request.mode;
+ }
+
+ static bool is_main_resource_load(
+ const content::ServiceWorkerFetchRequest& request) {
+ return request.is_main_resource_load;
+ }
+
+ static content::RequestContextType request_context_type(
+ const content::ServiceWorkerFetchRequest& request) {
+ return request.request_context_type;
+ }
+
+ static content::RequestContextFrameType frame_type(
+ const content::ServiceWorkerFetchRequest& request) {
+ return request.frame_type;
+ }
+
+ static const GURL& url(const content::ServiceWorkerFetchRequest& request) {
+ return request.url;
+ }
+
+ static const std::string& method(
+ const content::ServiceWorkerFetchRequest& request) {
+ return request.method;
+ }
+
+ static const std::map<std::string, std::string>& headers(
+ const content::ServiceWorkerFetchRequest& request,
+ void* context);
+
+ static const std::string& blob_uuid(
+ const content::ServiceWorkerFetchRequest& request) {
+ return request.blob_uuid;
+ }
+
+ static uint64_t blob_size(const content::ServiceWorkerFetchRequest& request) {
+ return request.blob_size;
+ }
+
+ static const content::Referrer& referrer(
+ const content::ServiceWorkerFetchRequest& request) {
+ return request.referrer;
+ }
+
+ static content::FetchCredentialsMode credentials_mode(
+ const content::ServiceWorkerFetchRequest& request) {
+ return request.credentials_mode;
+ }
+
+ static content::FetchRedirectMode redirect_mode(
+ const content::ServiceWorkerFetchRequest& request) {
+ return request.redirect_mode;
+ }
+
+ static const std::string& client_id(
+ const content::ServiceWorkerFetchRequest& request) {
+ return request.client_id;
+ }
+
+ static bool is_reload(const content::ServiceWorkerFetchRequest& request) {
+ return request.is_reload;
+ }
+
+ static content::ServiceWorkerFetchType fetch_type(
+ const content::ServiceWorkerFetchRequest& request) {
+ return request.fetch_type;
+ }
+
+ static bool Read(blink::mojom::FetchAPIRequestDataView data,
+ content::ServiceWorkerFetchRequest* out);
+};
+
+} // namespace mojo
+
+#endif // CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_FETCH_REQUEST_STRUCT_TRAITS_H_
diff --git a/chromium/content/common/service_worker/service_worker_messages.h b/chromium/content/common/service_worker/service_worker_messages.h
index 7cc0eee78e5..0f0356ab936 100644
--- a/chromium/content/common/service_worker/service_worker_messages.h
+++ b/chromium/content/common/service_worker/service_worker_messages.h
@@ -30,22 +30,22 @@
#define IPC_MESSAGE_START ServiceWorkerMsgStart
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerError::ErrorType,
- blink::WebServiceWorkerError::ErrorTypeLast)
+ blink::WebServiceWorkerError::kErrorTypeLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerEventResult,
- blink::WebServiceWorkerEventResultLast)
+ blink::kWebServiceWorkerEventResultLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerState,
- blink::WebServiceWorkerStateLast)
+ blink::kWebServiceWorkerStateLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerResponseType,
- blink::WebServiceWorkerResponseTypeLast)
+ blink::kWebServiceWorkerResponseTypeLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerResponseError,
- blink::WebServiceWorkerResponseErrorLast)
+ blink::kWebServiceWorkerResponseErrorLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerClientType,
- blink::WebServiceWorkerClientTypeLast)
+ blink::kWebServiceWorkerClientTypeLast)
IPC_ENUM_TRAITS_MAX_VALUE(content::ServiceWorkerProviderType,
content::SERVICE_WORKER_PROVIDER_TYPE_LAST)
@@ -251,10 +251,6 @@ IPC_MESSAGE_ROUTED4(ServiceWorkerHostMsg_FetchEventResponse,
content::ServiceWorkerResponse,
base::Time /* dispatch_event_time */)
-// Responds to a Ping from the browser.
-// Routed to the target ServiceWorkerVersion.
-IPC_MESSAGE_ROUTED0(ServiceWorkerHostMsg_Pong)
-
// Asks the browser to retrieve client of the sender ServiceWorker.
IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_GetClient,
int /* request_id */,
@@ -490,9 +486,6 @@ IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ClaimClientsError,
blink::WebServiceWorkerError::ErrorType /* code */,
base::string16 /* message */)
-// Sent via EmbeddedWorker to Ping the worker, expecting a Pong in response.
-IPC_MESSAGE_CONTROL0(ServiceWorkerMsg_Ping)
-
// Sent via EmbeddedWorker as a response of GetClient.
IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_DidGetClient,
int /* request_id */,
diff --git a/chromium/content/common/service_worker/service_worker_types.cc b/chromium/content/common/service_worker/service_worker_types.cc
index f483200bf94..9e8d63fb0b9 100644
--- a/chromium/content/common/service_worker/service_worker_types.cc
+++ b/chromium/content/common/service_worker/service_worker_types.cc
@@ -71,9 +71,9 @@ size_t ServiceWorkerFetchRequest::EstimatedStructSize() {
ServiceWorkerResponse::ServiceWorkerResponse()
: status_code(0),
- response_type(blink::WebServiceWorkerResponseTypeOpaque),
+ response_type(blink::kWebServiceWorkerResponseTypeOpaque),
blob_size(0),
- error(blink::WebServiceWorkerResponseErrorUnknown) {}
+ error(blink::kWebServiceWorkerResponseErrorUnknown) {}
ServiceWorkerResponse::ServiceWorkerResponse(
std::unique_ptr<std::vector<GURL>> url_list,
@@ -127,7 +127,7 @@ size_t ServiceWorkerResponse::EstimatedStructSize() {
ServiceWorkerObjectInfo::ServiceWorkerObjectInfo()
: handle_id(kInvalidServiceWorkerHandleId),
- state(blink::WebServiceWorkerStateUnknown),
+ state(blink::kWebServiceWorkerStateUnknown),
version_id(kInvalidServiceWorkerVersionId) {}
bool ServiceWorkerObjectInfo::IsValid() const {
@@ -141,9 +141,8 @@ ServiceWorkerRegistrationObjectInfo::ServiceWorkerRegistrationObjectInfo()
}
ServiceWorkerClientQueryOptions::ServiceWorkerClientQueryOptions()
- : client_type(blink::WebServiceWorkerClientTypeWindow),
- include_uncontrolled(false) {
-}
+ : client_type(blink::kWebServiceWorkerClientTypeWindow),
+ include_uncontrolled(false) {}
ExtendableMessageEventSource::ExtendableMessageEventSource() {}
diff --git a/chromium/content/common/service_worker/service_worker_types_struct_traits.cc b/chromium/content/common/service_worker/service_worker_types_struct_traits.cc
index f88acbca35f..3e40fd520d4 100644
--- a/chromium/content/common/service_worker/service_worker_types_struct_traits.cc
+++ b/chromium/content/common/service_worker/service_worker_types_struct_traits.cc
@@ -4,21 +4,55 @@
#include "content/common/service_worker/service_worker_types_struct_traits.h"
+#include "base/logging.h"
+
namespace mojo {
-content::mojom::ServiceWorkerProviderType
-EnumTraits<content::mojom::ServiceWorkerProviderType,
- content::ServiceWorkerProviderType>::
+using content::mojom::ServiceWorkerProviderType;
+
+ServiceWorkerProviderType
+EnumTraits<ServiceWorkerProviderType, content::ServiceWorkerProviderType>::
ToMojom(content::ServiceWorkerProviderType input) {
- return static_cast<content::mojom::ServiceWorkerProviderType>(input);
+ switch (input) {
+ case content::SERVICE_WORKER_PROVIDER_UNKNOWN:
+ return ServiceWorkerProviderType::SERVICE_WORKER_PROVIDER_UNKNOWN;
+ case content::SERVICE_WORKER_PROVIDER_FOR_WINDOW:
+ return ServiceWorkerProviderType::SERVICE_WORKER_PROVIDER_FOR_WINDOW;
+ case content::SERVICE_WORKER_PROVIDER_FOR_WORKER:
+ return ServiceWorkerProviderType::SERVICE_WORKER_PROVIDER_FOR_WORKER;
+ case content::SERVICE_WORKER_PROVIDER_FOR_SHARED_WORKER:
+ return ServiceWorkerProviderType::
+ SERVICE_WORKER_PROVIDER_FOR_SHARED_WORKER;
+ case content::SERVICE_WORKER_PROVIDER_FOR_CONTROLLER:
+ return ServiceWorkerProviderType::SERVICE_WORKER_PROVIDER_FOR_CONTROLLER;
+ }
+
+ NOTREACHED();
+ return ServiceWorkerProviderType::SERVICE_WORKER_PROVIDER_UNKNOWN;
}
-bool EnumTraits<content::mojom::ServiceWorkerProviderType,
- content::ServiceWorkerProviderType>::
- FromMojom(content::mojom::ServiceWorkerProviderType input,
+bool EnumTraits<ServiceWorkerProviderType, content::ServiceWorkerProviderType>::
+ FromMojom(ServiceWorkerProviderType input,
content::ServiceWorkerProviderType* out) {
- *out = static_cast<content::ServiceWorkerProviderType>(input);
- return true;
+ switch (input) {
+ case ServiceWorkerProviderType::SERVICE_WORKER_PROVIDER_UNKNOWN:
+ *out = content::SERVICE_WORKER_PROVIDER_UNKNOWN;
+ return true;
+ case ServiceWorkerProviderType::SERVICE_WORKER_PROVIDER_FOR_WINDOW:
+ *out = content::SERVICE_WORKER_PROVIDER_FOR_WINDOW;
+ return true;
+ case ServiceWorkerProviderType::SERVICE_WORKER_PROVIDER_FOR_WORKER:
+ *out = content::SERVICE_WORKER_PROVIDER_FOR_WORKER;
+ return true;
+ case ServiceWorkerProviderType::SERVICE_WORKER_PROVIDER_FOR_SHARED_WORKER:
+ *out = content::SERVICE_WORKER_PROVIDER_FOR_SHARED_WORKER;
+ return true;
+ case ServiceWorkerProviderType::SERVICE_WORKER_PROVIDER_FOR_CONTROLLER:
+ *out = content::SERVICE_WORKER_PROVIDER_FOR_CONTROLLER;
+ return true;
+ }
+
+ return false;
}
} // namespace mojo
diff --git a/chromium/content/common/service_worker/service_worker_utils_unittest.cc b/chromium/content/common/service_worker/service_worker_utils_unittest.cc
index 96564a26550..f75f04c7e2c 100644
--- a/chromium/content/common/service_worker/service_worker_utils_unittest.cc
+++ b/chromium/content/common/service_worker/service_worker_utils_unittest.cc
@@ -91,6 +91,10 @@ TEST(ServiceWorkerUtilsTest, ScopeMatches) {
// URLs canonicalize \ to / so this is equivalent to "...//x"
ASSERT_TRUE(ServiceWorkerUtils::ScopeMatches(
GURL("http://www.example.com/\\x"), GURL("http://www.example.com//x")));
+
+ // URLs that are in different origin shouldn't match.
+ ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches(
+ GURL("https://evil.com"), GURL("https://evil.com.example.com")));
}
TEST(ServiceWorkerUtilsTest, FindLongestScopeMatch) {
diff --git a/chromium/content/common/set_process_title.cc b/chromium/content/common/set_process_title.cc
deleted file mode 100644
index 21185989f2f..00000000000
--- a/chromium/content/common/set_process_title.cc
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/common/set_process_title.h"
-
-#include <stddef.h>
-
-#include "build/build_config.h"
-
-#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_SOLARIS)
-#include <limits.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <string>
-
-#include "base/command_line.h"
-#endif // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_SOLARIS)
-
-#if defined(OS_LINUX)
-#include <sys/prctl.h>
-
-#include "base/files/file_path.h"
-#include "base/files/file_util.h"
-#include "base/process/process_metrics.h"
-#include "base/strings/string_util.h"
-#include "base/threading/platform_thread.h"
-// Linux/glibc doesn't natively have setproctitle().
-#include "content/common/set_process_title_linux.h"
-#endif // defined(OS_LINUX)
-
-namespace content {
-
-// TODO(jrg): Find out if setproctitle or equivalent is available on Android.
-#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_SOLARIS) && \
- !defined(OS_ANDROID)
-
-void SetProcessTitleFromCommandLine(const char** main_argv) {
- // Build a single string which consists of all the arguments separated
- // by spaces. We can't actually keep them separate due to the way the
- // setproctitle() function works.
- std::string title;
- bool have_argv0 = false;
-
-#if defined(OS_LINUX)
- DCHECK_EQ(base::PlatformThread::CurrentId(), getpid());
-
- if (main_argv)
- setproctitle_init(main_argv);
-
- // In Linux we sometimes exec ourselves from /proc/self/exe, but this makes us
- // show up as "exe" in process listings. Read the symlink /proc/self/exe and
- // use the path it points at for our process title. Note that this is only for
- // display purposes and has no TOCTTOU security implications.
- base::FilePath target;
- base::FilePath self_exe(base::kProcSelfExe);
- if (base::ReadSymbolicLink(self_exe, &target)) {
- have_argv0 = true;
- title = target.value();
- // If the binary has since been deleted, Linux appends " (deleted)" to the
- // symlink target. Remove it, since this is not really part of our name.
- const std::string kDeletedSuffix = " (deleted)";
- if (base::EndsWith(title, kDeletedSuffix, base::CompareCase::SENSITIVE))
- title.resize(title.size() - kDeletedSuffix.size());
-
- // PR_SET_NAME is available in Linux 2.6.9 and newer.
- // When available at run time, this sets the short process name that shows
- // when the full command line is not being displayed in most process
- // listings.
- prctl(PR_SET_NAME, base::FilePath(title).BaseName().value().c_str());
- }
-#endif // defined(OS_LINUX)
-
- const base::CommandLine* command_line =
- base::CommandLine::ForCurrentProcess();
- for (size_t i = 1; i < command_line->argv().size(); ++i) {
- if (!title.empty())
- title += " ";
- title += command_line->argv()[i];
- }
- // Disable prepending argv[0] with '-' if we prepended it ourselves above.
- setproctitle(have_argv0 ? "-%s" : "%s", title.c_str());
-}
-
-#else
-
-// All other systems (basically Windows & Mac) have no need or way to implement
-// this function.
-void SetProcessTitleFromCommandLine(const char** /* main_argv */) {
-}
-
-#endif
-
-} // namespace content
diff --git a/chromium/content/common/set_process_title.h b/chromium/content/common/set_process_title.h
deleted file mode 100644
index 91ea61a89a1..00000000000
--- a/chromium/content/common/set_process_title.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2010 The Chromium 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 CONTENT_COMMON_SET_PROCESS_TITLE_H_
-#define CONTENT_COMMON_SET_PROCESS_TITLE_H_
-
-namespace content {
-// Sets OS-specific process title information based on the command line. This
-// does nothing if the OS doesn't support or need this capability.
-//
-// Pass in the argv from main(). On Windows, where there is no argv, you can
-// pass NULL or just don't call this function, since it does nothing. This
-// argv pointer will be cached so if you call this function again, you can pass
-// NULL in the second call. This is to support the case where it's called once
-// at startup, and later when a zygote is fork()ed. The later call doesn't have
-// easy access to main's argv.
-//
-// On non-Mac Unix platforms, we exec ourselves from /proc/self/exe, but that
-// makes the process name that shows up in "ps" etc. for the child processes
-// show as "exe" instead of "chrome" or something reasonable. This function
-// will try to fix it so the "effective" command line shows up instead.
-void SetProcessTitleFromCommandLine(const char** main_argv);
-
-} // namespace content
-
-#endif // CONTENT_COMMON_SET_PROCESS_TITLE_H_
diff --git a/chromium/content/common/set_process_title_linux.cc b/chromium/content/common/set_process_title_linux.cc
deleted file mode 100644
index 0c90826d9d1..00000000000
--- a/chromium/content/common/set_process_title_linux.cc
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// This file implements BSD-style setproctitle() for Linux.
-// It is written such that it can easily be compiled outside Chromium.
-//
-// The Linux kernel sets up two locations in memory to pass arguments and
-// environment variables to processes. First, there are two char* arrays stored
-// one after another: argv and environ. A pointer to argv is passed to main(),
-// while glibc sets the global variable |environ| to point at the latter. Both
-// of these arrays are terminated by a NULL pointer; the environment array is
-// also followed by some empty space to allow additional variables to be added.
-//
-// These arrays contain pointers to a second location in memory, where the
-// strings themselves are stored one after another: first all the arguments,
-// then the environment variables. The kernel will allocate a single page of
-// memory for this purpose, so the end of the page containing argv[0] is the
-// end of the storage potentially available to store the process title.
-//
-// When the kernel reads the command line arguments for a process, it looks at
-// the range of memory within this page that it initially used for the argument
-// list. If the terminating '\0' character is still where it expects, nothing
-// further is done. If it has been overwritten, the kernel will scan up to the
-// size of a page looking for another. (Note, however, that in general not that
-// much space is actually mapped, since argv[0] is rarely page-aligned and only
-// one page is mapped.)
-//
-// Thus to change the process title, we must move any environment variables out
-// of the way to make room for a potentially longer title, and then overwrite
-// the memory pointed to by argv[0] with a single replacement string, making
-// sure its size does not exceed the available space.
-//
-// It is perhaps worth noting that patches to add a system call to Linux for
-// this, like in BSD, have never made it in: this is the "official" way to do
-// this on Linux. Presumably it is not in glibc due to some disagreement over
-// this position within the glibc project, leaving applications caught in the
-// middle. (Also, only a very few applications need or want this anyway.)
-
-#include "content/common/set_process_title_linux.h"
-
-#include <stdarg.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-extern char** environ;
-
-static char** g_main_argv = NULL;
-static char* g_orig_argv0 = NULL;
-
-void setproctitle(const char* fmt, ...) {
- va_list ap;
- size_t i, avail_size;
- uintptr_t page_size, page, page_end;
- // Sanity check before we try and set the process title.
- // The BSD version allows fmt == NULL to restore the original title.
- if (!g_main_argv || !environ || !fmt)
- return;
- if (!g_orig_argv0) {
- // Save the original argv[0].
- g_orig_argv0 = strdup(g_main_argv[0]);
- if (!g_orig_argv0)
- return;
- }
- page_size = sysconf(_SC_PAGESIZE);
- // Get the page on which the argument list and environment live.
- page = (uintptr_t) g_main_argv[0];
- page -= page % page_size;
- page_end = page + page_size;
- // Move the environment out of the way. Note that we are moving the values,
- // not the environment array itself (which may not be on the page we need
- // to overwrite anyway).
- for (i = 0; environ[i]; ++i) {
- uintptr_t env_i = (uintptr_t) environ[i];
- // Only move the value if it's actually in the way. This avoids
- // leaking copies of the values if this function is called again.
- if (page <= env_i && env_i < page_end) {
- char* copy = strdup(environ[i]);
- // Be paranoid. Check for allocation failure and bail out.
- if (!copy)
- return;
- environ[i] = copy;
- }
- }
- // Put the title in argv[0]. We have to zero out the space first since the
- // kernel doesn't actually look for a null terminator unless we make the
- // argument list longer than it started.
- avail_size = page_end - (uintptr_t) g_main_argv[0];
- memset(g_main_argv[0], 0, avail_size);
- va_start(ap, fmt);
- if (fmt[0] == '-') {
- vsnprintf(g_main_argv[0], avail_size, &fmt[1], ap);
- } else {
- size_t size = snprintf(g_main_argv[0], avail_size, "%s ", g_orig_argv0);
- if (size < avail_size)
- vsnprintf(g_main_argv[0] + size, avail_size - size, fmt, ap);
- }
- va_end(ap);
- g_main_argv[1] = NULL;
-}
-
-// A version of this built into glibc would not need this function, since
-// it could stash the argv pointer in __libc_start_main(). But we need it.
-void setproctitle_init(const char** main_argv) {
- if (g_main_argv)
- return;
-
- uintptr_t page_size = sysconf(_SC_PAGESIZE);
- // Check that the argv array is in fact on the same page of memory
- // as the environment array just as an added measure of protection.
- if (((uintptr_t) environ) / page_size == ((uintptr_t) main_argv) / page_size)
- g_main_argv = const_cast<char**>(main_argv);
-}
diff --git a/chromium/content/common/set_process_title_linux.h b/chromium/content/common/set_process_title_linux.h
deleted file mode 100644
index d72a7b6ccac..00000000000
--- a/chromium/content/common/set_process_title_linux.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_COMMON_SET_PROCESS_TITLE_LINUX_H_
-#define CONTENT_COMMON_SET_PROCESS_TITLE_LINUX_H_
-
-// Set the process title that will show in "ps" and similar tools. Takes
-// printf-style format string and arguments. After calling setproctitle()
-// the original main() argv[] array should not be used. By default, the
-// original argv[0] is prepended to the format; this can be disabled by
-// including a '-' as the first character of the format string.
-//
-// This signature and naming is to be compatible with most other Unix
-// implementations of setproctitle().
-void setproctitle(const char* fmt, ...);
-
-// Initialize state needed for setproctitle() on Linux. Pass the argv pointer
-// from main() to setproctitle_init() before calling setproctitle().
-void setproctitle_init(const char** main_argv);
-
-#endif // CONTENT_COMMON_SET_PROCESS_TITLE_LINUX_H_
diff --git a/chromium/content/common/swapped_out_messages.cc b/chromium/content/common/swapped_out_messages.cc
index 233d07d45d9..442cd3e1fe2 100644
--- a/chromium/content/common/swapped_out_messages.cc
+++ b/chromium/content/common/swapped_out_messages.cc
@@ -28,7 +28,6 @@ bool SwappedOutMessages::CanSendWhileSwappedOut(const IPC::Message* msg) {
case ViewHostMsg_Focus::ID:
case ViewHostMsg_ShowFullscreenWidget::ID:
case ViewHostMsg_ShowWidget::ID:
- case ViewHostMsg_SwapCompositorFrame::ID:
// Handled by SharedWorkerMessageFilter.
case ViewHostMsg_DocumentDetached::ID:
// Allow cross-process JavaScript calls.
diff --git a/chromium/content/common/typemaps.gni b/chromium/content/common/typemaps.gni
index 894e1acf237..505b6d26091 100644
--- a/chromium/content/common/typemaps.gni
+++ b/chromium/content/common/typemaps.gni
@@ -3,11 +3,13 @@
# found in the LICENSE file.
typemaps = [
+ "//content/common/background_fetch/background_fetch_types.typemap",
"//content/common/native_types.typemap",
"//content/common/media/media_devices.typemap",
"//content/common/push_messaging.typemap",
"//content/common/service_worker/embedded_worker.typemap",
"//content/common/service_worker/service_worker_event_dispatcher.typemap",
+ "//content/common/service_worker/service_worker_fetch_request.typemap",
"//content/common/service_worker/service_worker_provider.typemap",
"//content/common/service_worker/service_worker_types.typemap",
"//content/common/url_loader_status.typemap",
diff --git a/chromium/content/common/url_schemes.cc b/chromium/content/common/url_schemes.cc
index 29a3c85f5bc..6667cb10b30 100644
--- a/chromium/content/common/url_schemes.cc
+++ b/chromium/content/common/url_schemes.cc
@@ -68,6 +68,9 @@ void RegisterContentSchemes(bool lock_schemes) {
for (auto& scheme : schemes.csp_bypassing_schemes)
url::AddCSPBypassingScheme(scheme.c_str());
+ for (auto& scheme : schemes.empty_document_schemes)
+ url::AddEmptyDocumentScheme(scheme.c_str());
+
// Prevent future modification of the scheme lists. This is to prevent
// accidental creation of data races in the program. Add*Scheme aren't
// threadsafe so must be called when GURL isn't used on any other thread. This
diff --git a/chromium/content/common/user_agent.cc b/chromium/content/common/user_agent.cc
index 5602261f681..b071e6ba90d 100644
--- a/chromium/content/common/user_agent.cc
+++ b/chromium/content/common/user_agent.cc
@@ -78,11 +78,7 @@ std::string BuildOSCpuInfo() {
#endif
#if defined(OS_ANDROID)
- std::string android_version_str;
- base::StringAppendF(
- &android_version_str, "%d.%d", os_major_version, os_minor_version);
- if (os_bugfix_version != 0)
- base::StringAppendF(&android_version_str, ".%d", os_bugfix_version);
+ std::string android_version_str = base::SysInfo::OperatingSystemVersion();
std::string android_info_str;
diff --git a/chromium/content/common/view_messages.h b/chromium/content/common/view_messages.h
index 93459214ab4..82ffcc94291 100644
--- a/chromium/content/common/view_messages.h
+++ b/chromium/content/common/view_messages.h
@@ -78,23 +78,23 @@
#define IPC_MESSAGE_START ViewMsgStart
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebDeviceEmulationParams::ScreenPosition,
- blink::WebDeviceEmulationParams::ScreenPositionLast)
+ blink::WebDeviceEmulationParams::kScreenPositionLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebMediaPlayerAction::Type,
- blink::WebMediaPlayerAction::Type::TypeLast)
+ blink::WebMediaPlayerAction::Type::kTypeLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebPluginAction::Type,
- blink::WebPluginAction::Type::TypeLast)
+ blink::WebPluginAction::Type::kTypeLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebPopupType,
- blink::WebPopupType::WebPopupTypeLast)
+ blink::WebPopupType::kWebPopupTypeLast)
// TODO(dcheng): Update WebScreenOrientationType to have a "Last" enum member.
IPC_ENUM_TRAITS_MIN_MAX_VALUE(blink::WebScreenOrientationType,
- blink::WebScreenOrientationUndefined,
- blink::WebScreenOrientationLandscapeSecondary)
+ blink::kWebScreenOrientationUndefined,
+ blink::kWebScreenOrientationLandscapeSecondary)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebWorkerCreationError,
- blink::WebWorkerCreationErrorLast)
+ blink::kWebWorkerCreationErrorLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebTextDirection,
- blink::WebTextDirection::WebTextDirectionLast)
+ blink::WebTextDirection::kWebTextDirectionLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebDisplayMode,
- blink::WebDisplayMode::WebDisplayModeLast)
+ blink::WebDisplayMode::kWebDisplayModeLast)
IPC_ENUM_TRAITS(content::FaviconURL::IconType)
IPC_ENUM_TRAITS(content::MenuItem::Type)
IPC_ENUM_TRAITS_MAX_VALUE(content::NavigationGesture,
@@ -120,9 +120,9 @@ IPC_ENUM_TRAITS_MAX_VALUE(ui::TextInputType, ui::TEXT_INPUT_TYPE_MAX)
#if defined(OS_MACOSX)
IPC_ENUM_TRAITS_MAX_VALUE(
blink::WebScrollbarButtonsPlacement,
- blink::WebScrollbarButtonsPlacement::WebScrollbarButtonsPlacementLast)
+ blink::WebScrollbarButtonsPlacement::kWebScrollbarButtonsPlacementLast)
-IPC_ENUM_TRAITS_MAX_VALUE(blink::ScrollerStyle, blink::ScrollerStyleOverlay)
+IPC_ENUM_TRAITS_MAX_VALUE(blink::ScrollerStyle, blink::kScrollerStyleOverlay)
#endif
IPC_STRUCT_TRAITS_BEGIN(blink::WebMediaPlayerAction)
@@ -153,16 +153,16 @@ IPC_STRUCT_TRAITS_BEGIN(blink::WebSize)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(blink::WebDeviceEmulationParams)
- IPC_STRUCT_TRAITS_MEMBER(screenPosition)
- IPC_STRUCT_TRAITS_MEMBER(screenSize)
- IPC_STRUCT_TRAITS_MEMBER(viewPosition)
- IPC_STRUCT_TRAITS_MEMBER(deviceScaleFactor)
- IPC_STRUCT_TRAITS_MEMBER(viewSize)
- IPC_STRUCT_TRAITS_MEMBER(fitToView)
+ IPC_STRUCT_TRAITS_MEMBER(screen_position)
+ IPC_STRUCT_TRAITS_MEMBER(screen_size)
+ IPC_STRUCT_TRAITS_MEMBER(view_position)
+ IPC_STRUCT_TRAITS_MEMBER(device_scale_factor)
+ IPC_STRUCT_TRAITS_MEMBER(view_size)
+ IPC_STRUCT_TRAITS_MEMBER(fit_to_view)
IPC_STRUCT_TRAITS_MEMBER(offset)
IPC_STRUCT_TRAITS_MEMBER(scale)
- IPC_STRUCT_TRAITS_MEMBER(screenOrientationAngle)
- IPC_STRUCT_TRAITS_MEMBER(screenOrientationType)
+ IPC_STRUCT_TRAITS_MEMBER(screen_orientation_angle)
+ IPC_STRUCT_TRAITS_MEMBER(screen_orientation_type)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(content::ScreenInfo)
@@ -570,11 +570,19 @@ IPC_MESSAGE_ROUTED1(ViewMsg_PpapiBrokerPermissionResult,
bool /* result */)
#endif
-// An acknowledge to ViewHostMsg_MultipleTargetsTouched to notify the renderer
-// process to release the magnified image.
+// An acknowledgement to ViewHostMsg_ShowDisambiguationPopup to notify the
+// renderer process to release the magnified image.
IPC_MESSAGE_ROUTED1(ViewMsg_ReleaseDisambiguationPopupBitmap,
cc::SharedBitmapId /* id */)
+// If the ViewHostMsg_ShowDisambiguationPopup resulted in the user tapping
+// inside the popup, instruct the renderer to generate a synthetic tap at that
+// offset.
+IPC_MESSAGE_ROUTED3(ViewMsg_ResolveTapDisambiguation,
+ double /* timestamp_seconds */,
+ gfx::Point /* tap_viewport_offset */,
+ bool /* is_long_press */)
+
// Fetches complete rendered content of a web page as plain text.
IPC_MESSAGE_ROUTED0(ViewMsg_GetRenderedText)
@@ -588,14 +596,6 @@ IPC_MESSAGE_ROUTED3(ViewMsg_UpdateBrowserControlsState,
#endif
-// Sent by browser to tell renderer compositor that some resources that were
-// given to the browser in a swap are not being used anymore.
-// If this message is in response to a swap then is_swap_ack is set.
-IPC_MESSAGE_ROUTED3(ViewMsg_ReclaimCompositorResources,
- uint32_t /* compositor_frame_sink_id */,
- bool /* is_swap_ack */,
- cc::ReturnedResourceArray /* resources */)
-
IPC_MESSAGE_ROUTED0(ViewMsg_SelectWordAroundCaret)
// Sent by the browser to ask the renderer to redraw. Robust to events that can
@@ -796,11 +796,14 @@ IPC_MESSAGE_ROUTED2(ViewHostMsg_UpdateZoomLimits,
int /* minimum_percent */,
int /* maximum_percent */)
-IPC_MESSAGE_ROUTED3(
- ViewHostMsg_SwapCompositorFrame,
- uint32_t /* compositor_frame_sink_id */,
- cc::CompositorFrame /* frame */,
- std::vector<IPC::Message> /* messages_to_deliver_with_frame */)
+IPC_MESSAGE_ROUTED2(ViewHostMsg_FrameSwapMessages,
+ uint32_t /* frame_token */,
+ std::vector<IPC::Message> /* messages */)
+
+// Sent if the BeginFrame did not cause a SwapCompositorFrame (e.g. because no
+// updates were required or because it was aborted in the renderer).
+IPC_MESSAGE_ROUTED1(ViewHostMsg_BeginFrameDidNotSwap,
+ cc::BeginFrameAck /* ack */)
// Send back a string to be recorded by UserMetrics.
IPC_MESSAGE_CONTROL1(ViewHostMsg_UserMetricsRecordAction,
@@ -862,21 +865,10 @@ IPC_MESSAGE_ROUTED1(ViewHostMsg_MoveValidationMessage,
// after the frame widget has painted something.
IPC_MESSAGE_ROUTED0(ViewHostMsg_DidFirstVisuallyNonEmptyPaint)
-// Send after a paint happens after any page commit, including a blank one.
-// TODO(kenrb): This, and all ViewHostMsg_* messages that actually pertain to
-// RenderWidget(Host), should be renamed to WidgetHostMsg_*.
-// See https://crbug.com/537793.
-IPC_MESSAGE_ROUTED0(ViewHostMsg_DidFirstPaintAfterLoad)
-
// Sent in reply to ViewMsg_WaitForNextFrameForTests.
IPC_MESSAGE_ROUTED0(ViewHostMsg_WaitForNextFrameForTests_ACK)
#if defined(OS_ANDROID)
-// Start an android intent with the given URI.
-IPC_MESSAGE_ROUTED2(ViewHostMsg_StartContentIntent,
- GURL /* content_url */,
- bool /* is_main_frame */)
-
// Notifies that an unhandled tap has occurred at the specified x,y position
// and that the UI may need to be triggered.
IPC_MESSAGE_ROUTED2(ViewHostMsg_ShowUnhandledTapUIIfNeeded,