From 5d62b1faa47c46dd8c34dbd2412693028e0038c9 Mon Sep 17 00:00:00 2001 From: Roman Sorokin Date: Tue, 14 Dec 2021 11:58:42 +0000 Subject: [PATCH 01/51] [ChromeOS] Add raleksandrov@ as an owner c/b/ui/webui/chromeos/login Bug: none Change-Id: I994a4cca87e3cda24cbf1f3ae44ef29e91e977fb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3338336 Auto-Submit: Roman Sorokin Reviewed-by: Roman Aleksandrov Commit-Queue: Roman Aleksandrov Cr-Commit-Position: refs/heads/main@{#951451} --- chrome/browser/ui/webui/chromeos/login/OWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/chrome/browser/ui/webui/chromeos/login/OWNERS b/chrome/browser/ui/webui/chromeos/login/OWNERS index 39af14ec6d6fc6..e1b8bcc2f8121f 100644 --- a/chrome/browser/ui/webui/chromeos/login/OWNERS +++ b/chrome/browser/ui/webui/chromeos/login/OWNERS @@ -1,5 +1,6 @@ # primary (in CET) antrim@chromium.org +raleksandrov@google.com rsorokin@chromium.org # secondary (in PST) From 83681fe0b07d8c68d8e28ba37fa62ba5f39acdba Mon Sep 17 00:00:00 2001 From: chromium-autoroll Date: Tue, 14 Dec 2021 12:00:25 +0000 Subject: [PATCH 02/51] Roll Chrome Win32 PGO Profile Roll Chrome Win32 PGO profile from chrome-win32-main-1639461558-d1317f8df3a47076c53ad387642fd817bb433e6b.profdata to chrome-win32-main-1639472251-55695819d100cc1e6d371b12dbe33261804b0154.profdata If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/pgo-win32-chromium Please CC pgo-profile-sheriffs@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Chromium main branch: https://bugs.chromium.org/p/chromium/issues/entry To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md Cq-Include-Trybots: luci.chrome.try:win-chrome Tbr: pgo-profile-sheriffs@google.com Change-Id: Ifbaa7e428e06ebde0994ebe9be8b09a49760bb75 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3338204 Commit-Queue: chromium-autoroll Bot-Commit: chromium-autoroll Cr-Commit-Position: refs/heads/main@{#951452} --- chrome/build/win32.pgo.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/build/win32.pgo.txt b/chrome/build/win32.pgo.txt index fec086d409c072..d2a4c3e645e709 100644 --- a/chrome/build/win32.pgo.txt +++ b/chrome/build/win32.pgo.txt @@ -1 +1 @@ -chrome-win32-main-1639461558-d1317f8df3a47076c53ad387642fd817bb433e6b.profdata +chrome-win32-main-1639472251-55695819d100cc1e6d371b12dbe33261804b0154.profdata From 3493ce7f0e57707ad4f16df38709b94f9ebf3426 Mon Sep 17 00:00:00 2001 From: chromium-autoroll Date: Tue, 14 Dec 2021 12:05:36 +0000 Subject: [PATCH 03/51] Roll ChromeOS Atom AFDO profile from 98-4729.0-1638787322-benchmark-98.0.4758.5-r1 to 98-4744.1-1639393599-benchmark-98.0.4758.7-r1 If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/cros-afdo-atom-chromium Please CC c-compiler-chrome@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Chromium: https://bugs.chromium.org/p/chromium/issues/entry To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md Tbr: c-compiler-chrome@google.com Change-Id: I1d3d8cb8a1e22655d708b66e38e97079802dac90 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3338724 Commit-Queue: chromium-autoroll Bot-Commit: chromium-autoroll Cr-Commit-Position: refs/heads/main@{#951453} --- chromeos/profiles/atom.afdo.newest.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chromeos/profiles/atom.afdo.newest.txt b/chromeos/profiles/atom.afdo.newest.txt index e9fe5b4b7eaa89..efa35adbebef6a 100644 --- a/chromeos/profiles/atom.afdo.newest.txt +++ b/chromeos/profiles/atom.afdo.newest.txt @@ -1 +1 @@ -chromeos-chrome-amd64-atom-98-4729.0-1638787322-benchmark-98.0.4758.5-r1-redacted.afdo.xz +chromeos-chrome-amd64-atom-98-4744.1-1639393599-benchmark-98.0.4758.7-r1-redacted.afdo.xz From 94cdce409c2581fb1aa7a2d083835701e87cea5a Mon Sep 17 00:00:00 2001 From: Michael van Ouwerkerk Date: Tue, 14 Dec 2021 12:09:12 +0000 Subject: [PATCH 04/51] Disable ContextualSearchTest#testTextTapFollowedByNonTextTap. Bug: 1279770 Change-Id: Id86a939c9c77f1ea30c9613dd68a7ffeb26ffc5d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3338477 Owners-Override: Michael van Ouwerkerk Auto-Submit: Michael van Ouwerkerk Reviewed-by: Peter Beverloo Commit-Queue: Peter Beverloo Cr-Commit-Position: refs/heads/main@{#951454} --- .../chrome/browser/contextualsearch/ContextualSearchTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTest.java index 5ac975cca9e2ef..2ccc5c0894d0bd 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchTest.java @@ -20,6 +20,7 @@ import org.chromium.base.test.util.Batch; import org.chromium.base.test.util.CommandLineFlags; +import org.chromium.base.test.util.DisabledTest; import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.JniMocker; import org.chromium.base.test.util.Restriction; @@ -305,6 +306,7 @@ public void testLongpressFollowedByNonTextTap() { @Feature({"ContextualSearch"}) @Restriction(Restriction.RESTRICTION_TYPE_NON_LOW_END_DEVICE) @Features.DisableFeatures(ChromeFeatureList.SNOOZABLE_IPH) + @DisabledTest(message = "https://crbug.com/1279770") public void testTextTapFollowedByNonTextTap() { Assert.assertEquals(mPanelManager.getRequestPanelShowCount(), 0); From bed03968ec6f3b0c635c025df8360697d588c128 Mon Sep 17 00:00:00 2001 From: Sreeja Kamishetty Date: Tue, 14 Dec 2021 12:09:46 +0000 Subject: [PATCH 05/51] Sherrif: Disable failing Linux TSan test Bug: 1278842 Change-Id: I401a00baec18707475eca5a6cd5a876e280029a2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3338576 Reviewed-by: Sreeja Kamishetty Owners-Override: Sreeja Kamishetty Auto-Submit: Sreeja Kamishetty Reviewed-by: Eric Seckler Commit-Queue: Eric Seckler Cr-Commit-Position: refs/heads/main@{#951455} --- components/permissions/permission_context_base_unittest.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/permissions/permission_context_base_unittest.cc b/components/permissions/permission_context_base_unittest.cc index 6da2d3999bbd57..fe893242f45abc 100644 --- a/components/permissions/permission_context_base_unittest.cc +++ b/components/permissions/permission_context_base_unittest.cc @@ -803,7 +803,8 @@ TEST_F(PermissionContextBaseTests, TestGrantAndRevoke) { } // Tests the global kill switch by enabling/disabling the Field Trials. -TEST_F(PermissionContextBaseTests, TestGlobalKillSwitch) { +// TODO(crbug.com/1278842): Fix flaky test on Linux TSan. +TEST_F(PermissionContextBaseTests, DISABLED_TestGlobalKillSwitch) { TestGlobalPermissionsKillSwitch(ContentSettingsType::GEOLOCATION); TestGlobalPermissionsKillSwitch(ContentSettingsType::NOTIFICATIONS); TestGlobalPermissionsKillSwitch(ContentSettingsType::MIDI_SYSEX); From d8756ae8badd601066185704eede3504254064b7 Mon Sep 17 00:00:00 2001 From: chromium-internal-autoroll Date: Tue, 14 Dec 2021 12:34:33 +0000 Subject: [PATCH 06/51] Roll Projector App from GNNkSm3f-... to FchxTKMvf... Release_Notes: http://go/projector_app-x20/relnotes/Main/projector_app_nightly_202112140100_RC00.html https://chrome-infra-packages.appspot.com/p/chromeos_internal/apps/projector_app/app/+/FchxTKMvfxSkGTLMU23cSyqvexH52wHP-zPlLYF6QqUC If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://skia-autoroll.corp.goog/r/projector-app-chromium-autoroll Please CC cros-projector-oncall@grotations.appspotmail.com on the revert to ensure that a human is aware of the problem. To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md Cq-Include-Trybots: luci.chrome.try:chromeos-betty-pi-arc-chrome;luci.chrome.try:linux-chromeos-chrome Bug: b/201468078,b/207127989,b/209922355,b/209999957 Tbr: cros-projector-oncall@grotations.appspotmail.com Change-Id: I879656ff3742bef74a311d69003194954387870b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3338199 Commit-Queue: chromium-internal-autoroll Bot-Commit: chromium-internal-autoroll Cr-Commit-Position: refs/heads/main@{#951456} --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index a4964f4d80a6e6..2b1bd9581f2fe0 100644 --- a/DEPS +++ b/DEPS @@ -1741,7 +1741,7 @@ deps = { 'packages': [ { 'package': 'chromeos_internal/apps/projector_app/app', - 'version': 'GNNkSm3f-_u5XLEkNk_gDIcdzAc9jLL9kkDHNH94I1kC', + 'version': 'FchxTKMvfxSkGTLMU23cSyqvexH52wHP-zPlLYF6QqUC', }, ], 'condition': 'checkout_chromeos and checkout_src_internal', From 9c9a227378ffe53bc480180116546e20b338db9b Mon Sep 17 00:00:00 2001 From: chromium-autoroll Date: Tue, 14 Dec 2021 12:55:22 +0000 Subject: [PATCH 07/51] Roll AFDO from 98.0.4758.5_rc-r1-merged to 98.0.4758.7_rc-r1-merged This CL may cause a small binary size increase, roughly proportional to how long it's been since our last AFDO profile roll. For larger increases (around or exceeding 100KB), please file a bug against gbiv@chromium.org. Additional context: https://crbug.com/805539 Please note that, despite rolling to chrome/android, this profile is used for both Linux and Android. If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/afdo-chromium-autoroll Please CC gbiv@chromium.org on the revert to ensure that a human is aware of the problem. To file a bug in Chromium: https://bugs.chromium.org/p/chromium/issues/entry To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md Tbr: gbiv@chromium.org Change-Id: I123507134510f57c5886e5bc2576b158ae311e56 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3338196 Commit-Queue: chromium-autoroll Bot-Commit: chromium-autoroll Cr-Commit-Position: refs/heads/main@{#951457} --- chrome/android/profiles/newest.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/android/profiles/newest.txt b/chrome/android/profiles/newest.txt index 2463ed9f5e6695..a4a494ffe34ef8 100644 --- a/chrome/android/profiles/newest.txt +++ b/chrome/android/profiles/newest.txt @@ -1 +1 @@ -chromeos-chrome-amd64-98.0.4758.5_rc-r1-merged.afdo.bz2 +chromeos-chrome-amd64-98.0.4758.7_rc-r1-merged.afdo.bz2 From 8e6a6b81ca16335fc57c81b76e9d33d686120857 Mon Sep 17 00:00:00 2001 From: Max Ihlenfeldt Date: Tue, 14 Dec 2021 13:00:12 +0000 Subject: [PATCH 08/51] ozone/wayland: make IME work without keyboard Currently, the IME is only activated if a window has keyboard focus. As this is impossible when no keyboard is attached, IME does not work in this case. To fix this, use the pointer- or touch-focused window when no keyboard is attached. Bug: 1168411 Change-Id: Idacab0be3bed9828e91c9d7fe4fccf704f393187 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3320387 Reviewed-by: Maksim Sisov Commit-Queue: Max Ihlenfeldt Cr-Commit-Position: refs/heads/main@{#951458} --- .../host/wayland_input_method_context.cc | 4 ++ .../wayland_input_method_context_unittest.cc | 52 ++++++++++++++++++- .../wayland/host/wayland_window_manager.cc | 9 ++++ .../wayland/host/wayland_window_manager.h | 3 ++ 4 files changed, 67 insertions(+), 1 deletion(-) diff --git a/ui/ozone/platform/wayland/host/wayland_input_method_context.cc b/ui/ozone/platform/wayland/host/wayland_input_method_context.cc index f8a932081712f3..1ac224b217fb6f 100644 --- a/ui/ozone/platform/wayland/host/wayland_input_method_context.cc +++ b/ui/ozone/platform/wayland/host/wayland_input_method_context.cc @@ -585,9 +585,13 @@ void WaylandInputMethodContext::MaybeUpdateActivated() { WaylandWindow* window = connection_->wayland_window_manager()->GetCurrentKeyboardFocusedWindow(); + if (!window && !connection_->keyboard()) + window = connection_->wayland_window_manager()->GetCurrentActiveWindow(); // Activate Wayland IME only if 1) InputMethod in Chrome has some // TextInputClient connected, and 2) the actual keyboard focus of Wayland // is given to Chrome, which is notified via wl_keyboard::enter. + // If no keyboard is connected, the current active window is used for 2) + // instead (https://crbug.com/1168411). bool activated = focused_ && window; if (activated_ == activated) return; diff --git a/ui/ozone/platform/wayland/host/wayland_input_method_context_unittest.cc b/ui/ozone/platform/wayland/host/wayland_input_method_context_unittest.cc index b4ea88559a50d8..a45f1021ea5010 100644 --- a/ui/ozone/platform/wayland/host/wayland_input_method_context_unittest.cc +++ b/ui/ozone/platform/wayland/host/wayland_input_method_context_unittest.cc @@ -98,6 +98,7 @@ class TestInputMethodContextDelegate : public LinuxInputMethodContextDelegate { class WaylandInputMethodContextTest : public WaylandTest { public: WaylandInputMethodContextTest() = default; + ~WaylandInputMethodContextTest() override = default; WaylandInputMethodContextTest(const WaylandInputMethodContextTest&) = delete; WaylandInputMethodContextTest& operator=( const WaylandInputMethodContextTest&) = delete; @@ -105,8 +106,18 @@ class WaylandInputMethodContextTest : public WaylandTest { void SetUp() override { WaylandTest::SetUp(); + // WaylandInputMethodContext behaves differently when no keyboard is + // attached. + wl_seat_send_capabilities(server_.seat()->resource(), + WL_SEAT_CAPABILITY_KEYBOARD); + Sync(); + SetUpInternal(); + } + + protected: + void SetUpInternal() { input_method_context_delegate_ = std::make_unique(); @@ -132,7 +143,6 @@ class WaylandInputMethodContextTest : public WaylandTest { ASSERT_TRUE(zcr_extended_text_input_); } - protected: std::unique_ptr input_method_context_delegate_; std::unique_ptr input_method_context_; @@ -146,6 +156,7 @@ TEST_P(WaylandInputMethodContextTest, ActivateDeactivate) { // Scenario 1: InputMethod focus is set, then Keyboard focus is set. // Unset them in the reversed order. + EXPECT_CALL(*zwp_text_input_, Activate(surface_->resource())).Times(0); EXPECT_CALL(*zwp_text_input_, ShowInputPanel()).Times(0); input_method_context_->Focus(); @@ -483,6 +494,37 @@ TEST_P(WaylandInputMethodContextTest, input_method_context_delegate_->was_on_set_preedit_region_called()); } +class WaylandInputMethodContextNoKeyboardTest + : public WaylandInputMethodContextTest { + public: + WaylandInputMethodContextNoKeyboardTest() = default; + ~WaylandInputMethodContextNoKeyboardTest() override = default; + + void SetUp() override { + WaylandTest::SetUp(); + SetUpInternal(); + } +}; + +TEST_P(WaylandInputMethodContextNoKeyboardTest, ActivateDeactivate) { + // Because there is no keyboard, Activate is called as soon as InputMethod's + // TextInputClient focus is met. + + EXPECT_CALL(*zwp_text_input_, Activate(surface_->resource())); + EXPECT_CALL(*zwp_text_input_, ShowInputPanel()); + input_method_context_->Focus(); + connection_->ScheduleFlush(); + Sync(); + Mock::VerifyAndClearExpectations(zwp_text_input_); + + EXPECT_CALL(*zwp_text_input_, Deactivate()); + EXPECT_CALL(*zwp_text_input_, HideInputPanel()); + input_method_context_->Blur(); + connection_->ScheduleFlush(); + Sync(); + Mock::VerifyAndClearExpectations(zwp_text_input_); +} + INSTANTIATE_TEST_SUITE_P(XdgVersionStableTest, WaylandInputMethodContextTest, Values(wl::ServerConfig{ @@ -491,6 +533,14 @@ INSTANTIATE_TEST_SUITE_P(XdgVersionV6Test, WaylandInputMethodContextTest, Values(wl::ServerConfig{ .shell_version = wl::ShellVersion::kV6})); +INSTANTIATE_TEST_SUITE_P(XdgVersionStableTest, + WaylandInputMethodContextNoKeyboardTest, + Values(wl::ServerConfig{ + .shell_version = wl::ShellVersion::kStable})); +INSTANTIATE_TEST_SUITE_P(XdgVersionV6Test, + WaylandInputMethodContextNoKeyboardTest, + Values(wl::ServerConfig{ + .shell_version = wl::ShellVersion::kV6})); } // namespace } // namespace ui diff --git a/ui/ozone/platform/wayland/host/wayland_window_manager.cc b/ui/ozone/platform/wayland/host/wayland_window_manager.cc index 5d7d32d841cc38..52f17a55f6f727 100644 --- a/ui/ozone/platform/wayland/host/wayland_window_manager.cc +++ b/ui/ozone/platform/wayland/host/wayland_window_manager.cc @@ -64,6 +64,15 @@ WaylandWindow* WaylandWindowManager::GetWindowWithLargestBounds() const { return window_with_largest_bounds; } +WaylandWindow* WaylandWindowManager::GetCurrentActiveWindow() const { + for (const auto& entry : window_map_) { + WaylandWindow* window = entry.second; + if (window->IsActive()) + return window; + } + return nullptr; +} + WaylandWindow* WaylandWindowManager::GetCurrentFocusedWindow() const { for (const auto& entry : window_map_) { WaylandWindow* window = entry.second; diff --git a/ui/ozone/platform/wayland/host/wayland_window_manager.h b/ui/ozone/platform/wayland/host/wayland_window_manager.h index 8908d1d4217ee9..abefcdf91a125d 100644 --- a/ui/ozone/platform/wayland/host/wayland_window_manager.h +++ b/ui/ozone/platform/wayland/host/wayland_window_manager.h @@ -51,6 +51,9 @@ class WaylandWindowManager { // Returns a window with largests bounds. WaylandWindow* GetWindowWithLargestBounds() const; + // Returns a current active window. + WaylandWindow* GetCurrentActiveWindow() const; + // Returns a current focused window by pointer, touch, or keyboard. WaylandWindow* GetCurrentFocusedWindow() const; From 5441f9b71eecac1b8acfafa78dbc7c4148cb2143 Mon Sep 17 00:00:00 2001 From: Nohemi Fernandez Date: Tue, 14 Dec 2021 13:11:35 +0000 Subject: [PATCH 09/51] Update WebUI JS code naming to reflect the Profile::IsChild API. Follow-up to crrev.com/c/3314914. Bug: 1277015 Change-Id: I795073972657eea79412e274b7f50c4180a5b42b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3322993 Reviewed-by: Kyle Horimoto Reviewed-by: Xiyuan Xia Reviewed-by: Demetrios Papadopoulos Reviewed-by: Reilly Grant Commit-Queue: Nohemi Fernandez Cr-Commit-Position: refs/heads/main@{#951459} --- .../developer_private_api.cc | 12 +++++------ .../developer_private_api_unittest.cc | 2 +- .../browser/resources/extensions/manager.html | 2 +- .../browser/resources/extensions/manager.ts | 6 +++--- .../browser/resources/extensions/toolbar.html | 10 +++++----- .../browser/resources/extensions/toolbar.ts | 12 +++++------ .../appearance_browser_proxy.ts | 8 ++++---- .../appearance_page/appearance_page.ts | 2 +- .../chromeos/os_people_page/users_page.js | 2 +- .../clear_browsing_data_dialog.html | 6 +++--- .../clear_browsing_data_dialog.ts | 6 +++--- .../webui/settings/chromeos/main_section.cc | 2 +- .../settings_localized_strings_provider.cc | 2 +- .../extensions/api/developer_private.idl | 2 +- .../data/webui/extensions/toolbar_test.js | 6 +++--- .../webui/settings/appearance_page_test.ts | 20 +++++++++---------- .../settings/clear_browsing_data_test.ts | 4 ++-- .../externs/developer_private.js | 2 +- .../definitions/developer_private.d.ts | 2 +- 19 files changed, 54 insertions(+), 54 deletions(-) diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api.cc b/chrome/browser/extensions/api/developer_private/developer_private_api.cc index eb2b0f714c2602..7b56123c921530 100644 --- a/chrome/browser/extensions/api/developer_private/developer_private_api.cc +++ b/chrome/browser/extensions/api/developer_private/developer_private_api.cc @@ -129,8 +129,8 @@ const char kManifestKeyIsRequiredError[] = "The 'manifestKey' argument is required for manifest files."; const char kCouldNotFindWebContentsError[] = "Could not find a valid web contents."; -const char kCannotUpdateSupervisedProfileSettingsError[] = - "Cannot change settings for a supervised profile."; +const char kCannotUpdateChildAccountProfileSettingsError[] = + "Cannot change settings for a child account profile."; const char kNoOptionsPageForExtensionError[] = "Extension does not have an options page."; const char kCannotRepairHealthyExtension[] = @@ -308,7 +308,7 @@ DeveloperPrivateAPI::GetFactoryInstance() { std::unique_ptr DeveloperPrivateAPI::CreateProfileInfo( Profile* profile) { std::unique_ptr info(new developer::ProfileInfo()); - info->is_supervised = profile->IsChild(); + info->is_child_account = profile->IsChild(); PrefService* prefs = profile->GetPrefs(); const PrefService::Preference* pref = prefs->FindPreference(prefs::kExtensionsUIDeveloperMode); @@ -316,7 +316,7 @@ std::unique_ptr DeveloperPrivateAPI::CreateProfileInfo( IncognitoModePrefs::Availability::kDisabled; info->is_developer_mode_controlled_by_policy = pref->IsManaged(); info->in_developer_mode = - !info->is_supervised && + !info->is_child_account && prefs->GetBoolean(prefs::kExtensionsUIDeveloperMode); info->can_load_unpacked = ExtensionManagementFactory::GetForBrowserContext(profile) @@ -896,7 +896,7 @@ DeveloperPrivateUpdateProfileConfigurationFunction::Run() { PrefService* prefs = profile->GetPrefs(); if (update.in_developer_mode) { if (profile->IsChild()) - return RespondNow(Error(kCannotUpdateSupervisedProfileSettingsError)); + return RespondNow(Error(kCannotUpdateChildAccountProfileSettingsError)); prefs->SetBoolean(prefs::kExtensionsUIDeveloperMode, *update.in_developer_mode); } @@ -1110,7 +1110,7 @@ ExtensionFunction::ResponseAction DeveloperPrivateLoadUnpackedFunction::Run() { Profile* profile = Profile::FromBrowserContext(browser_context()); if (profile->IsChild()) { return RespondNow( - Error("Supervised users cannot load unpacked extensions.")); + Error("Child account users cannot load unpacked extensions.")); } PrefService* prefs = profile->GetPrefs(); if (!prefs->GetBoolean(prefs::kExtensionsUIDeveloperMode)) { diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc b/chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc index 777210e2f6c71b..fea8582b4177e9 100644 --- a/chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc +++ b/chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc @@ -1897,7 +1897,7 @@ TEST_F(DeveloperPrivateApiSupervisedUserUnitTest, function->SetRenderFrameHost(web_contents->GetMainFrame()); std::string error = extension_function_test_utils::RunFunctionAndReturnError( function.get(), "[]", browser()); - EXPECT_THAT(error, testing::HasSubstr("Supervised")); + EXPECT_THAT(error, testing::HasSubstr("Child account")); } #endif diff --git a/chrome/browser/resources/extensions/manager.html b/chrome/browser/resources/extensions/manager.html index 05321de1697d77..123e3056e3cc9a 100644 --- a/chrome/browser/resources/extensions/manager.html +++ b/chrome/browser/resources/extensions/manager.html @@ -24,7 +24,7 @@ { - this.isSupervised_ = profileInfo.isSupervised; + this.isChildAccount_ = profileInfo.isChildAccount; this.incognitoAvailable_ = profileInfo.isIncognitoAvailable; this.devModeControlledByPolicy = profileInfo.isDeveloperModeControlledByPolicy; diff --git a/chrome/browser/resources/extensions/toolbar.html b/chrome/browser/resources/extensions/toolbar.html index 5bdfb0ef605044..62ff38f976cfdc 100644 --- a/chrome/browser/resources/extensions/toolbar.html +++ b/chrome/browser/resources/extensions/toolbar.html @@ -89,14 +89,14 @@
$i18n{toolbarDevMode}
diff --git a/chrome/browser/resources/extensions/toolbar.ts b/chrome/browser/resources/extensions/toolbar.ts index 132398aaa9120a..e45bb841a432ee 100644 --- a/chrome/browser/resources/extensions/toolbar.ts +++ b/chrome/browser/resources/extensions/toolbar.ts @@ -61,7 +61,7 @@ class ExtensionsToolbarElement extends ExtensionsToolbarElementBase { }, devModeControlledByPolicy: Boolean, - isSupervised: Boolean, + isChildAccount: Boolean, // kioskEnabled: Boolean, @@ -83,7 +83,7 @@ class ExtensionsToolbarElement extends ExtensionsToolbarElementBase { delegate: ToolbarDelegate; inDevMode: boolean; devModeControlledByPolicy: boolean; - isSupervised: boolean; + isChildAccount: boolean; // kioskEnabled: boolean; @@ -109,17 +109,17 @@ class ExtensionsToolbarElement extends ExtensionsToolbarElementBase { } private shouldDisableDevMode_(): boolean { - return this.devModeControlledByPolicy || this.isSupervised; + return this.devModeControlledByPolicy || this.isChildAccount; } private getTooltipText_(): string { return this.i18n( - this.isSupervised ? 'controlledSettingChildRestriction' : - 'controlledSettingPolicy'); + this.isChildAccount ? 'controlledSettingChildRestriction' : + 'controlledSettingPolicy'); } private getIcon_(): string { - return this.isSupervised ? 'cr20:kite' : 'cr20:domain'; + return this.isChildAccount ? 'cr20:kite' : 'cr20:domain'; } private onDevModeToggleChange_(e: CustomEvent) { diff --git a/chrome/browser/resources/settings/appearance_page/appearance_browser_proxy.ts b/chrome/browser/resources/settings/appearance_page/appearance_browser_proxy.ts index f510055569e5ef..be408638d1e93e 100644 --- a/chrome/browser/resources/settings/appearance_page/appearance_browser_proxy.ts +++ b/chrome/browser/resources/settings/appearance_page/appearance_browser_proxy.ts @@ -11,8 +11,8 @@ export interface AppearanceBrowserProxy { getDefaultZoom(): Promise; getThemeInfo(themeId: string): Promise; - /** @return Whether the current profile is supervised. */ - isSupervised(): boolean; + /** @return Whether the current profile is a child account. */ + isChildAccount(): boolean; useDefaultTheme(): void; @@ -36,8 +36,8 @@ export class AppearanceBrowserProxyImpl implements AppearanceBrowserProxy { }); } - isSupervised() { - return loadTimeData.getBoolean('isSupervised'); + isChildAccount() { + return loadTimeData.getBoolean('isChildAccount'); } useDefaultTheme() { diff --git a/chrome/browser/resources/settings/appearance_page/appearance_page.ts b/chrome/browser/resources/settings/appearance_page/appearance_page.ts index 79dbbe14bb10c5..60d2a6b5dc103d 100644 --- a/chrome/browser/resources/settings/appearance_page/appearance_page.ts +++ b/chrome/browser/resources/settings/appearance_page/appearance_page.ts @@ -277,7 +277,7 @@ export class SettingsAppearancePageElement extends /** @return Whether to show the "USE GTK+" button. */ private showUseSystem_(themeId: string, useSystemTheme: boolean): boolean { return (!!themeId || !useSystemTheme) && - !this.appearanceBrowserProxy_.isSupervised(); + !this.appearanceBrowserProxy_.isChildAccount(); } /** diff --git a/chrome/browser/resources/settings/chromeos/os_people_page/users_page.js b/chrome/browser/resources/settings/chromeos/os_people_page/users_page.js index 1d4a4987022a6e..f0b209c5e2d477 100644 --- a/chrome/browser/resources/settings/chromeos/os_people_page/users_page.js +++ b/chrome/browser/resources/settings/chromeos/os_people_page/users_page.js @@ -40,7 +40,7 @@ Polymer({ isChild_: { type: Boolean, value() { - return loadTimeData.getBoolean('isSupervised'); + return loadTimeData.getBoolean('isChildAccount'); }, }, diff --git a/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html b/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html index 777ce417c2badf..62a6235366d5da 100644 --- a/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html +++ b/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html @@ -181,7 +181,7 @@ '$i18nPolymer{clearBrowsingHistorySummarySignedInNoLink}', '$i18nPolymer{clearBrowsingHistorySummarySynced}')]]" disabled="[[clearingInProgress_]]" - hidden="[[isSupervised_]]" no-set-pref> + hidden="[[isChildAccount_]]" no-set-pref> AddBoolean( "isKioskModeActive", user_manager::UserManager::Get()->IsLoggedInAsAnyKioskApp()); - html_source->AddBoolean("isSupervised", profile()->IsChild()); + html_source->AddBoolean("isChildAccount", profile()->IsChild()); html_source->AddBoolean( "appManagementIntentSettingsEnabled", diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc index 848e1e9d0af9b9..ef9ab1d61a504c 100644 --- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc +++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc @@ -210,7 +210,7 @@ void AddCommonStrings(content::WebUIDataSource* html_source, Profile* profile) { profile->IsGuestSession()); #endif - html_source->AddBoolean("isSupervised", profile->IsChild()); + html_source->AddBoolean("isChildAccount", profile->IsChild()); } void AddA11yStrings(content::WebUIDataSource* html_source) { diff --git a/chrome/common/extensions/api/developer_private.idl b/chrome/common/extensions/api/developer_private.idl index e6afd3d51db732..d3cc055d5780a3 100644 --- a/chrome/common/extensions/api/developer_private.idl +++ b/chrome/common/extensions/api/developer_private.idl @@ -261,7 +261,7 @@ namespace developerPrivate { boolean inDeveloperMode; boolean isDeveloperModeControlledByPolicy; boolean isIncognitoAvailable; - boolean isSupervised; + boolean isChildAccount; }; // DEPRECATED: Prefer ExtensionInfo. diff --git a/chrome/test/data/webui/extensions/toolbar_test.js b/chrome/test/data/webui/extensions/toolbar_test.js index babafc65ff2ed1..cda75d4e20b462 100644 --- a/chrome/test/data/webui/extensions/toolbar_test.js +++ b/chrome/test/data/webui/extensions/toolbar_test.js @@ -37,7 +37,7 @@ suite(extension_toolbar_tests.suiteName, function() { document.body.appendChild(toolbar); toolbar.inDevMode = false; toolbar.devModeControlledByPolicy = false; - toolbar.isSupervised = false; + toolbar.isChildAccount = false; if (isChromeOS) { toolbar.kioskEnabled = false; } @@ -88,8 +88,8 @@ suite(extension_toolbar_tests.suiteName, function() { flush(); assertFalse(toggle.disabled); - // Test that the dev-mode toggle is disabled when the user is supervised. - toolbar.set('isSupervised', true); + // Test that the dev-mode toggle is disabled for child account users. + toolbar.set('isChildAccount', true); flush(); assertTrue(toggle.disabled); }); diff --git a/chrome/test/data/webui/settings/appearance_page_test.ts b/chrome/test/data/webui/settings/appearance_page_test.ts index eaac6d38319238..bbaba265648938 100644 --- a/chrome/test/data/webui/settings/appearance_page_test.ts +++ b/chrome/test/data/webui/settings/appearance_page_test.ts @@ -12,14 +12,14 @@ import {TestBrowserProxy} from 'chrome://webui-test/test_browser_proxy.js'; class TestAppearanceBrowserProxy extends TestBrowserProxy implements AppearanceBrowserProxy { private defaultZoom_: number = 1; - private isSupervised_: boolean = false; + private isChildAccount_: boolean = false; private isHomeUrlValid_: boolean = true; constructor() { super([ 'getDefaultZoom', 'getThemeInfo', - 'isSupervised', + 'isChildAccount', 'useDefaultTheme', 'useSystemTheme', 'validateStartupPage', @@ -49,9 +49,9 @@ class TestAppearanceBrowserProxy extends TestBrowserProxy implements }); } - isSupervised() { - this.methodCalled('isSupervised'); - return this.isSupervised_; + isChildAccount() { + this.methodCalled('isChildAccount'); + return this.isChildAccount_; } useDefaultTheme() { @@ -66,8 +66,8 @@ class TestAppearanceBrowserProxy extends TestBrowserProxy implements this.defaultZoom_ = defaultZoom; } - setIsSupervised(isSupervised: boolean) { - this.isSupervised_ = isSupervised; + setIsChildAccount(isChildAccount: boolean) { + this.isChildAccount_ = isChildAccount; } validateStartupPage(url: string) { @@ -165,10 +165,10 @@ suite('AppearanceHandler', function() { // The "USE GTK+" button shouldn't be showing if it's already in use. assertFalse(!!appearancePage.shadowRoot!.querySelector('#useSystem')); - appearanceBrowserProxy.setIsSupervised(true); + appearanceBrowserProxy.setIsChildAccount(true); appearancePage.set(USE_SYSTEM_PREF, false); flush(); - // Supervised users have their own theme and can't use GTK+ theme. + // Child account users have their own theme and can't use GTK+ theme. assertFalse(!!appearancePage.shadowRoot!.querySelector('#useDefault')); assertFalse(!!appearancePage.shadowRoot!.querySelector('#useSystem')); // If there's no "USE" buttons, the container should be hidden. @@ -176,7 +176,7 @@ suite('AppearanceHandler', function() { appearancePage.shadowRoot! .querySelector('#themesSecondaryActions')!.hidden); - appearanceBrowserProxy.setIsSupervised(false); + appearanceBrowserProxy.setIsChildAccount(false); appearancePage.set(THEME_ID_PREF, 'fake theme id'); flush(); // If there's "USE" buttons again, the container should be visible. diff --git a/chrome/test/data/webui/settings/clear_browsing_data_test.ts b/chrome/test/data/webui/settings/clear_browsing_data_test.ts index 4878e41588cb7a..0d25101661affa 100644 --- a/chrome/test/data/webui/settings/clear_browsing_data_test.ts +++ b/chrome/test/data/webui/settings/clear_browsing_data_test.ts @@ -604,7 +604,7 @@ suite('ClearBrowsingDataAllPlatforms', function() { }); test('history rows are hidden for supervised users', function() { - assertFalse(loadTimeData.getBoolean('isSupervised')); + assertFalse(loadTimeData.getBoolean('isChildAccount')); assertFalse(element.shadowRoot! .querySelector( '#browsingCheckbox')!.hidden); @@ -617,7 +617,7 @@ suite('ClearBrowsingDataAllPlatforms', function() { element.remove(); testBrowserProxy.reset(); - loadTimeData.overrideValues({isSupervised: true}); + loadTimeData.overrideValues({isChildAccount: true}); element = document.createElement('settings-clear-browsing-data-dialog'); document.body.appendChild(element); diff --git a/third_party/closure_compiler/externs/developer_private.js b/third_party/closure_compiler/externs/developer_private.js index eca28a05d3ee56..47f8cc75f93f64 100644 --- a/third_party/closure_compiler/externs/developer_private.js +++ b/third_party/closure_compiler/externs/developer_private.js @@ -333,7 +333,7 @@ chrome.developerPrivate.ExtensionInfo; * inDeveloperMode: boolean, * isDeveloperModeControlledByPolicy: boolean, * isIncognitoAvailable: boolean, - * isSupervised: boolean + * isChildAccount: boolean * }} */ chrome.developerPrivate.ProfileInfo; diff --git a/tools/typescript/definitions/developer_private.d.ts b/tools/typescript/definitions/developer_private.d.ts index 12e5398203f19e..f282147fc05112 100644 --- a/tools/typescript/definitions/developer_private.d.ts +++ b/tools/typescript/definitions/developer_private.d.ts @@ -248,7 +248,7 @@ declare global { inDeveloperMode: boolean, isDeveloperModeControlledByPolicy: boolean, isIncognitoAvailable: boolean, - isSupervised: boolean, + isChildAccount: boolean, }; export type ExtensionConfigurationUpdate = { From 78a96dc779b8cd9317ef81fdd04fbef4fe50101d Mon Sep 17 00:00:00 2001 From: Ossama Mahmoud Date: Tue, 14 Dec 2021 13:16:21 +0000 Subject: [PATCH 10/51] OOBE: Handle Guest ToS screen in browsertests Bug: 1273975 Change-Id: Iac51ef4668d1962f3cb2f6a42672342ebac3794d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3338556 Reviewed-by: Roman Sorokin Commit-Queue: Osama Fathy Cr-Commit-Position: refs/heads/main@{#951460} --- .../ash/login/guest_login_browsertest.cc | 46 +++++++++++++++++-- .../shill_profile_loading_browsertest.cc | 4 ++ 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/chrome/browser/ash/login/guest_login_browsertest.cc b/chrome/browser/ash/login/guest_login_browsertest.cc index 1e2b63c070e96a..c7359a60129fe4 100644 --- a/chrome/browser/ash/login/guest_login_browsertest.cc +++ b/chrome/browser/ash/login/guest_login_browsertest.cc @@ -2,13 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "ash/constants/ash_features.h" #include "ash/public/cpp/keyboard/keyboard_controller.h" #include "ash/public/cpp/login_screen_test_api.h" #include "chrome/browser/about_flags.h" +#include "chrome/browser/ash/login/startup_utils.h" +#include "chrome/browser/ash/login/test/js_checker.h" #include "chrome/browser/ash/login/test/login_manager_mixin.h" +#include "chrome/browser/ash/login/test/oobe_screen_waiter.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" +#include "chrome/browser/ui/webui/chromeos/login/guest_tos_screen_handler.h" #include "chrome/test/base/mixin_based_in_process_browser_test.h" #include "chromeos/dbus/power/fake_power_manager_client.h" #include "chromeos/dbus/session_manager/fake_session_manager_client.h" @@ -19,6 +24,9 @@ namespace ash { +constexpr char kGuestTosId[] = "guest-tos"; +const test::UIPath kGuestTosAcceptButton = {kGuestTosId, "acceptButton"}; + // Tests guest user log in. class GuestLoginTest : public MixinBasedInProcessBrowserTest { public: @@ -40,6 +48,15 @@ class GuestLoginTest : public MixinBasedInProcessBrowserTest { MixinBasedInProcessBrowserTest::SetUpOnMainThread(); } + void StartGuestSession() { + ASSERT_TRUE(LoginScreenTestApi::ClickGuestButton()); + + if (chromeos::features::IsOobeConsolidatedConsentEnabled()) { + OobeScreenWaiter(GuestTosScreenView::kScreenId).Wait(); + test::OobeJS().ClickOnPath(kGuestTosAcceptButton); + } + } + protected: LoginManagerMixin login_manager_{&mixin_host_, {}}; }; @@ -71,7 +88,7 @@ IN_PROC_BROWSER_TEST_F(GuestLoginTest, PRE_Login) { FakeSessionManagerClient::Get()->set_restart_job_callback( restart_job_waiter.QuitClosure()); - ASSERT_TRUE(LoginScreenTestApi::ClickGuestButton()); + StartGuestSession(); restart_job_waiter.Run(); EXPECT_TRUE(FakeSessionManagerClient::Get()->restart_job_argv().has_value()); @@ -89,7 +106,7 @@ IN_PROC_BROWSER_TEST_F(GuestLoginTest, PRE_ExitFullscreenOnSuspend) { FakeSessionManagerClient::Get()->set_restart_job_callback( restart_job_waiter.QuitClosure()); - ASSERT_TRUE(LoginScreenTestApi::ClickGuestButton()); + StartGuestSession(); restart_job_waiter.Run(); EXPECT_TRUE(FakeSessionManagerClient::Get()->restart_job_argv().has_value()); @@ -114,7 +131,7 @@ IN_PROC_BROWSER_TEST_F(GuestLoginTest, FakeSessionManagerClient::Get()->set_restart_job_callback( restart_job_waiter.QuitClosure()); - ASSERT_TRUE(LoginScreenTestApi::ClickGuestButton()); + StartGuestSession(); restart_job_waiter.Run(); EXPECT_TRUE(FakeSessionManagerClient::Get()->restart_job_argv().has_value()); @@ -137,6 +154,27 @@ IN_PROC_BROWSER_TEST_F(GuestLoginTest, EXPECT_TRUE(config.voice_input); } +// When Eula is marked as accepted, the Guest ToS screen is skipped. +IN_PROC_BROWSER_TEST_F(GuestLoginTest, PRE_SkipGuestToS) { + StartupUtils::MarkEulaAccepted(); + + base::RunLoop restart_job_waiter; + FakeSessionManagerClient::Get()->set_restart_job_callback( + restart_job_waiter.QuitClosure()); + + ASSERT_TRUE(LoginScreenTestApi::ClickGuestButton()); + + restart_job_waiter.Run(); + EXPECT_TRUE(FakeSessionManagerClient::Get()->restart_job_argv().has_value()); +} + +IN_PROC_BROWSER_TEST_F(GuestLoginTest, SkipGuestToS) { + login_manager_.WaitForActiveSession(); + + user_manager::UserManager* user_manager = user_manager::UserManager::Get(); + EXPECT_TRUE(user_manager->IsLoggedInAsGuest()); +} + IN_PROC_BROWSER_TEST_F(GuestLoginWithLoginSwitchesTest, PRE_Login) { base::RunLoop restart_job_waiter; FakeSessionManagerClient::Get()->set_restart_job_callback( @@ -144,7 +182,7 @@ IN_PROC_BROWSER_TEST_F(GuestLoginWithLoginSwitchesTest, PRE_Login) { EXPECT_TRUE( base::CommandLine::ForCurrentProcess()->HasSwitch("feature-switch")); - ASSERT_TRUE(LoginScreenTestApi::ClickGuestButton()); + StartGuestSession(); restart_job_waiter.Run(); EXPECT_TRUE(FakeSessionManagerClient::Get()->restart_job_argv().has_value()); diff --git a/chrome/browser/ash/login/shill_profile_loading_browsertest.cc b/chrome/browser/ash/login/shill_profile_loading_browsertest.cc index 3f5213fb81801f..a82145c2a1c892 100644 --- a/chrome/browser/ash/login/shill_profile_loading_browsertest.cc +++ b/chrome/browser/ash/login/shill_profile_loading_browsertest.cc @@ -19,6 +19,7 @@ #include "base/bind_internal.h" #include "base/run_loop.h" #include "chrome/browser/ash/login/login_manager_test.h" +#include "chrome/browser/ash/login/startup_utils.h" #include "chrome/browser/ash/login/test/login_manager_mixin.h" #include "chrome/browser/ash/login/test/user_policy_mixin.h" #include "chrome/browser/ash/login/ui/user_adding_screen.h" @@ -233,6 +234,9 @@ IN_PROC_BROWSER_TEST_F(ShillProfileLoadingGuestLoginTest, GuestLogin) { LoadShillProfileWaiter load_shill_profile_waiter( FakeSessionManagerClient::Get()); + + // Mark EULA accepted to skip the guest ToS screen. + StartupUtils::MarkEulaAccepted(); ASSERT_TRUE(LoginScreenTestApi::ClickGuestButton()); restart_job_waiter.Run(); From 9e2430b8e78ff0feea8230944bd53757396483f4 Mon Sep 17 00:00:00 2001 From: Maksim Ivanov Date: Tue, 14 Dec 2021 13:28:55 +0000 Subject: [PATCH 11/51] Fix use-after-move in AccessTokenFetcher Fix a use-after-move issue in a debug assertion in AccessTokenFetcher, as found by clang-tidy: components/signin/public/identity_manager/access_token_fetcher.cc:100: 'url_loader_factory' used after it was moved components/signin/public/identity_manager/access_token_fetcher.cc:95: move occurred here Bug: 1122844 Change-Id: I015298bac8fff3113e6518fbf8687fbf5471abe3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3335916 Auto-Submit: Maksim Ivanov Reviewed-by: Nohemi Fernandez Commit-Queue: Nohemi Fernandez Cr-Commit-Position: refs/heads/main@{#951461} --- .../signin/public/identity_manager/access_token_fetcher.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/signin/public/identity_manager/access_token_fetcher.cc b/components/signin/public/identity_manager/access_token_fetcher.cc index a49158ae2937c2..bb41d02c07fb2e 100644 --- a/components/signin/public/identity_manager/access_token_fetcher.cc +++ b/components/signin/public/identity_manager/access_token_fetcher.cc @@ -97,7 +97,7 @@ AccessTokenFetcher::AccessTokenFetcher( mode_(mode), callback_(std::move(callback)) { DCHECK(client_id_.empty() == client_secret_.empty()); - DCHECK(client_id_.empty() || !url_loader_factory); + DCHECK(client_id_.empty() || !url_loader_factory_); if (mode_ == Mode::kImmediate || IsRefreshTokenAvailable()) { StartAccessTokenRequest(); From c42d733c292e19d9df6a8ee9f4ebb23b7953bf3e Mon Sep 17 00:00:00 2001 From: Florian Gauger Date: Tue, 14 Dec 2021 13:39:03 +0000 Subject: [PATCH 12/51] [Autofill Assistant] Remove ActivityType Chrome dependency Bug: b/173103628 Change-Id: Id6010fd01ac6ef2b59ebe3bd1cefe0d42eaf4d91 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3320286 Auto-Submit: Florian Gauger Reviewed-by: Sandro Maggi Reviewed-by: Andrew Grieve Commit-Queue: Florian Gauger Cr-Commit-Position: refs/heads/main@{#951462} --- .../AssistantDependencyUtilsChrome.java | 13 +++++++++++++ .../AutofillAssistantFacade.java | 18 +++--------------- .../directactions/DirectActionInitializer.java | 5 +++-- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AssistantDependencyUtilsChrome.java b/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AssistantDependencyUtilsChrome.java index ed72166f715675..4982fd11309be4 100644 --- a/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AssistantDependencyUtilsChrome.java +++ b/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AssistantDependencyUtilsChrome.java @@ -6,11 +6,13 @@ import android.app.Activity; import android.content.Intent; +import android.os.Build; import androidx.annotation.Nullable; import org.chromium.chrome.browser.IntentHandler; import org.chromium.chrome.browser.IntentHandler.ExternalAppId; +import org.chromium.chrome.browser.flags.ActivityType; /** * Chrome specific dependency methods used by the Autofill Assistant outside of it's module. @@ -36,5 +38,16 @@ public static boolean isGsa(@Nullable Activity activity) { return IntentHandler.determineExternalIntentSource(intent) == ExternalAppId.GSA; } + /** + * Checks whether direct actions provided by Autofill Assistant should be available - assuming + * that direct actions are available at all. + */ + public static boolean areDirectActionsAvailable(@ActivityType int activityType) { + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q + && (activityType == ActivityType.CUSTOM_TAB || activityType == ActivityType.TABBED) + && AssistantFeatures.AUTOFILL_ASSISTANT.isEnabled() + && AssistantFeatures.AUTOFILL_ASSISTANT_DIRECT_ACTIONS.isEnabled(); + } + private AssistantDependencyUtilsChrome() {} } diff --git a/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantFacade.java b/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantFacade.java index d6888c4f5f4744..63223930c9b956 100644 --- a/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantFacade.java +++ b/chrome/android/features/autofill_assistant/public/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantFacade.java @@ -8,7 +8,6 @@ import android.content.Context; import android.content.Intent; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.text.TextUtils; import android.view.View; @@ -23,7 +22,6 @@ import org.chromium.chrome.browser.autofill_assistant.metrics.DropOutReason; import org.chromium.chrome.browser.browser_controls.BrowserControlsStateProvider; import org.chromium.chrome.browser.directactions.DirectActionHandler; -import org.chromium.chrome.browser.flags.ActivityType; import org.chromium.chrome.browser.metrics.UmaSessionStats; import org.chromium.chrome.browser.tab.Tab; import org.chromium.components.browser_ui.bottomsheet.BottomSheetController; @@ -112,22 +110,12 @@ public static void start(@Nullable Activity activity, TriggerContext triggerCont tab -> { AutofillAssistantTabHelper.get(tab).start(triggerContext); }); } - /** - * Checks whether direct actions provided by Autofill Assistant should be available - assuming - * that direct actions are available at all. - */ - public static boolean areDirectActionsAvailable(@ActivityType int activityType) { - return Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q - && (activityType == ActivityType.CUSTOM_TAB || activityType == ActivityType.TABBED) - && AssistantFeatures.AUTOFILL_ASSISTANT.isEnabled() - && AssistantFeatures.AUTOFILL_ASSISTANT_DIRECT_ACTIONS.isEnabled(); - } - /** * Returns a {@link DirectActionHandler} for making dynamic actions available under Android Q. * - *

This should only be called if {@link #areDirectActionsAvailable} returns true. This method - * can also return null if autofill assistant is not available for some other reasons. + *

This should only be called if {@link + * AssistantDependencyUtilsChrome#areDirectActionsAvailable} returns true. This method can also + * return null if autofill assistant is not available for some other reasons. */ public static DirectActionHandler createDirectActionHandler(Context context, BottomSheetController bottomSheetController, diff --git a/chrome/android/java/src/org/chromium/chrome/browser/directactions/DirectActionInitializer.java b/chrome/android/java/src/org/chromium/chrome/browser/directactions/DirectActionInitializer.java index 527ad7f8b78a43..a25c7c4f48299e 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/directactions/DirectActionInitializer.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/directactions/DirectActionInitializer.java @@ -14,6 +14,7 @@ import org.chromium.chrome.R; import org.chromium.chrome.browser.ActivityTabProvider; import org.chromium.chrome.browser.AppHooks; +import org.chromium.chrome.browser.autofill_assistant.AssistantDependencyUtilsChrome; import org.chromium.chrome.browser.autofill_assistant.AutofillAssistantFacade; import org.chromium.chrome.browser.browser_controls.BrowserControlsStateProvider; import org.chromium.chrome.browser.compositor.CompositorViewHolder; @@ -152,7 +153,7 @@ private void registerCommonChromeActions(Context context, @ActivityType int acti registerMenuHandlerIfNecessary(actionController, tabModelSelector) .allowlistActions(R.id.forward_menu_id, R.id.reload_menu_id); - if (AutofillAssistantFacade.areDirectActionsAvailable(activityType)) { + if (AssistantDependencyUtilsChrome.areDirectActionsAvailable(activityType)) { DirectActionHandler handler = AutofillAssistantFacade.createDirectActionHandler(context, bottomSheetController, browserControls, compositorViewHolder, activityTabProvider); @@ -207,7 +208,7 @@ public void onFinishNativeInitialization() { void registerDirectActions() { registerCommonChromeActions(mContext, mActivityType, mMenuOrKeyboardActionController, mGoBackAction, mTabModelSelector, mFindToolbarManager, - AutofillAssistantFacade.areDirectActionsAvailable(mActivityType) + AssistantDependencyUtilsChrome.areDirectActionsAvailable(mActivityType) ? mBottomSheetController : null, mBrowserControls, mCompositorViewHolder, mActivityTabProvider); From 0a250d45333f3c64b95ba23949173ab26cedc317 Mon Sep 17 00:00:00 2001 From: James Forshaw Date: Tue, 14 Dec 2021 13:47:21 +0000 Subject: [PATCH 13/51] Revert "[Windows] Remove duplicate use of NtQueryObject." This reverts commit 312744cf056543cf5d3ed31598fedfcb4cc5188c. Reason for revert: Possible release blocker https://bugs.chromium.org/p/chromium/issues/detail?id=1279699 Original change's description: > [Windows] Remove duplicate use of NtQueryObject. > > This CL removes duplicate uses of the NtQueryObject system call and > replaces them with common functions. > > Bug: 1270309 > Change-Id: Ie15e2547235ac8700d32c5fe2e371c95f85c0491 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3327958 > Reviewed-by: Will Harris > Commit-Queue: James Forshaw > Cr-Commit-Position: refs/heads/main@{#951036} Bug: 1270309 Change-Id: I277fcd8fd0b44e14321ca3f8dc4856354e4ea194 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3338261 Auto-Submit: James Forshaw Commit-Queue: James Forshaw Commit-Queue: Rubber Stamper Bot-Commit: Rubber Stamper Cr-Commit-Position: refs/heads/main@{#951463} --- sandbox/policy/win/sandbox_win.cc | 2 +- sandbox/win/src/handle_closer.cc | 29 ++++++++ sandbox/win/src/handle_closer.h | 3 + sandbox/win/src/handle_closer_agent.cc | 90 ++++++++++++++++------- sandbox/win/src/handle_closer_test.cc | 62 +++++++++++++--- sandbox/win/src/named_pipe_policy_test.cc | 4 +- sandbox/win/src/nt_internals.h | 7 ++ sandbox/win/src/sandbox_nt_util.cc | 64 ++++++++++++++++ sandbox/win/src/sandbox_nt_util.h | 6 ++ sandbox/win/src/win_utils.cc | 67 ++++++----------- sandbox/win/src/win_utils.h | 5 +- sandbox/win/src/win_utils_unittest.cc | 45 ------------ 12 files changed, 253 insertions(+), 131 deletions(-) diff --git a/sandbox/policy/win/sandbox_win.cc b/sandbox/policy/win/sandbox_win.cc index 602e1fc03c8152..497d535f27884a 100644 --- a/sandbox/policy/win/sandbox_win.cc +++ b/sandbox/policy/win/sandbox_win.cc @@ -463,7 +463,7 @@ typedef BOOL(WINAPI* DuplicateHandleFunctionPtr)(HANDLE source_process_handle, DuplicateHandleFunctionPtr g_iat_orig_duplicate_handle; -NtQueryObjectFunction g_QueryObject = NULL; +NtQueryObject g_QueryObject = NULL; static const char* kDuplicateHandleWarning = "You are attempting to duplicate a privileged handle into a sandboxed" diff --git a/sandbox/win/src/handle_closer.cc b/sandbox/win/src/handle_closer.cc index 56e27d20826308..841a81506b3d7c 100644 --- a/sandbox/win/src/handle_closer.cc +++ b/sandbox/win/src/handle_closer.cc @@ -11,6 +11,10 @@ #include "base/check_op.h" #include "base/memory/free_deleter.h" #include "base/win/windows_version.h" +#include "sandbox/win/src/interceptors.h" +#include "sandbox/win/src/internal_types.h" +#include "sandbox/win/src/nt_internals.h" +#include "sandbox/win/src/process_thread_interception.h" #include "sandbox/win/src/win_utils.h" namespace { @@ -153,4 +157,29 @@ bool HandleCloser::SetupHandleList(void* buffer, size_t buffer_bytes) { return output <= end; } +bool GetHandleName(HANDLE handle, std::wstring* handle_name) { + static NtQueryObject QueryObject = nullptr; + if (!QueryObject) + ResolveNTFunctionPtr("NtQueryObject", &QueryObject); + + ULONG size = MAX_PATH; + std::unique_ptr name; + NTSTATUS result; + + do { + name.reset(static_cast(malloc(size))); + DCHECK(name.get()); + result = + QueryObject(handle, ObjectNameInformation, name.get(), size, &size); + } while (result == STATUS_INFO_LENGTH_MISMATCH || + result == STATUS_BUFFER_OVERFLOW); + + if (NT_SUCCESS(result) && name->Buffer && name->Length) + handle_name->assign(name->Buffer, name->Length / sizeof(wchar_t)); + else + handle_name->clear(); + + return NT_SUCCESS(result); +} + } // namespace sandbox diff --git a/sandbox/win/src/handle_closer.h b/sandbox/win/src/handle_closer.h index ef885dc664ec6f..4bfab94417806a 100644 --- a/sandbox/win/src/handle_closer.h +++ b/sandbox/win/src/handle_closer.h @@ -72,6 +72,9 @@ class HandleCloser { HandleMap handles_to_close_; }; +// Returns the object manager's name associated with a handle +bool GetHandleName(HANDLE handle, std::wstring* handle_name); + } // namespace sandbox #endif // SANDBOX_WIN_SRC_HANDLE_CLOSER_H_ diff --git a/sandbox/win/src/handle_closer_agent.cc b/sandbox/win/src/handle_closer_agent.cc index 0b0de365d12709..045b17ac3972a3 100644 --- a/sandbox/win/src/handle_closer_agent.cc +++ b/sandbox/win/src/handle_closer_agent.cc @@ -6,13 +6,35 @@ #include #include -#include #include "base/check.h" #include "base/win/static_constants.h" -#include "base/win/win_util.h" +#include "sandbox/win/src/nt_internals.h" #include "sandbox/win/src/win_utils.h" +namespace { + +// Returns type infomation for an NT object. This routine is expected to be +// called for invalid handles so it catches STATUS_INVALID_HANDLE exceptions +// that can be generated when handle tracing is enabled. +NTSTATUS QueryObjectTypeInformation(HANDLE handle, void* buffer, ULONG* size) { + static NtQueryObject QueryObject = nullptr; + if (!QueryObject) + ResolveNTFunctionPtr("NtQueryObject", &QueryObject); + + NTSTATUS status = STATUS_UNSUCCESSFUL; + __try { + status = QueryObject(handle, ObjectTypeInformation, buffer, *size, size); + } __except (GetExceptionCode() == STATUS_INVALID_HANDLE + ? EXCEPTION_EXECUTE_HANDLER + : EXCEPTION_CONTINUE_SEARCH) { + status = STATUS_INVALID_HANDLE; + } + return status; +} + +} // namespace + namespace sandbox { // Memory buffer mapped from the parent, with the list of handles. @@ -155,44 +177,60 @@ bool HandleCloserAgent::CloseHandles() { if (GetModuleHandleA(base::win::kApplicationVerifierDllName)) return true; - uint32_t handle_value = 0; + // Set up buffers for the type info and the name. + std::vector type_info_buffer(sizeof(OBJECT_TYPE_INFORMATION) + + 32 * sizeof(wchar_t)); + OBJECT_TYPE_INFORMATION* type_info = + reinterpret_cast(&(type_info_buffer[0])); + std::wstring handle_name; + HANDLE handle = nullptr; int invalid_count = 0; // Keep incrementing until we hit the number of handles reported by // GetProcessHandleCount(). If we hit a very long sequence of invalid // handles we assume that we've run past the end of the table. while (handle_count && invalid_count < kInvalidHandleThreshold) { - handle_value += kHandleOffset; - HANDLE handle = base::win::Uint32ToHandle(handle_value); - std::wstring type_name; - if (!GetTypeNameFromHandle(handle, &type_name)) { + reinterpret_cast(handle) += kHandleOffset; + NTSTATUS rc; + + // Get the type name, reusing the buffer. + ULONG size = static_cast(type_info_buffer.size()); + rc = QueryObjectTypeInformation(handle, type_info, &size); + while (rc == STATUS_INFO_LENGTH_MISMATCH || rc == STATUS_BUFFER_OVERFLOW) { + type_info_buffer.resize(size + sizeof(wchar_t)); + type_info = + reinterpret_cast(&(type_info_buffer[0])); + rc = QueryObjectTypeInformation(handle, type_info, &size); + // Leave padding for the nul terminator. + if (NT_SUCCESS(rc) && size == type_info_buffer.size()) + rc = STATUS_INFO_LENGTH_MISMATCH; + } + if (!NT_SUCCESS(rc) || !type_info->Name.Buffer) { ++invalid_count; continue; } --handle_count; - // Check if we're looking for this type of handle. - HandleMap::iterator result = handles_to_close_.find(type_name); - if (result == handles_to_close_.end()) - continue; + type_info->Name.Buffer[type_info->Name.Length / sizeof(wchar_t)] = L'\0'; - HandleMap::mapped_type& names = result->second; - // Empty set means close all handles of this type; otherwise check name. - if (!names.empty()) { - std::wstring handle_name; - // Move on to the next handle if this name doesn't match. - if (!GetPathFromHandle(handle, &handle_name) || - !names.count(handle_name)) { - continue; + // Check if we're looking for this type of handle. + HandleMap::iterator result = handles_to_close_.find(type_info->Name.Buffer); + if (result != handles_to_close_.end()) { + HandleMap::mapped_type& names = result->second; + // Empty set means close all handles of this type; otherwise check name. + if (!names.empty()) { + // Move on to the next handle if this name doesn't match. + if (!GetHandleName(handle, &handle_name) || !names.count(handle_name)) + continue; } - } - if (!::SetHandleInformation(handle, HANDLE_FLAG_PROTECT_FROM_CLOSE, 0)) - return false; - if (!::CloseHandle(handle)) - return false; - // Attempt to stuff this handle with a new dummy Event. - AttemptToStuffHandleSlot(handle, result->first); + if (!::SetHandleInformation(handle, HANDLE_FLAG_PROTECT_FROM_CLOSE, 0)) + return false; + if (!::CloseHandle(handle)) + return false; + // Attempt to stuff this handle with a new dummy Event. + AttemptToStuffHandleSlot(handle, result->first); + } } return true; diff --git a/sandbox/win/src/handle_closer_test.cc b/sandbox/win/src/handle_closer_test.cc index abfb21ca88f433..7406f77592a944 100644 --- a/sandbox/win/src/handle_closer_test.cc +++ b/sandbox/win/src/handle_closer_test.cc @@ -5,7 +5,6 @@ #include #include -#include "base/strings/string_util_win.h" #include "base/strings/stringprintf.h" #include "base/win/scoped_handle.h" #include "sandbox/win/src/handle_closer_agent.h" @@ -13,7 +12,6 @@ #include "sandbox/win/src/sandbox.h" #include "sandbox/win/src/sandbox_factory.h" #include "sandbox/win/src/target_services.h" -#include "sandbox/win/src/win_utils.h" #include "sandbox/win/tests/common/controller.h" #include "testing/gtest/include/gtest/gtest.h" @@ -47,6 +45,25 @@ HANDLE GetMarkerFile(const wchar_t* extension) { nullptr, OPEN_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, nullptr); } +// Returns type infomation for an NT object. This routine is expected to be +// called for invalid handles so it catches STATUS_INVALID_HANDLE exceptions +// that can be generated when handle tracing is enabled. +NTSTATUS QueryObjectTypeInformation(HANDLE handle, void* buffer, ULONG* size) { + static NtQueryObject QueryObject = nullptr; + if (!QueryObject) + ResolveNTFunctionPtr("NtQueryObject", &QueryObject); + + NTSTATUS status = STATUS_UNSUCCESSFUL; + __try { + status = QueryObject(handle, ObjectTypeInformation, buffer, *size, size); + } __except (GetExceptionCode() == STATUS_INVALID_HANDLE + ? EXCEPTION_EXECUTE_HANDLER + : EXCEPTION_CONTINUE_SEARCH) { + status = STATUS_INVALID_HANDLE; + } + return status; +} + // Used by the thread pool tests. HANDLE finish_event; const int kWaitCount = 20; @@ -88,7 +105,7 @@ SBOX_TESTS_COMMAND int CheckForFileHandles(int argc, wchar_t** argv) { while (handle_count && invalid_count < kInvalidHandleThreshold) { reinterpret_cast(handle) += kHandleOffset; - if (GetPathFromHandle(handle, &handle_name)) { + if (GetHandleName(handle, &handle_name)) { for (int i = 1; i < argc; ++i) { if (handle_name == argv[i]) return should_find ? SBOX_TEST_SUCCEEDED : SBOX_TEST_FAILED; @@ -127,9 +144,36 @@ SBOX_TESTS_COMMAND int CheckForEventHandles(int argc, wchar_t** argv) { case AFTER_REVERT: for (HANDLE handle : to_check) { - std::wstring type_name; - CHECK(GetTypeNameFromHandle(handle, &type_name)); - CHECK(base::EqualsCaseInsensitiveASCII(type_name, L"Event")); + // Set up buffers for the type info and the name. + std::vector type_info_buffer(sizeof(OBJECT_TYPE_INFORMATION) + + 32 * sizeof(wchar_t)); + OBJECT_TYPE_INFORMATION* type_info = + reinterpret_cast(&(type_info_buffer[0])); + NTSTATUS rc; + + // Get the type name, reusing the buffer. + ULONG size = static_cast(type_info_buffer.size()); + rc = QueryObjectTypeInformation(handle, type_info, &size); + while (rc == STATUS_INFO_LENGTH_MISMATCH || + rc == STATUS_BUFFER_OVERFLOW) { + type_info_buffer.resize(size + sizeof(wchar_t)); + type_info = reinterpret_cast( + &(type_info_buffer[0])); + rc = QueryObjectTypeInformation(handle, type_info, &size); + // Leave padding for the nul terminator. + if (NT_SUCCESS(rc) && size == type_info_buffer.size()) + rc = STATUS_INFO_LENGTH_MISMATCH; + } + + CHECK(NT_SUCCESS(rc)); + CHECK(type_info->Name.Buffer); + + type_info->Name.Buffer[type_info->Name.Length / sizeof(wchar_t)] = + L'\0'; + + // Should be an Event now. + CHECK_EQ(wcslen(type_info->Name.Buffer), 5U); + CHECK_EQ(wcscmp(L"Event", type_info->Name.Buffer), 0); // Should not be able to wait. CHECK_EQ(WaitForSingleObject(handle, INFINITE), WAIT_FAILED); @@ -156,7 +200,7 @@ TEST(HandleCloserTest, CheckForMarkerFiles) { std::wstring handle_name; base::win::ScopedHandle marker(GetMarkerFile(kExtension)); CHECK(marker.IsValid()); - CHECK(GetPathFromHandle(marker.Get(), &handle_name)); + CHECK(sandbox::GetHandleName(marker.Get(), &handle_name)); command += (L" "); command += handle_name; } @@ -176,7 +220,7 @@ TEST(HandleCloserTest, CloseMarkerFiles) { std::wstring handle_name; base::win::ScopedHandle marker(GetMarkerFile(kExtension)); CHECK(marker.IsValid()); - CHECK(GetPathFromHandle(marker.Get(), &handle_name)); + CHECK(sandbox::GetHandleName(marker.Get(), &handle_name)); CHECK_EQ(policy->AddKernelObjectToClose(L"File", handle_name.c_str()), SBOX_ALL_OK); command += (L" "); @@ -197,7 +241,7 @@ TEST(HandleCloserTest, CheckStuffedHandle) { std::wstring handle_name; base::win::ScopedHandle marker(GetMarkerFile(kExtension)); CHECK(marker.IsValid()); - CHECK(GetPathFromHandle(marker.Get(), &handle_name)); + CHECK(sandbox::GetHandleName(marker.Get(), &handle_name)); CHECK_EQ(policy->AddKernelObjectToClose(L"File", handle_name.c_str()), SBOX_ALL_OK); } diff --git a/sandbox/win/src/named_pipe_policy_test.cc b/sandbox/win/src/named_pipe_policy_test.cc index 3d8db97a99ebca..db532d618d6d2d 100644 --- a/sandbox/win/src/named_pipe_policy_test.cc +++ b/sandbox/win/src/named_pipe_policy_test.cc @@ -3,10 +3,10 @@ // found in the LICENSE file. #include "base/win/windows_version.h" +#include "sandbox/win/src/handle_closer.h" #include "sandbox/win/src/sandbox.h" #include "sandbox/win/src/sandbox_factory.h" #include "sandbox/win/src/sandbox_policy.h" -#include "sandbox/win/src/win_utils.h" #include "sandbox/win/tests/common/controller.h" #include "testing/gtest/include/gtest/gtest.h" @@ -26,7 +26,7 @@ SBOX_TESTS_COMMAND int NamedPipe_Create(int argc, wchar_t** argv) { // pipe should be in the object namespace after creation. if (argc == 2) { std::wstring handle_name; - if (GetPathFromHandle(pipe, &handle_name)) { + if (GetHandleName(pipe, &handle_name)) { if (handle_name.compare(0, wcslen(argv[1]), argv[1]) != 0) return SBOX_TEST_FAILED; } else { diff --git a/sandbox/win/src/nt_internals.h b/sandbox/win/src/nt_internals.h index 79784aa7d69bf4..46d489fe2c506b 100644 --- a/sandbox/win/src/nt_internals.h +++ b/sandbox/win/src/nt_internals.h @@ -723,6 +723,13 @@ typedef NTSTATUS(WINAPI* NtQuerySystemInformation)( IN ULONG SystemInformationLength, OUT PULONG ReturnLength); +typedef NTSTATUS(WINAPI* NtQueryObject)(IN HANDLE Handle, + IN OBJECT_INFORMATION_CLASS + ObjectInformationClass, + OUT PVOID ObjectInformation, + IN ULONG ObjectInformationLength, + OUT PULONG ReturnLength); + // ----------------------------------------------------------------------- // Strings diff --git a/sandbox/win/src/sandbox_nt_util.cc b/sandbox/win/src/sandbox_nt_util.cc index 84b5bb67ed9066..8ba59ff7bf99c0 100644 --- a/sandbox/win/src/sandbox_nt_util.cc +++ b/sandbox/win/src/sandbox_nt_util.cc @@ -230,6 +230,70 @@ NTSTATUS CopyData(void* destination, const void* source, size_t bytes) { return ret; } +NTSTATUS AllocAndGetFullPath( + HANDLE root, + const wchar_t* path, + std::unique_ptr* full_path) { + if (!InitHeap()) + return STATUS_NO_MEMORY; + + DCHECK_NT(full_path); + DCHECK_NT(path); + NTSTATUS ret = STATUS_UNSUCCESSFUL; + __try { + do { + static NtQueryObjectFunction NtQueryObject = nullptr; + if (!NtQueryObject) + ResolveNTFunctionPtr("NtQueryObject", &NtQueryObject); + + ULONG size = 0; + // Query the name information a first time to get the size of the name. + ret = NtQueryObject(root, ObjectNameInformation, nullptr, 0, &size); + + std::unique_ptr handle_name; + if (size) { + handle_name.reset(reinterpret_cast( + new (NT_ALLOC) BYTE[size])); + + // Query the name information a second time to get the name of the + // object referenced by the handle. + ret = NtQueryObject(root, ObjectNameInformation, handle_name.get(), + size, &size); + } + + if (STATUS_SUCCESS != ret) + break; + + // Space for path + '\' + name + '\0'. + size_t name_length = + handle_name->ObjectName.Length + (wcslen(path) + 2) * sizeof(wchar_t); + full_path->reset(new (NT_ALLOC) wchar_t[name_length / sizeof(wchar_t)]); + if (!*full_path) + break; + wchar_t* off = full_path->get(); + ret = CopyData(off, handle_name->ObjectName.Buffer, + handle_name->ObjectName.Length); + if (!NT_SUCCESS(ret)) + break; + off += handle_name->ObjectName.Length / sizeof(wchar_t); + *off = L'\\'; + off += 1; + ret = CopyData(off, path, wcslen(path) * sizeof(wchar_t)); + if (!NT_SUCCESS(ret)) + break; + off += wcslen(path); + *off = L'\0'; + } while (false); + } __except (EXCEPTION_EXECUTE_HANDLER) { + ret = GetExceptionCode(); + } + + if (!NT_SUCCESS(ret) && *full_path) + full_path->reset(nullptr); + + return ret; +} + // Hacky code... replace with AllocAndCopyObjectAttributes. NTSTATUS AllocAndCopyName(const OBJECT_ATTRIBUTES* in_object, std::unique_ptr* out_name, diff --git a/sandbox/win/src/sandbox_nt_util.h b/sandbox/win/src/sandbox_nt_util.h index 2eddc3f46fc1e5..f7a91d8eefae83 100644 --- a/sandbox/win/src/sandbox_nt_util.h +++ b/sandbox/win/src/sandbox_nt_util.h @@ -117,6 +117,12 @@ NTSTATUS AllocAndCopyName(const OBJECT_ATTRIBUTES* in_object, uint32_t* attributes, HANDLE* root); +// Determine full path name from object root and path. +NTSTATUS AllocAndGetFullPath( + HANDLE root, + const wchar_t* path, + std::unique_ptr* full_path); + // Initializes our ntdll level heap bool InitHeap(); diff --git a/sandbox/win/src/win_utils.cc b/sandbox/win/src/win_utils.cc index 5469e634a2c52a..c8d0702652e912 100644 --- a/sandbox/win/src/win_utils.cc +++ b/sandbox/win/src/win_utils.cc @@ -147,31 +147,6 @@ void RemoveImpliedDevice(std::wstring* path) { *path = path->substr(kNTDotPrefixLen); } -bool QueryObjectInformation(HANDLE handle, - OBJECT_INFORMATION_CLASS info_class, - DWORD initial_size, - std::vector* buffer) { - static NtQueryObjectFunction NtQueryObject = nullptr; - if (!NtQueryObject) - ResolveNTFunctionPtr("NtQueryObject", &NtQueryObject); - - ULONG size = initial_size; - NTSTATUS status = STATUS_BUFFER_OVERFLOW; - __try { - do { - buffer->resize(size); - status = NtQueryObject(handle, info_class, buffer->data(), size, &size); - } while (status == STATUS_INFO_LENGTH_MISMATCH || - status == STATUS_BUFFER_OVERFLOW); - } __except (GetExceptionCode() == STATUS_INVALID_HANDLE - ? EXCEPTION_EXECUTE_HANDLER - : EXCEPTION_CONTINUE_SEARCH) { - status = STATUS_INVALID_HANDLE; - } - - return NT_SUCCESS(status); -} - } // namespace namespace sandbox { @@ -436,13 +411,30 @@ bool ConvertToLongPath(std::wstring* native_path, } bool GetPathFromHandle(HANDLE handle, std::wstring* path) { - std::vector buffer; - if (!QueryObjectInformation(handle, ObjectNameInformation, - sizeof(OBJECT_NAME_INFORMATION), &buffer)) { - return false; + NtQueryObjectFunction NtQueryObject = nullptr; + ResolveNTFunctionPtr("NtQueryObject", &NtQueryObject); + + OBJECT_NAME_INFORMATION initial_buffer; + OBJECT_NAME_INFORMATION* name = &initial_buffer; + ULONG size = sizeof(initial_buffer); + // Query the name information a first time to get the size of the name. + // Windows XP requires that the size of the buffer passed in here be != 0. + NTSTATUS status = + NtQueryObject(handle, ObjectNameInformation, name, size, &size); + + std::unique_ptr name_ptr; + if (size) { + name_ptr.reset(new BYTE[size]); + name = reinterpret_cast(name_ptr.get()); + + // Query the name information a second time to get the name of the + // object referenced by the handle. + status = NtQueryObject(handle, ObjectNameInformation, name, size, &size); } - OBJECT_NAME_INFORMATION* name = - reinterpret_cast(buffer.data()); + + if (STATUS_SUCCESS != status) + return false; + path->assign(name->ObjectName.Buffer, name->ObjectName.Length / sizeof(name->ObjectName.Buffer[0])); return true; @@ -459,19 +451,6 @@ bool GetNtPathFromWin32Path(const std::wstring& path, std::wstring* nt_path) { return rv; } -bool GetTypeNameFromHandle(HANDLE handle, std::wstring* type_name) { - std::vector buffer; - if (!QueryObjectInformation(handle, ObjectTypeInformation, - sizeof(OBJECT_TYPE_INFORMATION), &buffer)) { - return false; - } - OBJECT_TYPE_INFORMATION* name = - reinterpret_cast(buffer.data()); - type_name->assign(name->Name.Buffer, - name->Name.Length / sizeof(name->Name.Buffer[0])); - return true; -} - bool WriteProtectedChildMemory(HANDLE child_process, void* address, const void* buffer, diff --git a/sandbox/win/src/win_utils.h b/sandbox/win/src/win_utils.h index ce96c0f19ae361..6f54d200499a97 100644 --- a/sandbox/win/src/win_utils.h +++ b/sandbox/win/src/win_utils.h @@ -69,12 +69,9 @@ bool SameObject(HANDLE handle, const wchar_t* full_path); bool GetPathFromHandle(HANDLE handle, std::wstring* path); // Resolves a win32 path to an nt path using GetPathFromHandle. The path must -// exist. Returns true if the translation was successful. +// exist. Returs true if the translation was succesful. bool GetNtPathFromWin32Path(const std::wstring& path, std::wstring* nt_path); -// Resolves a handle to its type name. Returns true if successful. -bool GetTypeNameFromHandle(HANDLE handle, std::wstring* type_name); - // Translates a reserved key name to its handle. // For example "HKEY_LOCAL_MACHINE" returns HKEY_LOCAL_MACHINE. // Returns nullptr if the name does not represent any reserved key name. diff --git a/sandbox/win/src/win_utils_unittest.cc b/sandbox/win/src/win_utils_unittest.cc index a84db938fb8b5a..b81721c2887cd6 100644 --- a/sandbox/win/src/win_utils_unittest.cc +++ b/sandbox/win/src/win_utils_unittest.cc @@ -15,9 +15,6 @@ #include "base/files/scoped_temp_dir.h" #include "base/numerics/safe_conversions.h" #include "base/path_service.h" -#include "base/rand_util.h" -#include "base/strings/string_util_win.h" -#include "base/strings/stringprintf.h" #include "base/win/scoped_handle.h" #include "base/win/scoped_process_information.h" #include "sandbox/win/src/nt_internals.h" @@ -61,25 +58,6 @@ bool GetModuleList(HANDLE process, std::vector* result) { return false; } -std::wstring GetRandomName() { - return base::StringPrintf(L"chrome_%08X%08X", base::RandUint64(), - base::RandUint64()); -} - -void CompareHandlePath(const base::win::ScopedHandle& handle, - const std::wstring& expected_path) { - std::wstring path; - ASSERT_TRUE(GetPathFromHandle(handle.Get(), &path)); - EXPECT_TRUE(base::EqualsCaseInsensitiveASCII(path, expected_path)); -} - -void CompareHandleType(const base::win::ScopedHandle& handle, - const std::wstring& expected_type) { - std::wstring type_name; - ASSERT_TRUE(GetTypeNameFromHandle(handle.Get(), &type_name)); - EXPECT_TRUE(base::EqualsCaseInsensitiveASCII(type_name, expected_type)); -} - } // namespace TEST(WinUtils, IsReparsePoint) { @@ -273,27 +251,4 @@ TEST(WinUtils, ConvertToLongPath) { // Expected result: "\Device\HarddiskVolumeX\ProgramData\%TEMP%\test_calc.exe" } -TEST(WinUtils, GetPathAndTypeFromHandle) { - std::wstring invalid_handle; - EXPECT_FALSE(GetPathFromHandle(nullptr, &invalid_handle)); - EXPECT_TRUE(invalid_handle.empty()); - EXPECT_FALSE(GetTypeNameFromHandle(nullptr, &invalid_handle)); - EXPECT_TRUE(invalid_handle.empty()); - std::wstring random_name = GetRandomName(); - ASSERT_FALSE(random_name.empty()); - std::wstring event_name = L"Global\\" + random_name; - base::win::ScopedHandle event_handle( - ::CreateEvent(nullptr, FALSE, FALSE, event_name.c_str())); - ASSERT_TRUE(event_handle.IsValid()); - CompareHandlePath(event_handle, L"\\BaseNamedObjects\\" + random_name); - CompareHandleType(event_handle, L"Event"); - std::wstring pipe_name = L"\\\\.\\pipe\\" + random_name; - base::win::ScopedHandle pipe_handle(::CreateNamedPipe( - pipe_name.c_str(), PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE, - PIPE_UNLIMITED_INSTANCES, 0, 0, NMPWAIT_USE_DEFAULT_WAIT, nullptr)); - ASSERT_TRUE(pipe_handle.IsValid()); - CompareHandlePath(pipe_handle, L"\\Device\\NamedPipe\\" + random_name); - CompareHandleType(pipe_handle, L"File"); -} - } // namespace sandbox From 293ef66ce69d271b8ff9288c6f0598688270ed0b Mon Sep 17 00:00:00 2001 From: Mikel Astiz Date: Tue, 14 Dec 2021 13:50:32 +0000 Subject: [PATCH 14/51] [Passwords] Fix assertion failure when opening password settings Method SyncService.isUsingExplicitPassphrase() has the precondition that the sync engine must have initialized, as per isEngineInitialized(). To avoiding running into assertion failures, PasswordManagerHelper must first rule out ongoing initialization before invoking isUsingExplicitPassphrase(). Change-Id: I8f519953c6d37aa4d9d54e6b043c24054fb46b45 Fixed: 1276532 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3336879 Reviewed-by: Ioana Pandele Commit-Queue: Mikel Astiz Cr-Commit-Position: refs/heads/main@{#951464} --- .../password_manager/PasswordManagerHelper.java | 3 ++- .../PasswordManagerHelperTest.java | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/chrome/browser/password_manager/android/java/src/org/chromium/chrome/browser/password_manager/PasswordManagerHelper.java b/chrome/browser/password_manager/android/java/src/org/chromium/chrome/browser/password_manager/PasswordManagerHelper.java index a8317123a12568..0fad594c3b401c 100644 --- a/chrome/browser/password_manager/android/java/src/org/chromium/chrome/browser/password_manager/PasswordManagerHelper.java +++ b/chrome/browser/password_manager/android/java/src/org/chromium/chrome/browser/password_manager/PasswordManagerHelper.java @@ -97,7 +97,7 @@ public static boolean hasChosenToSyncPasswords(SyncService syncService) { */ public static boolean hasChosenToSyncPasswordsWithNoCustomPassphrase(SyncService syncService) { return PasswordManagerHelper.hasChosenToSyncPasswords(syncService) - && !syncService.isUsingExplicitPassphrase(); + && syncService.isEngineInitialized() && !syncService.isUsingExplicitPassphrase(); } /** @@ -109,6 +109,7 @@ public static boolean hasChosenToSyncPasswordsWithNoCustomPassphrase(SyncService public static boolean isSyncingPasswordsWithNoCustomPassphrase(SyncService syncService) { if (syncService == null || !syncService.hasSyncConsent()) return false; if (!syncService.getActiveDataTypes().contains(ModelType.PASSWORDS)) return false; + if (!syncService.isEngineInitialized()) return false; if (syncService.isUsingExplicitPassphrase()) return false; return true; } diff --git a/chrome/browser/password_manager/android/junit/src/org/chromium/chrome/browser/password_manager/PasswordManagerHelperTest.java b/chrome/browser/password_manager/android/junit/src/org/chromium/chrome/browser/password_manager/PasswordManagerHelperTest.java index 35b05a1f9e3a09..67940dc25e68dd 100644 --- a/chrome/browser/password_manager/android/junit/src/org/chromium/chrome/browser/password_manager/PasswordManagerHelperTest.java +++ b/chrome/browser/password_manager/android/junit/src/org/chromium/chrome/browser/password_manager/PasswordManagerHelperTest.java @@ -131,17 +131,31 @@ public void testSyncEnabledWithCustomPassphrase() { when(mSyncServiceMock.isSyncFeatureEnabled()).thenReturn(true); when(mSyncServiceMock.getChosenDataTypes()) .thenReturn(CollectionUtil.newHashSet(ModelType.PASSWORDS)); + when(mSyncServiceMock.isEngineInitialized()).thenReturn(true); when(mSyncServiceMock.isUsingExplicitPassphrase()).thenReturn(true); Assert.assertTrue(PasswordManagerHelper.hasChosenToSyncPasswords(mSyncServiceMock)); Assert.assertFalse(PasswordManagerHelper.hasChosenToSyncPasswordsWithNoCustomPassphrase( mSyncServiceMock)); } + @Test + public void testSyncEnabledButInitializing() { + when(mSyncServiceMock.isSyncFeatureEnabled()).thenReturn(true); + when(mSyncServiceMock.getChosenDataTypes()) + .thenReturn(CollectionUtil.newHashSet(ModelType.PASSWORDS)); + when(mSyncServiceMock.isEngineInitialized()).thenReturn(false); + Assert.assertTrue(PasswordManagerHelper.hasChosenToSyncPasswords(mSyncServiceMock)); + Assert.assertFalse(PasswordManagerHelper.hasChosenToSyncPasswordsWithNoCustomPassphrase( + mSyncServiceMock)); + verify(mSyncServiceMock, never()).isUsingExplicitPassphrase(); + } + @Test public void testActivelySyncingPasswordsWithNoCustomPassphrase() { when(mSyncServiceMock.hasSyncConsent()).thenReturn(true); when(mSyncServiceMock.getActiveDataTypes()) .thenReturn(CollectionUtil.newHashSet(ModelType.PASSWORDS)); + when(mSyncServiceMock.isEngineInitialized()).thenReturn(true); when(mSyncServiceMock.isUsingExplicitPassphrase()).thenReturn(false); Assert.assertTrue( PasswordManagerHelper.isSyncingPasswordsWithNoCustomPassphrase(mSyncServiceMock)); @@ -152,6 +166,7 @@ public void testActivelySyncingPasswordsWithCustomPassphrase() { when(mSyncServiceMock.hasSyncConsent()).thenReturn(true); when(mSyncServiceMock.getActiveDataTypes()) .thenReturn(CollectionUtil.newHashSet(ModelType.PASSWORDS)); + when(mSyncServiceMock.isEngineInitialized()).thenReturn(true); when(mSyncServiceMock.isUsingExplicitPassphrase()).thenReturn(true); Assert.assertFalse( PasswordManagerHelper.isSyncingPasswordsWithNoCustomPassphrase(mSyncServiceMock)); From 50788d87cc48faa2d9b9e549ee9ca3dec2df3920 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Tue, 14 Dec 2021 13:55:12 +0000 Subject: [PATCH 15/51] Record Metal ReadWrite texture UMA histogram. The distribution of tiers of support across Chromium users will allow the WebGPU W3C group to decide whether to require support for it. Fixed: dawn:924 Change-Id: Idfa787a9d8c88f23533048f159ab90eb78e4f1ee Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3330356 Reviewed-by: Zhenyao Mo Reviewed-by: Jonathan Ross Commit-Queue: Corentin Wallez Cr-Commit-Position: refs/heads/main@{#951465} --- gpu/config/gpu_info_collector_mac.mm | 36 +++++++++++++++++++ tools/metrics/histograms/enums.xml | 7 ++++ .../histograms/metadata/gpu/histograms.xml | 14 ++++++++ 3 files changed, 57 insertions(+) diff --git a/gpu/config/gpu_info_collector_mac.mm b/gpu/config/gpu_info_collector_mac.mm index fc58409f497326..37dada864036de 100644 --- a/gpu/config/gpu_info_collector_mac.mm +++ b/gpu/config/gpu_info_collector_mac.mm @@ -4,12 +4,46 @@ #include "gpu/config/gpu_info_collector.h" +#include "base/mac/scoped_nsobject.h" +#include "base/metrics/histogram_macros.h" #include "base/trace_event/trace_event.h" #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" #include "third_party/angle/src/gpu_info_util/SystemInfo.h" +#import + namespace gpu { +namespace { + +// The enums is used for an UMA histogram so we should never reorder entries or +// remove unused values. +enum class MetalReadWriteTextureSupportTier { + kUnknown = 0, + kTier0_NoSupport = 1, + kTier1_R32Formats = 2, + kTier2_AdditionalFormats = 3, + kMaxValue = kTier2_AdditionalFormats, +}; + +void RecordReadWriteMetalTexturesSupportedHistogram() { + // Metal tiers go 0, 1, 2, but we reserve 0 for when macOS is less then 10.13 + // and we can't query. + NSUInteger best_tier = 0; + + if (@available(macOS 10.13, *)) { + base::scoped_nsobject>> devices(MTLCopyAllDevices()); + for (id device in devices.get()) { + best_tier = std::max(best_tier, [device readWriteTextureSupport] + 1); + } + } + + UMA_HISTOGRAM_ENUMERATION( + "Gpu.Metal.ReadWriteTextureSupport", + static_cast(best_tier)); +} +} + bool CollectContextGraphicsInfo(GPUInfo* gpu_info) { DCHECK(gpu_info); @@ -18,6 +52,8 @@ bool CollectContextGraphicsInfo(GPUInfo* gpu_info) { gpu_info->macos_specific_texture_target = gpu::GetPlatformSpecificTextureTarget(); + RecordReadWriteMetalTexturesSupportedHistogram(); + return CollectGraphicsInfoGL(gpu_info); } diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index 7c25cba27d50a0..1f5ec2082287d8 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml @@ -58332,6 +58332,13 @@ Called by update_use_counter_css.py.--> + + + + + + + diff --git a/tools/metrics/histograms/metadata/gpu/histograms.xml b/tools/metrics/histograms/metadata/gpu/histograms.xml index 0887b239551c71..457c71900f0c7b 100644 --- a/tools/metrics/histograms/metadata/gpu/histograms.xml +++ b/tools/metrics/histograms/metadata/gpu/histograms.xml @@ -1279,6 +1279,20 @@ chromium-metrics-reviews@google.com. + + cwallez@chromium.org + graphics-dev@chromium.org +

+ Read-write textures are not always supported on Metal. This histograms is + meant to gather information so that the WebGPU W3C group can decide whether + to require support for this feature. The reported tier is the best tier that + was found on the system. Meaning that if only one of the GPUs support + read-write textures, a non-zero tier will be reported. The histogram is + recorded at GPU process startup time. + + + ccameron@chromium.org From 23dd95c947555925cd83f350aec1df09aa7c7bd8 Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Tue, 14 Dec 2021 13:57:52 +0000 Subject: [PATCH 16/51] FLEDGE: support bidding_wasm_helper_url in InterestGroupStorage Bug: 1275638 Change-Id: I645cd466ab80c145dc36bc147307f4b59cfe2c47 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3330516 Reviewed-by: Russ Hamilton Commit-Queue: Maks Orlovich Cr-Commit-Position: refs/heads/main@{#951466} --- .../interest_group/interest_group_storage.cc | 65 +++++++++++-------- .../interest_group_storage_unittest.cc | 20 ++++++ 2 files changed, 58 insertions(+), 27 deletions(-) diff --git a/content/browser/interest_group/interest_group_storage.cc b/content/browser/interest_group/interest_group_storage.cc index 816f1717c92323..6180b796e9d9c3 100644 --- a/content/browser/interest_group/interest_group_storage.cc +++ b/content/browser/interest_group/interest_group_storage.cc @@ -51,21 +51,23 @@ const base::FilePath::CharType kDatabasePath[] = // Version 3 - 2021/09 - crrev.com/c/3165576 // Version 4 - 2021/10 - crrev.com/c/3172863 // Version 5 - 2021/10 - crrev.com/c/3067804 +// Version 6 - 2021/12 - crrev.com/c/3330516 // // Version 1 adds a table for interest groups. // Version 2 adds a column for rate limiting interest group updates. // Version 3 adds a field for ad components. // Version 4 adds joining origin and url. // Version 5 adds k-anonymity tables and fields. -const int kCurrentVersionNumber = 5; +// Version 6 adds WebAssembly helper url. +const int kCurrentVersionNumber = 6; // Earliest version of the code which can use a |kCurrentVersionNumber| // database without failing. -const int kCompatibleVersionNumber = 5; +const int kCompatibleVersionNumber = 6; // Latest version of the database that cannot be upgraded to // |kCurrentVersionNumber| without razing the database. -const int kDeprecatedVersionNumber = 4; +const int kDeprecatedVersionNumber = 5; enum class KAnonType { kOwnerAndName = 1, @@ -174,7 +176,7 @@ absl::optional> DeserializeStringVector( // Initializes the tables, returning true on success. // The tables cannot exist when calling this function. -bool CreateV5Schema(sql::Database& db) { +bool CreateV6Schema(sql::Database& db) { DCHECK(!db.DoesTableExist("interest_groups")); static const char kInterestGroupTableSql[] = // clang-format off @@ -187,6 +189,7 @@ bool CreateV5Schema(sql::Database& db) { "name TEXT NOT NULL," "joining_url TEXT NOT NULL," "bidding_url TEXT NOT NULL," + "bidding_wasm_helper_url TEXT NOT NULL," "update_url TEXT NOT NULL," "trusted_bidding_signals_url TEXT NOT NULL," "trusted_bidding_signals_keys TEXT NOT NULL," @@ -476,13 +479,14 @@ bool DoJoinInterestGroup(sql::Database& db, "name," "joining_url," "bidding_url," + "bidding_wasm_helper_url," "update_url," "trusted_bidding_signals_url," "trusted_bidding_signals_keys," "user_bidding_signals," // opaque data "ads," "ad_components) " - "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)")); + "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")); // clang-format on if (!join_group.is_valid()) @@ -497,16 +501,17 @@ bool DoJoinInterestGroup(sql::Database& db, join_group.BindString(5, data.name); join_group.BindString(6, Serialize(joining_url)); join_group.BindString(7, Serialize(data.bidding_url)); - join_group.BindString(8, Serialize(data.update_url)); - join_group.BindString(9, Serialize(data.trusted_bidding_signals_url)); - join_group.BindString(10, Serialize(data.trusted_bidding_signals_keys)); + join_group.BindString(8, Serialize(data.bidding_wasm_helper_url)); + join_group.BindString(9, Serialize(data.update_url)); + join_group.BindString(10, Serialize(data.trusted_bidding_signals_url)); + join_group.BindString(11, Serialize(data.trusted_bidding_signals_keys)); if (data.user_bidding_signals) { - join_group.BindString(11, data.user_bidding_signals.value()); + join_group.BindString(12, data.user_bidding_signals.value()); } else { - join_group.BindNull(11); + join_group.BindNull(12); } - join_group.BindString(12, Serialize(data.ads)); - join_group.BindString(13, Serialize(data.ad_components)); + join_group.BindString(13, Serialize(data.ads)); + join_group.BindString(14, Serialize(data.ad_components)); if (!join_group.Run()) return false; @@ -544,6 +549,7 @@ bool DoLoadInterestGroup(sql::Database& db, db.GetCachedStatement(SQL_FROM_HERE, "SELECT expiration," "bidding_url," + "bidding_wasm_helper_url," "update_url," "trusted_bidding_signals_url," "trusted_bidding_signals_keys," @@ -568,14 +574,15 @@ bool DoLoadInterestGroup(sql::Database& db, group.owner = owner; group.name = name; group.bidding_url = DeserializeURL(load.ColumnString(1)); - group.update_url = DeserializeURL(load.ColumnString(2)); - group.trusted_bidding_signals_url = DeserializeURL(load.ColumnString(3)); + group.bidding_wasm_helper_url = DeserializeURL(load.ColumnString(2)); + group.update_url = DeserializeURL(load.ColumnString(3)); + group.trusted_bidding_signals_url = DeserializeURL(load.ColumnString(4)); group.trusted_bidding_signals_keys = - DeserializeStringVector(load.ColumnString(4)); - if (load.GetColumnType(5) != sql::ColumnType::kNull) - group.user_bidding_signals = load.ColumnString(5); - group.ads = DeserializeInterestGroupAdVector(load.ColumnString(6)); - group.ad_components = DeserializeInterestGroupAdVector(load.ColumnString(7)); + DeserializeStringVector(load.ColumnString(5)); + if (load.GetColumnType(6) != sql::ColumnType::kNull) + group.user_bidding_signals = load.ColumnString(6); + group.ads = DeserializeInterestGroupAdVector(load.ColumnString(7)); + group.ad_components = DeserializeInterestGroupAdVector(load.ColumnString(8)); return true; } @@ -589,6 +596,7 @@ bool DoStoreInterestGroupUpdate(sql::Database& db, "UPDATE interest_groups " "SET last_updated=?," "bidding_url=?," + "bidding_wasm_helper_url=?," "update_url=?," "trusted_bidding_signals_url=?," "trusted_bidding_signals_keys=?," @@ -603,13 +611,14 @@ bool DoStoreInterestGroupUpdate(sql::Database& db, store_group.Reset(true); store_group.BindTime(0, last_updated); store_group.BindString(1, Serialize(group.bidding_url)); - store_group.BindString(2, Serialize(group.update_url)); - store_group.BindString(3, Serialize(group.trusted_bidding_signals_url)); - store_group.BindString(4, Serialize(group.trusted_bidding_signals_keys)); - store_group.BindString(5, Serialize(group.ads)); - store_group.BindString(6, Serialize(group.ad_components)); - store_group.BindString(7, Serialize(group.owner)); - store_group.BindString(8, group.name); + store_group.BindString(2, Serialize(group.bidding_wasm_helper_url)); + store_group.BindString(3, Serialize(group.update_url)); + store_group.BindString(4, Serialize(group.trusted_bidding_signals_url)); + store_group.BindString(5, Serialize(group.trusted_bidding_signals_keys)); + store_group.BindString(6, Serialize(group.ads)); + store_group.BindString(7, Serialize(group.ad_components)); + store_group.BindString(8, Serialize(group.owner)); + store_group.BindString(9, group.name); return store_group.Run(); } @@ -640,6 +649,8 @@ bool DoUpdateInterestGroup(sql::Database& db, if (update.bidding_url) stored_group.bidding_url = update.bidding_url; + if (update.bidding_wasm_helper_url) + stored_group.bidding_wasm_helper_url = update.bidding_wasm_helper_url; if (update.trusted_bidding_signals_url) stored_group.trusted_bidding_signals_url = update.trusted_bidding_signals_url; @@ -1566,7 +1577,7 @@ bool InterestGroupStorage::InitializeSchema() { return false; if (new_db) - return CreateV5Schema(*db_); + return CreateV6Schema(*db_); const int db_version = meta_table.GetVersionNumber(); diff --git a/content/browser/interest_group/interest_group_storage_unittest.cc b/content/browser/interest_group/interest_group_storage_unittest.cc index 1b2070e52be4e9..2930234bbc5b08 100644 --- a/content/browser/interest_group/interest_group_storage_unittest.cc +++ b/content/browser/interest_group/interest_group_storage_unittest.cc @@ -680,6 +680,7 @@ TEST_F(InterestGroupStorageTest, StoresAllFields) { full.name = "full"; full.expiry = base::Time::Now() + base::Days(30); full.bidding_url = GURL("https://full.example.com/bid"); + full.bidding_wasm_helper_url = GURL("https://full.example.com/bid_wasm"); full.update_url = GURL("https://full.example.com/update"); full.trusted_bidding_signals_url = GURL("https://full.example.com/signals"); full.trusted_bidding_signals_keys = @@ -711,6 +712,25 @@ TEST_F(InterestGroupStorageTest, StoresAllFields) { ASSERT_EQ(1u, storage_interest_groups.size()); EXPECT_TRUE( full.IsEqualForTesting(storage_interest_groups[0].bidding_group->group)); + + // Test update as well. + InterestGroup updated = full; + updated.bidding_url = GURL("https://full.example.com/bid2"); + updated.bidding_wasm_helper_url = GURL("https://full.example.com/bid_wasm2"); + updated.trusted_bidding_signals_url = + GURL("https://full.example.com/signals2"); + updated.trusted_bidding_signals_keys = + absl::make_optional(std::vector{"a", "b2", "c", "d"}); + updated.ads->emplace_back(blink::InterestGroup::Ad( + GURL("https://full.example.com/ad3"), "metadata3")); + updated.ad_components->emplace_back(blink::InterestGroup::Ad( + GURL("https://full.example.com/adcomponent3"), "metadata3c")); + storage->UpdateInterestGroup(updated); + + storage_interest_groups = storage->GetInterestGroupsForOwner(full_origin); + ASSERT_EQ(1u, storage_interest_groups.size()); + EXPECT_TRUE(updated.IsEqualForTesting( + storage_interest_groups[0].bidding_group->group)); } TEST_F(InterestGroupStorageTest, DeleteOriginDeleteAll) { From 4d4e7b19a79b724e703fde678536ce83075b3a6b Mon Sep 17 00:00:00 2001 From: Maks Orlovich Date: Tue, 14 Dec 2021 13:59:31 +0000 Subject: [PATCH 17/51] FLEDGE: Teach AuctionUrlLoaderFactoryProxy about WASM ... And hook it up appropriately for (presently non-existent) use in bidder worklets. Also fix typo in test fixture name. Bug: 1275638 Change-Id: I1adb956d69558e87a29da62337d93a74da57a71f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3335061 Reviewed-by: Matt Menke Commit-Queue: Maks Orlovich Cr-Commit-Position: refs/heads/main@{#951467} --- .../browser/interest_group/auction_runner.cc | 2 + .../auction_url_loader_factory_proxy.cc | 5 ++ .../auction_url_loader_factory_proxy.h | 9 ++-- ...ction_url_loader_factory_proxy_unittest.cc | 51 ++++++++++++++----- 4 files changed, 51 insertions(+), 16 deletions(-) diff --git a/content/browser/interest_group/auction_runner.cc b/content/browser/interest_group/auction_runner.cc index b4fa0e7693ab29..76430ad895e9dc 100644 --- a/content/browser/interest_group/auction_runner.cc +++ b/content/browser/interest_group/auction_runner.cc @@ -255,6 +255,7 @@ void AuctionRunner::OnSellerWorkletProcessReceived() { base::Unretained(delegate_)), browser_signals_->top_frame_origin, frame_origin_, /*is_for_seller_=*/true, delegate_->GetClientSecurityState(), seller_url, + /*wasm_url=*/absl::nullopt, /*trusted_signals_base_url=*/ auction_config_->trusted_scoring_signals_url); mojo::PendingReceiver @@ -652,6 +653,7 @@ void AuctionRunner::LoadBidderWorklet(BidState& bid_state, base::Unretained(delegate_)), browser_signals_->top_frame_origin, frame_origin_, /*is_for_seller=*/false, delegate_->GetClientSecurityState(), bidding_url, + bid_state.bidder.bidding_group->group.bidding_wasm_helper_url, bidder->group.trusted_bidding_signals_url); mojo::PendingReceiver diff --git a/content/browser/interest_group/auction_url_loader_factory_proxy.cc b/content/browser/interest_group/auction_url_loader_factory_proxy.cc index af3dd5f040022a..1ecd5996cc6904 100644 --- a/content/browser/interest_group/auction_url_loader_factory_proxy.cc +++ b/content/browser/interest_group/auction_url_loader_factory_proxy.cc @@ -41,6 +41,7 @@ AuctionURLLoaderFactoryProxy::AuctionURLLoaderFactoryProxy( bool is_for_seller, network::mojom::ClientSecurityStatePtr client_security_state, const GURL& script_url, + const absl::optional& wasm_url, const absl::optional& trusted_signals_base_url) : receiver_(this, std::move(pending_receiver)), get_frame_url_loader_factory_(std::move(get_frame_url_loader_factory)), @@ -51,6 +52,7 @@ AuctionURLLoaderFactoryProxy::AuctionURLLoaderFactoryProxy( is_for_seller_(is_for_seller), client_security_state_(std::move(client_security_state)), script_url_(script_url), + wasm_url_(wasm_url), trusted_signals_base_url_(trusted_signals_base_url) { DCHECK(client_security_state_); } @@ -78,6 +80,9 @@ void AuctionURLLoaderFactoryProxy::CreateLoaderAndStart( if (url_request.url == script_url_ && accept_header == "application/javascript") { is_request_allowed = true; + } else if (wasm_url_.has_value() && url_request.url == wasm_url_.value() && + accept_header == "application/wasm") { + is_request_allowed = true; } else if (CouldBeTrustedSignalsUrl(url_request.url) && accept_header == "application/json") { is_request_allowed = true; diff --git a/content/browser/interest_group/auction_url_loader_factory_proxy.h b/content/browser/interest_group/auction_url_loader_factory_proxy.h index 36e7b6fa73eb27..e2ea9a88559594 100644 --- a/content/browser/interest_group/auction_url_loader_factory_proxy.h +++ b/content/browser/interest_group/auction_url_loader_factory_proxy.h @@ -53,9 +53,10 @@ class CONTENT_EXPORT AuctionURLLoaderFactoryProxy // bidder worklets. Ignored for seller worklets, since they use a // URLLoaderFactory with that information already attached. // - // `script_url` is the Javascript URL for the worklet, and - // `trusted_signals_url` is the optional JSON url for additional input to the - // script. No other URLs may be requested. + // `script_url` is the Javascript URL for the worklet, `wasm_url` is a URL + // for an optional WASM helper for the worklet, and `trusted_signals_url` is + // the optional JSON url for additional input to the script. No other URLs may + // be requested. AuctionURLLoaderFactoryProxy( mojo::PendingReceiver pending_receiver, GetUrlLoaderFactoryCallback get_frame_url_loader_factory, @@ -65,6 +66,7 @@ class CONTENT_EXPORT AuctionURLLoaderFactoryProxy bool is_for_seller, network::mojom::ClientSecurityStatePtr client_security_state, const GURL& script_url, + const absl::optional& wasm_url, const absl::optional& trusted_signals_base_url); AuctionURLLoaderFactoryProxy(const AuctionURLLoaderFactoryProxy&) = delete; AuctionURLLoaderFactoryProxy& operator=(const AuctionURLLoaderFactoryProxy&) = @@ -106,6 +108,7 @@ class CONTENT_EXPORT AuctionURLLoaderFactoryProxy net::IsolationInfo isolation_info_for_seller_signals_; const GURL script_url_; + const absl::optional wasm_url_; const absl::optional trusted_signals_base_url_; }; diff --git a/content/browser/interest_group/auction_url_loader_factory_proxy_unittest.cc b/content/browser/interest_group/auction_url_loader_factory_proxy_unittest.cc index 37fd43bccff13d..257344a878d48c 100644 --- a/content/browser/interest_group/auction_url_loader_factory_proxy_unittest.cc +++ b/content/browser/interest_group/auction_url_loader_factory_proxy_unittest.cc @@ -33,6 +33,7 @@ namespace content { const char kScriptUrl[] = "https://host.test/script"; +const char kWasmUrl[] = "https://host.test/wasm"; const char kTrustedSignalsBaseUrl[] = "https://host.test/trusted_signals"; // Basic example of a trusted signals URL. Seller signals typically have URLs as // keys, but AuctionUrlLoaderProxy doesn't currently verify that. @@ -43,8 +44,9 @@ const char kTrustedSignalsUrl[] = const char kAcceptJavascript[] = "application/javascript"; const char kAcceptJson[] = "application/json"; const char kAcceptOther[] = "binary/ocelot-stream"; +const char kAcceptWasm[] = "application/wasm"; -class ActionUrlLoaderFactoryProxyTest : public testing::Test { +class AuctionUrlLoaderFactoryProxyTest : public testing::Test { public: // Ways the proxy can behave in response to a request. enum class ExpectedResponse { @@ -52,13 +54,13 @@ class ActionUrlLoaderFactoryProxyTest : public testing::Test { kAllow, }; - ActionUrlLoaderFactoryProxyTest() { + AuctionUrlLoaderFactoryProxyTest() { // Other defaults are all reasonable, but this should always be true for // FLEDGE. client_security_state_->is_web_secure_context = true; } - ~ActionUrlLoaderFactoryProxyTest() override = default; + ~AuctionUrlLoaderFactoryProxyTest() override = default; void CreateUrlLoaderFactoryProxy() { // The AuctionURLLoaderFactoryProxy should only be created if there is no @@ -76,7 +78,7 @@ class ActionUrlLoaderFactoryProxyTest : public testing::Test { [](network::mojom::URLLoaderFactory* factory) { return factory; }, &trusted_url_loader_factory_), top_frame_origin_, frame_origin_, is_for_seller_, - client_security_state_.Clone(), GURL(kScriptUrl), + client_security_state_.Clone(), GURL(kScriptUrl), wasm_url_, trusted_signals_base_url_); } @@ -205,9 +207,11 @@ class ActionUrlLoaderFactoryProxyTest : public testing::Test { EXPECT_EQ(network::mojom::RequestMode::kNoCors, observed_request.mode); if (is_for_seller_) { - if (original_accept_header == kAcceptJavascript) { - // Seller worklet Javascript requests use the renderer's untrusted - // URLLoaderFactory, so inherit security parameters from there. + if (original_accept_header == kAcceptJavascript || + original_accept_header == kAcceptWasm) { + // Seller worklet Javascript & WASM requests use the renderer's + // untrusted URLLoaderFactory, so inherit security parameters from + // there. EXPECT_FALSE(trusted_factory_used); EXPECT_FALSE(observed_request.trusted_params); } else { @@ -266,6 +270,7 @@ class ActionUrlLoaderFactoryProxyTest : public testing::Test { const network::mojom::ClientSecurityStatePtr client_security_state_ = network::mojom::ClientSecurityState::New(); absl::optional trusted_signals_base_url_ = GURL(kTrustedSignalsBaseUrl); + absl::optional wasm_url_ = GURL(kWasmUrl); url::Origin top_frame_origin_ = url::Origin::Create(GURL("https://top.test/")); @@ -277,7 +282,7 @@ class ActionUrlLoaderFactoryProxyTest : public testing::Test { mojo::Remote remote_url_loader_factory_; }; -TEST_F(ActionUrlLoaderFactoryProxyTest, Basic) { +TEST_F(AuctionUrlLoaderFactoryProxyTest, Basic) { for (bool is_for_seller : {false, true}) { is_for_seller_ = is_for_seller; // Force creation of a new proxy, with correct `is_for_seller` value. @@ -287,27 +292,47 @@ TEST_F(ActionUrlLoaderFactoryProxyTest, Basic) { TryMakeRequest(kScriptUrl, kAcceptJavascript, ExpectedResponse::kAllow); TryMakeRequest(kScriptUrl, kAcceptJson, ExpectedResponse::kReject); TryMakeRequest(kScriptUrl, kAcceptOther, ExpectedResponse::kReject); + TryMakeRequest(kScriptUrl, kAcceptWasm, ExpectedResponse::kReject); TryMakeRequest(kScriptUrl, absl::nullopt, ExpectedResponse::kReject); TryMakeRequest(kTrustedSignalsUrl, kAcceptJavascript, ExpectedResponse::kReject); TryMakeRequest(kTrustedSignalsUrl, kAcceptJson, ExpectedResponse::kAllow); TryMakeRequest(kTrustedSignalsUrl, kAcceptOther, ExpectedResponse::kReject); + TryMakeRequest(kTrustedSignalsUrl, kAcceptWasm, ExpectedResponse::kReject); TryMakeRequest(kTrustedSignalsUrl, absl::nullopt, ExpectedResponse::kReject); + TryMakeRequest(kWasmUrl, kAcceptJavascript, ExpectedResponse::kReject); + TryMakeRequest(kWasmUrl, kAcceptJson, ExpectedResponse::kReject); + TryMakeRequest(kWasmUrl, kAcceptOther, ExpectedResponse::kReject); + TryMakeRequest(kWasmUrl, kAcceptWasm, ExpectedResponse::kAllow); + TryMakeRequest(kWasmUrl, absl::nullopt, ExpectedResponse::kReject); + TryMakeRequest("https://host.test/", kAcceptJavascript, ExpectedResponse::kReject); TryMakeRequest("https://host.test/", kAcceptJson, ExpectedResponse::kReject); TryMakeRequest("https://host.test/", kAcceptOther, ExpectedResponse::kReject); + TryMakeRequest("https://host.test/", kAcceptWasm, + ExpectedResponse::kReject); TryMakeRequest("https://host.test/", absl::nullopt, ExpectedResponse::kReject); } } -TEST_F(ActionUrlLoaderFactoryProxyTest, NoTrustedSignalsUrl) { +TEST_F(AuctionUrlLoaderFactoryProxyTest, NoWasmUrl) { + wasm_url_ = absl::nullopt; + CreateUrlLoaderFactoryProxy(); + TryMakeRequest(kWasmUrl, kAcceptJavascript, ExpectedResponse::kReject); + TryMakeRequest(kWasmUrl, kAcceptJson, ExpectedResponse::kReject); + TryMakeRequest(kWasmUrl, kAcceptOther, ExpectedResponse::kReject); + TryMakeRequest(kWasmUrl, kAcceptWasm, ExpectedResponse::kReject); + TryMakeRequest(kWasmUrl, absl::nullopt, ExpectedResponse::kReject); +} + +TEST_F(AuctionUrlLoaderFactoryProxyTest, NoTrustedSignalsUrl) { trusted_signals_base_url_ = absl::nullopt; for (bool is_for_seller : {false, true}) { @@ -349,7 +374,7 @@ TEST_F(ActionUrlLoaderFactoryProxyTest, NoTrustedSignalsUrl) { } // This test focuses on validation of the requested trusted signals URLs. -TEST_F(ActionUrlLoaderFactoryProxyTest, TrustedSignalsUrl) { +TEST_F(AuctionUrlLoaderFactoryProxyTest, TrustedSignalsUrl) { for (bool is_for_seller : {false, true}) { is_for_seller_ = is_for_seller; // Force creation of a new proxy, with correct `is_for_seller` value. @@ -439,7 +464,7 @@ TEST_F(ActionUrlLoaderFactoryProxyTest, TrustedSignalsUrl) { // Make sure all seller signals requests use the same transient // NetworkIsolationKey. -TEST_F(ActionUrlLoaderFactoryProxyTest, SellerSignalsNetworkIsolationKey) { +TEST_F(AuctionUrlLoaderFactoryProxyTest, SellerSignalsNetworkIsolationKey) { is_for_seller_ = true; // Make 20 JSON requests, 10 with the same URL, 10 with different ones. All // should be plumbed through successfully. @@ -465,7 +490,7 @@ TEST_F(ActionUrlLoaderFactoryProxyTest, SellerSignalsNetworkIsolationKey) { // Test the case the same URL is used for trusted signals and the script (which // seems weird, but should still work). -TEST_F(ActionUrlLoaderFactoryProxyTest, SameUrl) { +TEST_F(AuctionUrlLoaderFactoryProxyTest, SameUrl) { trusted_signals_base_url_ = GURL(kScriptUrl); for (bool is_for_seller : {false, true}) { @@ -501,7 +526,7 @@ TEST_F(ActionUrlLoaderFactoryProxyTest, SameUrl) { // Make sure that proxies for bidder worklets pass through ClientSecurityState. // This test relies on the ClientSecurityState equality check in // TryMakeRequest(). -TEST_F(ActionUrlLoaderFactoryProxyTest, ClientSecurityState) { +TEST_F(AuctionUrlLoaderFactoryProxyTest, ClientSecurityState) { is_for_seller_ = false; for (auto ip_address_space : {network::mojom::IPAddressSpace::kLocal, From 263346f23a9d81c208f51e4e16c201a49197b0de Mon Sep 17 00:00:00 2001 From: Internal Frameworks Autoroller Date: Tue, 14 Dec 2021 14:00:34 +0000 Subject: [PATCH 18/51] [Frameworks roll] Roll to 416225180 piper revision Change-Id: I8ebc81a6376f4bb4ed958bda3d8569a6e73d4798 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3338316 Commit-Queue: Internal Frameworks Autoroller Bot-Commit: Internal Frameworks Autoroller Cr-Commit-Position: refs/heads/main@{#951468} --- DEPS | 2 +- .../chrome_internal_dynamic_framework.ios.zip.sha1 | 2 +- ...chrome_internal_dynamic_framework.iossimulator.zip.sha1 | 2 +- .../chrome_sso_internal_dynamic_framework.ios.zip.sha1 | 2 +- ...me_sso_internal_dynamic_framework.iossimulator.zip.sha1 | 2 +- ...emoting_dogfood_internal_dynamic_framework.ios.zip.sha1 | 2 +- ...ogfood_internal_dynamic_framework.iossimulator.zip.sha1 | 2 +- .../remoting_internal_dynamic_framework.ios.zip.sha1 | 2 +- ...moting_internal_dynamic_framework.iossimulator.zip.sha1 | 2 +- .../web_view_shell_internal_dynamic_framework.ios.zip.sha1 | 2 +- ..._shell_internal_dynamic_framework.iossimulator.zip.sha1 | 2 +- ios/third_party/material_components_ios/BUILD.gn | 7 ++++--- 12 files changed, 15 insertions(+), 14 deletions(-) diff --git a/DEPS b/DEPS index 2b1bd9581f2fe0..8042ceaf0bc03e 100644 --- a/DEPS +++ b/DEPS @@ -635,7 +635,7 @@ deps = { }, 'src/ios/third_party/material_components_ios/src': { - 'url': Var('chromium_git') + '/external/github.com/material-components/material-components-ios.git' + '@' + 'fc61c312d9bd1650f8bb558359c3e179900bc94d', + 'url': Var('chromium_git') + '/external/github.com/material-components/material-components-ios.git' + '@' + 'fae0808b93a28b00796cdf10d3f50e16aaf2d71e', 'condition': 'checkout_ios', }, 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 c2f56f622bf6fd..3dc06b974c9f3a 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 @@ -297c41c630261f0d40fed2270396a76a98f080ee \ No newline at end of file +230498e1951004a66ec73c5102bd96c3963ad541 \ 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 f6094e0837e192..20a11579f7db89 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 @@ -b92a2f9f7f4f8c984a70dc3205488b77ca24ee44 \ No newline at end of file +525b829fa0eb212a83831e8553b3fe820c2425a9 \ 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 2750a10181e3f5..8ca7de3264aa1c 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 @@ -a29549704477dc5527c684658758b162dc1cbcef \ No newline at end of file +bed82ffdc8ab7cf2377b832c9c138a61399baef0 \ 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 5694eb67058aae..d882d3517f820f 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 @@ -aa079019bf0c67c7601fd190a998c2dea1a5e6e8 \ No newline at end of file +3b945e58f52a2305fd7180c18af6d7f04f96b887 \ 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 7f169b88eeaab2..724c65e47219a6 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 @@ -d11f4cd33ecd30b71549ff1af6fd66de5c625f81 \ No newline at end of file +6f2519a2c1467c5e7ed7c1e7f72fecbe0cfa701c \ 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 516c3ba39cac99..e76eecfee93833 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 @@ -215645445de4765f7bc1dffeb78e793580db86b6 \ No newline at end of file +300c9f59171763afd68e7a1f7ccfb49037a9a600 \ 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 697cbc94bfe7b3..07433b03a4d7e4 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 @@ -d91416e578ed6b14d741e48b70592a183bf6009a \ No newline at end of file +069af65b116b1a93d73e8f67e2f18a91bb75661a \ 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 099f74cabbe129..d578d6964b1655 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 @@ -ac8c538c30b1591ab918a9f05a5f286759ff3264 \ No newline at end of file +f8fb430360e82952b5465991b7c1a6cb71e2ac46 \ 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 94ae1489fe1741..67448979e437e2 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 @@ -209e495ba6c9ba63198a36717fe754fe7ac4cde5 \ No newline at end of file +81598f1241bb5898b76498892fbb638128723031 \ 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 72fe90904bb981..4274e61ccf1dc6 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 @@ -155c2d35bf123526a32e946fdc3be595daf3d3f0 \ No newline at end of file +d71667f660eda347eb1e22633c43d6bfe45d7ef6 \ No newline at end of file diff --git a/ios/third_party/material_components_ios/BUILD.gn b/ios/third_party/material_components_ios/BUILD.gn index a6821c3808c6a4..17c2164e13d4cb 100644 --- a/ios/third_party/material_components_ios/BUILD.gn +++ b/ios/third_party/material_components_ios/BUILD.gn @@ -53,6 +53,7 @@ _mdc_public_headers = [ "src/components/AppBar/src/private/MaterialAppBarStrings_table.h", "src/components/Availability/src/MDCAvailability.h", "src/components/Availability/src/MaterialAvailability.h", + "src/components/Badges/src/MDCBadgeView.h", "src/components/Banner/src/MDCBannerView.h", "src/components/Banner/src/MaterialBanner.h", "src/components/Banner/src/Theming/MDCBannerView+MaterialTheming.h", @@ -69,7 +70,6 @@ _mdc_public_headers = [ "src/components/BottomNavigation/src/MaterialBottomNavigation.h", "src/components/BottomNavigation/src/PerformantShadowMigration/MDCBottomNavigationBar+ShadowsPrivate.h", "src/components/BottomNavigation/src/private/MDCBottomNavigationBar+Private.h", - "src/components/BottomNavigation/src/private/MDCBottomNavigationItemBadge.h", "src/components/BottomNavigation/src/private/MDCBottomNavigationItemView.h", "src/components/BottomNavigation/src/private/MDCBottomNavigationLargeItemDialogView.h", "src/components/BottomNavigation/src/private/MDCBottomNavigationSystemDialogView.h", @@ -572,6 +572,7 @@ _mdc_include_dirs = [ "src/components/AppBar/src/TypographyThemer", "src/components/AppBar/src/private", "src/components/Availability/src", + "src/components/Badges/src", "src/components/Banner/src", "src/components/Banner/src/Theming", "src/components/BottomAppBar/src", @@ -778,6 +779,8 @@ _mdc_sources = [ "src/components/AppBar/src/private/MaterialAppBarStrings_table.h", "src/components/Availability/src/MDCAvailability.h", "src/components/Availability/src/MaterialAvailability.h", + "src/components/Badges/src/MDCBadgeView.h", + "src/components/Badges/src/MDCBadgeView.m", "src/components/Banner/src/MDCBannerView.h", "src/components/Banner/src/MDCBannerView.m", "src/components/Banner/src/MaterialBanner.h", @@ -800,8 +803,6 @@ _mdc_sources = [ "src/components/BottomNavigation/src/MaterialBottomNavigation.h", "src/components/BottomNavigation/src/PerformantShadowMigration/MDCBottomNavigationBar+ShadowsPrivate.h", "src/components/BottomNavigation/src/private/MDCBottomNavigationBar+Private.h", - "src/components/BottomNavigation/src/private/MDCBottomNavigationItemBadge.h", - "src/components/BottomNavigation/src/private/MDCBottomNavigationItemBadge.m", "src/components/BottomNavigation/src/private/MDCBottomNavigationItemView.h", "src/components/BottomNavigation/src/private/MDCBottomNavigationItemView.m", "src/components/BottomNavigation/src/private/MDCBottomNavigationLargeItemDialogView.h", From 5d7c602e0236ed522d59f16e78075e516e2552e4 Mon Sep 17 00:00:00 2001 From: Michael van Ouwerkerk Date: Tue, 14 Dec 2021 14:03:43 +0000 Subject: [PATCH 19/51] Revert "Add remaining html accessibility static tree tests on Android" This reverts commit fd4253204fd45d4a3075dcefd5ae8fe45640f966. Reason for revert: Too many failing tests. Original change's description: > Add remaining html accessibility static tree tests on Android > > This CL adds the remaining static tree dump tests to Android that are > part of the content/test/data/accessibility/html directory, to > continue the work on closing the gap on the "missing layer". > > We add a batch of tests with the generated output for each test > as a txt file. We only include tests that are being run on another > platform already (i.e., not a blink-exclusive test), and we skip > all tests which have diff --git a/chrome/browser/resources/chromeos/login/oobe_polymer3.html b/chrome/browser/resources/chromeos/login/oobe_polymer3.html index 0da0a75b31bd08..b55519669228b2 100644 --- a/chrome/browser/resources/chromeos/login/oobe_polymer3.html +++ b/chrome/browser/resources/chromeos/login/oobe_polymer3.html @@ -11,7 +11,6 @@ - From 010d67f1f636e62b191ff4b7d6e5a7f766e51418 Mon Sep 17 00:00:00 2001 From: Sky Malice Date: Tue, 14 Dec 2021 14:58:42 +0000 Subject: [PATCH 46/51] Actual version update for material design to 1.6.0-alpha01. Bug: 1279417 Change-Id: I2ef3d0e13d2be596b1652d7087ba3541727dcabb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3335253 Auto-Submit: Sky Malice Reviewed-by: Peter Wen Commit-Queue: Peter Wen Cr-Commit-Position: refs/heads/main@{#951496} --- DEPS | 2 +- third_party/android_deps/BUILD.gn | 2 +- .../libs/com_google_android_material_material/README.chromium | 2 +- .../libs/com_google_android_material_material/cipd.yaml | 4 ++-- .../com_google_android_material_material.info | 4 ++++ 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/DEPS b/DEPS index 6cb0fdf56e16b3..26416479ba34f5 100644 --- a/DEPS +++ b/DEPS @@ -2543,7 +2543,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_material_material', - 'version': 'version:2@1.5.0-alpha05.cr0', + 'version': 'version:2@1.6.0-alpha01.cr0', }, ], 'condition': 'checkout_android', diff --git a/third_party/android_deps/BUILD.gn b/third_party/android_deps/BUILD.gn index 029724d68f653a..ad62a459f37e6a 100644 --- a/third_party/android_deps/BUILD.gn +++ b/third_party/android_deps/BUILD.gn @@ -1237,7 +1237,7 @@ if (!limit_android_deps) { # This is generated, do not edit. Update BuildConfigGenerator.groovy instead. android_aar_prebuilt("com_google_android_material_material_java") { aar_path = - "libs/com_google_android_material_material/material-1.5.0-alpha05.aar" + "libs/com_google_android_material_material/material-1.6.0-alpha01.aar" info_path = "libs/com_google_android_material_material/com_google_android_material_material.info" # Material Design is pulled in via Doubledown, thus this target should not diff --git a/third_party/android_deps/libs/com_google_android_material_material/README.chromium b/third_party/android_deps/libs/com_google_android_material_material/README.chromium index e3e8b71fda1408..2074f38115ecd0 100644 --- a/third_party/android_deps/libs/com_google_android_material_material/README.chromium +++ b/third_party/android_deps/libs/com_google_android_material_material/README.chromium @@ -1,7 +1,7 @@ Name: Material Components for Android Short Name: material URL: https://github.com/material-components/material-components-android -Version: 1.5.0-alpha05 +Version: 1.6.0-alpha01 License: Android Software Development Kit License License File: LICENSE Security Critical: yes diff --git a/third_party/android_deps/libs/com_google_android_material_material/cipd.yaml b/third_party/android_deps/libs/com_google_android_material_material/cipd.yaml index 11223fcfe3f01c..c8674265f39638 100644 --- a/third_party/android_deps/libs/com_google_android_material_material/cipd.yaml +++ b/third_party/android_deps/libs/com_google_android_material_material/cipd.yaml @@ -3,8 +3,8 @@ # found in the LICENSE file. # To create CIPD package run the following command. -# cipd create --pkg-def cipd.yaml -tag version:2@1.5.0-alpha05.cr0 +# cipd create --pkg-def cipd.yaml -tag version:2@1.6.0-alpha01.cr0 package: chromium/third_party/android_deps/libs/com_google_android_material_material description: "Material Components for Android" data: -- file: material-1.5.0-alpha05.aar +- file: material-1.6.0-alpha01.aar diff --git a/third_party/android_deps/libs/com_google_android_material_material/com_google_android_material_material.info b/third_party/android_deps/libs/com_google_android_material_material/com_google_android_material_material.info index 07b2585ec84fcd..19ee4dfd1995f5 100644 --- a/third_party/android_deps/libs/com_google_android_material_material/com_google_android_material_material.info +++ b/third_party/android_deps/libs/com_google_android_material_material/com_google_android_material_material.info @@ -28,9 +28,11 @@ resources = [ "res/animator/linear_indeterminate_line2_head_interpolator.xml", "res/animator/linear_indeterminate_line2_tail_interpolator.xml", "res/animator/m3_btn_elevated_btn_state_list_anim.xml", + "res/animator/m3_btn_state_list_anim.xml", "res/animator/m3_card_elevated_state_list_anim.xml", "res/animator/m3_card_state_list_anim.xml", "res/animator/m3_chip_state_list_anim.xml", + "res/animator/m3_elevated_chip_state_list_anim.xml", "res/animator/mtrl_btn_state_list_anim.xml", "res/animator/mtrl_btn_unelevated_state_list_anim.xml", "res/animator/mtrl_card_state_list_anim.xml", @@ -50,6 +52,7 @@ resources = [ "res/color/design_error.xml", "res/color/design_icon_tint.xml", "res/color/m3_appbar_overlay_color.xml", + "res/color/m3_assist_chip_icon_tint_color.xml", "res/color/m3_assist_chip_stroke_color.xml", "res/color/m3_button_background_color_selector.xml", "res/color/m3_button_foreground_color_selector.xml", @@ -207,6 +210,7 @@ resources = [ "res/drawable/ic_keyboard_black_24dp.xml", "res/drawable/ic_m3_chip_check.xml", "res/drawable/ic_m3_chip_checked_circle.xml", + "res/drawable/ic_m3_chip_close.xml", "res/drawable/ic_mtrl_checked_circle.xml", "res/drawable/ic_mtrl_chip_checked_black.xml", "res/drawable/ic_mtrl_chip_checked_circle.xml", From a0d01ec287414c5352d2e4450d30a572b7d744a5 Mon Sep 17 00:00:00 2001 From: Sergey Poromov Date: Tue, 14 Dec 2021 15:05:18 +0000 Subject: [PATCH 47/51] dlp: Rename DlpContentManager -> DlpContentManagerAsh As a preparation to introduce DlpContentManager containing shared functionality in between Ash and Lacros, it's needed to rename DlpContentManager. In the future there will be base class with shared functionality DlpContentManager and classes with platform-specific implementations: DlpContentManagerAsh and DlpContentManagerLacros. Tests are not renamed as some of them will be migrated to be enabled on Lacros too, but this will come in the following CLs after fixing DLP testing on LaCros. Bug: 1254326 Test: Trybots Change-Id: I8d94a58d77e30f0c69048ffd80ba8406e1d58eb1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3330363 Reviewed-by: Lei Zhang Reviewed-by: Aya Elsayed Commit-Queue: Sergey Poromov Cr-Commit-Position: refs/heads/main@{#951497} --- chrome/browser/ash/crosapi/dlp_ash.cc | 6 +- ..._manager.cc => dlp_content_manager_ash.cc} | 197 +++++++++--------- ...nt_manager.h => dlp_content_manager_ash.h} | 44 ++-- ...=> dlp_content_manager_ash_browsertest.cc} | 64 +++--- ...=> dlp_content_manager_ash_test_helper.cc} | 35 ++-- ... => dlp_content_manager_ash_test_helper.h} | 20 +- ...cc => dlp_content_manager_ash_unittest.cc} | 69 +++--- ...ger.cc => mock_dlp_content_manager_ash.cc} | 10 +- ...nager.h => mock_dlp_content_manager_ash.h} | 14 +- chrome/browser/chromeos/BUILD.gn | 14 +- .../policy/dlp/dlp_content_observer.cc | 6 +- .../extensions/api/tabs/tabs_api_unittest.cc | 6 +- .../extensions/api/tabs/tabs_util_ash.cc | 4 +- .../webrtc/desktop_capture_access_handler.cc | 11 +- ...desktop_capture_access_handler_unittest.cc | 14 +- .../webrtc/display_media_access_handler.cc | 4 +- .../display_media_access_handler_unittest.cc | 10 +- .../webrtc/media_stream_capture_indicator.cc | 7 +- .../webrtc/tab_capture_access_handler.cc | 11 +- .../tab_capture_access_handler_unittest.cc | 6 +- .../webrtc_getdisplaymedia_browsertest.cc | 4 +- chrome/browser/printing/print_view_manager.cc | 4 +- .../chrome_capture_mode_delegate.cc | 16 +- chrome/test/BUILD.gn | 6 +- 24 files changed, 300 insertions(+), 282 deletions(-) rename chrome/browser/ash/policy/dlp/{dlp_content_manager.cc => dlp_content_manager_ash.cc} (86%) rename chrome/browser/ash/policy/dlp/{dlp_content_manager.h => dlp_content_manager_ash.h} (92%) rename chrome/browser/ash/policy/dlp/{dlp_content_manager_browsertest.cc => dlp_content_manager_ash_browsertest.cc} (95%) rename chrome/browser/ash/policy/dlp/{dlp_content_manager_test_helper.cc => dlp_content_manager_ash_test_helper.cc} (60%) rename chrome/browser/ash/policy/dlp/{dlp_content_manager_test_helper.h => dlp_content_manager_ash_test_helper.h} (69%) rename chrome/browser/ash/policy/dlp/{dlp_content_manager_unittest.cc => dlp_content_manager_ash_unittest.cc} (95%) rename chrome/browser/ash/policy/dlp/{mock_dlp_content_manager.cc => mock_dlp_content_manager_ash.cc} (75%) rename chrome/browser/ash/policy/dlp/{mock_dlp_content_manager.h => mock_dlp_content_manager_ash.h} (79%) diff --git a/chrome/browser/ash/crosapi/dlp_ash.cc b/chrome/browser/ash/crosapi/dlp_ash.cc index 75ca477af26ecf..dfcc04a4a0a78e 100644 --- a/chrome/browser/ash/crosapi/dlp_ash.cc +++ b/chrome/browser/ash/crosapi/dlp_ash.cc @@ -6,7 +6,7 @@ #include "base/logging.h" #include "chrome/browser/ash/crosapi/window_util.h" -#include "chrome/browser/ash/policy/dlp/dlp_content_manager.h" +#include "chrome/browser/ash/policy/dlp/dlp_content_manager_ash.h" #include "chrome/browser/chromeos/policy/dlp/dlp_content_restriction_set.h" #include "chrome/browser/chromeos/policy/dlp/dlp_rules_manager.h" @@ -67,8 +67,8 @@ void DlpAsh::DlpRestrictionsUpdated(const std::string& window_id, LOG(WARNING) << "Didn't find Lacros window with id: " << window_id; return; } - policy::DlpContentManager* dlp_content_manager = - policy::DlpContentManager::Get(); + policy::DlpContentManagerAsh* dlp_content_manager = + policy::DlpContentManagerAsh::Get(); DCHECK(dlp_content_manager); dlp_content_manager->OnWindowRestrictionChanged( window, ConvertMojoToDlpContentRestrictionSet(restrictions)); diff --git a/chrome/browser/ash/policy/dlp/dlp_content_manager.cc b/chrome/browser/ash/policy/dlp/dlp_content_manager_ash.cc similarity index 86% rename from chrome/browser/ash/policy/dlp/dlp_content_manager.cc rename to chrome/browser/ash/policy/dlp/dlp_content_manager_ash.cc index 70b6906086a876..b6355604e967d6 100644 --- a/chrome/browser/ash/policy/dlp/dlp_content_manager.cc +++ b/chrome/browser/ash/policy/dlp/dlp_content_manager_ash.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ash/policy/dlp/dlp_content_manager.h" +#include "chrome/browser/ash/policy/dlp/dlp_content_manager_ash.h" #include #include @@ -111,40 +111,40 @@ void InterruptVideoRecording() { } // namespace -static DlpContentManager* g_dlp_content_manager = nullptr; +static DlpContentManagerAsh* g_dlp_content_manager = nullptr; // static -DlpContentManager* DlpContentManager::Get() { +DlpContentManagerAsh* DlpContentManagerAsh::Get() { if (!g_dlp_content_manager) { - g_dlp_content_manager = new DlpContentManager(); + g_dlp_content_manager = new DlpContentManagerAsh(); g_dlp_content_manager->Init(); } return g_dlp_content_manager; } -void DlpContentManager::OnWindowOcclusionChanged(aura::Window* window) { +void DlpContentManagerAsh::OnWindowOcclusionChanged(aura::Window* window) { // Stop video captures that now might include restricted content. CheckRunningVideoCapture(); } -void DlpContentManager::OnWindowDestroying(aura::Window* window) { +void DlpContentManagerAsh::OnWindowDestroying(aura::Window* window) { window_observers_.erase(window); MaybeChangeOnScreenRestrictions(); } -DlpContentRestrictionSet DlpContentManager::GetConfidentialRestrictions( +DlpContentRestrictionSet DlpContentManagerAsh::GetConfidentialRestrictions( content::WebContents* web_contents) const { if (!base::Contains(confidential_web_contents_, web_contents)) return DlpContentRestrictionSet(); return confidential_web_contents_.at(web_contents); } -DlpContentRestrictionSet DlpContentManager::GetOnScreenPresentRestrictions() +DlpContentRestrictionSet DlpContentManagerAsh::GetOnScreenPresentRestrictions() const { return on_screen_restrictions_; } -bool DlpContentManager::IsScreenshotRestricted(const ScreenshotArea& area) { +bool DlpContentManagerAsh::IsScreenshotRestricted(const ScreenshotArea& area) { const ConfidentialContentsInfo info = GetAreaConfidentialContentsInfo(area, DlpContentRestriction::kScreenshot); MaybeReportEvent(info.restriction_info, @@ -154,7 +154,8 @@ bool DlpContentManager::IsScreenshotRestricted(const ScreenshotArea& area) { return IsBlocked(info.restriction_info); } -bool DlpContentManager::IsScreenshotApiRestricted(const ScreenshotArea& area) { +bool DlpContentManagerAsh::IsScreenshotApiRestricted( + const ScreenshotArea& area) { const ConfidentialContentsInfo info = GetAreaConfidentialContentsInfo(area, DlpContentRestriction::kScreenshot); MaybeReportEvent(info.restriction_info, @@ -165,7 +166,7 @@ bool DlpContentManager::IsScreenshotApiRestricted(const ScreenshotArea& area) { return IsBlocked(info.restriction_info) || IsWarn(info.restriction_info); } -void DlpContentManager::CheckScreenshotRestriction( +void DlpContentManagerAsh::CheckScreenshotRestriction( const ScreenshotArea& area, ash::OnCaptureModeDlpRestrictionChecked callback) { const ConfidentialContentsInfo info = @@ -177,7 +178,7 @@ void DlpContentManager::CheckScreenshotRestriction( CheckScreenCaptureRestriction(info, std::move(callback)); } -void DlpContentManager::CheckPrintingRestriction( +void DlpContentManagerAsh::CheckPrintingRestriction( content::WebContents* web_contents, OnDlpRestrictionCheckedCallback callback) { const RestrictionLevelAndUrl restriction_info = @@ -211,7 +212,7 @@ void DlpContentManager::CheckPrintingRestriction( &MaybeReportWarningProceededEvent, restriction_info.url, DlpRulesManager::Restriction::kPrinting, reporting_manager_); warn_notifier_->ShowDlpPrintWarningDialog(base::BindOnce( - &DlpContentManager::OnDlpWarnDialogReply, base::Unretained(this), + &DlpContentManagerAsh::OnDlpWarnDialogReply, base::Unretained(this), DlpConfidentialContents({web_contents}), DlpRulesManager::Restriction::kPrinting, std::move(reporting_callback).Then(std::move(callback)))); @@ -222,7 +223,7 @@ void DlpContentManager::CheckPrintingRestriction( std::move(callback).Run(true); } -bool DlpContentManager::IsScreenCaptureRestricted( +bool DlpContentManagerAsh::IsScreenCaptureRestricted( const content::DesktopMediaID& media_id) { const ConfidentialContentsInfo info = GetScreenShareConfidentialContentsInfo(media_id); @@ -233,7 +234,7 @@ bool DlpContentManager::IsScreenCaptureRestricted( return IsBlocked(info.restriction_info); } -void DlpContentManager::CheckScreenShareRestriction( +void DlpContentManagerAsh::CheckScreenShareRestriction( const content::DesktopMediaID& media_id, const std::u16string& application_title, OnDlpRestrictionCheckedCallback callback) { @@ -258,10 +259,10 @@ void DlpContentManager::CheckScreenShareRestriction( std::move(callback).Run(true); return; } - // base::Unretained(this) is safe here because DlpContentManager is + // base::Unretained(this) is safe here because DlpContentManagerAsh is // initialized as a singleton that's always available in the system. warn_notifier_->ShowDlpScreenShareWarningDialog( - base::BindOnce(&DlpContentManager::OnDlpWarnDialogReply, + base::BindOnce(&DlpContentManagerAsh::OnDlpWarnDialogReply, base::Unretained(this), info.confidential_contents, DlpRulesManager::Restriction::kScreenShare, std::move(callback)), @@ -272,7 +273,7 @@ void DlpContentManager::CheckScreenShareRestriction( std::move(callback).Run(true); } -void DlpContentManager::OnVideoCaptureStarted(const ScreenshotArea& area) { +void DlpContentManagerAsh::OnVideoCaptureStarted(const ScreenshotArea& area) { if (IsScreenshotRestricted(area)) { InterruptVideoRecording(); return; @@ -281,7 +282,7 @@ void DlpContentManager::OnVideoCaptureStarted(const ScreenshotArea& area) { running_video_capture_info_.emplace(area); } -void DlpContentManager::CheckStoppedVideoCapture( +void DlpContentManagerAsh::CheckStoppedVideoCapture( ash::OnCaptureModeDlpRestrictionChecked callback) { // If some confidential content was shown during the recording, but not // before, warn the user before saving the file. @@ -297,7 +298,7 @@ void DlpContentManager::CheckStoppedVideoCapture( running_video_capture_info_.reset(); } -bool DlpContentManager::IsCaptureModeInitRestricted() { +bool DlpContentManagerAsh::IsCaptureModeInitRestricted() { const RestrictionLevelAndUrl restriction_info = GetOnScreenPresentRestrictions().GetRestrictionLevelAndUrl( DlpContentRestriction::kScreenshot); @@ -307,7 +308,7 @@ bool DlpContentManager::IsCaptureModeInitRestricted() { return IsBlocked(restriction_info); } -void DlpContentManager::CheckCaptureModeInitRestriction( +void DlpContentManagerAsh::CheckCaptureModeInitRestriction( ash::OnCaptureModeDlpRestrictionChecked callback) { const ConfidentialContentsInfo info = GetConfidentialContentsOnScreen(DlpContentRestriction::kScreenshot); @@ -319,7 +320,7 @@ void DlpContentManager::CheckCaptureModeInitRestriction( CheckScreenCaptureRestriction(info, std::move(callback)); } -void DlpContentManager::OnScreenCaptureStarted( +void DlpContentManagerAsh::OnScreenCaptureStarted( const std::string& label, std::vector screen_capture_ids, const std::u16string& application_title, @@ -333,7 +334,7 @@ void DlpContentManager::OnScreenCaptureStarted( CheckRunningScreenShares(); } -void DlpContentManager::OnScreenCaptureStopped( +void DlpContentManagerAsh::OnScreenCaptureStopped( const std::string& label, const content::DesktopMediaID& media_id) { base::EraseIf( @@ -346,7 +347,7 @@ void DlpContentManager::OnScreenCaptureStopped( }); } -void DlpContentManager::OnWindowRestrictionChanged( +void DlpContentManagerAsh::OnWindowRestrictionChanged( aura::Window* window, const DlpContentRestrictionSet& restrictions) { confidential_windows_[window] = restrictions; @@ -355,20 +356,20 @@ void DlpContentManager::OnWindowRestrictionChanged( } /* static */ -void DlpContentManager::SetDlpContentManagerForTesting( - DlpContentManager* dlp_content_manager) { +void DlpContentManagerAsh::SetDlpContentManagerAshForTesting( + DlpContentManagerAsh* dlp_content_manager) { if (g_dlp_content_manager) delete g_dlp_content_manager; g_dlp_content_manager = dlp_content_manager; } /* static */ -void DlpContentManager::ResetDlpContentManagerForTesting() { +void DlpContentManagerAsh::ResetDlpContentManagerAshForTesting() { g_dlp_content_manager = nullptr; } -DlpContentManager::ScreenShareInfo::ScreenShareInfo() = default; -DlpContentManager::ScreenShareInfo::ScreenShareInfo( +DlpContentManagerAsh::ScreenShareInfo::ScreenShareInfo() = default; +DlpContentManagerAsh::ScreenShareInfo::ScreenShareInfo( const std::string& label, const content::DesktopMediaID& media_id, const std::u16string& application_title, @@ -377,68 +378,69 @@ DlpContentManager::ScreenShareInfo::ScreenShareInfo( media_id_(media_id), application_title_(application_title), state_change_callback_(state_change_callback) {} -DlpContentManager::ScreenShareInfo::ScreenShareInfo( - const DlpContentManager::ScreenShareInfo& other) = default; -DlpContentManager::ScreenShareInfo& -DlpContentManager::ScreenShareInfo::operator=( - const DlpContentManager::ScreenShareInfo& other) = default; -DlpContentManager::ScreenShareInfo::~ScreenShareInfo() = default; - -bool DlpContentManager::ScreenShareInfo::operator==( - const DlpContentManager::ScreenShareInfo& other) const { +DlpContentManagerAsh::ScreenShareInfo::ScreenShareInfo( + const DlpContentManagerAsh::ScreenShareInfo& other) = default; +DlpContentManagerAsh::ScreenShareInfo& +DlpContentManagerAsh::ScreenShareInfo::operator=( + const DlpContentManagerAsh::ScreenShareInfo& other) = default; +DlpContentManagerAsh::ScreenShareInfo::~ScreenShareInfo() = default; + +bool DlpContentManagerAsh::ScreenShareInfo::operator==( + const DlpContentManagerAsh::ScreenShareInfo& other) const { return label_ == other.label_ && media_id_ == other.media_id_; } -bool DlpContentManager::ScreenShareInfo::operator!=( - const DlpContentManager::ScreenShareInfo& other) const { +bool DlpContentManagerAsh::ScreenShareInfo::operator!=( + const DlpContentManagerAsh::ScreenShareInfo& other) const { return !(*this == other); } -const content::DesktopMediaID& DlpContentManager::ScreenShareInfo::GetMediaId() - const { +const content::DesktopMediaID& +DlpContentManagerAsh::ScreenShareInfo::GetMediaId() const { return media_id_; } -const std::string& DlpContentManager::ScreenShareInfo::GetLabel() const { +const std::string& DlpContentManagerAsh::ScreenShareInfo::GetLabel() const { return label_; } -const std::u16string& DlpContentManager::ScreenShareInfo::GetApplicationTitle() - const { +const std::u16string& +DlpContentManagerAsh::ScreenShareInfo::GetApplicationTitle() const { // TODO(crbug.com/1264793): Don't cache the application name, but compute it // here. return application_title_; } -bool DlpContentManager::ScreenShareInfo::IsRunning() const { +bool DlpContentManagerAsh::ScreenShareInfo::IsRunning() const { return is_running_; } -void DlpContentManager::ScreenShareInfo::Pause() { +void DlpContentManagerAsh::ScreenShareInfo::Pause() { DCHECK(is_running_); state_change_callback_.Run(media_id_, blink::mojom::MediaStreamStateChange::PAUSE); is_running_ = false; } -void DlpContentManager::ScreenShareInfo::Resume() { +void DlpContentManagerAsh::ScreenShareInfo::Resume() { DCHECK(!is_running_); state_change_callback_.Run(media_id_, blink::mojom::MediaStreamStateChange::PLAY); is_running_ = true; } -void DlpContentManager::ScreenShareInfo::MaybeUpdateNotifications() { +void DlpContentManagerAsh::ScreenShareInfo::MaybeUpdateNotifications() { UpdatePausedNotification(/*show=*/!is_running_); UpdateResumedNotification(/*show=*/is_running_); } -void DlpContentManager::ScreenShareInfo::HideNotifications() { +void DlpContentManagerAsh::ScreenShareInfo::HideNotifications() { UpdatePausedNotification(/*show=*/false); UpdateResumedNotification(/*show=*/false); } -void DlpContentManager::ScreenShareInfo::UpdatePausedNotification(bool show) { +void DlpContentManagerAsh::ScreenShareInfo::UpdatePausedNotification( + bool show) { if ((notification_state_ == NotificationState::kShowingPausedNotification) == show) return; @@ -451,7 +453,8 @@ void DlpContentManager::ScreenShareInfo::UpdatePausedNotification(bool show) { } } -void DlpContentManager::ScreenShareInfo::UpdateResumedNotification(bool show) { +void DlpContentManagerAsh::ScreenShareInfo::UpdateResumedNotification( + bool show) { if ((notification_state_ == NotificationState::kShowingResumedNotification) == show) return; @@ -464,13 +467,13 @@ void DlpContentManager::ScreenShareInfo::UpdateResumedNotification(bool show) { } } -DlpContentManager::VideoCaptureInfo::VideoCaptureInfo( +DlpContentManagerAsh::VideoCaptureInfo::VideoCaptureInfo( const ScreenshotArea& area) : area(area) {} -DlpContentManager::DlpContentManager() = default; +DlpContentManagerAsh::DlpContentManagerAsh() = default; -void DlpContentManager::Init() { +void DlpContentManagerAsh::Init() { DlpRulesManager* rules_manager = DlpRulesManagerFactory::GetForPrimaryProfile(); if (rules_manager) @@ -479,9 +482,9 @@ void DlpContentManager::Init() { warn_notifier_ = std::make_unique(); } -DlpContentManager::~DlpContentManager() = default; +DlpContentManagerAsh::~DlpContentManagerAsh() = default; -void DlpContentManager::OnConfidentialityChanged( +void DlpContentManagerAsh::OnConfidentialityChanged( content::WebContents* web_contents, const DlpContentRestrictionSet& restriction_set) { if (restriction_set.IsEmpty()) { @@ -498,24 +501,24 @@ void DlpContentManager::OnConfidentialityChanged( CheckRunningScreenShares(); } -void DlpContentManager::OnWebContentsDestroyed( +void DlpContentManagerAsh::OnWebContentsDestroyed( content::WebContents* web_contents) { RemoveFromConfidential(web_contents); } -void DlpContentManager::OnVisibilityChanged( +void DlpContentManagerAsh::OnVisibilityChanged( content::WebContents* web_contents) { MaybeChangeOnScreenRestrictions(); } -void DlpContentManager::RemoveFromConfidential( +void DlpContentManagerAsh::RemoveFromConfidential( content::WebContents* web_contents) { confidential_web_contents_.erase(web_contents); web_contents_window_observers_.erase(web_contents); MaybeChangeOnScreenRestrictions(); } -void DlpContentManager::MaybeChangeOnScreenRestrictions() { +void DlpContentManagerAsh::MaybeChangeOnScreenRestrictions() { DlpContentRestrictionSet new_restriction_set; // Check each visible WebContents. for (const auto& entry : confidential_web_contents_) { @@ -541,7 +544,7 @@ void DlpContentManager::MaybeChangeOnScreenRestrictions() { CheckRunningScreenShares(); } -void DlpContentManager::OnScreenRestrictionsChanged( +void DlpContentManagerAsh::OnScreenRestrictionsChanged( const DlpContentRestrictionSet& added_restrictions, const DlpContentRestrictionSet& removed_restrictions) const { DCHECK(!(added_restrictions.GetRestrictionLevel( @@ -579,13 +582,14 @@ void DlpContentManager::OnScreenRestrictionsChanged( DlpRulesManager::Level::kBlock) { base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, - base::BindOnce(&DlpContentManager::MaybeRemovePrivacyScreenEnforcement, - base::Unretained(this)), + base::BindOnce( + &DlpContentManagerAsh::MaybeRemovePrivacyScreenEnforcement, + base::Unretained(this)), kPrivacyScreenOffDelay); } } -void DlpContentManager::MaybeRemovePrivacyScreenEnforcement() const { +void DlpContentManagerAsh::MaybeRemovePrivacyScreenEnforcement() const { if (GetOnScreenPresentRestrictions().GetRestrictionLevel( DlpContentRestriction::kPrivacyScreen) != DlpRulesManager::Level::kBlock) { @@ -594,10 +598,10 @@ void DlpContentManager::MaybeRemovePrivacyScreenEnforcement() const { } } -DlpContentManager::ConfidentialContentsInfo -DlpContentManager::GetConfidentialContentsOnScreen( +DlpContentManagerAsh::ConfidentialContentsInfo +DlpContentManagerAsh::GetConfidentialContentsOnScreen( DlpContentRestriction restriction) const { - DlpContentManager::ConfidentialContentsInfo info; + DlpContentManagerAsh::ConfidentialContentsInfo info; info.restriction_info = GetOnScreenPresentRestrictions().GetRestrictionLevelAndUrl(restriction); for (auto& entry : confidential_web_contents_) { @@ -611,11 +615,11 @@ DlpContentManager::GetConfidentialContentsOnScreen( return info; } -DlpContentManager::ConfidentialContentsInfo -DlpContentManager::GetAreaConfidentialContentsInfo( +DlpContentManagerAsh::ConfidentialContentsInfo +DlpContentManagerAsh::GetAreaConfidentialContentsInfo( const ScreenshotArea& area, DlpContentRestriction restriction) const { - DlpContentManager::ConfidentialContentsInfo info; + DlpContentManagerAsh::ConfidentialContentsInfo info; // Fullscreen - restricted if any confidential data is visible. if (area.type == ScreenshotType::kAllRootWindows) { return GetConfidentialContentsOnScreen(restriction); @@ -743,8 +747,8 @@ DlpContentManager::GetAreaConfidentialContentsInfo( return info; } -DlpContentManager::ConfidentialContentsInfo -DlpContentManager::GetScreenShareConfidentialContentsInfo( +DlpContentManagerAsh::ConfidentialContentsInfo +DlpContentManagerAsh::GetScreenShareConfidentialContentsInfo( const content::DesktopMediaID& media_id) const { if (media_id.type == content::DesktopMediaID::Type::TYPE_SCREEN) { return GetConfidentialContentsOnScreen(DlpContentRestriction::kScreenShare); @@ -810,7 +814,7 @@ DlpContentManager::GetScreenShareConfidentialContentsInfo( return info; } -void DlpContentManager::CheckRunningVideoCapture() { +void DlpContentManagerAsh::CheckRunningVideoCapture() { if (!running_video_capture_info_.has_value()) return; ConfidentialContentsInfo info = GetAreaConfidentialContentsInfo( @@ -836,7 +840,7 @@ void DlpContentManager::CheckRunningVideoCapture() { } } -void DlpContentManager::CheckRunningScreenShares() { +void DlpContentManagerAsh::CheckRunningScreenShares() { for (auto& screen_share : running_screen_shares_) { ConfidentialContentsInfo info = GetScreenShareConfidentialContentsInfo(screen_share.GetMediaId()); @@ -868,10 +872,10 @@ void DlpContentManager::CheckRunningScreenShares() { screen_share.Pause(); screen_share.HideNotifications(); } - // base::Unretained(this) is safe here because DlpContentManager is + // base::Unretained(this) is safe here because DlpContentManagerAsh is // initialized as a singleton that's always available in the system. warn_notifier_->ShowDlpScreenShareWarningDialog( - base::BindOnce(&DlpContentManager::OnDlpScreenShareWarnDialogReply, + base::BindOnce(&DlpContentManagerAsh::OnDlpScreenShareWarnDialogReply, base::Unretained(this), info.confidential_contents, screen_share), info.confidential_contents, screen_share.GetApplicationTitle()); @@ -886,27 +890,27 @@ void DlpContentManager::CheckRunningScreenShares() { } } -void DlpContentManager::SetReportingManagerForTesting( +void DlpContentManagerAsh::SetReportingManagerForTesting( DlpReportingManager* reporting_manager) { reporting_manager_ = reporting_manager; } -void DlpContentManager::SetWarnNotifierForTesting( +void DlpContentManagerAsh::SetWarnNotifierForTesting( std::unique_ptr warn_notifier) { DCHECK(warn_notifier); warn_notifier_ = std::move(warn_notifier); } -void DlpContentManager::ResetWarnNotifierForTesting() { +void DlpContentManagerAsh::ResetWarnNotifierForTesting() { warn_notifier_ = std::make_unique(); } // static -base::TimeDelta DlpContentManager::GetPrivacyScreenOffDelayForTesting() { +base::TimeDelta DlpContentManagerAsh::GetPrivacyScreenOffDelayForTesting() { return kPrivacyScreenOffDelay; } -RestrictionLevelAndUrl DlpContentManager::GetPrintingRestrictionInfo( +RestrictionLevelAndUrl DlpContentManagerAsh::GetPrintingRestrictionInfo( content::WebContents* web_contents) const { // If we're viewing the PDF in a MimeHandlerViewGuest, use its embedded // WebContents. @@ -919,7 +923,7 @@ RestrictionLevelAndUrl DlpContentManager::GetPrintingRestrictionInfo( .GetRestrictionLevelAndUrl(DlpContentRestriction::kPrint); } -void DlpContentManager::CheckScreenCaptureRestriction( +void DlpContentManagerAsh::CheckScreenCaptureRestriction( ConfidentialContentsInfo info, ash::OnCaptureModeDlpRestrictionChecked callback) { if (IsBlocked(info.restriction_info)) { @@ -937,10 +941,10 @@ void DlpContentManager::CheckScreenCaptureRestriction( std::move(callback).Run(true); return; } - // base::Unretained(this) is safe here because DlpContentManager is + // base::Unretained(this) is safe here because DlpContentManagerAsh is // initialized as a singleton that's always available in the system. warn_notifier_->ShowDlpScreenCaptureWarningDialog( - base::BindOnce(&DlpContentManager::OnDlpWarnDialogReply, + base::BindOnce(&DlpContentManagerAsh::OnDlpWarnDialogReply, base::Unretained(this), info.confidential_contents, DlpRulesManager::Restriction::kScreenshot, std::move(callback)), @@ -951,7 +955,7 @@ void DlpContentManager::CheckScreenCaptureRestriction( std::move(callback).Run(true); } -void DlpContentManager::OnDlpScreenShareWarnDialogReply( +void DlpContentManagerAsh::OnDlpScreenShareWarnDialogReply( const DlpConfidentialContents& confidential_contents, ScreenShareInfo screen_share, bool should_proceed) { @@ -968,7 +972,7 @@ void DlpContentManager::OnDlpScreenShareWarnDialogReply( screen_share.MaybeUpdateNotifications(); } -void DlpContentManager::OnDlpWarnDialogReply( +void DlpContentManagerAsh::OnDlpWarnDialogReply( const DlpConfidentialContents& confidential_contents, DlpRulesManager::Restriction restriction, OnDlpRestrictionCheckedCallback callback, @@ -981,7 +985,7 @@ void DlpContentManager::OnDlpWarnDialogReply( std::move(callback).Run(should_proceed); } -void DlpContentManager::MaybeReportEvent( +void DlpContentManagerAsh::MaybeReportEvent( const RestrictionLevelAndUrl& restriction_info, DlpRulesManager::Restriction restriction) { // TODO(crbug.com/1260302): Add reporting and metrics for WARN restrictions. @@ -991,7 +995,7 @@ void DlpContentManager::MaybeReportEvent( } } -void DlpContentManager::ReportWarningEvent( +void DlpContentManagerAsh::ReportWarningEvent( const RestrictionLevelAndUrl& restriction_info, DlpRulesManager::Restriction restriction) { DCHECK(IsWarn(restriction_info)); @@ -1001,7 +1005,7 @@ void DlpContentManager::ReportWarningEvent( } } -void DlpContentManager::RemoveAllowedContents( +void DlpContentManagerAsh::RemoveAllowedContents( DlpConfidentialContents& contents, DlpRulesManager::Restriction restriction) { base::EraseIf( @@ -1010,14 +1014,15 @@ void DlpContentManager::RemoveAllowedContents( }); } -// ScopedDlpContentManagerForTesting -ScopedDlpContentManagerForTesting::ScopedDlpContentManagerForTesting( - DlpContentManager* test_dlp_content_manager) { - DlpContentManager::SetDlpContentManagerForTesting(test_dlp_content_manager); +// ScopedDlpContentManagerAshForTesting +ScopedDlpContentManagerAshForTesting::ScopedDlpContentManagerAshForTesting( + DlpContentManagerAsh* test_dlp_content_manager) { + DlpContentManagerAsh::SetDlpContentManagerAshForTesting( + test_dlp_content_manager); } -ScopedDlpContentManagerForTesting::~ScopedDlpContentManagerForTesting() { - DlpContentManager::ResetDlpContentManagerForTesting(); +ScopedDlpContentManagerAshForTesting::~ScopedDlpContentManagerAshForTesting() { + DlpContentManagerAsh::ResetDlpContentManagerAshForTesting(); } } // namespace policy diff --git a/chrome/browser/ash/policy/dlp/dlp_content_manager.h b/chrome/browser/ash/policy/dlp/dlp_content_manager_ash.h similarity index 92% rename from chrome/browser/ash/policy/dlp/dlp_content_manager.h rename to chrome/browser/ash/policy/dlp/dlp_content_manager_ash.h index f96feb8aae6485..9e8acda1f0fd95 100644 --- a/chrome/browser/ash/policy/dlp/dlp_content_manager.h +++ b/chrome/browser/ash/policy/dlp/dlp_content_manager_ash.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_ASH_POLICY_DLP_DLP_CONTENT_MANAGER_H_ -#define CHROME_BROWSER_ASH_POLICY_DLP_DLP_CONTENT_MANAGER_H_ +#ifndef CHROME_BROWSER_ASH_POLICY_DLP_DLP_CONTENT_MANAGER_ASH_H_ +#define CHROME_BROWSER_ASH_POLICY_DLP_DLP_CONTENT_MANAGER_ASH_H_ #include #include @@ -46,15 +46,15 @@ class DlpWarnNotifier; // WebContents and whether any of them are currently visible. // If any confidential WebContents is visible, the corresponding restrictions // will be enforced according to the current enterprise policy. -class DlpContentManager : public DlpContentObserver, - public DlpWindowObserver::Delegate { +class DlpContentManagerAsh : public DlpContentObserver, + public DlpWindowObserver::Delegate { public: - DlpContentManager(const DlpContentManager&) = delete; - DlpContentManager& operator=(const DlpContentManager&) = delete; + DlpContentManagerAsh(const DlpContentManagerAsh&) = delete; + DlpContentManagerAsh& operator=(const DlpContentManagerAsh&) = delete; // Creates the instance if not yet created. // There will always be a single instance created on the first access. - static DlpContentManager* Get(); + static DlpContentManagerAsh* Get(); // DlpWindowObserver::Delegate overrides: void OnWindowOcclusionChanged(aura::Window* window) override; @@ -144,11 +144,11 @@ class DlpContentManager : public DlpContentObserver, // The caller (test) should manage |dlp_content_manager| lifetime. // Reset doesn't delete the object. - // Please use ScopedDlpContentManagerForTesting instead of these methods, + // Please use ScopedDlpContentManagerAshForTesting instead of these methods, // if possible. - static void SetDlpContentManagerForTesting( - DlpContentManager* dlp_content_manager); - static void ResetDlpContentManagerForTesting(); + static void SetDlpContentManagerAshForTesting( + DlpContentManagerAsh* dlp_content_manager); + static void ResetDlpContentManagerAshForTesting(); protected: void SetReportingManagerForTesting(DlpReportingManager* manager); @@ -158,9 +158,9 @@ class DlpContentManager : public DlpContentObserver, void ResetWarnNotifierForTesting(); private: - friend class DlpContentManagerTestHelper; + friend class DlpContentManagerAshTestHelper; friend class DlpContentTabHelper; - friend class MockDlpContentManager; + friend class MockDlpContentManagerAsh; // Used to keep track of running screen shares. class ScreenShareInfo { @@ -239,8 +239,8 @@ class DlpContentManager : public DlpContentObserver, DlpConfidentialContents confidential_contents; }; - DlpContentManager(); - ~DlpContentManager() override; + DlpContentManagerAsh(); + ~DlpContentManagerAsh() override; // Initializing to be called separately to make testing possible. virtual void Init(); @@ -378,17 +378,17 @@ class DlpContentManager : public DlpContentObserver, const bool is_screen_share_warning_mode_enabled_ = false; }; -// Helper class to call SetDlpContentManagerForTesting and -// ResetDlpContentManagerForTesting automically. +// Helper class to call SetDlpContentManagerAshForTesting and +// ResetDlpContentManagerAshForTesting automically. // The caller (test) should manage `test_dlp_content_manager` lifetime. // This class does not own it. -class ScopedDlpContentManagerForTesting { +class ScopedDlpContentManagerAshForTesting { public: - explicit ScopedDlpContentManagerForTesting( - DlpContentManager* test_dlp_content_manager); - ~ScopedDlpContentManagerForTesting(); + explicit ScopedDlpContentManagerAshForTesting( + DlpContentManagerAsh* test_dlp_content_manager); + ~ScopedDlpContentManagerAshForTesting(); }; } // namespace policy -#endif // CHROME_BROWSER_ASH_POLICY_DLP_DLP_CONTENT_MANAGER_H_ +#endif // CHROME_BROWSER_ASH_POLICY_DLP_DLP_CONTENT_MANAGER_ASH_H_ diff --git a/chrome/browser/ash/policy/dlp/dlp_content_manager_browsertest.cc b/chrome/browser/ash/policy/dlp/dlp_content_manager_ash_browsertest.cc similarity index 95% rename from chrome/browser/ash/policy/dlp/dlp_content_manager_browsertest.cc rename to chrome/browser/ash/policy/dlp/dlp_content_manager_ash_browsertest.cc index f5941225d965d4..b24a12aa8c7ad6 100644 --- a/chrome/browser/ash/policy/dlp/dlp_content_manager_browsertest.cc +++ b/chrome/browser/ash/policy/dlp/dlp_content_manager_ash_browsertest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ash/policy/dlp/dlp_content_manager.h" +#include "chrome/browser/ash/policy/dlp/dlp_content_manager_ash.h" #include @@ -13,7 +13,7 @@ #include "base/test/metrics/histogram_tester.h" #include "base/test/test_future.h" #include "base/threading/sequenced_task_runner_handle.h" -#include "chrome/browser/ash/policy/dlp/dlp_content_manager_test_helper.h" +#include "chrome/browser/ash/policy/dlp/dlp_content_manager_ash_test_helper.h" #include "chrome/browser/chromeos/policy/dlp/dlp_histogram_helper.h" #include "chrome/browser/chromeos/policy/dlp/dlp_policy_event.pb.h" #include "chrome/browser/chromeos/policy/dlp/dlp_reporting_manager.h" @@ -87,10 +87,10 @@ constexpr char kGoogleUrl[] = "https://google.com"; constexpr char kSrcPattern[] = "example.com"; } // namespace -class DlpContentManagerBrowserTest : public InProcessBrowserTest { +class DlpContentManagerAshBrowserTest : public InProcessBrowserTest { public: - DlpContentManagerBrowserTest() = default; - ~DlpContentManagerBrowserTest() override = default; + DlpContentManagerAshBrowserTest() = default; + ~DlpContentManagerAshBrowserTest() override = default; std::unique_ptr SetDlpRulesManager( content::BrowserContext* context) { @@ -100,10 +100,10 @@ class DlpContentManagerBrowserTest : public InProcessBrowserTest { } void SetUpOnMainThread() override { - // Instantiate |DlpContentManagerTestHelper| after main thread has been set - // up cause |DlpReportingManager| needs a sequenced task runner handle to - // set up the report queue. - helper_ = std::make_unique(); + // Instantiate |DlpContentManagerAshTestHelper| after main thread has been + // set up cause |DlpReportingManager| needs a sequenced task runner handle + // to set up the report queue. + helper_ = std::make_unique(); } void TearDownOnMainThread() override { helper_.reset(); } @@ -112,8 +112,9 @@ class DlpContentManagerBrowserTest : public InProcessBrowserTest { void SetupDlpRulesManager() { DlpRulesManagerFactory::GetInstance()->SetTestingFactory( browser()->profile(), - base::BindRepeating(&DlpContentManagerBrowserTest::SetDlpRulesManager, - base::Unretained(this))); + base::BindRepeating( + &DlpContentManagerAshBrowserTest::SetDlpRulesManager, + base::Unretained(this))); ASSERT_TRUE(DlpRulesManagerFactory::GetForPrimaryProfile()); EXPECT_CALL(*mock_rules_manager_, GetSourceUrlPattern(_, _, _)) @@ -140,7 +141,7 @@ class DlpContentManagerBrowserTest : public InProcessBrowserTest { } protected: - std::unique_ptr helper_; + std::unique_ptr helper_; base::HistogramTester histogram_tester_; MockDlpRulesManager* mock_rules_manager_; @@ -148,9 +149,9 @@ class DlpContentManagerBrowserTest : public InProcessBrowserTest { std::vector events_; }; -IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, ScreenshotsRestricted) { +IN_PROC_BROWSER_TEST_F(DlpContentManagerAshBrowserTest, ScreenshotsRestricted) { SetupReporting(); - DlpContentManager* manager = helper_->GetContentManager(); + DlpContentManagerAsh* manager = helper_->GetContentManager(); ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), GURL(kExampleUrl))); content::WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); @@ -230,8 +231,8 @@ IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, ScreenshotsRestricted) { DlpRulesManager::Level::kBlock, 7u); } -IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, ScreenshotsWarned) { - DlpContentManager* manager = helper_->GetContentManager(); +IN_PROC_BROWSER_TEST_F(DlpContentManagerAshBrowserTest, ScreenshotsWarned) { + DlpContentManagerAsh* manager = helper_->GetContentManager(); ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), GURL(kExampleUrl))); content::WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); @@ -281,9 +282,9 @@ IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, ScreenshotsWarned) { EXPECT_FALSE(manager->IsScreenshotApiRestricted(partial_out)); } -IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, ScreenshotsReported) { +IN_PROC_BROWSER_TEST_F(DlpContentManagerAshBrowserTest, ScreenshotsReported) { SetupReporting(); - DlpContentManager* manager = helper_->GetContentManager(); + DlpContentManagerAsh* manager = helper_->GetContentManager(); ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), GURL(kExampleUrl))); content::WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); @@ -347,7 +348,7 @@ IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, ScreenshotsReported) { DlpRulesManager::Level::kReport, 7u); } -IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, +IN_PROC_BROWSER_TEST_F(DlpContentManagerAshBrowserTest, VideoCaptureStoppedWhenConfidentialWindowResized) { SetupReporting(); aura::Window* root_window = @@ -396,7 +397,7 @@ IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, DlpRulesManager::Level::kBlock, 1u); } -IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, VideoCaptureReported) { +IN_PROC_BROWSER_TEST_F(DlpContentManagerAshBrowserTest, VideoCaptureReported) { SetupReporting(); aura::Window* root_window = browser()->window()->GetNativeWindow()->GetRootWindow(); @@ -444,7 +445,7 @@ IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, VideoCaptureReported) { DlpRulesManager::Level::kReport, 1u); } -IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, +IN_PROC_BROWSER_TEST_F(DlpContentManagerAshBrowserTest, VideoCaptureStoppedWhenNonConfidentialWindowResized) { SetupReporting(); aura::Window* root_window = @@ -493,7 +494,7 @@ IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, DlpRulesManager::Level::kBlock, 1u); } -IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, +IN_PROC_BROWSER_TEST_F(DlpContentManagerAshBrowserTest, VideoCaptureNotStoppedWhenConfidentialWindowHidden) { SetupReporting(); aura::Window* root_window = @@ -542,10 +543,11 @@ IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, DlpRulesManager::Level::kBlock, 0u); } -IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, ScreenShareNotification) { +IN_PROC_BROWSER_TEST_F(DlpContentManagerAshBrowserTest, + ScreenShareNotification) { SetupReporting(); NotificationDisplayServiceTester display_service_tester(browser()->profile()); - DlpContentManager* manager = helper_->GetContentManager(); + DlpContentManagerAsh* manager = helper_->GetContentManager(); ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), GURL(kExampleUrl))); content::WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); @@ -603,11 +605,11 @@ IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, ScreenShareNotification) { DlpRulesManager::Level::kBlock, 1u); } -IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, +IN_PROC_BROWSER_TEST_F(DlpContentManagerAshBrowserTest, ScreenShareDisabledNotification) { SetupReporting(); NotificationDisplayServiceTester display_service_tester(browser()->profile()); - DlpContentManager* manager = helper_->GetContentManager(); + DlpContentManagerAsh* manager = helper_->GetContentManager(); ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), GURL(kExampleUrl))); content::WebContents* web_contents = browser()->tab_strip_model()->GetActiveWebContents(); @@ -639,7 +641,7 @@ IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, // Starting screen sharing and navigating other tabs should create exactly one // reporting event. -IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, ScreenShareReporting) { +IN_PROC_BROWSER_TEST_F(DlpContentManagerAshBrowserTest, ScreenShareReporting) { SetupReporting(); const GURL origin(kExampleUrl); NotificationDisplayServiceTester display_service_tester(browser()->profile()); @@ -718,7 +720,7 @@ IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, ScreenShareReporting) { kScreenShareBlockedNotificationId)); } -IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, PrintingNotRestricted) { +IN_PROC_BROWSER_TEST_F(DlpContentManagerAshBrowserTest, PrintingNotRestricted) { // Set up mock report queue and mock rules manager. SetupReporting(); ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), GURL(kExampleUrl))); @@ -752,10 +754,10 @@ IN_PROC_BROWSER_TEST_F(DlpContentManagerBrowserTest, PrintingNotRestricted) { } class DlpContentManagerReportingBrowserTest - : public DlpContentManagerBrowserTest { + : public DlpContentManagerAshBrowserTest { public: void SetUpOnMainThread() override { - DlpContentManagerBrowserTest::SetUpOnMainThread(); + DlpContentManagerAshBrowserTest::SetUpOnMainThread(); content::WebContents* first_tab = browser()->tab_strip_model()->GetActiveWebContents(); ASSERT_TRUE(first_tab); @@ -774,7 +776,7 @@ class DlpContentManagerReportingBrowserTest } void TearDownOnMainThread() override { - DlpContentManagerBrowserTest::TearDownOnMainThread(); + DlpContentManagerAshBrowserTest::TearDownOnMainThread(); cloned_tab_observer_.reset(); } diff --git a/chrome/browser/ash/policy/dlp/dlp_content_manager_test_helper.cc b/chrome/browser/ash/policy/dlp/dlp_content_manager_ash_test_helper.cc similarity index 60% rename from chrome/browser/ash/policy/dlp/dlp_content_manager_test_helper.cc rename to chrome/browser/ash/policy/dlp/dlp_content_manager_ash_test_helper.cc index 1f0d9de214b61e..7e6b4176eb29b1 100644 --- a/chrome/browser/ash/policy/dlp/dlp_content_manager_test_helper.cc +++ b/chrome/browser/ash/policy/dlp/dlp_content_manager_ash_test_helper.cc @@ -2,60 +2,60 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ash/policy/dlp/dlp_content_manager_test_helper.h" +#include "chrome/browser/ash/policy/dlp/dlp_content_manager_ash_test_helper.h" #include -#include "chrome/browser/ash/policy/dlp/dlp_content_manager.h" +#include "chrome/browser/ash/policy/dlp/dlp_content_manager_ash.h" #include "chrome/browser/chromeos/policy/dlp/dlp_reporting_manager.h" #include "chrome/browser/chromeos/policy/dlp/dlp_warn_notifier.h" namespace policy { -DlpContentManagerTestHelper::DlpContentManagerTestHelper() { - manager_ = new DlpContentManager(); +DlpContentManagerAshTestHelper::DlpContentManagerAshTestHelper() { + manager_ = new DlpContentManagerAsh(); DCHECK(manager_); reporting_manager_ = new DlpReportingManager(); DCHECK(reporting_manager_); manager_->SetReportingManagerForTesting(reporting_manager_); - DlpContentManager::SetDlpContentManagerForTesting(manager_); + DlpContentManagerAsh::SetDlpContentManagerAshForTesting(manager_); } -DlpContentManagerTestHelper::~DlpContentManagerTestHelper() { +DlpContentManagerAshTestHelper::~DlpContentManagerAshTestHelper() { delete reporting_manager_; } -void DlpContentManagerTestHelper::ChangeConfidentiality( +void DlpContentManagerAshTestHelper::ChangeConfidentiality( content::WebContents* web_contents, const DlpContentRestrictionSet& restrictions) { DCHECK(manager_); manager_->OnConfidentialityChanged(web_contents, restrictions); } -void DlpContentManagerTestHelper::ChangeVisibility( +void DlpContentManagerAshTestHelper::ChangeVisibility( content::WebContents* web_contents) { DCHECK(manager_); manager_->OnVisibilityChanged(web_contents); } -void DlpContentManagerTestHelper::DestroyWebContents( +void DlpContentManagerAshTestHelper::DestroyWebContents( content::WebContents* web_contents) { DCHECK(manager_); manager_->OnWebContentsDestroyed(web_contents); } -void DlpContentManagerTestHelper::SetWarnNotifierForTesting( +void DlpContentManagerAshTestHelper::SetWarnNotifierForTesting( std::unique_ptr notifier) { DCHECK(manager_); manager_->SetWarnNotifierForTesting(std::move(notifier)); } -void DlpContentManagerTestHelper::ResetWarnNotifierForTesting() { +void DlpContentManagerAshTestHelper::ResetWarnNotifierForTesting() { DCHECK(manager_); manager_->ResetWarnNotifierForTesting(); } -bool DlpContentManagerTestHelper::HasContentCachedForRestriction( +bool DlpContentManagerAshTestHelper::HasContentCachedForRestriction( content::WebContents* web_contents, DlpRulesManager::Restriction restriction) const { DCHECK(manager_); @@ -63,21 +63,24 @@ bool DlpContentManagerTestHelper::HasContentCachedForRestriction( restriction); } -bool DlpContentManagerTestHelper::HasAnyContentCached() const { +bool DlpContentManagerAshTestHelper::HasAnyContentCached() const { DCHECK(manager_); return manager_->user_allowed_contents_cache_.GetSizeForTesting() != 0; } -base::TimeDelta DlpContentManagerTestHelper::GetPrivacyScreenOffDelay() const { +base::TimeDelta DlpContentManagerAshTestHelper::GetPrivacyScreenOffDelay() + const { DCHECK(manager_); return manager_->GetPrivacyScreenOffDelayForTesting(); } -DlpContentManager* DlpContentManagerTestHelper::GetContentManager() const { +DlpContentManagerAsh* DlpContentManagerAshTestHelper::GetContentManager() + const { return manager_; } -DlpReportingManager* DlpContentManagerTestHelper::GetReportingManager() const { +DlpReportingManager* DlpContentManagerAshTestHelper::GetReportingManager() + const { return manager_->reporting_manager_; } diff --git a/chrome/browser/ash/policy/dlp/dlp_content_manager_test_helper.h b/chrome/browser/ash/policy/dlp/dlp_content_manager_ash_test_helper.h similarity index 69% rename from chrome/browser/ash/policy/dlp/dlp_content_manager_test_helper.h rename to chrome/browser/ash/policy/dlp/dlp_content_manager_ash_test_helper.h index 5aa77a30e9daea..03b3e65726bf30 100644 --- a/chrome/browser/ash/policy/dlp/dlp_content_manager_test_helper.h +++ b/chrome/browser/ash/policy/dlp/dlp_content_manager_ash_test_helper.h @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_ASH_POLICY_DLP_DLP_CONTENT_MANAGER_TEST_HELPER_H_ -#define CHROME_BROWSER_ASH_POLICY_DLP_DLP_CONTENT_MANAGER_TEST_HELPER_H_ +#ifndef CHROME_BROWSER_ASH_POLICY_DLP_DLP_CONTENT_MANAGER_ASH_TEST_HELPER_H_ +#define CHROME_BROWSER_ASH_POLICY_DLP_DLP_CONTENT_MANAGER_ASH_TEST_HELPER_H_ #include #include "base/time/time.h" -#include "chrome/browser/ash/policy/dlp/dlp_content_manager.h" +#include "chrome/browser/ash/policy/dlp/dlp_content_manager_ash.h" #include "chrome/browser/chromeos/policy/dlp/dlp_confidential_contents.h" #include "chrome/browser/chromeos/policy/dlp/dlp_content_restriction_set.h" #include "chrome/browser/chromeos/policy/dlp/dlp_rules_manager.h" @@ -20,12 +20,12 @@ namespace policy { class DlpReportingManager; -// This class is an interface to DlpContentManager and is used in tests to +// This class is an interface to DlpContentManagerAsh and is used in tests to // access some of its private methods. -class DlpContentManagerTestHelper { +class DlpContentManagerAshTestHelper { public: - DlpContentManagerTestHelper(); - ~DlpContentManagerTestHelper(); + DlpContentManagerAshTestHelper(); + ~DlpContentManagerAshTestHelper(); void ChangeConfidentiality(content::WebContents* web_contents, const DlpContentRestrictionSet& restrictions); @@ -46,14 +46,14 @@ class DlpContentManagerTestHelper { base::TimeDelta GetPrivacyScreenOffDelay() const; - DlpContentManager* GetContentManager() const; + DlpContentManagerAsh* GetContentManager() const; DlpReportingManager* GetReportingManager() const; private: - DlpContentManager* manager_; + DlpContentManagerAsh* manager_; DlpReportingManager* reporting_manager_; }; } // namespace policy -#endif // CHROME_BROWSER_ASH_POLICY_DLP_DLP_CONTENT_MANAGER_TEST_HELPER_H_ +#endif // CHROME_BROWSER_ASH_POLICY_DLP_DLP_CONTENT_MANAGER_ASH_TEST_HELPER_H_ diff --git a/chrome/browser/ash/policy/dlp/dlp_content_manager_unittest.cc b/chrome/browser/ash/policy/dlp/dlp_content_manager_ash_unittest.cc similarity index 95% rename from chrome/browser/ash/policy/dlp/dlp_content_manager_unittest.cc rename to chrome/browser/ash/policy/dlp/dlp_content_manager_ash_unittest.cc index e1496fadc88c1e..3239cc2e078952 100644 --- a/chrome/browser/ash/policy/dlp/dlp_content_manager_unittest.cc +++ b/chrome/browser/ash/policy/dlp/dlp_content_manager_ash_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 "chrome/browser/ash/policy/dlp/dlp_content_manager.h" +#include "chrome/browser/ash/policy/dlp/dlp_content_manager_ash.h" #include @@ -14,7 +14,7 @@ #include "base/test/metrics/histogram_tester.h" #include "base/test/task_environment.h" #include "chrome/browser/ash/login/users/fake_chrome_user_manager.h" -#include "chrome/browser/ash/policy/dlp/dlp_content_manager_test_helper.h" +#include "chrome/browser/ash/policy/dlp/dlp_content_manager_ash_test_helper.h" #include "chrome/browser/chromeos/policy/dlp/dlp_histogram_helper.h" #include "chrome/browser/chromeos/policy/dlp/dlp_policy_event.pb.h" #include "chrome/browser/chromeos/policy/dlp/dlp_reporting_manager.h" @@ -90,10 +90,10 @@ auto on_dlp_restriction_checked_callback = [](absl::optional* out_result, } // namespace -class DlpContentManagerTest : public testing::Test { +class DlpContentManagerAshTest : public testing::Test { public: - DlpContentManagerTest(const DlpContentManagerTest&) = delete; - DlpContentManagerTest& operator=(const DlpContentManagerTest&) = delete; + DlpContentManagerAshTest(const DlpContentManagerAshTest&) = delete; + DlpContentManagerAshTest& operator=(const DlpContentManagerAshTest&) = delete; std::unique_ptr SetDlpRulesManager( content::BrowserContext* context) { @@ -103,11 +103,11 @@ class DlpContentManagerTest : public testing::Test { } protected: - DlpContentManagerTest() + DlpContentManagerAshTest() : profile_manager_(TestingBrowserProcess::GetGlobal()), user_manager_(new ash::FakeChromeUserManager()), scoped_user_manager_(base::WrapUnique(user_manager_)) {} - ~DlpContentManagerTest() override = default; + ~DlpContentManagerAshTest() override = default; std::unique_ptr CreateWebContents() { return content::WebContentsTester::CreateTestWebContents(profile_, nullptr); @@ -146,18 +146,18 @@ class DlpContentManagerTest : public testing::Test { void SetupDlpRulesManager() { DlpRulesManagerFactory::GetInstance()->SetTestingFactory( profile(), - base::BindRepeating(&DlpContentManagerTest::SetDlpRulesManager, + base::BindRepeating(&DlpContentManagerAshTest::SetDlpRulesManager, base::Unretained(this))); ASSERT_TRUE(DlpRulesManagerFactory::GetForPrimaryProfile()); } - DlpContentManager* GetManager() { return helper_.GetContentManager(); } + DlpContentManagerAsh* GetManager() { return helper_.GetContentManager(); } TestingProfile* profile() { return profile_; } content::BrowserTaskEnvironment task_environment_{ base::test::TaskEnvironment::TimeSource::MOCK_TIME}; - DlpContentManagerTestHelper helper_; + DlpContentManagerAshTestHelper helper_; base::HistogramTester histogram_tester_; std::vector events_; MockDlpRulesManager* mock_rules_manager_ = nullptr; @@ -185,7 +185,7 @@ class DlpContentManagerTest : public testing::Test { user_manager::ScopedUserManager scoped_user_manager_; }; -TEST_F(DlpContentManagerTest, NoConfidentialDataShown) { +TEST_F(DlpContentManagerAshTest, NoConfidentialDataShown) { std::unique_ptr web_contents = CreateWebContents(); EXPECT_EQ(GetManager()->GetConfidentialRestrictions(web_contents.get()), kEmptyRestrictionSet); @@ -193,7 +193,7 @@ TEST_F(DlpContentManagerTest, NoConfidentialDataShown) { kEmptyRestrictionSet); } -TEST_F(DlpContentManagerTest, ConfidentialDataShown) { +TEST_F(DlpContentManagerAshTest, ConfidentialDataShown) { std::unique_ptr web_contents = CreateWebContents(); EXPECT_EQ(GetManager()->GetConfidentialRestrictions(web_contents.get()), kEmptyRestrictionSet); @@ -213,7 +213,7 @@ TEST_F(DlpContentManagerTest, ConfidentialDataShown) { kEmptyRestrictionSet); } -TEST_F(DlpContentManagerTest, ConfidentialDataVisibilityChanged) { +TEST_F(DlpContentManagerAshTest, ConfidentialDataVisibilityChanged) { std::unique_ptr web_contents = CreateWebContents(); EXPECT_EQ(GetManager()->GetConfidentialRestrictions(web_contents.get()), kEmptyRestrictionSet); @@ -247,7 +247,7 @@ TEST_F(DlpContentManagerTest, ConfidentialDataVisibilityChanged) { kEmptyRestrictionSet); } -TEST_F(DlpContentManagerTest, +TEST_F(DlpContentManagerAshTest, TwoWebContentsVisibilityAndConfidentialityChanged) { std::unique_ptr web_contents1 = CreateWebContents(); std::unique_ptr web_contents2 = CreateWebContents(); @@ -313,7 +313,7 @@ TEST_F(DlpContentManagerTest, kEmptyRestrictionSet); } -TEST_F(DlpContentManagerTest, PrivacyScreenEnforcement) { +TEST_F(DlpContentManagerAshTest, PrivacyScreenEnforcement) { SetReportQueueForReportingManager(); SetupDlpRulesManager(); const std::string src_pattern("example.com"); @@ -379,7 +379,7 @@ TEST_F(DlpContentManagerTest, PrivacyScreenEnforcement) { EXPECT_EQ(events_.size(), 2u); } -TEST_F(DlpContentManagerTest, PrivacyScreenReported) { +TEST_F(DlpContentManagerAshTest, PrivacyScreenReported) { SetReportQueueForReportingManager(); SetupDlpRulesManager(); const std::string src_pattern("example.com"); @@ -421,7 +421,7 @@ TEST_F(DlpContentManagerTest, PrivacyScreenReported) { EXPECT_EQ(events_.size(), 2u); } -TEST_F(DlpContentManagerTest, +TEST_F(DlpContentManagerAshTest, PrivacyScreenNotEnforcedAndReportedOnUnsupportedDevice) { SetReportQueueForReportingManager(); SetupDlpRulesManager(); @@ -450,18 +450,19 @@ TEST_F(DlpContentManagerTest, helper_.DestroyWebContents(web_contents.get()); } -class DlpContentManagerCheckRestrictionTest : public DlpContentManagerTest { +class DlpContentManagerAshCheckRestrictionTest + : public DlpContentManagerAshTest { public: - DlpContentManagerCheckRestrictionTest( - const DlpContentManagerCheckRestrictionTest&) = delete; - DlpContentManagerCheckRestrictionTest& operator=( - const DlpContentManagerCheckRestrictionTest&) = delete; + DlpContentManagerAshCheckRestrictionTest( + const DlpContentManagerAshCheckRestrictionTest&) = delete; + DlpContentManagerAshCheckRestrictionTest& operator=( + const DlpContentManagerAshCheckRestrictionTest&) = delete; protected: - DlpContentManagerCheckRestrictionTest() = default; + DlpContentManagerAshCheckRestrictionTest() = default; void SetUp() override { - DlpContentManagerTest::SetUp(); + DlpContentManagerAshTest::SetUp(); SetReportQueueForReportingManager(); SetupDlpRulesManager(); @@ -493,7 +494,7 @@ class DlpContentManagerCheckRestrictionTest : public DlpContentManagerTest { absl::optional is_action_allowed_; }; -TEST_F(DlpContentManagerCheckRestrictionTest, PrintingRestricted) { +TEST_F(DlpContentManagerAshCheckRestrictionTest, PrintingRestricted) { // Needs to be set because CheckPrintingRestriction() will show the blocked // notification. NotificationDisplayServiceTester display_service_tester(profile()); @@ -548,7 +549,7 @@ TEST_F(DlpContentManagerCheckRestrictionTest, PrintingRestricted) { GetDlpHistogramPrefix() + dlp::kPrintingBlockedUMA, false, 2); } -TEST_F(DlpContentManagerCheckRestrictionTest, PrintingWarnedContinued) { +TEST_F(DlpContentManagerAshCheckRestrictionTest, PrintingWarnedContinued) { // Set the notifier to "Proceed" on the warning. MockDlpWarnNotifier* mock_dlp_warn_notifier = CreateAndSetDlpWarnNotifier(true /*should_proceed*/); @@ -617,7 +618,7 @@ TEST_F(DlpContentManagerCheckRestrictionTest, PrintingWarnedContinued) { EXPECT_EQ(events_.size(), 3u); } -TEST_F(DlpContentManagerCheckRestrictionTest, PrintingWarnedCancelled) { +TEST_F(DlpContentManagerAshCheckRestrictionTest, PrintingWarnedCancelled) { // Set the notifier to "Proceed" on the warning. MockDlpWarnNotifier* mock_dlp_warn_notifier = CreateAndSetDlpWarnNotifier(false /*should_proceed*/); @@ -680,7 +681,7 @@ TEST_F(DlpContentManagerCheckRestrictionTest, PrintingWarnedCancelled) { EXPECT_EQ(events_.size(), 2u); } -TEST_F(DlpContentManagerCheckRestrictionTest, CaptureModeInitRestricted) { +TEST_F(DlpContentManagerAshCheckRestrictionTest, CaptureModeInitRestricted) { // Needs to be set because CheckCaptureModeInitRestriction() will show the // blocked notification. NotificationDisplayServiceTester display_service_tester(profile()); @@ -731,7 +732,8 @@ TEST_F(DlpContentManagerCheckRestrictionTest, CaptureModeInitRestricted) { GetDlpHistogramPrefix() + dlp::kCaptureModeInitBlockedUMA, false, 2); } -TEST_F(DlpContentManagerCheckRestrictionTest, CaptureModeInitWarnedContinued) { +TEST_F(DlpContentManagerAshCheckRestrictionTest, + CaptureModeInitWarnedContinued) { // Set the notifier to "Proceed" on the warning. MockDlpWarnNotifier* mock_dlp_warn_notifier = CreateAndSetDlpWarnNotifier(true /*should_proceed*/); @@ -774,7 +776,8 @@ TEST_F(DlpContentManagerCheckRestrictionTest, CaptureModeInitWarnedContinued) { VerifyAndResetActionAllowed(true /*expected*/); } -TEST_F(DlpContentManagerCheckRestrictionTest, CaptureModeInitWarnedCancelled) { +TEST_F(DlpContentManagerAshCheckRestrictionTest, + CaptureModeInitWarnedCancelled) { // Set the notifier to "Proceed" on the warning. MockDlpWarnNotifier* mock_dlp_warn_notifier = CreateAndSetDlpWarnNotifier(false /*should_proceed*/); @@ -816,7 +819,7 @@ TEST_F(DlpContentManagerCheckRestrictionTest, CaptureModeInitWarnedCancelled) { VerifyAndResetActionAllowed(true /*expected*/); } -TEST_F(DlpContentManagerCheckRestrictionTest, ScreenshotRestricted) { +TEST_F(DlpContentManagerAshCheckRestrictionTest, ScreenshotRestricted) { // Needs to be set because CheckScreenshotRestriction() will show the blocked // notification. NotificationDisplayServiceTester display_service_tester(profile()); @@ -872,7 +875,7 @@ TEST_F(DlpContentManagerCheckRestrictionTest, ScreenshotRestricted) { GetDlpHistogramPrefix() + dlp::kScreenshotBlockedUMA, false, 2); } -TEST_F(DlpContentManagerCheckRestrictionTest, ScreenshotWarnedContinued) { +TEST_F(DlpContentManagerAshCheckRestrictionTest, ScreenshotWarnedContinued) { // Set the notifier to "Proceed" on the warning. MockDlpWarnNotifier* mock_dlp_warn_notifier = CreateAndSetDlpWarnNotifier(true /*should_proceed*/); @@ -921,7 +924,7 @@ TEST_F(DlpContentManagerCheckRestrictionTest, ScreenshotWarnedContinued) { VerifyAndResetActionAllowed(true /*expected*/); } -TEST_F(DlpContentManagerCheckRestrictionTest, ScreenshotWarnedCancelled) { +TEST_F(DlpContentManagerAshCheckRestrictionTest, ScreenshotWarnedCancelled) { // Set the notifier to "Proceed" on the warning. MockDlpWarnNotifier* mock_dlp_warn_notifier = CreateAndSetDlpWarnNotifier(false /*should_proceed*/); diff --git a/chrome/browser/ash/policy/dlp/mock_dlp_content_manager.cc b/chrome/browser/ash/policy/dlp/mock_dlp_content_manager_ash.cc similarity index 75% rename from chrome/browser/ash/policy/dlp/mock_dlp_content_manager.cc rename to chrome/browser/ash/policy/dlp/mock_dlp_content_manager_ash.cc index fddc9567209800..bc3c0a8f064293 100644 --- a/chrome/browser/ash/policy/dlp/mock_dlp_content_manager.cc +++ b/chrome/browser/ash/policy/dlp/mock_dlp_content_manager_ash.cc @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ash/policy/dlp/mock_dlp_content_manager.h" +#include "chrome/browser/ash/policy/dlp/mock_dlp_content_manager_ash.h" -#include "chrome/browser/ash/policy/dlp/dlp_content_manager.h" +#include "chrome/browser/ash/policy/dlp/dlp_content_manager_ash.h" #include "chrome/browser/chromeos/policy/dlp/dlp_reporting_manager.h" namespace policy { -MockDlpContentManager::MockDlpContentManager() = default; +MockDlpContentManagerAsh::MockDlpContentManagerAsh() = default; -MockDlpContentManager::~MockDlpContentManager() = default; +MockDlpContentManagerAsh::~MockDlpContentManagerAsh() = default; -void MockDlpContentManager::Init() { +void MockDlpContentManagerAsh::Init() { SetReportingManagerForTesting(new DlpReportingManager()); ON_CALL(*this, CheckScreenShareRestriction) diff --git a/chrome/browser/ash/policy/dlp/mock_dlp_content_manager.h b/chrome/browser/ash/policy/dlp/mock_dlp_content_manager_ash.h similarity index 79% rename from chrome/browser/ash/policy/dlp/mock_dlp_content_manager.h rename to chrome/browser/ash/policy/dlp/mock_dlp_content_manager_ash.h index f8ba398a3a451b..8f736344e2cb33 100644 --- a/chrome/browser/ash/policy/dlp/mock_dlp_content_manager.h +++ b/chrome/browser/ash/policy/dlp/mock_dlp_content_manager_ash.h @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_ASH_POLICY_DLP_MOCK_DLP_CONTENT_MANAGER_H_ -#define CHROME_BROWSER_ASH_POLICY_DLP_MOCK_DLP_CONTENT_MANAGER_H_ +#ifndef CHROME_BROWSER_ASH_POLICY_DLP_MOCK_DLP_CONTENT_MANAGER_ASH_H_ +#define CHROME_BROWSER_ASH_POLICY_DLP_MOCK_DLP_CONTENT_MANAGER_ASH_H_ #include "base/callback_forward.h" -#include "chrome/browser/ash/policy/dlp/dlp_content_manager.h" +#include "chrome/browser/ash/policy/dlp/dlp_content_manager_ash.h" #include "testing/gmock/include/gmock/gmock.h" #include "url/gurl.h" namespace policy { -class MockDlpContentManager : public DlpContentManager { +class MockDlpContentManagerAsh : public DlpContentManagerAsh { public: - MockDlpContentManager(); - ~MockDlpContentManager() override; + MockDlpContentManagerAsh(); + ~MockDlpContentManagerAsh() override; MOCK_METHOD(void, OnConfidentialityChanged, @@ -47,4 +47,4 @@ class MockDlpContentManager : public DlpContentManager { } // namespace policy -#endif // CHROME_BROWSER_ASH_POLICY_DLP_MOCK_DLP_CONTENT_MANAGER_H_ +#endif // CHROME_BROWSER_ASH_POLICY_DLP_MOCK_DLP_CONTENT_MANAGER_ASH_H_ diff --git a/chrome/browser/chromeos/BUILD.gn b/chrome/browser/chromeos/BUILD.gn index 9bc7289d3ee7a9..21d897ac3f11e5 100644 --- a/chrome/browser/chromeos/BUILD.gn +++ b/chrome/browser/chromeos/BUILD.gn @@ -2452,8 +2452,8 @@ source_set("chromeos") { "../ash/policy/display/display_rotation_default_handler.h", "../ash/policy/display/display_settings_handler.cc", "../ash/policy/display/display_settings_handler.h", - "../ash/policy/dlp/dlp_content_manager.cc", - "../ash/policy/dlp/dlp_content_manager.h", + "../ash/policy/dlp/dlp_content_manager_ash.cc", + "../ash/policy/dlp/dlp_content_manager_ash.h", "../ash/policy/dlp/dlp_notification_helper.cc", "../ash/policy/dlp/dlp_notification_helper.h", "../ash/policy/dlp/dlp_window_observer.cc", @@ -3783,8 +3783,8 @@ static_library("test_support") { "../ash/plugin_vm/fake_plugin_vm_features.h", "../ash/policy/core/user_policy_test_helper.cc", "../ash/policy/core/user_policy_test_helper.h", - "../ash/policy/dlp/dlp_content_manager_test_helper.cc", - "../ash/policy/dlp/dlp_content_manager_test_helper.h", + "../ash/policy/dlp/dlp_content_manager_ash_test_helper.cc", + "../ash/policy/dlp/dlp_content_manager_ash_test_helper.h", "../ash/policy/handlers/fake_device_name_policy_handler.cc", "../ash/policy/handlers/fake_device_name_policy_handler.h", "../ash/policy/handlers/minimum_version_policy_test_helpers.cc", @@ -4344,9 +4344,9 @@ source_set("unit_tests") { "../ash/policy/core/user_cloud_policy_manager_ash_unittest.cc", "../ash/policy/core/user_cloud_policy_store_ash_unittest.cc", "../ash/policy/core/user_cloud_policy_token_forwarder_unittest.cc", - "../ash/policy/dlp/dlp_content_manager_unittest.cc", - "../ash/policy/dlp/mock_dlp_content_manager.cc", - "../ash/policy/dlp/mock_dlp_content_manager.h", + "../ash/policy/dlp/dlp_content_manager_ash_unittest.cc", + "../ash/policy/dlp/mock_dlp_content_manager_ash.cc", + "../ash/policy/dlp/mock_dlp_content_manager_ash.h", "../ash/policy/enrollment/account_status_check_fetcher_unittest.cc", "../ash/policy/enrollment/auto_enrollment_client_impl_unittest.cc", "../ash/policy/enrollment/device_cloud_policy_initializer_unittest.cc", diff --git a/chrome/browser/chromeos/policy/dlp/dlp_content_observer.cc b/chrome/browser/chromeos/policy/dlp/dlp_content_observer.cc index a17af62b5e9e15..70e4bb6c33a0db 100644 --- a/chrome/browser/chromeos/policy/dlp/dlp_content_observer.cc +++ b/chrome/browser/chromeos/policy/dlp/dlp_content_observer.cc @@ -7,7 +7,7 @@ #include "build/chromeos_buildflags.h" #if BUILDFLAG(IS_CHROMEOS_ASH) -#include "chrome/browser/ash/policy/dlp/dlp_content_manager.h" +#include "chrome/browser/ash/policy/dlp/dlp_content_manager_ash.h" #endif #if BUILDFLAG(IS_CHROMEOS_LACROS) @@ -25,9 +25,9 @@ DlpContentObserver* DlpContentObserver::Get() { if (g_testing_dlp_content_observer) return g_testing_dlp_content_observer; - // Initializes DlpContentManager(Lacros) if needed. + // Initializes DlpContentManager(Ash/Lacros) if needed. #if BUILDFLAG(IS_CHROMEOS_ASH) - return DlpContentManager::Get(); + return DlpContentManagerAsh::Get(); #else return DlpContentManagerLacros::Get(); #endif diff --git a/chrome/browser/extensions/api/tabs/tabs_api_unittest.cc b/chrome/browser/extensions/api/tabs/tabs_api_unittest.cc index 07c32b7eae8f15..78f610f3c4705c 100644 --- a/chrome/browser/extensions/api/tabs/tabs_api_unittest.cc +++ b/chrome/browser/extensions/api/tabs/tabs_api_unittest.cc @@ -39,7 +39,7 @@ #if BUILDFLAG(IS_CHROMEOS_ASH) #include "ash/test/ash_test_helper.h" #include "ash/test/test_window_builder.h" -#include "chrome/browser/ash/policy/dlp/mock_dlp_content_manager.h" +#include "chrome/browser/ash/policy/dlp/mock_dlp_content_manager_ash.h" #include "chrome/browser/ui/ash/window_pin_util.h" #endif @@ -1208,8 +1208,8 @@ TEST_F(TabsApiUnitTest, ScreenshotsRestricted) { web_contents_tester->NavigateAndCommit(kGoogle); // Setup Data Leak Prevention restriction. - policy::MockDlpContentManager mock_dlp_content_manager; - policy::ScopedDlpContentManagerForTesting scoped_dlp_content_manager_( + policy::MockDlpContentManagerAsh mock_dlp_content_manager; + policy::ScopedDlpContentManagerAshForTesting scoped_dlp_content_manager_( &mock_dlp_content_manager); EXPECT_CALL(mock_dlp_content_manager, IsScreenshotApiRestricted(testing::_)) .Times(1) diff --git a/chrome/browser/extensions/api/tabs/tabs_util_ash.cc b/chrome/browser/extensions/api/tabs/tabs_util_ash.cc index b33113e4663115..c81be5620c56f6 100644 --- a/chrome/browser/extensions/api/tabs/tabs_util_ash.cc +++ b/chrome/browser/extensions/api/tabs/tabs_util_ash.cc @@ -4,7 +4,7 @@ #include "chrome/browser/extensions/api/tabs/tabs_util.h" -#include "chrome/browser/ash/policy/dlp/dlp_content_manager.h" +#include "chrome/browser/ash/policy/dlp/dlp_content_manager_ash.h" #include "chrome/browser/ui/ash/capture_mode/chrome_capture_mode_delegate.h" #include "chrome/browser/ui/ash/window_pin_util.h" #include "chrome/browser/ui/browser.h" @@ -36,7 +36,7 @@ void SetLockedFullscreenState(Browser* browser, bool pinned) { } bool IsScreenshotRestricted(content::WebContents* web_contents) { - return policy::DlpContentManager::Get()->IsScreenshotApiRestricted( + return policy::DlpContentManagerAsh::Get()->IsScreenshotApiRestricted( ScreenshotArea::CreateForWindow(web_contents->GetNativeView())); } diff --git a/chrome/browser/media/webrtc/desktop_capture_access_handler.cc b/chrome/browser/media/webrtc/desktop_capture_access_handler.cc index c5123e61a3bff2..f41ac9b8159d15 100644 --- a/chrome/browser/media/webrtc/desktop_capture_access_handler.cc +++ b/chrome/browser/media/webrtc/desktop_capture_access_handler.cc @@ -56,7 +56,7 @@ #if BUILDFLAG(IS_CHROMEOS_ASH) #include "ash/shell.h" -#include "chrome/browser/ash/policy/dlp/dlp_content_manager.h" +#include "chrome/browser/ash/policy/dlp/dlp_content_manager_ash.h" #include "ui/base/ui_base_features.h" #endif // BUILDFLAG(IS_CHROMEOS_ASH) @@ -234,7 +234,8 @@ void DesktopCaptureAccessHandler::ProcessScreenCaptureAccessRequest( primary_root_window_for_testing_ ? primary_root_window_for_testing_ : ash::Shell::Get()->GetPrimaryRootWindow()); - if (policy::DlpContentManager::Get()->IsScreenCaptureRestricted(screen_id)) { + if (policy::DlpContentManagerAsh::Get()->IsScreenCaptureRestricted( + screen_id)) { std::move(callback).Run( blink::MediaStreamDevices(), blink::mojom::MediaStreamRequestResult::PERMISSION_DENIED, nullptr); @@ -424,7 +425,8 @@ void DesktopCaptureAccessHandler::HandleRequest( } #if BUILDFLAG(IS_CHROMEOS_ASH) { - if (policy::DlpContentManager::Get()->IsScreenCaptureRestricted(media_id)) { + if (policy::DlpContentManagerAsh::Get()->IsScreenCaptureRestricted( + media_id)) { std::move(callback).Run( blink::MediaStreamDevices(), blink::mojom::MediaStreamRequestResult::PERMISSION_DENIED, nullptr); @@ -613,7 +615,8 @@ void DesktopCaptureAccessHandler::OnPickerDialogResults( } #if BUILDFLAG(IS_CHROMEOS_ASH) - if (policy::DlpContentManager::Get()->IsScreenCaptureRestricted(media_id)) { + if (policy::DlpContentManagerAsh::Get()->IsScreenCaptureRestricted( + media_id)) { std::move(pending_request.callback) .Run(blink::MediaStreamDevices(), blink::mojom::MediaStreamRequestResult::PERMISSION_DENIED, diff --git a/chrome/browser/media/webrtc/desktop_capture_access_handler_unittest.cc b/chrome/browser/media/webrtc/desktop_capture_access_handler_unittest.cc index e44ebcc46f548c..9317fb466d33fb 100644 --- a/chrome/browser/media/webrtc/desktop_capture_access_handler_unittest.cc +++ b/chrome/browser/media/webrtc/desktop_capture_access_handler_unittest.cc @@ -32,7 +32,7 @@ #include "third_party/blink/public/mojom/mediastream/media_stream.mojom-shared.h" #if BUILDFLAG(IS_CHROMEOS_ASH) -#include "chrome/browser/ash/policy/dlp/mock_dlp_content_manager.h" +#include "chrome/browser/ash/policy/dlp/mock_dlp_content_manager_ash.h" #include "ui/aura/window.h" #endif @@ -384,8 +384,8 @@ TEST_F(DesktopCaptureAccessHandlerTest, ScreenCaptureAccessSuccess) { #if BUILDFLAG(IS_CHROMEOS_ASH) TEST_F(DesktopCaptureAccessHandlerTest, ScreenCaptureAccessDlpRestricted) { // Setup Data Leak Prevention restriction. - policy::MockDlpContentManager mock_dlp_content_manager; - policy::ScopedDlpContentManagerForTesting scoped_dlp_content_manager( + policy::MockDlpContentManagerAsh mock_dlp_content_manager; + policy::ScopedDlpContentManagerAshForTesting scoped_dlp_content_manager( &mock_dlp_content_manager); EXPECT_CALL(mock_dlp_content_manager, IsScreenCaptureRestricted(testing::_)) .Times(1) @@ -416,8 +416,8 @@ TEST_F(DesktopCaptureAccessHandlerTest, ScreenCaptureAccessDlpRestricted) { TEST_F(DesktopCaptureAccessHandlerTest, GenerateStreamDlpRestricted) { // Setup Data Leak Prevention restriction. - policy::MockDlpContentManager mock_dlp_content_manager; - policy::ScopedDlpContentManagerForTesting scoped_dlp_content_manager( + policy::MockDlpContentManagerAsh mock_dlp_content_manager; + policy::ScopedDlpContentManagerAshForTesting scoped_dlp_content_manager( &mock_dlp_content_manager); EXPECT_CALL(mock_dlp_content_manager, IsScreenCaptureRestricted(testing::_)) .Times(1) @@ -445,8 +445,8 @@ TEST_F(DesktopCaptureAccessHandlerTest, GenerateStreamDlpRestricted) { TEST_F(DesktopCaptureAccessHandlerTest, ChangeSourceDlpRestricted) { // Setup Data Leak Prevention restriction. - policy::MockDlpContentManager mock_dlp_content_manager; - policy::ScopedDlpContentManagerForTesting scoped_dlp_content_manager( + policy::MockDlpContentManagerAsh mock_dlp_content_manager; + policy::ScopedDlpContentManagerAshForTesting scoped_dlp_content_manager( &mock_dlp_content_manager); EXPECT_CALL(mock_dlp_content_manager, IsScreenCaptureRestricted(testing::_)) .Times(1) diff --git a/chrome/browser/media/webrtc/display_media_access_handler.cc b/chrome/browser/media/webrtc/display_media_access_handler.cc index eaae9d4acfa0c3..6625771d00a216 100644 --- a/chrome/browser/media/webrtc/display_media_access_handler.cc +++ b/chrome/browser/media/webrtc/display_media_access_handler.cc @@ -37,7 +37,7 @@ #include "third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom.h" #if BUILDFLAG(IS_CHROMEOS_ASH) -#include "chrome/browser/ash/policy/dlp/dlp_content_manager.h" +#include "chrome/browser/ash/policy/dlp/dlp_content_manager_ash.h" #endif // BUILDFLAG(IS_CHROMEOS_ASH) #if defined(OS_MAC) @@ -440,7 +440,7 @@ void DisplayMediaAccessHandler::OnDisplaySurfaceSelected( #if BUILDFLAG(IS_CHROMEOS_ASH) // Check Data Leak Prevention restrictions on Chrome. - policy::DlpContentManager::Get()->CheckScreenShareRestriction( + policy::DlpContentManagerAsh::Get()->CheckScreenShareRestriction( media_id, GetApplicationTitle(web_contents), base::BindOnce(&DisplayMediaAccessHandler::OnDlpRestrictionChecked, base::Unretained(this), web_contents, media_id)); diff --git a/chrome/browser/media/webrtc/display_media_access_handler_unittest.cc b/chrome/browser/media/webrtc/display_media_access_handler_unittest.cc index 2593c9e7731e0f..6c7962af9983af 100644 --- a/chrome/browser/media/webrtc/display_media_access_handler_unittest.cc +++ b/chrome/browser/media/webrtc/display_media_access_handler_unittest.cc @@ -31,7 +31,7 @@ #endif #if BUILDFLAG(IS_CHROMEOS_ASH) -#include "chrome/browser/ash/policy/dlp/mock_dlp_content_manager.h" +#include "chrome/browser/ash/policy/dlp/mock_dlp_content_manager_ash.h" #endif class DisplayMediaAccessHandlerTest : public ChromeRenderViewHostTestHarness { @@ -258,8 +258,8 @@ TEST_F(DisplayMediaAccessHandlerTest, DlpRestricted) { content::DesktopMediaID::kFakeId); // Setup Data Leak Prevention restriction. - policy::MockDlpContentManager mock_dlp_content_manager; - policy::ScopedDlpContentManagerForTesting scoped_dlp_content_manager( + policy::MockDlpContentManagerAsh mock_dlp_content_manager; + policy::ScopedDlpContentManagerAshForTesting scoped_dlp_content_manager( &mock_dlp_content_manager); EXPECT_CALL(mock_dlp_content_manager, CheckScreenShareRestriction) .WillOnce([](const content::DesktopMediaID& media_id, @@ -513,8 +513,8 @@ TEST_F(DisplayMediaAccessHandlerTest, ChangeSourceDlpRestricted) { content::DesktopMediaID::kNullId, GetWebContentsMediaCaptureId()); // Setup Data Leak Prevention restriction. - policy::MockDlpContentManager mock_dlp_content_manager; - policy::ScopedDlpContentManagerForTesting scoped_dlp_content_manager_( + policy::MockDlpContentManagerAsh mock_dlp_content_manager; + policy::ScopedDlpContentManagerAshForTesting scoped_dlp_content_manager_( &mock_dlp_content_manager); EXPECT_CALL(mock_dlp_content_manager, CheckScreenShareRestriction) .WillOnce([](const content::DesktopMediaID& media_id, diff --git a/chrome/browser/media/webrtc/media_stream_capture_indicator.cc b/chrome/browser/media/webrtc/media_stream_capture_indicator.cc index aa44e5bdc7890f..9eea99c487e114 100644 --- a/chrome/browser/media/webrtc/media_stream_capture_indicator.cc +++ b/chrome/browser/media/webrtc/media_stream_capture_indicator.cc @@ -47,7 +47,7 @@ #endif #if BUILDFLAG(IS_CHROMEOS_ASH) -#include "chrome/browser/ash/policy/dlp/dlp_content_manager.h" +#include "chrome/browser/ash/policy/dlp/dlp_content_manager_ash.h" #endif using content::BrowserThread; @@ -240,7 +240,7 @@ class MediaStreamCaptureIndicator::UIDelegate : public content::MediaStreamUI { } #if BUILDFLAG(IS_CHROMEOS_ASH) - policy::DlpContentManager::Get()->OnScreenCaptureStarted( + policy::DlpContentManagerAsh::Get()->OnScreenCaptureStarted( label, screen_capture_ids, application_title_, state_change_callback); #endif @@ -256,7 +256,8 @@ class MediaStreamCaptureIndicator::UIDelegate : public content::MediaStreamUI { void OnDeviceStopped(const std::string& label, const content::DesktopMediaID& media_id) override { #if BUILDFLAG(IS_CHROMEOS_ASH) - policy::DlpContentManager::Get()->OnScreenCaptureStopped(label, media_id); + policy::DlpContentManagerAsh::Get()->OnScreenCaptureStopped(label, + media_id); #endif } diff --git a/chrome/browser/media/webrtc/tab_capture_access_handler.cc b/chrome/browser/media/webrtc/tab_capture_access_handler.cc index 03de8535c43353..771c6125598b39 100644 --- a/chrome/browser/media/webrtc/tab_capture_access_handler.cc +++ b/chrome/browser/media/webrtc/tab_capture_access_handler.cc @@ -21,6 +21,10 @@ #include "extensions/common/permissions/permissions_data.h" #include "third_party/blink/public/mojom/mediastream/media_stream.mojom-shared.h" +#if BUILDFLAG(IS_CHROMEOS_ASH) +#include "chrome/browser/ash/policy/dlp/dlp_content_manager_ash.h" +#endif // BUILDFLAG(IS_CHROMEOS_ASH) + namespace { // This helper class is designed to live as long as the capture, and is used // when no other MediaStreamUI object is used. If the capture violates the @@ -58,10 +62,6 @@ class SameOriginPolicyUI : public MediaStreamUI { }; } // namespace -#if BUILDFLAG(IS_CHROMEOS_ASH) -#include "chrome/browser/ash/policy/dlp/dlp_content_manager.h" -#endif // BUILDFLAG(IS_CHROMEOS_ASH) - TabCaptureAccessHandler::TabCaptureAccessHandler() = default; TabCaptureAccessHandler::~TabCaptureAccessHandler() = default; @@ -127,7 +127,8 @@ void TabCaptureAccessHandler::HandleRequest( content::DesktopMediaID::TYPE_WEB_CONTENTS, /*id=*/0, content::WebContentsMediaCaptureId(request.render_process_id, request.render_frame_id)); - if (policy::DlpContentManager::Get()->IsScreenCaptureRestricted(media_id)) { + if (policy::DlpContentManagerAsh::Get()->IsScreenCaptureRestricted( + media_id)) { std::move(callback).Run( devices, blink::mojom::MediaStreamRequestResult::PERMISSION_DENIED, std::move(ui)); diff --git a/chrome/browser/media/webrtc/tab_capture_access_handler_unittest.cc b/chrome/browser/media/webrtc/tab_capture_access_handler_unittest.cc index 9434a04b6d1ffe..ebf9b884756a8b 100644 --- a/chrome/browser/media/webrtc/tab_capture_access_handler_unittest.cc +++ b/chrome/browser/media/webrtc/tab_capture_access_handler_unittest.cc @@ -24,7 +24,7 @@ #include "third_party/blink/public/mojom/mediastream/media_stream.mojom-shared.h" #if BUILDFLAG(IS_CHROMEOS_ASH) -#include "chrome/browser/ash/policy/dlp/mock_dlp_content_manager.h" +#include "chrome/browser/ash/policy/dlp/mock_dlp_content_manager_ash.h" #endif class TabCaptureAccessHandlerTest : public ChromeRenderViewHostTestHarness { @@ -110,8 +110,8 @@ TEST_F(TabCaptureAccessHandlerTest, DlpRestricted) { web_contents()->GetMainFrame()->GetRoutingID())); // Setup Data Leak Prevention restriction. - policy::MockDlpContentManager mock_dlp_content_manager; - policy::ScopedDlpContentManagerForTesting scoped_dlp_content_manager_( + policy::MockDlpContentManagerAsh mock_dlp_content_manager; + policy::ScopedDlpContentManagerAshForTesting scoped_dlp_content_manager_( &mock_dlp_content_manager); EXPECT_CALL(mock_dlp_content_manager, IsScreenCaptureRestricted(source)) .Times(1) diff --git a/chrome/browser/media/webrtc/webrtc_getdisplaymedia_browsertest.cc b/chrome/browser/media/webrtc/webrtc_getdisplaymedia_browsertest.cc index f22af2d78f9012..d24c88c488c0e6 100644 --- a/chrome/browser/media/webrtc/webrtc_getdisplaymedia_browsertest.cc +++ b/chrome/browser/media/webrtc/webrtc_getdisplaymedia_browsertest.cc @@ -39,7 +39,7 @@ #endif #if BUILDFLAG(IS_CHROMEOS_ASH) -#include "chrome/browser/ash/policy/dlp/dlp_content_manager_test_helper.h" +#include "chrome/browser/ash/policy/dlp/dlp_content_manager_ash_test_helper.h" #include "chrome/browser/chromeos/policy/dlp/dlp_content_restriction_set.h" #endif @@ -233,7 +233,7 @@ IN_PROC_BROWSER_TEST_P(WebRtcScreenCaptureBrowserTestWithPicker, ScreenCaptureVideoWithDlp) { ASSERT_TRUE(embedded_test_server()->Start()); - policy::DlpContentManagerTestHelper helper; + policy::DlpContentManagerAshTestHelper helper; content::WebContents* tab = OpenTestPageInNewTab(kMainHtmlPage); RunGetDisplayMedia(tab, GetConstraints(/*video=*/true, /*audio=*/false), /*is_fake_ui=*/false, test_config_.accept_this_tab_capture, diff --git a/chrome/browser/printing/print_view_manager.cc b/chrome/browser/printing/print_view_manager.cc index 2dff3ebf4a9a19..bc429817329609 100644 --- a/chrome/browser/printing/print_view_manager.cc +++ b/chrome/browser/printing/print_view_manager.cc @@ -26,7 +26,7 @@ #include "printing/buildflags/buildflags.h" #if BUILDFLAG(IS_CHROMEOS_ASH) -#include "chrome/browser/ash/policy/dlp/dlp_content_manager.h" +#include "chrome/browser/ash/policy/dlp/dlp_content_manager_ash.h" #endif using content::BrowserThread; @@ -194,7 +194,7 @@ void PrintViewManager::RejectPrintPreviewRequestIfRestricted( base::OnceCallback callback) { #if BUILDFLAG(IS_CHROMEOS_ASH) // Don't print DLP restricted content on Chrome OS. - policy::DlpContentManager::Get()->CheckPrintingRestriction( + policy::DlpContentManagerAsh::Get()->CheckPrintingRestriction( web_contents(), std::move(callback)); #else std::move(callback).Run(true); diff --git a/chrome/browser/ui/ash/capture_mode/chrome_capture_mode_delegate.cc b/chrome/browser/ui/ash/capture_mode/chrome_capture_mode_delegate.cc index 9929a615348cc3..e5a4b799fcf919 100644 --- a/chrome/browser/ui/ash/capture_mode/chrome_capture_mode_delegate.cc +++ b/chrome/browser/ui/ash/capture_mode/chrome_capture_mode_delegate.cc @@ -16,7 +16,7 @@ #include "chrome/browser/apps/app_service/launch_utils.h" #include "chrome/browser/ash/drive/drive_integration_service.h" #include "chrome/browser/ash/file_manager/path_util.h" -#include "chrome/browser/ash/policy/dlp/dlp_content_manager.h" +#include "chrome/browser/ash/policy/dlp/dlp_content_manager_ash.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/download/download_prefs.h" #include "chrome/browser/platform_util.h" @@ -134,12 +134,12 @@ bool ChromeCaptureModeDelegate::Uses24HourFormat() const { } bool ChromeCaptureModeDelegate::IsCaptureModeInitRestrictedByDlp() const { - return policy::DlpContentManager::Get()->IsCaptureModeInitRestricted(); + return policy::DlpContentManagerAsh::Get()->IsCaptureModeInitRestricted(); } void ChromeCaptureModeDelegate::CheckCaptureModeInitRestrictionByDlp( ash::OnCaptureModeDlpRestrictionChecked callback) { - policy::DlpContentManager::Get()->CheckCaptureModeInitRestriction( + policy::DlpContentManagerAsh::Get()->CheckCaptureModeInitRestriction( std::move(callback)); } @@ -148,14 +148,14 @@ void ChromeCaptureModeDelegate::CheckCaptureOperationRestrictionByDlp( const gfx::Rect& bounds, ash::OnCaptureModeDlpRestrictionChecked callback) { const ScreenshotArea area = ConvertToScreenshotArea(window, bounds); - policy::DlpContentManager::Get()->CheckScreenshotRestriction( + policy::DlpContentManagerAsh::Get()->CheckScreenshotRestriction( area, std::move(callback)); } bool ChromeCaptureModeDelegate::IsCaptureAllowedByDlp( const aura::Window* window, const gfx::Rect& bounds) const { - return !policy::DlpContentManager::Get()->IsScreenshotRestricted( + return !policy::DlpContentManagerAsh::Get()->IsScreenshotRestricted( ConvertToScreenshotArea(window, bounds)); } @@ -167,18 +167,18 @@ void ChromeCaptureModeDelegate::StartObservingRestrictedContent( const aura::Window* window, const gfx::Rect& bounds, base::OnceClosure stop_callback) { - // The order here matters, since DlpContentManager::OnVideoCaptureStarted() + // The order here matters, since DlpContentManagerAsh::OnVideoCaptureStarted() // may call InterruptVideoRecordingIfAny() right away, so the callback must be // set first. interrupt_video_recording_callback_ = std::move(stop_callback); - policy::DlpContentManager::Get()->OnVideoCaptureStarted( + policy::DlpContentManagerAsh::Get()->OnVideoCaptureStarted( ConvertToScreenshotArea(window, bounds)); } void ChromeCaptureModeDelegate::StopObservingRestrictedContent( ash::OnCaptureModeDlpRestrictionChecked callback) { interrupt_video_recording_callback_.Reset(); - policy::DlpContentManager::Get()->CheckStoppedVideoCapture( + policy::DlpContentManagerAsh::Get()->CheckStoppedVideoCapture( std::move(callback)); } diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index daca7868be8c2a..da7a68bb5daa9b 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn @@ -3331,9 +3331,9 @@ if (!is_android && !is_fuchsia) { "../browser/ash/policy/display/device_display_cros_browser_test.h", "../browser/ash/policy/display/display_resolution_handler_browsertest.cc", "../browser/ash/policy/display/display_rotation_default_handler_browsertest.cc", - "../browser/ash/policy/dlp/dlp_content_manager_browsertest.cc", - "../browser/ash/policy/dlp/mock_dlp_content_manager.cc", - "../browser/ash/policy/dlp/mock_dlp_content_manager.h", + "../browser/ash/policy/dlp/dlp_content_manager_ash_browsertest.cc", + "../browser/ash/policy/dlp/mock_dlp_content_manager_ash.cc", + "../browser/ash/policy/dlp/mock_dlp_content_manager_ash.h", "../browser/ash/policy/external_data/device_cloud_external_data_policy_observer_browsertest.cc", "../browser/ash/policy/external_data/device_policy_cloud_external_data_manager_browsertest.cc", "../browser/ash/policy/external_data/handlers/device_wilco_dtc_configuration_external_data_handler_browsertest.cc", From 4184d58341ce6fbe12a7535e4d39419c5c79ae4a Mon Sep 17 00:00:00 2001 From: Haiyang Pan Date: Tue, 14 Dec 2021 15:06:12 +0000 Subject: [PATCH 48/51] Update API level for Android-12L from Sv2 to 32 for sdk-packager The API level has been changed in sdkmanager. Bug: 1264159 Change-Id: I2de390608303057c7e5d57c54ee8898da2efa979 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3335297 Auto-Submit: Haiyang Pan Reviewed-by: Peter Wen Commit-Queue: Peter Wen Cr-Commit-Position: refs/heads/main@{#951498} --- infra/config/generated/luci/cr-buildbucket.cfg | 8 ++++---- infra/config/subprojects/chromium/ci.star | 10 ++++------ .../google_apis/x86_64.yaml | 6 +++--- .../google_apis_playstore/x86_64.yaml | 6 +++--- 4 files changed, 14 insertions(+), 16 deletions(-) rename third_party/android_sdk/cipd/system_images/{android-Sv2 => android-32}/google_apis/x86_64.yaml (64%) rename third_party/android_sdk/cipd/system_images/{android-Sv2 => android-32}/google_apis_playstore/x86_64.yaml (60%) diff --git a/infra/config/generated/luci/cr-buildbucket.cfg b/infra/config/generated/luci/cr-buildbucket.cfg index 5ad54662e4da5e..d8160714666e2e 100644 --- a/infra/config/generated/luci/cr-buildbucket.cfg +++ b/infra/config/generated/luci/cr-buildbucket.cfg @@ -27446,12 +27446,12 @@ buckets { ' "sdk_package_name": "system-images;android-31;google_apis_playstore;x86_64"' ' },' ' {' - ' "cipd_yaml": "third_party/android_sdk/cipd/system_images/android-Sv2/google_apis/x86_64.yaml",' - ' "sdk_package_name": "system-images;android-Sv2;google_apis;x86_64"' + ' "cipd_yaml": "third_party/android_sdk/cipd/system_images/android-32/google_apis/x86_64.yaml",' + ' "sdk_package_name": "system-images;android-32;google_apis;x86_64"' ' },' ' {' - ' "cipd_yaml": "third_party/android_sdk/cipd/system_images/android-Sv2/google_apis_playstore/x86_64.yaml",' - ' "sdk_package_name": "system-images;android-Sv2;google_apis_playstore;x86_64"' + ' "cipd_yaml": "third_party/android_sdk/cipd/system_images/android-32/google_apis_playstore/x86_64.yaml",' + ' "sdk_package_name": "system-images;android-32;google_apis_playstore;x86_64"' ' }' ' ],' ' "recipe": "android/sdk_packager"' diff --git a/infra/config/subprojects/chromium/ci.star b/infra/config/subprojects/chromium/ci.star index 6a9cb0e7e0913a..9f4ba0d2e56fd8 100644 --- a/infra/config/subprojects/chromium/ci.star +++ b/infra/config/subprojects/chromium/ci.star @@ -2399,15 +2399,13 @@ ci.cipd_builder( "sdk_package_name": "system-images;android-31;google_apis_playstore;x86_64", "cipd_yaml": "third_party/android_sdk/cipd/system_images/android-31/google_apis_playstore/x86_64.yaml", }, - # Preview system images for Android 12L. - # Should be updated once it is fully released. { - "sdk_package_name": "system-images;android-Sv2;google_apis;x86_64", - "cipd_yaml": "third_party/android_sdk/cipd/system_images/android-Sv2/google_apis/x86_64.yaml", + "sdk_package_name": "system-images;android-32;google_apis;x86_64", + "cipd_yaml": "third_party/android_sdk/cipd/system_images/android-32/google_apis/x86_64.yaml", }, { - "sdk_package_name": "system-images;android-Sv2;google_apis_playstore;x86_64", - "cipd_yaml": "third_party/android_sdk/cipd/system_images/android-Sv2/google_apis_playstore/x86_64.yaml", + "sdk_package_name": "system-images;android-32;google_apis_playstore;x86_64", + "cipd_yaml": "third_party/android_sdk/cipd/system_images/android-32/google_apis_playstore/x86_64.yaml", }, ], }, diff --git a/third_party/android_sdk/cipd/system_images/android-Sv2/google_apis/x86_64.yaml b/third_party/android_sdk/cipd/system_images/android-32/google_apis/x86_64.yaml similarity index 64% rename from third_party/android_sdk/cipd/system_images/android-Sv2/google_apis/x86_64.yaml rename to third_party/android_sdk/cipd/system_images/android-32/google_apis/x86_64.yaml index 0f29bd0e234ad7..5e8f6637adf9bb 100644 --- a/third_party/android_sdk/cipd/system_images/android-Sv2/google_apis/x86_64.yaml +++ b/third_party/android_sdk/cipd/system_images/android-32/google_apis/x86_64.yaml @@ -2,8 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -package: chromium/third_party/android_sdk/public/system-images/android-sv2/google_apis/x86_64 -description: system_images;android-Sv2;google_apis;x86_64 +package: chromium/third_party/android_sdk/public/system-images/android-32/google_apis/x86_64 +description: system_images;android-32;google_apis;x86_64 root: ../../../../public/ data: - - dir: system-images/android-Sv2/google_apis/x86_64 + - dir: system-images/android-32/google_apis/x86_64 diff --git a/third_party/android_sdk/cipd/system_images/android-Sv2/google_apis_playstore/x86_64.yaml b/third_party/android_sdk/cipd/system_images/android-32/google_apis_playstore/x86_64.yaml similarity index 60% rename from third_party/android_sdk/cipd/system_images/android-Sv2/google_apis_playstore/x86_64.yaml rename to third_party/android_sdk/cipd/system_images/android-32/google_apis_playstore/x86_64.yaml index a19de82a238006..d5d37314430ed6 100644 --- a/third_party/android_sdk/cipd/system_images/android-Sv2/google_apis_playstore/x86_64.yaml +++ b/third_party/android_sdk/cipd/system_images/android-32/google_apis_playstore/x86_64.yaml @@ -2,8 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -package: chromium/third_party/android_sdk/public/system-images/android-sv2/google_apis_playstore/x86_64 -description: system_images;android-Sv2;google_apis_playstore;x86_64 +package: chromium/third_party/android_sdk/public/system-images/android-32/google_apis_playstore/x86_64 +description: system_images;android-32;google_apis_playstore;x86_64 root: ../../../../public/ data: - - dir: system-images/android-Sv2/google_apis_playstore/x86_64 + - dir: system-images/android-32/google_apis_playstore/x86_64 From 67725fd5eba85a8caa9d7d3fe66467c325df33fe Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Tue, 14 Dec 2021 15:06:34 +0000 Subject: [PATCH 49/51] Android: Ensure multiprocessing pool is close in jni_registration_generator.py Should have been in a try/finally. With python3, we can now just use a "with" block. Change-Id: Iffa2383bfe8c1dfe50f31d58ee03390851fa0513 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3330114 Auto-Submit: Andrew Grieve Reviewed-by: Peter Wen Commit-Queue: Peter Wen Cr-Commit-Position: refs/heads/main@{#951499} --- .../jni_generator/jni_registration_generator.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/base/android/jni_generator/jni_registration_generator.py b/base/android/jni_generator/jni_registration_generator.py index a21b89bf2d3086..528eada6dbe51f 100755 --- a/base/android/jni_generator/jni_registration_generator.py +++ b/base/android/jni_generator/jni_registration_generator.py @@ -57,15 +57,13 @@ def _Generate(java_file_paths, """ # Without multiprocessing, script takes ~13 seconds for chrome_public_apk # on a z620. With multiprocessing, takes ~2 seconds. - pool = multiprocessing.Pool() - results = [] - for d in pool.imap_unordered( - functools.partial(_DictForPath, use_proxy_hash=proxy_opts.use_hash), - java_file_paths): - if d: - results.append(d) - pool.close() + with multiprocessing.Pool() as pool: + for d in pool.imap_unordered( + functools.partial(_DictForPath, use_proxy_hash=proxy_opts.use_hash), + java_file_paths): + if d: + results.append(d) # Sort to make output deterministic. results.sort(key=lambda d: d['FULL_CLASS_NAME']) From 1252f7e9c9b1cc63aa1da7089a84f37b964c4081 Mon Sep 17 00:00:00 2001 From: chromium-autoroll Date: Tue, 14 Dec 2021 15:19:15 +0000 Subject: [PATCH 50/51] Roll Chrome Win32 PGO Profile Roll Chrome Win32 PGO profile from chrome-win32-main-1639472251-55695819d100cc1e6d371b12dbe33261804b0154.profdata to chrome-win32-main-1639483122-6c64e4735696edd79f94e428f8b51a0056079d88.profdata If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/pgo-win32-chromium Please CC pgo-profile-sheriffs@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Chromium main branch: https://bugs.chromium.org/p/chromium/issues/entry To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md Cq-Include-Trybots: luci.chrome.try:win-chrome Tbr: pgo-profile-sheriffs@google.com Change-Id: I673592025e4a40810b0b066ff5ffd5b21e5c7757 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3338932 Commit-Queue: chromium-autoroll Bot-Commit: chromium-autoroll Cr-Commit-Position: refs/heads/main@{#951500} --- chrome/build/win32.pgo.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/build/win32.pgo.txt b/chrome/build/win32.pgo.txt index d2a4c3e645e709..c1d4c58849f2dc 100644 --- a/chrome/build/win32.pgo.txt +++ b/chrome/build/win32.pgo.txt @@ -1 +1 @@ -chrome-win32-main-1639472251-55695819d100cc1e6d371b12dbe33261804b0154.profdata +chrome-win32-main-1639483122-6c64e4735696edd79f94e428f8b51a0056079d88.profdata From fe4e8ad0b185ad3ee85158243221c0d894f72b5a Mon Sep 17 00:00:00 2001 From: Joshua Pawlicki Date: Tue, 14 Dec 2021 15:21:52 +0000 Subject: [PATCH 51/51] Updater: eliminate sleeps in integration tests. Fixed: 1217765 Change-Id: Ifa06cdb31b26f7c6332d95f877957c39ffb000b7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3330675 Reviewed-by: Sorin Jianu Commit-Queue: Joshua Pawlicki Cr-Commit-Position: refs/heads/main@{#951501} --- .../updater/test/integration_test_commands.h | 2 +- .../test/integration_test_commands_system.cc | 4 +- .../test/integration_test_commands_user.cc | 4 +- chrome/updater/test/integration_tests.cc | 44 ++++++++----------- chrome/updater/test/integration_tests_impl.cc | 12 ----- chrome/updater/test/integration_tests_impl.h | 7 +-- .../updater/test/integration_tests_linux.cc | 2 +- chrome/updater/test/integration_tests_mac.mm | 2 +- chrome/updater/test/integration_tests_win.cc | 10 ++--- 9 files changed, 30 insertions(+), 57 deletions(-) diff --git a/chrome/updater/test/integration_test_commands.h b/chrome/updater/test/integration_test_commands.h index 29090b63ab8620..8a9464dab05f6d 100644 --- a/chrome/updater/test/integration_test_commands.h +++ b/chrome/updater/test/integration_test_commands.h @@ -60,7 +60,7 @@ class IntegrationTestCommands virtual void UpdateAll() const = 0; virtual void PrintLog() const = 0; virtual base::FilePath GetDifferentUserPath() const = 0; - virtual void WaitForServerExit() const = 0; + virtual void WaitForUpdaterExit() const = 0; #if defined(OS_WIN) virtual void ExpectInterfacesRegistered() const = 0; virtual void ExpectLegacyUpdate3WebSucceeds( diff --git a/chrome/updater/test/integration_test_commands_system.cc b/chrome/updater/test/integration_test_commands_system.cc index 16ebb5fe6b7eef..b016a44ed60d19 100644 --- a/chrome/updater/test/integration_test_commands_system.cc +++ b/chrome/updater/test/integration_test_commands_system.cc @@ -146,8 +146,8 @@ class IntegrationTestCommandsSystem : public IntegrationTestCommands { RunCommand("register_app", {Param("app_id", app_id)}); } - void WaitForServerExit() const override { - updater::test::WaitForServerExit(updater_scope_); + void WaitForUpdaterExit() const override { + updater::test::WaitForUpdaterExit(updater_scope_); } #if defined(OS_WIN) diff --git a/chrome/updater/test/integration_test_commands_user.cc b/chrome/updater/test/integration_test_commands_user.cc index cc1997a6888b6d..c70a01d53c992a 100644 --- a/chrome/updater/test/integration_test_commands_user.cc +++ b/chrome/updater/test/integration_test_commands_user.cc @@ -135,8 +135,8 @@ class IntegrationTestCommandsUser : public IntegrationTestCommands { updater::test::RegisterApp(updater_scope_, app_id); } - void WaitForServerExit() const override { - updater::test::WaitForServerExit(updater_scope_); + void WaitForUpdaterExit() const override { + updater::test::WaitForUpdaterExit(updater_scope_); } #if defined(OS_WIN) diff --git a/chrome/updater/test/integration_tests.cc b/chrome/updater/test/integration_tests.cc index f9fbc75b9373fb..be20f5ca4d1570 100644 --- a/chrome/updater/test/integration_tests.cc +++ b/chrome/updater/test/integration_tests.cc @@ -120,6 +120,7 @@ class IntegrationTest : public ::testing::Test { PrintLog(); CopyLog(); test_commands_->Uninstall(); + WaitForUpdaterExit(); } void ExpectCandidateUninstalled() { @@ -211,7 +212,7 @@ class IntegrationTest : public ::testing::Test { return test_commands_->GetDifferentUserPath(); } - void WaitForServerExit() { test_commands_->WaitForServerExit(); } + void WaitForUpdaterExit() { test_commands_->WaitForUpdaterExit(); } void SetUpTestService() { #if defined(OS_WIN) @@ -265,7 +266,7 @@ class IntegrationTest : public ::testing::Test { TEST_F(IntegrationTest, InstallUninstall) { Install(); - WaitForServerExit(); + WaitForUpdaterExit(); ExpectInstalled(); ExpectVersionActive(kUpdaterVersion); ExpectActiveUpdater(); @@ -281,16 +282,12 @@ TEST_F(IntegrationTest, InstallUninstall) { TEST_F(IntegrationTest, SelfUninstallOutdatedUpdater) { Install(); ExpectInstalled(); - SleepFor(2); + WaitForUpdaterExit(); SetupFakeUpdaterHigherVersion(); ExpectVersionNotActive(kUpdaterVersion); RunWake(0); - - // The mac server will remain active for 10 seconds after it replies to the - // wake client, then shut down and uninstall itself. Sleep to wait for this - // to happen. - SleepFor(11); + WaitForUpdaterExit(); ExpectCandidateUninstalled(); // The candidate uninstall should not have altered global prefs. @@ -306,7 +303,7 @@ TEST_F(IntegrationTest, QualifyUpdater) { ExpectRegistrationEvent(&test_server, kUpdaterAppId); Install(); ExpectInstalled(); - WaitForServerExit(); + WaitForUpdaterExit(); SetupFakeUpdaterLowerVersion(); ExpectVersionNotActive(kUpdaterVersion); @@ -315,7 +312,7 @@ TEST_F(IntegrationTest, QualifyUpdater) { base::Version("0.2")); RunWake(0); - WaitForServerExit(); + WaitForUpdaterExit(); // This instance is now qualified and should activate itself and check itself // for updates on the next check. @@ -324,7 +321,7 @@ TEST_F(IntegrationTest, QualifyUpdater) { base::StringPrintf(".*%s.*", kUpdaterAppId))}, ")]}'\n"); RunWake(0); - WaitForServerExit(); + WaitForUpdaterExit(); ExpectVersionActive(kUpdaterVersion); Uninstall(); @@ -341,7 +338,7 @@ TEST_F(IntegrationTest, SelfUpdate) { base::Version(kUpdaterVersion), next_version); RunWake(0); - WaitForServerExit(); + WaitForUpdaterExit(); ExpectAppVersion(kUpdaterAppId, next_version); Uninstall(); @@ -404,7 +401,7 @@ TEST_F(IntegrationTest, UpdateApp) { base::Version v2("2"); ExpectUpdateSequence(&test_server, kAppId, v1, v2); Update(kAppId); - WaitForServerExit(); + WaitForUpdaterExit(); ExpectAppVersion(kAppId, v2); Uninstall(); @@ -502,8 +499,7 @@ TEST_F(IntegrationTest, UninstallCmdLine) { ExpectActiveUpdater(); RunUninstallCmdLine(); - WaitForServerExit(); - SleepFor(2); + WaitForUpdaterExit(); ExpectClean(); } #endif // defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) @@ -514,14 +510,14 @@ TEST_F(IntegrationTest, UnregisterUninstalledApp) { RegisterApp("test1"); RegisterApp("test2"); - WaitForServerExit(); + WaitForUpdaterExit(); ExpectVersionActive(kUpdaterVersion); ExpectActiveUpdater(); SetExistenceCheckerPath("test1", base::FilePath(FILE_PATH_LITERAL("NONE"))); RunWake(0); - WaitForServerExit(); + WaitForUpdaterExit(); ExpectInstalled(); ExpectAppUnregisteredExistenceCheckerPath("test1"); @@ -530,12 +526,11 @@ TEST_F(IntegrationTest, UnregisterUninstalledApp) { TEST_F(IntegrationTest, UninstallIfMaxServerWakesBeforeRegistrationExceeded) { Install(); - WaitForServerExit(); + WaitForUpdaterExit(); ExpectInstalled(); SetServerStarts(24); RunWake(0); - WaitForServerExit(); - SleepFor(2); + WaitForUpdaterExit(); ExpectClean(); } @@ -543,17 +538,16 @@ TEST_F(IntegrationTest, UninstallUpdaterWhenAllAppsUninstalled) { Install(); RegisterApp("test1"); ExpectInstalled(); - WaitForServerExit(); + WaitForUpdaterExit(); SetServerStarts(24); RunWake(0); - WaitForServerExit(); + WaitForUpdaterExit(); ExpectInstalled(); ExpectVersionActive(kUpdaterVersion); ExpectActiveUpdater(); SetExistenceCheckerPath("test1", base::FilePath(FILE_PATH_LITERAL("NONE"))); RunWake(0); - WaitForServerExit(); - SleepFor(2); + WaitForUpdaterExit(); ExpectClean(); } @@ -572,7 +566,7 @@ TEST_F(IntegrationTest, UnregisterUnownedApp) { SetExistenceCheckerPath("test1", GetDifferentUserPath()); RunWake(0); - WaitForServerExit(); + WaitForUpdaterExit(); ExpectAppUnregisteredExistenceCheckerPath("test1"); diff --git a/chrome/updater/test/integration_tests_impl.cc b/chrome/updater/test/integration_tests_impl.cc index 9ca520761f83a8..06e90b0abee0c1 100644 --- a/chrome/updater/test/integration_tests_impl.cc +++ b/chrome/updater/test/integration_tests_impl.cc @@ -313,18 +313,6 @@ bool Run(UpdaterScope scope, base::CommandLine command_line, int* exit_code) { return process.WaitForExitWithTimeout(base::Seconds(45), exit_code); } -void SleepFor(int seconds) { - VLOG(2) << "Sleeping " << seconds << " seconds..."; - base::WaitableEvent sleep(base::WaitableEvent::ResetPolicy::MANUAL, - base::WaitableEvent::InitialState::NOT_SIGNALED); - base::ThreadPool::PostDelayedTask( - FROM_HERE, {base::MayBlock()}, - base::BindOnce(&base::WaitableEvent::Signal, base::Unretained(&sleep)), - base::Seconds(seconds)); - sleep.Wait(); - VLOG(2) << "Sleep complete."; -} - bool WaitFor(base::RepeatingCallback predicate) { base::TimeTicks deadline = base::TimeTicks::Now() + TestTimeouts::action_max_timeout(); diff --git a/chrome/updater/test/integration_tests_impl.h b/chrome/updater/test/integration_tests_impl.h index dc8c38b043309a..7e5937895a53ac 100644 --- a/chrome/updater/test/integration_tests_impl.h +++ b/chrome/updater/test/integration_tests_impl.h @@ -51,11 +51,6 @@ void EnterTestMode(const GURL& url); // Copies the logs to a location where they can be retrieved by ResultDB. void CopyLog(const base::FilePath& src_dir); -// Sleeps for the given number of seconds. This should be avoided, but in some -// cases surrounding uninstall it is necessary since the processes can exit -// prior to completing the actual uninstallation. -void SleepFor(int seconds); - // Waits for a given predicate to become true, testing it by polling. Returns // true if the predicate becomes true before a timeout, otherwise returns false. bool WaitFor(base::RepeatingCallback predicate); @@ -143,7 +138,7 @@ void ExpectAppVersion(UpdaterScope scope, void RegisterApp(UpdaterScope scope, const std::string& app_id); -void WaitForServerExit(UpdaterScope scope); +void WaitForUpdaterExit(UpdaterScope scope); #if defined(OS_WIN) void ExpectInterfacesRegistered(UpdaterScope scope); diff --git a/chrome/updater/test/integration_tests_linux.cc b/chrome/updater/test/integration_tests_linux.cc index d4fb5b6795dc86..6850c64921d38f 100644 --- a/chrome/updater/test/integration_tests_linux.cc +++ b/chrome/updater/test/integration_tests_linux.cc @@ -27,7 +27,7 @@ absl::optional GetInstalledExecutablePath(UpdaterScope scope) { return absl::nullopt; } -void WaitForServerExit(UpdaterScope scope) { +void WaitForUpdaterExit(UpdaterScope scope) { NOTREACHED(); } diff --git a/chrome/updater/test/integration_tests_mac.mm b/chrome/updater/test/integration_tests_mac.mm index 89aa572bfc6612..4ff231403eab88 100644 --- a/chrome/updater/test/integration_tests_mac.mm +++ b/chrome/updater/test/integration_tests_mac.mm @@ -300,7 +300,7 @@ void ExpectNotActive(UpdaterScope scope, const std::string& app_id) { EXPECT_FALSE(base::PathIsWritable(*path)); } -void WaitForServerExit(UpdaterScope /*scope*/) { +void WaitForUpdaterExit(UpdaterScope /*scope*/) { ASSERT_TRUE(WaitFor(base::BindRepeating([]() { std::string ps_stdout; EXPECT_TRUE(base::GetAppOutput({"ps", "ax", "-o", "command"}, &ps_stdout)); diff --git a/chrome/updater/test/integration_tests_win.cc b/chrome/updater/test/integration_tests_win.cc index e7bbeacb6319ae..1a29f59ffefe53 100644 --- a/chrome/updater/test/integration_tests_win.cc +++ b/chrome/updater/test/integration_tests_win.cc @@ -290,8 +290,8 @@ void CheckInstallation(UpdaterScope scope, // Returns true is any updater process is found running in any session in the // system, regardless of its path. bool IsUpdaterRunning() { - ProcessFilterName filter(kUpdaterProcessName); - return base::ProcessIterator(&filter).NextProcessEntry(); + return IsProcessRunning(kUpdaterProcessName) || + IsProcessRunning(base::UTF8ToWide(kUninstallScript).c_str()); } } // namespace @@ -411,10 +411,6 @@ void Uninstall(UpdaterScope scope) { int exit_code = -1; ASSERT_TRUE(Run(scope, command_line, &exit_code)); EXPECT_EQ(0, exit_code); - - // Uninstallation involves a race with the uninstall.cmd script and the - // process exit. Sleep to allow the script to complete its work. - SleepFor(5); } void SetActive(UpdaterScope /*scope*/, const std::string& id) { @@ -450,7 +446,7 @@ void ExpectNotActive(UpdaterScope /*scope*/, const std::string& id) { // Waits for all updater processes to end, including the server process holding // the prefs lock. -void WaitForServerExit(UpdaterScope /*scope*/) { +void WaitForUpdaterExit(UpdaterScope /*scope*/) { WaitFor(base::BindRepeating([]() { return !IsUpdaterRunning(); })); }