diff --git a/DEPS b/DEPS index 3febb5a..23a704d 100644 --- a/DEPS +++ b/DEPS
@@ -234,7 +234,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling Skia # and whatever else without interference from each other. - 'skia_revision': '705dce533a072cbe39349d4b917cb519d1cd8a97', + 'skia_revision': 'fa183572bfd34c5ea8dec024d4751b131ebd3572', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling V8 # and whatever else without interference from each other. @@ -242,7 +242,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling ANGLE # and whatever else without interference from each other. - 'angle_revision': '657202725195546fccd5d5e69f25a39d4317dd45', + 'angle_revision': 'ce854632690e505551414f80d01d864df6118882', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling SwiftShader # and whatever else without interference from each other. @@ -301,7 +301,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling catapult # and whatever else without interference from each other. - 'catapult_revision': 'bd8b0c2c47c1a9433c38123f2533c796fd7f8521', + 'catapult_revision': '5695a8426cf0e5f0f780769fec9baee8cb1c4353', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling libFuzzer # and whatever else without interference from each other. @@ -349,7 +349,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. - 'dawn_revision': '0c429e354e6c01028022d15bcff3e9b0cf8c52d2', + 'dawn_revision': 'dcf57433957731e9139358a5634f078912f1a26c', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. @@ -791,7 +791,7 @@ 'packages': [ { 'package': 'chromium/third_party/androidx', - 'version': 'yAYkpiAexFiePTwSGcIK0Fh0Q7AjB3YFFda0UfCrl9QC', + 'version': 'TcDziAa8Rlh7MmMwOoAuvVyEbTC8z8QJJpj8gafKMdsC', }, ], 'condition': 'checkout_android', @@ -956,7 +956,7 @@ }, 'src/third_party/breakpad/breakpad': - Var('chromium_git') + '/breakpad/breakpad.git' + '@' + 'ee2ad61263ebc54396df7d7a835e1e3f8455134e', + Var('chromium_git') + '/breakpad/breakpad.git' + '@' + '0ae29c99d1a0abed797ad78e5e061f4e2cb9c1cb', 'src/third_party/byte_buddy': { 'packages': [ @@ -1030,7 +1030,7 @@ }, 'src/third_party/depot_tools': - Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + '320a1caf813ca9764ab029fa76be0a6504f454d0', + Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + 'ad7c145263ca671783a363131bfe7db9a49725f1', 'src/third_party/devtools-frontend/src': Var('chromium_git') + '/devtools/devtools-frontend' + '@' + Var('devtools_frontend_revision'), @@ -1413,7 +1413,7 @@ }, 'src/third_party/perfetto': - Var('android_git') + '/platform/external/perfetto.git' + '@' + 'abe1a8bc88f4de6d0e796f5e925c65c8bc09f796', + Var('android_git') + '/platform/external/perfetto.git' + '@' + '70f73380a55418668aa87df92c6c85253e053af3', 'src/third_party/perl': { 'url': Var('chromium_git') + '/chromium/deps/perl.git' + '@' + '6f3e5028eb65d0b4c5fdd792106ac4c84eee1eb3', @@ -1595,7 +1595,7 @@ 'src/third_party/usrsctp/usrsctplib': Var('chromium_git') + '/external/github.com/sctplab/usrsctp' + '@' + '62d7d0c928c9a040dce96aa2f16c00e7e67d59cb', - 'src/third_party/vulkan-deps': '{chromium_git}/vulkan-deps@bc57443e991d039b42d9322f775092f76431da5a', + 'src/third_party/vulkan-deps': '{chromium_git}/vulkan-deps@b83177223d96273d4788f64b19724c60dfb86507', 'src/third_party/vulkan_memory_allocator': Var('chromium_git') + '/external/github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git' + '@' + '5e49f57a6e71a026a54eb42e366de09a4142d24e', @@ -1631,10 +1631,10 @@ Var('chromium_git') + '/external/khronosgroup/webgl.git' + '@' + '9ec0bd5501c6a35eb365dc49be7618a763135a10', 'src/third_party/webgpu-cts/src': - Var('chromium_git') + '/external/github.com/gpuweb/cts.git' + '@' + 'f6f0c1129dffbd7f2c862ea6f7543f3cba582b4c', + Var('chromium_git') + '/external/github.com/gpuweb/cts.git' + '@' + 'c531d83e7869a8265a62892db877fc56c20ca4c4', 'src/third_party/webrtc': - Var('webrtc_git') + '/src.git' + '@' + '90cc4fe0e9e78b4b7f631f495d63422816bf2763', + Var('webrtc_git') + '/src.git' + '@' + '0ce7f165fdf237609a942786219bed248205c827', 'src/third_party/libgifcodec': Var('skia_git') + '/libgifcodec' + '@'+ Var('libgifcodec_revision'), @@ -1692,7 +1692,7 @@ Var('chromium_git') + '/v8/v8.git' + '@' + Var('v8_revision'), 'src-internal': { - 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@e77d11f497177826d9ac64a1267e8d2449b8836d', + 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@5edfce7abcd30fcf502e0a47ad438293e411baab', 'condition': 'checkout_src_internal', },
diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 646b3ed..80b0081d 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py
@@ -5528,9 +5528,10 @@ DEFAULT_FILES_TO_SKIP), files_to_check=[r'.*\.py$']) for f in input_api.AffectedSourceFiles(sources): - [line_num, line] = f.ChangedContents()[0] - if line_num == 1 and line.startswith('#!/usr/bin/python'): - errors.append(f.LocalPath()) + for line_num, line in f.ChangedContents(): + if line_num == 1 and line.startswith('#!/usr/bin/python'): + errors.append(f.LocalPath()) + break result = [] for file in errors:
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py index 799a49fb..c4d4016 100755 --- a/PRESUBMIT_test.py +++ b/PRESUBMIT_test.py
@@ -4064,6 +4064,7 @@ MockFile('ash/test.py', ['#!/usr/bin/python']), MockFile('chrome/test.py', ['#!/usr/bin/python2']), MockFile('third_party/blink/test.py', ['#!/usr/bin/python3']), + MockFile('empty.py', []), ] errors = PRESUBMIT.CheckPythonShebang(input_api, MockOutputApi()) self.assertEqual(3, len(errors))
diff --git a/android_webview/nonembedded/component_updater/aw_component_update_service.cc b/android_webview/nonembedded/component_updater/aw_component_update_service.cc index 38c1e8e..015b81c 100644 --- a/android_webview/nonembedded/component_updater/aw_component_update_service.cc +++ b/android_webview/nonembedded/component_updater/aw_component_update_service.cc
@@ -71,7 +71,7 @@ } bool AwComponentUpdateService::RegisterComponent( - const component_updater::ComponentRegistration& component) { + update_client::CrxComponent component) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); // TODO(crbug.com/1180595): Add the histograms being logged in @@ -168,26 +168,7 @@ } } -update_client::CrxComponent AwComponentUpdateService::ToCrxComponent( - const component_updater::ComponentRegistration& component) const { - update_client::CrxComponent crx; - crx.pk_hash = component.public_key_hash; - crx.app_id = component.app_id; - crx.installer = component.installer; - crx.action_handler = component.action_handler; - crx.version = component.version; - crx.fingerprint = component.fingerprint; - crx.name = component.name; - crx.installer_attributes = component.installer_attributes; - crx.requires_network_encryption = component.requires_network_encryption; - - crx.crx_format_requirement = - crx_file::VerifierFormat::CRX3_WITH_PUBLISHER_PROOF; - - return crx; -} - -absl::optional<component_updater::ComponentRegistration> +absl::optional<update_client::CrxComponent> AwComponentUpdateService::GetComponent(const std::string& id) const { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); return component_updater::GetComponent(components_, id); @@ -197,15 +178,7 @@ AwComponentUpdateService::GetCrxComponents( const std::vector<std::string>& ids) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - std::vector<absl::optional<update_client::CrxComponent>> crxs; - for (absl::optional<component_updater::ComponentRegistration> item : - component_updater::GetCrxComponents(components_, ids)) { - crxs.push_back( - item - ? absl::optional<update_client::CrxComponent>{ToCrxComponent(*item)} - : absl::nullopt); - } - return crxs; + return component_updater::GetCrxComponents(components_, ids); } void AwComponentUpdateService::ScheduleUpdatesOfRegisteredComponents(
diff --git a/android_webview/nonembedded/component_updater/aw_component_update_service.h b/android_webview/nonembedded/component_updater/aw_component_update_service.h index 114c2af..04c7ced 100644 --- a/android_webview/nonembedded/component_updater/aw_component_update_service.h +++ b/android_webview/nonembedded/component_updater/aw_component_update_service.h
@@ -25,13 +25,9 @@ class TimeTicks; } -namespace component_updater { -struct ComponentRegistration; -} - namespace android_webview { -using RegisterComponentsCallback = base::RepeatingCallback<bool( - const component_updater::ComponentRegistration&)>; +using RegisterComponentsCallback = + base::RepeatingCallback<bool(update_client::CrxComponent)>; class TestAwComponentUpdateService; @@ -47,8 +43,7 @@ void StartComponentUpdateService(UpdateCallback finished_callback, bool on_demand_update); - bool RegisterComponent( - const component_updater::ComponentRegistration& component); + bool RegisterComponent(update_client::CrxComponent component); void CheckForUpdates(UpdateCallback on_finished, bool on_demand_update); void IncrementComponentsUpdatedCount(); @@ -73,9 +68,7 @@ void OnUpdateComplete(update_client::Callback callback, const base::TimeTicks& start_time, update_client::Error error); - update_client::CrxComponent ToCrxComponent( - const component_updater::ComponentRegistration& component) const; - absl::optional<component_updater::ComponentRegistration> GetComponent( + absl::optional<update_client::CrxComponent> GetComponent( const std::string& id) const; std::vector<absl::optional<update_client::CrxComponent>> GetCrxComponents( const std::vector<std::string>& ids); @@ -89,8 +82,7 @@ scoped_refptr<update_client::UpdateClient> update_client_; // A collection of every registered component. - base::flat_map<std::string, component_updater::ComponentRegistration> - components_; + base::flat_map<std::string, update_client::CrxComponent> components_; // Maintains the order in which components have been registered. The // position of a component id in this sequence indicates the priority of the
diff --git a/android_webview/nonembedded/component_updater/aw_component_update_service_test.cc b/android_webview/nonembedded/component_updater/aw_component_update_service_test.cc index e8021e38..b5e259a 100644 --- a/android_webview/nonembedded/component_updater/aw_component_update_service_test.cc +++ b/android_webview/nonembedded/component_updater/aw_component_update_service_test.cc
@@ -26,7 +26,6 @@ #include "base/version.h" #include "components/component_updater/component_installer.h" #include "components/component_updater/component_updater_paths.h" -#include "components/component_updater/component_updater_service.h" #include "components/prefs/testing_pref_service.h" #include "components/update_client/network.h" #include "components/update_client/update_client.h"
diff --git a/android_webview/nonembedded/component_updater/aw_component_updater_configurator.cc b/android_webview/nonembedded/component_updater/aw_component_updater_configurator.cc index decb16d9..6fa0571 100644 --- a/android_webview/nonembedded/component_updater/aw_component_updater_configurator.cc +++ b/android_webview/nonembedded/component_updater/aw_component_updater_configurator.cc
@@ -152,6 +152,11 @@ return configurator_impl_.EnabledDeltas(); } +bool AwComponentUpdaterConfigurator::EnabledComponentUpdates() const { + // Always enabled. + return configurator_impl_.EnabledComponentUpdates(); +} + bool AwComponentUpdaterConfigurator::EnabledBackgroundDownloader() const { return configurator_impl_.EnabledBackgroundDownloader(); }
diff --git a/android_webview/nonembedded/component_updater/aw_component_updater_configurator.h b/android_webview/nonembedded/component_updater/aw_component_updater_configurator.h index f196faff..2c21e31a 100644 --- a/android_webview/nonembedded/component_updater/aw_component_updater_configurator.h +++ b/android_webview/nonembedded/component_updater/aw_component_updater_configurator.h
@@ -52,6 +52,7 @@ scoped_refptr<update_client::UnzipperFactory> GetUnzipperFactory() override; scoped_refptr<update_client::PatcherFactory> GetPatcherFactory() override; bool EnabledDeltas() const override; + bool EnabledComponentUpdates() const override; bool EnabledBackgroundDownloader() const override; bool EnabledCupSigning() const override; PrefService* GetPrefService() const override;
diff --git a/android_webview/nonembedded/component_updater/aw_component_updater_configurator_unittest.cc b/android_webview/nonembedded/component_updater/aw_component_updater_configurator_unittest.cc index 1d7b259..20153b9 100644 --- a/android_webview/nonembedded/component_updater/aw_component_updater_configurator_unittest.cc +++ b/android_webview/nonembedded/component_updater/aw_component_updater_configurator_unittest.cc
@@ -93,6 +93,7 @@ EXPECT_TRUE(config->EnabledCupSigning()); EXPECT_TRUE(config->EnabledDeltas()); + EXPECT_TRUE(config->EnabledComponentUpdates()); EXPECT_FALSE(config->EnabledBackgroundDownloader()); }
diff --git a/android_webview/nonembedded/component_updater/installer_policies/aw_package_names_allowlist_component_installer_policy.cc b/android_webview/nonembedded/component_updater/installer_policies/aw_package_names_allowlist_component_installer_policy.cc index 269acc6..b70fcea 100644 --- a/android_webview/nonembedded/component_updater/installer_policies/aw_package_names_allowlist_component_installer_policy.cc +++ b/android_webview/nonembedded/component_updater/installer_policies/aw_package_names_allowlist_component_installer_policy.cc
@@ -46,8 +46,7 @@ } void RegisterWebViewAppsPackageNamesAllowlistComponent( - base::OnceCallback<bool(const component_updater::ComponentRegistration&)> - register_callback, + base::OnceCallback<bool(update_client::CrxComponent)> register_callback, base::OnceClosure registration_finished) { base::MakeRefCounted<component_updater::ComponentInstaller>( std::make_unique<AwPackageNamesAllowlistComponentInstallerPolicy>())
diff --git a/android_webview/nonembedded/component_updater/installer_policies/aw_package_names_allowlist_component_installer_policy.h b/android_webview/nonembedded/component_updater/installer_policies/aw_package_names_allowlist_component_installer_policy.h index 74b92d88..2bbddd5 100644 --- a/android_webview/nonembedded/component_updater/installer_policies/aw_package_names_allowlist_component_installer_policy.h +++ b/android_webview/nonembedded/component_updater/installer_policies/aw_package_names_allowlist_component_installer_policy.h
@@ -50,8 +50,7 @@ // Call once during startup to make the component update service aware of // the package name logging component. void RegisterWebViewAppsPackageNamesAllowlistComponent( - base::OnceCallback<bool(const component_updater::ComponentRegistration&)> - register_callback, + base::OnceCallback<bool(update_client::CrxComponent)> register_callback, base::OnceClosure registration_finished); } // namespace android_webview
diff --git a/android_webview/nonembedded/component_updater/registration.cc b/android_webview/nonembedded/component_updater/registration.cc index 8ed879c..15c82cf 100644 --- a/android_webview/nonembedded/component_updater/registration.cc +++ b/android_webview/nonembedded/component_updater/registration.cc
@@ -15,7 +15,6 @@ #include "base/command_line.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_refptr.h" -#include "components/component_updater/component_updater_service.h" #include "components/component_updater/installer_policies/origin_trials_component_installer.h" #include "components/component_updater/installer_policies/trust_token_key_commitments_component_installer_policy.h" @@ -27,8 +26,7 @@ void RegisterComponentInstallerPolicyShim( std::unique_ptr<component_updater::ComponentInstallerPolicy> policy_, - base::OnceCallback<bool(const component_updater::ComponentRegistration&)> - register_callback, + base::OnceCallback<bool(update_client::CrxComponent)> register_callback, base::OnceClosure registration_finished) { base::MakeRefCounted<component_updater::ComponentInstaller>( std::make_unique<AwComponentInstallerPolicyShim>(std::move(policy_))) @@ -39,8 +37,8 @@ } // namespace void RegisterComponentsForUpdate( - base::RepeatingCallback<bool( - const component_updater::ComponentRegistration&)> register_callback, + base::RepeatingCallback<bool(update_client::CrxComponent)> + register_callback, base::OnceClosure on_finished) { // TODO(crbug.com/1174022): remove command line flag once launched. bool package_names_allowlist_enabled =
diff --git a/android_webview/nonembedded/component_updater/registration.h b/android_webview/nonembedded/component_updater/registration.h index 6f3b7d50f..497cc4c 100644 --- a/android_webview/nonembedded/component_updater/registration.h +++ b/android_webview/nonembedded/component_updater/registration.h
@@ -6,16 +6,13 @@ #define ANDROID_WEBVIEW_NONEMBEDDED_COMPONENT_UPDATER_REGISTRATION_H_ #include "base/callback_forward.h" - -namespace component_updater { -struct ComponentRegistration; -} +#include "components/update_client/update_client.h" namespace android_webview { void RegisterComponentsForUpdate( - base::RepeatingCallback<bool( - const component_updater::ComponentRegistration&)> register_callback, + base::RepeatingCallback<bool(update_client::CrxComponent)> + register_callback, base::OnceClosure on_finished); } // namespace android_webview
diff --git a/ash/BUILD.gn b/ash/BUILD.gn index 251d8fd..d3f2a98 100644 --- a/ash/BUILD.gn +++ b/ash/BUILD.gn
@@ -1521,6 +1521,8 @@ "system/unified/feature_pod_controller_base.h", "system/unified/feature_pods_container_view.cc", "system/unified/feature_pods_container_view.h", + "system/unified/hps_notify_controller.cc", + "system/unified/hps_notify_controller.h", "system/unified/hps_notify_view.cc", "system/unified/hps_notify_view.h", "system/unified/ime_mode_view.cc", @@ -2551,7 +2553,7 @@ "system/tray/tri_view_unittest.cc", "system/unified/camera_mic_tray_item_view_unittest.cc", "system/unified/feature_pods_container_view_unittest.cc", - "system/unified/hps_notify_view_unittest.cc", + "system/unified/hps_notify_controller_unittest.cc", "system/unified/notification_counter_view_unittest.cc", "system/unified/notification_icons_controller_unittest.cc", "system/unified/page_indicator_view_unittest.cc",
diff --git a/ash/ash_prefs.cc b/ash/ash_prefs.cc index d3f6a5a..5ea13a1e 100644 --- a/ash/ash_prefs.cc +++ b/ash/ash_prefs.cc
@@ -41,7 +41,7 @@ #include "ash/system/power/power_prefs.h" #include "ash/system/session/logout_button_tray.h" #include "ash/system/session/logout_confirmation_controller.h" -#include "ash/system/unified/hps_notify_view.h" +#include "ash/system/unified/hps_notify_controller.h" #include "ash/system/unified/top_shortcuts_view.h" #include "ash/system/unified/unified_system_tray_controller.h" #include "ash/touch/touch_devices_controller.h" @@ -81,7 +81,7 @@ GestureEducationNotificationController::RegisterProfilePrefs(registry, for_test); holding_space_prefs::RegisterProfilePrefs(registry); - HpsNotifyView::RegisterProfilePrefs(registry); + HpsNotifyController::RegisterProfilePrefs(registry); LoginScreenController::RegisterProfilePrefs(registry, for_test); LogoutButtonTray::RegisterProfilePrefs(registry); LogoutConfirmationController::RegisterProfilePrefs(registry);
diff --git a/ash/ash_strings.grd b/ash/ash_strings.grd index 0b668861..964e126 100644 --- a/ash/ash_strings.grd +++ b/ash/ash_strings.grd
@@ -589,6 +589,9 @@ <message name="IDS_ASH_STATUS_TRAY_BLUETOOTH_PAIRED_OR_CONNECTED_TOAST" desc="The text used in the toast shown when a new Bluetooth device is newly paired or connected."> <ph name="DEVICE_NAME">$1<ex>Pixel Buds</ex></ph> connected </message> + <message name="IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCONNECTED_TOAST" desc="The text used in the toast shown when a new Bluetooth device disconnected from Chromebook."> + <ph name="DEVICE_NAME">$1<ex>Pixel Buds</ex></ph> disconnected + </message> <message name="IDS_ASH_STATUS_TRAY_UPDATE" desc="The label used in the tray popup to notify that the user should restart to get system updates."> Restart to update @@ -1800,7 +1803,7 @@ Only <ph name="MAX_DESK_LIMIT">$1<ex>8</ex></ph> desks allowed. Remove a desk to open a new one. </message> <message name="IDS_ASH_DESKS_TEMPLATES_UNAVAILABLE_APP_TOAST_ONE" desc="The text of the toast displayed when user tries to launch a template with one unavailable apps."> - <ph name="UNAVAILABLE_APPS">$1<ex>unavailable app</ex></ph>isn't on this device. + <ph name="UNAVAILABLE_APPS">$1<ex>unavailable app</ex></ph> isn't on this device. </message> <message name="IDS_ASH_DESKS_TEMPLATES_UNAVAILABLE_APP_TOAST_TWO" desc="The text of the toast displayed when user tries to launch a template with two unavailable apps."> <ph name="UNAVAILABLE_APPS_ONE">$1<ex>unavailable app one</ex></ph>, and <ph name="UNAVAILABLE_APPS_TWO">$2<ex>unavailable app two</ex></ph> aren't on this device.
diff --git a/ash/ash_strings_grd/IDS_ASH_DESKS_TEMPLATES_UNAVAILABLE_APP_TOAST_ONE.png.sha1 b/ash/ash_strings_grd/IDS_ASH_DESKS_TEMPLATES_UNAVAILABLE_APP_TOAST_ONE.png.sha1 index b955715..e6545ac 100644 --- a/ash/ash_strings_grd/IDS_ASH_DESKS_TEMPLATES_UNAVAILABLE_APP_TOAST_ONE.png.sha1 +++ b/ash/ash_strings_grd/IDS_ASH_DESKS_TEMPLATES_UNAVAILABLE_APP_TOAST_ONE.png.sha1
@@ -1 +1 @@ -f21a27b750fae117db1541f59726b8ea23c6aa37 \ No newline at end of file +a56e18abdd91c170ed4da738a32de63771906b0b \ No newline at end of file
diff --git a/ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCONNECTED_TOAST.png.sha1 b/ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCONNECTED_TOAST.png.sha1 new file mode 100644 index 0000000..237c350 --- /dev/null +++ b/ash/ash_strings_grd/IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCONNECTED_TOAST.png.sha1
@@ -0,0 +1 @@ +6eafdacd2b0a22bdce5227bf031f7d567bc052c8 \ No newline at end of file
diff --git a/ash/components/arc/lock_screen/arc_lock_screen_bridge.h b/ash/components/arc/lock_screen/arc_lock_screen_bridge.h index a688694..0d9afc4 100644 --- a/ash/components/arc/lock_screen/arc_lock_screen_bridge.h +++ b/ash/components/arc/lock_screen/arc_lock_screen_bridge.h
@@ -5,9 +5,9 @@ #ifndef ASH_COMPONENTS_ARC_LOCK_SCREEN_ARC_LOCK_SCREEN_BRIDGE_H_ #define ASH_COMPONENTS_ARC_LOCK_SCREEN_ARC_LOCK_SCREEN_BRIDGE_H_ +#include "ash/components/arc/mojom/lock_screen.mojom.h" #include "ash/components/arc/session/connection_observer.h" #include "base/threading/thread_checker.h" -#include "components/arc/mojom/lock_screen.mojom.h" #include "components/keyed_service/core/keyed_service.h" #include "components/session_manager/core/session_manager_observer.h"
diff --git a/ash/components/arc/media_session/arc_media_session_bridge.h b/ash/components/arc/media_session/arc_media_session_bridge.h index af719a2..e523cf46 100644 --- a/ash/components/arc/media_session/arc_media_session_bridge.h +++ b/ash/components/arc/media_session/arc_media_session_bridge.h
@@ -5,8 +5,8 @@ #ifndef ASH_COMPONENTS_ARC_MEDIA_SESSION_ARC_MEDIA_SESSION_BRIDGE_H_ #define ASH_COMPONENTS_ARC_MEDIA_SESSION_ARC_MEDIA_SESSION_BRIDGE_H_ +#include "ash/components/arc/mojom/media_session.mojom.h" #include "ash/components/arc/session/connection_observer.h" -#include "components/arc/mojom/media_session.mojom.h" #include "components/keyed_service/core/keyed_service.h" namespace content {
diff --git a/ash/components/arc/memory/arc_memory_bridge.h b/ash/components/arc/memory/arc_memory_bridge.h index df7ad8a..b9ea7a2 100644 --- a/ash/components/arc/memory/arc_memory_bridge.h +++ b/ash/components/arc/memory/arc_memory_bridge.h
@@ -5,9 +5,9 @@ #ifndef ASH_COMPONENTS_ARC_MEMORY_ARC_MEMORY_BRIDGE_H_ #define ASH_COMPONENTS_ARC_MEMORY_ARC_MEMORY_BRIDGE_H_ +#include "ash/components/arc/mojom/memory.mojom.h" #include "base/callback_forward.h" #include "base/threading/thread_checker.h" -#include "components/arc/mojom/memory.mojom.h" #include "components/keyed_service/core/keyed_service.h" namespace content {
diff --git a/ash/components/arc/midis/arc_midis_bridge.h b/ash/components/arc/midis/arc_midis_bridge.h index b44b4c1..df0d29a 100644 --- a/ash/components/arc/midis/arc_midis_bridge.h +++ b/ash/components/arc/midis/arc_midis_bridge.h
@@ -7,7 +7,7 @@ #include <stdint.h> -#include "components/arc/mojom/midis.mojom.h" +#include "ash/components/arc/mojom/midis.mojom.h" #include "components/keyed_service/core/keyed_service.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_remote.h"
diff --git a/ash/components/arc/mojom/BUILD.gn b/ash/components/arc/mojom/BUILD.gn index b825a57..87fa5ae 100644 --- a/ash/components/arc/mojom/BUILD.gn +++ b/ash/components/arc/mojom/BUILD.gn
@@ -38,6 +38,15 @@ "keyboard_shortcut.mojom", "keymaster.mojom", "kiosk.mojom", + "lock_screen.mojom", + "media_session.mojom", + "memory.mojom", + "midis.mojom", + "nearby_share.mojom", + "net.mojom", + "obb_mounter.mojom", + "payment_app.mojom", + "pip.mojom", ] public_deps = [
diff --git a/ash/components/arc/mojom/arc_bridge.mojom b/ash/components/arc/mojom/arc_bridge.mojom index b77530089..e32b15b4 100644 --- a/ash/components/arc/mojom/arc_bridge.mojom +++ b/ash/components/arc/mojom/arc_bridge.mojom
@@ -27,24 +27,24 @@ import "ash/components/arc/mojom/keyboard_shortcut.mojom"; import "ash/components/arc/mojom/keymaster.mojom"; import "ash/components/arc/mojom/kiosk.mojom"; +import "ash/components/arc/mojom/lock_screen.mojom"; +import "ash/components/arc/mojom/media_session.mojom"; +import "ash/components/arc/mojom/memory.mojom"; +import "ash/components/arc/mojom/midis.mojom"; +import "ash/components/arc/mojom/nearby_share.mojom"; +import "ash/components/arc/mojom/net.mojom"; import "ash/components/arc/mojom/notifications.mojom"; +import "ash/components/arc/mojom/obb_mounter.mojom"; import "ash/components/arc/mojom/oemcrypto.mojom"; +import "ash/components/arc/mojom/payment_app.mojom"; +import "ash/components/arc/mojom/pip.mojom"; import "ash/components/arc/mojom/video.mojom"; import "components/arc/mojom/app.mojom"; import "components/arc/mojom/app_permissions.mojom"; import "components/arc/mojom/compatibility_mode.mojom"; import "components/arc/mojom/file_system.mojom"; import "components/arc/mojom/intent_helper.mojom"; -import "components/arc/mojom/lock_screen.mojom"; -import "components/arc/mojom/media_session.mojom"; -import "components/arc/mojom/memory.mojom"; import "components/arc/mojom/metrics.mojom"; -import "components/arc/mojom/midis.mojom"; -import "components/arc/mojom/nearby_share.mojom"; -import "components/arc/mojom/net.mojom"; -import "components/arc/mojom/obb_mounter.mojom"; -import "components/arc/mojom/payment_app.mojom"; -import "components/arc/mojom/pip.mojom"; import "components/arc/mojom/policy.mojom"; import "components/arc/mojom/power.mojom"; import "components/arc/mojom/print_spooler.mojom";
diff --git a/components/arc/mojom/lock_screen.mojom b/ash/components/arc/mojom/lock_screen.mojom similarity index 100% rename from components/arc/mojom/lock_screen.mojom rename to ash/components/arc/mojom/lock_screen.mojom
diff --git a/components/arc/mojom/media_session.mojom b/ash/components/arc/mojom/media_session.mojom similarity index 100% rename from components/arc/mojom/media_session.mojom rename to ash/components/arc/mojom/media_session.mojom
diff --git a/components/arc/mojom/memory.mojom b/ash/components/arc/mojom/memory.mojom similarity index 100% rename from components/arc/mojom/memory.mojom rename to ash/components/arc/mojom/memory.mojom
diff --git a/components/arc/mojom/midis.mojom b/ash/components/arc/mojom/midis.mojom similarity index 100% rename from components/arc/mojom/midis.mojom rename to ash/components/arc/mojom/midis.mojom
diff --git a/components/arc/mojom/nearby_share.mojom b/ash/components/arc/mojom/nearby_share.mojom similarity index 100% rename from components/arc/mojom/nearby_share.mojom rename to ash/components/arc/mojom/nearby_share.mojom
diff --git a/components/arc/mojom/net.mojom b/ash/components/arc/mojom/net.mojom similarity index 100% rename from components/arc/mojom/net.mojom rename to ash/components/arc/mojom/net.mojom
diff --git a/components/arc/mojom/obb_mounter.mojom b/ash/components/arc/mojom/obb_mounter.mojom similarity index 100% rename from components/arc/mojom/obb_mounter.mojom rename to ash/components/arc/mojom/obb_mounter.mojom
diff --git a/components/arc/mojom/payment_app.mojom b/ash/components/arc/mojom/payment_app.mojom similarity index 100% rename from components/arc/mojom/payment_app.mojom rename to ash/components/arc/mojom/payment_app.mojom
diff --git a/components/arc/mojom/pip.mojom b/ash/components/arc/mojom/pip.mojom similarity index 100% rename from components/arc/mojom/pip.mojom rename to ash/components/arc/mojom/pip.mojom
diff --git a/ash/components/arc/net/arc_net_host_impl.h b/ash/components/arc/net/arc_net_host_impl.h index c084ee5..4c222d64 100644 --- a/ash/components/arc/net/arc_net_host_impl.h +++ b/ash/components/arc/net/arc_net_host_impl.h
@@ -11,6 +11,7 @@ #include <string> #include <vector> +#include "ash/components/arc/mojom/net.mojom.h" #include "ash/components/arc/session/connection_observer.h" #include "base/callback_forward.h" #include "base/files/scoped_file.h" @@ -20,7 +21,6 @@ #include "chromeos/network/network_connection_observer.h" #include "chromeos/network/network_profile_handler.h" #include "chromeos/network/network_state_handler_observer.h" -#include "components/arc/mojom/net.mojom.h" #include "components/keyed_service/core/keyed_service.h" namespace content {
diff --git a/ash/components/arc/obb_mounter/arc_obb_mounter_bridge.h b/ash/components/arc/obb_mounter/arc_obb_mounter_bridge.h index c1e968c..9b927b7 100644 --- a/ash/components/arc/obb_mounter/arc_obb_mounter_bridge.h +++ b/ash/components/arc/obb_mounter/arc_obb_mounter_bridge.h
@@ -7,7 +7,7 @@ #include <string> -#include "components/arc/mojom/obb_mounter.mojom.h" +#include "ash/components/arc/mojom/obb_mounter.mojom.h" #include "components/keyed_service/core/keyed_service.h" namespace content {
diff --git a/ash/components/arc/pay/arc_payment_app_bridge.h b/ash/components/arc/pay/arc_payment_app_bridge.h index 8fd84dcf..66281bf4 100644 --- a/ash/components/arc/pay/arc_payment_app_bridge.h +++ b/ash/components/arc/pay/arc_payment_app_bridge.h
@@ -7,8 +7,8 @@ #include <string> +#include "ash/components/arc/mojom/payment_app.mojom.h" #include "base/callback_forward.h" -#include "components/arc/mojom/payment_app.mojom.h" #include "components/keyed_service/core/keyed_service.h" namespace content {
diff --git a/ash/components/arc/session/arc_bridge_host_impl.cc b/ash/components/arc/session/arc_bridge_host_impl.cc index e29aa09..0ad5bfe 100644 --- a/ash/components/arc/session/arc_bridge_host_impl.cc +++ b/ash/components/arc/session/arc_bridge_host_impl.cc
@@ -30,8 +30,17 @@ #include "ash/components/arc/mojom/keyboard_shortcut.mojom.h" #include "ash/components/arc/mojom/keymaster.mojom.h" #include "ash/components/arc/mojom/kiosk.mojom.h" +#include "ash/components/arc/mojom/lock_screen.mojom.h" +#include "ash/components/arc/mojom/media_session.mojom.h" +#include "ash/components/arc/mojom/memory.mojom.h" +#include "ash/components/arc/mojom/midis.mojom.h" +#include "ash/components/arc/mojom/nearby_share.mojom.h" +#include "ash/components/arc/mojom/net.mojom.h" #include "ash/components/arc/mojom/notifications.mojom.h" +#include "ash/components/arc/mojom/obb_mounter.mojom.h" #include "ash/components/arc/mojom/oemcrypto.mojom.h" +#include "ash/components/arc/mojom/payment_app.mojom.h" +#include "ash/components/arc/mojom/pip.mojom.h" #include "ash/components/arc/mojom/video.mojom.h" #include "ash/components/arc/session/arc_bridge_service.h" #include "ash/components/arc/session/mojo_channel.h" @@ -45,16 +54,7 @@ #include "components/arc/mojom/compatibility_mode.mojom.h" #include "components/arc/mojom/file_system.mojom.h" #include "components/arc/mojom/intent_helper.mojom.h" -#include "components/arc/mojom/lock_screen.mojom.h" -#include "components/arc/mojom/media_session.mojom.h" -#include "components/arc/mojom/memory.mojom.h" #include "components/arc/mojom/metrics.mojom.h" -#include "components/arc/mojom/midis.mojom.h" -#include "components/arc/mojom/nearby_share.mojom.h" -#include "components/arc/mojom/net.mojom.h" -#include "components/arc/mojom/obb_mounter.mojom.h" -#include "components/arc/mojom/payment_app.mojom.h" -#include "components/arc/mojom/pip.mojom.h" #include "components/arc/mojom/policy.mojom.h" #include "components/arc/mojom/power.mojom.h" #include "components/arc/mojom/print_spooler.mojom.h"
diff --git a/ash/components/arc/session/arc_bridge_service.cc b/ash/components/arc/session/arc_bridge_service.cc index 577deaa1..3239bb4 100644 --- a/ash/components/arc/session/arc_bridge_service.cc +++ b/ash/components/arc/session/arc_bridge_service.cc
@@ -28,21 +28,21 @@ #include "ash/components/arc/mojom/keyboard_shortcut.mojom.h" #include "ash/components/arc/mojom/keymaster.mojom.h" #include "ash/components/arc/mojom/kiosk.mojom.h" +#include "ash/components/arc/mojom/lock_screen.mojom.h" +#include "ash/components/arc/mojom/media_session.mojom.h" +#include "ash/components/arc/mojom/midis.mojom.h" +#include "ash/components/arc/mojom/nearby_share.mojom.h" +#include "ash/components/arc/mojom/net.mojom.h" +#include "ash/components/arc/mojom/obb_mounter.mojom.h" #include "ash/components/arc/mojom/oemcrypto.mojom.h" +#include "ash/components/arc/mojom/payment_app.mojom.h" +#include "ash/components/arc/mojom/pip.mojom.h" #include "ash/components/arc/mojom/video.mojom.h" #include "components/arc/mojom/app.mojom.h" #include "components/arc/mojom/app_permissions.mojom.h" #include "components/arc/mojom/file_system.mojom.h" #include "components/arc/mojom/intent_helper.mojom.h" -#include "components/arc/mojom/lock_screen.mojom.h" -#include "components/arc/mojom/media_session.mojom.h" #include "components/arc/mojom/metrics.mojom.h" -#include "components/arc/mojom/midis.mojom.h" -#include "components/arc/mojom/nearby_share.mojom.h" -#include "components/arc/mojom/net.mojom.h" -#include "components/arc/mojom/obb_mounter.mojom.h" -#include "components/arc/mojom/payment_app.mojom.h" -#include "components/arc/mojom/pip.mojom.h" #include "components/arc/mojom/policy.mojom.h" #include "components/arc/mojom/power.mojom.h" #include "components/arc/mojom/print_spooler.mojom.h"
diff --git a/ash/components/arc/test/arc_payment_app_bridge_test_support.h b/ash/components/arc/test/arc_payment_app_bridge_test_support.h index 96a2692c..4af3394 100644 --- a/ash/components/arc/test/arc_payment_app_bridge_test_support.h +++ b/ash/components/arc/test/arc_payment_app_bridge_test_support.h
@@ -8,10 +8,10 @@ #include <memory> #include <string> +#include "ash/components/arc/mojom/payment_app.mojom.h" #include "ash/components/arc/pay/arc_payment_app_bridge.h" #include "ash/components/arc/session/arc_service_manager.h" #include "ash/components/arc/test/test_browser_context.h" -#include "components/arc/mojom/payment_app.mojom.h" #include "content/public/test/browser_task_environment.h" #include "testing/gmock/include/gmock/gmock.h"
diff --git a/ash/components/arc/test/fake_arc_bridge_host.cc b/ash/components/arc/test/fake_arc_bridge_host.cc index 9e2d647..7b75a129 100644 --- a/ash/components/arc/test/fake_arc_bridge_host.cc +++ b/ash/components/arc/test/fake_arc_bridge_host.cc
@@ -26,23 +26,23 @@ #include "ash/components/arc/mojom/keyboard_shortcut.mojom.h" #include "ash/components/arc/mojom/keymaster.mojom.h" #include "ash/components/arc/mojom/kiosk.mojom.h" +#include "ash/components/arc/mojom/lock_screen.mojom.h" +#include "ash/components/arc/mojom/media_session.mojom.h" +#include "ash/components/arc/mojom/memory.mojom.h" +#include "ash/components/arc/mojom/midis.mojom.h" +#include "ash/components/arc/mojom/nearby_share.mojom.h" +#include "ash/components/arc/mojom/net.mojom.h" #include "ash/components/arc/mojom/notifications.mojom.h" +#include "ash/components/arc/mojom/obb_mounter.mojom.h" #include "ash/components/arc/mojom/oemcrypto.mojom.h" +#include "ash/components/arc/mojom/pip.mojom.h" #include "ash/components/arc/mojom/video.mojom.h" #include "components/arc/mojom/app.mojom.h" #include "components/arc/mojom/app_permissions.mojom.h" #include "components/arc/mojom/compatibility_mode.mojom.h" #include "components/arc/mojom/file_system.mojom.h" #include "components/arc/mojom/intent_helper.mojom.h" -#include "components/arc/mojom/lock_screen.mojom.h" -#include "components/arc/mojom/media_session.mojom.h" -#include "components/arc/mojom/memory.mojom.h" #include "components/arc/mojom/metrics.mojom.h" -#include "components/arc/mojom/midis.mojom.h" -#include "components/arc/mojom/nearby_share.mojom.h" -#include "components/arc/mojom/net.mojom.h" -#include "components/arc/mojom/obb_mounter.mojom.h" -#include "components/arc/mojom/pip.mojom.h" #include "components/arc/mojom/policy.mojom.h" #include "components/arc/mojom/power.mojom.h" #include "components/arc/mojom/print_spooler.mojom.h"
diff --git a/ash/components/arc/test/fake_lock_screen_instance.h b/ash/components/arc/test/fake_lock_screen_instance.h index ef56b4e06..ed67315 100644 --- a/ash/components/arc/test/fake_lock_screen_instance.h +++ b/ash/components/arc/test/fake_lock_screen_instance.h
@@ -5,7 +5,7 @@ #ifndef ASH_COMPONENTS_ARC_TEST_FAKE_LOCK_SCREEN_INSTANCE_H_ #define ASH_COMPONENTS_ARC_TEST_FAKE_LOCK_SCREEN_INSTANCE_H_ -#include "components/arc/mojom/lock_screen.mojom.h" +#include "ash/components/arc/mojom/lock_screen.mojom.h" #include "third_party/abseil-cpp/absl/types/optional.h" namespace arc {
diff --git a/ash/components/arc/test/fake_memory_instance.h b/ash/components/arc/test/fake_memory_instance.h index 233519b..bf038d2 100644 --- a/ash/components/arc/test/fake_memory_instance.h +++ b/ash/components/arc/test/fake_memory_instance.h
@@ -5,8 +5,8 @@ #ifndef ASH_COMPONENTS_ARC_TEST_FAKE_MEMORY_INSTANCE_H_ #define ASH_COMPONENTS_ARC_TEST_FAKE_MEMORY_INSTANCE_H_ +#include "ash/components/arc/mojom/memory.mojom.h" #include "base/callback.h" -#include "components/arc/mojom/memory.mojom.h" namespace arc {
diff --git a/ash/components/arc/test/fake_nearby_share_instance.cc b/ash/components/arc/test/fake_nearby_share_instance.cc index cb072f02..5378e76 100644 --- a/ash/components/arc/test/fake_nearby_share_instance.cc +++ b/ash/components/arc/test/fake_nearby_share_instance.cc
@@ -4,8 +4,8 @@ #include "ash/components/arc/test/fake_nearby_share_instance.h" +#include "ash/components/arc/mojom/nearby_share.mojom.h" #include "base/callback_helpers.h" -#include "components/arc/mojom/nearby_share.mojom.h" namespace arc {
diff --git a/ash/components/arc/test/fake_nearby_share_instance.h b/ash/components/arc/test/fake_nearby_share_instance.h index 5386d09..d61125c 100644 --- a/ash/components/arc/test/fake_nearby_share_instance.h +++ b/ash/components/arc/test/fake_nearby_share_instance.h
@@ -5,7 +5,7 @@ #ifndef ASH_COMPONENTS_ARC_TEST_FAKE_NEARBY_SHARE_INSTANCE_H_ #define ASH_COMPONENTS_ARC_TEST_FAKE_NEARBY_SHARE_INSTANCE_H_ -#include "components/arc/mojom/nearby_share.mojom.h" +#include "ash/components/arc/mojom/nearby_share.mojom.h" #include "mojo/public/cpp/bindings/remote.h" namespace arc {
diff --git a/ash/components/arc/test/fake_net_instance.h b/ash/components/arc/test/fake_net_instance.h index fb1f726..499db3e8 100644 --- a/ash/components/arc/test/fake_net_instance.h +++ b/ash/components/arc/test/fake_net_instance.h
@@ -5,7 +5,7 @@ #ifndef ASH_COMPONENTS_ARC_TEST_FAKE_NET_INSTANCE_H_ #define ASH_COMPONENTS_ARC_TEST_FAKE_NET_INSTANCE_H_ -#include "components/arc/mojom/net.mojom.h" +#include "ash/components/arc/mojom/net.mojom.h" namespace arc {
diff --git a/ash/components/arc/test/fake_pip_instance.h b/ash/components/arc/test/fake_pip_instance.h index 69ea742..01d37ce 100644 --- a/ash/components/arc/test/fake_pip_instance.h +++ b/ash/components/arc/test/fake_pip_instance.h
@@ -5,7 +5,7 @@ #ifndef ASH_COMPONENTS_ARC_TEST_FAKE_PIP_INSTANCE_H_ #define ASH_COMPONENTS_ARC_TEST_FAKE_PIP_INSTANCE_H_ -#include "components/arc/mojom/pip.mojom.h" +#include "ash/components/arc/mojom/pip.mojom.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/remote.h"
diff --git a/ash/constants/ash_features.cc b/ash/constants/ash_features.cc index 49a33dd..ab0e792 100644 --- a/ash/constants/ash_features.cc +++ b/ash/constants/ash_features.cc
@@ -1249,7 +1249,7 @@ // Enable or disable showing multipaste suggestions in virtual keyboard on // Chrome OS. const base::Feature kVirtualKeyboardMultipasteSuggestion{ - "VirtualKeyboardMultipasteSuggestion", base::FEATURE_ENABLED_BY_DEFAULT}; + "VirtualKeyboardMultipasteSuggestion", base::FEATURE_DISABLED_BY_DEFAULT}; // Controls whether to allow enabling wake on WiFi features in shill. const base::Feature kWakeOnWifiAllowed{"WakeOnWifiAllowed",
diff --git a/ash/public/cpp/shell_window_ids.h b/ash/public/cpp/shell_window_ids.h index e37a610..0e2803f 100644 --- a/ash/public/cpp/shell_window_ids.h +++ b/ash/public/cpp/shell_window_ids.h
@@ -208,6 +208,9 @@ // |SelectFileDialogExtension| from favoring to parent the dialog to a browser // window (if one exists). kShellWindowId_CaptureModeFolderSelectionDialogOwner, + + // The window that shows the Desks Templates grid in overview. + kShellWindowId_DesksTemplatesGridWindow, }; // A list of system modal container IDs. The order of the list is important that
diff --git a/ash/quick_pair/BUILD.gn b/ash/quick_pair/BUILD.gn index 8e7c9eb4..1245b8fd 100644 --- a/ash/quick_pair/BUILD.gn +++ b/ash/quick_pair/BUILD.gn
@@ -10,6 +10,7 @@ source_set("quick_pair") { deps = [ "//ash/quick_pair/common", + "//ash/quick_pair/fast_pair_handshake", "//ash/quick_pair/feature_status_tracker", "//ash/quick_pair/keyed_service", "//ash/quick_pair/message_stream", @@ -24,6 +25,7 @@ deps = [ "//ash/quick_pair/common:unit_tests", + "//ash/quick_pair/fast_pair_handshake:unit_tests", "//ash/quick_pair/feature_status_tracker:unit_tests", "//ash/quick_pair/keyed_service:unit_tests", "//ash/quick_pair/message_stream:unit_tests",
diff --git a/ash/quick_pair/fast_pair_handshake/BUILD.gn b/ash/quick_pair/fast_pair_handshake/BUILD.gn new file mode 100644 index 0000000..3900bdd --- /dev/null +++ b/ash/quick_pair/fast_pair_handshake/BUILD.gn
@@ -0,0 +1,91 @@ +# Copyright 2021 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/config/chromeos/ui_mode.gni") +import("//testing/libfuzzer/fuzzer_test.gni") + +assert(is_chromeos_ash, + "Quick Pair protocols (e.g. Fast Pair) are ash-chrome only") + +source_set("fast_pair_handshake") { + sources = [ + "fast_pair_data_encryptor.h", + "fast_pair_data_encryptor_impl.cc", + "fast_pair_data_encryptor_impl.h", + "fast_pair_encryption.cc", + "fast_pair_encryption.h", + "fast_pair_gatt_service_client.h", + "fast_pair_gatt_service_client_impl.cc", + "fast_pair_gatt_service_client_impl.h", + "fast_pair_key_pair.cc", + "fast_pair_key_pair.h", + ] + + deps = [ + "//ash/public/cpp", + "//ash/quick_pair/common", + "//ash/quick_pair/proto:fastpair_proto", + "//ash/quick_pair/repository", + "//ash/services/quick_pair", + "//ash/services/quick_pair/public/cpp", + "//base", + "//crypto:crypto", + "//device/bluetooth", + "//third_party/protobuf:protobuf_lite", + ] +} + +static_library("test_support") { + testonly = true + + sources = [ + "fake_fast_pair_gatt_service_client.cc", + "fake_fast_pair_gatt_service_client.h", + "fast_pair_data_encryptor.h", + "fast_pair_gatt_service_client.h", + ] + + deps = [ + "//ash/quick_pair/common", + "//ash/services/quick_pair/public/cpp", + "//base", + "//base/test:test_support", + "//device/bluetooth", + "//testing/gtest", + ] +} + +source_set("unit_tests") { + testonly = true + + sources = [ + "fast_pair_data_encryptor_unittest.cc", + "fast_pair_encryption_unittest.cc", + "fast_pair_gatt_service_client_unittest.cc", + ] + + deps = [ + ":fast_pair_handshake", + "//ash/quick_pair/common", + "//ash/quick_pair/repository:test_support", + "//ash/services/quick_pair", + "//ash/services/quick_pair:test_support", + "//base", + "//base/test:test_support", + "//device/bluetooth", + "//device/bluetooth:mocks", + "//testing/gtest", + ] +} + +fuzzer_test("fast_pair_encryption_fuzzer") { + sources = [ "fast_pair_encryption_fuzzer.cc" ] + deps = [ + ":fast_pair_handshake", + "//ash:test_support", + "//ash/quick_pair/common", + "//ash/services/quick_pair", + "//base", + ] +}
diff --git a/ash/quick_pair/fast_pair_handshake/DEPS b/ash/quick_pair/fast_pair_handshake/DEPS new file mode 100644 index 0000000..b9ec86f --- /dev/null +++ b/ash/quick_pair/fast_pair_handshake/DEPS
@@ -0,0 +1,4 @@ +include_rules = [ + "+crypto/openssl_util.h", + "+third_party/boringssl/src/include", +]
diff --git a/ash/quick_pair/pairing/fast_pair/fake_fast_pair_gatt_service_client.cc b/ash/quick_pair/fast_pair_handshake/fake_fast_pair_gatt_service_client.cc similarity index 94% rename from ash/quick_pair/pairing/fast_pair/fake_fast_pair_gatt_service_client.cc rename to ash/quick_pair/fast_pair_handshake/fake_fast_pair_gatt_service_client.cc index 18ae445..f3b8307 100644 --- a/ash/quick_pair/pairing/fast_pair/fake_fast_pair_gatt_service_client.cc +++ b/ash/quick_pair/fast_pair_handshake/fake_fast_pair_gatt_service_client.cc
@@ -2,9 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/quick_pair/pairing/fast_pair/fake_fast_pair_gatt_service_client.h" +#include "ash/quick_pair/fast_pair_handshake/fake_fast_pair_gatt_service_client.h" + #include "ash/quick_pair/common/logging.h" -#include "ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor.h" #include "base/callback_helpers.h" #include "device/bluetooth/bluetooth_adapter.h" #include "device/bluetooth/bluetooth_device.h"
diff --git a/ash/quick_pair/pairing/fast_pair/fake_fast_pair_gatt_service_client.h b/ash/quick_pair/fast_pair_handshake/fake_fast_pair_gatt_service_client.h similarity index 89% rename from ash/quick_pair/pairing/fast_pair/fake_fast_pair_gatt_service_client.h rename to ash/quick_pair/fast_pair_handshake/fake_fast_pair_gatt_service_client.h index b6c1e42..e8713c9 100644 --- a/ash/quick_pair/pairing/fast_pair/fake_fast_pair_gatt_service_client.h +++ b/ash/quick_pair/fast_pair_handshake/fake_fast_pair_gatt_service_client.h
@@ -2,19 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAKE_FAST_PAIR_GATT_SERVICE_CLIENT_H_ -#define ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAKE_FAST_PAIR_GATT_SERVICE_CLIENT_H_ +#ifndef ASH_QUICK_PAIR_FAST_PAIR_HANDSHAKE_FAKE_FAST_PAIR_GATT_SERVICE_CLIENT_H_ +#define ASH_QUICK_PAIR_FAST_PAIR_HANDSHAKE_FAKE_FAST_PAIR_GATT_SERVICE_CLIENT_H_ #include "ash/quick_pair/common/pair_failure.h" -#include "ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client.h" #include "base/callback.h" #include "third_party/abseil-cpp/absl/types/optional.h" namespace device { - -class BluetothAdapter; class BluetoothDevice; - } // namespace device namespace ash { @@ -88,4 +85,4 @@ } // namespace quick_pair } // namespace ash -#endif // ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAKE_FAST_PAIR_GATT_SERVICE_CLIENT_H_ +#endif // ASH_QUICK_PAIR_FAST_PAIR_HANDSHAKE_FAKE_FAST_PAIR_GATT_SERVICE_CLIENT_H_
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor.h b/ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor.h similarity index 88% rename from ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor.h rename to ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor.h index 655b0e9..c9eb13d 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor.h +++ b/ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_DATA_ENCRYPTOR_H_ -#define ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_DATA_ENCRYPTOR_H_ +#ifndef ASH_QUICK_PAIR_FAST_PAIR_HANDSHAKE_FAST_PAIR_DATA_ENCRYPTOR_H_ +#define ASH_QUICK_PAIR_FAST_PAIR_HANDSHAKE_FAST_PAIR_DATA_ENCRYPTOR_H_ #include <stddef.h> #include <stdint.h> @@ -54,4 +54,4 @@ } // namespace quick_pair } // namespace ash -#endif // ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_DATA_ENCRYPTOR_H_ +#endif // ASH_QUICK_PAIR_FAST_PAIR_HANDSHAKE_FAST_PAIR_DATA_ENCRYPTOR_H_
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor_impl.cc b/ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor_impl.cc similarity index 97% rename from ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor_impl.cc rename to ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor_impl.cc index cffb684..455d70b 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor_impl.cc +++ b/ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor_impl.cc
@@ -2,13 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor_impl.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor_impl.h" + #include <array> #include <cstdint> #include "ash/quick_pair/common/logging.h" #include "ash/quick_pair/common/protocol.h" -#include "ash/quick_pair/pairing/fast_pair/fast_pair_encryption.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_encryption.h" #include "ash/quick_pair/proto/fastpair.pb.h" #include "ash/quick_pair/repository/fast_pair/device_metadata.h" #include "ash/quick_pair/repository/fast_pair_repository.h"
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor_impl.h b/ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor_impl.h similarity index 89% rename from ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor_impl.h rename to ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor_impl.h index f210cae..732359f 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor_impl.h +++ b/ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor_impl.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_DATA_ENCRYPTOR_IMPL_H_ -#define ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_DATA_ENCRYPTOR_IMPL_H_ +#ifndef ASH_QUICK_PAIR_FAST_PAIR_HANDSHAKE_FAST_PAIR_DATA_ENCRYPTOR_IMPL_H_ +#define ASH_QUICK_PAIR_FAST_PAIR_HANDSHAKE_FAST_PAIR_DATA_ENCRYPTOR_IMPL_H_ #include <stddef.h> #include <stdint.h> @@ -11,8 +11,8 @@ #include <array> #include "ash/quick_pair/common/device.h" -#include "ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor.h" -#include "ash/quick_pair/pairing/fast_pair/fast_pair_key_pair.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_key_pair.h" #include "ash/services/quick_pair/quick_pair_process_manager.h" #include "base/memory/scoped_refptr.h" #include "base/memory/weak_ptr.h" @@ -107,4 +107,4 @@ } // namespace quick_pair } // namespace ash -#endif // ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_DATA_ENCRYPTOR_IMPL_H_ +#endif // ASH_QUICK_PAIR_FAST_PAIR_HANDSHAKE_FAST_PAIR_DATA_ENCRYPTOR_IMPL_H_
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor_unittest.cc b/ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor_unittest.cc similarity index 97% rename from ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor_unittest.cc rename to ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor_unittest.cc index bcadb74..310e36d 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor_unittest.cc +++ b/ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor.h" #include <stddef.h> #include <stdint.h> @@ -10,7 +10,7 @@ #include <array> #include "ash/quick_pair/common/protocol.h" -#include "ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor_impl.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor_impl.h" #include "ash/quick_pair/repository/fake_fast_pair_repository.h" #include "ash/services/quick_pair/mock_quick_pair_process_manager.h" #include "ash/services/quick_pair/quick_pair_process.h"
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_encryption.cc b/ash/quick_pair/fast_pair_handshake/fast_pair_encryption.cc similarity index 97% rename from ash/quick_pair/pairing/fast_pair/fast_pair_encryption.cc rename to ash/quick_pair/fast_pair_handshake/fast_pair_encryption.cc index f8a56f1..c1be849 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_encryption.cc +++ b/ash/quick_pair/fast_pair_handshake/fast_pair_encryption.cc
@@ -5,10 +5,10 @@ #include <algorithm> #include <array> -#include "ash/quick_pair/pairing/fast_pair/fast_pair_encryption.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_encryption.h" #include "ash/quick_pair/common/logging.h" -#include "ash/quick_pair/pairing/fast_pair/fast_pair_key_pair.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_key_pair.h" #include "ash/services/quick_pair/public/cpp/fast_pair_message_type.h" #include "base/check.h" #include "third_party/abseil-cpp/absl/types/optional.h"
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_encryption.h b/ash/quick_pair/fast_pair_handshake/fast_pair_encryption.h similarity index 67% rename from ash/quick_pair/pairing/fast_pair/fast_pair_encryption.h rename to ash/quick_pair/fast_pair_handshake/fast_pair_encryption.h index 4c4b4dc..4b8f4c7 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_encryption.h +++ b/ash/quick_pair/fast_pair_handshake/fast_pair_encryption.h
@@ -2,16 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_ENCRYPTION_H_ -#define ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_ENCRYPTION_H_ +#ifndef ASH_QUICK_PAIR_FAST_PAIR_HANDSHAKE_FAST_PAIR_ENCRYPTION_H_ +#define ASH_QUICK_PAIR_FAST_PAIR_HANDSHAKE_FAST_PAIR_ENCRYPTION_H_ #include <stdint.h> #include <array> #include <string> -#include "ash/quick_pair/pairing/fast_pair/fast_pair_key_pair.h" -#include "base/component_export.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_key_pair.h" #include "third_party/abseil-cpp/absl/types/optional.h" namespace ash { @@ -20,11 +19,9 @@ constexpr int kBlockByteSize = 16; -COMPONENT_EXPORT(QUICK_PAIR_PAIRING) absl::optional<KeyPair> GenerateKeysWithEcdhKeyAgreement( const std::string& decoded_public_anti_spoofing); -COMPONENT_EXPORT(QUICK_PAIR_PAIRING) const std::array<uint8_t, kBlockByteSize> EncryptBytes( const std::array<uint8_t, kBlockByteSize>& aes_key_bytes, const std::array<uint8_t, kBlockByteSize>& bytes_to_encrypt); @@ -33,4 +30,4 @@ } // namespace quick_pair } // namespace ash -#endif // ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_ENCRYPTION_H_ +#endif // ASH_QUICK_PAIR_FAST_PAIR_HANDSHAKE_FAST_PAIR_ENCRYPTION_H_
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_encryption_fuzzer.cc b/ash/quick_pair/fast_pair_handshake/fast_pair_encryption_fuzzer.cc similarity index 96% rename from ash/quick_pair/pairing/fast_pair/fast_pair_encryption_fuzzer.cc rename to ash/quick_pair/fast_pair_handshake/fast_pair_encryption_fuzzer.cc index d646cab..d3d4878 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_encryption_fuzzer.cc +++ b/ash/quick_pair/fast_pair_handshake/fast_pair_encryption_fuzzer.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/quick_pair/pairing/fast_pair/fast_pair_encryption.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_encryption.h" #include <fuzzer/FuzzedDataProvider.h> #include <stddef.h> @@ -10,7 +10,7 @@ #include <array> #include "ash/quick_pair/common/logging.h" -#include "ash/quick_pair/pairing/fast_pair/fast_pair_key_pair.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_key_pair.h" #include "ash/services/quick_pair/fast_pair_decryption.h" #include "base/check.h" #include "base/no_destructor.h" @@ -113,4 +113,4 @@ anti_spoofing_key); return 0; -} \ No newline at end of file +}
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_encryption_unittest.cc b/ash/quick_pair/fast_pair_handshake/fast_pair_encryption_unittest.cc similarity index 97% rename from ash/quick_pair/pairing/fast_pair/fast_pair_encryption_unittest.cc rename to ash/quick_pair/fast_pair_handshake/fast_pair_encryption_unittest.cc index 04c5a34..49b2de61 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_encryption_unittest.cc +++ b/ash/quick_pair/fast_pair_handshake/fast_pair_encryption_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/quick_pair/pairing/fast_pair/fast_pair_encryption.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_encryption.h" #include <algorithm> #include <array>
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client.h b/ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client.h similarity index 90% rename from ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client.h rename to ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client.h index 9643f8f..38832348d 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client.h +++ b/ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_GATT_SERVICE_CLIENT_H_ -#define ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_GATT_SERVICE_CLIENT_H_ +#ifndef ASH_QUICK_PAIR_FAST_PAIR_HANDSHAKE_FAST_PAIR_GATT_SERVICE_CLIENT_H_ +#define ASH_QUICK_PAIR_FAST_PAIR_HANDSHAKE_FAST_PAIR_GATT_SERVICE_CLIENT_H_ #include "device/bluetooth/bluetooth_adapter.h" @@ -63,4 +63,4 @@ } // namespace quick_pair } // namespace ash -#endif // ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_GATT_SERVICE_CLIENT_H_ +#endif // ASH_QUICK_PAIR_FAST_PAIR_HANDSHAKE_FAST_PAIR_GATT_SERVICE_CLIENT_H_
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_impl.cc b/ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client_impl.cc similarity index 98% rename from ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_impl.cc rename to ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client_impl.cc index 657cb7c..d706bf08 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_impl.cc +++ b/ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client_impl.cc
@@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_impl.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client_impl.h" #include "ash/quick_pair/common/constants.h" #include "ash/quick_pair/common/logging.h" -#include "ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor.h" #include "base/memory/ptr_util.h" #include "base/time/time.h" #include "device/bluetooth/bluetooth_device.h"
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_impl.h b/ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client_impl.h similarity index 95% rename from ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_impl.h rename to ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client_impl.h index a1ffb47e..d739a7f 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_impl.h +++ b/ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client_impl.h
@@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_GATT_SERVICE_CLIENT_IMPL_H_ -#define ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_GATT_SERVICE_CLIENT_IMPL_H_ +#ifndef ASH_QUICK_PAIR_FAST_PAIR_HANDSHAKE_FAST_PAIR_GATT_SERVICE_CLIENT_IMPL_H_ +#define ASH_QUICK_PAIR_FAST_PAIR_HANDSHAKE_FAST_PAIR_GATT_SERVICE_CLIENT_IMPL_H_ #include <stdint.h> #include <vector> #include "ash/quick_pair/common/pair_failure.h" -#include "ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client.h" #include "base/callback.h" #include "base/callback_helpers.h" #include "base/memory/scoped_refptr.h" @@ -196,4 +196,4 @@ } // namespace quick_pair } // namespace ash -#endif // ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_GATT_SERVICE_CLIENT_IMPL_H_ +#endif // ASH_QUICK_PAIR_FAST_PAIR_HANDSHAKE_FAST_PAIR_GATT_SERVICE_CLIENT_IMPL_H_
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_unittest.cc b/ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client_unittest.cc similarity index 98% rename from ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_unittest.cc rename to ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client_unittest.cc index f856de991..ce8fac905 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_unittest.cc +++ b/ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client_unittest.cc
@@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_impl.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client_impl.h" #include <stddef.h> #include "ash/quick_pair/common/constants.h" #include "ash/quick_pair/common/logging.h" #include "ash/quick_pair/common/pair_failure.h" -#include "ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor.h" -#include "ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor_impl.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor_impl.h" #include "base/bind.h" #include "base/callback.h" #include "base/memory/weak_ptr.h"
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_key_pair.cc b/ash/quick_pair/fast_pair_handshake/fast_pair_key_pair.cc similarity index 90% rename from ash/quick_pair/pairing/fast_pair/fast_pair_key_pair.cc rename to ash/quick_pair/fast_pair_handshake/fast_pair_key_pair.cc index 41ca33f..71dcfbc 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_key_pair.cc +++ b/ash/quick_pair/fast_pair_handshake/fast_pair_key_pair.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/quick_pair/pairing/fast_pair/fast_pair_key_pair.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_key_pair.h" namespace ash { namespace quick_pair {
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_key_pair.h b/ash/quick_pair/fast_pair_handshake/fast_pair_key_pair.h similarity index 77% rename from ash/quick_pair/pairing/fast_pair/fast_pair_key_pair.h rename to ash/quick_pair/fast_pair_handshake/fast_pair_key_pair.h index 71500c2..487f459 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_key_pair.h +++ b/ash/quick_pair/fast_pair_handshake/fast_pair_key_pair.h
@@ -2,16 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_KEY_PAIR_H_ -#define ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_KEY_PAIR_H_ +#ifndef ASH_QUICK_PAIR_FAST_PAIR_HANDSHAKE_FAST_PAIR_KEY_PAIR_H_ +#define ASH_QUICK_PAIR_FAST_PAIR_HANDSHAKE_FAST_PAIR_KEY_PAIR_H_ #include <stddef.h> #include <stdint.h> #include <array> -#include "base/component_export.h" - namespace { constexpr int kPrivateKeyByteSize = 16; @@ -25,7 +23,7 @@ // Key pair structure to represent public and private keys used for encryption/ // decryption. -struct COMPONENT_EXPORT(QUICK_PAIR_PAIRING) KeyPair { +struct KeyPair { KeyPair(std::array<uint8_t, kPrivateKeyByteSize> private_key, std::array<uint8_t, kPublicKeyByteSize> public_key); KeyPair(const KeyPair&); @@ -42,4 +40,4 @@ } // namespace quick_pair } // namespace ash -#endif // ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_KEY_PAIR_H_ +#endif // ASH_QUICK_PAIR_FAST_PAIR_HANDSHAKE_FAST_PAIR_KEY_PAIR_H_
diff --git a/ash/quick_pair/pairing/BUILD.gn b/ash/quick_pair/pairing/BUILD.gn index 2275f3ba..b678fe6 100644 --- a/ash/quick_pair/pairing/BUILD.gn +++ b/ash/quick_pair/pairing/BUILD.gn
@@ -10,18 +10,6 @@ source_set("pairing") { sources = [ - "fast_pair/fake_fast_pair_gatt_service_client.cc", - "fast_pair/fake_fast_pair_gatt_service_client.h", - "fast_pair/fast_pair_data_encryptor.h", - "fast_pair/fast_pair_data_encryptor_impl.cc", - "fast_pair/fast_pair_data_encryptor_impl.h", - "fast_pair/fast_pair_encryption.cc", - "fast_pair/fast_pair_encryption.h", - "fast_pair/fast_pair_gatt_service_client.h", - "fast_pair/fast_pair_gatt_service_client_impl.cc", - "fast_pair/fast_pair_gatt_service_client_impl.h", - "fast_pair/fast_pair_key_pair.cc", - "fast_pair/fast_pair_key_pair.h", "fast_pair/fast_pair_pairer.cc", "fast_pair/fast_pair_pairer.h", "fast_pair/fast_pair_unpair_handler.cc", @@ -37,6 +25,7 @@ deps = [ "//ash/public/cpp", "//ash/quick_pair/common", + "//ash/quick_pair/fast_pair_handshake", "//ash/quick_pair/message_stream", "//ash/quick_pair/proto:fastpair_proto", "//ash/quick_pair/repository", @@ -63,6 +52,7 @@ deps = [ "//ash/quick_pair/common", + "//ash/quick_pair/fast_pair_handshake", "//base", "//base/test:test_support", "//device/bluetooth", @@ -74,9 +64,6 @@ testonly = true sources = [ - "fast_pair/fast_pair_data_encryptor_unittest.cc", - "fast_pair/fast_pair_encryption_unittest.cc", - "fast_pair/fast_pair_gatt_service_client_unittest.cc", "fast_pair/fast_pair_pairer_unittest.cc", "fast_pair/fast_pair_unpair_handler_unittest.cc", "retroactive_pairing_detector_unittest.cc", @@ -88,6 +75,8 @@ "//ash:test_support", "//ash/public/cpp:test_support", "//ash/quick_pair/common", + "//ash/quick_pair/fast_pair_handshake", + "//ash/quick_pair/fast_pair_handshake:test_support", "//ash/quick_pair/message_stream", "//ash/quick_pair/message_stream:test_support", "//ash/quick_pair/proto:fastpair_proto", @@ -104,15 +93,3 @@ "//testing/gtest", ] } - -fuzzer_test("fast_pair_encryption_fuzzer") { - sources = [ "fast_pair/fast_pair_encryption_fuzzer.cc" ] - deps = [ - ":pairing", - ":test_support", - "//ash:test_support", - "//ash/quick_pair/common", - "//ash/services/quick_pair", - "//base", - ] -}
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_pairer.cc b/ash/quick_pair/pairing/fast_pair/fast_pair_pairer.cc index f2d84e7..252b8be 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_pairer.cc +++ b/ash/quick_pair/pairing/fast_pair/fast_pair_pairer.cc
@@ -10,9 +10,9 @@ #include "ash/quick_pair/common/logging.h" #include "ash/quick_pair/common/pair_failure.h" #include "ash/quick_pair/common/protocol.h" -#include "ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor.h" -#include "ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor_impl.h" -#include "ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_impl.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor_impl.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client_impl.h" #include "ash/quick_pair/repository/fast_pair_repository.h" #include "ash/services/quick_pair/public/cpp/fast_pair_message_type.h" #include "ash/shell.h"
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_pairer.h b/ash/quick_pair/pairing/fast_pair/fast_pair_pairer.h index e1abd9a0..1da5d218 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_pairer.h +++ b/ash/quick_pair/pairing/fast_pair/fast_pair_pairer.h
@@ -6,7 +6,7 @@ #define ASH_QUICK_PAIR_PAIRING_FAST_PAIR_FAST_PAIR_PAIRER_H_ #include "ash/quick_pair/common/pair_failure.h" -#include "ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client.h" #include "ash/services/quick_pair/public/cpp/decrypted_passkey.h" #include "ash/services/quick_pair/public/cpp/decrypted_response.h" #include "base/callback.h"
diff --git a/ash/quick_pair/pairing/fast_pair/fast_pair_pairer_unittest.cc b/ash/quick_pair/pairing/fast_pair/fast_pair_pairer_unittest.cc index 51ded6e..5028505 100644 --- a/ash/quick_pair/pairing/fast_pair/fast_pair_pairer_unittest.cc +++ b/ash/quick_pair/pairing/fast_pair/fast_pair_pairer_unittest.cc
@@ -12,11 +12,11 @@ #include "ash/quick_pair/common/logging.h" #include "ash/quick_pair/common/pair_failure.h" #include "ash/quick_pair/common/protocol.h" -#include "ash/quick_pair/pairing/fast_pair/fake_fast_pair_gatt_service_client.h" -#include "ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor.h" -#include "ash/quick_pair/pairing/fast_pair/fast_pair_data_encryptor_impl.h" -#include "ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client.h" -#include "ash/quick_pair/pairing/fast_pair/fast_pair_gatt_service_client_impl.h" +#include "ash/quick_pair/fast_pair_handshake/fake_fast_pair_gatt_service_client.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_data_encryptor_impl.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_gatt_service_client_impl.h" #include "ash/quick_pair/repository/fake_fast_pair_repository.h" #include "ash/services/quick_pair/public/cpp/decrypted_passkey.h" #include "ash/services/quick_pair/public/cpp/decrypted_response.h"
diff --git a/ash/services/ime/decoder/system_engine_unittest.cc b/ash/services/ime/decoder/system_engine_unittest.cc index bd988797..b7fe2dd 100644 --- a/ash/services/ime/decoder/system_engine_unittest.cc +++ b/ash/services/ime/decoder/system_engine_unittest.cc
@@ -95,8 +95,7 @@ MOCK_METHOD(void, SetComposition, (const std::u16string& text, - std::vector<mojom::CompositionSpanPtr> spans, - uint32_t new_cursor_position), + std::vector<mojom::CompositionSpanPtr> spans), (override)); MOCK_METHOD(void, SetCompositionRange,
diff --git a/ash/services/ime/ime_service_unittest.cc b/ash/services/ime/ime_service_unittest.cc index 6063498..fdb5c926 100644 --- a/ash/services/ime/ime_service_unittest.cc +++ b/ash/services/ime/ime_service_unittest.cc
@@ -122,8 +122,7 @@ last_commit = text; } void SetComposition(const std::u16string& text, - std::vector<mojom::CompositionSpanPtr> spans, - uint32_t new_cursor_position) override { + std::vector<mojom::CompositionSpanPtr> spans) override { last_composition = text; } void SetCompositionRange(uint32_t start_index, uint32_t end_index) override {} @@ -156,8 +155,7 @@ void CommitText(const std::u16string& text, mojom::CommitTextCursorBehavior cursor_behavior) override {} void SetComposition(const std::u16string& text, - std::vector<mojom::CompositionSpanPtr> spans, - uint32_t new_cursor_position) override {} + std::vector<mojom::CompositionSpanPtr> spans) override {} void SetCompositionRange(uint32_t start_index, uint32_t end_index) override {} void FinishComposition() override {} void DeleteSurroundingText(uint32_t num_before_cursor,
diff --git a/ash/services/ime/public/mojom/input_method_host.mojom b/ash/services/ime/public/mojom/input_method_host.mojom index e93e17a8..19fe73b4 100644 --- a/ash/services/ime/public/mojom/input_method_host.mojom +++ b/ash/services/ime/public/mojom/input_method_host.mojom
@@ -6,7 +6,7 @@ // the Chromium repo. This file should be updated first, before syncing in the // other repos. -// Next MinVersion: 6 +// Next MinVersion: 5 module chromeos.ime.mojom; @@ -244,20 +244,9 @@ // Asks the focused input field to set composition with `text`. // Replaces the current composition if there is one. Otherwise, start a // new composition at the current cursor position, deleting any text in the - // current selection if any. - // + // current selection if any. The cursor is moved to the end of `text`. // `spans` is used to style `text`. - // - // The cursor then moves based on `new_cursor_position`, which is the relative - // UTF-16 offset of the new cursor position from the front of `text`. - // For example, if `new_cursor_position` is 3, then the cursor is placed - // between `text[3]` and `text[4]`. A `new_cursor_position` of 0 places the - // cursor immediately before `text`, and a value of `text.length()` places the - // cursor immediately after `text`. - // If `new_cursor_position > text.length()`, then this is a no-op. - SetComposition@1(mojo_base.mojom.String16 text, - array<CompositionSpan> spans, - [MinVersion=5] uint32 new_cursor_position); + SetComposition@1(mojo_base.mojom.String16 text, array<CompositionSpan> spans); // Asks the focused input field to mark the range of text spanned by // `start_index` and `end_index` as the current composition, where index 0
diff --git a/ash/services/ime/rule_based_engine.cc b/ash/services/ime/rule_based_engine.cc index 0d5c35b..846894b 100644 --- a/ash/services/ime/rule_based_engine.cc +++ b/ash/services/ime/rule_based_engine.cc
@@ -60,9 +60,7 @@ std::vector<mojom::CompositionSpanPtr> spans; spans.push_back(mojom::CompositionSpan::New( 0, text.length(), mojom::CompositionSpanStyle::kDefault)); - const int new_cursor_position = text.length(); - host->SetComposition(std::move(text), std::move(spans), - new_cursor_position); + host->SetComposition(std::move(text), std::move(spans)); } return result.key_handled ? mojom::KeyEventResult::kConsumedByIme : mojom::KeyEventResult::kNeedsHandlingBySystem;
diff --git a/ash/services/quick_pair/BUILD.gn b/ash/services/quick_pair/BUILD.gn index 0c30041..6d37dcd 100644 --- a/ash/services/quick_pair/BUILD.gn +++ b/ash/services/quick_pair/BUILD.gn
@@ -67,7 +67,7 @@ deps = [ ":quick_pair", "//ash/quick_pair/common:test_support", - "//ash/quick_pair/pairing", + "//ash/quick_pair/fast_pair_handshake", "//ash/services/quick_pair/public/cpp", "//ash/services/quick_pair/public/cpp:unit_tests", "//ash/services/quick_pair/public/mojom",
diff --git a/ash/services/quick_pair/fast_pair_decryption_unittest.cc b/ash/services/quick_pair/fast_pair_decryption_unittest.cc index 1094ac8..53df33a27 100644 --- a/ash/services/quick_pair/fast_pair_decryption_unittest.cc +++ b/ash/services/quick_pair/fast_pair_decryption_unittest.cc
@@ -6,7 +6,7 @@ #include <array> -#include "ash/quick_pair/pairing/fast_pair/fast_pair_encryption.h" +#include "ash/quick_pair/fast_pair_handshake/fast_pair_encryption.h" #include "ash/services/quick_pair/public/cpp/fast_pair_message_type.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/ash/shell.cc b/ash/shell.cc index d2131c24..bfabee18 100644 --- a/ash/shell.cc +++ b/ash/shell.cc
@@ -138,6 +138,7 @@ #include "ash/system/system_notification_controller.h" #include "ash/system/toast/toast_manager_impl.h" #include "ash/system/tray/system_tray_notifier.h" +#include "ash/system/unified/hps_notify_controller.h" #include "ash/touch/ash_touch_transform_controller.h" #include "ash/touch/touch_devices_controller.h" #include "ash/tray_action/tray_action.h" @@ -796,6 +797,8 @@ ScreenAsh::CreateScreenForShutdown(); display_configuration_controller_.reset(); + hps_notify_controller_.reset(); + // These members access Shell in their destructors. wallpaper_controller_.reset(); accessibility_controller_.reset(); @@ -970,6 +973,8 @@ media_notification_provider_ = std::make_unique<MediaNotificationProviderImpl>( shell_delegate_->GetMediaSessionService()); + if (features::IsSnoopingProtectionEnabled()) + hps_notify_controller_ = std::make_unique<HpsNotifyController>(); tablet_mode_controller_ = std::make_unique<TabletModeController>();
diff --git a/ash/shell.h b/ash/shell.h index 761587b6..f36c16b 100644 --- a/ash/shell.h +++ b/ash/shell.h
@@ -131,6 +131,7 @@ class HighContrastController; class HighlighterController; class HoldingSpaceController; +class HpsNotifyController; class ImeControllerImpl; class InSessionAuthDialogControllerImpl; class KeyAccessibilityEnabler; @@ -423,6 +424,9 @@ HighContrastController* high_contrast_controller() { return high_contrast_controller_.get(); } + HpsNotifyController* hps_notify_controller() { + return hps_notify_controller_.get(); + } ImeControllerImpl* ime_controller() { return ime_controller_.get(); } InSessionAuthDialogControllerImpl* in_session_auth_dialog_controller() { return in_session_auth_dialog_controller_.get(); @@ -741,6 +745,7 @@ std::unique_ptr<FocusCycler> focus_cycler_; std::unique_ptr<FloatController> float_controller_; std::unique_ptr<HoldingSpaceController> holding_space_controller_; + std::unique_ptr<HpsNotifyController> hps_notify_controller_; std::unique_ptr<ImeControllerImpl> ime_controller_; std::unique_ptr<chromeos::ImmersiveContext> immersive_context_; std::unique_ptr<InSessionAuthDialogControllerImpl>
diff --git a/ash/system/accessibility/accessibility_feature_pod_controller_unittest.cc b/ash/system/accessibility/accessibility_feature_pod_controller_unittest.cc index 01477388..78eff1a 100644 --- a/ash/system/accessibility/accessibility_feature_pod_controller_unittest.cc +++ b/ash/system/accessibility/accessibility_feature_pod_controller_unittest.cc
@@ -8,6 +8,7 @@ #include "ash/system/unified/unified_system_tray_controller.h" #include "ash/system/unified/unified_system_tray_model.h" #include "ash/test/ash_test_base.h" +#include "base/memory/scoped_refptr.h" namespace ash { @@ -26,7 +27,7 @@ void SetUp() override { NoSessionAshTestBase::SetUp(); - tray_model_ = std::make_unique<UnifiedSystemTrayModel>(nullptr); + tray_model_ = base::MakeRefCounted<UnifiedSystemTrayModel>(nullptr); tray_controller_ = std::make_unique<UnifiedSystemTrayController>(tray_model_.get()); } @@ -53,7 +54,7 @@ FeaturePodButton* button() { return button_.get(); } private: - std::unique_ptr<UnifiedSystemTrayModel> tray_model_; + scoped_refptr<UnifiedSystemTrayModel> tray_model_; std::unique_ptr<UnifiedSystemTrayController> tray_controller_; std::unique_ptr<AccessibilityFeaturePodController> controller_; std::unique_ptr<FeaturePodButton> button_;
diff --git a/ash/system/accessibility/tray_accessibility.cc b/ash/system/accessibility/tray_accessibility.cc index efbfac9..b84681c4 100644 --- a/ash/system/accessibility/tray_accessibility.cc +++ b/ash/system/accessibility/tray_accessibility.cc
@@ -86,7 +86,7 @@ //////////////////////////////////////////////////////////////////////////////// // ash::tray::AccessibilityDetailedView -constexpr char AccessibilityDetailedView::kClassName[]; +const char AccessibilityDetailedView::kClassName[] = "AccessibilityDetailedView"; AccessibilityDetailedView::AccessibilityDetailedView( DetailedViewDelegate* delegate)
diff --git a/ash/system/accessibility/tray_accessibility.h b/ash/system/accessibility/tray_accessibility.h index 962b0bd..f5f4cb8e 100644 --- a/ash/system/accessibility/tray_accessibility.h +++ b/ash/system/accessibility/tray_accessibility.h
@@ -40,7 +40,7 @@ : public TrayDetailedView, public speech::SodaInstaller::Observer { public: - static constexpr char kClassName[] = "AccessibilityDetailedView"; + static const char kClassName[]; explicit AccessibilityDetailedView(DetailedViewDelegate* delegate);
diff --git a/ash/system/audio/unified_audio_detailed_view_controller_unittest.cc b/ash/system/audio/unified_audio_detailed_view_controller_unittest.cc index b9b957e..6b9b961 100644 --- a/ash/system/audio/unified_audio_detailed_view_controller_unittest.cc +++ b/ash/system/audio/unified_audio_detailed_view_controller_unittest.cc
@@ -101,7 +101,7 @@ cras_audio_handler_ = CrasAudioHandler::Get(); cras_audio_handler_->SetPrefHandlerForTesting(audio_pref_handler_); - tray_model_ = std::make_unique<UnifiedSystemTrayModel>(nullptr); + tray_model_ = base::MakeRefCounted<UnifiedSystemTrayModel>(nullptr); tray_controller_ = std::make_unique<UnifiedSystemTrayController>(tray_model_.get()); audio_detailed_view_controller_ = @@ -178,7 +178,7 @@ scoped_refptr<AudioDevicesPrefHandlerStub> audio_pref_handler_; std::unique_ptr<UnifiedAudioDetailedViewController> audio_detailed_view_controller_; - std::unique_ptr<UnifiedSystemTrayModel> tray_model_; + scoped_refptr<UnifiedSystemTrayModel> tray_model_; std::unique_ptr<UnifiedSystemTrayController> tray_controller_; base::test::ScopedFeatureList scoped_feature_list_; std::unique_ptr<tray::AudioDetailedView> audio_detailed_view_;
diff --git a/ash/system/bluetooth/bluetooth_device_status_ui_handler.cc b/ash/system/bluetooth/bluetooth_device_status_ui_handler.cc index 560cf17..bc28149 100644 --- a/ash/system/bluetooth/bluetooth_device_status_ui_handler.cc +++ b/ash/system/bluetooth/bluetooth_device_status_ui_handler.cc
@@ -52,12 +52,30 @@ void BluetoothDeviceStatusUiHandler::OnDeviceDisconnected( PairedBluetoothDevicePropertiesPtr device) { - // TODO(crbug.com/1010321): Implement this function. + ash::ToastData toast_data( + /*id=*/GetToastId(device.get()), + /*text=*/ + l10n_util::GetStringFUTF16( + IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCONNECTED_TOAST, + GetPairedDeviceName(device.get())), + /*timeout_ms=*/kToastDurationMs, + /*dismiss_text=*/absl::nullopt, + /*visible_on_lock_screen=*/false); + ShowToast(toast_data); } void BluetoothDeviceStatusUiHandler::OnDeviceConnected( PairedBluetoothDevicePropertiesPtr device) { - // TODO(crbug.com/1010321): Implement this function. + ash::ToastData toast_data( + /*id=*/GetToastId(device.get()), + /*text=*/ + l10n_util::GetStringFUTF16( + IDS_ASH_STATUS_TRAY_BLUETOOTH_PAIRED_OR_CONNECTED_TOAST, + GetPairedDeviceName(device.get())), + /*timeout_ms=*/kToastDurationMs, + /*dismiss_text=*/absl::nullopt, + /*visible_on_lock_screen=*/false); + ShowToast(toast_data); } void BluetoothDeviceStatusUiHandler::ShowToast(
diff --git a/ash/system/bluetooth/bluetooth_device_status_ui_handler_unittest.cc b/ash/system/bluetooth/bluetooth_device_status_ui_handler_unittest.cc index b50a372..f2bf9e5 100644 --- a/ash/system/bluetooth/bluetooth_device_status_ui_handler_unittest.cc +++ b/ash/system/bluetooth/bluetooth_device_status_ui_handler_unittest.cc
@@ -50,12 +50,36 @@ } void SetPairedDevices( - std::vector<PairedBluetoothDevicePropertiesPtr>& paired_devices) { + std::vector<PairedBluetoothDevicePropertiesPtr> paired_devices) { fake_device_status_notifier()->SetNewlyPairedDevices( std::move(paired_devices)); base::RunLoop().RunUntilIdle(); } + void SetConnectedDevices( + std::vector<PairedBluetoothDevicePropertiesPtr> paired_devices) { + fake_device_status_notifier()->SetConnectedDevices( + std::move(paired_devices)); + base::RunLoop().RunUntilIdle(); + } + + void SetDisconnectedDevices( + std::vector<PairedBluetoothDevicePropertiesPtr> paired_devices) { + fake_device_status_notifier()->SetDisconnectedDevices( + std::move(paired_devices)); + base::RunLoop().RunUntilIdle(); + } + + std::vector<PairedBluetoothDevicePropertiesPtr> GetPairedDevices() { + auto paired_device = PairedBluetoothDeviceProperties::New(); + paired_device->nickname = "Beats X"; + paired_device->device_properties = BluetoothDeviceProperties::New(); + + std::vector<PairedBluetoothDevicePropertiesPtr> paired_devices; + paired_devices.push_back(std::move(paired_device)); + return paired_devices; + } + private: chromeos::bluetooth_config::FakeBluetoothDeviceStatusNotifier* fake_device_status_notifier() { @@ -71,16 +95,17 @@ TEST_F(BluetoothDeviceStatusUiHandlerTest, PairedDevice) { EXPECT_CALL(device_status_ui_handler(), ShowToast); - // Create a device paired device. - auto paired_device = PairedBluetoothDeviceProperties::New(); - paired_device->nickname = "Beats X"; - paired_device->device_properties = BluetoothDeviceProperties::New(); - paired_device->device_properties->connection_state = - DeviceConnectionState::kConnected; + SetPairedDevices(GetPairedDevices()); +} - std::vector<PairedBluetoothDevicePropertiesPtr> paired_devices; - paired_devices.push_back(mojo::Clone(paired_device)); - SetPairedDevices(paired_devices); +TEST_F(BluetoothDeviceStatusUiHandlerTest, ConnectedDevice) { + EXPECT_CALL(device_status_ui_handler(), ShowToast); + SetConnectedDevices(GetPairedDevices()); +} + +TEST_F(BluetoothDeviceStatusUiHandlerTest, DisconnectedDevice) { + EXPECT_CALL(device_status_ui_handler(), ShowToast); + SetDisconnectedDevices(GetPairedDevices()); } } // namespace ash \ No newline at end of file
diff --git a/ash/system/bluetooth/unified_bluetooth_detailed_view_controller_unittest.cc b/ash/system/bluetooth/unified_bluetooth_detailed_view_controller_unittest.cc index 9f5722af..1901a305 100644 --- a/ash/system/bluetooth/unified_bluetooth_detailed_view_controller_unittest.cc +++ b/ash/system/bluetooth/unified_bluetooth_detailed_view_controller_unittest.cc
@@ -11,6 +11,7 @@ #include "ash/system/unified/unified_system_tray_controller.h" #include "ash/system/unified/unified_system_tray_model.h" #include "ash/test/ash_test_base.h" +#include "base/memory/scoped_refptr.h" #include "base/strings/stringprintf.h" #include "device/bluetooth/dbus/bluez_dbus_manager.h" #include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h" @@ -51,7 +52,7 @@ device_client_->SetSimulationIntervalMs(0); task_environment()->RunUntilIdle(); - tray_model_ = std::make_unique<UnifiedSystemTrayModel>(nullptr); + tray_model_ = base::MakeRefCounted<UnifiedSystemTrayModel>(nullptr); tray_controller_ = std::make_unique<UnifiedSystemTrayController>(tray_model_.get()); bt_detailed_view_controller_ = @@ -107,7 +108,7 @@ private: bluez::FakeBluetoothAdapterClient* adapter_client_; bluez::FakeBluetoothDeviceClient* device_client_; - std::unique_ptr<UnifiedSystemTrayModel> tray_model_; + scoped_refptr<UnifiedSystemTrayModel> tray_model_; std::unique_ptr<UnifiedSystemTrayController> tray_controller_; std::unique_ptr<UnifiedBluetoothDetailedViewController> bt_detailed_view_controller_;
diff --git a/ash/system/brightness/unified_brightness_slider_controller.cc b/ash/system/brightness/unified_brightness_slider_controller.cc index d215481d..ad36f690 100644 --- a/ash/system/brightness/unified_brightness_slider_controller.cc +++ b/ash/system/brightness/unified_brightness_slider_controller.cc
@@ -8,6 +8,7 @@ #include "ash/system/brightness/unified_brightness_view.h" #include "ash/system/brightness_control_delegate.h" #include "ash/system/unified/unified_system_tray_model.h" +#include "base/memory/scoped_refptr.h" namespace ash { namespace { @@ -21,7 +22,7 @@ } // namespace UnifiedBrightnessSliderController::UnifiedBrightnessSliderController( - UnifiedSystemTrayModel* model) + scoped_refptr<UnifiedSystemTrayModel> model) : model_(model) {} UnifiedBrightnessSliderController::~UnifiedBrightnessSliderController() =
diff --git a/ash/system/brightness/unified_brightness_slider_controller.h b/ash/system/brightness/unified_brightness_slider_controller.h index 7f2adbb..0e6d72c 100644 --- a/ash/system/brightness/unified_brightness_slider_controller.h +++ b/ash/system/brightness/unified_brightness_slider_controller.h
@@ -6,6 +6,7 @@ #define ASH_SYSTEM_BRIGHTNESS_UNIFIED_BRIGHTNESS_SLIDER_CONTROLLER_H_ #include "ash/system/unified/unified_slider_view.h" +#include "base/memory/scoped_refptr.h" namespace ash { @@ -14,7 +15,8 @@ // Controller of a slider that can change display brightness. class UnifiedBrightnessSliderController : public UnifiedSliderListener { public: - explicit UnifiedBrightnessSliderController(UnifiedSystemTrayModel* model); + explicit UnifiedBrightnessSliderController( + scoped_refptr<UnifiedSystemTrayModel> model); UnifiedBrightnessSliderController(const UnifiedBrightnessSliderController&) = delete; @@ -31,7 +33,7 @@ views::SliderChangeReason reason) override; private: - UnifiedSystemTrayModel* const model_; + scoped_refptr<UnifiedSystemTrayModel> model_; UnifiedSliderView* slider_ = nullptr; // We have to store previous manually set value because |old_value| might be
diff --git a/ash/system/brightness/unified_brightness_view.cc b/ash/system/brightness/unified_brightness_view.cc index 3788a2f..516b90f 100644 --- a/ash/system/brightness/unified_brightness_view.cc +++ b/ash/system/brightness/unified_brightness_view.cc
@@ -9,13 +9,14 @@ #include "ash/strings/grit/ash_strings.h" #include "ash/style/ash_color_provider.h" #include "ash/system/brightness/unified_brightness_slider_controller.h" +#include "base/memory/scoped_refptr.h" #include "ui/gfx/paint_vector_icon.h" namespace ash { UnifiedBrightnessView::UnifiedBrightnessView( UnifiedBrightnessSliderController* controller, - UnifiedSystemTrayModel* model) + scoped_refptr<UnifiedSystemTrayModel> model) : UnifiedSliderView(views::Button::PressedCallback(), controller, kUnifiedMenuBrightnessIcon,
diff --git a/ash/system/brightness/unified_brightness_view.h b/ash/system/brightness/unified_brightness_view.h index af6cc045..a3c849d 100644 --- a/ash/system/brightness/unified_brightness_view.h +++ b/ash/system/brightness/unified_brightness_view.h
@@ -7,6 +7,7 @@ #include "ash/system/unified/unified_slider_view.h" #include "ash/system/unified/unified_system_tray_model.h" +#include "base/memory/scoped_refptr.h" namespace ash { @@ -18,7 +19,7 @@ public UnifiedSystemTrayModel::Observer { public: UnifiedBrightnessView(UnifiedBrightnessSliderController* controller, - UnifiedSystemTrayModel* model); + scoped_refptr<UnifiedSystemTrayModel> model); UnifiedBrightnessView(const UnifiedBrightnessView&) = delete; UnifiedBrightnessView& operator=(const UnifiedBrightnessView&) = delete; @@ -33,7 +34,7 @@ void OnThemeChanged() override; private: - UnifiedSystemTrayModel* const model_; + scoped_refptr<UnifiedSystemTrayModel> model_; }; } // namespace ash
diff --git a/ash/system/hps/hps_configuration.cc b/ash/system/hps/hps_configuration.cc index fe67eb2..40031815 100644 --- a/ash/system/hps/hps_configuration.cc +++ b/ash/system/hps/hps_configuration.cc
@@ -12,8 +12,10 @@ namespace ash { namespace { // Used for indicating which oneof field to construct for `filter_config` inside -// FeatureConfig. -constexpr int kFilterConfigCaseDefault = 0; +// FeatureConfig. We ensure that this is a valid configuration so that passing +// empty params induces a working config (as required for, e.g., a +// chrome:://flags entry). +constexpr int kFilterConfigCaseDefault = 1; // Default value for `FeatureConfig.consecutive_results_filter_config.count`. // Default 1 means the change will be notified if the inference result is @@ -77,4 +79,4 @@ return ConstructHpsFilterConfigFromFinch(features::kSnoopingProtection); } -} // namespace ash \ No newline at end of file +} // namespace ash
diff --git a/ash/system/hps/hps_configuration_unittest.cc b/ash/system/hps/hps_configuration_unittest.cc index a1cadb7f..f74d808 100644 --- a/ash/system/hps/hps_configuration_unittest.cc +++ b/ash/system/hps/hps_configuration_unittest.cc
@@ -21,6 +21,16 @@ return expected_serialized == actual_serialized; } +TEST(HpsFeatureConfigTest, EmptyParamsValid) { + base::test::ScopedFeatureList feature_list; + feature_list.InitWithFeatures( + {features::kLeaveDetection, features::kSnoopingProtection}, + {} /* disabled_features */); + + EXPECT_TRUE(GetEnableHpsSenseConfig().has_value()); + EXPECT_TRUE(GetEnableHpsNotifyConfig().has_value()); +} + TEST(HpsFeatureConfigTest, ReturnNullIfTypeIsNotRecognizable) { const base::FieldTrialParams params = {{"filter_config_case", "0"}}; base::test::ScopedFeatureList feature_list;
diff --git a/ash/system/ime/ime_feature_pod_controller_unittest.cc b/ash/system/ime/ime_feature_pod_controller_unittest.cc index 5c5451d..a4918e1 100644 --- a/ash/system/ime/ime_feature_pod_controller_unittest.cc +++ b/ash/system/ime/ime_feature_pod_controller_unittest.cc
@@ -12,6 +12,7 @@ #include "ash/system/unified/unified_system_tray_controller.h" #include "ash/system/unified/unified_system_tray_model.h" #include "ash/test/ash_test_base.h" +#include "base/memory/scoped_refptr.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" @@ -31,7 +32,7 @@ void SetUp() override { NoSessionAshTestBase::SetUp(); - tray_model_ = std::make_unique<UnifiedSystemTrayModel>(nullptr); + tray_model_ = base::MakeRefCounted<UnifiedSystemTrayModel>(nullptr); tray_controller_ = std::make_unique<UnifiedSystemTrayController>(tray_model_.get()); } @@ -46,8 +47,7 @@ protected: void SetUpButton() { - controller_ = - std::make_unique<IMEFeaturePodController>(tray_controller()); + controller_ = std::make_unique<IMEFeaturePodController>(tray_controller()); button_.reset(controller_->CreateButton()); } @@ -79,7 +79,7 @@ } private: - std::unique_ptr<UnifiedSystemTrayModel> tray_model_; + scoped_refptr<UnifiedSystemTrayModel> tray_model_; std::unique_ptr<UnifiedSystemTrayController> tray_controller_; std::unique_ptr<IMEFeaturePodController> controller_; std::unique_ptr<FeaturePodButton> button_;
diff --git a/ash/system/locale/locale_feature_pod_controller_unittest.cc b/ash/system/locale/locale_feature_pod_controller_unittest.cc index 4ce0aec..eb374b5 100644 --- a/ash/system/locale/locale_feature_pod_controller_unittest.cc +++ b/ash/system/locale/locale_feature_pod_controller_unittest.cc
@@ -14,6 +14,7 @@ #include "ash/system/unified/unified_system_tray_controller.h" #include "ash/system/unified/unified_system_tray_model.h" #include "ash/test/ash_test_base.h" +#include "base/memory/scoped_refptr.h" #include "base/strings/utf_string_conversions.h" namespace ash { @@ -33,7 +34,7 @@ void SetUp() override { NoSessionAshTestBase::SetUp(); - tray_model_ = std::make_unique<UnifiedSystemTrayModel>(nullptr); + tray_model_ = base::MakeRefCounted<UnifiedSystemTrayModel>(nullptr); tray_controller_ = std::make_unique<UnifiedSystemTrayController>(tray_model_.get()); controller_ = @@ -51,7 +52,7 @@ std::unique_ptr<LocaleFeaturePodController> controller_; private: - std::unique_ptr<UnifiedSystemTrayModel> tray_model_; + scoped_refptr<UnifiedSystemTrayModel> tray_model_; std::unique_ptr<UnifiedSystemTrayController> tray_controller_; };
diff --git a/ash/system/message_center/unified_message_center_bubble.cc b/ash/system/message_center/unified_message_center_bubble.cc index 293a0a8..5a6b32c 100644 --- a/ash/system/message_center/unified_message_center_bubble.cc +++ b/ash/system/message_center/unified_message_center_bubble.cc
@@ -122,7 +122,7 @@ bubble_view_->ResetDelegate(); bubble_widget_->RemoveObserver(this); - bubble_widget_->CloseNow(); + bubble_widget_->Close(); } CHECK(!views::WidgetObserver::IsInObserverList()); }
diff --git a/ash/system/message_center/unified_message_center_bubble_unittest.cc b/ash/system/message_center/unified_message_center_bubble_unittest.cc index 123a44d..51fc252d 100644 --- a/ash/system/message_center/unified_message_center_bubble_unittest.cc +++ b/ash/system/message_center/unified_message_center_bubble_unittest.cc
@@ -18,6 +18,7 @@ #include "ash/test/ash_test_base.h" #include "base/strings/stringprintf.h" #include "components/prefs/pref_service.h" +#include "ui/events/keycodes/keyboard_codes_posix.h" #include "ui/message_center/message_center.h" using message_center::MessageCenter; @@ -38,23 +39,36 @@ ~UnifiedMessageCenterBubbleTest() override = default; - // AshTestBase: - void SetUp() override { - AshTestBase::SetUp(); + protected: + std::string AddWebNotification() { + std::string id = base::NumberToString(id_++); + MessageCenter::Get()->AddNotification(std::make_unique<Notification>( + message_center::NOTIFICATION_TYPE_SIMPLE, id, u"title", u"message", + gfx::Image(), std::u16string(), GURL(), + message_center::NotifierId(GURL(u"example.com"), u"webpagetitle"), + message_center::RichNotificationData(), /*delegate=*/nullptr)); + return id; } - protected: std::string AddNotification() { std::string id = base::NumberToString(id_++); MessageCenter::Get()->AddNotification(std::make_unique<Notification>( message_center::NOTIFICATION_TYPE_BASE_FORMAT, id, u"test title", - u"test message", gfx::Image(), std::u16string() /* display_source */, - GURL(), message_center::NotifierId(), - message_center::RichNotificationData(), + u"test message", gfx::Image(), std::u16string(), GURL(), + message_center::NotifierId(), message_center::RichNotificationData(), new message_center::NotificationDelegate())); return id; } + void RemoveAllNotifications() { + message_center::MessageCenter::Get()->RemoveAllNotifications( + /*by_user=*/true, MessageCenter::RemoveType::ALL); + GetMessageCenterBubble() + ->message_center_view() + ->message_list_view() + ->DeleteRemovedNotifications(); + } + UnifiedMessageCenterBubble* GetMessageCenterBubble() { return GetPrimaryUnifiedSystemTray()->message_center_bubble(); } @@ -83,25 +97,36 @@ // Helper functions for focus cycle testing. void DoTab() { - ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); - generator.PressKey(ui::KeyboardCode::VKEY_TAB, ui::EventFlags::EF_NONE); + PressAndReleaseKey(ui::KeyboardCode::VKEY_TAB, ui::EventFlags::EF_NONE); } void DoShiftTab() { - ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); - generator.PressKey(ui::KeyboardCode::VKEY_TAB, + PressAndReleaseKey(ui::KeyboardCode::VKEY_TAB, ui::EventFlags::EF_SHIFT_DOWN); } + void DoAltShiftN() { + PressAndReleaseKey( + ui::KeyboardCode::VKEY_N, + ui::EventFlags::EF_SHIFT_DOWN | ui::EventFlags::EF_ALT_DOWN); + } + + void DoEsc() { PressAndReleaseKey(ui::KeyboardCode::VKEY_ESCAPE); } + void ToggleExpanded() { GetSystemTrayBubble()->controller_for_test()->ToggleExpanded(); } void WaitForAnimation() { - while (GetSystemTrayBubble() - ->controller_for_test() - ->animation_->is_animating()) + // Some animations do not complete without checking is_animating(); + do { base::RunLoop().RunUntilIdle(); + } while (GetSystemTrayBubble() && + GetSystemTrayBubble()->controller_for_test() && + GetSystemTrayBubble()->controller_for_test()->animation_ && + GetSystemTrayBubble() + ->controller_for_test() + ->animation_->is_animating()); } views::View* GetFirstMessageCenterFocusable() { @@ -205,6 +230,42 @@ GetFirstQuickSettingsFocusable()); } +TEST_F(UnifiedMessageCenterBubbleTest, HandleAccelerators) { + auto id = AddWebNotification(); + WaitForAnimation(); + + // Open and focus message center. + DoAltShiftN(); + WaitForAnimation(); + EXPECT_TRUE(GetMessageCenterBubble()->IsMessageCenterVisible()); + EXPECT_EQ( + 1u, + message_center::MessageCenter::Get()->GetVisibleNotifications().size()); + + views::Widget* quick_settings_widget = + GetSystemTrayBubble()->GetBubbleWidget(); + views::Widget* message_center_widget = + GetMessageCenterBubble()->GetBubbleWidget(); + EXPECT_FALSE(quick_settings_widget->IsActive()); + EXPECT_TRUE(message_center_widget->IsActive()); + + RemoveAllNotifications(); + WaitForAnimation(); + EXPECT_EQ( + 0u, + message_center::MessageCenter::Get()->GetVisibleNotifications().size()); + EXPECT_FALSE(quick_settings_widget->IsActive()); + EXPECT_TRUE(message_center_widget->IsActive()); + EXPECT_EQ(GetFirstMessageCenterFocusable(), + message_center_widget->GetFocusManager()->GetFocusedView()); + + // Press Esc to close system tray. + DoEsc(); + WaitForAnimation(); + EXPECT_EQ(nullptr, + GetPrimaryUnifiedSystemTray()->GetFocusManager()->GetFocusedView()); +} + TEST_F(UnifiedMessageCenterBubbleTest, ReverseFocusCycle) { GetPrimaryUnifiedSystemTray()->ShowBubble(); AddNotification();
diff --git a/ash/system/message_center/unified_message_center_view.cc b/ash/system/message_center/unified_message_center_view.cc index ca459df..72db4a4 100644 --- a/ash/system/message_center/unified_message_center_view.cc +++ b/ash/system/message_center/unified_message_center_view.cc
@@ -21,6 +21,7 @@ #include "ash/system/unified/unified_system_tray_model.h" #include "ash/system/unified/unified_system_tray_view.h" #include "base/memory/ptr_util.h" +#include "base/memory/scoped_refptr.h" #include "base/metrics/user_metrics.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/compositor/layer.h" @@ -45,7 +46,7 @@ class ScrollerContentsView : public views::View { public: - ScrollerContentsView(UnifiedMessageListView* message_list_view) { + explicit ScrollerContentsView(UnifiedMessageListView* message_list_view) { auto* contents_layout = SetLayoutManager(std::make_unique<views::BoxLayout>( views::BoxLayout::Orientation::kVertical)); contents_layout->set_cross_axis_alignment( @@ -70,7 +71,7 @@ UnifiedMessageCenterView::UnifiedMessageCenterView( UnifiedSystemTrayView* parent, - UnifiedSystemTrayModel* model, + scoped_refptr<UnifiedSystemTrayModel> model, UnifiedMessageCenterBubble* bubble) : parent_(parent), model_(model), @@ -92,6 +93,7 @@ } UnifiedMessageCenterView::~UnifiedMessageCenterView() { + DCHECK(model_); model_->set_notification_target_mode( UnifiedSystemTrayModel::NotificationTargetMode::LAST_NOTIFICATION); @@ -300,6 +302,8 @@ last_scroll_position_from_bottom_ = scroll_bar_->GetMaxPosition() - scroller_->GetVisibleRect().y(); + DCHECK(model_); + // Reset the target if user scrolls the list manually. model_->set_notification_target_mode( UnifiedSystemTrayModel::NotificationTargetMode::LAST_POSITION); @@ -411,6 +415,7 @@ (!session_controller->IsScreenLocked() || AshMessageCenterLockScreenController::IsEnabled())); + DCHECK(model_); if (!GetVisible()) { // When notification list went invisible, the last notification should be // targeted next time. @@ -430,6 +435,8 @@ if (!GetVisible()) return; + DCHECK(model_); + auto target_mode = model_->notification_target_mode(); // Notification views may be deleted during an animation, so wait until it
diff --git a/ash/system/message_center/unified_message_center_view.h b/ash/system/message_center/unified_message_center_view.h index b82824aa..52d3301 100644 --- a/ash/system/message_center/unified_message_center_view.h +++ b/ash/system/message_center/unified_message_center_view.h
@@ -8,6 +8,7 @@ #include "ash/ash_export.h" #include "ash/system/message_center/message_center_scroll_bar.h" #include "ash/system/message_center/unified_message_list_view.h" +#include "base/memory/scoped_refptr.h" #include "ui/gfx/animation/animation_delegate.h" #include "ui/views/background.h" #include "ui/views/controls/button/button.h" @@ -36,7 +37,7 @@ class UnifiedSystemTrayView; // Note: This enum represents the current animation state for -// UnifiedMessageCenterView. There is an equivalent animation state emum in +// UnifiedMessageCenterView. There is an equivalent animation state enum in // the child UnifiedMessageListView. The animations for these two views can // occur simultaneously or independently, so states for both views are tracked // separately. @@ -62,7 +63,7 @@ public gfx::AnimationDelegate { public: UnifiedMessageCenterView(UnifiedSystemTrayView* parent, - UnifiedSystemTrayModel* model, + scoped_refptr<UnifiedSystemTrayModel> model, UnifiedMessageCenterBubble* bubble); UnifiedMessageCenterView(const UnifiedMessageCenterView&) = delete; @@ -178,7 +179,7 @@ View* GetLastFocusableChild(); UnifiedSystemTrayView* const parent_; - UnifiedSystemTrayModel* const model_; + scoped_refptr<UnifiedSystemTrayModel> model_; UnifiedMessageCenterBubble* const message_center_bubble_; StackedNotificationBar* const notification_bar_; views::ScrollBar* scroll_bar_;
diff --git a/ash/system/message_center/unified_message_center_view_unittest.cc b/ash/system/message_center/unified_message_center_view_unittest.cc index 34f95f9..9c25dc9 100644 --- a/ash/system/message_center/unified_message_center_view_unittest.cc +++ b/ash/system/message_center/unified_message_center_view_unittest.cc
@@ -15,6 +15,7 @@ #include "ash/system/unified/unified_system_tray_controller.h" #include "ash/system/unified/unified_system_tray_model.h" #include "ash/test/ash_test_base.h" +#include "base/memory/scoped_refptr.h" #include "base/run_loop.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" @@ -72,7 +73,7 @@ // AshTestBase: void SetUp() override { AshTestBase::SetUp(); - model_ = std::make_unique<UnifiedSystemTrayModel>(nullptr); + model_ = base::MakeRefCounted<UnifiedSystemTrayModel>(nullptr); } void TearDown() override { @@ -241,7 +242,7 @@ int id_ = 0; int size_changed_count_ = 0; - std::unique_ptr<UnifiedSystemTrayModel> model_; + scoped_refptr<UnifiedSystemTrayModel> model_; std::unique_ptr<TestUnifiedMessageCenterView> message_center_view_; };
diff --git a/ash/system/message_center/unified_message_list_view.cc b/ash/system/message_center/unified_message_list_view.cc index 2d4e6a7..c0b05f0 100644 --- a/ash/system/message_center/unified_message_list_view.cc +++ b/ash/system/message_center/unified_message_list_view.cc
@@ -18,6 +18,7 @@ #include "ash/system/unified/unified_system_tray_model.h" #include "base/auto_reset.h" #include "base/callback_forward.h" +#include "base/memory/scoped_refptr.h" #include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_macros.h" #include "ui/compositor/compositor.h" @@ -130,6 +131,7 @@ // Check if the notification is manually expanded / collapsed before and // restores the state. void LoadExpandedState(UnifiedSystemTrayModel* model, bool is_latest) { + DCHECK(model); absl::optional<bool> manually_expanded = model->GetNotificationExpanded(GetNotificationId()); if (manually_expanded.has_value()) { @@ -145,6 +147,7 @@ // Stores if the notification is manually expanded or collapsed so that we can // restore that when UnifiedSystemTray is reopened. void StoreExpandedState(UnifiedSystemTrayModel* model) { + DCHECK(model); if (message_view_->IsManuallyExpandedOrCollapsed()) { model->SetNotificationExpanded(GetNotificationId(), message_view_->IsExpanded()); @@ -258,7 +261,7 @@ UnifiedMessageListView::UnifiedMessageListView( UnifiedMessageCenterView* message_center_view, - UnifiedSystemTrayModel* model) + scoped_refptr<UnifiedSystemTrayModel> model) : views::AnimationDelegateViews(this), message_center_view_(message_center_view), model_(model), @@ -278,18 +281,20 @@ } UnifiedMessageListView::~UnifiedMessageListView() { + DCHECK(model_); model_->ClearNotificationChanges(); for (auto* view : children()) - AsMVC(view)->StoreExpandedState(model_); + AsMVC(view)->StoreExpandedState(model_.get()); } void UnifiedMessageListView::Init() { + DCHECK(model_); bool is_latest = true; for (auto* notification : message_center_utils::GetSortedNotificationsWithOwnView()) { auto* view = new MessageViewContainer(CreateMessageView(*notification), this); - view->LoadExpandedState(model_, is_latest); + view->LoadExpandedState(model_.get(), is_latest); AddChildViewAt(view, 0); MessageCenter::Get()->DisplayedNotification( notification->id(), message_center::DISPLAY_SOURCE_MESSAGE_CENTER); @@ -763,6 +768,7 @@ } void UnifiedMessageListView::DeleteRemovedNotifications() { + DCHECK(model_); views::View::Views removed_views; std::copy_if(children().cbegin(), children().cend(), std::back_inserter(removed_views),
diff --git a/ash/system/message_center/unified_message_list_view.h b/ash/system/message_center/unified_message_list_view.h index d1cc422..32c4c327 100644 --- a/ash/system/message_center/unified_message_list_view.h +++ b/ash/system/message_center/unified_message_list_view.h
@@ -6,6 +6,8 @@ #define ASH_SYSTEM_MESSAGE_CENTER_UNIFIED_MESSAGE_LIST_VIEW_H_ #include "ash/ash_export.h" +#include "ash/system/unified/unified_system_tray_model.h" +#include "base/memory/scoped_refptr.h" #include "base/scoped_observation.h" #include "ui/compositor/throughput_tracker.h" #include "ui/message_center/message_center.h" @@ -40,7 +42,7 @@ public: // |message_center_view| can be null in unit tests. UnifiedMessageListView(UnifiedMessageCenterView* message_center_view, - UnifiedSystemTrayModel* model); + scoped_refptr<UnifiedSystemTrayModel> model); UnifiedMessageListView(const UnifiedMessageListView& other) = delete; UnifiedMessageListView& operator=(const UnifiedMessageListView& other) = delete; @@ -157,6 +159,7 @@ private: friend class UnifiedMessageCenterViewTest; friend class UnifiedMessageListViewTest; + friend class UnifiedMessageCenterBubbleTest; class Background; class MessageViewContainer; @@ -229,7 +232,7 @@ void UpdateClearAllAnimation(); UnifiedMessageCenterView* const message_center_view_; - UnifiedSystemTrayModel* const model_; + scoped_refptr<UnifiedSystemTrayModel> model_; // If true, ChildPreferredSizeChanged() will be ignored. This is used in // CollapseAllNotifications() to prevent PreferredSizeChanged() triggered
diff --git a/ash/system/message_center/unified_message_list_view_unittest.cc b/ash/system/message_center/unified_message_list_view_unittest.cc index 28fe54d3..9737c665 100644 --- a/ash/system/message_center/unified_message_list_view_unittest.cc +++ b/ash/system/message_center/unified_message_list_view_unittest.cc
@@ -9,6 +9,7 @@ #include "ash/system/tray/tray_constants.h" #include "ash/system/unified/unified_system_tray_model.h" #include "ash/test/ash_test_base.h" +#include "base/memory/scoped_refptr.h" #include "base/run_loop.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" @@ -130,7 +131,7 @@ AshTestBase::SetUp(); - model_ = std::make_unique<UnifiedSystemTrayModel>(nullptr); + model_ = base::MakeRefCounted<UnifiedSystemTrayModel>(nullptr); } bool IsNotificationsRefreshEnabled() const { return GetParam(); } @@ -197,9 +198,7 @@ message_list_view()->animation_.get()); } - void AnimateToEnd() { - message_list_view()->animation_->End(); - } + void AnimateToEnd() { message_list_view()->animation_->End(); } void AnimateUntilIdle() { while (message_list_view()->animation_->is_animating()) @@ -222,7 +221,7 @@ int id_ = 0; int size_changed_count_ = 0; - std::unique_ptr<UnifiedSystemTrayModel> model_; + scoped_refptr<UnifiedSystemTrayModel> model_; std::unique_ptr<TestUnifiedMessageListView> message_list_view_; std::unique_ptr<base::test::ScopedFeatureList> scoped_feature_list_; };
diff --git a/ash/system/nearby_share/nearby_share_feature_pod_controller_unittest.cc b/ash/system/nearby_share/nearby_share_feature_pod_controller_unittest.cc index 3f7fbac..00fada1 100644 --- a/ash/system/nearby_share/nearby_share_feature_pod_controller_unittest.cc +++ b/ash/system/nearby_share/nearby_share_feature_pod_controller_unittest.cc
@@ -10,6 +10,7 @@ #include "ash/system/unified/unified_system_tray_controller.h" #include "ash/system/unified/unified_system_tray_model.h" #include "ash/test/ash_test_base.h" +#include "base/memory/scoped_refptr.h" namespace ash { @@ -26,7 +27,7 @@ void SetUp() override { NoSessionAshTestBase::SetUp(); - tray_model_ = std::make_unique<UnifiedSystemTrayModel>(nullptr); + tray_model_ = base::MakeRefCounted<UnifiedSystemTrayModel>(nullptr); tray_controller_ = std::make_unique<UnifiedSystemTrayController>(tray_model_.get()); @@ -52,7 +53,7 @@ button_.reset(pod_controller_->CreateButton()); } - std::unique_ptr<UnifiedSystemTrayModel> tray_model_; + scoped_refptr<UnifiedSystemTrayModel> tray_model_; std::unique_ptr<UnifiedSystemTrayController> tray_controller_; std::unique_ptr<NearbyShareFeaturePodController> pod_controller_; std::unique_ptr<FeaturePodButton> button_;
diff --git a/ash/system/time/calendar_view_unittest.cc b/ash/system/time/calendar_view_unittest.cc index 3cda9db..2fb54d4 100644 --- a/ash/system/time/calendar_view_unittest.cc +++ b/ash/system/time/calendar_view_unittest.cc
@@ -10,6 +10,7 @@ #include "ash/system/time/calendar_view_controller.h" #include "ash/system/tray/detailed_view_delegate.h" #include "ash/test/ash_test_base.h" +#include "base/memory/scoped_refptr.h" #include "base/test/task_environment.h" #include "base/time/time.h" #include "base/time/time_override.h" @@ -32,7 +33,8 @@ delegate_ = std::make_unique<DetailedViewDelegate>(/*tray_controller=*/nullptr); - tray_model_ = std::make_unique<UnifiedSystemTrayModel>(/*shelf=*/nullptr); + tray_model_ = + base::MakeRefCounted<UnifiedSystemTrayModel>(/*shelf=*/nullptr); tray_controller_ = std::make_unique<UnifiedSystemTrayController>(tray_model_.get()); widget_ = CreateFramelessTestWidget(); @@ -152,7 +154,7 @@ // Owned by `widget_`. CalendarView* calendar_view_ = nullptr; std::unique_ptr<DetailedViewDelegate> delegate_; - std::unique_ptr<UnifiedSystemTrayModel> tray_model_; + scoped_refptr<UnifiedSystemTrayModel> tray_model_; std::unique_ptr<UnifiedSystemTrayController> tray_controller_; static base::Time fake_time_; }; @@ -573,7 +575,8 @@ delegate_ = std::make_unique<DetailedViewDelegate>(/*tray_controller=*/nullptr); - tray_model_ = std::make_unique<UnifiedSystemTrayModel>(/*shelf=*/nullptr); + tray_model_ = + base::MakeRefCounted<UnifiedSystemTrayModel>(/*shelf=*/nullptr); tray_controller_ = std::make_unique<UnifiedSystemTrayController>(tray_model_.get()); widget_ = CreateFramelessTestWidget(); @@ -605,7 +608,7 @@ // Owned by `widget_`. CalendarView* calendar_view_ = nullptr; std::unique_ptr<DetailedViewDelegate> delegate_; - std::unique_ptr<UnifiedSystemTrayModel> tray_model_; + scoped_refptr<UnifiedSystemTrayModel> tray_model_; std::unique_ptr<UnifiedSystemTrayController> tray_controller_; static base::Time fake_time_; };
diff --git a/ash/system/time/time_tray_item_view.cc b/ash/system/time/time_tray_item_view.cc index 5a13fd1..0577259 100644 --- a/ash/system/time/time_tray_item_view.cc +++ b/ash/system/time/time_tray_item_view.cc
@@ -12,6 +12,7 @@ #include "ash/system/model/system_tray_model.h" #include "ash/system/time/time_view.h" #include "ash/system/tray/tray_utils.h" +#include "base/memory/scoped_refptr.h" #include "ui/views/border.h" namespace ash { @@ -20,10 +21,10 @@ TimeTrayItemView::TimeTrayItemView( Shelf* shelf, - UnifiedSystemTrayModel* model, + scoped_refptr<UnifiedSystemTrayModel> model, absl::optional<TimeView::OnTimeViewActionPerformedCallback> callback) : TrayItemView(shelf), model_(model), session_observer_(this) { - system_tray_model_observation_.Observe(model_); + system_tray_model_observation_.Observe(model_.get()); TimeView::ClockLayout clock_layout = shelf->IsHorizontalAlignment() ? TimeView::ClockLayout::HORIZONTAL_CLOCK
diff --git a/ash/system/time/time_tray_item_view.h b/ash/system/time/time_tray_item_view.h index fa1e6d4..4a4b2b9 100644 --- a/ash/system/time/time_tray_item_view.h +++ b/ash/system/time/time_tray_item_view.h
@@ -9,6 +9,7 @@ #include "ash/public/cpp/session/session_observer.h" #include "ash/system/tray/tray_item_view.h" #include "ash/system/unified/unified_system_tray_model.h" +#include "base/memory/scoped_refptr.h" #include "base/scoped_observation.h" #include "time_view.h" @@ -22,7 +23,7 @@ public UnifiedSystemTrayModel::Observer { public: TimeTrayItemView(Shelf* shelf, - UnifiedSystemTrayModel* model, + scoped_refptr<UnifiedSystemTrayModel> model, absl::optional<TimeView::OnTimeViewActionPerformedCallback> callback = absl::nullopt); @@ -54,7 +55,7 @@ private: friend class TimeTrayItemViewTest; - UnifiedSystemTrayModel* model_ = nullptr; + scoped_refptr<UnifiedSystemTrayModel> model_; TimeView* time_view_ = nullptr; ScopedSessionObserver session_observer_; base::ScopedObservation<UnifiedSystemTrayModel,
diff --git a/ash/system/time/time_tray_item_view_unittest.cc b/ash/system/time/time_tray_item_view_unittest.cc index fc5fa91d9..f9decc9 100644 --- a/ash/system/time/time_tray_item_view_unittest.cc +++ b/ash/system/time/time_tray_item_view_unittest.cc
@@ -9,6 +9,7 @@ #include "ash/system/time/time_view.h" #include "ash/system/unified/unified_system_tray_model.h" #include "ash/test/ash_test_base.h" +#include "base/memory/scoped_refptr.h" #include "base/test/scoped_feature_list.h" namespace ash { @@ -30,7 +31,7 @@ else scoped_feature_list_.InitWithFeatures({}, features); - model_ = std::make_unique<UnifiedSystemTrayModel>(GetPrimaryShelf()); + model_ = base::MakeRefCounted<UnifiedSystemTrayModel>(GetPrimaryShelf()); time_tray_item_view_ = std::make_unique<TimeTrayItemView>(GetPrimaryShelf(), model_.get()); } @@ -57,7 +58,7 @@ protected: base::test::ScopedFeatureList scoped_feature_list_; - std::unique_ptr<UnifiedSystemTrayModel> model_; + scoped_refptr<UnifiedSystemTrayModel> model_; std::unique_ptr<TimeTrayItemView> time_tray_item_view_; };
diff --git a/ash/system/unified/feature_pods_container_view_unittest.cc b/ash/system/unified/feature_pods_container_view_unittest.cc index 0f4558e..46b1c66 100644 --- a/ash/system/unified/feature_pods_container_view_unittest.cc +++ b/ash/system/unified/feature_pods_container_view_unittest.cc
@@ -12,6 +12,7 @@ #include "ash/system/unified/unified_system_tray_controller.h" #include "ash/system/unified/unified_system_tray_model.h" #include "ash/test/ash_test_base.h" +#include "base/memory/scoped_refptr.h" #include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node_data.h" #include "ui/views/view_observer.h" @@ -33,7 +34,7 @@ // AshTestBase: void SetUp() override { AshTestBase::SetUp(); - model_ = std::make_unique<UnifiedSystemTrayModel>(nullptr); + model_ = base::MakeRefCounted<UnifiedSystemTrayModel>(nullptr); controller_ = std::make_unique<UnifiedSystemTrayController>(model_.get()); container_ = std::make_unique<FeaturePodsContainerView>( controller_.get(), true /* initially_expanded */); @@ -87,7 +88,7 @@ private: std::unique_ptr<FeaturePodsContainerView> container_; - std::unique_ptr<UnifiedSystemTrayModel> model_; + scoped_refptr<UnifiedSystemTrayModel> model_; std::unique_ptr<UnifiedSystemTrayController> controller_; int preferred_size_changed_count_ = 0; };
diff --git a/ash/system/unified/hps_notify_controller.cc b/ash/system/unified/hps_notify_controller.cc new file mode 100644 index 0000000..90e24de6 --- /dev/null +++ b/ash/system/unified/hps_notify_controller.cc
@@ -0,0 +1,127 @@ +// Copyright 2021 The Chromium 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 "ash/system/unified/hps_notify_controller.h" + +#include "ash/constants/ash_pref_names.h" +#include "ash/public/cpp/session/session_observer.h" +#include "ash/session/session_controller_impl.h" +#include "ash/shell.h" +#include "base/bind.h" +#include "base/callback.h" +#include "base/logging.h" +#include "components/account_id/account_id.h" +#include "components/pref_registry/pref_registry_syncable.h" +#include "components/prefs/pref_change_registrar.h" +#include "components/prefs/pref_registry_simple.h" +#include "components/prefs/pref_service.h" +#include "components/session_manager/session_manager_types.h" +#include "third_party/abseil-cpp/absl/types/optional.h" + +namespace ash { + +HpsNotifyController::HpsNotifyController() { + // When the controller is initialized, we are never in an active user session + // and we never have any user preferences active. Hence, our default state + // values are correct. + + // Session controller is instantiated before us in the shell. + SessionControllerImpl* session_controller = + Shell::Get()->session_controller(); + DCHECK(session_controller); + session_observation_.Observe(session_controller); + + // Poll the current HPS notify state if the daemon is active. Then, from now + // on, observe changes to the HPS notify signal. + chromeos::HpsDBusClient::Get()->GetResultHpsNotify(base::BindOnce( + &HpsNotifyController::OnHpsPollResult, weak_ptr_factory_.GetWeakPtr())); + hps_dbus_observation_.Observe(chromeos::HpsDBusClient::Get()); +} + +HpsNotifyController::~HpsNotifyController() = default; + +// static +void HpsNotifyController::RegisterProfilePrefs(PrefRegistrySimple* registry) { + registry->RegisterBooleanPref( + prefs::kSnoopingProtectionEnabled, + /*default_value=*/false, + user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PREF); +} + +void HpsNotifyController::OnSessionStateChanged( + session_manager::SessionState session_state) { + UpdateIconVisibility(session_state == session_manager::SessionState::ACTIVE, + hps_state_, is_enabled_); +} + +void HpsNotifyController::OnActiveUserPrefServiceChanged( + PrefService* pref_service) { + DCHECK(pref_service); + + UpdateIconVisibility( + session_active_, hps_state_, + pref_service->GetBoolean(prefs::kSnoopingProtectionEnabled)); + + // Re-subscribe to pref changes. + pref_change_registrar_ = std::make_unique<PrefChangeRegistrar>(); + pref_change_registrar_->Init(pref_service); + pref_change_registrar_->Add( + prefs::kSnoopingProtectionEnabled, + base::BindRepeating(&HpsNotifyController::OnPrefChanged, + weak_ptr_factory_.GetWeakPtr())); +} + +void HpsNotifyController::OnHpsNotifyChanged(bool hps_state) { + UpdateIconVisibility(session_active_, hps_state, is_enabled_); +} + +void HpsNotifyController::AddObserver(Observer* observer) { + observers_.AddObserver(observer); +} + +void HpsNotifyController::RemoveObserver(Observer* observer) { + observers_.RemoveObserver(observer); +} + +bool HpsNotifyController::IsIconVisible() const { + return session_active_ && hps_state_ && is_enabled_; +} + +void HpsNotifyController::UpdateIconVisibility(bool session_active, + bool hps_state, + bool is_enabled) { + const bool old_visibility = IsIconVisible(); + + session_active_ = session_active; + hps_state_ = hps_state; + is_enabled_ = is_enabled; + + const bool new_visibility = IsIconVisible(); + + if (old_visibility == new_visibility) + return; + + for (auto& observer : observers_) + observer.ShouldUpdateVisibility(new_visibility); +} + +void HpsNotifyController::OnHpsPollResult(absl::optional<bool> result) { + if (!result.has_value()) { + LOG(WARNING) << "Polling the presence daemon failed"; + return; + } + + UpdateIconVisibility(session_active_, *result, is_enabled_); +} + +void HpsNotifyController::OnPrefChanged() { + DCHECK(pref_change_registrar_); + DCHECK(pref_change_registrar_->prefs()); + + UpdateIconVisibility(session_active_, hps_state_, + pref_change_registrar_->prefs()->GetBoolean( + prefs::kSnoopingProtectionEnabled)); +} + +} // namespace ash
diff --git a/ash/system/unified/hps_notify_controller.h b/ash/system/unified/hps_notify_controller.h new file mode 100644 index 0000000..ce5aa926 --- /dev/null +++ b/ash/system/unified/hps_notify_controller.h
@@ -0,0 +1,98 @@ +// Copyright 2021 The Chromium 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 ASH_SYSTEM_UNIFIED_HPS_NOTIFY_CONTROLLER_H_ +#define ASH_SYSTEM_UNIFIED_HPS_NOTIFY_CONTROLLER_H_ + +#include "ash/ash_export.h" +#include "ash/public/cpp/session/session_controller.h" +#include "ash/public/cpp/session/session_observer.h" +#include "base/observer_list.h" +#include "base/observer_list_types.h" +#include "base/scoped_observation.h" +#include "chromeos/dbus/hps/hps_dbus_client.h" +#include "components/session_manager/session_manager_types.h" +#include "third_party/abseil-cpp/absl/types/optional.h" + +class PrefChangeRegistrar; +class PrefRegistrySimple; + +namespace ash { + +// Pushes visibility changes to the snooping protection icon based on DBus +// state, preferences and session type. +class ASH_EXPORT HpsNotifyController + : public SessionObserver, + public chromeos::HpsDBusClient::Observer { + public: + class Observer : public base::CheckedObserver { + public: + ~Observer() override = default; + + // Called when an observing icon should show or hide itself because the + // snooping status has changed. Argument is true if an icon should now be + // visible. + virtual void ShouldUpdateVisibility(bool visible) = 0; + }; + + HpsNotifyController(); + HpsNotifyController(const HpsNotifyController&) = delete; + HpsNotifyController& operator=(const HpsNotifyController&) = delete; + ~HpsNotifyController() override; + + static void RegisterProfilePrefs(PrefRegistrySimple* registry); + + // SessionObserver: + void OnSessionStateChanged(session_manager::SessionState state) override; + void OnActiveUserPrefServiceChanged(PrefService* pref_service) override; + + // chromeos::HpsDBusClient::Observer: + void OnHpsNotifyChanged(bool state) override; + + // Add/remove views that are listening for visibility updates. + void AddObserver(Observer* observer); + void RemoveObserver(Observer* observer); + + // The current visibility state. Polled by views on construction. + bool IsIconVisible() const; + + private: + // Updates visibility state as appropriate given the signal, session and + // preference state. If changed, notifies observers. + void UpdateIconVisibility(bool logged_in, bool hps_state, bool is_enabled); + + // A callback to set our initial state by polling the presence daemon. + void OnHpsPollResult(absl::optional<bool> result); + + // A callback to update visibility when the user enables or disables the + // feature. + void OnPrefChanged(); + + // Used to track whether a signal should actually trigger a visibility change: + bool hps_state_ = false; // The state last reported by the daemon. + bool session_active_ = false; // Whether or not there is an active user + // session ongoing. + bool is_enabled_ = false; // Whether or not the user has enabled the + // feature via preferences. + + base::ScopedObservation<SessionController, SessionObserver> + session_observation_{this}; + base::ScopedObservation<chromeos::HpsDBusClient, + chromeos::HpsDBusClient::Observer> + hps_dbus_observation_{this}; + + // Used to notify ourselves of changes to the pref that enables / disables + // this feature. + std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; + + // The views that are listening for visibililty instructions. + base::ObserverList<Observer> observers_; + + // Must be last. + base::WeakPtrFactory<HpsNotifyController> weak_ptr_factory_{this}; +}; + +} // namespace ash + +#endif // ASH_SYSTEM_UNIFIED_HPS_NOTIFY_CONTROLLER_H_
diff --git a/ash/system/unified/hps_notify_controller_unittest.cc b/ash/system/unified/hps_notify_controller_unittest.cc new file mode 100644 index 0000000..4ac2c41 --- /dev/null +++ b/ash/system/unified/hps_notify_controller_unittest.cc
@@ -0,0 +1,177 @@ +// Copyright 2021 The Chromium 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 "ash/system/unified/hps_notify_controller.h" + +#include <memory> + +#include "ash/constants/ash_features.h" +#include "ash/constants/ash_pref_names.h" +#include "ash/session/session_controller_impl.h" +#include "ash/session/test_session_controller_client.h" +#include "ash/shell.h" +#include "ash/test/ash_test_base.h" +#include "base/run_loop.h" +#include "base/test/scoped_feature_list.h" +#include "chromeos/dbus/hps/fake_hps_dbus_client.h" +#include "chromeos/dbus/hps/hps_dbus_client.h" +#include "components/account_id/account_id.h" +#include "components/user_manager/user_type.h" + +namespace ash { + +// Enables or disables the user pref for the feature. +void SetEnabledPref(bool enabled) { + Shell::Get()->session_controller()->GetActivePrefService()->SetBoolean( + prefs::kSnoopingProtectionEnabled, enabled); +} + +// A fixture that provides access to a fake daemon and an instance of the +// controller hooked up to the test environment. +class HpsNotifyControllerTestBase : public NoSessionAshTestBase { + public: + // Argument controls whether the DBus method should return true or false when + // the controller is being initialized. We can't set this value in individual + // tests since it must be done before AshTestBase::SetUp() executes. + HpsNotifyControllerTestBase(bool initial_dbus_state) + : initial_dbus_state_(initial_dbus_state) {} + HpsNotifyControllerTestBase(const HpsNotifyControllerTestBase&) = delete; + HpsNotifyControllerTestBase& operator=(const HpsNotifyControllerTestBase&) = + delete; + ~HpsNotifyControllerTestBase() override = default; + + void SetUp() override { + scoped_feature_list_.InitAndEnableFeature( + ash::features::kSnoopingProtection); + + chromeos::HpsDBusClient::InitializeFake(); + dbus_client_ = chromeos::FakeHpsDBusClient::Get(); + dbus_client_->set_hps_notify_result(initial_dbus_state_); + + AshTestBase::SetUp(); + + controller_ = Shell::Get()->hps_notify_controller(); + + // The controller has now been initialized, part of which entails sending a + // method to the DBus service. Here we wait for the service to + // asynchronously respond. + base::RunLoop().RunUntilIdle(); + } + + void TearDown() override { + AshTestBase::TearDown(); + chromeos::HpsDBusClient::Shutdown(); + } + + protected: + const bool initial_dbus_state_; + + chromeos::FakeHpsDBusClient* dbus_client_ = nullptr; + HpsNotifyController* controller_ = nullptr; + + base::test::ScopedFeatureList scoped_feature_list_; +}; + +// A test fixture where no snooper is initially detected. +class HpsNotifyControllerTestAbsent : public HpsNotifyControllerTestBase { + public: + HpsNotifyControllerTestAbsent() + : HpsNotifyControllerTestBase(/*initial_dbus_state=*/false) {} +}; + +// Test that icon is hidden by default. +TEST_F(HpsNotifyControllerTestAbsent, Hidden) { + SimulateUserLogin("testuser@gmail.com"); + SetEnabledPref(false); + EXPECT_EQ(dbus_client_->hps_notify_count(), 1); + + EXPECT_FALSE(controller_->IsIconVisible()); +} + +// Test that messages from the daemon toggle the icon. +TEST_F(HpsNotifyControllerTestAbsent, HpsStateChange) { + SimulateUserLogin("testuser@gmail.com"); + SetEnabledPref(true); + EXPECT_EQ(dbus_client_->hps_notify_count(), 1); + + EXPECT_FALSE(controller_->IsIconVisible()); + + controller_->OnHpsNotifyChanged(true); + + EXPECT_TRUE(controller_->IsIconVisible()); + + controller_->OnHpsNotifyChanged(false); + + EXPECT_FALSE(controller_->IsIconVisible()); +} + +// A test fixture where a snooper is initially detected. +class HpsNotifyControllerTestPresent : public HpsNotifyControllerTestBase { + public: + HpsNotifyControllerTestPresent() + : HpsNotifyControllerTestBase(/*initial_dbus_state=*/true) {} +}; + +// Test that initial daemon state is considered. +TEST_F(HpsNotifyControllerTestPresent, HpsState) { + SimulateUserLogin("testuser@gmail.com"); + SetEnabledPref(true); + EXPECT_EQ(dbus_client_->hps_notify_count(), 1); + + EXPECT_TRUE(controller_->IsIconVisible()); +} + +// Test that a user changing their preference toggles the icon. +TEST_F(HpsNotifyControllerTestPresent, PrefChanged) { + SimulateUserLogin("testuser@gmail.com"); + SetEnabledPref(false); + EXPECT_EQ(dbus_client_->hps_notify_count(), 1); + + EXPECT_FALSE(controller_->IsIconVisible()); + + SetEnabledPref(true); + + EXPECT_TRUE(controller_->IsIconVisible()); +} + +// Test that eye icon isn't shown during the OOBE. +TEST_F(HpsNotifyControllerTestPresent, Oobe) { + TestSessionControllerClient* session = GetSessionControllerClient(); + + // Simulate end of OOBE when user is logged in. + session->AddUserSession("testuser@gmail.com", user_manager::USER_TYPE_REGULAR, + /*provide_pref_service=*/true, + /*is_new_profile=*/true); + session->SwitchActiveUser(AccountId::FromUserEmail("testuser@gmail.com")); + session->SetSessionState(session_manager::SessionState::OOBE); + + SetEnabledPref(true); + EXPECT_EQ(dbus_client_->hps_notify_count(), 1); + + EXPECT_FALSE(controller_->IsIconVisible()); + + session->SetSessionState(session_manager::SessionState::ACTIVE); + + EXPECT_TRUE(controller_->IsIconVisible()); +} + +// Test that the eye icon isn't shown at the login page. +TEST_F(HpsNotifyControllerTestPresent, Login) { + // Note: login deferred. + + SetEnabledPref(true); + EXPECT_EQ(dbus_client_->hps_notify_count(), 1); + + EXPECT_FALSE(controller_->IsIconVisible()); + + SimulateUserLogin("testuser@gmail.com"); + + // Don't show until new user has enabled their preference. + EXPECT_FALSE(controller_->IsIconVisible()); + + SetEnabledPref(true); + EXPECT_TRUE(controller_->IsIconVisible()); +} + +} // namespace ash
diff --git a/ash/system/unified/hps_notify_view.cc b/ash/system/unified/hps_notify_view.cc index 8f8097f8..95e5afd 100644 --- a/ash/system/unified/hps_notify_view.cc +++ b/ash/system/unified/hps_notify_view.cc
@@ -4,7 +4,6 @@ #include "ash/system/unified/hps_notify_view.h" -#include "ash/constants/ash_pref_names.h" #include "ash/public/cpp/session/session_observer.h" #include "ash/resources/vector_icons/vector_icons.h" #include "ash/session/session_controller_impl.h" @@ -12,16 +11,8 @@ #include "ash/style/ash_color_provider.h" #include "ash/system/tray/tray_constants.h" #include "ash/system/tray/tray_utils.h" -#include "base/bind.h" -#include "base/callback.h" #include "base/logging.h" -#include "components/account_id/account_id.h" -#include "components/pref_registry/pref_registry_syncable.h" -#include "components/prefs/pref_change_registrar.h" -#include "components/prefs/pref_registry_simple.h" -#include "components/prefs/pref_service.h" #include "components/session_manager/session_manager_types.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/gfx/image/image_skia.h" #include "ui/gfx/paint_vector_icon.h" @@ -32,67 +23,25 @@ HpsNotifyView::HpsNotifyView(Shelf* shelf) : TrayItemView(shelf) { CreateImageView(); - SetVisible(false); SessionControllerImpl* session_controller = Shell::Get()->session_controller(); - - OnSessionStateChanged(session_controller->GetSessionState()); session_observation_.Observe(session_controller); - // Poll the current preference state if the pref service is already loaded for - // an active user. Then, from now on, observe changes to the active user pref - // service. - const AccountId& account_id = session_controller->GetActiveAccountId(); - PrefService* pref_service = - session_controller->GetUserPrefServiceForUser(account_id); - OnActiveUserPrefServiceChanged(pref_service); + HpsNotifyController* controller = Shell::Get()->hps_notify_controller(); + controller_observer_.Observe(controller); - // Poll the current HPS notify state if the daemon is active. Then, from now - // on, observe changes to the HPS notify signal. - chromeos::HpsDBusClient::Get()->GetResultHpsNotify(base::BindOnce( - &HpsNotifyView::OnHpsPollResult, weak_ptr_factory_.GetWeakPtr())); - hps_dbus_observation_.Observe(chromeos::HpsDBusClient::Get()); + SetVisible(controller->IsIconVisible()); + UpdateIconColor(session_controller->GetSessionState()); } HpsNotifyView::~HpsNotifyView() = default; -// static -void HpsNotifyView::RegisterProfilePrefs(PrefRegistrySimple* registry) { - registry->RegisterBooleanPref( - prefs::kSnoopingProtectionEnabled, - /*default_value=*/false, - user_prefs::PrefRegistrySyncable::SYNCABLE_OS_PREF); -} - void HpsNotifyView::HandleLocaleChange() {} void HpsNotifyView::OnSessionStateChanged( session_manager::SessionState session_state) { UpdateIconColor(session_state); - UpdateIconVisibility(session_state == session_manager::SessionState::OOBE, - hps_state_, is_enabled_); -} - -void HpsNotifyView::OnActiveUserPrefServiceChanged(PrefService* pref_service) { - UpdateIconVisibility(is_oobe_, hps_state_, - pref_service && pref_service->GetBoolean( - prefs::kSnoopingProtectionEnabled)); - - if (!pref_service) - return; - - // Re-subscribe to pref changes. - pref_change_registrar_ = std::make_unique<PrefChangeRegistrar>(); - pref_change_registrar_->Init(pref_service); - pref_change_registrar_->Add( - prefs::kSnoopingProtectionEnabled, - base::BindRepeating(&HpsNotifyView::OnPrefChanged, - weak_ptr_factory_.GetWeakPtr())); -} - -void HpsNotifyView::OnHpsNotifyChanged(bool hps_state) { - UpdateIconVisibility(is_oobe_, hps_state, is_enabled_); } void HpsNotifyView::OnThemeChanged() { @@ -104,6 +53,10 @@ return "HpsNotifyView"; } +void HpsNotifyView::ShouldUpdateVisibility(bool visible) { + SetVisible(visible); +} + void HpsNotifyView::UpdateIconColor( session_manager::SessionState session_state) { const SkColor new_color = TrayIconColor(session_state); @@ -112,36 +65,4 @@ image_view()->SetImage(new_icon); } -void HpsNotifyView::UpdateIconVisibility(bool is_oobe, - bool hps_state, - bool is_enabled) { - if (is_oobe_ == is_oobe && hps_state_ == hps_state && - is_enabled_ == is_enabled) - return; - - is_oobe_ = is_oobe; - hps_state_ = hps_state; - is_enabled_ = is_enabled; - - SetVisible(!is_oobe_ && hps_state_ && is_enabled); -} - -void HpsNotifyView::OnHpsPollResult(absl::optional<bool> result) { - if (!result.has_value()) { - LOG(WARNING) << "Polling the presence daemon failed"; - return; - } - - UpdateIconVisibility(is_oobe_, *result, is_enabled_); -} - -void HpsNotifyView::OnPrefChanged() { - DCHECK(pref_change_registrar_); - DCHECK(pref_change_registrar_->prefs()); - - UpdateIconVisibility(is_oobe_, hps_state_, - pref_change_registrar_->prefs()->GetBoolean( - prefs::kSnoopingProtectionEnabled)); -} - } // namespace ash
diff --git a/ash/system/unified/hps_notify_view.h b/ash/system/unified/hps_notify_view.h index a957d66..bd49382 100644 --- a/ash/system/unified/hps_notify_view.h +++ b/ash/system/unified/hps_notify_view.h
@@ -5,35 +5,28 @@ #ifndef ASH_SYSTEM_UNIFIED_HPS_NOTIFY_VIEW_H_ #define ASH_SYSTEM_UNIFIED_HPS_NOTIFY_VIEW_H_ +#include "ash/ash_export.h" #include "ash/public/cpp/session/session_controller.h" #include "ash/public/cpp/session/session_observer.h" #include "ash/system/tray/tray_item_view.h" +#include "ash/system/unified/hps_notify_controller.h" #include "base/scoped_observation.h" -#include "chromeos/dbus/hps/hps_dbus_client.h" #include "components/session_manager/session_manager_types.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/skia/include/core/SkColor.h" -class PrefChangeRegistrar; -class PrefRegistrySimple; - namespace ash { // The icon in the system tray notifying a user that a second person has been // detected looking over their shoulder. class ASH_EXPORT HpsNotifyView : public TrayItemView, public SessionObserver, - public chromeos::HpsDBusClient::Observer { + public HpsNotifyController::Observer { public: explicit HpsNotifyView(Shelf* shelf); HpsNotifyView(const HpsNotifyView&) = delete; HpsNotifyView& operator=(const HpsNotifyView&) = delete; ~HpsNotifyView() override; - // TODO(crbug.com/1241704): refactor this class into a controller that - // provides access to a TrayItemView* for the snooping icon. - static void RegisterProfilePrefs(PrefRegistrySimple* registry); - // views::TrayItemView: const char* GetClassName() const override; void HandleLocaleChange() override; @@ -41,41 +34,20 @@ // SessionObserver: void OnSessionStateChanged(session_manager::SessionState state) override; - void OnActiveUserPrefServiceChanged(PrefService* pref_service) override; - // chromeos::HpsDBusClient::Observer: - void OnHpsNotifyChanged(bool state) override; + // HpsNotifyController: + void ShouldUpdateVisibility(bool visible) override; private: // Updates the system tray icon to use the color corresponding to the current // session state (e.g. darker during OOBE). void UpdateIconColor(session_manager::SessionState session_state); - // Shows or hides the system tray icon as appropriate given the signal, - // session and preference state. Also updates the current cached states. - void UpdateIconVisibility(bool is_oobe, bool hps_state, bool is_enabled); - - // A callback to set our initial state by polling the presence daemon. - void OnHpsPollResult(absl::optional<bool> result); - - // A callback to update visibility when the user enables or disables the - // feature. - void OnPrefChanged(); - - // Used to track whether a signal should actually trigger a visibility: - bool hps_state_ = false; // The state last reported by the daemon. - bool is_oobe_ = false; // Whether or not we're in the OOBE. - bool is_enabled_ = false; // Whether or not the user has enabled the feature. - base::ScopedObservation<SessionController, SessionObserver> session_observation_{this}; - base::ScopedObservation<chromeos::HpsDBusClient, - chromeos::HpsDBusClient::Observer> - hps_dbus_observation_{this}; - // Used to notify ourselves of changes to the pref that enables / disables - // this feature. - std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; + base::ScopedObservation<HpsNotifyController, HpsNotifyController::Observer> + controller_observer_{this}; // Must be last. base::WeakPtrFactory<HpsNotifyView> weak_ptr_factory_{this};
diff --git a/ash/system/unified/hps_notify_view_unittest.cc b/ash/system/unified/hps_notify_view_unittest.cc deleted file mode 100644 index 904a3ff..0000000 --- a/ash/system/unified/hps_notify_view_unittest.cc +++ /dev/null
@@ -1,164 +0,0 @@ -// Copyright 2021 The Chromium 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 "ash/system/unified/hps_notify_view.h" - -#include <memory> - -#include "ash/constants/ash_pref_names.h" -#include "ash/session/session_controller_impl.h" -#include "ash/session/test_session_controller_client.h" -#include "ash/shell.h" -#include "ash/test/ash_test_base.h" -#include "base/run_loop.h" -#include "chromeos/dbus/hps/fake_hps_dbus_client.h" -#include "chromeos/dbus/hps/hps_dbus_client.h" - -namespace ash { -namespace { - -// Enables or disables the user pref for the feature. -void SetEnabledPref(bool enabled) { - Shell::Get()->session_controller()->GetActivePrefService()->SetBoolean( - prefs::kSnoopingProtectionEnabled, enabled); -} - -// Provides access to a fake daemon and an instance of the view hooked up to the -// test environment. -class HpsNotifyViewTest : public NoSessionAshTestBase { - public: - HpsNotifyViewTest() = default; - HpsNotifyViewTest(const HpsNotifyViewTest&) = delete; - HpsNotifyViewTest& operator=(const HpsNotifyViewTest&) = delete; - ~HpsNotifyViewTest() override = default; - - void SetUp() override { - AshTestBase::SetUp(); - - chromeos::HpsDBusClient::InitializeFake(); - dbus_client_ = chromeos::FakeHpsDBusClient::Get(); - } - - void TearDown() override { - view_.reset(); - dbus_client_ = nullptr; - chromeos::HpsDBusClient::Shutdown(); - - AshTestBase::TearDown(); - } - - protected: - // Recreates the view. Used to defer view construction. - void InitializeView() { - view_ = std::make_unique<HpsNotifyView>(GetPrimaryShelf()); - } - - chromeos::FakeHpsDBusClient* dbus_client_ = nullptr; - std::unique_ptr<HpsNotifyView> view_; -}; - -// Test that icon is hidden by default. -TEST_F(HpsNotifyViewTest, Hidden) { - SimulateUserLogin("testuser@gmail.com"); - SetEnabledPref(false); - dbus_client_->set_hps_notify_result(false); - InitializeView(); - base::RunLoop().RunUntilIdle(); - EXPECT_EQ(dbus_client_->hps_notify_count(), 1); - - EXPECT_FALSE(view_->GetVisible()); -} - -// Test that initial daemon state is considered. -TEST_F(HpsNotifyViewTest, HpsState) { - SimulateUserLogin("testuser@gmail.com"); - SetEnabledPref(true); - dbus_client_->set_hps_notify_result(true); - InitializeView(); - base::RunLoop().RunUntilIdle(); - EXPECT_EQ(dbus_client_->hps_notify_count(), 1); - - EXPECT_TRUE(view_->GetVisible()); -} - -// Test that messages from the daemon toggle the icon. -TEST_F(HpsNotifyViewTest, HpsStateChange) { - SimulateUserLogin("testuser@gmail.com"); - SetEnabledPref(true); - dbus_client_->set_hps_notify_result(false); - InitializeView(); - base::RunLoop().RunUntilIdle(); - EXPECT_EQ(dbus_client_->hps_notify_count(), 1); - - EXPECT_FALSE(view_->GetVisible()); - - view_->OnHpsNotifyChanged(true); - - EXPECT_TRUE(view_->GetVisible()); - - view_->OnHpsNotifyChanged(false); - - EXPECT_FALSE(view_->GetVisible()); -} - -// Test that a user changing their preference toggles the icon. -TEST_F(HpsNotifyViewTest, PrefChanged) { - SimulateUserLogin("testuser@gmail.com"); - SetEnabledPref(false); - dbus_client_->set_hps_notify_result(true); - InitializeView(); - base::RunLoop().RunUntilIdle(); - EXPECT_EQ(dbus_client_->hps_notify_count(), 1); - - EXPECT_FALSE(view_->GetVisible()); - - SetEnabledPref(true); - - EXPECT_TRUE(view_->GetVisible()); -} - -// Test that eye icon isn't shown during the OOBE. -TEST_F(HpsNotifyViewTest, Oobe) { - // Simulate end of OOBE when user is logged in. - SimulateUserLogin("testuser@gmail.com"); - GetSessionControllerClient()->SetSessionState( - session_manager::SessionState::OOBE); - - SetEnabledPref(true); - dbus_client_->set_hps_notify_result(true); - InitializeView(); - base::RunLoop().RunUntilIdle(); - EXPECT_EQ(dbus_client_->hps_notify_count(), 1); - - EXPECT_FALSE(view_->GetVisible()); - - GetSessionControllerClient()->SetSessionState( - session_manager::SessionState::ACTIVE); - - EXPECT_TRUE(view_->GetVisible()); -} - -// Test that the eye icon isn't shown at the login page. -TEST_F(HpsNotifyViewTest, Login) { - // Note: login deferred. - - SetEnabledPref(true); - dbus_client_->set_hps_notify_result(true); - InitializeView(); - base::RunLoop().RunUntilIdle(); - EXPECT_EQ(dbus_client_->hps_notify_count(), 1); - - EXPECT_FALSE(view_->GetVisible()); - - SimulateUserLogin("testuser@gmail.com"); - - // Don't show until new user has enabled their preference. - EXPECT_FALSE(view_->GetVisible()); - - SetEnabledPref(true); - EXPECT_TRUE(view_->GetVisible()); -} - -} // namespace -} // namespace ash
diff --git a/ash/system/unified/notification_icons_controller.cc b/ash/system/unified/notification_icons_controller.cc index ede548d..0ae81af0 100644 --- a/ash/system/unified/notification_icons_controller.cc +++ b/ash/system/unified/notification_icons_controller.cc
@@ -125,7 +125,7 @@ NotificationIconsController::NotificationIconsController( UnifiedSystemTray* tray) : tray_(tray) { - system_tray_model_observation_.Observe(tray_->model()); + system_tray_model_observation_.Observe(tray_->model().get()); message_center::MessageCenter::Get()->AddObserver(this); Shell::Get()->session_controller()->AddObserver(this); }
diff --git a/ash/system/unified/page_indicator_view_unittest.cc b/ash/system/unified/page_indicator_view_unittest.cc index 02caa658..537dfdb 100644 --- a/ash/system/unified/page_indicator_view_unittest.cc +++ b/ash/system/unified/page_indicator_view_unittest.cc
@@ -10,6 +10,7 @@ #include "ash/system/unified/unified_system_tray_model.h" #include "ash/system/unified/unified_system_tray_view.h" #include "ash/test/ash_test_base.h" +#include "base/memory/scoped_refptr.h" namespace ash { @@ -29,7 +30,7 @@ void SetUp() override { NoSessionAshTestBase::SetUp(); - model_ = std::make_unique<UnifiedSystemTrayModel>(nullptr); + model_ = base::MakeRefCounted<UnifiedSystemTrayModel>(nullptr); controller_ = std::make_unique<UnifiedSystemTrayController>(model_.get()); unified_view_ = std::make_unique<UnifiedSystemTrayView>( @@ -61,7 +62,7 @@ UnifiedSystemTrayView* unified_view() { return unified_view_.get(); } private: - std::unique_ptr<UnifiedSystemTrayModel> model_; + scoped_refptr<UnifiedSystemTrayModel> model_; std::unique_ptr<UnifiedSystemTrayController> controller_; std::unique_ptr<UnifiedSystemTrayView> unified_view_; };
diff --git a/ash/system/unified/quiet_mode_feature_pod_controller_unittest.cc b/ash/system/unified/quiet_mode_feature_pod_controller_unittest.cc index 2248946..ca2b7b512 100644 --- a/ash/system/unified/quiet_mode_feature_pod_controller_unittest.cc +++ b/ash/system/unified/quiet_mode_feature_pod_controller_unittest.cc
@@ -8,6 +8,7 @@ #include "ash/system/unified/unified_system_tray_controller.h" #include "ash/system/unified/unified_system_tray_model.h" #include "ash/test/ash_test_base.h" +#include "base/memory/scoped_refptr.h" namespace ash { @@ -26,7 +27,7 @@ void SetUp() override { NoSessionAshTestBase::SetUp(); - tray_model_ = std::make_unique<UnifiedSystemTrayModel>(nullptr); + tray_model_ = base::MakeRefCounted<UnifiedSystemTrayModel>(nullptr); tray_controller_ = std::make_unique<UnifiedSystemTrayController>(tray_model_.get()); } @@ -53,7 +54,7 @@ FeaturePodButton* button() { return button_.get(); } private: - std::unique_ptr<UnifiedSystemTrayModel> tray_model_; + scoped_refptr<UnifiedSystemTrayModel> tray_model_; std::unique_ptr<UnifiedSystemTrayController> tray_controller_; std::unique_ptr<QuietModeFeaturePodController> controller_; std::unique_ptr<FeaturePodButton> button_;
diff --git a/ash/system/unified/top_shortcuts_view_unittest.cc b/ash/system/unified/top_shortcuts_view_unittest.cc index 0fc0dbb..63fd9e95 100644 --- a/ash/system/unified/top_shortcuts_view_unittest.cc +++ b/ash/system/unified/top_shortcuts_view_unittest.cc
@@ -11,6 +11,7 @@ #include "ash/system/unified/unified_system_tray_controller.h" #include "ash/system/unified/unified_system_tray_model.h" #include "ash/test/ash_test_base.h" +#include "base/memory/scoped_refptr.h" #include "components/prefs/pref_registry_simple.h" namespace ash { @@ -28,7 +29,7 @@ void SetUp() override { NoSessionAshTestBase::SetUp(); - model_ = std::make_unique<UnifiedSystemTrayModel>(nullptr); + model_ = base::MakeRefCounted<UnifiedSystemTrayModel>(nullptr); controller_ = std::make_unique<UnifiedSystemTrayController>(model_.get()); } @@ -67,7 +68,7 @@ void Layout() { top_shortcuts_view_->Layout(); } private: - std::unique_ptr<UnifiedSystemTrayModel> model_; + scoped_refptr<UnifiedSystemTrayModel> model_; std::unique_ptr<UnifiedSystemTrayController> controller_; std::unique_ptr<TopShortcutsView> top_shortcuts_view_; };
diff --git a/ash/system/unified/unified_slider_bubble_controller.cc b/ash/system/unified/unified_slider_bubble_controller.cc index c691088e..6aa296f 100644 --- a/ash/system/unified/unified_slider_bubble_controller.cc +++ b/ash/system/unified/unified_slider_bubble_controller.cc
@@ -230,13 +230,13 @@ std::make_unique<UnifiedVolumeSliderController>(this); return; case SLIDER_TYPE_DISPLAY_BRIGHTNESS: - slider_controller_ = - std::make_unique<UnifiedBrightnessSliderController>(tray_->model()); + slider_controller_ = std::make_unique<UnifiedBrightnessSliderController>( + tray_->model().get()); return; case SLIDER_TYPE_KEYBOARD_BRIGHTNESS: slider_controller_ = std::make_unique<UnifiedKeyboardBrightnessSliderController>( - tray_->model()); + tray_->model().get()); return; case SLIDER_TYPE_MIC: slider_controller_ = std::make_unique<MicGainSliderController>();
diff --git a/ash/system/unified/unified_system_info_view_unittest.cc b/ash/system/unified/unified_system_info_view_unittest.cc index 5e0cbf3..0518e8d7 100644 --- a/ash/system/unified/unified_system_info_view_unittest.cc +++ b/ash/system/unified/unified_system_info_view_unittest.cc
@@ -13,6 +13,7 @@ #include "ash/system/unified/unified_system_tray_controller.h" #include "ash/system/unified/unified_system_tray_model.h" #include "ash/test/ash_test_base.h" +#include "base/memory/scoped_refptr.h" #include "base/test/scoped_feature_list.h" namespace ash { @@ -33,7 +34,7 @@ scoped_feature_list_->InitWithFeatureState( features::kManagedDeviceUIRedesign, IsManagedDeviceUIRedesignEnabled()); - model_ = std::make_unique<UnifiedSystemTrayModel>(nullptr); + model_ = base::MakeRefCounted<UnifiedSystemTrayModel>(nullptr); controller_ = std::make_unique<UnifiedSystemTrayController>(model_.get()); info_view_ = std::make_unique<UnifiedSystemInfoView>(controller_.get()); } @@ -55,7 +56,7 @@ } private: - std::unique_ptr<UnifiedSystemTrayModel> model_; + scoped_refptr<UnifiedSystemTrayModel> model_; std::unique_ptr<UnifiedSystemTrayController> controller_; std::unique_ptr<UnifiedSystemInfoView> info_view_; std::unique_ptr<base::test::ScopedFeatureList> scoped_feature_list_; @@ -105,7 +106,7 @@ TEST_F(UnifiedSystemInfoViewNoSessionTest, ChildVisible) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitAndDisableFeature(features::kManagedDeviceUIRedesign); - auto model = std::make_unique<UnifiedSystemTrayModel>(nullptr); + auto model = base::MakeRefCounted<UnifiedSystemTrayModel>(nullptr); auto controller = std::make_unique<UnifiedSystemTrayController>(model.get()); SessionControllerImpl* session = Shell::Get()->session_controller();
diff --git a/ash/system/unified/unified_system_tray.cc b/ash/system/unified/unified_system_tray.cc index 9a2dbfb..edae64b 100644 --- a/ash/system/unified/unified_system_tray.cc +++ b/ash/system/unified/unified_system_tray.cc
@@ -38,6 +38,7 @@ #include "ash/system/unified/unified_system_tray_bubble.h" #include "ash/system/unified/unified_system_tray_model.h" #include "ash/system/unified/unified_system_tray_view.h" +#include "base/memory/scoped_refptr.h" #include "base/metrics/histogram_macros.h" #include "base/time/time.h" #include "base/timer/timer.h" @@ -147,7 +148,7 @@ UnifiedSystemTray::UnifiedSystemTray(Shelf* shelf) : TrayBackgroundView(shelf), ui_delegate_(std::make_unique<UiDelegate>(this)), - model_(std::make_unique<UnifiedSystemTrayModel>(shelf)), + model_(base::MakeRefCounted<UnifiedSystemTrayModel>(shelf)), slider_bubble_controller_( std::make_unique<UnifiedSliderBubbleController>(this)), privacy_screen_toast_controller_( @@ -166,7 +167,7 @@ mic_view_( new CameraMicTrayItemView(shelf, CameraMicTrayItemView::Type::kMic)) { time_view_ = new tray::TimeTrayItemView( - shelf, model(), + shelf, model_, base::BindRepeating(&UnifiedSystemTray::OnTimeViewActionPerformed, weak_factory_.GetWeakPtr())); tray_container()->SetMargin(
diff --git a/ash/system/unified/unified_system_tray.h b/ash/system/unified/unified_system_tray.h index 48bf639a..c454699 100644 --- a/ash/system/unified/unified_system_tray.h +++ b/ash/system/unified/unified_system_tray.h
@@ -14,6 +14,8 @@ #include "ash/shell_observer.h" #include "ash/system/time/time_view.h" #include "ash/system/tray/tray_background_view.h" +#include "ash/system/unified/unified_system_tray_model.h" +#include "base/memory/scoped_refptr.h" #include "base/memory/weak_ptr.h" #include "base/scoped_multi_source_observation.h" #include "base/time/time.h" @@ -40,7 +42,6 @@ class TrayItemView; class UnifiedSliderBubbleController; class UnifiedSystemTrayBubble; -class UnifiedSystemTrayModel; class UnifiedMessageCenterBubble; class CameraMicTrayItemView; @@ -189,7 +190,7 @@ AshMessagePopupCollection* GetMessagePopupCollection(); - UnifiedSystemTrayModel* model() { return model_.get(); } + scoped_refptr<UnifiedSystemTrayModel> model() { return model_; } UnifiedSystemTrayBubble* bubble() { return bubble_.get(); } UnifiedMessageCenterBubble* message_center_bubble() { @@ -233,7 +234,7 @@ std::unique_ptr<UnifiedMessageCenterBubble> message_center_bubble_; // Model class that stores UnifiedSystemTray's UI specific variables. - const std::unique_ptr<UnifiedSystemTrayModel> model_; + scoped_refptr<UnifiedSystemTrayModel> model_; const std::unique_ptr<UnifiedSliderBubbleController> slider_bubble_controller_;
diff --git a/ash/system/unified/unified_system_tray_controller.cc b/ash/system/unified/unified_system_tray_controller.cc index 3fe444d..6e849e96 100644 --- a/ash/system/unified/unified_system_tray_controller.cc +++ b/ash/system/unified/unified_system_tray_controller.cc
@@ -65,6 +65,7 @@ #include "ash/wm/tablet_mode/tablet_mode_controller.h" #include "base/bind.h" #include "base/cxx17_backports.h" +#include "base/memory/scoped_refptr.h" #include "base/metrics/histogram_macros.h" #include "base/metrics/user_metrics.h" #include "components/prefs/pref_service.h" @@ -97,7 +98,7 @@ } UnifiedSystemTrayController::UnifiedSystemTrayController( - UnifiedSystemTrayModel* model, + scoped_refptr<UnifiedSystemTrayModel> model, UnifiedSystemTrayBubble* bubble, views::View* owner_view) : views::AnimationDelegateViews(owner_view),
diff --git a/ash/system/unified/unified_system_tray_controller.h b/ash/system/unified/unified_system_tray_controller.h index 86a8bbe..3e4ff8efac 100644 --- a/ash/system/unified/unified_system_tray_controller.h +++ b/ash/system/unified/unified_system_tray_controller.h
@@ -13,6 +13,7 @@ #include "ash/system/audio/unified_volume_slider_controller.h" #include "ash/system/media/unified_media_controls_controller.h" #include "ash/system/unified/unified_system_tray_model.h" +#include "base/memory/scoped_refptr.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/compositor/throughput_tracker.h" #include "ui/gfx/geometry/point.h" @@ -44,9 +45,10 @@ public UnifiedVolumeSliderController::Delegate, public UnifiedMediaControlsController::Delegate { public: - UnifiedSystemTrayController(UnifiedSystemTrayModel* model, - UnifiedSystemTrayBubble* bubble = nullptr, - views::View* owner_view = nullptr); + explicit UnifiedSystemTrayController( + scoped_refptr<UnifiedSystemTrayModel> model, + UnifiedSystemTrayBubble* bubble = nullptr, + views::View* owner_view = nullptr); UnifiedSystemTrayController(const UnifiedSystemTrayController&) = delete; UnifiedSystemTrayController& operator=(const UnifiedSystemTrayController&) = @@ -155,7 +157,7 @@ void ShowMediaControls() override; void OnMediaControlsViewClicked() override; - UnifiedSystemTrayModel* model() { return model_; } + scoped_refptr<UnifiedSystemTrayModel> model() { return model_; } PaginationController* pagination_controller() { return pagination_controller_.get(); @@ -227,7 +229,7 @@ base::TimeDelta GetAnimationDurationForReporting() const override; // Model that stores UI specific variables. Unowned. - UnifiedSystemTrayModel* const model_; + scoped_refptr<UnifiedSystemTrayModel> model_; // Unowned. Owned by Views hierarchy. UnifiedSystemTrayView* unified_view_ = nullptr;
diff --git a/ash/system/unified/unified_system_tray_controller_unittest.cc b/ash/system/unified/unified_system_tray_controller_unittest.cc index dadc4fad..c95da15 100644 --- a/ash/system/unified/unified_system_tray_controller_unittest.cc +++ b/ash/system/unified/unified_system_tray_controller_unittest.cc
@@ -14,6 +14,7 @@ #include "ash/system/unified/unified_system_tray_model.h" #include "ash/system/unified/unified_system_tray_view.h" #include "ash/test/ash_test_base.h" +#include "base/memory/scoped_refptr.h" #include "chromeos/dbus/shill/shill_clients.h" #include "chromeos/services/network_config/public/cpp/cros_network_config_test_helper.h" #include "components/prefs/testing_pref_service.h" @@ -53,7 +54,7 @@ // Networking stubs may have asynchronous initialization. base::RunLoop().RunUntilIdle(); - model_ = std::make_unique<UnifiedSystemTrayModel>(nullptr); + model_ = base::MakeRefCounted<UnifiedSystemTrayModel>(nullptr); controller_ = std::make_unique<UnifiedSystemTrayController>(model()); } @@ -106,7 +107,7 @@ private: std::unique_ptr<chromeos::network_config::CrosNetworkConfigTestHelper> network_config_helper_; - std::unique_ptr<UnifiedSystemTrayModel> model_; + scoped_refptr<UnifiedSystemTrayModel> model_; std::unique_ptr<UnifiedSystemTrayController> controller_; std::unique_ptr<UnifiedSystemTrayView> view_;
diff --git a/ash/system/unified/unified_system_tray_model.h b/ash/system/unified/unified_system_tray_model.h index 75b6c9ca..8dc3d8d 100644 --- a/ash/system/unified/unified_system_tray_model.h +++ b/ash/system/unified/unified_system_tray_model.h
@@ -7,6 +7,7 @@ #include "ash/ash_export.h" #include "ash/public/cpp/pagination/pagination_model.h" +#include "base/memory/scoped_refptr.h" #include "base/observer_list.h" #include "chromeos/dbus/power/power_manager_client.h" #include "third_party/abseil-cpp/absl/types/optional.h" @@ -22,7 +23,8 @@ // Model class that stores UnifiedSystemTray's UI specific variables. Owned by // UnifiedSystemTray status area button. Not to be confused with UI agnostic // SystemTrayModel. -class ASH_EXPORT UnifiedSystemTrayModel { +class ASH_EXPORT UnifiedSystemTrayModel + : public base::RefCounted<UnifiedSystemTrayModel> { public: enum class StateOnOpen { // The user has not made any changes to the quick settings state. @@ -58,7 +60,7 @@ class Observer { public: - virtual ~Observer() {} + virtual ~Observer() = default; // |by_user| is true when brightness is changed by user action. virtual void OnDisplayBrightnessChanged(bool by_user) {} @@ -72,15 +74,13 @@ UnifiedSystemTrayModel(const UnifiedSystemTrayModel&) = delete; UnifiedSystemTrayModel& operator=(const UnifiedSystemTrayModel&) = delete; - ~UnifiedSystemTrayModel(); - void AddObserver(Observer* observer); void RemoveObserver(Observer* observer); // Returns true if the tray should be expanded when initially opened. bool IsExpandedOnOpen() const; - // Returns true if the user explicity set the tray to its + // Returns true if the user explicitly set the tray to its // expanded state. bool IsExplicitlyExpanded() const; @@ -97,7 +97,7 @@ // Removes the state of the notification of |notification_id|. void RemoveNotificationExpanded(const std::string& notification_id); - // Clears all changes by SetNotificatinExpanded(). + // Clears all changes by SetNotificationExpanded(). void ClearNotificationChanges(); // Set the notification id of the target. This sets target mode as @@ -130,12 +130,20 @@ private: friend class UnifiedSystemTrayControllerTest; + // Required for private destructor to be called from RefCounted<>. + friend class base::RefCounted<UnifiedSystemTrayModel>; class DBusObserver; // Keeps track all the sources that can change the size of system tray button. class SizeObserver; + // Private destructor to prevent subverting reference counting. + // TODO(crbug/1269517): The use of this class should be refactored so that + // reference counting is not required. Likely, Message Center and Quick + // Settings will need to be combined. + ~UnifiedSystemTrayModel(); + void DisplayBrightnessChanged(float brightness, bool by_user); void KeyboardBrightnessChanged(float brightness, bool by_user); void SystemTrayButtonSizeChanged(SystemTrayButtonSize system_tray_size);
diff --git a/ash/webui/shimless_rma/backend/shimless_rma_service.cc b/ash/webui/shimless_rma/backend/shimless_rma_service.cc index a250e9ac..3ca5a1a1 100644 --- a/ash/webui/shimless_rma/backend/shimless_rma_service.cc +++ b/ash/webui/shimless_rma/backend/shimless_rma_service.cc
@@ -557,8 +557,46 @@ TransitionNextStateGeneric(std::move(callback)); } -void ShimlessRmaService::GetRegionList(GetRegionListCallback callback) {} -void ShimlessRmaService::GetSkuList(GetSkuListCallback callback) {} +void ShimlessRmaService::GetRegionList(GetRegionListCallback callback) { + std::vector<std::string> regions; + if (state_proto_.state_case() != rmad::RmadState::kUpdateDeviceInfo) { + LOG(ERROR) << "GetRegionList called from incorrect state " + << state_proto_.state_case(); + } else { + regions.reserve(state_proto_.update_device_info().region_list_size()); + regions.assign(state_proto_.update_device_info().region_list().begin(), + state_proto_.update_device_info().region_list().end()); + } + std::move(callback).Run(std::move(regions)); +} + +void ShimlessRmaService::GetSkuList(GetSkuListCallback callback) { + std::vector<uint64_t> skus; + if (state_proto_.state_case() != rmad::RmadState::kUpdateDeviceInfo) { + LOG(ERROR) << "GetSkuList called from incorrect state " + << state_proto_.state_case(); + } else { + skus.reserve(state_proto_.update_device_info().sku_list_size()); + skus.assign(state_proto_.update_device_info().sku_list().begin(), + state_proto_.update_device_info().sku_list().end()); + } + std::move(callback).Run(std::move(skus)); +} + +void ShimlessRmaService::GetWhiteLabelList(GetWhiteLabelListCallback callback) { + std::vector<std::string> whiteLabels; + if (state_proto_.state_case() != rmad::RmadState::kUpdateDeviceInfo) { + LOG(ERROR) << "GetSkuList called from incorrect state " + << state_proto_.state_case(); + } else { + whiteLabels.reserve( + state_proto_.update_device_info().whitelabel_list_size()); + whiteLabels.assign( + state_proto_.update_device_info().whitelabel_list().begin(), + state_proto_.update_device_info().whitelabel_list().end()); + } + std::move(callback).Run(std::move(whiteLabels)); +} void ShimlessRmaService::GetOriginalSerialNumber( GetOriginalSerialNumberCallback callback) { @@ -594,6 +632,20 @@ state_proto_.update_device_info().original_sku_index()); } +void ShimlessRmaService::GetOriginalWhiteLabel( + GetOriginalWhiteLabelCallback callback) { + if (state_proto_.state_case() != rmad::RmadState::kUpdateDeviceInfo) { + // TODO(gavindodd): Consider replacing all invalid call handling with + // mojo::ReportBadMessage("error message"); + LOG(ERROR) << "GetOriginalWhiteLabel called from incorrect state " + << state_proto_.state_case(); + std::move(callback).Run(0); + return; + } + std::move(callback).Run( + state_proto_.update_device_info().original_whitelabel_index()); +} + void ShimlessRmaService::SetDeviceInformation( const std::string& serial_number, uint8_t region_index,
diff --git a/ash/webui/shimless_rma/backend/shimless_rma_service.h b/ash/webui/shimless_rma/backend/shimless_rma_service.h index d5b013e..7a3f76e 100644 --- a/ash/webui/shimless_rma/backend/shimless_rma_service.h +++ b/ash/webui/shimless_rma/backend/shimless_rma_service.h
@@ -96,10 +96,12 @@ void GetRegionList(GetRegionListCallback callback) override; void GetSkuList(GetSkuListCallback callback) override; + void GetWhiteLabelList(GetWhiteLabelListCallback callback) override; void GetOriginalSerialNumber( GetOriginalSerialNumberCallback callback) override; void GetOriginalRegion(GetOriginalRegionCallback callback) override; void GetOriginalSku(GetOriginalSkuCallback callback) override; + void GetOriginalWhiteLabel(GetOriginalWhiteLabelCallback callback) override; void SetDeviceInformation(const std::string& serial_number, uint8_t region_index, uint8_t sku_index,
diff --git a/ash/webui/shimless_rma/backend/shimless_rma_service_unittest.cc b/ash/webui/shimless_rma/backend/shimless_rma_service_unittest.cc index c6fb346..d95273d 100644 --- a/ash/webui/shimless_rma/backend/shimless_rma_service_unittest.cc +++ b/ash/webui/shimless_rma/backend/shimless_rma_service_unittest.cc
@@ -224,7 +224,7 @@ TEST_F(ShimlessRmaServiceTest, AbortAndGoBackStatePassedCorrectly) { SetupWiFiNetwork(); - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK, /*can_abort*/ true, /*can_go_back*/ false), CreateStateReply(rmad::RmadState::kComponentsRepair, rmad::RMAD_ERROR_OK, @@ -270,7 +270,7 @@ TEST_F(ShimlessRmaServiceTest, WelcomeHasNetworkConnection) { SetupWiFiNetwork(); - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kWelcome, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kComponentsRepair, rmad::RMAD_ERROR_OK)}; @@ -299,7 +299,7 @@ } TEST_F(ShimlessRmaServiceTest, WelcomeHasNoNetworkConnection) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kWelcome, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kComponentsRepair, rmad::RMAD_ERROR_OK)}; @@ -331,7 +331,7 @@ } TEST_F(ShimlessRmaServiceTest, ChooseNetworkHasNetworkConnection) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kWelcome, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kComponentsRepair, rmad::RMAD_ERROR_OK)}; @@ -370,7 +370,7 @@ } TEST_F(ShimlessRmaServiceTest, ChooseNetworkHasNoNetworkConnection) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kWelcome, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kComponentsRepair, rmad::RMAD_ERROR_OK)}; @@ -494,7 +494,7 @@ } TEST_F(ShimlessRmaServiceTest, TransitionPreviousStateWithNoPrevStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -516,7 +516,7 @@ } TEST_F(ShimlessRmaServiceTest, CanCancelRma) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); fake_rmad_client_()->SetAbortable(true); @@ -530,7 +530,7 @@ } TEST_F(ShimlessRmaServiceTest, CannotCancelRma) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); fake_rmad_client_()->SetAbortable(false); @@ -544,7 +544,7 @@ } TEST_F(ShimlessRmaServiceTest, SetSameOwner) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kRestock, rmad::RMAD_ERROR_OK)}; @@ -575,7 +575,7 @@ } TEST_F(ShimlessRmaServiceTest, SetSameOwnerFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kRestock, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -598,7 +598,7 @@ } TEST_F(ShimlessRmaServiceTest, SetDifferentOwner) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kRestock, rmad::RMAD_ERROR_OK)}; @@ -629,7 +629,7 @@ } TEST_F(ShimlessRmaServiceTest, SetDifferentOwnerFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kRestock, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -651,7 +651,7 @@ } TEST_F(ShimlessRmaServiceTest, SetManuallyDisableWriteProtect) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kWpDisableMethod, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -685,7 +685,7 @@ TEST_F(ShimlessRmaServiceTest, SetManuallyDisableWriteProtectFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -709,7 +709,7 @@ } TEST_F(ShimlessRmaServiceTest, SetRsuDisableWriteProtect) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kWpDisableMethod, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -741,7 +741,7 @@ } TEST_F(ShimlessRmaServiceTest, SetRsuDisableWriteProtectFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -770,7 +770,7 @@ write_protect_disable_rsu_state.mutable_state() ->mutable_wp_disable_rsu() ->set_challenge_code("rsu write protect challenge code"); - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { write_protect_disable_rsu_state}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -796,7 +796,7 @@ write_protect_disable_rsu_state.mutable_state() ->mutable_wp_disable_rsu() ->set_hwid("rsu write protect hwid"); - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { write_protect_disable_rsu_state}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -822,7 +822,7 @@ write_protect_disable_rsu_state.mutable_state() ->mutable_wp_disable_rsu() ->set_challenge_url("https://challenge/url"); - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { write_protect_disable_rsu_state}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -874,7 +874,7 @@ } TEST_F(ShimlessRmaServiceTest, SetRsuDisableWriteProtectCode) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kWpDisableRsu, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -907,7 +907,7 @@ TEST_F(ShimlessRmaServiceTest, SetRsuDisableWriteProtectCodeFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -932,7 +932,7 @@ } TEST_F(ShimlessRmaServiceTest, WriteProtectManuallyDisabled) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kWpDisablePhysical, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, @@ -960,7 +960,7 @@ TEST_F(ShimlessRmaServiceTest, WriteProtectManuallyDisabledFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -984,7 +984,7 @@ } TEST_F(ShimlessRmaServiceTest, ConfirmManualWpDisableComplete) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kWpDisableComplete, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, @@ -1012,7 +1012,7 @@ TEST_F(ShimlessRmaServiceTest, ConfirmManualWpDisableCompleteFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -1055,7 +1055,7 @@ component->set_repair_status( rmad::ComponentsRepairState::ComponentRepairStatus:: RMAD_REPAIR_STATUS_REPLACED); - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { components_repair_state, CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -1089,7 +1089,7 @@ } TEST_F(ShimlessRmaServiceTest, GetComponentListFromWrongStateEmpty) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -1135,7 +1135,7 @@ components_repair_state.mutable_state() ->mutable_components_repair() ->set_mainboard_rework(true); - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { components_repair_state, CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -1188,7 +1188,7 @@ } TEST_F(ShimlessRmaServiceTest, SetComponentListFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -1238,7 +1238,7 @@ component->set_repair_status( rmad::ComponentsRepairState::ComponentRepairStatus:: RMAD_REPAIR_STATUS_ORIGINAL); - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { components_repair_state, CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -1268,7 +1268,7 @@ } // namespace shimless_rma TEST_F(ShimlessRmaServiceTest, ReworkMainboardFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -1291,7 +1291,7 @@ } TEST_F(ShimlessRmaServiceTest, ReimageRequiredTrue) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kUpdateRoFirmware, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -1319,7 +1319,7 @@ update_firmware_state.mutable_state() ->mutable_update_ro_firmware() ->set_optional(true); - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { update_firmware_state, CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -1342,7 +1342,7 @@ } TEST_F(ShimlessRmaServiceTest, ReimageRequiredFromWrongStateTrue) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -1368,7 +1368,7 @@ update_firmware_state.mutable_state() ->mutable_update_ro_firmware() ->set_optional(true); - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { update_firmware_state, CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -1400,7 +1400,7 @@ } TEST_F(ShimlessRmaServiceTest, ReimageSkippedWhenRequiredFails) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kUpdateRoFirmware, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -1425,7 +1425,7 @@ } TEST_F(ShimlessRmaServiceTest, ReimageSkippedFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -1446,7 +1446,7 @@ } TEST_F(ShimlessRmaServiceTest, ReimageFromDownload) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kUpdateRoFirmware, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -1478,7 +1478,7 @@ } TEST_F(ShimlessRmaServiceTest, ReimageFromDownloadFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -1501,7 +1501,7 @@ } TEST_F(ShimlessRmaServiceTest, ReimageFromUsb) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kUpdateRoFirmware, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -1534,7 +1534,7 @@ } TEST_F(ShimlessRmaServiceTest, ReimageFromUsbFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -1557,7 +1557,7 @@ } TEST_F(ShimlessRmaServiceTest, ShutdownForRestock) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kRestock, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -1588,7 +1588,7 @@ } TEST_F(ShimlessRmaServiceTest, ShutdownForRestockFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -1611,7 +1611,7 @@ } TEST_F(ShimlessRmaServiceTest, ContinueFinalizationAfterRestock) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kRestock, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -1644,7 +1644,7 @@ TEST_F(ShimlessRmaServiceTest, ContinueFinalizationAfterRestockFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -1676,7 +1676,7 @@ update_device_info_state.mutable_state() ->mutable_update_device_info() ->set_serial_number("serial number"); - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { update_device_info_state, CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -1699,7 +1699,7 @@ } TEST_F(ShimlessRmaServiceTest, GetOriginalSerialNumberFromWrongStateEmpty) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -1719,6 +1719,172 @@ run_loop.Run(); } +TEST_F(ShimlessRmaServiceTest, GetRegionList) { + rmad::GetStateReply update_device_info_state = + CreateStateReply(rmad::RmadState::kUpdateDeviceInfo, rmad::RMAD_ERROR_OK); + update_device_info_state.mutable_state() + ->mutable_update_device_info() + ->add_region_list("EMEA"); + update_device_info_state.mutable_state() + ->mutable_update_device_info() + ->add_region_list("AMER"); + const std::vector<rmad::GetStateReply> fake_states = { + update_device_info_state, + CreateStateReply(rmad::RmadState::kDeviceDestination, + rmad::RMAD_ERROR_OK)}; + fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); + base::RunLoop run_loop; + shimless_rma_provider_->GetCurrentState(base::BindLambdaForTesting( + [&](mojom::State state, bool can_cancel, bool can_go_back, + rmad::RmadErrorCode error) { + EXPECT_EQ(state, mojom::State::kUpdateDeviceInformation); + EXPECT_EQ(error, rmad::RmadErrorCode::RMAD_ERROR_OK); + })); + run_loop.RunUntilIdle(); + + shimless_rma_provider_->GetRegionList( + base::BindLambdaForTesting([&](const std::vector<std::string>& regions) { + EXPECT_EQ(regions.size(), 2UL); + EXPECT_EQ(regions[0], "EMEA"); + EXPECT_EQ(regions[1], "AMER"); + run_loop.Quit(); + })); + run_loop.Run(); +} + +TEST_F(ShimlessRmaServiceTest, GetRegionListWrongStateEmpty) { + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; + fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); + base::RunLoop run_loop; + shimless_rma_provider_->GetCurrentState(base::BindLambdaForTesting( + [&](mojom::State state, bool can_cancel, bool can_go_back, + rmad::RmadErrorCode error) { + EXPECT_EQ(state, mojom::State::kChooseDestination); + EXPECT_EQ(error, rmad::RmadErrorCode::RMAD_ERROR_OK); + })); + run_loop.RunUntilIdle(); + + shimless_rma_provider_->GetRegionList( + base::BindLambdaForTesting([&](const std::vector<std::string>& regions) { + EXPECT_EQ(regions.size(), 0UL); + run_loop.Quit(); + })); + run_loop.Run(); +} + +TEST_F(ShimlessRmaServiceTest, GetSkuList) { + rmad::GetStateReply update_device_info_state = + CreateStateReply(rmad::RmadState::kUpdateDeviceInfo, rmad::RMAD_ERROR_OK); + update_device_info_state.mutable_state() + ->mutable_update_device_info() + ->add_sku_list(1UL); + update_device_info_state.mutable_state() + ->mutable_update_device_info() + ->add_sku_list(7UL); + update_device_info_state.mutable_state() + ->mutable_update_device_info() + ->add_sku_list(2UL); + const std::vector<rmad::GetStateReply> fake_states = { + update_device_info_state, + CreateStateReply(rmad::RmadState::kDeviceDestination, + rmad::RMAD_ERROR_OK)}; + fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); + base::RunLoop run_loop; + shimless_rma_provider_->GetCurrentState(base::BindLambdaForTesting( + [&](mojom::State state, bool can_cancel, bool can_go_back, + rmad::RmadErrorCode error) { + EXPECT_EQ(state, mojom::State::kUpdateDeviceInformation); + EXPECT_EQ(error, rmad::RmadErrorCode::RMAD_ERROR_OK); + })); + run_loop.RunUntilIdle(); + + shimless_rma_provider_->GetSkuList( + base::BindLambdaForTesting([&](const std::vector<uint64_t>& skus) { + EXPECT_EQ(skus.size(), 3UL); + EXPECT_EQ(skus[0], 1UL); + EXPECT_EQ(skus[1], 7UL); + EXPECT_EQ(skus[2], 2UL); + run_loop.Quit(); + })); + run_loop.Run(); +} + +TEST_F(ShimlessRmaServiceTest, GetSkuListWrongStateEmpty) { + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; + fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); + base::RunLoop run_loop; + shimless_rma_provider_->GetCurrentState(base::BindLambdaForTesting( + [&](mojom::State state, bool can_cancel, bool can_go_back, + rmad::RmadErrorCode error) { + EXPECT_EQ(state, mojom::State::kChooseDestination); + EXPECT_EQ(error, rmad::RmadErrorCode::RMAD_ERROR_OK); + })); + run_loop.RunUntilIdle(); + + shimless_rma_provider_->GetSkuList( + base::BindLambdaForTesting([&](const std::vector<uint64_t>& skus) { + EXPECT_EQ(skus.size(), 0UL); + run_loop.Quit(); + })); + run_loop.Run(); +} + +TEST_F(ShimlessRmaServiceTest, GetWhiteLabelList) { + rmad::GetStateReply update_device_info_state = + CreateStateReply(rmad::RmadState::kUpdateDeviceInfo, rmad::RMAD_ERROR_OK); + update_device_info_state.mutable_state() + ->mutable_update_device_info() + ->add_whitelabel_list("White-label 1"); + update_device_info_state.mutable_state() + ->mutable_update_device_info() + ->add_whitelabel_list("White-label 5"); + const std::vector<rmad::GetStateReply> fake_states = { + update_device_info_state, + CreateStateReply(rmad::RmadState::kDeviceDestination, + rmad::RMAD_ERROR_OK)}; + fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); + base::RunLoop run_loop; + shimless_rma_provider_->GetCurrentState(base::BindLambdaForTesting( + [&](mojom::State state, bool can_cancel, bool can_go_back, + rmad::RmadErrorCode error) { + EXPECT_EQ(state, mojom::State::kUpdateDeviceInformation); + EXPECT_EQ(error, rmad::RmadErrorCode::RMAD_ERROR_OK); + })); + run_loop.RunUntilIdle(); + + shimless_rma_provider_->GetWhiteLabelList(base::BindLambdaForTesting( + [&](const std::vector<std::string>& whiteLabels) { + EXPECT_EQ(whiteLabels.size(), 2UL); + EXPECT_EQ(whiteLabels[0], "White-label 1"); + EXPECT_EQ(whiteLabels[1], "White-label 5"); + run_loop.Quit(); + })); + run_loop.Run(); +} + +TEST_F(ShimlessRmaServiceTest, GetWhiteLabelListWrongStateEmpty) { + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; + fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); + base::RunLoop run_loop; + shimless_rma_provider_->GetCurrentState(base::BindLambdaForTesting( + [&](mojom::State state, bool can_cancel, bool can_go_back, + rmad::RmadErrorCode error) { + EXPECT_EQ(state, mojom::State::kChooseDestination); + EXPECT_EQ(error, rmad::RmadErrorCode::RMAD_ERROR_OK); + })); + run_loop.RunUntilIdle(); + + shimless_rma_provider_->GetWhiteLabelList(base::BindLambdaForTesting( + [&](const std::vector<std::string>& whiteLabels) { + EXPECT_EQ(whiteLabels.size(), 0UL); + run_loop.Quit(); + })); + run_loop.Run(); +} + TEST_F(ShimlessRmaServiceTest, GetOriginalRegion) { rmad::GetStateReply update_device_info_state = CreateStateReply(rmad::RmadState::kUpdateDeviceInfo, rmad::RMAD_ERROR_OK); @@ -1728,7 +1894,7 @@ update_device_info_state.mutable_state() ->mutable_update_device_info() ->set_region_index(1); - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { update_device_info_state, CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -1751,7 +1917,7 @@ } TEST_F(ShimlessRmaServiceTest, GetOriginalRegionFromWrongStateEmpty) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -1780,7 +1946,7 @@ update_device_info_state.mutable_state() ->mutable_update_device_info() ->set_sku_index(2); - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { update_device_info_state, CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -1802,8 +1968,60 @@ run_loop.Run(); } +TEST_F(ShimlessRmaServiceTest, GetOriginalWhiteLabel) { + rmad::GetStateReply update_device_info_state = + CreateStateReply(rmad::RmadState::kUpdateDeviceInfo, rmad::RMAD_ERROR_OK); + update_device_info_state.mutable_state() + ->mutable_update_device_info() + ->set_original_whitelabel_index(3); + update_device_info_state.mutable_state() + ->mutable_update_device_info() + ->set_whitelabel_index(1); + const std::vector<rmad::GetStateReply> fake_states = { + update_device_info_state, + CreateStateReply(rmad::RmadState::kDeviceDestination, + rmad::RMAD_ERROR_OK)}; + fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); + base::RunLoop run_loop; + shimless_rma_provider_->GetCurrentState(base::BindLambdaForTesting( + [&](mojom::State state, bool can_cancel, bool can_go_back, + rmad::RmadErrorCode error) { + EXPECT_EQ(state, mojom::State::kUpdateDeviceInformation); + EXPECT_EQ(error, rmad::RmadErrorCode::RMAD_ERROR_OK); + })); + run_loop.RunUntilIdle(); + + shimless_rma_provider_->GetOriginalWhiteLabel( + base::BindLambdaForTesting([&](uint8_t whiteLabel) { + EXPECT_EQ(3, whiteLabel); + run_loop.Quit(); + })); + run_loop.Run(); +} + +TEST_F(ShimlessRmaServiceTest, GetOriginalWhiteLabelFromWrongStateEmpty) { + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; + fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); + base::RunLoop run_loop; + shimless_rma_provider_->GetCurrentState(base::BindLambdaForTesting( + [&](mojom::State state, bool can_cancel, bool can_go_back, + rmad::RmadErrorCode error) { + EXPECT_EQ(state, mojom::State::kChooseDestination); + EXPECT_EQ(error, rmad::RmadErrorCode::RMAD_ERROR_OK); + })); + run_loop.RunUntilIdle(); + + shimless_rma_provider_->GetOriginalWhiteLabel( + base::BindLambdaForTesting([&](uint8_t whiteLabel) { + EXPECT_EQ(0, whiteLabel); + run_loop.Quit(); + })); + run_loop.Run(); +} + TEST_F(ShimlessRmaServiceTest, GetOriginalSkuFromWrongStateEmpty) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -1824,7 +2042,7 @@ } TEST_F(ShimlessRmaServiceTest, SetDeviceInformation) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kUpdateDeviceInfo, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -1858,7 +2076,7 @@ } TEST_F(ShimlessRmaServiceTest, SetDeviceInformationFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -1894,7 +2112,7 @@ component->set_status( rmad::CalibrationComponentStatus::RMAD_CALIBRATION_IN_PROGRESS); component->set_progress(0.5); - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { check_calibration_state, CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -1921,7 +2139,7 @@ } TEST_F(ShimlessRmaServiceTest, GetCalibrationComponentListWrongStateEmpty) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -1950,7 +2168,7 @@ ->set_instruction( rmad::CalibrationSetupInstruction:: RMAD_CALIBRATION_INSTRUCTION_PLACE_BASE_ON_FLAT_SURFACE); - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { setup_calibration_state, CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -1978,7 +2196,7 @@ TEST_F(ShimlessRmaServiceTest, GetCalibrationSetupInstructionsWrongStateNoInstructions) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -2001,7 +2219,7 @@ } TEST_F(ShimlessRmaServiceTest, StartCalibration) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kCheckCalibration, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -2055,7 +2273,7 @@ } TEST_F(ShimlessRmaServiceTest, StartCalibrationFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); fake_rmad_client_()->check_state_callback = @@ -2090,7 +2308,7 @@ } TEST_F(ShimlessRmaServiceTest, RunCalibrationStep) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kSetupCalibration, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -2115,7 +2333,7 @@ } TEST_F(ShimlessRmaServiceTest, RunCalibrationStepFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -2137,7 +2355,7 @@ run_loop.Run(); } TEST_F(ShimlessRmaServiceTest, ContinueCalibration) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kRunCalibration, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -2162,7 +2380,7 @@ } TEST_F(ShimlessRmaServiceTest, ContinueCalibrationFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -2185,7 +2403,7 @@ } TEST_F(ShimlessRmaServiceTest, CalibrationComplete) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kRunCalibration, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -2210,7 +2428,7 @@ } TEST_F(ShimlessRmaServiceTest, CalibrationCompleteFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -2233,7 +2451,7 @@ } TEST_F(ShimlessRmaServiceTest, ProvisioningComplete) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kProvisionDevice, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -2258,7 +2476,7 @@ } TEST_F(ShimlessRmaServiceTest, ProvisioningCompleteFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -2281,7 +2499,7 @@ } TEST_F(ShimlessRmaServiceTest, kFinalize) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kFinalize, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -2306,7 +2524,7 @@ } TEST_F(ShimlessRmaServiceTest, FinalizationCompleteFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -2329,7 +2547,7 @@ } TEST_F(ShimlessRmaServiceTest, WriteProtectManuallyEnabled) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kWpEnablePhysical, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -2355,7 +2573,7 @@ } TEST_F(ShimlessRmaServiceTest, WriteProtectManuallyEnabledFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -2379,7 +2597,7 @@ } TEST_F(ShimlessRmaServiceTest, GetLog) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kRepairComplete, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -2397,7 +2615,7 @@ } TEST_F(ShimlessRmaServiceTest, GetLogWrongStateEmpty) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -2415,7 +2633,7 @@ } TEST_F(ShimlessRmaServiceTest, EndRmaAndReboot) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kRepairComplete, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -2446,7 +2664,7 @@ } TEST_F(ShimlessRmaServiceTest, EndRmaAndRebootFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -2469,7 +2687,7 @@ } TEST_F(ShimlessRmaServiceTest, EndRmaAndShutdown) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kRepairComplete, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -2500,7 +2718,7 @@ } TEST_F(ShimlessRmaServiceTest, EndRmaAndShutdownFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop; @@ -2523,7 +2741,7 @@ } TEST_F(ShimlessRmaServiceTest, EndRmaAndCutoffBattery) { - std::vector<rmad::GetStateReply> fake_states = { + const std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kRepairComplete, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; @@ -2555,7 +2773,7 @@ } TEST_F(ShimlessRmaServiceTest, EndRmaAndCutoffBatteryFromWrongStateFails) { - std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( + const std::vector<rmad::GetStateReply> fake_states = {CreateStateReply( rmad::RmadState::kDeviceDestination, rmad::RMAD_ERROR_OK)}; fake_rmad_client_()->SetFakeStateReplies(std::move(fake_states)); base::RunLoop run_loop;
diff --git a/ash/webui/shimless_rma/mojom/shimless_rma.mojom b/ash/webui/shimless_rma/mojom/shimless_rma.mojom index 3be9062..ac64088 100644 --- a/ash/webui/shimless_rma/mojom/shimless_rma.mojom +++ b/ash/webui/shimless_rma/mojom/shimless_rma.mojom
@@ -575,13 +575,17 @@ // Get the list of OEM regions for this device. GetRegionList() => (array<string> regions); // Get the list of OEM SKUs for this device. - GetSkuList() => (array<string> skus); + GetSkuList() => (array<uint64> skus); + // Get the list of valid white-labels for this device. + GetWhiteLabelList() => (array<string> whiteLabels); // Get the device serial number at RMA start. GetOriginalSerialNumber() => (string serial_number); // Get the device region index at RMA start. GetOriginalRegion() => (uint8 region_index); // Get the device SKU index at RMA start. GetOriginalSku() => (uint8 sku_index); + // Get the device white-label index at RMA start. + GetOriginalWhiteLabel() => (uint8 whiteLabel_index); // Attempt to set device info and transition to the next state. // Returns the next state to display and an error code. SetDeviceInformation(
diff --git a/ash/webui/shimless_rma/resources/BUILD.gn b/ash/webui/shimless_rma/resources/BUILD.gn index 49bb48c4..f9eeec9 100644 --- a/ash/webui/shimless_rma/resources/BUILD.gn +++ b/ash/webui/shimless_rma/resources/BUILD.gn
@@ -19,6 +19,7 @@ "base_page.js", "calibration_component_chip.js", "icons.js", + "critical_error_page.js", "onboarding_choose_destination_page.js", "onboarding_choose_wp_disable_method_page.js", "onboarding_enter_rsu_wp_disable_code_page.js", @@ -75,6 +76,7 @@ deps = [ ":base_page", ":calibration_component_chip", + ":critical_error_page", ":fake_shimless_rma_service", ":mojo_interface_provider", ":onboarding_choose_destination_page", @@ -105,6 +107,7 @@ js_library("shimless_rma") { deps = [ + ":critical_error_page", ":mojo_interface_provider", ":onboarding_choose_destination_page", ":onboarding_choose_wp_disable_method_page", @@ -144,6 +147,16 @@ ] } +js_library("critical_error_page") { + deps = [ + ":base_page", + ":mojo_interface_provider", + ":shimless_rma_types", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/js:i18n_behavior.m", + ] +} + js_library("data") { deps = [ ":shimless_rma_types",
diff --git a/ash/webui/shimless_rma/resources/critical_error_page.html b/ash/webui/shimless_rma/resources/critical_error_page.html new file mode 100644 index 0000000..ac68857 --- /dev/null +++ b/ash/webui/shimless_rma/resources/critical_error_page.html
@@ -0,0 +1,31 @@ +<style include="cr-shared-style shimless-rma-shared"> + .large-icon { + height: 200px; + width: 300px; + } + + .small-icon { + height: 20px; + width: 20px; + } +</style> +<base-page orientation="column"> + <div slot="header"> + <h1>[[i18n('criticalErrorTitleText')]]</h1> + <div id="writeProtectStatus">[[statusString_]]</div> + <cr-button id="exitToLoginButton" on-click="onExitToLoginButtonClicked_"> + [[i18n('criticalErrorExitToLoginText')]] + </cr-button> + <cr-button id="performUpdateButton" on-click="onRebootButtonClicked_"> + [[i18n('criticalErrorRebootText')]] + <iron-icon id="restartIcon" icon="shimless-icon:update" + class="small-icon"> + </iron-icon> + </cr-button> + </div> + <div slot="body"> + <!-- TODO(gavindodd): Replace with correct graphic --> + <iron-icon icon="shimless:shimless-placeholder" class="large-icon"> + </iron-icon> + </div> +</base-page>
diff --git a/ash/webui/shimless_rma/resources/critical_error_page.js b/ash/webui/shimless_rma/resources/critical_error_page.js new file mode 100644 index 0000000..dabe91fa6 --- /dev/null +++ b/ash/webui/shimless_rma/resources/critical_error_page.js
@@ -0,0 +1,56 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import './base_page.js'; +import './shimless_rma_shared_css.js'; +import 'chrome://resources/cr_elements/cr_dialog/cr_dialog.m.js'; +import 'chrome://resources/cr_elements/cr_button/cr_button.m.js'; + +import {I18nBehavior, I18nBehaviorInterface} from 'chrome://resources/js/i18n_behavior.m.js'; +import {html, mixinBehaviors, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + +import {getShimlessRmaService} from './mojo_interface_provider.js'; +import {ShimlessRmaServiceInterface} from './shimless_rma_types.js'; + +/** + * @fileoverview + * 'critical-error-page' is displayed when an unexpected error blocks RMA from + * continuing. + */ + +/** + * @constructor + * @extends {PolymerElement} + * @implements {I18nBehaviorInterface} + */ +const CriticalErrorPageBase = mixinBehaviors([I18nBehavior], PolymerElement); + +/** @polymer */ +export class CriticalErrorPage extends CriticalErrorPageBase { + static get is() { + return 'critical-error-page'; + } + + static get template() { + return html`{__html_template__}`; + } + + constructor() { + super(); + /** @private {ShimlessRmaServiceInterface} */ + this.shimlessRmaService_ = getShimlessRmaService(); + } + + /** @protected */ + onExitToLoginButtonClicked_() { + this.shimlessRmaService_.criticalErrorExitToLogin(); + } + + /** @protected */ + onRebootButtonClicked_() { + this.shimlessRmaService_.criticalErrorReboot(); + } +} + +customElements.define(CriticalErrorPage.is, CriticalErrorPage);
diff --git a/ash/webui/shimless_rma/resources/fake_data.js b/ash/webui/shimless_rma/resources/fake_data.js index f114d9a..57d380cf 100644 --- a/ash/webui/shimless_rma/resources/fake_data.js +++ b/ash/webui/shimless_rma/resources/fake_data.js
@@ -195,9 +195,12 @@ /** @type {!Array<string>} */ export const fakeDeviceRegions = ['EMEA', 'APAC', 'AMER']; -/** @type {!Array<string>} */ -export const fakeDeviceSkus = ['SKU 1', 'SKU 2', 'SKU 3']; +/** @type {!Array<bigint>} */ +export const fakeDeviceSkus = [1, 2, 3]; +/** @type {!Array<string>} */ +export const fakeDeviceWhiteLabels = + ['White-label 1', 'White-label 2', 'White-label 3']; /** @type {string} */ export const fakeLog =
diff --git a/ash/webui/shimless_rma/resources/fake_shimless_rma_service.js b/ash/webui/shimless_rma/resources/fake_shimless_rma_service.js index 0b68b86..21ed3c9 100644 --- a/ash/webui/shimless_rma/resources/fake_shimless_rma_service.js +++ b/ash/webui/shimless_rma/resources/fake_shimless_rma_service.js
@@ -503,20 +503,34 @@ } /** - * @return {!Promise<!{skus: !Array<string>}>} + * @return {!Promise<!{skus: !Array<bigint>}>} */ getSkuList() { return this.methods_.resolveMethod('getSkuList'); } /** - * @param {!Array<string>} skus + * @param {!Array<bigint>} skus */ setGetSkuListResult(skus) { this.methods_.setResult('getSkuList', {skus: skus}); } /** + * @return {!Promise<!{whiteLabels: !Array<string>}>} + */ + getWhiteLabelList() { + return this.methods_.resolveMethod('getWhiteLabelList'); + } + + /** + * @param {!Array<string>} whiteLabels + */ + setGetWhiteLabelListResult(whiteLabels) { + this.methods_.setResult('getWhiteLabelList', {whiteLabels: whiteLabels}); + } + + /** * @return {!Promise<!{serialNumber: string}>} */ getOriginalSerialNumber() { @@ -560,6 +574,21 @@ } /** + * @return {!Promise<!{whiteLabelIndex: number}>} + */ + getOriginalWhiteLabel() { + return this.methods_.resolveMethod('getOriginalWhiteLabel'); + } + + /** + * @param {number} whiteLabelIndex + */ + setGetOriginalWhiteLabelResult(whiteLabelIndex) { + this.methods_.setResult( + 'getOriginalWhiteLabel', {whiteLabelIndex: whiteLabelIndex}); + } + + /** * @param {string} serialNumber * @param {number} regionIndex * @param {number} skuIndex @@ -1166,9 +1195,11 @@ this.methods_.register('getRegionList'); this.methods_.register('getSkuList'); + this.methods_.register('getWhiteLabelList'); this.methods_.register('getOriginalSerialNumber'); this.methods_.register('getOriginalRegion'); this.methods_.register('getOriginalSku'); + this.methods_.register('getOriginalWhiteLabel'); this.methods_.register('setDeviceInformation'); this.methods_.register('getCalibrationComponentList');
diff --git a/ash/webui/shimless_rma/resources/mojo_interface_provider.js b/ash/webui/shimless_rma/resources/mojo_interface_provider.js index 66a5218b..2d46816 100644 --- a/ash/webui/shimless_rma/resources/mojo_interface_provider.js +++ b/ash/webui/shimless_rma/resources/mojo_interface_provider.js
@@ -4,7 +4,7 @@ import {assert} from 'chrome://resources/js/assert.m.js'; -import {fakeCalibrationComponents, fakeChromeVersion, fakeComponents, fakeDeviceRegions, fakeDeviceSkus, fakeLog, fakeRsuChallengeCode, fakeRsuChallengeQrCode, fakeStates} from './fake_data.js'; +import {fakeCalibrationComponents, fakeChromeVersion, fakeComponents, fakeDeviceRegions, fakeDeviceSkus, fakeDeviceWhiteLabels, fakeLog, fakeRsuChallengeCode, fakeRsuChallengeQrCode, fakeStates} from './fake_data.js'; import {FakeShimlessRmaService} from './fake_shimless_rma_service.js'; import {CalibrationSetupInstruction, NetworkConfigServiceInterface, RmadErrorCode, ShimlessRmaService, ShimlessRmaServiceInterface, WriteProtectDisableCompleteState} from './shimless_rma_types.js'; @@ -72,6 +72,8 @@ service.setGetOriginalRegionResult(1); service.setGetSkuListResult(fakeDeviceSkus); service.setGetOriginalSkuResult(1); + service.setGetWhiteLabelListResult(fakeDeviceWhiteLabels); + service.setGetOriginalWhiteLabelResult(1); service.setGetCalibrationSetupInstructionsResult( CalibrationSetupInstruction.kCalibrationInstructionPlaceLidOnFlatSurface);
diff --git a/ash/webui/shimless_rma/resources/shimless_rma.js b/ash/webui/shimless_rma/resources/shimless_rma.js index 47113f4..7686851 100644 --- a/ash/webui/shimless_rma/resources/shimless_rma.js +++ b/ash/webui/shimless_rma/resources/shimless_rma.js
@@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import './critical_error_page.js'; import './onboarding_choose_destination_page.js'; import './onboarding_choose_wp_disable_method_page.js'; import './onboarding_enter_rsu_wp_disable_code_page.js'; @@ -58,8 +59,9 @@ * @type {!Object<!State, !PageInfo>} */ const StateComponentMapping = { + // It is assumed that if state is kUnknown the error is kRmaNotRequired. [State.kUnknown]: { - componentIs: 'badcomponent', + componentIs: 'critical-error-page', requiresReloadWhenShown: false, buttonNext: ButtonState.HIDDEN, buttonCancel: ButtonState.HIDDEN, @@ -364,23 +366,34 @@ * @param {!StateResult} stateResult */ processStateResult_(stateResult) { - this.handleError_(stateResult.error); + // Do not show the state screen if the critical error screen was shown. + if (this.handleStandardAndCriticalError_(stateResult.error)) { + return; + } this.showState_( stateResult.state, stateResult.canCancel, stateResult.canGoBack); } /** @param {!RmadErrorCode} error */ onError(error) { - this.handleError_(error); + this.handleStandardAndCriticalError_(error); } /** * @private * @param {!RmadErrorCode} error + * @return {boolean} + * Returns true if the critical error screen was displayed. */ - handleError_(error) { + handleStandardAndCriticalError_(error) { + // Critical error - expected to be in RMA. + if (error === RmadErrorCode.kRmaNotRequired) { + this.showState_(State.kUnknown, false, false); + return true; + } // TODO(gavindodd): Handle error appropriately this.errorMessage_ = rmadErrorString(error); + return false; } /** @@ -507,7 +520,7 @@ onCancelButtonClicked_() { this.allButtonsDisabled_ = true; this.shimlessRmaService_.abortRma().then( - (result) => this.handleError_(result.error)); + (result) => this.handleStandardAndCriticalError_(result.error)); } /**
diff --git a/ash/webui/shimless_rma/shimless_rma.cc b/ash/webui/shimless_rma/shimless_rma.cc index 29f293e..82ddb0f6 100644 --- a/ash/webui/shimless_rma/shimless_rma.cc +++ b/ash/webui/shimless_rma/shimless_rma.cc
@@ -289,6 +289,12 @@ {"onboardingUpdateDisabled", IDS_SHIMLESS_RMA_ONBOARDING_UPDATE_DISABLED}, {"onboardingUpdatePermission", IDS_SHIMLESS_RMA_ONBOARDING_UPDATE_PERMISSION}, + // Critical error + {"criticalErrorTitleText", IDS_SHIMLESS_RMA_CRITICAL_ERROR_TITLE}, + {"criticalErrorMessageText", IDS_SHIMLESS_RMA_CRITICAL_ERROR_MESSAGE}, + {"criticalErrorExitToLoginText", + IDS_SHIMLESS_RMA_CRITICAL_EXIT_TO_LOGIN_BUTTON}, + {"criticalErrorRebootText", IDS_SHIMLESS_RMA_CRITICAL_REBOOT_BUTTON}, }; html_source->AddLocalizedStrings(kLocalizedStrings);
diff --git a/ash/wm/desks/templates/desks_templates_grid_view.cc b/ash/wm/desks/templates/desks_templates_grid_view.cc index 51aea55..31965a1 100644 --- a/ash/wm/desks/templates/desks_templates_grid_view.cc +++ b/ash/wm/desks/templates/desks_templates_grid_view.cc
@@ -71,7 +71,7 @@ views::Widget::InitParams params( views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); - params.activatable = views::Widget::InitParams::Activatable::kNo; + params.activatable = views::Widget::InitParams::Activatable::kYes; params.accept_events = true; // The parent should be a container that covers all the windows but is below // some other system UI features such as system tray and capture mode and also @@ -88,6 +88,8 @@ // Not opaque since we want to view the contents of the layer behind. widget->GetLayer()->SetFillsBoundsOpaquely(false); + widget->GetNativeWindow()->SetId(kShellWindowId_DesksTemplatesGridWindow); + return widget; } @@ -185,8 +187,6 @@ : event->root_location(); for (DesksTemplatesItemView* grid_item : grid_items_) grid_item->UpdateHoverButtonsVisibility(screen_location, is_touch); - - event->SetHandled(); return; } default:
diff --git a/ash/wm/desks/templates/desks_templates_item_view.cc b/ash/wm/desks/templates/desks_templates_item_view.cc index 168d084..f15ab17 100644 --- a/ash/wm/desks/templates/desks_templates_item_view.cc +++ b/ash/wm/desks/templates/desks_templates_item_view.cc
@@ -32,6 +32,7 @@ #include "ui/views/controls/highlight_path_generator.h" #include "ui/views/controls/label.h" #include "ui/views/layout/box_layout_view.h" +#include "ui/views/view_targeter_delegate.h" namespace ash { namespace { @@ -149,6 +150,8 @@ focus_ring->SetPathGenerator( std::make_unique<views::RoundRectHighlightPathGenerator>( gfx::Insets(-kFocusRingOffset), kCornerRadius + kFocusRingOffset)); + + SetEventTargeter(std::make_unique<views::ViewTargeter>(this)); } DesksTemplatesItemView::~DesksTemplatesItemView() = default; @@ -204,6 +207,18 @@ AshColorProvider::ControlsLayerType::kFocusRingColor)); } +views::View* DesksTemplatesItemView::TargetForRect(views::View* root, + const gfx::Rect& rect) { + // With the design of the template card having the textfield within a + // clickable button, as well as having the grid view be a `PreTargetHandler`, + // we needed to make `this` a `ViewTargeterDelegate` for the view event + // targeter in order to allow the `name_view_` to be specifically targeted and + // focused. + if (root == this && name_view_->bounds().Contains(rect)) + return name_view_; + return views::ViewTargeterDelegate::TargetForRect(root, rect); +} + void DesksTemplatesItemView::OnDeleteTemplate() { // Notify the highlight controller that we're going away. OverviewSession* overview_session =
diff --git a/ash/wm/desks/templates/desks_templates_item_view.h b/ash/wm/desks/templates/desks_templates_item_view.h index 36dcd3f..7a8d36c1 100644 --- a/ash/wm/desks/templates/desks_templates_item_view.h +++ b/ash/wm/desks/templates/desks_templates_item_view.h
@@ -10,6 +10,7 @@ #include "base/guid.h" #include "ui/base/metadata/metadata_header_macros.h" #include "ui/views/controls/button/button.h" +#include "ui/views/view_targeter_delegate.h" namespace views { class Label; @@ -26,6 +27,7 @@ // A view that represents each individual template item in the desks templates // grid. class ASH_EXPORT DesksTemplatesItemView : public views::Button, + public views::ViewTargeterDelegate, public OverviewHighlightableView { public: METADATA_HEADER(DesksTemplatesItemView); @@ -44,6 +46,9 @@ void Layout() override; void OnThemeChanged() override; + // views::ViewTargeterDelegate + views::View* TargetForRect(views::View* root, const gfx::Rect& rect) override; + private: friend class DesksTemplatesItemViewTestApi;
diff --git a/ash/wm/overview/overview_grid.cc b/ash/wm/overview/overview_grid.cc index ab89b52..b041cd45 100644 --- a/ash/wm/overview/overview_grid.cc +++ b/ash/wm/overview/overview_grid.cc
@@ -851,15 +851,6 @@ return false; } -void OverviewGrid::OnUserWorkAreaInsetsChanged(aura::Window* root_window) { - DCHECK_EQ(root_window, root_window_); - if (!desks_widget_) - return; - - SetBoundsAndUpdatePositions(GetGridBoundsInScreen(root_window_), - /*ignored_items=*/{}, /*animate=*/false); -} - void OverviewGrid::UpdateDropTargetBackgroundVisibility( OverviewItem* dragged_item, const gfx::PointF& location_in_screen) { @@ -879,158 +870,6 @@ overview_mode_item->OnSelectorItemDragStarted(item); } -void OverviewGrid::ShowDesksTemplatesGrid(bool was_zero_state) { - if (!desks_templates_grid_widget_) { - desks_templates_grid_widget_ = - DesksTemplatesGridView::CreateDesksTemplatesGridWidget(root_window_); - } - - // Before showing the grid, we need to hide the overview items. However, we - // don't want to affect the desk preview. To do this, we temporarily set a - // window property that will keep them visible. - if (DeskMiniView* desk_mini_view = desks_bar_view_->FindMiniViewForDesk( - DesksController::Get()->GetTargetActiveDesk())) { - std::vector<aura::Window*> updated_windows; - SetForceVisibleInMiniView(desk_mini_view->GetDeskContainer(), - &updated_windows); - - // This makes the desk preview pick up on the window property change. - desk_mini_view->desk_preview()->RecreateDeskContentsMirrorLayers(); - - // Remove the property that was temporarily applied. - for (aura::Window* window : updated_windows) - window->ClearProperty(kForceVisibleInMiniViewKey); - } - - // We can now hide the overview mode items. - for (auto& overview_mode_item : window_list_) - overview_mode_item->HideForDesksTemplatesGrid(); - - desks_templates_grid_widget_->Show(); - - if (was_zero_state) { - desks_bar_view_->UpdateNewMiniViews(/*initializing_bar_view=*/false, - /*expanded_desks_bar_button=*/true); - } - desks_bar_view_->UpdateButtonsForDesksTemplatesGrid(); -} - -void OverviewGrid::HideDesksTemplatesGrid(bool exit_overview) { - // Un-hide the overview mode items. - for (auto& overview_mode_item : window_list_) - overview_mode_item->RevertHideForDesksTemplatesGrid(); - - if (exit_overview) { - desks_templates_grid_widget_->CloseNow(); - return; - } - - desks_templates_grid_widget_->Hide(); - desks_bar_view_->UpdateButtonsForDesksTemplatesGrid(); - desks_bar_view_->OnDesksTemplatesGridHidden(); -} - -bool OverviewGrid::IsShowingDesksTemplatesGrid() const { - return desks_templates_grid_widget_ && - desks_templates_grid_widget_->IsVisible(); -} - -void OverviewGrid::UpdateNoWindowsWidget(bool no_items) { - // Hide the widget if there is an item in overview or the desk templates grid - // is visible. - if (!no_items || IsShowingDesksTemplatesGrid()) { - no_windows_widget_.reset(); - return; - } - - if (!no_windows_widget_) { - // Create and fade in the widget. - RoundedLabelWidget::InitParams params; - params.name = "OverviewNoWindowsLabel"; - params.horizontal_padding = kNoItemsIndicatorHorizontalPaddingDp; - params.vertical_padding = kNoItemsIndicatorVerticalPaddingDp; - params.rounding_dp = kNoItemsIndicatorRoundingDp; - auto* color_provider = AshColorProvider::Get(); - params.background_color = color_provider->GetBaseLayerColor( - AshColorProvider::BaseLayerType::kTransparent80); - params.foreground_color = color_provider->GetContentLayerColor( - AshColorProvider::ContentLayerType::kTextColorPrimary); - params.preferred_height = kNoItemsIndicatorHeightDp; - params.message_id = IDS_ASH_OVERVIEW_NO_RECENT_ITEMS; - params.parent = - root_window_->GetChildById(desks_util::GetActiveDeskContainerId()); - params.hide_in_mini_view = true; - no_windows_widget_ = std::make_unique<RoundedLabelWidget>(); - no_windows_widget_->Init(std::move(params)); - - aura::Window* widget_window = no_windows_widget_->GetNativeWindow(); - widget_window->parent()->StackChildAtBottom(widget_window); - ScopedOverviewAnimationSettings settings(OVERVIEW_ANIMATION_NO_RECENTS_FADE, - widget_window); - no_windows_widget_->SetOpacity(1.f); - } - - RefreshNoWindowsWidgetBounds(/*animate=*/false); -} - -void OverviewGrid::RefreshNoWindowsWidgetBounds(bool animate) { - if (!no_windows_widget_) - return; - - no_windows_widget_->SetBoundsCenteredIn(GetGridEffectiveBounds(), animate); -} - -void OverviewGrid::UpdateSaveDeskAsTemplateButton() { - if (!desks_templates_util::AreDesksTemplatesEnabled()) - return; - - // Do not create or show the save desk as template button if there are no - // windows in this grid, during a window drag or in tablet mode, or the desks - // templates grid is visible. - const bool visible = - !window_list_.empty() && - !overview_session_->GetCurrentDraggedOverviewItem() && - !Shell::Get()->tablet_mode_controller()->InTabletMode() && - !IsShowingDesksTemplatesGrid(); - - if (!visible) { - if (save_desk_as_template_widget_) - save_desk_as_template_widget_->Hide(); - return; - } - - if (!save_desk_as_template_widget_) { - save_desk_as_template_widget_ = SaveDeskAsTemplateWidget(root_window_); - save_desk_as_template_widget_->SetContentsView(std::make_unique<PillButton>( - base::BindRepeating(&OverviewGrid::OnSaveDeskAsTemplateButtonPressed, - base::Unretained(this)), - l10n_util::GetStringUTF16( - IDS_ASH_DESKS_TEMPLATES_SAVE_DESK_AS_TEMPLATE_BUTTON), - PillButton::Type::kIcon, &kSaveDeskAsTemplateIcon)); - } - save_desk_as_template_widget_->Show(); - - // Disable the create templates button if the current number of templates has - // reached the max. - auto* presenter = DesksTemplatesPresenter::Get(); - if (presenter->GetEntryCount() >= presenter->GetMaxEntryCount()) { - auto* button = static_cast<PillButton*>( - save_desk_as_template_widget_->GetContentsView()); - button->SetState(views::Button::STATE_DISABLED); - } - - // Set the widget position above the overview item window and default width - // and height. - // TODO: Reposition Desks Templates bounds for tablet mode. - const gfx::RectF overview_item_bounds = window_list_.front()->target_bounds(); - const gfx::Size preferred_size = - save_desk_as_template_widget_->GetContentsView()->GetPreferredSize(); - save_desk_as_template_widget_->SetBounds(gfx::Rect( - overview_item_bounds.x(), - overview_item_bounds.y() - kSaveDeskAsTemplateOverviewItemSpacingDp, - preferred_size.width(), preferred_size.height())); -} - void OverviewGrid::OnSelectorItemDragEnded(bool snap) { for (auto& overview_mode_item : window_list_) overview_mode_item->OnSelectorItemDragEnded(snap); @@ -1188,79 +1027,13 @@ /*ignored_items=*/{}, /*animate=*/false); } -void OverviewGrid::OnSplitViewStateChanged( - SplitViewController::State previous_state, - SplitViewController::State state) { - // Do nothing if overview is being shutdown. - OverviewController* overview_controller = Shell::Get()->overview_controller(); - if (!overview_controller->InOverviewSession()) +void OverviewGrid::OnUserWorkAreaInsetsChanged(aura::Window* root_window) { + DCHECK_EQ(root_window, root_window_); + if (!desks_widget_) return; - SplitViewController* split_view_controller = - SplitViewController::Get(root_window_); - const bool unsnappable_window_activated = - state == SplitViewController::State::kNoSnap && - split_view_controller->end_reason() == - SplitViewController::EndReason::kUnsnappableWindowActivated; - - // If two windows were snapped to both sides of the screen or an unsnappable - // window was just activated, or we're in single split mode in clamshell mode - // and there is no window in overview, end overview mode and bail out. - if (state == SplitViewController::State::kBothSnapped || - unsnappable_window_activated || - (split_view_controller->InClamshellSplitViewMode() && - overview_session_->IsEmpty())) { - overview_session_->RestoreWindowActivation(false); - overview_controller->EndOverview(OverviewEndAction::kSplitView); - return; - } - - // Update the cannot snap warnings and adjust the grid bounds. - UpdateCannotSnapWarningVisibility(); SetBoundsAndUpdatePositions(GetGridBoundsInScreen(root_window_), /*ignored_items=*/{}, /*animate=*/false); - - // If split view mode was ended, then activate the overview focus window, to - // match the behavior of entering overview mode in the beginning. - if (state == SplitViewController::State::kNoSnap) - wm::ActivateWindow(overview_session_->GetOverviewFocusWindow()); -} - -void OverviewGrid::OnSplitViewDividerPositionChanged() { - SetBoundsAndUpdatePositions( - GetGridBoundsInScreen(root_window_, - /*window_dragging_state=*/absl::nullopt, - /*divider_changed=*/true, - /*account_for_hotseat=*/true), - /*ignored_items=*/{}, /*animate=*/false); -} - -void OverviewGrid::OnScreenCopiedBeforeRotation() { - Shell::Get()->overview_controller()->PauseOcclusionTracker(); - - for (auto& window : window_list()) { - window->set_disable_mask(true); - window->UpdateRoundedCornersAndShadow(); - window->StopWidgetAnimation(); - } -} - -void OverviewGrid::OnScreenRotationAnimationFinished( - ScreenRotationAnimator* animator, - bool canceled) { - for (auto& window : window_list()) - window->set_disable_mask(false); - Shell::Get()->overview_controller()->DelayedUpdateRoundedCornersAndShadow(); - Shell::Get()->overview_controller()->UnpauseOcclusionTracker( - kOcclusionUnpauseDurationForRotation); -} - -void OverviewGrid::OnWallpaperChanging() { - grid_event_handler_.reset(); -} - -void OverviewGrid::OnWallpaperChanged() { - grid_event_handler_ = std::make_unique<OverviewGridEventHandler>(this); } void OverviewGrid::OnStartingAnimationComplete(bool canceled) { @@ -1884,6 +1657,233 @@ DeskNameView::CommitChanges(desks_widget_.get()); } +void OverviewGrid::ShowDesksTemplatesGrid(bool was_zero_state) { + if (!desks_templates_grid_widget_) { + desks_templates_grid_widget_ = + DesksTemplatesGridView::CreateDesksTemplatesGridWidget(root_window_); + } + + // Before showing the grid, we need to hide the overview items. However, we + // don't want to affect the desk preview. To do this, we temporarily set a + // window property that will keep them visible. + if (DeskMiniView* desk_mini_view = desks_bar_view_->FindMiniViewForDesk( + DesksController::Get()->GetTargetActiveDesk())) { + std::vector<aura::Window*> updated_windows; + SetForceVisibleInMiniView(desk_mini_view->GetDeskContainer(), + &updated_windows); + + // This makes the desk preview pick up on the window property change. + desk_mini_view->desk_preview()->RecreateDeskContentsMirrorLayers(); + + // Remove the property that was temporarily applied. + for (aura::Window* window : updated_windows) + window->ClearProperty(kForceVisibleInMiniViewKey); + } + + // We can now hide the overview mode items. + for (auto& overview_mode_item : window_list_) + overview_mode_item->HideForDesksTemplatesGrid(); + + desks_templates_grid_widget_->Show(); + + if (was_zero_state) { + desks_bar_view_->UpdateNewMiniViews(/*initializing_bar_view=*/false, + /*expanded_desks_bar_button=*/true); + } + desks_bar_view_->UpdateButtonsForDesksTemplatesGrid(); +} + +void OverviewGrid::HideDesksTemplatesGrid(bool exit_overview) { + // Un-hide the overview mode items. + for (auto& overview_mode_item : window_list_) + overview_mode_item->RevertHideForDesksTemplatesGrid(); + + if (exit_overview) { + desks_templates_grid_widget_->CloseNow(); + return; + } + + desks_templates_grid_widget_->Hide(); + desks_bar_view_->UpdateButtonsForDesksTemplatesGrid(); + desks_bar_view_->OnDesksTemplatesGridHidden(); +} + +bool OverviewGrid::IsShowingDesksTemplatesGrid() const { + return desks_templates_grid_widget_ && + desks_templates_grid_widget_->IsVisible(); +} + +void OverviewGrid::UpdateNoWindowsWidget(bool no_items) { + // Hide the widget if there is an item in overview or the desk templates grid + // is visible. + if (!no_items || IsShowingDesksTemplatesGrid()) { + no_windows_widget_.reset(); + return; + } + + if (!no_windows_widget_) { + // Create and fade in the widget. + RoundedLabelWidget::InitParams params; + params.name = "OverviewNoWindowsLabel"; + params.horizontal_padding = kNoItemsIndicatorHorizontalPaddingDp; + params.vertical_padding = kNoItemsIndicatorVerticalPaddingDp; + params.rounding_dp = kNoItemsIndicatorRoundingDp; + auto* color_provider = AshColorProvider::Get(); + params.background_color = color_provider->GetBaseLayerColor( + AshColorProvider::BaseLayerType::kTransparent80); + params.foreground_color = color_provider->GetContentLayerColor( + AshColorProvider::ContentLayerType::kTextColorPrimary); + params.preferred_height = kNoItemsIndicatorHeightDp; + params.message_id = IDS_ASH_OVERVIEW_NO_RECENT_ITEMS; + params.parent = + root_window_->GetChildById(desks_util::GetActiveDeskContainerId()); + params.hide_in_mini_view = true; + no_windows_widget_ = std::make_unique<RoundedLabelWidget>(); + no_windows_widget_->Init(std::move(params)); + + aura::Window* widget_window = no_windows_widget_->GetNativeWindow(); + widget_window->parent()->StackChildAtBottom(widget_window); + ScopedOverviewAnimationSettings settings(OVERVIEW_ANIMATION_NO_RECENTS_FADE, + widget_window); + no_windows_widget_->SetOpacity(1.f); + } + + RefreshNoWindowsWidgetBounds(/*animate=*/false); +} + +void OverviewGrid::RefreshNoWindowsWidgetBounds(bool animate) { + if (!no_windows_widget_) + return; + + no_windows_widget_->SetBoundsCenteredIn(GetGridEffectiveBounds(), animate); +} + +void OverviewGrid::UpdateSaveDeskAsTemplateButton() { + if (!desks_templates_util::AreDesksTemplatesEnabled()) + return; + + // Do not create or show the save desk as template button if there are no + // windows in this grid, during a window drag or in tablet mode, or the desks + // templates grid is visible. + const bool visible = + !window_list_.empty() && + !overview_session_->GetCurrentDraggedOverviewItem() && + !Shell::Get()->tablet_mode_controller()->InTabletMode() && + !IsShowingDesksTemplatesGrid(); + + if (!visible) { + if (save_desk_as_template_widget_) + save_desk_as_template_widget_->Hide(); + return; + } + + if (!save_desk_as_template_widget_) { + save_desk_as_template_widget_ = SaveDeskAsTemplateWidget(root_window_); + save_desk_as_template_widget_->SetContentsView(std::make_unique<PillButton>( + base::BindRepeating(&OverviewGrid::OnSaveDeskAsTemplateButtonPressed, + base::Unretained(this)), + l10n_util::GetStringUTF16( + IDS_ASH_DESKS_TEMPLATES_SAVE_DESK_AS_TEMPLATE_BUTTON), + PillButton::Type::kIcon, &kSaveDeskAsTemplateIcon)); + } + save_desk_as_template_widget_->Show(); + + // Disable the create templates button if the current number of templates has + // reached the max. + auto* presenter = DesksTemplatesPresenter::Get(); + if (presenter->GetEntryCount() >= presenter->GetMaxEntryCount()) { + auto* button = static_cast<PillButton*>( + save_desk_as_template_widget_->GetContentsView()); + button->SetState(views::Button::STATE_DISABLED); + } + + // Set the widget position above the overview item window and default width + // and height. + // TODO: Reposition Desks Templates bounds for tablet mode. + const gfx::RectF overview_item_bounds = window_list_.front()->target_bounds(); + const gfx::Size preferred_size = + save_desk_as_template_widget_->GetContentsView()->GetPreferredSize(); + save_desk_as_template_widget_->SetBounds(gfx::Rect( + overview_item_bounds.x(), + overview_item_bounds.y() - kSaveDeskAsTemplateOverviewItemSpacingDp, + preferred_size.width(), preferred_size.height())); +} + +void OverviewGrid::OnSplitViewStateChanged( + SplitViewController::State previous_state, + SplitViewController::State state) { + // Do nothing if overview is being shutdown. + OverviewController* overview_controller = Shell::Get()->overview_controller(); + if (!overview_controller->InOverviewSession()) + return; + + SplitViewController* split_view_controller = + SplitViewController::Get(root_window_); + const bool unsnappable_window_activated = + state == SplitViewController::State::kNoSnap && + split_view_controller->end_reason() == + SplitViewController::EndReason::kUnsnappableWindowActivated; + + // If two windows were snapped to both sides of the screen or an unsnappable + // window was just activated, or we're in single split mode in clamshell mode + // and there is no window in overview, end overview mode and bail out. + if (state == SplitViewController::State::kBothSnapped || + unsnappable_window_activated || + (split_view_controller->InClamshellSplitViewMode() && + overview_session_->IsEmpty())) { + overview_session_->RestoreWindowActivation(false); + overview_controller->EndOverview(OverviewEndAction::kSplitView); + return; + } + + // Update the cannot snap warnings and adjust the grid bounds. + UpdateCannotSnapWarningVisibility(); + SetBoundsAndUpdatePositions(GetGridBoundsInScreen(root_window_), + /*ignored_items=*/{}, /*animate=*/false); + + // If split view mode was ended, then activate the overview focus window, to + // match the behavior of entering overview mode in the beginning. + if (state == SplitViewController::State::kNoSnap) + wm::ActivateWindow(overview_session_->GetOverviewFocusWindow()); +} + +void OverviewGrid::OnSplitViewDividerPositionChanged() { + SetBoundsAndUpdatePositions( + GetGridBoundsInScreen(root_window_, + /*window_dragging_state=*/absl::nullopt, + /*divider_changed=*/true, + /*account_for_hotseat=*/true), + /*ignored_items=*/{}, /*animate=*/false); +} + +void OverviewGrid::OnScreenCopiedBeforeRotation() { + Shell::Get()->overview_controller()->PauseOcclusionTracker(); + + for (auto& window : window_list()) { + window->set_disable_mask(true); + window->UpdateRoundedCornersAndShadow(); + window->StopWidgetAnimation(); + } +} + +void OverviewGrid::OnScreenRotationAnimationFinished( + ScreenRotationAnimator* animator, + bool canceled) { + for (auto& window : window_list()) + window->set_disable_mask(false); + Shell::Get()->overview_controller()->DelayedUpdateRoundedCornersAndShadow(); + Shell::Get()->overview_controller()->UnpauseOcclusionTracker( + kOcclusionUnpauseDurationForRotation); +} + +void OverviewGrid::OnWallpaperChanging() { + grid_event_handler_.reset(); +} + +void OverviewGrid::OnWallpaperChanged() { + grid_event_handler_ = std::make_unique<OverviewGridEventHandler>(this); +} + void OverviewGrid::MaybeInitDesksWidget() { if (!desks_util::ShouldDesksBarBeCreated() || desks_widget_) return;
diff --git a/ash/wm/overview/overview_grid.h b/ash/wm/overview/overview_grid.h index daa26ec..f110ad0 100644 --- a/ash/wm/overview/overview_grid.h +++ b/ash/wm/overview/overview_grid.h
@@ -221,20 +221,6 @@ // Called by |OverviewSession::OnUserWorkAreaInsetsChanged|. void OnUserWorkAreaInsetsChanged(aura::Window* root_window); - // SplitViewObserver: - void OnSplitViewStateChanged(SplitViewController::State previous_state, - SplitViewController::State state) override; - void OnSplitViewDividerPositionChanged() override; - - // ScreenRotationAnimatorObserver: - void OnScreenCopiedBeforeRotation() override; - void OnScreenRotationAnimationFinished(ScreenRotationAnimator* animator, - bool canceled) override; - - // WallpaperControllerObserver: - void OnWallpaperChanging() override; - void OnWallpaperChanged() override; - // Called when overview starting animation completes. void OnStartingAnimationComplete(bool canceled); @@ -361,6 +347,20 @@ // button if it hasn't been created already, else it just sets its bounds. void UpdateSaveDeskAsTemplateButton(); + // SplitViewObserver: + void OnSplitViewStateChanged(SplitViewController::State previous_state, + SplitViewController::State state) override; + void OnSplitViewDividerPositionChanged() override; + + // ScreenRotationAnimatorObserver: + void OnScreenCopiedBeforeRotation() override; + void OnScreenRotationAnimationFinished(ScreenRotationAnimator* animator, + bool canceled) override; + + // WallpaperControllerObserver: + void OnWallpaperChanging() override; + void OnWallpaperChanged() override; + // Returns true if the grid has no more windows. bool empty() const { return window_list_.empty(); }
diff --git a/ash/wm/overview/overview_session.cc b/ash/wm/overview/overview_session.cc index bfcec664..4a60078 100644 --- a/ash/wm/overview/overview_session.cc +++ b/ash/wm/overview/overview_session.cc
@@ -737,9 +737,13 @@ if (ignore_activations_ || gained_active == GetOverviewFocusWindow()) return; - // Activating the Desks bar should not end overview. - if (gained_active && gained_active->GetId() == kShellWindowId_DesksBarWindow) + // Activating the Desks bar or the Desks Templates grid should not end + // overview. + if (gained_active && + (gained_active->GetId() == kShellWindowId_DesksBarWindow || + gained_active->GetId() == kShellWindowId_DesksTemplatesGridWindow)) { return; + } // Activating or deactivating one of the confirmation dialogs associated with // desks templates should not end overview.
diff --git a/base/BUILD.gn b/base/BUILD.gn index 5a0d922..6aa5067 100644 --- a/base/BUILD.gn +++ b/base/BUILD.gn
@@ -1387,6 +1387,7 @@ ":cfi_buildflags", ":clang_profiling_buildflags", ":debugging_buildflags", + ":feature_list_buildflags", ":logging_buildflags", ":orderfile_buildflags", ":profiler_buildflags", @@ -2494,6 +2495,19 @@ ] } +buildflag_header("feature_list_buildflags") { + header = "feature_list_buildflags.h" + + if (is_chromeos_ash) { + flags = [ + "ENABLE_BANNED_BASE_FEATURE_PREFIX=true", + "BANNED_BASE_FEATURE_PREFIX=\"CrOSLateBoot\"", + ] + } else { + flags = [ "ENABLE_BANNED_BASE_FEATURE_PREFIX=false" ] + } +} + buildflag_header("logging_buildflags") { header = "logging_buildflags.h" @@ -3279,6 +3293,7 @@ ":base", ":base_stack_sampling_profiler_test_util", ":base_unittests_tasktraits", + ":feature_list_buildflags", ":i18n", ":sanitizer_buildflags", "//base/allocator:buildflags",
diff --git a/base/feature_list.h b/base/feature_list.h index 0cef8ac..4c978ef9 100644 --- a/base/feature_list.h +++ b/base/feature_list.h
@@ -14,6 +14,7 @@ #include "base/base_export.h" #include "base/containers/flat_map.h" +#include "base/feature_list_buildflags.h" #include "base/gtest_prod_util.h" #include "base/memory/raw_ptr.h" #include "base/metrics/field_trial_params.h" @@ -40,7 +41,17 @@ // for a given feature name - generally defined as a constant global variable or // file static. It should never be used as a constexpr as it breaks // pointer-based identity lookup. +// Note: New code should use CONSTINIT on the base::Feature declaration. struct BASE_EXPORT Feature { + constexpr Feature(const char* name, FeatureState default_state) + : name(name), default_state(default_state) { +#if BUILDFLAG(ENABLE_BANNED_BASE_FEATURE_PREFIX) + if (StringPiece(name).find(BUILDFLAG(BANNED_BASE_FEATURE_PREFIX)) == 0) { + LOG(FATAL) << "Invalid feature name " << name << " starts with " + << BUILDFLAG(BANNED_BASE_FEATURE_PREFIX); + } +#endif // BUILDFLAG(ENABLE_BANNED_BASE_FEATURE_PREFIX) + } // The name of the feature. This should be unique to each feature and is used // for enabling/disabling features via command line flags and experiments. // It is strongly recommended to use CamelCase style for feature names, e.g.
diff --git a/base/feature_list_unittest.cc b/base/feature_list_unittest.cc index 8a8e093b..5cddec583 100644 --- a/base/feature_list_unittest.cc +++ b/base/feature_list_unittest.cc
@@ -10,11 +10,13 @@ #include <vector> #include "base/cxx17_backports.h" +#include "base/feature_list_buildflags.h" #include "base/format_macros.h" #include "base/memory/read_only_shared_memory_region.h" #include "base/metrics/field_trial.h" #include "base/metrics/persistent_memory_allocator.h" #include "base/ranges/algorithm.h" +#include "base/strings/strcat.h" #include "base/strings/string_piece.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" @@ -674,6 +676,20 @@ EXPECT_EQ(associated_trial2, trial2); } +#if BUILDFLAG(ENABLE_BANNED_BASE_FEATURE_PREFIX) && \ + defined(GTEST_HAS_DEATH_TEST) +using FeatureListDeathTest = FeatureListTest; +TEST_F(FeatureListDeathTest, DiesWithBadFeatureName) { + EXPECT_DEATH( + Feature( + StrCat({BUILDFLAG(BANNED_BASE_FEATURE_PREFIX), "MyFeature"}).c_str(), + FEATURE_DISABLED_BY_DEFAULT), + StrCat({"Invalid feature name ", BUILDFLAG(BANNED_BASE_FEATURE_PREFIX), + "MyFeature"})); +} +#endif // BUILDFLAG(ENABLE_BANNED_BASE_FEATURE_PREFIX) && + // defined(GTEST_HAS_DEATH_TEST) + TEST(FeatureListAccessorTest, DefaultStates) { auto feature_list = std::make_unique<FeatureList>(); auto feature_list_accessor = feature_list->ConstructAccessor();
diff --git a/base/metrics/field_trial_params_unittest.nc b/base/metrics/field_trial_params_unittest.nc index 4c6005e3..e0a0ff5 100644 --- a/base/metrics/field_trial_params_unittest.nc +++ b/base/metrics/field_trial_params_unittest.nc
@@ -8,7 +8,8 @@ #include "base/feature_list.h" #include "base/metrics/field_trial_params.h" -constexpr base::Feature kFeature{"NoCompileFeature"}; +constexpr base::Feature kFeature{ + "NoCompileFeature", base::FEATURE_DISABLED_BY_DEFAULT}; enum Param { FOO, BAR };
diff --git a/base/task/current_thread.cc b/base/task/current_thread.cc index 65c7aba..718ba706 100644 --- a/base/task/current_thread.cc +++ b/base/task/current_thread.cc
@@ -5,6 +5,7 @@ #include "base/task/current_thread.h" #include "base/bind.h" +#include "base/callback.h" #include "base/message_loop/message_pump_for_io.h" #include "base/message_loop/message_pump_for_ui.h" #include "base/message_loop/message_pump_type.h" @@ -82,6 +83,11 @@ current_->SetAddQueueTimeToTasks(enable); } +void CurrentThread::RegisterOnNextIdleCallback( + OnceClosure on_next_idle_callback) { + current_->RegisterOnNextIdleCallback(std::move(on_next_idle_callback)); +} + CurrentThread::ScopedAllowApplicationTasksInNativeNestedLoop:: ScopedAllowApplicationTasksInNativeNestedLoop() : sequence_manager_(GetCurrentSequenceManagerImpl()),
diff --git a/base/task/current_thread.h b/base/task/current_thread.h index da8b91c1..7ca1e0e 100644 --- a/base/task/current_thread.h +++ b/base/task/current_thread.h
@@ -8,6 +8,7 @@ #include <ostream> #include "base/base_export.h" +#include "base/callback_forward.h" #include "base/check.h" #include "base/memory/scoped_refptr.h" #include "base/message_loop/message_pump_for_io.h" @@ -123,6 +124,12 @@ // posted tasks. void SetAddQueueTimeToTasks(bool enable); + // Registers a OnceClosure to be called on this thread the next time it goes + // idle. This is meant for internal usage; callers should use BEST_EFFORT + // tasks instead of this for generic work that needs to wait until quiescence + // to run. There can only be one OnNextIdleCallback at a time. + void RegisterOnNextIdleCallback(OnceClosure on_next_idle_callback); + // Enables nested task processing in scope of an upcoming native message loop. // Some unwanted message loops may occur when using common controls or printer // functions. Hence, nested task processing is disabled by default to avoid
diff --git a/base/task/sequence_manager/sequence_manager_impl.cc b/base/task/sequence_manager/sequence_manager_impl.cc index 2b9e724..6dd3e27 100644 --- a/base/task/sequence_manager/sequence_manager_impl.cc +++ b/base/task/sequence_manager/sequence_manager_impl.cc
@@ -9,6 +9,7 @@ #include <vector> #include "base/bind.h" +#include "base/callback.h" #include "base/callback_helpers.h" #include "base/compiler_specific.h" #include "base/debug/crash_logging.h" @@ -793,8 +794,11 @@ bool have_work_to_do = main_thread_only().time_domain->MaybeFastForwardToWakeUp( wakeup, controller_->ShouldQuitRunLoopWhenIdle()); - if (!have_work_to_do) + if (!have_work_to_do) { MaybeReclaimMemory(); + if (main_thread_only().on_next_idle_callback) + std::move(main_thread_only().on_next_idle_callback).Run(); + } return have_work_to_do; } @@ -1173,6 +1177,12 @@ main_thread_only().destruction_observers.RemoveObserver(destruction_observer); } +void SequenceManagerImpl::RegisterOnNextIdleCallback( + OnceClosure on_next_idle_callback) { + DCHECK(!main_thread_only().on_next_idle_callback); + main_thread_only().on_next_idle_callback = std::move(on_next_idle_callback); +} + void SequenceManagerImpl::SetTaskRunner( scoped_refptr<SingleThreadTaskRunner> task_runner) { controller_->SetDefaultTaskRunner(task_runner);
diff --git a/base/task/sequence_manager/sequence_manager_impl.h b/base/task/sequence_manager/sequence_manager_impl.h index f363f46..f89e1bc 100644 --- a/base/task/sequence_manager/sequence_manager_impl.h +++ b/base/task/sequence_manager/sequence_manager_impl.h
@@ -14,6 +14,7 @@ #include <utility> #include "base/atomic_sequence_num.h" +#include "base/callback_forward.h" #include "base/cancelable_callback.h" #include "base/containers/circular_deque.h" #include "base/debug/crash_logging.h" @@ -156,6 +157,7 @@ CurrentThread::DestructionObserver* destruction_observer); void RemoveDestructionObserver( CurrentThread::DestructionObserver* destruction_observer); + void RegisterOnNextIdleCallback(OnceClosure on_next_idle_callback); // TODO(alexclarke): Remove this as part of https://crbug.com/825327. void SetTaskRunner(scoped_refptr<SingleThreadTaskRunner> task_runner); // TODO(alexclarke): Remove this as part of https://crbug.com/825327. @@ -332,6 +334,10 @@ ObserverList<CurrentThread::DestructionObserver>::Unchecked destruction_observers; + // If non-null, invoked the next time OnSystemIdle() completes without + // scheduling additional work. + OnceClosure on_next_idle_callback; + // By default native work is not prioritized at all. std::multiset<TaskQueue::QueuePriority> pending_native_work{ TaskQueue::kBestEffortPriority};
diff --git a/build/chromeos/test_runner.py b/build/chromeos/test_runner.py index 8e28e75..01c2c8b 100755 --- a/build/chromeos/test_runner.py +++ b/build/chromeos/test_runner.py
@@ -671,9 +671,6 @@ os.path.abspath( os.path.join(self._path_to_outdir, self._vpython_dir)), CHROMIUM_SRC_PATH)) - # TODO(bpastene): Add the vpython spec to the test's runtime deps instead - # of handling it here. - runtime_files.append('.vpython') for f in runtime_files: self._test_cmd.extend(['--files', f])
diff --git a/build/config/chromeos/rules.gni b/build/config/chromeos/rules.gni index f0731b6f..ff072d3 100644 --- a/build/config/chromeos/rules.gni +++ b/build/config/chromeos/rules.gni
@@ -324,7 +324,6 @@ deps += invoker.deps } data = [ - "//.vpython", "//.vpython3", # We use android test-runner's results libs to construct gtest output
diff --git a/build/rust/cargo_crate.gni b/build/rust/cargo_crate.gni index 5171835..65fb63ce 100644 --- a/build/rust/cargo_crate.gni +++ b/build/rust/cargo_crate.gni
@@ -141,7 +141,7 @@ # require them to be present until runtime. flags_file = get_label_info(":${orig_target_name}_build_script_output", "target_out_dir") + "/cargo_flags.rs" - rustflags += [ "@" + rebase_path(flags_file) ] + rustflags += [ "@" + rebase_path(flags_file, root_build_dir) ] sources += [ flags_file ] deps += [ ":${build_script_name}_output" ] } else {
diff --git a/build/rust/run_cxxbridge.py b/build/rust/run_cxxbridge.py index 9f2cc2f..b7bd9b7 100755 --- a/build/rust/run_cxxbridge.py +++ b/build/rust/run_cxxbridge.py
@@ -19,7 +19,7 @@ def run(exe, args, output, is_header): - cmdargs = [exe] + cmdargs = [os.path.abspath(exe)] cmdargs.extend(args) if is_header: cmdargs.extend(["--header"])
diff --git a/build/rust/rust_cxx.gni b/build/rust/rust_cxx.gni index f5512b2..496a6d85 100644 --- a/build/rust/rust_cxx.gni +++ b/build/rust/rust_cxx.gni
@@ -40,6 +40,36 @@ # Whether to generate a source_set target here. # (See below for why you might choose false) # +# export_symbols (optional; default is 'is_component_build') +# Whether the C++ side of the bindings should be exported +# from any shared objects in which it finds itself. +# This is not necessary if the Rust and C++ side of the +# bindings will always find themselves within the same binary, +# which is usually the case in a non-component build. +# Even in a component build, the Rust and C++ code will +# often find itself within the same binary and no exporting +# is required. However, there may be other binaries - most +# commonly Rust unit test executables - which contain the +# Rust side of the bindings but not the C++ side. In such +# a case, it's important that the C++ side symbols are +# exported such that the Rust unit tests can link against +# them. This does the equivalent of adding BASE_EXPORT +# or similar. +# Example: +# Non-component build: +# group of libfoo.a, foo.rlib # contain +# # C++ and Rust side bindings, always both linked +# # into final targets +# foo_rs_unittests # contains Rust side bindings, +# # and any C++ dependencies which will include +# # all of the libfoo code. +# Component build: +# libfoo.so # contains C++ and Rust side bindings +# foo_rs_unittests # contains Rust side test code, +# # but links against libfoo.so to get the C++ +# # side bindings. So libfoo.so must make those +# # symbols visible. +# # Consumers of this template may alternatively depend upon # the :${target_name}_gen target if you wish to include # the generated source code in an *existing* source set. @@ -70,13 +100,13 @@ cxxbridge_target = "//third_party/rust/cxxbridge_cmd/v1:cxxbridge($host_toolchain)" - cxxbridge_obj_dir = get_label_info(cxxbridge_target, "root_out_dir") - cxxbridge_executable = rebase_path("${cxxbridge_obj_dir}/cxxbridge") + cxxbridge_out_dir = get_label_info(cxxbridge_target, "root_out_dir") + cxxbridge_executable = "${cxxbridge_out_dir}/cxxbridge" if (is_win) { - cxxbridge_executable = rebase_path("${cxxbridge_executable}.exe") + cxxbridge_executable = "${cxxbridge_executable}.exe" } - script = rebase_path("//build/rust/run_cxxbridge.py") + script = "//build/rust/run_cxxbridge.py" inputs = [ cxxbridge_executable, script, @@ -89,14 +119,41 @@ args = [ "--exe", - cxxbridge_executable, + rebase_path(cxxbridge_executable, root_build_dir), "--header", output_h, "--cc", output_cc, "{{source}}", + "--", ] + if (!defined(export_symbols)) { + export_symbols = is_component_build + } + if (export_symbols) { + # See explanation of 'export_symbols' above for what this + # does. Implementation note: we could have required users + # of this template to specify a preprocessor symbol, e.g. + # BASE_EXPORT, which would vary per-component. However, + # since we're building only the definition of the bindings, + # not any header files, the export specifications are + # predictable and we don't need to foist that complexity + # on users of this template. The default behavior here + # should be correct. If this proves to be insufficient in + # future, this template should be modified to accept a + # parameter where users can specify 'BASE_EXPORT' or the + # equivalent for their component. + # cxxbridge --cxx-impl-annotations adds this annotation + # to each exported C++ function. + args += [ "--cxx-impl-annotations" ] + if (is_win) { + args += [ "__declspec(dllexport)" ] + } else { + args += [ "__attribute__((visibility(\"default\")))" ] + } + } + # Anyone building the header files we generate needs to have # RUST_CXX_NO_EXCEPTIONS defined so that they build without # exception support.
diff --git a/build/rust/tests/BUILD.gn b/build/rust/tests/BUILD.gn index cae2bf5..07d0721 100644 --- a/build/rust/tests/BUILD.gn +++ b/build/rust/tests/BUILD.gn
@@ -27,6 +27,7 @@ if (build_rust_unit_tests) { deps += [ "test_cpp_including_rust:test_cpp_including_rust_unittests", + "test_mixed_component:test_mixed_component_rs_unittests", "test_mixed_source_set:test_mixed_source_set_rs_unittests", "test_rust_source_set:test_rust_source_set_unittests", "test_rust_source_set_non_standard_arrangement:foo_tests",
diff --git a/build/rust/tests/test_mixed_component/DEPS b/build/rust/tests/test_mixed_component/DEPS new file mode 100644 index 0000000..b5d7786 --- /dev/null +++ b/build/rust/tests/test_mixed_component/DEPS
@@ -0,0 +1,3 @@ +include_rules = [ + "+third_party/rust/cxx/v1/crate/include", +]
diff --git a/build/rust/tests/test_mixed_component/component.cc b/build/rust/tests/test_mixed_component/component.cc index 6b8079a4..36ffdaf 100644 --- a/build/rust/tests/test_mixed_component/component.cc +++ b/build/rust/tests/test_mixed_component/component.cc
@@ -14,3 +14,17 @@ return a + b; #endif } + +COMPONENT_EXPORT std::string bilingual_string() { +#if defined(RUST_ENABLED) + return std::string(rust_get_an_uppercase_string()); +#else + return "sad panda, no Rust"; +#endif +} + +#if defined(RUST_ENABLED) +rust::String get_a_string_from_cpp() { + return rust::String("Mixed Case String"); +} +#endif
diff --git a/build/rust/tests/test_mixed_component/component.h b/build/rust/tests/test_mixed_component/component.h index 07c799b..76498d0 100644 --- a/build/rust/tests/test_mixed_component/component.h +++ b/build/rust/tests/test_mixed_component/component.h
@@ -2,7 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <string> #include "stdint.h" +#if (defined RUST_ENABLED) +#include "third_party/rust/cxx/v1/crate/include/cxx.h" +#endif #ifndef BUILD_RUST_TESTS_TEST_MIXED_COMPONENT_COMPONENT_H_ #define BUILD_RUST_TESTS_TEST_MIXED_COMPONENT_COMPONENT_H_ @@ -31,5 +35,10 @@ #endif COMPONENT_EXPORT uint32_t bilingual_math(uint32_t a, uint32_t b); +COMPONENT_EXPORT std::string bilingual_string(); + +#if (defined RUST_ENABLED) +rust::String get_a_string_from_cpp(); +#endif #endif // BUILD_RUST_TESTS_TEST_MIXED_COMPONENT_COMPONENT_H_
diff --git a/build/rust/tests/test_mixed_component/component.rs b/build/rust/tests/test_mixed_component/component.rs index e079011..2d41b185 100644 --- a/build/rust/tests/test_mixed_component/component.rs +++ b/build/rust/tests/test_mixed_component/component.rs
@@ -4,11 +4,33 @@ #[cxx::bridge] mod ffi { + unsafe extern "C++" { + include!("build/rust/tests/test_mixed_component/component.h"); + fn get_a_string_from_cpp() -> String; + } extern "Rust" { fn rust_math(a: u32, b: u32) -> u32; + fn rust_get_an_uppercase_string() -> String; } } fn rust_math(a: u32, b: u32) -> u32 { a.checked_add(b).expect("Oh noes! Integer overflow") } + +fn rust_get_an_uppercase_string() -> String { + ffi::get_a_string_from_cpp().to_uppercase() +} + +#[cfg(test)] +mod tests { + #[test] + fn test_math() { + assert_eq!(crate::rust_math(33, 3), 36) + } + + #[test] + fn test_string() { + assert_eq!(crate::ffi::get_a_string_from_cpp(), "Mixed Case String") + } +}
diff --git a/chrome/android/expectations/monochrome_public_bundle.AndroidManifest.expected b/chrome/android/expectations/monochrome_public_bundle.AndroidManifest.expected index 7b4ca4bc..dbbc714 100644 --- a/chrome/android/expectations/monochrome_public_bundle.AndroidManifest.expected +++ b/chrome/android/expectations/monochrome_public_bundle.AndroidManifest.expected
@@ -1046,24 +1046,15 @@ </intent-filter> # DIFF-ANCHOR: 4ed161a4 <meta-data android:name="android.appwidget.provider" android:resource="@xml/quick_action_search_widget_dino_info"/> </receiver> # DIFF-ANCHOR: 226134db - <receiver # DIFF-ANCHOR: 6e59bf36 - android:name="org.chromium.chrome.browser.quickactionsearchwidget.QuickActionSearchWidgetProvider$QuickActionSearchWidgetProviderMedium" - android:exported="true" - android:label="@string/quick_action_search_widget_title"> - <intent-filter> # DIFF-ANCHOR: 4ed161a4 - <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/> - </intent-filter> # DIFF-ANCHOR: 4ed161a4 - <meta-data android:name="android.appwidget.provider" android:resource="@xml/quick_action_search_widget_medium_info"/> - </receiver> # DIFF-ANCHOR: 6e59bf36 - <receiver # DIFF-ANCHOR: 5fe9b78b - android:name="org.chromium.chrome.browser.quickactionsearchwidget.QuickActionSearchWidgetProvider$QuickActionSearchWidgetProviderSmall" + <receiver # DIFF-ANCHOR: 5a0b9536 + android:name="org.chromium.chrome.browser.quickactionsearchwidget.QuickActionSearchWidgetProvider$QuickActionSearchWidgetProviderSearch" android:exported="true" android:label="@string/quick_action_search_widget_title"> <intent-filter> # DIFF-ANCHOR: 4ed161a4 <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/> </intent-filter> # DIFF-ANCHOR: 4ed161a4 <meta-data android:name="android.appwidget.provider" android:resource="@xml/quick_action_search_widget_small_info"/> - </receiver> # DIFF-ANCHOR: 5fe9b78b + </receiver> # DIFF-ANCHOR: 5a0b9536 <receiver # DIFF-ANCHOR: a0d83ae5 android:name="org.chromium.chrome.browser.searchwidget.SearchWidgetProvider" android:exported="true"
diff --git a/chrome/android/expectations/trichrome_chrome_bundle.AndroidManifest.expected b/chrome/android/expectations/trichrome_chrome_bundle.AndroidManifest.expected index da45153..70c7ba3 100644 --- a/chrome/android/expectations/trichrome_chrome_bundle.AndroidManifest.expected +++ b/chrome/android/expectations/trichrome_chrome_bundle.AndroidManifest.expected
@@ -972,24 +972,15 @@ </intent-filter> # DIFF-ANCHOR: 4ed161a4 <meta-data android:name="android.appwidget.provider" android:resource="@xml/quick_action_search_widget_dino_info"/> </receiver> # DIFF-ANCHOR: 226134db - <receiver # DIFF-ANCHOR: 6e59bf36 - android:name="org.chromium.chrome.browser.quickactionsearchwidget.QuickActionSearchWidgetProvider$QuickActionSearchWidgetProviderMedium" - android:exported="true" - android:label="@string/quick_action_search_widget_title"> - <intent-filter> # DIFF-ANCHOR: 4ed161a4 - <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/> - </intent-filter> # DIFF-ANCHOR: 4ed161a4 - <meta-data android:name="android.appwidget.provider" android:resource="@xml/quick_action_search_widget_medium_info"/> - </receiver> # DIFF-ANCHOR: 6e59bf36 - <receiver # DIFF-ANCHOR: 5fe9b78b - android:name="org.chromium.chrome.browser.quickactionsearchwidget.QuickActionSearchWidgetProvider$QuickActionSearchWidgetProviderSmall" + <receiver # DIFF-ANCHOR: 5a0b9536 + android:name="org.chromium.chrome.browser.quickactionsearchwidget.QuickActionSearchWidgetProvider$QuickActionSearchWidgetProviderSearch" android:exported="true" android:label="@string/quick_action_search_widget_title"> <intent-filter> # DIFF-ANCHOR: 4ed161a4 <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/> </intent-filter> # DIFF-ANCHOR: 4ed161a4 <meta-data android:name="android.appwidget.provider" android:resource="@xml/quick_action_search_widget_small_info"/> - </receiver> # DIFF-ANCHOR: 5fe9b78b + </receiver> # DIFF-ANCHOR: 5a0b9536 <receiver # DIFF-ANCHOR: a0d83ae5 android:name="org.chromium.chrome.browser.searchwidget.SearchWidgetProvider" android:exported="true"
diff --git a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabUiFeatureUtilities.java b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabUiFeatureUtilities.java index d9bd7bb..90d8b2e 100644 --- a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabUiFeatureUtilities.java +++ b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabUiFeatureUtilities.java
@@ -125,9 +125,9 @@ * @param context The activity context. */ public static boolean isGridTabSwitcherEnabled(Context context) { - // Disable grid tab switcher for tablet. + // Only enable grid tab switcher for tablet if flag is enabled. if (DeviceFormFactor.isNonMultiDisplayContextOnTablet(context)) { - return false; + return CachedFeatureFlags.isEnabled(ChromeFeatureList.GRID_TAB_SWITCHER_FOR_TABLETS); } // Having Tab Groups or Start implies Grid Tab Switcher.
diff --git a/chrome/android/java/AndroidManifest.xml b/chrome/android/java/AndroidManifest.xml index 64bea53..38c775f 100644 --- a/chrome/android/java/AndroidManifest.xml +++ b/chrome/android/java/AndroidManifest.xml
@@ -932,7 +932,7 @@ <!-- Quick Action Search widget --> <receiver - android:name="org.chromium.chrome.browser.quickactionsearchwidget.QuickActionSearchWidgetProvider$QuickActionSearchWidgetProviderSmall" + android:name="org.chromium.chrome.browser.quickactionsearchwidget.QuickActionSearchWidgetProvider$QuickActionSearchWidgetProviderSearch" android:label="@string/quick_action_search_widget_title" android:exported="true"> <intent-filter> @@ -944,18 +944,6 @@ </receiver> <receiver - android:name="org.chromium.chrome.browser.quickactionsearchwidget.QuickActionSearchWidgetProvider$QuickActionSearchWidgetProviderMedium" - android:label="@string/quick_action_search_widget_title" - android:exported="true"> - <intent-filter> - <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> - </intent-filter> - <meta-data - android:name="android.appwidget.provider" - android:resource="@xml/quick_action_search_widget_medium_info" /> - </receiver> - - <receiver android:name="org.chromium.chrome.browser.quickactionsearchwidget.QuickActionSearchWidgetProvider$QuickActionSearchWidgetProviderDino" android:label="@string/dino_widget_title" android:exported="true">
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java index 1da1584..78873d4e 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
@@ -606,19 +606,31 @@ } } - // TODO(960196) : remove this when the associated bug fix. This is a band-aid - // fix for TabGrid and closing tabs with TabGroupUi. + boolean gridTabSwitcherEnabled = TabUiFeatureUtilities.isGridTabSwitcherEnabled( + ChromeTabbedActivity.this); + boolean overviewVisible = mOverviewModeController.overviewVisible(); + boolean hasNextTab = !(getTabModelSelector().getTotalTabCount() == 0 + || (!getTabModelSelector().isIncognitoSelected() + && getTabModelSelector().getModel(false).getCount() == 0)); + + // TODO(crbug.com/1046541) : Remove this when the associated bug is fixed. This + // is a band-aid fix for TabGrid and closing tabs with TabGroupUi. // If one of the following is true, then exit Chrome when TabGroupsAndroid is // enabled, and tab switcher is not shown: // 1. If the very last tab is closed. // 2. If normal tab model is selected and no normal tabs. - if (TabUiFeatureUtilities.isGridTabSwitcherEnabled(ChromeTabbedActivity.this) - && !mOverviewModeController.overviewVisible()) { - if (getTabModelSelector().getTotalTabCount() == 0 - || (!getTabModelSelector().isIncognitoSelected() - && getTabModelSelector().getModel(false).getCount() == 0)) { - finish(); - } + if (gridTabSwitcherEnabled && !overviewVisible && !hasNextTab && !isTablet()) { + finish(); + } + + // TODO(crbug.com/1272821): Investigate unexpected behavior when the last tab is + // closed through grid tab switcher without this logic. + // If one of the following is true, then hide the grid tab switcher for tablets + // when TabGroupsAndroid is enabled, and tab switcher is shown: + // 1. If the very last tab is closed. + // 2. If normal tab model is selected and no normal tabs. + if (gridTabSwitcherEnabled && overviewVisible && !hasNextTab && isTablet()) { + mOverviewModeController.hideOverview(true); } } @@ -657,26 +669,10 @@ "ChromeTabbedActivity.setupCompositorContentPreNativeForPhone")) { CompositorViewHolder compositorViewHolder = getCompositorViewHolderSupplier().get(); - // TODO(1169205): Remove all GTS enabled checks after M5 is default. + // TODO(1239025): Remove all GTS enabled checks after GTS is enabled by default on + // tablets. if (TabUiFeatureUtilities.isGridTabSwitcherEnabled(this)) { - TabManagementDelegate tabManagementDelegate = - TabManagementModuleProvider.getDelegate(); - if (tabManagementDelegate != null) { - StartSurface startSurface = tabManagementDelegate.createStartSurface(this, - mRootUiCoordinator.getScrimCoordinator(), - mRootUiCoordinator.getBottomSheetController(), mStartSurfaceSupplier, - mStartSurfaceParentTabSupplier, hadWarmStart(), getWindowAndroid(), - compositorViewHolder, compositorViewHolder::getDynamicResourceLoader, - getTabModelSelector(), getBrowserControlsManager(), - getSnackbarManager(), getShareDelegateSupplier(), - getToolbarManager()::getOmniboxStub, getTabContentManager(), - getModalDialogManager(), - /* chromeActivityNativeDelegate= */ this, getLifecycleDispatcher(), - getTabCreatorManagerSupplier().get(), - getMenuOrKeyboardActionController(), - getMultiWindowModeStateDispatcher(), mJankTracker, - getToolbarManager()::getToolbar); - } + createStartSurface(compositorViewHolder); } // clang-format off @@ -699,9 +695,17 @@ try (TraceEvent e = TraceEvent.scoped( "ChromeTabbedActivity.setupCompositorContentPreNativeForTablet")) { + CompositorViewHolder compositorViewHolder = getCompositorViewHolderSupplier().get(); + + // TODO(1239025): Remove all GTS enabled checks after GTS is enabled by default on + // tablets. + if (TabUiFeatureUtilities.isGridTabSwitcherEnabled(this)) { + createStartSurface(compositorViewHolder); + } + // clang-format off - mLayoutManager = new LayoutManagerChromeTablet(getCompositorViewHolderSupplier().get(), - mContentContainer, getTabContentManagerSupplier(), + mLayoutManager = new LayoutManagerChromeTablet(compositorViewHolder, mContentContainer, + mStartSurfaceSupplier.get(), getTabContentManagerSupplier(), () -> { if (!getCompositorViewHolderSupplier().hasValue()) return null; return getCompositorViewHolderSupplier().get().getLayerTitleCache(); @@ -714,6 +718,23 @@ } } + private void createStartSurface(CompositorViewHolder compositorViewHolder) { + TabManagementDelegate tabManagementDelegate = TabManagementModuleProvider.getDelegate(); + if (tabManagementDelegate != null) { + tabManagementDelegate.createStartSurface(this, mRootUiCoordinator.getScrimCoordinator(), + mRootUiCoordinator.getBottomSheetController(), mStartSurfaceSupplier, + mStartSurfaceParentTabSupplier, hadWarmStart(), getWindowAndroid(), + compositorViewHolder, compositorViewHolder::getDynamicResourceLoader, + getTabModelSelector(), getBrowserControlsManager(), getSnackbarManager(), + getShareDelegateSupplier(), getToolbarManager()::getOmniboxStub, + getTabContentManager(), getModalDialogManager(), + /* chromeActivityNativeDelegate= */ this, getLifecycleDispatcher(), + getTabCreatorManagerSupplier().get(), getMenuOrKeyboardActionController(), + getMultiWindowModeStateDispatcher(), mJankTracker, + getToolbarManager()::getToolbar); + } + } + private void setupCompositorContentPostNative() { try (TraceEvent e = TraceEvent.scoped( "ChromeTabbedActivity.setupCompositorContentPostNative")) { @@ -1084,7 +1105,7 @@ RecordHistogram.recordCountHistogram( TAB_COUNT_ON_RETURN, getCurrentTabModel().getCount()); } - if (TabUiFeatureUtilities.isGridTabSwitcherEnabled(this) && !isTablet()) { + if (TabUiFeatureUtilities.isGridTabSwitcherEnabled(this)) { mStartSurfaceSupplier.get().getController().enableRecordingFirstMeaningfulPaint( getOnCreateTimestampMs()); }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/app/flags/ChromeCachedFlags.java b/chrome/android/java/src/org/chromium/chrome/browser/app/flags/ChromeCachedFlags.java index 7f0624fb..0a2fbd9 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/app/flags/ChromeCachedFlags.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/app/flags/ChromeCachedFlags.java
@@ -90,6 +90,7 @@ add(ChromeFeatureList.FEED_LOADING_PLACEHOLDER); add(ChromeFeatureList .GIVE_JAVA_UI_THREAD_DEFAULT_TASK_TRAITS_USER_BLOCKING_PRIORITY); + add(ChromeFeatureList.GRID_TAB_SWITCHER_FOR_TABLETS); add(ChromeFeatureList.IMMERSIVE_UI_MODE); add(ChromeFeatureList.INSTANT_START); add(ChromeFeatureList.INSTANCE_SWITCHER);
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/LayoutManagerChromeTablet.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/LayoutManagerChromeTablet.java index be3a638..b593d1df 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/LayoutManagerChromeTablet.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/LayoutManagerChromeTablet.java
@@ -16,8 +16,10 @@ import org.chromium.chrome.browser.tab.TabLaunchType; import org.chromium.chrome.browser.tabmodel.TabCreatorManager; import org.chromium.chrome.browser.tabmodel.TabModelSelector; +import org.chromium.chrome.browser.tasks.tab_management.TabUiFeatureUtilities; import org.chromium.chrome.browser.theme.TopUiThemeColorProvider; import org.chromium.chrome.browser.toolbar.ControlContainer; +import org.chromium.chrome.features.start_surface.StartSurface; import org.chromium.ui.resources.dynamics.DynamicResourceLoader; /** @@ -32,19 +34,22 @@ * Creates an instance of a {@link LayoutManagerChromePhone}. * @param host A {@link LayoutManagerHost} instance. * @param contentContainer A {@link ViewGroup} for Android views to be bound to. + * @param startSurface An interface to talk to the Grid Tab Switcher. * @param tabContentManagerSupplier Supplier of the {@link TabContentManager} instance. * @param layerTitleCacheSupplier Supplier of the {@link LayerTitleCache}. * @param overviewModeBehaviorSupplier Supplier of the {@link OverviewModeBehavior}. * @param topUiThemeColorProvider {@link ThemeColorProvider} for top UI. */ public LayoutManagerChromeTablet(LayoutManagerHost host, ViewGroup contentContainer, + StartSurface startSurface, ObservableSupplier<TabContentManager> tabContentManagerSupplier, Supplier<LayerTitleCache> layerTitleCacheSupplier, OneshotSupplierImpl<OverviewModeBehavior> overviewModeBehaviorSupplier, Supplier<TopUiThemeColorProvider> topUiThemeColorProvider, JankTracker jankTracker) { - super(host, contentContainer, false, null, tabContentManagerSupplier, - layerTitleCacheSupplier, overviewModeBehaviorSupplier, topUiThemeColorProvider, - jankTracker); + super(host, contentContainer, + TabUiFeatureUtilities.isGridTabSwitcherEnabled(host.getContext()), startSurface, + tabContentManagerSupplier, layerTitleCacheSupplier, overviewModeBehaviorSupplier, + topUiThemeColorProvider, jankTracker); mTabStripLayoutHelperManager = new StripLayoutHelperManager(host.getContext(), this, mHost.getLayoutRenderHost(), () -> mTitleCache, layerTitleCacheSupplier);
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/quickactionsearchwidget/QuickActionSearchWidgetProvider.java b/chrome/android/java/src/org/chromium/chrome/browser/quickactionsearchwidget/QuickActionSearchWidgetProvider.java index 3646fda..d0b045d 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/quickactionsearchwidget/QuickActionSearchWidgetProvider.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/quickactionsearchwidget/QuickActionSearchWidgetProvider.java
@@ -45,7 +45,7 @@ * A sub class of {@link QuickActionSearchWidgetProvider} that provides the widget that * can resize. */ - public static class QuickActionSearchWidgetResizableProvider + public static class QuickActionSearchWidgetProviderSearch extends QuickActionSearchWidgetProvider { protected static @Nullable QuickActionSearchWidgetProviderDelegate sSmallWidgetDelegate; protected static @Nullable QuickActionSearchWidgetProviderDelegate sMediumWidgetDelegate; @@ -98,23 +98,6 @@ return sMediumWidgetDelegate; } } - /** - * A sub class of {@link QuickActionSearchWidgetProvider} that provides the widget that - * initially has the small layout. - * Layout constraints are defined in the widget info xml file. - * Dedicated provider required by manifest declaration. - */ - public static class QuickActionSearchWidgetProviderSmall - extends QuickActionSearchWidgetResizableProvider {} - - /** - * A sub class of {@link QuickActionSearchWidgetProvider} that provides the widget that - * initially has the medium layout. - * Layout constraints are defined in the widget info xml file. - * Dedicated provider required by manifest declaration. - */ - public static class QuickActionSearchWidgetProviderMedium - extends QuickActionSearchWidgetResizableProvider {} /** * A sub class of {@link QuickActionSearchWidgetProvider} that provides the widget that @@ -249,8 +232,7 @@ }); QuickActionSearchWidgetProvider dinoWidget = new QuickActionSearchWidgetProviderDino(); - QuickActionSearchWidgetProvider smallWidget = new QuickActionSearchWidgetProviderSmall(); - QuickActionSearchWidgetProvider mediumWidget = new QuickActionSearchWidgetProviderMedium(); + QuickActionSearchWidgetProvider smallWidget = new QuickActionSearchWidgetProviderSearch(); SearchActivityPreferencesManager.addObserver(prefs -> { Context context = ContextUtils.getApplicationContext(); @@ -258,7 +240,6 @@ AppWidgetManager manager = AppWidgetManager.getInstance(context); dinoWidget.updateWidgets(context, manager, prefs, null); smallWidget.updateWidgets(context, manager, prefs, null); - mediumWidget.updateWidgets(context, manager, prefs, null); }); } @@ -274,9 +255,7 @@ private static void setWidgetEnabled( boolean shouldEnableQuickActionSearchWidget, boolean shouldEnableDinoVariant) { setWidgetComponentEnabled( - QuickActionSearchWidgetProviderSmall.class, shouldEnableQuickActionSearchWidget); - setWidgetComponentEnabled( - QuickActionSearchWidgetProviderMedium.class, shouldEnableQuickActionSearchWidget); + QuickActionSearchWidgetProviderSearch.class, shouldEnableQuickActionSearchWidget); setWidgetComponentEnabled( QuickActionSearchWidgetProviderDino.class, shouldEnableDinoVariant); }
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/quickactionsearchwidget/QuickActionSearchWidgetProviderTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/quickactionsearchwidget/QuickActionSearchWidgetProviderTest.java index 57975ae..9a5425a 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/quickactionsearchwidget/QuickActionSearchWidgetProviderTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/quickactionsearchwidget/QuickActionSearchWidgetProviderTest.java
@@ -33,8 +33,7 @@ import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.chrome.R; import org.chromium.chrome.browser.firstrun.FirstRunStatus; -import org.chromium.chrome.browser.quickactionsearchwidget.QuickActionSearchWidgetProvider.QuickActionSearchWidgetProviderMedium; -import org.chromium.chrome.browser.quickactionsearchwidget.QuickActionSearchWidgetProvider.QuickActionSearchWidgetProviderSmall; +import org.chromium.chrome.browser.quickactionsearchwidget.QuickActionSearchWidgetProvider.QuickActionSearchWidgetProviderSearch; import org.chromium.chrome.browser.ui.quickactionsearchwidget.QuickActionSearchWidgetProviderDelegate; /** @@ -112,9 +111,7 @@ @SmallTest public void testVerticalDynamicWidgetResizeForSmallWidgetProvider() { doVerticalDynamicWidgetResize( - "Small Widget provider", new QuickActionSearchWidgetProviderSmall()); - doVerticalDynamicWidgetResize( - "Medium Widget provider", new QuickActionSearchWidgetProviderMedium()); + "Small Widget provider", new QuickActionSearchWidgetProviderSearch()); } private void doVerticalDynamicWidgetResize( @@ -149,9 +146,7 @@ @SmallTest public void testVerticalWidgetResizeOfSmallWidget() { doVerticalWidgetResizeOfSmallWidget( - "Small Widget provider", new QuickActionSearchWidgetProviderSmall()); - doVerticalWidgetResizeOfSmallWidget( - "Medium Widget provider", new QuickActionSearchWidgetProviderMedium()); + "Small Widget provider", new QuickActionSearchWidgetProviderSearch()); } private void doVerticalWidgetResizeOfSmallWidget( @@ -184,9 +179,7 @@ @SmallTest public void testVerticalWidgetResizeOfMediumWidget() { doVerticalWidgetResizeOfMediumWidget( - "Small Widget provider", new QuickActionSearchWidgetProviderSmall()); - doVerticalWidgetResizeOfMediumWidget( - "Medium Widget provider", new QuickActionSearchWidgetProviderMedium()); + "Small Widget provider", new QuickActionSearchWidgetProviderSearch()); } private void doVerticalWidgetResizeOfMediumWidget(
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index 39e227b..f9c76e3 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn
@@ -1296,6 +1296,8 @@ "prefetch/prefetch_proxy/prefetch_proxy_features.h", "prefetch/prefetch_proxy/prefetch_proxy_from_string_url_loader.cc", "prefetch/prefetch_proxy/prefetch_proxy_from_string_url_loader.h", + "prefetch/prefetch_proxy/prefetch_proxy_network_context.cc", + "prefetch/prefetch_proxy/prefetch_proxy_network_context.h", "prefetch/prefetch_proxy/prefetch_proxy_network_context_client.cc", "prefetch/prefetch_proxy/prefetch_proxy_network_context_client.h", "prefetch/prefetch_proxy/prefetch_proxy_origin_decider.cc",
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index f2e63ce..b2c244d6 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc
@@ -7664,6 +7664,11 @@ {"context-menu-popup-style", flag_descriptions::kContextMenuPopupStyleName, flag_descriptions::kContextMenuPopupStyleDescription, kOsAndroid, FEATURE_VALUE_TYPE(chrome::android::kContextMenuPopupStyle)}, + + {"grid-tab-switcher-for-tablets", + flag_descriptions::kGridTabSwitcherForTabletsName, + flag_descriptions::kGridTabSwitcherForTabletsDescription, kOsAndroid, + FEATURE_VALUE_TYPE(chrome::android::kGridTabSwitcherForTablets)}, #endif // defined(OS_ANDROID) #if BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chrome/browser/ash/accessibility/dictation_browsertest.cc b/chrome/browser/ash/accessibility/dictation_browsertest.cc index 2bdae4d..80a0ded 100644 --- a/chrome/browser/ash/accessibility/dictation_browsertest.cc +++ b/chrome/browser/ash/accessibility/dictation_browsertest.cc
@@ -722,6 +722,12 @@ return input_context_handler_->update_preedit_text_call_count(); } + // Retrieves the number of times commit text is updated. + int GetCommitTextCallCount() { + DCHECK(input_context_handler_); + return input_context_handler_->commit_text_call_count(); + } + void WaitForCompositionText(const std::u16string& value) { DCHECK(input_context_handler_); SuccessWaiter waiter( @@ -884,6 +890,32 @@ ASSERT_EQ(0, GetUpdatePreeditTextCallCount()); } +IN_PROC_BROWSER_TEST_P(DictationExtensionTest, + EntersInterimSpeechWhenToggledOff) { + InstallMockInputContextHandler(); + + ToggleDictationWithKeystroke(); + WaitForRecognitionStarted(); + SendFakeSpeechResultAndWait(kFirstSpeechResult, /*is_final=*/false); + WaitForCompositionText(kFirstSpeechResult16); + ToggleDictationWithKeystroke(); + WaitForRecognitionStopped(); + WaitForCommitText(kFirstSpeechResult16); + ASSERT_EQ(1, GetUpdatePreeditTextCallCount()); +} + +// Tests that composition and commit text are not updated if the user +// toggles dictation and no speech results are processed. +IN_PROC_BROWSER_TEST_P(DictationExtensionTest, UserEndsDictationBeforeSpeech) { + InstallMockInputContextHandler(); + ToggleDictationWithKeystroke(); + WaitForRecognitionStarted(); + ToggleDictationWithKeystroke(); + WaitForRecognitionStopped(); + ASSERT_EQ(0, GetUpdatePreeditTextCallCount()); + EXPECT_EQ(0, GetCommitTextCallCount()); +} + // Ensures that the correct metrics are recorded when Dictation is toggled. IN_PROC_BROWSER_TEST_P(DictationExtensionTest, Metrics) { base::HistogramTester histogram_tester_;
diff --git a/chrome/browser/ash/arc/intent_helper/arc_settings_service.cc b/chrome/browser/ash/arc/intent_helper/arc_settings_service.cc index a672ac1..8d5de2b 100644 --- a/chrome/browser/ash/arc/intent_helper/arc_settings_service.cc +++ b/chrome/browser/ash/arc/intent_helper/arc_settings_service.cc
@@ -11,6 +11,7 @@ #include "ash/components/arc/arc_prefs.h" #include "ash/components/arc/arc_util.h" #include "ash/components/arc/mojom/backup_settings.mojom.h" +#include "ash/components/arc/mojom/pip.mojom.h" #include "ash/components/arc/session/arc_bridge_service.h" #include "ash/components/settings/timezone_settings.h" #include "ash/constants/ash_pref_names.h" @@ -41,7 +42,6 @@ #include "chromeos/network/onc/onc_utils.h" #include "chromeos/network/proxy/proxy_config_service_impl.h" #include "components/arc/intent_helper/arc_intent_helper_bridge.h" -#include "components/arc/mojom/pip.mojom.h" #include "components/language/core/browser/pref_names.h" #include "components/onc/onc_pref_names.h" #include "components/prefs/pref_change_registrar.h"
diff --git a/chrome/browser/ash/arc/nearby_share/arc_nearby_share_bridge.cc b/chrome/browser/ash/arc/nearby_share/arc_nearby_share_bridge.cc index 5227cbb..87e6b1c7 100644 --- a/chrome/browser/ash/arc/nearby_share/arc_nearby_share_bridge.cc +++ b/chrome/browser/ash/arc/nearby_share/arc_nearby_share_bridge.cc
@@ -8,6 +8,7 @@ #include "ash/components/arc/arc_browser_context_keyed_service_factory_base.h" #include "ash/components/arc/arc_util.h" +#include "ash/components/arc/mojom/nearby_share.mojom.h" #include "ash/components/arc/session/arc_bridge_service.h" #include "ash/public/cpp/app_types_util.h" #include "base/files/file_util.h" @@ -19,7 +20,6 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "components/arc/intent_helper/custom_tab.h" -#include "components/arc/mojom/nearby_share.mojom.h" #include "content/public/browser/browser_thread.h" namespace arc {
diff --git a/chrome/browser/ash/arc/nearby_share/arc_nearby_share_bridge.h b/chrome/browser/ash/arc/nearby_share/arc_nearby_share_bridge.h index 4940eed..6212118 100644 --- a/chrome/browser/ash/arc/nearby_share/arc_nearby_share_bridge.h +++ b/chrome/browser/ash/arc/nearby_share/arc_nearby_share_bridge.h
@@ -9,9 +9,9 @@ #include <map> #include <memory> +#include "ash/components/arc/mojom/nearby_share.mojom.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/ash/arc/nearby_share/nearby_share_session_impl.h" -#include "components/arc/mojom/nearby_share.mojom.h" #include "components/keyed_service/core/keyed_service.h" class Profile;
diff --git a/chrome/browser/ash/arc/nearby_share/nearby_share_session_impl.h b/chrome/browser/ash/arc/nearby_share/nearby_share_session_impl.h index 8bf562a..2acff465 100644 --- a/chrome/browser/ash/arc/nearby_share/nearby_share_session_impl.h +++ b/chrome/browser/ash/arc/nearby_share/nearby_share_session_impl.h
@@ -5,12 +5,12 @@ #ifndef CHROME_BROWSER_ASH_ARC_NEARBY_SHARE_NEARBY_SHARE_SESSION_IMPL_H_ #define CHROME_BROWSER_ASH_ARC_NEARBY_SHARE_NEARBY_SHARE_SESSION_IMPL_H_ +#include "ash/components/arc/mojom/nearby_share.mojom.h" #include "base/memory/weak_ptr.h" #include "base/scoped_observation.h" #include "base/timer/timer.h" #include "chrome/browser/ash/arc/nearby_share/share_info_file_handler.h" #include "chrome/browser/sharesheet/sharesheet_service.h" -#include "components/arc/mojom/nearby_share.mojom.h" #include "mojo/public/cpp/bindings/remote.h" #include "ui/aura/env.h" #include "ui/aura/env_observer.h"
diff --git a/chrome/browser/ash/arc/nearby_share/share_info_file_handler.h b/chrome/browser/ash/arc/nearby_share/share_info_file_handler.h index 5e833a9..d1314698 100644 --- a/chrome/browser/ash/arc/nearby_share/share_info_file_handler.h +++ b/chrome/browser/ash/arc/nearby_share/share_info_file_handler.h
@@ -10,10 +10,10 @@ #include <memory> #include <vector> +#include "ash/components/arc/mojom/nearby_share.mojom.h" #include "base/files/scoped_temp_dir.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/ash/arc/nearby_share/share_info_file_stream_adapter.h" -#include "components/arc/mojom/nearby_share.mojom.h" #include "content/public/browser/browser_thread.h" class GURL;
diff --git a/chrome/browser/ash/arc/pip/arc_pip_bridge.h b/chrome/browser/ash/arc/pip/arc_pip_bridge.h index 7e9162d1c..12f3606f 100644 --- a/chrome/browser/ash/arc/pip/arc_pip_bridge.h +++ b/chrome/browser/ash/arc/pip/arc_pip_bridge.h
@@ -7,8 +7,8 @@ #include <memory> +#include "ash/components/arc/mojom/pip.mojom.h" #include "ash/components/arc/session/connection_observer.h" -#include "components/arc/mojom/pip.mojom.h" #include "components/keyed_service/core/keyed_service.h" namespace content {
diff --git a/chrome/browser/ash/crosapi/crosapi_util.cc b/chrome/browser/ash/crosapi/crosapi_util.cc index 9cb5e052..d48da61 100644 --- a/chrome/browser/ash/crosapi/crosapi_util.cc +++ b/chrome/browser/ash/crosapi/crosapi_util.cc
@@ -91,6 +91,10 @@ namespace { +// Capability to support reloading the lacros browser on receiving a +// notification that the browser component was successfully updated. +constexpr char kBrowserManagerReloadBrowserCapability[] = "crbug/1237235"; + // Returns the vector containing policy data of the device account. In case of // an error, returns nullopt. absl::optional<std::vector<uint8_t>> GetDeviceAccountPolicy( @@ -382,6 +386,8 @@ ash::features:: IsHoldingSpaceInProgressDownloadsNotificationSuppressionEnabled(); + params->ash_capabilities = {{kBrowserManagerReloadBrowserCapability}}; + return params; }
diff --git a/chrome/browser/ash/input_method/input_method_settings.cc b/chrome/browser/ash/input_method/input_method_settings.cc index c841983..e9eea61 100644 --- a/chrome/browser/ash/input_method/input_method_settings.cc +++ b/chrome/browser/ash/input_method/input_method_settings.cc
@@ -65,9 +65,7 @@ } bool IsFstEngine(const std::string& engine_id) { - return base::StartsWith(engine_id, "xkb:", base::CompareCase::SENSITIVE) || - base::StartsWith(engine_id, "experimental_", - base::CompareCase::SENSITIVE); + return base::StartsWith(engine_id, "xkb:", base::CompareCase::SENSITIVE); } bool IsKoreanEngine(const std::string& engine_id) { @@ -98,12 +96,9 @@ const std::string& engine_id, const InputFieldContext& context) { auto settings = mojom::LatinSettings::New(); - settings->autocorrect = - base::StartsWith(engine_id, "experimental_", - base::CompareCase::SENSITIVE) || - input_method_specific_pref - .FindIntKey("physicalKeyboardAutoCorrectionLevel") - .value_or(0) > 0; + settings->autocorrect = input_method_specific_pref + .FindIntKey("physicalKeyboardAutoCorrectionLevel") + .value_or(0) > 0; settings->predictive_writing = context.multiword_enabled && context.multiword_allowed && !context.lacros_enabled &&
diff --git a/chrome/browser/ash/input_method/native_input_method_engine.cc b/chrome/browser/ash/input_method/native_input_method_engine.cc index fd492ae7..c29a2884 100644 --- a/chrome/browser/ash/input_method/native_input_method_engine.cc +++ b/chrome/browser/ash/input_method/native_input_method_engine.cc
@@ -59,9 +59,7 @@ } bool IsFstEngine(const std::string& engine_id) { - return base::StartsWith(engine_id, "xkb:", base::CompareCase::SENSITIVE) || - base::StartsWith(engine_id, "experimental_", - base::CompareCase::SENSITIVE); + return base::StartsWith(engine_id, "xkb:", base::CompareCase::SENSITIVE); } bool IsKoreanEngine(const std::string& engine_id) { @@ -106,11 +104,7 @@ bool IsPhysicalKeyboardAutocorrectEnabled(PrefService* prefs, const std::string& engine_id) { - if (base::StartsWith(engine_id, "experimental_", - base::CompareCase::SENSITIVE)) { - return true; - } - + // The FST Mojo engine is only needed if autocorrect is enabled. const base::DictionaryValue* input_method_settings = prefs->GetDictionary(::prefs::kLanguageInputMethodSpecificSettings); const base::Value* autocorrect_setting = input_method_settings->FindPath( @@ -584,7 +578,6 @@ // TODO(b/181077907): Always launch the IME service and let IME service decide // whether it should shutdown or not. if (IsFstEngine(engine_id) && ShouldRouteToNativeMojoEngine(engine_id) && - // The FST Mojo engine is only needed if autocorrect is enabled. !IsPhysicalKeyboardAutocorrectEnabled(prefs_, engine_id) && !IsPredictiveWritingEnabled(prefs_, engine_id)) { remote_manager_.reset(); @@ -932,12 +925,7 @@ void NativeInputMethodEngine::ImeObserver::SetComposition( const std::u16string& text, - std::vector<mojom::CompositionSpanPtr> spans, - uint32_t new_cursor_position) { - if (new_cursor_position > text.length()) { - return; - } - + std::vector<mojom::CompositionSpanPtr> spans) { ui::CompositionText composition; composition.text = text; @@ -946,9 +934,9 @@ composition.ime_text_spans.push_back(CompositionSpanToImeTextSpan(*span)); } - GetInputContext()->UpdateCompositionText(std::move(composition), - /*cursor_pos=*/new_cursor_position, - /*visible=*/true); + GetInputContext()->UpdateCompositionText( + std::move(composition), /*cursor_pos=*/composition.text.length(), + /*visible=*/true); } void NativeInputMethodEngine::ImeObserver::SetCompositionRange(
diff --git a/chrome/browser/ash/input_method/native_input_method_engine.h b/chrome/browser/ash/input_method/native_input_method_engine.h index 233f8f1..f79cafe 100644 --- a/chrome/browser/ash/input_method/native_input_method_engine.h +++ b/chrome/browser/ash/input_method/native_input_method_engine.h
@@ -142,8 +142,7 @@ cursor_behavior) override; void SetComposition( const std::u16string& text, - std::vector<chromeos::ime::mojom::CompositionSpanPtr> spans, - uint32_t new_cursor_position) override; + std::vector<chromeos::ime::mojom::CompositionSpanPtr> spans) override; void SetCompositionRange(uint32_t start_index, uint32_t end_index) override; void FinishComposition() override; void DeleteSurroundingText(uint32_t num_before_cursor,
diff --git a/chrome/browser/ash/net/network_diagnostics/arc_dns_resolution_routine.h b/chrome/browser/ash/net/network_diagnostics/arc_dns_resolution_routine.h index 3bd0b49..66b65e9 100644 --- a/chrome/browser/ash/net/network_diagnostics/arc_dns_resolution_routine.h +++ b/chrome/browser/ash/net/network_diagnostics/arc_dns_resolution_routine.h
@@ -8,10 +8,10 @@ #include <string> #include <vector> +#include "ash/components/arc/mojom/net.mojom.h" #include "ash/components/arc/session/arc_bridge_service.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/ash/net/network_diagnostics/network_diagnostics_routine.h" -#include "components/arc/mojom/net.mojom.h" namespace chromeos { namespace network_diagnostics {
diff --git a/chrome/browser/ash/net/network_diagnostics/arc_http_routine.h b/chrome/browser/ash/net/network_diagnostics/arc_http_routine.h index cd5098e..7639808f 100644 --- a/chrome/browser/ash/net/network_diagnostics/arc_http_routine.h +++ b/chrome/browser/ash/net/network_diagnostics/arc_http_routine.h
@@ -7,10 +7,10 @@ #include <vector> +#include "ash/components/arc/mojom/net.mojom.h" #include "ash/components/arc/session/arc_bridge_service.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/ash/net/network_diagnostics/network_diagnostics_routine.h" -#include "components/arc/mojom/net.mojom.h" namespace chromeos { namespace network_diagnostics {
diff --git a/chrome/browser/ash/net/network_diagnostics/arc_ping_routine.h b/chrome/browser/ash/net/network_diagnostics/arc_ping_routine.h index 8df3da7c..fc99452 100644 --- a/chrome/browser/ash/net/network_diagnostics/arc_ping_routine.h +++ b/chrome/browser/ash/net/network_diagnostics/arc_ping_routine.h
@@ -8,11 +8,11 @@ #include <string> #include <vector> +#include "ash/components/arc/mojom/net.mojom.h" #include "ash/components/arc/session/arc_bridge_service.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/ash/net/network_diagnostics/network_diagnostics_routine.h" #include "chromeos/services/network_config/public/mojom/cros_network_config.mojom.h" -#include "components/arc/mojom/net.mojom.h" #include "mojo/public/cpp/bindings/remote.h" namespace chromeos {
diff --git a/chrome/browser/chrome_web_platform_security_metrics_browsertest.cc b/chrome/browser/chrome_web_platform_security_metrics_browsertest.cc index 3cadd331..b027e51 100644 --- a/chrome/browser/chrome_web_platform_security_metrics_browsertest.cc +++ b/chrome/browser/chrome_web_platform_security_metrics_browsertest.cc
@@ -1293,144 +1293,3 @@ // In particular, it would be interesting knowing what happens with iframes? // Are CoopCoepOriginIsolated nested document counted as CoopAndCoepIsolated? // Not doing it would underestimate the usage metric. - -// Check reports for COOP same-origin-allow-popups between two top-level pages. -IN_PROC_BROWSER_TEST_F(ChromeWebPlatformSecurityMetricsBrowserTest, - COOPSOAPByDefaultTopLevel) { - GURL url1 = https_server().GetURL("a.com", "/empty.html"); - GURL url1_soap = https_server().GetURL( - "a.com", - "/set-header?Cross-Origin-Opener-Policy: same-origin-allow-popups"); - GURL url1_unsafe_none = https_server().GetURL( - "a.com", "/set-header?Cross-Origin-Opener-Policy: unsafe-none"); - GURL url2 = https_server().GetURL("b.com", "/empty.html"); - GURL url2_unsafe_none = https_server().GetURL( - "b.com", "/set-header?Cross-Origin-Opener-Policy: unsafe-none"); - const struct { - GURL start_url; - GURL popup_url; - bool expect_report; - } kTestCases[] = {{url1, url1, false}, - {url1, url1_unsafe_none, false}, - {url1_unsafe_none, url1, true}, - {url1_unsafe_none, url1_unsafe_none, false}, - {url1_soap, url1, false}, - {url1, url2, true}, - {url1, url2_unsafe_none, false}, - {url1_unsafe_none, url2, true}, - {url1_unsafe_none, url2_unsafe_none, false}, - {url1_soap, url2, true}}; - - int expected_count = 0; - for (auto const& test : kTestCases) { - SCOPED_TRACE(testing::Message() - << test.start_url.spec() + " opens " + test.popup_url.spec()); - EXPECT_TRUE(content::NavigateToURL(web_contents(), test.start_url)); - content::WebContents* popup = OpenPopup(test.popup_url); - EXPECT_TRUE(WaitForLoadStop(popup)); - EXPECT_TRUE(content::ExecJs(popup, "window.opener.top")); - - if (test.expect_report) { - ++expected_count; - } - CheckCounter(WebFeature::kCrossPageAccessBrokenByCOOPSOAPByDefault, - expected_count); - } -} - -// Check reports for COOP same-origin-allow-popups between coming from a -// same-origin subframe. -IN_PROC_BROWSER_TEST_F(ChromeWebPlatformSecurityMetricsBrowserTest, - COOPSOAPByDefaultSameOriginIframe) { - GURL url1 = https_server().GetURL("a.com", "/empty.html"); - GURL url1_soap = https_server().GetURL( - "a.com", - "/set-header?Cross-Origin-Opener-Policy: same-origin-allow-popups"); - GURL url1_unsafe_none = https_server().GetURL( - "a.com", "/set-header?Cross-Origin-Opener-Policy: unsafe-none"); - GURL url2 = https_server().GetURL("b.com", "/empty.html"); - GURL url2_unsafe_none = https_server().GetURL( - "b.com", "/set-header?Cross-Origin-Opener-Policy: unsafe-none"); - const struct { - GURL start_url; - GURL popup_url; - bool expect_report; - } kTestCases[] = {{url1, url1, false}, - {url1, url1_unsafe_none, false}, - {url1_unsafe_none, url1, true}, - {url1_unsafe_none, url1_unsafe_none, false}, - {url1_soap, url1, false}, - {url1, url2, true}, - {url1, url2_unsafe_none, false}, - {url1_unsafe_none, url2, true}, - {url1_unsafe_none, url2_unsafe_none, false}, - {url1_soap, url2, true}}; - - int expected_count = 0; - for (auto const& test : kTestCases) { - SCOPED_TRACE(testing::Message() - << test.start_url.spec() + " opens " + test.popup_url.spec()); - EXPECT_TRUE(content::NavigateToURL(web_contents(), test.start_url)); - content::WebContents* popup = OpenPopup(test.popup_url); - EXPECT_TRUE(WaitForLoadStop(popup)); - LoadIFrameInWebContents(popup, test.popup_url); - content::RenderFrameHost* subframe = ChildFrameAt(popup->GetMainFrame(), 0); - EXPECT_TRUE(content::ExecJs(subframe, "window.top.opener.top")); - - if (test.expect_report) { - ++expected_count; - } - CheckCounter(WebFeature::kCrossPageAccessBrokenByCOOPSOAPByDefault, - expected_count); - } -} - -// Check reports for COOP same-origin-allow-popups between coming from a -// cross-origin subframe. -IN_PROC_BROWSER_TEST_F(ChromeWebPlatformSecurityMetricsBrowserTest, - COOPSOAPByDefaultCrossOriginIframe) { - GURL url1 = https_server().GetURL("a.com", "/empty.html"); - GURL url1_soap = https_server().GetURL( - "a.com", - "/set-header?Cross-Origin-Opener-Policy: same-origin-allow-popups"); - GURL url1_unsafe_none = https_server().GetURL( - "a.com", "/set-header?Cross-Origin-Opener-Policy: unsafe-none"); - GURL url2 = https_server().GetURL("b.com", "/empty.html"); - GURL url2_unsafe_none = https_server().GetURL( - "b.com", "/set-header?Cross-Origin-Opener-Policy: unsafe-none"); - GURL url3 = https_server().GetURL("c.com", "/empty.html"); - const struct { - GURL start_url; - GURL popup_url; - bool expect_report; - } kTestCases[] = {{url1, url1, false}, - {url1, url1_unsafe_none, false}, - {url1_unsafe_none, url1, true}, - {url1_unsafe_none, url1_unsafe_none, false}, - {url1_soap, url1, false}, - {url1, url2, true}, - {url1, url2_unsafe_none, false}, - {url1_unsafe_none, url2, true}, - {url1_unsafe_none, url2_unsafe_none, false}, - {url1_soap, url2, true}}; - - int expected_count = 0; - for (auto const& test : kTestCases) { - SCOPED_TRACE(testing::Message() - << test.start_url.spec() + " opens " + test.popup_url.spec()); - EXPECT_TRUE(content::NavigateToURL(web_contents(), test.start_url)); - content::WebContents* popup = OpenPopup(test.popup_url); - EXPECT_TRUE(WaitForLoadStop(popup)); - LoadIFrameInWebContents(popup, url3); - content::RenderFrameHost* subframe = ChildFrameAt(popup->GetMainFrame(), 0); - EXPECT_TRUE(content::ExecJs(subframe, "window.top.opener.top")); - - // TODO(https://crbug.com/1238824): Currently, accesses from cross-origin - // frames are not logging use counters. This is because the underlying - // architecture for COOP reporting does not support reports from - // cross-origin frames. This should be modified so that accesses from - // cross-origin frames are also logged in metrics. - CheckCounter(WebFeature::kCrossPageAccessBrokenByCOOPSOAPByDefault, - expected_count); - } -}
diff --git a/chrome/browser/chromeos/extensions/telemetry/api/diagnostics_api_browsertest.cc b/chrome/browser/chromeos/extensions/telemetry/api/diagnostics_api_browsertest.cc index 7e47bb4d..d9d26dc 100644 --- a/chrome/browser/chromeos/extensions/telemetry/api/diagnostics_api_browsertest.cc +++ b/chrome/browser/chromeos/extensions/telemetry/api/diagnostics_api_browsertest.cc
@@ -178,8 +178,9 @@ cros_healthd::mojom::DiagnosticRoutineEnum::kBatteryCapacity); } +// Crashes on ChromeOS: crbug.com/1274591 IN_PROC_BROWSER_TEST_P(TelemetryExtensionDiagnosticsApiBrowserTest, - RunBatteryChargeRoutineSuccess) { + DISABLED_RunBatteryChargeRoutineSuccess) { CreateExtensionAndRunServiceWorker(R"( chrome.test.runTests([ async function runBatteryChargeRoutine() { @@ -276,8 +277,9 @@ cros_healthd::mojom::DiagnosticRoutineEnum::kCpuStress); } +// Crashes on ChromeOS: crbug.com/1274591 IN_PROC_BROWSER_TEST_P(TelemetryExtensionDiagnosticsApiBrowserTest, - RunMemoryRoutineSuccess) { + DISABLED_RunMemoryRoutineSuccess) { CreateExtensionAndRunServiceWorker(R"( chrome.test.runTests([ async function runMemoryRoutine() {
diff --git a/chrome/browser/chromeos/extensions/wallpaper_api.cc b/chrome/browser/chromeos/extensions/wallpaper_api.cc index 9bcad8643..4e5d9b53 100644 --- a/chrome/browser/chromeos/extensions/wallpaper_api.cc +++ b/chrome/browser/chromeos/extensions/wallpaper_api.cc
@@ -219,12 +219,15 @@ // But we should not display the 'wallpaper-set-by-mesage' since it might // introduce confusion as shown in crbug.com/599407. base::StringPiece ext_name; - bool is_file_manager = - (source_context_type() == - extensions::Feature::BLESSED_EXTENSION_CONTEXT || - source_context_type() == extensions::Feature::WEBUI_CONTEXT) && - file_manager::util::IsFileManagerURL( - GetSenderWebContents()->GetLastCommittedURL()); + bool is_file_manager = false; + if (source_context_type() == + extensions::Feature::BLESSED_EXTENSION_CONTEXT || + source_context_type() == extensions::Feature::WEBUI_CONTEXT) { + content::WebContents* web_contents = GetSenderWebContents(); + is_file_manager = + web_contents && file_manager::util::IsFileManagerURL( + web_contents->GetLastCommittedURL()); + } if (!is_file_manager) { ext_name = ext->name(); }
diff --git a/chrome/browser/component_updater/chrome_component_updater_configurator.cc b/chrome/browser/component_updater/chrome_component_updater_configurator.cc index eb0cb8e..e486e58 100644 --- a/chrome/browser/component_updater/chrome_component_updater_configurator.cc +++ b/chrome/browser/component_updater/chrome_component_updater_configurator.cc
@@ -20,8 +20,10 @@ #include "chrome/browser/net/system_network_context_manager.h" #include "chrome/browser/update_client/chrome_update_query_params_delegate.h" #include "chrome/common/channel_info.h" +#include "chrome/common/pref_names.h" #include "components/component_updater/component_updater_command_line_config_policy.h" #include "components/component_updater/configurator_impl.h" +#include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_service.h" #include "components/services/patch/content/patch_service.h" #include "components/services/unzip/content/unzip_service.h" @@ -71,6 +73,7 @@ scoped_refptr<update_client::UnzipperFactory> GetUnzipperFactory() override; scoped_refptr<update_client::PatcherFactory> GetPatcherFactory() override; bool EnabledDeltas() const override; + bool EnabledComponentUpdates() const override; bool EnabledBackgroundDownloader() const override; bool EnabledCupSigning() const override; PrefService* GetPrefService() const override; @@ -212,6 +215,10 @@ return configurator_impl_.EnabledDeltas(); } +bool ChromeConfigurator::EnabledComponentUpdates() const { + return pref_service_->GetBoolean(prefs::kComponentUpdatesEnabled); +} + bool ChromeConfigurator::EnabledBackgroundDownloader() const { return configurator_impl_.EnabledBackgroundDownloader(); } @@ -240,6 +247,12 @@ } // namespace +void RegisterPrefsForChromeComponentUpdaterConfigurator( + PrefRegistrySimple* registry) { + // The component updates are enabled by default, if the preference is not set. + registry->RegisterBooleanPref(prefs::kComponentUpdatesEnabled, true); +} + scoped_refptr<update_client::Configurator> MakeChromeComponentUpdaterConfigurator( const base::CommandLine* cmdline,
diff --git a/chrome/browser/component_updater/chrome_component_updater_configurator.h b/chrome/browser/component_updater/chrome_component_updater_configurator.h index a2b852f..608f1f1 100644 --- a/chrome/browser/component_updater/chrome_component_updater_configurator.h +++ b/chrome/browser/component_updater/chrome_component_updater_configurator.h
@@ -8,6 +8,7 @@ #include "base/memory/ref_counted.h" #include "components/update_client/configurator.h" +class PrefRegistrySimple; class PrefService; namespace base { @@ -16,6 +17,13 @@ namespace component_updater { +// Registers preferences associated with the component updater configurator +// for Chrome. The preferences must be registered with the local pref store +// before they can be queried by the configurator instance. +// This function is called before MakeChromeComponentUpdaterConfigurator. +void RegisterPrefsForChromeComponentUpdaterConfigurator( + PrefRegistrySimple* registry); + scoped_refptr<update_client::Configurator> MakeChromeComponentUpdaterConfigurator( const base::CommandLine* cmdline,
diff --git a/chrome/browser/component_updater/chrome_component_updater_configurator_unittest.cc b/chrome/browser/component_updater/chrome_component_updater_configurator_unittest.cc index dde178e..04e3aba0 100644 --- a/chrome/browser/component_updater/chrome_component_updater_configurator_unittest.cc +++ b/chrome/browser/component_updater/chrome_component_updater_configurator_unittest.cc
@@ -44,6 +44,7 @@ void ChromeComponentUpdaterConfiguratorTest::SetUp() { pref_service_ = std::make_unique<TestingPrefServiceSimple>(); + RegisterPrefsForChromeComponentUpdaterConfigurator(pref_service_->registry()); } TEST_F(ChromeComponentUpdaterConfiguratorTest, TestDisablePings) { @@ -153,6 +154,32 @@ } } +TEST_F(ChromeComponentUpdaterConfiguratorTest, TestEnabledComponentUpdates) { + base::CommandLine cmdline(*base::CommandLine::ForCurrentProcess()); + const auto config( + MakeChromeComponentUpdaterConfigurator(&cmdline, pref_service())); + // Tests the default is set to |true| and the component updates are enabled. + EXPECT_TRUE(config->EnabledComponentUpdates()); + + // Tests the component updates are disabled. + pref_service()->SetManagedPref("component_updates.component_updates_enabled", + std::make_unique<base::Value>(false)); + EXPECT_FALSE(config->EnabledComponentUpdates()); + + // Tests the component updates are enabled. + pref_service()->SetManagedPref("component_updates.component_updates_enabled", + std::make_unique<base::Value>(true)); + EXPECT_TRUE(config->EnabledComponentUpdates()); + + // Sanity check setting the preference back to |false| and then removing it. + pref_service()->SetManagedPref("component_updates.component_updates_enabled", + std::make_unique<base::Value>(false)); + EXPECT_FALSE(config->EnabledComponentUpdates()); + pref_service()->RemoveManagedPref( + "component_updates.component_updates_enabled"); + EXPECT_TRUE(config->EnabledComponentUpdates()); +} + TEST_F(ChromeComponentUpdaterConfiguratorTest, TestProdId) { base::CommandLine cmdline(*base::CommandLine::ForCurrentProcess()); const auto config(
diff --git a/chrome/browser/component_updater/component_updater_prefs.cc b/chrome/browser/component_updater/component_updater_prefs.cc index fd59de27..cd81a4f8 100644 --- a/chrome/browser/component_updater/component_updater_prefs.cc +++ b/chrome/browser/component_updater/component_updater_prefs.cc
@@ -4,11 +4,9 @@ #include "chrome/browser/component_updater/component_updater_prefs.h" -#include "build/build_config.h" #include "chrome/browser/component_updater/chrome_component_updater_configurator.h" #include "chrome/browser/component_updater/recovery_component_installer.h" #include "chrome/common/buildflags.h" -#include "components/component_updater/component_updater_service.h" #include "components/component_updater/installer_policies/autofill_states_component_installer.h" #if !defined(OS_ANDROID) @@ -18,7 +16,7 @@ namespace component_updater { void RegisterPrefs(PrefRegistrySimple* registry) { - RegisterComponentUpdateServicePrefs(registry); + RegisterPrefsForChromeComponentUpdaterConfigurator(registry); RegisterPrefsForRecoveryComponent(registry); AutofillStatesComponentInstallerPolicy::RegisterPrefs(registry); }
diff --git a/chrome/browser/component_updater/cros_component_installer_chromeos_unittest.cc b/chrome/browser/component_updater/cros_component_installer_chromeos_unittest.cc index f97f541..82381e3b 100644 --- a/chrome/browser/component_updater/cros_component_installer_chromeos_unittest.cc +++ b/chrome/browser/component_updater/cros_component_installer_chromeos_unittest.cc
@@ -109,11 +109,9 @@ } // Registers a CRX component for updates. - bool RegisterComponent(const ComponentRegistration& component) { + bool RegisterComponent(const update_client::CrxComponent& component) { component_installers_[component.name] = component.installer; - update_client::CrxComponent crx; - crx.pk_hash = component.public_key_hash; - component_id_to_name_[update_client::GetCrxComponentID(crx)] = + component_id_to_name_[update_client::GetCrxComponentID(component)] = component.name; return true; }
diff --git a/chrome/browser/download/download_target_determiner.cc b/chrome/browser/download/download_target_determiner.cc index aead4b9..5c63f94 100644 --- a/chrome/browser/download/download_target_determiner.cc +++ b/chrome/browser/download/download_target_determiner.cc
@@ -682,9 +682,9 @@ content::PluginService* plugin_service = content::PluginService::GetInstance(); - bool plugin_found = plugin_service->GetPluginInfo( - render_process_id, routing_id, url, url::Origin(), mime_type, false, - &is_stale, &plugin_info, &actual_mime_type); + bool plugin_found = + plugin_service->GetPluginInfo(render_process_id, url, mime_type, false, + &is_stale, &plugin_info, &actual_mime_type); if (is_stale && stale_plugin_action == RETRY_IF_STALE_PLUGIN_LIST) { // The GetPlugins call causes the plugin list to be refreshed. Once that's // done we can retry the GetPluginInfo call. We break out of this cycle
diff --git a/chrome/browser/enterprise/connectors/device_trust/attestation/ash/ash_attestation_service.cc b/chrome/browser/enterprise/connectors/device_trust/attestation/ash/ash_attestation_service.cc index 11f3362..a13cc70 100644 --- a/chrome/browser/enterprise/connectors/device_trust/attestation/ash/ash_attestation_service.cc +++ b/chrome/browser/enterprise/connectors/device_trust/attestation/ash/ash_attestation_service.cc
@@ -8,7 +8,6 @@ #include <string> #include <utility> -#include "base/base64.h" #include "base/bind.h" #include "base/callback.h" #include "base/check.h" @@ -50,22 +49,27 @@ std::unique_ptr<attestation::DeviceTrustSignals> signals, AttestationCallback callback) { DCHECK(signals); - tpm_key_challenger_ = + auto tpm_key_challenger = std::make_unique<ash::attestation::TpmChallengeKeyWithTimeout>(); - tpm_key_challenger_->BuildResponse( + auto* tpm_key_challenger_ptr = tpm_key_challenger.get(); + tpm_key_challenger_ptr->BuildResponse( base::Seconds(15), ash::attestation::KEY_DEVICE, profile_, base::BindOnce(&AshAttestationService::ReturnResult, - weak_factory_.GetWeakPtr(), std::move(callback)), + weak_factory_.GetWeakPtr(), std::move(tpm_key_challenger), + std::move(callback)), JsonChallengeToProtobufChallenge(challenge), /*register_key=*/false, /*key_name_for_spkac=*/std::string(), /*signals=*/*signals); } void AshAttestationService::ReturnResult( + std::unique_ptr<ash::attestation::TpmChallengeKeyWithTimeout> + tpm_key_challenger, AttestationCallback callback, const ash::attestation::TpmChallengeKeyResult& result) { std::string encoded_response; if (result.IsSuccess()) { - base::Base64Encode(result.challenge_response, &encoded_response); + encoded_response = + ProtobufChallengeToJsonChallenge(result.challenge_response); LogAttestationResult(DTAttestationResult::kSuccess); } else { LogAttestationResult(ToAttestationResult(result.result_code));
diff --git a/chrome/browser/enterprise/connectors/device_trust/attestation/ash/ash_attestation_service.h b/chrome/browser/enterprise/connectors/device_trust/attestation/ash/ash_attestation_service.h index bff439a..5caa0ea 100644 --- a/chrome/browser/enterprise/connectors/device_trust/attestation/ash/ash_attestation_service.h +++ b/chrome/browser/enterprise/connectors/device_trust/attestation/ash/ash_attestation_service.h
@@ -36,15 +36,17 @@ AttestationCallback callback) override; private: - // Run the callback that may resume the navigation with the challenge - // response. In case the challenge response was not successfully built. An - // empty challenge response will be used. - void ReturnResult(AttestationCallback callback, - const ash::attestation::TpmChallengeKeyResult& result); + // Runs the `callback` which resumes the navigation with the `result` + // challenge response. In case the challenge response was not successfully + // built. An empty challenge response will be used. `tpm_key_challenger` is + // also forwarded to ensure the instance lives as long as the callback runs. + void ReturnResult( + std::unique_ptr<ash::attestation::TpmChallengeKeyWithTimeout> + tpm_key_challenger, + AttestationCallback callback, + const ash::attestation::TpmChallengeKeyResult& result); Profile* const profile_; - std::unique_ptr<ash::attestation::TpmChallengeKeyWithTimeout> - tpm_key_challenger_; base::WeakPtrFactory<AshAttestationService> weak_factory_{this}; };
diff --git a/chrome/browser/enterprise/connectors/device_trust/attestation/ash/ash_attestation_service_unittest.cc b/chrome/browser/enterprise/connectors/device_trust/attestation/ash/ash_attestation_service_unittest.cc new file mode 100644 index 0000000..8d98ed3 --- /dev/null +++ b/chrome/browser/enterprise/connectors/device_trust/attestation/ash/ash_attestation_service_unittest.cc
@@ -0,0 +1,151 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/enterprise/connectors/device_trust/attestation/ash/ash_attestation_service.h" + +#include <memory> + +#include "base/base64.h" +#include "base/json/json_reader.h" +#include "base/run_loop.h" +#include "base/test/bind.h" +#include "base/test/gmock_callback_support.h" +#include "base/test/task_environment.h" +#include "base/values.h" +#include "chrome/browser/ash/attestation/mock_tpm_challenge_key.h" +#include "chrome/browser/ash/attestation/tpm_challenge_key.h" +#include "chrome/browser/ash/attestation/tpm_challenge_key_result.h" +#include "chrome/browser/enterprise/connectors/device_trust/attestation/common/attestation_utils.h" +#include "chrome/test/base/testing_browser_process.h" +#include "chrome/test/base/testing_profile.h" +#include "chrome/test/base/testing_profile_manager.h" +#include "chromeos/dbus/attestation/attestation_ca.pb.h" +#include "chromeos/dbus/attestation/attestation_client.h" +#include "chromeos/dbus/constants/attestation_constants.h" +#include "content/public/test/browser_task_environment.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" + +using base::test::RunOnceCallback; +using testing::_; +using testing::Invoke; +using testing::StrictMock; + +namespace enterprise_connectors { + +namespace { + +// A sample VerifiedAccess v2 challenge rerepsented as a JSON string. +constexpr char kJsonChallenge[] = + "{" + "\"challenge\": " + "\"CkEKFkVudGVycHJpc2VLZXlDaGFsbGVuZ2USIELlPXqh8+" + "rZJ2VIqwPXtPFrr653QdRrIzHFwqP+" + "b3L8GJTcufirLxKAAkindNwTfwYUcbCFDjiW3kXdmDPE0wC0J6b5ZI6X6vOVcSMXTpK7nxsAGK" + "zFV+i80LCnfwUZn7Ne1bHzloAqBdpLOu53vQ63hKRk6MRPhc9jYVDsvqXfQ7s+" + "FUA5r3lxdoluxwAUMFqcP4VgnMvKzKTPYbnnB+xj5h5BZqjQToXJYoP4VC3/" + "ID+YHNsCWy5o7+G5jnq0ak3zeqWfo1+lCibMPsCM+" + "2g7nCZIwvwWlfoKwv3aKvOVMBcJxPAIxH1w+hH+" + "NWxqRi6qgZm84q0ylm0ybs6TFjdgLvSViAIp0Z9p/An/" + "u3W4CMboCswxIxNYRCGrIIVPElE3Yb4QS65mKrg=\"" + "}"; + +constexpr char kFakeResponse[] = "fake_response"; + +constexpr char kDeviceId[] = "device-id"; +constexpr char kObfuscatedCustomerId[] = "customer-id"; + +absl::optional<std::string> ParseValueFromResponse( + const std::string& response) { + absl::optional<base::Value> data = base::JSONReader::Read( + response, base::JSONParserOptions::JSON_ALLOW_TRAILING_COMMAS); + + // If json is malformed or it doesn't include the needed field return + // an empty string. + if (!data || !data.value().FindPath("challengeResponse")) + return absl::nullopt; + + std::string decoded_response_value; + if (!base::Base64Decode( + data.value().FindPath("challengeResponse")->GetString(), + &decoded_response_value)) { + return absl::nullopt; + } + + return decoded_response_value; +} + +ash::attestation::MockTpmChallengeKey* InjectMockChallengeKey() { + auto mock_challenge_key = + std::make_unique<ash::attestation::MockTpmChallengeKey>(); + ash::attestation::MockTpmChallengeKey* challenge_key_ptr = + mock_challenge_key.get(); + ash::attestation::TpmChallengeKeyFactory::SetForTesting( + std::move(mock_challenge_key)); + return challenge_key_ptr; +} + +} // namespace + +class AshAttestationServiceTest : public testing::Test { + protected: + AshAttestationServiceTest() = default; + + void SetUp() override { + testing::Test::SetUp(); + + chromeos::AttestationClient::InitializeFake(); + + mock_challenge_key_ = InjectMockChallengeKey(); + attestation_service_ = + std::make_unique<AshAttestationService>(&test_profile_); + } + + std::unique_ptr<attestation::DeviceTrustSignals> CreateSignals() { + auto signals = std::make_unique<attestation::DeviceTrustSignals>(); + signals->set_device_id(kDeviceId); + signals->set_obfuscated_customer_id(kObfuscatedCustomerId); + return signals; + } + + content::BrowserTaskEnvironment task_environment_; + std::unique_ptr<AshAttestationService> attestation_service_; + + TestingProfile test_profile_; + ash::attestation::MockTpmChallengeKey* mock_challenge_key_; +}; + +TEST_F(AshAttestationServiceTest, BuildChallengeResponse_Success) { + auto signals = CreateSignals(); + + base::RunLoop run_loop; + auto callback = + base::BindLambdaForTesting([&](const std::string& challenge_response) { + ASSERT_FALSE(challenge_response.empty()); + auto parsed_value = ParseValueFromResponse(challenge_response); + ASSERT_TRUE(parsed_value.has_value()); + EXPECT_EQ(kFakeResponse, parsed_value.value()); + run_loop.Quit(); + }); + + auto protoChallenge = JsonChallengeToProtobufChallenge(kJsonChallenge); + EXPECT_CALL( + *mock_challenge_key_, + BuildResponse(chromeos::attestation::AttestationKeyType::KEY_DEVICE, + /*profile=*/&test_profile_, /*callback=*/_, + /*challenge=*/protoChallenge, + /*register_key=*/false, + /*key_name_for_spkac=*/std::string(), + /*signals=*/_)) + .WillOnce(RunOnceCallback<2>( + ash::attestation::TpmChallengeKeyResult::MakeChallengeResponse( + kFakeResponse))); + + attestation_service_->BuildChallengeResponseForVAChallenge( + kJsonChallenge, std::move(signals), std::move(callback)); + run_loop.Run(); +} + +} // namespace enterprise_connectors
diff --git a/chrome/browser/extensions/extension_disabled_ui.cc b/chrome/browser/extensions/extension_disabled_ui.cc index 0a53a1d..77c4281 100644 --- a/chrome/browser/extensions/extension_disabled_ui.cc +++ b/chrome/browser/extensions/extension_disabled_ui.cc
@@ -91,7 +91,7 @@ void RemoveGlobalError(); raw_ptr<ExtensionService> service_; - raw_ptr<const Extension> extension_; + scoped_refptr<const Extension> extension_; bool is_remote_install_; // How the user responded to the error; used for metrics. @@ -236,8 +236,7 @@ base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::BindOnce(&ExtensionService::GrantPermissionsAndEnableExtension, - service_->AsWeakPtr(), - base::RetainedRef(extension_.get()))); + service_->AsWeakPtr(), base::RetainedRef(extension_))); } void ExtensionDisabledGlobalError::BubbleViewCancelButtonPressed( @@ -250,7 +249,7 @@ base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::BindOnce(&ExtensionUninstallDialog::ConfirmUninstall, uninstall_dialog_->AsWeakPtr(), - base::RetainedRef(extension_.get()), + base::RetainedRef(extension_), UNINSTALL_REASON_EXTENSION_DISABLED, UNINSTALL_SOURCE_PERMISSIONS_INCREASE)); }
diff --git a/chrome/browser/extensions/updater/chrome_update_client_config.cc b/chrome/browser/extensions/updater/chrome_update_client_config.cc index e59396e..fbab584 100644 --- a/chrome/browser/extensions/updater/chrome_update_client_config.cc +++ b/chrome/browser/extensions/updater/chrome_update_client_config.cc
@@ -253,6 +253,10 @@ return impl_.EnabledDeltas(); } +bool ChromeUpdateClientConfig::EnabledComponentUpdates() const { + return impl_.EnabledComponentUpdates(); +} + bool ChromeUpdateClientConfig::EnabledBackgroundDownloader() const { return impl_.EnabledBackgroundDownloader(); }
diff --git a/chrome/browser/extensions/updater/chrome_update_client_config.h b/chrome/browser/extensions/updater/chrome_update_client_config.h index 38c71709..ce596d1 100644 --- a/chrome/browser/extensions/updater/chrome_update_client_config.h +++ b/chrome/browser/extensions/updater/chrome_update_client_config.h
@@ -70,6 +70,7 @@ scoped_refptr<update_client::UnzipperFactory> GetUnzipperFactory() override; scoped_refptr<update_client::PatcherFactory> GetPatcherFactory() override; bool EnabledDeltas() const override; + bool EnabledComponentUpdates() const override; bool EnabledBackgroundDownloader() const override; bool EnabledCupSigning() const override; PrefService* GetPrefService() const override;
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json index c7b86f0..c95c6bdf 100644 --- a/chrome/browser/flag-metadata.json +++ b/chrome/browser/flag-metadata.json
@@ -3328,6 +3328,11 @@ "expiry_milestone": 99 }, { + "name": "grid-tab-switcher-for-tablets", + "owners": [ "nemco", "clank-app-team@google.com" ], + "expiry_milestone": 104 + }, + { "name": "handwriting-gesture-editing", "owners": [ "curtismcmullan", "essential-inputs-team@google.com" ], "expiry_milestone": 95
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc index a6ff788..9c689ff0 100644 --- a/chrome/browser/flag_descriptions.cc +++ b/chrome/browser/flag_descriptions.cc
@@ -3167,6 +3167,10 @@ const char kFeedStampName[] = "StAMP cards in the feed"; const char kFeedStampDescription[] = "Enables StAMP cards in the feed."; +const char kGridTabSwitcherForTabletsName[] = "Grid tab switcher for tablets"; +const char kGridTabSwitcherForTabletsDescription[] = + "Enable grid tab switcher for tablets, replacing the tab strip."; + const char kHomepagePromoCardName[] = "Enable homepage promo card on the New Tab Page"; const char kHomepagePromoCardDescription[] =
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h index be9c018..08fe7661 100644 --- a/chrome/browser/flag_descriptions.h +++ b/chrome/browser/flag_descriptions.h
@@ -1816,6 +1816,9 @@ extern const char kFeedStampName[]; extern const char kFeedStampDescription[]; +extern const char kGridTabSwitcherForTabletsName[]; +extern const char kGridTabSwitcherForTabletsDescription[]; + extern const char kHomepagePromoCardName[]; extern const char kHomepagePromoCardDescription[];
diff --git a/chrome/browser/flags/android/chrome_feature_list.cc b/chrome/browser/flags/android/chrome_feature_list.cc index a239628..ac018c0f 100644 --- a/chrome/browser/flags/android/chrome_feature_list.cc +++ b/chrome/browser/flags/android/chrome_feature_list.cc
@@ -236,6 +236,7 @@ &kFixedUmaSessionResumeOrder, &kFocusOmniboxInIncognitoTabIntents, &kGoogleLensSdkIntent, + &kGridTabSwitcherForTablets, &kHandleMediaIntents, &kHomepagePromoCard, &kImmersiveUiMode, @@ -619,6 +620,9 @@ const base::Feature kFixedUmaSessionResumeOrder{ "FixedUmaSessionResumeOrder", base::FEATURE_DISABLED_BY_DEFAULT}; +const base::Feature kGridTabSwitcherForTablets{ + "GridTabSwitcherForTablets", base::FEATURE_DISABLED_BY_DEFAULT}; + const base::Feature kHandleMediaIntents{"HandleMediaIntents", base::FEATURE_ENABLED_BY_DEFAULT};
diff --git a/chrome/browser/flags/android/chrome_feature_list.h b/chrome/browser/flags/android/chrome_feature_list.h index 8ffb15f..a671ab8 100644 --- a/chrome/browser/flags/android/chrome_feature_list.h +++ b/chrome/browser/flags/android/chrome_feature_list.h
@@ -93,6 +93,7 @@ extern const base::Feature kFixedUmaSessionResumeOrder; extern const base::Feature kFocusOmniboxInIncognitoTabIntents; extern const base::Feature kGoogleLensSdkIntent; +extern const base::Feature kGridTabSwitcherForTablets; extern const base::Feature kHandleMediaIntents; extern const base::Feature kHomepagePromoCard; extern const base::Feature kImmersiveUiMode;
diff --git a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/CachedFeatureFlags.java b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/CachedFeatureFlags.java index 566a807..e339058 100644 --- a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/CachedFeatureFlags.java +++ b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/CachedFeatureFlags.java
@@ -101,6 +101,7 @@ .put(ChromeFeatureList.INSTANCE_SWITCHER, true) .put(ChromeFeatureList.WEB_APK_TRAMPOLINE_ON_INITIAL_INTENT, true) .put(ChromeFeatureList.FEED_LOADING_PLACEHOLDER, false) + .put(ChromeFeatureList.GRID_TAB_SWITCHER_FOR_TABLETS, false) .build(); /**
diff --git a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java index 0b85e8d..9f3d8dd 100644 --- a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java +++ b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java
@@ -356,6 +356,7 @@ public static final String GIVE_JAVA_UI_THREAD_DEFAULT_TASK_TRAITS_USER_BLOCKING_PRIORITY = "GiveJavaUiThreadDefaultTaskTraitsUserBlockingPriority"; public static final String GRANT_NOTIFICATIONS_TO_DSE = "GrantNotificationsToDSE"; + public static final String GRID_TAB_SWITCHER_FOR_TABLETS = "GridTabSwitcherForTablets"; public static final String HANDLE_MEDIA_INTENTS = "HandleMediaIntents"; public static final String HTTPS_FIRST_MODE = "HttpsOnlyMode"; public static final String CHROME_SURVEY_NEXT_ANDROID = "ChromeSurveyNextAndroid";
diff --git a/chrome/browser/metrics/startup_metrics_browsertest.cc b/chrome/browser/metrics/startup_metrics_browsertest.cc index 1aa65ea..1af83f7 100644 --- a/chrome/browser/metrics/startup_metrics_browsertest.cc +++ b/chrome/browser/metrics/startup_metrics_browsertest.cc
@@ -10,25 +10,39 @@ #include "base/run_loop.h" #include "base/test/bind.h" #include "build/build_config.h" -#include "chrome/test/base/in_process_browser_test.h" #include "components/startup_metric_utils/browser/startup_metric_utils.h" #include "content/public/test/browser_test.h" -using StartupMetricsTest = InProcessBrowserTest; +#if defined(OS_ANDROID) +#include "chrome/test/base/android/android_browser_test.h" +#else +#include "chrome/test/base/in_process_browser_test.h" +#endif + +using StartupMetricsTest = PlatformBrowserTest; namespace { constexpr const char* kStartupMetrics[] = { "Startup.BrowserMessageLoopFirstIdle", "Startup.BrowserMessageLoopStartTime", + +// Not Desktop specific but flaky on some Android bots. +// TODO(crbug.com/1252126): Figure out why. +#if !defined(OS_ANDROID) + "Startup.LoadTime.ApplicationStartToChromeMain", + "Startup.LoadTime.ProcessCreateToApplicationStart", +#endif // defined(OS_ANDROID) + +// Desktop specific metrics +#if !defined(OS_ANDROID) "Startup.BrowserWindow.FirstPaint", "Startup.BrowserWindowDisplay", "Startup.FirstWebContents.MainNavigationFinished", "Startup.FirstWebContents.MainNavigationStart", "Startup.FirstWebContents.NonEmptyPaint3", "Startup.FirstWebContents.RenderProcessHostInit.ToNonEmptyPaint", - "Startup.LoadTime.ApplicationStartToChromeMain", - "Startup.LoadTime.ProcessCreateToApplicationStart", +#endif // !defined(OS_ANDROID) #if defined(OS_WIN) "Startup.Temperature",
diff --git a/chrome/browser/optimization_guide/optimization_guide_keyed_service.cc b/chrome/browser/optimization_guide/optimization_guide_keyed_service.cc index 0dde01f..961afb0 100644 --- a/chrome/browser/optimization_guide/optimization_guide_keyed_service.cc +++ b/chrome/browser/optimization_guide/optimization_guide_keyed_service.cc
@@ -19,7 +19,6 @@ #include "chrome/browser/optimization_guide/optimization_guide_keyed_service_factory.h" #include "chrome/browser/optimization_guide/prediction/prediction_manager.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/profiles/profile_manager.h" #include "components/leveldb_proto/public/proto_database_provider.h" #include "components/optimization_guide/core/command_line_top_host_provider.h" #include "components/optimization_guide/core/hints_processing_util.h" @@ -111,21 +110,7 @@ ->GetDefaultStoragePartition() ->GetProtoDatabaseProvider(); base::FilePath profile_path = profile->GetOriginalProfile()->GetPath(); -#if !BUILDFLAG(IS_CHROMEOS_ASH) - // Do not use the primary profile on ChromeOS since it basically is an - // ephemeral profile anyway and we cannot provide hints or models to it - // anyway. Additionally, sign in profiles do not go through the standard - // profile initialization flow, so a lot of things that are required are not - // available when the browser context for the signin profile is created. - if (profile->IsGuestSession()) { - Profile* primary_profile = ProfileManager::GetPrimaryUserProfile(); - if (primary_profile) { - proto_db_provider = primary_profile->GetDefaultStoragePartition() - ->GetProtoDatabaseProvider(); - profile_path = primary_profile->GetPath(); - } - } -#endif + // We have different behavior if |this| is created for an incognito profile. // For incognito profiles, we act in "read-only" mode of the original // profile's store and do not fetch any new hints or models.
diff --git a/chrome/browser/optimization_guide/prediction/prediction_manager_browsertest.cc b/chrome/browser/optimization_guide/prediction/prediction_manager_browsertest.cc index 419861e..50e37cf 100644 --- a/chrome/browser/optimization_guide/prediction/prediction_manager_browsertest.cc +++ b/chrome/browser/optimization_guide/prediction/prediction_manager_browsertest.cc
@@ -814,61 +814,4 @@ CreateBrowser(profile); } -#if !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) -// CreateGuestBrowser() is not supported for Android or ChromeOS out of the box. -IN_PROC_BROWSER_TEST_F(PredictionManagerModelDownloadingBrowserTest, - GuestProfileReceivesModel) { - SetResponseType( - PredictionModelsFetcherRemoteResponseType::kSuccessfulWithValidModelFile); - - { - base::HistogramTester histogram_tester; - // Register in the primary profile and ensure the model returns. - RegisterModelFileObserverWithKeyedService(browser()->profile()); - - std::unique_ptr<base::RunLoop> run_loop = std::make_unique<base::RunLoop>(); - model_file_observer()->set_model_file_received_callback(base::BindOnce( - [](base::RunLoop* run_loop, - proto::OptimizationTarget optimization_target, - const ModelInfo& model_info) { - EXPECT_EQ(optimization_target, - proto::OPTIMIZATION_TARGET_PAINFUL_PAGE_LOAD); - run_loop->Quit(); - }, - run_loop.get())); - run_loop->Run(); - histogram_tester.ExpectUniqueSample( - "OptimizationGuide.PredictionModelDownloadManager.DownloadStatus", - PredictionModelDownloadStatus::kSuccess, 1); - } - - { - base::HistogramTester histogram_tester; - // Now hook everything up in the guest profile and we should still get the - // model back. We should have seen only 1 model fetch/download occur. - Browser* guest_browser = CreateGuestBrowser(); - std::unique_ptr<base::RunLoop> run_loop = std::make_unique<base::RunLoop>(); - ModelFileObserver model_file_observer; - model_file_observer.set_model_file_received_callback(base::BindOnce( - [](base::RunLoop* run_loop, - proto::OptimizationTarget optimization_target, - const ModelInfo& model_info) { - EXPECT_EQ(optimization_target, - proto::OPTIMIZATION_TARGET_PAINFUL_PAGE_LOAD); - run_loop->Quit(); - }, - run_loop.get())); - OptimizationGuideKeyedServiceFactory::GetForProfile( - guest_browser->profile()) - ->AddObserverForOptimizationTargetModel( - proto::OPTIMIZATION_TARGET_PAINFUL_PAGE_LOAD, - /*model_metadata=*/absl::nullopt, &model_file_observer); - - run_loop->Run(); - histogram_tester.ExpectTotalCount( - "OptimizationGuide.PredictionModelDownloadManager.DownloadStatus", 0); - } -} -#endif - } // namespace optimization_guide
diff --git a/chrome/browser/plugins/pdf_iframe_navigation_throttle.cc b/chrome/browser/plugins/pdf_iframe_navigation_throttle.cc index 7f37317..117bf61 100644 --- a/chrome/browser/plugins/pdf_iframe_navigation_throttle.cc +++ b/chrome/browser/plugins/pdf_iframe_navigation_throttle.cc
@@ -62,12 +62,10 @@ bool* is_stale) { content::WebContents* web_contents = navigation_handle->GetWebContents(); int process_id = web_contents->GetMainFrame()->GetProcess()->GetID(); - int routing_id = web_contents->GetMainFrame()->GetRoutingID(); content::WebPluginInfo plugin_info; return content::PluginService::GetInstance()->GetPluginInfo( - process_id, routing_id, navigation_handle->GetURL(), - web_contents->GetMainFrame()->GetLastCommittedOrigin(), kPDFMimeType, + process_id, navigation_handle->GetURL(), kPDFMimeType, false /* allow_wildcard */, is_stale, &plugin_info, nullptr /* actual_mime_type */); }
diff --git a/chrome/browser/policy/test/component_updater_policy_browsertest.cc b/chrome/browser/policy/test/component_updater_policy_browsertest.cc index ce943bf..5536f8e 100644 --- a/chrome/browser/policy/test/component_updater_policy_browsertest.cc +++ b/chrome/browser/policy/test/component_updater_policy_browsertest.cc
@@ -67,14 +67,13 @@ void BeginTest(); void EndTest(); - void UpdateComponent( - const component_updater::ComponentRegistration& crx_component); + void UpdateComponent(const update_client::CrxComponent& crx_component); void CallAsync(TestCaseAction action); void VerifyExpectations(bool update_disabled); void SetEnableComponentUpdates(bool enable_component_updates); - static component_updater::ComponentRegistration MakeComponentRegistration( + static update_client::CrxComponent MakeCrxComponent( bool supports_group_policy_enable_component_updates); TestCase cur_test_case_; @@ -134,8 +133,7 @@ UpdateProviderPolicy(policies); } -component_updater::ComponentRegistration -ComponentUpdaterPolicyTest::MakeComponentRegistration( +update_client::CrxComponent ComponentUpdaterPolicyTest::MakeCrxComponent( bool supports_group_policy_enable_component_updates) { class MockInstaller : public update_client::CrxInstaller { public: @@ -163,24 +161,30 @@ }; // component id "jebgalgnebhfojomionfpkfelancnnkf". - std::vector<uint8_t> jebg_hash = { + static const uint8_t jebg_hash[] = { 0x94, 0x16, 0x0b, 0x6d, 0x41, 0x75, 0xe9, 0xec, 0x8e, 0xd5, 0xfa, 0x54, 0xb0, 0xd2, 0xdd, 0xa5, 0x6e, 0x05, 0x6b, 0xe8, 0x73, 0x47, 0xf6, 0xc4, 0x11, 0x9f, 0xbc, 0xb3, 0x09, 0xb3, 0x5b, 0x40}; // The component uses HTTPS only for network interception purposes. - return component_updater::ComponentRegistration( - "jebgalgnebhfojomionfpkfelancnnkf", {}, jebg_hash, base::Version("0.9"), - {}, {}, nullptr, base::MakeRefCounted<MockInstaller>(), true, - supports_group_policy_enable_component_updates); + update_client::CrxComponent crx_component; + crx_component.pk_hash.assign(std::begin(jebg_hash), std::end(jebg_hash)); + crx_component.app_id = "jebgalgnebhfojomionfpkfelancnnkf"; + crx_component.version = base::Version("0.9"); + crx_component.installer = scoped_refptr<MockInstaller>(new MockInstaller()); + crx_component.requires_network_encryption = true; + crx_component.supports_group_policy_enable_component_updates = + supports_group_policy_enable_component_updates; + + return crx_component; } void ComponentUpdaterPolicyTest::UpdateComponent( - const component_updater::ComponentRegistration& reg) { + const update_client::CrxComponent& crx_component) { post_interceptor_->Reset(); EXPECT_TRUE(post_interceptor_->ExpectRequest( std::make_unique<update_client::PartialMatch>("updatecheck"))); - EXPECT_TRUE(cus_->RegisterComponent(reg)); + EXPECT_TRUE(cus_->RegisterComponent(crx_component)); cus_->GetOnDemandUpdater().OnDemandUpdate( component_id_, component_updater::OnDemandUpdater::Priority::FOREGROUND, base::BindOnce(&ComponentUpdaterPolicyTest::OnDemandComplete, @@ -251,7 +255,7 @@ } void ComponentUpdaterPolicyTest::DefaultPolicy_GroupPolicySupported() { - UpdateComponent(MakeComponentRegistration(true)); + UpdateComponent(MakeCrxComponent(true)); } void ComponentUpdaterPolicyTest::FinishDefaultPolicy_GroupPolicySupported() { @@ -265,7 +269,7 @@ } void ComponentUpdaterPolicyTest::DefaultPolicy_GroupPolicyNotSupported() { - UpdateComponent(MakeComponentRegistration(false)); + UpdateComponent(MakeCrxComponent(false)); } void ComponentUpdaterPolicyTest::FinishDefaultPolicy_GroupPolicyNotSupported() { @@ -280,7 +284,7 @@ void ComponentUpdaterPolicyTest::EnabledPolicy_GroupPolicySupported() { SetEnableComponentUpdates(true); - UpdateComponent(MakeComponentRegistration(true)); + UpdateComponent(MakeCrxComponent(true)); } void ComponentUpdaterPolicyTest::FinishEnabledPolicy_GroupPolicySupported() { @@ -295,7 +299,7 @@ void ComponentUpdaterPolicyTest::EnabledPolicy_GroupPolicyNotSupported() { SetEnableComponentUpdates(true); - UpdateComponent(MakeComponentRegistration(false)); + UpdateComponent(MakeCrxComponent(false)); } void ComponentUpdaterPolicyTest::FinishEnabledPolicy_GroupPolicyNotSupported() { @@ -310,7 +314,7 @@ void ComponentUpdaterPolicyTest::DisabledPolicy_GroupPolicySupported() { SetEnableComponentUpdates(false); - UpdateComponent(MakeComponentRegistration(true)); + UpdateComponent(MakeCrxComponent(true)); } void ComponentUpdaterPolicyTest::FinishDisabled_PolicyGroupPolicySupported() { @@ -326,7 +330,7 @@ void ComponentUpdaterPolicyTest::DisabledPolicy_GroupPolicyNotSupported() { SetEnableComponentUpdates(false); - UpdateComponent(MakeComponentRegistration(false)); + UpdateComponent(MakeCrxComponent(false)); } void ComponentUpdaterPolicyTest::
diff --git a/chrome/browser/prefetch/prefetch_proxy/prefetch_container.cc b/chrome/browser/prefetch/prefetch_proxy/prefetch_container.cc index f928219..171af20 100644 --- a/chrome/browser/prefetch/prefetch_proxy/prefetch_container.cc +++ b/chrome/browser/prefetch/prefetch_proxy/prefetch_container.cc
@@ -6,8 +6,10 @@ #include "base/time/time.h" #include "chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_cookie_listener.h" +#include "chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_network_context.h" #include "chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_params.h" #include "chrome/browser/prefetch/prefetch_proxy/prefetched_mainframe_response_container.h" +#include "chrome/browser/profiles/profile.h" #include "url/gurl.h" PrefetchContainer::PrefetchContainer(const GURL& url, @@ -85,3 +87,13 @@ no_state_prefetch_status_ = no_state_prefetch_status; } + +void PrefetchContainer::CreateNetworkContextForPrefetch(Profile* profile) { + network_context_ = std::make_unique<PrefetchProxyNetworkContext>(profile); +} + +std::unique_ptr<PrefetchProxyNetworkContext> +PrefetchContainer::ReleaseNetworkContext() { + DCHECK(network_context_); + return std::move(network_context_); +}
diff --git a/chrome/browser/prefetch/prefetch_proxy/prefetch_container.h b/chrome/browser/prefetch/prefetch_proxy/prefetch_container.h index e9a7aaa..507e062 100644 --- a/chrome/browser/prefetch/prefetch_proxy/prefetch_container.h +++ b/chrome/browser/prefetch/prefetch_proxy/prefetch_container.h
@@ -8,11 +8,14 @@ #include <memory> #include "chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_cookie_listener.h" +#include "chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_network_context.h" #include "chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_prefetch_status.h" #include "chrome/browser/prefetch/prefetch_proxy/prefetched_mainframe_response_container.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" +class Profile; + // This class contains the state for a request to prefetch a page. This // encompasses the prefetch for the page itself as well as the prefetches for // any subresources for the page. @@ -104,6 +107,13 @@ std::unique_ptr<PrefetchedMainframeResponseContainer> ClonePrefetchedResponse() const; + // The network context used for just this prefetch. + void CreateNetworkContextForPrefetch(Profile* profile); + PrefetchProxyNetworkContext* GetNetworkContext() const { + return network_context_.get(); + } + std::unique_ptr<PrefetchProxyNetworkContext> ReleaseNetworkContext(); + private: // The URL that will potentially be prefetched. // TODO(crbug.com/1266876): The container needs to track the entire redirect @@ -139,6 +149,9 @@ // The time at which |prefetched_response_| was received. This is used to // determine if |prefetched_response_| is stale. absl::optional<base::TimeTicks> prefetch_received_time_; + + // The network context used to prefetch |url_|. + std::unique_ptr<PrefetchProxyNetworkContext> network_context_; }; #endif // CHROME_BROWSER_PREFETCH_PREFETCH_PROXY_PREFETCH_CONTAINER_H_
diff --git a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_browsertest.cc b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_browsertest.cc index 6514322..cd7647958 100644 --- a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_browsertest.cc +++ b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_browsertest.cc
@@ -666,14 +666,16 @@ } } - bool CheckForResourceInIsolatedCache(const GURL& url) { + bool CheckForResourceInIsolatedCache(const GURL& prefetch_url, + const GURL& resource_url) { PrefetchProxyTabHelper* tab_helper = PrefetchProxyTabHelper::FromWebContents(GetWebContents()); DCHECK(tab_helper); - DCHECK(tab_helper->GetIsolatedContextForTesting()); + DCHECK(tab_helper->GetIsolatedContextForTesting(prefetch_url)); return net::OK == - content::LoadBasicRequest(tab_helper->GetIsolatedContextForTesting(), - url, net::LOAD_ONLY_FROM_CACHE); + content::LoadBasicRequest( + tab_helper->GetIsolatedContextForTesting(prefetch_url), + resource_url, net::LOAD_ONLY_FROM_CACHE); } absl::optional<int64_t> GetUKMMetric(const GURL& url, @@ -3176,8 +3178,10 @@ EXPECT_EQ(expected_subresources, manager->successfully_loaded_subresources()); EXPECT_TRUE(CheckForResourceInIsolatedCache( + eligible_link, GetOriginServerURL("/prefetch/prefetch_proxy/prefetch.js"))); EXPECT_TRUE(CheckForResourceInIsolatedCache( + eligible_link, GetOriginServerURL("/prefetch/prefetch_proxy/prefetch-redirect-end.js"))); // Navigate to the predicted site. We expect: @@ -4326,8 +4330,10 @@ EXPECT_EQ(expected_subresources, manager->successfully_loaded_subresources()); EXPECT_TRUE(CheckForResourceInIsolatedCache( + eligible_link, GetOriginServerURL("/prefetch/prefetch_proxy/prefetch.js"))); EXPECT_TRUE(CheckForResourceInIsolatedCache( + eligible_link, GetOriginServerURL("/prefetch/prefetch_proxy/prefetch-redirect-end.js"))); // Navigate to the predicted site. We expect: @@ -4619,3 +4625,102 @@ histogram_tester.ExpectTotalCount( "PrefetchProxy.Prefetch.Mainframe.CookiesToCopy", 0); } + +class IndividualNetworkContextsPrefetchProxyBrowserTest + : public PrefetchProxyBrowserTest { + public: + void SetFeatures() override { + base::CommandLine::ForCurrentProcess()->AppendSwitch( + "isolated-prerender-unlimited-prefetches"); + + scoped_feature_list_.InitAndEnableFeatureWithParameters( + features::kIsolatePrerenders, + {{"use_individual_network_contexts", "true"}}); + } + + private: + base::test::ScopedFeatureList scoped_feature_list_; +}; + +// This test confirms that, when using separate network contexts for each +// prefetch, we do not encounter the cookie collision issue that is possible +// when using a single network context for all prefetches from the same main +// frame. See the SingleNetworkContextPrefetchProxyBrowserTest.CookieCollision +// test above. +IN_PROC_BROWSER_TEST_F(IndividualNetworkContextsPrefetchProxyBrowserTest, + DISABLE_ON_WIN_MAC_CHROMEOS(NoCookieCollision)) { + GURL starting_page = GetOriginServerURL("/simple.html"); + SetDataSaverEnabled(true); + ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), starting_page)); + WaitForUpdatedCustomProxyConfig(); + + PrefetchProxyTabHelper* tab_helper = + PrefetchProxyTabHelper::FromWebContents(GetWebContents()); + + // The two possible prefetches from the same origin with different cookies. + GURL eligible_link_1 = + GetOriginServerURL("/prefetch/prefetch_proxy/prefetch_page.html"); + GURL eligible_link_2 = GetOriginServerURL( + "/prefetch/prefetch_proxy/prefetch_page_different_cookie.html"); + + TestTabHelperObserver tab_helper_observer(tab_helper); + tab_helper_observer.SetExpectedSuccessfulURLs( + {eligible_link_1, eligible_link_2}); + + base::RunLoop prefetch_run_loop; + tab_helper_observer.SetOnPrefetchSuccessfulClosure( + prefetch_run_loop.QuitClosure()); + + GURL doc_url("https://www.google.com/search?q=test"); + MakeNavigationPrediction(doc_url, {eligible_link_1, eligible_link_2}); + + // This run loop will quit when all the prefetch responses have been + // successfully done and processed. + prefetch_run_loop.Run(); + + std::vector<net::test_server::HttpRequest> origin_requests_after_prefetch = + origin_server_requests(); + + base::HistogramTester histogram_tester; + + // Navigate to first predicted site. + ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), eligible_link_1)); + + std::vector<net::test_server::HttpRequest> origin_requests_after_click = + origin_server_requests(); + + EXPECT_GT(origin_requests_after_click.size(), + origin_requests_after_prefetch.size()); + + // Check the cookies used when requesting the image subresource. + bool inspected_image_request = false; + for (size_t i = origin_requests_after_prefetch.size(); + i < origin_requests_after_click.size(); ++i) { + net::test_server::HttpRequest request = origin_requests_after_click[i]; + if (request.GetURL().path() != "/prefetch/prefetch_proxy/image.png") { + continue; + } + inspected_image_request = true; + + auto cookie_iter = request.headers.find("Cookie"); + ASSERT_FALSE(cookie_iter == request.headers.end()); + + // Since each prefetch uses its own network context, when |eligible_link_1| + // is committed, then we only copy over the cookies added from that prefetch + // to the default network context. Any cookies from |eligible_link_2| are + // discarded. + EXPECT_EQ(cookie_iter->second, "type=ChocolateChip"); + } + + EXPECT_TRUE(inspected_image_request); + + histogram_tester.ExpectTotalCount( + "PrefetchProxy.AfterClick.Mainframe.CookieWaitTime", 1); + histogram_tester.ExpectUniqueSample( + "PrefetchProxy.Prefetch.Mainframe.CookiesToCopy", 1, 1); + + EXPECT_EQ("type=ChocolateChip", + content::GetCookies( + browser()->profile(), eligible_link_1, + net::CookieOptions::SameSiteCookieContext::MakeInclusive())); +}
diff --git a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_network_context.cc b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_network_context.cc new file mode 100644 index 0000000..6c24722 --- /dev/null +++ b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_network_context.cc
@@ -0,0 +1,143 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_network_context.h" + +#include "base/callback_helpers.h" +#include "base/command_line.h" +#include "chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_network_context_client.h" +#include "chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_proxy_configurator.h" +#include "chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_service.h" +#include "chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_service_factory.h" +#include "chrome/browser/profiles/profile.h" +#include "components/language/core/browser/pref_names.h" +#include "components/prefs/pref_service.h" +#include "components/version_info/version_info.h" +#include "content/public/browser/network_service_instance.h" +#include "content/public/browser/storage_partition.h" +#include "content/public/common/content_constants.h" +#include "content/public/common/content_switches.h" +#include "content/public/common/user_agent.h" +#include "mojo/public/cpp/bindings/self_owned_receiver.h" +#include "net/base/isolation_info.h" +#include "net/http/http_util.h" +#include "services/cert_verifier/public/mojom/cert_verifier_service_factory.mojom.h" +#include "services/network/public/cpp/wrapper_shared_url_loader_factory.h" +#include "services/network/public/mojom/cookie_manager.mojom.h" +#include "services/network/public/mojom/network_context.mojom.h" + +PrefetchProxyNetworkContext::PrefetchProxyNetworkContext(Profile* profile) + : profile_(profile) {} + +PrefetchProxyNetworkContext::~PrefetchProxyNetworkContext() = default; + +network::mojom::NetworkContext* PrefetchProxyNetworkContext::GetNetworkContext() + const { + DCHECK(network_context_); + return network_context_.get(); +} + +network::mojom::URLLoaderFactory* +PrefetchProxyNetworkContext::GetUrlLoaderFactory() { + if (!url_loader_factory_) { + CreateIsolatedUrlLoaderFactory(); + } + DCHECK(network_context_); + DCHECK(url_loader_factory_); + return url_loader_factory_.get(); +} + +network::mojom::CookieManager* PrefetchProxyNetworkContext::GetCookieManager() { + DCHECK(network_context_); + if (!cookie_manager_) + network_context_->GetCookieManager( + cookie_manager_.BindNewPipeAndPassReceiver()); + + return cookie_manager_.get(); +} + +void PrefetchProxyNetworkContext::CreateNewUrlLoaderFactory( + mojo::PendingReceiver<network::mojom::URLLoaderFactory> pending_receiver, + absl::optional<net::IsolationInfo> isolation_info) { + DCHECK(network_context_); + + auto factory_params = network::mojom::URLLoaderFactoryParams::New(); + factory_params->process_id = network::mojom::kBrowserProcessId; + factory_params->is_trusted = true; + factory_params->is_corb_enabled = false; + if (isolation_info) { + factory_params->isolation_info = *isolation_info; + } + + GetNetworkContext()->CreateURLLoaderFactory(std::move(pending_receiver), + std::move(factory_params)); +} + +void PrefetchProxyNetworkContext::CloseIdleConnections() { + DCHECK(network_context_); + network_context_->CloseIdleConnections(base::DoNothing()); +} + +void PrefetchProxyNetworkContext::CreateIsolatedUrlLoaderFactory() { + network_context_.reset(); + url_loader_factory_.reset(); + + PrefetchProxyService* prefetch_proxy_service = + PrefetchProxyServiceFactory::GetForProfile(profile_); + + auto context_params = network::mojom::NetworkContextParams::New(); + context_params->user_agent = content::GetReducedUserAgent( + base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kUseMobileUserAgent), + version_info::GetMajorVersionNumber()); + context_params->accept_language = net::HttpUtil::GenerateAcceptLanguageHeader( + profile_->GetPrefs()->GetString(language::prefs::kAcceptLanguages)); + context_params->initial_custom_proxy_config = + prefetch_proxy_service->proxy_configurator()->CreateCustomProxyConfig(); + context_params->custom_proxy_connection_observer_remote = + prefetch_proxy_service->proxy_configurator() + ->NewProxyConnectionObserverRemote(); + context_params->cert_verifier_params = content::GetCertVerifierParams( + cert_verifier::mojom::CertVerifierCreationParams::New()); + context_params->cors_exempt_header_list = { + content::kCorsExemptPurposeHeaderName}; + context_params->cookie_manager_params = + network::mojom::CookieManagerParams::New(); + + context_params->http_cache_enabled = true; + DCHECK(!context_params->http_cache_path); + + // Register a client config receiver so that updates to the set of proxy hosts + // or proxy headers will be updated. + mojo::Remote<network::mojom::CustomProxyConfigClient> config_client; + context_params->custom_proxy_config_client_receiver = + config_client.BindNewPipeAndPassReceiver(); + prefetch_proxy_service->proxy_configurator()->AddCustomProxyConfigClient( + std::move(config_client), base::DoNothing()); + + // Explicitly disallow network service features which could cause a privacy + // leak. + context_params->enable_certificate_reporting = false; + context_params->enable_expect_ct_reporting = false; + context_params->enable_domain_reliability = false; + + content::CreateNetworkContextInNetworkService( + network_context_.BindNewPipeAndPassReceiver(), std::move(context_params)); + + // Configure a context client to ensure Web Reports and other privacy leak + // surfaces won't be enabled. + mojo::PendingRemote<network::mojom::NetworkContextClient> client_remote; + mojo::MakeSelfOwnedReceiver( + std::make_unique<PrefetchProxyNetworkContextClient>(), + client_remote.InitWithNewPipeAndPassReceiver()); + network_context_->SetClient(std::move(client_remote)); + + mojo::PendingRemote<network::mojom::URLLoaderFactory> isolated_factory_remote; + + CreateNewUrlLoaderFactory( + isolated_factory_remote.InitWithNewPipeAndPassReceiver(), absl::nullopt); + url_loader_factory_ = network::SharedURLLoaderFactory::Create( + std::make_unique<network::WrapperPendingSharedURLLoaderFactory>( + std::move(isolated_factory_remote))); +}
diff --git a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_network_context.h b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_network_context.h new file mode 100644 index 0000000..a60330fe --- /dev/null +++ b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_network_context.h
@@ -0,0 +1,79 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_PREFETCH_PREFETCH_PROXY_PREFETCH_PROXY_NETWORK_CONTEXT_H_ +#define CHROME_BROWSER_PREFETCH_PREFETCH_PROXY_PREFETCH_PROXY_NETWORK_CONTEXT_H_ + +#include "base/memory/scoped_refptr.h" +#include "base/memory/weak_ptr.h" +#include "mojo/public/cpp/bindings/pending_receiver.h" +#include "mojo/public/cpp/bindings/remote.h" +#include "net/base/isolation_info.h" +#include "services/network/public/cpp/shared_url_loader_factory.h" +#include "services/network/public/mojom/cookie_manager.mojom.h" +#include "services/network/public/mojom/network_context.mojom.h" +#include "services/network/public/mojom/url_loader_factory.mojom.h" +#include "third_party/abseil-cpp/absl/types/optional.h" + +class Profile; + +// An isolated network context used for prefetches. The purpose of using a +// separate network context is to set a custom proxy configuration, and separate +// any cookies. +class PrefetchProxyNetworkContext { + public: + explicit PrefetchProxyNetworkContext(Profile* profile); + ~PrefetchProxyNetworkContext(); + + PrefetchProxyNetworkContext(const PrefetchProxyNetworkContext&) = delete; + PrefetchProxyNetworkContext& operator=(const PrefetchProxyNetworkContext) = + delete; + + // Get a reference to |network_context_|. + network::mojom::NetworkContext* GetNetworkContext() const; + + // Get a reference to |url_loader_factory_|. If it is null, then + // |network_context_| is bound and configured, and a new + // |SharedURLLoaderFactory| is created. + network::mojom::URLLoaderFactory* GetUrlLoaderFactory(); + + // Get a reference to |cookie_manager_|. If it is null, then it is bound to + // the cookie manager of |network_context_|. + network::mojom::CookieManager* GetCookieManager(); + + // Binds |pending_receiver| to a URL loader factory associated with + // |network_context_|. + void CreateNewUrlLoaderFactory( + mojo::PendingReceiver<network::mojom::URLLoaderFactory> pending_receiver, + absl::optional<net::IsolationInfo> isolation_info); + + // Close any idle connections with |network_context_|. + void CloseIdleConnections(); + + base::WeakPtr<PrefetchProxyNetworkContext> GetWeakPtr() { + return weak_factory_.GetWeakPtr(); + } + + private: + // Bind |network_context_| to a new network context and configure it to use + // the prefetch proxy. Also set up |url_loader_factory_| as a new URL loader + // factory for |network_context_|. + void CreateIsolatedUrlLoaderFactory(); + + // The profile to use when configuring |network_context_|. + Profile* profile_; + + // The network context and URL loader factory to use when making prefetches. + mojo::Remote<network::mojom::NetworkContext> network_context_; + scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_; + + // The cookie manager for the isolated |network_context_|. This is used when + // copying cookies from the isolated prefetch network context to the default + // network context after a prefetch is committed. + mojo::Remote<network::mojom::CookieManager> cookie_manager_; + + base::WeakPtrFactory<PrefetchProxyNetworkContext> weak_factory_{this}; +}; + +#endif // CHROME_BROWSER_PREFETCH_PREFETCH_PROXY_PREFETCH_PROXY_NETWORK_CONTEXT_H_
diff --git a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_params.cc b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_params.cc index bb06fbbe..d588a96 100644 --- a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_params.cc +++ b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_params.cc
@@ -275,3 +275,8 @@ return base::GetFieldTrialParamValueByFeature(features::kIsolatePrerenders, "server_experiment_group"); } + +bool PrefetchProxyUseIndividualNetworkContextsForEachPrefetch() { + return base::GetFieldTrialParamByFeatureAsBool( + features::kIsolatePrerenders, "use_individual_network_contexts", false); +}
diff --git a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_params.h b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_params.h index 0547442..48bbedb 100644 --- a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_params.h +++ b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_params.h
@@ -124,4 +124,9 @@ // group, this will return an empty string. std::string PrefetchProxyServerExperimentGroup(); +// Whether each prefetch should have its own isolated network context (return +// true), or if all prefetches from a main frame should share a single isolated +// network context (returns false). +bool PrefetchProxyUseIndividualNetworkContextsForEachPrefetch(); + #endif // CHROME_BROWSER_PREFETCH_PREFETCH_PROXY_PREFETCH_PROXY_PARAMS_H_
diff --git a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper.cc b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper.cc index 6412e94..f03da2e1 100644 --- a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper.cc +++ b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper.cc
@@ -312,8 +312,12 @@ } network::mojom::NetworkContext* -PrefetchProxyTabHelper::GetIsolatedContextForTesting() const { - return page_->isolated_network_context_.get(); +PrefetchProxyTabHelper::GetIsolatedContextForTesting(const GURL& url) const { + PrefetchProxyNetworkContext* network_context = + page_->GetNetworkContextForUrl(url); + if (!network_context) + return nullptr; + return network_context->GetNetworkContext(); } absl::optional<PrefetchProxyTabHelper::AfterSRPMetrics> @@ -659,12 +663,18 @@ service->TakeSubresourceManagerForURL(url); if (manager) { new_page->subresource_manager_ = std::move(manager); - new_page->isolated_cookie_manager_ = - std::move(page_->isolated_cookie_manager_); - new_page->isolated_url_loader_factory_ = - std::move(page_->isolated_url_loader_factory_); - new_page->isolated_network_context_ = - std::move(page_->isolated_network_context_); + + if (PrefetchProxyUseIndividualNetworkContextsForEachPrefetch()) { + auto prefetch_container_iter = page_->prefetch_containers_.find(url); + if (prefetch_container_iter != page_->prefetch_containers_.end() && + prefetch_container_iter->second->GetNetworkContext()) { + new_page->previous_network_context_ = + prefetch_container_iter->second->ReleaseNetworkContext(); + } + } else { + new_page->previous_network_context_ = + std::move(page_->network_context_); + } } } @@ -737,8 +747,16 @@ base::TimeDelta()); } - if (PrefetchProxyCloseIdleSockets() && page_->isolated_network_context_) { - page_->isolated_network_context_->CloseIdleConnections(base::DoNothing()); + if (PrefetchProxyCloseIdleSockets()) { + if (page_->network_context_) { + page_->network_context_->CloseIdleConnections(); + } + + for (const auto& iter : page_->prefetch_containers_) { + if (iter.second->GetNetworkContext()) { + iter.second->GetNetworkContext()->CloseIdleConnections(); + } + } } if (web_contents()->GetVisibility() != content::Visibility::VISIBLE) { @@ -846,7 +864,7 @@ loader->SetAllowHttpErrorResults(true); loader->SetTimeoutDuration(PrefetchProxyTimeoutDuration()); loader->DownloadToString( - GetURLLoaderFactory(), + GetURLLoaderFactory(prefetch_container->GetUrl()), base::BindOnce(&PrefetchProxyTabHelper::OnPrefetchComplete, base::Unretained(this), loader.get(), prefetch_container->GetUrl(), isolation_info), @@ -1101,9 +1119,11 @@ manager->SetPrefetchMetricsCollector(page_->prefetch_metrics_collector_); - manager->SetCreateIsolatedLoaderFactoryCallback( - base::BindRepeating(&PrefetchProxyTabHelper::CreateNewURLLoaderFactory, - weak_factory_.GetWeakPtr())); + DCHECK(page_->GetNetworkContextForUrl(prefetch_container->GetUrl())); + manager->SetCreateIsolatedLoaderFactoryCallback(base::BindRepeating( + &PrefetchProxyNetworkContext::CreateNewUrlLoaderFactory, + page_->GetNetworkContextForUrl(prefetch_container->GetUrl()) + ->GetWeakPtr())); content::SessionStorageNamespace* session_storage_namespace = web_contents()->GetController().GetDefaultSessionStorageNamespace(); @@ -1537,7 +1557,7 @@ PrefetchContainer* prefetch_container) { DCHECK(prefetch_container); - if (!page_->isolated_network_context_) { + if (!page_->GetNetworkContextForUrl(prefetch_container->GetUrl())) { // Not set in unit tests. return; } @@ -1548,18 +1568,15 @@ page_->cookie_copy_status_ = CookieCopyStatus::kWaitingForCopy; - if (!page_->isolated_cookie_manager_) { - page_->isolated_network_context_->GetCookieManager( - page_->isolated_cookie_manager_.BindNewPipeAndPassReceiver()); - } - net::CookieOptions options = net::CookieOptions::MakeAllInclusive(); - page_->isolated_cookie_manager_->GetCookieList( - prefetch_container->GetUrl(), options, - net::CookiePartitionKeychain::Todo(), - base::BindOnce( - &PrefetchProxyTabHelper::OnGotIsolatedCookiesToCopyAfterSRPClick, - weak_factory_.GetWeakPtr(), prefetch_container->GetUrl())); + page_->GetNetworkContextForUrl(prefetch_container->GetUrl()) + ->GetCookieManager() + ->GetCookieList( + prefetch_container->GetUrl(), options, + net::CookiePartitionKeychain::Todo(), + base::BindOnce( + &PrefetchProxyTabHelper::OnGotIsolatedCookiesToCopyAfterSRPClick, + weak_factory_.GetWeakPtr(), prefetch_container->GetUrl())); } void PrefetchProxyTabHelper::OnGotIsolatedCookiesToCopyAfterSRPClick( @@ -1606,95 +1623,12 @@ } } -network::mojom::URLLoaderFactory* -PrefetchProxyTabHelper::GetURLLoaderFactory() { - if (!page_->isolated_url_loader_factory_) { - CreateIsolatedURLLoaderFactory(); - } - DCHECK(page_->isolated_url_loader_factory_); - return page_->isolated_url_loader_factory_.get(); -} - -void PrefetchProxyTabHelper::CreateNewURLLoaderFactory( - mojo::PendingReceiver<network::mojom::URLLoaderFactory> pending_receiver, - absl::optional<net::IsolationInfo> isolation_info) { - DCHECK(page_->isolated_network_context_); - - auto factory_params = network::mojom::URLLoaderFactoryParams::New(); - factory_params->process_id = network::mojom::kBrowserProcessId; - factory_params->is_trusted = true; - factory_params->is_corb_enabled = false; - if (isolation_info) { - factory_params->isolation_info = *isolation_info; - } - - page_->isolated_network_context_->CreateURLLoaderFactory( - std::move(pending_receiver), std::move(factory_params)); -} - -void PrefetchProxyTabHelper::CreateIsolatedURLLoaderFactory() { - page_->isolated_network_context_.reset(); - page_->isolated_url_loader_factory_.reset(); - - PrefetchProxyService* prefetch_proxy_service = - PrefetchProxyServiceFactory::GetForProfile(profile_); - - auto context_params = network::mojom::NetworkContextParams::New(); - context_params->user_agent = content::GetReducedUserAgent( - base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kUseMobileUserAgent), - version_info::GetMajorVersionNumber()); - context_params->accept_language = net::HttpUtil::GenerateAcceptLanguageHeader( - profile_->GetPrefs()->GetString(language::prefs::kAcceptLanguages)); - context_params->initial_custom_proxy_config = - prefetch_proxy_service->proxy_configurator()->CreateCustomProxyConfig(); - context_params->custom_proxy_connection_observer_remote = - prefetch_proxy_service->proxy_configurator() - ->NewProxyConnectionObserverRemote(); - context_params->cert_verifier_params = content::GetCertVerifierParams( - cert_verifier::mojom::CertVerifierCreationParams::New()); - context_params->cors_exempt_header_list = { - content::kCorsExemptPurposeHeaderName}; - context_params->cookie_manager_params = - network::mojom::CookieManagerParams::New(); - - context_params->http_cache_enabled = true; - DCHECK(!context_params->http_cache_path); - - // Also register a client config receiver so that updates to the set of proxy - // hosts or proxy headers will be updated. - mojo::Remote<network::mojom::CustomProxyConfigClient> config_client; - context_params->custom_proxy_config_client_receiver = - config_client.BindNewPipeAndPassReceiver(); - prefetch_proxy_service->proxy_configurator()->AddCustomProxyConfigClient( - std::move(config_client), base::DoNothing()); - - // Explicitly disallow network service features which could cause a privacy - // leak. - context_params->enable_certificate_reporting = false; - context_params->enable_expect_ct_reporting = false; - context_params->enable_domain_reliability = false; - - content::CreateNetworkContextInNetworkService( - page_->isolated_network_context_.BindNewPipeAndPassReceiver(), - std::move(context_params)); - - // Configure a context client to ensure Web Reports and other privacy leak - // surfaces won't be enabled. - mojo::PendingRemote<network::mojom::NetworkContextClient> client_remote; - mojo::MakeSelfOwnedReceiver( - std::make_unique<PrefetchProxyNetworkContextClient>(), - client_remote.InitWithNewPipeAndPassReceiver()); - page_->isolated_network_context_->SetClient(std::move(client_remote)); - - mojo::PendingRemote<network::mojom::URLLoaderFactory> isolated_factory_remote; - - CreateNewURLLoaderFactory( - isolated_factory_remote.InitWithNewPipeAndPassReceiver(), absl::nullopt); - - page_->isolated_url_loader_factory_ = network::SharedURLLoaderFactory::Create( - std::make_unique<network::WrapperPendingSharedURLLoaderFactory>( - std::move(isolated_factory_remote))); +network::mojom::URLLoaderFactory* PrefetchProxyTabHelper::GetURLLoaderFactory( + const GURL& url) { + if (!page_->GetNetworkContextForUrl(url)) + page_->CreateNetworkContextForUrl(url); + DCHECK(page_->GetNetworkContextForUrl(url)); + return page_->GetNetworkContextForUrl(url)->GetUrlLoaderFactory(); } bool PrefetchProxyTabHelper::HaveCookiesChanged(const GURL& url) const { @@ -1704,4 +1638,28 @@ return prefetch_container_iter->second->HaveCookiesChanged(); } +void PrefetchProxyTabHelper::CurrentPageLoad::CreateNetworkContextForUrl( + const GURL& url) { + if (PrefetchProxyUseIndividualNetworkContextsForEachPrefetch()) { + auto prefetch_container_iter = prefetch_containers_.find(url); + if (prefetch_container_iter != prefetch_containers_.end()) + prefetch_container_iter->second->CreateNetworkContextForPrefetch( + profile_); + return; + } + network_context_ = std::make_unique<PrefetchProxyNetworkContext>(profile_); +} + +PrefetchProxyNetworkContext* +PrefetchProxyTabHelper::CurrentPageLoad::GetNetworkContextForUrl( + const GURL& url) const { + if (PrefetchProxyUseIndividualNetworkContextsForEachPrefetch()) { + auto prefetch_container_iter = prefetch_containers_.find(url); + if (prefetch_container_iter == prefetch_containers_.end()) + return nullptr; + return prefetch_container_iter->second->GetNetworkContext(); + } + return network_context_.get(); +} + WEB_CONTENTS_USER_DATA_KEY_IMPL(PrefetchProxyTabHelper);
diff --git a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper.h b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper.h index 603c5f4..3bb9965 100644 --- a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper.h +++ b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper.h
@@ -19,6 +19,7 @@ #include "chrome/browser/navigation_predictor/navigation_predictor_keyed_service.h" #include "chrome/browser/prefetch/prefetch_proxy/prefetch_container.h" #include "chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_cookie_listener.h" +#include "chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_network_context.h" #include "chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_prefetch_status.h" #include "chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_probe_result.h" #include "chrome/browser/prefetch/prefetch_proxy/prefetched_mainframe_response_container.h" @@ -226,7 +227,8 @@ void AddObserverForTesting(Observer* observer); void RemoveObserverForTesting(Observer* observer); - network::mojom::NetworkContext* GetIsolatedContextForTesting() const; + network::mojom::NetworkContext* GetIsolatedContextForTesting( + const GURL& url) const; // Sets the service_worker_context_for_test_ with a FakeServiceWorkerContext // for the the purpose of testing. @@ -237,7 +239,8 @@ protected: // Exposed for testing. explicit PrefetchProxyTabHelper(content::WebContents* web_contents); - virtual network::mojom::URLLoaderFactory* GetURLLoaderFactory(); + virtual network::mojom::URLLoaderFactory* GetURLLoaderFactory( + const GURL& url); private: friend class PrefetchProxyPageLoadMetricsObserver; @@ -262,6 +265,14 @@ explicit CurrentPageLoad(content::NavigationHandle* handle); ~CurrentPageLoad(); + // Helper functions to create / get the network context for a given URL. If + // |PrefetchProxyUseIndividualNetworkContextsForEachPrefetch| is true, then + // this will use the network context for a single prefetch in + // |prefetch_containers_|. Otherwise this will use this instances + // |network_context_|. + void CreateNetworkContextForUrl(const GURL& url); + PrefetchProxyNetworkContext* GetNetworkContextForUrl(const GURL& url) const; + raw_ptr<Profile> profile_; // The set of URLs that can potentially be prefetched, and the state @@ -316,8 +327,8 @@ // is taken from |PrefetchProxyService| and used to facilitate loading // of prefetched resources from cache. Note: An // |PrefetchProxySubresourceManager| is dependent on the - // |isolated_url_loader_factory_| and |isolated_network_context_| from the - // previous page load remaining alive. + // |PrefetchProxyNetworkContext|s from the previous page load remaining + // alive. std::unique_ptr<PrefetchProxySubresourceManager> subresource_manager_; // The current status of copying cookies for the next page load when the @@ -327,12 +338,17 @@ // A callback that runs once |cookie_copy_status_| is set to copy complete. base::OnceClosure on_after_srp_cookie_copy_complete_; - // The cookie manager, network contextm and url loader factory that will be - // used for prefetches. A separate network context is used so that the - // prefetch proxy can be used via a custom proxy configuration. - mojo::Remote<network::mojom::NetworkContext> isolated_network_context_; - mojo::Remote<network::mojom::CookieManager> isolated_cookie_manager_; - scoped_refptr<network::SharedURLLoaderFactory> isolated_url_loader_factory_; + // If |PrefetchProxyUseIndividualNetworkContextsForEachPrefetch| is false + // then this network context is used for all prefetches for this page load. + // Otherwise each prefetch in |prefetch_containers_| will use its own + // network context. The main purpose of using separate network contexts is + // allow for a custom proxy configuration. + std::unique_ptr<PrefetchProxyNetworkContext> network_context_; + + // This keeps the network context used to prefetch the current page load + // from the previous page load alive, if the current page load was + // prerendered, because |subresource_manager_| is dependent on it. + std::unique_ptr<PrefetchProxyNetworkContext> previous_network_context_; }; // Returns true if the current profile is not incognito and meets any @@ -426,13 +442,6 @@ bool eligible, absl::optional<PrefetchProxyPrefetchStatus> status); - // Creates a new URL Loader Factory on |page_|'s isolated network context. - // |isolation_info| may be passed if the factory will be used in the renderer - // for subresources. - void CreateNewURLLoaderFactory( - mojo::PendingReceiver<network::mojom::URLLoaderFactory> pending_receiver, - absl::optional<net::IsolationInfo> isolation_info); - // Starts a query for all cookies associated with |prefetch_container|| in the // isolated cookie jar so that they can be copied to the normal profile. After // this method is called, |IsWaitingForAfterSRPCookiesCopy| returns true until @@ -451,9 +460,6 @@ // if any, is run. void OnCopiedIsolatedCookiesAfterSRPClick(); - // Creates the isolated network context and url loader factory for this page. - void CreateIsolatedURLLoaderFactory(); - // Prepare to serve prefetched resources for the given |url| when a navigation // to that url is started. This initiates the copying of cookies from the // isolated network context to the default context, and notifies the
diff --git a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper_unittest.cc b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper_unittest.cc index 6d66a255..1d6a6e53 100644 --- a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper_unittest.cc +++ b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper_unittest.cc
@@ -84,7 +84,8 @@ url_loader_factory_ = url_loader_factory; } - network::mojom::URLLoaderFactory* GetURLLoaderFactory() override { + network::mojom::URLLoaderFactory* GetURLLoaderFactory( + const GURL& url) override { return url_loader_factory_.get(); }
diff --git a/chrome/browser/prerender/prerender_omnibox_ui_browsertest.cc b/chrome/browser/prerender/prerender_omnibox_ui_browsertest.cc new file mode 100644 index 0000000..a8d6bfa --- /dev/null +++ b/chrome/browser/prerender/prerender_omnibox_ui_browsertest.cc
@@ -0,0 +1,180 @@ +// Copyright 2021 The Chromium 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 <string> + +#include "base/bind.h" +#include "base/files/file_path.h" +#include "base/path_service.h" +#include "base/test/metrics/histogram_tester.h" +#include "build/build_config.h" +#include "chrome/browser/predictors/autocomplete_action_predictor.h" +#include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" +#include "chrome/browser/ui/browser_window.h" +#include "chrome/browser/ui/location_bar/location_bar.h" +#include "chrome/browser/ui/omnibox/omnibox_tab_helper.h" +#include "chrome/common/chrome_features.h" +#include "chrome/common/chrome_paths.h" +#include "chrome/test/base/in_process_browser_test.h" +#include "chrome/test/base/interactive_test_utils.h" +#include "components/omnibox/browser/omnibox_edit_model.h" +#include "content/public/browser/navigation_handle.h" +#include "content/public/browser/web_contents_observer.h" +#include "content/public/test/browser_test.h" +#include "content/public/test/browser_test_utils.h" +#include "content/public/test/prerender_test_util.h" +#include "content/public/test/test_navigation_observer.h" +#include "net/dns/mock_host_resolver.h" +#include "net/test/embedded_test_server/embedded_test_server.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +// This is a browser test for Omnibox triggered prerendering. This is +// implemented as an interactive UI test so that it can emulate navigation +// initiated by URL typed on the Omnibox. +class PrerenderOmniboxUIBrowserTest : public InProcessBrowserTest, + public content::WebContentsObserver { + public: + PrerenderOmniboxUIBrowserTest() + : prerender_helper_(base::BindRepeating( + &PrerenderOmniboxUIBrowserTest::GetActiveWebContents, + base::Unretained(this))) { + scoped_feature_list_.InitAndEnableFeature( + features::kOmniboxTriggerForPrerender2); + } + + void SetUp() override { + prerender_helper_.SetUp(embedded_test_server()); + InProcessBrowserTest::SetUp(); + } + + void SetUpOnMainThread() override { + host_resolver()->AddRule("*", "127.0.0.1"); + embedded_test_server()->ServeFilesFromDirectory( + base::PathService::CheckedGet(chrome::DIR_TEST_DATA)); + ASSERT_TRUE(embedded_test_server()->Start()); + } + + void TearDownOnMainThread() override { + ASSERT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete()); + } + + content::WebContents* GetActiveWebContents() { + return browser()->tab_strip_model()->GetActiveWebContents(); + } + + content::test::PrerenderTestHelper& prerender_helper() { + return prerender_helper_; + } + + // Returns last committed page transition type. This value is only + // meaningful after calling Observe(GetActiveWebContents()) in the test case + // and after DidFinishNavigation. + ui::PageTransition GetLastPageTransitionType() { + return last_finished_page_transition_type_; + } + + // Returns last committed page is prerendered or not. This value is only + // meaningful after calling Observe(GetActiveWebContents()) in the test case + // and after DidFinishNavigation. + bool IsPrerenderingNavigation() { return is_prerendering_page_; } + + protected: + void StartOmniboxPrerenderingAndWaitForActivation(const GURL& url) { + SetOmniboxText(url.spec()); + PressEnterAndWaitForActivation(url); + } + + predictors::AutocompleteActionPredictor* GetAutocompleteActionPredictor() { + return predictors::AutocompleteActionPredictorFactory::GetForProfile( + browser()->profile()); + } + + private: + OmniboxView* omnibox() { + return browser()->window()->GetLocationBar()->GetOmniboxView(); + } + + void FocusOmnibox() { + // If the omnibox already has focus, just notify OmniboxTabHelper. + if (omnibox()->model()->has_focus()) { + OmniboxTabHelper::FromWebContents(GetActiveWebContents()) + ->OnFocusChanged(OMNIBOX_FOCUS_VISIBLE, + OMNIBOX_FOCUS_CHANGE_EXPLICIT); + } else { + browser()->window()->GetLocationBar()->FocusLocation(false); + } + } + + void SetOmniboxText(const std::string& text) { + FocusOmnibox(); + // Enter user input mode to prevent spurious unelision. + omnibox()->model()->SetInputInProgress(true); + omnibox()->OnBeforePossibleChange(); + omnibox()->SetUserText(base::UTF8ToUTF16(text), true); + omnibox()->OnAfterPossibleChange(true); + } + + void PressEnter() { + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, + base::BindOnce( + [](const Browser* browser, bool ctrl_key) { + EXPECT_TRUE(ui_test_utils::SendKeyPressSync( + browser, ui::VKEY_RETURN, ctrl_key, false, false, false)); + }, + browser(), false)); + } + + // Presses enter and waits for Activation + void PressEnterAndWaitForActivation(const GURL& url) { + content::test::PrerenderHostObserver prerender_observer( + *GetActiveWebContents(), url); + PressEnter(); + prerender_observer.WaitForActivation(); + } + + // WebContentsObserver: + void DidFinishNavigation( + content::NavigationHandle* navigation_handle) override { + last_finished_page_transition_type_ = + navigation_handle->GetPageTransition(); + is_prerendering_page_ = navigation_handle->IsPrerenderedPageActivation(); + } + + content::test::PrerenderTestHelper prerender_helper_; + base::test::ScopedFeatureList scoped_feature_list_; + ui::PageTransition last_finished_page_transition_type_; + bool is_prerendering_page_; +}; + +// This test covers the path from starting a omnibox triggered prerendering +// by AutocompleteActionPredictor, and simulate the omnibox input to check +// that prerendering can be activated successfully and the page transition type +// is correctly set as (ui::PAGE_TRANSITION_TYPED | +// ui::PAGE_TRANSITION_FROM_ADDRESS_BAR). +IN_PROC_BROWSER_TEST_F(PrerenderOmniboxUIBrowserTest, + PrerenderingByAutocompleteActionPredictorCanActivate) { + Observe(GetActiveWebContents()); + base::HistogramTester histogram_tester; + const GURL kInitialUrl = embedded_test_server()->GetURL("/empty.html"); + ASSERT_TRUE(GetActiveWebContents()); + ASSERT_TRUE(content::NavigateToURL(GetActiveWebContents(), kInitialUrl)); + + // Attempt to prerender a direct URL input. + ASSERT_TRUE(GetAutocompleteActionPredictor()); + const GURL kPrerenderingUrl = + embedded_test_server()->GetURL("/empty.html?prerender"); + GetAutocompleteActionPredictor()->StartPrerendering( + kPrerenderingUrl, *GetActiveWebContents(), gfx::Size(50, 50)); + StartOmniboxPrerenderingAndWaitForActivation(kPrerenderingUrl); + EXPECT_EQ(static_cast<int>(GetLastPageTransitionType()), + static_cast<int>(ui::PAGE_TRANSITION_TYPED | + ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)); + EXPECT_TRUE(IsPrerenderingNavigation()); + EXPECT_EQ(GetActiveWebContents()->GetLastCommittedURL(), kPrerenderingUrl); +} + +} // namespace
diff --git a/chrome/browser/printing/print_job.cc b/chrome/browser/printing/print_job.cc index 2a5b203..2874452 100644 --- a/chrome/browser/printing/print_job.cc +++ b/chrome/browser/printing/print_job.cc
@@ -513,6 +513,17 @@ base::RetainedRef(document_)))); } +#if defined(OS_WIN) +void PrintJob::OnPageDone(PrintedPage* page) { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + if (pdf_conversion_state_) { + pdf_conversion_state_->OnPageProcessed( + base::BindRepeating(&PrintJob::OnPdfPageConverted, this)); + } + document_->DropPage(page); +} +#endif // defined(OS_WIN) + void PrintJob::OnNotifyPrintJobEvent(const JobEventDetails& event_details) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); @@ -526,15 +537,6 @@ content::GetUIThreadTaskRunner({})->PostTask( FROM_HERE, base::BindOnce(&PrintJob::OnDocumentDone, this)); break; -#if defined(OS_WIN) - case JobEventDetails::PAGE_DONE: - if (pdf_conversion_state_) { - pdf_conversion_state_->OnPageProcessed( - base::BindRepeating(&PrintJob::OnPdfPageConverted, this)); - } - document_->DropPage(event_details.page()); - break; -#endif // defined(OS_WIN) default: break; } @@ -613,14 +615,6 @@ is_job_pending_ = pending; } -#if defined(OS_WIN) -JobEventDetails::JobEventDetails(Type type, - int job_id, - PrintedDocument* document, - PrintedPage* page) - : document_(document), page_(page), type_(type), job_id_(job_id) {} -#endif - JobEventDetails::JobEventDetails(Type type, int job_id, PrintedDocument* document) @@ -631,8 +625,4 @@ PrintedDocument* JobEventDetails::document() const { return document_.get(); } -#if defined(OS_WIN) -PrintedPage* JobEventDetails::page() const { return page_.get(); } -#endif - } // namespace printing
diff --git a/chrome/browser/printing/print_job.h b/chrome/browser/printing/print_job.h index c1808c6..bb89591 100644 --- a/chrome/browser/printing/print_job.h +++ b/chrome/browser/printing/print_job.h
@@ -84,6 +84,9 @@ // of pages, because all PDF pages will be converted, but only the user's // selected pages should be sent to the printer. See https://crbug.com/823876. void ResetPageMapping(); + + // Called when |page| is done printing. + void OnPageDone(PrintedPage* page); #endif // content::NotificationObserver implementation. @@ -254,20 +257,9 @@ JOB_DONE, // An error occured. Printing is canceled. - FAILED, - -#if defined(OS_WIN) - // A page is done printing. Only used on Windows. - PAGE_DONE, -#endif + FAILED }; -#if defined(OS_WIN) - JobEventDetails(Type type, - int job_id, - PrintedDocument* document, - PrintedPage* page); -#endif JobEventDetails(Type type, int job_id, PrintedDocument* document); JobEventDetails(const JobEventDetails&) = delete; @@ -275,9 +267,6 @@ // Getters. PrintedDocument* document() const; -#if defined(OS_WIN) - PrintedPage* page() const; -#endif Type type() const { return type_; } @@ -289,9 +278,6 @@ ~JobEventDetails(); scoped_refptr<PrintedDocument> document_; -#if defined(OS_WIN) - scoped_refptr<PrintedPage> page_; -#endif const Type type_; int job_id_; };
diff --git a/chrome/browser/printing/print_job_worker.cc b/chrome/browser/printing/print_job_worker.cc index f4b73ced..50dc36e 100644 --- a/chrome/browser/printing/print_job_worker.cc +++ b/chrome/browser/printing/print_job_worker.cc
@@ -129,17 +129,8 @@ } #if defined(OS_WIN) -void PageNotificationCallback(PrintJob* print_job, - JobEventDetails::Type detail_type, - int job_id, - PrintedDocument* document, - PrintedPage* page) { - auto details = base::MakeRefCounted<JobEventDetails>(detail_type, job_id, - document, page); - content::NotificationService::current()->Notify( - chrome::NOTIFICATION_PRINT_JOB_EVENT, - content::Source<PrintJob>(print_job), - content::Details<JobEventDetails>(details.get())); +void PageNotificationCallback(PrintJob* print_job, PrintedPage* page) { + print_job->OnPageDone(page); } #endif @@ -533,12 +524,10 @@ // Signal everyone that the page is printed. DCHECK(print_job_); - print_job_->PostTask( - FROM_HERE, - base::BindOnce(&PageNotificationCallback, - base::RetainedRef(print_job_.get()), - JobEventDetails::PAGE_DONE, printing_context_->job_id(), - base::RetainedRef(document_), base::RetainedRef(page))); + print_job_->PostTask(FROM_HERE, + base::BindOnce(&PageNotificationCallback, + base::RetainedRef(print_job_.get()), + base::RetainedRef(page))); } #endif // defined(OS_WIN)
diff --git a/chrome/browser/printing/print_view_manager_base.cc b/chrome/browser/printing/print_view_manager_base.cc index c338885..82b23fa 100644 --- a/chrome/browser/printing/print_view_manager_base.cc +++ b/chrome/browser/printing/print_view_manager_base.cc
@@ -204,26 +204,7 @@ #if BUILDFLAG(ENABLE_PRINT_PREVIEW) #if defined(OS_WIN) -content::WebContents* GetWebContentsForRenderFrame(int render_process_id, - int render_frame_id) { - DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - content::RenderFrameHost* frame = - content::RenderFrameHost::FromID(render_process_id, render_frame_id); - return frame ? content::WebContents::FromRenderFrameHost(frame) : nullptr; -} - -PrintViewManager* GetPrintViewManager(int render_process_id, - int render_frame_id) { - DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - content::WebContents* web_contents = - GetWebContentsForRenderFrame(render_process_id, render_frame_id); - return web_contents ? PrintViewManager::FromWebContents(web_contents) - : nullptr; -} - -void NotifySystemDialogCancelled(int render_process_id, int routing_id) { - PrintViewManager* manager = - GetPrintViewManager(render_process_id, routing_id); +void NotifySystemDialogCancelled(base::WeakPtr<PrintViewManagerBase> manager) { if (manager) manager->SystemDialogCancelled(); } @@ -233,8 +214,7 @@ scoped_refptr<PrintQueriesQueue> queue, std::unique_ptr<PrinterQuery> printer_query, mojom::PrintManagerHost::UpdatePrintSettingsCallback callback, - int process_id, - int routing_id) { + base::WeakPtr<PrintViewManagerBase> manager) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); DCHECK(printer_query); mojom::PrintPagesParamsPtr params = CreateEmptyPrintPagesParamsPtr(); @@ -249,7 +229,7 @@ if (canceled) { content::GetUIThreadTaskRunner({})->PostTask( FROM_HERE, - base::BindOnce(&NotifySystemDialogCancelled, process_id, routing_id)); + base::BindOnce(&NotifySystemDialogCancelled, std::move(manager))); } #endif @@ -269,8 +249,7 @@ mojom::PrintManagerHost::UpdatePrintSettingsCallback callback, scoped_refptr<PrintQueriesQueue> queue, base::Value job_settings, - int process_id, - int routing_id) { + base::WeakPtr<PrintViewManagerBase> manager) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); std::unique_ptr<PrinterQuery> printer_query = queue->PopPrinterQuery(cookie); if (!printer_query) { @@ -281,8 +260,8 @@ printer_query_ptr->SetSettings( std::move(job_settings), base::BindOnce(&UpdatePrintSettingsReplyOnIO, queue, - std::move(printer_query), std::move(callback), process_id, - routing_id)); + std::move(printer_query), std::move(callback), + std::move(manager))); } #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) @@ -689,16 +668,14 @@ job_settings.SetIntKey(kSettingRasterizePdfDpi, value); } - content::RenderFrameHost* render_frame_host = GetCurrentTargetFrame(); auto callback_wrapper = base::BindOnce(&PrintViewManagerBase::UpdatePrintSettingsReply, weak_ptr_factory_.GetWeakPtr(), std::move(callback)); content::GetIOThreadTaskRunner({})->PostTask( - FROM_HERE, base::BindOnce(&UpdatePrintSettingsOnIO, cookie, - std::move(callback_wrapper), queue_, - std::move(job_settings), - render_frame_host->GetProcess()->GetID(), - render_frame_host->GetRoutingID())); + FROM_HERE, + base::BindOnce(&UpdatePrintSettingsOnIO, cookie, + std::move(callback_wrapper), queue_, + std::move(job_settings), weak_ptr_factory_.GetWeakPtr())); } #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/background/desktop_automation_handler.js b/chrome/browser/resources/chromeos/accessibility/chromevox/background/desktop_automation_handler.js index 7fc69d9e..d826f449 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/background/desktop_automation_handler.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/background/desktop_automation_handler.js
@@ -665,6 +665,13 @@ override = !!walker || override; } + // The popup view associated with a datalist element does not descend + // from the input with which it is associated. + if (focus.role === RoleType.TEXT_FIELD_WITH_COMBO_BOX && + target.role === RoleType.LIST_BOX_OPTION) { + override = true; + } + if (override || AutomationUtil.isDescendantOf(target, focus)) { this.onEventDefault(evt); }
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/background/desktop_automation_handler_test.js b/chrome/browser/resources/chromeos/accessibility/chromevox/background/desktop_automation_handler_test.js index 3de9dea..311f994 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/background/desktop_automation_handler_test.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/background/desktop_automation_handler_test.js
@@ -13,6 +13,7 @@ /** @override */ setUp() { super.setUp(); + window.press = this.press; const runTest = this.deferRunTest(WhenTestDone.EXPECT); chrome.automation.getDesktop(desktop => { @@ -20,6 +21,12 @@ runTest(); }); } + + press(keyCode, modifiers) { + return function() { + EventGenerator.sendKeyPress(keyCode, modifiers); + }; + } }; TEST_F( @@ -149,3 +156,28 @@ .replay(); }); }); + +TEST_F( + 'ChromeVoxDesktopAutomationHandlerTest', 'DatalistSelection', function() { + const mockFeedback = this.createMockFeedback(); + const site = ` + <input list="list"> + <datalist id="list"> + <option>foo</option> + <option>bar</option> + </datalist> + `; + this.runWithLoadedTree(site, function(root) { + root.find({role: RoleType.TEXT_FIELD_WITH_COMBO_BOX}).focus(); + mockFeedback.call(press(KeyCode.DOWN)) + .expectSpeech('foo', 'List item', ' 1 of 2 ') + .expectBraille('foo lstitm 1/2 (x)') + .call(press(KeyCode.DOWN)) + .expectSpeech('bar', 'List item', ' 2 of 2 ') + .expectBraille('bar lstitm 2/2 (x)') + .call(press(KeyCode.UP)) + .expectSpeech('foo', 'List item', ' 1 of 2 ') + .expectBraille('foo lstitm 1/2 (x)') + .replay(); + }); + });
diff --git a/chrome/browser/sessions/chrome_tab_restore_service_client.cc b/chrome/browser/sessions/chrome_tab_restore_service_client.cc index c4c4d0a..cfdf854 100644 --- a/chrome/browser/sessions/chrome_tab_restore_service_client.cc +++ b/chrome/browser/sessions/chrome_tab_restore_service_client.cc
@@ -40,7 +40,7 @@ ui::WindowShowState show_state, const std::string& workspace, const std::string& user_title, - const std::map<std::string, base::Value>& extra_data) { + const std::map<std::string, std::string>& extra_data) { #if defined(OS_ANDROID) // Android does not support creating a LiveTabContext here. NOTREACHED();
diff --git a/chrome/browser/sessions/chrome_tab_restore_service_client.h b/chrome/browser/sessions/chrome_tab_restore_service_client.h index a4f1fad..2984ab36 100644 --- a/chrome/browser/sessions/chrome_tab_restore_service_client.h +++ b/chrome/browser/sessions/chrome_tab_restore_service_client.h
@@ -30,7 +30,7 @@ ui::WindowShowState show_state, const std::string& workspace, const std::string& user_title, - const std::map<std::string, base::Value>& extra_data) override; + const std::map<std::string, std::string>& extra_data) override; sessions::LiveTabContext* FindLiveTabContextForTab( const sessions::LiveTab* tab) override; sessions::LiveTabContext* FindLiveTabContextWithID(
diff --git a/chrome/browser/sessions/tab_restore_service_unittest.cc b/chrome/browser/sessions/tab_restore_service_unittest.cc index c05a2e2..8c157ad8 100644 --- a/chrome/browser/sessions/tab_restore_service_unittest.cc +++ b/chrome/browser/sessions/tab_restore_service_unittest.cc
@@ -19,7 +19,6 @@ #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "base/test/bind.h" -#include "base/values.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/sessions/chrome_tab_restore_service_client.h" #include "chrome/browser/sessions/exit_type_service.h" @@ -83,9 +82,9 @@ MOCK_CONST_METHOD1(GetLiveTabAt, sessions::LiveTab*(int index)); MOCK_CONST_METHOD0(GetActiveLiveTab, sessions::LiveTab*()); MOCK_CONST_METHOD1(GetExtraDataForTab, - std::map<std::string, base::Value>(int index)); + std::map<std::string, std::string>(int index)); MOCK_CONST_METHOD0(GetExtraDataForWindow, - std::map<std::string, base::Value>()); + std::map<std::string, std::string>()); MOCK_CONST_METHOD1(GetTabGroupForTab, absl::optional<tab_groups::TabGroupId>(int index)); MOCK_CONST_METHOD1(GetVisualDataForGroup, @@ -111,7 +110,7 @@ bool, const sessions::PlatformSpecificTabData*, (const sessions::SerializedUserAgentOverride&), - (const std::map<std::string, base::Value>&), + (const std::map<std::string, std::string>&), (const SessionID*)), (override)); @@ -123,7 +122,7 @@ (const std::string&), (const sessions::PlatformSpecificTabData*), (const sessions::SerializedUserAgentOverride&), - (const std::map<std::string, base::Value>&)), + (const std::map<std::string, std::string>&)), (override)); MOCK_METHOD0(CloseTab, void()); @@ -141,7 +140,7 @@ ui::WindowShowState show_state, const std::string& workspace, const std::string& user_title, - const std::map<std::string, base::Value>& extra_data)); + const std::map<std::string, std::string>& extra_data)); MOCK_METHOD1(FindLiveTabContextForTab, sessions::LiveTabContext*(const sessions::LiveTab* tab)); MOCK_METHOD1(FindLiveTabContextWithID, @@ -407,16 +406,20 @@ TEST_F(TabRestoreServiceImplWithMockClientTest, TabExtraDataPresentInHistoricalTab) { + constexpr char kSampleKey[] = "test"; + constexpr char kSampleValue[] = "true"; + std::unique_ptr<MockLiveTabContext> mock_live_tab_context_ptr( new ::testing::NiceMock<MockLiveTabContext>()); SessionID sample_session_id = SessionID::NewUnique(); EXPECT_CALL(*mock_live_tab_context_ptr, GetSessionID) .WillOnce(Return(sample_session_id)); - EXPECT_CALL(*mock_live_tab_context_ptr, GetExtraDataForTab).WillOnce([]() { - std::map<std::string, base::Value> sample_extra_data; - sample_extra_data["test"] = base::Value(true); - return sample_extra_data; - }); + EXPECT_CALL(*mock_live_tab_context_ptr, GetExtraDataForTab) + .WillOnce([kSampleKey, kSampleValue]() { + std::map<std::string, std::string> sample_extra_data; + sample_extra_data[kSampleKey] = kSampleValue; + return sample_extra_data; + }); ON_CALL(*mock_tab_restore_service_client_, FindLiveTabContextForTab(_)) .WillByDefault(Return(mock_live_tab_context_ptr.get())); ON_CALL(*mock_tab_restore_service_client_, GetNewTabURL()) @@ -435,7 +438,7 @@ ASSERT_EQ(1U, tab->navigations.size()); EXPECT_EQ(url1_, tab->navigations[0].virtual_url()); ASSERT_EQ(1U, tab->extra_data.size()); - ASSERT_TRUE(tab->extra_data["test"].GetBool()); + ASSERT_EQ(kSampleValue, tab->extra_data[kSampleKey]); } // Make sure TabRestoreService doesn't create an entry for a tab with no
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn index 9829438..669d4755 100644 --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn
@@ -5302,6 +5302,11 @@ "views/side_search/side_search_browser_controller.cc", "views/side_search/side_search_browser_controller.h", ] + + deps += [ + "side_search:side_search_tab_data_proto", + "side_search:side_search_window_data_proto", + ] } }
diff --git a/chrome/browser/ui/android/quickactionsearchwidget/BUILD.gn b/chrome/browser/ui/android/quickactionsearchwidget/BUILD.gn index c2304e47..20eb0fc 100644 --- a/chrome/browser/ui/android/quickactionsearchwidget/BUILD.gn +++ b/chrome/browser/ui/android/quickactionsearchwidget/BUILD.gn
@@ -54,7 +54,6 @@ android_resources("java_resources") { sources = [ "java/res/drawable-nodpi/quick_action_search_widget_dino_preview.png", - "java/res/drawable-nodpi/quick_action_search_widget_medium_preview.png", "java/res/drawable-nodpi/quick_action_search_widget_small_preview.png", "java/res/drawable/ic_dino.xml", "java/res/drawable/quick_action_search_widget_background.xml", @@ -70,7 +69,6 @@ "java/res/values/dimens.xml", "java/res/values/styles.xml", "java/res/xml/quick_action_search_widget_dino_info.xml", - "java/res/xml/quick_action_search_widget_medium_info.xml", "java/res/xml/quick_action_search_widget_small_info.xml", ] }
diff --git a/chrome/browser/ui/android/quickactionsearchwidget/java/res/drawable-nodpi/quick_action_search_widget_medium_preview.png b/chrome/browser/ui/android/quickactionsearchwidget/java/res/drawable-nodpi/quick_action_search_widget_medium_preview.png deleted file mode 100644 index 65b0b510..0000000 --- a/chrome/browser/ui/android/quickactionsearchwidget/java/res/drawable-nodpi/quick_action_search_widget_medium_preview.png +++ /dev/null Binary files differ
diff --git a/chrome/browser/ui/android/quickactionsearchwidget/java/res/layout/quick_action_search_widget_dino_layout.xml b/chrome/browser/ui/android/quickactionsearchwidget/java/res/layout/quick_action_search_widget_dino_layout.xml index 87bcc88d..f62165f5 100644 --- a/chrome/browser/ui/android/quickactionsearchwidget/java/res/layout/quick_action_search_widget_dino_layout.xml +++ b/chrome/browser/ui/android/quickactionsearchwidget/java/res/layout/quick_action_search_widget_dino_layout.xml
@@ -3,7 +3,7 @@ Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. --> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/dino_quick_action_button" android:layout_width="@dimen/quick_action_search_widget_dino_size" android:layout_height="@dimen/quick_action_search_widget_dino_size" @@ -13,20 +13,19 @@ <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_alignParentTop="true" - android:layout_marginStart="12dp" + android:layout_marginStart="@dimen/quick_action_search_widget_dino_margin_start" + android:layout_marginTop="@dimen/quick_action_search_widget_dino_margin_top" + android:layout_marginBottom="@dimen/quick_action_search_widget_dino_margin_text" android:importantForAccessibility="no" android:src="@drawable/quick_action_search_widget_dino_content" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_alignParentBottom="true" - android:layout_marginBottom="14dp" - android:layout_marginStart="12dp" + android:layout_marginStart="@dimen/quick_action_search_widget_dino_margin_start" android:maxLines="1" - android:textAppearance="@style/TextAppearance.TextMedium.Secondary.Baseline" + android:textAppearance="@style/TextAppearance.TextLarge.Primary.Baseline" android:textAlignment="viewStart" android:text="@string/dino_widget_text" /> -</RelativeLayout> +</LinearLayout>
diff --git a/chrome/browser/ui/android/quickactionsearchwidget/java/res/layout/quick_action_search_widget_medium_layout.xml b/chrome/browser/ui/android/quickactionsearchwidget/java/res/layout/quick_action_search_widget_medium_layout.xml index dc1a5821..e69482e 100644 --- a/chrome/browser/ui/android/quickactionsearchwidget/java/res/layout/quick_action_search_widget_medium_layout.xml +++ b/chrome/browser/ui/android/quickactionsearchwidget/java/res/layout/quick_action_search_widget_medium_layout.xml
@@ -4,10 +4,12 @@ found in the LICENSE file. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/quick_action_widget" + android:id="@android:id/background" android:layout_width="match_parent" - android:layout_height="@dimen/quick_action_search_widget_medium_height" + android:layout_height="@dimen/quick_action_search_widget_medium_height" + android:paddingVertical="@dimen/quick_action_search_widget_medium_vertical_margin" android:background="@drawable/quick_action_search_widget_background" + android:clipToOutline="true" android:orientation="vertical"> <LinearLayout @@ -15,8 +17,8 @@ android:layout_width="match_parent" android:layout_height="@dimen/quick_action_search_widget_medium_search_bar_height" android:layout_gravity="center" - android:layout_marginHorizontal="@dimen/quick_action_search_widget_medium_margin" - android:layout_marginTop="@dimen/quick_action_search_widget_medium_margin" + android:layout_marginHorizontal="@dimen/quick_action_search_widget_medium_horizontal_margin" + android:layout_marginBottom="@dimen/quick_action_search_widget_medium_row_vertical_margin" android:background="@drawable/quick_action_search_widget_medium_search_bar_background" android:gravity="center_vertical" android:orientation="horizontal"> @@ -25,7 +27,10 @@ android:id="@+id/quick_action_search_widget_icon" android:layout_width="@dimen/quick_action_search_widget_medium_search_bar_icon_size" android:layout_height="@dimen/quick_action_search_widget_medium_search_bar_icon_size" - android:layout_margin="@dimen/quick_action_search_widget_medium_search_bar_icon_margin" + android:layout_marginTop="@dimen/quick_action_search_widget_medium_search_bar_icon_margin" + android:layout_marginBottom="@dimen/quick_action_search_widget_medium_search_bar_icon_margin" + android:layout_marginStart="@dimen/quick_action_search_widget_medium_search_bar_icon_margin" + android:layout_marginEnd="@dimen/quick_action_search_widget_medium_search_bar_icon_margin_text" android:contentDescription="@string/accessibility_quick_action_search_widget_icon" android:src="@mipmap/app_icon" /> @@ -38,7 +43,6 @@ android:hint="@string/quick_action_search_widget_search_bar_hint" android:singleLine="true" android:textAlignment="viewStart" /> - </LinearLayout> <LinearLayout @@ -46,31 +50,33 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" - android:layout_margin="@dimen/quick_action_search_widget_button_container_margin" - android:gravity="center" android:orientation="horizontal"> <ImageButton - android:id="@+id/incognito_quick_action_button" - android:src="@drawable/incognito_simple" - style="@style/QuickActionSearchWidgetMediumButton" - android:contentDescription="@string/button_new_incognito_tab" /> - - <ImageButton android:id="@+id/voice_search_quick_action_button" android:src="@drawable/btn_mic" + android:layout_marginHorizontal="@dimen/quick_action_search_widget_medium_button_horizontal_margin" style="@style/QuickActionSearchWidgetMediumButton" android:contentDescription="@string/accessibility_toolbar_btn_mic" /> <ImageButton + android:id="@+id/incognito_quick_action_button" + android:src="@drawable/incognito_simple" + android:layout_marginHorizontal="@dimen/quick_action_search_widget_medium_button_horizontal_margin" + style="@style/QuickActionSearchWidgetMediumButton" + android:contentDescription="@string/button_new_incognito_tab" /> + + <ImageButton android:id="@+id/lens_quick_action_button" android:src="@drawable/lens_camera_icon" + android:layout_marginHorizontal="@dimen/quick_action_search_widget_medium_button_horizontal_margin" style="@style/QuickActionSearchWidgetMediumButton" android:contentDescription="@string/accessibility_btn_lens_camera"/> <ImageButton android:id="@+id/dino_quick_action_button" android:src="@drawable/ic_dino" + android:layout_marginHorizontal="@dimen/quick_action_search_widget_medium_button_horizontal_margin" style="@style/QuickActionSearchWidgetMediumButton" android:contentDescription="@string/accessibility_quick_action_search_widget_start_dino_game" />
diff --git a/chrome/browser/ui/android/quickactionsearchwidget/java/res/layout/quick_action_search_widget_small_layout.xml b/chrome/browser/ui/android/quickactionsearchwidget/java/res/layout/quick_action_search_widget_small_layout.xml index b4f51a78..f2f97a0 100644 --- a/chrome/browser/ui/android/quickactionsearchwidget/java/res/layout/quick_action_search_widget_small_layout.xml +++ b/chrome/browser/ui/android/quickactionsearchwidget/java/res/layout/quick_action_search_widget_small_layout.xml
@@ -4,20 +4,22 @@ found in the LICENSE file. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/quick_action_widget_small" + android:id="@android:id/background" android:layout_width="match_parent" - android:layout_height="wrap_content" + android:layout_height="@dimen/quick_action_search_widget_small_height" android:background="@drawable/quick_action_search_widget_background" + android:clipToOutline="true" android:baselineAligned="false" android:orientation="horizontal" - android:padding="@dimen/quick_action_search_widget_small_margin"> + android:layout_gravity="center" + android:paddingHorizontal="@dimen/quick_action_search_widget_small_margin"> <LinearLayout android:id="@+id/quick_action_search_widget_search_bar_container" android:layout_width="0dp" android:layout_height="@dimen/quick_action_search_widget_small_search_bar_height" android:layout_gravity="center" - android:layout_margin="@dimen/quick_action_search_widget_button_margin" + android:layout_marginHorizontal="@dimen/quick_action_search_widget_small_button_horizontal_margin" android:layout_weight="1" android:background="@drawable/quick_action_search_widget_small_search_bar_background" android:gravity="center_vertical" @@ -27,13 +29,16 @@ android:id="@+id/quick_action_search_widget_icon" android:layout_width="@dimen/quick_action_search_widget_small_search_bar_icon_size" android:layout_height="@dimen/quick_action_search_widget_small_search_bar_icon_size" - android:layout_margin="@dimen/quick_action_search_widget_small_search_bar_icon_margin" + android:layout_marginTop="@dimen/quick_action_search_widget_small_search_bar_icon_margin" + android:layout_marginBottom="@dimen/quick_action_search_widget_small_search_bar_icon_margin" + android:layout_marginStart="@dimen/quick_action_search_widget_small_search_bar_icon_margin" + android:layout_marginEnd="@dimen/quick_action_search_widget_small_search_bar_icon_margin_text" android:contentDescription="@string/accessibility_quick_action_search_widget_icon" android:src="@mipmap/app_icon" /> <TextView android:id="@+id/search_bar" - style="@style/TextAppearance.QuickActionSearchWidgetSmallSearchBoxText" + style="@style/TextAppearance.NewTabPageSearchBoxText" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_vertical" @@ -52,23 +57,32 @@ android:orientation="horizontal"> <ImageButton - android:id="@+id/incognito_quick_action_button" - style="@style/QuickActionSearchWidgetSmallButton" - android:contentDescription="@string/button_new_incognito_tab" - android:src="@drawable/incognito_simple" /> - - <ImageButton android:id="@+id/voice_search_quick_action_button" style="@style/QuickActionSearchWidgetSmallButton" + android:layout_marginHorizontal="@dimen/quick_action_search_widget_small_button_horizontal_margin" android:contentDescription="@string/accessibility_toolbar_btn_mic" android:src="@drawable/btn_mic" /> <ImageButton + android:id="@+id/incognito_quick_action_button" + style="@style/QuickActionSearchWidgetSmallButton" + android:layout_marginHorizontal="@dimen/quick_action_search_widget_small_button_horizontal_margin" + android:contentDescription="@string/button_new_incognito_tab" + android:src="@drawable/incognito_simple" /> + + <ImageButton android:id="@+id/lens_quick_action_button" style="@style/QuickActionSearchWidgetSmallButton" + android:layout_marginHorizontal="@dimen/quick_action_search_widget_small_button_horizontal_margin" android:contentDescription="@string/accessibility_btn_lens_camera" android:src="@drawable/lens_camera_icon" /> + <ImageButton + android:id="@+id/dino_quick_action_button" + style="@style/QuickActionSearchWidgetSmallButton" + android:layout_marginHorizontal="@dimen/quick_action_search_widget_small_button_horizontal_margin" + android:contentDescription="@string/accessibility_quick_action_search_widget_start_dino_game" + android:src="@drawable/ic_dino" /> </LinearLayout> </LinearLayout>
diff --git a/chrome/browser/ui/android/quickactionsearchwidget/java/res/values/dimens.xml b/chrome/browser/ui/android/quickactionsearchwidget/java/res/values/dimens.xml index d03ea97..297dac13 100644 --- a/chrome/browser/ui/android/quickactionsearchwidget/java/res/values/dimens.xml +++ b/chrome/browser/ui/android/quickactionsearchwidget/java/res/values/dimens.xml
@@ -4,45 +4,54 @@ found in the LICENSE file. --> <resources xmlns:tools="http://schemas.android.com/tools"> - <dimen name="quick_action_search_widget_width">240dp</dimen> - <dimen name="quick_action_search_widget_background_radius">16dp</dimen> - <dimen name="quick_action_search_widget_button_container_margin">12dp</dimen> - <dimen name="quick_action_search_widget_button_margin">4dp</dimen> + <dimen name="quick_action_search_widget_width">264dp</dimen> + <dimen name="quick_action_search_widget_background_radius">20dp</dimen> <!-- Small Widget Dimensions --> - <dimen name="quick_action_search_widget_small_height">48dp</dimen> - <dimen name="quick_action_search_widget_small_margin">12dp</dimen> + <!-- True margin is a combination of quick_action_search_widget_small_margin + and quick_action_search_widget_small_button_horizontal_margin --> + <dimen name="quick_action_search_widget_small_height">72dp</dimen> + <dimen name="quick_action_search_widget_small_margin">8dp</dimen> <!-- Medium Widget Dimensions --> - <dimen name="quick_action_search_widget_medium_margin">16dp</dimen> - <dimen name="quick_action_search_widget_medium_height">160dp</dimen> + <dimen name="quick_action_search_widget_medium_horizontal_margin">15dp</dimen> + <dimen name="quick_action_search_widget_medium_vertical_margin">18dp</dimen> + <dimen name="quick_action_search_widget_medium_row_vertical_margin">15dp</dimen> + <dimen name="quick_action_search_widget_medium_height">155dp</dimen> <!-- Small Button Dimensions --> - <dimen name="quick_action_search_widget_small_button_radius">24dp</dimen> - <dimen name="quick_action_search_widget_small_button_icon_padding">14dp</dimen> - <dimen name="quick_action_search_widget_small_button_height">48dp</dimen> - <dimen name="quick_action_search_widget_small_button_width">48dp</dimen> + <dimen name="quick_action_search_widget_small_button_radius">21dp</dimen> + <dimen name="quick_action_search_widget_small_button_icon_padding">12dp</dimen> + <dimen name="quick_action_search_widget_small_button_height">41dp</dimen> + <dimen name="quick_action_search_widget_small_button_width">41dp</dimen> + <dimen name="quick_action_search_widget_small_button_horizontal_margin">3dp</dimen> <!-- Medium Button Dimensions --> - <dimen name="quick_action_search_widget_medium_button_icon_padding">20dp</dimen> - <dimen name="quick_action_search_widget_medium_button_radius">30dp</dimen> - <dimen name="quick_action_search_widget_medium_button_height">60dp</dimen> - <dimen name="quick_action_search_widget_medium_button_width">60dp</dimen> + <dimen name="quick_action_search_widget_medium_button_icon_padding">17dp</dimen> + <dimen name="quick_action_search_widget_medium_button_radius">27dp</dimen> + <dimen name="quick_action_search_widget_medium_button_height">54dp</dimen> + <dimen name="quick_action_search_widget_medium_button_width">54dp</dimen> + <dimen name="quick_action_search_widget_medium_button_horizontal_margin">3dp</dimen> <!-- Medium Search Bar Dimensions --> - <dimen name="quick_action_search_widget_medium_search_bar_corner_radius">28dp</dimen> - <dimen name="quick_action_search_widget_medium_search_bar_height">56dp</dimen> - <dimen name="quick_action_search_widget_medium_search_bar_icon_size">40dp</dimen> - <dimen name="quick_action_search_widget_medium_search_bar_icon_margin">8dp</dimen> + <dimen name="quick_action_search_widget_medium_search_bar_corner_radius">25dp</dimen> + <dimen name="quick_action_search_widget_medium_search_bar_height">50dp</dimen> + <dimen name="quick_action_search_widget_medium_search_bar_icon_size">28dp</dimen> + <dimen name="quick_action_search_widget_medium_search_bar_icon_margin">11dp</dimen> + <dimen name="quick_action_search_widget_medium_search_bar_icon_margin_text">7dp</dimen> <!-- Small Search Bar Dimensions --> - <dimen name="quick_action_search_widget_small_search_bar_height">48dp</dimen> - <dimen name="quick_action_search_widget_small_search_bar_corner_radius">24dp</dimen> - <dimen name="quick_action_search_widget_small_search_bar_icon_size">28dp</dimen> + <dimen name="quick_action_search_widget_small_search_bar_height">39dp</dimen> + <dimen name="quick_action_search_widget_small_search_bar_corner_radius">20dp</dimen> + <dimen name="quick_action_search_widget_small_search_bar_icon_size">20dp</dimen> <dimen name="quick_action_search_widget_small_search_bar_icon_margin">8dp</dimen> + <dimen name="quick_action_search_widget_small_search_bar_icon_margin_text">5dp</dimen> <!-- Dino Widget Dimensions --> - <dimen name="quick_action_search_widget_dino_min_size">110dp</dimen> - <dimen name="quick_action_search_widget_dino_size">124dp</dimen> - <dimen name="quick_action_search_widget_dino_corner_radius">24dp</dimen> + <dimen name="quick_action_search_widget_dino_min_size">136dp</dimen> + <dimen name="quick_action_search_widget_dino_size">136dp</dimen> + <dimen name="quick_action_search_widget_dino_corner_radius">20dp</dimen> + <dimen name="quick_action_search_widget_dino_margin_start">12dp</dimen> + <dimen name="quick_action_search_widget_dino_margin_top">6dp</dimen> + <dimen name="quick_action_search_widget_dino_margin_text">10dp</dimen> </resources>
diff --git a/chrome/browser/ui/android/quickactionsearchwidget/java/res/values/styles.xml b/chrome/browser/ui/android/quickactionsearchwidget/java/res/values/styles.xml index bde61d8..f3aa3663 100644 --- a/chrome/browser/ui/android/quickactionsearchwidget/java/res/values/styles.xml +++ b/chrome/browser/ui/android/quickactionsearchwidget/java/res/values/styles.xml
@@ -7,7 +7,6 @@ <style name="QuickActionSearchWidgetSmallButton"> <item name="android:layout_width">@dimen/quick_action_search_widget_small_button_width</item> <item name="android:layout_height">@dimen/quick_action_search_widget_small_button_height</item> - <item name="android:layout_margin">@dimen/quick_action_search_widget_button_margin</item> <item name="android:background">@drawable/quick_action_search_widget_small_button_background</item> <item name="android:padding">@dimen/quick_action_search_widget_small_button_icon_padding</item> <item name="android:tint">@color/default_icon_color_baseline</item> @@ -17,14 +16,9 @@ <style name="QuickActionSearchWidgetMediumButton"> <item name="android:layout_width">@dimen/quick_action_search_widget_medium_button_width</item> <item name="android:layout_height">@dimen/quick_action_search_widget_medium_button_height</item> - <item name="android:layout_margin">@dimen/quick_action_search_widget_button_margin</item> <item name="android:background">@drawable/quick_action_search_widget_medium_button_background</item> <item name="android:padding">@dimen/quick_action_search_widget_medium_button_icon_padding</item> <item name="android:tint">@color/default_icon_color_baseline</item> <item name="android:scaleType">fitCenter</item> </style> - - <style name="TextAppearance.QuickActionSearchWidgetSmallSearchBoxText" parent="TextAppearance.NewTabPageSearchBoxText"> - <item name="android:textSize">@dimen/text_size_medium</item> - </style> </resources>
diff --git a/chrome/browser/ui/android/quickactionsearchwidget/java/res/xml/quick_action_search_widget_dino_info.xml b/chrome/browser/ui/android/quickactionsearchwidget/java/res/xml/quick_action_search_widget_dino_info.xml index d2b2b6c..98ee728 100644 --- a/chrome/browser/ui/android/quickactionsearchwidget/java/res/xml/quick_action_search_widget_dino_info.xml +++ b/chrome/browser/ui/android/quickactionsearchwidget/java/res/xml/quick_action_search_widget_dino_info.xml
@@ -9,4 +9,4 @@ android:minHeight="@dimen/quick_action_search_widget_dino_min_size" android:initialLayout="@layout/quick_action_search_widget_dino_layout" android:previewImage="@drawable/quick_action_search_widget_dino_preview" - android:widgetCategory="home_screen|searchbox" /> + android:widgetCategory="home_screen" />
diff --git a/chrome/browser/ui/android/quickactionsearchwidget/java/res/xml/quick_action_search_widget_medium_info.xml b/chrome/browser/ui/android/quickactionsearchwidget/java/res/xml/quick_action_search_widget_medium_info.xml deleted file mode 100644 index b61d531..0000000 --- a/chrome/browser/ui/android/quickactionsearchwidget/java/res/xml/quick_action_search_widget_medium_info.xml +++ /dev/null
@@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright 2021 The Chromium Authors. All rights reserved. - Use of this source code is governed by a BSD-style license that can be - found in the LICENSE file. --> - -<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" - android:initialLayout="@layout/quick_action_search_widget_medium_layout" - android:minWidth="@dimen/quick_action_search_widget_width" - android:minResizeHeight="@dimen/quick_action_search_widget_small_height" - android:minHeight="@dimen/quick_action_search_widget_medium_height" - android:previewImage="@drawable/quick_action_search_widget_medium_preview" - android:resizeMode="vertical|horizontal" - android:widgetCategory="home_screen|searchbox" />
diff --git a/chrome/browser/ui/android/quickactionsearchwidget/java/res/xml/quick_action_search_widget_small_info.xml b/chrome/browser/ui/android/quickactionsearchwidget/java/res/xml/quick_action_search_widget_small_info.xml index fd82041..35dd436d 100644 --- a/chrome/browser/ui/android/quickactionsearchwidget/java/res/xml/quick_action_search_widget_small_info.xml +++ b/chrome/browser/ui/android/quickactionsearchwidget/java/res/xml/quick_action_search_widget_small_info.xml
@@ -7,6 +7,8 @@ android:initialLayout="@layout/quick_action_search_widget_small_layout" android:minWidth="@dimen/quick_action_search_widget_width" android:minHeight="@dimen/quick_action_search_widget_small_height" + android:minResizeWidth="@dimen/quick_action_search_widget_width" + android:minResizeHeight="@dimen/quick_action_search_widget_small_height" android:resizeMode="vertical|horizontal" android:previewImage="@drawable/quick_action_search_widget_small_preview" android:widgetCategory="home_screen|searchbox" />
diff --git a/chrome/browser/ui/android/tab_model/android_live_tab_context.cc b/chrome/browser/ui/android/tab_model/android_live_tab_context.cc index 8dbf6003..82f602c 100644 --- a/chrome/browser/ui/android/tab_model/android_live_tab_context.cc +++ b/chrome/browser/ui/android/tab_model/android_live_tab_context.cc
@@ -6,7 +6,6 @@ #include <memory> -#include "base/values.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/android/tab_model/tab_model.h" @@ -64,14 +63,14 @@ return sessions::ContentLiveTab::GetForWebContents(web_contents); } -std::map<std::string, base::Value> AndroidLiveTabContext::GetExtraDataForTab( +std::map<std::string, std::string> AndroidLiveTabContext::GetExtraDataForTab( int index) const { - return std::map<std::string, base::Value>(); + return std::map<std::string, std::string>(); } -std::map<std::string, base::Value> +std::map<std::string, std::string> AndroidLiveTabContext::GetExtraDataForWindow() const { - return std::map<std::string, base::Value>(); + return std::map<std::string, std::string>(); } absl::optional<tab_groups::TabGroupId> AndroidLiveTabContext::GetTabGroupForTab( @@ -131,7 +130,7 @@ bool pin, const sessions::PlatformSpecificTabData* tab_platform_data, const sessions::SerializedUserAgentOverride& user_agent_override, - const std::map<std::string, base::Value>& extra_data, + const std::map<std::string, std::string>& extra_data, const SessionID* tab_id) { Profile* profile = tab_model_->GetProfile(); @@ -162,7 +161,7 @@ const std::string& extension_app_id, const sessions::PlatformSpecificTabData* tab_platform_data, const sessions::SerializedUserAgentOverride& user_agent_override, - const std::map<std::string, base::Value>& extra_data) { + const std::map<std::string, std::string>& extra_data) { NOTIMPLEMENTED(); return nullptr; }
diff --git a/chrome/browser/ui/android/tab_model/android_live_tab_context.h b/chrome/browser/ui/android/tab_model/android_live_tab_context.h index f69c110..bb50e81 100644 --- a/chrome/browser/ui/android/tab_model/android_live_tab_context.h +++ b/chrome/browser/ui/android/tab_model/android_live_tab_context.h
@@ -14,10 +14,6 @@ #include "components/tab_groups/tab_group_id.h" #include "components/tab_groups/tab_group_visual_data.h" -namespace base { -class Value; -} - namespace content { class WebContents; } @@ -43,9 +39,9 @@ std::string GetUserTitle() const override; sessions::LiveTab* GetLiveTabAt(int index) const override; sessions::LiveTab* GetActiveLiveTab() const override; - std::map<std::string, base::Value> GetExtraDataForTab( + std::map<std::string, std::string> GetExtraDataForTab( int index) const override; - std::map<std::string, base::Value> GetExtraDataForWindow() const override; + std::map<std::string, std::string> GetExtraDataForWindow() const override; absl::optional<tab_groups::TabGroupId> GetTabGroupForTab( int index) const override; const tab_groups::TabGroupVisualData* GetVisualDataForGroup( @@ -68,7 +64,7 @@ bool pin, const sessions::PlatformSpecificTabData* storage_namespace, const sessions::SerializedUserAgentOverride& user_agent_override, - const std::map<std::string, base::Value>& extra_data, + const std::map<std::string, std::string>& extra_data, const SessionID* tab_id) override; sessions::LiveTab* ReplaceRestoredTab( const std::vector<sessions::SerializedNavigationEntry>& navigations, @@ -77,7 +73,7 @@ const std::string& extension_app_id, const sessions::PlatformSpecificTabData* tab_platform_data, const sessions::SerializedUserAgentOverride& user_agent_override, - const std::map<std::string, base::Value>& extra_data) override; + const std::map<std::string, std::string>& extra_data) override; void CloseTab() override; static LiveTabContext* FindContextForWebContents(
diff --git a/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarTablet.java b/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarTablet.java index f20471c..c8024bbb1 100644 --- a/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarTablet.java +++ b/chrome/browser/ui/android/toolbar/java/src/org/chromium/chrome/browser/toolbar/top/ToolbarTablet.java
@@ -27,6 +27,8 @@ import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.supplier.BooleanSupplier; import org.chromium.base.supplier.ObservableSupplier; +import org.chromium.chrome.browser.flags.CachedFeatureFlags; +import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.omnibox.LocationBar; import org.chromium.chrome.browser.omnibox.LocationBarCoordinator; import org.chromium.chrome.browser.omnibox.NewTabPageDelegate; @@ -135,8 +137,9 @@ getContext(), R.drawable.btn_close, R.color.default_icon_color_tint_list); reloadIcon.addLevel(stopLevel, stopLevel, stopLevelDrawable); mReloadButton.setImageDrawable(reloadIcon); - mShowTabStack = ChromeAccessibilityUtil.get().isAccessibilityEnabled() - && isAccessibilityTabSwitcherPreferenceEnabled(); + mShowTabStack = (ChromeAccessibilityUtil.get().isAccessibilityEnabled() + && isAccessibilityTabSwitcherPreferenceEnabled()) + || isGridTabSwitcherEnabled(); mAccessibilitySwitcherButton = findViewById(R.id.tab_switcher_button); updateSwitcherButtonVisibility(mShowTabStack); @@ -526,7 +529,8 @@ @Override void onAccessibilityStatusChanged(boolean enabled) { - mShowTabStack = enabled && isAccessibilityTabSwitcherPreferenceEnabled(); + mShowTabStack = (enabled && isAccessibilityTabSwitcherPreferenceEnabled()) + || isGridTabSwitcherEnabled(); updateSwitcherButtonVisibility(mShowTabStack); } @@ -744,4 +748,8 @@ return SharedPreferencesManager.getInstance().readBoolean( ChromePreferenceKeys.ACCESSIBILITY_TAB_SWITCHER, true); } + + private boolean isGridTabSwitcherEnabled() { + return CachedFeatureFlags.isEnabled(ChromeFeatureList.GRID_TAB_SWITCHER_FOR_TABLETS); + } }
diff --git a/chrome/browser/ui/app_list/app_list_sort_unittest.cc b/chrome/browser/ui/app_list/app_list_sort_unittest.cc index e15bd6c..61bdf4b 100644 --- a/chrome/browser/ui/app_list/app_list_sort_unittest.cc +++ b/chrome/browser/ui/app_list/app_list_sort_unittest.cc
@@ -502,13 +502,13 @@ syncer::StringOrdinal child_position = syncer::StringOrdinal::CreateInitialOrdinal(); - sync_list.push_back( - CreateAppRemoteData(kChildItemId1_1, "folder_child1", kFolderItemId, - child_position.ToInternalValue(), kUnset)); + sync_list.push_back(CreateAppRemoteData(kChildItemId1_1, "D", kFolderItemId, + child_position.ToInternalValue(), + kUnset)); child_position = child_position.CreateAfter(); - sync_list.push_back( - CreateAppRemoteData(kChildItemId1_2, "folder_child2", kFolderItemId, - child_position.ToInternalValue(), kUnset)); + sync_list.push_back(CreateAppRemoteData(kChildItemId1_2, "E", kFolderItemId, + child_position.ToInternalValue(), + kUnset)); app_list_syncable_service()->MergeDataAndStartSyncing( syncer::APP_LIST, sync_list, @@ -535,33 +535,28 @@ // Sort with the name alphabetical order and commit. model_updater->RequestAppListSort(ash::AppListSortOrder::kNameAlphabetical); Commit(); - EXPECT_EQ( - std::vector<std::string>({kFolderItemId, kItemId1, kItemId2, kItemId3, - kChildItemId1_1, kChildItemId1_2}), - GetOrderedItemIdsFromSyncableService()); + EXPECT_EQ(std::vector<std::string>({"Folder", "A", "B", "C", "D", "E"}), + GetOrderedNamesFromSyncableService()); // Sort with the name reverse alphabetical order without committing. model_updater->RequestAppListSort( ash::AppListSortOrder::kNameReverseAlphabetical); EXPECT_EQ(ash::AppListSortOrder::kNameAlphabetical, GetSortOrderFromPrefs()); - EXPECT_EQ( - std::vector<std::string>({kFolderItemId, kItemId1, kItemId2, kItemId3, - kChildItemId1_1, kChildItemId1_2}), - GetOrderedItemIdsFromSyncableService()); + EXPECT_EQ(std::vector<std::string>({"Folder", "A", "B", "C", "D", "E"}), + GetOrderedNamesFromSyncableService()); // Move `app3` to the folder. model_updater->RequestMoveItemToFolder( kItemId3, kFolderItemId, ash::RequestMoveToFolderReason::kMoveItem); - // TODO(https://crbug.com/1260447): the correct behavior is to commit the - // temporary sort order. However, implementation is blocked by the issue - // 1267417. Revisit this test when the blocking issue is fixed. - // Verify that: // (1) Temporary sort ends. - // (2) Sort order is cleared. + // (2) Sort order is committed. EXPECT_FALSE(IsUnderTemporarySort()); - EXPECT_EQ(ash::AppListSortOrder::kCustom, GetSortOrderFromPrefs()); + EXPECT_EQ(ash::AppListSortOrder::kNameReverseAlphabetical, + GetSortOrderFromPrefs()); + EXPECT_EQ(std::vector<std::string>({"Folder", "E", "D", "C", "B", "A"}), + GetOrderedNamesFromSyncableService()); } // Verifies the temporary sorting behavior with local app installation.
diff --git a/chrome/browser/ui/app_list/app_list_syncable_service.cc b/chrome/browser/ui/app_list/app_list_syncable_service.cc index 539ab69..a0c8acc 100644 --- a/chrome/browser/ui/app_list/app_list_syncable_service.cc +++ b/chrome/browser/ui/app_list/app_list_syncable_service.cc
@@ -1296,6 +1296,11 @@ return reorder::CalculateFrontPosition(sync_items_); } +ash::AppListSortOrder AppListSyncableService::GetPermanentSortingOrder() const { + return static_cast<ash::AppListSortOrder>( + profile()->GetPrefs()->GetInteger(prefs::kAppListPreferredOrder)); +} + // AppListSyncableService private bool AppListSyncableService::ProcessSyncItemSpecifics( @@ -1664,8 +1669,7 @@ // The target position of `new_item`. syncer::StringOrdinal position; - ash::AppListSortOrder order = static_cast<ash::AppListSortOrder>( - profile()->GetPrefs()->GetInteger(prefs::kAppListPreferredOrder)); + ash::AppListSortOrder order = GetPermanentSortingOrder(); // TODO(https://crbug.com/1260877): ideally we would not have to create a // one-off vector of items using `GetItems()`.
diff --git a/chrome/browser/ui/app_list/app_list_syncable_service.h b/chrome/browser/ui/app_list/app_list_syncable_service.h index 1602b7b..109d51e 100644 --- a/chrome/browser/ui/app_list/app_list_syncable_service.h +++ b/chrome/browser/ui/app_list/app_list_syncable_service.h
@@ -198,6 +198,7 @@ void AddObserverAndStart(Observer* observer); void RemoveObserver(Observer* observer); + const Profile* profile() const { return profile_; } Profile* profile() { return profile_; } size_t GetNumSyncItemsForTest(); const std::string& GetOemFolderNameForTest() const { @@ -231,6 +232,7 @@ // reorder::AppListReorderDelegate: void SetAppListPreferredOrder(ash::AppListSortOrder order) override; syncer::StringOrdinal CalculateGlobalFrontPosition() const override; + ash::AppListSortOrder GetPermanentSortingOrder() const override; private: class ModelUpdaterObserver;
diff --git a/chrome/browser/ui/app_list/chrome_app_list_model_updater.cc b/chrome/browser/ui/app_list/chrome_app_list_model_updater.cc index 464e80c..b432494 100644 --- a/chrome/browser/ui/app_list/chrome_app_list_model_updater.cc +++ b/chrome/browser/ui/app_list/chrome_app_list_model_updater.cc
@@ -663,19 +663,41 @@ ash::AppListItem* item = model_.FindItem(id); if (item) { - // The target position relies on the items under the target folder. - // Therefore calculate `target_position` before moving the item to the - // folder. + // Indicates the item's target position after moving to folder. The target + // position relies on the items under the target folder. Therefore calculate + // `target_position` before moving the item to the folder. syncer::StringOrdinal target_position; - ChromeAppListItem* last_child = - item_manager_->FindLastChildInFolder(folder_id); - if (!last_child) { - // The moved item is the first item under folder. - target_position = syncer::StringOrdinal::CreateInitialOrdinal(); + + const syncer::StringOrdinal old_position = + item_manager_->FindItem(id)->position(); + + const bool is_sorted = ash::features::IsLauncherAppSortEnabled() + ? (is_under_temporary_sort() || + order_delegate_->GetPermanentSortingOrder() != + ash::AppListSortOrder::kCustom) + : false; + + // Verify that when the app list is under sorting, `old_position` should be + // valid. But the case that `old_position` is invalid is handled for safety. + DCHECK(!is_sorted || old_position.IsValid()); + + if (is_sorted && old_position.IsValid()) { + // When items are sorted, item positions are set so all items in the model + // are in correct sort order (regardless of their parent IDs). Therefore, + // item position will be in correct sort order relative to items already + // in the target folder. + target_position = old_position; } else { - // TODO(https://crbug.com/1247408): now the new item is always added to - // the rear. We should take launcher sort order into consideration. - target_position = last_child->position().CreateAfter(); + ChromeAppListItem* last_child = + item_manager_->FindLastChildInFolder(folder_id); + if (!last_child) { + // The moved item is the first item under folder. + target_position = syncer::StringOrdinal::CreateInitialOrdinal(); + } else { + // TODO(https://crbug.com/1247408): now the new item is always added to + // the rear. We should take launcher sort order into consideration. + target_position = last_child->position().CreateAfter(); + } } std::unique_ptr<ash::AppListItemMetadata> data = item->CloneMetadata(); @@ -690,17 +712,17 @@ DCHECK(temporary_sort_manager_->is_active()); // When user moves a local item to a folder, the user is believed to accept - // the item layout after reordering. Therefore local positions are committed. - if (reason == ash::RequestMoveToFolderReason::kMergeSecondItem || - reason == ash::RequestMoveToFolderReason::kMoveItem) { - // Clear the sort order. Note that the folder that is created by merging may - // not be placed following the temporary sort order. Therefore the sort - // order is cleared. + // the item layout after reordering. Therefore local positions are + // committed. + if (reason == ash::RequestMoveToFolderReason::kMergeSecondItem) { + // Clear the sort order. Note that the folder that is created by merging + // may not be placed following the temporary sort order. Therefore the + // sort order is cleared. EndTemporarySortAndTakeAction(EndAction::kCommitAndClearSort); - - // TODO(https://crbug.com/1267417): now `target_position` is incorrect when - // app list is under temporary sort. When this issue gets fixed, commit the - // sort order as well as local positions if `reason` is kMoveItem. + } else if (reason == ash::RequestMoveToFolderReason::kMoveItem) { + // When an item is moved to an existing folder, the sorting order is still + // maintained. Therefore commit the temporary order in this scenario. + EndTemporarySortAndTakeAction(EndAction::kCommit); } } @@ -794,8 +816,8 @@ void ChromeAppListModelUpdater::MaybeNotifyObserversOfItemChange( ChromeAppListItem* chrome_item, ItemChangeType type) { - // If `temporary_sort_manager_` is active, item changes are not propagated to - // observers. + // If `temporary_sort_manager_` is active, item changes are not propagated + // to observers. if (is_under_temporary_sort() && temporary_sort_manager_->is_active()) return;
diff --git a/chrome/browser/ui/app_list/reorder/app_list_reorder_core.cc b/chrome/browser/ui/app_list/reorder/app_list_reorder_core.cc index f6a7a4da..9d906441 100644 --- a/chrome/browser/ui/app_list/reorder/app_list_reorder_core.cc +++ b/chrome/browser/ui/app_list/reorder/app_list_reorder_core.cc
@@ -477,7 +477,7 @@ if (global_items) { AdjustNeighborsInGlobalScope( - order, reorder::ConvertAppListItemToStringWrapper(new_item), + order, reorder::SyncItemWrapper<std::string>(new_item), reorder::GenerateStringWrappersFromSyncItems(*global_items), &prev_neighbor, &next_neighbor); }
diff --git a/chrome/browser/ui/app_list/reorder/app_list_reorder_delegate.h b/chrome/browser/ui/app_list/reorder/app_list_reorder_delegate.h index f38f7ac..4992438 100644 --- a/chrome/browser/ui/app_list/reorder/app_list_reorder_delegate.h +++ b/chrome/browser/ui/app_list/reorder/app_list_reorder_delegate.h
@@ -24,6 +24,10 @@ // Returns the front position among all sync items. virtual syncer::StringOrdinal CalculateGlobalFrontPosition() const = 0; + + // Returns the sorting order that is saved in perf service and gets shared + // among synced devices. + virtual ash::AppListSortOrder GetPermanentSortingOrder() const = 0; }; } // namespace reorder
diff --git a/chrome/browser/ui/app_list/reorder/app_list_reorder_util.cc b/chrome/browser/ui/app_list/reorder/app_list_reorder_util.cc index 5f2bec3f..f171f80 100644 --- a/chrome/browser/ui/app_list/reorder/app_list_reorder_util.cc +++ b/chrome/browser/ui/app_list/reorder/app_list_reorder_util.cc
@@ -21,7 +21,33 @@ ReorderParam::~ReorderParam() = default; -// Method Implementations ----------------------------------------------------- +// SyncItemWrapper<std::string> ------------------------------------------------ + +template <> +SyncItemWrapper<std::string>::SyncItemWrapper( + const AppListSyncableService::SyncItem& sync_item) + : id(sync_item.item_id), + item_ordinal(sync_item.item_ordinal), + is_folder(sync_item.item_type == sync_pb::AppListSpecifics::TYPE_FOLDER), + key_attribute(sync_item.item_name) {} + +template <> +SyncItemWrapper<std::string>::SyncItemWrapper( + const ChromeAppListItem& app_list_item) + : id(app_list_item.id()), + item_ordinal(app_list_item.position()), + is_folder(app_list_item.is_folder()), + key_attribute(app_list_item.name()) {} + +bool operator<(const SyncItemWrapper<std::string>& lhs, + const SyncItemWrapper<std::string>& rhs) { + return lhs.key_attribute < rhs.key_attribute; +} + +bool operator>(const SyncItemWrapper<std::string>& lhs, + const SyncItemWrapper<std::string>& rhs) { + return lhs.key_attribute > rhs.key_attribute; +} std::vector<SyncItemWrapper<std::string>> GenerateStringWrappersFromSyncItems( const AppListSyncableService::SyncItemMap& sync_item_map) { @@ -32,28 +58,12 @@ if (sync_item->item_type == sync_pb::AppListSpecifics::TYPE_PAGE_BREAK) continue; - SyncItemWrapper<std::string> wrapper; - wrapper.id = sync_item->item_id; - wrapper.item_ordinal = sync_item->item_ordinal; - wrapper.key_attribute = sync_item->item_name; - wrapper.is_folder = - sync_item->item_type == sync_pb::AppListSpecifics::TYPE_FOLDER; - wrappers.emplace_back(std::move(wrapper)); + wrappers.emplace_back(*sync_item); } return wrappers; } -SyncItemWrapper<std::string> ConvertAppListItemToStringWrapper( - const ChromeAppListItem& app_list_item) { - SyncItemWrapper<std::string> wrapper; - wrapper.id = app_list_item.id(); - wrapper.item_ordinal = app_list_item.position(); - wrapper.key_attribute = app_list_item.name(); - wrapper.is_folder = app_list_item.is_folder(); - return wrapper; -} - std::vector<SyncItemWrapper<std::string>> GenerateStringWrappersFromAppListItems( const std::vector<const ChromeAppListItem*>& items) { @@ -62,7 +72,7 @@ if (app_list_item->is_page_break()) continue; - wrappers.emplace_back(ConvertAppListItemToStringWrapper(*app_list_item)); + wrappers.emplace_back(*app_list_item); } return wrappers; }
diff --git a/chrome/browser/ui/app_list/reorder/app_list_reorder_util.h b/chrome/browser/ui/app_list/reorder/app_list_reorder_util.h index 173d444f..a13f403 100644 --- a/chrome/browser/ui/app_list/reorder/app_list_reorder_util.h +++ b/chrome/browser/ui/app_list/reorder/app_list_reorder_util.h
@@ -35,6 +35,9 @@ // Wrapping a sync item for comparison. template <typename T> struct SyncItemWrapper { + explicit SyncItemWrapper(const AppListSyncableService::SyncItem& sync_item); + explicit SyncItemWrapper(const ChromeAppListItem& app_list_item); + std::string id; syncer::StringOrdinal item_ordinal; bool is_folder = false; @@ -43,23 +46,26 @@ T key_attribute; }; -template <typename T> -bool operator<(const SyncItemWrapper<T>& lhs, const SyncItemWrapper<T>& rhs) { - return lhs.key_attribute < rhs.key_attribute; -} +// SyncItemWrapper<std::string> ------------------------------------------------ -template <typename T> -bool operator>(const SyncItemWrapper<T>& lhs, const SyncItemWrapper<T>& rhs) { - return rhs.key_attribute < lhs.key_attribute; -} +// Full template specialization to support name ordering. +template <> +SyncItemWrapper<std::string>::SyncItemWrapper( + const AppListSyncableService::SyncItem& sync_item); +template <> +SyncItemWrapper<std::string>::SyncItemWrapper( + const ChromeAppListItem& app_list_item); + +// Overloaded comparison operators: +bool operator<(const SyncItemWrapper<std::string>& lhs, + const SyncItemWrapper<std::string>& rhs); +bool operator>(const SyncItemWrapper<std::string>& lhs, + const SyncItemWrapper<std::string>& rhs); // Gets a list of string wrappers based on the mappings from ids to sync items. std::vector<SyncItemWrapper<std::string>> GenerateStringWrappersFromSyncItems( const AppListSyncableService::SyncItemMap& sync_item_map); -SyncItemWrapper<std::string> ConvertAppListItemToStringWrapper( - const ChromeAppListItem& app_list_item); - // Gets a list of string wrappers based on the given app list items. std::vector<SyncItemWrapper<std::string>> GenerateStringWrappersFromAppListItems(
diff --git a/chrome/browser/ui/app_list/test/chrome_app_list_test_support.cc b/chrome/browser/ui/app_list/test/chrome_app_list_test_support.cc index 2cf4586..33d9164 100644 --- a/chrome/browser/ui/app_list/test/chrome_app_list_test_support.cc +++ b/chrome/browser/ui/app_list/test/chrome_app_list_test_support.cc
@@ -56,6 +56,18 @@ AppListClientImpl* client = GetAppListClient(); Profile* profile = client->GetCurrentAppListProfile(); AppListModelUpdater* model_updater = GetModelUpdater(client); + + // Calculate `last_position` among the existing app list items. + std::vector<const ChromeAppListItem*> existing_items = + model_updater->GetItems(); + syncer::StringOrdinal last_position = + syncer::StringOrdinal::CreateInitialOrdinal(); + for (const auto* item : existing_items) { + if (item->position().GreaterThan(last_position)) + last_position = item->position(); + } + + syncer::StringOrdinal new_item_position = last_position.CreateAfter(); for (int i = 0; i < n; ++i) { const std::string app_name = base::StringPrintf("app %d", i); const std::string app_id = crx_file::id_util::GenerateId(app_name); @@ -65,6 +77,8 @@ metadata->id = app_id; metadata->name = app_name; metadata->icon = CreateImageSkia(i); + metadata->position = new_item_position; + new_item_position = new_item_position.CreateAfter(); item->SetMetadata(std::move(metadata)); model_updater->AddItem(std::move(item)); }
diff --git a/chrome/browser/ui/app_list/test/chrome_app_list_test_support.h b/chrome/browser/ui/app_list/test/chrome_app_list_test_support.h index 4956765..bac3ea8 100644 --- a/chrome/browser/ui/app_list/test/chrome_app_list_test_support.h +++ b/chrome/browser/ui/app_list/test/chrome_app_list_test_support.h
@@ -22,7 +22,7 @@ Profile* CreateSecondProfileAsync(); // Creates |n| app items with dummy data and adds to the current app-list -// client. +// client. New app items are appended to the end of the app list. void PopulateDummyAppListItems(int n); } // namespace test
diff --git a/chrome/browser/ui/ash/desks_templates/chrome_desks_templates_delegate.cc b/chrome/browser/ui/ash/desks_templates/chrome_desks_templates_delegate.cc index 40be29c..6125e644 100644 --- a/chrome/browser/ui/ash/desks_templates/chrome_desks_templates_delegate.cc +++ b/chrome/browser/ui/ash/desks_templates/chrome_desks_templates_delegate.cc
@@ -35,6 +35,7 @@ #include "components/favicon/core/favicon_service.h" #include "components/services/app_service/public/cpp/app_registry_cache.h" #include "components/services/app_service/public/cpp/app_types.h" +#include "components/services/app_service/public/cpp/types_util.h" #include "components/services/app_service/public/mojom/types.mojom.h" #include "components/user_manager/user_manager.h" #include "extensions/common/constants.h" @@ -80,19 +81,15 @@ // Return true if `app_id` is available to launch from template. bool IsAppAvailable(const std::string& app_id, - apps::AppServiceProxy* app_service_proxy = nullptr) { + apps::AppServiceProxy* app_service_proxy) { + DCHECK(app_service_proxy); bool installed = false; Profile* app_profile = ProfileManager::GetActiveUserProfile(); DCHECK(app_profile); - if (!app_service_proxy) { - app_service_proxy = - apps::AppServiceProxyFactory::GetForProfile(app_profile); - if (!app_service_proxy) - return false; - } + app_service_proxy->AppRegistryCache().ForOneApp( app_id, [&](const apps::AppUpdate& app) { - installed = app.Readiness() == apps::mojom::Readiness::kReady; + installed = apps_util::IsInstalled(app.Readiness()); }); if (installed) return true; @@ -117,7 +114,7 @@ app_service_proxy->AppRegistryCache().ForOneApp( iter.first, [&name](const apps::AppUpdate& update) { name = update.ShortName(); }); - if (!IsAppAvailable(name, app_service_proxy)) + if (!IsAppAvailable(iter.first, app_service_proxy)) app_names.push_back(name); } return app_names;
diff --git a/chrome/browser/ui/ash/desks_templates/desks_templates_client_browsertest.cc b/chrome/browser/ui/ash/desks_templates/desks_templates_client_browsertest.cc index 6c320a2..c57789c 100644 --- a/chrome/browser/ui/ash/desks_templates/desks_templates_client_browsertest.cc +++ b/chrome/browser/ui/ash/desks_templates/desks_templates_client_browsertest.cc
@@ -1028,12 +1028,14 @@ ASSERT_TRUE(template_item); ClickButton(template_item); - // TODO(sammiequon): Investigate a better wait here after the new desk from - // template behavior is finalized and implemented. - base::RunLoop run_loop; - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, run_loop.QuitClosure(), base::Seconds(1)); - run_loop.Run(); + // Clicking the button is a two part, both async process. We need to wait for + // the template to be fetched from the model, and then wait for the desk + // animation to be launched. + // TODO(dandersson): Remove this when the desk is no longer activated on + // template launch. + ash::WaitForDesksTemplatesUI(); + ash::DeskSwitchAnimationWaiter waiter; + waiter.Wait(); // Wait for the tabs to load. content::RunAllTasksUntilIdle();
diff --git a/chrome/browser/ui/ash/shelf/chrome_shelf_controller_util.cc b/chrome/browser/ui/ash/shelf/chrome_shelf_controller_util.cc index cfbcb43c..fc563a9 100644 --- a/chrome/browser/ui/ash/shelf/chrome_shelf_controller_util.cc +++ b/chrome/browser/ui/ash/shelf/chrome_shelf_controller_util.cc
@@ -161,16 +161,8 @@ auto* shelf_model = shelf_controller->shelf_model(); if (shelf_model->ItemIndexByAppID(app_id) >= 0) { shelf_model->PinExistingItemWithID(app_id); - return; - } - - ash::ShelfItem item; - std::unique_ptr<ash::ShelfItemDelegate> delegate; - bool result = shelf_controller->shelf_item_factory()->CreateShelfItemForAppId( - app_id, &item, &delegate); - if (result) { - item.type = ash::TYPE_PINNED_APP; - shelf_model->Add(item, std::move(delegate)); + } else { + shelf_model->AddAndPinAppWithFactoryConstructedDelegate(app_id); } }
diff --git a/chrome/browser/ui/browser_live_tab_context.cc b/chrome/browser/ui/browser_live_tab_context.cc index fa8fefb7..f26ab54 100644 --- a/chrome/browser/ui/browser_live_tab_context.cc +++ b/chrome/browser/ui/browser_live_tab_context.cc
@@ -102,9 +102,9 @@ browser_->tab_strip_model()->GetActiveWebContents()); } -std::map<std::string, base::Value> BrowserLiveTabContext::GetExtraDataForTab( +std::map<std::string, std::string> BrowserLiveTabContext::GetExtraDataForTab( int index) const { - std::map<std::string, base::Value> extra_data; + std::map<std::string, std::string> extra_data; #if BUILDFLAG(ENABLE_SIDE_SEARCH) if (IsSideSearchEnabled(browser_->profile())) { @@ -116,9 +116,9 @@ return extra_data; } -std::map<std::string, base::Value> +std::map<std::string, std::string> BrowserLiveTabContext::GetExtraDataForWindow() const { - std::map<std::string, base::Value> extra_data; + std::map<std::string, std::string> extra_data; #if BUILDFLAG(ENABLE_SIDE_SEARCH) if (IsSideSearchEnabled(browser_->profile())) { @@ -178,7 +178,7 @@ bool pin, const sessions::PlatformSpecificTabData* tab_platform_data, const sessions::SerializedUserAgentOverride& user_agent_override, - const std::map<std::string, base::Value>& extra_data, + const std::map<std::string, std::string>& extra_data, const SessionID* tab_id) { SessionStorageNamespace* storage_namespace = tab_platform_data @@ -261,7 +261,7 @@ const std::string& extension_app_id, const sessions::PlatformSpecificTabData* tab_platform_data, const sessions::SerializedUserAgentOverride& user_agent_override, - const std::map<std::string, base::Value>& extra_data) { + const std::map<std::string, std::string>& extra_data) { SessionStorageNamespace* storage_namespace = tab_platform_data ? static_cast<const sessions::ContentPlatformSpecificTabData*>( @@ -292,7 +292,7 @@ ui::WindowShowState show_state, const std::string& workspace, const std::string& user_title, - const std::map<std::string, base::Value>& extra_data) { + const std::map<std::string, std::string>& extra_data) { std::unique_ptr<Browser::CreateParams> create_params; if (ShouldCreateAppWindowForAppName(profile, app_name)) { // Only trusted app popup windows should ever be restored.
diff --git a/chrome/browser/ui/browser_live_tab_context.h b/chrome/browser/ui/browser_live_tab_context.h index 0969545..e9eeed4 100644 --- a/chrome/browser/ui/browser_live_tab_context.h +++ b/chrome/browser/ui/browser_live_tab_context.h
@@ -18,10 +18,6 @@ class Browser; class Profile; -namespace base { -class Value; -} - namespace content { class WebContents; } @@ -50,9 +46,9 @@ std::string GetUserTitle() const override; sessions::LiveTab* GetLiveTabAt(int index) const override; sessions::LiveTab* GetActiveLiveTab() const override; - std::map<std::string, base::Value> GetExtraDataForTab( + std::map<std::string, std::string> GetExtraDataForTab( int index) const override; - std::map<std::string, base::Value> GetExtraDataForWindow() const override; + std::map<std::string, std::string> GetExtraDataForWindow() const override; absl::optional<tab_groups::TabGroupId> GetTabGroupForTab( int index) const override; const tab_groups::TabGroupVisualData* GetVisualDataForGroup( @@ -75,7 +71,7 @@ bool pin, const sessions::PlatformSpecificTabData* storage_namespace, const sessions::SerializedUserAgentOverride& user_agent_override, - const std::map<std::string, base::Value>& extra_data, + const std::map<std::string, std::string>& extra_data, const SessionID* tab_id) override; sessions::LiveTab* ReplaceRestoredTab( const std::vector<sessions::SerializedNavigationEntry>& navigations, @@ -84,7 +80,7 @@ const std::string& extension_app_id, const sessions::PlatformSpecificTabData* tab_platform_data, const sessions::SerializedUserAgentOverride& user_agent_override, - const std::map<std::string, base::Value>& extra_data) override; + const std::map<std::string, std::string>& extra_data) override; void CloseTab() override; // see Browser::Create @@ -95,7 +91,7 @@ ui::WindowShowState show_state, const std::string& workspace, const std::string& user_title, - const std::map<std::string, base::Value>& extra_data); + const std::map<std::string, std::string>& extra_data); // see browser::FindBrowserForWebContents static sessions::LiveTabContext* FindContextForWebContents(
diff --git a/chrome/browser/ui/browser_window.h b/chrome/browser/ui/browser_window.h index 5c7e1ff..985a5be 100644 --- a/chrome/browser/ui/browser_window.h +++ b/chrome/browser/ui/browser_window.h
@@ -560,7 +560,7 @@ #if BUILDFLAG(ENABLE_SIDE_SEARCH) virtual bool IsSideSearchPanelVisible() const = 0; virtual void MaybeRestoreSideSearchStatePerWindow( - const std::map<std::string, base::Value>& extra_data) = 0; + const std::map<std::string, std::string>& extra_data) = 0; #endif protected:
diff --git a/chrome/browser/ui/side_search/BUILD.gn b/chrome/browser/ui/side_search/BUILD.gn new file mode 100644 index 0000000..2495de1 --- /dev/null +++ b/chrome/browser/ui/side_search/BUILD.gn
@@ -0,0 +1,13 @@ +# Copyright 2021 The Chromium Authors.All rights reserved. +# Use of this source code is governed by a BSD - style license that can be +# found in the LICENSE file. + +import("//third_party/protobuf/proto_library.gni") + +proto_library("side_search_window_data_proto") { + sources = [ "side_search_window_data.proto" ] +} + +proto_library("side_search_tab_data_proto") { + sources = [ "side_search_tab_data.proto" ] +}
diff --git a/chrome/browser/ui/side_search/side_search_tab_data.proto b/chrome/browser/ui/side_search/side_search_tab_data.proto new file mode 100644 index 0000000..e9e456c --- /dev/null +++ b/chrome/browser/ui/side_search/side_search_tab_data.proto
@@ -0,0 +1,18 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +syntax = "proto3"; + +option optimize_for = LITE_RUNTIME; + +package side_search; + +// Used for storing a tab's associated Side Search state. +message SideSearchTabData { + // The last search URL encountered by the current tab. + string last_search_url = 1; + + // Whether the side panel is open or closed for the current tab. + bool toggled_open = 2; +}
diff --git a/chrome/browser/ui/side_search/side_search_utils.cc b/chrome/browser/ui/side_search/side_search_utils.cc index b1db2096..bcb2b253 100644 --- a/chrome/browser/ui/side_search/side_search_utils.cc +++ b/chrome/browser/ui/side_search/side_search_utils.cc
@@ -4,11 +4,14 @@ #include "chrome/browser/ui/side_search/side_search_utils.h" +#include <string> + #include "base/containers/contains.h" -#include "base/values.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/side_search/side_search_prefs.h" #include "chrome/browser/ui/side_search/side_search_tab_contents_helper.h" +#include "chrome/browser/ui/side_search/side_search_tab_data.pb.h" +#include "chrome/browser/ui/side_search/side_search_window_data.pb.h" #include "chrome/browser/ui/ui_features.h" #include "components/prefs/pref_service.h" #include "content/public/browser/web_contents.h" @@ -16,69 +19,66 @@ namespace side_search { const char kSideSearchExtraDataKey[] = "side_search"; -const char kLastSearchUrl[] = "last_search_url"; -const char kToggledOpen[] = "toggled_open"; void MaybeAddSideSearchTabRestoreData( content::WebContents* web_contents, - std::map<std::string, base::Value>& extra_data) { + std::map<std::string, std::string>& extra_data) { SideSearchTabContentsHelper* helper = SideSearchTabContentsHelper::FromWebContents(web_contents); if (helper && helper->last_search_url().has_value()) { - base::Value side_search_tab_data(base::Value::Type::DICTIONARY); - side_search_tab_data.SetStringKey(kLastSearchUrl, - helper->last_search_url().value().spec()); - side_search_tab_data.SetBoolKey(kToggledOpen, helper->toggled_open()); + SideSearchTabData side_search_tab_data; + side_search_tab_data.set_last_search_url( + helper->last_search_url().value().spec()); + side_search_tab_data.set_toggled_open(helper->toggled_open()); - extra_data[kSideSearchExtraDataKey] = std::move(side_search_tab_data); + extra_data[kSideSearchExtraDataKey] = + side_search_tab_data.SerializeAsString(); } } void MaybeAddSideSearchWindowRestoreData( bool toggled_open, - std::map<std::string, base::Value>& extra_data) { + std::map<std::string, std::string>& extra_data) { if (base::FeatureList::IsEnabled(features::kSideSearchStatePerTab)) return; - base::Value side_search_window_data(base::Value::Type::DICTIONARY); - side_search_window_data.SetBoolKey(kToggledOpen, toggled_open); + SideSearchWindowData side_search_window_data; + side_search_window_data.set_toggled_open(toggled_open); - extra_data[kSideSearchExtraDataKey] = std::move(side_search_window_data); + extra_data[kSideSearchExtraDataKey] = + side_search_window_data.SerializeAsString(); } void MaybeRestoreSideSearchWindowState( SideSearchTabContentsHelper::Delegate* delegate, - const std::map<std::string, base::Value>& extra_data) { + const std::map<std::string, std::string>& extra_data) { if (base::FeatureList::IsEnabled(features::kSideSearchStatePerTab)) return; if (base::Contains(extra_data, kSideSearchExtraDataKey)) { - absl::optional<bool> toggled_open = - extra_data.at(kSideSearchExtraDataKey).FindBoolKey(kToggledOpen); + SideSearchWindowData side_search_window_data; + side_search_window_data.ParseFromString( + extra_data.at(kSideSearchExtraDataKey)); - if (toggled_open.has_value() && toggled_open.value()) + if (side_search_window_data.toggled_open()) delegate->OpenSidePanel(); } } void SetSideSearchStateFromRestoreData( content::WebContents* web_contents, - const std::map<std::string, base::Value>& extra_data) { + const std::map<std::string, std::string>& extra_data) { if (base::Contains(extra_data, kSideSearchExtraDataKey)) { auto* side_search_tab_contents_helper = SideSearchTabContentsHelper::FromWebContents(web_contents); - const std::string* last_search_url_str = - extra_data.at(kSideSearchExtraDataKey).FindStringKey(kLastSearchUrl); - if (last_search_url_str) - side_search_tab_contents_helper->set_last_search_url( - GURL(*last_search_url_str)); - - absl::optional<bool> toggled_open = - extra_data.at(kSideSearchExtraDataKey).FindBoolKey(kToggledOpen); - if (toggled_open.has_value()) { - side_search_tab_contents_helper->set_toggled_open(toggled_open.value()); - } + SideSearchTabData side_search_tab_data; + side_search_tab_data.ParseFromString( + extra_data.at(kSideSearchExtraDataKey)); + side_search_tab_contents_helper->set_last_search_url( + GURL(side_search_tab_data.last_search_url())); + side_search_tab_contents_helper->set_toggled_open( + side_search_tab_data.toggled_open()); } }
diff --git a/chrome/browser/ui/side_search/side_search_utils.h b/chrome/browser/ui/side_search/side_search_utils.h index 54ba742..0a95b73 100644 --- a/chrome/browser/ui/side_search/side_search_utils.h +++ b/chrome/browser/ui/side_search/side_search_utils.h
@@ -14,10 +14,6 @@ class Profile; -namespace base { -class Value; -} - namespace content { class WebContents; } @@ -27,20 +23,20 @@ // Adds side search state data to a tab's state restore data if applicable. void MaybeAddSideSearchTabRestoreData( content::WebContents* web_contents, - std::map<std::string, base::Value>& extra_data); + std::map<std::string, std::string>& extra_data); // Add side search state data for a window's state restore data if applicable. void MaybeAddSideSearchWindowRestoreData( bool toggled_open, - std::map<std::string, base::Value>& extra_data); + std::map<std::string, std::string>& extra_data); void MaybeRestoreSideSearchWindowState( SideSearchTabContentsHelper::Delegate* delegate, - const std::map<std::string, base::Value>& extra_data); + const std::map<std::string, std::string>& extra_data); void SetSideSearchStateFromRestoreData( content::WebContents* web_contents, - const std::map<std::string, base::Value>& extra_data); + const std::map<std::string, std::string>& extra_data); } // namespace side_search
diff --git a/chrome/browser/ui/side_search/side_search_window_data.proto b/chrome/browser/ui/side_search/side_search_window_data.proto new file mode 100644 index 0000000..af36f206 --- /dev/null +++ b/chrome/browser/ui/side_search/side_search_window_data.proto
@@ -0,0 +1,15 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +syntax = "proto3"; + +option optimize_for = LITE_RUNTIME; + +package side_search; + +// Used for storing a window's associated Side search state. +message SideSearchWindowData { + // Whether the side panel is open or closed for the current window. + bool toggled_open = 1; +}
diff --git a/chrome/browser/ui/views/frame/browser_root_view.cc b/chrome/browser/ui/views/frame/browser_root_view.cc index 6e2d0988..612684da 100644 --- a/chrome/browser/ui/views/frame/browser_root_view.cc +++ b/chrome/browser/ui/views/frame/browser_root_view.cc
@@ -73,7 +73,6 @@ void OnFindURLMimeType(const GURL& url, int process_id, - int routing_id, FileSupportedCallback callback, const std::string& mime_type) { // Check whether the mime type, if given, is known to be supported or whether @@ -84,9 +83,9 @@ #if BUILDFLAG(ENABLE_PLUGINS) content::WebPluginInfo plugin; - result = result || content::PluginService::GetInstance()->GetPluginInfo( - process_id, routing_id, url, url::Origin(), mime_type, - false, nullptr, &plugin, nullptr); + result = result || + content::PluginService::GetInstance()->GetPluginInfo( + process_id, url, mime_type, false, nullptr, &plugin, nullptr); #endif std::move(callback).Run(url, result); @@ -177,7 +176,6 @@ FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE}, base::BindOnce(&FindURLMimeType, url), base::BindOnce(&OnFindURLMimeType, url, rfh->GetProcess()->GetID(), - rfh->GetRoutingID(), base::BindOnce(&BrowserRootView::OnFileSupported, weak_ptr_factory_.GetWeakPtr()))); }
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 2ab684b..a2bef32 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -3062,7 +3062,7 @@ } void BrowserView::MaybeRestoreSideSearchStatePerWindow( - const std::map<std::string, base::Value>& extra_data) { + const std::map<std::string, std::string>& extra_data) { if (side_search_controller_) { side_search::MaybeRestoreSideSearchWindowState( side_search_controller_.get(), extra_data);
diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h index 93e2cd3..003434b 100644 --- a/chrome/browser/ui/views/frame/browser_view.h +++ b/chrome/browser/ui/views/frame/browser_view.h
@@ -701,7 +701,7 @@ #if BUILDFLAG(ENABLE_SIDE_SEARCH) bool IsSideSearchPanelVisible() const override; void MaybeRestoreSideSearchStatePerWindow( - const std::map<std::string, base::Value>& extra_data) override; + const std::map<std::string, std::string>& extra_data) override; #endif private:
diff --git a/chrome/browser/ui/views/frame/top_controls_slide_controller_chromeos.cc b/chrome/browser/ui/views/frame/top_controls_slide_controller_chromeos.cc index cee49c46..09bc05f 100644 --- a/chrome/browser/ui/views/frame/top_controls_slide_controller_chromeos.cc +++ b/chrome/browser/ui/views/frame/top_controls_slide_controller_chromeos.cc
@@ -584,10 +584,6 @@ if (!web_contents) return; - content::RenderFrameHost* main_frame = web_contents->GetMainFrame(); - if (!main_frame) - return; - // If the omnibox is focused, then the top controls should be constrained to // remain fully shown until the omnibox is blurred. const cc::BrowserControlsState constraints_state =
diff --git a/chrome/browser/ui/views/global_media_controls/media_dialog_view_interactive_browsertest.cc b/chrome/browser/ui/views/global_media_controls/media_dialog_view_interactive_browsertest.cc index 9034e2be..6c55363 100644 --- a/chrome/browser/ui/views/global_media_controls/media_dialog_view_interactive_browsertest.cc +++ b/chrome/browser/ui/views/global_media_controls/media_dialog_view_interactive_browsertest.cc
@@ -964,8 +964,9 @@ base::UTF16ToUTF8(GetLiveCaptionTitleLabel()->GetText())); } -#if defined(OS_MAC) && defined(ARCH_CPU_ARM64) +#if defined(OS_MAC) // https://crbug.com/1222873 +// Flaky on all Mac bots: https://crbug.com/1274967 #define MAYBE_LiveCaptionProgressUpdate DISABLED_LiveCaptionProgressUpdate #else #define MAYBE_LiveCaptionProgressUpdate LiveCaptionProgressUpdate
diff --git a/chrome/browser/ui/views/lens/OWNERS b/chrome/browser/ui/views/lens/OWNERS new file mode 100644 index 0000000..cf750e8 --- /dev/null +++ b/chrome/browser/ui/views/lens/OWNERS
@@ -0,0 +1,2 @@ +benwgold@google.com +yusuyoutube@google.com \ No newline at end of file
diff --git a/chrome/browser/ui/views/lens/lens_side_panel_view.cc b/chrome/browser/ui/views/lens/lens_side_panel_view.cc index a51fc6bc..303dc60 100644 --- a/chrome/browser/ui/views/lens/lens_side_panel_view.cc +++ b/chrome/browser/ui/views/lens/lens_side_panel_view.cc
@@ -65,8 +65,6 @@ icon, dip_size); button->SetTooltipText(tooltip_text); button->SetImageHorizontalAlignment(views::ImageButton::ALIGN_CENTER); - button->SetBackground( - views::CreateThemedSolidBackground(host, ui::kColorWindowBackground)); button->SetProperty(views::kMarginsKey, margin_insets); return button; }
diff --git a/chrome/browser/ui/web_applications/web_app_browsertest.cc b/chrome/browser/ui/web_applications/web_app_browsertest.cc index ba8c06a..6b58233 100644 --- a/chrome/browser/ui/web_applications/web_app_browsertest.cc +++ b/chrome/browser/ui/web_applications/web_app_browsertest.cc
@@ -19,7 +19,6 @@ #include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "build/os_buildflags.h" -#include "chrome/app/chrome_command_ids.h" #include "chrome/browser/apps/app_service/app_launch_params.h" #include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy_factory.h" @@ -56,6 +55,7 @@ #include "chrome/browser/web_applications/external_install_options.h" #include "chrome/browser/web_applications/externally_installed_web_app_prefs.h" #include "chrome/browser/web_applications/test/web_app_test_observers.h" +#include "chrome/browser/web_applications/test/web_app_test_utils.h" #include "chrome/browser/web_applications/web_app.h" #include "chrome/browser/web_applications/web_app_constants.h" #include "chrome/browser/web_applications/web_app_helpers.h" @@ -175,19 +175,6 @@ return https_server()->GetURL("app.com", path); } - AppId InstallPwaForCurrentUrl() { - // Depending on the installability criteria, different dialogs can be used. - chrome::SetAutoAcceptWebAppDialogForTesting(true, true); - chrome::SetAutoAcceptPWAInstallConfirmationForTesting(true); - WebAppTestInstallObserver observer(profile()); - observer.BeginListening(); - CHECK(chrome::ExecuteCommand(browser(), IDC_INSTALL_PWA)); - AppId app_id = observer.Wait(); - chrome::SetAutoAcceptPWAInstallConfirmationForTesting(false); - chrome::SetAutoAcceptWebAppDialogForTesting(false, false); - return app_id; - } - bool HasMinimalUiButtons(DisplayMode display_mode, absl::optional<DisplayMode> display_override_mode, bool open_as_window) { @@ -465,7 +452,7 @@ "manifest_test_page.html?manifest=manifest_display_override.json"); NavigateToURLAndWait(browser(), test_url); - const AppId app_id = InstallPwaForCurrentUrl(); + const AppId app_id = test::InstallPwaForCurrentUrl(browser()); auto* provider = WebAppProvider::GetForTest(profile()); std::vector<DisplayMode> app_display_mode_override = @@ -910,7 +897,7 @@ NavigateToURLAndWait( browser(), https_server()->GetURL("/banners/scope_is_start_url/index.html")); - InstallPwaForCurrentUrl(); + test::InstallPwaForCurrentUrl(browser()); // Open a page that is one directory up from the installed PWA. Browser* const new_browser = NavigateInNewWindowAndAwaitInstallabilityCheck( @@ -928,7 +915,7 @@ base::UserActionTester user_action_tester; NavigateToURLAndWait(browser(), GetInstallableAppURL()); - const AppId app_id = InstallPwaForCurrentUrl(); + const AppId app_id = test::InstallPwaForCurrentUrl(browser()); auto* provider = WebAppProvider::GetForTest(profile()); EXPECT_EQ(provider->registrar().GetAppShortName(app_id), GetInstallableAppName()); @@ -953,7 +940,7 @@ IN_PROC_BROWSER_TEST_F(WebAppBrowserTest, DISABLE_POSIX(CanInstallOverBrowserTabPwa)) { NavigateToURLAndWait(browser(), GetInstallableAppURL()); - const AppId app_id = InstallPwaForCurrentUrl(); + const AppId app_id = test::InstallPwaForCurrentUrl(browser()); // Change display mode to open in tab. auto* provider = WebAppProvider::GetForTest(profile()); @@ -972,7 +959,7 @@ IN_PROC_BROWSER_TEST_F(WebAppBrowserTest, DISABLE_POSIX(CannotInstallOverWindowPwa)) { NavigateToURLAndWait(browser(), GetInstallableAppURL()); - InstallPwaForCurrentUrl(); + test::InstallPwaForCurrentUrl(browser()); // Avoid any interference if active browser was changed by PWA install. Browser* const new_browser = @@ -1079,7 +1066,7 @@ content::WindowedNotificationObserver app_loaded_observer( content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, content::NotificationService::AllSources()); - const AppId app_id = InstallPwaForCurrentUrl(); + const AppId app_id = test::InstallPwaForCurrentUrl(browser()); run_loop_install.Run(); app_loaded_observer.Wait(); @@ -1165,7 +1152,7 @@ content::WindowedNotificationObserver app_loaded_observer( content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, content::NotificationService::AllSources()); - const AppId app_id = InstallPwaForCurrentUrl(); + const AppId app_id = test::InstallPwaForCurrentUrl(browser()); run_loop_install.Run(); app_loaded_observer.Wait(); @@ -1223,7 +1210,7 @@ content::WindowedNotificationObserver app_loaded_observer( content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, content::NotificationService::AllSources()); - const AppId app_id = InstallPwaForCurrentUrl(); + const AppId app_id = test::InstallPwaForCurrentUrl(browser()); run_loop_install.Run(); app_loaded_observer.Wait(); @@ -1660,7 +1647,7 @@ "manifest_test_page.html?manifest=manifest_window_controls_overlay.json"); NavigateToURLAndWait(browser(), test_url); - const AppId app_id = InstallPwaForCurrentUrl(); + const AppId app_id = test::InstallPwaForCurrentUrl(browser()); auto* provider = WebAppProvider::GetForTest(profile()); std::vector<DisplayMode> app_display_mode_override = @@ -1681,7 +1668,7 @@ "manifest_test_page.html?manifest=manifest_tabbed_display_override.json"); NavigateToURLAndWait(browser(), test_url); - const AppId app_id = InstallPwaForCurrentUrl(); + const AppId app_id = test::InstallPwaForCurrentUrl(browser()); auto* provider = WebAppProvider::GetForTest(profile()); std::vector<DisplayMode> app_display_mode_override = @@ -1704,7 +1691,7 @@ IN_PROC_BROWSER_TEST_F(WebAppBrowserTest_RemoveStatusBar, DISABLE_POSIX(RemoveStatusBar)) { NavigateToURLAndWait(browser(), GetInstallableAppURL()); - const AppId app_id = InstallPwaForCurrentUrl(); + const AppId app_id = test::InstallPwaForCurrentUrl(browser()); Browser* const app_browser = LaunchWebAppBrowser(app_id); EXPECT_EQ(nullptr, app_browser->GetStatusBubbleForTesting()); } @@ -1755,7 +1742,7 @@ DISABLE_POSIX(NoManifestId)) { NavigateToURLAndWait(browser(), GetInstallableAppURL()); - const AppId app_id = InstallPwaForCurrentUrl(); + const AppId app_id = test::InstallPwaForCurrentUrl(browser()); auto* provider = WebAppProvider::GetForTest(profile()); auto* app = provider->registrar().GetAppById(app_id); @@ -1774,7 +1761,7 @@ https_server()->GetURL( "/banners/manifest_test_page.html?manifest=manifest_with_id.json")); - const AppId app_id = InstallPwaForCurrentUrl(); + const AppId app_id = test::InstallPwaForCurrentUrl(browser()); auto* provider = WebAppProvider::GetForTest(profile()); auto* app = provider->registrar().GetAppById(app_id); @@ -1834,7 +1821,7 @@ WebAppTestRegistryObserverAdapter observer(profile()); observer.SetWebAppInstalledWithOsHooksDelegate(base::BindLambdaForTesting( [&](const AppId& installed_app_id) { run_loop_install.Quit(); })); - const AppId app_id = InstallPwaForCurrentUrl(); + const AppId app_id = test::InstallPwaForCurrentUrl(browser()); run_loop_install.Run(); content::RunAllTasksUntilIdle(); chrome::SetAutoAcceptWebAppDialogForTesting(false, false); @@ -1917,7 +1904,7 @@ WebAppTestRegistryObserverAdapter observer(profile()); observer.SetWebAppInstalledWithOsHooksDelegate(base::BindLambdaForTesting( [&](const AppId& installed_app_id) { run_loop_install.Quit(); })); - const AppId app_id = InstallPwaForCurrentUrl(); + const AppId app_id = test::InstallPwaForCurrentUrl(browser()); run_loop_install.Run(); EXPECT_TRUE(provider->registrar().IsInstalled(app_id));
diff --git a/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc b/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc index d878efc..2215ba2 100644 --- a/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc +++ b/chrome/browser/ui/webui/settings/chromeos/internet_handler.cc
@@ -7,6 +7,7 @@ #include <memory> #include <vector> +#include "ash/components/arc/mojom/net.mojom.h" #include "ash/components/arc/session/arc_bridge_service.h" #include "ash/components/arc/session/arc_service_manager.h" #include "ash/constants/ash_pref_names.h" @@ -23,7 +24,6 @@ #include "chromeos/network/network_event_log.h" #include "chromeos/network/network_state.h" #include "chromeos/network/network_state_handler.h" -#include "components/arc/mojom/net.mojom.h" #include "components/onc/onc_constants.h" #include "components/prefs/pref_service.h" #include "content/public/browser/web_contents.h"
diff --git a/chrome/browser/upgrade_detector/get_installed_version_lacros.cc b/chrome/browser/upgrade_detector/get_installed_version_lacros.cc index 96e0928a..86b7e092 100644 --- a/chrome/browser/upgrade_detector/get_installed_version_lacros.cc +++ b/chrome/browser/upgrade_detector/get_installed_version_lacros.cc
@@ -8,16 +8,32 @@ #include "base/bind.h" #include "base/callback.h" +#include "base/containers/contains.h" #include "base/logging.h" #include "base/version.h" #include "chromeos/crosapi/mojom/browser_version.mojom.h" #include "chromeos/lacros/lacros_service.h" #include "components/version_info/version_info.h" +namespace { + +// The presence of this capability constant in the ash capabilities array +// indicates that Ash supports reloading and starting updated browser images on +// subsequent starts. +constexpr char kBrowserManagerReloadBrowserCapability[] = "crbug/1237235"; + +} // namespace + void GetInstalledVersion(InstalledVersionCallback callback) { + // In addition to checking that Ash supports the browser version API, we also + // check that Ash supports loading the latest browser image on subsequent + // starts by inspecting the ash capabilities entries. auto* lacros_service = chromeos::LacrosService::Get(); if (lacros_service && - lacros_service->IsAvailable<crosapi::mojom::BrowserVersionService>()) { + lacros_service->IsAvailable<crosapi::mojom::BrowserVersionService>() && + lacros_service->init_params()->ash_capabilities.has_value() && + base::Contains(lacros_service->init_params()->ash_capabilities.value(), + kBrowserManagerReloadBrowserCapability)) { lacros_service->GetRemote<crosapi::mojom::BrowserVersionService>() ->GetInstalledBrowserVersion(base::BindOnce( [](InstalledVersionCallback callback, @@ -26,16 +42,18 @@ InstalledAndCriticalVersion(base::Version(version_str))); }, std::move(callback))); - } else { - // Invoking an Ash-Chrome version that predates the introduction of the - // GetInstalledBrowserVersion API will result in this failure. - DLOG(ERROR) - << "Current lacros service does not support the browser version api."; - - // We must return the current version as opposed to an invalid version so - // that the InstalledVersionPoller can interpret that no update is - // available. - std::move(callback).Run( - InstalledAndCriticalVersion(version_info::GetVersion())); + return; } + + // Invoking an Ash-Chrome version that predates the introduction of the + // GetInstalledBrowserVersion API or browser relaunch capability will result + // in this failure. + DLOG(ERROR) << "Current lacros service does not support the browser version " + "api or relaunch capability."; + + // We must return the current version as opposed to an invalid version so + // that the InstalledVersionPoller can interpret that no update is + // available. + std::move(callback).Run( + InstalledAndCriticalVersion(version_info::GetVersion())); }
diff --git a/chrome/browser/web_applications/BUILD.gn b/chrome/browser/web_applications/BUILD.gn index c1391b3..2191b37 100644 --- a/chrome/browser/web_applications/BUILD.gn +++ b/chrome/browser/web_applications/BUILD.gn
@@ -446,6 +446,7 @@ ":web_app_test_group", ":web_applications", "//base/test:test_support", + "//chrome/app:command_ids", "//chrome/app/theme:chrome_unscaled_resources_grit", "//chrome/browser", "//chrome/browser/profiles:profile", @@ -602,6 +603,7 @@ sources = [ "externally_managed_app_manager_impl_browsertest.cc", + "isolated_app_browsertest.cc", "manifest_update_manager_browsertest.cc", "preinstalled_web_app_manager_browsertest.cc", "preinstalled_web_app_migration_browsertest.cc",
diff --git a/chrome/browser/web_applications/isolated_app_browsertest.cc b/chrome/browser/web_applications/isolated_app_browsertest.cc new file mode 100644 index 0000000..a66da45f --- /dev/null +++ b/chrome/browser/web_applications/isolated_app_browsertest.cc
@@ -0,0 +1,78 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/test/scoped_feature_list.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/web_applications/web_app_controller_browsertest.h" +#include "chrome/browser/web_applications/test/web_app_test_utils.h" +#include "chrome/test/base/ui_test_utils.h" +#include "content/public/test/browser_test.h" +#include "third_party/blink/public/common/features.h" + +namespace web_app { + +namespace { + +const char kAppHost[] = "app.com"; +const char kApp2Host[] = "app2.com"; + +} // namespace + +class IsolatedAppBrowserTest : public WebAppControllerBrowserTest { + public: + IsolatedAppBrowserTest() + : scoped_feature_list_(blink::features::kWebAppEnableIsolatedStorage) {} + + IsolatedAppBrowserTest(const IsolatedAppBrowserTest&) = delete; + IsolatedAppBrowserTest& operator=(const IsolatedAppBrowserTest&) = delete; + ~IsolatedAppBrowserTest() override = default; + + protected: + AppId InstallIsolatedApp(const std::string& host) { + GURL app_url = https_server()->GetURL(host, + "/banners/manifest_test_page.html" + "?manifest=manifest_isolated.json"); + EXPECT_TRUE(ui_test_utils::NavigateToURLWithDisposition( + browser(), app_url, WindowOpenDisposition::NEW_FOREGROUND_TAB, + ui_test_utils::BROWSER_TEST_WAIT_FOR_LOAD_STOP)); + return test::InstallPwaForCurrentUrl(browser()); + } + + content::StoragePartition* default_storage_partition() { + return browser()->profile()->GetDefaultStoragePartition(); + } + + content::RenderFrameHost* GetMainFrame(Browser* browser) { + return browser->tab_strip_model()->GetActiveWebContents()->GetMainFrame(); + } + + private: + base::test::ScopedFeatureList scoped_feature_list_; +}; + +IN_PROC_BROWSER_TEST_F(IsolatedAppBrowserTest, AppsPartitioned) { + InstallIsolatedApp(kAppHost); + InstallIsolatedApp(kApp2Host); + + auto* non_app_frame = ui_test_utils::NavigateToURL( + browser(), https_server()->GetURL("/banners/isolated/simple.html")); + EXPECT_TRUE(non_app_frame); + EXPECT_EQ(default_storage_partition(), non_app_frame->GetStoragePartition()); + + auto* app_window = NavigateInNewWindowAndAwaitInstallabilityCheck( + https_server()->GetURL(kAppHost, "/banners/isolated/simple.html")); + auto* app_frame = GetMainFrame(app_window); + EXPECT_NE(default_storage_partition(), app_frame->GetStoragePartition()); + + auto* app2_window = NavigateInNewWindowAndAwaitInstallabilityCheck( + https_server()->GetURL(kApp2Host, "/banners/isolated/simple.html")); + auto* app2_frame = GetMainFrame(app2_window); + EXPECT_NE(default_storage_partition(), app2_frame->GetStoragePartition()); + + EXPECT_NE(app_frame->GetStoragePartition(), + app2_frame->GetStoragePartition()); +} + +} // namespace web_app
diff --git a/chrome/browser/web_applications/isolation_prefs_utils.cc b/chrome/browser/web_applications/isolation_prefs_utils.cc index 531f259..34e3a18 100644 --- a/chrome/browser/web_applications/isolation_prefs_utils.cc +++ b/chrome/browser/web_applications/isolation_prefs_utils.cc
@@ -30,8 +30,24 @@ // }, // } +namespace { + const char kStorageIsolationKey[] = "storage_isolation_key"; +// Creates a copy of the given origin but without a port set. This is a +// temporary hack meant to work around the fact that we key app isolation state +// on the app's origin, but StoragePartitions are looked up based on sites. +// Removing the port does not convert an origin into a site, but the actual +// origin to site logic is private to //content and this is good enough to +// allow testing in the short term. +// TODO(crbug.com/1212263): Remove this function. +url::Origin RemovePort(const url::Origin& origin) { + return url::Origin::CreateFromNormalizedTuple(origin.scheme(), origin.host(), + /*port=*/0); +} + +} // namespace + void IsolationPrefsUtilsRegisterProfilePrefs(PrefRegistrySimple* registry) { registry->RegisterDictionaryPref(::prefs::kWebAppsIsolationState); } @@ -39,7 +55,7 @@ void RecordOrRemoveAppIsolationState(PrefService* pref_service, const WebApp& web_app) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - url::Origin origin = url::Origin::Create(web_app.scope()); + url::Origin origin = RemovePort(url::Origin::Create(web_app.scope())); prefs::ScopedDictionaryPrefUpdate update(pref_service, prefs::kWebAppsIsolationState); @@ -61,7 +77,7 @@ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); prefs::ScopedDictionaryPrefUpdate update(pref_service, prefs::kWebAppsIsolationState); - update->RemoveWithoutPathExpansion(origin.Serialize(), nullptr); + update->RemoveWithoutPathExpansion(RemovePort(origin).Serialize(), nullptr); } const std::string* GetStorageIsolationKey(PrefService* pref_service, @@ -73,7 +89,7 @@ return nullptr; const base::Value* origin_prefs = - isolation_prefs->FindDictKey(origin.Serialize()); + isolation_prefs->FindDictKey(RemovePort(origin).Serialize()); if (!origin_prefs) return nullptr; return origin_prefs->FindStringKey(kStorageIsolationKey);
diff --git a/chrome/browser/web_applications/test/web_app_test_utils.cc b/chrome/browser/web_applications/test/web_app_test_utils.cc index 4147cce..8199fd0 100644 --- a/chrome/browser/web_applications/test/web_app_test_utils.cc +++ b/chrome/browser/web_applications/test/web_app_test_utils.cc
@@ -8,6 +8,11 @@ #include "base/strings/utf_string_conversions.h" #include "base/threading/thread_task_runner_handle.h" +#include "chrome/app/chrome_command_ids.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_commands.h" +#include "chrome/browser/ui/browser_dialogs.h" +#include "chrome/browser/web_applications/test/web_app_test_observers.h" #include "chrome/browser/web_applications/web_app_helpers.h" #include "chrome/browser/web_applications/web_app_utils.h" #include "chrome/browser/web_applications/web_application_info.h" @@ -460,5 +465,18 @@ false /*accept*/, std::move(web_app_info))); } +AppId InstallPwaForCurrentUrl(Browser* browser) { + // Depending on the installability criteria, different dialogs can be used. + chrome::SetAutoAcceptWebAppDialogForTesting(true, true); + chrome::SetAutoAcceptPWAInstallConfirmationForTesting(true); + WebAppTestInstallObserver observer(browser->profile()); + observer.BeginListening(); + CHECK(chrome::ExecuteCommand(browser, IDC_INSTALL_PWA)); + AppId app_id = observer.Wait(); + chrome::SetAutoAcceptPWAInstallConfirmationForTesting(false); + chrome::SetAutoAcceptWebAppDialogForTesting(false, false); + return app_id; +} + } // namespace test } // namespace web_app
diff --git a/chrome/browser/web_applications/test/web_app_test_utils.h b/chrome/browser/web_applications/test/web_app_test_utils.h index 72adee7..5f92fce 100644 --- a/chrome/browser/web_applications/test/web_app_test_utils.h +++ b/chrome/browser/web_applications/test/web_app_test_utils.h
@@ -12,6 +12,7 @@ #include "chrome/browser/web_applications/web_app_install_utils.h" struct WebApplicationInfo; +class Browser; class GURL; namespace content { @@ -40,6 +41,8 @@ ForInstallableSite for_installable_site, WebAppInstallationAcceptanceCallback acceptance_callback); +AppId InstallPwaForCurrentUrl(Browser* browser); + } // namespace test } // namespace web_app
diff --git a/chrome/browser/webshare/BUILD.gn b/chrome/browser/webshare/BUILD.gn index de7ec90..d82c94e 100644 --- a/chrome/browser/webshare/BUILD.gn +++ b/chrome/browser/webshare/BUILD.gn
@@ -9,6 +9,8 @@ sources = [ "prepare_directory_task.cc", "prepare_directory_task.h", + "prepare_subdirectory_task.cc", + "prepare_subdirectory_task.h", "store_file_task.cc", "store_file_task.h", "store_files_task.cc", @@ -22,13 +24,6 @@ "//base", "//third_party/blink/public/common", ] - - if (is_mac) { - sources += [ - "prepare_subdirectory_task.cc", - "prepare_subdirectory_task.h", - ] - } } }
diff --git a/chrome/browser/webshare/chromeos/sharesheet_client.cc b/chrome/browser/webshare/chromeos/sharesheet_client.cc index c453a0d..f6aa8cc 100644 --- a/chrome/browser/webshare/chromeos/sharesheet_client.cc +++ b/chrome/browser/webshare/chromeos/sharesheet_client.cc
@@ -23,8 +23,11 @@ #include "chrome/browser/sharesheet/sharesheet_service_factory.h" #include "chrome/browser/visibility_timer_tab_helper.h" #include "chrome/browser/webshare/prepare_directory_task.h" +#include "chrome/browser/webshare/prepare_subdirectory_task.h" #include "chrome/browser/webshare/share_service_impl.h" #include "chrome/browser/webshare/store_files_task.h" +#include "chrome/common/pref_names.h" +#include "components/prefs/pref_service.h" #include "components/services/app_service/public/cpp/intent_util.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" @@ -39,19 +42,29 @@ constexpr base::FilePath::CharType kWebShareDirname[] = FILE_PATH_LITERAL(".WebShare"); -// We don't use |supplied_name| as it may contain special characters, and it may -// not be unique. The suffix has been checked by +constexpr char kDefaultShareName[] = "share"; + +// Note that the suffix of |suggested_name| has been checked by // ShareServiceImpl::IsDangerousFilename(). -base::FilePath GenerateFileName(const base::FilePath& directory, - const std::string& supplied_name) { +base::FilePath GenerateFileName(content::WebContents* web_contents, + const base::FilePath& directory, + const std::string& suggested_name) { static unsigned counter = 0; ++counter; + std::string dirname = base::StringPrintf("share%u", counter); - size_t suffix_pos = supplied_name.find_last_of('.'); - std::string filename = base::StringPrintf("share%u%s", counter, - supplied_name.c_str() + suffix_pos); - return directory.Append(filename); + Profile* profile = + Profile::FromBrowserContext(web_contents->GetBrowserContext()); + std::string referrer_charset = + profile->GetPrefs()->GetString(prefs::kDefaultCharset); + + base::FilePath filename = net::GenerateFileName( + web_contents->GetLastCommittedURL(), + /*content_disposition=*/std::string(), referrer_charset, suggested_name, + /*mime_type=*/std::string(), kDefaultShareName); + + return directory.Append(dirname).Append(filename); } blink::mojom::ShareError SharesheetResultToShareError( @@ -171,11 +184,30 @@ for (const auto& file : current_share_->files) { current_share_->content_types.push_back(file->blob->content_type); - current_share_->file_paths.push_back( - GenerateFileName(current_share_->directory, file->name)); + current_share_->file_paths.push_back(GenerateFileName( + web_contents(), current_share_->directory, file->name)); current_share_->file_sizes.push_back(file->blob->size); } + current_share_->prepare_subdirectory_task = + std::make_unique<PrepareSubDirectoryTask>( + current_share_->file_paths, + base::BindOnce(&SharesheetClient::OnPrepareSubdirectory, + weak_ptr_factory_.GetWeakPtr())); + current_share_->prepare_subdirectory_task->Start(); +} + +void SharesheetClient::OnPrepareSubdirectory(blink::mojom::ShareError error) { + DCHECK_CURRENTLY_ON(BrowserThread::UI); + if (!current_share_.has_value()) + return; + + if (!web_contents() || error != blink::mojom::ShareError::OK) { + std::move(current_share_->callback).Run(error); + current_share_ = absl::nullopt; + return; + } + std::unique_ptr<StoreFilesTask> store_files_task = std::make_unique<StoreFilesTask>( current_share_->file_paths, std::move(current_share_->files),
diff --git a/chrome/browser/webshare/chromeos/sharesheet_client.h b/chrome/browser/webshare/chromeos/sharesheet_client.h index 718694e..e446e28 100644 --- a/chrome/browser/webshare/chromeos/sharesheet_client.h +++ b/chrome/browser/webshare/chromeos/sharesheet_client.h
@@ -22,6 +22,7 @@ namespace webshare { class PrepareDirectoryTask; +class PrepareSubDirectoryTask; // Chrome-OS implementation of navigator.share() sharing to // sharesheet::SharesheetService. @@ -53,6 +54,8 @@ private: void OnPrepareDirectory(blink::mojom::ShareError); + void OnPrepareSubdirectory(blink::mojom::ShareError); + void OnStoreFiles(blink::mojom::ShareError); void OnShowSharesheet(sharesheet::SharesheetResult result); @@ -88,6 +91,7 @@ blink::mojom::ShareService::ShareCallback callback; std::unique_ptr<PrepareDirectoryTask> prepare_directory_task; + std::unique_ptr<PrepareSubDirectoryTask> prepare_subdirectory_task; }; absl::optional<CurrentShare> current_share_;
diff --git a/chrome/browser/webshare/chromeos/sharesheet_client_browsertest.cc b/chrome/browser/webshare/chromeos/sharesheet_client_browsertest.cc index 6bf4950..a912000c 100644 --- a/chrome/browser/webshare/chromeos/sharesheet_client_browsertest.cc +++ b/chrome/browser/webshare/chromeos/sharesheet_client_browsertest.cc
@@ -123,8 +123,10 @@ const base::FilePath share_cache = file_manager::util::GetShareCacheFilePath(browser()->profile()); - EXPECT_EQ(file_paths[0], share_cache.AppendASCII(".WebShare/share1.mp3")); - EXPECT_EQ(file_paths[1], share_cache.AppendASCII(".WebShare/share2.mp4")); + EXPECT_EQ(file_paths[0], + share_cache.AppendASCII(".WebShare/share1/sam.ple.mp3")); + EXPECT_EQ(file_paths[1], + share_cache.AppendASCII(".WebShare/share2/_sample.mp4")); CheckSize(file_paths[0], /*expected_size=*/345); CheckSize(file_paths[1], /*expected_size=*/67890);
diff --git a/chrome/browser/webshare/chromeos/sharesheet_client_unittest.cc b/chrome/browser/webshare/chromeos/sharesheet_client_unittest.cc index 96b31ac5..c0f511f 100644 --- a/chrome/browser/webshare/chromeos/sharesheet_client_unittest.cc +++ b/chrome/browser/webshare/chromeos/sharesheet_client_unittest.cc
@@ -130,18 +130,20 @@ const base::FilePath share_cache_dir = file_manager::util::GetShareCacheFilePath(profile()); const base::FilePath first_file = - share_cache_dir.AppendASCII(".WebShare/share1.txt"); + share_cache_dir.AppendASCII(".WebShare/share1/first.txt"); const base::FilePath second_file = - share_cache_dir.AppendASCII(".WebShare/share2.txt"); + share_cache_dir.AppendASCII(".WebShare/share2/second.txt"); const std::string title = "Subject"; const std::string text = "Message"; const GURL share_url("https://example.com/"); std::vector<blink::mojom::SharedFilePtr> files; - files.push_back(blink::mojom::SharedFile::New( - first_file.AsUTF8Unsafe(), blink::mojom::SerializedBlob::New())); - files.push_back(blink::mojom::SharedFile::New( - second_file.AsUTF8Unsafe(), blink::mojom::SerializedBlob::New())); + files.push_back( + blink::mojom::SharedFile::New(first_file.BaseName().AsUTF8Unsafe(), + blink::mojom::SerializedBlob::New())); + files.push_back( + blink::mojom::SharedFile::New(second_file.BaseName().AsUTF8Unsafe(), + blink::mojom::SerializedBlob::New())); base::RunLoop run_loop; blink::mojom::ShareError error = blink::mojom::ShareError::INTERNAL_ERROR;
diff --git a/chrome/build/linux.pgo.txt b/chrome/build/linux.pgo.txt index bc99c68..49e94a2 100644 --- a/chrome/build/linux.pgo.txt +++ b/chrome/build/linux.pgo.txt
@@ -1 +1 @@ -chrome-linux-main-1638295043-f8e139d00a9d5e47cb05a7003f7413de56c54844.profdata +chrome-linux-main-1638316670-aa21a8032de4d6ab34fbb02943f83f22371fbce7.profdata
diff --git a/chrome/build/mac.pgo.txt b/chrome/build/mac.pgo.txt index f11c7f9..5198e8e7 100644 --- a/chrome/build/mac.pgo.txt +++ b/chrome/build/mac.pgo.txt
@@ -1 +1 @@ -chrome-mac-main-1638295043-3a2de8ab7e603a57a7375a4eca2c24fd0398a063.profdata +chrome-mac-main-1638316670-cf39dda6b34cfd75050c88da1c2943ff6299d114.profdata
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 86327b9..fe6bd22 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc
@@ -2929,6 +2929,10 @@ "commerce_merchant_viewer_messages_shown_time"; #endif +// Policy that indicates the state of updates for the binary components. +const char kComponentUpdatesEnabled[] = + "component_updates.component_updates_enabled"; + #if defined(OS_ANDROID) // Whether the search geolocation disclosure has been dismissed by the user. const char kSearchGeolocationDisclosureDismissed[] =
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 31ff683..3af268a 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h
@@ -999,6 +999,8 @@ extern const char kCommerceMerchantViewerMessagesShownTime[]; #endif +extern const char kComponentUpdatesEnabled[]; + #if defined(OS_ANDROID) extern const char kSearchGeolocationDisclosureDismissed[]; extern const char kSearchGeolocationDisclosureShownCount[];
diff --git a/chrome/services/speech/speech_recognition_recognizer_impl.cc b/chrome/services/speech/speech_recognition_recognizer_impl.cc index c3e1a42..89cd757 100644 --- a/chrome/services/speech/speech_recognition_recognizer_impl.cc +++ b/chrome/services/speech/speech_recognition_recognizer_impl.cc
@@ -265,7 +265,7 @@ } if (enable_soda_) { - DCHECK(soda_client_); + CHECK(soda_client_); DCHECK(base::PathExists(config_path_)); if (!soda_client_->IsInitialized() || soda_client_->DidAudioPropertyChange(sample_rate_, channel_count_)) { @@ -357,6 +357,7 @@ config.soda_config_size = serialized.size(); config.callback = &OnSodaResponse; config.callback_handle = this; + CHECK(soda_client_); soda_client_->Reset(config, sample_rate_, channel_count_); }
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index e1d4c2e..96d4a3d 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn
@@ -760,6 +760,7 @@ "../browser/browsing_data/chrome_browsing_data_lifetime_manager_browsertest.cc", "../browser/engagement/important_sites_util_browsertest.cc", "../browser/metrics/metrics_service_user_demographics_browsertest.cc", + "../browser/metrics/startup_metrics_browsertest.cc", "../browser/metrics/ukm_browsertest.cc", "../browser/net/cert_verify_proc_browsertest.cc", "../browser/page_load_metrics/observers/ad_metrics/ad_density_intervention_android_browsertest.cc", @@ -7482,6 +7483,13 @@ ] } + if (is_chromeos_ash) { + sources += [ "../browser/enterprise/connectors/device_trust/attestation/ash/ash_attestation_service_unittest.cc" ] + deps += [ + "//chrome/browser/enterprise/connectors/device_trust/attestation/ash", + ] + } + if (enable_plugins) { sources += [ "../browser/metrics/plugin_metrics_provider_unittest.cc", @@ -8296,6 +8304,7 @@ "../browser/password_manager/password_manager_interactive_uitest.cc", "../browser/permissions/permissions_security_model_interactive_uitest.cc", "../browser/portal/portal_interactive_uittest.cc", + "../browser/prerender/prerender_omnibox_ui_browsertest.cc", "../browser/renderer_context_menu/link_to_text_menu_observer_interactive_uitest.cc", "../browser/renderer_context_menu/mock_render_view_context_menu.cc", "../browser/renderer_context_menu/mock_render_view_context_menu.h",
diff --git a/chrome/test/android/browsertests_apk/AndroidManifest.xml.jinja2 b/chrome/test/android/browsertests_apk/AndroidManifest.xml.jinja2 index 62e66e7a..c86224460 100644 --- a/chrome/test/android/browsertests_apk/AndroidManifest.xml.jinja2 +++ b/chrome/test/android/browsertests_apk/AndroidManifest.xml.jinja2
@@ -104,14 +104,7 @@ </intent-filter> </activity> - <receiver android:name="org.chromium.chrome.browser.quickactionsearchwidget.QuickActionSearchWidgetProvider$QuickActionSearchWidgetProviderSmall" - android:exported="true"> - <intent-filter> - <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> - </intent-filter> - </receiver> - - <receiver android:name="org.chromium.chrome.browser.quickactionsearchwidget.QuickActionSearchWidgetProvider$QuickActionSearchWidgetProviderMedium" + <receiver android:name="org.chromium.chrome.browser.quickactionsearchwidget.QuickActionSearchWidgetProvider$QuickActionSearchWidgetProviderSearch" android:exported="true"> <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
diff --git a/chrome/test/base/test_browser_window.cc b/chrome/test/base/test_browser_window.cc index c2f5c76..6c07447 100644 --- a/chrome/test/base/test_browser_window.cc +++ b/chrome/test/base/test_browser_window.cc
@@ -317,7 +317,7 @@ } void TestBrowserWindow::MaybeRestoreSideSearchStatePerWindow( - const std::map<std::string, base::Value>& extra_data) {} + const std::map<std::string, std::string>& extra_data) {} #endif FeaturePromoController* TestBrowserWindow::GetFeaturePromoController() {
diff --git a/chrome/test/base/test_browser_window.h b/chrome/test/base/test_browser_window.h index f8b3bdb..5d37231 100644 --- a/chrome/test/base/test_browser_window.h +++ b/chrome/test/base/test_browser_window.h
@@ -42,12 +42,6 @@ class SharingHubBubbleView; } // namespace sharing_hub -#if BUILDFLAG(ENABLE_SIDE_SEARCH) -namespace base { -class Value; -} -#endif - // An implementation of BrowserWindow used for testing. TestBrowserWindow only // contains a valid LocationBar, all other getters return NULL. // However, some of them can be preset to a specific value. @@ -236,7 +230,7 @@ #if BUILDFLAG(ENABLE_SIDE_SEARCH) bool IsSideSearchPanelVisible() const override; void MaybeRestoreSideSearchStatePerWindow( - const std::map<std::string, base::Value>& extra_data) override; + const std::map<std::string, std::string>& extra_data) override; #endif FeaturePromoController* GetFeaturePromoController() override;
diff --git a/chrome/test/data/banners/isolated/simple.html b/chrome/test/data/banners/isolated/simple.html new file mode 100644 index 0000000..31ae1c8 --- /dev/null +++ b/chrome/test/data/banners/isolated/simple.html
@@ -0,0 +1 @@ +Page with COOP/COEP headers set.
diff --git a/chrome/test/data/banners/isolated/simple.html.mock-http-headers b/chrome/test/data/banners/isolated/simple.html.mock-http-headers new file mode 100644 index 0000000..858d4a51 --- /dev/null +++ b/chrome/test/data/banners/isolated/simple.html.mock-http-headers
@@ -0,0 +1,4 @@ +HTTP/1.1 200 OK +Content-Type: text/html +Cross-Origin-Opener-Policy: same-origin +Cross-Origin-Embedder-Policy: require-corp
diff --git a/chrome/test/data/banners/manifest_isolated.json b/chrome/test/data/banners/manifest_isolated.json new file mode 100644 index 0000000..6fa755b6 --- /dev/null +++ b/chrome/test/data/banners/manifest_isolated.json
@@ -0,0 +1,15 @@ +{ + "name": "Manifest test app", + "scope": "/", + "icons": [ + { + "src": "image-512px.png", + "sizes": "512x512", + "type": "image/png" + } + ], + "start_url": "manifest_test_page.html", + "display": "standalone", + "orientation": "landscape", + "isolated_storage": true +}
diff --git a/chrome/test/data/prefetch/prefetch_proxy/prefetch_page_different_cookie.html b/chrome/test/data/prefetch/prefetch_proxy/prefetch_page_different_cookie.html new file mode 100644 index 0000000..6be9149 --- /dev/null +++ b/chrome/test/data/prefetch/prefetch_proxy/prefetch_page_different_cookie.html
@@ -0,0 +1,13 @@ +<html> +<!-- +Copyright (c) 2021 The Chromium Authors. All rights reserved. +Use of this source code is governed by a BSD-style license that can be +found in the LICENSE file. +--> +<body> + <script src="prefetch.js"></script> + <script src="prefetch-redirect-start.js"></script> + Some content that is necessary for registering paint metrics. + <img src="image.png"> +</body> +</html>
diff --git a/chrome/test/data/prefetch/prefetch_proxy/prefetch_page_different_cookie.html.mock-http-headers b/chrome/test/data/prefetch/prefetch_proxy/prefetch_page_different_cookie.html.mock-http-headers new file mode 100644 index 0000000..af933d2 --- /dev/null +++ b/chrome/test/data/prefetch/prefetch_proxy/prefetch_page_different_cookie.html.mock-http-headers
@@ -0,0 +1,3 @@ +HTTP/1.1 200 OK +Content-Type: text/html +Set-Cookie: other_type=Snickerdoodle
diff --git a/chrome/test/data/webshare/index.html b/chrome/test/data/webshare/index.html index b62a167..bcfd603 100644 --- a/chrome/test/data/webshare/index.html +++ b/chrome/test/data/webshare/index.html
@@ -32,7 +32,7 @@ async function share_multiple_files() { try { - const first_file = create_file('sample.mp3', 'audio/mpeg', 345); + const first_file = create_file('sam.ple.mp3', 'audio/mpeg', 345); const second_file = create_file('../sample.mp4', 'video/mp4', 67890); await navigator.share({files: [first_file, second_file]}); return 'share succeeded';
diff --git a/chrome/test/data/webui/chromeos/shimless_rma/fake_shimless_rma_service_test.js b/chrome/test/data/webui/chromeos/shimless_rma/fake_shimless_rma_service_test.js index e4f4adf..bfb3fda 100644 --- a/chrome/test/data/webui/chromeos/shimless_rma/fake_shimless_rma_service_test.js +++ b/chrome/test/data/webui/chromeos/shimless_rma/fake_shimless_rma_service_test.js
@@ -515,13 +515,28 @@ }); test('SetGetSkuListResultUpdatesResult', () => { - let skuList = ['skuA', 'skuB', 'skuC']; + let skuList = [1, 202, 33]; service.setGetSkuListResult(skuList); return service.getSkuList().then((skus) => { assertDeepEquals(skus.skus, skuList); }); }); + test('GetWhiteLabelListDefaultUndefined', () => { + return service.getWhiteLabelList().then((whiteLabels) => { + assertEquals(whiteLabels, undefined); + }); + }); + + test('SetGetWhiteLabelListResultUpdatesResult', () => { + const whiteLabelList = + ['White-label 10', 'White-label 0', 'White-label 9999']; + service.setGetWhiteLabelListResult(whiteLabelList); + return service.getWhiteLabelList().then((whiteLabels) => { + assertDeepEquals(whiteLabels.whiteLabels, whiteLabelList); + }); + }); + test('GetOriginalSerialNumberDefaultUndefined', () => { return service.getOriginalSerialNumber().then((serialNumber) => { assertEquals(serialNumber, undefined); @@ -564,6 +579,20 @@ }); }); + test('GetOriginalWhiteLabelDefaultUndefined', () => { + return service.getOriginalWhiteLabel().then((whiteLabel) => { + assertEquals(whiteLabel, undefined); + }); + }); + + test('SetGetOriginalRegionResultUpdatesResult', () => { + const expected_whiteLabel = 1; + service.setGetOriginalWhiteLabelResult(expected_whiteLabel); + return service.getOriginalWhiteLabel().then((whiteLabel) => { + assertEquals(whiteLabel.whiteLabelIndex, expected_whiteLabel); + }); + }); + test('SetDeviceInformationOk', () => { let states = [ {state: State.kUpdateDeviceInformation, error: RmadErrorCode.kOk},
diff --git a/chrome/test/data/webui/chromeos/shimless_rma/reimaging_device_information_page_test.js b/chrome/test/data/webui/chromeos/shimless_rma/reimaging_device_information_page_test.js index 78336f4..99fa5ec 100644 --- a/chrome/test/data/webui/chromeos/shimless_rma/reimaging_device_information_page_test.js +++ b/chrome/test/data/webui/chromeos/shimless_rma/reimaging_device_information_page_test.js
@@ -55,7 +55,7 @@ assertFalse(!!component); service.setGetOriginalSerialNumberResult(serialNumber); service.setGetRegionListResult(fakeDeviceRegions); - service.setGetOriginalRegionResult(0); + service.setGetOriginalRegionResult(2); service.setGetSkuListResult(fakeDeviceSkus); service.setGetOriginalSkuResult(1); @@ -69,23 +69,23 @@ test('ReimagingDeviceInformationPageInitializes', async () => { await initializeReimagingDeviceInformationPage(fakeSerialNumber); + // A flush tasks is required to wait for the drop lists to render and set + // the initial selected index. + await flushTasks(); const serialNumberComponent = component.shadowRoot.querySelector('#serialNumber'); - // TODO selectedIndex does not get set correctly - // const regionSelectComponent = - // component.shadowRoot.querySelector('#regionSelect'); - // const skuSelectComponent = - // component.shadowRoot.querySelector('#skuSelect'); + const regionSelectComponent = + component.shadowRoot.querySelector('#regionSelect'); + const skuSelectComponent = component.shadowRoot.querySelector('#skuSelect'); const resetSerialNumberComponent = component.shadowRoot.querySelector('#resetSerialNumber'); const resetRegionComponent = component.shadowRoot.querySelector('#resetRegion'); const resetSkuComponent = component.shadowRoot.querySelector('#resetSku'); - assertEquals(serialNumberComponent.value, fakeSerialNumber); - // TODO selectedIndex does not get set correctly - // assertEquals(regionSelectComponent.selectedIndex, 1); - // assertEquals(skuSelectComponent.selectedIndex, 1); + assertEquals(fakeSerialNumber, serialNumberComponent.value); + assertEquals(2, regionSelectComponent.selectedIndex); + assertEquals(1, skuSelectComponent.selectedIndex); assertTrue(resetSerialNumberComponent.disabled); assertTrue(resetRegionComponent.disabled); assertTrue(resetSkuComponent.disabled);
diff --git a/chrome/updater/app/server/mac/service_delegate.mm b/chrome/updater/app/server/mac/service_delegate.mm index 241b93b..037c6e0 100644 --- a/chrome/updater/app/server/mac/service_delegate.mm +++ b/chrome/updater/app/server/mac/service_delegate.mm
@@ -6,6 +6,9 @@ #import <Foundation/Foundation.h> +#include <utility> +#include <vector> + #include "base/bind.h" #include "base/callback.h" #include "base/command_line.h" @@ -221,6 +224,24 @@ request, std::move(cb))); } +- (void)getAppStatesWithReply:(void (^_Nonnull)(CRUAppStatesWrapper*))reply { + auto cb = base::BindOnce(base::RetainBlock( + ^(const std::vector<updater::UpdateService::AppState>& states) { + if (reply) { + base::scoped_nsobject<CRUAppStatesWrapper> appStatesWrapper( + [[CRUAppStatesWrapper alloc] initWithAppStates:states], + base::scoped_policy::RETAIN); + reply(appStatesWrapper); + } + + _appServer->TaskCompleted(); + })); + + _appServer->TaskStarted(); + _callbackRunner->PostTask( + FROM_HERE, base::BindOnce(&updater::UpdateService::GetAppStates, _service, + std::move(cb))); +} @end @interface CRUUpdateServiceInternalXPCImpl
diff --git a/chrome/updater/app/server/mac/service_protocol.h b/chrome/updater/app/server/mac/service_protocol.h index 85aee5e2..84bebcb 100644 --- a/chrome/updater/app/server/mac/service_protocol.h +++ b/chrome/updater/app/server/mac/service_protocol.h
@@ -14,6 +14,7 @@ @class CRUUpdateStateWrapper; @class CRUPriorityWrapper; @class CRUPolicySameVersionUpdateWrapper; +@class CRUAppStatesWrapper; // Protocol which observes the state of the XPC update checking service. @protocol CRUUpdateStateObserving <NSObject> @@ -56,6 +57,10 @@ existenceCheckerPath:(NSString* _Nullable)existenceCheckerPath reply:(void (^_Nonnull)(int rc))reply; +// Gets states of all registered apps. +- (void)getAppStatesWithReply: + (void (^_Nonnull)(CRUAppStatesWrapper* _Nullable apps))reply; + @end // Protocol for the XPC update service internal tasks of the Updater.
diff --git a/chrome/updater/app/server/mac/update_service_wrappers.h b/chrome/updater/app/server/mac/update_service_wrappers.h index 4a45b8dc..da24b8e 100644 --- a/chrome/updater/app/server/mac/update_service_wrappers.h +++ b/chrome/updater/app/server/mac/update_service_wrappers.h
@@ -7,6 +7,8 @@ #import <Foundation/Foundation.h> +#include <vector> + #include "base/task/sequenced_task_runner.h" #import "chrome/updater/app/server/mac/service_protocol.h" #include "chrome/updater/update_service.h" @@ -89,4 +91,24 @@ @end +@interface CRUAppStateWrapper : NSObject <NSSecureCoding> + +@property(readonly, nonatomic) updater::UpdateService::AppState state; +- (instancetype)initWithAppState: + (const updater::UpdateService::AppState&)appState; +@end + +@interface CRUAppStatesWrapper : NSObject <NSSecureCoding> + +@property(readonly, nonatomic, getter=states) + std::vector<updater::UpdateService::AppState> + states; + +- (instancetype)initWithAppStateWrappers: + (NSArray<CRUAppStateWrapper*>*)appStateWrappers; +- (instancetype)initWithAppStates: + (const std::vector<updater::UpdateService::AppState>&)appStates; + +@end + #endif // CHROME_UPDATER_APP_SERVER_MAC_UPDATE_SERVICE_WRAPPERS_H_
diff --git a/chrome/updater/app/server/mac/update_service_wrappers.mm b/chrome/updater/app/server/mac/update_service_wrappers.mm index 5395616..45ed7e3 100644 --- a/chrome/updater/app/server/mac/update_service_wrappers.mm +++ b/chrome/updater/app/server/mac/update_service_wrappers.mm
@@ -9,6 +9,7 @@ #include "base/bind.h" #include "base/callback.h" #include "base/logging.h" +#include "base/mac/foundation_util.h" #include "base/strings/sys_string_conversions.h" #import "chrome/updater/app/server/mac/service_protocol.h" @@ -29,6 +30,14 @@ static NSString* const kCRUPolicySameVersionUpdate = @"policySameVersionUpdate"; static NSString* const kCRUErrorCategory = @"errorCategory"; +static NSString* const kCRUAppStateWrappers = @"appStateWrappers"; +static NSString* const kCRUAppStateAppId = @"appStateAppId"; +static NSString* const kCRUAppStateVersion = @"appStateVersion"; +static NSString* const kCRUAppStateAp = @"appStateAp"; +static NSString* const kCRUAppStateBrandCode = @"appStateBrandCode"; +static NSString* const kCRUAppStateExistenceChecker = + @"appStateExistenceChecker"; + using StateChangeCallback = base::RepeatingCallback<void(const updater::UpdateService::UpdateState&)>; @@ -468,3 +477,120 @@ } @end + +@implementation CRUAppStateWrapper + +@synthesize state = _state; + +- (instancetype)initWithAppState: + (const updater::UpdateService::AppState&)appState { + if (self = [super init]) { + _state = appState; + } + return self; +} + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (void)encodeWithCoder:(NSCoder*)coder { + DCHECK([coder respondsToSelector:@selector(encodeObject:forKey:)]); + + [coder encodeObject:base::SysUTF8ToNSString(self.state.app_id) + forKey:kCRUAppStateAppId]; + [coder encodeObject:base::SysUTF8ToNSString(self.state.version.GetString()) + forKey:kCRUAppStateVersion]; + [coder encodeObject:base::SysUTF8ToNSString(self.state.ap) + forKey:kCRUAppStateAp]; + [coder encodeObject:base::SysUTF8ToNSString(self.state.brand_code) + forKey:kCRUAppStateBrandCode]; + [coder encodeObject:base::mac::FilePathToNSString(self.state.ecp) + forKey:kCRUAppStateExistenceChecker]; +} + +- (instancetype)initWithCoder:(NSCoder*)aDecoder { + DCHECK([aDecoder allowsKeyedCoding]); + + NSString* appId = [aDecoder decodeObjectOfClass:[NSString class] + forKey:kCRUAppStateAppId]; + NSString* version = [aDecoder decodeObjectOfClass:[NSString class] + forKey:kCRUAppStateVersion]; + + NSString* ap = [aDecoder decodeObjectOfClass:[NSString class] + forKey:kCRUAppStateAp]; + NSString* brandCode = [aDecoder decodeObjectOfClass:[NSString class] + forKey:kCRUAppStateBrandCode]; + NSString* ecp = [aDecoder decodeObjectOfClass:[NSString class] + forKey:kCRUAppStateExistenceChecker]; + + updater::UpdateService::AppState appState; + appState.app_id = base::SysNSStringToUTF8(appId); + appState.version = base::Version(base::SysNSStringToUTF8(version)); + appState.ap = base::SysNSStringToUTF8(ap); + appState.brand_code = base::SysNSStringToUTF8(brandCode); + appState.ecp = base::mac::NSStringToFilePath(ecp); + return [self initWithAppState:appState]; +} + +@end + +@implementation CRUAppStatesWrapper { + NSArray<CRUAppStateWrapper*>* _states; +} + +- (instancetype)initWithAppStateWrappers: + (NSArray<CRUAppStateWrapper*>*)appStates { + if (self = [super init]) { + _states = [appStates copy]; + } + return self; +} + +- (void)dealloc { + [_states release]; + [super dealloc]; +} + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithAppStates: + (const std::vector<updater::UpdateService::AppState>&)appStates { + NSMutableArray<CRUAppStateWrapper*>* stateWrappers = [NSMutableArray array]; + for (const auto& state : appStates) { + [stateWrappers addObject:[[[CRUAppStateWrapper alloc] + initWithAppState:state] autorelease]]; + } + + return [self initWithAppStateWrappers:stateWrappers]; +} + +- (std::vector<updater::UpdateService::AppState>)states { + std::vector<updater::UpdateService::AppState> appStates; + for (CRUAppStateWrapper* wrapper in _states) { + appStates.push_back(wrapper.state); + } + + return appStates; +} + +- (void)encodeWithCoder:(NSCoder*)coder { + DCHECK([coder respondsToSelector:@selector(encodeObject:forKey:)]); + + [coder encodeObject:_states forKey:kCRUAppStateWrappers]; +} + +- (instancetype)initWithCoder:(NSCoder*)aDecoder { + DCHECK([aDecoder allowsKeyedCoding]); + + NSSet* objectClasses = + [NSSet setWithObjects:[NSArray class], [CRUAppStateWrapper class], nil]; + NSArray<CRUAppStateWrapper*>* stateWrappers = + [aDecoder decodeObjectOfClasses:objectClasses + forKey:kCRUAppStateWrappers]; + return [self initWithAppStateWrappers:stateWrappers]; +} + +@end
diff --git a/chrome/updater/configurator.cc b/chrome/updater/configurator.cc index 1a5bc3a9..985c29b 100644 --- a/chrome/updater/configurator.cc +++ b/chrome/updater/configurator.cc
@@ -151,6 +151,10 @@ return false; } +bool Configurator::EnabledComponentUpdates() const { + return false; +} + bool Configurator::EnabledBackgroundDownloader() const { return false; }
diff --git a/chrome/updater/configurator.h b/chrome/updater/configurator.h index 5cf5bf7..219a436 100644 --- a/chrome/updater/configurator.h +++ b/chrome/updater/configurator.h
@@ -62,6 +62,7 @@ scoped_refptr<update_client::UnzipperFactory> GetUnzipperFactory() override; scoped_refptr<update_client::PatcherFactory> GetPatcherFactory() override; bool EnabledDeltas() const override; + bool EnabledComponentUpdates() const override; bool EnabledBackgroundDownloader() const override; bool EnabledCupSigning() const override; PrefService* GetPrefService() const override;
diff --git a/chrome/updater/installer.cc b/chrome/updater/installer.cc index 2c51347..63f199c 100644 --- a/chrome/updater/installer.cc +++ b/chrome/updater/installer.cc
@@ -105,7 +105,7 @@ policy_same_version_update_ == UpdateService::PolicySameVersionUpdate::kAllowed; component.target_version_prefix = target_version_prefix_; - component.updates_enabled = !update_disabled_; + component.supports_group_policy_enable_component_updates = update_disabled_; return component; }
diff --git a/chrome/updater/mac/keystone/ksadmin.mm b/chrome/updater/mac/keystone/ksadmin.mm index df31351..4db820b 100644 --- a/chrome/updater/mac/keystone/ksadmin.mm +++ b/chrome/updater/mac/keystone/ksadmin.mm
@@ -8,6 +8,7 @@ #include <map> #include <string> +#include <utility> #include <vector> #include "base/at_exit.h" @@ -29,7 +30,9 @@ #include "chrome/updater/mac/mac_util.h" #include "chrome/updater/mac/setup/ks_tickets.h" #include "chrome/updater/mac/update_service_proxy.h" +#include "chrome/updater/persisted_data.h" #include "chrome/updater/registration_data.h" +#include "chrome/updater/service_proxy_factory.h" #include "chrome/updater/update_service.h" #include "chrome/updater/updater_scope.h" #include "chrome/updater/updater_version.h" @@ -133,6 +136,7 @@ void PrintUsage(const std::string& error_message); void PrintVersion(); void PrintTickets(); + void PrintKeystoneTickets(); UpdaterScope Scope() const; bool HasSwitch(const std::string& arg) const; @@ -303,9 +307,7 @@ Shutdown(0); } -void KSAdminApp::PrintTickets() { - // TODO(crbug.com/1250524): Print tickets owned by Chromium Updater. If there - // are any, suppress printing any legacy tickets. +void KSAdminApp::PrintKeystoneTickets() { @autoreleasepool { NSDictionary<NSString*, KSTicket*>* store = LoadTicketStore(); if (store.count > 0) { @@ -317,7 +319,28 @@ printf("No tickets\n"); } } - Shutdown(0); +} + +void KSAdminApp::PrintTickets() { + service_proxy_->GetAppStates(base::BindOnce( + [](base::OnceCallback<void()> fallback_cb, + base::OnceCallback<void(int)> done_cb, + const std::vector<updater::UpdateService::AppState>& states) { + for (const auto& state : states) { + KSTicket* ticket = + [[[KSTicket alloc] initWithAppState:state] autorelease]; + printf("%s\n", base::SysNSStringToUTF8([ticket description]).c_str()); + } + + // Fallback to print legacy Keystone tickets if there's no app + // registered with the new updater. + if (states.empty()) { + std::move(fallback_cb).Run(); + } + std::move(done_cb).Run(0); + }, + base::BindOnce(&KSAdminApp::PrintKeystoneTickets, this), + base::BindOnce(&KSAdminApp::Shutdown, this))); } void KSAdminApp::FirstTaskRun() {
diff --git a/chrome/updater/mac/setup/ks_tickets.h b/chrome/updater/mac/setup/ks_tickets.h index c709571..612f2c1d 100644 --- a/chrome/updater/mac/setup/ks_tickets.h +++ b/chrome/updater/mac/setup/ks_tickets.h
@@ -7,6 +7,8 @@ #import <Foundation/Foundation.h> +#include "chrome/updater/update_service.h" + @interface KSPathExistenceChecker : NSObject <NSSecureCoding> @property(nonnull, readonly) NSString* path; @end @@ -37,6 +39,9 @@ - (nullable NSString*)determineBrand; // brand - (nullable NSString*)determineVersion; // version +- (nullable instancetype)initWithAppState: + (const updater::UpdateService::AppState&)state; + @end // KSTicketStore holds a class method for reading an NSDictionary of NSString
diff --git a/chrome/updater/mac/setup/ks_tickets.mm b/chrome/updater/mac/setup/ks_tickets.mm index a308e8f..378cec4 100644 --- a/chrome/updater/mac/setup/ks_tickets.mm +++ b/chrome/updater/mac/setup/ks_tickets.mm
@@ -6,7 +6,9 @@ #import <Foundation/Foundation.h> +#include "base/files/file_path.h" #include "base/logging.h" +#include "base/mac/foundation_util.h" #include "base/notreached.h" #include "base/strings/sys_string_conversions.h" @@ -68,7 +70,7 @@ [super dealloc]; } -- (id)initWithCoder:(NSCoder*)coder { +- (instancetype)initWithCoder:(NSCoder*)coder { if ((self = [super init])) { @try { path_ = [[coder decodeObjectOfClass:[NSString class] @@ -82,6 +84,13 @@ return self; } +- (instancetype)initWithFilePath:(const base::FilePath&)filePath { + if ((self = [super init])) { + path_ = [base::mac::FilePathToNSString(filePath) retain]; + } + return self; +} + - (void)encodeWithCoder:(NSCoder*)coder { NOTREACHED() << "KSPathExistenceChecker::encodeWithCoder not implemented."; } @@ -101,6 +110,7 @@ @implementation KSTicket { NSString* tag_; NSString* version_; + NSString* brandCode_; } @synthesize productID = productID_; @@ -142,7 +152,7 @@ return (NSURL*)serverURL; } -- (id)initWithCoder:(NSCoder*)coder { +- (instancetype)initWithCoder:(NSCoder*)coder { if ((self = [super init])) { @try { productID_ = [[coder decodeObjectOfClass:[NSString class] @@ -187,6 +197,29 @@ return self; } +- (instancetype)initWithAppState: + (const updater::UpdateService::AppState&)state { + if ((self = [super init])) { + productID_ = [base::SysUTF8ToNSString(state.app_id) retain]; + version_ = [base::SysUTF8ToNSString(state.version.GetString()) retain]; + if (!state.ecp.empty()) { + existenceChecker_ = + [[KSPathExistenceChecker alloc] initWithFilePath:state.ecp]; + } + tag_ = [base::SysUTF8ToNSString(state.ap) retain]; + brandCode_ = [base::SysUTF8ToNSString(state.brand_code) retain]; + serverURL_ = [[NSURL + URLWithString:@"https://tools.google.com/service/update2"] retain]; + serverType_ = [@"Omaha" retain]; + ticketVersion_ = 1; + + // TODO(crbug/1250524): Infer tagPath, tagKey, brandPath, brandKey, + // versionPath, versionKey from app's existence checker and populate them + // as additional properties. + } + return self; +} + - (void)dealloc { [productID_ release]; [version_ release]; @@ -197,6 +230,7 @@ [tag_ release]; [tagPath_ release]; [tagKey_ release]; + [brandCode_ release]; [brandPath_ release]; [brandKey_ release]; [versionPath_ release];
diff --git a/chrome/updater/mac/update_service_proxy.h b/chrome/updater/mac/update_service_proxy.h index 5eb0e0a5..14d230d 100644 --- a/chrome/updater/mac/update_service_proxy.h +++ b/chrome/updater/mac/update_service_proxy.h
@@ -8,6 +8,7 @@ #import <Foundation/Foundation.h> #include <string> +#include <vector> #include "base/callback_forward.h" #include "base/mac/scoped_nsobject.h" @@ -41,6 +42,9 @@ void RegisterApp( const RegistrationRequest& request, base::OnceCallback<void(const RegistrationResponse&)> callback) override; + void GetAppStates( + base::OnceCallback<void(const std::vector<UpdateService::AppState>&)>) + const override; void RunPeriodicTasks(base::OnceClosure callback) override; void UpdateAll(StateChangeCallback state_update, Callback callback) override; void Update(const std::string& app_id,
diff --git a/chrome/updater/mac/update_service_proxy.mm b/chrome/updater/mac/update_service_proxy.mm index fff3d81..3ba5bda 100644 --- a/chrome/updater/mac/update_service_proxy.mm +++ b/chrome/updater/mac/update_service_proxy.mm
@@ -111,6 +111,17 @@ reply:reply]; } +- (void)getAppStatesWithReply:(void (^_Nonnull)(CRUAppStatesWrapper*))reply { + auto errorHandler = ^(NSError* xpcError) { + LOG(ERROR) << "XPC connection failed: " + << base::SysNSStringToUTF8([xpcError description]); + reply(nil); + }; + + [[_updateCheckXPCConnection remoteObjectProxyWithErrorHandler:errorHandler] + getAppStatesWithReply:reply]; +} + - (void)runPeriodicTasksWithReply:(void (^)(void))reply { auto errorHandler = ^(NSError* xpcError) { LOG(ERROR) << "XPC connection failed: " @@ -210,6 +221,21 @@ reply:reply]; } +void UpdateServiceProxy::GetAppStates( + base::OnceCallback<void( + const std::vector<updater::UpdateService::AppState>&)> callback) const { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + __block base::OnceCallback<void( + const std::vector<updater::UpdateService::AppState>&)> + block_callback = std::move(callback); + + auto reply = ^(CRUAppStatesWrapper* wrapper) { + callback_runner_->PostTask( + FROM_HERE, base::BindOnce(std::move(block_callback), wrapper.states)); + }; + [client_ getAppStatesWithReply:reply]; +} + void UpdateServiceProxy::RunPeriodicTasks(base::OnceClosure callback) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); __block base::OnceClosure block_callback = std::move(callback);
diff --git a/chrome/updater/update_service.cc b/chrome/updater/update_service.cc index db66dc7..13d1b6b4a 100644 --- a/chrome/updater/update_service.cc +++ b/chrome/updater/update_service.cc
@@ -17,6 +17,15 @@ UpdateState&&) = default; UpdateService::UpdateState::~UpdateState() = default; +UpdateService::AppState::AppState() = default; +UpdateService::AppState::AppState(const AppState&) = default; +UpdateService::AppState& UpdateService::AppState::operator=(const AppState&) = + default; +UpdateService::AppState::AppState(UpdateService::AppState&&) = default; +UpdateService::AppState& UpdateService::AppState::operator=(AppState&&) = + default; +UpdateService::AppState::~AppState() = default; + std::ostream& operator<<(std::ostream& os, const UpdateService::UpdateState& update_state) { auto state_formatter = [update_state]() {
diff --git a/chrome/updater/update_service.h b/chrome/updater/update_service.h index a711cb6f..6fd0620b 100644 --- a/chrome/updater/update_service.h +++ b/chrome/updater/update_service.h
@@ -9,6 +9,8 @@ #include <string> #include "base/callback_forward.h" +#include "base/files/file_path.h" +#include "base/files/file_util.h" #include "base/memory/ref_counted.h" #include "base/version.h" #include "chrome/updater/enum_traits.h" @@ -175,6 +177,21 @@ kForeground = 2, }; + struct AppState { + AppState(); + AppState(const AppState&); + AppState& operator=(const AppState&); + AppState(AppState&&); + AppState& operator=(AppState&&); + ~AppState(); + + std::string app_id; + base::Version version; + std::string ap; + std::string brand_code; + base::FilePath ecp; + }; + using Callback = base::OnceCallback<void(Result)>; using StateChangeCallback = base::RepeatingCallback<void(const UpdateState&)>; using RegisterAppCallback = @@ -190,6 +207,10 @@ virtual void RegisterApp(const RegistrationRequest& request, RegisterAppCallback callback) = 0; + // Gets state of all registered apps. + virtual void GetAppStates( + base::OnceCallback<void(const std::vector<AppState>&)>) const = 0; + // Runs periodic tasks such as checking for uninstallation of registered // applications or doing background updates for registered applications. virtual void RunPeriodicTasks(base::OnceClosure callback) = 0;
diff --git a/chrome/updater/update_service_impl.cc b/chrome/updater/update_service_impl.cc index 1512c47b..f7eaae74 100644 --- a/chrome/updater/update_service_impl.cc +++ b/chrome/updater/update_service_impl.cc
@@ -242,6 +242,26 @@ std::move(callback))); } +void UpdateServiceImpl::GetAppStates( + base::OnceCallback<void(const std::vector<AppState>&)> callback) const { + VLOG(1) << __func__; + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + + std::vector<std::string> app_ids = persisted_data_->GetAppIds(); + std::vector<AppState> apps; + for (const std::string& app_id : app_ids) { + AppState app_state; + app_state.app_id = app_id; + app_state.version = persisted_data_->GetProductVersion(app_id); + app_state.ap = persisted_data_->GetAP(app_id); + app_state.brand_code = persisted_data_->GetBrandCode(app_id); + app_state.ecp = persisted_data_->GetExistenceCheckerPath(app_id); + apps.push_back(app_state); + } + main_task_runner_->PostTask( + FROM_HERE, base::BindOnce(std::move(callback), std::move(apps))); +} + void UpdateServiceImpl::RunPeriodicTasks(base::OnceClosure callback) { VLOG(1) << __func__; DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
diff --git a/chrome/updater/update_service_impl.h b/chrome/updater/update_service_impl.h index 305dfe2..020a5ba 100644 --- a/chrome/updater/update_service_impl.h +++ b/chrome/updater/update_service_impl.h
@@ -41,6 +41,8 @@ void RegisterApp( const RegistrationRequest& request, base::OnceCallback<void(const RegistrationResponse&)> callback) override; + void GetAppStates( + base::OnceCallback<void(const std::vector<AppState>&)>) const override; void RunPeriodicTasks(base::OnceClosure callback) override; void UpdateAll(StateChangeCallback state_update, Callback callback) override; void Update(const std::string& app_id,
diff --git a/chrome/updater/update_service_impl_inactive.cc b/chrome/updater/update_service_impl_inactive.cc index 2fd27ca..6548f8c 100644 --- a/chrome/updater/update_service_impl_inactive.cc +++ b/chrome/updater/update_service_impl_inactive.cc
@@ -6,6 +6,7 @@ #include <string> #include <utility> +#include <vector> #include "base/bind.h" #include "base/callback.h" @@ -37,6 +38,13 @@ base::BindOnce(std::move(callback), RegistrationResponse(-1))); } + void GetAppStates(base::OnceCallback<void(const std::vector<AppState>&)> + callback) const override { + base::SequencedTaskRunnerHandle::Get()->PostTask( + FROM_HERE, + base::BindOnce(std::move(callback), std::vector<AppState>())); + } + void RunPeriodicTasks(base::OnceClosure callback) override { std::move(callback).Run(); }
diff --git a/chrome/updater/win/update_service_proxy.cc b/chrome/updater/win/update_service_proxy.cc index 5a9e80ee..d960157a 100644 --- a/chrome/updater/win/update_service_proxy.cc +++ b/chrome/updater/win/update_service_proxy.cc
@@ -11,6 +11,7 @@ #include <memory> #include <string> #include <utility> +#include <vector> #include "base/bind.h" #include "base/callback.h" @@ -371,6 +372,15 @@ base::BindPostTask(main_task_runner_, std::move(callback)))); } +void UpdateServiceProxy::GetAppStates( + base::OnceCallback<void(const std::vector<AppState>&)> callback) const { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_main_); + com_task_runner_->PostTask( + FROM_HERE, base::BindOnce(&UpdateServiceProxy::GetAppStatesSTA, this, + base::BindPostTask(main_task_runner_, + std::move(callback)))); +} + void UpdateServiceProxy::RunPeriodicTasks(base::OnceClosure callback) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_main_); com_task_runner_->PostTask( @@ -493,6 +503,15 @@ } } +void UpdateServiceProxy::GetAppStatesSTA( + base::OnceCallback<void(const std::vector<AppState>&)> callback) const { + DCHECK(com_task_runner_->BelongsToCurrentThread()); + + // TODO(crbug.com/1094024): implement this feature in the COM server and then + // replace this stub code with the actual call. + std::move(callback).Run(std::vector<AppState>()); +} + void UpdateServiceProxy::RunPeriodicTasksOnSTA(base::OnceClosure callback) { DCHECK(com_task_runner_->BelongsToCurrentThread()); Microsoft::WRL::ComPtr<IUpdater> updater;
diff --git a/chrome/updater/win/update_service_proxy.h b/chrome/updater/win/update_service_proxy.h index 612d5560..652f352 100644 --- a/chrome/updater/win/update_service_proxy.h +++ b/chrome/updater/win/update_service_proxy.h
@@ -6,6 +6,7 @@ #define CHROME_UPDATER_WIN_UPDATE_SERVICE_PROXY_H_ #include <string> +#include <vector> #include "base/callback.h" #include "base/memory/scoped_refptr.h" @@ -45,6 +46,8 @@ base::OnceCallback<void(const base::Version&)> callback) const override; void RegisterApp(const RegistrationRequest& request, RegisterAppCallback callback) override; + void GetAppStates( + base::OnceCallback<void(const std::vector<AppState>&)>) const override; void RunPeriodicTasks(base::OnceClosure callback) override; void UpdateAll(StateChangeCallback state_update, Callback callback) override; void Update(const std::string& app_id, @@ -62,6 +65,8 @@ base::OnceCallback<void(const base::Version&)> callback) const; void RegisterAppOnSTA(const RegistrationRequest& request, RegisterAppCallback callback); + void GetAppStatesSTA( + base::OnceCallback<void(const std::vector<AppState>&)>) const; void RunPeriodicTasksOnSTA(base::OnceClosure callback); void UpdateAllOnSTA(StateChangeCallback state_update, Callback callback); void UpdateOnSTA(const std::string& app_id,
diff --git a/chromecast/base/chromecast_switches.cc b/chromecast/base/chromecast_switches.cc index 04c0e1c..22c69ee 100644 --- a/chromecast/base/chromecast_switches.cc +++ b/chromecast/base/chromecast_switches.cc
@@ -215,6 +215,10 @@ // means that dummy info will be used. const char kSysInfoFilePath[] = "sys-info-file-path"; +// Specifies the directory where system extensions are found. +// Default is "/system/chrome/extensions". +const char kExtensionsDir[] = "cast-extensions-dir"; + } // namespace switches namespace chromecast {
diff --git a/chromecast/base/chromecast_switches.h b/chromecast/base/chromecast_switches.h index 7ccb5a2..76486a7 100644 --- a/chromecast/base/chromecast_switches.h +++ b/chromecast/base/chromecast_switches.h
@@ -102,6 +102,9 @@ extern const char kSysInfoFilePath[]; +// Extension switches. +extern const char kExtensionsDir[]; + } // namespace switches namespace chromecast {
diff --git a/chromecast/browser/BUILD.gn b/chromecast/browser/BUILD.gn index b8b11e0..bb0b580 100644 --- a/chromecast/browser/BUILD.gn +++ b/chromecast/browser/BUILD.gn
@@ -98,6 +98,8 @@ cast_source_set("browser_base") { sources = [ + "accessibility/accessibility_service_impl.cc", + "accessibility/accessibility_service_impl.h", "application_media_info_manager.cc", "application_media_info_manager.h", "audio_socket_broker.cc", @@ -245,6 +247,7 @@ "//chromecast/net:connectivity_checker", "//chromecast/net:socket_util", "//chromecast/service", + "//chromecast/ui:display_settings_public", "//components/cast/message_port:message_port_cast", "//components/cdm/browser", "//components/download/public/common:public", @@ -764,6 +767,7 @@ if (is_android) { generate_jni("jni_headers") { sources = [ + "android/apk/src/org/chromium/chromecast/shell/CastAccessibilityHelper.java", "android/apk/src/org/chromium/chromecast/shell/CastContentWindowAndroid.java", "android/apk/src/org/chromium/chromecast/shell/CastCrashHandler.java", "android/apk/src/org/chromium/chromecast/shell/CastMetricsHelper.java",
diff --git a/chromecast/browser/accessibility/accessibility_service_impl.cc b/chromecast/browser/accessibility/accessibility_service_impl.cc new file mode 100644 index 0000000..b9ee795 --- /dev/null +++ b/chromecast/browser/accessibility/accessibility_service_impl.cc
@@ -0,0 +1,266 @@ +// Copyright 2021 The Chromium 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 "chromecast/browser/accessibility/accessibility_service_impl.h" + +#include <string> +#include <utility> +#include <vector> + +#include "base/check.h" +#include "base/command_line.h" +#include "base/logging.h" +#include "base/notreached.h" +#include "base/task/post_task.h" +#include "base/task/sequenced_task_runner.h" +#include "chromecast/ui/display_settings_manager.h" + +#if defined(OS_ANDROID) +#include <jni.h> +#include "base/android/jni_android.h" +#include "chromecast/browser/jni_headers/CastAccessibilityHelper_jni.h" +#endif // defined(OS_ANDROID) + +#if BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) +#include "chromecast/base/chromecast_switches.h" +#include "chromecast/browser/accessibility/accessibility_manager.h" +#include "chromecast/browser/cast_browser_process.h" +#include "chromecast/browser/cast_web_contents.h" +#include "chromecast/common/extensions_api/accessibility_private.h" +#include "chromecast/common/mojom/accessibility.mojom.h" +#include "chromecast/graphics/cast_window_manager.h" +#include "content/public/browser/browser_task_traits.h" +#include "content/public/browser/browser_thread.h" +#include "content/public/browser/web_contents.h" +#include "extensions/browser/event_router.h" +#include "extensions/browser/extension_file_task_runner.h" + +namespace { +constexpr char kExtensionsDirDefault[] = "/system/chrome/extensions"; +constexpr char kChromeVoxManifestFile[] = "chromevox_manifest.json"; +} // namespace +#endif // BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) + +namespace chromecast { +namespace shell { + +AccessibilityServiceImpl::AccessibilityServiceImpl( + content::BrowserContext* browser_context, + DisplaySettingsManager* display_settings_manager) + : browser_context_(browser_context), +#if BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) + display_settings_manager_(display_settings_manager), + installer_task_runner_(extensions::GetExtensionFileTaskRunner()) +#else + display_settings_manager_(display_settings_manager) +#endif // BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) +{ + DCHECK(browser_context); +} + +AccessibilityServiceImpl::~AccessibilityServiceImpl() { + receivers_.Clear(); +} + +void AccessibilityServiceImpl::SetColorInversion(bool enable) { + if (enable != color_inversion_enabled_) { + NotifyAccessibilitySettingChanged(kColorInversion, enable); + } + + color_inversion_enabled_ = enable; + display_settings_manager_->SetColorInversion(enable); +} + +bool AccessibilityServiceImpl::IsScreenReaderEnabled() { +#if BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) + return (chromevox_extension_ != nullptr); +#elif defined(OS_ANDROID) + JNIEnv* env = base::android::AttachCurrentThread(); + return Java_CastAccessibilityHelper_isScreenReaderEnabled(env); +#else + return false; +#endif // BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) +} + +bool AccessibilityServiceImpl::IsMagnificationGestureEnabled() { +#if BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) + return CastBrowserProcess::GetInstance() + ->accessibility_manager() + ->IsMagnificationGestureEnabled(); +#else + return false; +#endif // BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) +} + +void AccessibilityServiceImpl::NotifyAccessibilitySettingChanged( + AccessibilitySettingType type, + bool new_value) { +#if BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) + std::vector<CastWebContents*>& webviews = + chromecast::CastWebContents::GetAll(); + + // Tell all renderers the setting has changed. + for (chromecast::CastWebContents* webview : webviews) { + mojo::Remote<mojom::CastAccessibilityClient> accessibility_client; + content::RenderFrameHost* render_frame_host = + webview->web_contents()->GetMainFrame(); + + if (!render_frame_host) + continue; + + if (!render_frame_host->IsRenderFrameCreated()) + continue; + + service_manager::InterfaceProvider* interface_provider = + render_frame_host->GetRemoteInterfaces(); + + if (!interface_provider) + continue; + + interface_provider->GetInterface( + accessibility_client.BindNewPipeAndPassReceiver()); + switch (type) { + case kScreenReader: + accessibility_client->ScreenReaderSettingChanged(new_value); + break; + case kColorInversion: + accessibility_client->ColorInversionSettingChanged(new_value); + break; + case kMagnificationGesture: + accessibility_client->MagnificationGestureSettingChanged(new_value); + break; + } + } +#endif // BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) +} + +void AccessibilityServiceImpl::SetScreenReader(bool enable) { +#if BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) + if (enable == chromevox_enabled_) { + LOG(WARNING) << "Screen reader already " + << (enable ? "enabled" : "disabled"); + return; + } + + NotifyAccessibilitySettingChanged(kScreenReader, enable); + + chromevox_enabled_ = enable; + CastBrowserProcess::GetInstance()->accessibility_manager()->SetScreenReader( + enable); + + // Disable extension. + if (!enable) { + // Only disable automation here. Enabling must be deferred until after + // automation is fully enabled by the extension we're about to load. + // Otherwise, the first tree we generate will go nowhere. See + // AutomationManagerAura::Enable() for where that happens. + CastBrowserProcess::GetInstance()->AccessibilityStateChanged(false); + + extensions::CastExtensionSystem* extension_system = + static_cast<extensions::CastExtensionSystem*>( + extensions::ExtensionSystem::Get(browser_context_)); + + extension_system->UnloadExtension( + chromevox_extension_->id(), + extensions::UnloadedExtensionReason::UNINSTALL); + chromevox_extension_ = nullptr; + + CastBrowserProcess::GetInstance()->accessibility_manager()->HideFocusRing(); + + // Disable accessibility mode in all web contents. + auto all_web_contents = chromecast::CastWebContents::GetAll(); + for (CastWebContents* web_contents : all_web_contents) { + web_contents->web_contents()->SetAccessibilityMode(0); + } + + return; + } + + extensions::CastExtensionSystem* extension_system = + static_cast<extensions::CastExtensionSystem*>( + extensions::ExtensionSystem::Get(browser_context_)); + + // Enable extension. + if (!installer_task_runner_->PostTask( + FROM_HERE, + base::BindOnce(&AccessibilityServiceImpl::LoadChromeVoxExtension, + base::Unretained(this), extension_system))) + NOTREACHED(); +#else + LOG(ERROR) << "SetScreenReader is not supported on this platform"; +#endif // BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) +} + +void AccessibilityServiceImpl::SetMagnificationGestureEnabled(bool enable) { +#if BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) + if (magnify_gesture_enabled_ != enable) { + NotifyAccessibilitySettingChanged(kMagnificationGesture, enable); + } + magnify_gesture_enabled_ = enable; + + CastBrowserProcess::GetInstance() + ->accessibility_manager() + ->SetMagnificationGestureEnabled(enable); +#else + LOG(ERROR) + << "SetMagnificationGestureEnabled is not supported on this platform"; +#endif // BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) +} + +void AccessibilityServiceImpl::GetAccessibilitySettings( + mojom::CastAccessibilityService::GetAccessibilitySettingsCallback + callback) { + DVLOG(2) << __func__; + + auto settings = mojom::AccessibilitySettings::New(); + settings->color_inversion_enabled = color_inversion_enabled_; + settings->screen_reader_enabled = IsScreenReaderEnabled(); + settings->magnification_gesture_enabled = IsMagnificationGestureEnabled(); + + std::move(callback).Run(std::move(settings)); +} + +void AccessibilityServiceImpl::AddBinding( + mojom::CastAccessibilityServiceRequest request) { + receivers_.Add(this, std::move(request)); +} + +#if BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) +void AccessibilityServiceImpl::LoadChromeVoxExtension( + extensions::CastExtensionSystem* extension_system) { + std::string ext_dir = + base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( + switches::kExtensionsDir); + if (ext_dir.empty()) { + ext_dir = kExtensionsDirDefault; + } + + chromevox_extension_ = extension_system->LoadExtension( + kChromeVoxManifestFile, base::FilePath(ext_dir)); + + base::PostTask(FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(&AccessibilityServiceImpl::AnnounceChromeVox, + base::Unretained(this))); +} +#endif // BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) + +void AccessibilityServiceImpl::AnnounceChromeVox() { +#if BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) + extensions::EventRouter* event_router = + extensions::EventRouter::Get(browser_context_); + + const std::string& extension_id = extension_misc::kChromeVoxExtensionId; + + std::vector<base::Value> event_args; + std::unique_ptr<extensions::Event> event(new extensions::Event( + extensions::events::ACCESSIBILITY_PRIVATE_ON_INTRODUCE_CHROME_VOX, + extensions::cast::api::accessibility_private::OnIntroduceChromeVox:: + kEventName, + std::move(event_args))); + event_router->DispatchEventWithLazyListener(extension_id, std::move(event)); +#endif // BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) +} + +} // namespace shell +} // namespace chromecast
diff --git a/chromecast/browser/accessibility/accessibility_service_impl.h b/chromecast/browser/accessibility/accessibility_service_impl.h new file mode 100644 index 0000000..5b6cce2 --- /dev/null +++ b/chromecast/browser/accessibility/accessibility_service_impl.h
@@ -0,0 +1,90 @@ +// Copyright 2021 The Chromium 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 CHROMECAST_BROWSER_ACCESSIBILITY_ACCESSIBILITY_SERVICE_IMPL_H_ +#define CHROMECAST_BROWSER_ACCESSIBILITY_ACCESSIBILITY_SERVICE_IMPL_H_ + +#include "chromecast/chromecast_buildflags.h" +#include "chromecast/common/mojom/accessibility.mojom.h" +#include "mojo/public/cpp/bindings/receiver.h" +#include "mojo/public/cpp/bindings/receiver_set.h" +#include "mojo/public/cpp/bindings/remote_set.h" + +#if BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) +#include "chromecast/browser/extensions/cast_extension_system.h" +#include "extensions/common/extension.h" +#endif // BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) + +namespace base { +class SequencedTaskRunner; +} // namespace base + +namespace content { +class BrowserContext; +} // namespace content + +namespace chromecast { + +class CastWindowManager; +class DisplaySettingsManager; + +namespace shell { + +// Browser side mojo service provider for accessibility functions. +// One instance per browser process. +class AccessibilityServiceImpl : public mojom::CastAccessibilityService { + public: + AccessibilityServiceImpl(content::BrowserContext* browser_context, + DisplaySettingsManager* display_settings_manager); + ~AccessibilityServiceImpl() override; + AccessibilityServiceImpl(const AccessibilityServiceImpl&) = delete; + AccessibilityServiceImpl& operator=(const AccessibilityServiceImpl&) = delete; + + // mojom::CastAccessibilityService implementation: + void SetColorInversion(bool enable) override; + void SetScreenReader(bool enable) override; + void SetMagnificationGestureEnabled(bool enable) override; + void GetAccessibilitySettings( + GetAccessibilitySettingsCallback callback) override; + + void AddBinding(mojom::CastAccessibilityServiceRequest request); + + void Stop(); + + private: + enum AccessibilitySettingType { + kScreenReader, + kColorInversion, + kMagnificationGesture, + }; + + void NotifyAccessibilitySettingChanged(AccessibilitySettingType type, + bool new_value); + +#if BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) + void LoadChromeVoxExtension( + extensions::CastExtensionSystem* extension_system); +#endif // BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) + void AnnounceChromeVox(); + bool IsScreenReaderEnabled(); + bool IsMagnificationGestureEnabled(); + + content::BrowserContext* const browser_context_; + DisplaySettingsManager* const display_settings_manager_; + mojo::ReceiverSet<mojom::CastAccessibilityService> receivers_; + +#if BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) + bool chromevox_enabled_ = false; + const extensions::Extension* chromevox_extension_ = nullptr; + const scoped_refptr<base::SequencedTaskRunner> installer_task_runner_; +#endif // BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) + + bool color_inversion_enabled_ = false; + bool magnify_gesture_enabled_ = false; +}; + +} // namespace shell +} // namespace chromecast + +#endif // CHROMECAST_BROWSER_ACCESSIBILITY_ACCESSIBILITY_SERVICE_IMPL_H_
diff --git a/chromecast/browser/android/BUILD.gn b/chromecast/browser/android/BUILD.gn index 08a2f2f..4e5cef87 100644 --- a/chromecast/browser/android/BUILD.gn +++ b/chromecast/browser/android/BUILD.gn
@@ -109,6 +109,7 @@ java_src_dir = "//chromecast/browser/android/apk/src" sources = [ "$java_src_dir/org/chromium/chromecast/shell/AndroidAppLogcatProvider.java", + "$java_src_dir/org/chromium/chromecast/shell/CastAccessibilityHelper.java", "$java_src_dir/org/chromium/chromecast/shell/CastApplication.java", "$java_src_dir/org/chromium/chromecast/shell/CastBrowserHelper.java", "$java_src_dir/org/chromium/chromecast/shell/CastCommandLineHelper.java",
diff --git a/chromecast/browser/android/apk/AndroidManifest.xml.jinja2 b/chromecast/browser/android/apk/AndroidManifest.xml.jinja2 index 642cded..c99215ec 100644 --- a/chromecast/browser/android/apk/AndroidManifest.xml.jinja2 +++ b/chromecast/browser/android/apk/AndroidManifest.xml.jinja2
@@ -22,6 +22,7 @@ android:launchMode="standard" android:screenOrientation="landscape" android:taskAffinity=".CastWebContentsActivity" + android:supportsPictureInPicture="true" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection" android:excludeFromRecents="false" android:noHistory="false">
diff --git a/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastAccessibilityHelper.java b/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastAccessibilityHelper.java new file mode 100644 index 0000000..bcdf5c2 --- /dev/null +++ b/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastAccessibilityHelper.java
@@ -0,0 +1,45 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.chromecast.shell; + +import android.accessibilityservice.AccessibilityServiceInfo; +import android.content.Context; +import android.view.accessibility.AccessibilityManager; + +import org.chromium.base.ContextUtils; +import org.chromium.base.annotations.CalledByNative; +import org.chromium.base.annotations.JNINamespace; + +import java.util.List; + +@JNINamespace("chromecast") +public final class CastAccessibilityHelper { + /** + * Copied from //chrome/android/java/src/org/chromium/chrome/browser/util/AccessibilityUtil.java + * Checks to see that this device has accessibility and touch exploration enabled. + * @return Whether or not accessibility and touch exploration are enabled. + */ + @CalledByNative + private static boolean isScreenReaderEnabled() { + AccessibilityManager manager = + (AccessibilityManager) ContextUtils.getApplicationContext().getSystemService( + Context.ACCESSIBILITY_SERVICE); + + if (manager == null) return false; + if (!manager.isEnabled()) return false; + if (manager.isTouchExplorationEnabled()) return true; + + List<AccessibilityServiceInfo> services = manager.getEnabledAccessibilityServiceList( + AccessibilityServiceInfo.FEEDBACK_ALL_MASK); + for (AccessibilityServiceInfo service : services) { + if ((service.getCapabilities() + & AccessibilityServiceInfo.CAPABILITY_CAN_PERFORM_GESTURES) + != 0) { + return true; + } + } + return false; + } +}
diff --git a/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastWebContentsActivity.java b/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastWebContentsActivity.java index 5617badb..159b1b8 100644 --- a/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastWebContentsActivity.java +++ b/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastWebContentsActivity.java
@@ -4,10 +4,13 @@ package org.chromium.chromecast.shell; +import android.annotation.TargetApi; import android.app.Activity; +import android.app.PictureInPictureParams; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.content.pm.PackageManager; import android.graphics.Color; import android.media.AudioManager; import android.net.Uri; @@ -182,6 +185,7 @@ })); } + @TargetApi(Build.VERSION_CODES.S) @Override protected void onCreate(final Bundle savedInstanceState) { if (DEBUG) Log.d(TAG, "onCreate"); @@ -193,6 +197,11 @@ // For more information read: // http://developer.android.com/training/managing-audio/volume-playback.html setVolumeControlStream(AudioManager.STREAM_MUSIC); + + if (canAutoEnterPictureInPicture()) { + setPictureInPictureParams( + new PictureInPictureParams.Builder().setAutoEnterEnabled(true).build()); + } } @Override @@ -264,6 +273,14 @@ } } + @TargetApi(Build.VERSION_CODES.O) + @Override + public void onUserLeaveHint() { + if (canUsePictureInPicture() && !canAutoEnterPictureInPicture()) { + enterPictureInPictureMode(new PictureInPictureParams.Builder().build()); + } + } + @Override public boolean dispatchTouchEvent(MotionEvent ev) { if (mSurfaceHelper != null && mSurfaceHelper.isTouchInputEnabled()) { @@ -284,6 +301,16 @@ } } + private boolean canUsePictureInPicture() { + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O + && getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE); + } + + private boolean canAutoEnterPictureInPicture() { + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.S + && getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE); + } + public void finishForTesting() { mIsFinishingState.set("Finish for testing"); }
diff --git a/chromecast/browser/android/junit/src/org/chromium/chromecast/shell/CastWebContentsActivityTest.java b/chromecast/browser/android/junit/src/org/chromium/chromecast/shell/CastWebContentsActivityTest.java index 64468e4..5561e3d 100644 --- a/chromecast/browser/android/junit/src/org/chromium/chromecast/shell/CastWebContentsActivityTest.java +++ b/chromecast/browser/android/junit/src/org/chromium/chromecast/shell/CastWebContentsActivityTest.java
@@ -231,6 +231,9 @@ .getFlag(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)); } + // TODO(guohuideng): Add unit test for PiP when the Robolectric in internal codebase is + // ready. + @Test public void testStopDoesNotCauseFinish() { mActivityLifecycle.create().start().resume();
diff --git a/chromecast/browser/cast_web_contents.h b/chromecast/browser/cast_web_contents.h index ae5da8f..b22aa6a 100644 --- a/chromecast/browser/cast_web_contents.h +++ b/chromecast/browser/cast_web_contents.h
@@ -126,6 +126,12 @@ virtual void MainFrameReadyToCommitNavigation( content::NavigationHandle* navigation_handle) {} + // Notify that an inner WebContents was created. |inner_contents| is created + // in a default-initialized state with no delegate, and can be safely + // initialized by the delegate. + virtual void InnerContentsCreated(CastWebContents* inner_contents, + CastWebContents* outer_contents) {} + // Sets |cast_web_contents_| to |nullptr| but does not remove the Observer // from the ObserverList. Called for each Observer during CastWebContents // destruction; we don't use Observe(nullptr) since it would mutate the
diff --git a/chromecast/browser/cast_web_contents_impl.cc b/chromecast/browser/cast_web_contents_impl.cc index 3f50e371..39becc3 100644 --- a/chromecast/browser/cast_web_contents_impl.cc +++ b/chromecast/browser/cast_web_contents_impl.cc
@@ -901,12 +901,19 @@ params->background_color = params_->background_color; auto result = inner_contents_.insert(std::make_unique<CastWebContentsImpl>( inner_web_contents, std::move(params))); + + // Notifies remote observers. for (auto& observer : observers_) { mojo::PendingRemote<mojom::CastWebContents> pending_remote; result.first->get()->BindSharedReceiver( pending_remote.InitWithNewPipeAndPassReceiver()); observer->InnerContentsCreated(std::move(pending_remote)); } + + // Notifies the local observers. + for (Observer& observer : sync_observers_) { + observer.InnerContentsCreated(result.first->get(), this); + } } void CastWebContentsImpl::TitleWasSet(content::NavigationEntry* entry) {
diff --git a/chromecast/cast_core/BUILD.gn b/chromecast/cast_core/BUILD.gn index 513c10c39..41f3e23f 100644 --- a/chromecast/cast_core/BUILD.gn +++ b/chromecast/cast_core/BUILD.gn
@@ -215,6 +215,7 @@ ":streaming_receiver_session_client", ":url_rewrite", "//chromecast/browser:browser_base", + "//chromecast/cast_core/url_rewrite", "//components/cast/message_port", "//components/cast_streaming/browser", "//components/cast_streaming/public", @@ -423,6 +424,7 @@ "//chromecast/browser:simple_client", "//chromecast/browser:simple_main_parts", "//chromecast/browser:test_support", + "//chromecast/cast_core/url_rewrite:unit_tests", "//chromecast/shared:platform_info_serializer", "//components/cast_streaming/browser", "//components/cast_streaming/public/mojom",
diff --git a/chromecast/cast_core/url_rewrite/BUILD.gn b/chromecast/cast_core/url_rewrite/BUILD.gn new file mode 100644 index 0000000..c06ce6e9 --- /dev/null +++ b/chromecast/cast_core/url_rewrite/BUILD.gn
@@ -0,0 +1,38 @@ +# Copyright 2021 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//chromecast/chromecast.gni") + +cast_source_set("url_rewrite") { + sources = [ + "url_request_rewrite_type_converters.cc", + "url_request_rewrite_type_converters.h", + ] + + public_deps = [ + "//base", + "//components/url_rewrite/mojom", + "//content/public/browser", + "//mojo/public/cpp/bindings", + "//third_party/cast_core/public/src/proto/v2:url_rewrite_proto", + ] +} + +cast_source_set("unit_tests") { + testonly = true + + sources = [ "url_request_rewrite_type_converters_unittest.cc" ] + + deps = [ + ":url_rewrite", + "//base", + "//base/test:test_support", + "//components/url_rewrite/browser", + "//components/url_rewrite/mojom", + "//mojo/core/test:run_all_unittests", + "//testing/gmock", + "//testing/gtest", + "//third_party/cast_core/public/src/proto/v2:url_rewrite_proto", + ] +}
diff --git a/chromecast/cast_core/url_rewrite/DEPS b/chromecast/cast_core/url_rewrite/DEPS new file mode 100644 index 0000000..108597cd --- /dev/null +++ b/chromecast/cast_core/url_rewrite/DEPS
@@ -0,0 +1,6 @@ +include_rules = [ + "+components/url_rewrite/browser", + "+components/url_rewrite/mojom", + "+mojo/public", + "+third_party/cast_core", +]
diff --git a/chromecast/cast_core/url_rewrite/OWNERS b/chromecast/cast_core/url_rewrite/OWNERS new file mode 100644 index 0000000..a166098 --- /dev/null +++ b/chromecast/cast_core/url_rewrite/OWNERS
@@ -0,0 +1,2 @@ +per-file *_type_converter*.*=set noparent +per-file *_type_converter*.*=file://ipc/SECURITY_OWNERS
diff --git a/chromecast/cast_core/url_rewrite/url_request_rewrite_type_converters.cc b/chromecast/cast_core/url_rewrite/url_request_rewrite_type_converters.cc new file mode 100644 index 0000000..af11f5b --- /dev/null +++ b/chromecast/cast_core/url_rewrite/url_request_rewrite_type_converters.cc
@@ -0,0 +1,232 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chromecast/cast_core/url_rewrite/url_request_rewrite_type_converters.h" + +#include "base/strings/strcat.h" +#include "base/strings/string_piece.h" +#include "base/strings/string_util.h" + +namespace { + +std::string NormalizeHost(base::StringPiece host) { + return GURL(base::StrCat({url::kHttpScheme, "://", host})).host(); +} + +} // namespace + +namespace mojo { + +template <> +struct TypeConverter<url_rewrite::mojom::UrlRequestRewriteAddHeadersPtr, + cast::v2::UrlRequestRewriteAddHeaders> { + static url_rewrite::mojom::UrlRequestRewriteAddHeadersPtr Convert( + const cast::v2::UrlRequestRewriteAddHeaders& input) { + url_rewrite::mojom::UrlRequestRewriteAddHeadersPtr add_headers = + url_rewrite::mojom::UrlRequestRewriteAddHeaders::New(); + for (const auto& header : input.headers()) { + url_rewrite::mojom::UrlHeaderPtr url_header = + url_rewrite::mojom::UrlHeader::New(header.name(), header.value()); + add_headers->headers.push_back(std::move(url_header)); + } + return add_headers; + } +}; + +template <> +struct TypeConverter<url_rewrite::mojom::UrlRequestRewriteRemoveHeaderPtr, + cast::v2::UrlRequestRewriteRemoveHeader> { + static url_rewrite::mojom::UrlRequestRewriteRemoveHeaderPtr Convert( + const cast::v2::UrlRequestRewriteRemoveHeader& input) { + url_rewrite::mojom::UrlRequestRewriteRemoveHeaderPtr remove_header = + url_rewrite::mojom::UrlRequestRewriteRemoveHeader::New(); + if (!input.query_pattern().empty()) + remove_header->query_pattern = absl::make_optional(input.query_pattern()); + if (!input.header_name().empty()) + remove_header->header_name = input.header_name(); + return remove_header; + } +}; + +template <> +struct TypeConverter< + url_rewrite::mojom::UrlRequestRewriteSubstituteQueryPatternPtr, + cast::v2::UrlRequestRewriteSubstituteQueryPattern> { + static url_rewrite::mojom::UrlRequestRewriteSubstituteQueryPatternPtr Convert( + const cast::v2::UrlRequestRewriteSubstituteQueryPattern& input) { + url_rewrite::mojom::UrlRequestRewriteSubstituteQueryPatternPtr + substitute_query_pattern = + url_rewrite::mojom::UrlRequestRewriteSubstituteQueryPattern::New(); + if (!input.pattern().empty()) + substitute_query_pattern->pattern = input.pattern(); + if (!input.substitution().empty()) + substitute_query_pattern->substitution = input.substitution(); + return substitute_query_pattern; + } +}; + +template <> +struct TypeConverter<url_rewrite::mojom::UrlRequestRewriteReplaceUrlPtr, + cast::v2::UrlRequestRewriteReplaceUrl> { + static url_rewrite::mojom::UrlRequestRewriteReplaceUrlPtr Convert( + const cast::v2::UrlRequestRewriteReplaceUrl& input) { + url_rewrite::mojom::UrlRequestRewriteReplaceUrlPtr replace_url = + url_rewrite::mojom::UrlRequestRewriteReplaceUrl::New(); + if (!input.url_ends_with().empty()) + replace_url->url_ends_with = input.url_ends_with(); + if (!input.new_url().empty()) + replace_url->new_url = GURL(input.new_url()); + return replace_url; + } +}; + +template <> +struct TypeConverter<url_rewrite::mojom::UrlRequestRewriteAppendToQueryPtr, + cast::v2::UrlRequestRewriteAppendToQuery> { + static url_rewrite::mojom::UrlRequestRewriteAppendToQueryPtr Convert( + const cast::v2::UrlRequestRewriteAppendToQuery& input) { + url_rewrite::mojom::UrlRequestRewriteAppendToQueryPtr append_to_query = + url_rewrite::mojom::UrlRequestRewriteAppendToQuery::New(); + if (!input.query().empty()) + append_to_query->query = input.query(); + return append_to_query; + } +}; + +// Returns nullptr if conversion is not possible. +template <> +struct TypeConverter<url_rewrite::mojom::UrlRequestActionPtr, + cast::v2::UrlRequestRewriteRule::UrlRequestAction> { + static url_rewrite::mojom::UrlRequestActionPtr Convert( + const cast::v2::UrlRequestRewriteRule::UrlRequestAction& input) { + // The converter should never get called if policy action is unspecified. + DCHECK(input != cast::v2::UrlRequestRewriteRule::ACTION_UNSPECIFIED); + switch (input) { + case cast::v2::UrlRequestRewriteRule::ALLOW: + return url_rewrite::mojom::UrlRequestAction::NewPolicy( + mojo::ConvertTo<url_rewrite::mojom::UrlRequestAccessPolicy>( + url_rewrite::mojom::UrlRequestAccessPolicy::kAllow)); + case cast::v2::UrlRequestRewriteRule::DENY: + return url_rewrite::mojom::UrlRequestAction::NewPolicy( + mojo::ConvertTo<url_rewrite::mojom::UrlRequestAccessPolicy>( + url_rewrite::mojom::UrlRequestAccessPolicy::kDeny)); + default: + // Cannot convert the gRPC policy action to a mojo counterpart. + return nullptr; + } + } +}; + +// Returns nullptr if conversion is not possible. +template <> +struct TypeConverter<url_rewrite::mojom::UrlRequestActionPtr, + cast::v2::UrlRequestRewrite> { + static url_rewrite::mojom::UrlRequestActionPtr Convert( + const cast::v2::UrlRequestRewrite& input) { + switch (input.action_case()) { + case cast::v2::UrlRequestRewrite::kAddHeaders: + return url_rewrite::mojom::UrlRequestAction::NewAddHeaders( + mojo::ConvertTo<url_rewrite::mojom::UrlRequestRewriteAddHeadersPtr>( + input.add_headers())); + case cast::v2::UrlRequestRewrite::kRemoveHeader: + return url_rewrite::mojom::UrlRequestAction::NewRemoveHeader( + mojo::ConvertTo< + url_rewrite::mojom::UrlRequestRewriteRemoveHeaderPtr>( + input.remove_header())); + case cast::v2::UrlRequestRewrite::kSubstituteQueryPattern: + return url_rewrite::mojom::UrlRequestAction::NewSubstituteQueryPattern( + mojo::ConvertTo< + url_rewrite::mojom::UrlRequestRewriteSubstituteQueryPatternPtr>( + input.substitute_query_pattern())); + case cast::v2::UrlRequestRewrite::kReplaceUrl: + return url_rewrite::mojom::UrlRequestAction::NewReplaceUrl( + mojo::ConvertTo<url_rewrite::mojom::UrlRequestRewriteReplaceUrlPtr>( + input.replace_url())); + case cast::v2::UrlRequestRewrite::kAppendToQuery: + return url_rewrite::mojom::UrlRequestAction::NewAppendToQuery( + mojo::ConvertTo< + url_rewrite::mojom::UrlRequestRewriteAppendToQueryPtr>( + input.append_to_query())); + case cast::v2::UrlRequestRewrite::ACTION_NOT_SET: + // Cannot convert the gRPC rewrite rule to a mojo counterpart. + return nullptr; + } + } +}; + +// Returns nullptr if conversion is not possible. +template <> +struct TypeConverter<url_rewrite::mojom::UrlRequestRulePtr, + cast::v2::UrlRequestRewriteRule> { + static url_rewrite::mojom::UrlRequestRulePtr Convert( + const cast::v2::UrlRequestRewriteRule& input) { + url_rewrite::mojom::UrlRequestRulePtr rule = + url_rewrite::mojom::UrlRequestRule::New(); + + if (!input.host_filters().empty()) { + // Convert host names in case they contain non-ASCII characters. + const base::StringPiece kWildcard("*."); + + std::vector<std::string> hosts; + for (base::StringPiece host : input.host_filters()) { + if (base::StartsWith(host, kWildcard, base::CompareCase::SENSITIVE)) { + hosts.push_back( + base::StrCat({kWildcard, NormalizeHost(host.substr(2))})); + } else { + hosts.push_back(NormalizeHost(host)); + } + } + rule->hosts_filter = std::move(hosts); + } + + if (!input.scheme_filters().empty()) + rule->schemes_filter.emplace(input.scheme_filters().begin(), + input.scheme_filters().end()); + + // Convert the rewrite rules. + for (const cast::v2::UrlRequestRewrite& grpc_rewrite : input.rewrites()) { + auto action = mojo::ConvertTo<url_rewrite::mojom::UrlRequestActionPtr>( + grpc_rewrite); + if (!action) { + // Conversion to Mojo failed. + return nullptr; + } + rule->actions.push_back(std::move(action)); + } + + // Convert the action policy. + if (input.action() != cast::v2::UrlRequestRewriteRule::ACTION_UNSPECIFIED) { + // Convert the action policy. + auto policy = mojo::ConvertTo<url_rewrite::mojom::UrlRequestActionPtr>( + input.action()); + if (!policy) { + // Conversion to Mojo failed. + return nullptr; + } + rule->actions.push_back(std::move(policy)); + } + + return rule; + } +}; + +url_rewrite::mojom::UrlRequestRewriteRulesPtr +TypeConverter<url_rewrite::mojom::UrlRequestRewriteRulesPtr, + cast::v2::UrlRequestRewriteRules>:: + Convert(const cast::v2::UrlRequestRewriteRules& input) { + url_rewrite::mojom::UrlRequestRewriteRulesPtr rules = + url_rewrite::mojom::UrlRequestRewriteRules::New(); + for (const auto& rule : input.rules()) { + auto mojo_rule = + mojo::ConvertTo<url_rewrite::mojom::UrlRequestRulePtr>(rule); + if (!mojo_rule) { + // Conversion to Mojo failed. + return nullptr; + } + rules->rules.push_back(std::move(mojo_rule)); + } + return rules; +} + +} // namespace mojo
diff --git a/chromecast/cast_core/url_rewrite/url_request_rewrite_type_converters.h b/chromecast/cast_core/url_rewrite/url_request_rewrite_type_converters.h new file mode 100644 index 0000000..25c939e --- /dev/null +++ b/chromecast/cast_core/url_rewrite/url_request_rewrite_type_converters.h
@@ -0,0 +1,33 @@ +// Copyright 2021 The Chromium 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 CHROMECAST_CAST_CORE_URL_REWRITE_URL_REQUEST_REWRITE_TYPE_CONVERTERS_H_ +#define CHROMECAST_CAST_CORE_URL_REWRITE_URL_REQUEST_REWRITE_TYPE_CONVERTERS_H_ + +#include "components/url_rewrite/mojom/url_request_rewrite.mojom.h" +#include "mojo/public/cpp/bindings/type_converter.h" +#include "third_party/cast_core/public/src/proto/v2/url_rewrite.pb.h" + +namespace mojo { + +// This conversion is done with a TypeCoverter rather than a typemap because +// it is only done one way, from the gRPC type to the Mojo type. This conversion +// is only done once, in the browser process. These rules are validated after +// they have been converted into Mojo. +// In Core Runtime, we have a one-way flow from the untrusted embedder into the +// browser process, via a gRPC API. From there, the rules are converted into +// Mojo and then validated before being sent to renderer processes. No further +// conversion is performed, the Mojo types are used as is to apply the rewrites +// on URL requests. +// Converter returns |nullptr| if conversion is not possible. +template <> +struct TypeConverter<url_rewrite::mojom::UrlRequestRewriteRulesPtr, + cast::v2::UrlRequestRewriteRules> { + static url_rewrite::mojom::UrlRequestRewriteRulesPtr Convert( + const cast::v2::UrlRequestRewriteRules& input); +}; + +} // namespace mojo + +#endif // CHROMECAST_CAST_CORE_URL_REWRITE_URL_REQUEST_REWRITE_TYPE_CONVERTERS_H_
diff --git a/chromecast/cast_core/url_rewrite/url_request_rewrite_type_converters_unittest.cc b/chromecast/cast_core/url_rewrite/url_request_rewrite_type_converters_unittest.cc new file mode 100644 index 0000000..d73a907 --- /dev/null +++ b/chromecast/cast_core/url_rewrite/url_request_rewrite_type_converters_unittest.cc
@@ -0,0 +1,278 @@ +// Copyright 2021 The Chromium 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 "chromecast/cast_core/url_rewrite/url_request_rewrite_type_converters.h" + +#include "base/run_loop.h" +#include "base/strings/string_piece.h" +#include "components/url_rewrite/browser/url_request_rewrite_rules_validation.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" +#include "third_party/cast_core/public/src/proto/v2/url_rewrite.pb.h" + +namespace chromecast { +namespace { + +using ::testing::SizeIs; + +cast::v2::UrlRequestRewrite CreateRewriteAddHeaders(std::string header_name, + std::string header_value) { + cast::v2::UrlRequestRewrite rewrite; + cast::v2::UrlHeader* url_header = + rewrite.mutable_add_headers()->mutable_headers()->Add(); + url_header->set_name(std::move(header_name)); + url_header->set_value(std::move(header_value)); + return rewrite; +} + +cast::v2::UrlRequestRewrite CreateRewriteRemoveHeader( + absl::optional<std::string> query_pattern, + std::string header_name) { + cast::v2::UrlRequestRewrite rewrite; + auto* remove_header = rewrite.mutable_remove_header(); + if (query_pattern) + remove_header->set_query_pattern(std::move(query_pattern).value()); + remove_header->set_header_name(std::move(header_name)); + return rewrite; +} + +cast::v2::UrlRequestRewrite CreateRewriteSubstituteQueryPattern( + std::string pattern, + std::string substitution) { + cast::v2::UrlRequestRewrite rewrite; + auto* substitute_query_pattern = rewrite.mutable_substitute_query_pattern(); + substitute_query_pattern->set_pattern(std::move(pattern)); + substitute_query_pattern->set_substitution(std::move(substitution)); + return rewrite; +} + +cast::v2::UrlRequestRewrite CreateRewriteReplaceUrl(std::string url_ends_with, + std::string new_url) { + cast::v2::UrlRequestRewrite rewrite; + auto* replace_url = rewrite.mutable_replace_url(); + replace_url->set_url_ends_with(std::move(url_ends_with)); + replace_url->set_new_url(std::move(new_url)); + return rewrite; +} + +cast::v2::UrlRequestRewrite CreateRewriteAppendToQuery(std::string query) { + cast::v2::UrlRequestRewrite rewrite; + auto* append_to_query = rewrite.mutable_append_to_query(); + append_to_query->set_query(std::move(query)); + return rewrite; +} + +class UrlRequestRewriteTypeConvertersTest : public testing::Test { + public: + UrlRequestRewriteTypeConvertersTest() = default; + + UrlRequestRewriteTypeConvertersTest( + const UrlRequestRewriteTypeConvertersTest&) = delete; + UrlRequestRewriteTypeConvertersTest& operator=( + const UrlRequestRewriteTypeConvertersTest&) = delete; + + ~UrlRequestRewriteTypeConvertersTest() override = default; + + protected: + bool UpdateRulesFromRewrite(cast::v2::UrlRequestRewrite rewrite) { + cast::v2::UrlRequestRewriteRules rules; + rules.mutable_rules()->Add()->mutable_rewrites()->Add(std::move(rewrite)); + cached_rules_ = + mojo::ConvertTo<url_rewrite::mojom::UrlRequestRewriteRulesPtr>( + std::move(rules)); + return url_rewrite::ValidateRules(cached_rules_.get()); + } + + url_rewrite::mojom::UrlRequestRewriteRulesPtr cached_rules_; +}; + +// Tests AddHeaders rewrites are properly converted to their Mojo equivalent. +TEST_F(UrlRequestRewriteTypeConvertersTest, ConvertAddHeader) { + EXPECT_TRUE(UpdateRulesFromRewrite(CreateRewriteAddHeaders("Test", "Value"))); + ASSERT_THAT(cached_rules_->rules, SizeIs(1)); + ASSERT_FALSE(cached_rules_->rules[0]->hosts_filter); + ASSERT_FALSE(cached_rules_->rules[0]->schemes_filter); + ASSERT_THAT(cached_rules_->rules[0]->actions, SizeIs(1)); + ASSERT_TRUE(cached_rules_->rules[0]->actions[0]->is_add_headers()); + + const std::vector<url_rewrite::mojom::UrlHeaderPtr>& headers = + cached_rules_->rules[0]->actions[0]->get_add_headers()->headers; + ASSERT_THAT(headers, SizeIs(1)); + ASSERT_EQ(headers[0]->name, "Test"); + ASSERT_EQ(headers[0]->value, "Value"); +} + +// Tests RemoveHeader rewrites are properly converted to their Mojo equivalent. +TEST_F(UrlRequestRewriteTypeConvertersTest, ConvertRemoveHeader) { + EXPECT_TRUE(UpdateRulesFromRewrite( + CreateRewriteRemoveHeader(absl::make_optional("Test"), "Header"))); + ASSERT_THAT(cached_rules_->rules, SizeIs(1)); + ASSERT_FALSE(cached_rules_->rules[0]->hosts_filter); + ASSERT_FALSE(cached_rules_->rules[0]->schemes_filter); + ASSERT_THAT(cached_rules_->rules[0]->actions, SizeIs(1)); + ASSERT_TRUE(cached_rules_->rules[0]->actions[0]->is_remove_header()); + + const url_rewrite::mojom::UrlRequestRewriteRemoveHeaderPtr& remove_header1 = + cached_rules_->rules[0]->actions[0]->get_remove_header(); + ASSERT_TRUE(remove_header1->query_pattern); + ASSERT_EQ(remove_header1->query_pattern.value().compare("Test"), 0); + ASSERT_EQ(remove_header1->header_name.compare("Header"), 0); + + // Create a RemoveHeader rewrite with no pattern. + EXPECT_TRUE(UpdateRulesFromRewrite( + CreateRewriteRemoveHeader(absl::nullopt, "Header"))); + ASSERT_THAT(cached_rules_->rules, SizeIs(1)); + ASSERT_FALSE(cached_rules_->rules[0]->hosts_filter); + ASSERT_FALSE(cached_rules_->rules[0]->schemes_filter); + ASSERT_THAT(cached_rules_->rules[0]->actions, SizeIs(1)); + ASSERT_TRUE(cached_rules_->rules[0]->actions[0]->is_remove_header()); + + const url_rewrite::mojom::UrlRequestRewriteRemoveHeaderPtr& remove_header2 = + cached_rules_->rules[0]->actions[0]->get_remove_header(); + ASSERT_FALSE(remove_header2->query_pattern); + ASSERT_EQ(remove_header2->header_name.compare("Header"), 0); +} + +// Tests SubstituteQueryPattern rewrites are properly converted to their Mojo +// equivalent. +TEST_F(UrlRequestRewriteTypeConvertersTest, ConvertSubstituteQueryPattern) { + EXPECT_TRUE(UpdateRulesFromRewrite( + CreateRewriteSubstituteQueryPattern("Pattern", "Substitution"))); + ASSERT_THAT(cached_rules_->rules, SizeIs(1)); + ASSERT_FALSE(cached_rules_->rules[0]->hosts_filter); + ASSERT_FALSE(cached_rules_->rules[0]->schemes_filter); + ASSERT_THAT(cached_rules_->rules[0]->actions, SizeIs(1)); + ASSERT_TRUE( + cached_rules_->rules[0]->actions[0]->is_substitute_query_pattern()); + + const url_rewrite::mojom::UrlRequestRewriteSubstituteQueryPatternPtr& + substitute_query_pattern = + cached_rules_->rules[0]->actions[0]->get_substitute_query_pattern(); + ASSERT_EQ(substitute_query_pattern->pattern.compare("Pattern"), 0); + ASSERT_EQ(substitute_query_pattern->substitution.compare("Substitution"), 0); +} + +// Tests ReplaceUrl rewrites are properly converted to their Mojo equivalent. +TEST_F(UrlRequestRewriteTypeConvertersTest, ConvertReplaceUrl) { + GURL url("http://site.xyz"); + EXPECT_TRUE(UpdateRulesFromRewrite( + CreateRewriteReplaceUrl("/something", url.spec()))); + ASSERT_THAT(cached_rules_->rules, SizeIs(1)); + ASSERT_FALSE(cached_rules_->rules[0]->hosts_filter); + ASSERT_FALSE(cached_rules_->rules[0]->schemes_filter); + ASSERT_THAT(cached_rules_->rules[0]->actions, SizeIs(1)); + ASSERT_TRUE(cached_rules_->rules[0]->actions[0]->is_replace_url()); + + const url_rewrite::mojom::UrlRequestRewriteReplaceUrlPtr& replace_url = + cached_rules_->rules[0]->actions[0]->get_replace_url(); + ASSERT_EQ(replace_url->url_ends_with.compare("/something"), 0); + ASSERT_EQ(replace_url->new_url.spec().compare(url.spec()), 0); +} + +// Tests AppendToQuery rewrites are properly converted to their Mojo equivalent. +TEST_F(UrlRequestRewriteTypeConvertersTest, ConvertAppendToQuery) { + EXPECT_TRUE( + UpdateRulesFromRewrite(CreateRewriteAppendToQuery("foo=bar&foo"))); + ASSERT_THAT(cached_rules_->rules, SizeIs(1)); + ASSERT_FALSE(cached_rules_->rules[0]->hosts_filter); + ASSERT_FALSE(cached_rules_->rules[0]->schemes_filter); + ASSERT_THAT(cached_rules_->rules[0]->actions, SizeIs(1)); + ASSERT_TRUE(cached_rules_->rules[0]->actions[0]->is_append_to_query()); + + const url_rewrite::mojom::UrlRequestRewriteAppendToQueryPtr& append_to_query = + cached_rules_->rules[0]->actions[0]->get_append_to_query(); + ASSERT_EQ(append_to_query->query.compare("foo=bar&foo"), 0); +} + +// Tests validation is working as expected. +TEST_F(UrlRequestRewriteTypeConvertersTest, Validation) { + // Empty rewrite. + EXPECT_FALSE(UpdateRulesFromRewrite(cast::v2::UrlRequestRewrite())); + + // Invalid AddHeaders header name. + EXPECT_FALSE( + UpdateRulesFromRewrite(CreateRewriteAddHeaders("Te\nst1", "Value"))); + + // Invalid AddHeaders header value. + EXPECT_FALSE( + UpdateRulesFromRewrite(CreateRewriteAddHeaders("Test1", "Val\nue"))); + + // Empty AddHeaders. + { + cast::v2::UrlRequestRewrite rewrite; + rewrite.mutable_add_headers(); + EXPECT_FALSE(UpdateRulesFromRewrite(std::move(rewrite))); + } + + // Invalid RemoveHeader header name. + EXPECT_FALSE( + UpdateRulesFromRewrite(CreateRewriteRemoveHeader("Query", "Head\ner"))); + + // Empty RemoveHeader. + { + cast::v2::UrlRequestRewrite rewrite; + rewrite.mutable_remove_header(); + EXPECT_FALSE(UpdateRulesFromRewrite(std::move(rewrite))); + } + + // Empty SubstituteQueryPattern. + { + cast::v2::UrlRequestRewrite rewrite; + rewrite.mutable_substitute_query_pattern(); + EXPECT_FALSE(UpdateRulesFromRewrite(std::move(rewrite))); + } + + // Invalid ReplaceUrl url_ends_with. + EXPECT_FALSE(UpdateRulesFromRewrite( + CreateRewriteReplaceUrl("some%00thing", GURL("http://site.xyz").spec()))); + + // Invalid ReplaceUrl new_url. + EXPECT_FALSE(UpdateRulesFromRewrite( + CreateRewriteReplaceUrl("/something", "http:site:xyz"))); + + // Empty ReplaceUrl. + { + cast::v2::UrlRequestRewrite rewrite; + rewrite.mutable_replace_url(); + EXPECT_FALSE(UpdateRulesFromRewrite(std::move(rewrite))); + } + + // Empty AppendToQuery. + { + cast::v2::UrlRequestRewrite rewrite; + rewrite.mutable_append_to_query(); + EXPECT_FALSE(UpdateRulesFromRewrite(std::move(rewrite))); + } +} + +// Tests rules are properly renewed after new rules are sent. +TEST_F(UrlRequestRewriteTypeConvertersTest, RuleRenewal) { + EXPECT_TRUE( + UpdateRulesFromRewrite(CreateRewriteAddHeaders("Test1", "Value"))); + ASSERT_THAT(cached_rules_->rules, SizeIs(1)); + ASSERT_THAT(cached_rules_->rules[0]->actions, SizeIs(1)); + ASSERT_TRUE(cached_rules_->rules[0]->actions[0]->is_add_headers()); + ASSERT_THAT(cached_rules_->rules[0]->actions[0]->get_add_headers()->headers, + SizeIs(1)); + ASSERT_EQ( + cached_rules_->rules[0]->actions[0]->get_add_headers()->headers[0]->name, + "Test1"); + + EXPECT_TRUE( + UpdateRulesFromRewrite(CreateRewriteAddHeaders("Test2", "Value"))); + + // We should have the new rules. + ASSERT_THAT(cached_rules_->rules, SizeIs(1)); + ASSERT_THAT(cached_rules_->rules[0]->actions, SizeIs(1)); + ASSERT_TRUE(cached_rules_->rules[0]->actions[0]->is_add_headers()); + ASSERT_THAT(cached_rules_->rules[0]->actions[0]->get_add_headers()->headers, + SizeIs(1)); + ASSERT_EQ( + cached_rules_->rules[0]->actions[0]->get_add_headers()->headers[0]->name, + "Test2"); +} + +} // namespace +} // namespace chromecast
diff --git a/chromecast/media/DEPS b/chromecast/media/DEPS index 7adfd22..993d5ac 100644 --- a/chromecast/media/DEPS +++ b/chromecast/media/DEPS
@@ -22,7 +22,7 @@ "+third_party/blink/public/common/tokens/tokens.h", "+third_party/blink/public/platform/audio/web_audio_device_source_type.h", "+third_party/blink/public/web/modules/media/audio/audio_device_factory.h", - "+third_party/blink/public/web/modules/media/audio/web_audio_output_ipc_factory.h", + "+third_party/blink/public/web/modules/media/audio/audio_output_ipc_factory.h", "+third_party/blink/public/web/web_local_frame.h", "+third_party/widevine/cdm/buildflags.h", "+third_party/widevine/cdm/widevine_cdm_common.h",
diff --git a/chromecast/media/audio/cast_audio_device_factory.cc b/chromecast/media/audio/cast_audio_device_factory.cc index 1263ac51..0b0cd15 100644 --- a/chromecast/media/audio/cast_audio_device_factory.cc +++ b/chromecast/media/audio/cast_audio_device_factory.cc
@@ -19,7 +19,7 @@ #include "media/base/bind_to_current_loop.h" #include "media/base/output_device_info.h" #include "third_party/blink/public/common/browser_interface_broker_proxy.h" -#include "third_party/blink/public/web/modules/media/audio/web_audio_output_ipc_factory.h" +#include "third_party/blink/public/web/modules/media/audio/audio_output_ipc_factory.h" #include "third_party/blink/public/web/web_local_frame.h" namespace chromecast { @@ -42,9 +42,9 @@ const ::media::AudioSinkParameters& params, base::TimeDelta auth_timeout) { auto device = base::MakeRefCounted<::media::AudioOutputDevice>( - blink::WebAudioOutputIPCFactory::GetInstance().CreateAudioOutputIPC( + blink::AudioOutputIPCFactory::GetInstance().CreateAudioOutputIPC( frame_token), - blink::WebAudioOutputIPCFactory::GetInstance().io_task_runner(), params, + blink::AudioOutputIPCFactory::GetInstance().io_task_runner(), params, auth_timeout); device->RequestDeviceAuthorization(); return device;
diff --git a/chromeos/chromeos_strings.grd b/chromeos/chromeos_strings.grd index 5d7e04d..777c280 100644 --- a/chromeos/chromeos_strings.grd +++ b/chromeos/chromeos_strings.grd
@@ -2111,8 +2111,7 @@ Chromebook repair </message> <message name="IDS_SHIMLESS_RMA_AUTHORIZED_TECH_ONLY_WARNING" translateable="false" desc="Warning that RMA is only for qualified technicians."> - This repair process is intended for a trained repair technicians. - Start only after replacing the malfunctioning components. + This repair process is intended for a trained repair technicians. Start only after replacing the malfunctioning components. </message> <message name="IDS_SHIMLESS_RMA_VALIDATING_COMPONENTS" translateable="false" desc="Checking that device components are approved for this device."> Validating components... @@ -2121,8 +2120,7 @@ Components are installed correctly. </message> <message name="IDS_SHIMLESS_RMA_VALIDATED_COMPONENTS_FAIL" translateable="false" desc="Validation check found that device components are NOT approved for this device."> - Components could not be validated. If you are certain you are using - qualified components updating Chrome OS may resolve this issue. + Components could not be validated. If you are certain you are using qualified components updating Chrome OS may resolve this issue. </message> <message name="IDS_SHIMLESS_RMA_GET_STARTED_BUTTON_LABEL" desc="The label for the button to start the RMA process."> Get started @@ -2132,8 +2130,7 @@ Get connected </message> <message name="IDS_SHIMLESS_RMA_CONNECT_PAGE_DESCRIPTION" desc="Description for the connect to wifi page."> - Connecting to Wi-Fi is recommended to make the repair process easier. - Your network will be saved. + Connecting to Wi-Fi is recommended to make the repair process easier. Your network will be saved. </message> <message name="IDS_SHIMLESS_RMA_CONNECT_DIALOG_CONFIG_NAME" desc="Title for the network configuration dialog for an existing network."> Configure <ph name="NAME">$1<ex>My WiFi network</ex></ph> @@ -2162,16 +2159,13 @@ Device will go to the same owner </message> <message name="IDS_SHIMLESS_RMA_SAME_OWNER_DESCRIPTION" desc="Detailed description of when to choose return to same owner."> - Select this option if the ownership of the device isn't changing. - For example, the device is being transferred to a different person - within an organization. + Select this option if the ownership of the device isn't changing. For example, the device is being transferred to a different person within an organization. </message> <message name="IDS_SHIMLESS_RMA_NEW_OWNER" desc="Text shown next to the return to a new owner radio button."> Device will go to a different owner </message> <message name="IDS_SHIMLESS_RMA_NEW_OWNER_DESCRIPTION" desc="Detailed description of when to choose return to a new owner."> - Select this option if the device is being restocked or refurbished for - distribution to a new customer. + Select this option if the device is being restocked or refurbished for distribution to a new customer. </message> <!-- Choose write protect disable method page --> <message name="IDS_SHIMLESS_RMA_CHOOSE_WP_DISABLE_METHOD_PAGE_TITLE" translateable="false" desc="Title for the page offering the options for disabling write protect on this device. Disabling write protection allows the new components to be calibrated and the system to be updated with information about them."> @@ -2213,8 +2207,7 @@ Hardware Write Protection Disabled Manually </message> <message name="IDS_SHIMLESS_RMA_WP_DISABLE_SKIPPED_MESSAGE" translateable="false" desc="If the device already had write protection disabled before reaching the 'choose method' page the flow skips straight to this page and informs the user they can manually re-enable if it is currently manually disabled. It is not possible for the device to determine this automatically, so the instructions must cover both cases."> - Write protection is already disabled. If the device is disassembled you - you may reassemble it now. + Write protection is already disabled. If the device is disassembled you may reassemble it now. </message> <message name="IDS_SHIMLESS_RMA_WP_DISABLE_REASSEMBLE_NOW_MESSAGE" translateable="false" desc="If the device does not need write protection to be disabled for the remainder of RMA then inform user they can enable now."> Write protection disable complete, you can reassemble the device. @@ -2350,9 +2343,7 @@ Make sure Chrome OS is up to date </message> <message name="IDS_SHIMLESS_RMA_UPDATE_OS_INVALID_COMPONENTS" translateable="false" desc="Description when components could not be validated."> - An unrecognized component has been found. Unrecognized devices will not - be configured correctly and may be unusable. Updating to the latest - version of Chrome OS may resolve this issue. + An unrecognized component has been found. Unrecognized devices will not be configured correctly and may be unusable. Updating to the latest version of Chrome OS may resolve this issue. </message> <message name="IDS_SHIMLESS_RMA_UPDATE_OS_VERY_OUT_OF_DATE" translateable="false" desc="Description when the installed OS is too many versions behind the update."> Chrome OS needs an additional update to get fully up to date @@ -2427,13 +2418,12 @@ <message name="IDS_SHIMLESS_RMA_CONFIRM_DEVICE_INFO_SKU_WARNING" translateable="false" desc="The text warning explaining when the device's SKU should be changed."> The SKU should only be changed if the new component(s) are different from the ones they replaced. For example, a touchscreen replacing a non-touchscreen, or memory being upgraded from 8GB to 16GB. </message> - <!-- Firmware reimaging page --> + <!-- RO firmware reimaging page --> <message name="IDS_SHIMLESS_RMA_REIMAGING_FIRMWARE_TITLE_REIMAGE_REQUIRED" translateable="false" desc="The title for the page when reimaging is required."> Select an option for firmware reimaging </message> <message name="IDS_SHIMLESS_RMA_REIMAGING_FIRMWARE_TITLE_REIMAGE_NOT_REQUIRED" translateable="false" desc="The title for the page when reimaging is not required."> - This device doesn't require firmware reimaging. - Would you like to reimage the firmware anyway? + This device doesn't require firmware reimaging. Would you like to reimage the firmware anyway? </message> <message name="IDS_SHIMLESS_RMA_REIMAGING_FIRMWARE_INTERNET_ACCESS" translateable="false" desc="The label that says that internet access is required."> Requires internet access @@ -2499,8 +2489,21 @@ <message name="IDS_SHIMLESS_RMA_ONBOARDING_UPDATE_PERMISSION" translateable="false" desc="The update permission required operation name."> need permission to update </message> + <!-- Critical error page --> + <message name="IDS_SHIMLESS_RMA_CRITICAL_ERROR_TITLE" translateable="false" desc="The title for the critical error page. Critical errors cause the RMA process to attempt to exit to login or reboot the device at users discretion. It will try to cancel RMA, but if that fails the next boot may also trigger an RMA critical error."> + Critical Error + </message> + <message name="IDS_SHIMLESS_RMA_CRITICAL_ERROR_MESSAGE" translateable="false" desc="The message for the critical error when Shimless RMA app is launched when not in RMA. This should never happen."> + Repair finalization is in an unexpected state. You can exit to the login screen to investigate or backup data or reboot the device to attempt to resolve the issue. If you continue to see this message you should use the recovery shim. + </message> + <message name="IDS_SHIMLESS_RMA_CRITICAL_EXIT_TO_LOGIN_BUTTON" translateable="false" desc="Label for the button that attempts to cancel RMA and exit to the login screen."> + Exit to login + </message> + <message name="IDS_SHIMLESS_RMA_CRITICAL_REBOOT_BUTTON" translateable="false" desc="Label for the button that attempts to cancel RMA and reboot the device."> + Reboot + </message> - <!-- Firmware Update --> + <!-- Peripheral Firmware Update --> <message name="IDS_FIRMWARE_TITLE_TEXT" desc="The title of the Firmware update app."> Update peripherals </message>
diff --git a/chromeos/chromeos_strings_grd/IDS_SHIMLESS_RMA_CONNECT_PAGE_DESCRIPTION.png.sha1 b/chromeos/chromeos_strings_grd/IDS_SHIMLESS_RMA_CONNECT_PAGE_DESCRIPTION.png.sha1 index 774bae6..1103f89 100644 --- a/chromeos/chromeos_strings_grd/IDS_SHIMLESS_RMA_CONNECT_PAGE_DESCRIPTION.png.sha1 +++ b/chromeos/chromeos_strings_grd/IDS_SHIMLESS_RMA_CONNECT_PAGE_DESCRIPTION.png.sha1
@@ -1 +1 @@ -a3061e9dc019468651b995e49f60aca97580c75d \ No newline at end of file +f5831dd696e9eddfb03ca29dff58c0d9cb8bc8da \ No newline at end of file
diff --git a/chromeos/chromeos_strings_grd/IDS_SHIMLESS_RMA_NEW_OWNER_DESCRIPTION.png.sha1 b/chromeos/chromeos_strings_grd/IDS_SHIMLESS_RMA_NEW_OWNER_DESCRIPTION.png.sha1 index 6d65024..22ecdd7 100644 --- a/chromeos/chromeos_strings_grd/IDS_SHIMLESS_RMA_NEW_OWNER_DESCRIPTION.png.sha1 +++ b/chromeos/chromeos_strings_grd/IDS_SHIMLESS_RMA_NEW_OWNER_DESCRIPTION.png.sha1
@@ -1 +1 @@ -559d52981eb58259977e9dd78e7d88f58db6bc0a \ No newline at end of file +fb709838fc2aad7a6861b2fa5875feb665387094 \ No newline at end of file
diff --git a/chromeos/chromeos_strings_grd/IDS_SHIMLESS_RMA_SAME_OWNER_DESCRIPTION.png.sha1 b/chromeos/chromeos_strings_grd/IDS_SHIMLESS_RMA_SAME_OWNER_DESCRIPTION.png.sha1 index 6d65024..22ecdd7 100644 --- a/chromeos/chromeos_strings_grd/IDS_SHIMLESS_RMA_SAME_OWNER_DESCRIPTION.png.sha1 +++ b/chromeos/chromeos_strings_grd/IDS_SHIMLESS_RMA_SAME_OWNER_DESCRIPTION.png.sha1
@@ -1 +1 @@ -559d52981eb58259977e9dd78e7d88f58db6bc0a \ No newline at end of file +fb709838fc2aad7a6861b2fa5875feb665387094 \ No newline at end of file
diff --git a/chromeos/crosapi/mojom/crosapi.mojom b/chromeos/crosapi/mojom/crosapi.mojom index 96572a3..ec511a8 100644 --- a/chromeos/crosapi/mojom/crosapi.mojom +++ b/chromeos/crosapi/mojom/crosapi.mojom
@@ -808,15 +808,15 @@ [MinVersion=31] bool is_unfiltered_bluetooth_device_enabled@30; - // Ash publishes the list of workarounds it has implemented to Lacros so + // Ash publishes the list of capabilities it has implemented to Lacros so // that Lacros can dynamically change its behavior. This should typically take // the format of a bug identifier, e.g. "crbug/123" or "b/456". This is // primarily necessary for backporting behavior changes and fixes to older - // branches. When adding a new workaround, please indicate with a comment when - // we can stop publishing the workaround -- e.g. once Ash and Lacros are both - // past M100, then we can remove this workaround. + // branches. If applicable, when adding a new capability, please indicate with + // a comment when we can stop publishing the capability -- e.g. once Ash and + // Lacros are both past M100, then we can remove this capability. [MinVersion=32] - array<string>? ash_workarounds@31; + array<string>? ash_capabilities@31; // Internal chrome:// URLs which can be handled by Ash. These are sent from // Ash to Lacros at startup so Lacros knows which URLs are OK to forward.
diff --git a/chromeos/dbus/rmad/fake_rmad_client.cc b/chromeos/dbus/rmad/fake_rmad_client.cc index 3b1eb03d..6a9e3f0b 100644 --- a/chromeos/dbus/rmad/fake_rmad_client.cc +++ b/chromeos/dbus/rmad/fake_rmad_client.cc
@@ -96,10 +96,14 @@ } rmad::GetStateReply CreateStateReply(rmad::RmadState::StateCase state, - rmad::RmadErrorCode error) { + rmad::RmadErrorCode error, + bool can_go_back = true, + bool can_abort = true) { rmad::GetStateReply reply; reply.set_allocated_state(CreateState(state)); reply.set_error(error); + reply.set_can_go_back(can_go_back); + reply.set_can_abort(can_abort); return reply; } } // namespace @@ -131,6 +135,47 @@ wp_disable_rsu_state.mutable_state() ->mutable_wp_disable_rsu() ->set_allocated_challenge_url(new std::string(rsu_challenge_url)); + rmad::GetStateReply update_device_info = CreateStateReply( + rmad::RmadState::kUpdateDeviceInfo, rmad::RMAD_ERROR_OK); + update_device_info.mutable_state() + ->mutable_update_device_info() + ->add_region_list("EMEA"); + update_device_info.mutable_state() + ->mutable_update_device_info() + ->add_region_list("APAC"); + update_device_info.mutable_state() + ->mutable_update_device_info() + ->add_region_list("AMER"); + update_device_info.mutable_state() + ->mutable_update_device_info() + ->add_sku_list(1UL); + update_device_info.mutable_state() + ->mutable_update_device_info() + ->add_sku_list(2UL); + update_device_info.mutable_state() + ->mutable_update_device_info() + ->add_sku_list(3UL); + update_device_info.mutable_state() + ->mutable_update_device_info() + ->add_whitelabel_list("White-label 1"); + update_device_info.mutable_state() + ->mutable_update_device_info() + ->add_whitelabel_list("White-label 2"); + update_device_info.mutable_state() + ->mutable_update_device_info() + ->add_whitelabel_list("White-label 3"); + update_device_info.mutable_state() + ->mutable_update_device_info() + ->set_original_serial_number("serial 0001"); + update_device_info.mutable_state() + ->mutable_update_device_info() + ->set_original_region_index(2); + update_device_info.mutable_state() + ->mutable_update_device_info() + ->set_original_sku_index(1); + update_device_info.mutable_state() + ->mutable_update_device_info() + ->set_original_whitelabel_index(0); std::vector<rmad::GetStateReply> fake_states = { CreateStateReply(rmad::RmadState::kWelcome, rmad::RMAD_ERROR_OK), @@ -147,8 +192,7 @@ CreateStateReply(rmad::RmadState::kUpdateRoFirmware, rmad::RMAD_ERROR_OK), CreateStateReply(rmad::RmadState::kRestock, rmad::RMAD_ERROR_OK), - CreateStateReply(rmad::RmadState::kUpdateDeviceInfo, - rmad::RMAD_ERROR_OK), + update_device_info, // TODO(gavindodd): Add calibration states when implemented. // rmad::RmadState::kCheckCalibration // rmad::RmadState::kSetupCalibration @@ -161,6 +205,7 @@ CreateStateReply(rmad::RmadState::kRepairComplete, rmad::RMAD_ERROR_OK), }; fake->SetFakeStateReplies(fake_states); + fake->SetAbortable(true); } }
diff --git a/chromeos/services/bluetooth_config/adapter_state_controller_impl.cc b/chromeos/services/bluetooth_config/adapter_state_controller_impl.cc index a377858..e2a0781fa 100644 --- a/chromeos/services/bluetooth_config/adapter_state_controller_impl.cc +++ b/chromeos/services/bluetooth_config/adapter_state_controller_impl.cc
@@ -50,6 +50,7 @@ device::BluetoothAdapter* adapter, bool powered) { NotifyAdapterStateChanged(); + AttemptQueuedStateChange(); } void AdapterStateControllerImpl::AttemptQueuedStateChange() { @@ -113,7 +114,12 @@ BLUETOOTH_LOG(EVENT) << "Bluetooth " << (enabled ? "enabled" : "disabled") << " successfully"; in_progress_state_change_ = PowerStateChange::kNoChange; - AttemptQueuedStateChange(); + + // Adapter->IsPowered() won't immediately be updated to the new value when + // SetPowered() finishes and this method is called. Don't call + // AttemptQueuedStateChange() now because the adapter isn't in the correct + // state yet. Wait until AdapterPoweredChanged() is invoked and call + // AttemptQueuedStateChange() there. } void AdapterStateControllerImpl::OnSetPoweredError(bool enabled) {
diff --git a/chromeos/services/bluetooth_config/adapter_state_controller_impl_unittest.cc b/chromeos/services/bluetooth_config/adapter_state_controller_impl_unittest.cc index 4b8eee4..69faa33 100644 --- a/chromeos/services/bluetooth_config/adapter_state_controller_impl_unittest.cc +++ b/chromeos/services/bluetooth_config/adapter_state_controller_impl_unittest.cc
@@ -107,9 +107,13 @@ pending_power_state_.reset(); if (success) { - SetAdapterPoweredState(expected_pending_state); std::move(set_powered_success_callback_).Run(); set_powered_error_callback_.Reset(); + + // In real-life, the adapter's powered state doesn't change until after + // the success callback is fired. Simulate this by setting the adapter + // state after invoking the success callback. + SetAdapterPoweredState(expected_pending_state); return; }
diff --git a/chromeos/services/bluetooth_config/fake_bluetooth_device_status_notifier.cc b/chromeos/services/bluetooth_config/fake_bluetooth_device_status_notifier.cc index 97065b0..d7bd6135 100644 --- a/chromeos/services/bluetooth_config/fake_bluetooth_device_status_notifier.cc +++ b/chromeos/services/bluetooth_config/fake_bluetooth_device_status_notifier.cc
@@ -18,5 +18,15 @@ NotifyDevicesNewlyPaired(devices); } +void FakeBluetoothDeviceStatusNotifier::SetConnectedDevices( + const std::vector<mojom::PairedBluetoothDevicePropertiesPtr>& devices) { + NotifyDevicesNewlyConnected(devices); +} + +void FakeBluetoothDeviceStatusNotifier::SetDisconnectedDevices( + const std::vector<mojom::PairedBluetoothDevicePropertiesPtr>& devices) { + NotifyDevicesNewlyDisconnected(devices); +} + } // namespace bluetooth_config } // namespace chromeos \ No newline at end of file
diff --git a/chromeos/services/bluetooth_config/fake_bluetooth_device_status_notifier.h b/chromeos/services/bluetooth_config/fake_bluetooth_device_status_notifier.h index fe336c2..c884b12 100644 --- a/chromeos/services/bluetooth_config/fake_bluetooth_device_status_notifier.h +++ b/chromeos/services/bluetooth_config/fake_bluetooth_device_status_notifier.h
@@ -19,6 +19,12 @@ void SetNewlyPairedDevices( const std::vector<mojom::PairedBluetoothDevicePropertiesPtr>& devices); + + void SetConnectedDevices( + const std::vector<mojom::PairedBluetoothDevicePropertiesPtr>& devices); + + void SetDisconnectedDevices( + const std::vector<mojom::PairedBluetoothDevicePropertiesPtr>& devices); }; } // namespace bluetooth_config
diff --git a/components/arc/mojom/BUILD.gn b/components/arc/mojom/BUILD.gn index 451e153..d6b3aff 100644 --- a/components/arc/mojom/BUILD.gn +++ b/components/arc/mojom/BUILD.gn
@@ -19,16 +19,7 @@ "file_system.mojom", "intent_common.mojom", "intent_helper.mojom", - "lock_screen.mojom", - "media_session.mojom", - "memory.mojom", "metrics.mojom", - "midis.mojom", - "nearby_share.mojom", - "net.mojom", - "obb_mounter.mojom", - "payment_app.mojom", - "pip.mojom", "policy.mojom", "power.mojom", "print_common.mojom", @@ -98,24 +89,6 @@ { types = [ { - mojom = "arc.mojom.TextInputType" - cpp = "::ui::TextInputType" - }, - { - mojom = "arc.mojom.KeyEventData" - cpp = "::std::unique_ptr<::ui::KeyEvent>" - move_only = true - }, - ] - traits_headers = [ "//ash/components/arc/mojom/ime_mojom_traits.h" ] - traits_public_deps = [ - "//ui/base/ime", - "//ui/events", - ] - }, - { - types = [ - { mojom = "arc.mojom.IntentFilter" cpp = "::arc::IntentFilter" move_only = true
diff --git a/components/autofill/core/browser/browser_autofill_manager.cc b/components/autofill/core/browser/browser_autofill_manager.cc index 50d911b..18c14c7 100644 --- a/components/autofill/core/browser/browser_autofill_manager.cc +++ b/components/autofill/core/browser/browser_autofill_manager.cc
@@ -1945,9 +1945,9 @@ if (profile) { const std::u16string phone_home_city_and_number = profile->GetInfo(PHONE_HOME_CITY_AND_NUMBER, app_locale_); - suggestion.value = - FieldFiller::GetPhoneNumberValue(autofill_field, suggestion.value, - phone_home_city_and_number, field); + suggestion.value = FieldFiller::GetPhoneNumberValueForInput( + autofill_field, suggestion.value, phone_home_city_and_number, + field); } } }
diff --git a/components/autofill/core/browser/data_model/credit_card.cc b/components/autofill/core/browser/data_model/credit_card.cc index 1ba8bbbe..5cd27b35 100644 --- a/components/autofill/core/browser/data_model/credit_card.cc +++ b/components/autofill/core/browser/data_model/credit_card.cc
@@ -57,6 +57,7 @@ constexpr char16_t kMidlineEllipsis2Dots[] = u"\u2022\u2060\u2006\u2060" u"\u2022\u2060\u2006\u2060"; +constexpr char16_t kMidlineEllipsisPlainDot = u'\u2022'; namespace { @@ -889,6 +890,13 @@ obfuscation_length); } +std::u16string CreditCard::ObfuscatedLastFourDigitsForSplitFields() const { + // For split credit card number fields, use plain dots without spacing and no + // LTR formatting. Only obfuscate 12 dots and append the last four digits of + // the credit card number. + return std::u16string(12, kMidlineEllipsisPlainDot) + LastFourDigits(); +} + std::string CreditCard::CardIconStringForAutofillSuggestion() const { if (base::FeatureList::IsEnabled(features::kAutofillEnableGoogleIssuedCard) && IsGoogleIssuedCard()) {
diff --git a/components/autofill/core/browser/data_model/credit_card.h b/components/autofill/core/browser/data_model/credit_card.h index 2cfeea5..922ef94 100644 --- a/components/autofill/core/browser/data_model/credit_card.h +++ b/components/autofill/core/browser/data_model/credit_card.h
@@ -275,6 +275,11 @@ // A label for this card formatted as '••••2345' where the number of dots are // specified by the `obfuscation_length`. std::u16string ObfuscatedLastFourDigits(int obfuscation_length = 4) const; + // A label for this card formatted '••••••••••••2345' where every digit in the + // the credit card number is obfuscated except for the last four. This method + // is primarily used for splitting the preview of a credit card number into + // several fields. + std::u16string ObfuscatedLastFourDigitsForSplitFields() const; // The string used to represent the icon to be used for the autofill // suggestion. For ex: visaCC, googleIssuedCC, americanExpressCC, etc. std::string CardIconStringForAutofillSuggestion() const;
diff --git a/components/autofill/core/browser/field_filler.cc b/components/autofill/core/browser/field_filler.cc index c1a6c767..61e06c9e 100644 --- a/components/autofill/core/browser/field_filler.cc +++ b/components/autofill/core/browser/field_filler.cc
@@ -497,17 +497,6 @@ return false; } -// Set |field_data|'s value to |number|, or |phone_home_city_and_number|, or -// possibly an appropriate substring of |number|. The |field| specifies the -// type of the phone and whether this is a phone prefix or suffix. -void FillPhoneNumberField(const AutofillField& field, - const std::u16string& number, - const std::u16string& phone_home_city_and_number, - FormFieldData* field_data) { - field_data->value = FieldFiller::GetPhoneNumberValue( - field, number, phone_home_city_and_number, *field_data); -} - // Return the appropriate credit card number from |credit_card|. Truncates the // credit card number to be split across HTML form input fields depending on if // |field.credit_card_number_offset()| is less than the length of the credit @@ -519,13 +508,28 @@ mojom::RendererFormDataAction action) { std::u16string value; - // In preview, only show the last four of the credit card number. - value = action == mojom::RendererFormDataAction::kPreview - ? credit_card.ObfuscatedLastFourDigits() - : credit_card.GetInfo(CREDIT_CARD_NUMBER, app_locale); + if (action == mojom::RendererFormDataAction::kPreview) { + // A single field is detected when the offset begins at 0 and the field's + // max_length can hold the entire obfuscated credit card number. + bool is_single_field = + (field.credit_card_number_offset() == 0 && + (field.max_length == 0 || + field.max_length >= credit_card.ObfuscatedLastFourDigits().length())); - // |field|'s max_length truncates credit card number to fit within. + // If previewing a credit card number that needs to be split, pad the number + // to 16 digits rather than displaying a fancy string with RTL support. + value = is_single_field + ? credit_card.ObfuscatedLastFourDigits() + : credit_card.ObfuscatedLastFourDigitsForSplitFields(); + } else { + value = credit_card.GetInfo(CREDIT_CARD_NUMBER, app_locale); + } + + // |field|'s max_length truncates the credit card number to fit within. if (field.credit_card_number_offset() < value.length()) { + // Take the substring of the credit card number starting from the offset and + // ending at the field's max_length (or the entire string if max_length is + // 0). value = value.substr( field.credit_card_number_offset(), field.max_length > 0 ? field.max_length : std::u16string::npos); @@ -586,82 +590,71 @@ card.Expiration2DigitMonthAsString(); } -// Fills |field| with the street address in |value|. Translates newlines into +// Returns appropriate street address for |field|. Translates newlines into // equivalent separators when necessary, i.e. when filling a single-line field. // The separators depend on |address_language_code|. -void FillStreetAddress(const std::u16string& value, - const std::string& address_language_code, - FormFieldData* field) { - if (field->form_control_type == "textarea") { - field->value = value; - return; - } +std::u16string GetStreetAddressForInput( + const std::u16string& address_value, + const std::string& address_language_code, + FormFieldData* field) { + if (field->form_control_type == "textarea") + return address_value; ::i18n::addressinput::AddressData address_data; address_data.language_code = address_language_code; address_data.address_line = - base::SplitString(base::UTF16ToUTF8(value), "\n", base::TRIM_WHITESPACE, - base::SPLIT_WANT_ALL); + base::SplitString(base::UTF16ToUTF8(address_value), "\n", + base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); std::string line; ::i18n::addressinput::GetStreetAddressLinesAsSingleLine(address_data, &line); - field->value = base::UTF8ToUTF16(line); + return base::UTF8ToUTF16(line); } -// Returns whether the |field| was filled with the state in |value| or its -// canonical state name or the abbreviation. -// First looks if |value| fits directly in the field, then looks if the -// abbreviation of |value| fits in case the +// Returns appropriate state value that matches |field|. +// First looks if |state_value| fits directly in the field, then looks if the +// abbreviation of |state_value| fits in case the // |features::kAutofillUseAlternativeStateNameMap| is disabled. // If the |features::kAutofillUseAlternativeStateNameMap| is enabled, the // canonical state is checked if it fits in the field and at last the -// abbreviations are tried. -// Does not fill if neither |value| nor the canonical state name nor its -// abbreviation fit into the field. -bool FillStateText(const std::u16string& value, - const std::string& country_code, - FormFieldData* field, - std::string* failure_to_fill) { - if (field->max_length == 0 || field->max_length >= value.size()) { - // Fill the state value directly. - field->value = value; - return true; - } +// abbreviations are tried. Does not return a state if neither |state_value| nor +// the canonical state name nor its abbreviation fit into the field. +std::u16string GetStateTextForInput(const std::u16string& state_value, + const std::string& country_code, + FormFieldData* field, + std::string* failure_to_fill) { + if (field->max_length == 0 || field->max_length >= state_value.size()) + // Return the state value directly. + return state_value; if (base::FeatureList::IsEnabled( features::kAutofillUseAlternativeStateNameMap)) { absl::optional<StateEntry> state = AlternativeStateNameMap::GetInstance()->GetEntry( AlternativeStateNameMap::CountryCode(country_code), - AlternativeStateNameMap::StateName(value)); + AlternativeStateNameMap::StateName(state_value)); if (state) { - // Fill with the canonical state name if possible. + // Return the canonical state name if possible. if (state->has_canonical_name() && !state->canonical_name().empty() && - field->max_length >= state->canonical_name().size()) { - field->value = base::UTF8ToUTF16(state->canonical_name()); - return true; - } + field->max_length >= state->canonical_name().size()) + return base::UTF8ToUTF16(state->canonical_name()); - // Fill with the abbreviation if possible. + // Return the abbreviation if possible. for (const auto& abbr : state->abbreviations()) { - if (!abbr.empty() && field->max_length >= abbr.size()) { - field->value = base::i18n::ToUpper(base::UTF8ToUTF16(abbr)); - return true; - } + if (!abbr.empty() && field->max_length >= abbr.size()) + return base::i18n::ToUpper(base::UTF8ToUTF16(abbr)); } } } - // Fill with the state abbreviation. + // Return with the state abbreviation. std::u16string abbreviation; - state_names::GetNameAndAbbreviation(value, nullptr, &abbreviation); - if (!abbreviation.empty() && field->max_length >= abbreviation.size()) { - field->value = base::i18n::ToUpper(abbreviation); - return true; - } + state_names::GetNameAndAbbreviation(state_value, nullptr, &abbreviation); + if (!abbreviation.empty() && field->max_length >= abbreviation.size()) + return base::i18n::ToUpper(abbreviation); if (failure_to_fill) *failure_to_fill += "Could not fit raw state nor abbreviation. "; - return false; + return std::u16string(); } // Returns the appropriate expiration year from |credit_card| for the field. @@ -737,16 +730,18 @@ // |country_code|. // If the exact match is not found, extracts the digits (ignoring leading '00' // or '+') from each option and compares them with the |country_code|. -void FillPhoneCountryCodeSelectControl(const std::u16string& country_code, - FormFieldData* field, - std::string* failure_to_fill) { +std::u16string GetPhoneCountryCodeSelectControlForInput( + const std::u16string& country_code, + FormFieldData* field, + std::string* failure_to_fill) { if (country_code.empty()) - return; + return std::u16string(); // Find the option that exactly matches the |country_code|. if (SetSelectControlValue(country_code, field, /*best_match_index=*/nullptr, - failure_to_fill)) - return; + failure_to_fill)) { + return country_code; + } for (const SelectOption& option : field->options) { std::u16string cc_candidate_in_value = @@ -756,10 +751,10 @@ RemoveWhitespace(option.content)); if (cc_candidate_in_value == country_code || cc_candidate_in_content == country_code) { - field->value = option.value; - return; + return option.value; } } + return std::u16string(); } // Returns the appropriate |credit_card| value based on |storable_type| to fill @@ -795,6 +790,44 @@ } } +// Returns the appropriate |profile| value based on |type| to fill +// into |field|. +std::u16string GetValueForProfile(const AutofillProfile& profile, + const std::string& app_locale, + const AutofillField& field, + FormFieldData* field_data, + std::string* failure_to_fill) { + const AutofillType type = field.Type(); + std::u16string value = profile.GetInfo(type, app_locale); + + if (type.group() == FieldTypeGroup::kPhoneHome) { + // If the |field_data| is a selection box and having the type + // |PHONE_HOME_COUNTRY_CODE|, call + // |GetPhoneCountryCodeSelectControlForInput|. + if (base::FeatureList::IsEnabled( + features::kAutofillEnableAugmentedPhoneCountryCode) && + field_data->form_control_type == "select-one" && + type.GetStorableType() == PHONE_HOME_COUNTRY_CODE) { + value = GetPhoneCountryCodeSelectControlForInput(value, field_data, + failure_to_fill); + } else { + const std::u16string phone_home_city_and_number = + profile.GetInfo(PHONE_HOME_CITY_AND_NUMBER, app_locale); + value = FieldFiller::GetPhoneNumberValueForInput( + field, value, phone_home_city_and_number, *field_data); + } + } else if (type.GetStorableType() == ADDRESS_HOME_STREET_ADDRESS) { + const std::string& profile_language_code = profile.language_code(); + value = GetStreetAddressForInput(value, profile_language_code, field_data); + } else if (type.GetStorableType() == ADDRESS_HOME_STATE) { + const std::string& country_code = + data_util::GetCountryCodeWithFallback(profile, app_locale); + value = + GetStateTextForInput(value, country_code, field_data, failure_to_fill); + } + return value; +} + } // namespace FieldFiller::FieldFiller(const std::string& app_locale, @@ -820,34 +853,23 @@ value = GetValueForCreditCard(*credit_card, cvc, app_locale_, action, field, failure_to_fill); - - // Do not attempt to fill empty values as it would skew the metrics. - if (value.empty()) { - if (failure_to_fill) - *failure_to_fill += "No value to fill available. "; - return false; - } - if (field.form_control_type == "select-one") { - return FillSelectControl(type, value, credit_card, app_locale_, - field_data, address_normalizer_, - failure_to_fill); - } - field_data->value = value; - return true; } // Grab AutofillProfile data. - DCHECK( - absl::holds_alternative<const AutofillProfile*>(profile_or_credit_card)); - const AutofillProfile* profile = - absl::get<const AutofillProfile*>(profile_or_credit_card); - if (profile->ShouldSkipFillingOrSuggesting(type.GetStorableType())) { - if (failure_to_fill) - *failure_to_fill += "ShouldSkipFillingOrSuggesting() returned true. "; - return false; - } + else { + DCHECK(absl::holds_alternative<const AutofillProfile*>( + profile_or_credit_card)); + const AutofillProfile* profile = + absl::get<const AutofillProfile*>(profile_or_credit_card); + if (profile->ShouldSkipFillingOrSuggesting(type.GetStorableType())) { + if (failure_to_fill) + *failure_to_fill += "ShouldSkipFillingOrSuggesting() returned true. "; + return false; + } - value = profile->GetInfo(type, app_locale_); + value = GetValueForProfile(*profile, app_locale_, field, field_data, + failure_to_fill); + } // Do not attempt to fill empty values as it would skew the metrics. if (value.empty()) { @@ -855,48 +877,10 @@ *failure_to_fill += "No value to fill available. "; return false; } - - // Filling of AutofillProfile. - if (type.group() == FieldTypeGroup::kPhoneHome) { - // If the |field_data| is a selection box and having the type - // |PHONE_HOME_COUNTRY_CODE|, call |FillPhoneCountryCodeSelectControl|. - if (base::FeatureList::IsEnabled( - features::kAutofillEnableAugmentedPhoneCountryCode) && - field_data->form_control_type == "select-one" && - type.GetStorableType() == PHONE_HOME_COUNTRY_CODE) { - FillPhoneCountryCodeSelectControl(value, field_data, failure_to_fill); - } else { - DCHECK(absl::holds_alternative<const AutofillProfile*>( - profile_or_credit_card)); - const std::u16string phone_home_city_and_number = - absl::get<const AutofillProfile*>(profile_or_credit_card) - ->GetInfo(PHONE_HOME_CITY_AND_NUMBER, app_locale_); - FillPhoneNumberField(field, value, phone_home_city_and_number, - field_data); - } - return true; - } - if (field_data->form_control_type == "select-one") { + if (field.form_control_type == "select-one") { return FillSelectControl(type, value, profile_or_credit_card, app_locale_, field_data, address_normalizer_, failure_to_fill); } - if (type.GetStorableType() == ADDRESS_HOME_STREET_ADDRESS) { - DCHECK(absl::holds_alternative<const AutofillProfile*>( - profile_or_credit_card)); - const std::string& profile_language_code = - absl::get<const AutofillProfile*>(profile_or_credit_card) - ->language_code(); - FillStreetAddress(value, profile_language_code, field_data); - return true; - } - if (type.GetStorableType() == ADDRESS_HOME_STATE) { - DCHECK(absl::holds_alternative<const AutofillProfile*>( - profile_or_credit_card)); - const std::string& country_code = data_util::GetCountryCodeWithFallback( - *absl::get<const AutofillProfile*>(profile_or_credit_card), - app_locale_); - return FillStateText(value, country_code, field_data, failure_to_fill); - } field_data->value = value; return true; } @@ -904,7 +888,7 @@ // TODO(crbug.com/581514): Add support for filling only the prefix/suffix for // phone numbers with 10 or 11 digits. // static -std::u16string FieldFiller::GetPhoneNumberValue( +std::u16string FieldFiller::GetPhoneNumberValueForInput( const AutofillField& field, const std::u16string& number, const std::u16string& phone_home_city_and_number,
diff --git a/components/autofill/core/browser/field_filler.h b/components/autofill/core/browser/field_filler.h index 21265a8..f6707a5 100644 --- a/components/autofill/core/browser/field_filler.h +++ b/components/autofill/core/browser/field_filler.h
@@ -45,7 +45,7 @@ // Returns the phone number value for the given |field|. The returned value // might be |number|, or |phone_home_city_and_number|, or could possibly be a // meaningful subset |number|, if that's appropriate for the field. - static std::u16string GetPhoneNumberValue( + static std::u16string GetPhoneNumberValueForInput( const AutofillField& field, const std::u16string& number, const std::u16string& phone_home_city_and_number,
diff --git a/components/autofill/core/browser/field_filler_unittest.cc b/components/autofill/core/browser/field_filler_unittest.cc index 5f0e196..399b17c 100644 --- a/components/autofill/core/browser/field_filler_unittest.cc +++ b/components/autofill/core/browser/field_filler_unittest.cc
@@ -1412,8 +1412,7 @@ CreditCardTestCase test; test.card_number_ = u"5187654321098765"; test.total_splits_ = 4; - int splits[] = {4, 4, 4, 4}; - test.splits_ = std::vector<int>(splits, splits + base::size(splits)); + test.splits_ = {4, 4, 4, 4}; test.expected_results_ = {u"5187", u"6543", u"2109", u"8765"}; FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); @@ -1430,8 +1429,7 @@ mojom::RendererFormDataAction::kFill); // Verify for expected results. - EXPECT_EQ(test.expected_results_[i], - cc_number_part.value.substr(0, cc_number_part.max_length)); + EXPECT_EQ(test.expected_results_[i], cc_number_part.value); EXPECT_EQ(4 * i, cc_number_part.credit_card_number_offset()); } @@ -1448,14 +1446,58 @@ EXPECT_EQ(test.card_number_, cc_number_full.value); } +TEST_F(AutofillFieldFillerTest, PreviewCreditCardNumberWithEqualSizeSplits) { + // Case 2: card number broken up into four equal groups, of length 4. + CreditCardTestCase test; + test.card_number_ = u"5187654321098765"; + test.total_splits_ = 4; + test.splits_ = {4, 4, 4, 4}; + test.expected_results_ = {u"\x2022\x2022\x2022\x2022", + u"\x2022\x2022\x2022\x2022", + u"\x2022\x2022\x2022\x2022", u"8765"}; + // 12 dots and last four of card number. + std::u16string obfuscated_card_number = + u"\x202A\x2022\x2060\x2006\x2060\x2022\x2060\x2006\x2060\x2022\x2060" + u"\x2006\x2060\x2022\x2060\x2006\x2060" + u"8765\x202C"; + FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); + for (size_t i = 0; i < test.total_splits_; ++i) { + AutofillField cc_number_part; + cc_number_part.set_heuristic_type(CREDIT_CARD_NUMBER); + cc_number_part.max_length = test.splits_[i]; + cc_number_part.set_credit_card_number_offset(4 * i); + + // Fill with a card-number; should fill just the card_number_part. + credit_card()->SetNumber(test.card_number_); + filler.FillFormField(cc_number_part, credit_card(), &cc_number_part, + /*cvc=*/std::u16string(), + mojom::RendererFormDataAction::kPreview); + + // Verify for expected results. + EXPECT_EQ(test.expected_results_[i], cc_number_part.value); + EXPECT_EQ(4 * i, cc_number_part.credit_card_number_offset()); + } + + // Verify that full card-number shall get fill properly as well. + AutofillField cc_number_full; + cc_number_full.set_heuristic_type(CREDIT_CARD_NUMBER); + + credit_card()->SetNumber(test.card_number_); + filler.FillFormField(cc_number_full, credit_card(), &cc_number_full, + /*cvc=*/std::u16string(), + mojom::RendererFormDataAction::kPreview); + + // Verify for expected results. + EXPECT_EQ(obfuscated_card_number, cc_number_full.value); +} + TEST_F(AutofillFieldFillerTest, FillCreditCardNumberWithUnequalSizeSplits) { // Case 3: card with 15 digits number, broken up into three unequal groups, of // lengths 4, 6, and 5. CreditCardTestCase test; test.card_number_ = u"423456789012345"; test.total_splits_ = 3; - int splits[] = {4, 6, 5}; - test.splits_ = std::vector<int>(splits, splits + base::size(splits)); + test.splits_ = {4, 6, 5}; test.expected_results_ = {u"4234", u"567890", u"12345"}; FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); @@ -1473,8 +1515,7 @@ mojom::RendererFormDataAction::kFill); // Verify for expected results. - EXPECT_EQ(test.expected_results_[i], - cc_number_part.value.substr(0, cc_number_part.max_length)); + EXPECT_EQ(test.expected_results_[i], cc_number_part.value); EXPECT_EQ(GetNumberOffset(i, test), cc_number_part.credit_card_number_offset()); } @@ -1491,6 +1532,55 @@ EXPECT_EQ(test.card_number_, cc_number_full.value); } +TEST_F(AutofillFieldFillerTest, PreviewCreditCardNumberWithUnequalSizeSplits) { + // Case 3: card with 15 digits number, broken up into three unequal groups, of + // lengths 4, 6, and 5. + CreditCardTestCase test; + test.card_number_ = u"423456789012345"; + // 12 dots and last four of card number. + std::u16string obfuscated_card_number = + u"\x202A\x2022\x2060\x2006\x2060\x2022\x2060\x2006\x2060\x2022\x2060" + u"\x2006\x2060\x2022\x2060\x2006\x2060" + u"2345\x202C"; + test.total_splits_ = 3; + test.splits_ = {4, 6, 6}; + test.expected_results_ = {u"\x2022\x2022\x2022\x2022", + u"\x2022\x2022\x2022\x2022\x2022\x2022", + u"\x2022\x2022" + u"2345"}; + + FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr); + // Start executing test cases to verify parts and full credit card number. + for (size_t i = 0; i < test.total_splits_; ++i) { + AutofillField cc_number_part; + cc_number_part.set_heuristic_type(CREDIT_CARD_NUMBER); + cc_number_part.max_length = test.splits_[i]; + cc_number_part.set_credit_card_number_offset(GetNumberOffset(i, test)); + + // Fill with a card-number; should fill just the card_number_part. + credit_card()->SetNumber(test.card_number_); + filler.FillFormField(cc_number_part, credit_card(), &cc_number_part, + /*cvc=*/std::u16string(), + mojom::RendererFormDataAction::kPreview); + + // Verify for expected results. + EXPECT_EQ(test.expected_results_[i], cc_number_part.value); + EXPECT_EQ(GetNumberOffset(i, test), + cc_number_part.credit_card_number_offset()); + } + + // Verify that full card-number shall get fill properly as well. + AutofillField cc_number_full; + cc_number_full.set_heuristic_type(CREDIT_CARD_NUMBER); + credit_card()->SetNumber(test.card_number_); + filler.FillFormField(cc_number_full, credit_card(), &cc_number_full, + /*cvc=*/std::u16string(), + mojom::RendererFormDataAction::kPreview); + + // Verify for expected results. + EXPECT_EQ(obfuscated_card_number, cc_number_full.value); +} + TEST_F(AutofillFieldFillerTest, FindShortestSubstringMatchInSelect) { std::vector<const char*> kCountries = {"États-Unis", "Canada"}; AutofillField field;
diff --git a/components/component_updater/BUILD.gn b/components/component_updater/BUILD.gn index 9d355b6..cdd4003 100644 --- a/components/component_updater/BUILD.gn +++ b/components/component_updater/BUILD.gn
@@ -34,7 +34,6 @@ "//base", "//build:chromeos_buildflags", "//components/crx_file", - "//components/prefs", "//components/update_client", "//components/version_info", "//third_party/boringssl:boringssl", @@ -80,7 +79,6 @@ "//base", "//base/test:test_support", "//components/crx_file", - "//components/prefs:test_support", "//components/update_client:test_support", "//services/service_manager/public/cpp", "//testing/gmock",
diff --git a/components/component_updater/DEPS b/components/component_updater/DEPS index 68c6559..f755dba 100644 --- a/components/component_updater/DEPS +++ b/components/component_updater/DEPS
@@ -1,6 +1,5 @@ include_rules = [ "+components/crx_file", - "+components/prefs", "+components/update_client", "+components/version_info", "+services/service_manager/public",
diff --git a/components/component_updater/component_installer.cc b/components/component_updater/component_installer.cc index 4c08b85..1b973ce0 100644 --- a/components/component_updater/component_installer.cc +++ b/components/component_updater/component_installer.cc
@@ -4,10 +4,7 @@ #include "components/component_updater/component_installer.h" -#include <cstdint> -#include <string> #include <utility> -#include <vector> #include "base/bind.h" #include "base/callback.h" @@ -421,18 +418,23 @@ current_version_ = registration_info->version; current_fingerprint_ = registration_info->fingerprint; - std::vector<uint8_t> public_key_hash; - installer_policy_->GetHash(&public_key_hash); + update_client::CrxComponent crx; + installer_policy_->GetHash(&crx.pk_hash); + crx.app_id = update_client::GetCrxIdFromPublicKeyHash(crx.pk_hash); + crx.installer = this; + crx.action_handler = action_handler_; + crx.version = current_version_; + crx.fingerprint = current_fingerprint_; + crx.name = installer_policy_->GetName(); + crx.installer_attributes = installer_policy_->GetInstallerAttributes(); + crx.requires_network_encryption = + installer_policy_->RequiresNetworkEncryption(); + crx.crx_format_requirement = + crx_file::VerifierFormat::CRX3_WITH_PUBLISHER_PROOF; + crx.supports_group_policy_enable_component_updates = + installer_policy_->SupportsGroupPolicyEnabledComponentUpdates(); - if (!std::move(register_callback) - .Run(ComponentRegistration( - update_client::GetCrxIdFromPublicKeyHash(public_key_hash), - installer_policy_->GetName(), public_key_hash, current_version_, - current_fingerprint_, - installer_policy_->GetInstallerAttributes(), action_handler_, - this, installer_policy_->RequiresNetworkEncryption(), - installer_policy_ - ->SupportsGroupPolicyEnabledComponentUpdates()))) { + if (!std::move(register_callback).Run(std::move(crx))) { LOG(ERROR) << "Component registration failed for " << installer_policy_->GetName(); if (!callback.is_null())
diff --git a/components/component_updater/component_installer.h b/components/component_updater/component_installer.h index 7dd911a..01582f7 100644 --- a/components/component_updater/component_installer.h +++ b/components/component_updater/component_installer.h
@@ -26,12 +26,10 @@ } // namespace base namespace component_updater { +using RegisterCallback = base::OnceCallback<bool(update_client::CrxComponent)>; -struct ComponentRegistration; class ComponentUpdateService; -using RegisterCallback = base::OnceCallback<bool(const ComponentRegistration&)>; - // Components should use a ComponentInstaller by defining a class that // implements the members of ComponentInstallerPolicy, and then registering a // ComponentInstaller that has been constructed with an instance of that
diff --git a/components/component_updater/component_installer_unittest.cc b/components/component_updater/component_installer_unittest.cc index 48d3de2..15d0760 100644 --- a/components/component_updater/component_installer_unittest.cc +++ b/components/component_updater/component_installer_unittest.cc
@@ -27,7 +27,6 @@ #include "components/component_updater/component_updater_service.h" #include "components/component_updater/component_updater_service_internal.h" #include "components/crx_file/crx_verifier.h" -#include "components/prefs/testing_pref_service.h" #include "components/update_client/component_unpacker.h" #include "components/update_client/crx_update_item.h" #include "components/update_client/patcher.h" @@ -214,10 +213,8 @@ base::ThreadTaskRunnerHandle::Get(); base::RunLoop runloop_; - std::unique_ptr<TestingPrefServiceSimple> pref_ = - std::make_unique<TestingPrefServiceSimple>(); scoped_refptr<TestConfigurator> config_ = - base::MakeRefCounted<TestConfigurator>(pref_.get()); + base::MakeRefCounted<TestConfigurator>(); raw_ptr<MockUpdateScheduler> scheduler_ = nullptr; scoped_refptr<MockUpdateClient> update_client_ = base::MakeRefCounted<MockUpdateClient>(); @@ -233,7 +230,6 @@ .WillByDefault(Invoke(this, &ComponentInstallerTest::Schedule)); component_updater_ = std::make_unique<CrxUpdateService>( config_, std::move(scheduler), update_client_, ""); - RegisterComponentUpdateServicePrefs(pref_->registry()); } ComponentInstallerTest::~ComponentInstallerTest() { @@ -335,6 +331,7 @@ EXPECT_STREQ("fake name", component.name.c_str()); EXPECT_EQ(expected_attrs, component.installer_attributes); EXPECT_TRUE(component.requires_network_encryption); + EXPECT_TRUE(component.supports_group_policy_enable_component_updates); } // Tests that the unpack path is removed when the install succeeded.
diff --git a/components/component_updater/component_updater_service.cc b/components/component_updater/component_updater_service.cc index 33d6bee..e0f8152 100644 --- a/components/component_updater/component_updater_service.cc +++ b/components/component_updater/component_updater_service.cc
@@ -24,15 +24,11 @@ #include "base/timer/timer.h" #include "components/component_updater/component_updater_service_internal.h" #include "components/component_updater/component_updater_utils.h" -#include "components/component_updater/pref_names.h" -#include "components/prefs/pref_registry_simple.h" -#include "components/prefs/pref_service.h" #include "components/update_client/configurator.h" #include "components/update_client/crx_update_item.h" #include "components/update_client/update_client.h" #include "components/update_client/update_client_errors.h" #include "components/update_client/utils.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" using CrxInstaller = update_client::CrxInstaller; @@ -61,38 +57,6 @@ ComponentInfo& ComponentInfo::operator=(ComponentInfo&& other) = default; ComponentInfo::~ComponentInfo() = default; -ComponentRegistration::ComponentRegistration( - const std::string& app_id, - const std::string& name, - std::vector<uint8_t> public_key_hash, - const base::Version& version, - const std::string& fingerprint, - std::map<std::string, std::string> installer_attributes, - scoped_refptr<update_client::ActionHandler> action_handler, - scoped_refptr<update_client::CrxInstaller> installer, - bool requires_network_encryption, - bool supports_group_policy_enable_component_updates) - : app_id(app_id), - name(name), - public_key_hash(public_key_hash), - version(version), - fingerprint(fingerprint), - installer_attributes(installer_attributes), - action_handler(action_handler), - installer(installer), - requires_network_encryption(requires_network_encryption), - supports_group_policy_enable_component_updates( - supports_group_policy_enable_component_updates) {} -ComponentRegistration::ComponentRegistration( - const ComponentRegistration& other) = default; -ComponentRegistration& ComponentRegistration::operator=( - const ComponentRegistration& other) = default; -ComponentRegistration::ComponentRegistration(ComponentRegistration&& other) = - default; -ComponentRegistration& ComponentRegistration::operator=( - ComponentRegistration&& other) = default; -ComponentRegistration::~ComponentRegistration() = default; - CrxUpdateService::CrxUpdateService(scoped_refptr<Configurator> config, std::unique_ptr<UpdateScheduler> scheduler, scoped_refptr<UpdateClient> update_client, @@ -153,8 +117,7 @@ // Adds a component to be checked for upgrades. If the component exists it // it will be replaced. -bool CrxUpdateService::RegisterComponent( - const ComponentRegistration& component) { +bool CrxUpdateService::RegisterComponent(CrxComponent component) { DCHECK(thread_checker_.CalledOnValidThread()); if (component.app_id.empty() || !component.version.IsValid() || !component.installer) { @@ -168,6 +131,9 @@ return true; } + // Replace the component's brand code with the updater's brand code. + component.brand = brand_; + components_.insert(std::make_pair(component.app_id, component)); components_order_.push_back(component.app_id); @@ -175,7 +141,7 @@ // response to events from the UpdateClient instance. CrxUpdateItem item; item.id = component.app_id; - item.component = ToCrxComponent(component); + item.component = component; const auto inserted = component_states_.insert(std::make_pair(component.app_id, item)); DCHECK(inserted.second); @@ -204,15 +170,16 @@ return true; } - return DoUnregisterComponent(id); + return DoUnregisterComponent(it->second); } -bool CrxUpdateService::DoUnregisterComponent(const std::string& id) { +bool CrxUpdateService::DoUnregisterComponent(const CrxComponent& component) { DCHECK(thread_checker_.CalledOnValidThread()); + const auto id = GetCrxComponentID(component); DCHECK(ready_callbacks_.find(id) == ready_callbacks_.end()); - const bool result = components_.find(id)->second.installer->Uninstall(); + const bool result = component.installer->Uninstall(); const auto pos = std::find(components_order_.begin(), components_order_.end(), id); @@ -249,30 +216,7 @@ return *this; } -update_client::CrxComponent CrxUpdateService::ToCrxComponent( - const ComponentRegistration& component) const { - update_client::CrxComponent crx; - crx.pk_hash = component.public_key_hash; - crx.app_id = component.app_id; - crx.installer = component.installer; - crx.action_handler = component.action_handler; - crx.version = component.version; - crx.fingerprint = component.fingerprint; - crx.name = component.name; - crx.installer_attributes = component.installer_attributes; - crx.requires_network_encryption = component.requires_network_encryption; - - crx.brand = brand_; - crx.crx_format_requirement = - crx_file::VerifierFormat::CRX3_WITH_PUBLISHER_PROOF; - crx.updates_enabled = - !component.supports_group_policy_enable_component_updates || - config_->GetPrefService()->GetBoolean(prefs::kComponentUpdatesEnabled); - - return crx; -} - -absl::optional<ComponentRegistration> CrxUpdateService::GetComponent( +absl::optional<CrxComponent> CrxUpdateService::GetComponent( const std::string& id) const { DCHECK(thread_checker_.CalledOnValidThread()); return component_updater::GetComponent(components_, id); @@ -439,13 +383,7 @@ std::vector<absl::optional<CrxComponent>> CrxUpdateService::GetCrxComponents( const std::vector<std::string>& ids) { DCHECK(thread_checker_.CalledOnValidThread()); - std::vector<absl::optional<CrxComponent>> crxs; - for (absl::optional<ComponentRegistration> item : - component_updater::GetCrxComponents(components_, ids)) { - crxs.push_back(item ? absl::optional<CrxComponent>{ToCrxComponent(*item)} - : absl::nullopt); - } - return crxs; + return component_updater::GetCrxComponents(components_, ids); } void CrxUpdateService::OnUpdateComplete(Callback callback, @@ -465,7 +403,7 @@ if (!update_client_->IsUpdating(id)) { const auto component = GetComponent(id); if (component) - DoUnregisterComponent(id); + DoUnregisterComponent(*component); } } @@ -524,10 +462,4 @@ std::move(update_client), brand); } -// Register prefs required by the component update service. -void RegisterComponentUpdateServicePrefs(PrefRegistrySimple* registry) { - // The component updates are enabled by default, if the preference is not set. - registry->RegisterBooleanPref(prefs::kComponentUpdatesEnabled, true); -} - } // namespace component_updater
diff --git a/components/component_updater/component_updater_service.h b/components/component_updater/component_updater_service.h index 3b565f1..622a95f1 100644 --- a/components/component_updater/component_updater_service.h +++ b/components/component_updater/component_updater_service.h
@@ -7,7 +7,6 @@ #include <stdint.h> -#include <map> #include <memory> #include <string> #include <vector> @@ -68,44 +67,14 @@ base::Version version; }; -struct ComponentRegistration { - ComponentRegistration( - const std::string& app_id, - const std::string& name, - std::vector<uint8_t> public_key_hash, - const base::Version& version, - const std::string& fingerprint, - std::map<std::string, std::string> installer_attributes, - scoped_refptr<update_client::ActionHandler> action_handler, - scoped_refptr<update_client::CrxInstaller> installer, - bool requires_network_encryption, - bool supports_group_policy_enable_component_updates); - ComponentRegistration(const ComponentRegistration& other); - ComponentRegistration& operator=(const ComponentRegistration& other); - ComponentRegistration(ComponentRegistration&& other); - ComponentRegistration& operator=(ComponentRegistration&& other); - ~ComponentRegistration(); - - std::string app_id; - std::string name; - std::vector<uint8_t> public_key_hash; - base::Version version; - std::string fingerprint; - std::map<std::string, std::string> installer_attributes; - scoped_refptr<update_client::ActionHandler> action_handler; - scoped_refptr<update_client::CrxInstaller> installer; - bool requires_network_encryption; - bool supports_group_policy_enable_component_updates; -}; - -// The component update service is in charge of installing or upgrading select -// parts of chrome. Each part is called a component and managed by instances of -// ComponentRegistration registered using RegisterComponent(). On the -// server, each component is packaged as a CRX which is the same format used to -// package extensions. To the update service each component is identified by -// its public key hash (CrxComponent::pk_hash). If there is an update available -// and its version is bigger than (CrxComponent::version), it will be -// downloaded, verified and unpacked. Then component-specific installer +// The component update service is in charge of installing or upgrading +// select parts of chrome. Each part is called a component and managed by +// instances of CrxComponent registered using RegisterComponent(). On the +// server, each component is packaged as a CRX which is the same format used +// to package extensions. To the update service each component is identified +// by its public key hash (CrxComponent::pk_hash). If there is an update +// available and its version is bigger than (CrxComponent::version), it will +// be downloaded, verified and unpacked. Then component-specific installer // ComponentInstaller::Install (of CrxComponent::installer) will be called. // // During the normal operation of the component updater some specific @@ -126,7 +95,7 @@ virtual void RemoveObserver(Observer* observer) = 0; // Add component to be checked for updates. - virtual bool RegisterComponent(const ComponentRegistration& component) = 0; + virtual bool RegisterComponent(CrxComponent component) = 0; // Unregisters the component with the given ID. This means that the component // is not going to be included in future update checks. If a download or @@ -221,9 +190,6 @@ std::unique_ptr<UpdateScheduler> scheduler, const std::string& brand); -// Register prefs required by the component update service. -void RegisterComponentUpdateServicePrefs(PrefRegistrySimple* registry); - } // namespace component_updater #endif // COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_
diff --git a/components/component_updater/component_updater_service_internal.h b/components/component_updater/component_updater_service_internal.h index 8abf650..2d7dffe 100644 --- a/components/component_updater/component_updater_service_internal.h +++ b/components/component_updater/component_updater_service_internal.h
@@ -50,7 +50,7 @@ // Overrides for ComponentUpdateService. void AddObserver(Observer* observer) override; void RemoveObserver(Observer* observer) override; - bool RegisterComponent(const ComponentRegistration& component) override; + bool RegisterComponent(CrxComponent component) override; bool UnregisterComponent(const std::string& id) override; std::vector<std::string> GetComponentIDs() const override; std::vector<ComponentInfo> GetComponents() const override; @@ -79,12 +79,9 @@ Callback callback); bool OnDemandUpdateWithCooldown(const std::string& id); - bool DoUnregisterComponent(const std::string& id); + bool DoUnregisterComponent(const CrxComponent& component); - CrxComponent ToCrxComponent(const ComponentRegistration& component) const; - - absl::optional<ComponentRegistration> GetComponent( - const std::string& id) const; + absl::optional<CrxComponent> GetComponent(const std::string& id) const; const CrxUpdateItem* GetComponentState(const std::string& id) const; @@ -104,7 +101,7 @@ std::string brand_; // A collection of every registered component. - using Components = base::flat_map<std::string, ComponentRegistration>; + using Components = base::flat_map<std::string, CrxComponent>; Components components_; // Maintains the order in which components have been registered. The position
diff --git a/components/component_updater/component_updater_service_unittest.cc b/components/component_updater/component_updater_service_unittest.cc index c400126..509f483a 100644 --- a/components/component_updater/component_updater_service_unittest.cc +++ b/components/component_updater/component_updater_service_unittest.cc
@@ -4,7 +4,6 @@ #include "components/component_updater/component_updater_service.h" -#include <cstdint> #include <memory> #include <string> #include <utility> @@ -24,7 +23,6 @@ #include "base/threading/thread_task_runner_handle.h" #include "base/values.h" #include "components/component_updater/component_updater_service_internal.h" -#include "components/prefs/testing_pref_service.h" #include "components/update_client/test_configurator.h" #include "components/update_client/test_installer.h" #include "components/update_client/update_client.h" @@ -179,10 +177,8 @@ base::test::TaskEnvironment task_environment_; base::RunLoop runloop_; - std::unique_ptr<TestingPrefServiceSimple> pref_ = - std::make_unique<TestingPrefServiceSimple>(); scoped_refptr<TestConfigurator> config_ = - base::MakeRefCounted<TestConfigurator>(pref_.get()); + base::MakeRefCounted<TestConfigurator>(); raw_ptr<MockUpdateScheduler> scheduler_; scoped_refptr<MockUpdateClient> update_client_ = base::MakeRefCounted<MockUpdateClient>(); @@ -231,7 +227,6 @@ .WillByDefault(Invoke(this, &ComponentUpdaterTest::Schedule)); component_updater_ = std::make_unique<CrxUpdateService>( config_, std::move(scheduler), update_client_, ""); - RegisterComponentUpdateServicePrefs(pref_->registry()); } ComponentUpdaterTest::~ComponentUpdaterTest() { @@ -302,14 +297,17 @@ ids.push_back(id1); ids.push_back(id2); - std::vector<uint8_t> hash; - hash.assign(std::begin(abag_hash), std::end(abag_hash)); - ComponentRegistration component1(id1, {}, hash, base::Version("1.0"), {}, {}, - nullptr, installer, false, true); + CrxComponent crx_component1; + crx_component1.app_id = id1; + crx_component1.pk_hash.assign(abag_hash, abag_hash + base::size(abag_hash)); + crx_component1.version = base::Version("1.0"); + crx_component1.installer = installer; - hash.assign(std::begin(jebg_hash), std::end(jebg_hash)); - ComponentRegistration component2(id2, {}, hash, base::Version("0.9"), {}, {}, - nullptr, installer, false, true); + CrxComponent crx_component2; + crx_component2.app_id = id2; + crx_component2.pk_hash.assign(jebg_hash, jebg_hash + base::size(jebg_hash)); + crx_component2.version = base::Version("0.9"); + crx_component2.installer = installer; // Quit after two update checks have fired. LoopHandler loop_handler(2, quit_closure()); @@ -321,8 +319,8 @@ EXPECT_CALL(scheduler(), Schedule(_, _, _, _)).Times(1); EXPECT_CALL(scheduler(), Stop()).Times(1); - EXPECT_TRUE(component_updater().RegisterComponent(component1)); - EXPECT_TRUE(component_updater().RegisterComponent(component2)); + EXPECT_TRUE(component_updater().RegisterComponent(crx_component1)); + EXPECT_TRUE(component_updater().RegisterComponent(crx_component2)); RunThreads(); EXPECT_TRUE(component_updater().UnregisterComponent(id1)); @@ -365,19 +363,21 @@ { using update_client::jebg_hash; - std::vector<uint8_t> hash; - hash.assign(std::begin(jebg_hash), std::end(jebg_hash)); - EXPECT_TRUE(cus.RegisterComponent(ComponentRegistration( - "jebgalgnebhfojomionfpkfelancnnkf", {}, hash, base::Version("0.9"), {}, - {}, nullptr, base::MakeRefCounted<MockInstaller>(), false, true))); + CrxComponent crx_component; + crx_component.app_id = "jebgalgnebhfojomionfpkfelancnnkf"; + crx_component.pk_hash.assign(jebg_hash, jebg_hash + base::size(jebg_hash)); + crx_component.version = base::Version("0.9"); + crx_component.installer = base::MakeRefCounted<MockInstaller>(); + EXPECT_TRUE(cus.RegisterComponent(crx_component)); } { using update_client::abag_hash; - std::vector<uint8_t> hash; - hash.assign(std::begin(abag_hash), std::end(abag_hash)); - EXPECT_TRUE(cus.RegisterComponent(ComponentRegistration( - "abagagagagagagagagagagagagagagag", {}, hash, base::Version("0.9"), {}, - {}, nullptr, base::MakeRefCounted<MockInstaller>(), false, true))); + CrxComponent crx_component; + crx_component.app_id = "abagagagagagagagagagagagagagagag"; + crx_component.pk_hash.assign(abag_hash, abag_hash + base::size(abag_hash)); + crx_component.version = base::Version("0.9"); + crx_component.installer = base::MakeRefCounted<MockInstaller>(); + EXPECT_TRUE(cus.RegisterComponent(crx_component)); } OnDemandTester ondemand_tester; @@ -403,9 +403,15 @@ // Don't run periodic update task. ON_CALL(scheduler(), Schedule(_, _, _, _)).WillByDefault(Return()); + scoped_refptr<MockInstaller> installer = + base::MakeRefCounted<MockInstaller>(); + using update_client::jebg_hash; - std::vector<uint8_t> hash; - hash.assign(std::begin(jebg_hash), std::end(jebg_hash)); + CrxComponent crx_component; + crx_component.app_id = "jebgalgnebhfojomionfpkfelancnnkf"; + crx_component.pk_hash.assign(jebg_hash, jebg_hash + base::size(jebg_hash)); + crx_component.version = base::Version("0.9"); + crx_component.installer = installer; LoopHandler loop_handler(1, quit_closure()); EXPECT_CALL(update_client(), Install(_, _, _, _)) @@ -414,9 +420,7 @@ EXPECT_CALL(scheduler(), Schedule(_, _, _, _)).Times(1); EXPECT_CALL(scheduler(), Stop()).Times(1); - EXPECT_TRUE(component_updater().RegisterComponent(ComponentRegistration( - "jebgalgnebhfojomionfpkfelancnnkf", {}, hash, base::Version("0.9"), {}, - {}, nullptr, base::MakeRefCounted<MockInstaller>(), false, true))); + EXPECT_TRUE(component_updater().RegisterComponent(crx_component)); component_updater().MaybeThrottle("jebgalgnebhfojomionfpkfelancnnkf", base::DoNothing());
diff --git a/components/component_updater/component_updater_utils.cc b/components/component_updater/component_updater_utils.cc index 90f74c8d..d314a26 100644 --- a/components/component_updater/component_updater_utils.cc +++ b/components/component_updater/component_updater_utils.cc
@@ -8,13 +8,13 @@ #include <vector> #include "base/containers/flat_map.h" -#include "components/component_updater/component_updater_service.h" +#include "components/update_client/update_client.h" #include "third_party/abseil-cpp/absl/types/optional.h" namespace component_updater { -absl::optional<ComponentRegistration> GetComponent( - const base::flat_map<std::string, ComponentRegistration>& components, +absl::optional<update_client::CrxComponent> GetComponent( + const base::flat_map<std::string, update_client::CrxComponent>& components, const std::string& id) { const auto it = components.find(id); if (it != components.end()) @@ -22,11 +22,11 @@ return absl::nullopt; } -std::vector<absl::optional<ComponentRegistration>> GetCrxComponents( - const base::flat_map<std::string, ComponentRegistration>& +std::vector<absl::optional<update_client::CrxComponent>> GetCrxComponents( + const base::flat_map<std::string, update_client::CrxComponent>& registered_components, const std::vector<std::string>& ids) { - std::vector<absl::optional<ComponentRegistration>> components; + std::vector<absl::optional<update_client::CrxComponent>> components; for (const auto& id : ids) components.push_back(GetComponent(registered_components, id)); return components;
diff --git a/components/component_updater/component_updater_utils.h b/components/component_updater/component_updater_utils.h index 96e7ff5..6819d75 100644 --- a/components/component_updater/component_updater_utils.h +++ b/components/component_updater/component_updater_utils.h
@@ -11,15 +11,18 @@ #include "base/containers/flat_map.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace component_updater { -struct ComponentRegistration; +namespace update_client { +struct CrxComponent; +} // namespace update_client -absl::optional<ComponentRegistration> GetComponent( - const base::flat_map<std::string, ComponentRegistration>& components, +namespace component_updater { + +absl::optional<update_client::CrxComponent> GetComponent( + const base::flat_map<std::string, update_client::CrxComponent>& components, const std::string& id); -std::vector<absl::optional<ComponentRegistration>> GetCrxComponents( - const base::flat_map<std::string, ComponentRegistration>& +std::vector<absl::optional<update_client::CrxComponent>> GetCrxComponents( + const base::flat_map<std::string, update_client::CrxComponent>& registered_components, const std::vector<std::string>& ids);
diff --git a/components/component_updater/mock_component_updater_service.h b/components/component_updater/mock_component_updater_service.h index 7786f98..5f6b7e5a 100644 --- a/components/component_updater/mock_component_updater_service.h +++ b/components/component_updater/mock_component_updater_service.h
@@ -37,7 +37,7 @@ void(Observer* observer)); MOCK_METHOD1(RemoveObserver, void(Observer* observer)); - MOCK_METHOD1(RegisterComponent, bool(const ComponentRegistration& component)); + MOCK_METHOD1(RegisterComponent, bool(CrxComponent component)); MOCK_METHOD1(UnregisterComponent, bool(const std::string& id)); MOCK_CONST_METHOD0(GetComponentIDs,
diff --git a/components/component_updater/pref_names.cc b/components/component_updater/pref_names.cc index e8162d0..10916fa 100644 --- a/components/component_updater/pref_names.cc +++ b/components/component_updater/pref_names.cc
@@ -7,10 +7,6 @@ namespace prefs { -// Policy that indicates the state of updates for the binary components. -const char kComponentUpdatesEnabled[] = - "component_updates.component_updates_enabled"; - // String that represents the recovery component last downloaded version. This // takes the usual 'a.b.c.d' notation. const char kRecoveryComponentVersion[] = "recovery_component.version"; @@ -46,7 +42,6 @@ // have been prompted with this seed before won't be prompted again until a new // seed comes in. const char kSwReporterPromptSeed[] = "software_reporter.prompt_seed"; - #endif } // namespace prefs
diff --git a/components/component_updater/pref_names.h b/components/component_updater/pref_names.h index 1d645a3f..5893a880 100644 --- a/components/component_updater/pref_names.h +++ b/components/component_updater/pref_names.h
@@ -9,8 +9,6 @@ namespace prefs { -extern const char kComponentUpdatesEnabled[]; - extern const char kRecoveryComponentVersion[]; extern const char kRecoveryComponentUnpackPath[];
diff --git a/components/exo/data_device.cc b/components/exo/data_device.cc index 5010423..c770efbf 100644 --- a/components/exo/data_device.cc +++ b/components/exo/data_device.cc
@@ -134,7 +134,8 @@ if (focused_surface_) { // The ExtendedDragSource instance can be null for tests. auto* extended_drag_source = ExtendedDragSource::Get(); - bool is_extended_drag_source_active = extended_drag_source->IsActive(); + bool is_extended_drag_source_active = + extended_drag_source && extended_drag_source->IsActive(); prevent_motion_drag_events = is_extended_drag_source_active &&
diff --git a/components/payments/content/android_app_communication_chrome_os.cc b/components/payments/content/android_app_communication_chrome_os.cc index d57ca6e..9c4b066 100644 --- a/components/payments/content/android_app_communication_chrome_os.cc +++ b/components/payments/content/android_app_communication_chrome_os.cc
@@ -6,10 +6,10 @@ #include <utility> +#include "ash/components/arc/mojom/payment_app.mojom.h" #include "ash/components/arc/pay/arc_payment_app_bridge.h" #include "ash/public/cpp/external_arc/overlay/arc_overlay_manager.h" #include "base/callback_helpers.h" -#include "components/arc/mojom/payment_app.mojom.h" #include "components/payments/core/android_app_description.h" #include "components/payments/core/chrome_os_error_strings.h" #include "components/payments/core/method_strings.h"
diff --git a/components/payments/content/android_app_communication_test_support_chrome_os.cc b/components/payments/content/android_app_communication_test_support_chrome_os.cc index 74b6c9b3..1ff4a25 100644 --- a/components/payments/content/android_app_communication_test_support_chrome_os.cc +++ b/components/payments/content/android_app_communication_test_support_chrome_os.cc
@@ -6,10 +6,10 @@ #include <utility> +#include "ash/components/arc/mojom/payment_app.mojom.h" #include "ash/components/arc/pay/arc_payment_app_bridge.h" #include "ash/components/arc/test/arc_payment_app_bridge_test_support.h" #include "ash/public/cpp/external_arc/overlay/test/test_arc_overlay_manager.h" -#include "components/arc/mojom/payment_app.mojom.h" #include "components/payments/core/method_strings.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/sessions/core/live_tab_context.h b/components/sessions/core/live_tab_context.h index a86f0059..fff5e758 100644 --- a/components/sessions/core/live_tab_context.h +++ b/components/sessions/core/live_tab_context.h
@@ -18,10 +18,6 @@ #include "third_party/skia/include/core/SkColor.h" #include "ui/base/ui_base_types.h" -namespace base { -class Value; -} - namespace gfx { class Rect; } @@ -46,9 +42,9 @@ virtual std::string GetUserTitle() const = 0; virtual LiveTab* GetLiveTabAt(int index) const = 0; virtual LiveTab* GetActiveLiveTab() const = 0; - virtual std::map<std::string, base::Value> GetExtraDataForTab( + virtual std::map<std::string, std::string> GetExtraDataForTab( int index) const = 0; - virtual std::map<std::string, base::Value> GetExtraDataForWindow() const = 0; + virtual std::map<std::string, std::string> GetExtraDataForWindow() const = 0; virtual absl::optional<tab_groups::TabGroupId> GetTabGroupForTab( int index) const = 0; // Should not be called for |group| unless GetTabGroupForTab() returned @@ -81,7 +77,7 @@ bool pin, const PlatformSpecificTabData* tab_platform_data, const sessions::SerializedUserAgentOverride& user_agent_override, - const std::map<std::string, base::Value>& extra_data, + const std::map<std::string, std::string>& extra_data, const SessionID* tab_id) = 0; // Note: |tab_platform_data| may be null (e.g., if restoring from last session @@ -94,7 +90,7 @@ const std::string& extension_app_id, const PlatformSpecificTabData* tab_platform_data, const sessions::SerializedUserAgentOverride& user_agent_override, - const std::map<std::string, base::Value>& extra_data) = 0; + const std::map<std::string, std::string>& extra_data) = 0; virtual void CloseTab() = 0; protected:
diff --git a/components/sessions/core/tab_restore_service.h b/components/sessions/core/tab_restore_service.h index 7fd1b75..89f1a706 100644 --- a/components/sessions/core/tab_restore_service.h +++ b/components/sessions/core/tab_restore_service.h
@@ -13,7 +13,6 @@ #include "base/memory/ref_counted.h" #include "base/time/time.h" #include "base/token.h" -#include "base/values.h" #include "components/keyed_service/core/keyed_service.h" #include "components/sessions/core/live_tab_context.h" #include "components/sessions/core/serialized_navigation_entry.h" @@ -82,7 +81,7 @@ base::Time timestamp; // Used for storing arbitrary key/value pairs. - std::map<std::string, base::Value> extra_data; + std::map<std::string, std::string> extra_data; // Estimates memory usage. By default returns 0. virtual size_t EstimateMemoryUsage() const;
diff --git a/components/sessions/core/tab_restore_service_client.h b/components/sessions/core/tab_restore_service_client.h index d415da7..a6480f21 100644 --- a/components/sessions/core/tab_restore_service_client.h +++ b/components/sessions/core/tab_restore_service_client.h
@@ -24,10 +24,6 @@ class TabGroupId; } -namespace base { -class Value; -} - namespace sessions { class LiveTab; @@ -55,7 +51,7 @@ ui::WindowShowState show_state, const std::string& workspace, const std::string& user_title, - const std::map<std::string, base::Value>& extra_data) = 0; + const std::map<std::string, std::string>& extra_data) = 0; // Returns the LiveTabContext instance that is associated with // |tab|, or null if there is no such instance.
diff --git a/components/sessions/core/tab_restore_service_helper.cc b/components/sessions/core/tab_restore_service_helper.cc index 913516c..a136bb6 100644 --- a/components/sessions/core/tab_restore_service_helper.cc +++ b/components/sessions/core/tab_restore_service_helper.cc
@@ -839,7 +839,7 @@ } else { context = client_->CreateLiveTabContext( std::string(), gfx::Rect(), ui::SHOW_STATE_NORMAL, std::string(), - std::string(), std::map<std::string, base::Value>()); + std::string(), std::map<std::string, std::string>()); if (tab.browser_id) UpdateTabBrowserIDs(tab.browser_id, context->GetSessionID()); }
diff --git a/components/startup_metric_utils/browser/startup_metric_utils.cc b/components/startup_metric_utils/browser/startup_metric_utils.cc index b2b9667..d1e155f 100644 --- a/components/startup_metric_utils/browser/startup_metric_utils.cc +++ b/components/startup_metric_utils/browser/startup_metric_utils.cc
@@ -11,10 +11,12 @@ #include <vector> #include "base/check_op.h" -#include "base/lazy_instance.h" +#include "base/containers/flat_set.h" +#include "base/dcheck_is_on.h" #include "base/memory/memory_pressure_listener.h" #include "base/metrics/histogram.h" #include "base/metrics/histogram_functions.h" +#include "base/no_destructor.h" #include "base/notreached.h" #include "base/process/process.h" #include "base/strings/strcat.h" @@ -386,8 +388,35 @@ return !WasMainWindowStartupInterrupted(); } +#if DCHECK_IS_ON() +base::flat_set<int>& GetSessionLog() { + static base::NoDestructor<base::flat_set<int>> session_log; + return *session_log; +} +#endif // DCHECK_IS_ON() + +// DCHECKs that this is the first time |method_id| is passed to this assertion +// in this session (a session is typically process-lifetime but this can be +// reset in tests via ResetSessionForTesting()). Callers should use __LINE__ as +// a unique id in this file. +void AssertFirstCallInSession(int method_id) { +#if DCHECK_IS_ON() + DCHECK(GetSessionLog().insert(method_id).second); +#endif // DCHECK_IS_ON() +} + } // namespace +void ResetSessionForTesting() { +#if DCHECK_IS_ON() + GetSessionLog().clear(); +#endif // DCHECK_IS_ON() + // Reset global ticks that will be recorded multiple times when multiple + // tests run in the same process. + g_message_loop_start_ticks = base::TimeTicks(); + g_browser_window_display_ticks = base::TimeTicks(); +} + bool WasMainWindowStartupInterrupted() { return g_main_window_startup_interrupted; } @@ -480,12 +509,7 @@ void RecordBrowserMainLoopFirstIdle(base::TimeTicks ticks) { DCHECK(!g_application_start_ticks.is_null()); - -#if DCHECK_IS_ON() - static bool is_first_call = true; - DCHECK(is_first_call); - is_first_call = false; -#endif // DCHECK_IS_ON() + AssertFirstCallInSession(__LINE__); if (!ShouldLogStartupHistogram()) return; @@ -515,12 +539,7 @@ base::TimeTicks now, base::TimeTicks render_process_host_init_time) { DCHECK(!g_application_start_ticks.is_null()); - -#if DCHECK_IS_ON() - static bool is_first_call = true; - DCHECK(is_first_call); - is_first_call = false; -#endif // DCHECK_IS_ON() + AssertFirstCallInSession(__LINE__); if (!ShouldLogStartupHistogram()) return; @@ -542,12 +561,7 @@ void RecordFirstWebContentsMainNavigationStart(base::TimeTicks ticks) { DCHECK(!g_application_start_ticks.is_null()); - -#if DCHECK_IS_ON() - static bool is_first_call = true; - DCHECK(is_first_call); - is_first_call = false; -#endif // DCHECK_IS_ON() + AssertFirstCallInSession(__LINE__); if (!ShouldLogStartupHistogram()) return; @@ -560,12 +574,7 @@ void RecordFirstWebContentsMainNavigationFinished(base::TimeTicks ticks) { DCHECK(!g_application_start_ticks.is_null()); - -#if DCHECK_IS_ON() - static bool is_first_call = true; - DCHECK(is_first_call); - is_first_call = false; -#endif // DCHECK_IS_ON() + AssertFirstCallInSession(__LINE__); if (!ShouldLogStartupHistogram()) return;
diff --git a/components/startup_metric_utils/browser/startup_metric_utils.h b/components/startup_metric_utils/browser/startup_metric_utils.h index f4c3369..7e26f9a99 100644 --- a/components/startup_metric_utils/browser/startup_metric_utils.h +++ b/components/startup_metric_utils/browser/startup_metric_utils.h
@@ -16,6 +16,10 @@ namespace startup_metric_utils { +// Resets this process's session to allow recording one-time-only metrics again +// when a process is reused for multiple tests. +void ResetSessionForTesting(); + // Returns true when browser UI was not launched normally: some other UI was // shown first or browser was launched in background mode. bool WasMainWindowStartupInterrupted();
diff --git a/components/update_client/component.cc b/components/update_client/component.cc index eb3a7c9..ead51985e 100644 --- a/components/update_client/component.cc +++ b/components/update_client/component.cc
@@ -681,7 +681,9 @@ component.is_update_available_ = true; component.NotifyObservers(Events::COMPONENT_UPDATE_FOUND); - if (!component.crx_component()->updates_enabled) { + if (component.crx_component() + ->supports_group_policy_enable_component_updates && + !component.update_context_.enabled_component_updates) { component.error_category_ = ErrorCategory::kService; component.error_code_ = static_cast<int>(ServiceError::UPDATE_DISABLED); component.extra_code1_ = 0;
diff --git a/components/update_client/configurator.h b/components/update_client/configurator.h index 01af489..5bc9b2d 100644 --- a/components/update_client/configurator.h +++ b/components/update_client/configurator.h
@@ -99,6 +99,12 @@ // True means that this client can handle delta updates. virtual bool EnabledDeltas() const = 0; + // True if component updates are enabled. Updates for all components are + // enabled by default. This method allows enabling or disabling + // updates for certain components such as the plugins. Updates for some + // components are always enabled and can't be disabled programatically. + virtual bool EnabledComponentUpdates() const = 0; + // True means that the background downloader can be used for downloading // non on-demand components. virtual bool EnabledBackgroundDownloader() const = 0;
diff --git a/components/update_client/test_configurator.cc b/components/update_client/test_configurator.cc index 7c7ee09..b2ce3c9 100644 --- a/components/update_client/test_configurator.cc +++ b/components/update_client/test_configurator.cc
@@ -37,6 +37,7 @@ TestConfigurator::TestConfigurator(PrefService* pref_service) : enabled_cup_signing_(false), + enabled_component_updates_(true), pref_service_(pref_service), unzip_factory_(base::MakeRefCounted<update_client::UnzipChromiumFactory>( base::BindRepeating(&unzip::LaunchInProcessUnzipper))), @@ -134,6 +135,10 @@ return true; } +bool TestConfigurator::EnabledComponentUpdates() const { + return enabled_component_updates_; +} + bool TestConfigurator::EnabledBackgroundDownloader() const { return false; } @@ -154,6 +159,11 @@ enabled_cup_signing_ = enabled_cup_signing; } +void TestConfigurator::SetEnabledComponentUpdates( + bool enabled_component_updates) { + enabled_component_updates_ = enabled_component_updates; +} + void TestConfigurator::SetDownloadPreference( const std::string& download_preference) { download_preference_ = download_preference;
diff --git a/components/update_client/test_configurator.h b/components/update_client/test_configurator.h index 7f4b1b0f..c6654137 100644 --- a/components/update_client/test_configurator.h +++ b/components/update_client/test_configurator.h
@@ -93,6 +93,7 @@ scoped_refptr<UnzipperFactory> GetUnzipperFactory() override; scoped_refptr<PatcherFactory> GetPatcherFactory() override; bool EnabledDeltas() const override; + bool EnabledComponentUpdates() const override; bool EnabledBackgroundDownloader() const override; bool EnabledCupSigning() const override; PrefService* GetPrefService() const override; @@ -105,6 +106,7 @@ void SetInitialDelay(double seconds); void SetDownloadPreference(const std::string& download_preference); void SetEnabledCupSigning(bool use_cup_signing); + void SetEnabledComponentUpdates(bool enabled_component_updates); void SetUpdateCheckUrl(const GURL& url); void SetPingUrl(const GURL& url); void SetCrxDownloaderFactory( @@ -124,6 +126,7 @@ int ondemand_time_{0}; std::string download_preference_; bool enabled_cup_signing_; + bool enabled_component_updates_; raw_ptr<PrefService> pref_service_; // Not owned by this class. GURL update_check_url_; GURL ping_url_;
diff --git a/components/update_client/update_checker.cc b/components/update_client/update_checker.cc index 239e055..157cab5 100644 --- a/components/update_client/update_checker.cc +++ b/components/update_client/update_checker.cc
@@ -67,6 +67,7 @@ const std::vector<std::string>& ids_checked, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override; private: @@ -75,6 +76,7 @@ const std::string& session_id, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, const std::set<std::string>& active_ids); void OnRequestSenderComplete(int error, const std::string& response, @@ -108,6 +110,7 @@ const std::vector<std::string>& ids_checked, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) { DCHECK(thread_checker_.CalledOnValidThread()); @@ -126,7 +129,8 @@ }, base::BindOnce(&UpdateCheckerImpl::CheckForUpdatesHelper, base::Unretained(this), session_id, - std::cref(components), additional_attributes), + std::cref(components), additional_attributes, + enabled_component_updates), base::Unretained(metadata_), ids_checked)); } @@ -148,6 +152,7 @@ const std::string& session_id, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, const std::set<std::string>& active_ids) { DCHECK(thread_checker_.CalledOnValidThread()); @@ -180,6 +185,10 @@ else if (component->is_foreground()) install_source = "ondemand"; + const bool is_update_disabled = + crx_component->supports_group_policy_enable_component_updates && + !enabled_component_updates; + apps.push_back(MakeProtocolApp( app_id, crx_component->version, crx_component->ap, crx_component->brand, install_source, crx_component->install_location, @@ -187,7 +196,7 @@ metadata_->GetCohort(app_id), metadata_->GetCohortName(app_id), metadata_->GetCohortHint(app_id), crx_component->channel, crx_component->disabled_reasons, - MakeProtocolUpdateCheck(!crx_component->updates_enabled, + MakeProtocolUpdateCheck(is_update_disabled, crx_component->target_version_prefix, crx_component->rollback_allowed), MakeProtocolPing(app_id, metadata_,
diff --git a/components/update_client/update_checker.h b/components/update_client/update_checker.h index 29df873..356b607 100644 --- a/components/update_client/update_checker.h +++ b/components/update_client/update_checker.h
@@ -50,6 +50,7 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) = 0; static std::unique_ptr<UpdateChecker> Create(
diff --git a/components/update_client/update_checker_unittest.cc b/components/update_client/update_checker_unittest.cc index a59df8e..be537c1 100644 --- a/components/update_client/update_checker_unittest.cc +++ b/components/update_client/update_checker_unittest.cc
@@ -220,7 +220,7 @@ update_checker_->CheckForUpdates( update_context_->session_id, {kUpdateItemId}, components, - {{"extra", "params"}, {"testrequest", "1"}}, + {{"extra", "params"}, {"testrequest", "1"}}, true, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -337,7 +337,7 @@ component->crx_component_->installer_attributes["ap"] = std::string(257, 'a'); update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, true, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); @@ -374,7 +374,7 @@ components[kUpdateItemId] = MakeComponent("TOOLONG"); update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, true, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); @@ -411,7 +411,7 @@ components[kUpdateItemId] = MakeComponent(); update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, true, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -440,7 +440,7 @@ update_checker_->CheckForUpdates( update_context_->session_id, {kUpdateItemId}, components, - {{"extra", "params"}}, + {{"extra", "params"}}, true, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -468,7 +468,7 @@ components[kUpdateItemId] = MakeComponent("TEST"); update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, true, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); @@ -518,7 +518,7 @@ component->crx_component_->requires_network_encryption = true; update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, true, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -546,7 +546,7 @@ activity_data_service_->SetDaysSinceLastRollCall(kUpdateItemId, 5); update_checker_->CheckForUpdates( update_context_->session_id, {kUpdateItemId}, components, - {{"extra", "params"}}, + {{"extra", "params"}}, true, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -554,7 +554,7 @@ update_checker_ = UpdateChecker::Create(config_, metadata_.get()); update_checker_->CheckForUpdates( update_context_->session_id, {kUpdateItemId}, components, - {{"extra", "params"}}, + {{"extra", "params"}}, true, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -595,7 +595,7 @@ activity_data_service_->SetDaysSinceLastActive(kUpdateItemId, 10); update_checker_->CheckForUpdates( update_context_->session_id, {kUpdateItemId}, components, - {{"extra", "params"}}, + {{"extra", "params"}}, true, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -607,7 +607,7 @@ update_checker_ = UpdateChecker::Create(config_, metadata_.get()); update_checker_->CheckForUpdates( update_context_->session_id, {kUpdateItemId}, components, - {{"extra", "params"}}, + {{"extra", "params"}}, true, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -618,7 +618,7 @@ update_checker_ = UpdateChecker::Create(config_, metadata_.get()); update_checker_->CheckForUpdates( update_context_->session_id, {kUpdateItemId}, components, - {{"extra", "params"}}, + {{"extra", "params"}}, true, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -674,7 +674,7 @@ std::make_unique<PartialMatch>("updatecheck"), test_file("updatecheck_reply_1.json"))); update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, false, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -696,7 +696,7 @@ crx_component->install_location = "policy"; component->set_crx_component(*crx_component); update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, false, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -719,7 +719,7 @@ std::make_unique<PartialMatch>("updatecheck"), test_file("updatecheck_reply_1.json"))); update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, false, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -739,7 +739,7 @@ crx_component->install_location = "external"; component->set_crx_component(*crx_component); update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, false, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -768,7 +768,7 @@ std::make_unique<PartialMatch>("updatecheck"), test_file("updatecheck_reply_1.json"))); update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, false, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -789,7 +789,7 @@ std::make_unique<PartialMatch>("updatecheck"), test_file("updatecheck_reply_1.json"))); update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, false, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -810,7 +810,7 @@ std::make_unique<PartialMatch>("updatecheck"), test_file("updatecheck_reply_1.json"))); update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, false, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -832,7 +832,7 @@ std::make_unique<PartialMatch>("updatecheck"), test_file("updatecheck_reply_1.json"))); update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, false, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -855,7 +855,7 @@ std::make_unique<PartialMatch>("updatecheck"), test_file("updatecheck_reply_1.json"))); update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, false, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -880,7 +880,7 @@ std::make_unique<PartialMatch>("updatecheck"), test_file("updatecheck_reply_1.json"))); update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, false, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -911,16 +911,18 @@ update_context_->is_foreground = false; { // Tests the scenario where: - // * the component updates are enabled. + // * the component does not support group policies. + // * the component updates are disabled. // Expects the group policy to be ignored and the update check to not // include the "updatedisabled" attribute. + EXPECT_FALSE(crx_component->supports_group_policy_enable_component_updates); auto post_interceptor = std::make_unique<URLLoaderPostInterceptor>( config_->test_url_loader_factory()); EXPECT_TRUE(post_interceptor->ExpectRequest( std::make_unique<PartialMatch>("updatecheck"), test_file("updatecheck_reply_1.json"))); update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, false, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -935,9 +937,10 @@ } { // Tests the scenario where: + // * the component supports group policies. // * the component updates are disabled. // Expects the update check to include the "updatedisabled" attribute. - crx_component->updates_enabled = false; + crx_component->supports_group_policy_enable_component_updates = true; component->set_crx_component(*crx_component); auto post_interceptor = std::make_unique<URLLoaderPostInterceptor>( config_->test_url_loader_factory()); @@ -945,7 +948,7 @@ std::make_unique<PartialMatch>("updatecheck"), test_file("updatecheck_reply_1.json"))); update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, false, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -958,6 +961,58 @@ EXPECT_EQ(true, app.FindKey("enabled")->GetBool()); EXPECT_TRUE(app.FindPath({"updatecheck", "updatedisabled"})->GetBool()); } + { + // Tests the scenario where: + // * the component does not support group policies. + // * the component updates are enabled. + // Expects the update check to not include the "updatedisabled" attribute. + crx_component->supports_group_policy_enable_component_updates = false; + component->set_crx_component(*crx_component); + auto post_interceptor = std::make_unique<URLLoaderPostInterceptor>( + config_->test_url_loader_factory()); + EXPECT_TRUE(post_interceptor->ExpectRequest( + std::make_unique<PartialMatch>("updatecheck"), + test_file("updatecheck_reply_1.json"))); + update_checker_->CheckForUpdates( + update_context_->session_id, {kUpdateItemId}, components, {}, true, + base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, + base::Unretained(this))); + RunThreads(); + const auto& request = post_interceptor->GetRequestBody(0); + const auto root = base::JSONReader::Read(request); + ASSERT_TRUE(root); + const auto& app = root->FindKey("request")->FindKey("app")->GetList()[0]; + EXPECT_EQ(kUpdateItemId, app.FindKey("appid")->GetString()); + EXPECT_EQ("0.9", app.FindKey("version")->GetString()); + EXPECT_EQ(true, app.FindKey("enabled")->GetBool()); + EXPECT_TRUE(app.FindKey("updatecheck")->DictEmpty()); + } + { + // Tests the scenario where: + // * the component supports group policies. + // * the component updates are enabled. + // Expects the update check to not include the "updatedisabled" attribute. + crx_component->supports_group_policy_enable_component_updates = true; + component->set_crx_component(*crx_component); + auto post_interceptor = std::make_unique<URLLoaderPostInterceptor>( + config_->test_url_loader_factory()); + EXPECT_TRUE(post_interceptor->ExpectRequest( + std::make_unique<PartialMatch>("updatecheck"), + test_file("updatecheck_reply_1.json"))); + update_checker_->CheckForUpdates( + update_context_->session_id, {kUpdateItemId}, components, {}, true, + base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, + base::Unretained(this))); + RunThreads(); + const auto& request = post_interceptor->GetRequestBody(0); + const auto root = base::JSONReader::Read(request); + ASSERT_TRUE(root); + const auto& app = root->FindKey("request")->FindKey("app")->GetList()[0]; + EXPECT_EQ(kUpdateItemId, app.FindKey("appid")->GetString()); + EXPECT_EQ("0.9", app.FindKey("version")->GetString()); + EXPECT_EQ(true, app.FindKey("enabled")->GetBool()); + EXPECT_TRUE(app.FindKey("updatecheck")->DictEmpty()); + } } TEST_P(UpdateCheckerTest, NoUpdateActionRun) { @@ -970,7 +1025,7 @@ components[kUpdateItemId] = MakeComponent(); update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, true, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -1011,7 +1066,7 @@ update_context_->is_foreground = false; update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, true, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -1052,7 +1107,7 @@ update_checker_ = UpdateChecker::Create(config_, metadata_.get()); update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, true, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); runloop.Run(); @@ -1071,7 +1126,7 @@ components[kUpdateItemId] = MakeComponent(); update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, true, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads(); @@ -1100,7 +1155,7 @@ components[kUpdateItemId] = MakeComponent(); update_checker_->CheckForUpdates( - update_context_->session_id, {kUpdateItemId}, components, {}, + update_context_->session_id, {kUpdateItemId}, components, {}, true, base::BindOnce(&UpdateCheckerTest::UpdateCheckComplete, base::Unretained(this))); RunThreads();
diff --git a/components/update_client/update_client.h b/components/update_client/update_client.h index 2dc65ac7..f4bb18a 100644 --- a/components/update_client/update_client.h +++ b/components/update_client/update_client.h
@@ -316,8 +316,11 @@ crx_file::VerifierFormat crx_format_requirement = crx_file::VerifierFormat::CRX3_WITH_PUBLISHER_PROOF; - // True if and only if this item may be updated. - bool updates_enabled = true; + // True if the component allows enabling or disabling updates by group policy. + // This member should be set to |false| for data, non-binary components, such + // as CRLSet, Supervised User Whitelists, STH Set, Origin Trials, and File + // Type Policies. + bool supports_group_policy_enable_component_updates = false; // Reasons why this component/extension is disabled. std::vector<int> disabled_reasons;
diff --git a/components/update_client/update_client_unittest.cc b/components/update_client/update_client_unittest.cc index cbdaef81..c74b230 100644 --- a/components/update_client/update_client_unittest.cc +++ b/components/update_client/update_client_unittest.cc
@@ -307,8 +307,10 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { EXPECT_FALSE(session_id.empty()); + EXPECT_TRUE(enabled_component_updates); EXPECT_EQ(1u, ids_to_check.size()); const std::string id = "jebgalgnebhfojomionfpkfelancnnkf"; EXPECT_EQ(id, ids_to_check.front()); @@ -436,6 +438,7 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { /* Mock the following response: @@ -462,6 +465,7 @@ </response> */ EXPECT_FALSE(session_id.empty()); + EXPECT_TRUE(enabled_component_updates); EXPECT_EQ(2u, ids_to_check.size()); ProtocolParser::Results results; @@ -690,6 +694,7 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { /* Mock the following response: @@ -713,6 +718,7 @@ </response> */ EXPECT_FALSE(session_id.empty()); + EXPECT_TRUE(enabled_component_updates); EXPECT_EQ(2u, ids_to_check.size()); ProtocolParser::Results results; @@ -918,6 +924,7 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { /* Mock the following response: @@ -941,6 +948,7 @@ </response> */ EXPECT_FALSE(session_id.empty()); + EXPECT_TRUE(enabled_component_updates); EXPECT_EQ(1u, ids_to_check.size()); ProtocolParser::Results results; @@ -1125,6 +1133,7 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { NOTREACHED(); } @@ -1239,6 +1248,7 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { /* Mock the following response: @@ -1277,6 +1287,7 @@ */ EXPECT_FALSE(session_id.empty()); + EXPECT_TRUE(enabled_component_updates); EXPECT_EQ(2u, ids_to_check.size()); ProtocolParser::Results results; @@ -1541,6 +1552,7 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { EXPECT_FALSE(session_id.empty()); @@ -1949,6 +1961,7 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { /* Mock the following response: @@ -2157,6 +2170,7 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { EXPECT_FALSE(session_id.empty()); @@ -2503,8 +2517,10 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { EXPECT_FALSE(session_id.empty()); + EXPECT_TRUE(enabled_component_updates); EXPECT_EQ(1u, ids_to_check.size()); const std::string id = "jebgalgnebhfojomionfpkfelancnnkf"; EXPECT_EQ(id, ids_to_check.front()); @@ -2646,6 +2662,7 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { /* Mock the following response: @@ -2670,6 +2687,7 @@ </response> */ EXPECT_FALSE(session_id.empty()); + EXPECT_TRUE(enabled_component_updates); EXPECT_EQ(1u, ids_to_check.size()); const std::string id = "jebgalgnebhfojomionfpkfelancnnkf"; @@ -2877,6 +2895,7 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { NOTREACHED(); } @@ -2999,8 +3018,10 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { EXPECT_FALSE(session_id.empty()); + EXPECT_TRUE(enabled_component_updates); EXPECT_EQ(1u, ids_to_check.size()); const std::string id = "jebgalgnebhfojomionfpkfelancnnkf"; EXPECT_EQ(id, ids_to_check.front()); @@ -3123,6 +3144,7 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { NOTREACHED(); } @@ -3181,6 +3203,7 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { NOTREACHED(); } @@ -3255,6 +3278,7 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { NOTREACHED(); } @@ -3354,6 +3378,7 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { EXPECT_FALSE(session_id.empty()); @@ -3499,7 +3524,7 @@ crx1.version = base::Version("0.9"); crx1.installer = base::MakeRefCounted<TestInstaller>(); crx1.crx_format_requirement = crx_file::VerifierFormat::CRX3; - crx1.updates_enabled = false; + crx1.supports_group_policy_enable_component_updates = true; CrxComponent crx2; crx2.name = "test_ihfo"; @@ -3533,6 +3558,7 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { /* Mock the following response: @@ -3570,7 +3596,12 @@ </response> */ + // UpdateClient reads the state of |enabled_component_updates| from the + // configurator instance, persists its value in the corresponding + // update context, and propagates it down to each of the update actions, + // and further down to the UpdateChecker instance. EXPECT_FALSE(session_id.empty()); + EXPECT_FALSE(enabled_component_updates); EXPECT_EQ(2u, ids_to_check.size()); ProtocolParser::Results results; @@ -3684,6 +3715,7 @@ }; // Disables updates for the components declaring support for the group policy. + config()->SetEnabledComponentUpdates(false); SetMockCrxDownloader<MockCrxDownloader>(); scoped_refptr<UpdateClient> update_client = base::MakeRefCounted<UpdateClientImpl>( @@ -3797,8 +3829,10 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { EXPECT_FALSE(session_id.empty()); + EXPECT_TRUE(enabled_component_updates); EXPECT_EQ(1u, ids_to_check.size()); const std::string id = "jebgalgnebhfojomionfpkfelancnnkf"; EXPECT_EQ(id, ids_to_check.front()); @@ -3946,8 +3980,10 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { EXPECT_FALSE(session_id.empty()); + EXPECT_TRUE(enabled_component_updates); EXPECT_EQ(4u, ids_to_check.size()); const std::string update_response = @@ -4099,6 +4135,7 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { /* Mock the following response: @@ -4124,6 +4161,7 @@ </response> */ EXPECT_FALSE(session_id.empty()); + EXPECT_TRUE(enabled_component_updates); EXPECT_EQ(1u, ids_to_check.size()); const std::string id = "gjpmebpgbhcamgdgjcmnjfhggjpgcimm"; @@ -4288,6 +4326,7 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { /* Mock the following response: @@ -4470,8 +4509,10 @@ const std::vector<std::string>& ids_to_check, const IdToComponentPtrMap& components, const base::flat_map<std::string, std::string>& additional_attributes, + bool enabled_component_updates, UpdateCheckCallback update_check_callback) override { EXPECT_FALSE(session_id.empty()); + EXPECT_TRUE(enabled_component_updates); EXPECT_EQ(1u, ids_to_check.size()); const std::string id = "jebgalgnebhfojomionfpkfelancnnkf"; EXPECT_EQ(id, ids_to_check.front());
diff --git a/components/update_client/update_engine.cc b/components/update_client/update_engine.cc index ae9d941..dd22cc7 100644 --- a/components/update_client/update_engine.cc +++ b/components/update_client/update_engine.cc
@@ -41,6 +41,7 @@ PersistedData* persisted_data) : config(config), is_foreground(is_foreground), + enabled_component_updates(config->EnabledComponentUpdates()), ids(ids), crx_state_change_callback(crx_state_change_callback), notify_observers_callback(notify_observers_callback), @@ -162,6 +163,7 @@ update_context->session_id, update_context->components_to_check_for_updates, update_context->components, config_->ExtraRequestParams(), + update_context->enabled_component_updates, base::BindOnce(&UpdateEngine::UpdateCheckResultsAvailable, this, update_context)); }
diff --git a/components/update_client/update_engine.h b/components/update_client/update_engine.h index 3b409dd..40bc78a 100644 --- a/components/update_client/update_engine.h +++ b/components/update_client/update_engine.h
@@ -132,6 +132,9 @@ // True if the component is updated as a result of user interaction. bool is_foreground = false; + // True if the component updates are enabled in this context. + const bool enabled_component_updates; + // Contains the ids of all CRXs in this context in the order specified // by the caller of |UpdateClient::Update| or |UpdateClient:Install|. const std::vector<std::string> ids;
diff --git a/components/viz/client/client_resource_provider.h b/components/viz/client/client_resource_provider.h index 049f4ea..f1e2aa3 100644 --- a/components/viz/client/client_resource_provider.h +++ b/components/viz/client/client_resource_provider.h
@@ -19,7 +19,6 @@ #include "components/viz/common/resources/transferable_resource.h" #include "third_party/khronos/GLES2/gl2.h" #include "third_party/skia/include/core/SkSurface.h" -#include "third_party/skia/include/gpu/GrBackendSurface.h" namespace gpu { namespace gles2 {
diff --git a/components/viz/service/display/output_surface.h b/components/viz/service/display/output_surface.h index 282a6c8..37ed775 100644 --- a/components/viz/service/display/output_surface.h +++ b/components/viz/service/display/output_surface.h
@@ -25,7 +25,6 @@ #include "mojo/public/cpp/bindings/pending_receiver.h" #include "skia/ext/skia_matrix_44.h" #include "third_party/abseil-cpp/absl/types/optional.h" -#include "third_party/skia/include/gpu/GrBackendSurface.h" #include "ui/gfx/color_space.h" #include "ui/gfx/overlay_transform.h" #include "ui/gfx/surface_origin.h"
diff --git a/content/browser/accessibility/accessibility_tools_utils_mac.mm b/content/browser/accessibility/accessibility_tools_utils_mac.mm index 96fdbd5..70e7fc9 100644 --- a/content/browser/accessibility/accessibility_tools_utils_mac.mm +++ b/content/browser/accessibility/accessibility_tools_utils_mac.mm
@@ -39,9 +39,13 @@ {NSAccessibilityAccessKeyAttribute, NSAccessibilityARIAAtomicAttribute, NSAccessibilityARIABusyAttribute, + NSAccessibilityARIAColumnCountAttribute, + NSAccessibilityARIAColumnIndexAttribute, NSAccessibilityARIACurrentAttribute, NSAccessibilityARIALiveAttribute, NSAccessibilityARIARelevantAttribute, + NSAccessibilityARIARowCountAttribute, + NSAccessibilityARIARowIndexAttribute, NSAccessibilityAutocompleteValueAttribute, NSAccessibilityColumnHeaderUIElementsAttribute, NSAccessibilityDetailsElementsAttribute,
diff --git a/content/browser/accessibility/accessibility_tree_formatter_win.cc b/content/browser/accessibility/accessibility_tree_formatter_win.cc index 09c8c22a..ee5b175 100644 --- a/content/browser/accessibility/accessibility_tree_formatter_win.cc +++ b/content/browser/accessibility/accessibility_tree_formatter_win.cc
@@ -839,15 +839,14 @@ case base::Value::Type::LIST: { // Currently all list values are string and are written without // attribute names. - const base::ListValue* list_value; - value->GetAsList(&list_value); std::unique_ptr<base::ListValue> filtered_list(new base::ListValue()); - for (const auto& entry : list_value->GetList()) { + for (const auto& entry : value->GetList()) { std::string string_value; - if (entry.GetAsString(&string_value)) - if (WriteAttribute(false, string_value, &line)) + if (entry.is_string()) { + if (WriteAttribute(false, entry.GetString(), &line)) filtered_list->Append(string_value); + } } break; }
diff --git a/content/browser/accessibility/ax_platform_node_textrangeprovider_win_browsertest.cc b/content/browser/accessibility/ax_platform_node_textrangeprovider_win_browsertest.cc index af488d0..39cb12a 100644 --- a/content/browser/accessibility/ax_platform_node_textrangeprovider_win_browsertest.cc +++ b/content/browser/accessibility/ax_platform_node_textrangeprovider_win_browsertest.cc
@@ -305,8 +305,7 @@ ComPtr<ITextRangeProvider> text_range_provider = ui::AXPlatformNodeTextRangeProviderWin::CreateTextRangeProvider( - start_browser_accessibility_com_win, std::move(start), - std::move(end)); + std::move(start), std::move(end)); ASSERT_NE(nullptr, text_range_provider); gfx::Rect previous_range_bounds = @@ -1051,6 +1050,76 @@ } IN_PROC_BROWSER_TEST_F(AXPlatformNodeTextRangeProviderWinBrowserTest, + RemoveNode) { + LoadInitialAccessibilityTreeFromHtml(R"HTML( + <!DOCTYPE html> + <div id="wrapper"> + <p id="node_1">Node 1</p> + <p>Node 2</p> + </div> + )HTML"); + + BrowserAccessibility* node = FindNode(ax::mojom::Role::kStaticText, "Node 1"); + ASSERT_NE(nullptr, node); + EXPECT_EQ(0u, node->PlatformChildCount()); + + // Create the text range on "Node 1". + ComPtr<ITextRangeProvider> text_range_provider; + GetTextRangeProviderFromTextNode(*node, &text_range_provider); + ASSERT_NE(nullptr, text_range_provider.Get()); + EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"Node 1"); + + // Move the text range to "Node 2". + EXPECT_UIA_MOVE(text_range_provider, TextUnit_Word, + /*count*/ 2, + /*expected_text*/ L"Node ", + /*expected_count*/ 2); + EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(text_range_provider, + TextPatternRangeEndpoint_End, TextUnit_Word, + /*count*/ 1, + /*expected_text*/ L"Node 2", + /*expected_count*/ 1); + + // Now remove "Node 1" from the DOM and verify the text range created from + // "Node 1" is still functional. + { + AccessibilityNotificationWaiter waiter(shell()->web_contents(), + ui::kAXModeComplete, + ax::mojom::Event::kChildrenChanged); + EXPECT_TRUE( + ExecJs(shell()->web_contents(), + "document.getElementById('wrapper').removeChild(document." + "getElementById('node_1'));")); + + waiter.WaitForNotification(); + EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT( + text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Character, + /*count*/ -1, + /*expected_text*/ L"Node ", + /*expected_count*/ -1); + } + + // Now remove all children from the DOM and verify the text range created from + // "Node 1" returns UIA_E_ELEMENTNOTAVAILABLE. + { + AccessibilityNotificationWaiter waiter(shell()->web_contents(), + ui::kAXModeComplete, + ax::mojom::Event::kChildrenChanged); + EXPECT_TRUE(ExecJs(shell()->web_contents(), + "while(document.body.childElementCount > 0) {" + " document.body.removeChild(document.body.firstChild);" + "}")); + + waiter.WaitForNotification(); + + int result_count = 0; + ASSERT_UIA_ELEMENTNOTAVAILABLE(text_range_provider->MoveEndpointByUnit( + TextPatternRangeEndpoint_End, TextUnit_Character, 1, &result_count)); + EXPECT_EQ(result_count, 0); + } +} + +IN_PROC_BROWSER_TEST_F(AXPlatformNodeTextRangeProviderWinBrowserTest, ScrollIntoViewTopStaticText) { LoadInitialAccessibilityTreeFromHtmlFilePath( "/accessibility/scrolling/text.html");
diff --git a/content/browser/accessibility/browser_accessibility_cocoa.mm b/content/browser/accessibility/browser_accessibility_cocoa.mm index f7ca8702..b39ef443 100644 --- a/content/browser/accessibility/browser_accessibility_cocoa.mm +++ b/content/browser/accessibility/browser_accessibility_cocoa.mm
@@ -61,11 +61,7 @@ namespace { // Private WebKit accessibility attributes. -NSString* const NSAccessibilityARIAColumnCountAttribute = @"AXARIAColumnCount"; -NSString* const NSAccessibilityARIAColumnIndexAttribute = @"AXARIAColumnIndex"; NSString* const NSAccessibilityARIAPosInSetAttribute = @"AXARIAPosInSet"; -NSString* const NSAccessibilityARIARowCountAttribute = @"AXARIARowCount"; -NSString* const NSAccessibilityARIARowIndexAttribute = @"AXARIARowIndex"; NSString* const NSAccessibilityARIASetSizeAttribute = @"AXARIASetSize"; NSString* const NSAccessibilityBlockQuoteLevelAttribute = @"AXBlockQuoteLevel"; NSString* const NSAccessibilityDOMClassList = @"AXDOMClassList"; @@ -776,11 +772,7 @@ NSString* attribute; NSString* methodName; } attributeToMethodNameContainer[] = { - {NSAccessibilityARIAColumnCountAttribute, @"ariaColumnCount"}, - {NSAccessibilityARIAColumnIndexAttribute, @"ariaColumnIndex"}, {NSAccessibilityARIAPosInSetAttribute, @"ariaPosInSet"}, - {NSAccessibilityARIARowCountAttribute, @"ariaRowCount"}, - {NSAccessibilityARIARowIndexAttribute, @"ariaRowIndex"}, {NSAccessibilityARIASetSizeAttribute, @"ariaSetSize"}, {NSAccessibilityBlockQuoteLevelAttribute, @"blockQuoteLevel"}, {NSAccessibilityChildrenAttribute, @"children"}, @@ -892,24 +884,6 @@ [super detach]; } -- (NSNumber*)ariaColumnCount { - if (![self instanceActive]) - return nil; - absl::optional<int> aria_col_count = _owner->node()->GetTableAriaColCount(); - if (!aria_col_count) - return nil; - return @(*aria_col_count); -} - -- (NSNumber*)ariaColumnIndex { - if (![self instanceActive]) - return nil; - absl::optional<int> ariaColIndex = _owner->node()->GetTableCellAriaColIndex(); - if (!ariaColIndex) - return nil; - return @(*ariaColIndex); -} - - (NSNumber*)ariaPosInSet { if (![self instanceActive]) return nil; @@ -919,24 +893,6 @@ return @(*posInSet); } -- (NSNumber*)ariaRowCount { - if (![self instanceActive]) - return nil; - absl::optional<int> ariaRowCount = _owner->node()->GetTableAriaRowCount(); - if (!ariaRowCount) - return nil; - return @(*ariaRowCount); -} - -- (NSNumber*)ariaRowIndex { - if (![self instanceActive]) - return nil; - absl::optional<int> ariaRowIndex = _owner->node()->GetTableCellAriaRowIndex(); - if (!ariaRowIndex) - return nil; - return @(*ariaRowIndex); -} - - (NSNumber*)ariaSetSize { if (![self instanceActive]) return nil; @@ -3199,8 +3155,6 @@ NSAccessibilityVisibleCellsAttribute, NSAccessibilityHeaderAttribute, NSAccessibilityRowHeaderUIElementsAttribute, - NSAccessibilityARIAColumnCountAttribute, - NSAccessibilityARIARowCountAttribute, ]]; } else if ([role isEqualToString:NSAccessibilityColumnRole]) { [ret addObjectsFromArray:@[ @@ -3211,8 +3165,6 @@ [ret addObjectsFromArray:@[ NSAccessibilityColumnIndexRangeAttribute, NSAccessibilityRowIndexRangeAttribute, - NSAccessibilityARIAColumnIndexAttribute, - NSAccessibilityARIARowIndexAttribute, @"AXSortDirection", ]]; if ([self internalRole] != ax::mojom::Role::kRowHeader)
diff --git a/content/browser/accessibility/browser_accessibility_manager.cc b/content/browser/accessibility/browser_accessibility_manager.cc index 909ea690..f7878da 100644 --- a/content/browser/accessibility/browser_accessibility_manager.cc +++ b/content/browser/accessibility/browser_accessibility_manager.cc
@@ -1510,6 +1510,19 @@ return wrapper ? wrapper->node() : nullptr; } +ui::AXPlatformNode* BrowserAccessibilityManager::GetPlatformNodeFromTree( + const ui::AXNodeID node_id) const { + BrowserAccessibility* wrapper = GetFromID(node_id); + if (wrapper) + return wrapper->GetAXPlatformNode(); + return nullptr; +} + +ui::AXPlatformNode* BrowserAccessibilityManager::GetPlatformNodeFromTree( + const ui::AXNode& node) const { + return GetPlatformNodeFromTree(node.id()); +} + void BrowserAccessibilityManager::AddObserver(ui::AXTreeObserver* observer) { ax_tree()->AddObserver(observer); }
diff --git a/content/browser/accessibility/browser_accessibility_manager.h b/content/browser/accessibility/browser_accessibility_manager.h index 089eb45..a045cd7 100644 --- a/content/browser/accessibility/browser_accessibility_manager.h +++ b/content/browser/accessibility/browser_accessibility_manager.h
@@ -38,6 +38,7 @@ #include "ui/accessibility/ax_tree_observer.h" #include "ui/accessibility/ax_tree_update.h" #include "ui/accessibility/platform/ax_platform_node.h" +#include "ui/accessibility/platform/ax_platform_tree_manager.h" #include "ui/base/buildflags.h" #include "ui/gfx/native_widget_types.h" @@ -137,9 +138,10 @@ }; // Manages a tree of BrowserAccessibility objects. -class CONTENT_EXPORT BrowserAccessibilityManager : public ui::AXTreeObserver, - public ui::AXTreeManager, - public WebContentsObserver { +class CONTENT_EXPORT BrowserAccessibilityManager + : public ui::AXTreeObserver, + public ui::AXPlatformTreeManager, + public WebContentsObserver { public: // Creates the platform-specific BrowserAccessibilityManager. static BrowserAccessibilityManager* Create( @@ -469,6 +471,9 @@ ui::AXNode* GetNodeFromTree(ui::AXTreeID tree_id, ui::AXNodeID node_id) const override; ui::AXNode* GetNodeFromTree(ui::AXNodeID node_id) const override; + ui::AXPlatformNode* GetPlatformNodeFromTree( + const ui::AXNodeID node_id) const override; + ui::AXPlatformNode* GetPlatformNodeFromTree(const ui::AXNode&) const override; void AddObserver(ui::AXTreeObserver* observer) override; void RemoveObserver(ui::AXTreeObserver* observer) override; ui::AXTreeID GetTreeID() const override;
diff --git a/content/browser/accessibility/dump_accessibility_scripts_browsertest.cc b/content/browser/accessibility/dump_accessibility_scripts_browsertest.cc index c768858..af892693 100644 --- a/content/browser/accessibility/dump_accessibility_scripts_browsertest.cc +++ b/content/browser/accessibility/dump_accessibility_scripts_browsertest.cc
@@ -141,10 +141,6 @@ ::testing::Values(ui::AXApiType::kMac), TestPassToString()); -IN_PROC_BROWSER_TEST_P(DumpAccessibilityScriptTest, AXPressButton) { - RunTypedTest<kMacAction>("ax-press-button.html"); -} - IN_PROC_BROWSER_TEST_P(DumpAccessibilityScriptTest, AXAccessKey) { RunTypedTest<kMacAttributes>("ax-access-key.html"); } @@ -157,6 +153,14 @@ RunTypedTest<kMacAttributes>("ax-aria-busy.html"); } +IN_PROC_BROWSER_TEST_P(DumpAccessibilityScriptTest, AXARIAColumnCount) { + RunTypedTest<kMacAttributes>("ax-aria-column-count.html"); +} + +IN_PROC_BROWSER_TEST_P(DumpAccessibilityScriptTest, AXARIAColumnIndex) { + RunTypedTest<kMacAttributes>("ax-aria-column-index.html"); +} + IN_PROC_BROWSER_TEST_P(DumpAccessibilityScriptTest, AXARIACurrent) { RunTypedTest<kMacAttributes>("ax-aria-current.html"); } @@ -169,6 +173,14 @@ RunTypedTest<kMacAttributes>("ax-aria-relevant.html"); } +IN_PROC_BROWSER_TEST_P(DumpAccessibilityScriptTest, AXARIARowCount) { + RunTypedTest<kMacAttributes>("ax-aria-row-count.html"); +} + +IN_PROC_BROWSER_TEST_P(DumpAccessibilityScriptTest, AXARIARowIndex) { + RunTypedTest<kMacAttributes>("ax-aria-row-index.html"); +} + IN_PROC_BROWSER_TEST_P(DumpAccessibilityScriptTest, AXAutocompleteValue) { RunTypedTest<kMacAttributes>("ax-autocomplete-value.html"); } @@ -233,6 +245,10 @@ RunTypedTest<kMacAttributes>("ax-math-under.html"); } +IN_PROC_BROWSER_TEST_P(DumpAccessibilityScriptTest, AXPressButton) { + RunTypedTest<kMacAction>("ax-press-button.html"); +} + IN_PROC_BROWSER_TEST_P(DumpAccessibilityScriptTest, AXRequired) { RunTypedTest<kMacAttributes>("ax-required.html"); }
diff --git a/content/browser/android/java/gin_java_method_invocation_helper.cc b/content/browser/android/java/gin_java_method_invocation_helper.cc index 3b585d5..567dfb00 100644 --- a/content/browser/android/java/gin_java_method_invocation_helper.cc +++ b/content/browser/android/java/gin_java_method_invocation_helper.cc
@@ -53,9 +53,7 @@ DispatcherDelegate* dispatcher, const base::Value& list_value) { DCHECK(list_value.is_list()); - const base::ListValue* list; - list_value.GetAsList(&list); - for (const auto& entry : list->GetList()) { + for (const auto& entry : list_value.GetList()) { if (AppendObjectRef(dispatcher, entry)) continue; if (entry.is_list()) {
diff --git a/content/browser/android/java/gin_java_script_to_java_types_coercion.cc b/content/browser/android/java/gin_java_script_to_java_types_coercion.cc index 0662192f..ed27e0b1 100644 --- a/content/browser/android/java/gin_java_script_to_java_types_coercion.cc +++ b/content/browser/android/java/gin_java_script_to_java_types_coercion.cc
@@ -9,6 +9,8 @@ #include <cmath> #include <limits> +#include <memory> +#include <string> #include "base/android/jni_android.h" #include "base/android/jni_string.h" @@ -456,21 +458,18 @@ return NULL; } - const base::ListValue* list_value; - value->GetAsList(&list_value); // Create the Java array. - jsize length = static_cast<jsize>(list_value->GetList().size()); + jsize length = static_cast<jsize>(value->GetList().size()); jobject result = CreateJavaArray(env, target_inner_type, length); if (!result) { return NULL; } - auto null_value = std::make_unique<base::Value>(); - for (jsize i = 0; i < length; ++i) { - const base::Value* value_element = null_value.get(); - list_value->Get(i, &value_element); + + jsize i = 0; + for (const auto& value_element : value->GetList()) { jvalue element = CoerceJavaScriptValueToJavaValue( - env, value_element, target_inner_type, false, object_refs, error); - SetArrayElement(env, result, target_inner_type, i, element); + env, &value_element, target_inner_type, false, object_refs, error); + SetArrayElement(env, result, target_inner_type, i++, element); // CoerceJavaScriptValueToJavaValue() creates new local references to // strings, objects and arrays. Of these, only strings can occur here. // SetArrayElement() causes the array to take its own reference to the
diff --git a/content/browser/attribution_reporting/attribution_internals_browsertest.cc b/content/browser/attribution_reporting/attribution_internals_browsertest.cc index afed6d68e..bf9a616 100644 --- a/content/browser/attribution_reporting/attribution_internals_browsertest.cc +++ b/content/browser/attribution_reporting/attribution_internals_browsertest.cc
@@ -6,7 +6,6 @@ #include "base/strings/utf_string_conversions.h" #include "base/time/time.h" -#include "build/build_config.h" #include "content/browser/attribution_reporting/attribution_manager.h" #include "content/browser/attribution_reporting/attribution_report.h" #include "content/browser/attribution_reporting/attribution_storage.h" @@ -92,50 +91,6 @@ TestAttributionManager manager_; }; -// crbug.com/1275187: various tests are flaky -#if defined(OS_LINUX) -#define MAYBE_DisabledByEmbedder_MeasurementConsideredDisabled \ - DISABLED_DisabledByEmbedder_MeasurementConsideredDisabled -#define MAYBE_WebUISendReports_ReportsRemoved \ - DISABLED_WebUISendReports_ReportsRemoved -#define MAYBE_WebUIShownWithActiveImpression_ImpressionsDisplayed \ - DISABLED_WebUIShownWithActiveImpression_ImpressionsDisplayed -#define MAYBE_WebUIShownWithManager_DebugModeDisabled \ - DISABLED_WebUIShownWithManager_DebugModeDisabled -#define MAYBE_WebUIShownWithManager_DebugModeEnabled \ - DISABLED_WebUIShownWithManager_DebugModeEnabled -#define MAYBE_WebUIShownWithManager_MeasurementConsideredEnabled \ - DISABLED_WebUIShownWithManager_MeasurementConsideredEnabled -#define MAYBE_WebUIShownWithNoActiveImpression_NoImpressionsDisplayed \ - DISABLED_WebUIShownWithNoActiveImpression_NoImpressionsDisplayed -#define MAYBE_WebUIShownWithNoReports_NoReportsDisplayed \ - DISABLED_WebUIShownWithNoReports_NoReportsDisplayed -#define MAYBE_WebUIShownWithPendingReports_ReportsDisplayed \ - DISABLED_WebUIShownWithPendingReports_ReportsDisplayed -#define MAYBE_WebUIWithPendingReportsClearStorage_ReportsRemoved \ - DISABLED_WebUIWithPendingReportsClearStorage_ReportsRemoved -#else -#define MAYBE_DisabledByEmbedder_MeasurementConsideredDisabled \ - DisabledByEmbedder_MeasurementConsideredDisabled -#define MAYBE_WebUISendReports_ReportsRemoved WebUISendReports_ReportsRemoved -#define MAYBE_WebUIShownWithActiveImpression_ImpressionsDisplayed \ - WebUIShownWithActiveImpression_ImpressionsDisplayed -#define MAYBE_WebUIShownWithManager_DebugModeDisabled \ - WebUIShownWithManager_DebugModeDisabled -#define MAYBE_WebUIShownWithManager_DebugModeEnabled \ - WebUIShownWithManager_DebugModeEnabled -#define MAYBE_WebUIShownWithManager_MeasurementConsideredEnabled \ - WebUIShownWithManager_MeasurementConsideredEnabled -#define MAYBE_WebUIShownWithNoActiveImpression_NoImpressionsDisplayed \ - WebUIShownWithNoActiveImpression_NoImpressionsDisplayed -#define MAYBE_WebUIShownWithNoReports_NoReportsDisplayed \ - WebUIShownWithNoReports_NoReportsDisplayed -#define MAYBE_WebUIShownWithPendingReports_ReportsDisplayed \ - WebUIShownWithPendingReports_ReportsDisplayed -#define MAYBE_WebUIWithPendingReportsClearStorage_ReportsRemoved \ - WebUIWithPendingReportsClearStorage_ReportsRemoved -#endif - IN_PROC_BROWSER_TEST_F(AttributionInternalsWebUiBrowserTest, NavigationUrl_ResolvedToWebUI) { EXPECT_TRUE(NavigateToURL(shell(), GURL(kAttributionInternalsUrl))); @@ -148,9 +103,8 @@ EXECUTE_SCRIPT_DEFAULT_OPTIONS, /*world_id=*/1)); } -IN_PROC_BROWSER_TEST_F( - AttributionInternalsWebUiBrowserTest, - MAYBE_WebUIShownWithManager_MeasurementConsideredEnabled) { +IN_PROC_BROWSER_TEST_F(AttributionInternalsWebUiBrowserTest, + WebUIShownWithManager_MeasurementConsideredEnabled) { EXPECT_TRUE(NavigateToURL(shell(), GURL(kAttributionInternalsUrl))); OverrideWebUIAttributionManager(); @@ -174,7 +128,7 @@ } IN_PROC_BROWSER_TEST_F(AttributionInternalsWebUiBrowserTest, - MAYBE_DisabledByEmbedder_MeasurementConsideredDisabled) { + DisabledByEmbedder_MeasurementConsideredDisabled) { AttributionDisallowingContentBrowserClient disallowed_browser_client; ScopedContentBrowserClientSetting setting(&disallowed_browser_client); @@ -202,7 +156,7 @@ IN_PROC_BROWSER_TEST_F( AttributionInternalsWebUiBrowserTest, - MAYBE_WebUIShownWithNoActiveImpression_NoImpressionsDisplayed) { + WebUIShownWithNoActiveImpression_NoImpressionsDisplayed) { EXPECT_TRUE(NavigateToURL(shell(), GURL(kAttributionInternalsUrl))); OverrideWebUIAttributionManager(); @@ -224,9 +178,8 @@ EXPECT_EQ(kCompleteTitle, title_watcher.WaitAndGetTitle()); } -IN_PROC_BROWSER_TEST_F( - AttributionInternalsWebUiBrowserTest, - MAYBE_WebUIShownWithActiveImpression_ImpressionsDisplayed) { +IN_PROC_BROWSER_TEST_F(AttributionInternalsWebUiBrowserTest, + WebUIShownWithActiveImpression_ImpressionsDisplayed) { EXPECT_TRUE(NavigateToURL(shell(), GURL(kAttributionInternalsUrl))); OverrideWebUIAttributionManager(); @@ -283,7 +236,7 @@ } IN_PROC_BROWSER_TEST_F(AttributionInternalsWebUiBrowserTest, - MAYBE_WebUIShownWithNoReports_NoReportsDisplayed) { + WebUIShownWithNoReports_NoReportsDisplayed) { EXPECT_TRUE(NavigateToURL(shell(), GURL(kAttributionInternalsUrl))); OverrideWebUIAttributionManager(); @@ -295,7 +248,7 @@ } IN_PROC_BROWSER_TEST_F(AttributionInternalsWebUiBrowserTest, - MAYBE_WebUIShownWithManager_DebugModeDisabled) { + WebUIShownWithManager_DebugModeDisabled) { EXPECT_TRUE(NavigateToURL(shell(), GURL(kAttributionInternalsUrl))); OverrideWebUIAttributionManager(); @@ -319,7 +272,7 @@ } IN_PROC_BROWSER_TEST_F(AttributionInternalsWebUiBrowserTest, - MAYBE_WebUIShownWithManager_DebugModeEnabled) { + WebUIShownWithManager_DebugModeEnabled) { base::CommandLine::ForCurrentProcess()->AppendSwitch( switches::kConversionsDebugMode); @@ -346,7 +299,7 @@ } IN_PROC_BROWSER_TEST_F(AttributionInternalsWebUiBrowserTest, - MAYBE_WebUIShownWithPendingReports_ReportsDisplayed) { + WebUIShownWithPendingReports_ReportsDisplayed) { EXPECT_TRUE(NavigateToURL(shell(), GURL(kAttributionInternalsUrl))); const base::Time now = base::Time::Now(); @@ -494,9 +447,8 @@ } } -IN_PROC_BROWSER_TEST_F( - AttributionInternalsWebUiBrowserTest, - MAYBE_WebUIWithPendingReportsClearStorage_ReportsRemoved) { +IN_PROC_BROWSER_TEST_F(AttributionInternalsWebUiBrowserTest, + WebUIWithPendingReportsClearStorage_ReportsRemoved) { EXPECT_TRUE(NavigateToURL(shell(), GURL(kAttributionInternalsUrl))); const base::Time now = base::Time::Now(); @@ -544,7 +496,7 @@ // TODO(johnidel): Use a real AttributionManager here and verify that the // reports are actually sent. IN_PROC_BROWSER_TEST_F(AttributionInternalsWebUiBrowserTest, - MAYBE_WebUISendReports_ReportsRemoved) { + WebUISendReports_ReportsRemoved) { EXPECT_TRUE(NavigateToURL(shell(), GURL(kAttributionInternalsUrl))); AttributionReport report =
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc index eaa4e8c..8286649d 100644 --- a/content/browser/browser_main_loop.cc +++ b/content/browser/browser_main_loop.cc
@@ -971,7 +971,7 @@ ContentBrowserClient::WideColorGamutHeuristic::kUseDisplay; // Let screen instance be overridable by parts. ui::SetScreenAndroid(use_display_wide_color_gamut); -#endif +#endif // defined(OS_ANDROID) if (parts_) result_code_ = parts_->PreMainMessageLoopRun(); @@ -984,7 +984,19 @@ content::DWriteFontLookupTableBuilder::GetInstance() ->SchedulePrepareFontUniqueNameTableIfNeeded(); } -#endif +#endif // defined(OS_WIN) + + // Unretained(this) is safe as the main message loop expected to run it is + // stopped before ~BrowserMainLoop (in the event the message loop doesn't + // reach idle before that point). + base::CurrentThread::Get()->RegisterOnNextIdleCallback(base::BindOnce( + [](BrowserMainLoop* self) { + if (self->parts_) + self->parts_->OnFirstIdle(); + + self->responsiveness_watcher_->OnFirstIdle(); + }, + base::Unretained(this))); // If the UI thread blocks, the whole UI is unresponsive. Do not allow // unresponsive tasks from the UI thread and instantiate a @@ -1023,24 +1035,6 @@ if (parts_) parts_->WillRunMainMessageLoop(main_run_loop); DCHECK(main_run_loop); - - main_run_loop->RunUntilIdle(); - // |parts_| may have captured a quit closure in WillRunMainMessageLoop(). If - // the above run is quit before it reaches idle on its own, - // RunMainMessageLoop() must return right away. - if (main_run_loop->AnyQuitCalled()) - return; - - // TODO(crbug.com/1175074): Figure out why (only) blink web tests goes through - // this code path multiple times... - static bool ran_once = false; - if (!ran_once) { - ran_once = true; - if (parts_) - parts_->OnFirstIdle(); - responsiveness_watcher_->OnFirstIdle(); - } - main_run_loop->Run(); #endif // defined(OS_ANDROID) }
diff --git a/content/browser/devtools/protocol/tracing_handler.cc b/content/browser/devtools/protocol/tracing_handler.cc index 9fd448d..a23e53b 100644 --- a/content/browser/devtools/protocol/tracing_handler.cc +++ b/content/browser/devtools/protocol/tracing_handler.cc
@@ -100,12 +100,13 @@ return std::move(out_dict); } - const base::ListValue* list = nullptr; - if (value.GetAsList(&list)) { - std::unique_ptr<base::ListValue> out_list(new base::ListValue()); - for (const auto& key : list->GetList()) - out_list->Append(ConvertDictKeyStyle(key)); - return std::move(out_list); + if (value.is_list()) { + base::Value::ListStorage out_list_storage; + base::Value out_list(std::move(out_list_storage)); + for (const auto& key : value.GetList()) + out_list.Append( + base::Value::FromUniquePtrValue(ConvertDictKeyStyle(key))); + return base::Value::ToUniquePtrValue(out_list.Clone()); } return base::Value::ToUniquePtrValue(value.Clone());
diff --git a/content/browser/gpu/gpu_data_manager_impl_private.cc b/content/browser/gpu/gpu_data_manager_impl_private.cc index 5ea2a9790..cddf8df 100644 --- a/content/browser/gpu/gpu_data_manager_impl_private.cc +++ b/content/browser/gpu/gpu_data_manager_impl_private.cc
@@ -224,6 +224,47 @@ } #endif // OS_WIN +// These values are persistent to logs. Entries should not be renumbered and +// numeric values should never be reused. +// This should match enum CanvasOopRasterAndGpuAcceleration in +// \tools\metrics\histograms\enums.xml +enum class CanvasOopRasterAndGpuAcceleration { + kAccelOop = 0, + kAccelNoOop = 1, + kNoAccelOop = 2, + kNoAccelNoOop = 3, + kMaxValue = kNoAccelNoOop, +}; + +void RecordCanvasAcceleratedOopRasterHistogram( + const gpu::GpuFeatureInfo& gpu_feature_info, + bool gpu_compositing_disabled) { + const base::CommandLine& command_line = + *base::CommandLine::ForCurrentProcess(); + bool accelerated_canvas = + gpu_feature_info + .status_values[gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS] == + gpu::kGpuFeatureStatusEnabled && + !command_line.HasSwitch(switches::kDisableAccelerated2dCanvas); + bool oopr_canvas = + gpu_feature_info + .status_values[gpu::GPU_FEATURE_TYPE_CANVAS_OOP_RASTERIZATION] == + gpu::kGpuFeatureStatusEnabled; + + CanvasOopRasterAndGpuAcceleration oop_acceleration_state = + CanvasOopRasterAndGpuAcceleration::kNoAccelNoOop; + if (!gpu_compositing_disabled) { + if (accelerated_canvas && oopr_canvas) + oop_acceleration_state = CanvasOopRasterAndGpuAcceleration::kAccelOop; + else if (accelerated_canvas && !oopr_canvas) + oop_acceleration_state = CanvasOopRasterAndGpuAcceleration::kAccelNoOop; + else if (!accelerated_canvas && oopr_canvas) + oop_acceleration_state = CanvasOopRasterAndGpuAcceleration::kNoAccelOop; + } + UMA_HISTOGRAM_ENUMERATION("GPU.CanvasOopRaster.OopRasterAndGpuAcceleration", + oop_acceleration_state); +} + // Send UMA histograms about the enabled features and GPU properties. void UpdateFeatureStats(const gpu::GpuFeatureInfo& gpu_feature_info) { // Update applied entry stats. @@ -1223,6 +1264,8 @@ if (update_histograms_) { UpdateFeatureStats(gpu_feature_info_); UpdateDriverBugListStats(gpu_feature_info_); + RecordCanvasAcceleratedOopRasterHistogram(gpu_feature_info_, + IsGpuCompositingDisabled()); } }
diff --git a/content/browser/isolated_origin_browsertest.cc b/content/browser/isolated_origin_browsertest.cc index 97c9676..518edf6 100644 --- a/content/browser/isolated_origin_browsertest.cc +++ b/content/browser/isolated_origin_browsertest.cc
@@ -792,11 +792,11 @@ ProcessLock::FromSiteInfo(child_frame_node->current_frame_host() ->GetSiteInstance() ->GetSiteInfo())); - EXPECT_EQ(ProcessLock::FromSiteInfo(child_frame_node->current_frame_host() - ->GetSiteInstance() - ->GetSiteInfo()), - ChildProcessSecurityPolicyImpl::GetInstance()->GetProcessLock( - child_frame_node->current_frame_host()->GetProcess()->GetID())); + EXPECT_EQ( + ProcessLock::FromSiteInfo(child_frame_node->current_frame_host() + ->GetSiteInstance() + ->GetSiteInfo()), + child_frame_node->current_frame_host()->GetProcess()->GetProcessLock()); EXPECT_THAT( histograms.GetAllSamples("Navigation.OriginAgentCluster.Result"), @@ -2301,30 +2301,25 @@ RenderFrameHost* main_frame = root->current_frame_host(); int main_frame_id = main_frame->GetProcess()->GetID(); RenderFrameHost* child_frame0 = root->child_at(0)->current_frame_host(); - int child_frame0_id = child_frame0->GetProcess()->GetID(); RenderFrameHost* child_frame1 = root->child_at(1)->current_frame_host(); - int child_frame1_id = child_frame1->GetProcess()->GetID(); RenderFrameHost* child_frame2 = root->child_at(2)->current_frame_host(); - int child_frame2_id = child_frame2->GetProcess()->GetID(); RenderFrameHost* grandchild_frame0 = root->child_at(1)->child_at(0)->current_frame_host(); - int grandchild_frame0_id = grandchild_frame0->GetProcess()->GetID(); - EXPECT_NE(main_frame_id, child_frame0_id); - EXPECT_NE(main_frame_id, child_frame1_id); - EXPECT_EQ(main_frame_id, child_frame2_id); - EXPECT_EQ(main_frame_id, grandchild_frame0_id); + EXPECT_NE(main_frame_id, child_frame0->GetProcess()->GetID()); + EXPECT_NE(main_frame_id, child_frame1->GetProcess()->GetID()); + EXPECT_EQ(main_frame_id, child_frame2->GetProcess()->GetID()); + EXPECT_EQ(main_frame_id, grandchild_frame0->GetProcess()->GetID()); - auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); EXPECT_EQ(GetStrictProcessLockForHost("foo.com"), - policy->GetProcessLock(main_frame_id)); + main_frame->GetProcess()->GetProcessLock()); EXPECT_EQ(GetStrictProcessLockForHost("mail.foo.com"), - policy->GetProcessLock(child_frame0_id)); + child_frame0->GetProcess()->GetProcessLock()); EXPECT_EQ(GetStrictProcessLockForHost("bar.foo.com"), - policy->GetProcessLock(child_frame1_id)); + child_frame1->GetProcess()->GetProcessLock()); EXPECT_EQ(GetStrictProcessLockForHost("foo.com"), - policy->GetProcessLock(child_frame2_id)); + child_frame2->GetProcess()->GetProcessLock()); EXPECT_EQ(GetStrictProcessLockForHost("foo.com"), - policy->GetProcessLock(grandchild_frame0_id)); + grandchild_frame0->GetProcess()->GetProcessLock()); // Navigate child_frame1 to a new origin ... it should get its own process. FrameTreeNode* child_frame2_node = root->child_at(2); @@ -2338,8 +2333,7 @@ child_frame2 = root->child_at(2)->current_frame_host(); EXPECT_NE(main_frame->GetProcess()->GetID(), child_frame2->GetProcess()->GetID()); - EXPECT_EQ(expected_foo_lock, - policy->GetProcessLock(child_frame2->GetProcess()->GetID())); + EXPECT_EQ(expected_foo_lock, child_frame2->GetProcess()->GetProcessLock()); } IN_PROC_BROWSER_TEST_F(StrictOriginIsolationTest, MainframesAreIsolated) { @@ -4508,9 +4502,10 @@ // Since foo.com isn't isolated yet, its process lock should allow any site. auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); - EXPECT_TRUE( - policy->GetProcessLock(root->current_frame_host()->GetProcess()->GetID()) - .allows_any_site()); + EXPECT_TRUE(root->current_frame_host() + ->GetProcess() + ->GetProcessLock() + .allows_any_site()); // Start isolating foo.com. policy->AddFutureIsolatedOrigins({url::Origin::Create(foo_url)}, @@ -4568,8 +4563,7 @@ EXPECT_NE(isolated_foo_com_process_id, second_root->current_frame_host()->GetProcess()->GetID()); EXPECT_EQ(ProcessLockFromUrl("http://sub.foo.com"), - policy->GetProcessLock( - second_root->current_frame_host()->GetProcess()->GetID())); + second_root->current_frame_host()->GetProcess()->GetProcessLock()); // Make sure that process can also access sub.foo.com cookies. EXPECT_TRUE(ExecJs(second_root, "document.cookie = 'foo=qux';")); @@ -4780,7 +4774,7 @@ RenderProcessHost* new_process = new_shell->web_contents()->GetMainFrame()->GetProcess(); EXPECT_EQ(ProcessLockFromUrl("http://foo.com"), - policy->GetProcessLock(new_process->GetID())); + new_process->GetProcessLock()); // Go to foo.com in the older first tab, where foo.com does not require a // dedicated process. Ensure that the existing locked foo.com process is @@ -4880,8 +4874,7 @@ EXPECT_EQ(root->current_frame_host()->GetProcess(), child->current_frame_host()->GetProcess()); auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); - EXPECT_TRUE(policy->GetProcessLock(first_instance->GetProcess()->GetID()) - .allows_any_site()); + EXPECT_TRUE(first_instance->GetProcess()->GetProcessLock().allows_any_site()); // Start isolating foo.com. BrowserContext* context = shell()->web_contents()->GetBrowserContext(); @@ -4901,7 +4894,7 @@ EXPECT_FALSE(first_instance->IsRelatedSiteInstance(second_instance.get())); EXPECT_NE(first_instance->GetProcess(), second_instance->GetProcess()); EXPECT_EQ(ProcessLockFromUrl("http://foo.com"), - policy->GetProcessLock(second_instance->GetProcess()->GetID())); + second_instance->GetProcess()->GetProcessLock()); // The frame on that page should now be an OOPIF. child = root->child_at(0); @@ -4928,8 +4921,7 @@ root->current_frame_host()->GetSiteInstance(); EXPECT_FALSE(first_instance->RequiresDedicatedProcess()); auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); - EXPECT_TRUE(policy->GetProcessLock(first_instance->GetProcess()->GetID()) - .allows_any_site()); + EXPECT_TRUE(first_instance->GetProcess()->GetProcessLock().allows_any_site()); // Set a sessionStorage value, to sanity check that foo.com's session storage // will still be accessible after the BrowsingInstance swap. @@ -4953,7 +4945,7 @@ EXPECT_FALSE(first_instance->IsRelatedSiteInstance(second_instance.get())); EXPECT_NE(first_instance->GetProcess(), second_instance->GetProcess()); EXPECT_EQ(ProcessLockFromUrl("http://foo.com"), - policy->GetProcessLock(second_instance->GetProcess()->GetID())); + second_instance->GetProcess()->GetProcessLock()); // The frame on that page should be an OOPIF. FrameTreeNode* child = root->child_at(0); @@ -4999,8 +4991,7 @@ // should still be able to communicate with the opener after the navigation. EXPECT_EQ(first_instance, root->current_frame_host()->GetSiteInstance()); EXPECT_FALSE(first_instance->RequiresDedicatedProcess()); - EXPECT_TRUE(policy->GetProcessLock(first_instance->GetProcess()->GetID()) - .allows_any_site()); + EXPECT_TRUE(first_instance->GetProcess()->GetProcessLock().allows_any_site()); } // This test ensures that when a page becomes isolated in the middle of @@ -5041,8 +5032,7 @@ // opener after the navigation. EXPECT_EQ(first_instance, root->current_frame_host()->GetSiteInstance()); EXPECT_FALSE(first_instance->RequiresDedicatedProcess()); - EXPECT_TRUE(policy->GetProcessLock(first_instance->GetProcess()->GetID()) - .allows_any_site()); + EXPECT_TRUE(first_instance->GetProcess()->GetProcessLock().allows_any_site()); } class IsolatedOriginTestWithStrictSiteInstances : public IsolatedOriginTest { @@ -5127,9 +5117,7 @@ RenderProcessHost* host = root->current_frame_host()->GetProcess(); EXPECT_EQ(host, child1->current_frame_host()->GetProcess()); EXPECT_EQ(host, child2->current_frame_host()->GetProcess()); - EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance() - ->GetProcessLock(host->GetID()) - .allows_any_site()); + EXPECT_TRUE(host->GetProcessLock().allows_any_site()); } // Creates a non-isolated main frame with an isolated child and non-isolated @@ -5548,8 +5536,7 @@ // dedicated process locked to b.com. EXPECT_TRUE(coop_instance->RequiresDedicatedProcess()); - auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); - auto lock = policy->GetProcessLock(coop_instance->GetProcess()->GetID()); + auto lock = coop_instance->GetProcess()->GetProcessLock(); EXPECT_TRUE(lock.is_locked_to_site()); EXPECT_EQ(ProcessLockFromUrl("https://b.com"), lock); @@ -5609,8 +5596,7 @@ // a dedicated process locked to coop.com. EXPECT_TRUE(coop_instance->RequiresDedicatedProcess()); - auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); - auto lock = policy->GetProcessLock(coop_instance->GetProcess()->GetID()); + auto lock = coop_instance->GetProcess()->GetProcessLock(); EXPECT_TRUE(lock.is_locked_to_site()); EXPECT_EQ(ProcessLockFromUrl("https://coop.com"), lock); @@ -5688,8 +5674,7 @@ EXPECT_TRUE(coop_instance->RequiresDedicatedProcess()); // Ensure that the process lock is for the site, not origin. - auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); - auto lock = policy->GetProcessLock(coop_instance->GetProcess()->GetID()); + auto lock = coop_instance->GetProcess()->GetProcessLock(); EXPECT_TRUE(lock.is_locked_to_site()); EXPECT_EQ(ProcessLockFromUrl("https://coop.com"), lock); @@ -5710,9 +5695,11 @@ // Check that ChildProcessSecurityPolicy considers coop.com (and not its // subdomain) to be the matching isolated origin for `coop_url`. url::Origin matching_isolated_origin; - policy->GetMatchingProcessIsolatedOrigin( - coop_instance->GetIsolationContext(), url::Origin::Create(GURL(coop_url)), - false /* origin_requests_isolation */, &matching_isolated_origin); + ChildProcessSecurityPolicyImpl::GetInstance() + ->GetMatchingProcessIsolatedOrigin(coop_instance->GetIsolationContext(), + url::Origin::Create(GURL(coop_url)), + false /* origin_requests_isolation */, + &matching_isolated_origin); EXPECT_EQ(matching_isolated_origin, url::Origin::Create(GURL("https://coop.com"))); } @@ -5735,8 +5722,7 @@ SiteInstanceImpl* coop_instance = web_contents()->GetMainFrame()->GetSiteInstance(); EXPECT_TRUE(coop_instance->RequiresDedicatedProcess()); - auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); - auto lock = policy->GetProcessLock(coop_instance->GetProcess()->GetID()); + auto lock = coop_instance->GetProcess()->GetProcessLock(); EXPECT_TRUE(lock.GetWebExposedIsolationInfo().is_isolated()); EXPECT_TRUE(lock.is_locked_to_site()); EXPECT_TRUE( @@ -5811,10 +5797,8 @@ EXPECT_EQ(main_instance->GetSiteInfo().process_lock_url(), child_instance->GetSiteInfo().process_lock_url()); - auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); - auto main_lock = policy->GetProcessLock(main_instance->GetProcess()->GetID()); - auto child_lock = - policy->GetProcessLock(child_instance->GetProcess()->GetID()); + auto main_lock = main_instance->GetProcess()->GetProcessLock(); + auto child_lock = child_instance->GetProcess()->GetProcessLock(); EXPECT_TRUE(main_lock.is_locked_to_site()); EXPECT_TRUE(child_lock.is_locked_to_site()); EXPECT_TRUE(main_lock.is_origin_keyed_process()); @@ -5869,10 +5853,8 @@ EXPECT_NE(main_instance->GetSiteInfo().process_lock_url(), child_instance->GetSiteInfo().process_lock_url()); - auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); - auto main_lock = policy->GetProcessLock(main_instance->GetProcess()->GetID()); - auto child_lock = - policy->GetProcessLock(child_instance->GetProcess()->GetID()); + auto main_lock = main_instance->GetProcess()->GetProcessLock(); + auto child_lock = child_instance->GetProcess()->GetProcessLock(); EXPECT_TRUE(main_lock.is_locked_to_site()); EXPECT_TRUE(child_lock.is_locked_to_site()); EXPECT_TRUE(main_lock.is_origin_keyed_process());
diff --git a/content/browser/loader/navigation_url_loader_impl.cc b/content/browser/loader/navigation_url_loader_impl.cc index cfc9f79..64619a1 100644 --- a/content/browser/loader/navigation_url_loader_impl.cc +++ b/content/browser/loader/navigation_url_loader_impl.cc
@@ -820,10 +820,9 @@ FrameTreeNode::GloballyFindByID(frame_tree_node_id_); int render_process_id = frame_tree_node->current_frame_host()->GetProcess()->GetID(); - int routing_id = frame_tree_node->current_frame_host()->GetRoutingID(); bool has_plugin = PluginService::GetInstance()->GetPluginInfo( - render_process_id, routing_id, resource_request_->url, url::Origin(), - head->mime_type, /*allow_wildcard=*/false, &stale, &plugin, nullptr); + render_process_id, resource_request_->url, head->mime_type, + /*allow_wildcard=*/false, &stale, &plugin, nullptr); if (stale) { // Refresh the plugins asynchronously.
diff --git a/content/browser/media/capture/aura_window_video_capture_device_browsertest.cc b/content/browser/media/capture/aura_window_video_capture_device_browsertest.cc index ff7cc1a..69638689c 100644 --- a/content/browser/media/capture/aura_window_video_capture_device_browsertest.cc +++ b/content/browser/media/capture/aura_window_video_capture_device_browsertest.cc
@@ -49,16 +49,10 @@ ~AuraWindowVideoCaptureDeviceBrowserTest() override = default; aura::Window* GetCapturedWindow() const { -#if BUILDFLAG(IS_CHROMEOS_ASH) - // Since the LameWindowCapturerChromeOS will be used, just return the normal - // shell window. - return shell()->window(); -#else // Note: The Window with an associated compositor frame sink (required for // capture) is the root window, which is an immediate ancestor of the // aura::Window provided by shell()->window(). return shell()->window()->GetRootWindow(); -#endif } // Returns the location of the content within the window. @@ -106,14 +100,6 @@ const gfx::RectF webcontents_in_frame_rect_f = TransformSimilarly( gfx::Rect(window_size), window_in_frame_rect_f, webcontents_rect); -#if BUILDFLAG(IS_CHROMEOS_ASH) - // Browser window capture on ChromeOS uses the - // LameWindowCapturerChromeOS, which takes RGB snapshots and then - // software-converts them to YUV, and color accuracy is greatly reduced. - // See comments in viz::CopyOutputResult::ReadI420Planes() for further - // details on why this has to be. - constexpr int max_color_diff = kVeryLooseMaxColorDifference; -#else // viz::SoftwareRenderer does not do color space management. Otherwise // (normal case), be strict about color differences. // TODO(crbug/795132): SkiaRenderer temporarily uses same code as @@ -122,7 +108,6 @@ (IsSoftwareCompositingTest() || features::IsUsingSkiaRenderer()) ? kVeryLooseMaxColorDifference : kMaxColorDifference; -#endif // Determine the average RGB color in the three regions of the frame. const auto average_webcontents_rgb = ComputeAverageColor(
diff --git a/content/browser/plugin_service_impl.cc b/content/browser/plugin_service_impl.cc index 51c7183b..00106b9 100644 --- a/content/browser/plugin_service_impl.cc +++ b/content/browser/plugin_service_impl.cc
@@ -233,11 +233,8 @@ url, mime_type, allow_wildcard, plugins, actual_mime_types); } -// TODO(crbug.com/850278): Remove unused parameters. bool PluginServiceImpl::GetPluginInfo(int render_process_id, - int /*render_frame_id*/, const GURL& url, - const url::Origin& /*main_frame_origin*/, const std::string& mime_type, bool allow_wildcard, bool* is_stale,
diff --git a/content/browser/plugin_service_impl.h b/content/browser/plugin_service_impl.h index e76794b..9f256a7f 100644 --- a/content/browser/plugin_service_impl.h +++ b/content/browser/plugin_service_impl.h
@@ -54,9 +54,7 @@ std::vector<WebPluginInfo>* info, std::vector<std::string>* actual_mime_types) override; bool GetPluginInfo(int render_process_id, - int render_frame_id, const GURL& url, - const url::Origin& main_frame_origin, const std::string& mime_type, bool allow_wildcard, bool* is_stale,
diff --git a/content/browser/prerender/prerender_attributes.cc b/content/browser/prerender/prerender_attributes.cc index 851baf06..caddceb 100644 --- a/content/browser/prerender/prerender_attributes.cc +++ b/content/browser/prerender/prerender_attributes.cc
@@ -24,7 +24,8 @@ const GURL& initiator_url, int initiator_process_id, absl::optional<blink::LocalFrameToken> initiator_frame_token, - ukm::SourceId initiator_ukm_id) + ukm::SourceId initiator_ukm_id, + ui::PageTransition transition_type) : prerendering_url(prerendering_url), trigger_type(trigger_type), embedder_histogram_suffix(embedder_histogram_suffix), @@ -33,7 +34,8 @@ initiator_url(initiator_url), initiator_process_id(initiator_process_id), initiator_frame_token(std::move(initiator_frame_token)), - initiator_ukm_id(initiator_ukm_id) {} + initiator_ukm_id(initiator_ukm_id), + transition_type(transition_type) {} PrerenderAttributes::~PrerenderAttributes() = default; @@ -49,6 +51,7 @@ initiator_url(attributes.initiator_url), initiator_process_id(attributes.initiator_process_id), initiator_frame_token(attributes.initiator_frame_token), - initiator_ukm_id(attributes.initiator_ukm_id) {} + initiator_ukm_id(attributes.initiator_ukm_id), + transition_type(attributes.transition_type) {} } // namespace content
diff --git a/content/browser/prerender/prerender_attributes.h b/content/browser/prerender/prerender_attributes.h index 026b1410..ad86a0e 100644 --- a/content/browser/prerender/prerender_attributes.h +++ b/content/browser/prerender/prerender_attributes.h
@@ -13,6 +13,7 @@ #include "services/metrics/public/cpp/ukm_source_id.h" #include "third_party/blink/public/mojom/navigation/navigation_params.mojom.h" #include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h" +#include "ui/base/page_transition_types.h" namespace content { @@ -27,7 +28,8 @@ const GURL& initiator_url, int initiator_process_id, absl::optional<blink::LocalFrameToken> initiator_frame_token, - ukm::SourceId initiator_ukm_id); + ukm::SourceId initiator_ukm_id, + ui::PageTransition transition_type); ~PrerenderAttributes(); PrerenderAttributes(const PrerenderAttributes&); PrerenderAttributes& operator=(const PrerenderAttributes&) = delete; @@ -63,6 +65,8 @@ // browser. ukm::SourceId initiator_ukm_id; + ui::PageTransition transition_type; + // Serialises this struct into a trace. void WriteIntoTrace(perfetto::TracedValue trace_context) const; };
diff --git a/content/browser/prerender/prerender_browsertest.cc b/content/browser/prerender/prerender_browsertest.cc index 98ca950..506bf450 100644 --- a/content/browser/prerender/prerender_browsertest.cc +++ b/content/browser/prerender/prerender_browsertest.cc
@@ -4460,6 +4460,8 @@ PrerenderBrowserTest, CancelEmbedderTriggeredPrerenderingSameOriginRedirection) { base::HistogramTester histogram_tester; + const GURL kInitialUrl = GetUrl("/empty.html"); + ASSERT_TRUE(NavigateToURL(shell(), kInitialUrl)); const GURL kRedirectedUrl = GetUrl("/empty.html?prerender"); const GURL kPrerenderingUrl = GetUrl("/server-redirect?" + kRedirectedUrl.spec()); @@ -4485,6 +4487,8 @@ PrerenderBrowserTest, CancelEmbedderTriggeredPrerenderingCrossOriginRedirection) { base::HistogramTester histogram_tester; + const GURL kInitialUrl = GetUrl("/empty.html"); + ASSERT_TRUE(NavigateToURL(shell(), kInitialUrl)); const GURL kRedirectedUrl = GetCrossOriginUrl("/empty.html?prerender"); const GURL kPrerenderingUrl = GetUrl("/server-redirect?" + kRedirectedUrl.spec());
diff --git a/content/browser/prerender/prerender_host.cc b/content/browser/prerender/prerender_host.cc index afb35d8..030a5fb 100644 --- a/content/browser/prerender/prerender_host.cc +++ b/content/browser/prerender/prerender_host.cc
@@ -336,6 +336,8 @@ load_url_params.initiator_origin = attributes_.initiator_origin; load_url_params.initiator_process_id = attributes_.initiator_process_id; load_url_params.initiator_frame_token = attributes_.initiator_frame_token; + load_url_params.transition_type = + ui::PageTransitionFromInt(attributes_.transition_type); // Just use the referrer from attributes, as NoStatePrefetch does. // TODO(crbug.com/1176054): For cross-origin prerender, follow the spec steps @@ -645,20 +647,8 @@ return false; } - // The initial navigation value is set to 0 as this is the default for - // LoadURLParams. - // TODO(crbug.com/1234291): update this check when omnibox - // prerendering is implemented. Currently, browser initiated prerendering - // will skip this check as short-termed workaround, since the implementation - // of updating transition is still absent. This workaround will be removed - // once the update mechanism is done. - if (!IsBrowserInitiated()) { - DCHECK(ui::PageTransitionTypeIncludingQualifiersIs( - ui::PageTransitionFromInt(common_params_->transition), - ui::PAGE_TRANSITION_FIRST)); - if (potential_activation.transition != common_params_->transition) { - return false; - } + if (potential_activation.transition != common_params_->transition) { + return false; } DCHECK_EQ(common_params_->navigation_type,
diff --git a/content/browser/prerender/prerender_host_registry_unittest.cc b/content/browser/prerender/prerender_host_registry_unittest.cc index 40e2f02..531d097 100644 --- a/content/browser/prerender/prerender_host_registry_unittest.cc +++ b/content/browser/prerender/prerender_host_registry_unittest.cc
@@ -47,11 +47,11 @@ PrerenderTriggerType trigger_type, const std::string& embedder_histogram_suffix, RenderFrameHostImpl* rfh) { - return PrerenderAttributes(url, trigger_type, embedder_histogram_suffix, - Referrer(), rfh->GetLastCommittedOrigin(), - rfh->GetLastCommittedURL(), - rfh->GetProcess()->GetID(), rfh->GetFrameToken(), - rfh->GetPageUkmSourceId()); + return PrerenderAttributes( + url, trigger_type, embedder_histogram_suffix, Referrer(), + rfh->GetLastCommittedOrigin(), rfh->GetLastCommittedURL(), + rfh->GetProcess()->GetID(), rfh->GetFrameToken(), + rfh->GetPageUkmSourceId(), ui::PAGE_TRANSITION_LINK); } // This definition is needed because this constant is odr-used in gtest macros.
diff --git a/content/browser/prerender/prerender_host_unittest.cc b/content/browser/prerender/prerender_host_unittest.cc index f6e2a99..1198e66 100644 --- a/content/browser/prerender/prerender_host_unittest.cc +++ b/content/browser/prerender/prerender_host_unittest.cc
@@ -110,12 +110,12 @@ PrerenderAttributes GeneratePrerenderAttributes(const GURL& url, RenderFrameHostImpl* rfh) { - return PrerenderAttributes(url, PrerenderTriggerType::kSpeculationRule, - /*embedder_histogram_suffix=*/"", Referrer(), - rfh->GetLastCommittedOrigin(), - rfh->GetLastCommittedURL(), - rfh->GetProcess()->GetID(), rfh->GetFrameToken(), - rfh->GetPageUkmSourceId()); + return PrerenderAttributes( + url, PrerenderTriggerType::kSpeculationRule, + /*embedder_histogram_suffix=*/"", Referrer(), + rfh->GetLastCommittedOrigin(), rfh->GetLastCommittedURL(), + rfh->GetProcess()->GetID(), rfh->GetFrameToken(), + rfh->GetPageUkmSourceId(), ui::PAGE_TRANSITION_LINK); } class TestWebContentsDelegate : public WebContentsDelegate {
diff --git a/content/browser/process_internals/process_internals_handler_impl.cc b/content/browser/process_internals/process_internals_handler_impl.cc index 4f29c82..192be797 100644 --- a/content/browser/process_internals/process_internals_handler_impl.cc +++ b/content/browser/process_internals/process_internals_handler_impl.cc
@@ -48,12 +48,8 @@ static_cast<SiteInstanceImpl*>(frame->GetSiteInstance()); frame_info->site_instance = ::mojom::SiteInstanceInfo::New(); frame_info->site_instance->id = site_instance->GetId().value(); - - auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); frame_info->site_instance->locked = - policy->GetProcessLock(site_instance->GetProcess()->GetID()) - .is_locked_to_site(); - + site_instance->GetProcess()->GetProcessLock().is_locked_to_site(); frame_info->site_instance->site_url = site_instance->HasSite() ? absl::make_optional(site_instance->GetSiteInfo().site_url())
diff --git a/content/browser/renderer_host/cross_origin_opener_policy_access_report_manager.cc b/content/browser/renderer_host/cross_origin_opener_policy_access_report_manager.cc index 4d63abf..09a6326 100644 --- a/content/browser/renderer_host/cross_origin_opener_policy_access_report_manager.cc +++ b/content/browser/renderer_host/cross_origin_opener_policy_access_report_manager.cc
@@ -34,49 +34,25 @@ return absl::nullopt; } -// Used to keep track of windows for which we need to send report or register -// metrics upon access. -struct WindowToMonitor { - WindowToMonitor(FrameTreeNode* top_level_frame, - bool send_reports, - bool register_metrics) - : top_level_frame(top_level_frame), - send_reports(send_reports), - register_metrics(register_metrics) {} - - FrameTreeNode* top_level_frame = nullptr; - bool send_reports = false; - bool register_metrics = false; -}; - // Find all the related windows that might try to access the new document in // |frame|, but are in a different virtual browsing context group. -std::vector<WindowToMonitor> CollectOtherWindowForCoopAccess( +std::vector<FrameTreeNode*> CollectOtherWindowForCoopAccess( FrameTreeNode* frame) { DCHECK(frame->IsMainFrame()); int virtual_browsing_context_group = frame->current_frame_host()->virtual_browsing_context_group(); - int soap_by_default_virtual_browsing_context_group = - frame->current_frame_host() - ->soap_by_default_virtual_browsing_context_group(); - std::vector<WindowToMonitor> out; + std::vector<FrameTreeNode*> out; for (RenderFrameHostImpl* rfh : frame->current_frame_host() ->delegate() ->GetActiveTopLevelDocumentsInBrowsingContextGroup( frame->current_frame_host())) { // Filter out windows from the same virtual browsing context group. - bool send_reports = - rfh->virtual_browsing_context_group() != virtual_browsing_context_group; - bool register_metrics = - rfh->soap_by_default_virtual_browsing_context_group() != - soap_by_default_virtual_browsing_context_group; - if (!send_reports && !register_metrics) + if (rfh->virtual_browsing_context_group() == virtual_browsing_context_group) continue; - out.emplace_back(WindowToMonitor(rfh->frame_tree_node(), send_reports, - register_metrics)); + out.push_back(rfh->frame_tree_node()); } return out; } @@ -97,50 +73,38 @@ // Find all the related windows that might try to access the new document, // but are from a different virtual browsing context group. - std::vector<WindowToMonitor> other_windows = + std::vector<FrameTreeNode*> other_main_frames = CollectOtherWindowForCoopAccess(frame); CrossOriginOpenerPolicyAccessReportManager* access_manager_frame = frame->current_frame_host()->coop_access_report_manager(); - for (WindowToMonitor& other : other_windows) { + for (FrameTreeNode* other : other_main_frames) { CrossOriginOpenerPolicyAccessReportManager* access_manager_other = - other.top_level_frame->current_frame_host() - ->coop_access_report_manager(); + other->current_frame_host()->coop_access_report_manager(); // If the current frame has a reporter, install the access monitors to // monitor the accesses between this frame and the other frame. - access_manager_frame->MonitorAccesses(frame, other.top_level_frame, - other.send_reports, - other.register_metrics); - access_manager_frame->MonitorAccesses(other.top_level_frame, frame, - other.send_reports, - other.register_metrics); + access_manager_frame->MonitorAccesses(frame, other); + access_manager_frame->MonitorAccesses(other, frame); // If the other frame has a reporter, install the access monitors to monitor // the accesses between this frame and the other frame. - access_manager_other->MonitorAccesses(frame, other.top_level_frame, - other.send_reports, - other.register_metrics); - access_manager_other->MonitorAccesses(other.top_level_frame, frame, - other.send_reports, - other.register_metrics); + access_manager_other->MonitorAccesses(frame, other); + access_manager_other->MonitorAccesses(other, frame); } } void CrossOriginOpenerPolicyAccessReportManager::MonitorAccesses( FrameTreeNode* accessing_node, - FrameTreeNode* accessed_node, - bool send_reports, - bool register_metrics) { + FrameTreeNode* accessed_node) { DCHECK_NE(accessing_node, accessed_node); DCHECK(accessing_node->current_frame_host()->coop_access_report_manager() == this || accessed_node->current_frame_host()->coop_access_report_manager() == this); - if (!coop_reporter_.get()) - send_reports = false; + return; // TODO(arthursonzogni): DCHECK same browsing context group. // TODO(arthursonzogni): DCHECK different virtual browsing context group. @@ -166,11 +130,9 @@ accessing_node->current_frame_host() ->GetAssociatedLocalMainFrame() ->InstallCoopAccessMonitor( - *accessed_window_token, register_metrics, - send_reports - ? coop_reporter_->CreateReporterParams( - access_from_coop_page, accessing_node, accessed_node) - : nullptr); + *accessed_window_token, + coop_reporter_->CreateReporterParams(access_from_coop_page, + accessing_node, accessed_node)); } // static
diff --git a/content/browser/renderer_host/cross_origin_opener_policy_access_report_manager.h b/content/browser/renderer_host/cross_origin_opener_policy_access_report_manager.h index 44b0f55..a0b825e 100644 --- a/content/browser/renderer_host/cross_origin_opener_policy_access_report_manager.h +++ b/content/browser/renderer_host/cross_origin_opener_policy_access_report_manager.h
@@ -42,9 +42,7 @@ // Install the CoopAccessMonitors monitoring accesses from |accessing_node| // toward |accessed_node|. void MonitorAccesses(FrameTreeNode* accessing_node, - FrameTreeNode* accessed_node, - bool send_reports, - bool register_metrics); + FrameTreeNode* accessed_node); std::unique_ptr<CrossOriginOpenerPolicyReporter> coop_reporter_; };
diff --git a/content/browser/renderer_host/navigation_controller_impl_browsertest.cc b/content/browser/renderer_host/navigation_controller_impl_browsertest.cc index b39c84f..41ca3360 100644 --- a/content/browser/renderer_host/navigation_controller_impl_browsertest.cc +++ b/content/browser/renderer_host/navigation_controller_impl_browsertest.cc
@@ -15434,7 +15434,6 @@ return; // Verify the error page committed to the error page process. - auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); EXPECT_NE(success_site_instance, error_site_instance); EXPECT_TRUE( success_site_instance->IsRelatedSiteInstance(error_site_instance.get())); @@ -15442,8 +15441,8 @@ error_site_instance->GetProcess()->GetID()); EXPECT_EQ(GURL(kUnreachableWebDataURL), error_site_instance->GetSiteURL()); - EXPECT_TRUE(policy->GetProcessLock(error_site_instance->GetProcess()->GetID()) - .is_error_page()); + EXPECT_TRUE( + error_site_instance->GetProcess()->GetProcessLock().is_error_page()); } // Test to verify that LoadPostCommitErrorPage loads an error page in a subframe
diff --git a/content/browser/renderer_host/navigation_request.cc b/content/browser/renderer_host/navigation_request.cc index eea70788..f9766f1 100644 --- a/content/browser/renderer_host/navigation_request.cc +++ b/content/browser/renderer_host/navigation_request.cc
@@ -544,10 +544,7 @@ // Navigation.IsLockedProcess { - ChildProcessSecurityPolicyImpl* policy = - ChildProcessSecurityPolicyImpl::GetInstance(); - ProcessLock process_lock = - policy->GetProcessLock(new_rfh->GetProcess()->GetID()); + ProcessLock process_lock = new_rfh->GetProcess()->GetProcessLock(); UMA_HISTOGRAM_BOOLEAN("Navigation.IsLockedProcess", process_lock.is_locked_to_site()); if (common_params.url.SchemeIsHTTPOrHTTPS()) {
diff --git a/content/browser/renderer_host/navigator.cc b/content/browser/renderer_host/navigator.cc index 131d4f1..6324736 100644 --- a/content/browser/renderer_host/navigator.cc +++ b/content/browser/renderer_host/navigator.cc
@@ -267,12 +267,8 @@ if (RenderProcessHost::run_renderer_in_process()) return true; - ChildProcessSecurityPolicyImpl* security_policy = - ChildProcessSecurityPolicyImpl::GetInstance(); - ProcessLock process_lock = - security_policy->GetProcessLock(render_frame_host->GetProcess()->GetID()); - // In the case of error page process, any URL is allowed to commit. + ProcessLock process_lock = render_frame_host->GetProcess()->GetProcessLock(); if (process_lock.is_error_page()) return true; @@ -297,7 +293,7 @@ // the browser process must be terminated. // TODO(nasko): Convert to CHECK() once it is confirmed this is not // violated in reality. - if (!security_policy->HasWebUIBindings( + if (!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( render_frame_host->GetProcess()->GetID())) { base::debug::DumpWithoutCrashing(); }
diff --git a/content/browser/renderer_host/page_lifecycle_state_manager.cc b/content/browser/renderer_host/page_lifecycle_state_manager.cc index a656ef8..ca0616b 100644 --- a/content/browser/renderer_host/page_lifecycle_state_manager.cc +++ b/content/browser/renderer_host/page_lifecycle_state_manager.cc
@@ -177,8 +177,13 @@ if (blink::IsRestoredFromBackForwardCache(last_state_sent_to_renderer_, new_state)) { // We see that IPCs are not received by the renderer. Check that we are - // about to send and IPC to a live RVH. - DCHECK(render_view_host_impl_->IsRenderViewLive()); + // about to send an IPC to a live RVH. + if (!render_view_host_impl_->IsRenderViewLive()) { + blink::RecordUMAEventPageShowPersisted( + blink::EventPageShowPersisted::kYesInBrowserRenderViewNotLive); + NOTREACHED(); + } + // And that the mojo interface is connected. if (!render_view_host_impl_->GetAssociatedPageBroadcast() .is_connected()) { blink::RecordUMAEventPageShowPersisted(
diff --git a/content/browser/renderer_host/recently_destroyed_hosts.cc b/content/browser/renderer_host/recently_destroyed_hosts.cc index 5c86d921..3d879ce 100644 --- a/content/browser/renderer_host/recently_destroyed_hosts.cc +++ b/content/browser/renderer_host/recently_destroyed_hosts.cc
@@ -71,8 +71,7 @@ if (time_spent_running_unload_handlers > kRecentlyDestroyedStorageTimeout) return; - auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); - ProcessLock process_lock = policy->GetProcessLock(host->GetID()); + ProcessLock process_lock = host->GetProcessLock(); // Don't record sites with an empty process lock. This includes sites on // Android that are not isolated, and some special cases on desktop (e.g.,
diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc index 5ea5ec0e..efa4d9f6 100644 --- a/content/browser/renderer_host/render_frame_host_impl.cc +++ b/content/browser/renderer_host/render_frame_host_impl.cc
@@ -10130,9 +10130,7 @@ (is_same_document_navigation && renderer_url_info_.was_loaded_from_load_data_with_base_url)) { // Allow bypass if the process isn't locked. Otherwise run normal checks. - bypass_checks_for_webview = !ChildProcessSecurityPolicyImpl::GetInstance() - ->GetProcessLock(process->GetID()) - .is_locked_to_site(); + bypass_checks_for_webview = !process->GetProcessLock().is_locked_to_site(); } if (!bypass_checks_for_error_page && !bypass_checks_for_file_scheme && @@ -10217,11 +10215,7 @@ case CanCommitStatus::CANNOT_COMMIT_URL: DLOG(ERROR) << "CANNOT_COMMIT_URL url '" << url << "'" << " origin '" << origin << "'" - << " lock '" - << ChildProcessSecurityPolicyImpl::GetInstance() - ->GetProcessLock(process->GetID()) - .ToString() - << "'"; + << " lock '" << process->GetProcessLock().ToString() << "'"; VLOG(1) << "Blocked URL " << url.spec(); LogCannotCommitUrlCrashKeys(url, is_same_document_navigation, navigation_request); @@ -10233,11 +10227,7 @@ case CanCommitStatus::CANNOT_COMMIT_ORIGIN: DLOG(ERROR) << "CANNOT_COMMIT_ORIGIN url '" << url << "'" << " origin '" << origin << "'" - << " lock '" - << ChildProcessSecurityPolicyImpl::GetInstance() - ->GetProcessLock(process->GetID()) - .ToString() - << "'"; + << " lock '" << process->GetProcessLock().ToString() << "'"; DEBUG_ALIAS_FOR_ORIGIN(origin_debug_alias, origin); LogCannotCommitOriginCrashKeys(is_same_document_navigation, navigation_request); @@ -11295,6 +11285,11 @@ site_lock_key, ProcessLock::FromSiteInfo(GetSiteInstance()->GetSiteInfo()).ToString()); + static auto* const process_lock_key = base::debug::AllocateCrashKeyString( + "process_lock", base::debug::CrashKeySize::Size256); + base::debug::SetCrashKeyString(process_lock_key, + GetProcess()->GetProcessLock().ToString()); + if (!GetSiteInstance()->IsDefaultSiteInstance()) { static auto* const original_url_origin_key = base::debug::AllocateCrashKeyString("original_url_origin", @@ -12523,15 +12518,14 @@ } void RenderFrameHostImpl::GetPluginInfo(const GURL& url, - const url::Origin& main_frame_origin, const std::string& mime_type, GetPluginInfoCallback callback) { bool allow_wildcard = true; WebPluginInfo info; std::string actual_mime_type; bool found = PluginServiceImpl::GetInstance()->GetPluginInfo( - GetProcess()->GetID(), routing_id_, url, main_frame_origin, mime_type, - allow_wildcard, nullptr, &info, &actual_mime_type); + GetProcess()->GetID(), url, mime_type, allow_wildcard, nullptr, &info, + &actual_mime_type); std::move(callback).Run(found, info, actual_mime_type); }
diff --git a/content/browser/renderer_host/render_frame_host_impl.h b/content/browser/renderer_host/render_frame_host_impl.h index bc8d5f6..382b929 100644 --- a/content/browser/renderer_host/render_frame_host_impl.h +++ b/content/browser/renderer_host/render_frame_host_impl.h
@@ -2710,7 +2710,6 @@ int32_t plugin_child_id, const base::FilePath& path) override; void GetPluginInfo(const GURL& url, - const url::Origin& main_frame_origin, const std::string& mime_type, GetPluginInfoCallback callback) override; void DidCreateInProcessInstance(int32_t instance,
diff --git a/content/browser/renderer_host/render_frame_host_manager.cc b/content/browser/renderer_host/render_frame_host_manager.cc index d7cdf5e4..24138bd 100644 --- a/content/browser/renderer_host/render_frame_host_manager.cc +++ b/content/browser/renderer_host/render_frame_host_manager.cc
@@ -1175,8 +1175,7 @@ // TODO(creis): Remove this check after we've gathered enough information to // debug issues with browser-side security checks. https://crbug.com/931895. auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); - const ProcessLock process_lock = ProcessLock::FromSiteInfo( - navigation_rfh->GetSiteInstance()->GetSiteInfo()); + const auto process_lock = navigation_rfh->GetProcess()->GetProcessLock(); if (!process_lock.is_error_page() && request->common_params().url.IsStandard() && // TODO(https://crbug.com/888079): Replace `common_params().url` with
diff --git a/content/browser/renderer_host/render_frame_host_manager_browsertest.cc b/content/browser/renderer_host/render_frame_host_manager_browsertest.cc index 3f6b3b2..23314a7 100644 --- a/content/browser/renderer_host/render_frame_host_manager_browsertest.cc +++ b/content/browser/renderer_host/render_frame_host_manager_browsertest.cc
@@ -264,9 +264,7 @@ } bool HasErrorPageProcessLock(SiteInstance* site_instance) { - return ChildProcessSecurityPolicyImpl::GetInstance() - ->GetProcessLock(site_instance->GetProcess()->GetID()) - .is_error_page(); + return site_instance->GetProcess()->GetProcessLock().is_error_page(); } } // anonymous namespace @@ -8654,7 +8652,7 @@ EXPECT_EQ(siteless_url, web_contents->GetMainFrame()->GetLastCommittedURL()); RenderProcessHost* process1 = web_contents->GetMainFrame()->GetProcess(); EXPECT_FALSE(web_contents->GetMainFrame()->GetSiteInstance()->HasSite()); - auto process1_lock = policy->GetProcessLock(process1->GetID()); + auto process1_lock = process1->GetProcessLock(); EXPECT_FALSE(process1_lock.is_invalid()); EXPECT_TRUE(process1_lock.allows_any_site());
diff --git a/content/browser/site_instance_impl.cc b/content/browser/site_instance_impl.cc index 8d2e4235..28f0c58 100644 --- a/content/browser/site_instance_impl.cc +++ b/content/browser/site_instance_impl.cc
@@ -1160,7 +1160,7 @@ void SiteInstanceImpl::LockProcessIfNeeded() { ChildProcessSecurityPolicyImpl* policy = ChildProcessSecurityPolicyImpl::GetInstance(); - ProcessLock process_lock = policy->GetProcessLock(process_->GetID()); + ProcessLock process_lock = process_->GetProcessLock(); StoragePartitionImpl* storage_partition = static_cast<StoragePartitionImpl*>(process_->GetStoragePartition()); if (!has_site_) {
diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc index 9b67888..1d414698 100644 --- a/content/browser/site_per_process_browsertest.cc +++ b/content/browser/site_per_process_browsertest.cc
@@ -14141,8 +14141,8 @@ const GURL bad_url = GURL("https://b.com"); // Sanity check the process lock logic. - auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); - int process_id = root->current_frame_host()->GetProcess()->GetID(); + auto process_lock = + root->current_frame_host()->GetProcess()->GetProcessLock(); IsolationContext isolation_context( shell()->web_contents()->GetBrowserContext()); ProcessLock start_url_lock = ProcessLock::FromSiteInfo( @@ -14151,9 +14151,9 @@ SiteInfo::CreateForTesting(isolation_context, another_url)); ProcessLock bad_url_lock = ProcessLock::FromSiteInfo( SiteInfo::CreateForTesting(isolation_context, bad_url)); - EXPECT_EQ(start_url_lock, policy->GetProcessLock(process_id)); - EXPECT_EQ(another_url_lock, policy->GetProcessLock(process_id)); - EXPECT_NE(bad_url_lock, policy->GetProcessLock(process_id)); + EXPECT_EQ(start_url_lock, process_lock); + EXPECT_EQ(another_url_lock, process_lock); + EXPECT_NE(bad_url_lock, process_lock); // Leave the commit URL alone, so the URL checks will pass, but change the // origin to one that does not match the origin lock of the process.
diff --git a/content/browser/speculation_rules/speculation_host_impl.cc b/content/browser/speculation_rules/speculation_host_impl.cc index 81c960f..6b87ac6 100644 --- a/content/browser/speculation_rules/speculation_host_impl.cc +++ b/content/browser/speculation_rules/speculation_host_impl.cc
@@ -137,7 +137,7 @@ /*embedder_histogram_suffix=*/"", Referrer(*(it->referrer)), rfhi->GetLastCommittedOrigin(), rfhi->GetLastCommittedURL(), rfhi->GetProcess()->GetID(), rfhi->GetFrameToken(), - rfhi->GetPageUkmSourceId()), + rfhi->GetPageUkmSourceId(), ui::PAGE_TRANSITION_LINK), *web_contents); if (prerender_host_id != RenderFrameHost::kNoFrameTreeNodeId) started_prerender_host_ids_.insert(prerender_host_id);
diff --git a/content/browser/storage_partition_impl_unittest.cc b/content/browser/storage_partition_impl_unittest.cc index b0127bc..5eca688 100644 --- a/content/browser/storage_partition_impl_unittest.cc +++ b/content/browser/storage_partition_impl_unittest.cc
@@ -1757,9 +1757,16 @@ // Ensure code cache is initialized. base::RunLoop().RunUntilIdle(); EXPECT_TRUE(partition->GetGeneratedCodeCacheContext() != nullptr); - EXPECT_EQ(partition->GetGeneratedCodeCacheContext() - ->generated_webui_js_code_cache(), - nullptr); + base::RunLoop run_loop; + auto* context = partition->GetGeneratedCodeCacheContext(); + GeneratedCodeCacheContext::RunOrPostTask( + context, FROM_HERE, base::BindLambdaForTesting([&]() { + EXPECT_EQ(partition->GetGeneratedCodeCacheContext() + ->generated_webui_js_code_cache(), + nullptr); + run_loop.Quit(); + })); + run_loop.Run(); } TEST_F(StoragePartitionImplTest, ClearCodeCacheIncognito) {
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index f8c23d687..a3da81f 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc
@@ -9160,11 +9160,15 @@ const GURL& prerendering_url, PrerenderTriggerType trigger_type, const std::string& embedder_histogram_suffix) { + // TODO(https://crbug.com/1166085): Use the ui::PageTransition value passed + // from Embedders for flexibility. PrerenderAttributes attributes( prerendering_url, trigger_type, embedder_histogram_suffix, content::Referrer(), /*initiator_origin=*/absl::nullopt, prerendering_url, content::ChildProcessHost::kInvalidUniqueID, - /*initiator_frame_token=*/absl::nullopt, ukm::kInvalidSourceId); + /*initiator_frame_token=*/absl::nullopt, ukm::kInvalidSourceId, + ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED | + ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)); int frame_tree_node_id = GetPrerenderHostRegistry()->CreateAndStartHost(attributes, *this);
diff --git a/content/browser/webrtc/webrtc_getusermedia_browsertest.cc b/content/browser/webrtc/webrtc_getusermedia_browsertest.cc index db53766..461d410 100644 --- a/content/browser/webrtc/webrtc_getusermedia_browsertest.cc +++ b/content/browser/webrtc/webrtc_getusermedia_browsertest.cc
@@ -143,10 +143,9 @@ ASSERT_TRUE(parsed_json.value) << parsed_json.error_message; EXPECT_EQ(parsed_json.value->type(), base::Value::Type::LIST); - base::ListValue* values; - ASSERT_TRUE(parsed_json.value->GetAsList(&values)); + ASSERT_TRUE(parsed_json.value->is_list()); - for (const auto& entry : values->GetList()) { + for (const auto& entry : parsed_json.value->GetList()) { const base::DictionaryValue* dict; std::string kind; std::string device_id;
diff --git a/content/browser/webui/web_ui_message_handler.cc b/content/browser/webui/web_ui_message_handler.cc index 94844ee..c86394c 100644 --- a/content/browser/webui/web_ui_message_handler.cc +++ b/content/browser/webui/web_ui_message_handler.cc
@@ -67,9 +67,10 @@ std::u16string WebUIMessageHandler::ExtractStringValue( const base::ListValue* value) { - std::u16string string16_value; - if (value->GetString(0, &string16_value)) - return string16_value; + base::Value::ConstListView list_view = value->GetList(); + if (0u < list_view.size() && list_view[0].is_string()) + return base::UTF8ToUTF16(list_view[0].GetString()); + NOTREACHED(); return std::u16string(); }
diff --git a/content/browser/webui/web_ui_navigation_browsertest.cc b/content/browser/webui/web_ui_navigation_browsertest.cc index 8d55a97..5f989d6 100644 --- a/content/browser/webui/web_ui_navigation_browsertest.cc +++ b/content/browser/webui/web_ui_navigation_browsertest.cc
@@ -680,8 +680,7 @@ webui_rfh->GetProcess()->GetID())); EXPECT_FALSE( webui_site_instance->GetSiteInfo().process_lock_url().is_empty()); - EXPECT_EQ(ChildProcessSecurityPolicyImpl::GetInstance()->GetProcessLock( - root->current_frame_host()->GetProcess()->GetID()), + EXPECT_EQ(root->current_frame_host()->GetProcess()->GetProcessLock(), ProcessLock::FromSiteInfo(webui_site_instance->GetSiteInfo())); TestUntrustedDataSourceHeaders headers; @@ -875,8 +874,7 @@ EXPECT_EQ(chrome_url, webui_rfh->GetLastCommittedURL()); EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( webui_rfh->GetProcess()->GetID())); - EXPECT_EQ(ChildProcessSecurityPolicyImpl::GetInstance()->GetProcessLock( - root->current_frame_host()->GetProcess()->GetID()), + EXPECT_EQ(root->current_frame_host()->GetProcess()->GetProcessLock(), ProcessLock::FromSiteInfo(webui_site_instance->GetSiteInfo())); GURL web_url(embedded_test_server()->GetURL("/title2.html")); @@ -894,8 +892,7 @@ root->current_frame_host()->GetSiteInstance())); EXPECT_FALSE(ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( root->current_frame_host()->GetProcess()->GetID())); - EXPECT_NE(ChildProcessSecurityPolicyImpl::GetInstance()->GetProcessLock( - root->current_frame_host()->GetProcess()->GetID()), + EXPECT_NE(root->current_frame_host()->GetProcess()->GetProcessLock(), ProcessLock::FromSiteInfo(webui_site_instance->GetSiteInfo())); }
diff --git a/content/common/pepper_plugin.mojom b/content/common/pepper_plugin.mojom index c20ff82..253aaac 100644 --- a/content/common/pepper_plugin.mojom +++ b/content/common/pepper_plugin.mojom
@@ -29,7 +29,6 @@ // found plugin. [Sync] GetPluginInfo(url.mojom.Url url, - url.mojom.Origin main_frame_origin, string mime_type) => (bool found, content.mojom.WebPluginInfo plugin_info,
diff --git a/content/public/browser/plugin_service.h b/content/public/browser/plugin_service.h index edcc4c17..d7621a6d 100644 --- a/content/public/browser/plugin_service.h +++ b/content/public/browser/plugin_service.h
@@ -23,10 +23,6 @@ class FilePath; } -namespace url { -class Origin; -} - namespace content { class BrowserContext; @@ -76,9 +72,7 @@ // via |is_stale| and returns whether or not the plugin can be found. // This must be called from the UI thread. virtual bool GetPluginInfo(int render_process_id, - int render_frame_id, const GURL& url, - const url::Origin& main_frame_origin, const std::string& mime_type, bool allow_wildcard, bool* is_stale,
diff --git a/content/public/browser/render_process_host.h b/content/public/browser/render_process_host.h index 1c024257..a2cc7b0 100644 --- a/content/public/browser/render_process_host.h +++ b/content/public/browser/render_process_host.h
@@ -509,16 +509,16 @@ virtual bool HostHasNotBeenUsed() = 0; // Locks this RenderProcessHost to documents compatible with |process_lock|. - // This method is public so that it can be called from SiteInstanceImpl, and + // This method is public so that it can be called from within //content, and // used by MockRenderProcessHost. It isn't meant to be called outside of - // content. + // //content. virtual void SetProcessLock(const IsolationContext& isolation_context, const ProcessLock& process_lock) = 0; // Returns the ProcessLock associated with this process. - // This method is public so that it can be called from SiteInstanceImpl, and + // This method is public so that it can be called from within //content, and // used by MockRenderProcessHost. It isn't meant to be called outside of - // content. + // //content. virtual ProcessLock GetProcessLock() = 0; // Returns true if this process is locked to a particular site-specific
diff --git a/content/public/browser/web_ui_controller.h b/content/public/browser/web_ui_controller.h index 6aeac29..79677967 100644 --- a/content/public/browser/web_ui_controller.h +++ b/content/public/browser/web_ui_controller.h
@@ -101,10 +101,10 @@ // This macro declares a static variable inside the class that inherits from // WebUIController. The address of the static variable is used as the unique // Type for the subclass. -#define WEB_UI_CONTROLLER_TYPE_DECL() \ - static constexpr int kWebUIControllerType = 0; \ - Type GetType() final; \ - friend class content::WebUIController; \ +#define WEB_UI_CONTROLLER_TYPE_DECL() \ + static const int kWebUIControllerType = 0; \ + Type GetType() final; \ + friend class content::WebUIController; \ friend class content::WebUIBrowserInterfaceBrokerRegistry // This macro instantiates the static variable declared by the previous macro.
diff --git a/content/public/common/content_features.cc b/content/public/common/content_features.cc index d3ff9ae..c970551 100644 --- a/content/public/common/content_features.cc +++ b/content/public/common/content_features.cc
@@ -317,8 +317,14 @@ // Whether to initialize the font manager when the renderer starts on a // background thread. -const base::Feature kFontManagerEarlyInit{"FontManagerEarlyInit", - base::FEATURE_DISABLED_BY_DEFAULT}; +const base::Feature kFontManagerEarlyInit { + "FontManagerEarlyInit", +#if defined(OS_ANDROID) + base::FEATURE_ENABLED_BY_DEFAULT +#else + base::FEATURE_DISABLED_BY_DEFAULT +#endif +}; // Enables fixes for matching src: local() for web fonts correctly against full // font name or postscript name. Rolling out behind a flag, as enabling this @@ -499,7 +505,7 @@ // Enables optimizations for renderer->browser mojo calls to avoid waiting on // the UI thread during navigation. const base::Feature kNavigationThreadingOptimizations{ - "NavigationThreadingOptimizations", base::FEATURE_DISABLED_BY_DEFAULT}; + "NavigationThreadingOptimizations", base::FEATURE_ENABLED_BY_DEFAULT}; // If the network service is enabled, runs it in process. const base::Feature kNetworkServiceInProcess {
diff --git a/content/public/test/DEPS b/content/public/test/DEPS index d601abe..6d534eb 100644 --- a/content/public/test/DEPS +++ b/content/public/test/DEPS
@@ -22,6 +22,7 @@ "+components/leveldb_proto/public", "+components/network_session_configurator/common/network_switches.h", "+components/services/storage/public", + "+components/startup_metric_utils/browser", "+components/viz/client", "+components/viz/common", "+components/viz/host",
diff --git a/content/public/test/browser_test_base.cc b/content/public/test/browser_test_base.cc index 8c181cab..e5f121f5 100644 --- a/content/public/test/browser_test_base.cc +++ b/content/public/test/browser_test_base.cc
@@ -40,6 +40,7 @@ #include "base/trace_event/typed_macros.h" #include "build/build_config.h" #include "build/chromeos_buildflags.h" +#include "components/startup_metric_utils/browser/startup_metric_utils.h" #include "components/tracing/common/tracing_switches.h" #include "components/variations/variations_ids_provider.h" #include "content/browser/browser_main_loop.h" @@ -567,6 +568,11 @@ // things up manually. A meager re-implementation of ContentMainRunnerImpl // follows. + // Unlike other platforms, android_browsertests can reuse the same process for + // multiple tests. Need to reset startup metrics to allow recording them + // again. + startup_metric_utils::ResetSessionForTesting(); + base::i18n::AllowMultipleInitializeCallsForTesting(); base::i18n::InitializeICU(); @@ -824,15 +830,14 @@ base::ScopedDisallowBlocking disallow_blocking; - // Since ProxyRunTestOnMainThreadLoop() replaces the main message loop, we - // need to invoke the OnFirstIdle() phase ourselves. + // Flush remaining startup tasks to make sure the + // BrowserMainParts::OnFirstIdle phase has occurred before entering the + // test body. base::RunLoop flush_startup_tasks; flush_startup_tasks.RunUntilIdle(); // Make sure there isn't an odd caller which reached |flush_startup_tasks| // statically via base::RunLoop::QuitCurrent*Deprecated(). DCHECK(!flush_startup_tasks.AnyQuitCalled()); - if (browser_main_parts_) - browser_main_parts_->OnFirstIdle(); } std::unique_ptr<InitialNavigationObserver> initial_navigation_observer;
diff --git a/content/public/test/mock_render_process_host.cc b/content/public/test/mock_render_process_host.cc index c581bb80..f9bea4b0 100644 --- a/content/public/test/mock_render_process_host.cc +++ b/content/public/test/mock_render_process_host.cc
@@ -505,9 +505,7 @@ } bool MockRenderProcessHost::IsProcessLockedToSiteForTesting() { - ProcessLock lock = - ChildProcessSecurityPolicyImpl::GetInstance()->GetProcessLock(GetID()); - return lock.is_locked_to_site(); + return GetProcessLock().is_locked_to_site(); } void MockRenderProcessHost::BindCacheStorage(
diff --git a/content/renderer/java/gin_java_bridge_value_converter_unittest.cc b/content/renderer/java/gin_java_bridge_value_converter_unittest.cc index 82058249..13e6c0a 100644 --- a/content/renderer/java/gin_java_bridge_value_converter_unittest.cc +++ b/content/renderer/java/gin_java_bridge_value_converter_unittest.cc
@@ -145,16 +145,13 @@ std::unique_ptr<base::Value> list_value( converter->FromV8Value(v8_typed_array, context)); ASSERT_TRUE(list_value.get()) << typed_array_type; - EXPECT_TRUE(list_value->is_list()) << typed_array_type; - base::ListValue* list; - ASSERT_TRUE(list_value->GetAsList(&list)) << typed_array_type; - EXPECT_EQ(1u, list->GetList().size()) << typed_array_type; + ASSERT_TRUE(list_value->is_list()) << typed_array_type; + EXPECT_EQ(1u, list_value->GetList().size()) << typed_array_type; - const base::Value* value; - list->Get(0, &value); + const auto value = list_value->GetList().cbegin(); if (value->type() == base::Value::Type::BINARY) { std::unique_ptr<const GinJavaBridgeValue> gin_value( - GinJavaBridgeValue::FromValue(value)); + GinJavaBridgeValue::FromValue(&*value)); EXPECT_EQ(gin_value->GetType(), GinJavaBridgeValue::TYPE_UINT32); uint32_t first_element = 0; ASSERT_TRUE(gin_value->GetAsUInt32(&first_element));
diff --git a/content/renderer/pepper/pepper_platform_audio_input.cc b/content/renderer/pepper/pepper_platform_audio_input.cc index 41aad81..444fcf62 100644 --- a/content/renderer/pepper/pepper_platform_audio_input.cc +++ b/content/renderer/pepper/pepper_platform_audio_input.cc
@@ -19,7 +19,7 @@ #include "media/audio/audio_source_parameters.h" #include "ppapi/shared_impl/ppb_audio_config_shared.h" #include "third_party/blink/public/platform/task_type.h" -#include "third_party/blink/public/web/modules/media/audio/web_audio_input_ipc_factory.h" +#include "third_party/blink/public/web/modules/media/audio/audio_input_ipc_factory.h" #include "third_party/blink/public/web/web_local_frame.h" namespace content { @@ -176,7 +176,7 @@ DCHECK(io_task_runner_->BelongsToCurrentThread()); if (ipc_startup_state_ != kStopped) - ipc_ = blink::WebAudioInputIPCFactory::GetInstance().CreateAudioInputIPC( + ipc_ = blink::AudioInputIPCFactory::GetInstance().CreateAudioInputIPC( render_frame_token_, media::AudioSourceParameters(session_id)); if (!ipc_) return;
diff --git a/content/renderer/pepper/pepper_platform_audio_output.cc b/content/renderer/pepper/pepper_platform_audio_output.cc index 5959db75..c98ea52 100644 --- a/content/renderer/pepper/pepper_platform_audio_output.cc +++ b/content/renderer/pepper/pepper_platform_audio_output.cc
@@ -14,7 +14,7 @@ #include "content/child/child_process.h" #include "content/renderer/pepper/audio_helper.h" #include "ppapi/shared_impl/ppb_audio_config_shared.h" -#include "third_party/blink/public/web/modules/media/audio/web_audio_output_ipc_factory.h" +#include "third_party/blink/public/web/modules/media/audio/audio_output_ipc_factory.h" namespace content { @@ -136,7 +136,7 @@ DCHECK(client); client_ = client; - ipc_ = blink::WebAudioOutputIPCFactory::GetInstance().CreateAudioOutputIPC( + ipc_ = blink::AudioOutputIPCFactory::GetInstance().CreateAudioOutputIPC( source_frame_token); CHECK(ipc_);
diff --git a/content/renderer/pepper/pepper_platform_audio_output_dev.cc b/content/renderer/pepper/pepper_platform_audio_output_dev.cc index b5e203c..dff7b02 100644 --- a/content/renderer/pepper/pepper_platform_audio_output_dev.cc +++ b/content/renderer/pepper/pepper_platform_audio_output_dev.cc
@@ -22,7 +22,7 @@ #include "content/renderer/render_frame_impl.h" #include "media/audio/audio_device_description.h" #include "ppapi/shared_impl/ppb_audio_config_shared.h" -#include "third_party/blink/public/web/modules/media/audio/web_audio_output_ipc_factory.h" +#include "third_party/blink/public/web/modules/media/audio/audio_output_ipc_factory.h" #include "third_party/blink/public/web/web_local_frame.h" namespace { @@ -261,7 +261,7 @@ client_ = client; - ipc_ = blink::WebAudioOutputIPCFactory::GetInstance().CreateAudioOutputIPC( + ipc_ = blink::AudioOutputIPCFactory::GetInstance().CreateAudioOutputIPC( render_frame->GetWebFrame()->GetLocalFrameToken()); CHECK(ipc_);
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index a78389d..fb0445b 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc
@@ -193,7 +193,7 @@ #include "third_party/blink/public/platform/web_vector.h" #include "third_party/blink/public/web/blink.h" #include "third_party/blink/public/web/modules/media/audio/audio_device_factory.h" -#include "third_party/blink/public/web/modules/media/audio/web_audio_output_ipc_factory.h" +#include "third_party/blink/public/web/modules/media/audio/audio_output_ipc_factory.h" #include "third_party/blink/public/web/modules/media/webmediaplayer_util.h" #include "third_party/blink/public/web/modules/mediastream/web_media_stream_device_observer.h" #include "third_party/blink/public/web/web_autofill_client.h" @@ -2007,8 +2007,8 @@ GetContentClient()->renderer()->RenderFrameCreated(this); } - // blink::WebAudioOutputIPCFactory::io_task_runner_ may be null in tests. - auto& factory = blink::WebAudioOutputIPCFactory::GetInstance(); + // blink::AudioOutputIPCFactory::io_task_runner_ may be null in tests. + auto& factory = blink::AudioOutputIPCFactory::GetInstance(); if (factory.io_task_runner()) { factory.RegisterRemoteFactory(GetWebFrame()->GetLocalFrameToken(), GetBrowserInterfaceBroker()); @@ -3341,9 +3341,8 @@ WebPluginInfo info; std::string mime_type; bool found = false; - GetPepperHost()->GetPluginInfo(params.url, frame_->Top()->GetSecurityOrigin(), - params.mime_type.Utf8(), &found, &info, - &mime_type); + GetPepperHost()->GetPluginInfo(params.url, params.mime_type.Utf8(), &found, + &info, &mime_type); if (!found) return nullptr; @@ -3699,8 +3698,8 @@ for (auto& observer : observers_) observer.WillDetach(); - // blink::WebAudioOutputIPCFactory::io_task_runner_ may be null in tests. - auto& factory = blink::WebAudioOutputIPCFactory::GetInstance(); + // blink::AudioOutputIPCFactory::io_task_runner_ may be null in tests. + auto& factory = blink::AudioOutputIPCFactory::GetInstance(); if (factory.io_task_runner()) factory.MaybeDeregisterRemoteFactory(GetWebFrame()->GetLocalFrameToken()); @@ -3877,8 +3876,8 @@ browser_interface_broker_receiver = browser_interface_broker_proxy_.Reset( agent_scheduling_group_.agent_group_scheduler().DefaultTaskRunner()); - // blink::WebAudioOutputIPCFactory::io_task_runner_ may be null in tests. - auto& factory = blink::WebAudioOutputIPCFactory::GetInstance(); + // blink::AudioOutputIPCFactory::io_task_runner_ may be null in tests. + auto& factory = blink::AudioOutputIPCFactory::GetInstance(); if (factory.io_task_runner()) { // The RendererAudioOutputStreamFactory must be readily accessible on the // IO thread when it's needed, because the main thread may block while
diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn index 82a89fe..3b0038c9 100644 --- a/content/test/BUILD.gn +++ b/content/test/BUILD.gn
@@ -438,6 +438,7 @@ "//cc:test_support", "//components/network_session_configurator/common:common", "//components/services/storage", + "//components/startup_metric_utils/browser", "//components/variations", "//components/viz/client", "//components/viz/host", @@ -1082,9 +1083,9 @@ "../browser/attribution_reporting/attributions_origin_trial_browsertest.cc", "../browser/attribution_reporting/source_declaration_browsertest.cc", "../browser/attribution_reporting/trigger_registration_browsertest.cc", + "../browser/back_forward_cache_basics_browsertest.cc", "../browser/back_forward_cache_browsertest.cc", "../browser/back_forward_cache_browsertest.h", - "../browser/back_forward_cache_basics_browsertest.cc", "../browser/back_forward_cache_features_browsertest.cc", "../browser/back_forward_cache_internal_browsertest.cc", "../browser/back_forward_cache_network_request_browsertest.cc",
diff --git a/content/test/data/accessibility/mac/attributes/ax-aria-column-count-expected.txt b/content/test/data/accessibility/mac/attributes/ax-aria-column-count-expected.txt new file mode 100644 index 0000000..4b3cfd75 --- /dev/null +++ b/content/test/data/accessibility/mac/attributes/ax-aria-column-count-expected.txt
@@ -0,0 +1,3 @@ +tableAuto.AXARIAColumnCount=1 +table.AXARIAColumnCount=2 +div.AXARIAColumnCount=n/a
diff --git a/content/test/data/accessibility/mac/attributes/ax-aria-column-count.html b/content/test/data/accessibility/mac/attributes/ax-aria-column-count.html new file mode 100644 index 0000000..412d122 --- /dev/null +++ b/content/test/data/accessibility/mac/attributes/ax-aria-column-count.html
@@ -0,0 +1,14 @@ +<!-- +@SCRIPT: + tableAuto.AXARIAColumnCount + table.AXARIAColumnCount + div.AXARIAColumnCount +--> +<!DOCTYPE html> +<div id="tableAuto" role="table"> + <div role="row"> + <span role="cell">column 1</span> + </div> +</div> +<div id="table" role="table" aria-colcount="2"></div> +<div id="div" aria-colcount="3"></div>
diff --git a/content/test/data/accessibility/mac/attributes/ax-aria-column-index-expected.txt b/content/test/data/accessibility/mac/attributes/ax-aria-column-index-expected.txt new file mode 100644 index 0000000..e8ba353 --- /dev/null +++ b/content/test/data/accessibility/mac/attributes/ax-aria-column-index-expected.txt
@@ -0,0 +1,3 @@ +tableCellAuto.AXARIAColumnIndex=1 +tableCell.AXARIAColumnIndex=2 +div.AXARIAColumnIndex=n/a
diff --git a/content/test/data/accessibility/mac/attributes/ax-aria-column-index.html b/content/test/data/accessibility/mac/attributes/ax-aria-column-index.html new file mode 100644 index 0000000..ff26eb1 --- /dev/null +++ b/content/test/data/accessibility/mac/attributes/ax-aria-column-index.html
@@ -0,0 +1,18 @@ +<!-- +@SCRIPT: + tableCellAuto.AXARIAColumnIndex + tableCell.AXARIAColumnIndex + div.AXARIAColumnIndex +--> +<!DOCTYPE html> +<div role="table"> + <div role="row"> + <span id="tableCellAuto" role="cell">column 1</span> + </div> +</div> +<div role="table"> + <div role="row"> + <span id="tableCell" role="cell" aria-colindex="2">column 2</span> + </div> +</div> +<div id="div" aria-colindex="3" ></div>
diff --git a/content/test/data/accessibility/mac/attributes/ax-aria-row-count-expected.txt b/content/test/data/accessibility/mac/attributes/ax-aria-row-count-expected.txt new file mode 100644 index 0000000..b12658f --- /dev/null +++ b/content/test/data/accessibility/mac/attributes/ax-aria-row-count-expected.txt
@@ -0,0 +1,3 @@ +tableAuto.AXARIARowCount=1 +table.AXARIARowCount=2 +div.AXARIARowCount=n/a
diff --git a/content/test/data/accessibility/mac/attributes/ax-aria-row-count.html b/content/test/data/accessibility/mac/attributes/ax-aria-row-count.html new file mode 100644 index 0000000..66da683 --- /dev/null +++ b/content/test/data/accessibility/mac/attributes/ax-aria-row-count.html
@@ -0,0 +1,14 @@ +<!-- +@SCRIPT: + tableAuto.AXARIARowCount + table.AXARIARowCount + div.AXARIARowCount +--> +<!DOCTYPE html> +<div id="tableAuto" role="table"> + <div role="row"> + <span role="cell">column 1</span> + </div> +</div> +<div id="table" role="table" aria-rowcount="2"></div> +<div id="div" aria-rowcount="3"></div>
diff --git a/content/test/data/accessibility/mac/attributes/ax-aria-row-index-expected.txt b/content/test/data/accessibility/mac/attributes/ax-aria-row-index-expected.txt new file mode 100644 index 0000000..882e4971 --- /dev/null +++ b/content/test/data/accessibility/mac/attributes/ax-aria-row-index-expected.txt
@@ -0,0 +1,3 @@ +tableCellAuto.AXARIARowIndex=1 +tableCell.AXARIARowIndex=2 +div.AXARIARowIndex=n/a
diff --git a/content/test/data/accessibility/mac/attributes/ax-aria-row-index.html b/content/test/data/accessibility/mac/attributes/ax-aria-row-index.html new file mode 100644 index 0000000..fbbba1d --- /dev/null +++ b/content/test/data/accessibility/mac/attributes/ax-aria-row-index.html
@@ -0,0 +1,18 @@ +<!-- +@SCRIPT: + tableCellAuto.AXARIARowIndex + tableCell.AXARIARowIndex + div.AXARIARowIndex +--> +<!DOCTYPE html> +<div role="table"> + <div role="row"> + <span id="tableCellAuto" role="cell">column 1</span> + </div> +</div> +<div role="table"> + <div role="row"> + <span id="tableCell" role="cell" aria-rowindex="2">column 2</span> + </div> +</div> +<div id="div" aria-rowindex="3" ></div>
diff --git a/content/test/gpu/gpu_tests/test_expectations/context_lost_expectations.txt b/content/test/gpu/gpu_tests/test_expectations/context_lost_expectations.txt index 8d9fce1..90a63c8c 100644 --- a/content/test/gpu/gpu_tests/test_expectations/context_lost_expectations.txt +++ b/content/test/gpu/gpu_tests/test_expectations/context_lost_expectations.txt
@@ -154,6 +154,7 @@ crbug.com/1064853 [ android android-nexus-5x ] ContextLost_WebGLContextLostFromSelectElement [ Failure ] crbug.com/1218559 [ android android-nexus-5x no-passthrough ] ContextLost_WebGLContextLostFromGPUProcessExit [ Failure ] crbug.com/1218559 [ android android-nexus-5x no-passthrough ] GpuCrash_GPUProcessCrashesExactlyOncePerVisitToAboutGpuCrash [ Failure ] +crbug.com/1275180 [ android android-nexus-5x no-passthrough ] ContextLost_WebGLContextLostFromQuantity [ RetryOnFailure ] # Flaky on Fuchsia. crbug.com/1122373 [ fuchsia ] ContextLost_WebGLContextLostFromQuantity [ Failure ]
diff --git a/content/test/gpu/gpu_tests/test_expectations/pixel_expectations.txt b/content/test/gpu/gpu_tests/test_expectations/pixel_expectations.txt index e2f9b569..51d73ef8 100644 --- a/content/test/gpu/gpu_tests/test_expectations/pixel_expectations.txt +++ b/content/test/gpu/gpu_tests/test_expectations/pixel_expectations.txt
@@ -486,6 +486,9 @@ crbug.com/1274796 [ win intel-0x3e92 ] Pixel_WebGPUImportVideoFrame [ Failure ] crbug.com/1274796 [ win amd-0x7340 ] Pixel_WebGPUImportVideoFrame [ Failure ] +# Pixel_Video_Media_Stream_Incompatible_Stride flakes on NVIDIA Linux SkiaRenderer GL +crbug.com/1213542 [ linux nvidia-0x1cb3 skia-renderer-gl ] Pixel_Video_Media_Stream_Incompatible_Stride [ RetryOnFailure ] + ####################################################################### # Automated Entries After This Point - Do Not Manually Add Below Here # #######################################################################
diff --git a/content/test/test_web_contents.cc b/content/test/test_web_contents.cc index f1d3299..c5e5d77 100644 --- a/content/test/test_web_contents.cc +++ b/content/test/test_web_contents.cc
@@ -420,7 +420,7 @@ rfhi->GetLastCommittedOrigin(), rfhi->GetLastCommittedURL(), rfhi->GetProcess()->GetID(), rfhi->GetFrameToken(), - rfhi->GetPageUkmSourceId()), + rfhi->GetPageUkmSourceId(), ui::PAGE_TRANSITION_LINK), *this); }
diff --git a/docs/python3_migration.md b/docs/python3_migration.md index de47c3d..3c197539 100644 --- a/docs/python3_migration.md +++ b/docs/python3_migration.md
@@ -13,19 +13,19 @@ As of the time of writing (2021-07-19), we're in the following state: * depot_tools is fully Python3-compatible. -* [gclient hooks](#gclient_hooks) are being migrated to use Python3 +* [gclient hooks](#gclient-hooks) are being migrated to use Python3 ([crbug.com/1208028](https://crbug.com/1208028)). * GN is fully Python3-compatible, meaning that all the scripts invoked through exec_script() are using Python3. * The [build](#gn_ninja-actions) (scripts invoked by Ninja) uses Python3. * We are updating the various test harnesses and frameworks to use Python3, but most still use Python2. It is possible to use - Python3 for tests if you're ready to do so. -* [PRESUBMIT checks](#presubmit_checks) are being migrated to use Python3 + Python3 for tests if you're ready to do so + ([crbug.com/1275016](https://crbug.com/1275016)). +* [PRESUBMIT checks](#presubmit-checks) are being migrated to use Python3 ([crbug.com/1207012](https://crbug.com/1207012)). -* Python3-compatible pylint checks are available but not yet fully - integrated into the presubmit checks - ([crbug.com/1157676](https://crbug.com/1157676)). +* Python3-compatible pylint checks are available + ([crbug.com/1207012](https://crbug.com/1207012)). ## Migrating Python code from 2 to 3
diff --git a/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.cc b/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.cc index f8aa1b3..8537449 100644 --- a/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.cc +++ b/extensions/browser/api/sockets_tcp_server/sockets_tcp_server_api.cc
@@ -16,6 +16,7 @@ #include "extensions/common/permissions/permissions_data.h" #include "extensions/common/permissions/socket_permission.h" #include "net/base/net_errors.h" +#include "net/base/sys_addrinfo.h" using content::SocketPermissionRequest; using extensions::ResumableTCPServerSocket;
diff --git a/gpu/command_buffer/service/webgpu_decoder_impl.cc b/gpu/command_buffer/service/webgpu_decoder_impl.cc index 241ec2e..92e32cf8 100644 --- a/gpu/command_buffer/service/webgpu_decoder_impl.cc +++ b/gpu/command_buffer/service/webgpu_decoder_impl.cc
@@ -294,7 +294,6 @@ return false; } bool WasContextLostByRobustnessExtension() const override { - NOTREACHED(); return false; } void MarkContextLost(error::ContextLostReason reason) override {
diff --git a/gpu/vulkan/BUILD.gn b/gpu/vulkan/BUILD.gn index bd07ac6..ad422d5 100644 --- a/gpu/vulkan/BUILD.gn +++ b/gpu/vulkan/BUILD.gn
@@ -151,7 +151,7 @@ # libraries and configs need to be included in the generated Fuchsia # package. if (is_debug || dcheck_always_on) { - data_deps += [ "//third_party/fuchsia-sdk:vulkan_validation" ] + data_deps += [ "//third_party/fuchsia-sdk/sdk/pkg/vulkan_layers:VkLayer_khronos_validation" ] } } }
diff --git a/infra/config/generated/builders/ci/Dawn Linux x64 Builder/properties.textpb b/infra/config/generated/builders/ci/Dawn Linux x64 Builder/properties.textpb index 9de08acc..7073447 100644 --- a/infra/config/generated/builders/ci/Dawn Linux x64 Builder/properties.textpb +++ b/infra/config/generated/builders/ci/Dawn Linux x64 Builder/properties.textpb
@@ -1,9 +1,8 @@ { - "$build/goma": { - "enable_ats": true, - "rpc_extra_params": "?prod", - "server_host": "goma.chromium.org", - "use_luci_auth": true + "$build/reclient": { + "instance": "rbe-chromium-trusted", + "jobs": 250, + "metrics_project": "chromium-reclient-metrics" }, "$recipe_engine/resultdb/test_presentation": { "column_keys": [],
diff --git a/infra/config/generated/builders/ci/Dawn Linux x64 DEPS Builder/properties.textpb b/infra/config/generated/builders/ci/Dawn Linux x64 DEPS Builder/properties.textpb index 9de08acc..7073447 100644 --- a/infra/config/generated/builders/ci/Dawn Linux x64 DEPS Builder/properties.textpb +++ b/infra/config/generated/builders/ci/Dawn Linux x64 DEPS Builder/properties.textpb
@@ -1,9 +1,8 @@ { - "$build/goma": { - "enable_ats": true, - "rpc_extra_params": "?prod", - "server_host": "goma.chromium.org", - "use_luci_auth": true + "$build/reclient": { + "instance": "rbe-chromium-trusted", + "jobs": 250, + "metrics_project": "chromium-reclient-metrics" }, "$recipe_engine/resultdb/test_presentation": { "column_keys": [],
diff --git a/infra/config/subprojects/chromium/ci.star b/infra/config/subprojects/chromium/ci.star index 3ba0d63..e773e02 100644 --- a/infra/config/subprojects/chromium/ci.star +++ b/infra/config/subprojects/chromium/ci.star
@@ -2790,6 +2790,9 @@ category = "ToT|Linux|Builder", short_name = "x64", ), + goma_backend = None, + reclient_jobs = rbe_jobs.DEFAULT, + reclient_instance = rbe_instance.DEFAULT, ) ci.dawn_linux_builder( @@ -2801,6 +2804,9 @@ ), cq_mirrors_console_view = "mirrors", main_console_view = main_console_if_on_branch(), + goma_backend = None, + reclient_jobs = rbe_jobs.DEFAULT, + reclient_instance = rbe_instance.DEFAULT, ) ci.dawn_thin_tester(
diff --git a/ios/chrome/browser/component_updater/ios_component_updater_configurator.cc b/ios/chrome/browser/component_updater/ios_component_updater_configurator.cc index f77598452..dd372b91 100644 --- a/ios/chrome/browser/component_updater/ios_component_updater_configurator.cc +++ b/ios/chrome/browser/component_updater/ios_component_updater_configurator.cc
@@ -58,6 +58,7 @@ scoped_refptr<update_client::UnzipperFactory> GetUnzipperFactory() override; scoped_refptr<update_client::PatcherFactory> GetPatcherFactory() override; bool EnabledDeltas() const override; + bool EnabledComponentUpdates() const override; bool EnabledBackgroundDownloader() const override; bool EnabledCupSigning() const override; PrefService* GetPrefService() const override; @@ -182,6 +183,10 @@ return configurator_impl_.EnabledDeltas(); } +bool IOSConfigurator::EnabledComponentUpdates() const { + return configurator_impl_.EnabledComponentUpdates(); +} + bool IOSConfigurator::EnabledBackgroundDownloader() const { return configurator_impl_.EnabledBackgroundDownloader(); }
diff --git a/ios/chrome/browser/prefs/BUILD.gn b/ios/chrome/browser/prefs/BUILD.gn index 48c33a3..0525a67 100644 --- a/ios/chrome/browser/prefs/BUILD.gn +++ b/ios/chrome/browser/prefs/BUILD.gn
@@ -33,8 +33,7 @@ deps = [ "//components/autofill/core/browser", "//components/browsing_data/core", - "//components/component_updater", - "//components/component_updater/installer_policies", + "//components/component_updater/installer_policies:installer_policies", "//components/content_settings/core/browser", "//components/dom_distiller/core", "//components/enterprise",
diff --git a/ios/chrome/browser/prefs/browser_prefs.mm b/ios/chrome/browser/prefs/browser_prefs.mm index 0589690..9e642a1 100644 --- a/ios/chrome/browser/prefs/browser_prefs.mm +++ b/ios/chrome/browser/prefs/browser_prefs.mm
@@ -6,7 +6,6 @@ #include "components/autofill/core/common/autofill_prefs.h" #include "components/browsing_data/core/pref_names.h" -#include "components/component_updater/component_updater_service.h" #include "components/component_updater/installer_policies/autofill_states_component_installer.h" #include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/dom_distiller/core/distilled_page_prefs.h" @@ -149,7 +148,6 @@ update_client::RegisterPrefs(registry); variations::VariationsService::RegisterPrefs(registry); fre_field_trial::RegisterLocalStatePrefs(registry); - component_updater::RegisterComponentUpdateServicePrefs(registry); component_updater::AutofillStatesComponentInstallerPolicy::RegisterPrefs( registry);
diff --git a/ios/chrome/browser/sessions/ios_chrome_tab_restore_service_client.h b/ios/chrome/browser/sessions/ios_chrome_tab_restore_service_client.h index 08831de..9028574f 100644 --- a/ios/chrome/browser/sessions/ios_chrome_tab_restore_service_client.h +++ b/ios/chrome/browser/sessions/ios_chrome_tab_restore_service_client.h
@@ -10,10 +10,6 @@ #include "components/sessions/core/tab_restore_service_client.h" -namespace base { -class Value; -} - class ChromeBrowserState; // IOSChromeTabRestoreServiceClient provides an implementation of @@ -38,7 +34,7 @@ ui::WindowShowState show_state, const std::string& workspace, const std::string& user_title, - const std::map<std::string, base::Value>& extra_data) override; + const std::map<std::string, std::string>& extra_data) override; sessions::LiveTabContext* FindLiveTabContextForTab( const sessions::LiveTab* tab) override; sessions::LiveTabContext* FindLiveTabContextWithID(
diff --git a/ios/chrome/browser/sessions/ios_chrome_tab_restore_service_client.mm b/ios/chrome/browser/sessions/ios_chrome_tab_restore_service_client.mm index 483ba83f..f8ccea25 100644 --- a/ios/chrome/browser/sessions/ios_chrome_tab_restore_service_client.mm +++ b/ios/chrome/browser/sessions/ios_chrome_tab_restore_service_client.mm
@@ -6,7 +6,6 @@ #include "base/bind.h" #include "base/callback.h" -#include "base/values.h" #include "components/sessions/ios/ios_live_tab.h" #include "components/tab_groups/tab_group_id.h" #include "ios/chrome/browser/application_context.h" @@ -67,7 +66,7 @@ ui::WindowShowState /* show_state */, const std::string& /* workspace */, const std::string& /* user_title */, - const std::map<std::string, base::Value>& /* extra_data */) { + const std::map<std::string, std::string>& /* extra_data */) { NOTREACHED() << "Tab restore service attempting to create a new window."; return nullptr; }
diff --git a/ios/chrome/browser/sessions/live_tab_context_browser_agent.h b/ios/chrome/browser/sessions/live_tab_context_browser_agent.h index 810af37f..4df9b3e 100644 --- a/ios/chrome/browser/sessions/live_tab_context_browser_agent.h +++ b/ios/chrome/browser/sessions/live_tab_context_browser_agent.h
@@ -14,10 +14,6 @@ #include "ios/chrome/browser/main/browser_observer.h" #include "ios/chrome/browser/main/browser_user_data.h" -namespace base { -class Value; -} - class WebStateList; // Implementation of sessions::LiveTabContext which uses a WebStateList @@ -41,9 +37,9 @@ std::string GetUserTitle() const override; sessions::LiveTab* GetLiveTabAt(int index) const override; sessions::LiveTab* GetActiveLiveTab() const override; - std::map<std::string, base::Value> GetExtraDataForTab( + std::map<std::string, std::string> GetExtraDataForTab( int index) const override; - std::map<std::string, base::Value> GetExtraDataForWindow() const override; + std::map<std::string, std::string> GetExtraDataForWindow() const override; absl::optional<tab_groups::TabGroupId> GetTabGroupForTab( int index) const override; const tab_groups::TabGroupVisualData* GetVisualDataForGroup( @@ -66,7 +62,7 @@ bool pin, const sessions::PlatformSpecificTabData* tab_platform_data, const sessions::SerializedUserAgentOverride& user_agent_override, - const std::map<std::string, base::Value>& extra_data, + const std::map<std::string, std::string>& extra_data, const SessionID* tab_id) override; sessions::LiveTab* ReplaceRestoredTab( const std::vector<sessions::SerializedNavigationEntry>& navigations, @@ -75,7 +71,7 @@ const std::string& extension_app_id, const sessions::PlatformSpecificTabData* tab_platform_data, const sessions::SerializedUserAgentOverride& user_agent_override, - const std::map<std::string, base::Value>& extra_data) override; + const std::map<std::string, std::string>& extra_data) override; void CloseTab() override; private:
diff --git a/ios/chrome/browser/sessions/live_tab_context_browser_agent.mm b/ios/chrome/browser/sessions/live_tab_context_browser_agent.mm index 4c1036c..f85dec4 100644 --- a/ios/chrome/browser/sessions/live_tab_context_browser_agent.mm +++ b/ios/chrome/browser/sessions/live_tab_context_browser_agent.mm
@@ -9,7 +9,6 @@ #include "base/notreached.h" #include "base/strings/sys_string_conversions.h" -#include "base/values.h" #include "components/sessions/core/session_types.h" #include "components/tab_groups/tab_group_id.h" #include "components/tab_groups/tab_group_visual_data.h" @@ -66,14 +65,14 @@ return nullptr; } -std::map<std::string, base::Value> +std::map<std::string, std::string> LiveTabContextBrowserAgent::GetExtraDataForTab(int index) const { - return std::map<std::string, base::Value>(); + return std::map<std::string, std::string>(); } -std::map<std::string, base::Value> +std::map<std::string, std::string> LiveTabContextBrowserAgent::GetExtraDataForWindow() const { - return std::map<std::string, base::Value>(); + return std::map<std::string, std::string>(); } absl::optional<tab_groups::TabGroupId> @@ -128,7 +127,7 @@ bool pin, const sessions::PlatformSpecificTabData* tab_platform_data, const sessions::SerializedUserAgentOverride& user_agent_override, - const std::map<std::string, base::Value>& extra_data, + const std::map<std::string, std::string>& extra_data, const SessionID* tab_id) { // TODO(crbug.com/661636): Handle tab-switch animation somehow... web_state_list_->InsertWebState( @@ -147,7 +146,7 @@ const std::string& extension_app_id, const sessions::PlatformSpecificTabData* tab_platform_data, const sessions::SerializedUserAgentOverride& user_agent_override, - const std::map<std::string, base::Value>& extra_data) { + const std::map<std::string, std::string>& extra_data) { web_state_list_->ReplaceWebStateAt( web_state_list_->active_index(), session_util::CreateWebStateWithNavigationEntries(
diff --git a/ios/chrome/browser/ui/browser_view/browser_view_controller.mm b/ios/chrome/browser/ui/browser_view/browser_view_controller.mm index 33bdfb30..67e40f0 100644 --- a/ios/chrome/browser/ui/browser_view/browser_view_controller.mm +++ b/ios/chrome/browser/ui/browser_view/browser_view_controller.mm
@@ -1059,6 +1059,7 @@ if (!active) { if (IsSingleNtpEnabled()) { [_ntpCoordinator stop]; + [_ntpCoordinator disconnect]; } else { for (const auto& element : _ntpCoordinatorsForWebStates) [element.second stop]; @@ -2654,11 +2655,10 @@ SnapshotTabHelper::FromWebState(webState)->SetDelegate(nil); // TODO(crbug.com/1173610): Have BrowserCoordinator manage the NTP. - if (IsSingleNtpEnabled()) { - if (self.currentWebState == webState) { - [_ntpCoordinator stop]; - } - } else { + // No need to stop _ntpCoordinator with Single NTP enabled since shutdown will + // do that. In addition, uninstallDelegatesForWebState: is called for + // individual WebState removals, which should not trigger a stop. + if (!IsSingleNtpEnabled()) { auto iterator = _ntpCoordinatorsForWebStates.find(webState); if (iterator != _ntpCoordinatorsForWebStates.end()) { [iterator->second stop];
diff --git a/ios/google_internal/frameworks/chrome_internal_dynamic_framework.ios.zip.sha1 b/ios/google_internal/frameworks/chrome_internal_dynamic_framework.ios.zip.sha1 index aecca75..efc692e 100644 --- a/ios/google_internal/frameworks/chrome_internal_dynamic_framework.ios.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_internal_dynamic_framework.ios.zip.sha1
@@ -1 +1 @@ -bfa7a0c49e4254e8ebb255713efa836efae236b1 \ No newline at end of file +83543d71493657a089a8e73c28c97e406a8a948c \ No newline at end of file
diff --git a/ios/google_internal/frameworks/chrome_internal_dynamic_framework.iossimulator.zip.sha1 b/ios/google_internal/frameworks/chrome_internal_dynamic_framework.iossimulator.zip.sha1 index 1e7b0337..56d1b8d 100644 --- a/ios/google_internal/frameworks/chrome_internal_dynamic_framework.iossimulator.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_internal_dynamic_framework.iossimulator.zip.sha1
@@ -1 +1 @@ -95307ab4f39a741129f6d37f74e05ca127d23fbe \ No newline at end of file +681e44a6e57bcc865b67decbde8a7d21565598a6 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.ios.zip.sha1 b/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.ios.zip.sha1 index 04acb64..e893245 100644 --- a/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.ios.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.ios.zip.sha1
@@ -1 +1 @@ -cf00a49d8b073d88c74d836dff8b8bded71205a2 \ No newline at end of file +a845266dbb1f3b6ae00914291d7fbf667847a7ea \ No newline at end of file
diff --git a/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.iossimulator.zip.sha1 b/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.iossimulator.zip.sha1 index fa8f82fc..f69bb0c 100644 --- a/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.iossimulator.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.iossimulator.zip.sha1
@@ -1 +1 @@ -c54ae81146277f7156414539ad5939b2376b3233 \ No newline at end of file +5939b702261ee752309e88e4d8229e52cc8993f4 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.ios.zip.sha1 b/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.ios.zip.sha1 index 28cd3ccb..484a4187 100644 --- a/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.ios.zip.sha1 +++ b/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.ios.zip.sha1
@@ -1 +1 @@ -b7c1203b636088282d219c4c1f6ca46e9ee6ddc1 \ No newline at end of file +18d500ef7bd4349c3b05e58ae5153d4a32932328 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.iossimulator.zip.sha1 b/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.iossimulator.zip.sha1 index 11ab6f7..ab37914e 100644 --- a/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.iossimulator.zip.sha1 +++ b/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.iossimulator.zip.sha1
@@ -1 +1 @@ -c4aa9c19475853170a43802787c4097b2a44af79 \ No newline at end of file +d22c79332faf1d22524f5d7c2bb596d066e07d88 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/remoting_internal_dynamic_framework.ios.zip.sha1 b/ios/google_internal/frameworks/remoting_internal_dynamic_framework.ios.zip.sha1 index cc46f88..549b5f3 100644 --- a/ios/google_internal/frameworks/remoting_internal_dynamic_framework.ios.zip.sha1 +++ b/ios/google_internal/frameworks/remoting_internal_dynamic_framework.ios.zip.sha1
@@ -1 +1 @@ -e74c84b713062821a60b0c1d892843d8a0b83886 \ No newline at end of file +70b400cda0ef21c820bd774345b56068e845cf70 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/remoting_internal_dynamic_framework.iossimulator.zip.sha1 b/ios/google_internal/frameworks/remoting_internal_dynamic_framework.iossimulator.zip.sha1 index de57bd4e..a077208 100644 --- a/ios/google_internal/frameworks/remoting_internal_dynamic_framework.iossimulator.zip.sha1 +++ b/ios/google_internal/frameworks/remoting_internal_dynamic_framework.iossimulator.zip.sha1
@@ -1 +1 @@ -b578a66cb49c1c98e6ffca83344d6353b10c9334 \ No newline at end of file +4c723533fdb9ac965d1ed2dd5d961998a58fd075 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.ios.zip.sha1 b/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.ios.zip.sha1 index 644552a..d6a7f57 100644 --- a/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.ios.zip.sha1 +++ b/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.ios.zip.sha1
@@ -1 +1 @@ -1f55550aac6a0d81159365fd61eb55dce448f189 \ No newline at end of file +bab0eb3a1d39d18f6d301d7529f41ffb5a69e0f6 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.iossimulator.zip.sha1 b/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.iossimulator.zip.sha1 index 3a1e95d3d..0d1cd3dd 100644 --- a/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.iossimulator.zip.sha1 +++ b/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.iossimulator.zip.sha1
@@ -1 +1 @@ -650d265276b1fc43b82189c970a47142814eb4f4 \ No newline at end of file +628b6d68247721f7070bd4b723cbc8ee011ef9c6 \ No newline at end of file
diff --git a/ios/web/common/features.mm b/ios/web/common/features.mm index b879bc773..1c50e424 100644 --- a/ios/web/common/features.mm +++ b/ios/web/common/features.mm
@@ -68,7 +68,8 @@ const base::Feature kSynthesizedRestoreSession{ "SynthesizedRestoreSession", base::FEATURE_DISABLED_BY_DEFAULT}; -const base::Feature kEnableUnrealizedWebStates{"EnableUnrealizedWebStates"}; +const base::Feature kEnableUnrealizedWebStates{ + "EnableUnrealizedWebStates", base::FEATURE_DISABLED_BY_DEFAULT}; bool UseWebClientDefaultUserAgent() { return base::FeatureList::IsEnabled(kUseDefaultUserAgentInWebClient);
diff --git a/media/gpu/gpu_video_encode_accelerator_helpers.cc b/media/gpu/gpu_video_encode_accelerator_helpers.cc index 151101e4..52c0f85 100644 --- a/media/gpu/gpu_video_encode_accelerator_helpers.cc +++ b/media/gpu/gpu_video_encode_accelerator_helpers.cc
@@ -7,6 +7,7 @@ #include <algorithm> #include "base/check_op.h" +#include "base/notreached.h" namespace media { namespace { @@ -83,4 +84,33 @@ return GetMaxEncodeBitstreamBufferSize(size); } +std::vector<uint8_t> GetFpsAllocation(size_t num_temporal_layers) { + DCHECK_LT(num_temporal_layers, 4u); + constexpr uint8_t kFullAllocation = 255; + // The frame rate fraction is given as an 8 bit unsigned integer where 0 = 0% + // and 255 = 100%. Each layer's allocated fps refers to the previous one, so + // e.g. your camera is opened at 30fps, and you want to have decode targets at + // 15fps and 7.5fps as well: + // TL0 then gets an allocation of 7.5/30 = 1/4. TL1 adds another 7.5fps to end + // up at (7.5 + 7.5)/30 = 15/30 = 1/2 of the total allocation. TL2 adds the + // final 15fps to end up at (15 + 15)/30, which is the full allocation. + // Therefor, fps_allocation values are as follows, + // fps_allocation[0][0] = kFullAllocation / 4; + // fps_allocation[0][1] = kFullAllocation / 2; + // fps_allocation[0][2] = kFullAllocation; + // For more information, see webrtc::VideoEncoderInfo::fps_allocation. + switch (num_temporal_layers) { + case 1: + // In this case, the number of spatial layers must great than 1. + return {kFullAllocation}; + case 2: + return {kFullAllocation / 2, kFullAllocation}; + case 3: + return {kFullAllocation / 4, kFullAllocation / 2, kFullAllocation}; + default: + NOTREACHED() << "Unsupported temporal layers"; + return {}; + } +} + } // namespace media
diff --git a/media/gpu/gpu_video_encode_accelerator_helpers.h b/media/gpu/gpu_video_encode_accelerator_helpers.h index 959ce874..f83248e 100644 --- a/media/gpu/gpu_video_encode_accelerator_helpers.h +++ b/media/gpu/gpu_video_encode_accelerator_helpers.h
@@ -5,6 +5,8 @@ #ifndef MEDIA_GPU_GPU_VIDEO_ENCODE_ACCELERATOR_HELPERS_H_ #define MEDIA_GPU_GPU_VIDEO_ENCODE_ACCELERATOR_HELPERS_H_ +#include <vector> + #include "media/gpu/media_gpu_export.h" #include "ui/gfx/geometry/size.h" @@ -24,6 +26,11 @@ // |size|: the resolution of video stream MEDIA_GPU_EXPORT size_t GetEncodeBitstreamBufferSize(const gfx::Size& size); +// Get the frame rate fraction assigned to each temporal layer. +// |num_temporal_layers|: total number of temporal layers +MEDIA_GPU_EXPORT std::vector<uint8_t> GetFpsAllocation( + size_t num_temporal_layers); + } // namespace media #endif // MEDIA_GPU_GPU_VIDEO_ENCODE_ACCELERATOR_HELPERS_H_
diff --git a/media/gpu/v4l2/test/v4l2_ioctl_shim.cc b/media/gpu/v4l2/test/v4l2_ioctl_shim.cc index 4d120dd..a9e780b 100644 --- a/media/gpu/v4l2/test/v4l2_ioctl_shim.cc +++ b/media/gpu/v4l2/test/v4l2_ioctl_shim.cc
@@ -110,9 +110,11 @@ uint32_t fourcc, const gfx::Size& size, uint32_t num_planes, - enum v4l2_memory memory) + enum v4l2_memory memory, + uint32_t num_buffers) : type_(type), fourcc_(fourcc), + num_buffers_(num_buffers), display_size_(size), num_planes_(num_planes), memory_(memory) {} @@ -302,17 +304,19 @@ return ret; } -bool V4L2IoctlShim::ReqBufs(const std::unique_ptr<V4L2Queue>& queue) const { +bool V4L2IoctlShim::ReqBufs(std::unique_ptr<V4L2Queue>& queue) const { struct v4l2_requestbuffers reqbuf; memset(&reqbuf, 0, sizeof(reqbuf)); - reqbuf.count = kRequestBufferCount; + reqbuf.count = queue->num_buffers(); reqbuf.type = queue->type(); reqbuf.memory = queue->memory(); const bool ret = Ioctl(VIDIOC_REQBUFS, &reqbuf); - LOG(INFO) << kRequestBufferCount << " buffers requested, " << reqbuf.count + queue->set_num_buffers(reqbuf.count); + + LOG(INFO) << queue->num_buffers() << " buffers requested, " << reqbuf.count << " buffers returned for " << queue->type() << "."; return ret; @@ -341,6 +345,14 @@ v4l2_buffer.m.planes[i].data_offset = 0; } + // Request API related setting is needed only for OUTPUT queue. + if (queue->type() == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { + v4l2_buffer.flags |= V4L2_BUF_FLAG_REQUEST_FD; + v4l2_buffer.request_fd = queue->media_request_fd(); + v4l2_buffer.timestamp.tv_usec = + static_cast<__suseconds_t>(buffer->reference_id()); + } + return Ioctl(VIDIOC_QBUF, &v4l2_buffer); } @@ -417,7 +429,7 @@ constexpr size_t kTimeStampToNanoSecs = 1000; - for (uint32_t i = 0; i < kRequestBufferCount; ++i) { + for (uint32_t i = 0; i < queue->num_buffers(); ++i) { struct v4l2_buffer v4l_buffer; std::vector<v4l2_plane> planes(VIDEO_MAX_PLANES); @@ -430,8 +442,8 @@ DCHECK(Ioctl(VIDIOC_QUERYBUF, &v4l_buffer)); - buffers[i] = base::MakeRefCounted<MmapedBuffer>( - decode_fd_.GetPlatformFile(), v4l_buffer); + buffers.emplace_back(base::MakeRefCounted<MmapedBuffer>( + decode_fd_.GetPlatformFile(), v4l_buffer)); // Converts buffer ID to reference ID. Reference ID of a frame can be specified // by converting its timestamp into nanoseconds. Buffer ID is used as timestamp @@ -445,10 +457,10 @@ // v4l2 video decode accelerator tests. buffers[i]->set_reference_id(i * kTimeStampToNanoSecs); - - queue->set_buffers(buffers); } + queue->set_buffers(buffers); + return true; }
diff --git a/media/gpu/v4l2/test/v4l2_ioctl_shim.h b/media/gpu/v4l2/test/v4l2_ioctl_shim.h index c295292..3243a9a 100644 --- a/media/gpu/v4l2/test/v4l2_ioctl_shim.h +++ b/media/gpu/v4l2/test/v4l2_ioctl_shim.h
@@ -15,8 +15,6 @@ namespace v4l2_test { -constexpr size_t kRequestBufferCount = 8; - // MmapedBuffer maintains |mmaped_planes_| for each buffer as well as // |reference_id_|. Reference ID is computed from buffer ID, which is an // index used for VIDIOC_REQBUFS ioctl call. Reference ID is needed to use @@ -56,8 +54,7 @@ uint64_t reference_id_; }; -using MmapedBuffers = - std::array<scoped_refptr<MmapedBuffer>, kRequestBufferCount>; +using MmapedBuffers = std::vector<scoped_refptr<MmapedBuffer>>; // V4L2Queue class maintains properties of a queue. class V4L2Queue { @@ -66,7 +63,8 @@ uint32_t fourcc, const gfx::Size& size, uint32_t num_planes, - enum v4l2_memory memory); + enum v4l2_memory memory, + uint32_t num_buffers); V4L2Queue(const V4L2Queue&) = delete; V4L2Queue& operator=(const V4L2Queue&) = delete; @@ -83,6 +81,9 @@ void set_buffers(MmapedBuffers& buffers) { buffers_ = buffers; } + uint32_t num_buffers() const { return num_buffers_; } + void set_num_buffers(uint32_t num_buffers) { num_buffers_ = num_buffers; } + gfx::Size coded_size() const { return coded_size_; } void set_coded_size(gfx::Size coded_size) { coded_size_ = coded_size; } @@ -98,6 +99,7 @@ const enum v4l2_buf_type type_; const uint32_t fourcc_; MmapedBuffers buffers_; + uint32_t num_buffers_; // The size of the image on the screen. const gfx::Size display_size_; // The size of the encoded frame. Usually has an alignment of 16, 32 @@ -141,8 +143,7 @@ bool TryFmt(const std::unique_ptr<V4L2Queue>& queue) const WARN_UNUSED_RESULT; // Allocates buffers via VIDIOC_REQBUFS for |queue|. - bool ReqBufs(const std::unique_ptr<V4L2Queue>& queue) const - WARN_UNUSED_RESULT; + bool ReqBufs(std::unique_ptr<V4L2Queue>& queue) const WARN_UNUSED_RESULT; // Enqueues an empty (capturing) or filled (output) buffer // in the driver's incoming |queue|.
diff --git a/media/gpu/v4l2/test/vp9_decoder.cc b/media/gpu/v4l2/test/vp9_decoder.cc index a9f3d0d..28b44b0 100644 --- a/media/gpu/v4l2/test/vp9_decoder.cc +++ b/media/gpu/v4l2/test/vp9_decoder.cc
@@ -159,7 +159,7 @@ auto OUTPUT_queue = std::make_unique<V4L2Queue>( V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, kDriverCodecFourcc, gfx::Size(file_header.width, file_header.height), /*num_planes=*/1, - V4L2_MEMORY_MMAP); + V4L2_MEMORY_MMAP, /*num_buffers=*/1); // TODO(stevecho): enable V4L2_MEMORY_DMABUF memory for CAPTURE queue. // |num_planes| represents separate memory buffers, not planes for Y, U, V. @@ -167,7 +167,7 @@ auto CAPTURE_queue = std::make_unique<V4L2Queue>( V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, kUncompressedFourcc, gfx::Size(file_header.width, file_header.height), /*num_planes=*/2, - V4L2_MEMORY_MMAP); + V4L2_MEMORY_MMAP, /*num_buffers=*/8); return base::WrapUnique( new Vp9Decoder(std::move(ivf_parser), std::move(v4l2_ioctl), @@ -214,7 +214,7 @@ if (!v4l2_ioctl_->QueryAndMmapQueueBuffers(CAPTURE_queue_)) LOG(ERROR) << "QueryAndMmapQueueBuffers for CAPTURE queue failed."; - for (uint32_t i = 0; i < kRequestBufferCount; ++i) { + for (uint32_t i = 0; i < CAPTURE_queue_->num_buffers(); ++i) { if (!v4l2_ioctl_->QBuf(CAPTURE_queue_, i)) LOG(ERROR) << "VIDIOC_QBUF failed for CAPTURE queue."; } @@ -289,6 +289,9 @@ break; } + if (!v4l2_ioctl_->QBuf(OUTPUT_queue_, 0)) + LOG(ERROR) << "VIDIOC_QBUF failed for OUTPUT queue."; + struct v4l2_ctrl_vp9_frame_decode_params v4l2_frame_params; memset(&v4l2_frame_params, 0, sizeof(v4l2_frame_params));
diff --git a/media/gpu/vaapi/vaapi_video_encode_accelerator.cc b/media/gpu/vaapi/vaapi_video_encode_accelerator.cc index 427b54b..4a5842523 100644 --- a/media/gpu/vaapi/vaapi_video_encode_accelerator.cc +++ b/media/gpu/vaapi/vaapi_video_encode_accelerator.cc
@@ -37,6 +37,7 @@ #include "media/base/unaligned_shared_memory.h" #include "media/base/video_bitrate_allocation.h" #include "media/gpu/chromeos/platform_video_frame_utils.h" +#include "media/gpu/gpu_video_encode_accelerator_helpers.h" #include "media/gpu/h264_dpb.h" #include "media/gpu/macros.h" #include "media/gpu/vaapi/h264_vaapi_video_encoder_delegate.h" @@ -387,8 +388,8 @@ if (config.HasSpatialLayer() || config.HasTemporalLayer()) { DCHECK(!config.spatial_layers.empty()); for (size_t i = 0; i < config.spatial_layers.size(); ++i) { - encoder_info_.fps_allocation[i] = VP9SVCLayers::GetFpsAllocation( - config.spatial_layers[i].num_of_temporal_layers); + encoder_info_.fps_allocation[i] = + GetFpsAllocation(config.spatial_layers[i].num_of_temporal_layers); } } else { constexpr uint8_t kFullFramerate = 255;
diff --git a/media/gpu/vaapi/vaapi_video_encode_accelerator_unittest.cc b/media/gpu/vaapi/vaapi_video_encode_accelerator_unittest.cc index 132e27d6..be23abf 100644 --- a/media/gpu/vaapi/vaapi_video_encode_accelerator_unittest.cc +++ b/media/gpu/vaapi/vaapi_video_encode_accelerator_unittest.cc
@@ -12,6 +12,7 @@ #include "base/run_loop.h" #include "base/test/gmock_callback_support.h" #include "base/test/task_environment.h" +#include "media/gpu/gpu_video_encode_accelerator_helpers.h" #include "media/gpu/vaapi/vaapi_utils.h" #include "media/gpu/vaapi/vaapi_wrapper.h" #include "media/gpu/vaapi/vp9_svc_layers.h" @@ -124,8 +125,7 @@ if (fps_allocation.back() != kFullFramerate) return false; if (fps_allocation.size() != 1 && - fps_allocation != - VP9SVCLayers::GetFpsAllocation(num_of_temporal_layers)) { + fps_allocation != GetFpsAllocation(num_of_temporal_layers)) { return false; } }
diff --git a/media/gpu/vaapi/vp9_svc_layers.cc b/media/gpu/vaapi/vp9_svc_layers.cc index 3c0f411..ead67ca 100644 --- a/media/gpu/vaapi/vp9_svc_layers.cc +++ b/media/gpu/vaapi/vp9_svc_layers.cc
@@ -122,37 +122,6 @@ } } // namespace -// static -std::vector<uint8_t> VP9SVCLayers::GetFpsAllocation( - size_t num_temporal_layers) { - DCHECK_LT(num_temporal_layers, 4u); - constexpr uint8_t kFullAllocation = 255; - // The frame rate fraction is given as an 8 bit unsigned integer where 0 = 0% - // and 255 = 100%. Each layer's allocated fps refers to the previous one, so - // e.g. your camera is opened at 30fps, and you want to have decode targets at - // 15fps and 7.5fps as well: - // TL0 then gets an allocation of 7.5/30 = 1/4. TL1 adds another 7.5fps to end - // up at (7.5 + 7.5)/30 = 15/30 = 1/2 of the total allocation. TL2 adds the - // final 15fps to end up at (15 + 15)/30, which is the full allocation. - // Therefor, fps_allocation values are as follows, - // fps_allocation[0][0] = kFullAllocation / 4; - // fps_allocation[0][1] = kFullAllocation / 2; - // fps_allocation[0][2] = kFullAllocation; - // For more information, see webrtc::VideoEncoderInfo::fps_allocation. - switch (num_temporal_layers) { - case 1: - // In this case, the number of spatial layers must great than 1. - return {kFullAllocation}; - case 2: - return {kFullAllocation / 2, kFullAllocation}; - case 3: - return {kFullAllocation / 4, kFullAllocation / 2, kFullAllocation}; - default: - NOTREACHED() << "Unsupported temporal layers"; - return {}; - } -} - VP9SVCLayers::VP9SVCLayers(const std::vector<SpatialLayer>& spatial_layers) : num_temporal_layers_(spatial_layers[0].num_of_temporal_layers), temporal_layers_reference_pattern_(
diff --git a/media/gpu/vaapi/vp9_svc_layers.h b/media/gpu/vaapi/vp9_svc_layers.h index 6c1c226..2b4c415 100644 --- a/media/gpu/vaapi/vp9_svc_layers.h +++ b/media/gpu/vaapi/vp9_svc_layers.h
@@ -42,8 +42,6 @@ explicit VP9SVCLayers(const std::vector<SpatialLayer>& spatial_layers); ~VP9SVCLayers(); - static std::vector<uint8_t> GetFpsAllocation(size_t num_temporal_layers); - // Returns true if EncodeJob needs to produce key frame. bool UpdateEncodeJob(bool is_key_frame_requested, size_t kf_period_frames);
diff --git a/media/gpu/windows/media_foundation_video_encode_accelerator_win.cc b/media/gpu/windows/media_foundation_video_encode_accelerator_win.cc index a74e9ed..72364baf 100644 --- a/media/gpu/windows/media_foundation_video_encode_accelerator_win.cc +++ b/media/gpu/windows/media_foundation_video_encode_accelerator_win.cc
@@ -32,6 +32,7 @@ #include "media/base/media_switches.h" #include "media/base/win/mf_helpers.h" #include "media/base/win/mf_initializer.h" +#include "media/gpu/gpu_video_encode_accelerator_helpers.h" #include "third_party/libyuv/include/libyuv.h" #include "ui/gfx/color_space_win.h" #include "ui/gfx/gpu_memory_buffer.h" @@ -436,6 +437,26 @@ FROM_HERE, base::BindOnce(&Client::RequireBitstreamBuffers, main_client_, kNumInputBuffers, input_visible_size_, bitstream_buffer_size_)); + + VideoEncoderInfo encoder_info; + encoder_info.implementation_name = "MediaFoundationVideoEncodeAccelerator"; + encoder_info.has_trusted_rate_controller = true; + DCHECK(encoder_info.is_hardware_accelerated); + DCHECK(encoder_info.supports_native_handle); + DCHECK(!encoder_info.supports_simulcast); + if (config.HasSpatialLayer() || config.HasTemporalLayer()) { + DCHECK(!config.spatial_layers.empty()); + for (size_t i = 0; i < config.spatial_layers.size(); ++i) { + encoder_info.fps_allocation[i] = + GetFpsAllocation(config.spatial_layers[i].num_of_temporal_layers); + } + } else { + constexpr uint8_t kFullFramerate = 255; + encoder_info.fps_allocation[0] = {kFullFramerate}; + } + main_client_task_runner_->PostTask( + FROM_HERE, base::BindOnce(&Client::NotifyEncoderInfoChange, main_client_, + encoder_info)); return SUCCEEDED(hr); }
diff --git a/net/base/ip_endpoint.h b/net/base/ip_endpoint.h index a596745..8ac6fed 100644 --- a/net/base/ip_endpoint.h +++ b/net/base/ip_endpoint.h
@@ -16,16 +16,18 @@ #include "net/base/ip_address.h" #include "net/base/net_export.h" -#if defined(OS_WIN) // Replicate these from Windows headers to avoid pulling net/sys_addrinfo.h. // Doing that transitively brings in windows.h. Including windows.h pollutes the // global namespace with thousands of macro definitions. This file is // transitively included in enough files that including windows.h potentially // impacts build performance. +// Similarly, just pull in the minimal header necessary on non-Windows platforms +// to help with build performance. struct sockaddr; +#if defined(OS_WIN) typedef int socklen_t; #else -#include "net/base/sys_addrinfo.h" +#include <sys/socket.h> #endif namespace net {
diff --git a/net/base/ip_endpoint_unittest.cc b/net/base/ip_endpoint_unittest.cc index 61a9568..e7406f53 100644 --- a/net/base/ip_endpoint_unittest.cc +++ b/net/base/ip_endpoint_unittest.cc
@@ -17,6 +17,7 @@ #include "build/build_config.h" #include "net/base/ip_address.h" #include "net/base/sockaddr_storage.h" +#include "net/base/sys_addrinfo.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h"
diff --git a/net/dns/host_resolver_manager.cc b/net/dns/host_resolver_manager.cc index c490516..3d79980 100644 --- a/net/dns/host_resolver_manager.cc +++ b/net/dns/host_resolver_manager.cc
@@ -109,8 +109,7 @@ #if defined(OS_POSIX) || defined(OS_FUCHSIA) #include <net/if.h> -#include <netdb.h> -#include <netinet/in.h> +#include "net/base/sys_addrinfo.h" #if defined(OS_ANDROID) #include "base/android/build_info.h" #include "net/android/network_library.h"
diff --git a/net/socket/tcp_socket_posix.cc b/net/socket/tcp_socket_posix.cc index bd6f087..30a21493 100644 --- a/net/socket/tcp_socket_posix.cc +++ b/net/socket/tcp_socket_posix.cc
@@ -31,6 +31,7 @@ #include "net/base/network_activity_monitor.h" #include "net/base/network_change_notifier.h" #include "net/base/sockaddr_storage.h" +#include "net/base/sys_addrinfo.h" #include "net/http/http_util.h" #include "net/log/net_log.h" #include "net/log/net_log_event_type.h"
diff --git a/net/socket/tcp_socket_unittest.cc b/net/socket/tcp_socket_unittest.cc index 74f8e1d..2ed9accc 100644 --- a/net/socket/tcp_socket_unittest.cc +++ b/net/socket/tcp_socket_unittest.cc
@@ -21,6 +21,7 @@ #include "net/base/ip_endpoint.h" #include "net/base/net_errors.h" #include "net/base/sockaddr_storage.h" +#include "net/base/sys_addrinfo.h" #include "net/base/test_completion_callback.h" #include "net/log/net_log_source.h" #include "net/socket/socket_descriptor.h"
diff --git a/remoting/protocol/BUILD.gn b/remoting/protocol/BUILD.gn index 25fe826..eca2c24 100644 --- a/remoting/protocol/BUILD.gn +++ b/remoting/protocol/BUILD.gn
@@ -273,6 +273,8 @@ "webrtc_connection_to_client.cc", "webrtc_connection_to_client.h", "webrtc_frame_scheduler.h", + "webrtc_frame_scheduler_constant_rate.cc", + "webrtc_frame_scheduler_constant_rate.h", "webrtc_frame_scheduler_simple.cc", "webrtc_frame_scheduler_simple.h", "webrtc_video_encoder_factory.cc",
diff --git a/remoting/protocol/webrtc_frame_scheduler_constant_rate.cc b/remoting/protocol/webrtc_frame_scheduler_constant_rate.cc new file mode 100644 index 0000000..9cbacf0b --- /dev/null +++ b/remoting/protocol/webrtc_frame_scheduler_constant_rate.cc
@@ -0,0 +1,136 @@ +// Copyright 2021 The Chromium 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 "remoting/protocol/webrtc_frame_scheduler_constant_rate.h" + +#include <algorithm> + +#include "base/logging.h" + +namespace remoting { +namespace protocol { + +WebrtcFrameSchedulerConstantRate::WebrtcFrameSchedulerConstantRate() = default; + +WebrtcFrameSchedulerConstantRate::~WebrtcFrameSchedulerConstantRate() { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); +} + +void WebrtcFrameSchedulerConstantRate::OnKeyFrameRequested() { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); +} + +void WebrtcFrameSchedulerConstantRate::OnTargetBitrateChanged( + int bitrate_kbps) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); +} + +void WebrtcFrameSchedulerConstantRate::OnFrameEncoded( + WebrtcVideoEncoder::EncodeResult encode_result, + const WebrtcVideoEncoder::EncodedFrame* encoded_frame) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + + if (encoded_frame && encoded_frame->stats) { + // This scheduler cannot estimate this delay. Set it to 0 + // so the client can still calculate the derived stats. + encoded_frame->stats->send_pending_delay = base::TimeDelta(); + } +} + +void WebrtcFrameSchedulerConstantRate::OnEncodedFrameSent( + webrtc::EncodedImageCallback::Result result, + const WebrtcVideoEncoder::EncodedFrame& frame) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); +} + +void WebrtcFrameSchedulerConstantRate::Start( + const base::RepeatingClosure& capture_callback) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + capture_callback_ = capture_callback; +} + +void WebrtcFrameSchedulerConstantRate::Pause(bool pause) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + paused_ = pause; + if (paused_) { + capture_timer_.Stop(); + } else { + ScheduleNextFrame(); + } +} + +void WebrtcFrameSchedulerConstantRate::OnFrameCaptured( + const webrtc::DesktopFrame* frame) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + DCHECK(frame_pending_); + frame_pending_ = false; + ScheduleNextFrame(); +} + +void WebrtcFrameSchedulerConstantRate::SetMaxFramerateFps( + int max_framerate_fps) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + max_framerate_fps_ = max_framerate_fps; + ScheduleNextFrame(); +} + +void WebrtcFrameSchedulerConstantRate::ScheduleNextFrame() { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + + base::TimeTicks now = base::TimeTicks::Now(); + + if (paused_) { + VLOG(0) << "Not scheduling capture because stream is paused."; + return; + } + + if (!capture_callback_) { + VLOG(0) << "Not scheduling capture because callback is not provided."; + return; + } + + if (frame_pending_) { + // This might be logged every time the capture takes more time than the + // polling period. To avoid spamming, only log if the capture has been + // pending for an unreasonable length of time. + DCHECK(!last_capture_started_time_.is_null()); + if (now - last_capture_started_time_ > base::Seconds(1)) { + // Log this as an error, because a capture should never be pending for + // this length of time. + LOG(ERROR) << "Not scheduling capture because a capture is pending."; + } + return; + } + + if (max_framerate_fps_ == 0) { + VLOG(0) << "Not scheduling capture because framerate is set to 0."; + return; + } + + // Captures should be scheduled at least 1ms apart, otherwise WebRTC's video + // stream encoder complains about non-increasing frame timestamps, which can + // affect some unittests. + base::TimeDelta capture_interval = + std::max(base::Seconds(1) / max_framerate_fps_, base::Milliseconds(1)); + base::TimeDelta delay; + if (!last_capture_started_time_.is_null()) { + base::TimeTicks target_capture_time = + std::max(last_capture_started_time_ + capture_interval, now); + delay = target_capture_time - now; + } + + capture_timer_.Start(FROM_HERE, delay, this, + &WebrtcFrameSchedulerConstantRate::CaptureNextFrame); +} + +void WebrtcFrameSchedulerConstantRate::CaptureNextFrame() { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + DCHECK(!frame_pending_); + last_capture_started_time_ = base::TimeTicks::Now(); + frame_pending_ = true; + capture_callback_.Run(); +} + +} // namespace protocol +} // namespace remoting
diff --git a/remoting/protocol/webrtc_frame_scheduler_constant_rate.h b/remoting/protocol/webrtc_frame_scheduler_constant_rate.h new file mode 100644 index 0000000..b77756b --- /dev/null +++ b/remoting/protocol/webrtc_frame_scheduler_constant_rate.h
@@ -0,0 +1,72 @@ +// Copyright 2021 The Chromium 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 REMOTING_PROTOCOL_WEBRTC_FRAME_SCHEDULER_CONSTANT_RATE_H_ +#define REMOTING_PROTOCOL_WEBRTC_FRAME_SCHEDULER_CONSTANT_RATE_H_ + +#include "remoting/protocol/webrtc_frame_scheduler.h" + +#include "base/sequence_checker.h" +#include "base/thread_annotations.h" +#include "base/timer/timer.h" + +namespace remoting { +namespace protocol { + +// WebrtcFrameSchedulerConstantRate is an implementation of WebrtcFrameScheduler +// that captures frames at a fixed rate. It uses the maximum frame rate provided +// by SetMaxFramerateFps(). +class WebrtcFrameSchedulerConstantRate : public WebrtcFrameScheduler { + public: + WebrtcFrameSchedulerConstantRate(); + + WebrtcFrameSchedulerConstantRate(const WebrtcFrameSchedulerConstantRate&) = + delete; + WebrtcFrameSchedulerConstantRate& operator=( + const WebrtcFrameSchedulerConstantRate&) = delete; + + ~WebrtcFrameSchedulerConstantRate() override; + + // VideoChannelStateObserver implementation. + void OnKeyFrameRequested() override; + void OnTargetBitrateChanged(int bitrate_kbps) override; + void OnFrameEncoded( + WebrtcVideoEncoder::EncodeResult encode_result, + const WebrtcVideoEncoder::EncodedFrame* encoded_frame) override; + void OnEncodedFrameSent( + webrtc::EncodedImageCallback::Result result, + const WebrtcVideoEncoder::EncodedFrame& frame) override; + + // WebrtcFrameScheduler implementation. + void Start(const base::RepeatingClosure& capture_callback) override; + void Pause(bool pause) override; + void OnFrameCaptured(const webrtc::DesktopFrame* frame) override; + void SetMaxFramerateFps(int max_framerate_fps) override; + + private: + void ScheduleNextFrame(); + void CaptureNextFrame(); + + base::RepeatingClosure capture_callback_ + GUARDED_BY_CONTEXT(sequence_checker_); + bool paused_ GUARDED_BY_CONTEXT(sequence_checker_) = false; + base::OneShotTimer capture_timer_ GUARDED_BY_CONTEXT(sequence_checker_); + base::TimeTicks last_capture_started_time_ + GUARDED_BY_CONTEXT(sequence_checker_); + + // Set to true when a frame is being captured. Used to avoid scheduling more + // than one capture in parallel. + bool frame_pending_ GUARDED_BY_CONTEXT(sequence_checker_) = false; + + // Framerate for scheduling frames. Initially 0 to prevent scheduling before + // the output sink has been added. + int max_framerate_fps_ GUARDED_BY_CONTEXT(sequence_checker_) = 0; + + SEQUENCE_CHECKER(sequence_checker_); +}; + +} // namespace protocol +} // namespace remoting + +#endif // REMOTING_PROTOCOL_WEBRTC_FRAME_SCHEDULER_CONSTANT_RATE_H_
diff --git a/remoting/protocol/webrtc_frame_scheduler_unittest.cc b/remoting/protocol/webrtc_frame_scheduler_unittest.cc index 4b7c3458..547a9a9 100644 --- a/remoting/protocol/webrtc_frame_scheduler_unittest.cc +++ b/remoting/protocol/webrtc_frame_scheduler_unittest.cc
@@ -10,6 +10,7 @@ #include "base/test/task_environment.h" #include "remoting/base/session_options.h" #include "remoting/protocol/frame_stats.h" +#include "remoting/protocol/webrtc_frame_scheduler_constant_rate.h" #include "remoting/protocol/webrtc_frame_scheduler_simple.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" @@ -25,20 +26,30 @@ public: WebrtcFrameSchedulerTest() : task_environment_(base::test::TaskEnvironment::TimeSource::MOCK_TIME), - frame_(DesktopSize(1, 1)) { + frame_(DesktopSize(1, 1)) {} + ~WebrtcFrameSchedulerTest() override = default; + + void InitSimpleScheduler() { // Default ctor starts clock with null TimeTicks, which confuses // the scheduler, so use the current time as a baseline. task_environment_.FastForwardBy(base::Time::NowFromSystemTime() - base::Time()); - scheduler_ = std::make_unique<WebrtcFrameSchedulerSimple>(SessionOptions()); - scheduler_->SetTickClockForTest(task_environment_.GetMockTickClock()); + auto scheduler = + std::make_unique<WebrtcFrameSchedulerSimple>(SessionOptions()); + scheduler->SetTickClockForTest(task_environment_.GetMockTickClock()); + scheduler_ = std::move(scheduler); scheduler_->Start( base::BindRepeating(&WebrtcFrameSchedulerTest::CaptureCallback, base::Unretained(this))); scheduler_->SetMaxFramerateFps(30); } - ~WebrtcFrameSchedulerTest() override = default; + + void InitConstantRateScheduler() { + scheduler_ = std::make_unique<WebrtcFrameSchedulerConstantRate>(); + scheduler_->Start(base::BindRepeating( + &WebrtcFrameSchedulerTest::CaptureCallback, base::Unretained(this))); + } void CaptureCallback() { capture_callback_count_++; @@ -57,14 +68,16 @@ protected: base::test::TaskEnvironment task_environment_; - std::unique_ptr<WebrtcFrameSchedulerSimple> scheduler_; + std::unique_ptr<WebrtcFrameScheduler> scheduler_; int capture_callback_count_ = 0; - bool simulate_capture_ = false; + bool simulate_capture_ = true; BasicDesktopFrame frame_; }; TEST_F(WebrtcFrameSchedulerTest, UpdateBitrateWhenPending) { + InitSimpleScheduler(); + simulate_capture_ = false; scheduler_->OnKeyFrameRequested(); scheduler_->OnTargetBitrateChanged(100); @@ -81,7 +94,7 @@ } TEST_F(WebrtcFrameSchedulerTest, Capturer_RunsAt30Fps) { - simulate_capture_ = true; + InitSimpleScheduler(); scheduler_->OnTargetBitrateChanged(100); @@ -99,5 +112,56 @@ EXPECT_LE(capture_callback_count_, 31); } +// The tests below operate on the constant-rate scheduler. When the simple +// scheduler is no longer used, the tests above can be removed. + +TEST_F(WebrtcFrameSchedulerTest, NoCapturesIfZeroFps) { + InitConstantRateScheduler(); + scheduler_->SetMaxFramerateFps(0); + + task_environment_.FastForwardBy(base::Seconds(1)); + + EXPECT_EQ(0, capture_callback_count_); +} + +TEST_F(WebrtcFrameSchedulerTest, CapturesAtRequestedFramerate) { + InitConstantRateScheduler(); + scheduler_->SetMaxFramerateFps(60); + + task_environment_.FastForwardBy(base::Seconds(1)); + + // There should be approximately 60 captures in 1 second, making an allowance + // for any off-by-one artifacts in timing. + EXPECT_LE(59, capture_callback_count_); + EXPECT_LE(capture_callback_count_, 61); +} + +TEST_F(WebrtcFrameSchedulerTest, NoCaptureWhileCapturePending) { + InitConstantRateScheduler(); + simulate_capture_ = false; + scheduler_->SetMaxFramerateFps(60); + + task_environment_.FastForwardBy(base::Seconds(1)); + + // Only 1 capture callback, because the fake "capturer" never returns a + // captured frame. The scheduler should only do 1 capture at a time. + EXPECT_EQ(1, capture_callback_count_); +} + +TEST_F(WebrtcFrameSchedulerTest, NoCaptureWhilePaused) { + InitConstantRateScheduler(); + scheduler_->SetMaxFramerateFps(60); + scheduler_->Pause(true); + + task_environment_.FastForwardBy(base::Seconds(1)); + + EXPECT_EQ(0, capture_callback_count_); + + scheduler_->Pause(false); + task_environment_.FastForwardBy(base::Seconds(1)); + + EXPECT_LE(1, capture_callback_count_); +} + } // namespace protocol } // namespace remoting
diff --git a/remoting/protocol/webrtc_video_stream.cc b/remoting/protocol/webrtc_video_stream.cc index ab40828..5d1800b 100644 --- a/remoting/protocol/webrtc_video_stream.cc +++ b/remoting/protocol/webrtc_video_stream.cc
@@ -12,7 +12,7 @@ #include "remoting/base/constants.h" #include "remoting/protocol/frame_stats.h" #include "remoting/protocol/host_video_stats_dispatcher.h" -#include "remoting/protocol/webrtc_frame_scheduler_simple.h" +#include "remoting/protocol/webrtc_frame_scheduler_constant_rate.h" #include "remoting/protocol/webrtc_transport.h" #include "remoting/protocol/webrtc_video_encoder_factory.h" #include "remoting/protocol/webrtc_video_frame_adapter.h" @@ -90,7 +90,7 @@ video_encoder_factory->SetVideoChannelStateObserver( weak_factory_.GetWeakPtr()); - scheduler_ = std::make_unique<WebrtcFrameSchedulerSimple>(session_options_); + scheduler_ = std::make_unique<WebrtcFrameSchedulerConstantRate>(); scheduler_->Start(base::BindRepeating(&WebrtcVideoStream::CaptureNextFrame, base::Unretained(this))); }
diff --git a/sandbox/win/src/restricted_token.cc b/sandbox/win/src/restricted_token.cc index 7977565..544b03d 100644 --- a/sandbox/win/src/restricted_token.cc +++ b/sandbox/win/src/restricted_token.cc
@@ -18,18 +18,6 @@ namespace { -LUID ConvertToLuid(const CHROME_LUID& luid) { - LUID ret; - memcpy(&ret, &luid, sizeof(luid)); - return ret; -} - -CHROME_LUID ConvertToChromeLuid(const LUID& luid) { - CHROME_LUID ret; - memcpy(&ret, &luid, sizeof(luid)); - return ret; -} - std::vector<SID_AND_ATTRIBUTES> ConvertToAttributes( const std::vector<base::win::Sid>& sids, DWORD attributes) { @@ -41,6 +29,17 @@ return ret; } +bool DeletePrivilege(const base::win::ScopedHandle& token, + const wchar_t* name) { + TOKEN_PRIVILEGES privs = {}; + privs.PrivilegeCount = 1; + if (!::LookupPrivilegeValue(nullptr, name, &privs.Privileges[0].Luid)) + return false; + privs.Privileges[0].Attributes = SE_PRIVILEGE_REMOVED; + return !!::AdjustTokenPrivileges(token.Get(), FALSE, &privs, 0, nullptr, + nullptr); +} + } // namespace namespace sandbox { @@ -48,7 +47,9 @@ RestrictedToken::RestrictedToken() : integrity_level_(INTEGRITY_LEVEL_LAST), init_(false), - lockdown_default_dacl_(false) {} + lockdown_default_dacl_(false), + delete_all_privileges_(false), + remove_traversal_privilege_(false) {} RestrictedToken::~RestrictedToken() {} @@ -92,20 +93,16 @@ ConvertToAttributes(sids_for_deny_only_, SE_GROUP_USE_FOR_DENY_ONLY); std::vector<SID_AND_ATTRIBUTES> restrict_sids = ConvertToAttributes(sids_to_restrict_, 0); - std::vector<LUID_AND_ATTRIBUTES> disable_privs(privileges_to_disable_.size()); - for (size_t i = 0; i < privileges_to_disable_.size(); ++i) { - disable_privs[i].Attributes = 0; - disable_privs[i].Luid = ConvertToLuid(privileges_to_disable_[i]); - } bool result = true; HANDLE new_token_handle = nullptr; - if (!deny_sids.empty() || !restrict_sids.empty() || !disable_privs.empty()) { + if (!deny_sids.empty() || !restrict_sids.empty() || delete_all_privileges_) { result = ::CreateRestrictedToken( - effective_token_.Get(), 0, static_cast<DWORD>(deny_sids.size()), - deny_sids.data(), static_cast<DWORD>(disable_privs.size()), - disable_privs.data(), static_cast<DWORD>(restrict_sids.size()), - restrict_sids.data(), &new_token_handle); + effective_token_.Get(), + delete_all_privileges_ ? DISABLE_MAX_PRIVILEGE : 0, + static_cast<DWORD>(deny_sids.size()), deny_sids.data(), 0, nullptr, + static_cast<DWORD>(restrict_sids.size()), restrict_sids.data(), + &new_token_handle); } else { // Duplicate the token even if it's not modified at this point // because any subsequent changes to this token would also affect the @@ -119,6 +116,10 @@ return ::GetLastError(); base::win::ScopedHandle new_token(new_token_handle); + if (delete_all_privileges_ && remove_traversal_privilege_) { + if (!DeletePrivilege(new_token, SE_CHANGE_NOTIFY_NAME)) + return ::GetLastError(); + } if (lockdown_default_dacl_) { // Don't add Restricted sid and also remove logon sid access. @@ -232,35 +233,12 @@ return ERROR_SUCCESS; } -DWORD RestrictedToken::DeleteAllPrivileges( - const std::vector<std::wstring>& exceptions) { +DWORD RestrictedToken::DeleteAllPrivileges(bool remove_traversal_privilege) { DCHECK(init_); if (!init_) return ERROR_NO_TOKEN; - std::unordered_set<std::wstring> privilege_set(exceptions.begin(), - exceptions.end()); - // Build the list of privileges to disable - for (const base::win::AccessToken::Privilege& privilege : - query_token_->Privileges()) { - if (privilege_set.count(privilege.GetName()) == 0) { - privileges_to_disable_.push_back(privilege.GetLuid()); - } - } - - return ERROR_SUCCESS; -} - -DWORD RestrictedToken::DeletePrivilege(const wchar_t* privilege) { - DCHECK(init_); - if (!init_) - return ERROR_NO_TOKEN; - - LUID luid = {0}; - if (::LookupPrivilegeValue(nullptr, privilege, &luid)) - privileges_to_disable_.push_back(ConvertToChromeLuid(luid)); - else - return ::GetLastError(); - + delete_all_privileges_ = true; + remove_traversal_privilege_ = remove_traversal_privilege; return ERROR_SUCCESS; }
diff --git a/sandbox/win/src/restricted_token.h b/sandbox/win/src/restricted_token.h index 71ac545e..9cb7e1dd 100644 --- a/sandbox/win/src/restricted_token.h +++ b/sandbox/win/src/restricted_token.h
@@ -109,32 +109,14 @@ // the error. DWORD AddUserSidForDenyOnly(); - // Lists all privileges in the token and add them to the list of privileges - // to remove except for those present in the exceptions parameter. If - // there is no exception needed, the caller can pass an empty list or nullptr - // for the exceptions parameter. + // Specify to remove all privileges in the restricted token. By default this + // will not remove SeChangeNotifyPrivilege, however you can specify true for + // |remove_traversal_privilege| to remove that privilege as well. // // If the function succeeds, the return value is ERROR_SUCCESS. If the // function fails, the return value is the win32 error code corresponding to // the error. - // - // Sample usage: - // std::vector<std::wstring> privilege_exceptions; - // privilege_exceptions.push_back(SE_CHANGE_NOTIFY_NAME); - // restricted_token.DeleteAllPrivileges(privilege_exceptions); - DWORD DeleteAllPrivileges(const std::vector<std::wstring>& exceptions); - - // Adds a privilege to the list of privileges to remove in the restricted - // token. - // Parameter: privilege is the privilege name to remove. This is the string - // representing the privilege. (e.g. "SeChangeNotifyPrivilege"). - // If the function succeeds, the return value is ERROR_SUCCESS. If the - // function fails, the return value is the win32 error code corresponding to - // the error. - // - // Sample usage: - // restricted_token.DeletePrivilege(SE_LOAD_DRIVER_NAME); - DWORD DeletePrivilege(const wchar_t* privilege); + DWORD DeleteAllPrivileges(bool remove_traversal_privilege); // Adds a SID to the list of restricting sids in the restricted token. // Parameter: sid is the sid to add to the list restricting sids. @@ -206,8 +188,6 @@ private: // The list of restricting sids in the restricted token. std::vector<base::win::Sid> sids_to_restrict_; - // The list of privileges to remove in the restricted token. - std::vector<CHROME_LUID> privileges_to_disable_; // The list of sids to mark as Deny Only in the restricted token. std::vector<base::win::Sid> sids_for_deny_only_; // The list of sids to add to the default DACL of the restricted token. @@ -223,6 +203,10 @@ bool init_; // Lockdown the default DACL when creating new tokens. bool lockdown_default_dacl_; + // Delete all privileges except for SeChangeNotifyPrivilege. + bool delete_all_privileges_; + // Also delete SeChangeNotifyPrivilege if delete_all_privileges_ is true. + bool remove_traversal_privilege_; }; } // namespace sandbox
diff --git a/sandbox/win/src/restricted_token_unittest.cc b/sandbox/win/src/restricted_token_unittest.cc index e0dd7da4..3f35043 100644 --- a/sandbox/win/src/restricted_token_unittest.cc +++ b/sandbox/win/src/restricted_token_unittest.cc
@@ -410,7 +410,8 @@ base::win::ScopedHandle token_handle; ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.Init(nullptr)); - ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.DeleteAllPrivileges({})); + ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), + token.DeleteAllPrivileges(/*remove_traversal_privilege=*/true)); ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.GetRestrictedToken(&token_handle)); auto restricted_token = base::win::AccessToken::FromToken(token_handle.Get()); @@ -423,12 +424,9 @@ RestrictedToken token; base::win::ScopedHandle token_handle; - std::vector<std::wstring> exceptions; - exceptions.push_back(SE_CHANGE_NOTIFY_NAME); - ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.Init(nullptr)); ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), - token.DeleteAllPrivileges(exceptions)); + token.DeleteAllPrivileges(/*remove_traversal_privilege=*/false)); ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.GetRestrictedToken(&token_handle)); @@ -439,23 +437,6 @@ EXPECT_EQ(privileges[0].GetName(), SE_CHANGE_NOTIFY_NAME); } -// Tests the method DeletePrivilege. -TEST(RestrictedTokenTest, DeletePrivilege) { - RestrictedToken token; - base::win::ScopedHandle token_handle; - - ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.Init(nullptr)); - ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), - token.DeletePrivilege(SE_CHANGE_NOTIFY_NAME)); - ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), - token.GetRestrictedToken(&token_handle)); - auto restricted_token = base::win::AccessToken::FromToken(token_handle.Get()); - ASSERT_TRUE(restricted_token); - for (const auto& priv : restricted_token->Privileges()) { - ASSERT_NE(priv.GetName(), SE_CHANGE_NOTIFY_NAME); - } -} - // Tests the method AddRestrictingSid. TEST(RestrictedTokenTest, AddRestrictingSid) { RestrictedToken token;
diff --git a/sandbox/win/src/restricted_token_utils.cc b/sandbox/win/src/restricted_token_utils.cc index f68fe1d..3185f4e 100644 --- a/sandbox/win/src/restricted_token_utils.cc +++ b/sandbox/win/src/restricted_token_utils.cc
@@ -82,6 +82,7 @@ bool deny_sids = true; bool remove_privileges = true; + bool remove_traverse_privilege = false; switch (security_level) { case USER_UNPROTECTED: { @@ -105,7 +106,6 @@ AddSidException(sid_exceptions, base::win::WellKnownSid::kInteractive); AddSidException(sid_exceptions, base::win::WellKnownSid::kAuthenticatedUser); - privilege_exceptions.push_back(SE_CHANGE_NOTIFY_NAME); break; } case USER_RESTRICTED_NON_ADMIN: { @@ -114,7 +114,6 @@ AddSidException(sid_exceptions, base::win::WellKnownSid::kInteractive); AddSidException(sid_exceptions, base::win::WellKnownSid::kAuthenticatedUser); - privilege_exceptions.push_back(SE_CHANGE_NOTIFY_NAME); restricted_token.AddRestrictingSid( base::win::WellKnownSid::kBuiltinUsers); restricted_token.AddRestrictingSid(base::win::WellKnownSid::kWorld); @@ -134,7 +133,6 @@ AddSidException(sid_exceptions, base::win::WellKnownSid::kInteractive); AddSidException(sid_exceptions, base::win::WellKnownSid::kAuthenticatedUser); - privilege_exceptions.push_back(SE_CHANGE_NOTIFY_NAME); restricted_token.AddRestrictingSid( base::win::WellKnownSid::kBuiltinUsers); restricted_token.AddRestrictingSid(base::win::WellKnownSid::kWorld); @@ -149,7 +147,6 @@ AddSidException(sid_exceptions, base::win::WellKnownSid::kBuiltinUsers); AddSidException(sid_exceptions, base::win::WellKnownSid::kWorld); AddSidException(sid_exceptions, base::win::WellKnownSid::kInteractive); - privilege_exceptions.push_back(SE_CHANGE_NOTIFY_NAME); restricted_token.AddRestrictingSid( base::win::WellKnownSid::kBuiltinUsers); restricted_token.AddRestrictingSid(base::win::WellKnownSid::kWorld); @@ -166,7 +163,6 @@ break; } case USER_RESTRICTED: { - privilege_exceptions.push_back(SE_CHANGE_NOTIFY_NAME); restricted_token.AddUserSidForDenyOnly(); restricted_token.AddRestrictingSid(base::win::WellKnownSid::kRestricted); if (unique_restricted_sid) @@ -174,6 +170,7 @@ break; } case USER_LOCKDOWN: { + remove_traverse_privilege = true; restricted_token.AddUserSidForDenyOnly(); restricted_token.AddRestrictingSid(base::win::WellKnownSid::kNull); if (unique_restricted_sid) @@ -191,7 +188,7 @@ } if (remove_privileges) { - err_code = restricted_token.DeleteAllPrivileges(privilege_exceptions); + err_code = restricted_token.DeleteAllPrivileges(remove_traverse_privilege); if (ERROR_SUCCESS != err_code) return err_code; }
diff --git a/services/device/generic_sensor/platform_sensor_fusion_unittest.cc b/services/device/generic_sensor/platform_sensor_fusion_unittest.cc index 511c7ab..29206b1 100644 --- a/services/device/generic_sensor/platform_sensor_fusion_unittest.cc +++ b/services/device/generic_sensor/platform_sensor_fusion_unittest.cc
@@ -8,6 +8,7 @@ #include "base/callback_helpers.h" #include "base/memory/ref_counted.h" #include "base/test/task_environment.h" +#include "base/test/test_future.h" #include "services/device/generic_sensor/absolute_orientation_euler_angles_fusion_algorithm_using_accelerometer_and_magnetometer.h" #include "services/device/generic_sensor/fake_platform_sensor_and_provider.h" #include "services/device/generic_sensor/linear_acceleration_fusion_algorithm_using_accelerometer.h" @@ -34,37 +35,18 @@ PlatformSensorFusionTest& operator=(const PlatformSensorFusionTest&) = delete; protected: - void AccelerometerCallback(scoped_refptr<PlatformSensor> sensor) { - accelerometer_callback_called_ = true; - accelerometer_ = static_cast<FakePlatformSensor*>(sensor.get()); - } - - void MagnetometerCallback(scoped_refptr<PlatformSensor> sensor) { - magnetometer_callback_called_ = true; - magnetometer_ = static_cast<FakePlatformSensor*>(sensor.get()); - } - - void PlatformSensorFusionCallback(scoped_refptr<PlatformSensor> sensor) { - platform_sensor_fusion_callback_called_ = true; - fusion_sensor_ = static_cast<PlatformSensorFusion*>(sensor.get()); - } - void CreateAccelerometer() { - auto callback = - base::BindOnce(&PlatformSensorFusionTest::AccelerometerCallback, - base::Unretained(this)); - provider_->CreateSensor(SensorType::ACCELEROMETER, std::move(callback)); - EXPECT_TRUE(accelerometer_callback_called_); + base::test::TestFuture<scoped_refptr<PlatformSensor>> future; + provider_->CreateSensor(SensorType::ACCELEROMETER, future.GetCallback()); + accelerometer_ = static_cast<FakePlatformSensor*>(future.Get().get()); EXPECT_TRUE(accelerometer_); EXPECT_EQ(SensorType::ACCELEROMETER, accelerometer_->GetType()); } void CreateMagnetometer() { - auto callback = - base::BindOnce(&PlatformSensorFusionTest::MagnetometerCallback, - base::Unretained(this)); - provider_->CreateSensor(SensorType::MAGNETOMETER, std::move(callback)); - EXPECT_TRUE(magnetometer_callback_called_); + base::test::TestFuture<scoped_refptr<PlatformSensor>> future; + provider_->CreateSensor(SensorType::MAGNETOMETER, future.GetCallback()); + magnetometer_ = static_cast<FakePlatformSensor*>(future.Get().get()); EXPECT_TRUE(magnetometer_); EXPECT_EQ(SensorType::MAGNETOMETER, magnetometer_->GetType()); } @@ -83,23 +65,18 @@ void CreateFusionSensor( std::unique_ptr<PlatformSensorFusionAlgorithm> fusion_algorithm) { - auto callback = - base::BindOnce(&PlatformSensorFusionTest::PlatformSensorFusionCallback, - base::Unretained(this)); - SensorType type = fusion_algorithm->fused_type(); + base::test::TestFuture<scoped_refptr<PlatformSensor>> future; + const SensorType type = fusion_algorithm->fused_type(); PlatformSensorFusion::Create(provider_->GetSensorReadingBuffer(type), provider_.get(), std::move(fusion_algorithm), - std::move(callback)); - EXPECT_TRUE(platform_sensor_fusion_callback_called_); + future.GetCallback()); + fusion_sensor_ = static_cast<PlatformSensorFusion*>(future.Get().get()); } base::test::TaskEnvironment task_environment_; std::unique_ptr<FakePlatformSensorProvider> provider_; - bool accelerometer_callback_called_ = false; scoped_refptr<FakePlatformSensor> accelerometer_; - bool magnetometer_callback_called_ = false; scoped_refptr<FakePlatformSensor> magnetometer_; - bool platform_sensor_fusion_callback_called_ = false; scoped_refptr<PlatformSensorFusion> fusion_sensor_; };
diff --git a/services/device/serial/bluetooth_serial_device_enumerator.cc b/services/device/serial/bluetooth_serial_device_enumerator.cc index 792fc3cb..bd69301 100644 --- a/services/device/serial/bluetooth_serial_device_enumerator.cc +++ b/services/device/serial/bluetooth_serial_device_enumerator.cc
@@ -52,26 +52,20 @@ SEQUENCE_CHECKER(sequence_checker_); DCHECK(adapter); adapter->AddObserver(this); - std::unordered_map<std::string, base::UnguessableToken> device_ports; + std::vector<std::string> port_device_addresses; BluetoothAdapter::DeviceList devices = adapter->GetDevices(); - std::vector<mojom::SerialPortInfoPtr> ports; for (auto* device : devices) { BluetoothDevice::UUIDSet device_uuids = device->GetUUIDs(); if (base::Contains(device_uuids, GetSerialPortProfileUUID())) { - auto port = mojom::SerialPortInfo::New(); - port->token = base::UnguessableToken::Create(); - port->path = base::FilePath::FromUTF8Unsafe(device->GetAddress()); - port->type = mojom::DeviceType::SPP_DEVICE; - device_ports.insert(std::make_pair(device->GetAddress(), port->token)); - ports.push_back(std::move(port)); + port_device_addresses.push_back(device->GetAddress()); } } enumerator_runner_->PostTask( FROM_HERE, base::BindOnce(&BluetoothSerialDeviceEnumerator::SetClassicAdapter, - enumerator_, std::move(adapter), std::move(device_ports), - std::move(ports))); + enumerator_, std::move(adapter), + std::move(port_device_addresses))); } void BluetoothSerialDeviceEnumerator::AdapterHelper::DeviceAdded( @@ -82,14 +76,9 @@ if (!base::Contains(device_uuids, GetSerialPortProfileUUID())) return; - auto port = mojom::SerialPortInfo::New(); - port->token = base::UnguessableToken::Create(); - port->path = base::FilePath::FromUTF8Unsafe(device->GetAddress()); - port->type = mojom::DeviceType::SPP_DEVICE; enumerator_runner_->PostTask( - FROM_HERE, - base::BindOnce(&BluetoothSerialDeviceEnumerator::PortAdded, enumerator_, - device->GetAddress(), std::move(port))); + FROM_HERE, base::BindOnce(&BluetoothSerialDeviceEnumerator::PortAdded, + enumerator_, device->GetAddress())); } void BluetoothSerialDeviceEnumerator::AdapterHelper::DeviceRemoved( @@ -115,15 +104,13 @@ void BluetoothSerialDeviceEnumerator::SetClassicAdapter( scoped_refptr<device::BluetoothAdapter> adapter, - std::unordered_map<std::string, base::UnguessableToken> device_ports, - std::vector<mojom::SerialPortInfoPtr> ports) { + std::vector<std::string> port_device_addresses) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK(adapter); - DCHECK(device_ports_.empty()); adapter_ = std::move(adapter); - device_ports_ = std::move(device_ports); - for (auto& port : ports) { - AddPort(std::move(port)); + DCHECK(device_ports_.empty()); + for (const auto& device_address : port_device_addresses) { + PortAdded(device_address); } if (got_adapter_callback_) { std::move(got_adapter_callback_).Run(); @@ -131,10 +118,13 @@ } void BluetoothSerialDeviceEnumerator::PortAdded( - const std::string& device_address, - mojom::SerialPortInfoPtr port) { + const std::string& device_address) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK(!base::Contains(device_ports_, device_address)); + auto port = mojom::SerialPortInfo::New(); + port->token = base::UnguessableToken::Create(); + port->path = base::FilePath::FromUTF8Unsafe(device_address); + port->type = mojom::DeviceType::SPP_DEVICE; device_ports_.insert(std::make_pair(device_address, port->token)); AddPort(std::move(port)); }
diff --git a/services/device/serial/bluetooth_serial_device_enumerator.h b/services/device/serial/bluetooth_serial_device_enumerator.h index c3650d6..2bc7ec3b 100644 --- a/services/device/serial/bluetooth_serial_device_enumerator.h +++ b/services/device/serial/bluetooth_serial_device_enumerator.h
@@ -31,8 +31,7 @@ const BluetoothSerialDeviceEnumerator&) = delete; ~BluetoothSerialDeviceEnumerator() override; - void PortAdded(const std::string& device_address, - mojom::SerialPortInfoPtr port); + void PortAdded(const std::string& device_address); void PortRemoved(const std::string& device_address); scoped_refptr<BluetoothAdapter> GetAdapter(); @@ -50,14 +49,15 @@ private: class AdapterHelper; - // Map BluetoothDevice address to Port token. + // Map BluetoothDevice address to port token. using DevicePortsMap = std::unordered_map<std::string, base::UnguessableToken>; - void SetClassicAdapter( - scoped_refptr<device::BluetoothAdapter> adapter, - std::unordered_map<std::string, base::UnguessableToken> device_ports, - std::vector<mojom::SerialPortInfoPtr> ports); + // Set the "classic" `adapter`. `port_device_addresses` is a collection of + // all known ports device addresses at the time the adapter is detected. + // Called once during initialization. + void SetClassicAdapter(scoped_refptr<device::BluetoothAdapter> adapter, + std::vector<std::string> port_device_addresses); base::OnceClosure got_adapter_callback_; scoped_refptr<BluetoothAdapter> adapter_;
diff --git a/services/device/serial/serial_port_manager_impl.cc b/services/device/serial/serial_port_manager_impl.cc index 5a14054..b91d21b 100644 --- a/services/device/serial/serial_port_manager_impl.cc +++ b/services/device/serial/serial_port_manager_impl.cc
@@ -35,9 +35,13 @@ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) : io_task_runner_(std::move(io_task_runner)), - ui_task_runner_(std::move(ui_task_runner)) {} + ui_task_runner_(std::move(ui_task_runner)) { + DETACH_FROM_SEQUENCE(sequence_checker_); +} -SerialPortManagerImpl::~SerialPortManagerImpl() = default; +SerialPortManagerImpl::~SerialPortManagerImpl() { + // Intentionally do not check sequence. See class comment doc for more info. +} void SerialPortManagerImpl::Bind( mojo::PendingReceiver<mojom::SerialPortManager> receiver) { @@ -47,6 +51,7 @@ void SerialPortManagerImpl::SetSerialEnumeratorForTesting( std::unique_ptr<SerialDeviceEnumerator> fake_enumerator) { DCHECK(fake_enumerator); + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); enumerator_ = std::move(fake_enumerator); observed_enumerator_.AddObservation(enumerator_.get()); } @@ -55,16 +60,19 @@ std::unique_ptr<BluetoothSerialDeviceEnumerator> fake_bluetooth_enumerator) { DCHECK(fake_bluetooth_enumerator); + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); bluetooth_enumerator_ = std::move(fake_bluetooth_enumerator); observed_enumerator_.AddObservation(bluetooth_enumerator_.get()); } void SerialPortManagerImpl::SetClient( mojo::PendingRemote<mojom::SerialPortManagerClient> client) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); clients_.Add(std::move(client)); } void SerialPortManagerImpl::GetDevices(GetDevicesCallback callback) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (!enumerator_) { enumerator_ = SerialDeviceEnumerator::Create(ui_task_runner_); observed_enumerator_.AddObservation(enumerator_.get()); @@ -93,6 +101,7 @@ mojo::PendingRemote<mojom::SerialPortClient> client, mojo::PendingRemote<mojom::SerialPortConnectionWatcher> watcher, OpenPortCallback callback) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (!enumerator_) { enumerator_ = SerialDeviceEnumerator::Create(ui_task_runner_); observed_enumerator_.AddObservation(enumerator_.get()); @@ -135,11 +144,13 @@ } void SerialPortManagerImpl::OnPortAdded(const mojom::SerialPortInfo& port) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); for (auto& client : clients_) client->OnPortAdded(port.Clone()); } void SerialPortManagerImpl::OnPortRemoved(const mojom::SerialPortInfo& port) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); for (auto& client : clients_) client->OnPortRemoved(port.Clone()); }
diff --git a/services/device/serial/serial_port_manager_impl.h b/services/device/serial/serial_port_manager_impl.h index 1417174e..5f9402e 100644 --- a/services/device/serial/serial_port_manager_impl.h +++ b/services/device/serial/serial_port_manager_impl.h
@@ -9,6 +9,7 @@ #include "base/memory/ref_counted.h" #include "base/scoped_multi_source_observation.h" +#include "base/sequence_checker.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/receiver_set.h" @@ -20,13 +21,21 @@ namespace base { class SingleThreadTaskRunner; class UnguessableToken; -} +} // namespace base namespace device { // TODO(leonhsl): Merge this class with SerialDeviceEnumerator if/once // SerialDeviceEnumerator is exposed only via the Device Service. // crbug.com/748505 +// +// Threading notes: +// 1. Created on the UI thread. +// 2. Used on the UI thread runner (macOS only), otherwise on a blocking task +// runner. +// 3. Deleted on the same runner on which it is used *except* sometimes +// during shutdown when the runner threadpool is already shutdown. +// See crbug.com/1263149#c20 for details. class SerialPortManagerImpl : public mojom::SerialPortManager, public SerialDeviceEnumerator::Observer { public: @@ -73,6 +82,8 @@ mojo::ReceiverSet<SerialPortManager> receivers_; mojo::RemoteSet<mojom::SerialPortManagerClient> clients_; + // See threading notes above for guidelines for checking sequence. + SEQUENCE_CHECKER(sequence_checker_); }; } // namespace device
diff --git a/testing/buildbot/chromium.android.fyi.json b/testing/buildbot/chromium.android.fyi.json index 87b6378..4024955 100644 --- a/testing/buildbot/chromium.android.fyi.json +++ b/testing/buildbot/chromium.android.fyi.json
@@ -5884,7 +5884,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M97", - "revision": "version:97.0.4692.34" + "revision": "version:97.0.4692.35" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -6148,7 +6148,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M97", - "revision": "version:97.0.4692.34" + "revision": "version:97.0.4692.35" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}",
diff --git a/testing/buildbot/chromium.android.json b/testing/buildbot/chromium.android.json index 3ab48ba..c1f9bfc 100644 --- a/testing/buildbot/chromium.android.json +++ b/testing/buildbot/chromium.android.json
@@ -43753,7 +43753,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M97", - "revision": "version:97.0.4692.34" + "revision": "version:97.0.4692.35" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -44017,7 +44017,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M97", - "revision": "version:97.0.4692.34" + "revision": "version:97.0.4692.35" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -44356,7 +44356,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M97", - "revision": "version:97.0.4692.34" + "revision": "version:97.0.4692.35" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -44620,7 +44620,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M97", - "revision": "version:97.0.4692.34" + "revision": "version:97.0.4692.35" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -44959,7 +44959,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M97", - "revision": "version:97.0.4692.34" + "revision": "version:97.0.4692.35" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -45223,7 +45223,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M97", - "revision": "version:97.0.4692.34" + "revision": "version:97.0.4692.35" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}",
diff --git a/testing/buildbot/variants.pyl b/testing/buildbot/variants.pyl index 60cb0f7..85dc253 100644 --- a/testing/buildbot/variants.pyl +++ b/testing/buildbot/variants.pyl
@@ -363,7 +363,7 @@ { 'cipd_package': 'chromium/testing/weblayer-x86', 'location': 'weblayer_instrumentation_test_M97', - 'revision': 'version:97.0.4692.34', + 'revision': 'version:97.0.4692.35', } ], }, @@ -435,7 +435,7 @@ { 'cipd_package': 'chromium/testing/weblayer-x86', 'location': 'weblayer_instrumentation_test_M97', - 'revision': 'version:97.0.4692.34', + 'revision': 'version:97.0.4692.35', } ], }, @@ -507,7 +507,7 @@ { 'cipd_package': 'chromium/testing/weblayer-x86', 'location': 'weblayer_instrumentation_test_M97', - 'revision': 'version:97.0.4692.34', + 'revision': 'version:97.0.4692.35', } ], },
diff --git a/testing/scripts/OWNERS b/testing/scripts/OWNERS index 983cd6d..bff28e2 100644 --- a/testing/scripts/OWNERS +++ b/testing/scripts/OWNERS
@@ -1,6 +1,7 @@ # This is reserved for people that are comfortably with buildbot recipes # and understand the implications of changing these files. +bsheedy@chromium.org dpranke@google.com kbr@chromium.org martiniss@chromium.org
diff --git a/testing/scripts/run_gpu_integration_test_as_googletest.py b/testing/scripts/run_gpu_integration_test_as_googletest.py index 9d54f0c..dc5e128 100755 --- a/testing/scripts/run_gpu_integration_test_as_googletest.py +++ b/testing/scripts/run_gpu_integration_test_as_googletest.py
@@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env vpython3 # Copyright 2015 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file.
diff --git a/testing/scripts/run_telemetry_as_googletest.py b/testing/scripts/run_telemetry_as_googletest.py index 0e0f604..e05f733 100755 --- a/testing/scripts/run_telemetry_as_googletest.py +++ b/testing/scripts/run_telemetry_as_googletest.py
@@ -1,4 +1,4 @@ -#!/usr/bin/env vpython +#!/usr/bin/env vpython3 # Copyright 2015 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file.
diff --git a/testing/variations/fieldtrial_testing_config.json b/testing/variations/fieldtrial_testing_config.json index 4e42d7b..b3dd7c2 100644 --- a/testing/variations/fieldtrial_testing_config.json +++ b/testing/variations/fieldtrial_testing_config.json
@@ -4456,6 +4456,21 @@ ] } ], + "IOSURLBlocklistPolicy": [ + { + "platforms": [ + "ios" + ], + "experiments": [ + { + "name": "Enabled", + "enable_features": [ + "URLBlocklistIOS" + ] + } + ] + } + ], "IOSUseUserDefaultsForExitedCleanlyBeacon": [ { "platforms": [
diff --git a/third_party/blink/public/BUILD.gn b/third_party/blink/public/BUILD.gn index 4afea14..bb5a471a 100644 --- a/third_party/blink/public/BUILD.gn +++ b/third_party/blink/public/BUILD.gn
@@ -280,8 +280,8 @@ "web/modules/autofill/web_form_element_observer.h", "web/modules/autofill_assistant/node_signals.h", "web/modules/media/audio/audio_device_factory.h", - "web/modules/media/audio/web_audio_input_ipc_factory.h", - "web/modules/media/audio/web_audio_output_ipc_factory.h", + "web/modules/media/audio/audio_input_ipc_factory.h", + "web/modules/media/audio/audio_output_ipc_factory.h", "web/modules/media/webmediaplayer_util.h", "web/modules/mediastream/encoded_video_frame.h", "web/modules/mediastream/media_stream_video_sink.h",
diff --git a/third_party/blink/public/common/frame/event_page_show_persisted.h b/third_party/blink/public/common/frame/event_page_show_persisted.h index e0f5ce5..6b04fdb 100644 --- a/third_party/blink/public/common/frame/event_page_show_persisted.h +++ b/third_party/blink/public/common/frame/event_page_show_persisted.h
@@ -44,11 +44,16 @@ // `should_dispatch_pageshow_for_debugging` set to true. kYesInBrowserAck = 9, + // Mojo interface was not connected when the IPC was being sent. kYesInBrowserDisconnected = 10, + + // RenderView was not live when the IPC was being sent. + kYesInBrowserRenderViewNotLive = 11, + // There is not kNoInBrowser as we don't have to compare the counts of // pageshow events without persisted between browser and renderer so far. - kMaxValue = kYesInBrowserDisconnected, + kMaxValue = kYesInBrowserRenderViewNotLive, }; BLINK_COMMON_EXPORT void RecordUMAEventPageShowPersisted(
diff --git a/third_party/blink/public/mojom/frame/frame.mojom b/third_party/blink/public/mojom/frame/frame.mojom index d088e3d..d3faf1f 100644 --- a/third_party/blink/public/mojom/frame/frame.mojom +++ b/third_party/blink/public/mojom/frame/frame.mojom
@@ -1157,8 +1157,7 @@ // InstallCoopAccessMonitor( blink.mojom.FrameToken accessed_window, - bool register_metrics, - network.mojom.CrossOriginOpenerPolicyReporterParams? coop_reporter_info); + network.mojom.CrossOriginOpenerPolicyReporterParams coop_reporter_info); // Called on the main frame of a page embedded in a Portal when it is // activated. The frame has the option to adopt the previous page as a portal
diff --git a/third_party/blink/public/mojom/web_feature/web_feature.mojom b/third_party/blink/public/mojom/web_feature/web_feature.mojom index 09d3a61..181a342 100644 --- a/third_party/blink/public/mojom/web_feature/web_feature.mojom +++ b/third_party/blink/public/mojom/web_feature/web_feature.mojom
@@ -3391,7 +3391,6 @@ kCSSMatchMediaUnknown = 4082, kCSSMediaListUnknown = 4083, kCSSOMMediaConditionUnknown = 4084, - kCrossPageAccessBrokenByCOOPSOAPByDefault = 4085, // Add new features immediately above this line. Don't change assigned // numbers of any item, and don't reuse removed slots.
diff --git a/third_party/blink/public/web/modules/media/audio/web_audio_input_ipc_factory.h b/third_party/blink/public/web/modules/media/audio/audio_input_ipc_factory.h similarity index 69% rename from third_party/blink/public/web/modules/media/audio/web_audio_input_ipc_factory.h rename to third_party/blink/public/web/modules/media/audio/audio_input_ipc_factory.h index c91f0f3..555ec2b 100644 --- a/third_party/blink/public/web/modules/media/audio/web_audio_input_ipc_factory.h +++ b/third_party/blink/public/web/modules/media/audio/audio_input_ipc_factory.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef THIRD_PARTY_BLINK_PUBLIC_WEB_MODULES_MEDIA_AUDIO_WEB_AUDIO_INPUT_IPC_FACTORY_H_ -#define THIRD_PARTY_BLINK_PUBLIC_WEB_MODULES_MEDIA_AUDIO_WEB_AUDIO_INPUT_IPC_FACTORY_H_ +#ifndef THIRD_PARTY_BLINK_PUBLIC_WEB_MODULES_MEDIA_AUDIO_AUDIO_INPUT_IPC_FACTORY_H_ +#define THIRD_PARTY_BLINK_PUBLIC_WEB_MODULES_MEDIA_AUDIO_AUDIO_INPUT_IPC_FACTORY_H_ #include <memory> @@ -24,16 +24,16 @@ namespace blink { // This is a thread-safe factory for AudioInputIPC objects. -class BLINK_MODULES_EXPORT WebAudioInputIPCFactory { +class BLINK_MODULES_EXPORT AudioInputIPCFactory { public: - WebAudioInputIPCFactory( + AudioInputIPCFactory( scoped_refptr<base::SequencedTaskRunner> main_task_runner, scoped_refptr<base::SingleThreadTaskRunner> io_task_runner); - WebAudioInputIPCFactory(const WebAudioInputIPCFactory&) = delete; - WebAudioInputIPCFactory& operator=(const WebAudioInputIPCFactory&) = delete; - ~WebAudioInputIPCFactory(); + AudioInputIPCFactory(const AudioInputIPCFactory&) = delete; + AudioInputIPCFactory& operator=(const AudioInputIPCFactory&) = delete; + ~AudioInputIPCFactory(); - static WebAudioInputIPCFactory& GetInstance(); + static AudioInputIPCFactory& GetInstance(); const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner() const { return io_task_runner_; @@ -51,4 +51,4 @@ } // namespace blink -#endif // THIRD_PARTY_BLINK_PUBLIC_WEB_MODULES_MEDIA_AUDIO_WEB_AUDIO_INPUT_IPC_FACTORY_H_ +#endif // THIRD_PARTY_BLINK_PUBLIC_WEB_MODULES_MEDIA_AUDIO_AUDIO_INPUT_IPC_FACTORY_H_
diff --git a/third_party/blink/public/web/modules/media/audio/web_audio_output_ipc_factory.h b/third_party/blink/public/web/modules/media/audio/audio_output_ipc_factory.h similarity index 78% rename from third_party/blink/public/web/modules/media/audio/web_audio_output_ipc_factory.h rename to third_party/blink/public/web/modules/media/audio/audio_output_ipc_factory.h index 5ae0c1f..2698bf73 100644 --- a/third_party/blink/public/web/modules/media/audio/web_audio_output_ipc_factory.h +++ b/third_party/blink/public/web/modules/media/audio/audio_output_ipc_factory.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef THIRD_PARTY_BLINK_PUBLIC_WEB_MODULES_MEDIA_AUDIO_WEB_AUDIO_OUTPUT_IPC_FACTORY_H_ -#define THIRD_PARTY_BLINK_PUBLIC_WEB_MODULES_MEDIA_AUDIO_WEB_AUDIO_OUTPUT_IPC_FACTORY_H_ +#ifndef THIRD_PARTY_BLINK_PUBLIC_WEB_MODULES_MEDIA_AUDIO_AUDIO_OUTPUT_IPC_FACTORY_H_ +#define THIRD_PARTY_BLINK_PUBLIC_WEB_MODULES_MEDIA_AUDIO_AUDIO_OUTPUT_IPC_FACTORY_H_ #include <memory> @@ -32,15 +32,15 @@ // TODO(maxmorin): Registering the factories for each frame will become // unnecessary when https://crbug.com/668275 is fixed. When that is done, this // class can be greatly simplified. -class BLINK_MODULES_EXPORT WebAudioOutputIPCFactory { +class BLINK_MODULES_EXPORT AudioOutputIPCFactory { public: - explicit WebAudioOutputIPCFactory( + explicit AudioOutputIPCFactory( scoped_refptr<base::SingleThreadTaskRunner> io_task_runner); - WebAudioOutputIPCFactory(const WebAudioOutputIPCFactory&) = delete; - WebAudioOutputIPCFactory& operator=(const WebAudioOutputIPCFactory&) = delete; - ~WebAudioOutputIPCFactory(); + AudioOutputIPCFactory(const AudioOutputIPCFactory&) = delete; + AudioOutputIPCFactory& operator=(const AudioOutputIPCFactory&) = delete; + ~AudioOutputIPCFactory(); - static WebAudioOutputIPCFactory& GetInstance(); + static AudioOutputIPCFactory& GetInstance(); const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner() const; @@ -67,4 +67,4 @@ } // namespace blink -#endif // THIRD_PARTY_BLINK_PUBLIC_WEB_MODULES_MEDIA_AUDIO_WEB_AUDIO_OUTPUT_IPC_FACTORY_H_ +#endif // THIRD_PARTY_BLINK_PUBLIC_WEB_MODULES_MEDIA_AUDIO_AUDIO_OUTPUT_IPC_FACTORY_H_
diff --git a/third_party/blink/renderer/bindings/core/v8/idl_dictionary_base.h b/third_party/blink/renderer/bindings/core/v8/idl_dictionary_base.h index 616c95a..ece9ac1 100644 --- a/third_party/blink/renderer/bindings/core/v8/idl_dictionary_base.h +++ b/third_party/blink/renderer/bindings/core/v8/idl_dictionary_base.h
@@ -6,7 +6,7 @@ #define THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_IDL_DICTIONARY_BASE_H_ #include "third_party/blink/renderer/core/core_export.h" -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "v8/include/v8.h"
diff --git a/third_party/blink/renderer/bindings/core/v8/script_streamer.h b/third_party/blink/renderer/bindings/core/v8/script_streamer.h index 4d863be..98ce365a 100644 --- a/third_party/blink/renderer/bindings/core/v8/script_streamer.h +++ b/third_party/blink/renderer/bindings/core/v8/script_streamer.h
@@ -13,6 +13,7 @@ #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/script/script_scheduling_type.h" #include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/heap/prefinalizer.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "v8/include/v8.h"
diff --git a/third_party/blink/renderer/core/clipboard/data_transfer_item_list.h b/third_party/blink/renderer/core/clipboard/data_transfer_item_list.h index fb6fca1..1275339 100644 --- a/third_party/blink/renderer/core/clipboard/data_transfer_item_list.h +++ b/third_party/blink/renderer/core/clipboard/data_transfer_item_list.h
@@ -34,6 +34,7 @@ #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/forward.h" namespace blink {
diff --git a/third_party/blink/renderer/core/css/container_query_data.h b/third_party/blink/renderer/core/css/container_query_data.h index 48c6a6d..f50790a 100644 --- a/third_party/blink/renderer/core/css/container_query_data.h +++ b/third_party/blink/renderer/core/css/container_query_data.h
@@ -7,7 +7,8 @@ #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/renderer/core/css/style_recalc.h" -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" namespace blink {
diff --git a/third_party/blink/renderer/core/css/css_counter_style_rule.h b/third_party/blink/renderer/core/css/css_counter_style_rule.h index 6e8620d..e11c8a90 100644 --- a/third_party/blink/renderer/core/css/css_counter_style_rule.h +++ b/third_party/blink/renderer/core/css/css_counter_style_rule.h
@@ -7,6 +7,7 @@ #include "third_party/blink/renderer/core/css/css_rule.h" #include "third_party/blink/renderer/core/css/parser/at_rule_descriptors.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/casting.h" namespace blink {
diff --git a/third_party/blink/renderer/core/css/css_default_style_sheets.h b/third_party/blink/renderer/core/css/css_default_style_sheets.h index 44fed53..c2266d799 100644 --- a/third_party/blink/renderer/core/css/css_default_style_sheets.h +++ b/third_party/blink/renderer/core/css/css_default_style_sheets.h
@@ -27,6 +27,7 @@ #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/style/computed_style_constants.h" #include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
diff --git a/third_party/blink/renderer/core/css/css_font_face_rule.h b/third_party/blink/renderer/core/css/css_font_face_rule.h index e1b0ec0..9a2a7f6 100644 --- a/third_party/blink/renderer/core/css/css_font_face_rule.h +++ b/third_party/blink/renderer/core/css/css_font_face_rule.h
@@ -24,6 +24,7 @@ #include "third_party/blink/renderer/core/css/css_rule.h" #include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/casting.h" namespace blink {
diff --git a/third_party/blink/renderer/core/css/css_layer_block_rule.cc b/third_party/blink/renderer/core/css/css_layer_block_rule.cc index dede0b2..11d38b5 100644 --- a/third_party/blink/renderer/core/css/css_layer_block_rule.cc +++ b/third_party/blink/renderer/core/css/css_layer_block_rule.cc
@@ -15,12 +15,16 @@ CSSLayerBlockRule::~CSSLayerBlockRule() = default; +String CSSLayerBlockRule::name() const { + return To<StyleRuleLayerBlock>(group_rule_.Get())->GetNameAsString(); +} + String CSSLayerBlockRule::cssText() const { StringBuilder result; result.Append("@layer "); - String name = To<StyleRuleLayerBlock>(group_rule_.Get())->GetNameAsString(); - if (name.length()) { - result.Append(name); + const String& layer_name = name(); + if (layer_name.length()) { + result.Append(layer_name); result.Append(" "); } result.Append("{\n");
diff --git a/third_party/blink/renderer/core/css/css_layer_block_rule.h b/third_party/blink/renderer/core/css/css_layer_block_rule.h index 4fdbd573..8ab557f 100644 --- a/third_party/blink/renderer/core/css/css_layer_block_rule.h +++ b/third_party/blink/renderer/core/css/css_layer_block_rule.h
@@ -19,6 +19,8 @@ CSSLayerBlockRule(StyleRuleLayerBlock*, CSSStyleSheet*); ~CSSLayerBlockRule() override; + String name() const; + void Reattach(StyleRuleBase*) override; String cssText() const override;
diff --git a/third_party/blink/renderer/core/css/css_layer_block_rule.idl b/third_party/blink/renderer/core/css/css_layer_block_rule.idl index 69e640e..2b34a5b 100644 --- a/third_party/blink/renderer/core/css/css_layer_block_rule.idl +++ b/third_party/blink/renderer/core/css/css_layer_block_rule.idl
@@ -2,9 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// https://drafts.csswg.org/css-cascade-5/#the-csslayerblockrule-interface [ Exposed=Window, RuntimeEnabled=CSSCascadeLayers ] interface CSSLayerBlockRule : CSSGroupingRule { - // TODO(crbug.com/1095765): Spec and implement. + readonly attribute CSSOMString name; };
diff --git a/third_party/blink/renderer/core/css/css_layer_statement_rule.cc b/third_party/blink/renderer/core/css/css_layer_statement_rule.cc index 33f31c1..3d19a17 100644 --- a/third_party/blink/renderer/core/css/css_layer_statement_rule.cc +++ b/third_party/blink/renderer/core/css/css_layer_statement_rule.cc
@@ -16,10 +16,14 @@ CSSLayerStatementRule::~CSSLayerStatementRule() = default; +Vector<String> CSSLayerStatementRule::nameList() const { + return layer_statement_rule_->GetNamesAsStrings(); +} + String CSSLayerStatementRule::cssText() const { StringBuilder result; result.Append("@layer "); - Vector<String> names = layer_statement_rule_->GetNamesAsStrings(); + const Vector<String>& names = nameList(); result.Append(names[0]); for (unsigned i = 1; i < names.size(); ++i) { result.Append(", ");
diff --git a/third_party/blink/renderer/core/css/css_layer_statement_rule.h b/third_party/blink/renderer/core/css/css_layer_statement_rule.h index 08fd49ea..6131274c 100644 --- a/third_party/blink/renderer/core/css/css_layer_statement_rule.h +++ b/third_party/blink/renderer/core/css/css_layer_statement_rule.h
@@ -6,6 +6,7 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_LAYER_STATEMENT_RULE_H_ #include "third_party/blink/renderer/core/css/css_rule.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/casting.h" namespace blink { @@ -19,6 +20,8 @@ CSSLayerStatementRule(StyleRuleLayerStatement*, CSSStyleSheet*); ~CSSLayerStatementRule() override; + Vector<String> nameList() const; + void Reattach(StyleRuleBase*) override; String cssText() const override;
diff --git a/third_party/blink/renderer/core/css/css_layer_statement_rule.idl b/third_party/blink/renderer/core/css/css_layer_statement_rule.idl index 2584f6a..6f361ce 100644 --- a/third_party/blink/renderer/core/css/css_layer_statement_rule.idl +++ b/third_party/blink/renderer/core/css/css_layer_statement_rule.idl
@@ -2,9 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// https://drafts.csswg.org/css-cascade-5/#the-csslayerstatementrule-interface [ Exposed=Window, RuntimeEnabled=CSSCascadeLayers ] interface CSSLayerStatementRule : CSSRule { - // TODO(crbug.com/1095765): Spec and implement. + readonly attribute FrozenArray<CSSOMString> nameList; };
diff --git a/third_party/blink/renderer/core/css/css_namespace_rule.h b/third_party/blink/renderer/core/css/css_namespace_rule.h index 48fc083..697e31d 100644 --- a/third_party/blink/renderer/core/css/css_namespace_rule.h +++ b/third_party/blink/renderer/core/css/css_namespace_rule.h
@@ -6,6 +6,7 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_NAMESPACE_RULE_H_ #include "third_party/blink/renderer/core/css/css_rule.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/casting.h" namespace blink {
diff --git a/third_party/blink/renderer/core/css/css_page_rule.h b/third_party/blink/renderer/core/css/css_page_rule.h index 161078e..b5832e3b 100644 --- a/third_party/blink/renderer/core/css/css_page_rule.h +++ b/third_party/blink/renderer/core/css/css_page_rule.h
@@ -24,6 +24,7 @@ #include "third_party/blink/renderer/core/css/css_rule.h" #include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/casting.h" namespace blink {
diff --git a/third_party/blink/renderer/core/css/css_property_rule.h b/third_party/blink/renderer/core/css/css_property_rule.h index 6a0c0c3a..5769432 100644 --- a/third_party/blink/renderer/core/css/css_property_rule.h +++ b/third_party/blink/renderer/core/css/css_property_rule.h
@@ -7,6 +7,7 @@ #include "third_party/blink/renderer/core/css/css_rule.h" #include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/casting.h" namespace blink {
diff --git a/third_party/blink/renderer/core/css/css_rule.h b/third_party/blink/renderer/core/css/css_rule.h index fb6e6f0d..5f394f8 100644 --- a/third_party/blink/renderer/core/css/css_rule.h +++ b/third_party/blink/renderer/core/css/css_rule.h
@@ -27,6 +27,7 @@ #include "third_party/blink/renderer/core/frame/web_feature_forward.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" namespace blink {
diff --git a/third_party/blink/renderer/core/css/css_scroll_timeline_rule.h b/third_party/blink/renderer/core/css/css_scroll_timeline_rule.h index 7e5da7a..53aa895 100644 --- a/third_party/blink/renderer/core/css/css_scroll_timeline_rule.h +++ b/third_party/blink/renderer/core/css/css_scroll_timeline_rule.h
@@ -7,6 +7,7 @@ #include "third_party/blink/renderer/core/css/css_rule.h" #include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/casting.h" namespace blink {
diff --git a/third_party/blink/renderer/core/css/local_font_face_source.h b/third_party/blink/renderer/core/css/local_font_face_source.h index fb948d9..f25dbb9 100644 --- a/third_party/blink/renderer/core/css/local_font_face_source.h +++ b/third_party/blink/renderer/core/css/local_font_face_source.h
@@ -7,6 +7,7 @@ #include "base/memory/weak_ptr.h" #include "third_party/blink/renderer/core/css/css_font_face_source.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
diff --git a/third_party/blink/renderer/core/css/media_list.h b/third_party/blink/renderer/core/css/media_list.h index 027f221..94ac5fa 100644 --- a/third_party/blink/renderer/core/css/media_list.h +++ b/third_party/blink/renderer/core/css/media_list.h
@@ -27,6 +27,7 @@ #include "third_party/blink/renderer/core/layout/geometry/axis.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/forward.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/vector.h"
diff --git a/third_party/blink/renderer/core/css/media_query_evaluator.h b/third_party/blink/renderer/core/css/media_query_evaluator.h index b5ecdd2..3b0703a3 100644 --- a/third_party/blink/renderer/core/css/media_query_evaluator.h +++ b/third_party/blink/renderer/core/css/media_query_evaluator.h
@@ -30,6 +30,7 @@ #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" namespace blink {
diff --git a/third_party/blink/renderer/core/dom/beforeunload_event_listener.h b/third_party/blink/renderer/core/dom/beforeunload_event_listener.h index 7f09e33..60a0bb4 100644 --- a/third_party/blink/renderer/core/dom/beforeunload_event_listener.h +++ b/third_party/blink/renderer/core/dom/beforeunload_event_listener.h
@@ -7,6 +7,7 @@ #include "third_party/blink/renderer/core/dom/events/native_event_listener.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/heap/visitor.h" namespace blink {
diff --git a/third_party/blink/renderer/core/dom/dom_token_list.h b/third_party/blink/renderer/core/dom/dom_token_list.h index 3a43d14..b39e376 100644 --- a/third_party/blink/renderer/core/dom/dom_token_list.h +++ b/third_party/blink/renderer/core/dom/dom_token_list.h
@@ -30,6 +30,7 @@ #include "third_party/blink/renderer/core/dom/space_split_string.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/text/atomic_string.h" #include "third_party/blink/renderer/platform/wtf/vector.h"
diff --git a/third_party/blink/renderer/core/dom/element_data.h b/third_party/blink/renderer/core/dom/element_data.h index 600cbbf..b8b48259 100644 --- a/third_party/blink/renderer/core/dom/element_data.h +++ b/third_party/blink/renderer/core/dom/element_data.h
@@ -36,7 +36,8 @@ #include "third_party/blink/renderer/core/dom/attribute.h" #include "third_party/blink/renderer/core/dom/attribute_collection.h" #include "third_party/blink/renderer/core/dom/space_split_string.h" -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/bit_field.h" #include "third_party/blink/renderer/platform/wtf/casting.h" #include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
diff --git a/third_party/blink/renderer/core/dom/events/registered_event_listener.h b/third_party/blink/renderer/core/dom/events/registered_event_listener.h index 9654dc59..73a21a8 100644 --- a/third_party/blink/renderer/core/dom/events/registered_event_listener.h +++ b/third_party/blink/renderer/core/dom/events/registered_event_listener.h
@@ -27,6 +27,7 @@ #include "base/memory/scoped_refptr.h" #include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/member.h" namespace blink {
diff --git a/third_party/blink/renderer/core/dom/events/window_event_context.h b/third_party/blink/renderer/core/dom/events/window_event_context.h index 8b67d01..63cb4d1 100644 --- a/third_party/blink/renderer/core/dom/events/window_event_context.h +++ b/third_party/blink/renderer/core/dom/events/window_event_context.h
@@ -27,7 +27,8 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_DOM_EVENTS_WINDOW_EVENT_CONTEXT_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_DOM_EVENTS_WINDOW_EVENT_CONTEXT_H_ -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" namespace blink {
diff --git a/third_party/blink/renderer/core/dom/id_target_observer.h b/third_party/blink/renderer/core/dom/id_target_observer.h index 1ca91df..048c08a 100644 --- a/third_party/blink/renderer/core/dom/id_target_observer.h +++ b/third_party/blink/renderer/core/dom/id_target_observer.h
@@ -26,7 +26,8 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_DOM_ID_TARGET_OBSERVER_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_DOM_ID_TARGET_OBSERVER_H_ -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/text/atomic_string.h" namespace blink {
diff --git a/third_party/blink/renderer/core/dom/node_iterator_base.h b/third_party/blink/renderer/core/dom/node_iterator_base.h index ab40744..b0c3b51 100644 --- a/third_party/blink/renderer/core/dom/node_iterator_base.h +++ b/third_party/blink/renderer/core/dom/node_iterator_base.h
@@ -25,7 +25,8 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_DOM_NODE_ITERATOR_BASE_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_DOM_NODE_ITERATOR_BASE_H_ -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" namespace blink {
diff --git a/third_party/blink/renderer/core/dom/synchronous_mutation_observer.h b/third_party/blink/renderer/core/dom/synchronous_mutation_observer.h index 65ff054..6b042d67 100644 --- a/third_party/blink/renderer/core/dom/synchronous_mutation_observer.h +++ b/third_party/blink/renderer/core/dom/synchronous_mutation_observer.h
@@ -6,7 +6,8 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_DOM_SYNCHRONOUS_MUTATION_OBSERVER_H_ #include "third_party/blink/renderer/core/core_export.h" -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" namespace blink {
diff --git a/third_party/blink/renderer/core/dom/tree_walker.h b/third_party/blink/renderer/core/dom/tree_walker.h index 4b8febf..8c66e98 100644 --- a/third_party/blink/renderer/core/dom/tree_walker.h +++ b/third_party/blink/renderer/core/dom/tree_walker.h
@@ -28,6 +28,7 @@ #include "third_party/blink/renderer/core/dom/node_iterator_base.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/member.h" namespace blink {
diff --git a/third_party/blink/renderer/core/editing/caret_display_item_client.h b/third_party/blink/renderer/core/editing/caret_display_item_client.h index f29b1ef..e97e7c4 100644 --- a/third_party/blink/renderer/core/editing/caret_display_item_client.h +++ b/third_party/blink/renderer/core/editing/caret_display_item_client.h
@@ -33,7 +33,8 @@ #include "third_party/blink/renderer/platform/graphics/color.h" #include "third_party/blink/renderer/platform/graphics/paint/display_item.h" #include "third_party/blink/renderer/platform/graphics/paint/display_item_client.h" -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" namespace blink {
diff --git a/third_party/blink/renderer/core/editing/layout_selection.h b/third_party/blink/renderer/core/editing/layout_selection.h index 9be3917..15ee785 100644 --- a/third_party/blink/renderer/core/editing/layout_selection.h +++ b/third_party/blink/renderer/core/editing/layout_selection.h
@@ -24,7 +24,8 @@ #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/editing/forward.h" -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" namespace blink {
diff --git a/third_party/blink/renderer/core/editing/reveal_selection_scope.h b/third_party/blink/renderer/core/editing/reveal_selection_scope.h index cc8f9bc..ac71a448 100644 --- a/third_party/blink/renderer/core/editing/reveal_selection_scope.h +++ b/third_party/blink/renderer/core/editing/reveal_selection_scope.h
@@ -30,7 +30,8 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_REVEAL_SELECTION_SCOPE_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_REVEAL_SELECTION_SCOPE_H_ -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" namespace blink {
diff --git a/third_party/blink/renderer/core/events/touch_event_context.h b/third_party/blink/renderer/core/events/touch_event_context.h index 6228438..d1ea495 100644 --- a/third_party/blink/renderer/core/events/touch_event_context.h +++ b/third_party/blink/renderer/core/events/touch_event_context.h
@@ -27,7 +27,8 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_EVENTS_TOUCH_EVENT_CONTEXT_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_EVENTS_TOUCH_EVENT_CONTEXT_H_ -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" namespace blink {
diff --git a/third_party/blink/renderer/core/execution_context/security_context.h b/third_party/blink/renderer/core/execution_context/security_context.h index a8a01e1..385ec0fb 100644 --- a/third_party/blink/renderer/core/execution_context/security_context.h +++ b/third_party/blink/renderer/core/execution_context/security_context.h
@@ -37,7 +37,8 @@ #include "third_party/blink/public/mojom/security_context/insecure_request_policy.mojom-blink-forward.h" #include "third_party/blink/public/platform/web_vector.h" #include "third_party/blink/renderer/core/core_export.h" -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/forward.h" #include "third_party/blink/renderer/platform/wtf/hash_set.h" #include "third_party/blink/renderer/platform/wtf/text/string_hash.h"
diff --git a/third_party/blink/renderer/core/fetch/blob_bytes_consumer.h b/third_party/blink/renderer/core/fetch/blob_bytes_consumer.h index 8c185cd5..87b88df9 100644 --- a/third_party/blink/renderer/core/fetch/blob_bytes_consumer.h +++ b/third_party/blink/renderer/core/fetch/blob_bytes_consumer.h
@@ -8,7 +8,8 @@ #include "base/memory/scoped_refptr.h" #include "third_party/blink/public/mojom/blob/blob.mojom-blink-forward.h" #include "third_party/blink/renderer/core/core_export.h" -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/loader/fetch/bytes_consumer.h" namespace blink {
diff --git a/third_party/blink/renderer/core/fetch/bytes_uploader.h b/third_party/blink/renderer/core/fetch/bytes_uploader.h index 610f583..fdc2048 100644 --- a/third_party/blink/renderer/core/fetch/bytes_uploader.h +++ b/third_party/blink/renderer/core/fetch/bytes_uploader.h
@@ -11,7 +11,8 @@ #include "mojo/public/cpp/system/simple_watcher.h" #include "services/network/public/mojom/chunked_data_pipe_getter.mojom-blink.h" #include "third_party/blink/renderer/core/core_export.h" -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/heap/prefinalizer.h" #include "third_party/blink/renderer/platform/loader/fetch/bytes_consumer.h"
diff --git a/third_party/blink/renderer/core/fetch/form_data_bytes_consumer.h b/third_party/blink/renderer/core/fetch/form_data_bytes_consumer.h index 4a68764..df667f6 100644 --- a/third_party/blink/renderer/core/fetch/form_data_bytes_consumer.h +++ b/third_party/blink/renderer/core/fetch/form_data_bytes_consumer.h
@@ -7,7 +7,7 @@ #include "base/memory/scoped_refptr.h" #include "third_party/blink/renderer/core/core_export.h" -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/heap/visitor.h" #include "third_party/blink/renderer/platform/loader/fetch/bytes_consumer.h" #include "third_party/blink/renderer/platform/wtf/forward.h"
diff --git a/third_party/blink/renderer/core/fetch/multipart_parser.h b/third_party/blink/renderer/core/fetch/multipart_parser.h index 76d4e57..66592ea 100644 --- a/third_party/blink/renderer/core/fetch/multipart_parser.h +++ b/third_party/blink/renderer/core/fetch/multipart_parser.h
@@ -6,7 +6,8 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_FETCH_MULTIPART_PARSER_H_ #include "third_party/blink/renderer/core/core_export.h" -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/network/http_header_map.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/vector.h"
diff --git a/third_party/blink/renderer/core/fetch/place_holder_bytes_consumer.h b/third_party/blink/renderer/core/fetch/place_holder_bytes_consumer.h index c2c4ec0..a16cdc5 100644 --- a/third_party/blink/renderer/core/fetch/place_holder_bytes_consumer.h +++ b/third_party/blink/renderer/core/fetch/place_holder_bytes_consumer.h
@@ -6,6 +6,7 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_FETCH_PLACE_HOLDER_BYTES_CONSUMER_H_ #include "third_party/blink/renderer/core/core_export.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/loader/fetch/bytes_consumer.h" namespace blink {
diff --git a/third_party/blink/renderer/core/frame/browser_controls.h b/third_party/blink/renderer/core/frame/browser_controls.h index 9d4fcce..e0018d9 100644 --- a/third_party/blink/renderer/core/frame/browser_controls.h +++ b/third_party/blink/renderer/core/frame/browser_controls.h
@@ -9,7 +9,8 @@ #include "cc/trees/browser_controls_params.h" #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/scroll/scroll_types.h" -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" namespace blink { class Page;
diff --git a/third_party/blink/renderer/core/frame/dom_window.cc b/third_party/blink/renderer/core/frame/dom_window.cc index ed7f05c..e39d2fda 100644 --- a/third_party/blink/renderer/core/frame/dom_window.cc +++ b/third_party/blink/renderer/core/frame/dom_window.cc
@@ -433,32 +433,26 @@ void DOMWindow::InstallCoopAccessMonitor( LocalFrame* accessing_frame, - bool register_metrics, network::mojom::blink::CrossOriginOpenerPolicyReporterParamsPtr coop_reporter_params) { - DCHECK(register_metrics || coop_reporter_params); CoopAccessMonitor monitor; - monitor.register_metrics = register_metrics; - monitor.send_reports = !!coop_reporter_params; - monitor.accessing_main_frame = accessing_frame->GetLocalFrameToken(); DCHECK(accessing_frame->IsMainFrame()); - if (coop_reporter_params) { - monitor.report_type = coop_reporter_params->report_type; - monitor.endpoint_defined = coop_reporter_params->endpoint_defined; - monitor.reported_window_url = - std::move(coop_reporter_params->reported_window_url); + monitor.report_type = coop_reporter_params->report_type; + monitor.accessing_main_frame = accessing_frame->GetLocalFrameToken(); + monitor.endpoint_defined = coop_reporter_params->endpoint_defined; + monitor.reported_window_url = + std::move(coop_reporter_params->reported_window_url); - monitor.reporter.Bind(std::move(coop_reporter_params->reporter)); - // CoopAccessMonitor are cleared when their reporter are gone. This avoids - // accumulation. However it would have been interesting continuing reporting - // accesses past this point, at least for the ReportingObserver and Devtool. - // TODO(arthursonzogni): Consider observing |accessing_main_frame| deletion - // instead. - monitor.reporter.set_disconnect_handler( - WTF::Bind(&DOMWindow::DisconnectCoopAccessMonitor, - WrapWeakPersistent(this), monitor.accessing_main_frame)); - } + monitor.reporter.Bind(std::move(coop_reporter_params->reporter)); + // CoopAccessMonitor are cleared when their reporter are gone. This avoids + // accumulation. However it would have been interesting continuing reporting + // accesses past this point, at least for the ReportingObserver and Devtool. + // TODO(arthursonzogni): Consider observing |accessing_main_frame| deletion + // instead. + monitor.reporter.set_disconnect_handler( + WTF::Bind(&DOMWindow::DisconnectCoopAccessMonitor, + WrapWeakPersistent(this), monitor.accessing_main_frame)); // As long as RenderDocument isn't shipped, it can exist a CoopAccessMonitor // for the same |accessing_main_frame|, because it might now host a different @@ -500,9 +494,6 @@ // Iframes are allowed to trigger reports, only when they are same-origin with // their top-level document. - // TODO(https://crbug.com/1238824): When used for recording metrics, accesses - // from cross-origin iframes should also be reported. This requires moving - // this and sending the corresponding remote frame tokens. if (accessing_frame->IsCrossOriginToMainFrame()) return; @@ -530,45 +521,37 @@ continue; } - if (it->register_metrics) { - UseCounter::Count(accessing_window, - WebFeature::kCrossPageAccessBrokenByCOOPSOAPByDefault); - } + // TODO(arthursonzogni): Send the blocked-window-url. - if (it->send_reports) { - // TODO(arthursonzogni): Send the blocked-window-url. + auto location = SourceLocation::Capture( + ExecutionContext::From(isolate->GetCurrentContext())); + // TODO(arthursonzogni): Once implemented, use the SourceLocation typemap + // https://chromium-review.googlesource.com/c/chromium/src/+/2041657 + auto source_location = network::mojom::blink::SourceLocation::New( + location->Url() ? location->Url() : "", location->LineNumber(), + location->ColumnNumber()); - auto location = SourceLocation::Capture( - ExecutionContext::From(isolate->GetCurrentContext())); - // TODO(arthursonzogni): Once implemented, use the SourceLocation typemap - // https://chromium-review.googlesource.com/c/chromium/src/+/2041657 - auto source_location = network::mojom::blink::SourceLocation::New( - location->Url() ? location->Url() : "", location->LineNumber(), - location->ColumnNumber()); + // TODO(https://crbug.com/1124251): Notify Devtool about the access attempt. - // TODO(https://crbug.com/1124251): Notify Devtool about the access - // attempt. - - // If the reporting document hasn't specified any network report - // endpoint(s), then it is likely not interested in receiving - // ReportingObserver's reports. - // - // TODO(arthursonzogni): Reconsider this decision later, developers might - // be interested. - if (it->endpoint_defined) { - it->reporter->QueueAccessReport(it->report_type, property_name, - std::move(source_location), - std::move(it->reported_window_url)); - // Send a coop-access-violation report. - if (network::IsAccessFromCoopPage(it->report_type)) { - ReportingContext::From(accessing_main_frame.DomWindow()) - ->QueueReport(MakeGarbageCollected<Report>( - ReportType::kCoopAccessViolation, - accessing_main_frame.GetDocument()->Url().GetString(), - MakeGarbageCollected<CoopAccessViolationReportBody>( - std::move(location), it->report_type, - String(property_name), it->reported_window_url))); - } + // If the reporting document hasn't specified any network report + // endpoint(s), then it is likely not interested in receiving + // ReportingObserver's reports. + // + // TODO(arthursonzogni): Reconsider this decision later, developers might be + // interested. + if (it->endpoint_defined) { + it->reporter->QueueAccessReport(it->report_type, property_name, + std::move(source_location), + std::move(it->reported_window_url)); + // Send a coop-access-violation report. + if (network::IsAccessFromCoopPage(it->report_type)) { + ReportingContext::From(accessing_main_frame.DomWindow()) + ->QueueReport(MakeGarbageCollected<Report>( + ReportType::kCoopAccessViolation, + accessing_main_frame.GetDocument()->Url().GetString(), + MakeGarbageCollected<CoopAccessViolationReportBody>( + std::move(location), it->report_type, String(property_name), + it->reported_window_url))); } } @@ -752,15 +735,11 @@ const LocalFrameToken& accessing_main_frame) { auto* it = coop_access_monitor_.begin(); while (it != coop_access_monitor_.end()) { - if (it->accessing_main_frame != accessing_main_frame) { - ++it; - continue; - } - it->send_reports = false; - if (it->register_metrics) - ++it; - else + if (it->accessing_main_frame == accessing_main_frame) { it = coop_access_monitor_.erase(it); + } else { + ++it; + } } }
diff --git a/third_party/blink/renderer/core/frame/dom_window.h b/third_party/blink/renderer/core/frame/dom_window.h index 783c42b7..cc318de 100644 --- a/third_party/blink/renderer/core/frame/dom_window.h +++ b/third_party/blink/renderer/core/frame/dom_window.h
@@ -137,13 +137,10 @@ ExceptionState&); // Cross-Origin-Opener-Policy (COOP): - // Check accesses from |accessing_frame| and every iframe toward this window. - // If |register_metrics| is true, metrics will be registered upon access. If - // a |coop_reporter_info| is provided, a report will be sent upon access from - // |accessing_frame| or its cross-origin iframes. + // Check accesses from |accessing_frame| and every same-origin iframe toward + // this window. A report is sent to |reporter| when this happens. void InstallCoopAccessMonitor( LocalFrame* accessing_frame, - bool register_metrics, network::mojom::blink::CrossOriginOpenerPolicyReporterParamsPtr coop_reporter_params); // Whenever we detect that the enforcement of a report-only COOP policy would @@ -204,8 +201,6 @@ // Check accesses made toward this window from |accessing_main_frame|. If this // happens a report will sent to |reporter|. struct CoopAccessMonitor { - bool register_metrics; - bool send_reports; network::mojom::blink::CoopAccessReportType report_type; blink::LocalFrameToken accessing_main_frame; mojo::Remote<network::mojom::blink::CrossOriginOpenerPolicyReporter>
diff --git a/third_party/blink/renderer/core/frame/frame_console.h b/third_party/blink/renderer/core/frame/frame_console.h index 21357417..27901c84 100644 --- a/third_party/blink/renderer/core/frame/frame_console.h +++ b/third_party/blink/renderer/core/frame/frame_console.h
@@ -31,7 +31,8 @@ #include "third_party/blink/public/mojom/devtools/console_message.mojom-blink-forward.h" #include "third_party/blink/renderer/core/core_export.h" -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/forward.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
diff --git a/third_party/blink/renderer/core/frame/frame_view_auto_size_info.h b/third_party/blink/renderer/core/frame/frame_view_auto_size_info.h index 4ea8e46..8475f6c7 100644 --- a/third_party/blink/renderer/core/frame/frame_view_auto_size_info.h +++ b/third_party/blink/renderer/core/frame/frame_view_auto_size_info.h
@@ -7,7 +7,8 @@ #include "base/memory/scoped_refptr.h" #include "third_party/blink/renderer/platform/geometry/int_size.h" -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" namespace blink {
diff --git a/third_party/blink/renderer/core/frame/local_frame_mojo_handler.cc b/third_party/blink/renderer/core/frame/local_frame_mojo_handler.cc index da64728..9c780940 100644 --- a/third_party/blink/renderer/core/frame/local_frame_mojo_handler.cc +++ b/third_party/blink/renderer/core/frame/local_frame_mojo_handler.cc
@@ -1179,7 +1179,6 @@ void LocalFrameMojoHandler::InstallCoopAccessMonitor( const FrameToken& accessed_window, - bool register_metrics, network::mojom::blink::CrossOriginOpenerPolicyReporterParamsPtr coop_reporter_params) { blink::Frame* accessed_frame = Frame::ResolveFrame(accessed_window); @@ -1188,7 +1187,7 @@ return; accessed_frame->DomWindow()->InstallCoopAccessMonitor( - frame_, register_metrics, std::move(coop_reporter_params)); + frame_, std::move(coop_reporter_params)); } void LocalFrameMojoHandler::OnPortalActivated(
diff --git a/third_party/blink/renderer/core/frame/local_frame_mojo_handler.h b/third_party/blink/renderer/core/frame/local_frame_mojo_handler.h index 032434e..b92f80e 100644 --- a/third_party/blink/renderer/core/frame/local_frame_mojo_handler.h +++ b/third_party/blink/renderer/core/frame/local_frame_mojo_handler.h
@@ -205,7 +205,6 @@ void ZoomToFindInPageRect(const gfx::Rect& rect_in_root_frame) override; void InstallCoopAccessMonitor( const FrameToken& accessed_window, - bool register_metrics, network::mojom::blink::CrossOriginOpenerPolicyReporterParamsPtr coop_reporter_params) final; void OnPortalActivated(
diff --git a/third_party/blink/renderer/core/frame/local_frame_view.cc b/third_party/blink/renderer/core/frame/local_frame_view.cc index 526c87e..6bf92321 100644 --- a/third_party/blink/renderer/core/frame/local_frame_view.cc +++ b/third_party/blink/renderer/core/frame/local_frame_view.cc
@@ -316,6 +316,7 @@ visitor->Trace(fragment_anchor_); visitor->Trace(scrollable_areas_); visitor->Trace(animating_scrollable_areas_); + visitor->Trace(user_scrollable_areas_); visitor->Trace(viewport_constrained_objects_); visitor->Trace(background_attachment_fixed_objects_); visitor->Trace(auto_size_info_); @@ -3191,12 +3192,11 @@ } } - WTF::Vector<const TransformPaintPropertyNode*> scroll_translation_nodes; + Vector<const TransformPaintPropertyNode*> scroll_translation_nodes; if (RuntimeEnabledFeatures::ScrollUnificationEnabled()) { ForAllNonThrottledLocalFrameViews( [&scroll_translation_nodes](LocalFrameView& frame_view) { - scroll_translation_nodes.AppendVector( - frame_view.GetScrollTranslationNodes()); + frame_view.GetUserScrollTranslationNodes(scroll_translation_nodes); }); } @@ -3793,6 +3793,8 @@ if (!scrollable_areas_) return; scrollable_areas_->erase(scrollable_area); + if (user_scrollable_areas_) + user_scrollable_areas_->erase(scrollable_area); } void LocalFrameView::AddAnimatingScrollableArea( @@ -3810,6 +3812,21 @@ animating_scrollable_areas_->erase(scrollable_area); } +void LocalFrameView::AddUserScrollableArea( + PaintLayerScrollableArea* scrollable_area) { + DCHECK(scrollable_area); + if (!user_scrollable_areas_) + user_scrollable_areas_ = MakeGarbageCollected<ScrollableAreaSet>(); + user_scrollable_areas_->insert(scrollable_area); +} + +void LocalFrameView::RemoveUserScrollableArea( + PaintLayerScrollableArea* scrollable_area) { + if (!user_scrollable_areas_) + return; + user_scrollable_areas_->erase(scrollable_area); +} + void LocalFrameView::AttachToLayout() { CHECK(!IsAttached()); if (frame_->GetDocument()) @@ -4958,17 +4975,19 @@ return *overlay_interstitial_ad_detector_.get(); } -WTF::Vector<const TransformPaintPropertyNode*> -LocalFrameView::GetScrollTranslationNodes() { - WTF::Vector<const TransformPaintPropertyNode*> scroll_translation_nodes; - for (auto area : *ScrollableAreas()) { +void LocalFrameView::GetUserScrollTranslationNodes( + Vector<const TransformPaintPropertyNode*>& scroll_translation_nodes) { + const auto* scrollable_areas = UserScrollableAreas(); + if (!scrollable_areas) + return; + + for (const auto& area : *scrollable_areas) { const auto* paint_properties = area->GetLayoutBox()->FirstFragment().PaintProperties(); if (paint_properties && paint_properties->Scroll()) { scroll_translation_nodes.push_back(paint_properties->ScrollTranslation()); } } - return scroll_translation_nodes; } StickyAdDetector& LocalFrameView::EnsureStickyAdDetector() {
diff --git a/third_party/blink/renderer/core/frame/local_frame_view.h b/third_party/blink/renderer/core/frame/local_frame_view.h index feecd14..df3ab02 100644 --- a/third_party/blink/renderer/core/frame/local_frame_view.h +++ b/third_party/blink/renderer/core/frame/local_frame_view.h
@@ -469,6 +469,12 @@ return animating_scrollable_areas_.Get(); } + void AddUserScrollableArea(PaintLayerScrollableArea*); + void RemoveUserScrollableArea(PaintLayerScrollableArea*); + const ScrollableAreaSet* UserScrollableAreas() const { + return user_scrollable_areas_.Get(); + } + void ServiceScriptedAnimations(base::TimeTicks); void ScheduleAnimation(base::TimeDelta = base::TimeDelta()); @@ -992,7 +998,8 @@ // necessary. OverlayInterstitialAdDetector& EnsureOverlayInterstitialAdDetector(); - WTF::Vector<const TransformPaintPropertyNode*> GetScrollTranslationNodes(); + void GetUserScrollTranslationNodes( + Vector<const TransformPaintPropertyNode*>& scroll_translation_nodes); // Return the sticky-ad detector for this frame, creating it if necessary. StickyAdDetector& EnsureStickyAdDetector(); @@ -1052,6 +1059,7 @@ Member<ScrollableAreaSet> scrollable_areas_; Member<ScrollableAreaSet> animating_scrollable_areas_; + Member<ScrollableAreaSet> user_scrollable_areas_; Member<ObjectSet> viewport_constrained_objects_; // Number of entries in viewport_constrained_objects_ that are sticky. unsigned sticky_position_object_count_;
diff --git a/third_party/blink/renderer/core/frame/page_scale_constraints_set.h b/third_party/blink/renderer/core/frame/page_scale_constraints_set.h index f6ffae33..5322d35 100644 --- a/third_party/blink/renderer/core/frame/page_scale_constraints_set.h +++ b/third_party/blink/renderer/core/frame/page_scale_constraints_set.h
@@ -37,7 +37,8 @@ #include "third_party/blink/renderer/core/page/viewport_description.h" #include "third_party/blink/renderer/platform/geometry/int_size.h" #include "third_party/blink/renderer/platform/geometry/length.h" -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" namespace blink {
diff --git a/third_party/blink/renderer/core/frame/remote_frame_owner.h b/third_party/blink/renderer/core/frame/remote_frame_owner.h index 57898ff..9731ff849 100644 --- a/third_party/blink/renderer/core/frame/remote_frame_owner.h +++ b/third_party/blink/renderer/core/frame/remote_frame_owner.h
@@ -12,6 +12,8 @@ #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/frame/frame_owner.h" #include "third_party/blink/renderer/core/scroll/scroll_types.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/casting.h" namespace blink {
diff --git a/third_party/blink/renderer/core/frame/remote_frame_view.h b/third_party/blink/renderer/core/frame/remote_frame_view.h index bcd0eeab..dff1289a 100644 --- a/third_party/blink/renderer/core/frame/remote_frame_view.h +++ b/third_party/blink/renderer/core/frame/remote_frame_view.h
@@ -12,7 +12,8 @@ #include "third_party/blink/renderer/core/frame/frame_view.h" #include "third_party/blink/renderer/core/layout/intrinsic_sizing_info.h" #include "third_party/blink/renderer/platform/geometry/int_rect.h" -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" namespace cc { class PaintCanvas;
diff --git a/third_party/blink/renderer/core/frame/viewport_data.h b/third_party/blink/renderer/core/frame/viewport_data.h index 9760850..a7771db 100644 --- a/third_party/blink/renderer/core/frame/viewport_data.h +++ b/third_party/blink/renderer/core/frame/viewport_data.h
@@ -9,7 +9,8 @@ #include "third_party/blink/public/mojom/page/display_cutout.mojom-blink-forward.h" #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/page/viewport_description.h" -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" namespace blink {
diff --git a/third_party/blink/renderer/core/html/fenced_frame/fenced_frame_shadow_dom_delegate_test.cc b/third_party/blink/renderer/core/html/fenced_frame/fenced_frame_shadow_dom_delegate_test.cc index 60eec1a..5ae9c40 100644 --- a/third_party/blink/renderer/core/html/fenced_frame/fenced_frame_shadow_dom_delegate_test.cc +++ b/third_party/blink/renderer/core/html/fenced_frame/fenced_frame_shadow_dom_delegate_test.cc
@@ -106,6 +106,19 @@ AssertInternalIFrameExists(fenced_frame); } +TEST_F(FencedFrameShadowDOMDelegateTest, PresentationAttributes) { + SetBodyInnerHTML(R"HTML( + <fencedframe width="123" height="456"></fencedframe> +)HTML"); + HTMLFencedFrameElement& fenced_frame = FencedFrame(); + const auto* box = fenced_frame.GetLayoutBox(); + ASSERT_TRUE(box); + EXPECT_EQ(box->StyleRef().Width(), Length::Fixed(123)); + EXPECT_EQ(box->StyleRef().Height(), Length::Fixed(456)); + EXPECT_EQ(box->OffsetWidth(), LayoutUnit(123)); + EXPECT_EQ(box->OffsetHeight(), LayoutUnit(456)); +} + // This test tests navigations with respect to the DOM-connectedness of the // element. TEST_F(FencedFrameShadowDOMDelegateTest, NavigationWithInsertionAndRemoval) {
diff --git a/third_party/blink/renderer/core/html/fenced_frame/html_fenced_frame_element.cc b/third_party/blink/renderer/core/html/fenced_frame/html_fenced_frame_element.cc index 2bd2f841..d4be6f6 100644 --- a/third_party/blink/renderer/core/html/fenced_frame/html_fenced_frame_element.cc +++ b/third_party/blink/renderer/core/html/fenced_frame/html_fenced_frame_element.cc
@@ -118,6 +118,27 @@ return attribute.GetName() == html_names::kSrcAttr; } +bool HTMLFencedFrameElement::IsPresentationAttribute( + const QualifiedName& name) const { + if (name == html_names::kWidthAttr || name == html_names::kHeightAttr) + return true; + return HTMLFrameOwnerElement::IsPresentationAttribute(name); +} + +void HTMLFencedFrameElement::CollectStyleForPresentationAttribute( + const QualifiedName& name, + const AtomicString& value, + MutableCSSPropertyValueSet* style) { + if (name == html_names::kWidthAttr) { + AddHTMLLengthToStyle(style, CSSPropertyID::kWidth, value); + } else if (name == html_names::kHeightAttr) { + AddHTMLLengthToStyle(style, CSSPropertyID::kHeight, value); + } else { + HTMLFrameOwnerElement::CollectStyleForPresentationAttribute(name, value, + style); + } +} + void HTMLFencedFrameElement::Navigate() { if (!isConnected()) return;
diff --git a/third_party/blink/renderer/core/html/fenced_frame/html_fenced_frame_element.h b/third_party/blink/renderer/core/html/fenced_frame/html_fenced_frame_element.h index c2eea9c..77e64865e 100644 --- a/third_party/blink/renderer/core/html/fenced_frame/html_fenced_frame_element.h +++ b/third_party/blink/renderer/core/html/fenced_frame/html_fenced_frame_element.h
@@ -108,6 +108,11 @@ // Element overrides. void ParseAttribute(const AttributeModificationParams&) override; bool IsURLAttribute(const Attribute&) const override; + bool IsPresentationAttribute(const QualifiedName&) const override; + void CollectStyleForPresentationAttribute( + const QualifiedName&, + const AtomicString&, + MutableCSSPropertyValueSet*) override; LayoutObject* CreateLayoutObject(const ComputedStyle&, LegacyLayout) override; void AttachLayoutTree(AttachContext& context) override; bool SupportsFocus() const override;
diff --git a/third_party/blink/renderer/core/html/fenced_frame/html_fenced_frame_element.idl b/third_party/blink/renderer/core/html/fenced_frame/html_fenced_frame_element.idl index 9a59158..333f00e 100644 --- a/third_party/blink/renderer/core/html/fenced_frame/html_fenced_frame_element.idl +++ b/third_party/blink/renderer/core/html/fenced_frame/html_fenced_frame_element.idl
@@ -7,6 +7,8 @@ [Exposed=Window, HTMLConstructor, RuntimeEnabled=FencedFrames] interface HTMLFencedFrameElement : HTMLElement { [CEReactions, Reflect, URL] attribute USVString src; + [CEReactions, Reflect] attribute DOMString width; + [CEReactions, Reflect] attribute DOMString height; // TODO(domfarolino): Resolve the discussion around what attributes we'd // like this element to support. };
diff --git a/third_party/blink/renderer/core/paint/paint_property_tree_builder.cc b/third_party/blink/renderer/core/paint/paint_property_tree_builder.cc index 6bb9bbb..d5a755a 100644 --- a/third_party/blink/renderer/core/paint/paint_property_tree_builder.cc +++ b/third_party/blink/renderer/core/paint/paint_property_tree_builder.cc
@@ -2152,6 +2152,11 @@ state.user_scrollable_vertical = scrollable_area->UserInputScrollable(kVerticalScrollbar); + if (state.user_scrollable_horizontal || state.user_scrollable_vertical) + object_.GetFrameView()->AddUserScrollableArea(scrollable_area); + else + object_.GetFrameView()->RemoveUserScrollableArea(scrollable_area); + // TODO(bokan): We probably don't need to pass ancestor reasons down the // scroll tree. On the compositor, in // LayerTreeHostImpl::FindScrollNodeForDeviceViewportPoint, we walk up
diff --git a/third_party/blink/renderer/core/typed_arrays/array_buffer_view_helpers.h b/third_party/blink/renderer/core/typed_arrays/array_buffer_view_helpers.h index 7f0c534..87dc4f2 100644 --- a/third_party/blink/renderer/core/typed_arrays/array_buffer_view_helpers.h +++ b/third_party/blink/renderer/core/typed_arrays/array_buffer_view_helpers.h
@@ -9,6 +9,7 @@ #include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer_view.h" #include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/type_traits.h" namespace blink {
diff --git a/third_party/blink/renderer/core/typed_arrays/dom_array_buffer_view.h b/third_party/blink/renderer/core/typed_arrays/dom_array_buffer_view.h index eaaef1d..8b52076 100644 --- a/third_party/blink/renderer/core/typed_arrays/dom_array_buffer_view.h +++ b/third_party/blink/renderer/core/typed_arrays/dom_array_buffer_view.h
@@ -9,6 +9,7 @@ #include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h" #include "third_party/blink/renderer/core/typed_arrays/dom_shared_array_buffer.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h" +#include "third_party/blink/renderer/platform/heap/member.h" namespace blink {
diff --git a/third_party/blink/renderer/modules/BUILD.gn b/third_party/blink/renderer/modules/BUILD.gn index 36b967df..911440a 100644 --- a/third_party/blink/renderer/modules/BUILD.gn +++ b/third_party/blink/renderer/modules/BUILD.gn
@@ -459,11 +459,11 @@ "manifest/image_resource_type_converters_test.cc", "manifest/manifest_manager_unittest.cc", "manifest/manifest_parser_unittest.cc", + "media/audio/audio_output_ipc_factory_test.cc", "media/audio/audio_renderer_mixer_manager_test.cc", "media/audio/audio_renderer_sink_cache_test.cc", "media/audio/mojo_audio_input_ipc_test.cc", "media/audio/mojo_audio_output_ipc_test.cc", - "media/audio/web_audio_output_ipc_factory_test.cc", "media/webmediaplayer_util_unittest.cc", "media_capabilities/media_capabilities_test.cc", "media_controls/elements/media_control_animated_arrow_container_element_test.cc",
diff --git a/third_party/blink/renderer/modules/media/BUILD.gn b/third_party/blink/renderer/modules/media/BUILD.gn index 555460a..3ed65b6 100644 --- a/third_party/blink/renderer/modules/media/BUILD.gn +++ b/third_party/blink/renderer/modules/media/BUILD.gn
@@ -7,6 +7,8 @@ blink_modules_sources("media") { sources = [ "audio/audio_device_factory.cc", + "audio/audio_input_ipc_factory.cc", + "audio/audio_output_ipc_factory.cc", "audio/audio_renderer_mixer_manager.cc", "audio/audio_renderer_mixer_manager.h", "audio/audio_renderer_sink_cache.cc", @@ -15,8 +17,6 @@ "audio/mojo_audio_input_ipc.h", "audio/mojo_audio_output_ipc.cc", "audio/mojo_audio_output_ipc.h", - "audio/web_audio_input_ipc_factory.cc", - "audio/web_audio_output_ipc_factory.cc", "webmediaplayer_util.cc", ]
diff --git a/third_party/blink/renderer/modules/media/audio/audio_device_factory.cc b/third_party/blink/renderer/modules/media/audio/audio_device_factory.cc index 7f568554..865af2f 100644 --- a/third_party/blink/renderer/modules/media/audio/audio_device_factory.cc +++ b/third_party/blink/renderer/modules/media/audio/audio_device_factory.cc
@@ -20,8 +20,8 @@ #include "media/audio/audio_output_device.h" #include "media/base/audio_renderer_mixer_input.h" #include "third_party/blink/public/platform/platform.h" -#include "third_party/blink/public/web/modules/media/audio/web_audio_input_ipc_factory.h" -#include "third_party/blink/public/web/modules/media/audio/web_audio_output_ipc_factory.h" +#include "third_party/blink/public/web/modules/media/audio/audio_input_ipc_factory.h" +#include "third_party/blink/public/web/modules/media/audio/audio_output_ipc_factory.h" #include "third_party/blink/renderer/modules/media/audio/audio_renderer_mixer_manager.h" #include "third_party/blink/renderer/modules/media/audio/audio_renderer_sink_cache.h" #include "third_party/blink/renderer/platform/wtf/wtf.h" @@ -56,11 +56,11 @@ const blink::LocalFrameToken& frame_token, const media::AudioSinkParameters& params, base::TimeDelta auth_timeout) { - CHECK(blink::WebAudioOutputIPCFactory::GetInstance().io_task_runner()); + CHECK(blink::AudioOutputIPCFactory::GetInstance().io_task_runner()); auto device = base::MakeRefCounted<media::AudioOutputDevice>( - blink::WebAudioOutputIPCFactory::GetInstance().CreateAudioOutputIPC( + blink::AudioOutputIPCFactory::GetInstance().CreateAudioOutputIPC( frame_token), - blink::WebAudioOutputIPCFactory::GetInstance().io_task_runner(), params, + blink::AudioOutputIPCFactory::GetInstance().io_task_runner(), params, auth_timeout); device->RequestDeviceAuthorization(); return device; @@ -178,7 +178,7 @@ } return base::MakeRefCounted<media::AudioInputDevice>( - blink::WebAudioInputIPCFactory::GetInstance().CreateAudioInputIPC( + blink::AudioInputIPCFactory::GetInstance().CreateAudioInputIPC( frame_token, params), media::AudioInputDevice::Purpose::kUserInput, media::AudioInputDevice::DeadStreamDetection::kEnabled);
diff --git a/third_party/blink/renderer/modules/media/audio/web_audio_input_ipc_factory.cc b/third_party/blink/renderer/modules/media/audio/audio_input_ipc_factory.cc similarity index 90% rename from third_party/blink/renderer/modules/media/audio/web_audio_input_ipc_factory.cc rename to third_party/blink/renderer/modules/media/audio/audio_input_ipc_factory.cc index 41dc2fd..dac7bf8 100644 --- a/third_party/blink/renderer/modules/media/audio/web_audio_input_ipc_factory.cc +++ b/third_party/blink/renderer/modules/media/audio/audio_input_ipc_factory.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "third_party/blink/public/web/modules/media/audio/web_audio_input_ipc_factory.h" +#include "third_party/blink/public/web/modules/media/audio/audio_input_ipc_factory.h" #include <string> #include <utility> @@ -78,23 +78,22 @@ } } // namespace -WebAudioInputIPCFactory& WebAudioInputIPCFactory::GetInstance() { - DEFINE_THREAD_SAFE_STATIC_LOCAL(WebAudioInputIPCFactory, instance, +AudioInputIPCFactory& AudioInputIPCFactory::GetInstance() { + DEFINE_THREAD_SAFE_STATIC_LOCAL(AudioInputIPCFactory, instance, (Thread::MainThread()->GetTaskRunner(), Platform::Current()->GetIOTaskRunner())); return instance; } -WebAudioInputIPCFactory::WebAudioInputIPCFactory( +AudioInputIPCFactory::AudioInputIPCFactory( scoped_refptr<base::SequencedTaskRunner> main_task_runner, scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) : main_task_runner_(std::move(main_task_runner)), io_task_runner_(std::move(io_task_runner)) {} -WebAudioInputIPCFactory::~WebAudioInputIPCFactory() = default; +AudioInputIPCFactory::~AudioInputIPCFactory() = default; -std::unique_ptr<media::AudioInputIPC> -WebAudioInputIPCFactory::CreateAudioInputIPC( +std::unique_ptr<media::AudioInputIPC> AudioInputIPCFactory::CreateAudioInputIPC( const blink::LocalFrameToken& frame_token, const media::AudioSourceParameters& source_params) const { CHECK(!source_params.session_id.is_empty());
diff --git a/third_party/blink/renderer/modules/media/audio/web_audio_output_ipc_factory.cc b/third_party/blink/renderer/modules/media/audio/audio_output_ipc_factory.cc similarity index 80% rename from third_party/blink/renderer/modules/media/audio/web_audio_output_ipc_factory.cc rename to third_party/blink/renderer/modules/media/audio/audio_output_ipc_factory.cc index 4a770a2..4911851 100644 --- a/third_party/blink/renderer/modules/media/audio/web_audio_output_ipc_factory.cc +++ b/third_party/blink/renderer/modules/media/audio/audio_output_ipc_factory.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "third_party/blink/public/web/modules/media/audio/web_audio_output_ipc_factory.h" +#include "third_party/blink/public/web/modules/media/audio/audio_output_ipc_factory.h" #include <utility> @@ -20,7 +20,7 @@ namespace blink { -class WebAudioOutputIPCFactory::Impl { +class AudioOutputIPCFactory::Impl { public: using StreamFactoryMap = WTF::HashMap< uint64_t, @@ -51,29 +51,29 @@ }; // static -WebAudioOutputIPCFactory& WebAudioOutputIPCFactory::GetInstance() { - DEFINE_THREAD_SAFE_STATIC_LOCAL(WebAudioOutputIPCFactory, instance, +AudioOutputIPCFactory& AudioOutputIPCFactory::GetInstance() { + DEFINE_THREAD_SAFE_STATIC_LOCAL(AudioOutputIPCFactory, instance, (Platform::Current()->GetIOTaskRunner())); return instance; } -WebAudioOutputIPCFactory::WebAudioOutputIPCFactory( +AudioOutputIPCFactory::AudioOutputIPCFactory( scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) : impl_(std::make_unique<Impl>(std::move(io_task_runner))) {} -WebAudioOutputIPCFactory::~WebAudioOutputIPCFactory() = default; +AudioOutputIPCFactory::~AudioOutputIPCFactory() = default; std::unique_ptr<media::AudioOutputIPC> -WebAudioOutputIPCFactory::CreateAudioOutputIPC( +AudioOutputIPCFactory::CreateAudioOutputIPC( const blink::LocalFrameToken& frame_token) const { // Unretained is safe due to the contract at the top of the header file. return std::make_unique<MojoAudioOutputIPC>( - base::BindRepeating(&WebAudioOutputIPCFactory::Impl::GetRemoteFactory, + base::BindRepeating(&AudioOutputIPCFactory::Impl::GetRemoteFactory, base::Unretained(impl_.get()), frame_token), io_task_runner()); } -void WebAudioOutputIPCFactory::RegisterRemoteFactory( +void AudioOutputIPCFactory::RegisterRemoteFactory( const blink::LocalFrameToken& frame_token, blink::BrowserInterfaceBrokerProxy* interface_broker) { mojo::PendingRemote<mojom::blink::RendererAudioOutputStreamFactory> @@ -85,33 +85,34 @@ io_task_runner()->PostTask( FROM_HERE, base::BindOnce( - &WebAudioOutputIPCFactory::Impl::RegisterRemoteFactoryOnIOThread, + &AudioOutputIPCFactory::Impl::RegisterRemoteFactoryOnIOThread, base::Unretained(impl_.get()), frame_token, std::move(factory_remote))); } -void WebAudioOutputIPCFactory::MaybeDeregisterRemoteFactory( +void AudioOutputIPCFactory::MaybeDeregisterRemoteFactory( const blink::LocalFrameToken& frame_token) { io_task_runner()->PostTask( - FROM_HERE, base::BindOnce(&WebAudioOutputIPCFactory::Impl:: - MaybeDeregisterRemoteFactoryOnIOThread, - base::Unretained(impl_.get()), frame_token)); + FROM_HERE, + base::BindOnce( + &AudioOutputIPCFactory::Impl::MaybeDeregisterRemoteFactoryOnIOThread, + base::Unretained(impl_.get()), frame_token)); } const scoped_refptr<base::SingleThreadTaskRunner>& -WebAudioOutputIPCFactory::io_task_runner() const { +AudioOutputIPCFactory::io_task_runner() const { return impl_->io_task_runner_; } mojom::blink::RendererAudioOutputStreamFactory* -WebAudioOutputIPCFactory::Impl::GetRemoteFactory( +AudioOutputIPCFactory::Impl::GetRemoteFactory( const blink::LocalFrameToken& frame_token) const { DCHECK(io_task_runner_->BelongsToCurrentThread()); auto it = factory_remotes_.find(LocalFrameToken::Hasher()(frame_token)); return it == factory_remotes_.end() ? nullptr : it->value.get(); } -void WebAudioOutputIPCFactory::Impl::RegisterRemoteFactoryOnIOThread( +void AudioOutputIPCFactory::Impl::RegisterRemoteFactoryOnIOThread( const blink::LocalFrameToken& frame_token, mojo::PendingRemote<mojom::blink::RendererAudioOutputStreamFactory> factory_pending_remote) { @@ -133,11 +134,11 @@ // Unretained is safe because |this| owns the remote, so a connection error // cannot trigger after destruction. emplaced_factory.set_disconnect_handler(base::BindOnce( - &WebAudioOutputIPCFactory::Impl::MaybeDeregisterRemoteFactoryOnIOThread, + &AudioOutputIPCFactory::Impl::MaybeDeregisterRemoteFactoryOnIOThread, base::Unretained(this), frame_token)); } -void WebAudioOutputIPCFactory::Impl::MaybeDeregisterRemoteFactoryOnIOThread( +void AudioOutputIPCFactory::Impl::MaybeDeregisterRemoteFactoryOnIOThread( const blink::LocalFrameToken& frame_token) { DCHECK(io_task_runner_->BelongsToCurrentThread()); // This function can be called both by the frame and the connection error
diff --git a/third_party/blink/renderer/modules/media/audio/web_audio_output_ipc_factory_test.cc b/third_party/blink/renderer/modules/media/audio/audio_output_ipc_factory_test.cc similarity index 89% rename from third_party/blink/renderer/modules/media/audio/web_audio_output_ipc_factory_test.cc rename to third_party/blink/renderer/modules/media/audio/audio_output_ipc_factory_test.cc index 23cd436..9cbb205e 100644 --- a/third_party/blink/renderer/modules/media/audio/web_audio_output_ipc_factory_test.cc +++ b/third_party/blink/renderer/modules/media/audio/audio_output_ipc_factory_test.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "third_party/blink/public/web/modules/media/audio/web_audio_output_ipc_factory.h" +#include "third_party/blink/public/web/modules/media/audio/audio_output_ipc_factory.h" #include <string> #include <utility> @@ -96,10 +96,10 @@ } // namespace -class WebAudioOutputIPCFactoryTest : public testing::Test { +class AudioOutputIPCFactoryTest : public testing::Test { public: - WebAudioOutputIPCFactoryTest() = default; - ~WebAudioOutputIPCFactoryTest() override = default; + AudioOutputIPCFactoryTest() = default; + ~AudioOutputIPCFactoryTest() override = default; void RequestAuthorizationOnIOThread( std::unique_ptr<media::AudioOutputIPC> output_ipc) { @@ -113,8 +113,8 @@ FakeAudioOutputIPCDelegate fake_delegate; }; -TEST_F(WebAudioOutputIPCFactoryTest, CallFactoryFromIOThread) { - // This test makes sure that WebAudioOutputIPCFactory correctly binds the +TEST_F(AudioOutputIPCFactoryTest, CallFactoryFromIOThread) { + // This test makes sure that AudioOutputIPCFactory correctly binds the // RendererAudioOutputStreamFactory to the IO thread. ScopedTestingPlatformSupport<IOTaskRunnerTestingPlatformSupport> platform; base::RunLoop run_loop; @@ -129,7 +129,7 @@ base::BindRepeating(&FakeRemoteFactory::Bind, base::Unretained(&remote_factory))); - WebAudioOutputIPCFactory ipc_factory(io_thread->task_runner()); + AudioOutputIPCFactory ipc_factory(io_thread->task_runner()); ipc_factory.RegisterRemoteFactory(TokenFromInt(kRenderFrameId), &interface_broker); @@ -141,7 +141,7 @@ io_thread->task_runner()->PostTask( FROM_HERE, base::BindOnce( - &WebAudioOutputIPCFactoryTest::RequestAuthorizationOnIOThread, + &AudioOutputIPCFactoryTest::RequestAuthorizationOnIOThread, base::Unretained(this), ipc_factory.CreateAudioOutputIPC(TokenFromInt(kRenderFrameId)))); @@ -157,7 +157,7 @@ base::RunLoop().RunUntilIdle(); } -TEST_F(WebAudioOutputIPCFactoryTest, SeveralFactories) { +TEST_F(AudioOutputIPCFactoryTest, SeveralFactories) { // This test simulates having several frames being created and destructed. ScopedTestingPlatformSupport<IOTaskRunnerTestingPlatformSupport> platform; auto io_thread = MakeIOThread(); @@ -177,7 +177,7 @@ base::RunLoop().RunUntilIdle(); - WebAudioOutputIPCFactory ipc_factory(io_thread->task_runner()); + AudioOutputIPCFactory ipc_factory(io_thread->task_runner()); for (int i = 0; i < n_factories; i++) { ipc_factory.RegisterRemoteFactory(TokenFromInt(kRenderFrameId + i), @@ -189,7 +189,7 @@ io_thread->task_runner()->PostTask( FROM_HERE, base::BindOnce( - &WebAudioOutputIPCFactoryTest::RequestAuthorizationOnIOThread, + &AudioOutputIPCFactoryTest::RequestAuthorizationOnIOThread, base::Unretained(this), ipc_factory.CreateAudioOutputIPC(TokenFromInt(kRenderFrameId)))); run_loop.Run(); @@ -202,7 +202,7 @@ io_thread->task_runner()->PostTask( FROM_HERE, base::BindOnce( - &WebAudioOutputIPCFactoryTest::RequestAuthorizationOnIOThread, + &AudioOutputIPCFactoryTest::RequestAuthorizationOnIOThread, base::Unretained(this), ipc_factory.CreateAudioOutputIPC(TokenFromInt(kRenderFrameId + 2)))); run_loop2.Run(); @@ -220,7 +220,7 @@ base::RunLoop().RunUntilIdle(); } -TEST_F(WebAudioOutputIPCFactoryTest, RegisterDeregisterBackToBack_Deregisters) { +TEST_F(AudioOutputIPCFactoryTest, RegisterDeregisterBackToBack_Deregisters) { // This test makes sure that calling Register... followed by Deregister... // correctly sequences the registration before the deregistration. ScopedTestingPlatformSupport<IOTaskRunnerTestingPlatformSupport> platform; @@ -235,13 +235,13 @@ base::BindRepeating(&FakeRemoteFactory::Bind, base::Unretained(&remote_factory))); - WebAudioOutputIPCFactory ipc_factory(io_thread->task_runner()); + AudioOutputIPCFactory ipc_factory(io_thread->task_runner()); ipc_factory.RegisterRemoteFactory(TokenFromInt(kRenderFrameId), &interface_broker); ipc_factory.MaybeDeregisterRemoteFactory(TokenFromInt(kRenderFrameId)); // That there is no factory remaining at destruction is DCHECKed in the - // WebAudioOutputIPCFactory destructor. + // AudioOutputIPCFactory destructor. base::RunLoop().RunUntilIdle();
diff --git a/third_party/blink/renderer/platform/context_lifecycle_observer.h b/third_party/blink/renderer/platform/context_lifecycle_observer.h index 26bb77cd..241a093 100644 --- a/third_party/blink/renderer/platform/context_lifecycle_observer.h +++ b/third_party/blink/renderer/platform/context_lifecycle_observer.h
@@ -6,7 +6,8 @@ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_CONTEXT_LIFECYCLE_OBSERVER_H_ #include "base/dcheck_is_on.h" -#include "third_party/blink/renderer/platform/heap/handle.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" +#include "third_party/blink/renderer/platform/heap/member.h" namespace blink {
diff --git a/third_party/blink/renderer/platform/scheduler/common/tracing_helper_unittest.cc b/third_party/blink/renderer/platform/scheduler/common/tracing_helper_unittest.cc index 28cdb56..2717b2e6 100644 --- a/third_party/blink/renderer/platform/scheduler/common/tracing_helper_unittest.cc +++ b/third_party/blink/renderer/platform/scheduler/common/tracing_helper_unittest.cc
@@ -58,15 +58,12 @@ // TODO(kraynov): TraceableCounter tests. -// crbug.com/1275221: tests are flaky on CrOS and Linux -#if defined(OS_CHROMEOS) || defined(OS_LINUX) +#if defined(COMPONENT_BUILD) +// TODO(https://crbug.com/1275221): Figure out, re-enable. #define MAYBE_TraceableState DISABLED_TraceableState -#define MAYBE_TraceableStateOperators DISABLED_TraceableStateOperators #else #define MAYBE_TraceableState TraceableState -#define MAYBE_TraceableStateOperators TraceableStateOperators #endif - TEST(TracingHelperTest, MAYBE_TraceableState) { TraceableVariableController controller; TraceableStateForTest state(&controller); @@ -80,6 +77,12 @@ ExpectTraced("negative"); } +#if defined(COMPONENT_BUILD) +// TODO(https://crbug.com/1275221): Figure out, re-enable. +#define MAYBE_TraceableStateOperators DISABLED_TraceableStateOperators +#else +#define MAYBE_TraceableStateOperators TraceableStateOperators +#endif TEST(TracingHelperTest, MAYBE_TraceableStateOperators) { TraceableVariableController controller; TraceableState<int, TracingCategoryName::kDebug> x(-1, "X", &controller,
diff --git a/third_party/blink/web_tests/FlagExpectations/enable-percent-based-scrolling b/third_party/blink/web_tests/FlagExpectations/enable-percent-based-scrolling index 1f3124c..ae4a4eb 100644 --- a/third_party/blink/web_tests/FlagExpectations/enable-percent-based-scrolling +++ b/third_party/blink/web_tests/FlagExpectations/enable-percent-based-scrolling
@@ -22,11 +22,9 @@ crbug.com/1204176 fast/scrolling/scroll-animation-on-by-default.html [ Failure ] crbug.com/1204176 fast/scrolling/wheel-scroll-latching-on-scrollbar.html [ Failure ] -# fast/scrolling/events -crbug.com/1204176 fast/scrolling/events/overscroll-event-fired-to-document.html [ Failure Timeout ] -crbug.com/1204176 fast/scrolling/events/overscroll-event-fired-to-element-with-overscroll-behavior.html [ Failure Timeout ] -crbug.com/1204176 fast/scrolling/events/overscroll-event-fired-to-scrolled-element.html [ Failure Timeout ] -crbug.com/1204176 fast/scrolling/events/overscroll-event-fired-to-window.html [ Failure Timeout ] +# fast/scrolling/events. Main thread only. +crbug.com/1199989 fast/scrolling/events/overscroll-event-fired-to-document.html [ Failure ] +crbug.com/1199989 fast/scrolling/events/overscroll-event-fired-to-window.html [ Failure ] # fast/scroll-snap/ crbug.com/1204176 fast/scroll-snap/snaps-after-touchpad-scrolling.html [ Failure ]
diff --git a/third_party/blink/web_tests/LeakExpectations b/third_party/blink/web_tests/LeakExpectations index 87715a5..fb3a014 100644 --- a/third_party/blink/web_tests/LeakExpectations +++ b/third_party/blink/web_tests/LeakExpectations
@@ -29,10 +29,6 @@ crbug.com/867532 external/wpt/workers/modules/dedicated-worker-import-data-url.any.worker.html [ Crash ] crbug.com/867532 external/wpt/workers/modules/dedicated-worker-import.any.worker.html [ Crash ] crbug.com/867532 http/tests/workers/worker-usecounter.html [ Crash ] - -# These tests crash with the leak detector enabled. Previously, crashes inside -# leak detection were incorrectly hidden with the test passing. -# See https://chromium-review.googlesource.com/c/chromium/src/+/2252943 crbug.com/1098106 virtual/off-main-thread-css-paint/http/tests/csspaint/invalidation-border-image.html [ Crash ] crbug.com/1098106 virtual/off-main-thread-css-paint/http/tests/csspaint/invalidation-background-image.html [ Crash ] crbug.com/1098106 virtual/off-main-thread-css-paint/http/tests/csspaint/invalidation-content-image.html [ Crash ] @@ -137,6 +133,9 @@ # Sheriff 2020-10-08 crbug.com/1136690 [ Linux ] http/tests/inspector-protocol/service-worker/service-worker-fetch-async-stacks.js [ Pass Timeout ] +# Sheriff 2021-02-25 +crbug.com/1182675 [ Linux ] dom/attr/id-update-map-crash.html [ Failure Pass ] + # Sheriff 2021-03-02 crbug.com/1183788 [ Linux ] external/wpt/pointerevents/pointerevent_fractional_coordinates.html?touch [ Pass Failure ]
diff --git a/third_party/blink/web_tests/TestExpectations b/third_party/blink/web_tests/TestExpectations index f34e4d9..6e7d6423 100644 --- a/third_party/blink/web_tests/TestExpectations +++ b/third_party/blink/web_tests/TestExpectations
@@ -2095,10 +2095,6 @@ crbug.com/919789 images/image-zoom-to-25.html [ Timeout ] crbug.com/919789 images/image-zoom-to-500.html [ Timeout ] -# Sheriff 2020-02-06 -# Flaking on Linux Leak -crbug.com/1049599 [ Linux ] virtual/threaded-prefer-compositing/fast/scrolling/events/overscroll-event-fired-to-element-with-overscroll-behavior.html [ Failure Pass Skip Timeout ] - # Sheriff 2019-08-19 crbug.com/626703 [ Win7 ] external/wpt/html/dom/documents/resource-metadata-management/document-lastModified-01.html [ Failure ] @@ -3019,53 +3015,13 @@ crbug.com/626703 virtual/plz-dedicated-worker/external/wpt/service-workers/service-worker/navigation-timing-extended.https.html [ Failure ] # ====== New tests from wpt-importer added here ====== +crbug.com/626703 [ Mac11 ] external/wpt/webauthn/createcredential-minpinlength.https.html [ Crash Skip Timeout ] crbug.com/626703 [ Mac11-arm64 ] external/wpt/webrtc/RTCDataChannel-close.html [ Skip Timeout ] crbug.com/626703 [ Mac11-arm64 ] external/wpt/webrtc/RTCDataChannel-send-blob-order.html [ Timeout ] crbug.com/626703 [ Mac11-arm64 ] external/wpt/webrtc/RTCPeerConnection-capture-video.https.html [ Skip Timeout ] crbug.com/626703 [ Mac11-arm64 ] external/wpt/webrtc/RTCPeerConnection-iceConnectionState.https.html [ Skip Timeout ] crbug.com/626703 [ Mac11-arm64 ] virtual/webrtc-wpt-plan-b/external/wpt/webrtc/RTCDataChannel-send.html [ Skip Timeout ] crbug.com/626703 [ Mac11-arm64 ] virtual/webrtc-wpt-plan-b/external/wpt/webrtc/RTCPeerConnection-onsignalingstatechanged.https.html [ Timeout ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/css-skew-001.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/css-transform-3d-rotateZ-negative.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/document-styles/svg-document-styles-003.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/document-styles/svg-document-styles-005.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/document-styles/svg-document-styles-013.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/external-styles/svg-external-styles-014.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/inline-styles/svg-inline-styles-013.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/matrix/svg-matrix-041.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/parsing/backface-visibility-valid.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/perspective-origin-xy.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/preserve3d-button.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/rotate_x_45deg.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/scaley.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/scrollable-scroll-3d-transform-z.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/transform-box/fill-box-001.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/transform-box/svgbox-initial.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/transform-inline-001.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/transform-matrix-002.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/transform-matrix-008.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/transform-origin-004.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/transform-origin-005.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/transform-origin/svg-origin-length-004.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/transform-origin/svg-origin-relative-length-007.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/transform-origin/svg-origin-relative-length-013.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/transform-origin/svg-origin-relative-length-022.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/transform-origin/svg-origin-relative-length-024.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/transform-origin/svg-origin-relative-length-042.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/transform-propagate-inherit-boolean-001.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/transform3d-perspective-002.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/transform3d-perspective-006.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/transform3d-scale-004.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/transform_translate_second_omited.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/translate.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/backface-visibility-interop/external/wpt/css/css-transforms/ttwf-transform-translatey-001.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/background-svg-in-lcp/external/wpt/largest-contentful-paint/animated/observe-animated-image-webp.tentative.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/background-svg-in-lcp/external/wpt/largest-contentful-paint/element-only-when-fully-active.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/background-svg-in-lcp/external/wpt/largest-contentful-paint/image-TAO.sub.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/background-svg-in-lcp/external/wpt/largest-contentful-paint/observe-svg-image.html [ Crash ] -crbug.com/626703 [ Mac10.13 ] virtual/change-service-worker-priority-when-client-foreground-state-change/external/wpt/service-workers/cache-storage/serviceworker/cache-abort.https.html [ Crash ] -crbug.com/626703 [ Mac10.12 ] virtual/container-queries/wpt_internal/css/css-conditional/container-queries/top-layer-001.html [ Crash Failure ] -crbug.com/626703 [ Mac10.12 ] virtual/scalefactor200/external/wpt/element-timing/cross-origin-element.sub.html [ Crash Failure ] crbug.com/626703 [ Mac11 ] wpt_internal/webcodecs/reconfiguring_encoder.https.any.worker.html [ Timeout ] crbug.com/626703 [ Mac10.15 ] external/wpt/streams/piping/abort.any.html [ Failure Timeout ] crbug.com/626703 [ Mac10.15 ] external/wpt/streams/piping/abort.any.sharedworker.html [ Crash Failure ] @@ -5619,10 +5575,6 @@ # [1] https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2049183 # [2] https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2119670 -crbug.com/1049456 fast/scrolling/events/overscroll-event-fired-to-element-with-overscroll-behavior.html [ Failure Pass ] -crbug.com/1081277 fast/scrolling/events/scrollend-event-fired-to-element-with-overscroll-behavior.html [ Failure Pass ] -crbug.com/1080997 fast/scrolling/events/scrollend-event-fired-to-scrolled-element.html [ Failure Pass ] - # "in-multicol-child.html" is laid out in legacy layout due by "multicol" but # reference is laid out by LayoutNG. crbug.com/829028 [ Mac ] editing/caret/in-multicol-child.html [ Failure ] @@ -5724,14 +5676,8 @@ crbug.com/1204176 virtual/compositor-threaded-percent-based-scrolling/fast/scrolling/mouse-scrolling-over-standard-scrollbar.html [ Failure Pass ] # fast/scrolling/events -crbug.com/1204176 virtual/main-threaded-percent-based-scrolling/fast/scrolling/events/overscroll-event-fired-to-document.html [ Failure Timeout ] -crbug.com/1204176 virtual/main-threaded-percent-based-scrolling/fast/scrolling/events/overscroll-event-fired-to-element-with-overscroll-behavior.html [ Failure Timeout ] -crbug.com/1204176 virtual/main-threaded-percent-based-scrolling/fast/scrolling/events/overscroll-event-fired-to-scrolled-element.html [ Failure Timeout ] -crbug.com/1204176 virtual/main-threaded-percent-based-scrolling/fast/scrolling/events/overscroll-event-fired-to-window.html [ Failure Timeout ] -crbug.com/1204176 virtual/compositor-threaded-percent-based-scrolling/fast/scrolling/events/overscroll-event-fired-to-document.html [ Failure Timeout ] -crbug.com/1204176 virtual/compositor-threaded-percent-based-scrolling/fast/scrolling/events/overscroll-event-fired-to-element-with-overscroll-behavior.html [ Failure Timeout ] -crbug.com/1204176 virtual/compositor-threaded-percent-based-scrolling/fast/scrolling/events/overscroll-event-fired-to-scrolled-element.html [ Failure Timeout ] -crbug.com/1204176 virtual/compositor-threaded-percent-based-scrolling/fast/scrolling/events/overscroll-event-fired-to-window.html [ Failure Timeout ] +crbug.com/1199989 virtual/main-threaded-percent-based-scrolling/fast/scrolling/events/overscroll-event-fired-to-document.html [ Failure ] +crbug.com/1199989 virtual/main-threaded-percent-based-scrolling/fast/scrolling/events/overscroll-event-fired-to-window.html [ Failure ] ### END PERCENT BASED SCROLLING TEST FAILURES @@ -6267,7 +6213,6 @@ crbug.com/1181857 external/wpt/webaudio/the-audio-api/the-analysernode-interface/test-analyser-output.html [ Failure Pass ] # Sheriff 2021-02-25 -crbug.com/1182675 [ Linux ] dom/attr/id-update-map-crash.html [ Failure Pass ] crbug.com/1182682 [ Linux ] http/tests/devtools/service-workers/service-workers-view.js [ Failure Pass ] # Sheriff 2021-03-04 @@ -6517,7 +6462,6 @@ crbug.com/1209223 external/wpt/url/url-constructor.any.worker.html [ Pass Skip Timeout ] # Sheriff 2021-05-17 -crbug.com/1193920 virtual/scroll-unification/fast/scrolling/events/overscroll-event-fired-to-scrolled-element.html [ Pass Timeout ] crbug.com/1210199 http/tests/devtools/elements/elements-panel-restore-selection-when-node-comes-later.js [ Failure Pass ] crbug.com/1199522 http/tests/devtools/layers/layers-3d-view-hit-testing.js [ Failure Pass ] @@ -6750,10 +6694,6 @@ crbug.com/1216587 [ Win7 ] accessibility/scroll-window-sends-notification.html [ Failure Pass ] crbug.com/1216587 [ Mac11-arm64 ] accessibility/scroll-window-sends-notification.html [ Failure Pass ] -# Sheriff 2021-07-01 -# Now also flakily timing-out. -crbug.com/1193920 virtual/threaded-prefer-compositing/fast/scrolling/events/overscroll-event-fired-to-scrolled-element.html [ Failure Pass Timeout ] - # Sheriff 2021-07-02 crbug.com/1226112 http/tests/text-autosizing/narrow-iframe.html [ Failure Pass ] @@ -7406,3 +7346,5 @@ # Sheriff 2021-11-30 crbug.com/1256763 [ Linux ] virtual/gpu-rasterization/images/color-profile-image-shape.html [ Failure Pass ] +crbug.com/1275209 [ Mac11 ] virtual/webrtc-wpt-plan-b/external/wpt/webrtc/RTCPeerConnection-mandatory-getStats.https.html [ Failure ] +crbug.com/1275209 [ Mac11 ] external/wpt/webrtc/RTCPeerConnection-mandatory-getStats.https.html [ Failure ]
diff --git a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json index 335802f..71ab2b6c 100644 --- a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json +++ b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json
@@ -78443,6 +78443,123 @@ ], {} ] + ], + "single-line-column-flex-fragmentation-015.html": [ + "b8e91335376e139c3164b7b14cdf09306bf52ff2", + [ + null, + [ + [ + "/css/reference/ref-filled-green-100px-square.xht", + "==" + ] + ], + {} + ] + ], + "single-line-column-flex-fragmentation-016.html": [ + "f079e1140e201a5b8c35c8b17aac4c49c3978a22", + [ + null, + [ + [ + "/css/reference/ref-filled-green-100px-square.xht", + "==" + ] + ], + {} + ] + ], + "single-line-column-flex-fragmentation-017.html": [ + "4c4dad3103bfd8809e3ca68997881bb3e06bed7d", + [ + null, + [ + [ + "/css/reference/ref-filled-green-100px-square.xht", + "==" + ] + ], + {} + ] + ], + "single-line-column-flex-fragmentation-018.html": [ + "d06e1bf914c0dea4fa17027e6026feab67418ea2", + [ + null, + [ + [ + "/css/reference/ref-filled-green-100px-square.xht", + "==" + ] + ], + {} + ] + ], + "single-line-column-flex-fragmentation-019.html": [ + "74f7caa0d0cac0f848183ad3fccb7ff07186aaf7", + [ + null, + [ + [ + "/css/reference/ref-filled-green-100px-square.xht", + "==" + ] + ], + {} + ] + ], + "single-line-column-flex-fragmentation-020.html": [ + "8b230270ceffa202f74e67be467f9f39b6709e4c", + [ + null, + [ + [ + "/css/reference/ref-filled-green-100px-square.xht", + "==" + ] + ], + {} + ] + ], + "single-line-column-flex-fragmentation-021.html": [ + "6248205bc16f807bf1caa09670fee624aea07e16", + [ + null, + [ + [ + "/css/reference/ref-filled-green-100px-square.xht", + "==" + ] + ], + {} + ] + ], + "single-line-column-flex-fragmentation-022.html": [ + "b0439bed67d1682d5419d6e7d66a327cc875d852", + [ + null, + [ + [ + "/css/reference/ref-filled-green-100px-square.xht", + "==" + ] + ], + {} + ] + ], + "single-line-column-flex-fragmentation-023.html": [ + "dd5c8a7c99bf3bc15083c24b4ee1589149e13116", + [ + null, + [ + [ + "/css/reference/ref-filled-green-100px-square.xht", + "==" + ] + ], + {} + ] ] }, "float-000.html": [ @@ -134896,19 +135013,6 @@ {} ] ], - "position-absolute-center-005.html": [ - "c586719f8e2b1cfaf8663bc53f357bcc9749279d", - [ - null, - [ - [ - "/css/reference/ref-filled-green-100px-square.xht", - "==" - ] - ], - {} - ] - ], "position-absolute-center-006.html": [ "cd7fb566264e0fadc8e682098da5e32d7f112a04", [ @@ -135344,6 +135448,45 @@ {} ] ], + "position-absolute-semi-replaced-stretch-button.html": [ + "fbcdbec51b63f2dc2eab281797b505e9586d8072", + [ + null, + [ + [ + "/css/css-position/position-absolute-semi-replaced-stretch-button-ref.html", + "==" + ] + ], + {} + ] + ], + "position-absolute-semi-replaced-stretch-input.html": [ + "6080f63c1019940bc702fae37a43041719863198", + [ + null, + [ + [ + "/css/css-position/position-absolute-semi-replaced-stretch-input-ref.html", + "==" + ] + ], + {} + ] + ], + "position-absolute-semi-replaced-stretch-other.html": [ + "21fc2c84e3d65863dc717b3dea3c82ecbc9dd097", + [ + null, + [ + [ + "/css/css-position/position-absolute-semi-replaced-stretch-other-ref.html", + "==" + ] + ], + {} + ] + ], "position-absolute-under-non-containing-stacking-context.html": [ "444f125767858827f220669a7088fe228626072e", [ @@ -251503,6 +251646,18 @@ "d4649f2d5abc240f09551cc9efebfa2029406101", [] ], + "position-absolute-semi-replaced-stretch-button-ref.html": [ + "296b87ba615414472370086a0a64e2206a34537d", + [] + ], + "position-absolute-semi-replaced-stretch-input-ref.html": [ + "554173c6323bd16348e6d008732c262dae3d3686", + [] + ], + "position-absolute-semi-replaced-stretch-other-ref.html": [ + "e334bc0f63d9a5c5906a134faaf07668c9d8b1ad", + [] + ], "position-absolute-under-non-containing-stacking-context-ref.html": [ "ceade7bafe9cc0510a2080b4a9ec5e7514469dcf", [] @@ -268850,7 +269005,7 @@ ], "include": { "editor-test-utils.js": [ - "430de2decf75986ea2147036896246ae82eaaeed", + "abf89d7e9edb9526a8efb1609c44e9741852d04d", [] ], "implementation.js": [ @@ -296311,7 +296466,7 @@ [] ], "pointerevent_support.js": [ - "6cbc8d69f393ce42c269f0906d1c1d845d778b52", + "727909fee72ee94b8970d2616384123c597cc731", [] ], "pointerlock": { @@ -296335,6 +296490,10 @@ "0a894d4401e80a7e3528e38e16a06b0cdcbf7acd", [] ], + "minimal.html": [ + "9402b95cb173389aead0aacf0c3e5fc553f6c3ae", + [] + ], "pointerevent_attributes_hoverable_pointers-iframe.html": [ "5e55868282ce5ce549f1d32092839f05bd43aba7", [] @@ -308648,10 +308807,6 @@ [] ] }, - "receiver-track-live-expected.txt": [ - "93d7c92f38ec8c3695b9bdee18843c34f78890f7", - [] - ], "resources": { "RTCCertificate-postMessage-iframe.html": [ "9e52ba0c888a8d500072c1669599d88f64cb22c3", @@ -378867,6 +379022,15 @@ {} ] ], + "undo-redo.html": [ + "69bee00c86ffa300c39b6e70f4e8f98921dd06a5", + [ + null, + { + "testdriver": true + } + ] + ], "unlink.html": [ "5a623b4a09faf0e84a5c0b9c914c525bf60329c8", [ @@ -428736,6 +428900,41 @@ } ] ], + "cookie-store.tentative.https.window.js": [ + "2332cb4950c345292716ae75a5b1576f422e96d3", + [ + "html/cross-origin-embedder-policy/anonymous-iframe/cookie-store.tentative.https.window.html", + { + "script_metadata": [ + [ + "timeout", + "long" + ], + [ + "script", + "/common/get-host-info.sub.js" + ], + [ + "script", + "/common/utils.js" + ], + [ + "script", + "/common/dispatcher/dispatcher.js" + ], + [ + "script", + "../credentialless/resources/common.js" + ], + [ + "script", + "./resources/common.js" + ] + ], + "timeout": "long" + } + ] + ], "cookie.tentative.https.window.js": [ "aafe5d3f5d1ffc5d5d7f4befcd81d19c2de809e2", [ @@ -430253,6 +430452,13 @@ {} ] ], + "coop-sandbox-cuts-opener.https.html": [ + "47e6d0d6fe54107f781454b99b6addb852b480bf", + [ + null, + {} + ] + ], "coop-sandbox.https.html": [ "6f250c1b0920808f519ee1278920215981fcd5e6", [ @@ -434261,13 +434467,6 @@ ] ], "button-layout": { - "abspos.html": [ - "c3089b1e39749e003fcadd7d822a8343575be212", - [ - null, - {} - ] - ], "computed-style.html": [ "764e0844069af07dd7c3b454e4dc94eed4c0551f", [ @@ -440097,6 +440296,15 @@ } ] ], + "email-set-value.html": [ + "95245fb8242a8c4a289c818f172281cc318dd531", + [ + null, + { + "testdriver": true + } + ] + ], "email.html": [ "fc92529efafb65166f86014b123b87285603f437", [ @@ -450967,6 +451175,13 @@ ] }, "inert": { + "dynamic-inert-on-focused-element.tentative.html": [ + "42b6e21935b743ac77bd3334d0abf32c8aa7078a", + [ + null, + {} + ] + ], "inert-computed-style.html": [ "a68eb7465128937801d5417cbe4ed2ca1bfc3757", [ @@ -456659,7 +456874,7 @@ ] ], "MediaStreamTrackProcessor-video.https.html": [ - "7cc87c7383461ee7aeb1fa9d56aef0f1564345b2", + "9295db3a5c451b08f2013520f772e02e1bb7cd57", [ null, {} @@ -465089,7 +465304,7 @@ ] ], "pointerevent_click_is_a_pointerevent.html": [ - "0ce9f0736090576c55f192e2da7f8c683e0fbac6", + "46c1ed4f49c5953cfe1c5ecd461a0eb17fee7d8b", [ "pointerevents/pointerevent_click_is_a_pointerevent.html?mouse", {
diff --git a/third_party/blink/web_tests/external/wpt/css/css-cascade/idlharness.html b/third_party/blink/web_tests/external/wpt/css/css-cascade/idlharness.html new file mode 100644 index 0000000..fff4c66 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-cascade/idlharness.html
@@ -0,0 +1,33 @@ +<!doctype html> +<title>CSS Cascade Layers IDL tests</title> +<link rel="help" href="https://drafts.csswg.org/css-cascade-5/#layer-apis"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/WebIDLParser.js"></script> +<script src="/resources/idlharness.js"></script> + +<style> +@layer foo { } +@layer bar, baz; +</style> + +<script> + 'use strict'; + idl_test( + ['css-cascade-5'], + ['cssom'], + idl_array => { + try { + self.block = document.styleSheets[0].cssRules.item(0); + self.statement = document.styleSheets[0].cssRules.item(1); + } catch (e) { + // Will be surfaced when block or statement is undefined below. + } + + idl_array.add_objects({ + CSSLayerBlockRule: ['block'], + CSSLayerStatementRule: ['statement'], + }); + } + ); +</script>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-cascade/layer-rules-cssom.html b/third_party/blink/web_tests/external/wpt/css/css-cascade/layer-rules-cssom.html new file mode 100644 index 0000000..923da1b --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-cascade/layer-rules-cssom.html
@@ -0,0 +1,82 @@ +<!DOCTYPE html> +<title>The CSSOM API for @layer Rules</title> +<link rel="help" href="https://drafts.csswg.org/css-cascade-5/#the-csslayerblockrule-interface"> +<link rel="help" href="https://drafts.csswg.org/css-cascade-5/#the-csslayerstatementrule-interface"> +<link rel="author" href="mailto:xiaochengh@chromium.org"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +const testCases = [ + { + style: `@layer foo { }`, + expectedNames: ['foo'], + title: 'Basic layer block name', + }, + { + style: `@layer { }`, + expectedNames: [''], + title: 'Anonymous layer block name', + }, + { + style: ` + @layer foo; + `, + expectedNames: [['foo']], + title: 'Basic layer statement name', + }, + { + style: ` + @layer foo, bar; + `, + expectedNames: [['foo', 'bar']], + title: 'Layer statement with multiple names', + }, + { + style: ` + @layer outer { + @layer foo.bar { } + } + @layer outer.foo.bar { } + `, + expectedNames: ['outer', 'foo.bar', 'outer.foo.bar'], + title: 'Nested layer block names', + }, + { + style: ` + @layer outer { + @layer foo.bar, baz; + } + @layer outer.foo.bar, outer.baz; + `, + expectedNames: ['outer', ['foo.bar', 'baz'], ['outer.foo.bar', 'outer.baz']], + title: 'Nested layer statement name lists', + }, +]; + +for (let testCase of testCases) { + const style = document.createElement('style'); + style.appendChild(document.createTextNode(testCase.style)); + document.head.appendChild(style); + + test(function () { + assert_implements(window.CSSLayerBlockRule); + assert_implements(window.CSSLayerStatementRule); + + let index = 0; + function compareNames(ruleOrSheet) { + if (ruleOrSheet instanceof CSSLayerBlockRule) + assert_equals(ruleOrSheet.name, testCase.expectedNames[index++]); + else if (ruleOrSheet instanceof CSSLayerStatementRule) + assert_array_equals(ruleOrSheet.nameList, testCase.expectedNames[index++]); + if (ruleOrSheet.cssRules) { + for (let i = 0; i < ruleOrSheet.cssRules.length; ++i) + compareNames(ruleOrSheet.cssRules.item(i)); + } + } + compareNames(style.sheet); + assert_equals(index, testCase.expectedNames.length); + }, testCase.title); + + style.remove(); +} +</script>
diff --git a/third_party/blink/web_tests/external/wpt/editing/include/editor-test-utils.js b/third_party/blink/web_tests/external/wpt/editing/include/editor-test-utils.js index 430de2d..abf89d7 100644 --- a/third_party/blink/web_tests/external/wpt/editing/include/editor-test-utils.js +++ b/third_party/blink/web_tests/external/wpt/editing/include/editor-test-utils.js
@@ -2,6 +2,8 @@ * EditorTestUtils is a helper utilities to test HTML editor. This can be * instantiated per an editing host. If you test `designMode`, the editing * host should be the <body> element. + * Note that if you want to use sendKey in a sub-document, you need to include + * testdriver.js (and related files) from the sub-document before creating this. */ class EditorTestUtils { kShift = "\uE008"; @@ -13,7 +15,7 @@ constructor(aEditingHost, aHarnessWindow = window) { this.editingHost = aEditingHost; - if (aHarnessWindow != this.window) { + if (aHarnessWindow != this.window && this.window.test_driver) { this.window.test_driver.set_test_context(aHarnessWindow); } }
diff --git a/third_party/blink/web_tests/external/wpt/editing/run/undo-redo.html b/third_party/blink/web_tests/external/wpt/editing/run/undo-redo.html new file mode 100644 index 0000000..69bee00 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/editing/run/undo-redo.html
@@ -0,0 +1,226 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<script src="/resources/testdriver-actions.js"></script> +<script src="../include/editor-test-utils.js"></script> +<iframe srcdoc=""></iframe> +<script> +"use strict"; +const iframe = document.querySelector("iframe"); + +promise_test(async () => { + await new Promise(resolve => { + addEventListener("load", resolve, {once: true}); + }); +}, "Waiting for load..."); + +/** + * This test does NOT test whether the edit result is valid or invalid. + * This test just tests whether "undo" and "redo" restores previous state + * and additional "undo" and "redo" does not run unexpectedly. + * + * description: Set string to explain what's testing. + * editorInnerHTML: Set initial innerHTML value of editor. + * init: Set a function object if you need to test complicated cases, e.g., + * testing with empty text node. + * run: Set a function object which run something modifying the editor (or + * does nothing). + * expectedUndoResult: Set an expected innerHTML result as string or array + * of the string. If this is not specified, it's compared + * with editorInnerHTML value. + * cleanUp: Set a function object if you need to clean something up after the + * test. + */ + +const tests = [ + { + description: "insertParagraph at start of a paragraph", + editorInnerHTML: "<p>[]abcdef</p>", + run: (win, doc, editingHost) => { + doc.execCommand("insertParagraph"); + }, + }, + { + description: "insertParagraph at middle of a paragraph", + editorInnerHTML: "<p>abc[]def</p>", + run: (win, doc, editingHost) => { + doc.execCommand("insertParagraph"); + }, + }, + { + description: "insertParagraph at end of a paragraph", + editorInnerHTML: "<p>abcdef[]</p>", + run: (win, doc, editingHost) => { + doc.execCommand("insertParagraph"); + }, + }, + { + description: "insertParagraph at start of a listitem", + editorInnerHTML: "<ul><li>[]abcdef</li></ul>", + run: (win, doc, editingHost) => { + doc.execCommand("insertParagraph"); + }, + }, + { + description: "insertParagraph at middle of a listitem", + editorInnerHTML: "<ul><li>abc[]def</li></ul>", + run: (win, doc, editingHost) => { + doc.execCommand("insertParagraph"); + }, + }, + { + description: "insertParagraph at end of a listitem", + editorInnerHTML: "<ul><li>abcdef[]</li></ul>", + run: (win, doc, editingHost) => { + doc.execCommand("insertParagraph"); + }, + }, + { + description: "insertLineBreak at start of a paragraph", + editorInnerHTML: "<p>[]abcdef</p>", + run: (win, doc, editingHost) => { + doc.execCommand("insertLineBreak"); + }, + }, + { + description: "insertLineBreak at middle of a paragraph", + editorInnerHTML: "<p>abc[]def</p>", + run: (win, doc, editingHost) => { + doc.execCommand("insertLineBreak"); + }, + }, + { + description: "insertLineBreak at end of a paragraph", + editorInnerHTML: "<p>abcdef[]</p>", + run: (win, doc, editingHost) => { + doc.execCommand("insertLineBreak"); + }, + }, + { + description: "insertLineBreak at start of a listitem", + editorInnerHTML: "<ul><li>[]abcdef</li></ul>", + run: (win, doc, editingHost) => { + doc.execCommand("insertLineBreak"); + }, + }, + { + description: "insertLineBreak at middle of a listitem", + editorInnerHTML: "<ul><li>abc[]def</li></ul>", + run: (win, doc, editingHost) => { + doc.execCommand("insertLineBreak"); + }, + }, + { + description: "insertLineBreak at end of a listitem", + editorInnerHTML: "<ul><li>abcdef[]</li></ul>", + run: (win, doc, editingHost) => { + doc.execCommand("insertLineBreak"); + }, + }, + { + description: "delete at start of second paragraph", + editorInnerHTML: "<p>abc</p><p>[]def</p>", + run: (win, doc, editingHost) => { + doc.execCommand("delete"); + } + }, + { + description: "forwarddelete at end of first paragraph", + editorInnerHTML: "<p>abc[]</p><p>def</p>", + run: (win, doc, editingHost) => { + doc.execCommand("forwarddelete"); + } + }, + { + description: "delete at start of second paragraph starting with an emoji", + editorInnerHTML: "<p>abc\uD83D\uDC49</p><p>[]\uD83D\uDC48def</p>", + run: (win, doc, editingHost) => { + doc.execCommand("delete"); + } + }, + { + description: "forwarddelete at end of first paragraph ending with an emoji", + editorInnerHTML: "<p>abc\uD83D\uDC49[]</p><p>\uD83D\uDC48def</p>", + run: (win, doc, editingHost) => { + doc.execCommand("forwarddelete"); + } + }, +]; + +for (const curTest of tests) { + promise_test(async t => { + await new Promise(resolve => { + iframe.addEventListener("load", resolve, {once: true}); + iframe.srcdoc = "<html><body><div contenteditable></div></body></html>"; + }); + const contentDocument = iframe.contentDocument; + const contentWindow = iframe.contentWindow; + contentWindow.focus(); + const editingHost = contentDocument.querySelector("div[contenteditable]"); + const utils = new EditorTestUtils(editingHost, window); + utils.setupEditingHost(curTest.editorInnerHTML); + contentDocument.documentElement.scrollHeight; // flush pending things + if (typeof curTest.init == "function") { + await curTest.init(contentWindow, contentDocument, editingHost); + } + const initialValue = editingHost.innerHTML; + await curTest.run(contentWindow, contentDocument, editingHost); + const newValue = editingHost.innerHTML; + test(t2 => { + const ret = contentDocument.execCommand("undo"); + if (curTest.expectedUndoResult !== undefined) { + if (typeof curTest.expectedUndoResult == "string") { + assert_equals( + editingHost.innerHTML, + curTest.expectedUndoResult, + `${t2.name}: should restore the innerHTML value` + ); + } else { + assert_in_array( + editingHost.innerHTML, + curTest.expectedUndoResult, + `${t2.name}: should restore one of the innerHTML values` + ); + } + } else { + assert_equals( + editingHost.innerHTML, + initialValue, + `${t2.name}: should restore the initial innerHTML value` + ); + } + assert_true(ret, `${t2.name}: execCommand("undo") should return true`); + }, `${t.name} - first undo`); + test(t3 => { + const ret = contentDocument.execCommand("redo"); + assert_equals( + editingHost.innerHTML, + newValue, + `${t3.name}: should restore the modified innerHTML value` + ); + assert_true(ret, `${t3.name}: execCommand("redo") should return true`); + }, `${curTest.description} - first redo`); + test(t4 => { + const ret = contentDocument.execCommand("redo"); + assert_equals( + editingHost.innerHTML, + newValue, + `${t4.name}: should not modify the modified innerHTML value` + ); + assert_false(ret, `${t4.name}: execCommand("redo") should return false`); + }, `${curTest.description} - second redo`); + if (typeof curTest.cleanUp == "function") { + await curTest.cleanUp(contentWindow, contentDocument, editingHost); + } + iframe.srcdoc = ""; + contentDocument.documentElement.scrollHeight; // flush pending things + await new Promise(resolve => + requestAnimationFrame( + () => requestAnimationFrame(resolve) + ) + ); + }, curTest.description); +} +</script>
diff --git a/third_party/blink/web_tests/external/wpt/html/semantics/interactive-elements/the-dialog-element/inertness-with-modal-dialogs-and-iframes.html b/third_party/blink/web_tests/external/wpt/html/semantics/interactive-elements/the-dialog-element/inertness-with-modal-dialogs-and-iframes.html new file mode 100644 index 0000000..ea7d46f9 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/html/semantics/interactive-elements/the-dialog-element/inertness-with-modal-dialogs-and-iframes.html
@@ -0,0 +1,132 @@ +<!DOCTYPE html> +<meta charset="utf-8" /> +<title>Inertness with modal dialogs and iframes</title> +<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#inert"> +<meta name="assert" content="Checks that a modal dialog marks outer nodes as inert, + but only in its document, not in the parent browsing context. + Also, when an iframe is marked as inert by a modal dialog, + all contents in the nested browsing context are marked as inert too."> +<div id="log"></div> +<div id="wrapper"> + (main document: outer text) + <iframe id="outerIframe" srcdoc=" + <div id='wrapper'> + (outer iframe: outer text) + <dialog id='dialog' style='display: block'> + (outer iframe: dialog) + </dialog> + </div> + "></iframe> + <dialog id="dialog" style="display: block"> + (main document: dialog) + <iframe id="innerIframe" srcdoc=" + <div id='wrapper'> + (inner iframe: outer text) + <dialog id='dialog' style='display: block'> + (inner iframe: dialog) + </dialog> + </div> + "></iframe> + </dialog> +</div> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +const innerIframeWindow = innerIframe.contentWindow; +const outerIframeWindow = outerIframe.contentWindow; +promise_setup(async () => { + for (let global of [innerIframeWindow, outerIframeWindow]) { + if (global.location.href === "about:blank" || + global.document.readyState !== "complete") { + await new Promise(resolve => { + global.frameElement.addEventListener("load", resolve, {once: true}); + }); + } + } +}); +add_completion_callback(() => { + for (let global of [window, innerIframeWindow, outerIframeWindow]) { + global.getSelection().removeAllRanges(); + } +}); + +function checkSelection(global, expectedText) { + const selection = global.getSelection(); + selection.selectAllChildren(global.wrapper); + + // Remove whitespace between parentheses since it varies among browsers, + // but that's not relevant to this test. + const actualText = selection.toString().replace(/\)\s*\(/g, ")(").trim(); + assert_equals(actualText, expectedText); +} + +function showModals(test, globals) { + for (let global of globals) { + global.dialog.showModal(); + test.add_cleanup(() => { global.dialog.close(); }); + } +} + +promise_test(async function() { + checkSelection(window, "(main document: outer text)(main document: dialog)"); + checkSelection(innerIframeWindow, "(inner iframe: outer text)(inner iframe: dialog)"); + checkSelection(outerIframeWindow, "(outer iframe: outer text)(outer iframe: dialog)"); +}, "Initially, no node is inert"); + +promise_test(async function() { + showModals(this, [outerIframeWindow]); + + checkSelection(window, "(main document: outer text)(main document: dialog)"); + checkSelection(innerIframeWindow, "(inner iframe: outer text)(inner iframe: dialog)"); + checkSelection(outerIframeWindow, "(outer iframe: dialog)"); +}, "Modal dialog in the outer iframe marks outer nodes in that iframe as inert."); + +promise_test(async function() { + showModals(this, [innerIframeWindow]); + + checkSelection(window, "(main document: outer text)(main document: dialog)"); + checkSelection(innerIframeWindow, "(inner iframe: dialog)"); + checkSelection(outerIframeWindow, "(outer iframe: outer text)(outer iframe: dialog)"); +}, "Modal dialog in the inner iframe marks outer nodes in that iframe as inert."); + +promise_test(async function() { + showModals(this, [innerIframeWindow, outerIframeWindow]); + + checkSelection(window, "(main document: outer text)(main document: dialog)"); + checkSelection(innerIframeWindow, "(inner iframe: dialog)"); + checkSelection(outerIframeWindow, "(outer iframe: dialog)"); +}, "Modal dialogs in both iframes mark outer nodes in these iframes as inert."); + +promise_test(async function() { + showModals(this, [window]); + + checkSelection(window, "(main document: dialog)"); + checkSelection(innerIframeWindow, "(inner iframe: outer text)(inner iframe: dialog)"); + checkSelection(outerIframeWindow, ""); +}, "Modal dialog in the main document marks outer nodes as inert. All contents of the outer iframe are also marked as inert."); + +promise_test(async function() { + showModals(this, [innerIframeWindow, window]); + + checkSelection(window, "(main document: dialog)"); + checkSelection(innerIframeWindow, "(inner iframe: dialog)"); + checkSelection(outerIframeWindow, ""); +}, "Modal dialogs in the main document and inner iframe mark outer nodes as inert. All contents of the outer iframe are also marked as inert."); + +promise_test(async function() { + showModals(this, [outerIframeWindow, window]); + + checkSelection(window, "(main document: dialog)"); + checkSelection(innerIframeWindow, "(inner iframe: outer text)(inner iframe: dialog)"); + checkSelection(outerIframeWindow, ""); +}, "Modal dialogs in the main document and outer iframe mark outer nodes as inert. All contents of the outer iframe are also marked as inert."); + +promise_test(async function() { + showModals(this, [innerIframeWindow, outerIframeWindow, window]); + + checkSelection(window, "(main document: dialog)"); + checkSelection(innerIframeWindow, "(inner iframe: dialog)"); + checkSelection(outerIframeWindow, ""); +}, "Modal dialogs in the main document and both iframes mark outer nodes as inert. All contents of the outer iframe are also marked as inert."); +</script>
diff --git a/third_party/blink/web_tests/external/wpt/inert/dynamic-inert-on-focused-element.tentative.html b/third_party/blink/web_tests/external/wpt/inert/dynamic-inert-on-focused-element.tentative.html new file mode 100644 index 0000000..42b6e219 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/inert/dynamic-inert-on-focused-element.tentative.html
@@ -0,0 +1,72 @@ +<!DOCTYPE html> +<meta charset="utf-8" /> +<title>Dynamic inertness on focused element</title> +<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#focus-fixup-rule"> +<meta name="assert" content="If a focused element becomes expressly inert, it stops being focused."> +<div id="log"></div> + +<div class="test-wrapper" data-name="<input> that gets 'inert' attribute"> + <input class="becomes-inert check-focus"> +</div> + +<div class="test-wrapper" data-name="<input> whose parent gets 'inert' attribute"> + <div class="becomes-inert"> + <input class="check-focus"> + </div> +</div> + +<div class="test-wrapper" data-name="<button> that gets 'inert' attribute"> + <button class="becomes-inert check-focus">foo</button> +</div> + +<div class="test-wrapper" data-name="<div> that gets 'inert' attribute"> + <div class="becomes-inert check-focus" tabindex="-1"></div> +</div> + +<div class="test-wrapper" data-name="<div> whose parent gets 'inert' attribute"> + <div class="becomes-inert"> + <div class="check-focus" tabindex="-1">bar</div> + </div> +</div> + +<div class="test-wrapper" data-name="<div> whose grandparent gets 'inert' attribute"> + <div class="becomes-inert"> + <p> + <span class="check-focus" tabindex="-1">baz</span> + </p> + </div> +</div> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +function nextRepaint() { + return new Promise(resolve => { + requestAnimationFrame(() => { + requestAnimationFrame(resolve); + }); + }); +} + +const loaded = new Promise(resolve => { + addEventListener("load", resolve, {once: true}); +}); +promise_setup(() => loaded); + +for (const testWrapper of document.querySelectorAll(".test-wrapper")) { + const becomesInert = testWrapper.querySelector(".becomes-inert"); + const checkFocus = testWrapper.querySelector(".check-focus"); + promise_test(async function() { + checkFocus.focus(); + assert_equals(document.activeElement, checkFocus, "The element is focused"); + + becomesInert.inert = true; + + // The focus fixup rule should blur the element since it's no longer focusable. + // In Chromium this happens after a repaint (https://crbug.com/1275097). + await nextRepaint(); + assert_equals(document.activeElement, document.body, "The element stops being focused"); + }, testWrapper.dataset.name); +} +</script>
diff --git a/third_party/blink/web_tests/external/wpt/interfaces/css-cascade-5.idl b/third_party/blink/web_tests/external/wpt/interfaces/css-cascade-5.idl new file mode 100644 index 0000000..c640a13 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/interfaces/css-cascade-5.idl
@@ -0,0 +1,11 @@ +// Source: CSS Cascading and Inheritance Level 5 (https://drafts.csswg.org/css-cascade-5/) + +[Exposed=Window] +interface CSSLayerBlockRule : CSSGroupingRule { + readonly attribute CSSOMString name; +}; + +[Exposed=Window] +interface CSSLayerStatementRule : CSSRule { + readonly attribute FrozenArray<CSSOMString> nameList; +};
diff --git a/third_party/blink/web_tests/fast/scrolling/events/overscroll-event-fired-to-document.html b/third_party/blink/web_tests/fast/scrolling/events/overscroll-event-fired-to-document.html index 75af1fa..cc90e468 100644 --- a/third_party/blink/web_tests/fast/scrolling/events/overscroll-event-fired-to-document.html +++ b/third_party/blink/web_tests/fast/scrolling/events/overscroll-event-fired-to-document.html
@@ -32,6 +32,11 @@ var x = rect.left + rect.width / 2; var y = rect.top + rect.height / 2; +const defaultPixelsToScroll = 800; +const { x: pixelsToScrollX, y: pixelsToScrollY } = calculatePixelsToScroll( + target_div, defaultPixelsToScroll, defaultPixelsToScroll +); + // SPEED_INSTANT doesn't work here because tests are timing out. // This could actually be a bug in how the overscroll event is computed. // Possible explanation on what happens is that "leftover" delta from a single @@ -39,10 +44,11 @@ // and the full delta is overscroll do we dispatch the event. // When the speed is INSTANT we'll put the entire scrolling delta into a single // event so we don't generate an overscroll event in that case. -const pixelsPerSec = 2000; -const pixelsToScroll = 600; -const { x: pixelsToScrollX, y: pixelsToScrollY } = calculatePixelsToScroll( - target_div, pixelsToScroll, pixelsToScroll +// Additionally, we are adjusting the scroll speed to prevent timeout when +// percent-based scrolling is enabled. Since the x/y scroll amount is the same +// we are using only pixelsToScrollX to scale the scroll speed. +const pixelsScrolledPerSec = scaleScrollSpeedToPercentBasedScrollingIfNeeded( + 2000 /* pixels per second */, defaultPixelsToScroll, pixelsToScrollX ); var overscrolled_x_delta = 0; @@ -64,7 +70,7 @@ // Scroll up on target div and wait for the doc to get overscroll event. await smoothScroll( - pixelsToScrollY, x, y, source_device, "up", pixelsPerSec, + pixelsToScrollY, x, y, source_device, "up", pixelsScrolledPerSec, precise_scrolling_delta ); await waitFor(() => { return overscrolled_y_delta < 0; }, @@ -73,7 +79,7 @@ // Scroll left on target div and wait for the doc to get overscroll event. await smoothScroll( - pixelsToScrollX, x, y, source_device, "left", pixelsPerSec, + pixelsToScrollX, x, y, source_device, "left", pixelsScrolledPerSec, precise_scrolling_delta ); await waitFor(() => { return overscrolled_x_delta < 0; },
diff --git a/third_party/blink/web_tests/fast/scrolling/events/overscroll-event-fired-to-element-with-overscroll-behavior.html b/third_party/blink/web_tests/fast/scrolling/events/overscroll-event-fired-to-element-with-overscroll-behavior.html index 6094796..071dc3a 100644 --- a/third_party/blink/web_tests/fast/scrolling/events/overscroll-event-fired-to-element-with-overscroll-behavior.html +++ b/third_party/blink/web_tests/fast/scrolling/events/overscroll-event-fired-to-element-with-overscroll-behavior.html
@@ -51,6 +51,11 @@ var x = rect.left + rect.width / 2; var y = rect.top + rect.height / 2; +const defaultPixelsToScroll = 800; +const { x: pixelsToScrollX, y: pixelsToScrollY } = calculatePixelsToScroll( + target_div, defaultPixelsToScroll, defaultPixelsToScroll +); + // SPEED_INSTANT doesn't work here because tests are timing out. // This could actually be a bug in how the overscroll event is computed. // Possible explanation on what happens is that "leftover" delta from a single @@ -58,10 +63,11 @@ // and the full delta is overscroll do we dispatch the event. // When the speed is INSTANT we'll put the entire scrolling delta into a single // event so we don't generate an overscroll event in that case. -const pixelsPerSec = 2000; -const pixelsToScroll = 600; -const { x: pixelsToScrollX, y: pixelsToScrollY } = calculatePixelsToScroll( - target_div, pixelsToScroll, pixelsToScroll +// Additionally, we are adjusting the scroll speed to prevent timeout when +// percent-based scrolling is enabled. Since the x/y scroll amount is the same +// we are using only pixelsToScrollX to scale the scroll speed. +const pixelsScrolledPerSec = scaleScrollSpeedToPercentBasedScrollingIfNeeded( + 2000 /* pixels per second */, defaultPixelsToScroll, pixelsToScrollX ); var overscrolled_x_delta = 0; @@ -90,7 +96,7 @@ // Scroll up on target div and wait for the element with overscroll-y to get // overscroll event. await smoothScroll( - pixelsToScrollY, x, y, source_device, "up", pixelsPerSec, + pixelsToScrollY, x, y, source_device, "up", pixelsScrolledPerSec, precise_scrolling_delta ); await waitFor(() => { return overscrolled_y_delta < 0; }, @@ -101,7 +107,7 @@ // Scroll left on target div and wait for the element with overscroll-x to // get overscroll event. await smoothScroll( - pixelsToScrollX, x, y, source_device, "left", pixelsPerSec, + pixelsToScrollX, x, y, source_device, "left", pixelsScrolledPerSec, precise_scrolling_delta ); await waitFor(() => { return overscrolled_x_delta < 0; },
diff --git a/third_party/blink/web_tests/fast/scrolling/events/overscroll-event-fired-to-scrolled-element.html b/third_party/blink/web_tests/fast/scrolling/events/overscroll-event-fired-to-scrolled-element.html index 9e163e3..63a0542 100644 --- a/third_party/blink/web_tests/fast/scrolling/events/overscroll-event-fired-to-scrolled-element.html +++ b/third_party/blink/web_tests/fast/scrolling/events/overscroll-event-fired-to-scrolled-element.html
@@ -32,6 +32,11 @@ var x = rect.left + rect.width / 2; var y = rect.top + rect.height / 2; +const defaultPixelsToScroll = 800; +const { x: pixelsToScrollX, y: pixelsToScrollY } = calculatePixelsToScroll( + scrolling_div, defaultPixelsToScroll, defaultPixelsToScroll +); + // SPEED_INSTANT doesn't work here because tests are timing out. // This could actually be a bug in how the overscroll event is computed. // Possible explanation on what happens is that "leftover" delta from a single @@ -39,10 +44,11 @@ // and the full delta is overscroll do we dispatch the event. // When the speed is INSTANT we'll put the entire scrolling delta into a single // event so we don't generate an overscroll event in that case. -const pixelsPerSec = 2000; -const pixelsToScroll = 800; -const { x: pixelsToScrollX, y: pixelsToScrollY } = calculatePixelsToScroll( - scrolling_div, pixelsToScroll, pixelsToScroll +// Additionally, we are adjusting the scroll speed to prevent timeout when the +// percent-based scrolling is enabled. Since the x/y scroll amount is the same +// we are using only pixelsToScrollX to scale the scroll speed. +const pixelsScrolledPerSec = scaleScrollSpeedToPercentBasedScrollingIfNeeded( + 2000 /* pixels per second */, defaultPixelsToScroll, pixelsToScrollX ); var overscrolled_x_delta = 0; @@ -64,28 +70,28 @@ // Do a horizontal scroll and wait for overscroll event. await smoothScroll( - pixelsToScrollX, x, y, source_device, "right", pixelsPerSec, + pixelsToScrollX, x, y, source_device, "right", pixelsScrolledPerSec, precise_scrolling_delta ); await waitFor(() => { return overscrolled_x_delta > 0; }, 'Scroller did not receive overscroll event after horizontal scroll.'); await waitForAnimationEndTimeBased(() => { return scrolling_div.scrollLeft }); assert_equals(scrolling_div.scrollWidth - scrolling_div.scrollLeft, - scrolling_div.clientWidth); + scrolling_div.clientWidth); overscrolled_x_delta = 0; overscrolled_y_delta = 0; // Do a vertical scroll and wait for overscroll event. await smoothScroll( - pixelsToScrollY, x, y, source_device, "down", pixelsPerSec, + pixelsToScrollY, x, y, source_device, "down", pixelsScrolledPerSec, precise_scrolling_delta ); await waitFor(() => { return overscrolled_y_delta > 0; }, 'Scroller did not receive overscroll event after vertical scroll.'); await waitForAnimationEndTimeBased(() => { return scrolling_div.scrollTop }); assert_equals(scrolling_div.scrollHeight - scrolling_div.scrollTop, - scrolling_div.clientHeight); + scrolling_div.clientHeight); } promise_test (async (t) => {
diff --git a/third_party/blink/web_tests/fast/scrolling/events/overscroll-event-fired-to-window.html b/third_party/blink/web_tests/fast/scrolling/events/overscroll-event-fired-to-window.html index a152734..0e62c24b 100644 --- a/third_party/blink/web_tests/fast/scrolling/events/overscroll-event-fired-to-window.html +++ b/third_party/blink/web_tests/fast/scrolling/events/overscroll-event-fired-to-window.html
@@ -32,6 +32,11 @@ var x = rect.left + rect.width / 2; var y = rect.top + rect.height / 2; +const defaultPixelsToScroll = 800; +const { y: pixelsToScrollY } = calculatePixelsToScroll( + target_div, defaultPixelsToScroll, defaultPixelsToScroll +); + // SPEED_INSTANT doesn't work here because tests are timing out. // This could actually be a bug in how the overscroll event is computed. // Possible explanation on what happens is that "leftover" delta from a single @@ -39,10 +44,10 @@ // and the full delta is overscroll do we dispatch the event. // When the speed is INSTANT we'll put the entire scrolling delta into a single // event so we don't generate an overscroll event in that case. -const pixelsPerSec = 2000; -const pixelsToScroll = 600; -const { y: pixelsToScrollY } = calculatePixelsToScroll( - target_div, pixelsToScroll, pixelsToScroll +// Additionally, we are adjusting the scroll speed to prevent timeout when +// percent-based scrolling is enabled. +const pixelsScrolledPerSec = scaleScrollSpeedToPercentBasedScrollingIfNeeded( + 2000 /* pixels per second */, defaultPixelsToScroll, pixelsToScrollY ); var window_received_overscroll = false; @@ -62,7 +67,7 @@ // Scroll up on target div and wait for the window to get overscroll event. await smoothScroll( - pixelsToScrollY, x, y, source_device, "up", pixelsPerSec, + pixelsToScrollY, x, y, source_device, "up", pixelsScrolledPerSec, precise_scrolling_delta ); await waitFor(() => { return window_received_overscroll; },
diff --git a/third_party/blink/web_tests/flag-specific/composite-after-paint/external/wpt/url/toascii.window-expected.txt b/third_party/blink/web_tests/flag-specific/composite-after-paint/external/wpt/url/toascii.window-expected.txt deleted file mode 100644 index 9229523..0000000 --- a/third_party/blink/web_tests/flag-specific/composite-after-paint/external/wpt/url/toascii.window-expected.txt +++ /dev/null
@@ -1,356 +0,0 @@ -This is a testharness.js-based test. -Found 352 tests; 198 PASS, 154 FAIL, 0 TIMEOUT, 0 NOTRUN. -PASS Loading data… -PASS aa-- (using URL) -PASS aa-- (using URL.host) -PASS aa-- (using URL.hostname) -PASS aa-- (using <a>) -PASS aa-- (using <a>.host) -PASS aa-- (using <a>.hostname) -PASS aa-- (using <area>) -PASS aa-- (using <area>.host) -PASS aa-- (using <area>.hostname) -PASS a†-- (using URL) -PASS a†-- (using URL.host) -PASS a†-- (using URL.hostname) -PASS a†-- (using <a>) -PASS a†-- (using <a>.host) -PASS a†-- (using <a>.hostname) -PASS a†-- (using <area>) -PASS a†-- (using <area>.host) -PASS a†-- (using <area>.hostname) -PASS ab--c (using URL) -PASS ab--c (using URL.host) -PASS ab--c (using URL.hostname) -PASS ab--c (using <a>) -PASS ab--c (using <a>.host) -PASS ab--c (using <a>.hostname) -PASS ab--c (using <area>) -PASS ab--c (using <area>.host) -PASS ab--c (using <area>.hostname) -PASS -x (using URL) -PASS -x (using URL.host) -PASS -x (using URL.hostname) -PASS -x (using <a>) -PASS -x (using <a>.host) -PASS -x (using <a>.hostname) -PASS -x (using <area>) -PASS -x (using <area>.host) -PASS -x (using <area>.hostname) -PASS -† (using URL) -PASS -† (using URL.host) -PASS -† (using URL.hostname) -PASS -† (using <a>) -PASS -† (using <a>.host) -PASS -† (using <a>.hostname) -PASS -† (using <area>) -PASS -† (using <area>.host) -PASS -† (using <area>.hostname) -PASS -x.xn--zca (using URL) -PASS -x.xn--zca (using URL.host) -PASS -x.xn--zca (using URL.hostname) -PASS -x.xn--zca (using <a>) -PASS -x.xn--zca (using <a>.host) -PASS -x.xn--zca (using <a>.hostname) -PASS -x.xn--zca (using <area>) -PASS -x.xn--zca (using <area>.host) -PASS -x.xn--zca (using <area>.hostname) -FAIL -x.ß (using URL) assert_equals: expected "-x.xn--zca" but got "-x.ss" -FAIL -x.ß (using URL.host) assert_equals: expected "-x.xn--zca" but got "-x.ss" -FAIL -x.ß (using URL.hostname) assert_equals: expected "-x.xn--zca" but got "-x.ss" -FAIL -x.ß (using <a>) assert_equals: expected "-x.xn--zca" but got "-x.ss" -FAIL -x.ß (using <a>.host) assert_equals: expected "-x.xn--zca" but got "-x.ss" -FAIL -x.ß (using <a>.hostname) assert_equals: expected "-x.xn--zca" but got "-x.ss" -FAIL -x.ß (using <area>) assert_equals: expected "-x.xn--zca" but got "-x.ss" -FAIL -x.ß (using <area>.host) assert_equals: expected "-x.xn--zca" but got "-x.ss" -FAIL -x.ß (using <area>.hostname) assert_equals: expected "-x.xn--zca" but got "-x.ss" -PASS x-.xn--zca (using URL) -PASS x-.xn--zca (using URL.host) -PASS x-.xn--zca (using URL.hostname) -PASS x-.xn--zca (using <a>) -PASS x-.xn--zca (using <a>.host) -PASS x-.xn--zca (using <a>.hostname) -PASS x-.xn--zca (using <area>) -PASS x-.xn--zca (using <area>.host) -PASS x-.xn--zca (using <area>.hostname) -FAIL x-.ß (using URL) assert_equals: expected "x-.xn--zca" but got "x-.ss" -FAIL x-.ß (using URL.host) assert_equals: expected "x-.xn--zca" but got "x-.ss" -FAIL x-.ß (using URL.hostname) assert_equals: expected "x-.xn--zca" but got "x-.ss" -FAIL x-.ß (using <a>) assert_equals: expected "x-.xn--zca" but got "x-.ss" -FAIL x-.ß (using <a>.host) assert_equals: expected "x-.xn--zca" but got "x-.ss" -FAIL x-.ß (using <a>.hostname) assert_equals: expected "x-.xn--zca" but got "x-.ss" -FAIL x-.ß (using <area>) assert_equals: expected "x-.xn--zca" but got "x-.ss" -FAIL x-.ß (using <area>.host) assert_equals: expected "x-.xn--zca" but got "x-.ss" -FAIL x-.ß (using <area>.hostname) assert_equals: expected "x-.xn--zca" but got "x-.ss" -PASS x..xn--zca (using URL) -PASS x..xn--zca (using URL.host) -PASS x..xn--zca (using URL.hostname) -PASS x..xn--zca (using <a>) -PASS x..xn--zca (using <a>.host) -PASS x..xn--zca (using <a>.hostname) -PASS x..xn--zca (using <area>) -PASS x..xn--zca (using <area>.host) -PASS x..xn--zca (using <area>.hostname) -FAIL x..ß (using URL) assert_equals: expected "x..xn--zca" but got "x..ss" -FAIL x..ß (using URL.host) assert_equals: expected "x..xn--zca" but got "x..ss" -FAIL x..ß (using URL.hostname) assert_equals: expected "x..xn--zca" but got "x..ss" -FAIL x..ß (using <a>) assert_equals: expected "x..xn--zca" but got "x..ss" -FAIL x..ß (using <a>.host) assert_equals: expected "x..xn--zca" but got "x..ss" -FAIL x..ß (using <a>.hostname) assert_equals: expected "x..xn--zca" but got "x..ss" -FAIL x..ß (using <area>) assert_equals: expected "x..xn--zca" but got "x..ss" -FAIL x..ß (using <area>.host) assert_equals: expected "x..xn--zca" but got "x..ss" -FAIL x..ß (using <area>.hostname) assert_equals: expected "x..xn--zca" but got "x..ss" -FAIL xn--a (using URL) assert_throws_js: function "() => makeURL("url", hostTest.input)" did not throw -FAIL xn--a (using URL.host) assert_equals: expected "x" but got "xn--a" -FAIL xn--a (using URL.hostname) assert_equals: expected "x" but got "xn--a" -FAIL xn--a (using <a>) assert_equals: expected "" but got "xn--a" -FAIL xn--a (using <a>.host) assert_equals: expected "x" but got "xn--a" -FAIL xn--a (using <a>.hostname) assert_equals: expected "x" but got "xn--a" -FAIL xn--a (using <area>) assert_equals: expected "" but got "xn--a" -FAIL xn--a (using <area>.host) assert_equals: expected "x" but got "xn--a" -FAIL xn--a (using <area>.hostname) assert_equals: expected "x" but got "xn--a" -FAIL xn--a.xn--zca (using URL) assert_throws_js: function "() => makeURL("url", hostTest.input)" did not throw -FAIL xn--a.xn--zca (using URL.host) assert_equals: expected "x" but got "xn--a.xn--zca" -FAIL xn--a.xn--zca (using URL.hostname) assert_equals: expected "x" but got "xn--a.xn--zca" -FAIL xn--a.xn--zca (using <a>) assert_equals: expected "" but got "xn--a.xn--zca" -FAIL xn--a.xn--zca (using <a>.host) assert_equals: expected "x" but got "xn--a.xn--zca" -FAIL xn--a.xn--zca (using <a>.hostname) assert_equals: expected "x" but got "xn--a.xn--zca" -FAIL xn--a.xn--zca (using <area>) assert_equals: expected "" but got "xn--a.xn--zca" -FAIL xn--a.xn--zca (using <area>.host) assert_equals: expected "x" but got "xn--a.xn--zca" -FAIL xn--a.xn--zca (using <area>.hostname) assert_equals: expected "x" but got "xn--a.xn--zca" -PASS xn--a.ß (using URL) -PASS xn--a.ß (using URL.host) -PASS xn--a.ß (using URL.hostname) -FAIL xn--a.ß (using <a>) assert_equals: expected "https://xn--a.ß/x" but got "https://xn--a.%C3%9F/x" -PASS xn--a.ß (using <a>.host) -PASS xn--a.ß (using <a>.hostname) -FAIL xn--a.ß (using <area>) assert_equals: expected "https://xn--a.ß/x" but got "https://xn--a.%C3%9F/x" -PASS xn--a.ß (using <area>.host) -PASS xn--a.ß (using <area>.hostname) -PASS xn--tešla (using URL) -PASS xn--tešla (using URL.host) -PASS xn--tešla (using URL.hostname) -FAIL xn--tešla (using <a>) assert_equals: expected "https://xn--tešla/x" but got "https://xn--te%C5%A1la/x" -PASS xn--tešla (using <a>.host) -PASS xn--tešla (using <a>.hostname) -FAIL xn--tešla (using <area>) assert_equals: expected "https://xn--tešla/x" but got "https://xn--te%C5%A1la/x" -PASS xn--tešla (using <area>.host) -PASS xn--tešla (using <area>.hostname) -PASS xn--zca.xn--zca (using URL) -PASS xn--zca.xn--zca (using URL.host) -PASS xn--zca.xn--zca (using URL.hostname) -PASS xn--zca.xn--zca (using <a>) -PASS xn--zca.xn--zca (using <a>.host) -PASS xn--zca.xn--zca (using <a>.hostname) -PASS xn--zca.xn--zca (using <area>) -PASS xn--zca.xn--zca (using <area>.host) -PASS xn--zca.xn--zca (using <area>.hostname) -FAIL xn--zca.ß (using URL) assert_equals: expected "xn--zca.xn--zca" but got "xn--zca.ss" -FAIL xn--zca.ß (using URL.host) assert_equals: expected "xn--zca.xn--zca" but got "xn--zca.ss" -FAIL xn--zca.ß (using URL.hostname) assert_equals: expected "xn--zca.xn--zca" but got "xn--zca.ss" -FAIL xn--zca.ß (using <a>) assert_equals: expected "xn--zca.xn--zca" but got "xn--zca.ss" -FAIL xn--zca.ß (using <a>.host) assert_equals: expected "xn--zca.xn--zca" but got "xn--zca.ss" -FAIL xn--zca.ß (using <a>.hostname) assert_equals: expected "xn--zca.xn--zca" but got "xn--zca.ss" -FAIL xn--zca.ß (using <area>) assert_equals: expected "xn--zca.xn--zca" but got "xn--zca.ss" -FAIL xn--zca.ß (using <area>.host) assert_equals: expected "xn--zca.xn--zca" but got "xn--zca.ss" -FAIL xn--zca.ß (using <area>.hostname) assert_equals: expected "xn--zca.xn--zca" but got "xn--zca.ss" -PASS ab--c.xn--zca (using URL) -PASS ab--c.xn--zca (using URL.host) -PASS ab--c.xn--zca (using URL.hostname) -PASS ab--c.xn--zca (using <a>) -PASS ab--c.xn--zca (using <a>.host) -PASS ab--c.xn--zca (using <a>.hostname) -PASS ab--c.xn--zca (using <area>) -PASS ab--c.xn--zca (using <area>.host) -PASS ab--c.xn--zca (using <area>.hostname) -FAIL ab--c.ß (using URL) assert_equals: expected "ab--c.xn--zca" but got "ab--c.ss" -FAIL ab--c.ß (using URL.host) assert_equals: expected "ab--c.xn--zca" but got "ab--c.ss" -FAIL ab--c.ß (using URL.hostname) assert_equals: expected "ab--c.xn--zca" but got "ab--c.ss" -FAIL ab--c.ß (using <a>) assert_equals: expected "ab--c.xn--zca" but got "ab--c.ss" -FAIL ab--c.ß (using <a>.host) assert_equals: expected "ab--c.xn--zca" but got "ab--c.ss" -FAIL ab--c.ß (using <a>.hostname) assert_equals: expected "ab--c.xn--zca" but got "ab--c.ss" -FAIL ab--c.ß (using <area>) assert_equals: expected "ab--c.xn--zca" but got "ab--c.ss" -FAIL ab--c.ß (using <area>.host) assert_equals: expected "ab--c.xn--zca" but got "ab--c.ss" -FAIL ab--c.ß (using <area>.hostname) assert_equals: expected "ab--c.xn--zca" but got "ab--c.ss" -FAIL .example (using URL) assert_throws_js: function "() => makeURL("url", hostTest.input)" did not throw -FAIL .example (using URL.host) assert_equals: expected "x" but got ".example" -FAIL .example (using URL.hostname) assert_equals: expected "x" but got ".example" -FAIL .example (using <a>) assert_equals: expected "" but got ".example" -FAIL .example (using <a>.host) assert_equals: expected "x" but got ".example" -FAIL .example (using <a>.hostname) assert_equals: expected "x" but got ".example" -FAIL .example (using <area>) assert_equals: expected "" but got ".example" -FAIL .example (using <area>.host) assert_equals: expected "x" but got ".example" -FAIL .example (using <area>.hostname) assert_equals: expected "x" but got ".example" -FAIL xn--1ug.example (using URL) assert_throws_js: function "() => makeURL("url", hostTest.input)" did not throw -FAIL xn--1ug.example (using URL.host) assert_equals: expected "x" but got "xn--1ug.example" -FAIL xn--1ug.example (using URL.hostname) assert_equals: expected "x" but got "xn--1ug.example" -FAIL xn--1ug.example (using <a>) assert_equals: expected "" but got "xn--1ug.example" -FAIL xn--1ug.example (using <a>.host) assert_equals: expected "x" but got "xn--1ug.example" -FAIL xn--1ug.example (using <a>.hostname) assert_equals: expected "x" but got "xn--1ug.example" -FAIL xn--1ug.example (using <area>) assert_equals: expected "" but got "xn--1ug.example" -FAIL xn--1ug.example (using <area>.host) assert_equals: expected "x" but got "xn--1ug.example" -FAIL xn--1ug.example (using <area>.hostname) assert_equals: expected "x" but got "xn--1ug.example" -PASS يa (using URL) -PASS يa (using URL.host) -PASS يa (using URL.hostname) -FAIL يa (using <a>) assert_equals: expected "https://يa/x" but got "https://%D9%8Aa/x" -PASS يa (using <a>.host) -PASS يa (using <a>.hostname) -FAIL يa (using <area>) assert_equals: expected "https://يa/x" but got "https://%D9%8Aa/x" -PASS يa (using <area>.host) -PASS يa (using <area>.hostname) -FAIL xn--a-yoc (using URL) assert_throws_js: function "() => makeURL("url", hostTest.input)" did not throw -FAIL xn--a-yoc (using URL.host) assert_equals: expected "x" but got "xn--a-yoc" -FAIL xn--a-yoc (using URL.hostname) assert_equals: expected "x" but got "xn--a-yoc" -FAIL xn--a-yoc (using <a>) assert_equals: expected "" but got "xn--a-yoc" -FAIL xn--a-yoc (using <a>.host) assert_equals: expected "x" but got "xn--a-yoc" -FAIL xn--a-yoc (using <a>.hostname) assert_equals: expected "x" but got "xn--a-yoc" -FAIL xn--a-yoc (using <area>) assert_equals: expected "" but got "xn--a-yoc" -FAIL xn--a-yoc (using <area>.host) assert_equals: expected "x" but got "xn--a-yoc" -FAIL xn--a-yoc (using <area>.hostname) assert_equals: expected "x" but got "xn--a-yoc" -FAIL ශ්රී (using URL) assert_equals: expected "xn--10cl1a0b660p" but got "xn--10cl1a0b" -FAIL ශ්රී (using URL.host) assert_equals: expected "xn--10cl1a0b660p" but got "xn--10cl1a0b" -FAIL ශ්රී (using URL.hostname) assert_equals: expected "xn--10cl1a0b660p" but got "xn--10cl1a0b" -FAIL ශ්රී (using <a>) assert_equals: expected "xn--10cl1a0b660p" but got "xn--10cl1a0b" -FAIL ශ්රී (using <a>.host) assert_equals: expected "xn--10cl1a0b660p" but got "xn--10cl1a0b" -FAIL ශ්රී (using <a>.hostname) assert_equals: expected "xn--10cl1a0b660p" but got "xn--10cl1a0b" -FAIL ශ්රී (using <area>) assert_equals: expected "xn--10cl1a0b660p" but got "xn--10cl1a0b" -FAIL ශ්රී (using <area>.host) assert_equals: expected "xn--10cl1a0b660p" but got "xn--10cl1a0b" -FAIL ශ්රී (using <area>.hostname) assert_equals: expected "xn--10cl1a0b660p" but got "xn--10cl1a0b" -FAIL نامهای (using URL) assert_equals: expected "xn--mgba3gch31f060k" but got "xn--mgba3gch31f" -FAIL نامهای (using URL.host) assert_equals: expected "xn--mgba3gch31f060k" but got "xn--mgba3gch31f" -FAIL نامهای (using URL.hostname) assert_equals: expected "xn--mgba3gch31f060k" but got "xn--mgba3gch31f" -FAIL نامهای (using <a>) assert_equals: expected "xn--mgba3gch31f060k" but got "xn--mgba3gch31f" -FAIL نامهای (using <a>.host) assert_equals: expected "xn--mgba3gch31f060k" but got "xn--mgba3gch31f" -FAIL نامهای (using <a>.hostname) assert_equals: expected "xn--mgba3gch31f060k" but got "xn--mgba3gch31f" -FAIL نامهای (using <area>) assert_equals: expected "xn--mgba3gch31f060k" but got "xn--mgba3gch31f" -FAIL نامهای (using <area>.host) assert_equals: expected "xn--mgba3gch31f060k" but got "xn--mgba3gch31f" -FAIL نامهای (using <area>.hostname) assert_equals: expected "xn--mgba3gch31f060k" but got "xn--mgba3gch31f" -PASS �.com (using URL) -PASS �.com (using URL.host) -PASS �.com (using URL.hostname) -FAIL �.com (using <a>) assert_equals: expected "https://\ufffd.com/x" but got "https://%EF%BF%BD.com/x" -PASS �.com (using <a>.host) -PASS �.com (using <a>.hostname) -FAIL �.com (using <area>) assert_equals: expected "https://\ufffd.com/x" but got "https://%EF%BF%BD.com/x" -PASS �.com (using <area>.host) -PASS �.com (using <area>.hostname) -FAIL xn--zn7c.com (using URL) assert_throws_js: function "() => makeURL("url", hostTest.input)" did not throw -FAIL xn--zn7c.com (using URL.host) assert_equals: expected "x" but got "xn--zn7c.com" -FAIL xn--zn7c.com (using URL.hostname) assert_equals: expected "x" but got "xn--zn7c.com" -FAIL xn--zn7c.com (using <a>) assert_equals: expected "" but got "xn--zn7c.com" -FAIL xn--zn7c.com (using <a>.host) assert_equals: expected "x" but got "xn--zn7c.com" -FAIL xn--zn7c.com (using <a>.hostname) assert_equals: expected "x" but got "xn--zn7c.com" -FAIL xn--zn7c.com (using <area>) assert_equals: expected "" but got "xn--zn7c.com" -FAIL xn--zn7c.com (using <area>.host) assert_equals: expected "x" but got "xn--zn7c.com" -FAIL xn--zn7c.com (using <area>.hostname) assert_equals: expected "x" but got "xn--zn7c.com" -PASS x01234567890123456789012345678901234567890123456789012345678901x (using URL) -PASS x01234567890123456789012345678901234567890123456789012345678901x (using URL.host) -PASS x01234567890123456789012345678901234567890123456789012345678901x (using URL.hostname) -PASS x01234567890123456789012345678901234567890123456789012345678901x (using <a>) -PASS x01234567890123456789012345678901234567890123456789012345678901x (using <a>.host) -PASS x01234567890123456789012345678901234567890123456789012345678901x (using <a>.hostname) -PASS x01234567890123456789012345678901234567890123456789012345678901x (using <area>) -PASS x01234567890123456789012345678901234567890123456789012345678901x (using <area>.host) -PASS x01234567890123456789012345678901234567890123456789012345678901x (using <area>.hostname) -PASS x01234567890123456789012345678901234567890123456789012345678901† (using URL) -PASS x01234567890123456789012345678901234567890123456789012345678901† (using URL.host) -PASS x01234567890123456789012345678901234567890123456789012345678901† (using URL.hostname) -PASS x01234567890123456789012345678901234567890123456789012345678901† (using <a>) -PASS x01234567890123456789012345678901234567890123456789012345678901† (using <a>.host) -PASS x01234567890123456789012345678901234567890123456789012345678901† (using <a>.hostname) -PASS x01234567890123456789012345678901234567890123456789012345678901† (using <area>) -PASS x01234567890123456789012345678901234567890123456789012345678901† (using <area>.host) -PASS x01234567890123456789012345678901234567890123456789012345678901† (using <area>.hostname) -PASS x01234567890123456789012345678901234567890123456789012345678901x.xn--zca (using URL) -PASS x01234567890123456789012345678901234567890123456789012345678901x.xn--zca (using URL.host) -PASS x01234567890123456789012345678901234567890123456789012345678901x.xn--zca (using URL.hostname) -PASS x01234567890123456789012345678901234567890123456789012345678901x.xn--zca (using <a>) -PASS x01234567890123456789012345678901234567890123456789012345678901x.xn--zca (using <a>.host) -PASS x01234567890123456789012345678901234567890123456789012345678901x.xn--zca (using <a>.hostname) -PASS x01234567890123456789012345678901234567890123456789012345678901x.xn--zca (using <area>) -PASS x01234567890123456789012345678901234567890123456789012345678901x.xn--zca (using <area>.host) -PASS x01234567890123456789012345678901234567890123456789012345678901x.xn--zca (using <area>.hostname) -FAIL x01234567890123456789012345678901234567890123456789012345678901x.ß (using URL) assert_equals: expected "x01234567890123456789012345678901234567890123456789012345678901x.xn--zca" but got "x01234567890123456789012345678901234567890123456789012345678901x.ss" -FAIL x01234567890123456789012345678901234567890123456789012345678901x.ß (using URL.host) assert_equals: expected "x01234567890123456789012345678901234567890123456789012345678901x.xn--zca" but got "x01234567890123456789012345678901234567890123456789012345678901x.ss" -FAIL x01234567890123456789012345678901234567890123456789012345678901x.ß (using URL.hostname) assert_equals: expected "x01234567890123456789012345678901234567890123456789012345678901x.xn--zca" but got "x01234567890123456789012345678901234567890123456789012345678901x.ss" -FAIL x01234567890123456789012345678901234567890123456789012345678901x.ß (using <a>) assert_equals: expected "x01234567890123456789012345678901234567890123456789012345678901x.xn--zca" but got "x01234567890123456789012345678901234567890123456789012345678901x.ss" -FAIL x01234567890123456789012345678901234567890123456789012345678901x.ß (using <a>.host) assert_equals: expected "x01234567890123456789012345678901234567890123456789012345678901x.xn--zca" but got "x01234567890123456789012345678901234567890123456789012345678901x.ss" -FAIL x01234567890123456789012345678901234567890123456789012345678901x.ß (using <a>.hostname) assert_equals: expected "x01234567890123456789012345678901234567890123456789012345678901x.xn--zca" but got "x01234567890123456789012345678901234567890123456789012345678901x.ss" -FAIL x01234567890123456789012345678901234567890123456789012345678901x.ß (using <area>) assert_equals: expected "x01234567890123456789012345678901234567890123456789012345678901x.xn--zca" but got "x01234567890123456789012345678901234567890123456789012345678901x.ss" -FAIL x01234567890123456789012345678901234567890123456789012345678901x.ß (using <area>.host) assert_equals: expected "x01234567890123456789012345678901234567890123456789012345678901x.xn--zca" but got "x01234567890123456789012345678901234567890123456789012345678901x.ss" -FAIL x01234567890123456789012345678901234567890123456789012345678901x.ß (using <area>.hostname) assert_equals: expected "x01234567890123456789012345678901234567890123456789012345678901x.xn--zca" but got "x01234567890123456789012345678901234567890123456789012345678901x.ss" -PASS 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.x (using URL) -PASS 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.x (using URL.host) -PASS 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.x (using URL.hostname) -PASS 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.x (using <a>) -PASS 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.x (using <a>.host) -PASS 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.x (using <a>.hostname) -PASS 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.x (using <area>) -PASS 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.x (using <area>.host) -PASS 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.x (using <area>.hostname) -PASS 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.xn--zca (using URL) -PASS 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.xn--zca (using URL.host) -PASS 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.xn--zca (using URL.hostname) -PASS 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.xn--zca (using <a>) -PASS 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.xn--zca (using <a>.host) -PASS 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.xn--zca (using <a>.hostname) -PASS 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.xn--zca (using <area>) -PASS 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.xn--zca (using <area>.host) -PASS 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.xn--zca (using <area>.hostname) -FAIL 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.ß (using URL) assert_equals: expected "01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.xn--zca" but got "01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.ss" -FAIL 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.ß (using URL.host) assert_equals: expected "01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.xn--zca" but got "01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.ss" -FAIL 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.ß (using URL.hostname) assert_equals: expected "01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.xn--zca" but got "01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.ss" -FAIL 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.ß (using <a>) assert_equals: expected "01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.xn--zca" but got "01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.ss" -FAIL 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.ß (using <a>.host) assert_equals: expected "01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.xn--zca" but got "01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.ss" -FAIL 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.ß (using <a>.hostname) assert_equals: expected "01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.xn--zca" but got "01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.ss" -FAIL 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.ß (using <area>) assert_equals: expected "01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.xn--zca" but got "01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.ss" -FAIL 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.ß (using <area>.host) assert_equals: expected "01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.xn--zca" but got "01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.ss" -FAIL 01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.ß (using <area>.hostname) assert_equals: expected "01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.xn--zca" but got "01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.01234567890123456789012345678901234567890123456789.0123456789012345678901234567890123456789012345678.ss" -PASS ab (using URL) -PASS ab (using URL.host) -PASS ab (using URL.hostname) -PASS ab (using <a>) -PASS ab (using <a>.host) -PASS ab (using <a>.hostname) -PASS ab (using <area>) -PASS ab (using <area>.host) -PASS ab (using <area>.hostname) -PASS a%C2%ADb (using URL) -PASS a%C2%ADb (using URL.host) -PASS a%C2%ADb (using URL.hostname) -PASS a%C2%ADb (using <a>) -PASS a%C2%ADb (using <a>.host) -PASS a%C2%ADb (using <a>.hostname) -PASS a%C2%ADb (using <area>) -PASS a%C2%ADb (using <area>.host) -PASS a%C2%ADb (using <area>.hostname) -PASS (using URL) -PASS (using URL.host) -PASS (using URL.hostname) -FAIL (using <a>) assert_equals: expected "https:///x" but got "https://%C2%AD/x" -PASS (using <a>.host) -PASS (using <a>.hostname) -FAIL (using <area>) assert_equals: expected "https:///x" but got "https://%C2%AD/x" -PASS (using <area>.host) -PASS (using <area>.hostname) -PASS %C2%AD (using URL) -PASS %C2%AD (using URL.host) -PASS %C2%AD (using URL.hostname) -PASS %C2%AD (using <a>) -PASS %C2%AD (using <a>.host) -PASS %C2%AD (using <a>.hostname) -PASS %C2%AD (using <area>) -PASS %C2%AD (using <area>.host) -PASS %C2%AD (using <area>.hostname) -FAIL xn-- (using URL) assert_throws_js: function "() => makeURL("url", hostTest.input)" did not throw -FAIL xn-- (using URL.host) assert_equals: expected "x" but got "xn--" -FAIL xn-- (using URL.hostname) assert_equals: expected "x" but got "xn--" -FAIL xn-- (using <a>) assert_equals: expected "" but got "xn--" -FAIL xn-- (using <a>.host) assert_equals: expected "x" but got "xn--" -FAIL xn-- (using <a>.hostname) assert_equals: expected "x" but got "xn--" -FAIL xn-- (using <area>) assert_equals: expected "" but got "xn--" -FAIL xn-- (using <area>.host) assert_equals: expected "x" but got "xn--" -FAIL xn-- (using <area>.hostname) assert_equals: expected "x" but got "xn--" -Harness: the test ran to completion. -
diff --git a/third_party/blink/web_tests/virtual/percent-based-scrolling/resources/percent-based-util.js b/third_party/blink/web_tests/virtual/percent-based-scrolling/resources/percent-based-util.js index 0f26e7b4..0025350 100644 --- a/third_party/blink/web_tests/virtual/percent-based-scrolling/resources/percent-based-util.js +++ b/third_party/blink/web_tests/virtual/percent-based-scrolling/resources/percent-based-util.js
@@ -80,6 +80,27 @@ return {x: Math.floor(pixelsToScrollX), y: Math.floor(pixelsToScrollY)}; } +// Scales the defaultScrollSpeed based on the ratio of scaledPixelsToScroll +// to defaultPixelsToScroll. It's used in scenarios when users might want to +// hasten the scroll speed to fit within a specific time to avoid bot timeout. +// +// Params: +// defaultScrollSpeed: scroll speed in pixels per second that we intend to +// scale if the feature is on. +// defaultPixelsToScroll: unscaled number of pixels that is used in a web test. +// scaledPixelsToScroll: scaled amount of pixels which is usually the result +// of the calculatePixelsToScroll() function defined +// above. Represents the value adjusted to a given +// container or window when the feature is on. +function scaleScrollSpeedToPercentBasedScrollingIfNeeded( + defaultScrollSpeed, defaultPixelsToScroll, scaledPixelsToScroll +) { + if (!isPercentBasedScrollingEnabled()) { + return defaultScrollSpeed; + } + return defaultScrollSpeed * scaledPixelsToScroll / defaultPixelsToScroll; +} + // Scrollbar Arrows Tests // Tests if scrolling the |scroller| element through its scrollbar arrows
diff --git a/third_party/blink/web_tests/webexposed/element-instance-property-listing-expected.txt b/third_party/blink/web_tests/webexposed/element-instance-property-listing-expected.txt index 1d723cbb..4779f44 100644 --- a/third_party/blink/web_tests/webexposed/element-instance-property-listing-expected.txt +++ b/third_party/blink/web_tests/webexposed/element-instance-property-listing-expected.txt
@@ -563,7 +563,9 @@ property type property width html element fencedframe + property height property src + property width html element fieldset property checkValidity property disabled
diff --git a/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt b/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt index 838dc7a..a41f0fa4 100644 --- a/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt +++ b/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt
@@ -783,9 +783,11 @@ setter value interface CSSLayerBlockRule : CSSGroupingRule attribute @@toStringTag + getter name method constructor interface CSSLayerStatementRule : CSSRule attribute @@toStringTag + getter nameList method constructor interface CSSMathInvert : CSSMathValue attribute @@toStringTag @@ -3451,9 +3453,13 @@ setter width interface HTMLFencedFrameElement : HTMLElement attribute @@toStringTag + getter height getter src + getter width method constructor + setter height setter src + setter width interface HTMLFieldSetElement : HTMLElement attribute @@toStringTag getter disabled
diff --git a/third_party/fuchsia-sdk/BUILD.gn b/third_party/fuchsia-sdk/BUILD.gn deleted file mode 100644 index 438467b..0000000 --- a/third_party/fuchsia-sdk/BUILD.gn +++ /dev/null
@@ -1,12 +0,0 @@ -# Copyright 2018 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -assert(is_fuchsia) - -import("//build/toolchain/toolchain.gni") -import("//third_party/fuchsia-sdk/sdk/build/fuchsia_sdk_pkg.gni") - -group("vulkan_validation") { - data_deps = [ "sdk/pkg/vulkan_layers:VkLayer_khronos_validation" ] -}
diff --git a/third_party/rust/cxxbridge_cmd/v1/README.chromium b/third_party/rust/cxxbridge_cmd/v1/README.chromium index cd7930eb..d704ae1 100644 --- a/third_party/rust/cxxbridge_cmd/v1/README.chromium +++ b/third_party/rust/cxxbridge_cmd/v1/README.chromium
@@ -4,3 +4,7 @@ Version: 1.0.56 Security Critical: no License: Apache 2.0 + +Patches: +0001-Export-UniquePtr-and-similar-functions.patch +Raised upstream at https://github.com/dtolnay/cxx/pull/967.
diff --git a/third_party/rust/cxxbridge_cmd/v1/crate/src/gen/write.rs b/third_party/rust/cxxbridge_cmd/v1/crate/src/gen/write.rs index a3b9c9f..efe49b3 100644 --- a/third_party/rust/cxxbridge_cmd/v1/crate/src/gen/write.rs +++ b/third_party/rust/cxxbridge_cmd/v1/crate/src/gen/write.rs
@@ -1637,6 +1637,7 @@ "static_assert(alignof(::std::unique_ptr<{}>) == alignof(void *), \"\");", inner, ); + begin_function_definition(out); writeln!( out, "void cxxbridge1$unique_ptr${}$null(::std::unique_ptr<{}> *ptr) noexcept {{", @@ -1646,6 +1647,7 @@ writeln!(out, "}}"); if can_construct_from_value { out.builtin.maybe_uninit = true; + begin_function_definition(out); writeln!( out, "{} *cxxbridge1$unique_ptr${}$uninit(::std::unique_ptr<{}> *ptr) noexcept {{", @@ -1660,6 +1662,7 @@ writeln!(out, " return uninit;"); writeln!(out, "}}"); } + begin_function_definition(out); writeln!( out, "void cxxbridge1$unique_ptr${}$raw(::std::unique_ptr<{}> *ptr, {} *raw) noexcept {{", @@ -1667,6 +1670,7 @@ ); writeln!(out, " ::new (ptr) ::std::unique_ptr<{}>(raw);", inner); writeln!(out, "}}"); + begin_function_definition(out); writeln!( out, "const {} *cxxbridge1$unique_ptr${}$get(const ::std::unique_ptr<{}>& ptr) noexcept {{", @@ -1674,6 +1678,7 @@ ); writeln!(out, " return ptr.get();"); writeln!(out, "}}"); + begin_function_definition(out); writeln!( out, "{} *cxxbridge1$unique_ptr${}$release(::std::unique_ptr<{}>& ptr) noexcept {{", @@ -1681,6 +1686,7 @@ ); writeln!(out, " return ptr.release();"); writeln!(out, "}}"); + begin_function_definition(out); writeln!( out, "void cxxbridge1$unique_ptr${}$drop(::std::unique_ptr<{}> *ptr) noexcept {{", @@ -1724,6 +1730,7 @@ "static_assert(alignof(::std::shared_ptr<{}>) == alignof(void *), \"\");", inner, ); + begin_function_definition(out); writeln!( out, "void cxxbridge1$shared_ptr${}$null(::std::shared_ptr<{}> *ptr) noexcept {{", @@ -1733,6 +1740,7 @@ writeln!(out, "}}"); if can_construct_from_value { out.builtin.maybe_uninit = true; + begin_function_definition(out); writeln!( out, "{} *cxxbridge1$shared_ptr${}$uninit(::std::shared_ptr<{}> *ptr) noexcept {{", @@ -1747,6 +1755,7 @@ writeln!(out, " return uninit;"); writeln!(out, "}}"); } + begin_function_definition(out); writeln!( out, "void cxxbridge1$shared_ptr${}$clone(const ::std::shared_ptr<{}>& self, ::std::shared_ptr<{}> *ptr) noexcept {{", @@ -1754,6 +1763,7 @@ ); writeln!(out, " ::new (ptr) ::std::shared_ptr<{}>(self);", inner); writeln!(out, "}}"); + begin_function_definition(out); writeln!( out, "const {} *cxxbridge1$shared_ptr${}$get(const ::std::shared_ptr<{}>& self) noexcept {{", @@ -1761,6 +1771,7 @@ ); writeln!(out, " return self.get();"); writeln!(out, "}}"); + begin_function_definition(out); writeln!( out, "void cxxbridge1$shared_ptr${}$drop(::std::shared_ptr<{}> *self) noexcept {{", @@ -1795,6 +1806,7 @@ ); writeln!(out, " ::new (ptr) ::std::weak_ptr<{}>();", inner); writeln!(out, "}}"); + begin_function_definition(out); writeln!( out, "void cxxbridge1$weak_ptr${}$clone(const ::std::weak_ptr<{}>& self, ::std::weak_ptr<{}> *ptr) noexcept {{", @@ -1802,6 +1814,7 @@ ); writeln!(out, " ::new (ptr) ::std::weak_ptr<{}>(self);", inner); writeln!(out, "}}"); + begin_function_definition(out); writeln!( out, "void cxxbridge1$weak_ptr${}$downgrade(const ::std::shared_ptr<{}>& shared, ::std::weak_ptr<{}> *weak) noexcept {{", @@ -1809,6 +1822,7 @@ ); writeln!(out, " ::new (weak) ::std::weak_ptr<{}>(shared);", inner); writeln!(out, "}}"); + begin_function_definition(out); writeln!( out, "void cxxbridge1$weak_ptr${}$upgrade(const ::std::weak_ptr<{}>& weak, ::std::shared_ptr<{}> *shared) noexcept {{", @@ -1820,6 +1834,7 @@ inner, ); writeln!(out, "}}"); + begin_function_definition(out); writeln!( out, "void cxxbridge1$weak_ptr${}$drop(::std::weak_ptr<{}> *self) noexcept {{", @@ -1846,6 +1861,7 @@ writeln!(out, " return s.size();"); writeln!(out, "}}"); + begin_function_definition(out); writeln!( out, "{} *cxxbridge1$std$vector${}$get_unchecked(::std::vector<{}> *s, ::std::size_t pos) noexcept {{", @@ -1855,6 +1871,7 @@ writeln!(out, "}}"); if out.types.is_maybe_trivial(element) { + begin_function_definition(out); writeln!( out, "void cxxbridge1$std$vector${}$push_back(::std::vector<{}> *v, {} *value) noexcept {{", @@ -1864,6 +1881,7 @@ writeln!(out, " ::rust::destroy(value);"); writeln!(out, "}}"); + begin_function_definition(out); writeln!( out, "void cxxbridge1$std$vector${}$pop_back(::std::vector<{}> *v, {} *out) noexcept {{",
diff --git a/third_party/rust/cxxbridge_cmd/v1/patches/0001-Export-UniquePtr-and-similar-functions.patch b/third_party/rust/cxxbridge_cmd/v1/patches/0001-Export-UniquePtr-and-similar-functions.patch new file mode 100644 index 0000000..c050c88f --- /dev/null +++ b/third_party/rust/cxxbridge_cmd/v1/patches/0001-Export-UniquePtr-and-similar-functions.patch
@@ -0,0 +1,165 @@ +From 0431bad0ddf7a8d03049bbb35c149c97adc34ca2 Mon Sep 17 00:00:00 2001 +From: adetaylor <adetaylor@chromium.org> +Date: Mon, 29 Nov 2021 22:33:25 -0800 +Subject: [PATCH] Export UniquePtr and similar functions. + +Previously these did not respect + cxxbridge --cxx-impl-annotations +and similar directives in other build pipelines. These may be linked against +from Rust code just as other generated functions are, so it's important that +they are exported from shared objects in a similar fashion. +--- + gen/src/write.rs | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +diff --git a/gen/src/write.rs b/gen/src/write.rs +index a3b9c9fa..efe49b32 100644 +--- a/gen/src/write.rs ++++ b/gen/src/write.rs +@@ -1637,6 +1637,7 @@ fn write_unique_ptr_common(out: &mut OutFile, ty: UniquePtr) { + "static_assert(alignof(::std::unique_ptr<{}>) == alignof(void *), \"\");", + inner, + ); ++ begin_function_definition(out); + writeln!( + out, + "void cxxbridge1$unique_ptr${}$null(::std::unique_ptr<{}> *ptr) noexcept {{", +@@ -1646,6 +1647,7 @@ fn write_unique_ptr_common(out: &mut OutFile, ty: UniquePtr) { + writeln!(out, "}}"); + if can_construct_from_value { + out.builtin.maybe_uninit = true; ++ begin_function_definition(out); + writeln!( + out, + "{} *cxxbridge1$unique_ptr${}$uninit(::std::unique_ptr<{}> *ptr) noexcept {{", +@@ -1660,6 +1662,7 @@ fn write_unique_ptr_common(out: &mut OutFile, ty: UniquePtr) { + writeln!(out, " return uninit;"); + writeln!(out, "}}"); + } ++ begin_function_definition(out); + writeln!( + out, + "void cxxbridge1$unique_ptr${}$raw(::std::unique_ptr<{}> *ptr, {} *raw) noexcept {{", +@@ -1667,6 +1670,7 @@ fn write_unique_ptr_common(out: &mut OutFile, ty: UniquePtr) { + ); + writeln!(out, " ::new (ptr) ::std::unique_ptr<{}>(raw);", inner); + writeln!(out, "}}"); ++ begin_function_definition(out); + writeln!( + out, + "const {} *cxxbridge1$unique_ptr${}$get(const ::std::unique_ptr<{}>& ptr) noexcept {{", +@@ -1674,6 +1678,7 @@ fn write_unique_ptr_common(out: &mut OutFile, ty: UniquePtr) { + ); + writeln!(out, " return ptr.get();"); + writeln!(out, "}}"); ++ begin_function_definition(out); + writeln!( + out, + "{} *cxxbridge1$unique_ptr${}$release(::std::unique_ptr<{}>& ptr) noexcept {{", +@@ -1681,6 +1686,7 @@ fn write_unique_ptr_common(out: &mut OutFile, ty: UniquePtr) { + ); + writeln!(out, " return ptr.release();"); + writeln!(out, "}}"); ++ begin_function_definition(out); + writeln!( + out, + "void cxxbridge1$unique_ptr${}$drop(::std::unique_ptr<{}> *ptr) noexcept {{", +@@ -1724,6 +1730,7 @@ fn write_shared_ptr(out: &mut OutFile, key: NamedImplKey) { + "static_assert(alignof(::std::shared_ptr<{}>) == alignof(void *), \"\");", + inner, + ); ++ begin_function_definition(out); + writeln!( + out, + "void cxxbridge1$shared_ptr${}$null(::std::shared_ptr<{}> *ptr) noexcept {{", +@@ -1733,6 +1740,7 @@ fn write_shared_ptr(out: &mut OutFile, key: NamedImplKey) { + writeln!(out, "}}"); + if can_construct_from_value { + out.builtin.maybe_uninit = true; ++ begin_function_definition(out); + writeln!( + out, + "{} *cxxbridge1$shared_ptr${}$uninit(::std::shared_ptr<{}> *ptr) noexcept {{", +@@ -1747,6 +1755,7 @@ fn write_shared_ptr(out: &mut OutFile, key: NamedImplKey) { + writeln!(out, " return uninit;"); + writeln!(out, "}}"); + } ++ begin_function_definition(out); + writeln!( + out, + "void cxxbridge1$shared_ptr${}$clone(const ::std::shared_ptr<{}>& self, ::std::shared_ptr<{}> *ptr) noexcept {{", +@@ -1754,6 +1763,7 @@ fn write_shared_ptr(out: &mut OutFile, key: NamedImplKey) { + ); + writeln!(out, " ::new (ptr) ::std::shared_ptr<{}>(self);", inner); + writeln!(out, "}}"); ++ begin_function_definition(out); + writeln!( + out, + "const {} *cxxbridge1$shared_ptr${}$get(const ::std::shared_ptr<{}>& self) noexcept {{", +@@ -1761,6 +1771,7 @@ fn write_shared_ptr(out: &mut OutFile, key: NamedImplKey) { + ); + writeln!(out, " return self.get();"); + writeln!(out, "}}"); ++ begin_function_definition(out); + writeln!( + out, + "void cxxbridge1$shared_ptr${}$drop(::std::shared_ptr<{}> *self) noexcept {{", +@@ -1795,6 +1806,7 @@ fn write_weak_ptr(out: &mut OutFile, key: NamedImplKey) { + ); + writeln!(out, " ::new (ptr) ::std::weak_ptr<{}>();", inner); + writeln!(out, "}}"); ++ begin_function_definition(out); + writeln!( + out, + "void cxxbridge1$weak_ptr${}$clone(const ::std::weak_ptr<{}>& self, ::std::weak_ptr<{}> *ptr) noexcept {{", +@@ -1802,6 +1814,7 @@ fn write_weak_ptr(out: &mut OutFile, key: NamedImplKey) { + ); + writeln!(out, " ::new (ptr) ::std::weak_ptr<{}>(self);", inner); + writeln!(out, "}}"); ++ begin_function_definition(out); + writeln!( + out, + "void cxxbridge1$weak_ptr${}$downgrade(const ::std::shared_ptr<{}>& shared, ::std::weak_ptr<{}> *weak) noexcept {{", +@@ -1809,6 +1822,7 @@ fn write_weak_ptr(out: &mut OutFile, key: NamedImplKey) { + ); + writeln!(out, " ::new (weak) ::std::weak_ptr<{}>(shared);", inner); + writeln!(out, "}}"); ++ begin_function_definition(out); + writeln!( + out, + "void cxxbridge1$weak_ptr${}$upgrade(const ::std::weak_ptr<{}>& weak, ::std::shared_ptr<{}> *shared) noexcept {{", +@@ -1820,6 +1834,7 @@ fn write_weak_ptr(out: &mut OutFile, key: NamedImplKey) { + inner, + ); + writeln!(out, "}}"); ++ begin_function_definition(out); + writeln!( + out, + "void cxxbridge1$weak_ptr${}$drop(::std::weak_ptr<{}> *self) noexcept {{", +@@ -1846,6 +1861,7 @@ fn write_cxx_vector(out: &mut OutFile, key: NamedImplKey) { + writeln!(out, " return s.size();"); + writeln!(out, "}}"); + ++ begin_function_definition(out); + writeln!( + out, + "{} *cxxbridge1$std$vector${}$get_unchecked(::std::vector<{}> *s, ::std::size_t pos) noexcept {{", +@@ -1855,6 +1871,7 @@ fn write_cxx_vector(out: &mut OutFile, key: NamedImplKey) { + writeln!(out, "}}"); + + if out.types.is_maybe_trivial(element) { ++ begin_function_definition(out); + writeln!( + out, + "void cxxbridge1$std$vector${}$push_back(::std::vector<{}> *v, {} *value) noexcept {{", +@@ -1864,6 +1881,7 @@ fn write_cxx_vector(out: &mut OutFile, key: NamedImplKey) { + writeln!(out, " ::rust::destroy(value);"); + writeln!(out, "}}"); + ++ begin_function_definition(out); + writeln!( + out, + "void cxxbridge1$std$vector${}$pop_back(::std::vector<{}> *v, {} *out) noexcept {{", +-- +2.34.0.rc2.393.gf8c9666880-goog +
diff --git a/third_party/zlib/google/zip_writer.h b/third_party/zlib/google/zip_writer.h index afc9390..fcc96275 100644 --- a/third_party/zlib/google/zip_writer.h +++ b/third_party/zlib/google/zip_writer.h
@@ -58,7 +58,9 @@ } // Should ignore missing files and directories? - void ContinueOnError(bool b) { continue_on_error_ = b; } + void ContinueOnError(bool continue_on_error) { + continue_on_error_ = continue_on_error; + } // Sets the recursive flag, indicating whether the contents of subdirectories // should be included.
diff --git a/tools/mb/mb_config.pyl b/tools/mb/mb_config.pyl index d2bbd1a..0d57327 100644 --- a/tools/mb/mb_config.pyl +++ b/tools/mb/mb_config.pyl
@@ -217,8 +217,8 @@ }, 'chromium.dawn': { - 'Dawn Linux x64 Builder': 'dawn_tests_with_desktop_gl_release_trybot', - 'Dawn Linux x64 DEPS Builder': 'dawn_tests_with_desktop_gl_release_trybot', + 'Dawn Linux x64 Builder': 'dawn_tests_with_desktop_gl_release_trybot_reclient', + 'Dawn Linux x64 DEPS Builder': 'dawn_tests_with_desktop_gl_release_trybot_reclient', 'Dawn Mac x64 Builder': 'dawn_tests_release_bot_dcheck_always_on', 'Dawn Mac x64 DEPS Builder': 'dawn_tests_release_bot_dcheck_always_on', @@ -2138,6 +2138,10 @@ 'dawn_tests', 'dawn_enable_desktop_gl', 'release_trybot_minimal_symbols', ], + 'dawn_tests_with_desktop_gl_release_trybot_reclient': [ + 'dawn_tests', 'dawn_enable_desktop_gl', 'release_trybot_minimal_symbols_reclient', + ], + 'debug_bot': [ 'debug_bot', ],
diff --git a/tools/mb/mb_config_expectations/chromium.dawn.json b/tools/mb/mb_config_expectations/chromium.dawn.json index 62fc4399..6bee502 100644 --- a/tools/mb/mb_config_expectations/chromium.dawn.json +++ b/tools/mb/mb_config_expectations/chromium.dawn.json
@@ -9,7 +9,8 @@ "is_debug": false, "symbol_level": 1, "use_dawn": true, - "use_goma": true + "use_rbe": true, + "use_remoteexec": true } }, "Dawn Linux x64 DEPS Builder": { @@ -22,7 +23,8 @@ "is_debug": false, "symbol_level": 1, "use_dawn": true, - "use_goma": true + "use_rbe": true, + "use_remoteexec": true } }, "Dawn Mac x64 Builder": {
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index f28ea78..9ecc1bb 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -11263,6 +11263,13 @@ <int value="11" label="Aborted because there was no surface"/> </enum> +<enum name="CanvasOopRasterAndGpuAcceleration"> + <int value="0" label="Canvas2D accelerated and OOPR enabled"/> + <int value="1" label="Canvas2D accelerated and OOPR disabled"/> + <int value="2" label="Canvas2D not accelerated and OOPR enabled"/> + <int value="3" label="Canvas2D not accelerated and OOPR disabled"/> +</enum> + <enum name="CanvasOverdrawOp"> <int value="0" label="None (should have 0 counts)"/> <int value="1" label="Total ops"/> @@ -27843,6 +27850,7 @@ <int value="8" label="Yes in browser seen in renderer with Page"/> <int value="9" label="Yes in browser seen in ACK to browser"/> <int value="10" label="Yes in browser while disconnected"/> + <int value="11" label="Yes in browser while RenderView was not live"/> </enum> <enum name="EventPreFilterResult"> @@ -35674,7 +35682,6 @@ <int value="4082" label="CSSMatchMediaUnknown"/> <int value="4083" label="CSSMediaListUnknown"/> <int value="4084" label="CSSOMMediaConditionUnknown"/> - <int value="4085" label="CrossPageAccessBrokenByCOOPSOAPByDefault"/> </enum> <enum name="FeaturePolicyAllowlistType"> @@ -49293,6 +49300,7 @@ <int value="-1767470652" label="out-of-process-pdf"/> <int value="-1766791501" label="WebUITabStrip:enabled"/> <int value="-1766648764" label="OmniboxShortBookmarkSuggestions:disabled"/> + <int value="-1766317053" label="GridTabSwitcherForTablets:enabled"/> <int value="-1766162197" label="AppServiceInstanceRegistry:enabled"/> <int value="-1766129470" label="DataSaverLiteModeRebranding:disabled"/> <int value="-1763899404" label="LayoutNGTable:enabled"/> @@ -50915,6 +50923,7 @@ <int value="-580897686" label="SharedHighlightingAmp:enabled"/> <int value="-579192400" label="disable-input-view"/> <int value="-577982497" label="CupsPrintersUiOverhaul:enabled"/> + <int value="-577503348" label="GridTabSwitcherForTablets:disabled"/> <int value="-574354898" label="PostQuantumCECPQ2:enabled"/> <int value="-574217217" label="kSignInProfileCreationEnterprise:enabled"/> <int value="-574000901" label="AVIF:enabled"/>
diff --git a/tools/metrics/histograms/metadata/assistant/histograms.xml b/tools/metrics/histograms/metadata/assistant/histograms.xml index 85b01e06..b2d7f69 100644 --- a/tools/metrics/histograms/metadata/assistant/histograms.xml +++ b/tools/metrics/histograms/metadata/assistant/histograms.xml
@@ -125,7 +125,7 @@ </histogram> <histogram name="Assistant.HotwordEnableNotification" enum="BooleanHit" - expires_after="2021-12-31"> + expires_after="2022-12-31"> <owner>updowndota@chromium.org</owner> <owner>croissant-eng@chromium.org</owner> <summary> @@ -422,7 +422,7 @@ </histogram> <histogram name="QuickAnswers.ContextMenu.Close.Duration{InteractionType}" - units="ms" expires_after="2021-12-31"> + units="ms" expires_after="2022-12-31"> <owner>updowndota@chromium.org</owner> <owner>croissant-eng@chromium.org</owner> <summary> @@ -469,7 +469,7 @@ </histogram> <histogram name="QuickAnswers.Loading.Status" enum="QuickAnswersLoadStatus" - expires_after="2022-01-02"> + expires_after="2022-12-31"> <owner>updowndota@chromium.org</owner> <owner>llin@google.com</owner> <owner>croissant-eng@chromium.org</owner> @@ -515,7 +515,7 @@ </histogram> <histogram name="QuickAnswers.Result.Duration{QuickAnswersClickResultType}" - units="ms" expires_after="2022-01-02"> + units="ms" expires_after="2022-12-31"> <owner>updowndota@chromium.org</owner> <owner>llin@google.com</owner> <owner>croissant-eng@chromium.org</owner>
diff --git a/tools/metrics/histograms/metadata/extensions/histograms.xml b/tools/metrics/histograms/metadata/extensions/histograms.xml index ceb89b0..096685b 100644 --- a/tools/metrics/histograms/metadata/extensions/histograms.xml +++ b/tools/metrics/histograms/metadata/extensions/histograms.xml
@@ -2046,7 +2046,9 @@ <histogram name="Extensions.Functions.FailedTime{ExtensionFunctionExecutionTime}" - enum="ExtensionFunctions" expires_after="2021-12-12"> + enum="ExtensionFunctions" expires_after="never"> +<!-- expires-never: Used for monitoring extension API usage. --> + <owner>rdevlin.cronin@chromium.org</owner> <owner>extensions-core@chromium.org</owner> <summary> @@ -2104,7 +2106,9 @@ <histogram name="Extensions.Functions.SucceededTime{ExtensionFunctionExecutionTime}" - enum="ExtensionFunctions" expires_after="2021-12-12"> + enum="ExtensionFunctions" expires_after="never"> +<!-- expires-never: Used for monitoring extension API usage. --> + <owner>rdevlin.cronin@chromium.org</owner> <owner>extensions-core@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/gpu/histograms.xml b/tools/metrics/histograms/metadata/gpu/histograms.xml index 90da7c55..53954a3 100644 --- a/tools/metrics/histograms/metadata/gpu/histograms.xml +++ b/tools/metrics/histograms/metadata/gpu/histograms.xml
@@ -500,6 +500,18 @@ </summary> </histogram> +<histogram name="GPU.CanvasOopRaster.OopRasterAndGpuAcceleration" + enum="CanvasOopRasterAndGpuAcceleration" expires_after="2022-11-01"> + <owner>vasilyt@chromium.org</owner> + <owner>nazabris@microsoft.com</owner> + <owner>jochin@microsoft.com</owner> + <summary> + Records, during GPU process initialization, the combination of the following + two features being enabled/disabled: 1) Accelerated 2D Canvas 2) OOP + Rasterization of Canvas. + </summary> +</histogram> + <histogram name="GPU.CollectContextGraphicsInfo" units="microseconds" expires_after="M77"> <owner>vmiura@chromium.org</owner>
diff --git a/tools/metrics/histograms/metadata/memory/histograms.xml b/tools/metrics/histograms/metadata/memory/histograms.xml index 44bcee0..a691b52 100644 --- a/tools/metrics/histograms/metadata/memory/histograms.xml +++ b/tools/metrics/histograms/metadata/memory/histograms.xml
@@ -23,7 +23,7 @@ <histograms> <histogram name="Memory.AudioService.PrivateMemoryFootprint" units="MB" - expires_after="2022-05-15"> + expires_after="2023-01-10"> <owner>marinaciocea@chromium.org</owner> <owner>maxmorin@chromium.org</owner> <owner>olka@chromium.org</owner> @@ -44,7 +44,7 @@ </histogram> <histogram name="Memory.AudioService.PrivateSwapFootprint" units="MB" - expires_after="2022-04-10"> + expires_after="2023-01-10"> <owner>olka@chromium.org</owner> <owner>guidou@chromium.org</owner> <summary> @@ -81,7 +81,7 @@ </histogram> <histogram name="Memory.AudioService.SharedMemoryFootprint" units="MB" - expires_after="2022-04-10"> + expires_after="2023-01-10"> <owner>olka@chromium.org</owner> <owner>guidou@chromium.org</owner> <summary> @@ -404,7 +404,7 @@ </histogram> <histogram name="Memory.Browser.PrivateSwapFootprint" units="MB" - expires_after="2022-04-10"> + expires_after="2023-01-10"> <owner>erikchen@chromium.org</owner> <owner>ssid@chromium.org</owner> <summary> @@ -440,7 +440,7 @@ </histogram> <histogram name="Memory.Browser.SharedMemoryFootprint" units="MB" - expires_after="2022-04-10"> + expires_after="2023-01-10"> <owner>erikchen@chromium.org</owner> <summary> A rough estimate of the shared memory footprint of the browser process. @@ -550,7 +550,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.Browser2" units="MB" - expires_after="2022-01-10"> + expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocator2" --> <owner>erikchen@chromium.org</owner> @@ -565,7 +565,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.Browser2.Custom" units="bytes" - expires_after="2022-05-01"> + expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocatorCustom2" --> <owner>sashamcintosh@chromium.org</owner> @@ -582,7 +582,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.Browser2.Small" units="KB" - expires_after="2022-05-15"> + expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocatorSmall2" --> <owner>erikchen@chromium.org</owner> @@ -597,7 +597,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.Browser2.Tiny" units="bytes" - expires_after="2022-01-10"> + expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocatorTiny2" --> <owner>sashamcintosh@chromium.org</owner> @@ -654,7 +654,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.Extension2" units="MB" - expires_after="2022-01-10"> + expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocator2" --> <owner>erikchen@chromium.org</owner> @@ -669,7 +669,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.Extension2.Custom" - units="bytes" expires_after="2022-01-10"> + units="bytes" expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocatorCustom2" --> <owner>sashamcintosh@chromium.org</owner> @@ -686,7 +686,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.Extension2.Small" units="KB" - expires_after="2022-01-10"> + expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocatorSmall2" --> <owner>erikchen@chromium.org</owner> @@ -701,7 +701,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.Extension2.Tiny" units="bytes" - expires_after="2022-01-10"> + expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocatorTiny2" --> <owner>sashamcintosh@chromium.org</owner> @@ -732,7 +732,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.Gpu2" units="MB" - expires_after="2022-05-15"> + expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocator2" --> <owner>erikchen@chromium.org</owner> @@ -747,7 +747,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.Gpu2.Custom" units="bytes" - expires_after="2022-04-17"> + expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocatorCustom2" --> <owner>sashamcintosh@chromium.org</owner> @@ -764,7 +764,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.Gpu2.Small" units="KB" - expires_after="2022-04-24"> + expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocatorSmall2" --> <owner>erikchen@chromium.org</owner> @@ -779,7 +779,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.Gpu2.Tiny" units="bytes" - expires_after="2022-01-10"> + expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocatorTiny2" --> <owner>sashamcintosh@chromium.org</owner> @@ -812,7 +812,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.NetworkService2" units="MiB" - expires_after="2022-01-10"> + expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocator2" --> <owner>mmenke@chromium.org</owner> @@ -829,7 +829,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.NetworkService2.Custom" - units="bytes" expires_after="2022-01-10"> + units="bytes" expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocatorCustom2" --> <owner>sashamcintosh@chromium.org</owner> @@ -846,7 +846,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.NetworkService2.Small" - units="KiB" expires_after="2022-01-10"> + units="KiB" expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocatorSmall2" --> <owner>mmenke@chromium.org</owner> @@ -863,7 +863,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.NetworkService2.Tiny" - units="bytes" expires_after="2022-01-10"> + units="bytes" expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocatorTiny2" --> <owner>sashamcintosh@chromium.org</owner> @@ -1173,7 +1173,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.Renderer2" units="MB" - expires_after="2022-05-15"> + expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocator2" --> <owner>erikchen@chromium.org</owner> @@ -1188,7 +1188,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.Renderer2.Custom" - units="bytes" expires_after="2022-01-10"> + units="bytes" expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocatorCustom2" --> <owner>sashamcintosh@chromium.org</owner> @@ -1205,7 +1205,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.Renderer2.Small" units="KB" - expires_after="2022-05-15"> + expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocatorSmall2" --> <owner>erikchen@chromium.org</owner> @@ -1220,7 +1220,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.Renderer2.Tiny" units="bytes" - expires_after="2022-04-24"> + expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocatorTiny2" --> <owner>sashamcintosh@chromium.org</owner> @@ -1237,7 +1237,7 @@ </histogram> <histogram name="Memory.Experimental.Total2.PrivateMemoryFootprint" units="MB" - expires_after="2022-04-17"> + expires_after="2023-01-10"> <owner>erikchen@chromium.org</owner> <owner>ssid@chromium.org</owner> <summary> @@ -1285,7 +1285,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.Utility2" units="MB" - expires_after="2022-01-10"> + expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocator2" --> <owner>erikchen@chromium.org</owner> @@ -1300,7 +1300,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.Utility2.Custom" units="bytes" - expires_after="2022-01-10"> + expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocatorCustom2" --> <owner>sashamcintosh@chromium.org</owner> @@ -1317,7 +1317,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.Utility2.Small" units="KB" - expires_after="2022-01-10"> + expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocatorSmall2" --> <owner>erikchen@chromium.org</owner> @@ -1332,7 +1332,7 @@ </histogram> <histogram base="true" name="Memory.Experimental.Utility2.Tiny" units="bytes" - expires_after="2022-01-10"> + expires_after="2023-01-10"> <!-- Name completed by histogram_suffixes name="ProcessMemoryAllocatorTiny2" --> <owner>sashamcintosh@chromium.org</owner> @@ -1349,7 +1349,7 @@ </histogram> <histogram name="Memory.Extension.PrivateMemoryFootprint" units="MB" - expires_after="2022-05-15"> + expires_after="2023-01-10"> <owner>erikchen@chromium.org</owner> <owner>ssid@chromium.org</owner> <summary> @@ -1554,7 +1554,7 @@ </histogram> <histogram name="Memory.Gpu.SharedMemoryFootprint" units="MB" - expires_after="2022-05-15"> + expires_after="2023-01-10"> <owner>erikchen@chromium.org</owner> <owner>ssid@chromium.org</owner> <summary> @@ -1611,7 +1611,7 @@ </histogram> <histogram name="Memory.LowMemoryKiller.FreedSize" units="KB" - expires_after="2022-04-17"> + expires_after="2023-01-10"> <owner>vovoy@google.com</owner> <owner>wvk@google.com</owner> <summary>The memory size freed by each low memory kill event.</summary> @@ -1713,7 +1713,7 @@ </histogram> <histogram name="Memory.NetworkService.PrivateSwapFootprint" units="MiB" - expires_after="2022-01-10"> + expires_after="2023-01-10"> <owner>mmenke@chromium.org</owner> <owner>morlovich@chromium.org</owner> <owner>erikchen@chromium.org</owner> @@ -1755,7 +1755,7 @@ </histogram> <histogram name="Memory.NetworkService.SharedMemoryFootprint" units="MiB" - expires_after="2022-05-01"> + expires_after="2023-01-10"> <owner>mmenke@chromium.org</owner> <owner>morlovich@chromium.org</owner> <owner>erikchen@chromium.org</owner> @@ -1913,7 +1913,7 @@ </histogram> <histogram name="Memory.PaintPreviewCompositor.PrivateSwapFootprint" units="MB" - expires_after="2022-04-10"> + expires_after="2023-01-10"> <owner>ckitagawa@chromium.org</owner> <owner>fredmello@chromium.org</owner> <owner>yashard@chromium.org</owner> @@ -1951,7 +1951,7 @@ </histogram> <histogram name="Memory.PaintPreviewCompositor.SharedMemoryFootprint" - units="MB" expires_after="2022-04-10"> + units="MB" expires_after="2023-01-10"> <owner>ckitagawa@chromium.org</owner> <owner>fredmello@chromium.org</owner> <owner>yashard@chromium.org</owner> @@ -2451,7 +2451,7 @@ </histogram> <histogram name="Memory.ProcessCount" units="processes" - expires_after="2022-05-15"> + expires_after="2023-01-10"> <owner>creis@chromium.org</owner> <owner>nasko@chromium.org</owner> <summary> @@ -2533,7 +2533,7 @@ </histogram> <histogram name="Memory.Renderer.SharedMemoryFootprint" units="MB" - expires_after="2022-04-10"> + expires_after="2023-01-10"> <owner>erikchen@chromium.org</owner> <owner>ssid@chromium.org</owner> <summary> @@ -2564,7 +2564,7 @@ </histogram> <histogram name="Memory.RenderProcessHost.Count.All" units="processes" - expires_after="2022-05-15"> + expires_after="2023-01-10"> <owner>alexmos@chromium.org</owner> <owner>creis@chromium.org</owner> <owner>lukasza@chromium.org</owner> @@ -2584,7 +2584,7 @@ </histogram> <histogram name="Memory.RenderProcessHost.Count.InitializedAndNotDead" - units="processes" expires_after="2022-05-01"> + units="processes" expires_after="2023-01-10"> <owner>alexmos@chromium.org</owner> <owner>creis@chromium.org</owner> <owner>lukasza@chromium.org</owner> @@ -2729,7 +2729,7 @@ </histogram> <histogram name="Memory.Total.SharedMemoryFootprint" units="MB" - expires_after="2022-05-15"> + expires_after="2023-01-10"> <owner>erikchen@chromium.org</owner> <owner>ssid@chromium.org</owner> <summary> @@ -2772,7 +2772,7 @@ </histogram> <histogram name="Memory.Utility.PrivateSwapFootprint" units="MB" - expires_after="2022-01-10"> + expires_after="2023-01-10"> <owner>jam@chromium.org</owner> <summary> An amount of private memory of the utility process placed in swap (VmSwap). @@ -2809,7 +2809,7 @@ </histogram> <histogram name="Memory.Utility.SharedMemoryFootprint" units="MB" - expires_after="2022-01-10"> + expires_after="2023-01-10"> <owner>jam@chromium.org</owner> <owner>erikchen@chromium.org</owner> <owner>ssid@chromium.org</owner>
diff --git a/tools/metrics/histograms/metadata/notifications/histograms.xml b/tools/metrics/histograms/metadata/notifications/histograms.xml index 4688601..f414050 100644 --- a/tools/metrics/histograms/metadata/notifications/histograms.xml +++ b/tools/metrics/histograms/metadata/notifications/histograms.xml
@@ -684,7 +684,7 @@ </histogram> <histogram name="Notifications.Scheduler.BackgroundTask.Event" - enum="NotificationSchedulerBackgroundTaskEvent" expires_after="2022-05-01"> + enum="NotificationSchedulerBackgroundTaskEvent" expires_after="2022-12-31"> <owner>xingliu@chromium.org</owner> <owner>hesen@chromium.org</owner> <summary> @@ -694,7 +694,7 @@ </histogram> <histogram name="Notifications.Scheduler.BackgroundTask.NotificationShown" - units="notifications" expires_after="2021-12-31"> + units="notifications" expires_after="2022-12-31"> <owner>xingliu@chromium.org</owner> <owner>hesen@chromium.org</owner> <summary> @@ -703,7 +703,7 @@ </histogram> <histogram name="Notifications.Scheduler.BackgroundTask.Start" units="hours" - expires_after="2021-12-31"> + expires_after="2022-12-31"> <owner>xingliu@chromium.org</owner> <owner>hesen@chromium.org</owner> <summary> @@ -713,7 +713,7 @@ </histogram> <histogram name="Notifications.Scheduler.IconDb.InitResult" - enum="BooleanSuccess" expires_after="2021-12-31"> + enum="BooleanSuccess" expires_after="2022-12-31"> <owner>xingliu@chromium.org</owner> <owner>hesen@chromium.org</owner> <summary> @@ -723,7 +723,7 @@ </histogram> <histogram name="Notifications.Scheduler.IconDb.OperationResult" - enum="BooleanSuccess" expires_after="2021-12-31"> + enum="BooleanSuccess" expires_after="2022-12-31"> <owner>xingliu@chromium.org</owner> <owner>hesen@chromium.org</owner> <summary> @@ -743,7 +743,7 @@ </histogram> <histogram name="Notifications.Scheduler.IhnrActionButtonEvent" - enum="NotificationSchedulerActionButtonEvent" expires_after="2021-12-31"> + enum="NotificationSchedulerActionButtonEvent" expires_after="2022-12-31"> <!-- Name completed by histogram_suffixes name="NotificationSchedulerClientType" --> <owner>xingliu@chromium.org</owner> @@ -755,7 +755,7 @@ </histogram> <histogram name="Notifications.Scheduler.Impression.Count" units="records" - expires_after="2021-12-31"> + expires_after="2022-12-31"> <!-- Name completed by histogram_suffixes name="NotificationSchedulerClientType" --> <owner>xingliu@chromium.org</owner> @@ -767,7 +767,7 @@ </histogram> <histogram name="Notifications.Scheduler.Impression.Event" - enum="NotificationSchedulerImpressionEvent" expires_after="2021-12-31"> + enum="NotificationSchedulerImpressionEvent" expires_after="2022-12-31"> <owner>xingliu@chromium.org</owner> <owner>hesen@chromium.org</owner> <summary> @@ -777,7 +777,7 @@ </histogram> <histogram name="Notifications.Scheduler.ImpressionDb.InitResult" - enum="BooleanSuccess" expires_after="2021-12-31"> + enum="BooleanSuccess" expires_after="2022-12-31"> <owner>xingliu@chromium.org</owner> <owner>hesen@chromium.org</owner> <summary> @@ -787,7 +787,7 @@ </histogram> <histogram name="Notifications.Scheduler.ImpressionDb.OperationResult" - enum="BooleanSuccess" expires_after="2021-12-31"> + enum="BooleanSuccess" expires_after="2022-12-31"> <owner>xingliu@chromium.org</owner> <owner>hesen@chromium.org</owner> <summary> @@ -797,7 +797,7 @@ </histogram> <histogram name="Notifications.Scheduler.ImpressionDb.RecordCount" - units="records" expires_after="2021-12-31"> + units="records" expires_after="2022-12-31"> <owner>xingliu@chromium.org</owner> <owner>hesen@chromium.org</owner> <summary> @@ -807,7 +807,7 @@ </histogram> <histogram name="Notifications.Scheduler.NotificationDb.InitResult" - enum="BooleanSuccess" expires_after="2022-05-01"> + enum="BooleanSuccess" expires_after="2022-12-31"> <owner>xingliu@chromium.org</owner> <owner>hesen@chromium.org</owner> <summary> @@ -817,7 +817,7 @@ </histogram> <histogram name="Notifications.Scheduler.NotificationDb.OperationResult" - enum="BooleanSuccess" expires_after="2021-12-31"> + enum="BooleanSuccess" expires_after="2022-12-31"> <owner>xingliu@chromium.org</owner> <owner>hesen@chromium.org</owner> <summary> @@ -827,7 +827,7 @@ </histogram> <histogram name="Notifications.Scheduler.NotificationDb.RecordCount" - units="records" expires_after="2021-12-31"> + units="records" expires_after="2022-12-31"> <owner>xingliu@chromium.org</owner> <owner>hesen@chromium.org</owner> <summary> @@ -838,7 +838,7 @@ <histogram name="Notifications.Scheduler.NotificationLifeCycleEvent" enum="NotificationSchedulerNotificationLifeCycleEvent" - expires_after="2022-04-24"> + expires_after="2022-12-31"> <!-- Name completed by histogram_suffixes name="NotificationSchedulerClientType" --> <owner>xingliu@chromium.org</owner> @@ -850,7 +850,7 @@ </histogram> <histogram name="Notifications.Scheduler.PngIconConverter.DecodeResult" - enum="BooleanSuccess" expires_after="2021-12-31"> + enum="BooleanSuccess" expires_after="2022-12-31"> <owner>xingliu@chromium.org</owner> <owner>hesen@chromium.org</owner> <summary> @@ -862,7 +862,7 @@ </histogram> <histogram name="Notifications.Scheduler.PngIconConverter.EncodeResult" - enum="BooleanSuccess" expires_after="2021-12-31"> + enum="BooleanSuccess" expires_after="2022-12-31"> <owner>xingliu@chromium.org</owner> <owner>hesen@chromium.org</owner> <summary> @@ -874,7 +874,7 @@ </histogram> <histogram name="Notifications.Scheduler.UserAction" - enum="NotificationSchedulerUserActionType" expires_after="2022-05-01"> + enum="NotificationSchedulerUserActionType" expires_after="2022-12-31"> <!-- Name completed by histogram_suffixes name="NotificationSchedulerClientType" --> <owner>xingliu@chromium.org</owner>
diff --git a/tools/metrics/histograms/metadata/password/histograms.xml b/tools/metrics/histograms/metadata/password/histograms.xml index 74d18fed..220ca587 100644 --- a/tools/metrics/histograms/metadata/password/histograms.xml +++ b/tools/metrics/histograms/metadata/password/histograms.xml
@@ -2133,7 +2133,7 @@ </histogram> <histogram name="PasswordManager.PasswordReuse.PasswordFieldDetected" - enum="PasswordReusePasswordFieldDetected" expires_after="2021-09-19"> + enum="PasswordReusePasswordFieldDetected" expires_after="2022-05-30"> <owner>vakh@chromium.org</owner> <owner>chrome-safebrowsing-alerts@google.com</owner> <summary> @@ -2775,7 +2775,7 @@ </histogram> <histogram name="PasswordManager.SyncPasswordHashChange" - enum="GaiaPasswordHashChange" expires_after="2021-12-05"> + enum="GaiaPasswordHashChange" expires_after="2022-05-30"> <owner>drubery@chromium.org</owner> <owner>chrome-safebrowsing-alerts@google.com</owner> <summary>
diff --git a/tools/perf/core/perfetto_binary_roller/BUILD.gn b/tools/perf/core/perfetto_binary_roller/BUILD.gn index d7289e1..f74c171 100644 --- a/tools/perf/core/perfetto_binary_roller/BUILD.gn +++ b/tools/perf/core/perfetto_binary_roller/BUILD.gn
@@ -13,7 +13,7 @@ data = [ "//tools/perf/core/", "//DEPS", - "//.vpython", + "//.vpython3", ] if (is_win) {
diff --git a/tools/perf/core/perfetto_binary_roller/binary_deps.json b/tools/perf/core/perfetto_binary_roller/binary_deps.json index fc5df336..6dabb19 100644 --- a/tools/perf/core/perfetto_binary_roller/binary_deps.json +++ b/tools/perf/core/perfetto_binary_roller/binary_deps.json
@@ -5,20 +5,20 @@ "remote_path": "perfetto_binaries/trace_processor_shell/linux_arm/49b4b5dcbc312d8d2c3751cf29238b8efeb4e494/trace_processor_shell" }, "win": { - "hash": "04bce0e605a3a62f5b7a43ddeed1cbbf5fcf74c7", - "remote_path": "perfetto_binaries/trace_processor_shell/win/9e18a83edc73bc998ed8aa2ee481b57c8fc5f5f5/trace_processor_shell.exe" + "hash": "effa04c578df0d6ac049ea745e65dd07e27e1571", + "remote_path": "perfetto_binaries/trace_processor_shell/win/70f73380a55418668aa87df92c6c85253e053af3/trace_processor_shell.exe" }, "mac": { - "hash": "87ea36cb679df339c481aa3f0e23a6d3fc96a876", - "remote_path": "perfetto_binaries/trace_processor_shell/mac/d6e08a1daedf6bfad1790f768f58c5a30757860a/trace_processor_shell" + "hash": "da18cbcf3746a90969280a00571f81c8d0d147c3", + "remote_path": "perfetto_binaries/trace_processor_shell/mac/70f73380a55418668aa87df92c6c85253e053af3/trace_processor_shell" }, "linux_arm64": { "hash": "5074025a2898ec41a872e70a5719e417acb0a380", "remote_path": "perfetto_binaries/trace_processor_shell/linux_arm64/49b4b5dcbc312d8d2c3751cf29238b8efeb4e494/trace_processor_shell" }, "linux": { - "hash": "1d0330761d312684fc101d2eb377eba1a3e2529d", - "remote_path": "perfetto_binaries/trace_processor_shell/linux/abe1a8bc88f4de6d0e796f5e925c65c8bc09f796/trace_processor_shell" + "hash": "f34f733ad287f6af4bfebf77a481fd20324d570a", + "remote_path": "perfetto_binaries/trace_processor_shell/linux/70f73380a55418668aa87df92c6c85253e053af3/trace_processor_shell" } }, "power_profile.sql": {
diff --git a/tools/perf/core/perfetto_binary_roller/upload_trace_processor.py b/tools/perf/core/perfetto_binary_roller/upload_trace_processor.py index 1e986cd..299ab7b2 100755 --- a/tools/perf/core/perfetto_binary_roller/upload_trace_processor.py +++ b/tools/perf/core/perfetto_binary_roller/upload_trace_processor.py
@@ -1,4 +1,4 @@ -#!/usr/bin/env vpython +#!/usr/bin/env vpython3 # Copyright 2020 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file.
diff --git a/tools/perf/core/results_processor/command_line.py b/tools/perf/core/results_processor/command_line.py index 51c3ef4..17255d16 100644 --- a/tools/perf/core/results_processor/command_line.py +++ b/tools/perf/core/results_processor/command_line.py
@@ -104,12 +104,12 @@ action='store_true', help='Android-specific argument to enable fetching data from a device.') group.add_argument( - '--device-data-path', + '--fetch-data-path-device', dest='device_data_path', help=('Android-specific argument for --fetch-data-device. Use this to ' 'specify the path on device to pull data from using adb.')) group.add_argument( - '--local-data-path', + '--fetch-data-path-local', dest='local_data_path', default=os.environ.get('ISOLATED_OUTDIR'), help=('Android-specific argument for --fetch-data-device. Use this to '
diff --git a/ui/accessibility/ax_tree_manager.h b/ui/accessibility/ax_tree_manager.h index ba8b4b6..1081ed8 100644 --- a/ui/accessibility/ax_tree_manager.h +++ b/ui/accessibility/ax_tree_manager.h
@@ -20,6 +20,7 @@ // Returns the AXNode with the given |node_id| from the tree that has the // given |tree_id|. This allows for callers to access nodes outside of their // own tree. Returns nullptr if |tree_id| or |node_id| is not found. + // TODO(kschmi): Remove |tree_id| parameter, as it's unnecessary. virtual AXNode* GetNodeFromTree(const AXTreeID tree_id, const AXNodeID node_id) const = 0;
diff --git a/ui/accessibility/platform/BUILD.gn b/ui/accessibility/platform/BUILD.gn index ad4ac3ca..d06bdd1 100644 --- a/ui/accessibility/platform/BUILD.gn +++ b/ui/accessibility/platform/BUILD.gn
@@ -37,6 +37,7 @@ "ax_platform_node_delegate.h", # Used by browser_accessibility.cc. + "ax_platform_tree_manager.h", "ax_unique_id.cc", "ax_unique_id.h",
diff --git a/ui/accessibility/platform/ax_platform_node_cocoa.mm b/ui/accessibility/platform/ax_platform_node_cocoa.mm index 02dc25aa..8406825 100644 --- a/ui/accessibility/platform/ax_platform_node_cocoa.mm +++ b/ui/accessibility/platform/ax_platform_node_cocoa.mm
@@ -810,7 +810,17 @@ // Table and grid. if (ui::IsTableLike(role)) { - [axAttributes addObject:NSAccessibilityColumnHeaderUIElementsAttribute]; + [axAttributes addObjectsFromArray:@[ + NSAccessibilityColumnHeaderUIElementsAttribute, + NSAccessibilityARIAColumnCountAttribute, + NSAccessibilityARIARowCountAttribute, + ]]; + } + if (ui::IsCellOrTableHeader(role)) { + [axAttributes addObjectsFromArray:@[ + NSAccessibilityARIAColumnIndexAttribute, + NSAccessibilityARIARowIndexAttribute, + ]]; } if (ui::IsCellOrTableHeader(role) && role != ax::mojom::Role::kColumnHeader) { [axAttributes addObject:NSAccessibilityColumnHeaderUIElementsAttribute]; @@ -920,6 +930,28 @@ return @"false"; } +- (NSNumber*)AXARIAColumnCount { + if (![self instanceActive]) + return nil; + absl::optional<int> ariaColCount = + _node->GetDelegate()->GetTableAriaColCount(); + if (!ariaColCount) + return nil; + return @(*ariaColCount); +} + +- (NSNumber*)AXARIAColumnIndex { + if (![self instanceActive]) + return nil; + + absl::optional<int> ariaColIndex = + _node->GetDelegate()->GetTableCellAriaColIndex(); + if (!ariaColIndex) + + return nil; + return @(*ariaColIndex); +} + - (NSString*)AXARIALive { if (![self instanceActive]) return nil; @@ -934,6 +966,26 @@ return [self getStringAttribute:ax::mojom::StringAttribute::kLiveRelevant]; } +- (NSNumber*)AXARIARowCount { + if (![self instanceActive]) + return nil; + absl::optional<int> ariaRowCount = + _node->GetDelegate()->GetTableAriaRowCount(); + if (!ariaRowCount) + return nil; + return @(*ariaRowCount); +} + +- (NSNumber*)AXARIARowIndex { + if (![self instanceActive]) + return nil; + absl::optional<int> ariaRowIndex = + _node->GetDelegate()->GetTableCellAriaRowIndex(); + if (!ariaRowIndex) + return nil; + return @(*ariaRowIndex); +} + - (NSString*)AXAutocompleteValue { if (![self instanceActive]) return nil;
diff --git a/ui/accessibility/platform/ax_platform_node_textchildprovider_win_unittest.cc b/ui/accessibility/platform/ax_platform_node_textchildprovider_win_unittest.cc index b66ad52..6caea7060 100644 --- a/ui/accessibility/platform/ax_platform_node_textchildprovider_win_unittest.cc +++ b/ui/accessibility/platform/ax_platform_node_textchildprovider_win_unittest.cc
@@ -130,6 +130,16 @@ } } + void SetOwner(AXPlatformNodeWin* owner, + ITextRangeProvider* destination_range) { + ComPtr<ITextRangeProvider> destination_provider = destination_range; + ComPtr<AXPlatformNodeTextRangeProviderWin> destination_provider_interal; + + destination_provider->QueryInterface( + IID_PPV_ARGS(&destination_provider_interal)); + destination_provider_interal->SetOwnerForTesting(owner); + } + ComPtr<IRawElementProviderSimple> root_provider_raw_; ComPtr<IRawElementProviderSimple> nontext_child_of_root_provider_raw_; ComPtr<IRawElementProviderSimple> text_child_of_root_text_provider_raw_; @@ -268,6 +278,10 @@ nontext_child_of_root_text_child_provider_->get_TextRange( &text_range_provider)); ASSERT_NE(nullptr, text_range_provider.Get()); + AXPlatformNodeWin* owner = static_cast<AXPlatformNodeWin*>( + AXPlatformNodeFromNode(GetRootAsAXNode())); + ASSERT_NE(nullptr, owner); + SetOwner(owner, text_range_provider.Get()); base::win::ScopedBstr text_content; // By design, empty objects, such as the unlabelled image in this case, are @@ -289,6 +303,10 @@ text_child_of_root_text_child_provider_->get_TextRange( &text_range_provider)); ASSERT_NE(nullptr, text_range_provider.Get()); + AXPlatformNodeWin* owner = static_cast<AXPlatformNodeWin*>( + AXPlatformNodeFromNode(GetRootAsAXNode())); + ASSERT_NE(nullptr, owner); + SetOwner(owner, text_range_provider.Get()); base::win::ScopedBstr text_content; EXPECT_HRESULT_SUCCEEDED( @@ -308,6 +326,10 @@ nontext_child_of_nontext_text_child_provider_->get_TextRange( &text_range_provider)); ASSERT_NE(nullptr, text_range_provider.Get()); + AXPlatformNodeWin* owner = static_cast<AXPlatformNodeWin*>( + AXPlatformNodeFromNode(GetRootAsAXNode())); + ASSERT_NE(nullptr, owner); + SetOwner(owner, text_range_provider.Get()); base::win::ScopedBstr text_content; EXPECT_HRESULT_SUCCEEDED( @@ -327,6 +349,10 @@ text_child_of_nontext_text_child_provider_->get_TextRange( &text_range_provider)); ASSERT_NE(nullptr, text_range_provider.Get()); + AXPlatformNodeWin* owner = static_cast<AXPlatformNodeWin*>( + AXPlatformNodeFromNode(GetRootAsAXNode())); + ASSERT_NE(nullptr, owner); + SetOwner(owner, text_range_provider.Get()); base::win::ScopedBstr text_content; EXPECT_HRESULT_SUCCEEDED( @@ -346,6 +372,10 @@ text_child_of_text_text_child_provider_->get_TextRange( &text_range_provider)); ASSERT_NE(nullptr, text_range_provider.Get()); + AXPlatformNodeWin* owner = static_cast<AXPlatformNodeWin*>( + AXPlatformNodeFromNode(GetRootAsAXNode())); + ASSERT_NE(nullptr, owner); + SetOwner(owner, text_range_provider.Get()); base::win::ScopedBstr text_content; EXPECT_HRESULT_SUCCEEDED(
diff --git a/ui/accessibility/platform/ax_platform_node_textprovider_win.cc b/ui/accessibility/platform/ax_platform_node_textprovider_win.cc index b845c3d..5d7e546 100644 --- a/ui/accessibility/platform/ax_platform_node_textprovider_win.cc +++ b/ui/accessibility/platform/ax_platform_node_textprovider_win.cc
@@ -94,7 +94,7 @@ Microsoft::WRL::ComPtr<ITextRangeProvider> text_range_provider = AXPlatformNodeTextRangeProviderWin::CreateTextRangeProvider( - owner_.Get(), std::move(start), std::move(end)); + std::move(start), std::move(end)); if (&text_range_provider == nullptr) return E_OUTOFMEMORY; @@ -157,8 +157,7 @@ if (frame_rect.Contains(current_rect)) { Microsoft::WRL::ComPtr<ITextRangeProvider> text_range_provider = AXPlatformNodeTextRangeProviderWin::CreateTextRangeProvider( - owner_.Get(), current_line_start->Clone(), - current_line_end->Clone()); + current_line_start->Clone(), current_line_end->Clone()); ranges.emplace_back(text_range_provider); } @@ -237,7 +236,7 @@ end = start->Clone(); *range = AXPlatformNodeTextRangeProviderWin::CreateTextRangeProvider( - nearest_node, std::move(start), std::move(end)); + std::move(start), std::move(end)); return S_OK; } @@ -326,7 +325,7 @@ } return AXPlatformNodeTextRangeProviderWin::CreateTextRangeProvider( - ancestor, std::move(start), std::move(end)); + std::move(start), std::move(end)); } ITextRangeProvider* AXPlatformNodeTextProviderWin::CreateDegenerateRangeAtStart( @@ -339,7 +338,7 @@ start = node->GetDelegate()->CreateTextPositionAt(0)->AsLeafTextPosition(); end = start->Clone(); return AXPlatformNodeTextRangeProviderWin::CreateTextRangeProvider( - node, std::move(start), std::move(end)); + std::move(start), std::move(end)); } ui::AXPlatformNodeWin* AXPlatformNodeTextProviderWin::owner() const { @@ -369,7 +368,7 @@ /*offset*/ active_composition_offset.end()); *range = AXPlatformNodeTextRangeProviderWin::CreateTextRangeProvider( - owner_.Get(), std::move(start), std::move(end)); + std::move(start), std::move(end)); } return S_OK;
diff --git a/ui/accessibility/platform/ax_platform_node_textprovider_win_unittest.cc b/ui/accessibility/platform/ax_platform_node_textprovider_win_unittest.cc index 6adcc2d..b4b9d69 100644 --- a/ui/accessibility/platform/ax_platform_node_textprovider_win_unittest.cc +++ b/ui/accessibility/platform/ax_platform_node_textprovider_win_unittest.cc
@@ -39,6 +39,15 @@ const AXPlatformNodeTextProviderTest&) = delete; protected: + void SetOwner(AXPlatformNodeWin* owner, + ITextRangeProvider* destination_range) { + ComPtr<ITextRangeProvider> destination_provider = destination_range; + ComPtr<AXPlatformNodeTextRangeProviderWin> destination_provider_interal; + + destination_provider->QueryInterface( + IID_PPV_ARGS(&destination_provider_interal)); + destination_provider_interal->SetOwnerForTesting(owner); + } AXPlatformNodeWin* GetOwner( const AXPlatformNodeTextProviderWin* text_provider) { return text_provider->owner_.Get(); @@ -87,6 +96,9 @@ AXNode* root_node = GetRootAsAXNode(); AXNode* link_node = root_node->children()[0]; AXNode* text2_node = link_node->children()[1]; + AXPlatformNodeWin* owner = + static_cast<AXPlatformNodeWin*>(AXPlatformNodeFromNode(root_node)); + DCHECK(owner); ComPtr<IRawElementProviderSimple> root_node_raw = QueryInterfaceFromNode<IRawElementProviderSimple>(root_node); @@ -110,6 +122,7 @@ ComPtr<ITextRangeProvider> text_range_provider = AXPlatformNodeTextProviderWin::CreateDegenerateRangeAtStart( root_platform_node.Get()); + SetOwner(owner, text_range_provider.Get()); base::win::ScopedBstr text_content; EXPECT_HRESULT_SUCCEEDED( text_range_provider->GetText(-1, text_content.Receive())); @@ -129,6 +142,7 @@ text_range_provider = AXPlatformNodeTextProviderWin::CreateDegenerateRangeAtStart( link_platform_node.Get()); + SetOwner(owner, text_range_provider.Get()); EXPECT_HRESULT_SUCCEEDED( text_range_provider->GetText(-1, text_content.Receive())); EXPECT_EQ(0, wcscmp(text_content.Get(), L"")); @@ -142,6 +156,7 @@ text_range_provider = AXPlatformNodeTextProviderWin::CreateDegenerateRangeAtStart( text2_platform_node.Get()); + SetOwner(owner, text_range_provider.Get()); EXPECT_HRESULT_SUCCEEDED( text_range_provider->GetText(-1, text_content.Receive())); EXPECT_EQ(0, wcscmp(text_content.Get(), L"")); @@ -185,6 +200,9 @@ AXNode* root_node = GetRootAsAXNode(); AXNode* text_node = root_node->children()[0]; AXNode* empty_text_node = root_node->children()[1]; + AXPlatformNodeWin* owner = + static_cast<AXPlatformNodeWin*>(AXPlatformNodeFromNode(root_node)); + DCHECK(owner); ComPtr<IRawElementProviderSimple> root_node_raw = QueryInterfaceFromNode<IRawElementProviderSimple>(root_node); @@ -201,6 +219,7 @@ ComPtr<ITextRangeProvider> text_range_provider; EXPECT_HRESULT_SUCCEEDED( text_provider->RangeFromChild(text_node_raw.Get(), &text_range_provider)); + SetOwner(owner, text_range_provider.Get()); base::win::ScopedBstr text_content; EXPECT_HRESULT_SUCCEEDED( @@ -221,6 +240,7 @@ EXPECT_HRESULT_SUCCEEDED(text_provider->RangeFromChild( empty_text_node_raw.Get(), &text_range_provider)); + SetOwner(owner, text_range_provider.Get()); base::win::ScopedBstr empty_text_content; EXPECT_HRESULT_SUCCEEDED( @@ -306,6 +326,9 @@ AXNode* root_node = GetRootAsAXNode(); AXNode* dialog_node = root_node->children()[0]; + AXPlatformNodeWin* owner = + static_cast<AXPlatformNodeWin*>(AXPlatformNodeFromNode(root_node)); + DCHECK(owner); ComPtr<IRawElementProviderSimple> root_node_raw = QueryInterfaceFromNode<IRawElementProviderSimple>(root_node); @@ -320,6 +343,7 @@ ComPtr<ITextRangeProvider> text_range_provider; EXPECT_HRESULT_SUCCEEDED(text_provider->RangeFromChild(dialog_node_raw.Get(), &text_range_provider)); + SetOwner(owner, text_range_provider.Get()); base::win::ScopedBstr text_content; EXPECT_HRESULT_SUCCEEDED( @@ -661,6 +685,7 @@ ComPtr<ITextRangeProvider> text_range_provider; EXPECT_HRESULT_SUCCEEDED(SafeArrayGetElement( selections.Get(), &index, static_cast<void**>(&text_range_provider))); + SetOwner(owner, text_range_provider.Get()); base::win::ScopedBstr text_content; EXPECT_HRESULT_SUCCEEDED( @@ -687,6 +712,7 @@ EXPECT_HRESULT_SUCCEEDED(SafeArrayGetElement( selections.Get(), &index, static_cast<void**>(&text_range_provider))); + SetOwner(owner, text_range_provider.Get()); EXPECT_HRESULT_SUCCEEDED( text_range_provider->GetText(-1, text_content.Receive())); @@ -725,7 +751,7 @@ EXPECT_HRESULT_SUCCEEDED( SafeArrayGetElement(selections.Get(), &index, static_cast<void**>(&text_edit_range_provider))); - + SetOwner(owner, text_edit_range_provider.Get()); EXPECT_HRESULT_SUCCEEDED( text_edit_range_provider->GetText(-1, text_content.Receive())); EXPECT_EQ(0U, text_content.Length()); @@ -750,6 +776,7 @@ EXPECT_HRESULT_SUCCEEDED(SafeArrayGetElement( selections.Get(), &index, static_cast<void**>(&text_range_provider))); + SetOwner(owner, text_range_provider.Get()); EXPECT_HRESULT_SUCCEEDED( text_range_provider->GetText(-1, text_content.Receive())); EXPECT_EQ(0, wcscmp(text_content.Get(), L"some texttextbox text")); @@ -774,6 +801,7 @@ EXPECT_HRESULT_SUCCEEDED(SafeArrayGetElement( selections.Get(), &index, static_cast<void**>(&text_range_provider))); + SetOwner(owner, text_range_provider.Get()); EXPECT_HRESULT_SUCCEEDED( text_range_provider->GetText(-1, text_content.Receive())); EXPECT_EQ(0, wcscmp(text_content.Get(), L"")); @@ -797,6 +825,7 @@ EXPECT_HRESULT_SUCCEEDED(SafeArrayGetElement( selections.Get(), &index, static_cast<void**>(&text_range_provider))); + SetOwner(owner, text_range_provider.Get()); EXPECT_HRESULT_SUCCEEDED( text_range_provider->GetText(-1, text_content.Receive())); EXPECT_EQ(0, wcscmp(text_content.Get(), L"text"));
diff --git a/ui/accessibility/platform/ax_platform_node_textrangeprovider_win.cc b/ui/accessibility/platform/ax_platform_node_textrangeprovider_win.cc index 74483e00..e0155df 100644 --- a/ui/accessibility/platform/ax_platform_node_textrangeprovider_win.cc +++ b/ui/accessibility/platform/ax_platform_node_textrangeprovider_win.cc
@@ -14,32 +14,33 @@ #include "base/win/variant_vector.h" #include "ui/accessibility/ax_action_data.h" #include "ui/accessibility/platform/ax_platform_node_delegate.h" +#include "ui/accessibility/platform/ax_platform_tree_manager.h" -#define UIA_VALIDATE_TEXTRANGEPROVIDER_CALL() \ - if (!owner() || !owner()->GetDelegate() || !start() || \ - !start()->GetAnchor() || !end() || !end()->GetAnchor()) \ - return UIA_E_ELEMENTNOTAVAILABLE; \ - SetStart(start()->AsValidPosition()); \ +#define UIA_VALIDATE_TEXTRANGEPROVIDER_CALL() \ + if (!GetOwner() || !GetOwner()->GetDelegate() || !start() || \ + !start()->GetAnchor() || !end() || !end()->GetAnchor()) \ + return UIA_E_ELEMENTNOTAVAILABLE; \ + SetStart(start()->AsValidPosition()); \ SetEnd(end()->AsValidPosition()); -#define UIA_VALIDATE_TEXTRANGEPROVIDER_CALL_1_IN(in) \ - if (!owner() || !owner()->GetDelegate() || !start() || \ - !start()->GetAnchor() || !end() || !end()->GetAnchor()) \ - return UIA_E_ELEMENTNOTAVAILABLE; \ - if (!in) \ - return E_POINTER; \ - SetStart(start()->AsValidPosition()); \ +#define UIA_VALIDATE_TEXTRANGEPROVIDER_CALL_1_IN(in) \ + if (!GetOwner() || !GetOwner()->GetDelegate() || !start() || \ + !start()->GetAnchor() || !end() || !end()->GetAnchor()) \ + return UIA_E_ELEMENTNOTAVAILABLE; \ + if (!in) \ + return E_POINTER; \ + SetStart(start()->AsValidPosition()); \ SetEnd(end()->AsValidPosition()); -#define UIA_VALIDATE_TEXTRANGEPROVIDER_CALL_1_OUT(out) \ - if (!owner() || !owner()->GetDelegate() || !start() || \ - !start()->GetAnchor() || !end() || !end()->GetAnchor()) \ - return UIA_E_ELEMENTNOTAVAILABLE; \ - if (!out) \ - return E_POINTER; \ - *out = {}; \ - SetStart(start()->AsValidPosition()); \ +#define UIA_VALIDATE_TEXTRANGEPROVIDER_CALL_1_OUT(out) \ + if (!GetOwner() || !GetOwner()->GetDelegate() || !start() || \ + !start()->GetAnchor() || !end() || !end()->GetAnchor()) \ + return UIA_E_ELEMENTNOTAVAILABLE; \ + if (!out) \ + return E_POINTER; \ + *out = {}; \ + SetStart(start()->AsValidPosition()); \ SetEnd(end()->AsValidPosition()); #define UIA_VALIDATE_TEXTRANGEPROVIDER_CALL_1_IN_1_OUT(in, out) \ - if (!owner() || !owner()->GetDelegate() || !start() || \ + if (!GetOwner() || !GetOwner()->GetDelegate() || !start() || \ !start()->GetAnchor() || !end() || !end()->GetAnchor()) \ return UIA_E_ELEMENTNOTAVAILABLE; \ if (!in || !out) \ @@ -96,14 +97,12 @@ AXPlatformNodeTextRangeProviderWin::~AXPlatformNodeTextRangeProviderWin() {} ITextRangeProvider* AXPlatformNodeTextRangeProviderWin::CreateTextRangeProvider( - AXPlatformNodeWin* owner, AXPositionInstance start, AXPositionInstance end) { CComObject<AXPlatformNodeTextRangeProviderWin>* text_range_provider = nullptr; if (SUCCEEDED(CComObject<AXPlatformNodeTextRangeProviderWin>::CreateInstance( &text_range_provider))) { DCHECK(text_range_provider); - text_range_provider->owner_ = owner; text_range_provider->SetStart(std::move(start)); text_range_provider->SetEnd(std::move(end)); text_range_provider->AddRef(); @@ -113,6 +112,24 @@ return nullptr; } +ITextRangeProvider* +AXPlatformNodeTextRangeProviderWin::CreateTextRangeProviderForTesting( + AXPlatformNodeWin* owner, + AXPositionInstance start, + AXPositionInstance end) { + Microsoft::WRL::ComPtr<ITextRangeProvider> text_range_provider = + CreateTextRangeProvider(start->Clone(), end->Clone()); + Microsoft::WRL::ComPtr<AXPlatformNodeTextRangeProviderWin> + text_range_provider_win; + if (SUCCEEDED(text_range_provider->QueryInterface( + IID_PPV_ARGS(&text_range_provider_win)))) { + text_range_provider_win->SetOwnerForTesting(owner); // IN-TEST + return text_range_provider_win.Get(); + } + + return nullptr; +} + // // ITextRangeProvider methods. // @@ -120,8 +137,7 @@ WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TEXTRANGE_CLONE); UIA_VALIDATE_TEXTRANGEPROVIDER_CALL_1_OUT(clone); - *clone = - CreateTextRangeProvider(owner_.Get(), start()->Clone(), end()->Clone()); + *clone = CreateTextRangeProvider(start()->Clone(), end()->Clone()); return S_OK; } @@ -382,7 +398,7 @@ return E_FAIL; if (matched_range_start != nullptr && matched_range_end != nullptr) - *result = CreateTextRangeProvider(owner(), std::move(matched_range_start), + *result = CreateTextRangeProvider(std::move(matched_range_start), std::move(matched_range_end)); return S_OK; } @@ -483,8 +499,7 @@ ax::mojom::TextAffinity::kDownstream) ->AsLeafTextPosition(); - *result = - CreateTextRangeProvider(owner_.Get(), start->Clone(), end->Clone()); + *result = CreateTextRangeProvider(start->Clone(), end->Clone()); } return S_OK; } @@ -914,7 +929,7 @@ UIA_VALIDATE_BOUNDS(root_frame_bounds); const AXPlatformNode* common_ancestor_platform_node = - owner_->GetDelegate()->GetFromTreeIDAndNodeID( + GetOwner()->GetDelegate()->GetFromTreeIDAndNodeID( common_ancestor_tree_id, common_ancestor_anchor->id()); DCHECK(common_ancestor_platform_node); AXPlatformNodeDelegate* common_ancestor_delegate = @@ -1063,8 +1078,31 @@ max_count, false, appended_newlines_count); } -AXPlatformNodeWin* AXPlatformNodeTextRangeProviderWin::owner() const { - return owner_.Get(); +AXPlatformNodeWin* AXPlatformNodeTextRangeProviderWin::GetOwner() const { + // Unit tests can't call |GetPlatformNodeFromTree|, so they must provide an + // owner node. + if (owner_for_test_.Get()) + return owner_for_test_.Get(); + + const AXPositionInstance& position = + !start()->IsNullPosition() ? start() : end(); + // If start and end are both null, there's no owner. + if (position->IsNullPosition()) + return nullptr; + + const AXNode* anchor = position->GetAnchor(); + DCHECK(anchor); + AXTreeID tree_id = anchor->tree()->GetAXTreeID(); + const AXTreeManager* ax_tree_manager = + AXTreeManagerMap::GetInstance().GetManager(tree_id); + DCHECK(ax_tree_manager); + + const AXPlatformTreeManager* platform_tree_manager = + static_cast<const AXPlatformTreeManager*>(ax_tree_manager); + DCHECK(platform_tree_manager); + + return static_cast<AXPlatformNodeWin*>( + platform_tree_manager->GetPlatformNodeFromTree(*anchor)); } AXPlatformNodeDelegate* AXPlatformNodeTextRangeProviderWin::GetDelegate( @@ -1076,7 +1114,7 @@ const AXTreeID tree_id, const AXNodeID node_id) const { AXPlatformNode* platform_node = - owner_->GetDelegate()->GetFromTreeIDAndNodeID(tree_id, node_id); + GetOwner()->GetDelegate()->GetFromTreeIDAndNodeID(tree_id, node_id); if (!platform_node) return nullptr; @@ -1307,7 +1345,8 @@ DCHECK(ax_tree_manager); AXNode* root_node = ax_tree_manager->GetRootAsAXNode(); const AXPlatformNode* root_platform_node = - owner_->GetDelegate()->GetFromTreeIDAndNodeID(tree_id, root_node->id()); + GetOwner()->GetDelegate()->GetFromTreeIDAndNodeID(tree_id, + root_node->id()); DCHECK(root_platform_node); return root_platform_node->GetDelegate(); } @@ -1321,8 +1360,13 @@ endpoints_.SetEnd(std::move(new_end)); } +void AXPlatformNodeTextRangeProviderWin::SetOwnerForTesting( + AXPlatformNodeWin* owner) { + owner_for_test_ = owner; +} + AXNode* AXPlatformNodeTextRangeProviderWin::GetSelectionCommonAnchor() { - AXPlatformNodeDelegate* delegate = owner()->GetDelegate(); + AXPlatformNodeDelegate* delegate = GetOwner()->GetDelegate(); ui::AXTree::Selection unignored_selection = delegate->GetUnignoredSelection(); AXPlatformNode* anchor_object = delegate->GetFromNodeID(unignored_selection.anchor_object_id);
diff --git a/ui/accessibility/platform/ax_platform_node_textrangeprovider_win.h b/ui/accessibility/platform/ax_platform_node_textrangeprovider_win.h index d6d4809..0d1874b 100644 --- a/ui/accessibility/platform/ax_platform_node_textrangeprovider_win.h +++ b/ui/accessibility/platform/ax_platform_node_textrangeprovider_win.h
@@ -32,6 +32,12 @@ // Creates an instance of the class. static ITextRangeProvider* CreateTextRangeProvider( + AXNodePosition::AXPositionInstance start, + AXNodePosition::AXPositionInstance end); + + // Creates an instance of the class for unit tests, where AXPlatformNodes + // cannot be queried automatically from endpoints. + static ITextRangeProvider* CreateTextRangeProviderForTesting( AXPlatformNodeWin* owner, AXNodePosition::AXPositionInstance start, AXNodePosition::AXPositionInstance end); @@ -81,6 +87,9 @@ IFACEMETHODIMP ScrollIntoView(BOOL align_to_top) override; IFACEMETHODIMP GetChildren(SAFEARRAY** children) override; + AXPlatformNodeWin* GetOwner() const; + void SetOwnerForTesting(AXPlatformNodeWin* owner); + private: using AXPositionInstance = AXNodePosition::AXPositionInstance; using AXPositionInstanceType = typename AXPositionInstance::element_type; @@ -111,7 +120,6 @@ std::u16string GetString(int max_count, size_t* appended_newlines_count = nullptr); - AXPlatformNodeWin* owner() const; const AXPositionInstance& start() const { return endpoints_.GetStart(); } const AXPositionInstance& end() const { return endpoints_.GetEnd(); } AXPlatformNodeDelegate* GetDelegate( @@ -193,7 +201,7 @@ TEXTATTRIBUTEID attribute_id, const base::win::VariantVector& vector); - Microsoft::WRL::ComPtr<AXPlatformNodeWin> owner_; + Microsoft::WRL::ComPtr<AXPlatformNodeWin> owner_for_test_; // Why we can't use a ScopedObserver here: // We tried using a ScopedObserver instead of a simple observer in this case,
diff --git a/ui/accessibility/platform/ax_platform_node_textrangeprovider_win_unittest.cc b/ui/accessibility/platform/ax_platform_node_textrangeprovider_win_unittest.cc index 5c0c65f7..4b6d18d 100644 --- a/ui/accessibility/platform/ax_platform_node_textrangeprovider_win_unittest.cc +++ b/ui/accessibility/platform/ax_platform_node_textrangeprovider_win_unittest.cc
@@ -142,12 +142,14 @@ EXPECT_STREQ(expected_content, provider_content.Get()); \ } -#define EXPECT_UIA_FIND_TEXT(text_range_provider, search_term, ignore_case) \ +#define EXPECT_UIA_FIND_TEXT(text_range_provider, search_term, ignore_case, \ + owner) \ { \ base::win::ScopedBstr find_string(search_term); \ ComPtr<ITextRangeProvider> text_range_provider_found; \ EXPECT_HRESULT_SUCCEEDED(text_range_provider->FindText( \ find_string.Get(), false, ignore_case, &text_range_provider_found)); \ + SetOwner(owner, text_range_provider_found.Get()); \ base::win::ScopedBstr found_content; \ EXPECT_HRESULT_SUCCEEDED( \ text_range_provider_found->GetText(-1, found_content.Receive())); \ @@ -158,7 +160,7 @@ } #define EXPECT_UIA_FIND_TEXT_NO_MATCH(text_range_provider, search_term, \ - ignore_case) \ + ignore_case, owner) \ { \ base::win::ScopedBstr find_string(search_term); \ ComPtr<ITextRangeProvider> text_range_provider_found; \ @@ -213,7 +215,31 @@ ui::AXPlatformNodeWin* GetOwner( const AXPlatformNodeTextRangeProviderWin* text_range) { - return text_range->owner_.Get(); + return text_range->GetOwner(); + } + + void CopyOwnerToClone(ITextRangeProvider* source_range, + ITextRangeProvider* destination_range) { + ComPtr<ITextRangeProvider> source_provider = source_range; + ComPtr<ITextRangeProvider> destination_provider = destination_range; + + ComPtr<AXPlatformNodeTextRangeProviderWin> source_provider_internal; + ComPtr<AXPlatformNodeTextRangeProviderWin> destination_provider_internal; + + source_provider->QueryInterface(IID_PPV_ARGS(&source_provider_internal)); + destination_provider->QueryInterface( + IID_PPV_ARGS(&destination_provider_internal)); + destination_provider_internal->SetOwnerForTesting( + source_provider_internal->GetOwner()); + } + + void SetOwner(AXPlatformNodeWin* owner, + ITextRangeProvider* destination_range) { + ComPtr<AXPlatformNodeTextRangeProviderWin> destination_provider_internal; + + destination_range->QueryInterface( + IID_PPV_ARGS(&destination_provider_internal)); + destination_provider_internal->SetOwnerForTesting(owner); } void NormalizeTextRange(AXPlatformNodeTextRangeProviderWin* text_range, @@ -224,15 +250,6 @@ text_range->NormalizeTextRange(start, end); } - ComPtr<AXPlatformNodeTextRangeProviderWin> CloneTextRangeProviderWin( - AXPlatformNodeTextRangeProviderWin* text_range) { - ComPtr<ITextRangeProvider> clone; - text_range->Clone(&clone); - ComPtr<AXPlatformNodeTextRangeProviderWin> clone_win; - clone->QueryInterface(IID_PPV_ARGS(&clone_win)); - return clone_win; - } - void GetTextRangeProviderFromTextNode( ComPtr<ITextRangeProvider>& text_range_provider, ui::AXNode* text_node) { @@ -248,6 +265,14 @@ EXPECT_HRESULT_SUCCEEDED( text_provider->get_DocumentRange(&text_range_provider)); ASSERT_NE(nullptr, text_range_provider.Get()); + + ComPtr<AXPlatformNodeTextRangeProviderWin> text_range_provider_interal; + EXPECT_HRESULT_SUCCEEDED(text_range_provider->QueryInterface( + IID_PPV_ARGS(&text_range_provider_interal))); + AXPlatformNode* ax_platform_node = AXPlatformNodeFromNode(text_node); + ASSERT_NE(ax_platform_node, nullptr); + text_range_provider_interal->SetOwnerForTesting( + static_cast<AXPlatformNodeWin*>(ax_platform_node)); } void CreateTextRangeProviderWin( @@ -268,7 +293,7 @@ end_affinity); ComPtr<ITextRangeProvider> text_range_provider = - AXPlatformNodeTextRangeProviderWin::CreateTextRangeProvider( + AXPlatformNodeTextRangeProviderWin::CreateTextRangeProviderForTesting( owner, std::move(range_start), std::move(range_end)); text_range_provider->QueryInterface(IID_PPV_ARGS(&text_range_provider_win)); @@ -994,7 +1019,7 @@ ComPtr<ITextRangeProvider> text_range_provider_clone; text_range_provider->Clone(&text_range_provider_clone); - + CopyOwnerToClone(text_range_provider.Get(), text_range_provider_clone.Get()); ComPtr<AXPlatformNodeTextRangeProviderWin> original_range; ComPtr<AXPlatformNodeTextRangeProviderWin> clone_range; @@ -1340,6 +1365,9 @@ AXNode* root_node = GetRootAsAXNode(); ComPtr<ITextRangeProvider> text_range_provider; GetTextRangeProviderFromTextNode(text_range_provider, root_node); + ComPtr<AXPlatformNodeTextRangeProviderWin> text_range_provider_internal; + ASSERT_HRESULT_SUCCEEDED(text_range_provider->QueryInterface( + IID_PPV_ARGS(&text_range_provider_internal))); EXPECT_UIA_TEXTRANGE_EQ( text_range_provider, @@ -1355,6 +1383,8 @@ // and B for this test. ComPtr<ITextRangeProvider> units_a_b_provider; ASSERT_HRESULT_SUCCEEDED(text_range_provider->Clone(&units_a_b_provider)); + CopyOwnerToClone(text_range_provider.Get(), units_a_b_provider.Get()); + int count; ASSERT_HRESULT_SUCCEEDED(units_a_b_provider->MoveEndpointByUnit( TextPatternRangeEndpoint_Start, TextUnit_Line, /*count*/ 5, &count)); @@ -1369,6 +1399,7 @@ // value of a range from start of A to end of A. ComPtr<ITextRangeProvider> unit_a_provider; ASSERT_HRESULT_SUCCEEDED(units_a_b_provider->Clone(&unit_a_provider)); + CopyOwnerToClone(units_a_b_provider.Get(), unit_a_provider.Get()); ASSERT_HRESULT_SUCCEEDED(unit_a_provider->MoveEndpointByUnit( TextPatternRangeEndpoint_End, TextUnit_Line, /*count*/ -2, &count)); ASSERT_EQ(-2, count); @@ -1379,6 +1410,7 @@ SCOPED_TRACE("Case 1: Degenerate range at start of A."); ComPtr<ITextRangeProvider> test_case_provider; ASSERT_HRESULT_SUCCEEDED(unit_a_provider->Clone(&test_case_provider)); + CopyOwnerToClone(unit_a_provider.Get(), test_case_provider.Get()); ASSERT_HRESULT_SUCCEEDED(test_case_provider->MoveEndpointByRange( TextPatternRangeEndpoint_End, test_case_provider.Get(), TextPatternRangeEndpoint_Start)); @@ -1397,6 +1429,7 @@ SCOPED_TRACE("Case 2: Range from start of A to middle of A."); ComPtr<ITextRangeProvider> test_case_provider; ASSERT_HRESULT_SUCCEEDED(unit_a_provider->Clone(&test_case_provider)); + CopyOwnerToClone(unit_a_provider.Get(), test_case_provider.Get()); ASSERT_HRESULT_SUCCEEDED(test_case_provider->MoveEndpointByUnit( TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ -7, &count)); @@ -1416,6 +1449,7 @@ SCOPED_TRACE("Case 3: Range from start of A to end of A."); ComPtr<ITextRangeProvider> test_case_provider; ASSERT_HRESULT_SUCCEEDED(unit_a_provider->Clone(&test_case_provider)); + CopyOwnerToClone(unit_a_provider.Get(), test_case_provider.Get()); EXPECT_UIA_TEXTRANGE_EQ(test_case_provider, L"Paragraph 1"); ASSERT_HRESULT_SUCCEEDED( @@ -1431,6 +1465,7 @@ SCOPED_TRACE("Case 4: Range from start of A to middle of B."); ComPtr<ITextRangeProvider> test_case_provider; ASSERT_HRESULT_SUCCEEDED(unit_a_provider->Clone(&test_case_provider)); + CopyOwnerToClone(unit_a_provider.Get(), test_case_provider.Get()); ASSERT_HRESULT_SUCCEEDED(test_case_provider->MoveEndpointByUnit( TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ 4, &count)); ASSERT_EQ(4, count); @@ -1449,6 +1484,7 @@ SCOPED_TRACE("Case 5: Degenerate range in middle of A."); ComPtr<ITextRangeProvider> test_case_provider; ASSERT_HRESULT_SUCCEEDED(unit_a_provider->Clone(&test_case_provider)); + CopyOwnerToClone(unit_a_provider.Get(), test_case_provider.Get()); ASSERT_HRESULT_SUCCEEDED(test_case_provider->MoveEndpointByUnit( TextPatternRangeEndpoint_Start, TextUnit_Character, /*count*/ 4, &count)); @@ -1471,6 +1507,7 @@ SCOPED_TRACE("Case 6: Range from middle of A to middle of A."); ComPtr<ITextRangeProvider> test_case_provider; ASSERT_HRESULT_SUCCEEDED(unit_a_provider->Clone(&test_case_provider)); + CopyOwnerToClone(unit_a_provider.Get(), test_case_provider.Get()); ASSERT_HRESULT_SUCCEEDED(test_case_provider->MoveEndpointByUnit( TextPatternRangeEndpoint_Start, TextUnit_Character, /*count*/ 4, &count)); @@ -1494,6 +1531,7 @@ SCOPED_TRACE("Case 7: Range from middle of A to end of A."); ComPtr<ITextRangeProvider> test_case_provider; ASSERT_HRESULT_SUCCEEDED(unit_a_provider->Clone(&test_case_provider)); + CopyOwnerToClone(unit_a_provider.Get(), test_case_provider.Get()); ASSERT_HRESULT_SUCCEEDED(test_case_provider->MoveEndpointByUnit( TextPatternRangeEndpoint_Start, TextUnit_Character, /*count*/ 4, &count)); @@ -1513,6 +1551,7 @@ SCOPED_TRACE("Case 8: Range from middle of A to middle of B."); ComPtr<ITextRangeProvider> test_case_provider; ASSERT_HRESULT_SUCCEEDED(unit_a_provider->Clone(&test_case_provider)); + CopyOwnerToClone(unit_a_provider.Get(), test_case_provider.Get()); ASSERT_HRESULT_SUCCEEDED(test_case_provider->MoveEndpointByUnit( TextPatternRangeEndpoint_Start, TextUnit_Character, /*count*/ 4, &count)); @@ -3392,6 +3431,9 @@ AXNode* pdf_highlight_node = paragraph_node->children()[4]; AXNode* static_text_node4 = pdf_highlight_node->children()[0]; AXNode* inline_text_node4 = static_text_node4->children()[0]; + AXPlatformNodeWin* owner = + static_cast<AXPlatformNodeWin*>(AXPlatformNodeFromNode(paragraph_node)); + ASSERT_NE(owner, nullptr); ComPtr<IRawElementProviderSimple> link_node_raw = QueryInterfaceFromNode<IRawElementProviderSimple>(link_node); @@ -3429,6 +3471,7 @@ ComPtr<ITextRangeProvider> text_range_provider; EXPECT_HRESULT_SUCCEEDED( text_provider->get_DocumentRange(&text_range_provider)); + SetOwner(owner, text_range_provider.Get()); ComPtr<IRawElementProviderSimple> enclosing_element; EXPECT_HRESULT_SUCCEEDED( @@ -3440,6 +3483,7 @@ EXPECT_HRESULT_SUCCEEDED( text_provider->get_DocumentRange(&text_range_provider)); + SetOwner(owner, text_range_provider.Get()); EXPECT_HRESULT_SUCCEEDED( text_range_provider->GetEnclosingElement(&enclosing_element)); @@ -3450,6 +3494,7 @@ EXPECT_HRESULT_SUCCEEDED( text_provider->get_DocumentRange(&text_range_provider)); + SetOwner(owner, text_range_provider.Get()); EXPECT_HRESULT_SUCCEEDED( text_range_provider->GetEnclosingElement(&enclosing_element)); @@ -3462,6 +3507,7 @@ EXPECT_HRESULT_SUCCEEDED( text_provider->get_DocumentRange(&text_range_provider)); + SetOwner(owner, text_range_provider.Get()); EXPECT_HRESULT_SUCCEEDED( text_range_provider->ExpandToEnclosingUnit(TextUnit_Character)); @@ -3477,6 +3523,7 @@ EXPECT_HRESULT_SUCCEEDED( text_provider->get_DocumentRange(&text_range_provider)); + SetOwner(owner, text_range_provider.Get()); EXPECT_HRESULT_SUCCEEDED( text_range_provider->GetEnclosingElement(&enclosing_element)); @@ -3490,6 +3537,9 @@ AXNode* root_node = GetRootAsAXNode(); AXNode* text_node = root_node->children()[0]; AXNode* more_text_node = root_node->children()[1]; + AXPlatformNodeWin* owner = + static_cast<AXPlatformNodeWin*>(AXPlatformNodeFromNode(root_node)); + ASSERT_NE(owner, nullptr); // Text range for the document, which contains text "some textmore text". ComPtr<IRawElementProviderSimple> root_node_raw = @@ -3535,6 +3585,7 @@ // "some textmore text". EXPECT_HRESULT_SUCCEEDED( document_provider->get_DocumentRange(&document_text_range_provider)); + SetOwner(owner, document_text_range_provider.Get()); EXPECT_HRESULT_SUCCEEDED(document_text_range_provider->MoveEndpointByRange( TextPatternRangeEndpoint_Start, document_text_range_provider.Get(), @@ -3562,6 +3613,7 @@ // "some textmore text". EXPECT_HRESULT_SUCCEEDED( document_provider->get_DocumentRange(&document_text_range_provider)); + SetOwner(owner, document_text_range_provider.Get()); EXPECT_HRESULT_SUCCEEDED(document_text_range_provider->MoveEndpointByRange( TextPatternRangeEndpoint_Start, document_text_range_provider.Get(), @@ -3588,9 +3640,11 @@ // "some textmore text". EXPECT_HRESULT_SUCCEEDED( document_provider->get_DocumentRange(&document_text_range_provider)); + SetOwner(owner, document_text_range_provider.Get()); // Get the textRangeProvider for more_text_node which contains "more text". EXPECT_HRESULT_SUCCEEDED( more_text_provider->get_DocumentRange(&more_text_range_provider)); + SetOwner(owner, more_text_range_provider.Get()); EXPECT_HRESULT_SUCCEEDED(document_text_range_provider->MoveEndpointByRange( TextPatternRangeEndpoint_Start, more_text_range_provider.Get(), @@ -3618,9 +3672,11 @@ // "some textmore text". EXPECT_HRESULT_SUCCEEDED( document_provider->get_DocumentRange(&document_text_range_provider)); + SetOwner(owner, document_text_range_provider.Get()); // Get the textRangeProvider for text_node which contains "some text". EXPECT_HRESULT_SUCCEEDED( text_provider->get_DocumentRange(&text_range_provider)); + SetOwner(owner, text_range_provider.Get()); EXPECT_HRESULT_SUCCEEDED(document_text_range_provider->MoveEndpointByRange( TextPatternRangeEndpoint_End, text_range_provider.Get(), @@ -3647,9 +3703,11 @@ // Get the textRangeProvider for text_node which contains "some text". EXPECT_HRESULT_SUCCEEDED( text_provider->get_DocumentRange(&text_range_provider)); + SetOwner(owner, document_text_range_provider.Get()); // Get the textRangeProvider for more_text_node which contains "more text". EXPECT_HRESULT_SUCCEEDED( more_text_provider->get_DocumentRange(&more_text_range_provider)); + SetOwner(owner, more_text_range_provider.Get()); EXPECT_HRESULT_SUCCEEDED(more_text_range_provider->MoveEndpointByRange( TextPatternRangeEndpoint_End, text_range_provider.Get(), @@ -3676,9 +3734,11 @@ // Get the textRangeProvider for text_node which contains "some text". EXPECT_HRESULT_SUCCEEDED( text_provider->get_DocumentRange(&text_range_provider)); + SetOwner(owner, text_range_provider.Get()); // Get the textRangeProvider for more_text_node which contains "more text". EXPECT_HRESULT_SUCCEEDED( more_text_provider->get_DocumentRange(&more_text_range_provider)); + SetOwner(owner, more_text_range_provider.Get()); EXPECT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByRange( TextPatternRangeEndpoint_Start, more_text_range_provider.Get(), @@ -4783,18 +4843,24 @@ document_provider->get_DocumentRange(&document_text_range_provider)); document_text_range_provider->QueryInterface( IID_PPV_ARGS(&document_text_range)); + AXPlatformNodeWin* owner_platform = + static_cast<AXPlatformNodeWin*>(AXPlatformNodeFromNode(root_node)); + ASSERT_NE(owner_platform, nullptr); + SetOwner(owner_platform, document_text_range_provider.Get()); // Text range related to "some text". ComPtr<ITextRangeProvider> text_range_provider; GetTextRangeProviderFromTextNode(text_range_provider, root_node->children()[0]); ComPtr<AXPlatformNodeTextRangeProviderWin> text_range; - text_range_provider->QueryInterface(IID_PPV_ARGS(&text_range)); + EXPECT_HRESULT_SUCCEEDED( + text_range_provider->QueryInterface(IID_PPV_ARGS(&text_range))); // Text range related to "more text2". ComPtr<ITextRangeProvider> more_text_range_provider; GetTextRangeProviderFromTextNode(more_text_range_provider, root_node->children()[1]); + SetOwner(owner_platform, more_text_range_provider.Get()); ComPtr<AXPlatformNodeTextRangeProviderWin> more_text_range; more_text_range_provider->QueryInterface(IID_PPV_ARGS(&more_text_range)); @@ -4829,6 +4895,7 @@ EXPECT_HRESULT_SUCCEEDED(SafeArrayGetElement( selection.Get(), &index, static_cast<void**>(&selected_text_range_provider))); + SetOwner(owner_platform, selected_text_range_provider.Get()); EXPECT_UIA_TEXTRANGE_EQ(selected_text_range_provider, L"some text"); selected_text_range_provider.Reset(); @@ -4857,6 +4924,7 @@ EXPECT_HRESULT_SUCCEEDED(SafeArrayGetElement( selection.Get(), &index, static_cast<void**>(&selected_text_range_provider))); + SetOwner(owner_platform, selected_text_range_provider.Get()); EXPECT_UIA_TEXTRANGE_EQ(selected_text_range_provider, L"more text2"); selected_text_range_provider.Reset(); @@ -4886,6 +4954,7 @@ EXPECT_HRESULT_SUCCEEDED(SafeArrayGetElement( selection.Get(), &index, static_cast<void**>(&selected_text_range_provider))); + SetOwner(owner_platform, selected_text_range_provider.Get()); EXPECT_UIA_TEXTRANGE_EQ(selected_text_range_provider, L"some textmore text2"); } @@ -4916,6 +4985,7 @@ EXPECT_HRESULT_SUCCEEDED(SafeArrayGetElement( selection.Get(), &index, static_cast<void**>(&selected_text_range_provider))); + SetOwner(owner_platform, selected_text_range_provider.Get()); EXPECT_UIA_TEXTRANGE_EQ(selected_text_range_provider, L""); selected_text_range_provider.Reset(); @@ -4998,27 +5068,30 @@ true /* place_text_on_one_line */)); AXNode* root_node = GetRootAsAXNode(); + AXPlatformNodeWin* owner = + static_cast<AXPlatformNodeWin*>(AXPlatformNodeFromNode(root_node)); + ASSERT_NE(owner, nullptr); ComPtr<ITextRangeProvider> range; // Test Leaf kStaticText search. GetTextRangeProviderFromTextNode(range, root_node->children()[0]); - EXPECT_UIA_FIND_TEXT(range, L"some text", false); - EXPECT_UIA_FIND_TEXT(range, L"SoMe TeXt", true); + EXPECT_UIA_FIND_TEXT(range, L"some text", false, owner); + EXPECT_UIA_FIND_TEXT(range, L"SoMe TeXt", true, owner); GetTextRangeProviderFromTextNode(range, root_node->children()[1]); - EXPECT_UIA_FIND_TEXT(range, L"more", false); - EXPECT_UIA_FIND_TEXT(range, L"MoRe", true); + EXPECT_UIA_FIND_TEXT(range, L"more", false, owner); + EXPECT_UIA_FIND_TEXT(range, L"MoRe", true, owner); // Test searching for leaf content from ancestor. GetTextRangeProviderFromTextNode(range, root_node); - EXPECT_UIA_FIND_TEXT(range, L"some text", false); - EXPECT_UIA_FIND_TEXT(range, L"SoMe TeXt", true); - EXPECT_UIA_FIND_TEXT(range, L"more text", false); - EXPECT_UIA_FIND_TEXT(range, L"MoRe TeXt", true); - EXPECT_UIA_FIND_TEXT(range, L"more", false); + EXPECT_UIA_FIND_TEXT(range, L"some text", false, owner); + EXPECT_UIA_FIND_TEXT(range, L"SoMe TeXt", true, owner); + EXPECT_UIA_FIND_TEXT(range, L"more text", false, owner); + EXPECT_UIA_FIND_TEXT(range, L"MoRe TeXt", true, owner); + EXPECT_UIA_FIND_TEXT(range, L"more", false, owner); // Test finding text that crosses a node boundary. - EXPECT_UIA_FIND_TEXT(range, L"textmore", false); + EXPECT_UIA_FIND_TEXT(range, L"textmore", false, owner); // Test no match. - EXPECT_UIA_FIND_TEXT_NO_MATCH(range, L"no match", false); + EXPECT_UIA_FIND_TEXT_NO_MATCH(range, L"no match", false, owner); // Test if range returned is in expected anchor node. GetTextRangeProviderFromTextNode(range, root_node->children()[1]); @@ -5059,6 +5132,7 @@ // Forward search finds the text_node1. EXPECT_HRESULT_SUCCEEDED(root_range_provider->FindText( find_string.Get(), false, false, &text_range_provider_found)); + CopyOwnerToClone(root_range_provider.Get(), text_range_provider_found.Get()); EXPECT_UIA_TEXTRANGE_EQ(text_range_provider_found, find_string.Get()); range_equal = false; @@ -5069,6 +5143,7 @@ // Backwards search finds the text_node3. EXPECT_HRESULT_SUCCEEDED(root_range_provider->FindText( find_string.Get(), true, false, &text_range_provider_found)); + CopyOwnerToClone(root_range_provider.Get(), text_range_provider_found.Get()); EXPECT_UIA_TEXTRANGE_EQ(text_range_provider_found, find_string.Get()); range_equal = false; @@ -5138,6 +5213,8 @@ UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward, &matched_range_provider); ASSERT_NE(nullptr, matched_range_provider.Get()); + CopyOwnerToClone(document_range_provider.Get(), + matched_range_provider.Get()); EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L""); matched_range_provider.Reset(); @@ -5161,6 +5238,8 @@ UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward, &matched_range_provider); ASSERT_NE(nullptr, matched_range_provider.Get()); + CopyOwnerToClone(document_range_provider.Get(), + matched_range_provider.Get()); EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L""); } @@ -5211,6 +5290,8 @@ UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward, &matched_range_provider); ASSERT_NE(nullptr, matched_range_provider.Get()); + CopyOwnerToClone(document_range_provider.Get(), + matched_range_provider.Get()); EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text1"); matched_range_provider.Reset(); @@ -5231,6 +5312,8 @@ UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward, &matched_range_provider); ASSERT_NE(nullptr, matched_range_provider.Get()); + CopyOwnerToClone(document_range_provider.Get(), + matched_range_provider.Get()); EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text1"); matched_range_provider.Reset(); @@ -5305,6 +5388,8 @@ UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward, &matched_range_provider); ASSERT_NE(nullptr, matched_range_provider.Get()); + CopyOwnerToClone(document_range_provider.Get(), + matched_range_provider.Get()); EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text1text2"); matched_range_provider.Reset(); @@ -5325,6 +5410,8 @@ UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward, &matched_range_provider); ASSERT_NE(nullptr, matched_range_provider.Get()); + CopyOwnerToClone(document_range_provider.Get(), + matched_range_provider.Get()); EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text1text2"); } @@ -5402,6 +5489,8 @@ UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward, &matched_range_provider); ASSERT_NE(nullptr, matched_range_provider.Get()); + CopyOwnerToClone(document_range_provider.Get(), + matched_range_provider.Get()); EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text2text3"); matched_range_provider.Reset(); @@ -5413,6 +5502,8 @@ UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward, &matched_range_provider); ASSERT_NE(nullptr, matched_range_provider.Get()); + CopyOwnerToClone(document_range_provider.Get(), + matched_range_provider.Get()); EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text1"); matched_range_provider.Reset(); @@ -5424,6 +5515,8 @@ UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward, &matched_range_provider); ASSERT_NE(nullptr, matched_range_provider.Get()); + CopyOwnerToClone(document_range_provider.Get(), + matched_range_provider.Get()); EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text5"); matched_range_provider.Reset(); @@ -5435,6 +5528,8 @@ UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward, &matched_range_provider); ASSERT_NE(nullptr, matched_range_provider.Get()); + CopyOwnerToClone(document_range_provider.Get(), + matched_range_provider.Get()); EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text4"); } @@ -5512,6 +5607,8 @@ UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward, &matched_range_provider); ASSERT_NE(nullptr, matched_range_provider.Get()); + CopyOwnerToClone(document_range_provider.Get(), + matched_range_provider.Get()); EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text2text3text4"); matched_range_provider.Reset(); @@ -5523,6 +5620,8 @@ UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward, &matched_range_provider); ASSERT_NE(nullptr, matched_range_provider.Get()); + CopyOwnerToClone(document_range_provider.Get(), + matched_range_provider.Get()); EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text1"); matched_range_provider.Reset(); @@ -5534,6 +5633,8 @@ UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward, &matched_range_provider); ASSERT_NE(nullptr, matched_range_provider.Get()); + CopyOwnerToClone(document_range_provider.Get(), + matched_range_provider.Get()); EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text2text3text4"); matched_range_provider.Reset(); @@ -5545,6 +5646,8 @@ UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward, &matched_range_provider); ASSERT_NE(nullptr, matched_range_provider.Get()); + CopyOwnerToClone(document_range_provider.Get(), + matched_range_provider.Get()); EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text5"); } }
diff --git a/ui/accessibility/platform/ax_platform_tree_manager.h b/ui/accessibility/platform/ax_platform_tree_manager.h new file mode 100644 index 0000000..8d2944a --- /dev/null +++ b/ui/accessibility/platform/ax_platform_tree_manager.h
@@ -0,0 +1,32 @@ +// Copyright 2021 The Chromium 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 UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_TREE_MANAGER_H_ +#define UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_TREE_MANAGER_H_ + +#include "ui/accessibility/ax_export.h" +#include "ui/accessibility/ax_node.h" +#include "ui/accessibility/ax_tree_id.h" +#include "ui/accessibility/ax_tree_manager.h" + +namespace ui { + +class AXPlatformNode; + +// Abstract interface for a class that owns an AXTree and manages its +// connections to other AXTrees in the same page or desktop (parent and child +// trees). +class AX_EXPORT AXPlatformTreeManager : public AXTreeManager { + public: + // Returns an AXPlatformNode with the specified and |node_id|. + virtual AXPlatformNode* GetPlatformNodeFromTree( + const AXNodeID node_id) const = 0; + + // Returns an AXPlatformNode that corresponds to the given |node|. + virtual AXPlatformNode* GetPlatformNodeFromTree(const AXNode& node) const = 0; +}; + +} // namespace ui + +#endif // UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_TREE_MANAGER_H_
diff --git a/ui/accessibility/platform/ax_private_attributes_mac.h b/ui/accessibility/platform/ax_private_attributes_mac.h index 587aae55..1ed7812 100644 --- a/ui/accessibility/platform/ax_private_attributes_mac.h +++ b/ui/accessibility/platform/ax_private_attributes_mac.h
@@ -16,12 +16,20 @@ @"AXARIAAtomic"; AX_EXPORT constexpr NSString* const NSAccessibilityARIABusyAttribute = @"AXARIABusy"; +AX_EXPORT constexpr NSString* const NSAccessibilityARIAColumnCountAttribute = + @"AXARIAColumnCount"; +AX_EXPORT constexpr NSString* const NSAccessibilityARIAColumnIndexAttribute = + @"AXARIAColumnIndex"; AX_EXPORT constexpr NSString* const NSAccessibilityARIACurrentAttribute = @"AXARIACurrent"; AX_EXPORT constexpr NSString* const NSAccessibilityARIALiveAttribute = @"AXARIALive"; AX_EXPORT constexpr NSString* const NSAccessibilityARIARelevantAttribute = @"AXARIARelevant"; +AX_EXPORT constexpr NSString* const NSAccessibilityARIARowCountAttribute = + @"AXARIARowCount"; +AX_EXPORT constexpr NSString* const NSAccessibilityARIARowIndexAttribute = + @"AXARIARowIndex"; AX_EXPORT constexpr NSString* const NSAccessibilityAutocompleteValueAttribute = @"AXAutocompleteValue"; AX_EXPORT constexpr NSString* const NSAccessibilityDetailsElementsAttribute =
diff --git a/ui/file_manager/file_manager/foreground/images/files/ui/2x/menu.png b/ui/file_manager/file_manager/foreground/images/files/ui/2x/menu.png deleted file mode 100644 index 83694a7..0000000 --- a/ui/file_manager/file_manager/foreground/images/files/ui/2x/menu.png +++ /dev/null Binary files differ
diff --git a/ui/file_manager/file_manager/foreground/images/files/ui/menu.png b/ui/file_manager/file_manager/foreground/images/files/ui/menu.png deleted file mode 100644 index db9918f..0000000 --- a/ui/file_manager/file_manager/foreground/images/files/ui/menu.png +++ /dev/null Binary files differ