diff --git a/DEPS b/DEPS index d42d72ee8cd644..4a2dd087a89c8b 100644 --- a/DEPS +++ b/DEPS @@ -239,7 +239,7 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling Skia # and whatever else without interference from each other. - 'skia_revision': 'dc60ca197e0280fb2fe82e42321498a0443b408f', + 'skia_revision': 'fec9a3027c9e54b6671769c8d04d07382214c557', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling V8 # and whatever else without interference from each other. @@ -247,7 +247,7 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling ANGLE # and whatever else without interference from each other. - 'angle_revision': '26fa0fe68b928dcf037b0fbd8af07e88d4f91235', + 'angle_revision': '6706799186683dd3733c4610de09d84721aa08c8', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling SwiftShader # and whatever else without interference from each other. @@ -314,7 +314,7 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling devtools-frontend # and whatever else without interference from each other. - 'devtools_frontend_revision': 'd692cac31ffea822377407e775750d9f6a042eba', + 'devtools_frontend_revision': 'de5ebd0ec8b1cce77140041cd80a14d8ec28bdad', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling libprotobuf-mutator # and whatever else without interference from each other. @@ -799,7 +799,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/androidx', - 'version': 'rjqESjGVnqj61OsILGz2zAx9aZu_63YrdoiwrUlJrHoC', + 'version': 'JA8W6XUESiIusRecU6mz7G-zjV6Tk4hlDO5hwQf6i8YC', }, ], 'condition': 'checkout_android', @@ -1038,7 +1038,7 @@ deps = { }, 'src/third_party/depot_tools': - Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + 'fd41e488b72ece0125db83730f298a9e1393bc86', + Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + '168ca4d812a03fc41408c8eb8fdca34083a7a135', 'src/third_party/devtools-frontend/src': Var('chromium_git') + '/devtools/devtools-frontend' + '@' + Var('devtools_frontend_revision'), @@ -1642,7 +1642,7 @@ deps = { Var('chromium_git') + '/external/github.com/gpuweb/cts.git' + '@' + 'c843f8d63c8c17acfbb7d48e09059a581ba779b9', 'src/third_party/webrtc': - Var('webrtc_git') + '/src.git' + '@' + 'd525e2d9f71f02832a8c8d2d63d47b96c16a00fe', + Var('webrtc_git') + '/src.git' + '@' + 'f8e160e1c9f8e805e94be71e2f2da3259dd88b8f', 'src/third_party/libgifcodec': Var('skia_git') + '/libgifcodec' + '@'+ Var('libgifcodec_revision'), @@ -1700,7 +1700,7 @@ deps = { Var('chromium_git') + '/v8/v8.git' + '@' + Var('v8_revision'), 'src-internal': { - 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@cc4f8ef12d745384de360d967ac3f324fdeb8b67', + 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@6d21a3cb937a00f0212b50f7d0744ac830cc654d', 'condition': 'checkout_src_internal', }, diff --git a/android_webview/browser/metrics/aw_metrics_service_client.cc b/android_webview/browser/metrics/aw_metrics_service_client.cc index 00318a96d48722..22804da7dc396b 100644 --- a/android_webview/browser/metrics/aw_metrics_service_client.cc +++ b/android_webview/browser/metrics/aw_metrics_service_client.cc @@ -104,6 +104,25 @@ int AwMetricsServiceClient::GetSampleRatePerMille() const { return kBetaDevCanarySampledInRatePerMille; } +std::string AwMetricsServiceClient::GetAppPackageNameIfLoggable() { + if (!base::FeatureList::IsEnabled( + android_webview::features::kWebViewAppsPackageNamesAllowlist)) { + // Revert to the default implementation. + return ::metrics::AndroidMetricsServiceClient:: + GetAppPackageNameIfLoggable(); + } + AndroidMetricsServiceClient::InstallerPackageType installer_type = + GetInstallerPackageType(); + // Always record the app package name of system apps even if it's not in the + // allowlist. + if (installer_type == InstallerPackageType::SYSTEM_APP || + (installer_type == InstallerPackageType::GOOGLE_PLAY_STORE && + ShouldRecordPackageName())) { + return GetAppPackageName(); + } + return std::string(); +} + bool AwMetricsServiceClient::ShouldRecordPackageName() { if (!base::FeatureList::IsEnabled( android_webview::features::kWebViewAppsPackageNamesAllowlist)) { diff --git a/android_webview/browser/metrics/aw_metrics_service_client.h b/android_webview/browser/metrics/aw_metrics_service_client.h index 16ac74c67201cb..ea8ab479cd1ab4 100644 --- a/android_webview/browser/metrics/aw_metrics_service_client.h +++ b/android_webview/browser/metrics/aw_metrics_service_client.h @@ -172,6 +172,10 @@ class AwMetricsServiceClient : public ::metrics::AndroidMetricsServiceClient, void RegisterAdditionalMetricsProviders( metrics::MetricsService* service) override; + // Gets the embedding app's package name if it's OK to log. Otherwise, this + // returns the empty string. + std::string GetAppPackageNameIfLoggable() override; + // If `android_webview::features::kWebViewAppsPackageNamesAllowlist` is // enabled: // - It returns `true` if the app is in the list of allowed apps. diff --git a/android_webview/browser/metrics/aw_metrics_service_client_unittest.cc b/android_webview/browser/metrics/aw_metrics_service_client_unittest.cc index f3701282567497..b3715bc7712db3 100644 --- a/android_webview/browser/metrics/aw_metrics_service_client_unittest.cc +++ b/android_webview/browser/metrics/aw_metrics_service_client_unittest.cc @@ -14,6 +14,7 @@ #include "base/test/test_simple_task_runner.h" #include "base/time/time.h" #include "base/version.h" +#include "components/embedder_support/android/metrics/android_metrics_service_client.h" #include "components/prefs/testing_pref_service.h" #include "testing/gtest/include/gtest/gtest.h" @@ -22,6 +23,9 @@ namespace android_webview { using AppPackageNameLoggingRuleStatus = AwMetricsServiceClient::AppPackageNameLoggingRuleStatus; +using InstallerPackageType = + metrics::AndroidMetricsServiceClient::InstallerPackageType; + namespace { constexpr char kTestAllowlistVersion[] = "123.456.789.10"; @@ -245,4 +249,64 @@ TEST_F(AwMetricsServiceClientTest, TestShouldRecordPackageName_SameAsCache) { "Android.WebView.Metrics.PackagesAllowList.RecordStatus", 1); } +TEST_F(AwMetricsServiceClientTest, TestGetAppPackageNameIfLoggable) { + base::test::ScopedFeatureList scoped_list; + scoped_list.InitAndEnableFeature( + android_webview::features::kWebViewAppsPackageNamesAllowlist); + + class TestClient : public AwMetricsServiceClient { + public: + TestClient() + : AwMetricsServiceClient( + std::make_unique()) {} + ~TestClient() override = default; + + bool ShouldRecordPackageName() override { + return should_record_package_name_; + } + + void SetShouldRecordPackageName(bool value) { + should_record_package_name_ = value; + } + + InstallerPackageType GetInstallerPackageType() override { + return installer_type_; + } + + void SetInstallerPackageType(InstallerPackageType installer_type) { + installer_type_ = installer_type; + } + + private: + bool should_record_package_name_; + InstallerPackageType installer_type_; + }; + + TestClient client; + + // Package names of system apps are always loggable even if they are not in + // the allowlist of apps. + client.SetInstallerPackageType(InstallerPackageType::SYSTEM_APP); + client.SetShouldRecordPackageName(false); + EXPECT_FALSE(client.GetAppPackageNameIfLoggable().empty()); + client.SetShouldRecordPackageName(true); + EXPECT_FALSE(client.GetAppPackageNameIfLoggable().empty()); + + // Package names of APPs that are installed by the Play Store are loggable if + // they are in the allowlist of apps. + client.SetInstallerPackageType(InstallerPackageType::GOOGLE_PLAY_STORE); + client.SetShouldRecordPackageName(false); + EXPECT_TRUE(client.GetAppPackageNameIfLoggable().empty()); + client.SetShouldRecordPackageName(true); + EXPECT_FALSE(client.GetAppPackageNameIfLoggable().empty()); + + // Package names of APPs that are not system apps nor installed by the Play + // Store are not loggable. + client.SetInstallerPackageType(InstallerPackageType::OTHER); + client.SetShouldRecordPackageName(false); + EXPECT_TRUE(client.GetAppPackageNameIfLoggable().empty()); + client.SetShouldRecordPackageName(true); + EXPECT_TRUE(client.GetAppPackageNameIfLoggable().empty()); +} + } // namespace android_webview diff --git a/android_webview/common/crash_reporter/crash_keys.cc b/android_webview/common/crash_reporter/crash_keys.cc index 9269afc2d7f2ef..a6848fbad4f3af 100644 --- a/android_webview/common/crash_reporter/crash_keys.cc +++ b/android_webview/common/crash_reporter/crash_keys.cc @@ -128,6 +128,12 @@ const char* const kWebViewCrashKeyAllowList[] = { "VerifyDidCommit-has_si_url", + "NoNode-ftn_is_main_frame", + "NoNode-ftn_child_count", + "NoNode-bfs_depth", + "NoFTN-is_main_frame", + "NoFTN-children_size", + // services/network "network_deserialization", diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwMetricsIntegrationTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwMetricsIntegrationTest.java index b2857f6c61d275..426692a9cbf26e 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/AwMetricsIntegrationTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwMetricsIntegrationTest.java @@ -39,6 +39,7 @@ import org.chromium.components.metrics.AndroidMetricsLogUploader; import org.chromium.components.metrics.AndroidMetricsServiceClient; import org.chromium.components.metrics.ChromeUserMetricsExtensionProtos.ChromeUserMetricsExtension; +import org.chromium.components.metrics.InstallerPackageType; import org.chromium.components.metrics.MetricsSwitches; import org.chromium.components.metrics.StabilityEventType; import org.chromium.components.metrics.SystemProfileProtos.SystemProfileProto; @@ -385,7 +386,8 @@ public void testMetadata_appPackageName() throws Throwable { mRule.runOnUiThread(() -> { AwBrowserProcess.setWebViewPackageName(appPackageName); - AndroidMetricsServiceClient.setCanRecordPackageNameForAppTypeForTesting(true); + AndroidMetricsServiceClient.setInstallerPackageTypeForTesting( + InstallerPackageType.GOOGLE_PLAY_STORE); // A valid version string and non expired date means the app package name should be // recorded. AwMetricsServiceClient.setAppPackageNameLoggingRuleForTesting( diff --git a/android_webview/test/BUILD.gn b/android_webview/test/BUILD.gn index 0a53b2cc03f88a..de509f5b566b93 100644 --- a/android_webview/test/BUILD.gn +++ b/android_webview/test/BUILD.gn @@ -532,6 +532,7 @@ test("android_webview_unittests") { "//components/component_updater", "//components/component_updater/android:embedded_component_loader", "//components/embedder_support/android:util", + "//components/embedder_support/android/metrics:metrics", "//components/flags_ui:flags_ui", "//components/metrics", "//components/metrics:component_metrics", diff --git a/ash/BUILD.gn b/ash/BUILD.gn index 8b298f3d573bcf..e14e547115f990 100644 --- a/ash/BUILD.gn +++ b/ash/BUILD.gn @@ -2178,7 +2178,6 @@ component("ash") { # on it. TODO(stevenjb): Assert on //chromeos/dbus/cryptohome_client once it # is extracted from //chromeos/dbus. https://crbug.com/647367. "//chromeos/cryptohome", - "//chromeos/login/auth", "//chromeos/tpm", # Ash should not depend upon content at all. diff --git a/ash/capture_mode/capture_mode_unittests.cc b/ash/capture_mode/capture_mode_unittests.cc index 596bfd8726146f..d719c2dc0f33de 100644 --- a/ash/capture_mode/capture_mode_unittests.cc +++ b/ash/capture_mode/capture_mode_unittests.cc @@ -41,6 +41,7 @@ #include "ash/projector/test/mock_projector_client.h" #include "ash/public/cpp/capture_mode/capture_mode_test_api.h" #include "ash/public/cpp/holding_space/holding_space_test_api.h" +#include "ash/public/cpp/projector/projector_new_screencast_precondition.h" #include "ash/public/cpp/projector/projector_session.h" #include "ash/public/cpp/shell_window_ids.h" #include "ash/root_window_controller.h" @@ -5044,7 +5045,8 @@ TEST_F(ProjectorCaptureModeIntegrationTests, controller->StartVideoRecordingImmediatelyForTesting(); EXPECT_TRUE(controller->is_recording_in_progress()); EXPECT_FALSE(ProjectorSession::Get()->is_active()); - EXPECT_FALSE(ProjectorController::Get()->CanStartNewSession()); + EXPECT_NE(ProjectorController::Get()->GetNewScreencastPrecondition().state, + NewScreencastPreconditionState::kEnabled); } namespace { diff --git a/ash/components/BUILD.gn b/ash/components/BUILD.gn index a580d5b3d9ebe3..1418baa7fd46be 100644 --- a/ash/components/BUILD.gn +++ b/ash/components/BUILD.gn @@ -18,6 +18,7 @@ source_set("unit_tests") { "//ash/components/drivefs:unit_tests", "//ash/components/fwupd:unit_tests", "//ash/components/geolocation:unit_tests", + "//ash/components/login/auth:unit_tests", "//ash/components/login/session:unit_tests", "//ash/components/peripheral_notification:unit_tests", "//ash/components/phonehub:unit_tests", diff --git a/chromeos/login/auth/BUILD.gn b/ash/components/login/auth/BUILD.gn similarity index 95% rename from chromeos/login/auth/BUILD.gn rename to ash/components/login/auth/BUILD.gn index 51e7da6a9f4257..06e5b8c1d06b26 100644 --- a/chromeos/login/auth/BUILD.gn +++ b/ash/components/login/auth/BUILD.gn @@ -2,13 +2,14 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/config/chromeos/ui_mode.gni") import("//testing/test.gni") import("//third_party/protobuf/proto_library.gni") -assert(is_chromeos, "Non-Chrome-OS builds must not depend on //chromeos") +assert(is_chromeos_ash, "Non-Chrome-OS builds must not depend on //ash") component("auth") { - defines = [ "IS_CHROMEOS_LOGIN_AUTH_IMPL" ] + defines = [ "IS_ASH_LOGIN_AUTH_IMPL" ] public_deps = [ ":challenge_response_key" ] deps = [ "//ash/constants", @@ -109,7 +110,7 @@ source_set("test_support") { # This is a separate targat to avoid a circular dependency with # chromeos/cryptohome. source_set("challenge_response_key") { - defines = [ "IS_CHROMEOS_LOGIN_AUTH_IMPL" ] + defines = [ "IS_ASH_LOGIN_AUTH_IMPL" ] deps = [ "//base" ] sources = [ "challenge_response_key.cc", diff --git a/chromeos/login/auth/DEPS b/ash/components/login/auth/DEPS similarity index 100% rename from chromeos/login/auth/DEPS rename to ash/components/login/auth/DEPS diff --git a/chromeos/login/auth/DIR_METADATA b/ash/components/login/auth/DIR_METADATA similarity index 100% rename from chromeos/login/auth/DIR_METADATA rename to ash/components/login/auth/DIR_METADATA diff --git a/chromeos/login/auth/auth_attempt_state.cc b/ash/components/login/auth/auth_attempt_state.cc similarity index 96% rename from chromeos/login/auth/auth_attempt_state.cc rename to ash/components/login/auth/auth_attempt_state.cc index ecbd54b4c75caa..67aa04550180ec 100644 --- a/chromeos/login/auth/auth_attempt_state.cc +++ b/ash/components/login/auth/auth_attempt_state.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 "chromeos/login/auth/auth_attempt_state.h" +#include "ash/components/login/auth/auth_attempt_state.h" #include diff --git a/chromeos/login/auth/auth_attempt_state.h b/ash/components/login/auth/auth_attempt_state.h similarity index 89% rename from chromeos/login/auth/auth_attempt_state.h rename to ash/components/login/auth/auth_attempt_state.h index aa5f3b804dc6d5..489076b269538c 100644 --- a/chromeos/login/auth/auth_attempt_state.h +++ b/ash/components/login/auth/auth_attempt_state.h @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_LOGIN_AUTH_AUTH_ATTEMPT_STATE_H_ -#define CHROMEOS_LOGIN_AUTH_AUTH_ATTEMPT_STATE_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_AUTH_ATTEMPT_STATE_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_AUTH_ATTEMPT_STATE_H_ #include #include +#include "ash/components/login/auth/auth_status_consumer.h" +#include "ash/components/login/auth/user_context.h" #include "base/component_export.h" #include "base/memory/weak_ptr.h" -#include "chromeos/login/auth/auth_status_consumer.h" -#include "chromeos/login/auth/user_context.h" #include "google_apis/gaia/gaia_auth_consumer.h" #include "third_party/cros_system_api/dbus/service_constants.h" @@ -19,7 +19,7 @@ namespace chromeos { // Tracks the state associated with a single attempt to log in to chromium OS. // Enforces that methods are only called on the UI thread. -class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) AuthAttemptState +class COMPONENT_EXPORT(ASH_LOGIN_AUTH) AuthAttemptState : public base::SupportsWeakPtr { public: // Used to initialize for a login attempt. @@ -88,4 +88,4 @@ class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) AuthAttemptState } // namespace chromeos -#endif // CHROMEOS_LOGIN_AUTH_AUTH_ATTEMPT_STATE_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_AUTH_ATTEMPT_STATE_H_ diff --git a/chromeos/login/auth/auth_session_authenticator.cc b/ash/components/login/auth/auth_session_authenticator.cc similarity index 99% rename from chromeos/login/auth/auth_session_authenticator.cc rename to ash/components/login/auth/auth_session_authenticator.cc index fd0000d667d944..51d5f161bfa661 100644 --- a/chromeos/login/auth/auth_session_authenticator.cc +++ b/ash/components/login/auth/auth_session_authenticator.cc @@ -2,8 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/login/auth/auth_session_authenticator.h" +#include "ash/components/login/auth/auth_session_authenticator.h" +#include "ash/components/login/auth/cryptohome_key_constants.h" +#include "ash/components/login/auth/cryptohome_parameter_utils.h" +#include "ash/components/login/auth/user_context.h" #include "base/bind.h" #include "base/callback.h" #include "base/callback_helpers.h" @@ -14,9 +17,6 @@ #include "chromeos/cryptohome/userdataauth_util.h" #include "chromeos/dbus/cryptohome/UserDataAuth.pb.h" #include "chromeos/dbus/userdataauth/userdataauth_client.h" -#include "chromeos/login/auth/cryptohome_key_constants.h" -#include "chromeos/login/auth/cryptohome_parameter_utils.h" -#include "chromeos/login/auth/user_context.h" #include "components/device_event_log/device_event_log.h" #include "components/user_manager/user_names.h" diff --git a/chromeos/login/auth/auth_session_authenticator.h b/ash/components/login/auth/auth_session_authenticator.h similarity index 97% rename from chromeos/login/auth/auth_session_authenticator.h rename to ash/components/login/auth/auth_session_authenticator.h index 83aa023823d366..b38b703de2c969 100644 --- a/chromeos/login/auth/auth_session_authenticator.h +++ b/ash/components/login/auth/auth_session_authenticator.h @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_LOGIN_AUTH_AUTH_SESSION_AUTHENTICATOR_H_ -#define CHROMEOS_LOGIN_AUTH_AUTH_SESSION_AUTHENTICATOR_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_AUTH_SESSION_AUTHENTICATOR_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_AUTH_SESSION_AUTHENTICATOR_H_ +#include "ash/components/login/auth/authenticator.h" +#include "ash/components/login/auth/safe_mode_delegate.h" #include "base/component_export.h" #include "base/memory/weak_ptr.h" #include "chromeos/dbus/cryptohome/UserDataAuth.pb.h" -#include "chromeos/login/auth/authenticator.h" -#include "chromeos/login/auth/safe_mode_delegate.h" #include "components/account_id/account_id.h" #include "components/user_manager/user_type.h" #include "third_party/abseil-cpp/absl/types/optional.h" @@ -45,7 +45,7 @@ class AuthStatusConsumer; // * Different ways to hash plain text key // * Different ways to create crytohome key from key in UserContext -class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) AuthSessionAuthenticator +class COMPONENT_EXPORT(ASH_LOGIN_AUTH) AuthSessionAuthenticator : public Authenticator { public: AuthSessionAuthenticator( @@ -279,4 +279,4 @@ class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) AuthSessionAuthenticator } // namespace chromeos -#endif // CHROMEOS_LOGIN_AUTH_AUTH_SESSION_AUTHENTICATOR_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_AUTH_SESSION_AUTHENTICATOR_H_ diff --git a/chromeos/login/auth/auth_status_consumer.cc b/ash/components/login/auth/auth_status_consumer.cc similarity index 89% rename from chromeos/login/auth/auth_status_consumer.cc rename to ash/components/login/auth/auth_status_consumer.cc index 261c11bd986040..c071c761e6587a 100644 --- a/chromeos/login/auth/auth_status_consumer.cc +++ b/ash/components/login/auth/auth_status_consumer.cc @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/login/auth/auth_status_consumer.h" +#include "ash/components/login/auth/auth_status_consumer.h" + #include "base/notreached.h" namespace chromeos { diff --git a/chromeos/login/auth/auth_status_consumer.h b/ash/components/login/auth/auth_status_consumer.h similarity index 95% rename from chromeos/login/auth/auth_status_consumer.h rename to ash/components/login/auth/auth_status_consumer.h index 77d8485c1b85b7..45277bf4452053 100644 --- a/chromeos/login/auth/auth_status_consumer.h +++ b/ash/components/login/auth/auth_status_consumer.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 CHROMEOS_LOGIN_AUTH_AUTH_STATUS_CONSUMER_H_ -#define CHROMEOS_LOGIN_AUTH_AUTH_STATUS_CONSUMER_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_AUTH_STATUS_CONSUMER_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_AUTH_STATUS_CONSUMER_H_ #include @@ -19,7 +19,7 @@ namespace chromeos { class UserContext; -class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) AuthFailure { +class COMPONENT_EXPORT(ASH_LOGIN_AUTH) AuthFailure { public: // Enum used for UMA. Do NOT reorder or remove entry. Don't forget to // update LoginFailureReason enum in enums.xml when adding new entries. @@ -132,7 +132,7 @@ enum SuccessReason { // An interface that defines the callbacks for objects that the // Authenticator class will call to report the success/failure of // authentication for Chromium OS. -class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) AuthStatusConsumer +class COMPONENT_EXPORT(ASH_LOGIN_AUTH) AuthStatusConsumer : public base::CheckedObserver { public: ~AuthStatusConsumer() override = default; @@ -159,4 +159,4 @@ using ::chromeos::AuthFailure; using ::chromeos::AuthStatusConsumer; } // namespace ash -#endif // CHROMEOS_LOGIN_AUTH_AUTH_STATUS_CONSUMER_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_AUTH_STATUS_CONSUMER_H_ diff --git a/chromeos/login/auth/authenticator.cc b/ash/components/login/auth/authenticator.cc similarity index 89% rename from chromeos/login/auth/authenticator.cc rename to ash/components/login/auth/authenticator.cc index 4db29ea89469b9..de78867fcd7a32 100644 --- a/chromeos/login/auth/authenticator.cc +++ b/ash/components/login/auth/authenticator.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 "chromeos/login/auth/authenticator.h" +#include "ash/components/login/auth/authenticator.h" namespace chromeos { diff --git a/chromeos/login/auth/authenticator.h b/ash/components/login/auth/authenticator.h similarity index 93% rename from chromeos/login/auth/authenticator.h rename to ash/components/login/auth/authenticator.h index 337cf401d39cb8..9ebc62451fb521 100644 --- a/chromeos/login/auth/authenticator.h +++ b/ash/components/login/auth/authenticator.h @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_LOGIN_AUTH_AUTHENTICATOR_H_ -#define CHROMEOS_LOGIN_AUTH_AUTHENTICATOR_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_AUTHENTICATOR_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_AUTHENTICATOR_H_ #include +#include "ash/components/login/auth/auth_status_consumer.h" #include "base/component_export.h" #include "base/memory/ref_counted.h" -#include "chromeos/login/auth/auth_status_consumer.h" #include "google_apis/gaia/gaia_auth_consumer.h" class AccountId; @@ -23,7 +23,7 @@ class UserContext; // 1. On successful authentication, will call consumer_->OnAuthSuccess(). // 2. On failure, will call consumer_->OnAuthFailure(). // 3. On password change, will call consumer_->OnPasswordChangeDetected(). -class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) Authenticator +class COMPONENT_EXPORT(ASH_LOGIN_AUTH) Authenticator : public base::RefCountedThreadSafe { public: explicit Authenticator(AuthStatusConsumer* consumer); @@ -101,4 +101,4 @@ namespace ash { using ::chromeos::Authenticator; } -#endif // CHROMEOS_LOGIN_AUTH_AUTHENTICATOR_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_AUTHENTICATOR_H_ diff --git a/chromeos/login/auth/challenge_response/cert_utils.cc b/ash/components/login/auth/challenge_response/cert_utils.cc similarity index 97% rename from chromeos/login/auth/challenge_response/cert_utils.cc rename to ash/components/login/auth/challenge_response/cert_utils.cc index c743c073fc29ce..7749c1f9230680 100644 --- a/chromeos/login/auth/challenge_response/cert_utils.cc +++ b/ash/components/login/auth/challenge_response/cert_utils.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 "chromeos/login/auth/challenge_response/cert_utils.h" +#include "ash/components/login/auth/challenge_response/cert_utils.h" #include diff --git a/chromeos/login/auth/challenge_response/cert_utils.h b/ash/components/login/auth/challenge_response/cert_utils.h similarity index 76% rename from chromeos/login/auth/challenge_response/cert_utils.h rename to ash/components/login/auth/challenge_response/cert_utils.h index 9ee7f9e46d9b58..ae82327e1c4de4 100644 --- a/chromeos/login/auth/challenge_response/cert_utils.h +++ b/ash/components/login/auth/challenge_response/cert_utils.h @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_LOGIN_AUTH_CHALLENGE_RESPONSE_CERT_UTILS_H_ -#define CHROMEOS_LOGIN_AUTH_CHALLENGE_RESPONSE_CERT_UTILS_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_CHALLENGE_RESPONSE_CERT_UTILS_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_CHALLENGE_RESPONSE_CERT_UTILS_H_ #include #include +#include "ash/components/login/auth/challenge_response_key.h" #include "base/component_export.h" -#include "chromeos/login/auth/challenge_response_key.h" #include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -20,14 +20,14 @@ namespace chromeos { // Maps from the TLS 1.3 SignatureScheme value into the challenge-response key // algorithm. -COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) +COMPONENT_EXPORT(ASH_LOGIN_AUTH) absl::optional GetChallengeResponseKeyAlgorithmFromSsl(uint16_t ssl_algorithm); // Constructs the ChallengeResponseKey instance based on the public key referred // by the specified certificate and on the specified list of supported // algorithms. Returns false on failure. -bool COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) ExtractChallengeResponseKeyFromCert( +bool COMPONENT_EXPORT(ASH_LOGIN_AUTH) ExtractChallengeResponseKeyFromCert( const net::X509Certificate& certificate, const std::vector& signature_algorithms, @@ -41,4 +41,4 @@ namespace ash { using ::chromeos::GetChallengeResponseKeyAlgorithmFromSsl; } -#endif // CHROMEOS_LOGIN_AUTH_CHALLENGE_RESPONSE_CERT_UTILS_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_CHALLENGE_RESPONSE_CERT_UTILS_H_ diff --git a/chromeos/login/auth/challenge_response/cert_utils_unittest.cc b/ash/components/login/auth/challenge_response/cert_utils_unittest.cc similarity index 93% rename from chromeos/login/auth/challenge_response/cert_utils_unittest.cc rename to ash/components/login/auth/challenge_response/cert_utils_unittest.cc index 923769df9e660f..8b2514d8c4342e 100644 --- a/chromeos/login/auth/challenge_response/cert_utils_unittest.cc +++ b/ash/components/login/auth/challenge_response/cert_utils_unittest.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/login/auth/challenge_response/cert_utils.h" +#include "ash/components/login/auth/challenge_response/cert_utils.h" #include #include +#include "ash/components/login/auth/challenge_response_key.h" #include "base/hash/sha1.h" #include "base/memory/ref_counted.h" -#include "chromeos/login/auth/challenge_response_key.h" #include "net/cert/x509_certificate.h" #include "net/test/cert_test_util.h" #include "net/test/test_certificate_data.h" diff --git a/chromeos/login/auth/challenge_response/key_label_utils.cc b/ash/components/login/auth/challenge_response/key_label_utils.cc similarity index 95% rename from chromeos/login/auth/challenge_response/key_label_utils.cc rename to ash/components/login/auth/challenge_response/key_label_utils.cc index 967df1ed0b2570..4f25897d4a435d 100644 --- a/chromeos/login/auth/challenge_response/key_label_utils.cc +++ b/ash/components/login/auth/challenge_response/key_label_utils.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 "chromeos/login/auth/challenge_response/key_label_utils.h" +#include "ash/components/login/auth/challenge_response/key_label_utils.h" #include "base/check_op.h" #include "base/strings/string_number_conversions.h" diff --git a/chromeos/login/auth/challenge_response/key_label_utils.h b/ash/components/login/auth/challenge_response/key_label_utils.h similarity index 66% rename from chromeos/login/auth/challenge_response/key_label_utils.h rename to ash/components/login/auth/challenge_response/key_label_utils.h index 98a04e60b87773..8bbbbb270e754f 100644 --- a/chromeos/login/auth/challenge_response/key_label_utils.h +++ b/ash/components/login/auth/challenge_response/key_label_utils.h @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_LOGIN_AUTH_CHALLENGE_RESPONSE_KEY_LABEL_UTILS_H_ -#define CHROMEOS_LOGIN_AUTH_CHALLENGE_RESPONSE_KEY_LABEL_UTILS_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_CHALLENGE_RESPONSE_KEY_LABEL_UTILS_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_CHALLENGE_RESPONSE_KEY_LABEL_UTILS_H_ #include #include -#include "chromeos/login/auth/challenge_response_key.h" +#include "ash/components/login/auth/challenge_response_key.h" namespace chromeos { @@ -20,4 +20,4 @@ std::string GenerateChallengeResponseKeyLabel( } // namespace chromeos -#endif // CHROMEOS_LOGIN_AUTH_CHALLENGE_RESPONSE_KEY_LABEL_UTILS_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_CHALLENGE_RESPONSE_KEY_LABEL_UTILS_H_ diff --git a/chromeos/login/auth/challenge_response/known_user_pref_utils.cc b/ash/components/login/auth/challenge_response/known_user_pref_utils.cc similarity index 97% rename from chromeos/login/auth/challenge_response/known_user_pref_utils.cc rename to ash/components/login/auth/challenge_response/known_user_pref_utils.cc index d69e5fbb34267e..5aaf6e0e42ccc1 100644 --- a/chromeos/login/auth/challenge_response/known_user_pref_utils.cc +++ b/ash/components/login/auth/challenge_response/known_user_pref_utils.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 "chromeos/login/auth/challenge_response/known_user_pref_utils.h" +#include "ash/components/login/auth/challenge_response/known_user_pref_utils.h" #include diff --git a/chromeos/login/auth/challenge_response/known_user_pref_utils.h b/ash/components/login/auth/challenge_response/known_user_pref_utils.h similarity index 77% rename from chromeos/login/auth/challenge_response/known_user_pref_utils.h rename to ash/components/login/auth/challenge_response/known_user_pref_utils.h index 30407ee790364f..3df3993571307e 100644 --- a/chromeos/login/auth/challenge_response/known_user_pref_utils.h +++ b/ash/components/login/auth/challenge_response/known_user_pref_utils.h @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_LOGIN_AUTH_CHALLENGE_RESPONSE_KNOWN_USER_PREF_UTILS_H_ -#define CHROMEOS_LOGIN_AUTH_CHALLENGE_RESPONSE_KNOWN_USER_PREF_UTILS_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_CHALLENGE_RESPONSE_KNOWN_USER_PREF_UTILS_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_CHALLENGE_RESPONSE_KNOWN_USER_PREF_UTILS_H_ #include #include +#include "ash/components/login/auth/challenge_response_key.h" #include "base/component_export.h" -#include "chromeos/login/auth/challenge_response_key.h" namespace base { class Value; @@ -25,11 +25,11 @@ namespace chromeos { // Subject Public Key Info. // * "extension_id" - contains the base64-encoded id of the extension that is // used to sign the key. -base::Value COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) +base::Value COMPONENT_EXPORT(ASH_LOGIN_AUTH) SerializeChallengeResponseKeysForKnownUser( const std::vector& challenge_response_keys); -bool COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) +bool COMPONENT_EXPORT(ASH_LOGIN_AUTH) DeserializeChallengeResponseKeyFromKnownUser( const base::Value& pref_value, std::vector* @@ -43,4 +43,4 @@ namespace ash { using ::chromeos::SerializeChallengeResponseKeysForKnownUser; } -#endif // CHROMEOS_LOGIN_AUTH_CHALLENGE_RESPONSE_KNOWN_USER_PREF_UTILS_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_CHALLENGE_RESPONSE_KNOWN_USER_PREF_UTILS_H_ diff --git a/chromeos/login/auth/challenge_response_key.cc b/ash/components/login/auth/challenge_response_key.cc similarity index 92% rename from chromeos/login/auth/challenge_response_key.cc rename to ash/components/login/auth/challenge_response_key.cc index 22cc9406fc2c5c..89c51f7467547b 100644 --- a/chromeos/login/auth/challenge_response_key.cc +++ b/ash/components/login/auth/challenge_response_key.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 "chromeos/login/auth/challenge_response_key.h" +#include "ash/components/login/auth/challenge_response_key.h" namespace chromeos { diff --git a/chromeos/login/auth/challenge_response_key.h b/ash/components/login/auth/challenge_response_key.h similarity index 89% rename from chromeos/login/auth/challenge_response_key.h rename to ash/components/login/auth/challenge_response_key.h index 70efe0d5a72996..aa4db5c7fe13a9 100644 --- a/chromeos/login/auth/challenge_response_key.h +++ b/ash/components/login/auth/challenge_response_key.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 CHROMEOS_LOGIN_AUTH_CHALLENGE_RESPONSE_KEY_H_ -#define CHROMEOS_LOGIN_AUTH_CHALLENGE_RESPONSE_KEY_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_CHALLENGE_RESPONSE_KEY_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_CHALLENGE_RESPONSE_KEY_H_ #include #include @@ -17,7 +17,7 @@ namespace chromeos { // cryptographic key to be challenged, the signature algorithms supported for // the challenge, and the id of the extension that handles the // challenge-response. -class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) ChallengeResponseKey { +class COMPONENT_EXPORT(ASH_LOGIN_AUTH) ChallengeResponseKey { public: // Cryptographic signature algorithm type for challenge requests. enum class SignatureAlgorithm { @@ -67,7 +67,7 @@ class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) ChallengeResponseKey { }; // Contains the parts of a ChallengeResponseKey that can be persisted to disk. -struct COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) DeserializedChallengeResponseKey { +struct COMPONENT_EXPORT(ASH_LOGIN_AUTH) DeserializedChallengeResponseKey { std::string public_key_spki_der; std::string extension_id; }; @@ -81,4 +81,4 @@ using ::chromeos::ChallengeResponseKey; using ::chromeos::DeserializedChallengeResponseKey; } // namespace ash -#endif // CHROMEOS_LOGIN_AUTH_CHALLENGE_RESPONSE_KEY_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_CHALLENGE_RESPONSE_KEY_H_ diff --git a/chromeos/login/auth/cryptohome_authenticator.cc b/ash/components/login/auth/cryptohome_authenticator.cc similarity index 99% rename from chromeos/login/auth/cryptohome_authenticator.cc rename to ash/components/login/auth/cryptohome_authenticator.cc index d23ec18ce5e7cc..ef65e934c97302 100644 --- a/chromeos/login/auth/cryptohome_authenticator.cc +++ b/ash/components/login/auth/cryptohome_authenticator.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 "chromeos/login/auth/cryptohome_authenticator.h" +#include "ash/components/login/auth/cryptohome_authenticator.h" #include #include #include +#include "ash/components/login/auth/auth_status_consumer.h" +#include "ash/components/login/auth/cryptohome_key_constants.h" +#include "ash/components/login/auth/cryptohome_parameter_utils.h" +#include "ash/components/login/auth/key.h" +#include "ash/components/login/auth/user_context.h" #include "ash/constants/ash_switches.h" #include "base/bind.h" #include "base/files/file_path.h" @@ -22,11 +27,6 @@ #include "chromeos/cryptohome/userdataauth_util.h" #include "chromeos/dbus/userdataauth/cryptohome_misc_client.h" #include "chromeos/dbus/userdataauth/userdataauth_client.h" -#include "chromeos/login/auth/auth_status_consumer.h" -#include "chromeos/login/auth/cryptohome_key_constants.h" -#include "chromeos/login/auth/cryptohome_parameter_utils.h" -#include "chromeos/login/auth/key.h" -#include "chromeos/login/auth/user_context.h" #include "chromeos/login/login_state/login_state.h" #include "chromeos/metrics/login_event_recorder.h" #include "components/account_id/account_id.h" diff --git a/chromeos/login/auth/cryptohome_authenticator.h b/ash/components/login/auth/cryptohome_authenticator.h similarity index 95% rename from chromeos/login/auth/cryptohome_authenticator.h rename to ash/components/login/auth/cryptohome_authenticator.h index 24985b97fca7ed..f2ae81d646164a 100644 --- a/chromeos/login/auth/cryptohome_authenticator.h +++ b/ash/components/login/auth/cryptohome_authenticator.h @@ -2,22 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_LOGIN_AUTH_CRYPTOHOME_AUTHENTICATOR_H_ -#define CHROMEOS_LOGIN_AUTH_CRYPTOHOME_AUTHENTICATOR_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_CRYPTOHOME_AUTHENTICATOR_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_CRYPTOHOME_AUTHENTICATOR_H_ #include #include +#include "ash/components/login/auth/auth_attempt_state.h" +#include "ash/components/login/auth/authenticator.h" +#include "ash/components/login/auth/safe_mode_delegate.h" +#include "ash/components/login/auth/test_attempt_state.h" #include "base/compiler_specific.h" #include "base/component_export.h" #include "base/gtest_prod_util.h" #include "base/synchronization/lock.h" #include "base/task/sequenced_task_runner.h" #include "chromeos/dbus/cryptohome/UserDataAuth.pb.h" -#include "chromeos/login/auth/auth_attempt_state.h" -#include "chromeos/login/auth/authenticator.h" -#include "chromeos/login/auth/safe_mode_delegate.h" -#include "chromeos/login/auth/test_attempt_state.h" #include "google_apis/gaia/gaia_auth_consumer.h" #include "third_party/abseil-cpp/absl/types/optional.h" @@ -55,7 +55,7 @@ class AuthStatusConsumer; // Old password failure: NEED_OLD_PW // Old password ok: RECOVER_MOUNT > CONTINUE > ONLINE_LOGIN // -class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) CryptohomeAuthenticator +class COMPONENT_EXPORT(ASH_LOGIN_AUTH) CryptohomeAuthenticator : public Authenticator { public: enum AuthState { @@ -270,4 +270,4 @@ namespace ash { using ::chromeos::CryptohomeAuthenticator; } -#endif // CHROMEOS_LOGIN_AUTH_CRYPTOHOME_AUTHENTICATOR_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_CRYPTOHOME_AUTHENTICATOR_H_ diff --git a/chromeos/login/auth/cryptohome_key_constants.cc b/ash/components/login/auth/cryptohome_key_constants.cc similarity index 92% rename from chromeos/login/auth/cryptohome_key_constants.cc rename to ash/components/login/auth/cryptohome_key_constants.cc index d6f89678011382..fb1d6eca2a0506 100644 --- a/chromeos/login/auth/cryptohome_key_constants.cc +++ b/ash/components/login/auth/cryptohome_key_constants.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 "chromeos/login/auth/cryptohome_key_constants.h" +#include "ash/components/login/auth/cryptohome_key_constants.h" namespace chromeos { diff --git a/chromeos/login/auth/cryptohome_key_constants.h b/ash/components/login/auth/cryptohome_key_constants.h similarity index 66% rename from chromeos/login/auth/cryptohome_key_constants.h rename to ash/components/login/auth/cryptohome_key_constants.h index 38e1ba8a3cfa30..340dd0f0e601ba 100644 --- a/chromeos/login/auth/cryptohome_key_constants.h +++ b/ash/components/login/auth/cryptohome_key_constants.h @@ -2,23 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_LOGIN_AUTH_CRYPTOHOME_KEY_CONSTANTS_H_ -#define CHROMEOS_LOGIN_AUTH_CRYPTOHOME_KEY_CONSTANTS_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_CRYPTOHOME_KEY_CONSTANTS_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_CRYPTOHOME_KEY_CONSTANTS_H_ #include "base/component_export.h" namespace chromeos { -COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) +COMPONENT_EXPORT(ASH_LOGIN_AUTH) extern const char kCryptohomeGaiaKeyLabel[]; -COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) +COMPONENT_EXPORT(ASH_LOGIN_AUTH) extern const char kCryptohomePinLabel[]; -COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) +COMPONENT_EXPORT(ASH_LOGIN_AUTH) extern const char kCryptohomePublicMountLabel[]; -COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) +COMPONENT_EXPORT(ASH_LOGIN_AUTH) extern const char kCryptohomeWildcardLabel[]; } // namespace chromeos @@ -30,4 +30,4 @@ using ::chromeos::kCryptohomeGaiaKeyLabel; using ::chromeos::kCryptohomePinLabel; } -#endif // CHROMEOS_LOGIN_AUTH_CRYPTOHOME_KEY_CONSTANTS_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_CRYPTOHOME_KEY_CONSTANTS_H_ diff --git a/chromeos/login/auth/cryptohome_parameter_utils.cc b/ash/components/login/auth/cryptohome_parameter_utils.cc similarity index 90% rename from chromeos/login/auth/cryptohome_parameter_utils.cc rename to ash/components/login/auth/cryptohome_parameter_utils.cc index bb2610acbe38cc..f8b6ab56d8aff0 100644 --- a/chromeos/login/auth/cryptohome_parameter_utils.cc +++ b/ash/components/login/auth/cryptohome_parameter_utils.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/login/auth/cryptohome_parameter_utils.h" +#include "ash/components/login/auth/cryptohome_parameter_utils.h" +#include "ash/components/login/auth/challenge_response/key_label_utils.h" +#include "ash/components/login/auth/key.h" +#include "ash/components/login/auth/user_context.h" #include "base/check_op.h" #include "chromeos/cryptohome/cryptohome_parameters.h" -#include "chromeos/login/auth/challenge_response/key_label_utils.h" -#include "chromeos/login/auth/key.h" -#include "chromeos/login/auth/user_context.h" using cryptohome::KeyDefinition; diff --git a/chromeos/login/auth/cryptohome_parameter_utils.h b/ash/components/login/auth/cryptohome_parameter_utils.h similarity index 79% rename from chromeos/login/auth/cryptohome_parameter_utils.h rename to ash/components/login/auth/cryptohome_parameter_utils.h index ec5f3907027a67..327ecbadc444e5 100644 --- a/chromeos/login/auth/cryptohome_parameter_utils.h +++ b/ash/components/login/auth/cryptohome_parameter_utils.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 CHROMEOS_LOGIN_AUTH_CRYPTOHOME_PARAMETER_UTILS_H_ -#define CHROMEOS_LOGIN_AUTH_CRYPTOHOME_PARAMETER_UTILS_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_CRYPTOHOME_PARAMETER_UTILS_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_CRYPTOHOME_PARAMETER_UTILS_H_ #include "base/component_export.h" @@ -22,17 +22,17 @@ namespace cryptohome_parameter_utils { // Creates the cryptohome key definition structure based on the credentials and // other information from the given user context. -COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) +COMPONENT_EXPORT(ASH_LOGIN_AUTH) cryptohome::KeyDefinition CreateKeyDefFromUserContext( const UserContext& user_context); // Similar to CreateKeyDefFromUserContext(), but the returned value is // slightly altered to be suitable for authorization requests to cryptohome. -COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) +COMPONENT_EXPORT(ASH_LOGIN_AUTH) cryptohome::KeyDefinition CreateAuthorizationKeyDefFromUserContext( const UserContext& user_context); } // namespace cryptohome_parameter_utils } // namespace chromeos -#endif // CHROMEOS_LOGIN_AUTH_CRYPTOHOME_PARAMETER_UTILS_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_CRYPTOHOME_PARAMETER_UTILS_H_ diff --git a/chromeos/login/auth/extended_authenticator.cc b/ash/components/login/auth/extended_authenticator.cc similarity index 79% rename from chromeos/login/auth/extended_authenticator.cc rename to ash/components/login/auth/extended_authenticator.cc index 6901c25fc07ed3..404f0a6804c1b2 100644 --- a/chromeos/login/auth/extended_authenticator.cc +++ b/ash/components/login/auth/extended_authenticator.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/login/auth/extended_authenticator.h" +#include "ash/components/login/auth/extended_authenticator.h" -#include "chromeos/login/auth/extended_authenticator_impl.h" +#include "ash/components/login/auth/extended_authenticator_impl.h" namespace chromeos { diff --git a/chromeos/login/auth/extended_authenticator.h b/ash/components/login/auth/extended_authenticator.h similarity index 94% rename from chromeos/login/auth/extended_authenticator.h rename to ash/components/login/auth/extended_authenticator.h index a1ca11d02122bc..86eba1e48e86ef 100644 --- a/chromeos/login/auth/extended_authenticator.h +++ b/ash/components/login/auth/extended_authenticator.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 CHROMEOS_LOGIN_AUTH_EXTENDED_AUTHENTICATOR_H_ -#define CHROMEOS_LOGIN_AUTH_EXTENDED_AUTHENTICATOR_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_EXTENDED_AUTHENTICATOR_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_EXTENDED_AUTHENTICATOR_H_ #include #include @@ -26,7 +26,7 @@ class UserContext; // Typical flow: // AuthenticateToMount() calls cryptohomed to perform offline login, // AuthenticateToCreate() calls cryptohomed to create new cryptohome. -class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) ExtendedAuthenticator +class COMPONENT_EXPORT(ASH_LOGIN_AUTH) ExtendedAuthenticator : public base::RefCountedThreadSafe { public: enum AuthState { @@ -112,4 +112,4 @@ namespace ash { using ::chromeos::ExtendedAuthenticator; } -#endif // CHROMEOS_LOGIN_AUTH_EXTENDED_AUTHENTICATOR_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_EXTENDED_AUTHENTICATOR_H_ diff --git a/chromeos/login/auth/extended_authenticator_impl.cc b/ash/components/login/auth/extended_authenticator_impl.cc similarity index 97% rename from chromeos/login/auth/extended_authenticator_impl.cc rename to ash/components/login/auth/extended_authenticator_impl.cc index cd7c4140236954..00b0e3c774376e 100644 --- a/chromeos/login/auth/extended_authenticator_impl.cc +++ b/ash/components/login/auth/extended_authenticator_impl.cc @@ -2,10 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/login/auth/extended_authenticator_impl.h" +#include "ash/components/login/auth/extended_authenticator_impl.h" #include +#include "ash/components/login/auth/auth_status_consumer.h" +#include "ash/components/login/auth/cryptohome_parameter_utils.h" +#include "ash/components/login/auth/key.h" +#include "ash/components/login/auth/user_context.h" #include "base/bind.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" @@ -14,10 +18,6 @@ #include "chromeos/cryptohome/system_salt_getter.h" #include "chromeos/cryptohome/userdataauth_util.h" #include "chromeos/dbus/userdataauth/userdataauth_client.h" -#include "chromeos/login/auth/auth_status_consumer.h" -#include "chromeos/login/auth/cryptohome_parameter_utils.h" -#include "chromeos/login/auth/key.h" -#include "chromeos/login/auth/user_context.h" #include "chromeos/metrics/login_event_recorder.h" #include "components/account_id/account_id.h" #include "crypto/sha2.h" diff --git a/chromeos/login/auth/extended_authenticator_impl.h b/ash/components/login/auth/extended_authenticator_impl.h similarity index 91% rename from chromeos/login/auth/extended_authenticator_impl.h rename to ash/components/login/auth/extended_authenticator_impl.h index 3a4c39197e0981..1e7da2beca0a27 100644 --- a/chromeos/login/auth/extended_authenticator_impl.h +++ b/ash/components/login/auth/extended_authenticator_impl.h @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_LOGIN_AUTH_EXTENDED_AUTHENTICATOR_IMPL_H_ -#define CHROMEOS_LOGIN_AUTH_EXTENDED_AUTHENTICATOR_IMPL_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_EXTENDED_AUTHENTICATOR_IMPL_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_EXTENDED_AUTHENTICATOR_IMPL_H_ #include #include +#include "ash/components/login/auth/extended_authenticator.h" #include "base/callback.h" #include "base/compiler_specific.h" #include "base/component_export.h" #include "chromeos/dbus/cryptohome/UserDataAuth.pb.h" -#include "chromeos/login/auth/extended_authenticator.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/cros_system_api/dbus/service_constants.h" @@ -22,7 +22,7 @@ class AuthStatusConsumer; class UserContext; // Implements ExtendedAuthenticator. -class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) ExtendedAuthenticatorImpl +class COMPONENT_EXPORT(ASH_LOGIN_AUTH) ExtendedAuthenticatorImpl : public ExtendedAuthenticator { public: static scoped_refptr Create( @@ -95,4 +95,4 @@ class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) ExtendedAuthenticatorImpl } // namespace chromeos -#endif // CHROMEOS_LOGIN_AUTH_EXTENDED_AUTHENTICATOR_IMPL_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_EXTENDED_AUTHENTICATOR_IMPL_H_ diff --git a/chromeos/login/auth/fake_extended_authenticator.cc b/ash/components/login/auth/fake_extended_authenticator.cc similarity index 95% rename from chromeos/login/auth/fake_extended_authenticator.cc rename to ash/components/login/auth/fake_extended_authenticator.cc index 2e7ef974cf0b4a..aa4b400035053f 100644 --- a/chromeos/login/auth/fake_extended_authenticator.cc +++ b/ash/components/login/auth/fake_extended_authenticator.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/login/auth/fake_extended_authenticator.h" +#include "ash/components/login/auth/fake_extended_authenticator.h" +#include "ash/components/login/auth/auth_status_consumer.h" #include "base/notreached.h" -#include "chromeos/login/auth/auth_status_consumer.h" #include "components/account_id/account_id.h" namespace chromeos { diff --git a/chromeos/login/auth/fake_extended_authenticator.h b/ash/components/login/auth/fake_extended_authenticator.h similarity index 84% rename from chromeos/login/auth/fake_extended_authenticator.h rename to ash/components/login/auth/fake_extended_authenticator.h index db913cbfcbac71..258a574770eca5 100644 --- a/chromeos/login/auth/fake_extended_authenticator.h +++ b/ash/components/login/auth/fake_extended_authenticator.h @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_LOGIN_AUTH_FAKE_EXTENDED_AUTHENTICATOR_H_ -#define CHROMEOS_LOGIN_AUTH_FAKE_EXTENDED_AUTHENTICATOR_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_FAKE_EXTENDED_AUTHENTICATOR_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_FAKE_EXTENDED_AUTHENTICATOR_H_ +#include "ash/components/login/auth/extended_authenticator.h" +#include "ash/components/login/auth/user_context.h" #include "base/component_export.h" -#include "chromeos/login/auth/extended_authenticator.h" -#include "chromeos/login/auth/user_context.h" namespace chromeos { class AuthFailure; -class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) FakeExtendedAuthenticator +class COMPONENT_EXPORT(ASH_LOGIN_AUTH) FakeExtendedAuthenticator : public ExtendedAuthenticator { public: FakeExtendedAuthenticator(AuthStatusConsumer* consumer, @@ -64,4 +64,4 @@ namespace ash { using ::chromeos::FakeExtendedAuthenticator; } -#endif // CHROMEOS_LOGIN_AUTH_FAKE_EXTENDED_AUTHENTICATOR_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_FAKE_EXTENDED_AUTHENTICATOR_H_ diff --git a/chromeos/login/auth/key.cc b/ash/components/login/auth/key.cc similarity index 98% rename from chromeos/login/auth/key.cc rename to ash/components/login/auth/key.cc index 465ab67e79210d..d8a06c32d01d35 100644 --- a/chromeos/login/auth/key.cc +++ b/ash/components/login/auth/key.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 "chromeos/login/auth/key.h" +#include "ash/components/login/auth/key.h" #include diff --git a/chromeos/login/auth/key.h b/ash/components/login/auth/key.h similarity index 91% rename from chromeos/login/auth/key.h rename to ash/components/login/auth/key.h index 09d76e61cb0db1..9cfe41266008ea 100644 --- a/chromeos/login/auth/key.h +++ b/ash/components/login/auth/key.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 CHROMEOS_LOGIN_AUTH_KEY_H_ -#define CHROMEOS_LOGIN_AUTH_KEY_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_KEY_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_KEY_H_ #include @@ -15,7 +15,7 @@ namespace chromeos { // passwords to generate keys as well as the use of pre-hashed keys. // // TODO(crbug.com/826417): Consider making this class movable. -class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) Key { +class COMPONENT_EXPORT(ASH_LOGIN_AUTH) Key { public: enum KeyType { // Plain text password. @@ -69,4 +69,4 @@ namespace ash { using ::chromeos::Key; } -#endif // CHROMEOS_LOGIN_AUTH_KEY_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_KEY_H_ diff --git a/chromeos/login/auth/key_unittest.cc b/ash/components/login/auth/key_unittest.cc similarity index 98% rename from chromeos/login/auth/key_unittest.cc rename to ash/components/login/auth/key_unittest.cc index 26a6c8d808fa4f..0ea06131be8309 100644 --- a/chromeos/login/auth/key_unittest.cc +++ b/ash/components/login/auth/key_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 "chromeos/login/auth/key.h" +#include "ash/components/login/auth/key.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chromeos/login/auth/login_performer.cc b/ash/components/login/auth/login_performer.cc similarity index 99% rename from chromeos/login/auth/login_performer.cc rename to ash/components/login/auth/login_performer.cc index 6939c89fedb548..39d180979966c6 100644 --- a/chromeos/login/auth/login_performer.cc +++ b/ash/components/login/auth/login_performer.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 "chromeos/login/auth/login_performer.h" +#include "ash/components/login/auth/login_performer.h" #include "base/bind.h" #include "base/location.h" diff --git a/chromeos/login/auth/login_performer.h b/ash/components/login/auth/login_performer.h similarity index 94% rename from chromeos/login/auth/login_performer.h rename to ash/components/login/auth/login_performer.h index 7f657f698f9a94..5cf4e6f28431f4 100644 --- a/chromeos/login/auth/login_performer.h +++ b/ash/components/login/auth/login_performer.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 CHROMEOS_LOGIN_AUTH_LOGIN_PERFORMER_H_ -#define CHROMEOS_LOGIN_AUTH_LOGIN_PERFORMER_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_LOGIN_PERFORMER_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_LOGIN_PERFORMER_H_ #include #include +#include "ash/components/login/auth/auth_status_consumer.h" +#include "ash/components/login/auth/authenticator.h" +#include "ash/components/login/auth/extended_authenticator.h" +#include "ash/components/login/auth/user_context.h" #include "base/callback.h" #include "base/component_export.h" #include "base/memory/weak_ptr.h" #include "base/sequence_checker.h" -#include "chromeos/login/auth/auth_status_consumer.h" -#include "chromeos/login/auth/authenticator.h" -#include "chromeos/login/auth/extended_authenticator.h" -#include "chromeos/login/auth/user_context.h" #include "components/user_manager/user_type.h" #include "google_apis/gaia/google_service_auth_error.h" #include "third_party/abseil-cpp/absl/types/optional.h" @@ -36,7 +36,7 @@ namespace chromeos { // If auth is succeeded, cookie fetcher is executed, LP instance deletes itself. // // If |delegate_| is not NULL it will handle error messages, password input. -class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) LoginPerformer +class COMPONENT_EXPORT(ASH_LOGIN_AUTH) LoginPerformer : public AuthStatusConsumer { public: enum class AuthorizationMode { @@ -218,4 +218,4 @@ namespace ash { using ::chromeos::LoginPerformer; } -#endif // CHROMEOS_LOGIN_AUTH_LOGIN_PERFORMER_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_LOGIN_PERFORMER_H_ diff --git a/chromeos/login/auth/mock_auth_status_consumer.cc b/ash/components/login/auth/mock_auth_status_consumer.cc similarity index 96% rename from chromeos/login/auth/mock_auth_status_consumer.cc rename to ash/components/login/auth/mock_auth_status_consumer.cc index 93574c579d99b9..eb371447ed12bf 100644 --- a/chromeos/login/auth/mock_auth_status_consumer.cc +++ b/ash/components/login/auth/mock_auth_status_consumer.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 "chromeos/login/auth/mock_auth_status_consumer.h" +#include "ash/components/login/auth/mock_auth_status_consumer.h" #include "base/run_loop.h" #include "google_apis/gaia/gaia_auth_consumer.h" diff --git a/chromeos/login/auth/mock_auth_status_consumer.h b/ash/components/login/auth/mock_auth_status_consumer.h similarity index 83% rename from chromeos/login/auth/mock_auth_status_consumer.h rename to ash/components/login/auth/mock_auth_status_consumer.h index d95d2f576889be..9ab1ed5de788a8 100644 --- a/chromeos/login/auth/mock_auth_status_consumer.h +++ b/ash/components/login/auth/mock_auth_status_consumer.h @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_LOGIN_AUTH_MOCK_AUTH_STATUS_CONSUMER_H_ -#define CHROMEOS_LOGIN_AUTH_MOCK_AUTH_STATUS_CONSUMER_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_MOCK_AUTH_STATUS_CONSUMER_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_MOCK_AUTH_STATUS_CONSUMER_H_ +#include "ash/components/login/auth/auth_status_consumer.h" +#include "ash/components/login/auth/user_context.h" #include "base/callback.h" #include "base/component_export.h" -#include "chromeos/login/auth/auth_status_consumer.h" -#include "chromeos/login/auth/user_context.h" #include "testing/gmock/include/gmock/gmock.h" namespace chromeos { -class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) MockAuthStatusConsumer +class COMPONENT_EXPORT(ASH_LOGIN_AUTH) MockAuthStatusConsumer : public AuthStatusConsumer { public: explicit MockAuthStatusConsumer(base::OnceClosure quit_closure); @@ -59,4 +59,4 @@ namespace ash { using ::chromeos::MockAuthStatusConsumer; } -#endif // CHROMEOS_LOGIN_AUTH_MOCK_AUTH_STATUS_CONSUMER_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_MOCK_AUTH_STATUS_CONSUMER_H_ diff --git a/chromeos/login/auth/password_visibility_utils.cc b/ash/components/login/auth/password_visibility_utils.cc similarity index 91% rename from chromeos/login/auth/password_visibility_utils.cc rename to ash/components/login/auth/password_visibility_utils.cc index 6d7f09b25e735d..92ded90ba1c3dd 100644 --- a/chromeos/login/auth/password_visibility_utils.cc +++ b/ash/components/login/auth/password_visibility_utils.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 "chromeos/login/auth/password_visibility_utils.h" +#include "ash/components/login/auth/password_visibility_utils.h" #include "components/user_manager/known_user.h" diff --git a/chromeos/login/auth/password_visibility_utils.h b/ash/components/login/auth/password_visibility_utils.h similarity index 68% rename from chromeos/login/auth/password_visibility_utils.h rename to ash/components/login/auth/password_visibility_utils.h index 222cf9fb18afb3..10c1eb9c3d693e 100644 --- a/chromeos/login/auth/password_visibility_utils.h +++ b/ash/components/login/auth/password_visibility_utils.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 CHROMEOS_LOGIN_AUTH_PASSWORD_VISIBILITY_UTILS_H_ -#define CHROMEOS_LOGIN_AUTH_PASSWORD_VISIBILITY_UTILS_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_PASSWORD_VISIBILITY_UTILS_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_PASSWORD_VISIBILITY_UTILS_H_ #include "base/component_export.h" @@ -15,11 +15,11 @@ namespace password_visibility { // Whether the account has a user facing password that the user can enter for // security checks. -bool COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) +bool COMPONENT_EXPORT(ASH_LOGIN_AUTH) AccountHasUserFacingPassword(const AccountId& account_id); } // namespace password_visibility } // namespace chromeos -#endif // CHROMEOS_LOGIN_AUTH_PASSWORD_VISIBILITY_UTILS_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_PASSWORD_VISIBILITY_UTILS_H_ diff --git a/chromeos/login/auth/safe_mode_delegate.h b/ash/components/login/auth/safe_mode_delegate.h similarity index 88% rename from chromeos/login/auth/safe_mode_delegate.h rename to ash/components/login/auth/safe_mode_delegate.h index 53b66836db3550..555630ed05a91e 100644 --- a/chromeos/login/auth/safe_mode_delegate.h +++ b/ash/components/login/auth/safe_mode_delegate.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 CHROMEOS_LOGIN_AUTH_SAFE_MODE_DELEGATE_H_ -#define CHROMEOS_LOGIN_AUTH_SAFE_MODE_DELEGATE_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_SAFE_MODE_DELEGATE_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_SAFE_MODE_DELEGATE_H_ #include "base/callback.h" #include "base/component_export.h" @@ -20,7 +20,7 @@ namespace chromeos { // This inteface abstracts interface between code that performs cryptohome // mounting and code that has access to DeviceSettings. -class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) SafeModeDelegate { +class COMPONENT_EXPORT(ASH_LOGIN_AUTH) SafeModeDelegate { public: SafeModeDelegate() = default; virtual ~SafeModeDelegate() = default; @@ -50,4 +50,4 @@ namespace ash { using ::chromeos::SafeModeDelegate; } -#endif // CHROMEOS_LOGIN_AUTH_SAFE_MODE_DELEGATE_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_SAFE_MODE_DELEGATE_H_ diff --git a/chromeos/login/auth/saml_password_attributes.cc b/ash/components/login/auth/saml_password_attributes.cc similarity index 98% rename from chromeos/login/auth/saml_password_attributes.cc rename to ash/components/login/auth/saml_password_attributes.cc index 64a956b80790e2..021ca53538ab3a 100644 --- a/chromeos/login/auth/saml_password_attributes.cc +++ b/ash/components/login/auth/saml_password_attributes.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 "chromeos/login/auth/saml_password_attributes.h" +#include "ash/components/login/auth/saml_password_attributes.h" #include "ash/constants/ash_pref_names.h" #include "base/strings/string_number_conversions.h" diff --git a/chromeos/login/auth/saml_password_attributes.h b/ash/components/login/auth/saml_password_attributes.h similarity index 91% rename from chromeos/login/auth/saml_password_attributes.h rename to ash/components/login/auth/saml_password_attributes.h index a4f096c4057f19..b39a80bfd8b8f9 100644 --- a/chromeos/login/auth/saml_password_attributes.h +++ b/ash/components/login/auth/saml_password_attributes.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 CHROMEOS_LOGIN_AUTH_SAML_PASSWORD_ATTRIBUTES_H_ -#define CHROMEOS_LOGIN_AUTH_SAML_PASSWORD_ATTRIBUTES_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_SAML_PASSWORD_ATTRIBUTES_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_SAML_PASSWORD_ATTRIBUTES_H_ #include @@ -24,7 +24,7 @@ namespace chromeos { // the PrefService. // The IdP is not required to set these, so any or all of them may be missing - // the has_*() functions are for checking which attributes are set. -class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) SamlPasswordAttributes { +class COMPONENT_EXPORT(ASH_LOGIN_AUTH) SamlPasswordAttributes { public: SamlPasswordAttributes(); SamlPasswordAttributes(const base::Time& modified_time, @@ -79,4 +79,4 @@ namespace ash { using ::chromeos::SamlPasswordAttributes; } -#endif // CHROMEOS_LOGIN_AUTH_SAML_PASSWORD_ATTRIBUTES_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_SAML_PASSWORD_ATTRIBUTES_H_ diff --git a/chromeos/login/auth/saml_password_attributes_unittest.cc b/ash/components/login/auth/saml_password_attributes_unittest.cc similarity index 97% rename from chromeos/login/auth/saml_password_attributes_unittest.cc rename to ash/components/login/auth/saml_password_attributes_unittest.cc index 1b328882046f1c..0faf21e9e1efde 100644 --- a/chromeos/login/auth/saml_password_attributes_unittest.cc +++ b/ash/components/login/auth/saml_password_attributes_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 "chromeos/login/auth/saml_password_attributes.h" +#include "ash/components/login/auth/saml_password_attributes.h" #include "components/prefs/pref_registry_simple.h" #include "components/prefs/testing_pref_service.h" diff --git a/chromeos/login/auth/stub_authenticator.cc b/ash/components/login/auth/stub_authenticator.cc similarity index 99% rename from chromeos/login/auth/stub_authenticator.cc rename to ash/components/login/auth/stub_authenticator.cc index dd319ddf7870ae..ca8260eab4bddd 100644 --- a/chromeos/login/auth/stub_authenticator.cc +++ b/ash/components/login/auth/stub_authenticator.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 "chromeos/login/auth/stub_authenticator.h" +#include "ash/components/login/auth/stub_authenticator.h" #include "base/bind.h" #include "base/location.h" diff --git a/chromeos/login/auth/stub_authenticator.h b/ash/components/login/auth/stub_authenticator.h similarity index 88% rename from chromeos/login/auth/stub_authenticator.h rename to ash/components/login/auth/stub_authenticator.h index d367a6d3aa68b2..82905b61329282 100644 --- a/chromeos/login/auth/stub_authenticator.h +++ b/ash/components/login/auth/stub_authenticator.h @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_LOGIN_AUTH_STUB_AUTHENTICATOR_H_ -#define CHROMEOS_LOGIN_AUTH_STUB_AUTHENTICATOR_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_STUB_AUTHENTICATOR_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_STUB_AUTHENTICATOR_H_ #include +#include "ash/components/login/auth/auth_status_consumer.h" +#include "ash/components/login/auth/authenticator.h" +#include "ash/components/login/auth/user_context.h" #include "base/callback.h" #include "base/component_export.h" #include "base/task/single_thread_task_runner.h" -#include "chromeos/login/auth/auth_status_consumer.h" -#include "chromeos/login/auth/authenticator.h" -#include "chromeos/login/auth/user_context.h" class AccountId; @@ -21,7 +21,7 @@ namespace chromeos { class AuthStatusConsumer; class StubAuthenticatorBuilder; -class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) StubAuthenticator +class COMPONENT_EXPORT(ASH_LOGIN_AUTH) StubAuthenticator : public Authenticator { public: enum class DataRecoveryStatus { @@ -102,4 +102,4 @@ namespace ash { using ::chromeos::StubAuthenticator; } -#endif // CHROMEOS_LOGIN_AUTH_STUB_AUTHENTICATOR_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_STUB_AUTHENTICATOR_H_ diff --git a/chromeos/login/auth/stub_authenticator_builder.cc b/ash/components/login/auth/stub_authenticator_builder.cc similarity index 96% rename from chromeos/login/auth/stub_authenticator_builder.cc rename to ash/components/login/auth/stub_authenticator_builder.cc index 3cd0c01113d7f4..6c2f129f0f9c75 100644 --- a/chromeos/login/auth/stub_authenticator_builder.cc +++ b/ash/components/login/auth/stub_authenticator_builder.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 "chromeos/login/auth/stub_authenticator_builder.h" +#include "ash/components/login/auth/stub_authenticator_builder.h" namespace chromeos { diff --git a/chromeos/login/auth/stub_authenticator_builder.h b/ash/components/login/auth/stub_authenticator_builder.h similarity index 86% rename from chromeos/login/auth/stub_authenticator_builder.h rename to ash/components/login/auth/stub_authenticator_builder.h index 3e5318790508a5..d8d519aaf440b1 100644 --- a/chromeos/login/auth/stub_authenticator_builder.h +++ b/ash/components/login/auth/stub_authenticator_builder.h @@ -2,23 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_LOGIN_AUTH_STUB_AUTHENTICATOR_BUILDER_H_ -#define CHROMEOS_LOGIN_AUTH_STUB_AUTHENTICATOR_BUILDER_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_STUB_AUTHENTICATOR_BUILDER_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_STUB_AUTHENTICATOR_BUILDER_H_ #include +#include "ash/components/login/auth/auth_status_consumer.h" +#include "ash/components/login/auth/stub_authenticator.h" +#include "ash/components/login/auth/user_context.h" #include "base/component_export.h" #include "base/memory/ref_counted.h" -#include "chromeos/login/auth/auth_status_consumer.h" -#include "chromeos/login/auth/stub_authenticator.h" -#include "chromeos/login/auth/user_context.h" namespace chromeos { // Helper class for creating a StubAuthenticator with certain configuration. // Useful in tests for injecting StubAuthenticators to be used during user // login. -class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) StubAuthenticatorBuilder { +class COMPONENT_EXPORT(ASH_LOGIN_AUTH) StubAuthenticatorBuilder { public: explicit StubAuthenticatorBuilder(const UserContext& expected_user_context); @@ -78,4 +78,4 @@ namespace ash { using ::chromeos::StubAuthenticatorBuilder; } -#endif // CHROMEOS_LOGIN_AUTH_STUB_AUTHENTICATOR_BUILDER_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_STUB_AUTHENTICATOR_BUILDER_H_ diff --git a/chromeos/login/auth/sync_trusted_vault_keys.cc b/ash/components/login/auth/sync_trusted_vault_keys.cc similarity index 98% rename from chromeos/login/auth/sync_trusted_vault_keys.cc rename to ash/components/login/auth/sync_trusted_vault_keys.cc index 1d97b8ed45c7d9..cedc043597e477 100644 --- a/chromeos/login/auth/sync_trusted_vault_keys.cc +++ b/ash/components/login/auth/sync_trusted_vault_keys.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 "chromeos/login/auth/sync_trusted_vault_keys.h" +#include "ash/components/login/auth/sync_trusted_vault_keys.h" #include "base/bind.h" #include "base/callback.h" diff --git a/chromeos/login/auth/sync_trusted_vault_keys.h b/ash/components/login/auth/sync_trusted_vault_keys.h similarity index 88% rename from chromeos/login/auth/sync_trusted_vault_keys.h rename to ash/components/login/auth/sync_trusted_vault_keys.h index 0698af58da139e..334dd168eef69c 100644 --- a/chromeos/login/auth/sync_trusted_vault_keys.h +++ b/ash/components/login/auth/sync_trusted_vault_keys.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 CHROMEOS_LOGIN_AUTH_SYNC_TRUSTED_VAULT_KEYS_H_ -#define CHROMEOS_LOGIN_AUTH_SYNC_TRUSTED_VAULT_KEYS_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_SYNC_TRUSTED_VAULT_KEYS_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_SYNC_TRUSTED_VAULT_KEYS_H_ #include #include @@ -17,7 +17,7 @@ class DictionaryValue; namespace chromeos { // Struct which holds keys about a user's encryption keys during signin flow. -class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) SyncTrustedVaultKeys { +class COMPONENT_EXPORT(ASH_LOGIN_AUTH) SyncTrustedVaultKeys { public: SyncTrustedVaultKeys(); SyncTrustedVaultKeys(const SyncTrustedVaultKeys&); @@ -62,4 +62,4 @@ namespace ash { using ::chromeos::SyncTrustedVaultKeys; } -#endif // CHROMEOS_LOGIN_AUTH_SYNC_TRUSTED_VAULT_KEYS_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_SYNC_TRUSTED_VAULT_KEYS_H_ diff --git a/chromeos/login/auth/sync_trusted_vault_keys_unittest.cc b/ash/components/login/auth/sync_trusted_vault_keys_unittest.cc similarity index 98% rename from chromeos/login/auth/sync_trusted_vault_keys_unittest.cc rename to ash/components/login/auth/sync_trusted_vault_keys_unittest.cc index 923c2552f3670e..f6d9333ffeff7e 100644 --- a/chromeos/login/auth/sync_trusted_vault_keys_unittest.cc +++ b/ash/components/login/auth/sync_trusted_vault_keys_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 "chromeos/login/auth/sync_trusted_vault_keys.h" +#include "ash/components/login/auth/sync_trusted_vault_keys.h" #include "base/values.h" #include "testing/gmock/include/gmock/gmock.h" diff --git a/chromeos/login/auth/test_attempt_state.cc b/ash/components/login/auth/test_attempt_state.cc similarity index 94% rename from chromeos/login/auth/test_attempt_state.cc rename to ash/components/login/auth/test_attempt_state.cc index 7b330239461385..0ad09f838acd76 100644 --- a/chromeos/login/auth/test_attempt_state.cc +++ b/ash/components/login/auth/test_attempt_state.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 "chromeos/login/auth/test_attempt_state.h" +#include "ash/components/login/auth/test_attempt_state.h" #include diff --git a/chromeos/login/auth/test_attempt_state.h b/ash/components/login/auth/test_attempt_state.h similarity index 78% rename from chromeos/login/auth/test_attempt_state.h rename to ash/components/login/auth/test_attempt_state.h index 93935532053f1b..2318f5ec9ce542 100644 --- a/chromeos/login/auth/test_attempt_state.h +++ b/ash/components/login/auth/test_attempt_state.h @@ -2,22 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_LOGIN_AUTH_TEST_ATTEMPT_STATE_H_ -#define CHROMEOS_LOGIN_AUTH_TEST_ATTEMPT_STATE_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_TEST_ATTEMPT_STATE_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_TEST_ATTEMPT_STATE_H_ #include +#include "ash/components/login/auth/auth_attempt_state.h" +#include "ash/components/login/auth/auth_status_consumer.h" #include "base/compiler_specific.h" #include "base/component_export.h" -#include "chromeos/login/auth/auth_attempt_state.h" -#include "chromeos/login/auth/auth_status_consumer.h" #include "google_apis/gaia/gaia_auth_consumer.h" namespace chromeos { class UserContext; -class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) TestAttemptState +class COMPONENT_EXPORT(ASH_LOGIN_AUTH) TestAttemptState : public AuthAttemptState { public: explicit TestAttemptState(std::unique_ptr credentials); @@ -47,4 +47,4 @@ namespace ash { using ::chromeos::TestAttemptState; } -#endif // CHROMEOS_LOGIN_AUTH_TEST_ATTEMPT_STATE_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_TEST_ATTEMPT_STATE_H_ diff --git a/chromeos/login/auth/user_context.cc b/ash/components/login/auth/user_context.cc similarity index 99% rename from chromeos/login/auth/user_context.cc rename to ash/components/login/auth/user_context.cc index 29bfacdccf9756..296f45782acb53 100644 --- a/chromeos/login/auth/user_context.cc +++ b/ash/components/login/auth/user_context.cc @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/login/auth/user_context.h" +#include "ash/components/login/auth/user_context.h" + #include "components/user_manager/user.h" #include "components/user_manager/user_manager.h" #include "components/user_manager/user_names.h" diff --git a/chromeos/login/auth/user_context.h b/ash/components/login/auth/user_context.h similarity index 94% rename from chromeos/login/auth/user_context.h rename to ash/components/login/auth/user_context.h index b89ad0819bb930..732522eb589b03 100644 --- a/chromeos/login/auth/user_context.h +++ b/ash/components/login/auth/user_context.h @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_ -#define CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_ +#ifndef ASH_COMPONENTS_LOGIN_AUTH_USER_CONTEXT_H_ +#define ASH_COMPONENTS_LOGIN_AUTH_USER_CONTEXT_H_ #include +#include "ash/components/login/auth/challenge_response_key.h" +#include "ash/components/login/auth/key.h" +#include "ash/components/login/auth/saml_password_attributes.h" +#include "ash/components/login/auth/sync_trusted_vault_keys.h" #include "base/component_export.h" -#include "chromeos/login/auth/challenge_response_key.h" -#include "chromeos/login/auth/key.h" -#include "chromeos/login/auth/saml_password_attributes.h" -#include "chromeos/login/auth/sync_trusted_vault_keys.h" #include "components/account_id/account_id.h" #include "components/password_manager/core/browser/password_hash_data.h" #include "components/user_manager/user_type.h" @@ -30,7 +30,7 @@ namespace chromeos { // |auth_code_|. // The |user_id_hash_| is used to locate the user's home directory // mount point for the user. It is set when the mount has been completed. -class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) UserContext { +class COMPONENT_EXPORT(ASH_LOGIN_AUTH) UserContext { public: // The authentication flow used during sign-in. enum AuthFlow { @@ -198,4 +198,4 @@ namespace ash { using ::chromeos::UserContext; } -#endif // CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_ +#endif // ASH_COMPONENTS_LOGIN_AUTH_USER_CONTEXT_H_ diff --git a/ash/login/ui/smart_lock_auth_factor_model.cc b/ash/login/ui/smart_lock_auth_factor_model.cc index 1ddab8ad18f2fd..eb29a256bbe0f7 100644 --- a/ash/login/ui/smart_lock_auth_factor_model.cc +++ b/ash/login/ui/smart_lock_auth_factor_model.cc @@ -150,8 +150,7 @@ int SmartLockAuthFactorModel::GetLabelId() const { } bool SmartLockAuthFactorModel::ShouldAnnounceLabel() const { - // TODO(crbug.com/1233614): Return 'true' depending on SmartLockState. - return false; + return true; } int SmartLockAuthFactorModel::GetAccessibleNameId() const { diff --git a/ash/login/ui/smart_lock_auth_factor_model_unittest.cc b/ash/login/ui/smart_lock_auth_factor_model_unittest.cc index 29c8ebebc5aac0..b5d3dfa3f3f0b5 100644 --- a/ash/login/ui/smart_lock_auth_factor_model_unittest.cc +++ b/ash/login/ui/smart_lock_auth_factor_model_unittest.cc @@ -227,6 +227,7 @@ TEST_F(SmartLockAuthFactorModelUnittest, GetLabelAndAccessibleName) { } EXPECT_EQ(testcase.label_id, model_->GetLabelId()); EXPECT_EQ(testcase.accessible_name_id, model_->GetAccessibleNameId()); + EXPECT_TRUE(model_->ShouldAnnounceLabel()); } } diff --git a/ash/projector/projector_controller_impl.cc b/ash/projector/projector_controller_impl.cc index 0b298baea419c1..921be9ebf49525 100644 --- a/ash/projector/projector_controller_impl.cc +++ b/ash/projector/projector_controller_impl.cc @@ -9,6 +9,7 @@ #include "ash/projector/projector_metadata_controller.h" #include "ash/projector/projector_ui_controller.h" #include "ash/public/cpp/projector/projector_client.h" +#include "ash/public/cpp/projector/projector_new_screencast_precondition.h" #include "ash/public/cpp/projector/projector_session.h" #include "ash/shell.h" #include "ash/strings/grit/ash_strings.h" @@ -79,7 +80,8 @@ ProjectorControllerImpl* ProjectorControllerImpl::Get() { void ProjectorControllerImpl::StartProjectorSession( const std::string& storage_dir) { - DCHECK(CanStartNewSession()); + DCHECK_EQ(GetNewScreencastPrecondition().state, + NewScreencastPreconditionState::kEnabled); auto* controller = CaptureModeController::Get(); if (!controller->is_recording_in_progress()) { @@ -156,12 +158,62 @@ bool ProjectorControllerImpl::IsEligible() const { ProjectorController::AreExtendedProjectorFeaturesDisabled(); } -bool ProjectorControllerImpl::CanStartNewSession() const { - // TODO(crbug.com/1165435) Add other pre-conditions to starting a new - // projector session. - return IsEligible() && !projector_session_->is_active() && - client_->IsDriveFsMounted() && - !CaptureModeController::Get()->is_recording_in_progress(); +NewScreencastPrecondition +ProjectorControllerImpl::GetNewScreencastPrecondition() const { + NewScreencastPrecondition result; + + // For development purposes on the x11 simulator, on-device speech recognition + // and DriveFS are not supported. + if (!ProjectorController::AreExtendedProjectorFeaturesDisabled()) { + switch (speech_recognition_availability_) { + case SpeechRecognitionAvailability:: + kOnDeviceSpeechRecognitionNotSupported: + result.state = NewScreencastPreconditionState::kDisabled; + result.reasons = {NewScreencastPreconditionReason:: + kOnDeviceSpeechRecognitionNotSupported}; + return result; + case SpeechRecognitionAvailability::kUserLanguageNotSupported: + result.state = NewScreencastPreconditionState::kDisabled; + result.reasons = { + NewScreencastPreconditionReason::kUserLocaleNotSupported}; + return result; + + // We will attempt to install SODA. + case SpeechRecognitionAvailability::kSodaNotInstalled: + case SpeechRecognitionAvailability::kSodaInstalling: + result.state = NewScreencastPreconditionState::kDisabled; + result.reasons = { + NewScreencastPreconditionReason::kSodaDownloadInProgress}; + return result; + case SpeechRecognitionAvailability::kAvailable: + break; + } + + if (!client_->IsDriveFsMounted()) { + result.state = NewScreencastPreconditionState::kDisabled; + result.reasons = {NewScreencastPreconditionReason::kOthers}; + return result; + } + + // TODO(crbug.com/1165435) Disable New Screencast button when out of disk + // space or drive quota. + } + + if (projector_session_->is_active()) { + result.state = NewScreencastPreconditionState::kDisabled; + result.reasons = {NewScreencastPreconditionReason::kInProjectorSession}; + return result; + } + + if (CaptureModeController::Get()->is_recording_in_progress()) { + result.state = NewScreencastPreconditionState::kDisabled; + result.reasons = { + NewScreencastPreconditionReason::kScreenRecordingInProgress}; + return result; + } + + result.state = NewScreencastPreconditionState::kEnabled; + return result; } void ProjectorControllerImpl::OnToolSet(const AnnotatorTool& tool) { @@ -190,8 +242,11 @@ void ProjectorControllerImpl::MarkKeyIdea() { } void ProjectorControllerImpl::OnRecordingStarted(bool is_in_projector_mode) { - if (!is_in_projector_mode) + if (!is_in_projector_mode) { + OnNewScreencastPreconditionChanged(); return; + } + ui_controller_->ShowToolbar(); StartSpeechRecognition(); ui_controller_->OnRecordingStateChanged(true /* started */); @@ -199,8 +254,11 @@ void ProjectorControllerImpl::OnRecordingStarted(bool is_in_projector_mode) { } void ProjectorControllerImpl::OnRecordingEnded(bool is_in_projector_mode) { - if (!is_in_projector_mode) + if (!is_in_projector_mode) { + OnNewScreencastPreconditionChanged(); return; + } + DCHECK(projector_session_->is_active()); StopSpeechRecognition(); @@ -279,7 +337,7 @@ void ProjectorControllerImpl::OnChangeMarkerColorPressed(SkColor new_color) { } void ProjectorControllerImpl::OnNewScreencastPreconditionChanged() { - client_->OnNewScreencastPreconditionChanged(CanStartNewSession()); + client_->OnNewScreencastPreconditionChanged(GetNewScreencastPrecondition()); } void ProjectorControllerImpl::SetProjectorUiControllerForTest( diff --git a/ash/projector/projector_controller_impl.h b/ash/projector/projector_controller_impl.h index 9076ce99c3be0c..7bb8cf4d57b3f5 100644 --- a/ash/projector/projector_controller_impl.h +++ b/ash/projector/projector_controller_impl.h @@ -50,7 +50,7 @@ class ASH_EXPORT ProjectorControllerImpl : public ProjectorController, void OnTranscription(const media::SpeechRecognitionResult& result) override; void OnTranscriptionError() override; bool IsEligible() const override; - bool CanStartNewSession() const override; + NewScreencastPrecondition GetNewScreencastPrecondition() const override; void OnToolSet(const AnnotatorTool& tool) override; void OnUndoRedoAvailabilityChanged(bool undo_available, bool redo_available) override; diff --git a/ash/projector/projector_controller_unittest.cc b/ash/projector/projector_controller_unittest.cc index 5ae437d195f84a..7f6e716834449d 100644 --- a/ash/projector/projector_controller_unittest.cc +++ b/ash/projector/projector_controller_unittest.cc @@ -14,6 +14,7 @@ #include "ash/projector/test/mock_projector_client.h" #include "ash/projector/test/mock_projector_metadata_controller.h" #include "ash/projector/test/mock_projector_ui_controller.h" +#include "ash/public/cpp/projector/projector_new_screencast_precondition.h" #include "ash/public/cpp/projector/projector_session.h" #include "ash/test/ash_test_base.h" #include "base/files/file_path.h" @@ -235,7 +236,9 @@ TEST_F(ProjectorControllerTest, RecordingEnded) { EXPECT_CALL(mock_client_, CloseSelfieCam()).Times(1); EXPECT_CALL(mock_client_, OpenProjectorApp()); EXPECT_CALL(mock_client_, - OnNewScreencastPreconditionChanged(/*can_start=*/false)); + OnNewScreencastPreconditionChanged(NewScreencastPrecondition( + NewScreencastPreconditionState::kDisabled, + {NewScreencastPreconditionReason::kInProjectorSession}))); // Advance clock to 20:02:10 Jan 2nd, 2021. base::Time start_time; @@ -248,8 +251,10 @@ TEST_F(ProjectorControllerTest, RecordingEnded) { base::RunLoop runLoop; controller_->CreateScreencastContainerFolder(base::BindLambdaForTesting( [&](const base::FilePath& screencast_file_path_no_extension) { - EXPECT_CALL(mock_client_, - OnNewScreencastPreconditionChanged(/*can_start=*/true)); + EXPECT_CALL( + mock_client_, + OnNewScreencastPreconditionChanged(NewScreencastPrecondition( + NewScreencastPreconditionState::kEnabled, {}))); EXPECT_CALL(mock_client_, StopSpeechRecognition()); EXPECT_CALL(*mock_ui_controller_, diff --git a/ash/projector/projector_feature_pod_controller.cc b/ash/projector/projector_feature_pod_controller.cc index 75d526a507d0b3..4b305f7601808e 100644 --- a/ash/projector/projector_feature_pod_controller.cc +++ b/ash/projector/projector_feature_pod_controller.cc @@ -7,6 +7,7 @@ #include "ash/projector/model/projector_session_impl.h" #include "ash/projector/projector_controller_impl.h" #include "ash/projector/projector_ui_controller.h" +#include "ash/public/cpp/projector/projector_new_screencast_precondition.h" #include "ash/public/cpp/projector/projector_session.h" #include "ash/resources/vector_icons/vector_icons.h" #include "ash/session/session_controller_impl.h" @@ -48,7 +49,8 @@ FeaturePodButton* ProjectorFeaturePodController::CreateButton() { DCHECK(projector_controller); button_->SetVisible( !Shell::Get()->session_controller()->IsUserSessionBlocked() && - projector_controller->CanStartNewSession()); + projector_controller->GetNewScreencastPrecondition().state == + NewScreencastPreconditionState::kEnabled); button_->SetToggled( projector_controller->ui_controller()->model()->bar_enabled()); return button_; diff --git a/ash/projector/test/mock_projector_client.h b/ash/projector/test/mock_projector_client.h index fb806a9677853f..a6781853e0aa82 100644 --- a/ash/projector/test/mock_projector_client.h +++ b/ash/projector/test/mock_projector_client.h @@ -33,7 +33,8 @@ class ASH_EXPORT MockProjectorClient : public ProjectorClient { MOCK_METHOD0(CloseSelfieCam, void()); MOCK_CONST_METHOD0(OpenProjectorApp, void()); MOCK_CONST_METHOD0(MinimizeProjectorApp, void()); - MOCK_CONST_METHOD1(OnNewScreencastPreconditionChanged, void(bool)); + MOCK_CONST_METHOD1(OnNewScreencastPreconditionChanged, + void(const NewScreencastPrecondition&)); bool IsSelfieCamVisible() const override; void SetSelfieCamVisible(bool visible); diff --git a/ash/public/cpp/BUILD.gn b/ash/public/cpp/BUILD.gn index 600a4ffbaedfd9..6267301fad1bb9 100644 --- a/ash/public/cpp/BUILD.gn +++ b/ash/public/cpp/BUILD.gn @@ -235,6 +235,8 @@ component("cpp") { "projector/projector_client.h", "projector/projector_controller.cc", "projector/projector_controller.h", + "projector/projector_new_screencast_precondition.cc", + "projector/projector_new_screencast_precondition.h", "projector/projector_session.cc", "projector/projector_session.h", "resize_shadow_type.h", diff --git a/ash/public/cpp/projector/projector_client.h b/ash/public/cpp/projector/projector_client.h index 3bd432d8133681..b04c0aadd2f1b8 100644 --- a/ash/public/cpp/projector/projector_client.h +++ b/ash/public/cpp/projector/projector_client.h @@ -13,6 +13,8 @@ class FilePath; namespace ash { +struct NewScreencastPrecondition; + // Creates interface to access Browser side functionalities for the // ProjectorControllerImpl. class ASH_PUBLIC_EXPORT ProjectorClient { @@ -41,7 +43,8 @@ class ASH_PUBLIC_EXPORT ProjectorClient { virtual bool IsSelfieCamVisible() const = 0; // Notifies the Projector SWA if it can trigger a new Projector session. - virtual void OnNewScreencastPreconditionChanged(bool can_start) const = 0; + virtual void OnNewScreencastPreconditionChanged( + const NewScreencastPrecondition& precondition) const = 0; }; } // namespace ash diff --git a/ash/public/cpp/projector/projector_controller.h b/ash/public/cpp/projector/projector_controller.h index 9bf25fde1a1409..1456344e5255c7 100644 --- a/ash/public/cpp/projector/projector_controller.h +++ b/ash/public/cpp/projector/projector_controller.h @@ -12,6 +12,7 @@ namespace ash { struct AnnotatorTool; +struct NewScreencastPrecondition; // File extension of Projector metadata file. It is used to identify Projector // screencasts at processing pending screencasts and fetching screencast list. @@ -74,7 +75,7 @@ class ASH_PUBLIC_EXPORT ProjectorController { virtual bool IsEligible() const = 0; // Returns true if we can start a new Projector session. - virtual bool CanStartNewSession() const = 0; + virtual NewScreencastPrecondition GetNewScreencastPrecondition() const = 0; // The following functions are callbacks from the annotator back to the // ProjectorController. diff --git a/ash/public/cpp/projector/projector_new_screencast_precondition.cc b/ash/public/cpp/projector/projector_new_screencast_precondition.cc new file mode 100644 index 00000000000000..813dbb426d939c --- /dev/null +++ b/ash/public/cpp/projector/projector_new_screencast_precondition.cc @@ -0,0 +1,48 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/public/cpp/projector/projector_new_screencast_precondition.h" + +#include "base/values.h" + +namespace ash { + +namespace { +constexpr char kState[] = "state"; +constexpr char kReasons[] = "reasons"; +} // namespace + +NewScreencastPrecondition::NewScreencastPrecondition() = default; + +NewScreencastPrecondition::NewScreencastPrecondition( + NewScreencastPreconditionState new_state, + const std::vector& new_state_reason) + : state(new_state), reasons(new_state_reason) {} + +NewScreencastPrecondition::NewScreencastPrecondition( + const NewScreencastPrecondition&) = default; + +NewScreencastPrecondition& NewScreencastPrecondition::operator=( + const NewScreencastPrecondition&) = default; + +NewScreencastPrecondition::~NewScreencastPrecondition() = default; + +base::Value NewScreencastPrecondition::ToValue() const { + base::Value result(base::Value::Type::DICTIONARY); + result.SetIntKey(kState, static_cast(state)); + + base::Value reasons_value(base::Value::Type::LIST); + for (const auto& reason : reasons) + reasons_value.Append(static_cast(reason)); + + result.SetKey(kReasons, std::move(reasons_value)); + return result; +} + +bool NewScreencastPrecondition::operator==( + const NewScreencastPrecondition& rhs) const { + return rhs.state == state && rhs.reasons == reasons; +} + +} // namespace ash diff --git a/ash/public/cpp/projector/projector_new_screencast_precondition.h b/ash/public/cpp/projector/projector_new_screencast_precondition.h new file mode 100644 index 00000000000000..e60dedcdb90f86 --- /dev/null +++ b/ash/public/cpp/projector/projector_new_screencast_precondition.h @@ -0,0 +1,64 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_PUBLIC_CPP_PROJECTOR_PROJECTOR_NEW_SCREENCAST_PRECONDITION_H_ +#define ASH_PUBLIC_CPP_PROJECTOR_PROJECTOR_NEW_SCREENCAST_PRECONDITION_H_ + +#include + +#include "ash/public/cpp/ash_public_export.h" + +namespace base { +class Value; +} // namespace base + +namespace ash { + +// The new screencast button state in the Projector SWA. +// Ensure that this enum class is synchronized with +// NewScreencastPreconditionState enum in +// //ash/webui/projector_app/resources/communication/message_types.js. +enum class ASH_PUBLIC_EXPORT NewScreencastPreconditionState { + // The new screencast button is visible but is disabled. + kDisabled = 1, + // The new screencast button is enabled and the user can create new ones now. + kEnabled = 2 +}; + +// The reason for the new screencast button state. +// Ensure that this enum class is synchronized with +// NewScreencastPreconditionReason enum in +// //ash/webui/projector_app/resources/communication/message_types.js. +enum class ASH_PUBLIC_EXPORT NewScreencastPreconditionReason { + kOnDeviceSpeechRecognitionNotSupported = 1, + kUserLocaleNotSupported = 2, + kInProjectorSession = 3, + kScreenRecordingInProgress = 4, + kSodaDownloadInProgress = 5, + kOutOfDiskSpace = 6, + kNoMic = 7, + kOthers = 8 +}; + +// Struct used to provide the new screen cast precondition state and the reasons +// for such a state. +struct ASH_PUBLIC_EXPORT NewScreencastPrecondition { + NewScreencastPrecondition(); + NewScreencastPrecondition( + NewScreencastPreconditionState new_state, + const std::vector& new_state_reason); + NewScreencastPrecondition(const NewScreencastPrecondition&); + NewScreencastPrecondition& operator=(const NewScreencastPrecondition&); + ~NewScreencastPrecondition(); + + base::Value ToValue() const; + bool operator==(const NewScreencastPrecondition& rhs) const; + + NewScreencastPreconditionState state; + std::vector reasons; +}; + +} // namespace ash + +#endif // ASH_PUBLIC_CPP_PROJECTOR_PROJECTOR_NEW_SCREENCAST_PRECONDITION_H_ diff --git a/ash/public/cpp/test/mock_projector_controller.h b/ash/public/cpp/test/mock_projector_controller.h index f5e6f7d6f62be2..ea07bb0c50888a 100644 --- a/ash/public/cpp/test/mock_projector_controller.h +++ b/ash/public/cpp/test/mock_projector_controller.h @@ -6,6 +6,7 @@ #define ASH_PUBLIC_CPP_TEST_MOCK_PROJECTOR_CONTROLLER_H_ #include "ash/public/cpp/projector/projector_controller.h" +#include "ash/public/cpp/projector/projector_new_screencast_precondition.h" #include "testing/gmock/include/gmock/gmock.h" namespace ash { @@ -27,7 +28,7 @@ class MockProjectorController : public ash::ProjectorController { MOCK_METHOD0(OnTranscriptionError, void()); MOCK_METHOD1(SetProjectorToolsVisible, void(bool is_visible)); MOCK_CONST_METHOD0(IsEligible, bool()); - MOCK_CONST_METHOD0(CanStartNewSession, bool()); + MOCK_CONST_METHOD0(GetNewScreencastPrecondition, NewScreencastPrecondition()); MOCK_METHOD1(OnToolSet, void(const AnnotatorTool& tool)); MOCK_METHOD2(OnUndoRedoAvailabilityChanged, void(bool undo_available, bool redo_available)); diff --git a/ash/shell.h b/ash/shell.h index f36c16ba595591..1ae942b4a15f01 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -667,7 +667,6 @@ class ASH_EXPORT Shell : public SessionObserver, friend class AcceleratorControllerTest; friend class AshTestHelper; friend class RootWindowController; - friend class ScopedRootWindowForNewWindows; friend class ShellTestApi; friend class SmsObserverTest; diff --git a/ash/system/message_center/unified_message_center_bubble.cc b/ash/system/message_center/unified_message_center_bubble.cc index f2c1abce90c716..28d4dc6de564d8 100644 --- a/ash/system/message_center/unified_message_center_bubble.cc +++ b/ash/system/message_center/unified_message_center_bubble.cc @@ -106,8 +106,8 @@ void UnifiedMessageCenterBubble::ShowBubble() { float radius = kBubbleCornerRadius; widget_layer->SetRoundedCornerRadius({radius, radius, radius, radius}); widget_layer->SetIsFastRoundedCorner(true); + widget_layer->Add(border_->layer()); } - widget_layer->Add(border_->layer()); bubble_view_->InitializeAndShowBubble(); message_center_view_->Init(); @@ -173,8 +173,10 @@ void UnifiedMessageCenterBubble::UpdatePosition() { kUnifiedMessageCenterBubbleSpacing); bubble_view_->ChangeAnchorRect(anchor_rect); - bubble_widget_->GetLayer()->StackAtTop(border_->layer()); - border_->layer()->SetBounds(message_center_view_->GetContentsBounds()); + if (!features::IsNotificationsRefreshEnabled()) { + bubble_widget_->GetLayer()->StackAtTop(border_->layer()); + border_->layer()->SetBounds(message_center_view_->GetContentsBounds()); + } } void UnifiedMessageCenterBubble::FocusEntered(bool reverse) { @@ -229,6 +231,24 @@ void UnifiedMessageCenterBubble::OnViewPreferredSizeChanged( bubble_view_->Layout(); } +void UnifiedMessageCenterBubble::OnViewVisibilityChanged( + views::View* observed_view, + views::View* starting_view) { + // Hide the message center widget if the message center is not + // visible. This is to ensure we do not see an empty bubble. + + if (observed_view != message_center_view_) + return; + + if (observed_view->GetVisible()) { + bubble_widget_->Show(); + return; + } + + tray_->ActivateBubble(); + bubble_widget_->Hide(); +} + void UnifiedMessageCenterBubble::OnWidgetDestroying(views::Widget* widget) { CHECK_EQ(bubble_widget_, widget); tray_->tray_event_filter()->RemoveBubble(this); diff --git a/ash/system/message_center/unified_message_center_bubble.h b/ash/system/message_center/unified_message_center_bubble.h index f50660219287b5..3f722640f8e0d0 100644 --- a/ash/system/message_center/unified_message_center_bubble.h +++ b/ash/system/message_center/unified_message_center_bubble.h @@ -88,6 +88,8 @@ class ASH_EXPORT UnifiedMessageCenterBubble // views::ViewObserver: void OnViewPreferredSizeChanged(views::View* observed_view) override; + void OnViewVisibilityChanged(views::View* observed_view, + views::View* starting_view) override; // views::WidgetObserver: void OnWidgetDestroying(views::Widget* widget) override; diff --git a/ash/system/unified/hps_notify_controller.cc b/ash/system/unified/hps_notify_controller.cc index 1595a03d4e7820..bcca78cefb8ec2 100644 --- a/ash/system/unified/hps_notify_controller.cc +++ b/ash/system/unified/hps_notify_controller.cc @@ -66,7 +66,8 @@ void HpsNotifyController::OnSessionStateChanged( const bool session_active = session_state == session_manager::SessionState::ACTIVE; ReconfigureHps(hps_available_, session_active, pref_enabled_); - UpdateIconVisibility(session_active, hps_state_, pref_enabled_); + UpdateIconVisibility(session_active, hps_state_ && session_active, + pref_enabled_); } void HpsNotifyController::OnActiveUserPrefServiceChanged( @@ -76,7 +77,8 @@ void HpsNotifyController::OnActiveUserPrefServiceChanged( const bool pref_enabled = pref_service->GetBoolean(prefs::kSnoopingProtectionEnabled); ReconfigureHps(hps_available_, session_active_, pref_enabled); - UpdateIconVisibility(session_active_, hps_state_, pref_enabled); + UpdateIconVisibility(session_active_, hps_state_ && pref_enabled, + pref_enabled); // Re-subscribe to pref changes. pref_change_registrar_ = std::make_unique(); @@ -92,6 +94,8 @@ void HpsNotifyController::OnHpsNotifyChanged(bool hps_state) { } void HpsNotifyController::OnRestart() { + DCHECK(!hps_state_); + ReconfigureHps(/*hps_available_=*/true, session_active_, pref_enabled_); } @@ -214,7 +218,8 @@ void HpsNotifyController::UpdatePrefState() { const bool pref_enabled = pref_change_registrar_->prefs()->GetBoolean( prefs::kSnoopingProtectionEnabled); ReconfigureHps(hps_available_, session_active_, pref_enabled); - UpdateIconVisibility(session_active_, hps_state_, pref_enabled); + UpdateIconVisibility(session_active_, hps_state_ && pref_enabled, + pref_enabled); } } // namespace ash diff --git a/ash/system/unified/hps_notify_controller_unittest.cc b/ash/system/unified/hps_notify_controller_unittest.cc index 83e1b2d653ed33..19907edf31324a 100644 --- a/ash/system/unified/hps_notify_controller_unittest.cc +++ b/ash/system/unified/hps_notify_controller_unittest.cc @@ -315,6 +315,24 @@ TEST_F(HpsNotifyControllerTestPresent, Restarts) { EXPECT_TRUE(controller_->IsIconVisible()); } +// Check that the controller state stays consistent even when the daemon starts +// and stops. +TEST_F(HpsNotifyControllerTestPresent, ClearHpsState) { + SimulateLogin(); + SetEnabledPref(true); + EXPECT_EQ(controller_->IsIconVisible(), true); + + // This should internally clear the cached daemon state. + SetEnabledPref(false); + EXPECT_EQ(controller_->IsIconVisible(), false); + + // Note: we don't exhaust the run loop here since we want to check the + // controller state _before_ it is updated by asynchronous DBus calls. + Shell::Get()->session_controller()->GetActivePrefService()->SetBoolean( + prefs::kSnoopingProtectionEnabled, true); + EXPECT_EQ(controller_->IsIconVisible(), false); +} + // Fixture with the DBus service initially unavailable (using a minimal set of // valid params). class HpsNotifyControllerTestUnavailable : public HpsNotifyControllerTestBase { diff --git a/ash/webui/camera_app_ui/resources/js/barcode_chip.js b/ash/webui/camera_app_ui/resources/js/barcode_chip.ts similarity index 84% rename from ash/webui/camera_app_ui/resources/js/barcode_chip.js rename to ash/webui/camera_app_ui/resources/js/barcode_chip.ts index 2a180446f3df6a..796a944d18e064 100644 --- a/ash/webui/camera_app_ui/resources/js/barcode_chip.js +++ b/ash/webui/camera_app_ui/resources/js/barcode_chip.ts @@ -21,21 +21,18 @@ const CHIP_DURATION = 8000; /** * The detected string that is being shown currently. - * @type {?string} */ -let currentCode = null; +let currentCode: string|null = null; /** * The barcode chip container that is being shown currently. - * @type {?HTMLElement} */ -let currentChip = null; +let currentChip: HTMLElement|null = null; /** * The countdown timer for dismissing the chip. - * @type {?OneShotTimer} */ -let currentTimer = null; +let currentTimer: OneShotTimer|null = null; /** * Resets the variables of the current state and dismisses the chip. @@ -51,9 +48,9 @@ function deactivate() { /** * Activates the chip on container and starts the timer. - * @param {!HTMLElement} container The container of the chip. + * @param container The container of the chip. */ -function activate(container) { +function activate(container: HTMLElement) { container.classList.remove('invisible'); currentChip = container; @@ -67,10 +64,8 @@ function activate(container) { /** * Checks whether a string is a regular url link with http or https protocol. - * @param {string} s - * @return {boolean} */ -function isSafeUrl(s) { +function isSafeUrl(s: string): boolean { try { const url = new URL(s); if (url.protocol !== 'http:' && url.protocol !== 'https:') { @@ -87,13 +82,15 @@ function isSafeUrl(s) { /** * Setups the copy button. - * @param {!HTMLElement} container The container for the button. - * @param {string} content The content to be copied. - * @param {!I18nString} snackbarLabel The label to be displayed on snackbar when - * the content is copied. - * @return {!HTMLElement} The copy button element. + * @param container The container for the button. + * @param content The content to be copied. + * @param snackbarLabel The label to be displayed on snackbar when the content + * is copied. + * @return The copy button element. */ -function setupCopyButton(container, content, snackbarLabel) { +function setupCopyButton( + container: HTMLElement, content: string, + snackbarLabel: I18nString): HTMLElement { const copyButton = dom.getFrom(container, '.barcode-copy-button', HTMLButtonElement); copyButton.onclick = async () => { @@ -105,9 +102,8 @@ function setupCopyButton(container, content, snackbarLabel) { /** * Shows an actionable url chip. - * @param {string} url */ -function showUrl(url) { +function showUrl(url: string) { const container = dom.get('#barcode-chip-url-container', HTMLDivElement); activate(container); @@ -128,9 +124,8 @@ function showUrl(url) { /** * Shows an actionable text chip. - * @param {string} text */ -function showText(text) { +function showText(text: string) { const container = dom.get('#barcode-chip-text-container', HTMLDivElement); activate(container); container.classList.remove('expanded'); @@ -161,9 +156,8 @@ function showText(text) { /** * Shows an actionable chip for the string detected from a barcode. - * @param {string} code */ -export async function show(code) { +export async function show(code: string): Promise { if (code === currentCode) { if (currentTimer !== null) { // Extend the duration by resetting the timeout. @@ -192,7 +186,7 @@ export async function show(code) { /** * Dismisses the current barcode chip if it's being shown. */ -export function dismiss() { +export function dismiss(): void { if (currentTimer === null) { return; } diff --git a/ash/webui/camera_app_ui/resources/js/js.gni b/ash/webui/camera_app_ui/resources/js/js.gni index 29372572234b9a..b2f1d687aeeae1 100644 --- a/ash/webui/camera_app_ui/resources/js/js.gni +++ b/ash/webui/camera_app_ui/resources/js/js.gni @@ -7,7 +7,7 @@ compile_js_files = [ "app_window.ts", "assert.ts", "async_job_queue.ts", - "barcode_chip.js", + "barcode_chip.ts", "css.ts", "device/camera3_device_info.js", "device/constraints_preferrer.js", diff --git a/ash/webui/diagnostics_ui/backend/BUILD.gn b/ash/webui/diagnostics_ui/backend/BUILD.gn index 99abf73182c952..0de4aa05c728be 100644 --- a/ash/webui/diagnostics_ui/backend/BUILD.gn +++ b/ash/webui/diagnostics_ui/backend/BUILD.gn @@ -47,7 +47,6 @@ static_library("backend") { ] deps = [ - "//ash", "//ash/constants:constants", "//ash/public/cpp", "//ash/webui/diagnostics_ui/mojom", @@ -66,8 +65,6 @@ static_library("backend") { "//services/device/public/mojom", "//ui/base", "//ui/base/ime/ash", - "//ui/chromeos/events", - "//ui/events/devices", "//ui/events/ozone", "//ui/events/ozone/evdev:event_device_info", "//ui/events/ozone/layout", @@ -121,11 +118,9 @@ source_set("unit_tests") { "//components/sync_preferences:test_support", "//content/test:test_support", "//dbus", - "//device/udev_linux:test_support", "//services/data_decoder/public/cpp:test_support", "//services/device/public/cpp:test_support", "//testing/gtest", - "//ui/chromeos/events", "//ui/events/ozone", "//ui/events/ozone/evdev:event_device_info_test_utils", "//ui/gfx", diff --git a/ash/webui/diagnostics_ui/backend/DEPS b/ash/webui/diagnostics_ui/backend/DEPS deleted file mode 100644 index bb33d0a1a6d699..00000000000000 --- a/ash/webui/diagnostics_ui/backend/DEPS +++ /dev/null @@ -1,5 +0,0 @@ -specific_include_rules = { - "input_data_provider_unittest\.cc": [ - "+device/udev_linux/fake_udev_loader.h", - ] -} diff --git a/ash/webui/diagnostics_ui/backend/input_data_provider.cc b/ash/webui/diagnostics_ui/backend/input_data_provider.cc index 04f2b764f8d679..3e93f9bc6db506 100644 --- a/ash/webui/diagnostics_ui/backend/input_data_provider.cc +++ b/ash/webui/diagnostics_ui/backend/input_data_provider.cc @@ -20,8 +20,6 @@ #include "base/strings/string_util.h" #include "chromeos/system/statistics_provider.h" #include "ui/base/ime/ash/input_method_manager.h" -#include "ui/events/devices/device_util_linux.h" -#include "ui/events/devices/input_device.h" #include "ui/events/event_constants.h" #include "ui/events/keycodes/dom/keycode_converter.h" #include "ui/events/ozone/evdev/event_device_info.h" @@ -35,27 +33,27 @@ bool GetEventNodeId(base::FilePath path, int* id) { const std::string base_name_prefix = "event"; std::string base_name = path.BaseName().value(); - if (!base::StartsWith(base_name, base_name_prefix)) - return false; + DCHECK(base::StartsWith(base_name, base_name_prefix)); base_name.erase(0, base_name_prefix.length()); return base::StringToInt(base_name, id); } -// Determine if this particular evdev provides touchpad or touchscreen input; -// we do not want stylus devices, which also claim to be touchscreens. -bool IsTouchInputDevice(InputDeviceInformation* device_info) { - return (device_info->event_device_info.HasTouchpad() || - (device_info->event_device_info.HasTouchscreen() && - !device_info->event_device_info.HasStylus())); +mojom::ConnectionType ConnectionTypeFromInputDeviceType( + ui::InputDeviceType type) { + switch (type) { + case ui::InputDeviceType::INPUT_DEVICE_INTERNAL: + return mojom::ConnectionType::kInternal; + case ui::InputDeviceType::INPUT_DEVICE_USB: + return mojom::ConnectionType::kUsb; + case ui::InputDeviceType::INPUT_DEVICE_BLUETOOTH: + return mojom::ConnectionType::kBluetooth; + case ui::InputDeviceType::INPUT_DEVICE_UNKNOWN: + return mojom::ConnectionType::kUnknown; + } } - } // namespace -// All blockings calls for identifying hardware need to go here: both -// EventDeviceInfo::Initialize and ui::GetInputPathInSys can block in -// base::MakeAbsoluteFilePath. -std::unique_ptr InputDeviceInfoHelper::GetDeviceInfo( - int id, +std::unique_ptr InputDeviceInfoHelper::GetDeviceInfo( base::FilePath path) { base::ScopedFD fd(open(path.value().c_str(), O_RDWR | O_NONBLOCK)); if (fd.get() < 0) { @@ -63,26 +61,12 @@ std::unique_ptr InputDeviceInfoHelper::GetDeviceInfo( return nullptr; } - auto info = std::make_unique(); - - if (!info->event_device_info.Initialize(fd.get(), path)) { + auto device_info = std::make_unique(); + if (!device_info->Initialize(fd.get(), path)) { LOG(ERROR) << "Failed to get device info for " << path; return nullptr; } - - const base::FilePath sys_path = ui::GetInputPathInSys(path); - - info->path = path; - info->evdev_id = id; - info->connection_type = InputDataProvider::ConnectionTypeFromInputDeviceType( - info->event_device_info.device_type()); - info->input_device = ui::InputDevice( - id, info->event_device_info.device_type(), info->event_device_info.name(), - info->event_device_info.phys(), sys_path, - info->event_device_info.vendor_id(), info->event_device_info.product_id(), - info->event_device_info.version()); - - return info; + return device_info; } InputDataProvider::InputDataProvider() @@ -100,21 +84,6 @@ InputDataProvider::~InputDataProvider() { device_manager_->RemoveObserver(this); } -// static -mojom::ConnectionType InputDataProvider::ConnectionTypeFromInputDeviceType( - ui::InputDeviceType type) { - switch (type) { - case ui::InputDeviceType::INPUT_DEVICE_INTERNAL: - return mojom::ConnectionType::kInternal; - case ui::InputDeviceType::INPUT_DEVICE_USB: - return mojom::ConnectionType::kUsb; - case ui::InputDeviceType::INPUT_DEVICE_BLUETOOTH: - return mojom::ConnectionType::kBluetooth; - case ui::InputDeviceType::INPUT_DEVICE_UNKNOWN: - return mojom::ConnectionType::kUnknown; - } -} - void InputDataProvider::Initialize() { device_manager_->AddObserver(this); device_manager_->ScanDevices(this); @@ -135,7 +104,6 @@ bool InputDataProvider::ReceiverIsBound() { void InputDataProvider::OnBoundInterfaceDisconnect() { receiver_.reset(); } - void InputDataProvider::GetConnectedDevices( GetConnectedDevicesCallback callback) { std::vector keyboard_vector; @@ -190,12 +158,10 @@ void InputDataProvider::OnDeviceEvent(const ui::DeviceEvent& event) { if (event.action_type() == ui::DeviceEvent::ActionType::ADD) { info_helper_.AsyncCall(&InputDeviceInfoHelper::GetDeviceInfo) - .WithArgs(id, event.path()) + .WithArgs(event.path()) .Then(base::BindOnce(&InputDataProvider::ProcessDeviceInfo, - weak_factory_.GetWeakPtr())); - + weak_factory_.GetWeakPtr(), id)); } else { - DCHECK(event.action_type() == ui::DeviceEvent::ActionType::REMOVE); if (keyboards_.contains(id)) { keyboards_.erase(id); for (auto& observer : connected_devices_observers_) { @@ -210,39 +176,40 @@ void InputDataProvider::OnDeviceEvent(const ui::DeviceEvent& event) { } } -InputDeviceInformation::InputDeviceInformation() = default; -InputDeviceInformation::~InputDeviceInformation() = default; - void InputDataProvider::ProcessDeviceInfo( - std::unique_ptr device_info) { + int id, + std::unique_ptr device_info) { if (device_info == nullptr) { return; } - if (IsTouchInputDevice(device_info.get())) { - AddTouchDevice(device_info.get()); - } else if (device_info->event_device_info.HasKeyboard()) { - AddKeyboard(device_info.get()); + if (device_info->HasTouchpad() || + (device_info->HasTouchscreen() && !device_info->HasStylus())) { + AddTouchDevice(id, device_info.get()); + } else if (device_info->HasKeyboard()) { + AddKeyboard(id, device_info.get()); } } -void InputDataProvider::AddTouchDevice( - const InputDeviceInformation* device_info) { - touch_devices_[device_info->evdev_id] = - touch_helper_.ConstructTouchDevice(device_info); +void InputDataProvider::AddTouchDevice(int id, + const ui::EventDeviceInfo* device_info) { + touch_devices_[id] = touch_helper_.ConstructTouchDevice( + id, device_info, + ConnectionTypeFromInputDeviceType(device_info->device_type())); for (auto& observer : connected_devices_observers_) { - observer->OnTouchDeviceConnected( - touch_devices_[device_info->evdev_id]->Clone()); + observer->OnTouchDeviceConnected(touch_devices_[id]->Clone()); } } -void InputDataProvider::AddKeyboard(const InputDeviceInformation* device_info) { - keyboards_[device_info->evdev_id] = - keyboard_helper_.ConstructKeyboard(device_info); +void InputDataProvider::AddKeyboard(int id, + const ui::EventDeviceInfo* device_info) { + keyboards_[id] = keyboard_helper_.ConstructKeyboard( + id, device_info, + ConnectionTypeFromInputDeviceType(device_info->device_type())); for (auto& observer : connected_devices_observers_) { - observer->OnKeyboardConnected(keyboards_[device_info->evdev_id]->Clone()); + observer->OnKeyboardConnected(keyboards_[id]->Clone()); } } diff --git a/ash/webui/diagnostics_ui/backend/input_data_provider.h b/ash/webui/diagnostics_ui/backend/input_data_provider.h index cf86582d883df4..699e974e44eb95 100644 --- a/ash/webui/diagnostics_ui/backend/input_data_provider.h +++ b/ash/webui/diagnostics_ui/backend/input_data_provider.h @@ -18,7 +18,6 @@ #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/remote_set.h" -#include "ui/chromeos/events/event_rewriter_chromeos.h" #include "ui/events/ozone/device/device_event.h" #include "ui/events/ozone/device/device_event_observer.h" #include "ui/events/ozone/device/device_manager.h" @@ -27,37 +26,14 @@ namespace ash { namespace diagnostics { -// Wrapper for tracking several pieces of information about an evdev-backed -// device. -class InputDeviceInformation { - public: - InputDeviceInformation(); - InputDeviceInformation(const InputDeviceInformation& other) = delete; - InputDeviceInformation& operator=(const InputDeviceInformation& other) = - delete; - ~InputDeviceInformation(); - - int evdev_id; - ui::EventDeviceInfo event_device_info; - ui::InputDevice input_device; - mojom::ConnectionType connection_type; - base::FilePath path; -}; - -// Class for running GetDeviceInfo in its own sequence that can block. class InputDeviceInfoHelper { public: - InputDeviceInfoHelper() {} virtual ~InputDeviceInfoHelper() {} - virtual std::unique_ptr GetDeviceInfo( - int evdev_id, + virtual std::unique_ptr GetDeviceInfo( base::FilePath path); }; -// Provides information about input devices connected to the system. Implemented -// in the browser process and called by the Diagnostics SWA (a renderer -// process). class InputDataProvider : public mojom::InputDataProvider, public ui::DeviceEventObserver { public: @@ -72,8 +48,6 @@ class InputDataProvider : public mojom::InputDataProvider, // Handler for when remote attached to |receiver_| disconnects. void OnBoundInterfaceDisconnect(); bool ReceiverIsBound(); - static mojom::ConnectionType ConnectionTypeFromInputDeviceType( - ui::InputDeviceType type); // mojom::InputDataProvider: void GetConnectedDevices(GetConnectedDevicesCallback callback) override; @@ -95,15 +69,15 @@ class InputDataProvider : public mojom::InputDataProvider, private: void Initialize(); - void ProcessDeviceInfo(std::unique_ptr device_info); + void ProcessDeviceInfo(int id, + std::unique_ptr device_info); - void AddTouchDevice(const InputDeviceInformation* device_info); - void AddKeyboard(const InputDeviceInformation* device_info); + void AddTouchDevice(int id, const ui::EventDeviceInfo* device_info); + void AddKeyboard(int id, const ui::EventDeviceInfo* device_info); InputDataProviderKeyboard keyboard_helper_; InputDataProviderTouch touch_helper_; - // Map by evdev ids to information blocks base::flat_map keyboards_; base::flat_map touch_devices_; diff --git a/ash/webui/diagnostics_ui/backend/input_data_provider_keyboard.cc b/ash/webui/diagnostics_ui/backend/input_data_provider_keyboard.cc index aab7065f5c9836..568bad75111ef1 100644 --- a/ash/webui/diagnostics_ui/backend/input_data_provider_keyboard.cc +++ b/ash/webui/diagnostics_ui/backend/input_data_provider_keyboard.cc @@ -4,17 +4,10 @@ #include "ash/webui/diagnostics_ui/backend/input_data_provider_keyboard.h" -#include -#include #include #include "ash/constants/ash_switches.h" -#include "ash/display/privacy_screen_controller.h" -#include "ash/shell.h" -#include "ash/webui/diagnostics_ui/backend/input_data_provider.h" #include "base/command_line.h" -#include "base/containers/fixed_flat_map.h" -#include "base/files/scoped_file.h" #include "base/logging.h" #include "base/run_loop.h" #include "base/strings/strcat.h" @@ -23,9 +16,6 @@ #include "base/strings/string_util.h" #include "chromeos/system/statistics_provider.h" #include "ui/base/ime/ash/input_method_manager.h" -#include "ui/chromeos/events/event_rewriter_chromeos.h" -#include "ui/events/devices/device_util_linux.h" -#include "ui/events/devices/input_device.h" #include "ui/events/event_constants.h" #include "ui/events/keycodes/dom/keycode_converter.h" #include "ui/events/ozone/evdev/event_device_info.h" @@ -35,135 +25,6 @@ namespace diagnostics { namespace { -enum { - kFKey1 = 0, - kFKey2, - kFKey3, - kFKey4, - kFKey5, - kFKey6, - kFKey7, - kFKey8, - kFKey9, - kFKey10, - kFKey11, - kFKey12, - kFKey13, - kFKey14, - kFKey15 -}; - -// Mapping from keyboard scancodes to TopRowKeys (must be in scancode-sorted -// order). This replicates and should be identical to the mapping behaviour -// of ChromeOS: changes will be needed if new AT scancodes or HID mappings -// are used in a top-row key, likely added in -// ui/events/keycodes/dom/dom_code_data.inc -// -// Note that there are no dedicated scancodes for kScreenMirror. -constexpr auto kScancodeMapping = - base::MakeFixedFlatMap({ - // Vivaldi extended Set-1 AT-style scancodes - {0x90, mojom::TopRowKey::kPreviousTrack}, - {0x91, mojom::TopRowKey::kFullscreen}, - {0x92, mojom::TopRowKey::kOverview}, - {0x93, mojom::TopRowKey::kScreenshot}, - {0x94, mojom::TopRowKey::kScreenBrightnessDown}, - {0x95, mojom::TopRowKey::kScreenBrightnessUp}, - {0x96, mojom::TopRowKey::kPrivacyScreenToggle}, - {0x97, mojom::TopRowKey::kKeyboardBacklightDown}, - {0x98, mojom::TopRowKey::kKeyboardBacklightUp}, - {0x99, mojom::TopRowKey::kNextTrack}, - {0x9A, mojom::TopRowKey::kPlayPause}, - {0xA0, mojom::TopRowKey::kVolumeMute}, - {0xAE, mojom::TopRowKey::kVolumeDown}, - {0xB0, mojom::TopRowKey::kVolumeUp}, - {0xD3, mojom::TopRowKey::kDelete}, // Only relevant for Drallion. - {0xE9, mojom::TopRowKey::kForward}, - {0xEA, mojom::TopRowKey::kBack}, - {0xE7, mojom::TopRowKey::kRefresh}, - - // HID 32-bit usage codes - {0x070046, mojom::TopRowKey::kScreenshot}, - {0x0C00E2, mojom::TopRowKey::kVolumeMute}, - {0x0C00E9, mojom::TopRowKey::kVolumeUp}, - {0x0C00EA, mojom::TopRowKey::kVolumeDown}, - {0x0C006F, mojom::TopRowKey::kScreenBrightnessUp}, - {0x0C0070, mojom::TopRowKey::kScreenBrightnessDown}, - {0x0C0079, mojom::TopRowKey::kKeyboardBacklightUp}, - {0x0C007A, mojom::TopRowKey::kKeyboardBacklightDown}, - {0x0C00B5, mojom::TopRowKey::kNextTrack}, - {0x0C00B6, mojom::TopRowKey::kPreviousTrack}, - {0x0C00CD, mojom::TopRowKey::kPlayPause}, - {0x0C0224, mojom::TopRowKey::kBack}, - {0x0C0225, mojom::TopRowKey::kForward}, - {0x0C0227, mojom::TopRowKey::kRefresh}, - {0x0C0232, mojom::TopRowKey::kFullscreen}, - {0x0C029F, mojom::TopRowKey::kOverview}, - {0x0C02D0, mojom::TopRowKey::kPrivacyScreenToggle}, - }); - -// Hard-coded top-row key mappings. These are intended to match the behaviour of -// EventRewriterChromeOS::RewriteFunctionKeys for historical keyboards. No -// updates should be needed, as all new keyboards are expected to be using -// customizable top row keys (vivaldi). - -constexpr mojom::TopRowKey kSystemKeys1[] = { - mojom::TopRowKey::kBack, - mojom::TopRowKey::kForward, - mojom::TopRowKey::kRefresh, - mojom::TopRowKey::kFullscreen, - mojom::TopRowKey::kOverview, - mojom::TopRowKey::kScreenBrightnessDown, - mojom::TopRowKey::kScreenBrightnessUp, - mojom::TopRowKey::kVolumeMute, - mojom::TopRowKey::kVolumeDown, - mojom::TopRowKey::kVolumeUp}; - -constexpr mojom::TopRowKey kSystemKeys2[] = { - mojom::TopRowKey::kBack, - mojom::TopRowKey::kRefresh, - mojom::TopRowKey::kFullscreen, - mojom::TopRowKey::kOverview, - mojom::TopRowKey::kScreenBrightnessDown, - mojom::TopRowKey::kScreenBrightnessUp, - mojom::TopRowKey::kPlayPause, - mojom::TopRowKey::kVolumeMute, - mojom::TopRowKey::kVolumeDown, - mojom::TopRowKey::kVolumeUp}; - -constexpr mojom::TopRowKey kSystemKeysWilco[] = { - mojom::TopRowKey::kBack, - mojom::TopRowKey::kRefresh, - mojom::TopRowKey::kFullscreen, - mojom::TopRowKey::kOverview, - mojom::TopRowKey::kScreenBrightnessDown, - mojom::TopRowKey::kScreenBrightnessUp, - mojom::TopRowKey::kVolumeMute, - mojom::TopRowKey::kVolumeDown, - mojom::TopRowKey::kVolumeUp, - mojom::TopRowKey::kNone, // F10 - mojom::TopRowKey::kNone, // F11 - mojom::TopRowKey::kScreenMirror, // F12 - mojom::TopRowKey::kDelete // Just a normal Delete key, but in the top row. -}; - -constexpr mojom::TopRowKey kSystemKeysDrallion[] = { - mojom::TopRowKey::kBack, - mojom::TopRowKey::kRefresh, - mojom::TopRowKey::kFullscreen, - mojom::TopRowKey::kOverview, - mojom::TopRowKey::kScreenBrightnessDown, - mojom::TopRowKey::kScreenBrightnessUp, - mojom::TopRowKey::kVolumeMute, - mojom::TopRowKey::kVolumeDown, - mojom::TopRowKey::kVolumeUp, - mojom::TopRowKey::kNone, // F10 - mojom::TopRowKey::kNone, // F11 - mojom::TopRowKey::kNone, // F12 - May be Privacy Screen on some models. - mojom::TopRowKey::kScreenMirror, - mojom::TopRowKey::kDelete // Just a normal Delete key, but in the top row. -}; - mojom::MechanicalLayout GetSystemMechanicalLayout() { chromeos::system::StatisticsProvider* stats_provider = chromeos::system::StatisticsProvider::GetInstance(); @@ -290,96 +151,17 @@ mojom::KeyGlyphSetPtr InputDataProviderKeyboard::LookupGlyphSet( return glyph_set; } -void InputDataProviderKeyboard::ProcessKeyboardTopRowLayout( - const InputDeviceInformation* device_info, - ui::EventRewriterChromeOS::KeyboardTopRowLayout* out_top_row_layout, - std::vector* out_top_row_keys) { - ui::InputDevice input_device = device_info->input_device; - ui::EventRewriterChromeOS::DeviceType device_type; - ui::EventRewriterChromeOS::KeyboardTopRowLayout top_row_layout; - base::flat_map - scan_code_map; - ui::EventRewriterChromeOS::IdentifyKeyboard(input_device, &device_type, - &top_row_layout, &scan_code_map); - - // Simple array in physical order from left to right - std::vector top_row_keys = {}; - - switch (top_row_layout) { - case ui::EventRewriterChromeOS::kKbdTopRowLayoutWilco: - top_row_keys.assign(std::begin(kSystemKeysWilco), - std::end(kSystemKeysWilco)); - break; - - case ui::EventRewriterChromeOS::kKbdTopRowLayoutDrallion: - top_row_keys.assign(std::begin(kSystemKeysDrallion), - std::end(kSystemKeysDrallion)); - - // On some Drallion devices, the F12 key is used for the Privacy Screen. - - // This should be the same logic as in - // EventRewriterControllerImpl::Initialize. This is a historic device, and - // this logic should not need to be updated, as newer devices will use - // custom top row layouts (vivaldi). - if (Shell::Get()->privacy_screen_controller() && - Shell::Get()->privacy_screen_controller()->IsSupported()) { - top_row_keys[kFKey12] = mojom::TopRowKey::kPrivacyScreenToggle; - } - - break; - - case ui::EventRewriterChromeOS::kKbdTopRowLayoutCustom: - - // Process scan-code map generated from custom top-row key layout: it maps - // from physical scan codes to several things, including VKEY key-codes, - // which we will use to produce indexes. - - for (auto iter = scan_code_map.begin(); iter != scan_code_map.end(); - iter++) { - size_t fn_key_number = iter->second.key_code - ui::VKEY_F1; - uint32_t scancode = iter->first; - - if (top_row_keys.size() < fn_key_number + 1) - top_row_keys.resize(fn_key_number + 1, mojom::TopRowKey::kNone); - - if (kScancodeMapping.contains(scancode)) - top_row_keys[fn_key_number] = kScancodeMapping.at(scancode); - else - top_row_keys[fn_key_number] = mojom::TopRowKey::kUnknown; - } - break; - - case ui::EventRewriterChromeOS::kKbdTopRowLayout2: - top_row_keys.assign(std::begin(kSystemKeys2), std::end(kSystemKeys2)); - break; - - case ui::EventRewriterChromeOS::kKbdTopRowLayout1: - default: - top_row_keys.assign(std::begin(kSystemKeys1), std::end(kSystemKeys1)); - } - - *out_top_row_layout = std::move(top_row_layout); - *out_top_row_keys = std::move(top_row_keys); -} - mojom::KeyboardInfoPtr InputDataProviderKeyboard::ConstructKeyboard( - const InputDeviceInformation* device_info) { + int id, + const ui::EventDeviceInfo* device_info, + mojom::ConnectionType connection_type) { mojom::KeyboardInfoPtr result = mojom::KeyboardInfo::New(); - - result->id = device_info->evdev_id; - result->connection_type = device_info->connection_type; - result->name = device_info->event_device_info.name(); - - // TODO(crbug.com/1207678): review support for WWCB keyboards, Chromebase - // keyboards, and Dell KM713 Chrome keyboard. - - ui::EventRewriterChromeOS::KeyboardTopRowLayout top_row_layout_type; - - ProcessKeyboardTopRowLayout(device_info, &top_row_layout_type, - &result->top_row_keys); + result->id = id; + result->connection_type = connection_type; + result->name = device_info->name(); if (result->connection_type == mojom::ConnectionType::kInternal) { - if (device_info->event_device_info.HasKeyEvent(KEY_KBD_LAYOUT_NEXT)) { + if (device_info->HasKeyEvent(KEY_KBD_LAYOUT_NEXT)) { // Only Dell Enterprise devices have this key, marked by a globe icon. result->physical_layout = mojom::PhysicalLayout::kChromeOSDellEnterprise; } else { @@ -394,36 +176,14 @@ mojom::KeyboardInfoPtr InputDataProviderKeyboard::ConstructKeyboard( chromeos::switches::kHasNumberPad) ? mojom::NumberPadPresence::kPresent : mojom::NumberPadPresence::kNotPresent; - - // Log if there is contradictory information. - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - chromeos::switches::kHasNumberPad) && - !device_info->event_device_info.HasNumberpad()) - LOG(ERROR) << "OS believes internal numberpad is implemented, but " - "evdev disagrees."; } else { result->physical_layout = mojom::PhysicalLayout::kUnknown; - - if (top_row_layout_type == ui::EventRewriterChromeOS::KeyboardTopRowLayout:: - kKbdTopRowLayoutCustom) { - // If keyboard has WWCB top row custom layout (vivaldi) then we can trust - // the HID descriptor to be accurate about presence of keys. - result->number_pad_present = - !device_info->event_device_info.HasNumberpad() - ? mojom::NumberPadPresence::kNotPresent - : mojom::NumberPadPresence::kPresent; - } else { - // Without WWCB information, absence of KP keycodes means it definitely - // doesn't have a numberpad, but the presence isn't a reliable indicator. - result->number_pad_present = - !device_info->event_device_info.HasNumberpad() - ? mojom::NumberPadPresence::kNotPresent - : mojom::NumberPadPresence::kUnknown; - } + result->number_pad_present = mojom::NumberPadPresence::kUnknown; + // TODO(crbug.com/1207678): support WWCB keyboards, Chromebase keyboards, + // and Dell KM713 Chrome keyboard. } - result->has_assistant_key = - device_info->event_device_info.HasKeyEvent(KEY_ASSISTANT); + result->has_assistant_key = device_info->HasKeyEvent(KEY_ASSISTANT); return result; } diff --git a/ash/webui/diagnostics_ui/backend/input_data_provider_keyboard.h b/ash/webui/diagnostics_ui/backend/input_data_provider_keyboard.h index ea6f94817d8913..14776d18d35bf3 100644 --- a/ash/webui/diagnostics_ui/backend/input_data_provider_keyboard.h +++ b/ash/webui/diagnostics_ui/backend/input_data_provider_keyboard.h @@ -7,7 +7,6 @@ #include "ash/webui/diagnostics_ui/mojom/input_data_provider.mojom.h" #include "base/memory/weak_ptr.h" -#include "ui/chromeos/events/event_rewriter_chromeos.h" #include "ui/events/ozone/evdev/event_device_info.h" #include "ui/events/ozone/layout/xkb/xkb_evdev_codes.h" #include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h" @@ -15,8 +14,6 @@ namespace ash { namespace diagnostics { -class InputDeviceInformation; - // Helper to provide InputDataProvider diagnostic interface with // keyboard-specific logic. class InputDataProviderKeyboard { @@ -32,18 +29,15 @@ class InputDataProviderKeyboard { mojom::InputDataProvider::GetKeyboardVisualLayoutCallback callback); mojom::KeyboardInfoPtr ConstructKeyboard( - const InputDeviceInformation* device_info); + int id, + const ui::EventDeviceInfo* device_info, + mojom::ConnectionType connection_type); private: void ProcessXkbLayout( mojom::InputDataProvider::GetKeyboardVisualLayoutCallback callback); mojom::KeyGlyphSetPtr LookupGlyphSet(uint32_t evdev_code); - void ProcessKeyboardTopRowLayout( - const InputDeviceInformation* device_info, - ui::EventRewriterChromeOS::KeyboardTopRowLayout* out_top_row_layout, - std::vector* out_top_row_keys); - ui::XkbEvdevCodes xkb_evdev_codes_; ui::XkbKeyboardLayoutEngine xkb_layout_engine_; diff --git a/ash/webui/diagnostics_ui/backend/input_data_provider_touch.cc b/ash/webui/diagnostics_ui/backend/input_data_provider_touch.cc index 48b05e871db8bb..29335cc5bc38f5 100644 --- a/ash/webui/diagnostics_ui/backend/input_data_provider_touch.cc +++ b/ash/webui/diagnostics_ui/backend/input_data_provider_touch.cc @@ -3,8 +3,6 @@ // found in the LICENSE file. #include "ash/webui/diagnostics_ui/backend/input_data_provider_touch.h" -#include "ash/webui/diagnostics_ui/backend/input_data_provider.h" -#include "base/logging.h" #include "ui/events/ozone/evdev/event_device_info.h" namespace ash { @@ -14,17 +12,15 @@ InputDataProviderTouch::InputDataProviderTouch() {} InputDataProviderTouch::~InputDataProviderTouch() {} mojom::TouchDeviceInfoPtr InputDataProviderTouch::ConstructTouchDevice( - const InputDeviceInformation* device_info) { + int id, + const ui::EventDeviceInfo* device_info, + mojom::ConnectionType connection_type) { mojom::TouchDeviceInfoPtr result = mojom::TouchDeviceInfo::New(); - - result->id = device_info->evdev_id; - result->connection_type = device_info->connection_type; - - // TODO(crbug.com/1207678): double-check logic - result->type = device_info->event_device_info.HasTouchpad() - ? mojom::TouchDeviceType::kPointer - : mojom::TouchDeviceType::kDirect; - result->name = device_info->event_device_info.name(); + result->id = id; + result->connection_type = connection_type; + result->type = device_info->HasTouchpad() ? mojom::TouchDeviceType::kPointer + : mojom::TouchDeviceType::kDirect; + result->name = device_info->name(); return result; } diff --git a/ash/webui/diagnostics_ui/backend/input_data_provider_touch.h b/ash/webui/diagnostics_ui/backend/input_data_provider_touch.h index 5fe7db225a3e14..93aaa5655511e5 100644 --- a/ash/webui/diagnostics_ui/backend/input_data_provider_touch.h +++ b/ash/webui/diagnostics_ui/backend/input_data_provider_touch.h @@ -11,8 +11,6 @@ namespace ash { namespace diagnostics { -class InputDeviceInformation; - // Helper to provide InputDataProvider diagnostic interface with touch-specific // logic. class InputDataProviderTouch { @@ -23,7 +21,9 @@ class InputDataProviderTouch { ~InputDataProviderTouch(); mojom::TouchDeviceInfoPtr ConstructTouchDevice( - const InputDeviceInformation* device_info); + int id, + const ui::EventDeviceInfo* device_info, + mojom::ConnectionType connection_type); }; } // namespace diagnostics diff --git a/ash/webui/diagnostics_ui/backend/input_data_provider_unittest.cc b/ash/webui/diagnostics_ui/backend/input_data_provider_unittest.cc index e07bf86face01f..a09db7b9717024 100644 --- a/ash/webui/diagnostics_ui/backend/input_data_provider_unittest.cc +++ b/ash/webui/diagnostics_ui/backend/input_data_provider_unittest.cc @@ -8,13 +8,10 @@ #include "base/command_line.h" #include "base/run_loop.h" -#include "base/strings/stringprintf.h" #include "base/test/bind.h" #include "base/test/task_environment.h" -#include "base/test/test_future.h" #include "chromeos/system/fake_statistics_provider.h" #include "chromeos/system/statistics_provider.h" -#include "device/udev_linux/fake_udev_loader.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/events/ozone/device/device_event_observer.h" #include "ui/events/ozone/device/device_manager.h" @@ -23,77 +20,6 @@ namespace ash { namespace diagnostics { -namespace { - -constexpr mojom::TopRowKey kClassicTopRowKeys[] = { - mojom::TopRowKey::kBack, - mojom::TopRowKey::kForward, - mojom::TopRowKey::kRefresh, - mojom::TopRowKey::kFullscreen, - mojom::TopRowKey::kOverview, - mojom::TopRowKey::kScreenBrightnessDown, - mojom::TopRowKey::kScreenBrightnessUp, - mojom::TopRowKey::kVolumeMute, - mojom::TopRowKey::kVolumeDown, - mojom::TopRowKey::kVolumeUp}; - -constexpr mojom::TopRowKey kInternalJinlonTopRowKeys[] = { - mojom::TopRowKey::kBack, - mojom::TopRowKey::kRefresh, - mojom::TopRowKey::kFullscreen, - mojom::TopRowKey::kOverview, - mojom::TopRowKey::kScreenshot, - mojom::TopRowKey::kScreenBrightnessDown, - mojom::TopRowKey::kScreenBrightnessUp, - mojom::TopRowKey::kPrivacyScreenToggle, - mojom::TopRowKey::kKeyboardBacklightDown, - mojom::TopRowKey::kKeyboardBacklightUp, - mojom::TopRowKey::kVolumeMute, - mojom::TopRowKey::kVolumeDown, - mojom::TopRowKey::kVolumeUp}; - -// One possible variant of a Dell configuration -constexpr mojom::TopRowKey kInternalDellTopRowKeys[] = { - mojom::TopRowKey::kBack, - mojom::TopRowKey::kRefresh, - mojom::TopRowKey::kFullscreen, - mojom::TopRowKey::kOverview, - mojom::TopRowKey::kScreenBrightnessDown, - mojom::TopRowKey::kScreenBrightnessUp, - mojom::TopRowKey::kVolumeMute, - mojom::TopRowKey::kVolumeDown, - mojom::TopRowKey::kVolumeUp, - mojom::TopRowKey::kNone, - mojom::TopRowKey::kNone, - mojom::TopRowKey::kScreenMirror, - mojom::TopRowKey::kDelete}; - -constexpr char kKbdTopRowPropertyName[] = "CROS_KEYBOARD_TOP_ROW_LAYOUT"; -constexpr char kKbdTopRowLayoutAttributeName[] = "function_row_physmap"; - -constexpr char kSillyDeviceName[] = "eventWithoutANumber"; - -constexpr char kInvalidMechnicalLayout[] = "Not ANSI, JIS, or ISO"; - -// NOTE: This is only creates a simple ui::InputDevice based on a device -// capabilities report; it is not suitable for subclasses of ui::InputDevice. -ui::InputDevice InputDeviceFromCapabilities( - int device_id, - const ui::DeviceCapabilities& capabilities) { - ui::EventDeviceInfo device_info = {}; - ui::CapabilitiesToDeviceInfo(capabilities, &device_info); - - const std::string sys_path = - base::StringPrintf("/dev/input/event%d-%s", device_id, capabilities.path); - - return ui::InputDevice(device_id, device_info.device_type(), - device_info.name(), device_info.phys(), - base::FilePath(sys_path), device_info.vendor_id(), - device_info.product_id(), device_info.version()); -} - -} // namespace - class FakeDeviceManager : public ui::DeviceManager { public: FakeDeviceManager() {} @@ -134,71 +60,34 @@ class FakeConnectedDevicesObserver : public mojom::ConnectedDevicesObserver { class FakeInputDeviceInfoHelper : public InputDeviceInfoHelper { public: - FakeInputDeviceInfoHelper() {} - - ~FakeInputDeviceInfoHelper() override {} - - std::unique_ptr GetDeviceInfo( - int id, + std::unique_ptr GetDeviceInfo( base::FilePath path) override { + std::unique_ptr dev_info = + std::make_unique(); ui::DeviceCapabilities device_caps; - const std::string base_name = path.BaseName().value(); - + std::string base_name = path.BaseName().value(); if (base_name == "event0") { device_caps = ui::kLinkKeyboard; - EXPECT_EQ(0, id); } else if (base_name == "event1") { device_caps = ui::kLinkTouchpad; - EXPECT_EQ(1, id); } else if (base_name == "event2") { device_caps = ui::kKohakuTouchscreen; - EXPECT_EQ(2, id); } else if (base_name == "event3") { device_caps = ui::kKohakuStylus; - EXPECT_EQ(3, id); } else if (base_name == "event4") { device_caps = ui::kHpUsbKeyboard; - EXPECT_EQ(4, id); } else if (base_name == "event5") { - device_caps = ui::kSarienKeyboard; // Wilco - EXPECT_EQ(5, id); + device_caps = ui::kSarienKeyboard; } else if (base_name == "event6") { device_caps = ui::kEveKeyboard; - EXPECT_EQ(6, id); } else if (base_name == "event7") { - device_caps = ui::kJinlonKeyboard; - EXPECT_EQ(7, id); - } else if (base_name == "event8") { - device_caps = ui::kMicrosoftBluetoothNumberPad; - EXPECT_EQ(8, id); - } else if (base_name == "event9") { - device_caps = ui::kLogitechTouchKeyboardK400; - EXPECT_EQ(9, id); - } else if (base_name == kSillyDeviceName) { - // Simulate a device that is properly described, but has a malformed - // device name. - EXPECT_EQ(98, id); - device_caps = ui::kLinkKeyboard; - } else if (base_name == "event99") { - EXPECT_EQ(99, id); // Simulate a device that couldn't be opened or have its info determined // for whatever reason. return nullptr; } - auto info = std::make_unique(); - - EXPECT_TRUE( - ui::CapabilitiesToDeviceInfo(device_caps, &info->event_device_info)); - info->evdev_id = id; - info->path = path; - info->input_device = - InputDeviceFromCapabilities(info->evdev_id, device_caps); - info->connection_type = - InputDataProvider::ConnectionTypeFromInputDeviceType( - info->event_device_info.device_type()); - - return info; + EXPECT_TRUE(ui::CapabilitiesToDeviceInfo(device_caps, dev_info.get())); + return dev_info; } }; @@ -223,46 +112,7 @@ class InputDataProviderTest : public testing::Test { auto manager = std::make_unique(); manager_ = manager.get(); - fake_udev_ = std::make_unique(); provider_ = std::make_unique(std::move(manager)); - - // Apply these early; delaying until - // FakeInputDeviceInfoHelper::GetDeviceInfo() is not appropriate, as - // fake_udev is not thread safe. (If multiple devices are constructed in a - // row, then GetDeviceInfo() invocation can overlap with - // ProcessInputDataProvider::ProcessDeviceInfo() which reads from udev). - UdevAddFakeDeviceCapabilities("/dev/input/event5", ui::kSarienKeyboard); - UdevAddFakeDeviceCapabilities("/dev/input/event6", ui::kEveKeyboard); - UdevAddFakeDeviceCapabilities("/dev/input/event7", ui::kJinlonKeyboard); - } - - void UdevAddFakeDeviceCapabilities( - const std::string& device_name, - const ui::DeviceCapabilities& device_caps) { - std::map - sysfs_properties; // Old style numeric tags - std::map - sysfs_attributes; // New style vivaldi scancode layouts - - if (device_caps.kbd_function_row_physmap && - strlen(device_caps.kbd_function_row_physmap) > 0) { - sysfs_attributes[kKbdTopRowLayoutAttributeName] = - device_caps.kbd_function_row_physmap; - } - - if (device_caps.kbd_top_row_layout && - strlen(device_caps.kbd_top_row_layout) > 0) { - sysfs_properties[kKbdTopRowPropertyName] = device_caps.kbd_top_row_layout; - } - - // Each device needs a unique sys path - const std::string sys_path = device_name + "-" + device_caps.path; - - fake_udev_->AddFakeDevice(device_caps.name, sys_path.c_str(), - /*subsystem=*/"input", /*devnode=*/absl::nullopt, - /*devtype=*/absl::nullopt, - std::move(sysfs_attributes), - std::move(sysfs_properties)); } ~InputDataProviderTest() override { @@ -273,12 +123,12 @@ class InputDataProviderTest : public testing::Test { protected: base::test::TaskEnvironment task_environment_; FakeDeviceManager* manager_; - std::unique_ptr fake_udev_; chromeos::system::FakeStatisticsProvider statistics_provider_; std::unique_ptr provider_; }; TEST_F(InputDataProviderTest, GetConnectedDevices_DeviceInfoMapping) { + base::RunLoop run_loop; ui::DeviceEvent event0(ui::DeviceEvent::DeviceType::INPUT, ui::DeviceEvent::ActionType::ADD, base::FilePath("/dev/input/event0")); @@ -297,48 +147,44 @@ TEST_F(InputDataProviderTest, GetConnectedDevices_DeviceInfoMapping) { provider_->OnDeviceEvent(event3); task_environment_.RunUntilIdle(); - base::test::TestFuture, - std::vector> - future; - provider_->GetConnectedDevices(future.GetCallback()); - - const auto& keyboards = future.Get<0>(); - const auto& touch_devices = future.Get<1>(); - - ASSERT_EQ(1ul, keyboards.size()); - // The stylus device should be filtered out, hence only 2 touch devices. - ASSERT_EQ(2ul, touch_devices.size()); - - const mojom::KeyboardInfoPtr& keyboard = keyboards[0]; - EXPECT_EQ(0u, keyboard->id); - EXPECT_EQ(mojom::ConnectionType::kInternal, keyboard->connection_type); - EXPECT_EQ("AT Translated Set 2 keyboard", keyboard->name); - - const mojom::TouchDeviceInfoPtr& touchpad = touch_devices[0]; - EXPECT_EQ(1u, touchpad->id); - EXPECT_EQ(mojom::ConnectionType::kInternal, touchpad->connection_type); - EXPECT_EQ(mojom::TouchDeviceType::kPointer, touchpad->type); - EXPECT_EQ("Atmel maXTouch Touchpad", touchpad->name); - - const mojom::TouchDeviceInfoPtr& touchscreen = touch_devices[1]; - EXPECT_EQ(2u, touchscreen->id); - EXPECT_EQ(mojom::ConnectionType::kInternal, touchscreen->connection_type); - EXPECT_EQ(mojom::TouchDeviceType::kDirect, touchscreen->type); - EXPECT_EQ("Atmel maXTouch Touchscreen", touchscreen->name); + provider_->GetConnectedDevices(base::BindLambdaForTesting( + [&](std::vector keyboards, + std::vector touch_devices) { + ASSERT_EQ(1ul, keyboards.size()); + // The stylus device should be filtered out, hence only 2 touch devices. + ASSERT_EQ(2ul, touch_devices.size()); + + mojom::KeyboardInfoPtr keyboard = keyboards[0].Clone(); + EXPECT_EQ(0u, keyboard->id); + EXPECT_EQ(mojom::ConnectionType::kInternal, keyboard->connection_type); + EXPECT_EQ("AT Translated Set 2 keyboard", keyboard->name); + + mojom::TouchDeviceInfoPtr touchpad = touch_devices[0].Clone(); + EXPECT_EQ(1u, touchpad->id); + EXPECT_EQ(mojom::ConnectionType::kInternal, touchpad->connection_type); + EXPECT_EQ(mojom::TouchDeviceType::kPointer, touchpad->type); + EXPECT_EQ("Atmel maXTouch Touchpad", touchpad->name); + + mojom::TouchDeviceInfoPtr touchscreen = touch_devices[1].Clone(); + EXPECT_EQ(2u, touchscreen->id); + EXPECT_EQ(mojom::ConnectionType::kInternal, + touchscreen->connection_type); + EXPECT_EQ(mojom::TouchDeviceType::kDirect, touchscreen->type); + EXPECT_EQ("Atmel maXTouch Touchscreen", touchscreen->name); + + run_loop.Quit(); + })); + run_loop.Run(); } TEST_F(InputDataProviderTest, GetConnectedDevices_AddEventAfterFirstCall) { - { - base::test::TestFuture, - std::vector> - future; - provider_->GetConnectedDevices(future.GetCallback()); - - const auto& keyboards = future.Get<0>(); - const auto& touch_devices = future.Get<1>(); - ASSERT_EQ(0ul, keyboards.size()); - ASSERT_EQ(0ul, touch_devices.size()); - } + base::RunLoop run_loop; + provider_->GetConnectedDevices(base::BindLambdaForTesting( + [&](std::vector keyboards, + std::vector touch_devices) { + ASSERT_EQ(0ul, keyboards.size()); + ASSERT_EQ(0ul, touch_devices.size()); + })); ui::DeviceEvent event(ui::DeviceEvent::DeviceType::INPUT, ui::DeviceEvent::ActionType::ADD, @@ -346,60 +192,25 @@ TEST_F(InputDataProviderTest, GetConnectedDevices_AddEventAfterFirstCall) { provider_->OnDeviceEvent(event); task_environment_.RunUntilIdle(); - { - base::test::TestFuture, - std::vector> - future; - provider_->GetConnectedDevices(future.GetCallback()); - - const auto& keyboards = future.Get<0>(); - const auto& touch_devices = future.Get<1>(); - - ASSERT_EQ(1ul, keyboards.size()); - const mojom::KeyboardInfoPtr& keyboard = keyboards[0]; - EXPECT_EQ(4u, keyboard->id); - EXPECT_EQ(mojom::ConnectionType::kUsb, keyboard->connection_type); - EXPECT_EQ("Chicony HP Elite USB Keyboard", keyboard->name); - - EXPECT_EQ(0ul, touch_devices.size()); - } -} - -TEST_F(InputDataProviderTest, GetConnectedDevices_AddUnusualDevices) { - ui::DeviceEvent event0(ui::DeviceEvent::DeviceType::INPUT, - ui::DeviceEvent::ActionType::ADD, - base::FilePath("/dev/input/event8")); - ui::DeviceEvent event1(ui::DeviceEvent::DeviceType::INPUT, - ui::DeviceEvent::ActionType::ADD, - base::FilePath("/dev/input/event9")); - provider_->OnDeviceEvent(event0); - provider_->OnDeviceEvent(event1); - task_environment_.RunUntilIdle(); - - base::test::TestFuture, - std::vector> - future; - provider_->GetConnectedDevices(future.GetCallback()); + provider_->GetConnectedDevices(base::BindLambdaForTesting( + [&](std::vector keyboards, + std::vector touch_devices) { + ASSERT_EQ(1ul, keyboards.size()); + mojom::KeyboardInfoPtr keyboard = keyboards[0].Clone(); + EXPECT_EQ(4u, keyboard->id); + EXPECT_EQ(mojom::ConnectionType::kUsb, keyboard->connection_type); + EXPECT_EQ("Chicony HP Elite USB Keyboard", keyboard->name); - const auto& keyboards = future.Get<0>(); - const auto& touch_devices = future.Get<1>(); + EXPECT_EQ(0ul, touch_devices.size()); - ASSERT_EQ(2ul, keyboards.size()); - // The stylus device should be filtered out, hence only 2 touch devices. - ASSERT_EQ(0ul, touch_devices.size()); + run_loop.Quit(); + })); - const mojom::KeyboardInfoPtr& keyboard1 = keyboards[0]; - EXPECT_EQ(8u, keyboard1->id); - EXPECT_EQ(mojom::ConnectionType::kBluetooth, keyboard1->connection_type); - EXPECT_EQ(ui::kMicrosoftBluetoothNumberPad.name, keyboard1->name); - - const mojom::KeyboardInfoPtr& keyboard2 = keyboards[1]; - EXPECT_EQ(9u, keyboard2->id); - EXPECT_EQ(mojom::ConnectionType::kUnknown, keyboard2->connection_type); - EXPECT_EQ(ui::kLogitechTouchKeyboardK400.name, keyboard2->name); + run_loop.Run(); } TEST_F(InputDataProviderTest, GetConnectedDevices_Remove) { + base::RunLoop run_loop; ui::DeviceEvent add_touch_event(ui::DeviceEvent::DeviceType::INPUT, ui::DeviceEvent::ActionType::ADD, base::FilePath("/dev/input/event1")); @@ -410,21 +221,15 @@ TEST_F(InputDataProviderTest, GetConnectedDevices_Remove) { provider_->OnDeviceEvent(add_kbd_event); task_environment_.RunUntilIdle(); - { - base::test::TestFuture, - std::vector> - future; - provider_->GetConnectedDevices(future.GetCallback()); - - const auto& keyboards = future.Get<0>(); - const auto& touch_devices = future.Get<1>(); + provider_->GetConnectedDevices(base::BindLambdaForTesting( + [&](std::vector keyboards, + std::vector touch_devices) { + ASSERT_EQ(1ul, keyboards.size()); + EXPECT_EQ(4u, keyboards[0]->id); - ASSERT_EQ(1ul, keyboards.size()); - EXPECT_EQ(4u, keyboards[0]->id); - - ASSERT_EQ(1ul, touch_devices.size()); - EXPECT_EQ(1u, touch_devices[0]->id); - } + ASSERT_EQ(1ul, touch_devices.size()); + EXPECT_EQ(1u, touch_devices[0]->id); + })); ui::DeviceEvent remove_touch_event(ui::DeviceEvent::DeviceType::INPUT, ui::DeviceEvent::ActionType::REMOVE, @@ -436,21 +241,20 @@ TEST_F(InputDataProviderTest, GetConnectedDevices_Remove) { provider_->OnDeviceEvent(remove_kbd_event); task_environment_.RunUntilIdle(); - { - base::test::TestFuture, - std::vector> - future; - provider_->GetConnectedDevices(future.GetCallback()); + provider_->GetConnectedDevices(base::BindLambdaForTesting( + [&](std::vector keyboards, + std::vector touch_devices) { + EXPECT_EQ(0ul, keyboards.size()); + EXPECT_EQ(0ul, touch_devices.size()); - const auto& keyboards = future.Get<0>(); - const auto& touch_devices = future.Get<1>(); + run_loop.Quit(); + })); - EXPECT_EQ(0ul, keyboards.size()); - EXPECT_EQ(0ul, touch_devices.size()); - } + run_loop.Run(); } TEST_F(InputDataProviderTest, KeyboardPhysicalLayoutDetection) { + base::RunLoop run_loop; statistics_provider_.SetMachineStatistic( chromeos::system::kKeyboardMechanicalLayoutKey, "ISO"); @@ -463,77 +267,50 @@ TEST_F(InputDataProviderTest, KeyboardPhysicalLayoutDetection) { ui::DeviceEvent event2(ui::DeviceEvent::DeviceType::INPUT, ui::DeviceEvent::ActionType::ADD, base::FilePath("/dev/input/event5")); - ui::DeviceEvent event3(ui::DeviceEvent::DeviceType::INPUT, - ui::DeviceEvent::ActionType::ADD, - base::FilePath("/dev/input/event7")); provider_->OnDeviceEvent(event0); provider_->OnDeviceEvent(event1); provider_->OnDeviceEvent(event2); - provider_->OnDeviceEvent(event3); task_environment_.RunUntilIdle(); - base::test::TestFuture, - std::vector> - future; - provider_->GetConnectedDevices(future.GetCallback()); - - const auto& keyboards = future.Get<0>(); - - ASSERT_EQ(4ul, keyboards.size()); - - const mojom::KeyboardInfoPtr& builtin_keyboard = keyboards[0]; - EXPECT_EQ(0u, builtin_keyboard->id); - EXPECT_EQ(mojom::PhysicalLayout::kChromeOS, - builtin_keyboard->physical_layout); - EXPECT_EQ(mojom::MechanicalLayout::kIso, builtin_keyboard->mechanical_layout); - EXPECT_EQ(mojom::NumberPadPresence::kNotPresent, - builtin_keyboard->number_pad_present); - EXPECT_EQ( - std::vector(std::begin(kClassicTopRowKeys), std::end(kClassicTopRowKeys)), - builtin_keyboard->top_row_keys); - - const mojom::KeyboardInfoPtr& external_keyboard = keyboards[1]; - EXPECT_EQ(4u, external_keyboard->id); - EXPECT_EQ(mojom::PhysicalLayout::kUnknown, - external_keyboard->physical_layout); - EXPECT_EQ(mojom::MechanicalLayout::kUnknown, - external_keyboard->mechanical_layout); - EXPECT_EQ(mojom::NumberPadPresence::kUnknown, - external_keyboard->number_pad_present); - EXPECT_EQ( - std::vector(std::begin(kClassicTopRowKeys), std::end(kClassicTopRowKeys)), - external_keyboard->top_row_keys); - - const mojom::KeyboardInfoPtr& dell_internal_keyboard = keyboards[2]; - EXPECT_EQ(5u, dell_internal_keyboard->id); - EXPECT_EQ(mojom::PhysicalLayout::kChromeOSDellEnterprise, - dell_internal_keyboard->physical_layout); - EXPECT_EQ(mojom::MechanicalLayout::kIso, - dell_internal_keyboard->mechanical_layout); - EXPECT_EQ(mojom::NumberPadPresence::kNotPresent, - dell_internal_keyboard->number_pad_present); - EXPECT_EQ(std::vector(std::begin(kInternalDellTopRowKeys), - std::end(kInternalDellTopRowKeys)), - dell_internal_keyboard->top_row_keys); - - const mojom::KeyboardInfoPtr& jinlon_internal_keyboard = keyboards[3]; - EXPECT_EQ(7u, jinlon_internal_keyboard->id); - EXPECT_EQ(mojom::PhysicalLayout::kChromeOS, - jinlon_internal_keyboard->physical_layout); - EXPECT_EQ(mojom::MechanicalLayout::kIso, - jinlon_internal_keyboard->mechanical_layout); - EXPECT_EQ(mojom::NumberPadPresence::kNotPresent, - jinlon_internal_keyboard->number_pad_present); - EXPECT_EQ(std::vector(std::begin(kInternalJinlonTopRowKeys), - std::end(kInternalJinlonTopRowKeys)), - jinlon_internal_keyboard->top_row_keys); - - // TODO(b/208729519): We should check a Drallion keyboard, however that - // invokes a check through the global Shell that does not operate in - // this test. + provider_->GetConnectedDevices(base::BindLambdaForTesting( + [&](std::vector keyboards, + std::vector touch_devices) { + ASSERT_EQ(3ul, keyboards.size()); + + mojom::KeyboardInfoPtr builtin_keyboard = keyboards[0].Clone(); + EXPECT_EQ(0u, builtin_keyboard->id); + EXPECT_EQ(mojom::PhysicalLayout::kChromeOS, + builtin_keyboard->physical_layout); + EXPECT_EQ(mojom::MechanicalLayout::kIso, + builtin_keyboard->mechanical_layout); + EXPECT_EQ(mojom::NumberPadPresence::kNotPresent, + builtin_keyboard->number_pad_present); + + mojom::KeyboardInfoPtr external_keyboard = keyboards[1].Clone(); + EXPECT_EQ(4u, external_keyboard->id); + EXPECT_EQ(mojom::PhysicalLayout::kUnknown, + external_keyboard->physical_layout); + EXPECT_EQ(mojom::MechanicalLayout::kUnknown, + external_keyboard->mechanical_layout); + EXPECT_EQ(mojom::NumberPadPresence::kUnknown, + external_keyboard->number_pad_present); + + mojom::KeyboardInfoPtr dell_internal_keyboard = keyboards[2].Clone(); + EXPECT_EQ(5u, dell_internal_keyboard->id); + EXPECT_EQ(mojom::PhysicalLayout::kChromeOSDellEnterprise, + dell_internal_keyboard->physical_layout); + EXPECT_EQ(mojom::MechanicalLayout::kIso, + dell_internal_keyboard->mechanical_layout); + EXPECT_EQ(mojom::NumberPadPresence::kNotPresent, + dell_internal_keyboard->number_pad_present); + + run_loop.Quit(); + })); + run_loop.Run(); } TEST_F(InputDataProviderTest, KeyboardAssistantKeyDetection) { + base::RunLoop run_loop; ui::DeviceEvent link_event(ui::DeviceEvent::DeviceType::INPUT, ui::DeviceEvent::ActionType::ADD, base::FilePath("/dev/input/event0")); @@ -544,46 +321,43 @@ TEST_F(InputDataProviderTest, KeyboardAssistantKeyDetection) { provider_->OnDeviceEvent(eve_event); task_environment_.RunUntilIdle(); - base::test::TestFuture, - std::vector> - future; - provider_->GetConnectedDevices(future.GetCallback()); - const auto& keyboards = future.Get<0>(); - - ASSERT_EQ(2ul, keyboards.size()); - - const mojom::KeyboardInfoPtr& link_keyboard = keyboards[0]; - EXPECT_EQ(0u, link_keyboard->id); - EXPECT_FALSE(link_keyboard->has_assistant_key); - const mojom::KeyboardInfoPtr& eve_keyboard = keyboards[1]; - EXPECT_EQ(6u, eve_keyboard->id); - EXPECT_TRUE(eve_keyboard->has_assistant_key); + provider_->GetConnectedDevices(base::BindLambdaForTesting( + [&](std::vector keyboards, + std::vector touch_devices) { + ASSERT_EQ(2ul, keyboards.size()); + + mojom::KeyboardInfoPtr link_keyboard = keyboards[0].Clone(); + EXPECT_EQ(0u, link_keyboard->id); + EXPECT_FALSE(link_keyboard->has_assistant_key); + mojom::KeyboardInfoPtr eve_keyboard = keyboards[1].Clone(); + EXPECT_EQ(6u, eve_keyboard->id); + EXPECT_TRUE(eve_keyboard->has_assistant_key); + })); } -TEST_F(InputDataProviderTest, KeyboardNumberPadDetectionInternal) { - // Detection of internal number pad depends on command-line - // argument, and is not a property of the keyboard device. - +TEST_F(InputDataProviderTest, KeyboardNumberPadDetection) { base::CommandLine::ForCurrentProcess()->InitFromArgv( {"", "--has-number-pad"}); + base::RunLoop run_loop; ui::DeviceEvent link_event(ui::DeviceEvent::DeviceType::INPUT, ui::DeviceEvent::ActionType::ADD, base::FilePath("/dev/input/event0")); provider_->OnDeviceEvent(link_event); task_environment_.RunUntilIdle(); - base::test::TestFuture, - std::vector> - future; - provider_->GetConnectedDevices(future.GetCallback()); - const auto& keyboards = future.Get<0>(); + provider_->GetConnectedDevices(base::BindLambdaForTesting( + [&](std::vector keyboards, + std::vector touch_devices) { + ASSERT_EQ(1ul, keyboards.size()); - ASSERT_EQ(1ul, keyboards.size()); + mojom::KeyboardInfoPtr builtin_keyboard = keyboards[0].Clone(); + EXPECT_EQ(0u, builtin_keyboard->id); + EXPECT_EQ(mojom::NumberPadPresence::kPresent, + builtin_keyboard->number_pad_present); - const mojom::KeyboardInfoPtr& builtin_keyboard = keyboards[0]; - EXPECT_EQ(0u, builtin_keyboard->id); - EXPECT_EQ(mojom::NumberPadPresence::kPresent, - builtin_keyboard->number_pad_present); + run_loop.Quit(); + })); + run_loop.Run(); } TEST_F(InputDataProviderTest, ObserveConnectedDevices_Keyboards) { @@ -630,37 +404,14 @@ TEST_F(InputDataProviderTest, ObserveConnectedDevices_TouchDevices) { EXPECT_EQ(1u, fake_observer.touch_devices_disconnected[0]); } -TEST_F(InputDataProviderTest, ChangeDeviceDoesNotCrash) { - ui::DeviceEvent add_device_event(ui::DeviceEvent::DeviceType::INPUT, - ui::DeviceEvent::ActionType::ADD, - base::FilePath("/dev/input/event1")); - ui::DeviceEvent change_device_event(ui::DeviceEvent::DeviceType::INPUT, - ui::DeviceEvent::ActionType::CHANGE, - base::FilePath("/dev/input/event1")); - provider_->OnDeviceEvent(add_device_event); - task_environment_.RunUntilIdle(); - provider_->OnDeviceEvent(change_device_event); - task_environment_.RunUntilIdle(); -} - -TEST_F(InputDataProviderTest, BadDeviceDoesNotCrash) { - // Try a device that specifically fails to be processed +TEST_F(InputDataProviderTest, BadDeviceDoesntCrash) { ui::DeviceEvent add_bad_device_event(ui::DeviceEvent::DeviceType::INPUT, ui::DeviceEvent::ActionType::ADD, - base::FilePath("/dev/input/event99")); + base::FilePath("/dev/input/event7")); provider_->OnDeviceEvent(add_bad_device_event); task_environment_.RunUntilIdle(); } -TEST_F(InputDataProviderTest, SillyDeviceDoesNotCrash) { - // Try a device that has data, but has a non-parseable name. - ui::DeviceEvent add_silly_device_event(ui::DeviceEvent::DeviceType::INPUT, - ui::DeviceEvent::ActionType::ADD, - base::FilePath(kSillyDeviceName)); - provider_->OnDeviceEvent(add_silly_device_event); - task_environment_.RunUntilIdle(); -} - TEST_F(InputDataProviderTest, GetKeyboardVisualLayout_AmericanEnglish) { statistics_provider_.SetMachineStatistic(chromeos::system::kKeyboardLayoutKey, "xkb:us::eng,m17n:ar,t13n:ar"); @@ -671,25 +422,28 @@ TEST_F(InputDataProviderTest, GetKeyboardVisualLayout_AmericanEnglish) { provider_->OnDeviceEvent(add_keyboard_event); task_environment_.RunUntilIdle(); - base::test::TestFuture> - future; - provider_->GetKeyboardVisualLayout(6, future.GetCallback()); - const auto& layout = future.Get<0>(); - - ASSERT_FALSE(layout.at(KEY_Q).is_null()); - EXPECT_EQ("q", layout.at(KEY_Q)->main_glyph); - EXPECT_FALSE(layout.at(KEY_Q)->shift_glyph.has_value()); - - ASSERT_FALSE(layout.at(KEY_3).is_null()); - EXPECT_EQ("3", layout.at(KEY_3)->main_glyph); - EXPECT_EQ("#", layout.at(KEY_3)->shift_glyph); - - // Check all of the essential keys (at least on US QWERTY) have - // glyphs. - for (auto const& entry : layout) { - EXPECT_FALSE(entry.second.is_null()) - << "No glyphs for evdev code " << entry.first; - } + base::RunLoop run_loop; + provider_->GetKeyboardVisualLayout( + 6, base::BindLambdaForTesting( + [&](base::flat_map layout) { + ASSERT_FALSE(layout[KEY_Q].is_null()); + EXPECT_EQ("q", layout[KEY_Q]->main_glyph); + EXPECT_FALSE(layout[KEY_Q]->shift_glyph.has_value()); + + ASSERT_FALSE(layout[KEY_3].is_null()); + EXPECT_EQ("3", layout[KEY_3]->main_glyph); + EXPECT_EQ("#", layout[KEY_3]->shift_glyph); + + // Check all of the essential keys (at least on US QWERTY) have + // glyphs. + for (auto const& entry : layout) { + EXPECT_FALSE(entry.second.is_null()) + << "No glyphs for evdev code " << entry.first; + } + + run_loop.Quit(); + })); + run_loop.Run(); } TEST_F(InputDataProviderTest, GetKeyboardVisualLayout_FrenchFrench) { @@ -702,85 +456,27 @@ TEST_F(InputDataProviderTest, GetKeyboardVisualLayout_FrenchFrench) { provider_->OnDeviceEvent(add_keyboard_event); task_environment_.RunUntilIdle(); - base::test::TestFuture> - future; - provider_->GetKeyboardVisualLayout(6, future.GetCallback()); - const auto& layout = future.Get<0>(); - - ASSERT_FALSE(layout.at(KEY_Q).is_null()); - EXPECT_EQ("a", layout.at(KEY_Q)->main_glyph); - EXPECT_FALSE(layout.at(KEY_Q)->shift_glyph.has_value()); - - ASSERT_FALSE(layout.at(KEY_3).is_null()); - EXPECT_EQ("\"", layout.at(KEY_3)->main_glyph); - EXPECT_EQ("3", layout.at(KEY_3)->shift_glyph); - - // Check all of the essential keys have glyphs. - for (auto const& entry : layout) { - EXPECT_FALSE(entry.second.is_null()) - << "No glyphs for evdev code " << entry.first; - } -} - -TEST_F(InputDataProviderTest, GetKeyboardMechanicalLayout_Unknown1) { - statistics_provider_.ClearMachineStatistic( - chromeos::system::kKeyboardMechanicalLayoutKey); - - ui::DeviceEvent add_keyboard_event(ui::DeviceEvent::DeviceType::INPUT, - ui::DeviceEvent::ActionType::ADD, - base::FilePath("/dev/input/event6")); - provider_->OnDeviceEvent(add_keyboard_event); - task_environment_.RunUntilIdle(); - - { - base::test::TestFuture, - std::vector> - future; - provider_->GetConnectedDevices(future.GetCallback()); - - const auto& keyboards = future.Get<0>(); - - ASSERT_EQ(1ul, keyboards.size()); - - const mojom::KeyboardInfoPtr& builtin_keyboard = keyboards[0]; - EXPECT_EQ(6u, builtin_keyboard->id); - EXPECT_EQ(mojom::PhysicalLayout::kChromeOS, - builtin_keyboard->physical_layout); - EXPECT_EQ(mojom::MechanicalLayout::kUnknown, - builtin_keyboard->mechanical_layout); - EXPECT_EQ(mojom::NumberPadPresence::kNotPresent, - builtin_keyboard->number_pad_present); - } -} - -TEST_F(InputDataProviderTest, GetKeyboardMechanicalLayout_Unknown2) { - statistics_provider_.SetMachineStatistic( - chromeos::system::kKeyboardMechanicalLayoutKey, kInvalidMechnicalLayout); - ui::DeviceEvent add_keyboard_event(ui::DeviceEvent::DeviceType::INPUT, - ui::DeviceEvent::ActionType::ADD, - base::FilePath("/dev/input/event6")); - provider_->OnDeviceEvent(add_keyboard_event); - task_environment_.RunUntilIdle(); - - { - base::test::TestFuture, - std::vector> - future; - provider_->GetConnectedDevices(future.GetCallback()); - - const auto& keyboards = future.Get<0>(); - - ASSERT_EQ(1ul, keyboards.size()); - - const mojom::KeyboardInfoPtr& builtin_keyboard = keyboards[0]; - EXPECT_EQ(6u, builtin_keyboard->id); - EXPECT_EQ(mojom::PhysicalLayout::kChromeOS, - builtin_keyboard->physical_layout); - EXPECT_EQ(mojom::MechanicalLayout::kUnknown, - builtin_keyboard->mechanical_layout); - EXPECT_EQ(mojom::NumberPadPresence::kNotPresent, - builtin_keyboard->number_pad_present); - } + base::RunLoop run_loop; + provider_->GetKeyboardVisualLayout( + 6, base::BindLambdaForTesting( + [&](base::flat_map layout) { + ASSERT_FALSE(layout[KEY_Q].is_null()); + EXPECT_EQ("a", layout[KEY_Q]->main_glyph); + EXPECT_FALSE(layout[KEY_Q]->shift_glyph.has_value()); + + ASSERT_FALSE(layout[KEY_3].is_null()); + EXPECT_EQ("\"", layout[KEY_3]->main_glyph); + EXPECT_EQ("3", layout[KEY_3]->shift_glyph); + + // Check all of the essential keys have glyphs. + for (auto const& entry : layout) { + EXPECT_FALSE(entry.second.is_null()) + << "No glyphs for evdev code " << entry.first; + } + + run_loop.Quit(); + })); + run_loop.Run(); } TEST_F(InputDataProviderTest, ResetReceiverOnDisconnect) { diff --git a/ash/webui/diagnostics_ui/mojom/input_data_provider.mojom b/ash/webui/diagnostics_ui/mojom/input_data_provider.mojom index e3a07bda14c148..22cc37ad3abaad 100644 --- a/ash/webui/diagnostics_ui/mojom/input_data_provider.mojom +++ b/ash/webui/diagnostics_ui/mojom/input_data_provider.mojom @@ -5,15 +5,13 @@ module ash.diagnostics.mojom; enum ConnectionType { - // Includes devices connected over USB that are on fully internal busses, as - // well as the keyboards/touchpads for detachables. - kInternal, + kInternal, // Includes internal USB devices. kUsb, kBluetooth, - // An unknown device is most likely to be internal. kUnknown, }; +// The physical style of a keyboard. enum PhysicalLayout { kUnknown, // A typical Chrome OS keyboard with action keys on the top row, reduced @@ -33,40 +31,11 @@ enum MechanicalLayout { }; enum NumberPadPresence { - // Unknown indicates there is no reliable evidence whether a numberpad is - // present. This is common for external keyboards. kUnknown, kPresent, kNotPresent, }; -// Note that this enumeration will need to be extended if new keys are added. -enum TopRowKey { - // Either no key at all, or no special action key at this position. - kNone, - // Marker for keys which cannot be decoded, but have some action. - kUnknown, - kBack, - kForward, - kRefresh, - kFullscreen, - kOverview, - kScreenshot, - kScreenBrightnessDown, - kScreenBrightnessUp, - kPrivacyScreenToggle, - kVolumeMute, - kVolumeDown, - kVolumeUp, - kKeyboardBacklightDown, - kKeyboardBacklightUp, - kNextTrack, - kPreviousTrack, - kPlayPause, - kScreenMirror, - kDelete, -}; - // Describes a connected keyboard. struct KeyboardInfo { // The number of the keyboard's /dev/input/event* node. @@ -75,11 +44,8 @@ struct KeyboardInfo { string name; PhysicalLayout physical_layout; MechanicalLayout mechanical_layout; - NumberPadPresence number_pad_present; - // Excludes left-most Escape key, and right-most key (usually Power/Lock). - array top_row_keys; - // Only applicable to CrOS keyboards. bool has_assistant_key; + NumberPadPresence number_pad_present; }; // Describes the glyphs that appear on a single key. diff --git a/ash/webui/diagnostics_ui/resources/diagnostics_types.js b/ash/webui/diagnostics_ui/resources/diagnostics_types.js index 4b0e3792c03a01..e79f6d91a0f714 100644 --- a/ash/webui/diagnostics_ui/resources/diagnostics_types.js +++ b/ash/webui/diagnostics_ui/resources/diagnostics_types.js @@ -464,12 +464,6 @@ export const MechanicalLayout = ash.diagnostics.mojom.MechanicalLayout; */ export const NumberPadPresence = ash.diagnostics.mojom.NumberPadPresence; -/** - * Type alias for TopRowKey. - * @typedef {ash.diagnostics.mojom.TopRowKey} - */ -export const TopRowKey = ash.diagnostics.mojom.TopRowKey; - /** * Type alias for KeyboardInfo. * @typedef {ash.diagnostics.mojom.KeyboardInfo} diff --git a/ash/webui/personalization_app/mojom/personalization_app.mojom b/ash/webui/personalization_app/mojom/personalization_app.mojom index 1c9635245cd9dd..ed87407b97a0e7 100644 --- a/ash/webui/personalization_app/mojom/personalization_app.mojom +++ b/ash/webui/personalization_app/mojom/personalization_app.mojom @@ -129,7 +129,7 @@ interface WallpaperProvider { // Fetch the number of photos the user has stored in Google Photos. |count| // will be -1 on failure. - FetchGooglePhotosCount() => (int64 count); + FetchGooglePhotosCount() => (int32 count); // Fetch a list of FilePath objects from the local file system. |images| // will be null on failure. diff --git a/ash/webui/personalization_app/resources/trusted/personalization_actions.ts b/ash/webui/personalization_app/resources/trusted/personalization_actions.ts index 0ad0715d36e2d2..c1748348f68696 100644 --- a/ash/webui/personalization_app/resources/trusted/personalization_actions.ts +++ b/ash/webui/personalization_app/resources/trusted/personalization_actions.ts @@ -258,13 +258,13 @@ export function setGooglePhotosAlbumsAction(albums: WallpaperCollection[]| export type SetGooglePhotosCountAction = Action&{ name: ActionName.SET_GOOGLE_PHOTOS_COUNT; - count: bigint|null; + count: number|null; }; /** * Sets the count of Google Photos photos. May be called with null on error. */ -export function setGooglePhotosCountAction(count: bigint| +export function setGooglePhotosCountAction(count: number| null): SetGooglePhotosCountAction { return {count, name: ActionName.SET_GOOGLE_PHOTOS_COUNT}; } diff --git a/ash/webui/personalization_app/resources/trusted/personalization_state.ts b/ash/webui/personalization_app/resources/trusted/personalization_state.ts index eca452304df113..ebc95b52acf0dc 100644 --- a/ash/webui/personalization_app/resources/trusted/personalization_state.ts +++ b/ash/webui/personalization_app/resources/trusted/personalization_state.ts @@ -28,7 +28,7 @@ export interface BackdropState { * initialized, then either null (in error state) or a valid Array. */ export interface GooglePhotosState { - count: bigint|null|undefined; + count: number|null|undefined; albums: WallpaperCollection[]|null|undefined; photos: unknown[]|null|undefined; photosByAlbumId: Record; diff --git a/ash/webui/personalization_app/resources/trusted/wallpaper/wallpaper_collections_element.js b/ash/webui/personalization_app/resources/trusted/wallpaper/wallpaper_collections_element.js index e6b0492beae88d..2f852e54039eae 100644 --- a/ash/webui/personalization_app/resources/trusted/wallpaper/wallpaper_collections_element.js +++ b/ash/webui/personalization_app/resources/trusted/wallpaper/wallpaper_collections_element.js @@ -11,7 +11,7 @@ import './styles.js'; import {kMaximumLocalImagePreviews} from '/common/constants.js'; -import {isNonEmptyArray, isNullOrArray, isNullOrBigint, promisifyOnload} from '/common/utils.js'; +import {isNonEmptyArray, isNullOrArray, isNullOrNumber, promisifyOnload} from '/common/utils.js'; import {sendCollections, sendGooglePhotosCount, sendGooglePhotosPhotos, sendImageCounts, sendLocalImageData, sendLocalImages, sendVisible} from '/trusted/iframe_api.js'; import {afterNextRender, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; @@ -370,7 +370,7 @@ export class WallpaperCollections extends WithPersonalizationStore { */ async onGooglePhotosCountChanged_( googlePhotosCount, googlePhotosCountLoading) { - if (googlePhotosCountLoading || !isNullOrBigint(googlePhotosCount)) { + if (googlePhotosCountLoading || !isNullOrNumber(googlePhotosCount)) { return; } const iframe = await this.iframePromise_; diff --git a/ash/webui/personalization_app/resources/trusted/wallpaper/wallpaper_controller.ts b/ash/webui/personalization_app/resources/trusted/wallpaper/wallpaper_controller.ts index 6b7b412f3438a0..bc1885e233256b 100644 --- a/ash/webui/personalization_app/resources/trusted/wallpaper/wallpaper_controller.ts +++ b/ash/webui/personalization_app/resources/trusted/wallpaper/wallpaper_controller.ts @@ -108,7 +108,7 @@ async function fetchGooglePhotosCount( store: PersonalizationStore): Promise { store.dispatch(action.beginLoadGooglePhotosCountAction()); const {count} = await provider.fetchGooglePhotosCount(); - store.dispatch(action.setGooglePhotosCountAction(count >= 0n ? count : null)); + store.dispatch(action.setGooglePhotosCountAction(count >= 0 ? count : null)); } /** Fetches the list of Google Photos photos and saves it to the store. */ @@ -309,8 +309,8 @@ export async function initializeGooglePhotosData( // If the count of Google Photos photos is zero or null, it's not necesssary // to query the server for the list of albums/photos. const count = store.data.googlePhotos.count; - if (count === 0n || count === null) { - const /** ?Array */ result = count === 0n ? [] : null; + if (count === 0 || count === null) { + const /** ?Array */ result = count === 0 ? [] : null; store.beginBatchUpdate(); store.dispatch(action.beginLoadGooglePhotosAlbumsAction()); store.dispatch(action.beginLoadGooglePhotosPhotosAction()); diff --git a/ash/webui/personalization_app/resources/untrusted/collections_grid.js b/ash/webui/personalization_app/resources/untrusted/collections_grid.js index 88f5cce35abb84..3d7a353625eac7 100644 --- a/ash/webui/personalization_app/resources/untrusted/collections_grid.js +++ b/ash/webui/personalization_app/resources/untrusted/collections_grid.js @@ -9,7 +9,7 @@ import './styles.js'; import {afterNextRender, html, PolymerElement} from 'chrome-untrusted://personalization/polymer/v3_0/polymer/polymer_bundled.min.js'; import {EventType, kMaximumLocalImagePreviews} from '../common/constants.js'; -import {getLoadingPlaceholderAnimationDelay, getNumberOfGridItemsPerRow, isNullOrArray, isNullOrBigint, isSelectionEvent} from '../common/utils.js'; +import {getLoadingPlaceholderAnimationDelay, getNumberOfGridItemsPerRow, isNullOrArray, isNullOrNumber, isSelectionEvent} from '../common/utils.js'; import {selectCollection, selectGooglePhotosCollection, selectLocalCollection, validateReceivedData} from '../untrusted/iframe_api.js'; /** @@ -65,7 +65,7 @@ let Tile; /** * Get the text to display for number of images. - * @param {?bigint|?number|undefined} x + * @param {?number|undefined} x * @return {string} */ function getCountText(x) { @@ -80,7 +80,7 @@ function getCountText(x) { case 1n: return loadTimeData.getString('oneImage'); default: - if (!['bigint', 'number'].includes(typeof x) || x < 0) { + if ('number' !== typeof x || x < 0) { console.error('Received an impossible value'); return ''; } @@ -91,7 +91,7 @@ function getCountText(x) { /** * Returns the tile to display for the Google Photos collection. * @param {?Array} googlePhotos - * @param {?bigint} googlePhotosCount + * @param {?number} googlePhotosCount * @return {!ImageTile} */ function getGooglePhotosTile(googlePhotos, googlePhotosCount) { @@ -193,7 +193,7 @@ export class CollectionsGrid extends PolymerElement { /** * The count of Google Photos photos. - * @type {?bigint} + * @type {?number} * @private */ googlePhotosCount_: { @@ -330,10 +330,10 @@ export class CollectionsGrid extends PolymerElement { /** * Invoked on changes to the list and count of Google Photos photos. * @param {?Array} googlePhotos - * @param {?bigint} googlePhotosCount + * @param {?number} googlePhotosCount */ onGooglePhotosLoaded_(googlePhotos, googlePhotosCount) { - if (isNullOrArray(googlePhotos) && isNullOrBigint(googlePhotosCount)) { + if (isNullOrArray(googlePhotos) && isNullOrNumber(googlePhotosCount)) { const tile = getGooglePhotosTile(googlePhotos, googlePhotosCount); this.set('tiles_.1', tile); } diff --git a/ash/webui/personalization_app/resources/untrusted/iframe_api.ts b/ash/webui/personalization_app/resources/untrusted/iframe_api.ts index 13ce9a73ad7295..b674cf62b7b857 100644 --- a/ash/webui/personalization_app/resources/untrusted/iframe_api.ts +++ b/ash/webui/personalization_app/resources/untrusted/iframe_api.ts @@ -4,7 +4,7 @@ import {assert, assertNotReached} from '../common/assert.m.js'; import * as constants from '../common/constants.js'; -import {isNonEmptyArray, isNullOrArray, isNullOrBigint} from '../common/utils.js'; +import {isNonEmptyArray, isNullOrArray, isNullOrNumber} from '../common/utils.js'; /** * @fileoverview Helper functions for communicating between trusted and @@ -76,7 +76,7 @@ export function validateReceivedData( return data.collections ?? []; } case constants.EventType.SEND_GOOGLE_PHOTOS_COUNT: { - assert(isNullOrBigint(data.count), 'Expected photos count'); + assert(isNullOrNumber(data.count), 'Expected photos count'); return data.count; } case constants.EventType.SEND_GOOGLE_PHOTOS_PHOTOS: { diff --git a/ash/webui/projector_app/projector_app_client.h b/ash/webui/projector_app/projector_app_client.h index 51b19689fd8ede..edd30c023683ef 100644 --- a/ash/webui/projector_app/projector_app_client.h +++ b/ash/webui/projector_app/projector_app_client.h @@ -26,6 +26,8 @@ class Value; namespace ash { +struct NewScreencastPrecondition; + // TODO(b/201468756): pendings screencasts are sorted by created time. Add // `created_time` field to PendingScreencast. Screencasts might fail to // upload. Add `failed_to_upload` field to PendingScreencast. Implement upload @@ -52,7 +54,8 @@ class ProjectorAppClient { public: // Used to notify the Projector SWA app on whether it can start a new // screencast session. - virtual void OnNewScreencastPreconditionChanged(bool can_start) = 0; + virtual void OnNewScreencastPreconditionChanged( + const NewScreencastPrecondition& precondition) = 0; // Observes the pending screencast state change events. virtual void OnScreencastsPendingStatusChanged( @@ -86,7 +89,8 @@ class ProjectorAppClient { // Used to notify the Projector SWA app on whether it can start a new // screencast session. - virtual void OnNewScreencastPreconditionChanged(bool can_start) = 0; + virtual void OnNewScreencastPreconditionChanged( + const NewScreencastPrecondition& precondition) = 0; // Returns pending screencast uploaded by primary user. virtual const std::set& GetPendingScreencasts() const = 0; diff --git a/ash/webui/projector_app/projector_message_handler.cc b/ash/webui/projector_app/projector_message_handler.cc index 586acec4452962..2d3996be711527 100644 --- a/ash/webui/projector_app/projector_message_handler.cc +++ b/ash/webui/projector_app/projector_message_handler.cc @@ -10,6 +10,7 @@ #include "ash/constants/ash_features.h" #include "ash/constants/ash_pref_names.h" #include "ash/public/cpp/projector/projector_controller.h" +#include "ash/public/cpp/projector/projector_new_screencast_precondition.h" #include "ash/webui/projector_app/projector_app_client.h" #include "base/bind.h" #include "base/check.h" @@ -47,10 +48,6 @@ constexpr char kNoneStr[] = "NONE"; constexpr char kOtherStr[] = "OTHER"; constexpr char kTokenFetchFailureStr[] = "TOKEN_FETCH_FAILURE"; -// Projector NewScreencastPreconditionState keys. -constexpr char kNewScreencastPreconditionState[] = "state"; -constexpr char kNewScreencastPreconditionReasons[] = "reasons"; - // Struct used to describe args to set user's preference. struct SetUserPrefArgs { std::string pref_name; @@ -147,25 +144,6 @@ base::Value CreateRejectMessageForArgs(const base::Value& value) { return rejected_response; } -base::Value GetNewScreencastPreconditionValue(bool can_start) { - // TODO(b/204233075): Provide Hidden state if device doesn't support on-device - // speech recognition. - auto state = can_start ? NewScreencastPreconditionState::kEnabled - : NewScreencastPreconditionState::kDisabled; - base::Value response(base::Value::Type::DICTIONARY); - response.SetIntKey(kNewScreencastPreconditionState, static_cast(state)); - - base::Value reasons(base::Value::Type::LIST); - - if (!can_start) { - // TODO(b/204233075): Provide more fine grained than kOthers. - reasons.Append(static_cast(NewScreencastPreconditionReason::kOthers)); - } - - response.SetKey(kNewScreencastPreconditionReasons, std::move(reasons)); - return response; -} - } // namespace ProjectorMessageHandler::ProjectorMessageHandler(PrefService* pref_service) @@ -256,10 +234,10 @@ void ProjectorMessageHandler::OnSodaInstalled() { } void ProjectorMessageHandler::OnNewScreencastPreconditionChanged( - bool can_start) { + const NewScreencastPrecondition& precondition) { AllowJavascript(); FireWebUIListener("onNewScreencastPreconditionChanged", - GetNewScreencastPreconditionValue(can_start)); + precondition.ToValue()); } void ProjectorMessageHandler::GetAccounts(base::Value::ConstListView args) { @@ -296,9 +274,10 @@ void ProjectorMessageHandler::GetNewScreencastPrecondition( // Check that there is only one argument which is the callback id. DCHECK_EQ(args.size(), 1u); - ResolveJavascriptCallback( - args[0], GetNewScreencastPreconditionValue( - ProjectorController::Get()->CanStartNewSession())); + ResolveJavascriptCallback(args[0], + base::Value(ProjectorController::Get() + ->GetNewScreencastPrecondition() + .ToValue())); } void ProjectorMessageHandler::StartProjectorSession( @@ -320,7 +299,9 @@ void ProjectorMessageHandler::StartProjectorSession( // TODO(b/195113693): Start the projector session with the selected account // and folder. auto* controller = ProjectorController::Get(); - if (!controller->CanStartNewSession()) { + + if (controller->GetNewScreencastPrecondition().state != + NewScreencastPreconditionState::kEnabled) { ResolveJavascriptCallback(args[0], base::Value(false)); return; } diff --git a/ash/webui/projector_app/projector_message_handler.h b/ash/webui/projector_app/projector_message_handler.h index f1fa3841118158..24a0538665cff0 100644 --- a/ash/webui/projector_app/projector_message_handler.h +++ b/ash/webui/projector_app/projector_message_handler.h @@ -7,6 +7,7 @@ #include +#include "ash/public/cpp/projector/projector_new_screencast_precondition.h" #include "ash/webui/projector_app/projector_app_client.h" #include "ash/webui/projector_app/projector_oauth_token_fetcher.h" #include "ash/webui/projector_app/projector_xhr_sender.h" @@ -30,37 +31,6 @@ enum class ProjectorError { kTokenFetchFailure, }; -// The new screencast button state in the Projector SWA. -// Ensure that this enum class is synchronized with -// NewScreencastPreconditionState enum in -// //ash/webui/projector_app/resources/communication/message_types.js. -enum class NewScreencastPreconditionState { - // The new screencast button is visible but is disabled. - kDisabled = 1, - // The new screencast button is enabled and the user can create new ones now. - kEnabled = 2, - // The new screencast button is hidden. - kHidden = 3 -}; - -// The reason for the new screencast button state. -// Ensure that this enum class is synchronized with -// NewScreencastPreconditionReason enum in -// //ash/webui/projector_app/resources/communication/message_types.js. -enum class NewScreencastPreconditionReason { - // Reasons for NewScreenCastPreconditionState.kHidden state: - kOnDeviceSpeechRecognitionNotSupported = 1, - kUserLocaleNotSupported = 2, - - // Reasons for NewScreenCastPreconditionState.kDisabled state: - kInProjectorSession = 3, - kScreenRecordingInProgress = 4, - kSodaDownloadInProgress = 5, - kOutOfDiskSpace = 6, - kNoMic = 7, - kOthers = 8 -}; - // Handles messages from the Projector WebUIs (i.e. chrome://projector). class ProjectorMessageHandler : public content::WebUIMessageHandler, public ProjectorAppClient::Observer { @@ -76,7 +46,8 @@ class ProjectorMessageHandler : public content::WebUIMessageHandler, void RegisterMessages() override; // ProjectorAppClient:Observer: - void OnNewScreencastPreconditionChanged(bool can_start) override; + void OnNewScreencastPreconditionChanged( + const NewScreencastPrecondition& precondition) override; void set_web_ui_for_test(content::WebUI* web_ui) { set_web_ui(web_ui); } diff --git a/ash/webui/projector_app/resources/communication/message_types.js b/ash/webui/projector_app/resources/communication/message_types.js index e93baf05145812..f7a65a2b54d8cd 100644 --- a/ash/webui/projector_app/resources/communication/message_types.js +++ b/ash/webui/projector_app/resources/communication/message_types.js @@ -44,7 +44,6 @@ export const ProjectorError = { export const NewScreencastPreconditionState = { DISABLED: 1, ENABLED: 2, - HIDDEN: 3, }; /** @@ -53,11 +52,8 @@ export const NewScreencastPreconditionState = { * @enum {number} */ export const NewScreencastPreconditionReason = { - // Reasons for NEW_SCREENCAST_PRECONDITION_STATE.HIDDEN state: ON_DEVICE_RECOGNITION_NOT_SUPPORTED: 1, USER_LOCALE_NOT_SUPPORTED: 2, - - // Reasons for NEW_SCREENCAST_PRECONDITION_STATE.DISABLED state: IN_PROJECTOR_SESSION: 3, SCREEN_RECORDING_IN_PROGRESS: 4, SODA_DOWNLOAD_IN_PROGRESS: 5, diff --git a/ash/webui/projector_app/test/mock_app_client.h b/ash/webui/projector_app/test/mock_app_client.h index efd4447af4a1ee..36cc1ebb7e0d77 100644 --- a/ash/webui/projector_app/test/mock_app_client.h +++ b/ash/webui/projector_app/test/mock_app_client.h @@ -43,7 +43,8 @@ class MockAppClient : public ProjectorAppClient { MOCK_METHOD1(AddObserver, void(Observer*)); MOCK_METHOD1(RemoveObserver, void(Observer*)); - MOCK_METHOD1(OnNewScreencastPreconditionChanged, void(bool)); + MOCK_METHOD1(OnNewScreencastPreconditionChanged, + void(const NewScreencastPrecondition&)); MOCK_CONST_METHOD0(GetPendingScreencasts, const std::set&()); MOCK_METHOD0(ShouldDownloadSoda, bool()); diff --git a/ash/webui/projector_app/test/projector_message_handler_unittest.cc b/ash/webui/projector_app/test/projector_message_handler_unittest.cc index f7ca0652961a63..6bd56d464ae98a 100644 --- a/ash/webui/projector_app/test/projector_message_handler_unittest.cc +++ b/ash/webui/projector_app/test/projector_message_handler_unittest.cc @@ -6,6 +6,7 @@ #include "ash/constants/ash_pref_names.h" #include "ash/public/cpp/projector/projector_controller.h" +#include "ash/public/cpp/projector/projector_new_screencast_precondition.h" #include "ash/public/cpp/test/mock_projector_controller.h" #include "ash/webui/projector_app/test/mock_app_client.h" #include "base/files/file_path.h" @@ -147,9 +148,12 @@ TEST_F(ProjectorMessageHandlerUnitTest, GetAccounts) { } TEST_F(ProjectorMessageHandlerUnitTest, CanStartProjectorSession) { - EXPECT_CALL(controller(), CanStartNewSession()); - ON_CALL(controller(), CanStartNewSession) - .WillByDefault(testing::Return(true)); + NewScreencastPrecondition precondition; + precondition.state = NewScreencastPreconditionState::kEnabled; + + EXPECT_CALL(controller(), GetNewScreencastPrecondition()); + ON_CALL(controller(), GetNewScreencastPrecondition) + .WillByDefault(testing::Return(precondition)); base::ListValue list_args; list_args.Append(kGetNewScreencastPreconditionCallback); @@ -270,13 +274,14 @@ TEST_F(ProjectorMessageHandlerUnitTest, SendXhrWithUnSupportedUrl) { EXPECT_EQ("UNSUPPORTED_URL", *error); } -TEST_F(ProjectorMessageHandlerUnitTest, CanStartNewSession) { - message_handler()->OnNewScreencastPreconditionChanged(/** canStart = */ true); - const content::TestWebUI::CallData& call_data = FetchCallData(0); +TEST_F(ProjectorMessageHandlerUnitTest, NewScreencastPreconditionChanged) { + NewScreencastPrecondition precondition; + precondition.state = NewScreencastPreconditionState::kEnabled; + message_handler()->OnNewScreencastPreconditionChanged(precondition); + const content::TestWebUI::CallData& call_data = *(web_ui().call_data()[0]); EXPECT_EQ(call_data.function_name(), kWebUIListenerCall); EXPECT_EQ(call_data.arg1()->GetString(), kOnNewScreencastPreconditionChanged); - EXPECT_EQ(*(call_data.arg2()->FindIntKey(kState)), - static_cast(NewScreencastPreconditionState::kEnabled)); + EXPECT_EQ(*(call_data.arg2()), precondition.ToValue()); } TEST_F(ProjectorMessageHandlerUnitTest, OnSodaProgress) { @@ -462,7 +467,7 @@ TEST_F(ProjectorMessageHandlerUnitTest, SetCreationFlowEnabledUnsupportedPref) { } class ProjectorSessionStartUnitTest - : public ::testing::WithParamInterface, + : public ::testing::WithParamInterface, public ProjectorMessageHandlerUnitTest { public: ProjectorSessionStartUnitTest() = default; @@ -473,10 +478,12 @@ class ProjectorSessionStartUnitTest }; TEST_P(ProjectorSessionStartUnitTest, ProjectorSessionTest) { - bool success = GetParam(); - EXPECT_CALL(controller(), CanStartNewSession()); - ON_CALL(controller(), CanStartNewSession) - .WillByDefault(testing::Return(success)); + const auto& precondition = GetParam(); + EXPECT_CALL(controller(), GetNewScreencastPrecondition()); + ON_CALL(controller(), GetNewScreencastPrecondition) + .WillByDefault(testing::Return(precondition)); + + bool success = precondition.state == NewScreencastPreconditionState::kEnabled; EXPECT_CALL(controller(), StartProjectorSession("folderId")) .Times(success ? 1 : 0); @@ -500,9 +507,14 @@ TEST_P(ProjectorSessionStartUnitTest, ProjectorSessionTest) { EXPECT_EQ(call_data.arg3()->GetBool(), success); } -INSTANTIATE_TEST_CASE_P(SessionStartSuccessFailTest, - ProjectorSessionStartUnitTest, - ::testing::Values(true, false)); +INSTANTIATE_TEST_CASE_P( + SessionStartSuccessFailTest, + ProjectorSessionStartUnitTest, + ::testing::Values( + NewScreencastPrecondition(NewScreencastPreconditionState::kEnabled, {}), + NewScreencastPrecondition( + NewScreencastPreconditionState::kDisabled, + {NewScreencastPreconditionReason::kInProjectorSession}))); // Tests getting and setting the Projector onboarding preferences. // Parameterized by the preference strings. diff --git a/base/BUILD.gn b/base/BUILD.gn index 7ebd6d3f7c88fe..b9c5b658f9670a 100644 --- a/base/BUILD.gn +++ b/base/BUILD.gn @@ -3749,7 +3749,10 @@ test("base_unittests") { sources += [ "allocator/winheap_stubs_win_unittest.cc" ] } - sources += [ "allocator/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc" ] + sources += [ + "allocator/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc", + "allocator/partition_alloc_support_unittest.cc", + ] } if (enable_base_tracing) { diff --git a/base/allocator/allocator_shim_default_dispatch_to_partition_alloc.cc b/base/allocator/allocator_shim_default_dispatch_to_partition_alloc.cc index a0e313c26be42d..342a2bb9d00f91 100644 --- a/base/allocator/allocator_shim_default_dispatch_to_partition_alloc.cc +++ b/base/allocator/allocator_shim_default_dispatch_to_partition_alloc.cc @@ -6,9 +6,12 @@ #include #include +#include +#include #include "base/allocator/allocator_shim_internals.h" #include "base/allocator/buildflags.h" +#include "base/allocator/partition_alloc_features.h" #include "base/allocator/partition_allocator/allocation_guard.h" #include "base/allocator/partition_allocator/memory_reclaimer.h" #include "base/allocator/partition_allocator/partition_alloc.h" @@ -19,6 +22,7 @@ #include "base/allocator/partition_allocator/partition_stats.h" #include "base/bits.h" #include "base/compiler_specific.h" +#include "base/feature_list.h" #include "base/ignore_result.h" #include "base/memory/nonscannable_memory.h" #include "base/numerics/checked_math.h" diff --git a/base/allocator/partition_alloc_support.cc b/base/allocator/partition_alloc_support.cc index 74337419dfd47a..ab9a6c4d9c03a5 100644 --- a/base/allocator/partition_alloc_support.cc +++ b/base/allocator/partition_alloc_support.cc @@ -4,7 +4,13 @@ #include "base/allocator/partition_alloc_support.h" +#include +#include + +#include "base/allocator/buildflags.h" +#include "base/allocator/partition_alloc_features.h" #include "base/allocator/partition_allocator/memory_reclaimer.h" +#include "base/allocator/partition_allocator/partition_alloc_config.h" #include "base/allocator/partition_allocator/starscan/pcscan.h" #include "base/allocator/partition_allocator/starscan/stats_collector.h" #include "base/allocator/partition_allocator/starscan/stats_reporter.h" @@ -12,6 +18,7 @@ #include "base/bind.h" #include "base/callback.h" #include "base/check.h" +#include "base/feature_list.h" #include "base/ignore_result.h" #include "base/metrics/histogram_functions.h" #include "base/no_destructor.h" @@ -189,5 +196,222 @@ void StartMemoryReclaimer(scoped_refptr task_runner) { BindRepeating(&ReclaimPeriodically)); } +std::map ProposeSyntheticFinchTrials( + bool is_enterprise) { + std::map trials; + + // Records whether or not PartitionAlloc is used as the default allocator. + trials.emplace("PartitionAllocEverywhere", +#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) + "Enabled" +#else + "Disabled" +#endif + ); + + // Records whether or not PartitionAlloc-Everywhere is enabled, and whether + // PCScan is enabled on top of it. This is meant for a 3-way experiment with 2 + // binaries: + // - binary A: deployed to 33% users, with PA-E and PCScan off. + // - binary B: deployed to 66% users, with PA-E on, half of which having + // PCScan on + // + // NOTE, deliberately don't use PA_ALLOW_PCSCAN which depends on bitness. + // In the 32-bit case, PCScan is always disabled, but we'll deliberately + // misrepresent it as enabled here (and later ignored when analyzing results), + // in order to keep each population at 33%. + trials.emplace( + "PartitionAllocEverywhereAndPCScan", +#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) + FeatureList::IsEnabled(features::kPartitionAllocPCScanBrowserOnly) + ? "EnabledWithPCScan" + : "EnabledWithoutPCScan" +#else + "Disabled" +#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) + ); + +#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) + // BackupRefPtr_Effective and PCScan_Effective record whether or not + // BackupRefPtr and/or PCScan are enabled. The experiments aren't independent, + // so having a synthetic Finch will help look only at cases where one isn't + // affected by the other. + + // Whether PartitionAllocBackupRefPtr is enabled (as determined by + // FeatureList::IsEnabled). + bool brp_finch_enabled = false; + ALLOW_UNUSED_LOCAL(brp_finch_enabled); + // Whether PartitionAllocBackupRefPtr is set up for the default behavior. The + // default behavior is when either the Finch flag is disabled, or is enabled + // in brp-mode=disabled (these two options are equivalent). + bool brp_nondefault_behavior = false; + ALLOW_UNUSED_LOCAL(brp_nondefault_behavior); + // Whether PartitionAllocBackupRefPtr is set up to enable BRP protection. It + // requires the Finch flag to be enabled and brp-mode!=disabled*. Some modes, + // e.g. disabled-but-3-way-split, do something (hence can't be considered the + // default behavior), but don't enable BRP protection. + bool brp_truly_enabled = false; + ALLOW_UNUSED_LOCAL(brp_truly_enabled); +#if BUILDFLAG(USE_BACKUP_REF_PTR) + if (FeatureList::IsEnabled(features::kPartitionAllocBackupRefPtr)) + brp_finch_enabled = true; + if (brp_finch_enabled && features::kBackupRefPtrModeParam.Get() != + features::BackupRefPtrMode::kDisabled) + brp_nondefault_behavior = true; + if (brp_finch_enabled && features::kBackupRefPtrModeParam.Get() == + features::BackupRefPtrMode::kEnabled) + brp_truly_enabled = true; +#endif // BUILDFLAG(USE_BACKUP_REF_PTR) + bool pcscan_enabled = +#if defined(PA_ALLOW_PCSCAN) + FeatureList::IsEnabled(features::kPartitionAllocPCScanBrowserOnly); +#else + false; +#endif + + std::string brp_group_name; + if (pcscan_enabled) { + // If PCScan is enabled, just ignore the population. + brp_group_name = "Ignore_PCScanIsOn"; + } else if (!brp_finch_enabled) { + // The control group is actually disguised as "enabled", but in fact it's + // disabled using a param. This is to differentiate the population that + // participates in the control group, from the population that isn't in any + // group. + brp_group_name = "Ignore_NoGroup"; + } else { + switch (features::kBackupRefPtrModeParam.Get()) { + case features::BackupRefPtrMode::kDisabled: + brp_group_name = "Disabled"; + break; + case features::BackupRefPtrMode::kEnabled: +#if BUILDFLAG(PUT_REF_COUNT_IN_PREVIOUS_SLOT) + brp_group_name = "EnabledPrevSlot"; +#else + brp_group_name = "EnabledBeforeAlloc"; +#endif + break; + case features::BackupRefPtrMode::kDisabledButSplitPartitions2Way: + brp_group_name = "DisabledBut2WaySplit"; + break; + case features::BackupRefPtrMode::kDisabledButSplitPartitions3Way: + brp_group_name = "DisabledBut3WaySplit"; + break; + } + + if (features::kBackupRefPtrModeParam.Get() != + features::BackupRefPtrMode::kDisabled) { + std::string process_selector; + switch (features::kBackupRefPtrEnabledProcessesParam.Get()) { + case features::BackupRefPtrEnabledProcesses::kBrowserOnly: + process_selector = "BrowserOnly"; + break; + case features::BackupRefPtrEnabledProcesses::kBrowserAndRenderer: + process_selector = "BrowserAndRenderer"; + break; + case features::BackupRefPtrEnabledProcesses::kNonRenderer: + process_selector = "NonRenderer"; + break; + case features::BackupRefPtrEnabledProcesses::kAllProcesses: + process_selector = "AllProcesses"; + break; + } + + brp_group_name += ("_" + process_selector); + } + } + trials.emplace("BackupRefPtr_Effective", brp_group_name); + + std::string pcscan_group_name; + std::string pcscan_group_name_fallback; +#if defined(PA_ALLOW_PCSCAN) + if (brp_truly_enabled) { + // If BRP protection is enabled, just ignore the population. Check + // brp_truly_enabled, not brp_finch_enabled, because there are certain modes + // where BRP protection is actually disabled. + pcscan_group_name = "Ignore_BRPIsOn"; + } else { + pcscan_group_name = (pcscan_enabled ? "Enabled" : "Disabled"); + } + // In case we are incorrect that PCScan is independent of partition-split + // modes, create a fallback trial that only takes into account the BRP Finch + // settings that preserve the default behavior. + if (brp_nondefault_behavior) { + pcscan_group_name_fallback = "Ignore_BRPIsOn"; + } else { + pcscan_group_name_fallback = (pcscan_enabled ? "Enabled" : "Disabled"); + } +#else + // On certain platforms, PCScan is not supported and permanently disabled. + // Don't lump it into "Disabled", so that belonging to "Enabled"/"Disabled" is + // fully controlled by Finch and thus have identical population sizes. + pcscan_group_name = "Unavailable"; + pcscan_group_name_fallback = "Unavailable"; +#endif // defined(PA_ALLOW_PCSCAN) + trials.emplace("PCScan_Effective", pcscan_group_name); + trials.emplace("PCScan_Effective_Fallback", pcscan_group_name_fallback); + + // This synthetic Finch setting reflects the new USE_BACKUP_REF_PTR behavior, + // which simply compiles in the BackupRefPtr support, but keeps it disabled at + // run-time (which can be further enabled via Finch). + trials.emplace("BackupRefPtrSupport", +#if BUILDFLAG(USE_BACKUP_REF_PTR) + "CompiledIn" +#else + "Disabled" +#endif // BUILDFLAG(USE_BACKUP_REF_PTR) + ); +#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) + + // This synthetic field trial for the BackupRefPtr binary A/B experiment is + // set up such that: + // 1) Enterprises are excluded from experiment, to make sure we honor + // ChromeVariations policy. + // 2) The experiment binary (USE_BACKUP_REF_PTR) is delivered via Google + // Update to fraction X of the non-enterprise population. + // 3) The control group is established in fraction X of non-enterprise + // popluation via Finch (PartitionAllocBackupRefPtrControl). Since this + // Finch is applicable only to 1-X of the non-enterprise population, we + // need to set it to Y=X/(1-X). E.g. if X=.333, Y=.5; if X=.01, Y=.0101. +#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) +#if BUILDFLAG(USE_BACKUP_REF_PTR) + constexpr bool kIsBrpOn = true; // experiment binary only +#else + constexpr bool kIsBrpOn = false; // non-experiment binary +#endif + const bool is_brp_control = + FeatureList::IsEnabled(features::kPartitionAllocBackupRefPtrControl); + const char* group_name; + if (is_enterprise) { + if (kIsBrpOn) { // is_enterprise && kIsBrpOn + group_name = "Excluded_Enterprise_BrpOn"; + } else { // is_enterprise && !kIsBrpOn + group_name = "Excluded_Enterprise_BrpOff"; + } + } else { + if (kIsBrpOn) { // !is_enterprise && kIsBrpOn + group_name = "Enabled"; + } else { // !is_enterprise && !kIsBrpOn + if (is_brp_control) { + group_name = "Control"; + } else { + group_name = "Excluded_NonEnterprise"; + } + } + } + trials.emplace("BackupRefPtrNoEnterprise", group_name); +#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) + + trials.emplace("FakeBinaryExperiment", +#if BUILDFLAG(USE_FAKE_BINARY_EXPERIMENT) + "Enabled" +#else + "Disabled" +#endif + ); + + return trials; +} + } // namespace allocator } // namespace base diff --git a/base/allocator/partition_alloc_support.h b/base/allocator/partition_alloc_support.h index 356f75eb6d6482..d73bca733cd2b1 100644 --- a/base/allocator/partition_alloc_support.h +++ b/base/allocator/partition_alloc_support.h @@ -5,6 +5,9 @@ #ifndef BASE_ALLOCATOR_PARTITION_ALLOC_SUPPORT_H_ #define BASE_ALLOCATOR_PARTITION_ALLOC_SUPPORT_H_ +#include +#include + #include "base/allocator/partition_allocator/partition_alloc_config.h" #include "base/base_export.h" #include "base/memory/scoped_refptr.h" @@ -23,6 +26,9 @@ BASE_EXPORT void StartThreadCachePeriodicPurge(); BASE_EXPORT void StartMemoryReclaimer( scoped_refptr task_runner); +BASE_EXPORT std::map ProposeSyntheticFinchTrials( + bool is_enterprise); + } // namespace allocator } // namespace base diff --git a/base/allocator/partition_alloc_support_unittest.cc b/base/allocator/partition_alloc_support_unittest.cc new file mode 100644 index 00000000000000..22b2d162b5faea --- /dev/null +++ b/base/allocator/partition_alloc_support_unittest.cc @@ -0,0 +1,158 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/allocator/partition_alloc_support.h" + +#include +#include +#include + +#include "base/allocator/buildflags.h" +#include "base/allocator/partition_alloc_features.h" +#include "base/allocator/partition_allocator/partition_alloc_config.h" +#include "base/compiler_specific.h" +#include "base/feature_list.h" +#include "base/test/scoped_feature_list.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace base { +namespace allocator { + +#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) +TEST(PartitionAllocSupportTest, ProposeSyntheticFinchTrials_BRPAndPCScan) { + for (bool pcscan_enabled : {false, true}) { + test::ScopedFeatureList pcscan_scope; + std::vector empty_list = {}; + std::vector pcscan_list = { + features::kPartitionAllocPCScanBrowserOnly}; + pcscan_scope.InitWithFeatures(pcscan_enabled ? pcscan_list : empty_list, + pcscan_enabled ? empty_list : pcscan_list); +#if !defined(PA_ALLOW_PCSCAN) + pcscan_enabled = false; +#endif + + std::string brp_expectation = + pcscan_enabled ? "Ignore_PCScanIsOn" : "Ignore_NoGroup"; + std::string pcscan_expectation = +#if defined(PA_ALLOW_PCSCAN) + pcscan_enabled ? "Enabled" : "Disabled"; +#else + "Unavailable"; +#endif + + auto trials = ProposeSyntheticFinchTrials(false); + auto group_iter = trials.find("BackupRefPtr_Effective"); + EXPECT_NE(group_iter, trials.end()); + EXPECT_EQ(group_iter->second, brp_expectation); + group_iter = trials.find("PCScan_Effective"); + EXPECT_NE(group_iter, trials.end()); + EXPECT_EQ(group_iter->second, pcscan_expectation); + group_iter = trials.find("PCScan_Effective_Fallback"); + EXPECT_NE(group_iter, trials.end()); + EXPECT_EQ(group_iter->second, pcscan_expectation); + + { + test::ScopedFeatureList brp_scope; + brp_scope.InitAndEnableFeatureWithParameters( + features::kPartitionAllocBackupRefPtr, {}); + + pcscan_expectation = "Unavailable"; +#if BUILDFLAG(USE_BACKUP_REF_PTR) + brp_expectation = pcscan_enabled ? "Ignore_PCScanIsOn" +#if BUILDFLAG(PUT_REF_COUNT_IN_PREVIOUS_SLOT) + : "EnabledPrevSlot_BrowserOnly"; +#else + : "EnabledBeforeAlloc_" + "BrowserOnly"; +#endif // BUILDFLAG(PUT_REF_COUNT_IN_PREVIOUS_SLOT) +#if defined(PA_ALLOW_PCSCAN) + pcscan_expectation = "Ignore_BRPIsOn"; +#endif +#else // BUILDFLAG(USE_BACKUP_REF_PTR) + brp_expectation = pcscan_enabled ? "Ignore_PCScanIsOn" : "Ignore_NoGroup"; +#if defined(PA_ALLOW_PCSCAN) + pcscan_expectation = pcscan_enabled ? "Enabled" : "Disabled"; +#endif +#endif // BUILDFLAG(USE_BACKUP_REF_PTR) + + trials = ProposeSyntheticFinchTrials(false); + group_iter = trials.find("BackupRefPtr_Effective"); + EXPECT_NE(group_iter, trials.end()); + EXPECT_EQ(group_iter->second, brp_expectation); + group_iter = trials.find("PCScan_Effective"); + EXPECT_NE(group_iter, trials.end()); + EXPECT_EQ(group_iter->second, pcscan_expectation); + group_iter = trials.find("PCScan_Effective_Fallback"); + EXPECT_NE(group_iter, trials.end()); + EXPECT_EQ(group_iter->second, pcscan_expectation); + } + + const std::string kEnabledMode = +#if BUILDFLAG(PUT_REF_COUNT_IN_PREVIOUS_SLOT) + "PrevSlot_"; +#else + "BeforeAlloc_"; +#endif + const std::vector> kModes = { + {"disabled", "Disabled"}, + {"enabled", "Enabled" + kEnabledMode}, + {"disabled-but-2-way-split", "DisabledBut2WaySplit_"}, + {"disabled-but-3-way-split", "DisabledBut3WaySplit_"}}; + const std::vector> kProcesses = { + {"browser-only", "BrowserOnly"}, + {"browser-and-renderer", "BrowserAndRenderer"}, + {"non-renderer", "NonRenderer"}, + {"all-processes", "AllProcesses"}}; + + for (auto mode : kModes) { + for (auto process_set : kProcesses) { + test::ScopedFeatureList brp_scope; + brp_scope.InitAndEnableFeatureWithParameters( + features::kPartitionAllocBackupRefPtr, + {{"brp-mode", mode.first}, + {"enabled-processes", process_set.first}}); + +#if BUILDFLAG(USE_BACKUP_REF_PTR) + brp_expectation = pcscan_enabled ? "Ignore_PCScanIsOn" : mode.second; + bool brp_unavailable = false; +#else + brp_expectation = + pcscan_enabled ? "Ignore_PCScanIsOn" : "Ignore_NoGroup"; + bool brp_unavailable = true; +#endif + ALLOW_UNUSED_LOCAL(brp_unavailable); + if (brp_expectation[brp_expectation.length() - 1] == '_') { + brp_expectation += process_set.second; + } + pcscan_expectation = "Unavailable"; + std::string pcscan_expectation_fallback = "Unavailable"; +#if defined(PA_ALLOW_PCSCAN) + pcscan_expectation = + (brp_unavailable || mode.first.find("disabled") == 0) + ? (pcscan_enabled ? "Enabled" : "Disabled") + : "Ignore_BRPIsOn"; + pcscan_expectation_fallback = + (brp_unavailable || mode.first == "disabled") + ? (pcscan_enabled ? "Enabled" : "Disabled") + : "Ignore_BRPIsOn"; +#endif + + trials = ProposeSyntheticFinchTrials(false); + group_iter = trials.find("BackupRefPtr_Effective"); + EXPECT_NE(group_iter, trials.end()); + EXPECT_EQ(group_iter->second, brp_expectation); + group_iter = trials.find("PCScan_Effective"); + EXPECT_NE(group_iter, trials.end()); + EXPECT_EQ(group_iter->second, pcscan_expectation); + group_iter = trials.find("PCScan_Effective_Fallback"); + EXPECT_NE(group_iter, trials.end()); + EXPECT_EQ(group_iter->second, pcscan_expectation_fallback); + } + } + } +} +#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) + +} // namespace allocator +} // namespace base diff --git a/build/fuchsia/common_args.py b/build/fuchsia/common_args.py index ac00fa69bd1f1b..7312a145cc4561 100644 --- a/build/fuchsia/common_args.py +++ b/build/fuchsia/common_args.py @@ -164,6 +164,15 @@ def ConfigureLogging(args): logging.DEBUG if args.verbose else logging.WARN) +def InitializeTargetArgs(): + """Set args for all targets to default values. This is used by test scripts + that have their own parser but still uses the target classes.""" + parser = argparse.ArgumentParser() + AddCommonArgs(parser) + AddTargetSpecificArgs(parser) + return parser.parse_args([]) + + def GetDeploymentTargetForArgs(args): """Constructs a deployment target object using command line arguments. If needed, an additional_args dict can be used to supplement the diff --git a/build/fuchsia/linux.sdk.sha1 b/build/fuchsia/linux.sdk.sha1 index 7ab9e4879c1f15..d25fb92dc30896 100644 --- a/build/fuchsia/linux.sdk.sha1 +++ b/build/fuchsia/linux.sdk.sha1 @@ -1 +1 @@ -7.20211215.1.1 +7.20211215.3.1 diff --git a/build/fuchsia/linux_internal.sdk.sha1 b/build/fuchsia/linux_internal.sdk.sha1 index 8f856653e1e1c4..d25fb92dc30896 100644 --- a/build/fuchsia/linux_internal.sdk.sha1 +++ b/build/fuchsia/linux_internal.sdk.sha1 @@ -1 +1 @@ -7.20211215.2.1 +7.20211215.3.1 diff --git a/build/fuchsia/mac.sdk.sha1 b/build/fuchsia/mac.sdk.sha1 index 7ab9e4879c1f15..d25fb92dc30896 100644 --- a/build/fuchsia/mac.sdk.sha1 +++ b/build/fuchsia/mac.sdk.sha1 @@ -1 +1 @@ -7.20211215.1.1 +7.20211215.3.1 diff --git a/chrome/VERSION b/chrome/VERSION index fc51c366ba7f55..2e61bb85803f7a 100644 --- a/chrome/VERSION +++ b/chrome/VERSION @@ -1,4 +1,4 @@ MAJOR=99 MINOR=0 -BUILD=4769 +BUILD=4770 PATCH=0 diff --git a/chrome/android/chrome_test_java_sources.gni b/chrome/android/chrome_test_java_sources.gni index 18f3ce53b565ba..e7c446f3d3ab3b 100644 --- a/chrome/android/chrome_test_java_sources.gni +++ b/chrome/android/chrome_test_java_sources.gni @@ -346,6 +346,7 @@ chrome_test_java_sources = [ "javatests/src/org/chromium/chrome/browser/omnibox/suggestions/CachedZeroSuggestionsManagerUnitTest.java", "javatests/src/org/chromium/chrome/browser/omnibox/suggestions/DropdownItemViewInfoListBuilderUnitTest.java", "javatests/src/org/chromium/chrome/browser/omnibox/suggestions/DropdownItemViewInfoListManagerUnitTest.java", + "javatests/src/org/chromium/chrome/browser/omnibox/suggestions/OmniboxPedalsTest.java", "javatests/src/org/chromium/chrome/browser/omnibox/suggestions/SwitchToTabTest.java", "javatests/src/org/chromium/chrome/browser/omnibox/suggestions/answer/AnswerSuggestionProcessorUnitTest.java", "javatests/src/org/chromium/chrome/browser/omnibox/suggestions/base/BaseSuggestionProcessorTest.java", diff --git a/chrome/android/java/res/values/styles.xml b/chrome/android/java/res/values/styles.xml index e5e65088243db2..f044866415a6d0 100644 --- a/chrome/android/java/res/values/styles.xml +++ b/chrome/android/java/res/values/styles.xml @@ -125,7 +125,7 @@ @macro/default_text_color_link @android:color/black @macro/default_control_color_active - @color/control_highlight_color + @macro/default_control_color_highlight @style/SpinnerStyle @style/Widget.BrowserUI.TextInputLayout diff --git a/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkSaveFlowMediator.java b/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkSaveFlowMediator.java index 26a2606beabed5..7d0ce4d15df069 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkSaveFlowMediator.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkSaveFlowMediator.java @@ -8,7 +8,7 @@ import android.widget.CompoundButton; import androidx.annotation.Nullable; -import androidx.core.content.res.ResourcesCompat; +import androidx.appcompat.content.res.AppCompatResources; import org.chromium.base.Callback; import org.chromium.base.CallbackController; @@ -171,10 +171,9 @@ void setPriceTrackingNotificationUiEnabled(boolean enabled) { void setPriceTrackingIconForEnabledState(boolean enabled) { mPropertyModel.set(BookmarkSaveFlowProperties.NOTIFICATION_SWITCH_START_ICON, - ResourcesCompat.getDrawable(mContext.getResources(), + AppCompatResources.getDrawable(mContext, enabled ? R.drawable.price_tracking_enabled_filled - : R.drawable.price_tracking_disabled, - /*theme=*/null)); + : R.drawable.price_tracking_disabled)); } void destroy() { diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/omnibox/suggestions/OmniboxPedalsTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/omnibox/suggestions/OmniboxPedalsTest.java new file mode 100644 index 00000000000000..6115ff81bb40c1 --- /dev/null +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/omnibox/suggestions/OmniboxPedalsTest.java @@ -0,0 +1,239 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.chrome.browser.omnibox.suggestions; + +import android.app.Activity; + +import androidx.test.filters.MediumTest; + +import org.hamcrest.Matchers; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.chromium.base.ThreadUtils; +import org.chromium.base.test.util.CommandLineFlags; +import org.chromium.base.test.util.Criteria; +import org.chromium.base.test.util.CriteriaHelper; +import org.chromium.chrome.R; +import org.chromium.chrome.browser.flags.ChromeSwitches; +import org.chromium.chrome.browser.omnibox.LocationBarLayout; +import org.chromium.chrome.browser.omnibox.UrlBar; +import org.chromium.chrome.browser.omnibox.action.OmniboxPedalType; +import org.chromium.chrome.test.ChromeJUnit4ClassRunner; +import org.chromium.chrome.test.ChromeTabbedActivityTestRule; +import org.chromium.chrome.test.util.OmniboxTestUtils; +import org.chromium.chrome.test.util.WaitForFocusHelper; +import org.chromium.chrome.test.util.browser.Features.EnableFeatures; +import org.chromium.components.omnibox.AutocompleteMatch; +import org.chromium.content_public.browser.test.util.TestThreadUtils; + +/** + * Tests of the Omnibox Pedals feature. + */ +@RunWith(ChromeJUnit4ClassRunner.class) +@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE}) +public class OmniboxPedalsTest { + @Rule + public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule(); + + @Before + public void setUp() throws InterruptedException { + mActivityTestRule.startMainActivityOnBlankPage(); + } + + /** + * Type the |text| into |activity|'s url_bar. + * + * @param activity The Activity which url_bar is in. + * @param text The text will be typed into url_bar. + */ + private void typeInOmnibox(Activity activity, String text) throws InterruptedException { + final UrlBar urlBar = activity.findViewById(R.id.url_bar); + Assert.assertNotNull(urlBar); + + WaitForFocusHelper.acquireFocusForView(urlBar); + OmniboxTestUtils.waitForFocusAndKeyboardActive(urlBar, true); + + TestThreadUtils.runOnUiThreadBlocking(() -> { urlBar.setText(text); }); + } + + /** + * Find the Omnibox Pedal suggestion which suggests the |pedalType|, and return the + * suggestion. This method needs to run on the UI thread. + * + * @param locationBarLayout The layout which omnibox suggestions will show in. + * @param pedalType The Omnibox pedal type to be found. + * @return The suggesstion which suggests the matching OmniboxPedalType. + */ + private AutocompleteMatch findOmniboxPedalSuggestion( + LocationBarLayout locationBarLayout, @OmniboxPedalType int pedalType) { + ThreadUtils.assertOnUiThread(); + + AutocompleteCoordinator coordinator = locationBarLayout.getAutocompleteCoordinator(); + // Find the first matching suggestion. + for (int i = 0; i < coordinator.getSuggestionCount(); ++i) { + AutocompleteMatch suggestion = coordinator.getSuggestionAt(i); + if (suggestion != null && suggestion.getOmniboxPedal() != null + && suggestion.getOmniboxPedal().getID() == pedalType) { + return suggestion; + } + } + return null; + } + + @Test + @MediumTest + @EnableFeatures("OmniboxPedalsAndroidBatch1") + public void testClearBrowsingDataOmniboxPedalSuggestion() throws InterruptedException { + LocationBarLayout locationBarLayout = + (LocationBarLayout) mActivityTestRule.getActivity().findViewById(R.id.location_bar); + typeInOmnibox(mActivityTestRule.getActivity(), "Clear data"); + + CriteriaHelper.pollUiThread(() -> { + AutocompleteMatch matchSuggestion = findOmniboxPedalSuggestion( + locationBarLayout, OmniboxPedalType.CLEAR_BROWSING_DATA); + Criteria.checkThat(matchSuggestion, Matchers.notNullValue()); + }); + } + + @Test + @MediumTest + @EnableFeatures("OmniboxPedalsAndroidBatch1") + public void testManagePasswordsOmniboxPedalSuggestion() throws InterruptedException { + LocationBarLayout locationBarLayout = + (LocationBarLayout) mActivityTestRule.getActivity().findViewById(R.id.location_bar); + typeInOmnibox(mActivityTestRule.getActivity(), "Manage passwords"); + + CriteriaHelper.pollUiThread(() -> { + AutocompleteMatch matchSuggestion = findOmniboxPedalSuggestion( + locationBarLayout, OmniboxPedalType.MANAGE_PASSWORDS); + Criteria.checkThat(matchSuggestion, Matchers.notNullValue()); + }); + } + + @Test + @MediumTest + @EnableFeatures("OmniboxPedalsAndroidBatch1") + public void testManagePaymentMethodsOmniboxPedalSuggestion() throws InterruptedException { + LocationBarLayout locationBarLayout = + (LocationBarLayout) mActivityTestRule.getActivity().findViewById(R.id.location_bar); + typeInOmnibox(mActivityTestRule.getActivity(), "Manage payment methods"); + + CriteriaHelper.pollUiThread(() -> { + AutocompleteMatch matchSuggestion = findOmniboxPedalSuggestion( + locationBarLayout, OmniboxPedalType.UPDATE_CREDIT_CARD); + Criteria.checkThat(matchSuggestion, Matchers.notNullValue()); + }); + } + + @Test + @MediumTest + @EnableFeatures("OmniboxPedalsAndroidBatch1") + public void testOpenIncognitoTabOmniboxPedalSuggestion() throws InterruptedException { + LocationBarLayout locationBarLayout = + (LocationBarLayout) mActivityTestRule.getActivity().findViewById(R.id.location_bar); + typeInOmnibox(mActivityTestRule.getActivity(), "Open Incognito"); + + CriteriaHelper.pollUiThread(() -> { + AutocompleteMatch matchSuggestion = findOmniboxPedalSuggestion( + locationBarLayout, OmniboxPedalType.LAUNCH_INCOGNITO); + Criteria.checkThat(matchSuggestion, Matchers.notNullValue()); + }); + } + + @Test + @MediumTest + @EnableFeatures("OmniboxPedalsAndroidBatch1") + public void testRunChromeSafetyCheckOmniboxPedalSuggestion() throws InterruptedException { + LocationBarLayout locationBarLayout = + (LocationBarLayout) mActivityTestRule.getActivity().findViewById(R.id.location_bar); + typeInOmnibox(mActivityTestRule.getActivity(), "Run safety check"); + + CriteriaHelper.pollUiThread(() -> { + AutocompleteMatch matchSuggestion = findOmniboxPedalSuggestion( + locationBarLayout, OmniboxPedalType.RUN_CHROME_SAFETY_CHECK); + Criteria.checkThat(matchSuggestion, Matchers.notNullValue()); + }); + } + + @Test + @MediumTest + @EnableFeatures("OmniboxPedalsAndroidBatch1") + public void testManageSiteSettingsOmniboxPedalSuggestion() throws InterruptedException { + LocationBarLayout locationBarLayout = + (LocationBarLayout) mActivityTestRule.getActivity().findViewById(R.id.location_bar); + typeInOmnibox(mActivityTestRule.getActivity(), "Change site permissions"); + + CriteriaHelper.pollUiThread(() -> { + AutocompleteMatch matchSuggestion = findOmniboxPedalSuggestion( + locationBarLayout, OmniboxPedalType.MANAGE_SITE_SETTINGS); + Criteria.checkThat(matchSuggestion, Matchers.notNullValue()); + }); + } + + @Test + @MediumTest + @EnableFeatures("OmniboxPedalsAndroidBatch1") + public void testManageChromeSettingsOmniboxPedalSuggestion() throws InterruptedException { + LocationBarLayout locationBarLayout = + (LocationBarLayout) mActivityTestRule.getActivity().findViewById(R.id.location_bar); + typeInOmnibox(mActivityTestRule.getActivity(), "manage settings"); + + CriteriaHelper.pollUiThread(() -> { + AutocompleteMatch matchSuggestion = findOmniboxPedalSuggestion( + locationBarLayout, OmniboxPedalType.MANAGE_CHROME_SETTINGS); + Criteria.checkThat(matchSuggestion, Matchers.notNullValue()); + }); + } + + @Test + @MediumTest + @EnableFeatures("OmniboxPedalsAndroidBatch1") + public void testViewYourChromeHistoryOmniboxPedalSuggestion() throws InterruptedException { + LocationBarLayout locationBarLayout = + (LocationBarLayout) mActivityTestRule.getActivity().findViewById(R.id.location_bar); + typeInOmnibox(mActivityTestRule.getActivity(), "view chrome history"); + + CriteriaHelper.pollUiThread(() -> { + AutocompleteMatch matchSuggestion = findOmniboxPedalSuggestion( + locationBarLayout, OmniboxPedalType.VIEW_CHROME_HISTORY); + Criteria.checkThat(matchSuggestion, Matchers.notNullValue()); + }); + } + + @Test + @MediumTest + @EnableFeatures("OmniboxPedalsAndroidBatch1") + public void testManageAccessibilitySettingsOmniboxPedalSuggestion() + throws InterruptedException { + LocationBarLayout locationBarLayout = + (LocationBarLayout) mActivityTestRule.getActivity().findViewById(R.id.location_bar); + typeInOmnibox(mActivityTestRule.getActivity(), "Chrome accessibility"); + + CriteriaHelper.pollUiThread(() -> { + AutocompleteMatch matchSuggestion = findOmniboxPedalSuggestion( + locationBarLayout, OmniboxPedalType.MANAGE_CHROME_ACCESSIBILITY); + Criteria.checkThat(matchSuggestion, Matchers.notNullValue()); + }); + } + + @Test + @MediumTest + @EnableFeatures("OmniboxPedalsAndroidBatch1") + public void testPlayChromeDinoGameOmniboxPedalSuggestion() throws InterruptedException { + LocationBarLayout locationBarLayout = + (LocationBarLayout) mActivityTestRule.getActivity().findViewById(R.id.location_bar); + typeInOmnibox(mActivityTestRule.getActivity(), "Dino game"); + + CriteriaHelper.pollUiThread(() -> { + AutocompleteMatch matchSuggestion = findOmniboxPedalSuggestion( + locationBarLayout, OmniboxPedalType.PLAY_CHROME_DINO_GAME); + Criteria.checkThat(matchSuggestion, Matchers.notNullValue()); + }); + } +} diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 4d25d7a6e67105..e56e458078b969 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -5049,6 +5049,12 @@ Keep your key file in a safe place. You will need it to create new versions of y Permissions + + Allowed to read and change $1google.com + + + Requested to read and change $1google.com + Installed diff --git a/chrome/app/generated_resources_grd/IDS_EXTENSIONS_MENU_SITE_ACCESS_TAB_HAS_ACCESS_SECTION_TITLE.png.sha1 b/chrome/app/generated_resources_grd/IDS_EXTENSIONS_MENU_SITE_ACCESS_TAB_HAS_ACCESS_SECTION_TITLE.png.sha1 new file mode 100644 index 00000000000000..553e376e31fdad --- /dev/null +++ b/chrome/app/generated_resources_grd/IDS_EXTENSIONS_MENU_SITE_ACCESS_TAB_HAS_ACCESS_SECTION_TITLE.png.sha1 @@ -0,0 +1 @@ +2eb1b882e9c8fa5d2aa0f27a4d84ccb5e1b0a3fc \ No newline at end of file diff --git a/chrome/app/generated_resources_grd/IDS_EXTENSIONS_MENU_SITE_ACCESS_TAB_REQUESTS_ACCESS_SECTION_TITLE.png.sha1 b/chrome/app/generated_resources_grd/IDS_EXTENSIONS_MENU_SITE_ACCESS_TAB_REQUESTS_ACCESS_SECTION_TITLE.png.sha1 new file mode 100644 index 00000000000000..553e376e31fdad --- /dev/null +++ b/chrome/app/generated_resources_grd/IDS_EXTENSIONS_MENU_SITE_ACCESS_TAB_REQUESTS_ACCESS_SECTION_TITLE.png.sha1 @@ -0,0 +1 @@ +2eb1b882e9c8fa5d2aa0f27a4d84ccb5e1b0a3fc \ No newline at end of file diff --git a/chrome/app/os_settings_strings_grdp/IDS_SETTINGS_BLUETOOTH_PAIRED_DEVICE_ITEM_SUBPAGE_BUTTON_A11Y_LABEL.png.sha1 b/chrome/app/os_settings_strings_grdp/IDS_SETTINGS_BLUETOOTH_PAIRED_DEVICE_ITEM_SUBPAGE_BUTTON_A11Y_LABEL.png.sha1 deleted file mode 100644 index 18453f957cfcb0..00000000000000 --- a/chrome/app/os_settings_strings_grdp/IDS_SETTINGS_BLUETOOTH_PAIRED_DEVICE_ITEM_SUBPAGE_BUTTON_A11Y_LABEL.png.sha1 +++ /dev/null @@ -1 +0,0 @@ -8ea28bdda83d0d5ce6a9a889bcdaae4fe7ceb1b8 \ No newline at end of file diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index 27d216dd98b1c4..42646ee47ef72f 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn @@ -529,6 +529,8 @@ static_library("browser") { "file_system_access/file_system_access_tab_helper.h", "file_util_service.cc", "file_util_service.h", + "first_party_sets/first_party_sets_pref_names.cc", + "first_party_sets/first_party_sets_pref_names.h", "first_party_sets/first_party_sets_util.cc", "first_party_sets/first_party_sets_util.h", "flag_descriptions.cc", @@ -4912,6 +4914,7 @@ static_library("browser") { "//chrome/browser/nearby_sharing/proto", "//chrome/browser/nearby_sharing/proto:tachyon_proto", "//chrome/browser/nearby_sharing/scheduling", + "//chrome/browser/resources/chromeos:app_icon_resources", "//chrome/browser/supervised_user:supervised_user_unscaled_resources", "//chrome/browser/ui/webui/nearby_share:mojom", "//chrome/browser/ui/webui/nearby_share/public/mojom", @@ -5133,8 +5136,8 @@ static_library("browser") { "lacros/account_manager/profile_account_manager_factory.h", "lacros/app_mode/kiosk_session_service_lacros.cc", "lacros/app_mode/kiosk_session_service_lacros.h", - "lacros/arc_icon_cache_lacros.cc", - "lacros/arc_icon_cache_lacros.h", + "lacros/arc/arc_icon_cache.cc", + "lacros/arc/arc_icon_cache.h", "lacros/automation_manager_lacros.cc", "lacros/automation_manager_lacros.h", "lacros/browser_service_lacros.cc", @@ -7687,12 +7690,12 @@ static_library("test_support") { deps += [ "//ash/components/attestation:test_support", "//ash/components/disks", + "//ash/components/login/auth", "//ash/public/cpp", "//chrome/test:test_support_ui", "//chromeos:test_support", "//chromeos/dbus", "//chromeos/dbus/cros_disks", - "//chromeos/login/auth", "//components/session_manager/core", "//components/soda", "//components/user_manager:test_support", diff --git a/chrome/browser/apps/app_service/app_icon/app_icon_factory.cc b/chrome/browser/apps/app_service/app_icon/app_icon_factory.cc index c3e6273309d512..15c0a014e2f04a 100644 --- a/chrome/browser/apps/app_service/app_icon/app_icon_factory.cc +++ b/chrome/browser/apps/app_service/app_icon/app_icon_factory.cc @@ -39,7 +39,7 @@ #include "ui/gfx/image/image_skia_operations.h" #if BUILDFLAG(IS_CHROMEOS_ASH) -#include "ui/chromeos/resources/grit/ui_chromeos_resources.h" +#include "chrome/grit/app_icon_resources.h" #include "ui/gfx/geometry/skia_conversions.h" #endif diff --git a/chrome/browser/apps/app_service/intent_util.cc b/chrome/browser/apps/app_service/intent_util.cc index 03d56ce129a410..734d78801725ae 100644 --- a/chrome/browser/apps/app_service/intent_util.cc +++ b/chrome/browser/apps/app_service/intent_util.cc @@ -39,7 +39,7 @@ #include "ash/constants/ash_features.h" #include "ash/webui/projector_app/public/cpp/projector_app_constants.h" #include "base/files/file_path.h" -#include "chrome/browser/ui/app_list/arc/arc_app_utils.h" +#include "chrome/browser/ui/app_list/arc/intent.h" #include "chrome/browser/web_applications/web_app_id.h" #include "chrome/common/extensions/api/file_browser_handlers/file_browser_handler.h" #include "components/arc/intent_helper/intent_constants.h" diff --git a/chrome/browser/apps/app_service/metrics/app_platform_metrics.cc b/chrome/browser/apps/app_service/metrics/app_platform_metrics.cc index eb51082577a5b7..e0466e85976d02 100644 --- a/chrome/browser/apps/app_service/metrics/app_platform_metrics.cc +++ b/chrome/browser/apps/app_service/metrics/app_platform_metrics.cc @@ -381,6 +381,136 @@ AppPlatformMetrics::~AppPlatformMetrics() { RecordAppsUsageTime(); } +// static +ukm::SourceId AppPlatformMetrics::GetSourceId(Profile* profile, + const std::string& app_id) { + if (!AppServiceProxyFactory::IsAppServiceAvailableForProfile(profile)) { + return ukm::kInvalidSourceId; + } + + ukm::SourceId source_id = ukm::kInvalidSourceId; + apps::mojom::AppType app_type = GetAppType(profile, app_id); + if (!ShouldRecordUkmForAppTypeName(ConvertMojomAppTypToAppType(app_type))) { + return ukm::kInvalidSourceId; + } + + switch (app_type) { + case apps::mojom::AppType::kBuiltIn: + case apps::mojom::AppType::kChromeApp: + case apps::mojom::AppType::kExtension: + source_id = ukm::AppSourceUrlRecorder::GetSourceIdForChromeApp(app_id); + break; + case apps::mojom::AppType::kArc: + case apps::mojom::AppType::kWeb: + case apps::mojom::AppType::kSystemWeb: { + std::string publisher_id; + apps::mojom::InstallReason install_reason; + apps::AppServiceProxyFactory::GetForProfile(profile) + ->AppRegistryCache() + .ForOneApp(app_id, [&publisher_id, + &install_reason](const apps::AppUpdate& update) { + publisher_id = update.PublisherId(); + install_reason = update.InstallReason(); + }); + if (publisher_id.empty()) { + return ukm::kInvalidSourceId; + } + if (app_type == apps::mojom::AppType::kArc) { + source_id = ukm::AppSourceUrlRecorder::GetSourceIdForArcPackageName( + publisher_id); + break; + } + if (app_type == apps::mojom::AppType::kSystemWeb || + install_reason == apps::mojom::InstallReason::kSystem) { + // For system web apps, call GetSourceIdForChromeApp to record the app + // id because the url could be filtered by the server side. + source_id = ukm::AppSourceUrlRecorder::GetSourceIdForChromeApp(app_id); + break; + } + source_id = + ukm::AppSourceUrlRecorder::GetSourceIdForPWA(GURL(publisher_id)); + break; + } + case apps::mojom::AppType::kCrostini: + source_id = GetSourceIdForCrostini(profile, app_id); + break; + case apps::mojom::AppType::kBorealis: + source_id = GetSourceIdForBorealis(profile, app_id); + break; + case apps::mojom::AppType::kUnknown: + case apps::mojom::AppType::kMacOs: + case apps::mojom::AppType::kPluginVm: + case apps::mojom::AppType::kStandaloneBrowser: + case apps::mojom::AppType::kStandaloneBrowserChromeApp: + case apps::mojom::AppType::kRemote: + return ukm::kInvalidSourceId; + } + return source_id; +} + +// static +ukm::SourceId AppPlatformMetrics::GetSourceIdForBorealis( + Profile* profile, + const std::string& app_id) { + // Most Borealis apps are identified by a numeric ID, except these. + if (app_id == borealis::kBorealisMainAppId) { + return ukm::AppSourceUrlRecorder::GetSourceIdForBorealis("client"); + } else if (app_id == borealis::kBorealisAppId) { + return ukm::AppSourceUrlRecorder::GetSourceIdForBorealis("installer"); + } else if (app_id.find(borealis::kIgnoredAppIdPrefix) != std::string::npos) { + // These are not real apps from a user's point of view, + // so it doesn't make sense to record metrics for them. + return ukm::kInvalidSourceId; + } + + auto* registry = + guest_os::GuestOsRegistryServiceFactory::GetForProfile(profile); + auto registration = registry->GetRegistration(app_id); + if (!registration) { + // If there's no registration then we're not allowed to record anything that + // could identify the app (and we don't know the app name anyway), but + // recording every unregistered app in one big bucket is fine. + // + // In general all Borealis apps should be registered, so if we do see this + // Source ID being reported, that's a bug. + LOG(WARNING) << "Couldn't get Borealis ID for UNREGISTERED app " << app_id; + return ukm::AppSourceUrlRecorder::GetSourceIdForBorealis("UNREGISTERED"); + } + absl::optional borealis_id = + borealis::GetBorealisAppId(registration->Exec()); + if (!borealis_id) + LOG(WARNING) << "Couldn't get Borealis ID for registered app " << app_id; + return ukm::AppSourceUrlRecorder::GetSourceIdForBorealis( + borealis_id ? base::NumberToString(borealis_id.value()) : "NoId"); +} + +// static +ukm::SourceId AppPlatformMetrics::GetSourceIdForCrostini( + Profile* profile, + const std::string& app_id) { + if (app_id == crostini::kCrostiniTerminalSystemAppId) { + // The terminal is special, since it's actually a web app (though one we + // count as Crostini) it doesn't have a desktop id, so give it a fake one. + return ukm::AppSourceUrlRecorder::GetSourceIdForCrostini("CrostiniTerminal", + "Terminal"); + } + auto* registry = + guest_os::GuestOsRegistryServiceFactory::GetForProfile(profile); + auto registration = registry->GetRegistration(app_id); + if (!registration) { + // If there's no registration then we're not allowed to record anything that + // could identify the app (and we don't know the app name anyway), but + // recording every unregistered app in one big bucket is fine. + return ukm::AppSourceUrlRecorder::GetSourceIdForCrostini("UNREGISTERED", + "UNREGISTERED"); + } + auto desktop_id = registration->DesktopFileId() == "" + ? "NoId" + : registration->DesktopFileId(); + return ukm::AppSourceUrlRecorder::GetSourceIdForCrostini( + desktop_id, registration->Name()); +} + // static std::string AppPlatformMetrics::GetAppsCountHistogramNameForTest( AppTypeName app_type_name) { @@ -477,7 +607,7 @@ void AppPlatformMetrics::RecordAppLaunchUkm( apps::AppTypeName app_type_name = GetAppTypeName(profile_, app_type, app_id, container); - ukm::SourceId source_id = GetSourceId(app_id); + ukm::SourceId source_id = GetSourceId(profile_, app_id); if (source_id == ukm::kInvalidSourceId) { return; } @@ -498,7 +628,7 @@ void AppPlatformMetrics::RecordAppUninstallUkm( GetAppTypeName(profile_, app_type, app_id, apps::mojom::LaunchContainer::kLaunchContainerNone); - ukm::SourceId source_id = GetSourceId(app_id); + ukm::SourceId source_id = GetSourceId(profile_, app_id); if (source_id == ukm::kInvalidSourceId) { return; } @@ -755,7 +885,7 @@ void AppPlatformMetrics::SetWindowInActivated( app_type_v2_running_time_per_five_minutes_[app_type_name_v2] += running_time; if (usage_time_it == usage_time_per_five_minutes_.end()) { - auto source_id = GetSourceId(app_id); + auto source_id = GetSourceId(profile_, app_id); if (source_id != ukm::kInvalidSourceId) { usage_time_per_five_minutes_[it->first].source_id = source_id; usage_time_it = usage_time_per_five_minutes_.find(it->first); @@ -897,7 +1027,7 @@ void AppPlatformMetrics::RecordAppsUsageTime() { auto usage_time_it = usage_time_per_five_minutes_.find(it.first); if (usage_time_it == usage_time_per_five_minutes_.end()) { - auto source_id = GetSourceId(it.second.app_id); + auto source_id = GetSourceId(profile_, it.second.app_id); if (source_id != ukm::kInvalidSourceId) { usage_time_per_five_minutes_[it.first].source_id = source_id; usage_time_it = usage_time_per_five_minutes_.find(it.first); @@ -965,7 +1095,7 @@ void AppPlatformMetrics::RecordAppsInstallUkm(const apps::AppUpdate& update, GetAppTypeName(profile_, update.AppType(), update.AppId(), apps::mojom::LaunchContainer::kLaunchContainerNone); - ukm::SourceId source_id = GetSourceId(update.AppId()); + ukm::SourceId source_id = GetSourceId(profile_, update.AppId()); if (source_id == ukm::kInvalidSourceId) { return; } @@ -980,122 +1110,4 @@ void AppPlatformMetrics::RecordAppsInstallUkm(const apps::AppUpdate& update, ukm::AppSourceUrlRecorder::MarkSourceForDeletion(source_id); } -ukm::SourceId AppPlatformMetrics::GetSourceId(const std::string& app_id) { - ukm::SourceId source_id = ukm::kInvalidSourceId; - apps::mojom::AppType app_type = GetAppType(profile_, app_id); - if (!ShouldRecordUkmForAppTypeName(ConvertMojomAppTypToAppType(app_type))) { - return ukm::kInvalidSourceId; - } - - switch (app_type) { - case apps::mojom::AppType::kBuiltIn: - case apps::mojom::AppType::kChromeApp: - case apps::mojom::AppType::kExtension: - source_id = ukm::AppSourceUrlRecorder::GetSourceIdForChromeApp(app_id); - break; - case apps::mojom::AppType::kArc: - case apps::mojom::AppType::kWeb: - case apps::mojom::AppType::kSystemWeb: { - std::string publisher_id; - apps::mojom::InstallReason install_reason; - app_registry_cache_.ForOneApp(app_id, [&publisher_id, &install_reason]( - const apps::AppUpdate& update) { - publisher_id = update.PublisherId(); - install_reason = update.InstallReason(); - }); - if (publisher_id.empty()) { - return ukm::kInvalidSourceId; - } - if (app_type == apps::mojom::AppType::kArc) { - source_id = ukm::AppSourceUrlRecorder::GetSourceIdForArcPackageName( - publisher_id); - break; - } - if (app_type == apps::mojom::AppType::kSystemWeb || - install_reason == apps::mojom::InstallReason::kSystem) { - // For system web apps, call GetSourceIdForChromeApp to record the app - // id because the url could be filtered by the server side. - source_id = ukm::AppSourceUrlRecorder::GetSourceIdForChromeApp(app_id); - break; - } - source_id = - ukm::AppSourceUrlRecorder::GetSourceIdForPWA(GURL(publisher_id)); - break; - } - case apps::mojom::AppType::kCrostini: - source_id = GetSourceIdForCrostini(app_id); - break; - case apps::mojom::AppType::kBorealis: - source_id = GetSourceIdForBorealis(app_id); - break; - case apps::mojom::AppType::kUnknown: - case apps::mojom::AppType::kMacOs: - case apps::mojom::AppType::kPluginVm: - case apps::mojom::AppType::kStandaloneBrowser: - case apps::mojom::AppType::kStandaloneBrowserChromeApp: - case apps::mojom::AppType::kRemote: - return ukm::kInvalidSourceId; - } - return source_id; -} - -ukm::SourceId AppPlatformMetrics::GetSourceIdForBorealis( - const std::string& app_id) { - // Most Borealis apps are identified by a numeric ID, except these. - if (app_id == borealis::kBorealisMainAppId) { - return ukm::AppSourceUrlRecorder::GetSourceIdForBorealis("client"); - } else if (app_id == borealis::kBorealisAppId) { - return ukm::AppSourceUrlRecorder::GetSourceIdForBorealis("installer"); - } else if (app_id.find(borealis::kIgnoredAppIdPrefix) != std::string::npos) { - // These are not real apps from a user's point of view, - // so it doesn't make sense to record metrics for them. - return ukm::kInvalidSourceId; - } - - auto* registry = - guest_os::GuestOsRegistryServiceFactory::GetForProfile(profile_); - auto registration = registry->GetRegistration(app_id); - if (!registration) { - // If there's no registration then we're not allowed to record anything that - // could identify the app (and we don't know the app name anyway), but - // recording every unregistered app in one big bucket is fine. - // - // In general all Borealis apps should be registered, so if we do see this - // Source ID being reported, that's a bug. - LOG(WARNING) << "Couldn't get Borealis ID for UNREGISTERED app " << app_id; - return ukm::AppSourceUrlRecorder::GetSourceIdForBorealis("UNREGISTERED"); - } - absl::optional borealis_id = - borealis::GetBorealisAppId(registration->Exec()); - if (!borealis_id) - LOG(WARNING) << "Couldn't get Borealis ID for registered app " << app_id; - return ukm::AppSourceUrlRecorder::GetSourceIdForBorealis( - borealis_id ? base::NumberToString(borealis_id.value()) : "NoId"); -} - -ukm::SourceId AppPlatformMetrics::GetSourceIdForCrostini( - const std::string& app_id) { - if (app_id == crostini::kCrostiniTerminalSystemAppId) { - // The terminal is special, since it's actually a web app (though one we - // count as Crostini) it doesn't have a desktop id, so give it a fake one. - return ukm::AppSourceUrlRecorder::GetSourceIdForCrostini("CrostiniTerminal", - "Terminal"); - } - auto* registry = - guest_os::GuestOsRegistryServiceFactory::GetForProfile(profile_); - auto registration = registry->GetRegistration(app_id); - if (!registration) { - // If there's no registration then we're not allowed to record anything that - // could identify the app (and we don't know the app name anyway), but - // recording every unregistered app in one big bucket is fine. - return ukm::AppSourceUrlRecorder::GetSourceIdForCrostini("UNREGISTERED", - "UNREGISTERED"); - } - auto desktop_id = registration->DesktopFileId() == "" - ? "NoId" - : registration->DesktopFileId(); - return ukm::AppSourceUrlRecorder::GetSourceIdForCrostini( - desktop_id, registration->Name()); -} - } // namespace apps diff --git a/chrome/browser/apps/app_service/metrics/app_platform_metrics.h b/chrome/browser/apps/app_service/metrics/app_platform_metrics.h index 19796b02d626ec..92751d5c3da35a 100644 --- a/chrome/browser/apps/app_service/metrics/app_platform_metrics.h +++ b/chrome/browser/apps/app_service/metrics/app_platform_metrics.h @@ -83,6 +83,17 @@ class AppPlatformMetrics : public apps::AppRegistryCache::Observer, AppPlatformMetrics& operator=(const AppPlatformMetrics&) = delete; ~AppPlatformMetrics() override; + // Returns the SourceId of UKM for `app_id`. + static ukm::SourceId GetSourceId(Profile* profile, const std::string& app_id); + + // Returns the SourceId for a Borealis app_id. + static ukm::SourceId GetSourceIdForBorealis(Profile* profile, + const std::string& app_id); + + // Gets the source id for a Crostini app_id. + static ukm::SourceId GetSourceIdForCrostini(Profile* profile, + const std::string& app_id); + // UMA metrics name for installed apps count in Chrome OS. static std::string GetAppsCountHistogramNameForTest( AppTypeName app_type_name); @@ -220,15 +231,6 @@ class AppPlatformMetrics : public apps::AppRegistryCache::Observer, void RecordAppsInstallUkm(const apps::AppUpdate& update, InstallTime install_time); - // Returns the SourceId of UKM for `app_id`. - ukm::SourceId GetSourceId(const std::string& app_id); - - // Returns the SourceId for a Borealis app_id. - ukm::SourceId GetSourceIdForBorealis(const std::string& app_id); - - // Gets the source id for a Crostini app_id. - ukm::SourceId GetSourceIdForCrostini(const std::string& app_id); - Profile* const profile_ = nullptr; AppRegistryCache& app_registry_cache_; diff --git a/chrome/browser/apps/guest_view/web_view_browsertest.cc b/chrome/browser/apps/guest_view/web_view_browsertest.cc index 40183a997392b4..cdda7e5e15e888 100644 --- a/chrome/browser/apps/guest_view/web_view_browsertest.cc +++ b/chrome/browser/apps/guest_view/web_view_browsertest.cc @@ -1618,7 +1618,45 @@ IN_PROC_BROWSER_TEST_F(WebViewNewWindowTest, } IN_PROC_BROWSER_TEST_F(WebViewNewWindowTest, Shim_TestNewWindowNoReferrerLink) { + GURL newwindow_url("about:blank#noreferrer"); + content::TestNavigationObserver observer(newwindow_url); + observer.StartWatchingNewWebContents(); + TestHelper("testNewWindowNoReferrerLink", "web_view/shim", NEEDS_TEST_SERVER); + + // The first tag in the test will run window.open(), which the + // embedder will translate into an injected second tag. Ensure + // that both 's are in guest SiteInstances and in the same + // StoragePartition. + GetGuestViewManager()->WaitForNumGuestsCreated(2); + std::vector guest_contents_list; + GetGuestViewManager()->GetGuestWebContentsList(&guest_contents_list); + ASSERT_EQ(2u, guest_contents_list.size()); + content::WebContents* guest1 = guest_contents_list[0]; + content::WebContents* guest2 = guest_contents_list[1]; + ASSERT_NE(guest1, guest2); + auto* guest_instance1 = guest1->GetMainFrame()->GetSiteInstance(); + auto* guest_instance2 = guest2->GetMainFrame()->GetSiteInstance(); + EXPECT_TRUE(guest_instance1->IsGuest()); + EXPECT_TRUE(guest_instance2->IsGuest()); + EXPECT_EQ(guest_instance1->GetStoragePartitionConfig(), + guest_instance2->GetStoragePartitionConfig()); + + // Until guests have site isolation, both guests should be in the + // same SiteInstance, even in this `opener_suppressed` case which typically + // places the new window in a new BrowsingInstance. + // + // TODO(alexmos): revisit this once guests support site isolation. + EXPECT_EQ(guest_instance1, guest_instance2); + + // Check that the source SiteInstance used when the first guest opened the + // new noreferrer window is also a guest SiteInstance in the same + // StoragePartition. + observer.Wait(); + ASSERT_TRUE(observer.last_source_site_instance()); + EXPECT_TRUE(observer.last_source_site_instance()->IsGuest()); + EXPECT_EQ(observer.last_source_site_instance()->GetStoragePartitionConfig(), + guest_instance1->GetStoragePartitionConfig()); } IN_PROC_BROWSER_TEST_F(WebViewNewWindowTest, diff --git a/chrome/browser/apps/platform_apps/api/arc_apps_private/arc_apps_private_apitest.cc b/chrome/browser/apps/platform_apps/api/arc_apps_private/arc_apps_private_apitest.cc index 415eba00b7bdf5..59941cd7703584 100644 --- a/chrome/browser/apps/platform_apps/api/arc_apps_private/arc_apps_private_apitest.cc +++ b/chrome/browser/apps/platform_apps/api/arc_apps_private/arc_apps_private_apitest.cc @@ -106,8 +106,11 @@ IN_PROC_BROWSER_TEST_F(ArcAppsPrivateApiTest, GetPackageNameAndLaunchApp) { // successfully. CreateAppInstance(prefs); app_instance()->SendRefreshAppList({launchable_app}); - ASSERT_EQ(1u, app_instance()->launch_requests().size()); - EXPECT_TRUE(app_instance()->launch_requests()[0]->IsForApp(launchable_app)); + EXPECT_EQ(0u, app_instance()->launch_requests().size()); + ASSERT_EQ(1u, app_instance()->launch_intents().size()); + EXPECT_NE(app_instance()->launch_intents()[0].find( + "component=Package_0/Dummy_activity_0;"), + std::string::npos); } IN_PROC_BROWSER_TEST_F(ArcAppsPrivateApiTest, OnInstalled) { diff --git a/chrome/browser/ash/app_mode/kiosk_app_data.cc b/chrome/browser/ash/app_mode/kiosk_app_data.cc index c1764f0c436acf..0a2e00199553ef 100644 --- a/chrome/browser/ash/app_mode/kiosk_app_data.cc +++ b/chrome/browser/ash/app_mode/kiosk_app_data.cc @@ -225,15 +225,15 @@ class KioskAppData::WebstoreDataParser } std::string required_platform_version; - if (manifest.FindPath( - extensions::manifest_keys::kKioskRequiredPlatformVersion) && - (!manifest.GetString( - extensions::manifest_keys::kKioskRequiredPlatformVersion, - &required_platform_version) || - !extensions::KioskModeInfo::IsValidPlatformVersion( - required_platform_version))) { - ReportFailure(); - return; + if (const base::Value* temp = manifest.FindPath( + extensions::manifest_keys::kKioskRequiredPlatformVersion)) { + if (!temp->is_string() || + !extensions::KioskModeInfo::IsValidPlatformVersion( + temp->GetString())) { + ReportFailure(); + return; + } + required_platform_version = temp->GetString(); } if (client_) diff --git a/chrome/browser/ash/app_mode/kiosk_app_launch_error.cc b/chrome/browser/ash/app_mode/kiosk_app_launch_error.cc index 2390676d8df7ab..e177517656b62d 100644 --- a/chrome/browser/ash/app_mode/kiosk_app_launch_error.cc +++ b/chrome/browser/ash/app_mode/kiosk_app_launch_error.cc @@ -4,11 +4,11 @@ #include "chrome/browser/ash/app_mode/kiosk_app_launch_error.h" +#include "ash/components/login/auth/auth_status_consumer.h" #include "base/metrics/histogram_macros.h" #include "chrome/browser/ash/app_mode/kiosk_app_manager.h" #include "chrome/browser/browser_process.h" #include "chrome/grit/generated_resources.h" -#include "chromeos/login/auth/auth_status_consumer.h" #include "components/prefs/scoped_user_pref_update.h" #include "ui/base/l10n/l10n_util.h" diff --git a/chrome/browser/ash/app_mode/kiosk_app_launch_error.h b/chrome/browser/ash/app_mode/kiosk_app_launch_error.h index 4e8e4eeab573ce..8fa88a5ca333fe 100644 --- a/chrome/browser/ash/app_mode/kiosk_app_launch_error.h +++ b/chrome/browser/ash/app_mode/kiosk_app_launch_error.h @@ -9,7 +9,7 @@ // TODO(https://crbug.com/1164001): forward declare AuthFailure when migrated // to ash/components/. -#include "chromeos/login/auth/auth_status_consumer.h" +#include "ash/components/login/auth/auth_status_consumer.h" namespace ash { diff --git a/chrome/browser/ash/app_mode/kiosk_app_launch_error_unittest.cc b/chrome/browser/ash/app_mode/kiosk_app_launch_error_unittest.cc index ac1c1ebfb92b01..b51b3a4d332dd3 100644 --- a/chrome/browser/ash/app_mode/kiosk_app_launch_error_unittest.cc +++ b/chrome/browser/ash/app_mode/kiosk_app_launch_error_unittest.cc @@ -6,11 +6,11 @@ #include +#include "ash/components/login/auth/auth_status_consumer.h" #include "chrome/browser/ash/app_mode/kiosk_app_manager.h" #include "chrome/grit/generated_resources.h" #include "chrome/test/base/scoped_testing_local_state.h" #include "chrome/test/base/testing_browser_process.h" -#include "chromeos/login/auth/auth_status_consumer.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/l10n/l10n_util.h" diff --git a/chrome/browser/ash/app_mode/kiosk_external_update_validator.cc b/chrome/browser/ash/app_mode/kiosk_external_update_validator.cc index 4a37e0a26731ac..440c4e2d73932d 100644 --- a/chrome/browser/ash/app_mode/kiosk_external_update_validator.cc +++ b/chrome/browser/ash/app_mode/kiosk_external_update_validator.cc @@ -62,12 +62,12 @@ void KioskExternalUpdateValidator::OnUnpackSuccess( DCHECK(crx_file_.extension_id == extension->id()); std::string minimum_browser_version; - if (!extension->manifest()->GetString( - extensions::manifest_keys::kMinimumChromeVersion, - &minimum_browser_version)) { + if (const std::string* temp = extension->manifest()->FindStringPath( + extensions::manifest_keys::kMinimumChromeVersion)) { + minimum_browser_version = *temp; + } else { LOG(ERROR) << "Can't find minimum browser version for app " << crx_file_.extension_id; - minimum_browser_version.clear(); } content::GetUIThreadTaskRunner({})->PostTask( diff --git a/chrome/browser/ash/app_mode/kiosk_profile_loader.cc b/chrome/browser/ash/app_mode/kiosk_profile_loader.cc index 5d2b5237e7757d..49d06b07f8801f 100644 --- a/chrome/browser/ash/app_mode/kiosk_profile_loader.cc +++ b/chrome/browser/ash/app_mode/kiosk_profile_loader.cc @@ -6,6 +6,8 @@ #include +#include "ash/components/login/auth/auth_status_consumer.h" +#include "ash/components/login/auth/user_context.h" #include "base/bind.h" #include "base/ignore_result.h" #include "base/location.h" @@ -22,8 +24,6 @@ #include "chrome/browser/lifetime/application_lifetime.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/userdataauth/userdataauth_client.h" -#include "chromeos/login/auth/auth_status_consumer.h" -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" #include "components/user_manager/user_names.h" #include "content/public/browser/browser_thread.h" diff --git a/chrome/browser/ash/app_mode/kiosk_profile_loader.h b/chrome/browser/ash/app_mode/kiosk_profile_loader.h index dacfda99ae67b2..242162d6f092a6 100644 --- a/chrome/browser/ash/app_mode/kiosk_profile_loader.h +++ b/chrome/browser/ash/app_mode/kiosk_profile_loader.h @@ -8,13 +8,13 @@ #include #include +#include "ash/components/login/auth/login_performer.h" +// TODO(https://crbug.com/1164001): remove when migrated to ash/components/. +#include "ash/components/login/auth/user_context.h" #include "base/callback.h" #include "chrome/browser/ash/app_mode/kiosk_app_launch_error.h" #include "chrome/browser/ash/app_mode/kiosk_app_manager_base.h" #include "chrome/browser/ash/login/session/user_session_manager.h" -#include "chromeos/login/auth/login_performer.h" -// TODO(https://crbug.com/1164001): remove when migrated to ash/components/. -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" class Profile; diff --git a/chrome/browser/ash/arc/arc_optin_uma.cc b/chrome/browser/ash/arc/arc_optin_uma.cc index ab8861aa77a9fe..cc7d2414f2c80f 100644 --- a/chrome/browser/ash/arc/arc_optin_uma.cc +++ b/chrome/browser/ash/arc/arc_optin_uma.cc @@ -166,11 +166,10 @@ void UpdatePlayStoreLaunchTime(const base::TimeDelta& elapsed_time) { base::Milliseconds(10), base::Seconds(20), 50); } -void UpdatePlayStoreShownTimeDeprecated(const base::TimeDelta& elapsed_time, - const Profile* profile) { +void UpdateDeferredLaunchTime(const base::TimeDelta& elapsed_time) { base::UmaHistogramCustomTimes( - GetHistogramNameByUserType("Arc.PlayStoreShown.TimeDelta", profile), - elapsed_time, base::Seconds(1), base::Minutes(10), 50); + "Arc.FirstAppLaunchDelay.TimeDeltaUntilAppLaunch", elapsed_time, + base::Milliseconds(10), base::Seconds(60), 50); } void UpdateAuthTiming(const char* histogram_name, diff --git a/chrome/browser/ash/arc/arc_optin_uma.h b/chrome/browser/ash/arc/arc_optin_uma.h index 93f7e14b5c1113..2f6acf1e148001 100644 --- a/chrome/browser/ash/arc/arc_optin_uma.h +++ b/chrome/browser/ash/arc/arc_optin_uma.h @@ -263,10 +263,7 @@ void UpdateArcUiAvailableTime(const base::TimeDelta& elapsed_time, const std::string& mode, const Profile* profile); void UpdatePlayStoreLaunchTime(const base::TimeDelta& elapsed_time); -// TODO(khmel): Remove this in favor of UpdateArcUiAvailableTime once it is -// rolled and has confirmed usability. -void UpdatePlayStoreShownTimeDeprecated(const base::TimeDelta& elapsed_time, - const Profile* profile); +void UpdateDeferredLaunchTime(const base::TimeDelta& elapsed_time); void UpdateSilentAuthCodeUMA(OptInSilentAuthCode state); void UpdateSupervisionTransitionResultUMA(mojom::ManagementChangeStatus result); void UpdateReauthorizationSilentAuthCodeUMA(OptInSilentAuthCode state); diff --git a/chrome/browser/ash/arc/intent_helper/open_with_menu.h b/chrome/browser/ash/arc/intent_helper/open_with_menu.h index ac007113cd37bf..3c6b1376f16f0f 100644 --- a/chrome/browser/ash/arc/intent_helper/open_with_menu.h +++ b/chrome/browser/ash/arc/intent_helper/open_with_menu.h @@ -10,7 +10,7 @@ #include #include -#include "components/arc/intent_helper/link_handler_model.h" +#include "components/arc/common/intent_helper/link_handler_model.h" #include "components/renderer_context_menu/render_view_context_menu_observer.h" #include "ui/base/models/simple_menu_model.h" #include "url/gurl.h" diff --git a/chrome/browser/ash/arc/intent_helper/open_with_menu_unittest.cc b/chrome/browser/ash/arc/intent_helper/open_with_menu_unittest.cc index eff26217299241..1e839d9ce5169b 100644 --- a/chrome/browser/ash/arc/intent_helper/open_with_menu_unittest.cc +++ b/chrome/browser/ash/arc/intent_helper/open_with_menu_unittest.cc @@ -14,7 +14,7 @@ #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/renderer_context_menu/mock_render_view_context_menu.h" #include "chrome/grit/generated_resources.h" -#include "components/arc/intent_helper/link_handler_model.h" +#include "components/arc/common/intent_helper/link_handler_model.h" #include "components/renderer_context_menu/render_view_context_menu_observer.h" #include "components/renderer_context_menu/render_view_context_menu_proxy.h" #include "content/public/test/browser_task_environment.h" diff --git a/chrome/browser/ash/arc/session/arc_session_manager.cc b/chrome/browser/ash/arc/session/arc_session_manager.cc index a207f471433e93..ee623d465f7ce5 100644 --- a/chrome/browser/ash/arc/session/arc_session_manager.cc +++ b/chrome/browser/ash/arc/session/arc_session_manager.cc @@ -59,6 +59,7 @@ #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" #include "chrome/browser/ui/app_list/arc/arc_fast_app_reinstall_starter.h" #include "chrome/browser/ui/app_list/arc/arc_pai_starter.h" +#include "chrome/browser/ui/app_list/arc/intent.h" #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/webui/chromeos/diagnostics_dialog.h" diff --git a/chrome/browser/ash/borealis/borealis_features.cc b/chrome/browser/ash/borealis/borealis_features.cc index bd69a53e3c0b25..b3490a653445ca 100644 --- a/chrome/browser/ash/borealis/borealis_features.cc +++ b/chrome/browser/ash/borealis/borealis_features.cc @@ -12,24 +12,44 @@ #include "chromeos/tpm/install_attributes.h" #include "components/prefs/pref_service.h" -namespace borealis { +using AllowStatus = borealis::BorealisFeatures::AllowStatus; -BorealisFeatures::BorealisFeatures(Profile* profile) : profile_(profile) {} +namespace borealis { -bool BorealisFeatures::IsAllowed() { +// static +AllowStatus BorealisFeatures::GetAllowanceForProfile(Profile* profile) { if (!base::FeatureList::IsEnabled(features::kBorealis)) - return false; + return AllowStatus::kFeatureDisabled; bool allowed_for_device; if (ash::CrosSettings::Get()->GetBoolean(ash::kBorealisAllowedForDevice, &allowed_for_device)) { if (!allowed_for_device) - return false; + return AllowStatus::kDevicePolicyBlocked; } - if (!profile_->GetPrefs()->GetBoolean(prefs::kBorealisAllowedForUser)) - return false; + if (!profile->GetPrefs()->GetBoolean(prefs::kBorealisAllowedForUser)) + return AllowStatus::kUserPrefBlocked; + + return AllowStatus::kAllowed; +} + +BorealisFeatures::BorealisFeatures(Profile* profile) : profile_(profile) {} +namespace { + +bool g_should_show_reason = true; + +} // namespace + +bool BorealisFeatures::IsAllowed() { + AllowStatus reason = GetAllowanceForProfile(profile_); + if (reason != AllowStatus::kAllowed) { + LOG_IF(ERROR, g_should_show_reason) + << "Borealis is not allowed: " << reason; + g_should_show_reason = false; + return false; + } return true; } @@ -40,3 +60,16 @@ bool BorealisFeatures::IsEnabled() { } } // namespace borealis + +std::ostream& operator<<(std::ostream& os, const AllowStatus& reason) { + switch (reason) { + case AllowStatus::kAllowed: + return os << "Borealis is allowed"; + case AllowStatus::kFeatureDisabled: + return os << "Borealis feature is unavailable"; + case AllowStatus::kDevicePolicyBlocked: + return os << "Device is enrolled and borealis is disabled by policy"; + case AllowStatus::kUserPrefBlocked: + return os << "User profile preferences disallow borealis"; + } +} diff --git a/chrome/browser/ash/borealis/borealis_features.h b/chrome/browser/ash/borealis/borealis_features.h index fbbe5d123ec378..23906a823ff993 100644 --- a/chrome/browser/ash/borealis/borealis_features.h +++ b/chrome/browser/ash/borealis/borealis_features.h @@ -5,12 +5,27 @@ #ifndef CHROME_BROWSER_ASH_BOREALIS_BOREALIS_FEATURES_H_ #define CHROME_BROWSER_ASH_BOREALIS_BOREALIS_FEATURES_H_ +#include +#include + class Profile; namespace borealis { class BorealisFeatures { public: + // Enumeration for the reasons borealis might be allowed or not. + enum class AllowStatus { + kAllowed, + kFeatureDisabled, + kDevicePolicyBlocked, + kUserPrefBlocked, + }; + + // Static accessor for the allowed-ness check. Returns an AllowStatus + // relevant to the given |profile|. + static AllowStatus GetAllowanceForProfile(Profile* profile); + // Creates a per-profile instance of the feature-checker for borealis. explicit BorealisFeatures(Profile* profile); @@ -27,4 +42,7 @@ class BorealisFeatures { } // namespace borealis +std::ostream& operator<<(std::ostream& os, + const borealis::BorealisFeatures::AllowStatus& reason); + #endif // CHROME_BROWSER_ASH_BOREALIS_BOREALIS_FEATURES_H_ diff --git a/chrome/browser/ash/crosapi/BUILD.gn b/chrome/browser/ash/crosapi/BUILD.gn index bfb0ba524743fc..56217688584c10 100644 --- a/chrome/browser/ash/crosapi/BUILD.gn +++ b/chrome/browser/ash/crosapi/BUILD.gn @@ -162,6 +162,7 @@ source_set("crosapi") { "//ash/components/account_manager", "//ash/components/arc/mojom", "//ash/components/arc/session", + "//ash/components/login/auth", "//ash/components/settings:settings", "//ash/constants", "//base", @@ -185,7 +186,6 @@ source_set("crosapi") { "//chromeos/dbus/update_engine", "//chromeos/dbus/upstart", "//chromeos/dbus/userdataauth:userdataauth_proto", - "//chromeos/login/auth", "//chromeos/login/login_state", "//chromeos/network", "//chromeos/printing", diff --git a/chrome/browser/ash/crosapi/arc_ash.cc b/chrome/browser/ash/crosapi/arc_ash.cc index d9afdb0af36324..d3b630aa7e1ef7 100644 --- a/chrome/browser/ash/crosapi/arc_ash.cc +++ b/chrome/browser/ash/crosapi/arc_ash.cc @@ -10,7 +10,6 @@ #include "ash/components/arc/session/arc_bridge_service.h" #include "ash/components/arc/session/arc_service_manager.h" #include "base/bind.h" -#include "base/notreached.h" #include "chrome/browser/profiles/profile.h" #include "components/arc/intent_helper/arc_intent_helper_bridge.h" @@ -26,6 +25,31 @@ STATIC_ASSERT_SCALE_FACTOR(SCALE_FACTOR_300P); namespace crosapi { +namespace { + +// Retrurns IntentHelperHolder for getting mojom API. +// Return nullptr if not ready or supported. +arc::ConnectionHolder* +GetIntentHelperHolder() { + auto* arc_service_manager = arc::ArcServiceManager::Get(); + if (!arc_service_manager) { + LOG(WARNING) << "ARC is not ready"; + return nullptr; + } + + auto* intent_helper_holder = + arc_service_manager->arc_bridge_service()->intent_helper(); + if (!intent_helper_holder->IsConnected()) { + LOG(WARNING) << "ARC intent helper instance is not ready."; + return nullptr; + } + + return intent_helper_holder; +} + +} // namespace + ArcAsh::ArcAsh() = default; ArcAsh::~ArcAsh() = default; @@ -72,18 +96,9 @@ void ArcAsh::RequestActivityIcons( std::vector activities, mojom::ScaleFactor scale_factor, RequestActivityIconsCallback callback) { - auto* arc_service_manager = arc::ArcServiceManager::Get(); - if (!arc_service_manager) { - LOG(WARNING) << "ARC is not ready"; - return; - } - - auto* intent_helper_holder = - arc_service_manager->arc_bridge_service()->intent_helper(); - if (!intent_helper_holder->IsConnected()) { - LOG(WARNING) << "ARC intent helper instance is not ready."; + auto* intent_helper_holder = GetIntentHelperHolder(); + if (!intent_helper_holder) return; - } auto* instance = ARC_GET_INSTANCE_FOR_METHOD(intent_helper_holder, RequestActivityIcons); @@ -127,7 +142,49 @@ void ArcAsh::ConvertActivityIcons( void ArcAsh::RequestUrlHandlerList(const std::string& url, RequestUrlHandlerListCallback callback) { - NOTIMPLEMENTED(); + auto* intent_helper_holder = GetIntentHelperHolder(); + if (!intent_helper_holder) + return; + + auto* instance = + ARC_GET_INSTANCE_FOR_METHOD(intent_helper_holder, RequestUrlHandlerList); + if (!instance) { + LOG(WARNING) << "RequestUrlHandlerList is not supported."; + return; + } + + instance->RequestUrlHandlerList( + url, base::BindOnce(&ArcAsh::ConvertIntentHandlerInfo, + weak_ptr_factory_.GetWeakPtr(), std::move(callback))); +} + +void ArcAsh::ConvertIntentHandlerInfo( + RequestUrlHandlerListCallback callback, + std::vector handlers) { + // Convert handlers to crosapi::mojom::IntentHandlerInfoPtr from + // arc::mojom::IntentHandlerInfoPtr. + std::vector converted_handlers; + for (const auto& handler : handlers) { + mojom::IntentHandlerInfoPtr converted_handler(mojom::IntentHandlerInfo::New( + handler->name, handler->package_name, handler->activity_name)); + converted_handlers.push_back(std::move(converted_handler)); + } + std::move(callback).Run(std::move(converted_handlers)); +} + +void ArcAsh::HandleUrl(const std::string& url, + const std::string& package_name) { + auto* intent_helper_holder = GetIntentHelperHolder(); + if (!intent_helper_holder) + return; + + auto* instance = ARC_GET_INSTANCE_FOR_METHOD(intent_helper_holder, HandleUrl); + if (!instance) { + LOG(WARNING) << "HandleUrl is not supported."; + return; + } + + instance->HandleUrl(url, package_name); } void ArcAsh::OnIconInvalidated(const std::string& package_name) { diff --git a/chrome/browser/ash/crosapi/arc_ash.h b/chrome/browser/ash/crosapi/arc_ash.h index db87ba45340b2c..31aceed96dcb3a 100644 --- a/chrome/browser/ash/crosapi/arc_ash.h +++ b/chrome/browser/ash/crosapi/arc_ash.h @@ -40,6 +40,8 @@ class ArcAsh : public mojom::Arc, public arc::ArcIntentHelperObserver { RequestActivityIconsCallback callback) override; void RequestUrlHandlerList(const std::string& url, RequestUrlHandlerListCallback callback) override; + void HandleUrl(const std::string& url, + const std::string& package_name) override; // arc::ArcLacrosObserver: void OnIconInvalidated(const std::string& package_name) override; @@ -49,6 +51,10 @@ class ArcAsh : public mojom::Arc, public arc::ArcIntentHelperObserver { // Called when activity icons are sent. void ConvertActivityIcons(RequestActivityIconsCallback callback, std::vector icons); + // Called when intent handler list is sent. + void ConvertIntentHandlerInfo( + RequestUrlHandlerListCallback callback, + std::vector handlers); // This class supports any number of connections. mojo::ReceiverSet receivers_; diff --git a/chrome/browser/ash/crosapi/authentication_ash.cc b/chrome/browser/ash/crosapi/authentication_ash.cc index c293829f745884..c72c09b1afe90a 100644 --- a/chrome/browser/ash/crosapi/authentication_ash.cc +++ b/chrome/browser/ash/crosapi/authentication_ash.cc @@ -6,13 +6,13 @@ #include +#include "ash/components/login/auth/extended_authenticator.h" #include "base/check.h" #include "chrome/browser/extensions/api/passwords_private/passwords_private_utils_chromeos.h" #include "chrome/browser/extensions/api/quick_unlock_private/quick_unlock_private_ash_utils.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/common/extensions/api/quick_unlock_private.h" -#include "chromeos/login/auth/extended_authenticator.h" #include "content/public/browser/browser_thread.h" #include "third_party/abseil-cpp/absl/types/optional.h" diff --git a/chrome/browser/ash/guest_os/guest_os_registry_service.cc b/chrome/browser/ash/guest_os/guest_os_registry_service.cc index f7222ed45f1ab0..dd62c543e62171 100644 --- a/chrome/browser/ash/guest_os/guest_os_registry_service.cc +++ b/chrome/browser/ash/guest_os/guest_os_registry_service.cc @@ -35,6 +35,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/app_list/app_list_syncable_service.h" #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" +#include "chrome/grit/app_icon_resources.h" #include "chrome/grit/generated_resources.h" #include "chromeos/dbus/vm_applications/apps.pb.h" #include "components/crx_file/id_util.h" @@ -44,7 +45,6 @@ #include "components/services/app_service/public/cpp/icon_types.h" #include "extensions/browser/api/file_handlers/mime_util.h" #include "ui/base/l10n/l10n_util.h" -#include "ui/chromeos/resources/grit/ui_chromeos_resources.h" #include "ui/gfx/image/image_skia_operations.h" using vm_tools::apps::App; diff --git a/chrome/browser/ash/login/auth/chrome_cryptohome_authenticator.h b/chrome/browser/ash/login/auth/chrome_cryptohome_authenticator.h index f668410a5e1c4d..08641ad465102e 100644 --- a/chrome/browser/ash/login/auth/chrome_cryptohome_authenticator.h +++ b/chrome/browser/ash/login/auth/chrome_cryptohome_authenticator.h @@ -5,7 +5,7 @@ #ifndef CHROME_BROWSER_ASH_LOGIN_AUTH_CHROME_CRYPTOHOME_AUTHENTICATOR_H_ #define CHROME_BROWSER_ASH_LOGIN_AUTH_CHROME_CRYPTOHOME_AUTHENTICATOR_H_ -#include "chromeos/login/auth/cryptohome_authenticator.h" +#include "ash/components/login/auth/cryptohome_authenticator.h" namespace ash { diff --git a/chrome/browser/ash/login/auth/chrome_login_performer.h b/chrome/browser/ash/login/auth/chrome_login_performer.h index 2af4bd7b10da93..f1a3499082b174 100644 --- a/chrome/browser/ash/login/auth/chrome_login_performer.h +++ b/chrome/browser/ash/login/auth/chrome_login_performer.h @@ -8,13 +8,13 @@ #include #include +#include "ash/components/login/auth/auth_status_consumer.h" +#include "ash/components/login/auth/authenticator.h" +#include "ash/components/login/auth/extended_authenticator.h" +#include "ash/components/login/auth/login_performer.h" +#include "ash/components/login/auth/user_context.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/ash/policy/login/wildcard_login_checker.h" -#include "chromeos/login/auth/auth_status_consumer.h" -#include "chromeos/login/auth/authenticator.h" -#include "chromeos/login/auth/extended_authenticator.h" -#include "chromeos/login/auth/login_performer.h" -#include "chromeos/login/auth/user_context.h" #include "components/user_manager/user_type.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" diff --git a/chrome/browser/ash/login/auth/chrome_safe_mode_delegate.h b/chrome/browser/ash/login/auth/chrome_safe_mode_delegate.h index 88fbb15f6a667a..6e53534f5efcb7 100644 --- a/chrome/browser/ash/login/auth/chrome_safe_mode_delegate.h +++ b/chrome/browser/ash/login/auth/chrome_safe_mode_delegate.h @@ -5,7 +5,7 @@ #ifndef CHROME_BROWSER_ASH_LOGIN_AUTH_CHROME_SAFE_MODE_DELEGATE_H_ #define CHROME_BROWSER_ASH_LOGIN_AUTH_CHROME_SAFE_MODE_DELEGATE_H_ -#include "chromeos/login/auth/safe_mode_delegate.h" +#include "ash/components/login/auth/safe_mode_delegate.h" namespace ash { diff --git a/chrome/browser/ash/login/auth/cryptohome_authenticator_unittest.cc b/chrome/browser/ash/login/auth/cryptohome_authenticator_unittest.cc index a73e9262bbe5dd..ca6fce9ad1c5e2 100644 --- a/chrome/browser/ash/login/auth/cryptohome_authenticator_unittest.cc +++ b/chrome/browser/ash/login/auth/cryptohome_authenticator_unittest.cc @@ -9,6 +9,11 @@ #include #include +#include "ash/components/login/auth/cryptohome_key_constants.h" +#include "ash/components/login/auth/key.h" +#include "ash/components/login/auth/mock_auth_status_consumer.h" +#include "ash/components/login/auth/test_attempt_state.h" +#include "ash/components/login/auth/user_context.h" #include "ash/constants/ash_switches.h" #include "base/bind.h" #include "base/command_line.h" @@ -36,11 +41,6 @@ #include "chromeos/dbus/cryptohome/rpc.pb.h" #include "chromeos/dbus/userdataauth/fake_cryptohome_misc_client.h" #include "chromeos/dbus/userdataauth/fake_userdataauth_client.h" -#include "chromeos/login/auth/cryptohome_key_constants.h" -#include "chromeos/login/auth/key.h" -#include "chromeos/login/auth/mock_auth_status_consumer.h" -#include "chromeos/login/auth/test_attempt_state.h" -#include "chromeos/login/auth/user_context.h" #include "chromeos/login/login_state/login_state.h" #include "components/ownership/mock_owner_key_util.h" #include "components/user_manager/scoped_user_manager.h" diff --git a/chrome/browser/ash/login/challenge_response_auth_keys_loader.cc b/chrome/browser/ash/login/challenge_response_auth_keys_loader.cc index df1463e89229cb..9515f6dc1f283a 100644 --- a/chrome/browser/ash/login/challenge_response_auth_keys_loader.cc +++ b/chrome/browser/ash/login/challenge_response_auth_keys_loader.cc @@ -9,6 +9,8 @@ #include #include +#include "ash/components/login/auth/challenge_response/cert_utils.h" +#include "ash/components/login/auth/challenge_response/known_user_pref_utils.h" #include "base/bind.h" #include "base/callback.h" #include "base/containers/flat_set.h" @@ -22,8 +24,6 @@ #include "chrome/browser/ash/certificate_provider/certificate_provider_service_factory.h" #include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/profiles/profile.h" -#include "chromeos/login/auth/challenge_response/cert_utils.h" -#include "chromeos/login/auth/challenge_response/known_user_pref_utils.h" #include "components/account_id/account_id.h" #include "components/prefs/pref_service.h" #include "components/user_manager/known_user.h" diff --git a/chrome/browser/ash/login/challenge_response_auth_keys_loader.h b/chrome/browser/ash/login/challenge_response_auth_keys_loader.h index 1231fc64db3e2f..6fa2d8d8eded35 100644 --- a/chrome/browser/ash/login/challenge_response_auth_keys_loader.h +++ b/chrome/browser/ash/login/challenge_response_auth_keys_loader.h @@ -8,11 +8,11 @@ #include #include +#include "ash/components/login/auth/challenge_response_key.h" #include "base/memory/weak_ptr.h" #include "base/scoped_observation.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_observer.h" -#include "chromeos/login/auth/challenge_response_key.h" #include "net/ssl/client_cert_identity.h" class AccountId; diff --git a/chrome/browser/ash/login/challenge_response_auth_keys_loader_browsertest.cc b/chrome/browser/ash/login/challenge_response_auth_keys_loader_browsertest.cc index ec4efc38dfc4f9..adea7396c538b7 100644 --- a/chrome/browser/ash/login/challenge_response_auth_keys_loader_browsertest.cc +++ b/chrome/browser/ash/login/challenge_response_auth_keys_loader_browsertest.cc @@ -6,6 +6,8 @@ #include +#include "ash/components/login/auth/challenge_response/known_user_pref_utils.h" +#include "ash/components/login/auth/challenge_response_key.h" #include "base/callback_helpers.h" #include "base/run_loop.h" #include "base/scoped_observation.h" @@ -16,8 +18,6 @@ #include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/policy/extension_force_install_mixin.h" #include "chrome/browser/profiles/profile.h" -#include "chromeos/login/auth/challenge_response/known_user_pref_utils.h" -#include "chromeos/login/auth/challenge_response_key.h" #include "components/account_id/account_id.h" #include "components/user_manager/known_user.h" #include "content/public/test/browser_test.h" diff --git a/chrome/browser/ash/login/crash_restore_browsertest.cc b/chrome/browser/ash/login/crash_restore_browsertest.cc index 95bd54d94d48ff..e61d4596bc0031 100644 --- a/chrome/browser/ash/login/crash_restore_browsertest.cc +++ b/chrome/browser/ash/login/crash_restore_browsertest.cc @@ -6,6 +6,7 @@ #include #include +#include "ash/components/login/auth/user_context.h" #include "ash/constants/ash_switches.h" #include "base/command_line.h" #include "base/files/file_path.h" @@ -32,7 +33,6 @@ #include "chromeos/dbus/session_manager/fake_session_manager_client.h" #include "chromeos/dbus/session_manager/session_manager_client.h" #include "chromeos/dbus/userdataauth/userdataauth_client.h" -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" #include "components/session_manager/core/session_manager.h" #include "components/user_manager/user.h" diff --git a/chrome/browser/ash/login/device_family_link_allowed_policy_browsertest.cc b/chrome/browser/ash/login/device_family_link_allowed_policy_browsertest.cc index c4c88367af6afd..c668df693d65ac 100644 --- a/chrome/browser/ash/login/device_family_link_allowed_policy_browsertest.cc +++ b/chrome/browser/ash/login/device_family_link_allowed_policy_browsertest.cc @@ -4,6 +4,8 @@ #include +#include "ash/components/login/auth/stub_authenticator_builder.h" +#include "ash/components/login/auth/user_context.h" #include "ash/components/settings/cros_settings_names.h" #include "ash/constants/ash_features.h" #include "ash/public/cpp/login_screen_test_api.h" @@ -18,8 +20,6 @@ #include "chrome/browser/ash/policy/core/device_policy_cros_browser_test.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/lifetime/application_lifetime.h" -#include "chromeos/login/auth/stub_authenticator_builder.h" -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" #include "components/policy/proto/chrome_device_policy.pb.h" #include "components/user_manager/user_manager.h" diff --git a/chrome/browser/ash/login/easy_unlock/easy_unlock_create_keys_operation.cc b/chrome/browser/ash/login/easy_unlock/easy_unlock_create_keys_operation.cc index 0fb92dccdbccd5..f47fd605fdf284 100644 --- a/chrome/browser/ash/login/easy_unlock/easy_unlock_create_keys_operation.cc +++ b/chrome/browser/ash/login/easy_unlock/easy_unlock_create_keys_operation.cc @@ -9,6 +9,7 @@ #include #include +#include "ash/components/login/auth/key.h" #include "base/base64url.h" #include "base/bind.h" #include "base/logging.h" @@ -22,7 +23,6 @@ #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/easy_unlock/easy_unlock_client.h" #include "chromeos/dbus/userdataauth/userdataauth_client.h" -#include "chromeos/login/auth/key.h" #include "crypto/encryptor.h" #include "crypto/random.h" #include "crypto/symmetric_key.h" diff --git a/chrome/browser/ash/login/easy_unlock/easy_unlock_create_keys_operation.h b/chrome/browser/ash/login/easy_unlock/easy_unlock_create_keys_operation.h index e291d7470e8319..bbcc3a09ff5db5 100644 --- a/chrome/browser/ash/login/easy_unlock/easy_unlock_create_keys_operation.h +++ b/chrome/browser/ash/login/easy_unlock/easy_unlock_create_keys_operation.h @@ -10,11 +10,11 @@ #include #include +#include "ash/components/login/auth/user_context.h" #include "base/callback.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/ash/login/easy_unlock/easy_unlock_types.h" #include "chromeos/dbus/cryptohome/UserDataAuth.pb.h" -#include "chromeos/login/auth/user_context.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/cros_system_api/dbus/service_constants.h" diff --git a/chrome/browser/ash/login/easy_unlock/easy_unlock_get_keys_operation.h b/chrome/browser/ash/login/easy_unlock/easy_unlock_get_keys_operation.h index 27b8a13e40ea96..9e996f98ae4312 100644 --- a/chrome/browser/ash/login/easy_unlock/easy_unlock_get_keys_operation.h +++ b/chrome/browser/ash/login/easy_unlock/easy_unlock_get_keys_operation.h @@ -7,12 +7,12 @@ #include +#include "ash/components/login/auth/user_context.h" #include "base/callback.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/ash/login/easy_unlock/easy_unlock_types.h" #include "chromeos/dbus/cryptohome/UserDataAuth.pb.h" #include "chromeos/dbus/cryptohome/rpc.pb.h" -#include "chromeos/login/auth/user_context.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/cros_system_api/dbus/service_constants.h" diff --git a/chrome/browser/ash/login/easy_unlock/easy_unlock_key_manager.h b/chrome/browser/ash/login/easy_unlock/easy_unlock_key_manager.h index 0a83b21cfc223c..baf93cfd4bf302 100644 --- a/chrome/browser/ash/login/easy_unlock/easy_unlock_key_manager.h +++ b/chrome/browser/ash/login/easy_unlock/easy_unlock_key_manager.h @@ -11,14 +11,14 @@ #include #include +// TODO(https://crbug.com/1164001): move to forward declaration +#include "ash/components/login/auth/user_context.h" #include "base/callback.h" #include "base/containers/circular_deque.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/ash/login/easy_unlock/easy_unlock_get_keys_operation.h" #include "chrome/browser/ash/login/easy_unlock/easy_unlock_refresh_keys_operation.h" #include "chrome/browser/ash/login/easy_unlock/easy_unlock_types.h" -// TODO(https://crbug.com/1164001): move to forward declaration -#include "chromeos/login/auth/user_context.h" class AccountId; diff --git a/chrome/browser/ash/login/easy_unlock/easy_unlock_refresh_keys_operation.h b/chrome/browser/ash/login/easy_unlock/easy_unlock_refresh_keys_operation.h index fe12f279c1387d..7b612d62355b4e 100644 --- a/chrome/browser/ash/login/easy_unlock/easy_unlock_refresh_keys_operation.h +++ b/chrome/browser/ash/login/easy_unlock/easy_unlock_refresh_keys_operation.h @@ -7,10 +7,10 @@ #include +#include "ash/components/login/auth/user_context.h" #include "base/callback.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/ash/login/easy_unlock/easy_unlock_types.h" -#include "chromeos/login/auth/user_context.h" namespace ash { class EasyUnlockCreateKeysOperation; diff --git a/chrome/browser/ash/login/easy_unlock/easy_unlock_remove_keys_operation.h b/chrome/browser/ash/login/easy_unlock/easy_unlock_remove_keys_operation.h index df04215acaabb7..df5df42a299990 100644 --- a/chrome/browser/ash/login/easy_unlock/easy_unlock_remove_keys_operation.h +++ b/chrome/browser/ash/login/easy_unlock/easy_unlock_remove_keys_operation.h @@ -7,10 +7,10 @@ #include +#include "ash/components/login/auth/user_context.h" #include "base/callback.h" #include "base/memory/weak_ptr.h" #include "chromeos/dbus/cryptohome/UserDataAuth.pb.h" -#include "chromeos/login/auth/user_context.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/cros_system_api/dbus/service_constants.h" diff --git a/chrome/browser/ash/login/easy_unlock/easy_unlock_service.cc b/chrome/browser/ash/login/easy_unlock/easy_unlock_service.cc index b08655bdd63db4..5c33631db26b0e 100644 --- a/chrome/browser/ash/login/easy_unlock/easy_unlock_service.cc +++ b/chrome/browser/ash/login/easy_unlock/easy_unlock_service.cc @@ -7,6 +7,7 @@ #include #include +#include "ash/components/login/auth/user_context.h" #include "ash/components/proximity_auth/proximity_auth_local_state_pref_manager.h" #include "ash/components/proximity_auth/proximity_auth_profile_pref_manager.h" #include "ash/components/proximity_auth/proximity_auth_system.h" @@ -41,7 +42,6 @@ #include "chromeos/components/multidevice/logging/logging.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/power/power_manager_client.h" -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" #include "components/pref_registry/pref_registry_syncable.h" #include "components/prefs/pref_registry_simple.h" diff --git a/chrome/browser/ash/login/easy_unlock/easy_unlock_service_signin.cc b/chrome/browser/ash/login/easy_unlock/easy_unlock_service_signin.cc index 621d74abaa0fdd..48773a7423c16c 100644 --- a/chrome/browser/ash/login/easy_unlock/easy_unlock_service_signin.cc +++ b/chrome/browser/ash/login/easy_unlock/easy_unlock_service_signin.cc @@ -8,6 +8,7 @@ #include +#include "ash/components/login/auth/user_context.h" #include "ash/components/proximity_auth/proximity_auth_local_state_pref_manager.h" #include "ash/components/proximity_auth/smart_lock_metrics_recorder.h" #include "ash/public/cpp/smartlock_state.h" @@ -34,7 +35,6 @@ #include "chromeos/components/multidevice/remote_device_cache.h" #include "chromeos/components/multidevice/remote_device_ref.h" #include "chromeos/components/multidevice/software_feature_state.h" -#include "chromeos/login/auth/user_context.h" #include "chromeos/login/login_state/login_state.h" #include "chromeos/tpm/tpm_token_loader.h" diff --git a/chrome/browser/ash/login/easy_unlock/easy_unlock_user_login_flow.h b/chrome/browser/ash/login/easy_unlock/easy_unlock_user_login_flow.h index c09981acf638f2..440041f0d0752a 100644 --- a/chrome/browser/ash/login/easy_unlock/easy_unlock_user_login_flow.h +++ b/chrome/browser/ash/login/easy_unlock/easy_unlock_user_login_flow.h @@ -5,9 +5,9 @@ #ifndef CHROME_BROWSER_ASH_LOGIN_EASY_UNLOCK_EASY_UNLOCK_USER_LOGIN_FLOW_H_ #define CHROME_BROWSER_ASH_LOGIN_EASY_UNLOCK_EASY_UNLOCK_USER_LOGIN_FLOW_H_ -#include "chrome/browser/ash/login/user_flow.h" // TODO(https://crbug.com/1164001): move to forward declaration -#include "chromeos/login/auth/user_context.h" +#include "ash/components/login/auth/user_context.h" +#include "chrome/browser/ash/login/user_flow.h" class AccountId; diff --git a/chrome/browser/ash/login/encryption_migration_browsertest.cc b/chrome/browser/ash/login/encryption_migration_browsertest.cc index 8f5ed5ebf94ff4..ca27fcd5af24aa 100644 --- a/chrome/browser/ash/login/encryption_migration_browsertest.cc +++ b/chrome/browser/ash/login/encryption_migration_browsertest.cc @@ -4,6 +4,8 @@ #include +#include "ash/components/login/auth/stub_authenticator_builder.h" +#include "ash/components/login/auth/user_context.h" #include "ash/constants/ash_switches.h" #include "ash/public/cpp/login_screen_test_api.h" #include "base/command_line.h" @@ -26,8 +28,6 @@ #include "chromeos/dbus/power/fake_power_manager_client.h" #include "chromeos/dbus/session_manager/fake_session_manager_client.h" #include "chromeos/dbus/userdataauth/fake_userdataauth_client.h" -#include "chromeos/login/auth/stub_authenticator_builder.h" -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" #include "components/user_manager/known_user.h" #include "content/public/test/browser_test.h" diff --git a/chrome/browser/ash/login/enterprise_user_session_metrics.cc b/chrome/browser/ash/login/enterprise_user_session_metrics.cc index f6935c4109f053..4a7df02da8a94c 100644 --- a/chrome/browser/ash/login/enterprise_user_session_metrics.cc +++ b/chrome/browser/ash/login/enterprise_user_session_metrics.cc @@ -6,6 +6,7 @@ #include +#include "ash/components/login/auth/user_context.h" #include "base/check.h" #include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_macros.h" @@ -15,7 +16,6 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process_platform_part.h" #include "chrome/common/pref_names.h" -#include "chromeos/login/auth/user_context.h" #include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_service.h" diff --git a/chrome/browser/ash/login/enterprise_user_session_metrics.h b/chrome/browser/ash/login/enterprise_user_session_metrics.h index afdd3f979ba631..11aa14eed4f8cb 100644 --- a/chrome/browser/ash/login/enterprise_user_session_metrics.h +++ b/chrome/browser/ash/login/enterprise_user_session_metrics.h @@ -5,10 +5,10 @@ #ifndef CHROME_BROWSER_ASH_LOGIN_ENTERPRISE_USER_SESSION_METRICS_H_ #define CHROME_BROWSER_ASH_LOGIN_ENTERPRISE_USER_SESSION_METRICS_H_ +// TODO(https://crbug.com/1164001): move to forward declaration.h +#include "ash/components/login/auth/user_context.h" #include "base/time/time.h" #include "components/user_manager/user_type.h" -// TODO(https://crbug.com/1164001): move to forward declaration.h -#include "chromeos/login/auth/user_context.h" class PrefRegistrySimple; diff --git a/chrome/browser/ash/login/enterprise_user_session_metrics_unittest.cc b/chrome/browser/ash/login/enterprise_user_session_metrics_unittest.cc index 73b09917f18c92..1be564c217d109 100644 --- a/chrome/browser/ash/login/enterprise_user_session_metrics_unittest.cc +++ b/chrome/browser/ash/login/enterprise_user_session_metrics_unittest.cc @@ -6,12 +6,12 @@ #include +#include "ash/components/login/auth/user_context.h" #include "base/test/metrics/histogram_tester.h" #include "base/time/time.h" #include "chrome/browser/ash/login/demo_mode/demo_session.h" #include "chrome/test/base/scoped_testing_local_state.h" #include "chrome/test/base/testing_browser_process.h" -#include "chromeos/login/auth/user_context.h" #include "chromeos/tpm/stub_install_attributes.h" #include "components/account_id/account_id.h" #include "content/public/test/browser_task_environment.h" diff --git a/chrome/browser/ash/login/existing_user_controller.cc b/chrome/browser/ash/login/existing_user_controller.cc index d25ba5d3095d36..2fff4925527e60 100644 --- a/chrome/browser/ash/login/existing_user_controller.cc +++ b/chrome/browser/ash/login/existing_user_controller.cc @@ -10,6 +10,7 @@ #include "ash/components/arc/arc_util.h" #include "ash/components/arc/enterprise/arc_data_snapshotd_manager.h" +#include "ash/components/login/auth/key.h" #include "ash/components/login/session/session_termination_manager.h" #include "ash/components/settings/cros_settings_names.h" #include "ash/constants/ash_pref_names.h" @@ -95,7 +96,6 @@ #include "chromeos/dbus/power/power_manager_client.h" #include "chromeos/dbus/session_manager/session_manager_client.h" #include "chromeos/dbus/userdataauth/userdataauth_client.h" -#include "chromeos/login/auth/key.h" #include "chromeos/strings/grit/chromeos_strings.h" #include "components/account_id/account_id.h" #include "components/google/core/common/google_util.h" diff --git a/chrome/browser/ash/login/existing_user_controller.h b/chrome/browser/ash/login/existing_user_controller.h index 46cb2ad56a5d18..410a27fdfac34f 100644 --- a/chrome/browser/ash/login/existing_user_controller.h +++ b/chrome/browser/ash/login/existing_user_controller.h @@ -10,6 +10,8 @@ #include #include +#include "ash/components/login/auth/login_performer.h" +#include "ash/components/login/auth/user_context.h" #include "base/callback_forward.h" #include "base/gtest_prod_util.h" #include "base/memory/weak_ptr.h" @@ -22,8 +24,6 @@ #include "chrome/browser/ash/login/session/user_session_manager.h" #include "chrome/browser/ash/login/ui/login_display.h" #include "chrome/browser/ash/settings/device_settings_service.h" -#include "chromeos/login/auth/login_performer.h" -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" #include "components/user_manager/user.h" #include "components/user_manager/user_manager.h" diff --git a/chrome/browser/ash/login/existing_user_controller_browsertest.cc b/chrome/browser/ash/login/existing_user_controller_browsertest.cc index 3118517dde560a..fd8c9e818bb745 100644 --- a/chrome/browser/ash/login/existing_user_controller_browsertest.cc +++ b/chrome/browser/ash/login/existing_user_controller_browsertest.cc @@ -7,6 +7,9 @@ #include "ash/components/arc/enterprise/arc_data_snapshotd_manager.h" #include "ash/components/arc/test/arc_util_test_support.h" +#include "ash/components/login/auth/key.h" +#include "ash/components/login/auth/stub_authenticator_builder.h" +#include "ash/components/login/auth/user_context.h" #include "ash/components/settings/cros_settings_names.h" #include "ash/components/settings/cros_settings_provider.h" #include "ash/constants/ash_switches.h" @@ -67,9 +70,6 @@ #include "chromeos/dbus/power/fake_power_manager_client.h" #include "chromeos/dbus/session_manager/fake_session_manager_client.h" #include "chromeos/dbus/userdataauth/fake_userdataauth_client.h" -#include "chromeos/login/auth/key.h" -#include "chromeos/login/auth/stub_authenticator_builder.h" -#include "chromeos/login/auth/user_context.h" #include "chromeos/network/network_state_test_helper.h" #include "chromeos/strings/grit/chromeos_strings.h" #include "components/account_id/account_id.h" diff --git a/chrome/browser/ash/login/helper.cc b/chrome/browser/ash/login/helper.cc index 22d01864eaa6d7..11dbdc3c9e56b9 100644 --- a/chrome/browser/ash/login/helper.cc +++ b/chrome/browser/ash/login/helper.cc @@ -6,6 +6,7 @@ #include +#include "ash/components/login/auth/user_context.h" #include "base/bind.h" #include "base/command_line.h" #include "base/json/json_reader.h" @@ -20,7 +21,6 @@ #include "chrome/browser/password_manager/password_reuse_manager_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/grit/generated_resources.h" -#include "chromeos/login/auth/user_context.h" #include "chromeos/network/managed_network_configuration_handler.h" #include "chromeos/network/network_connection_handler.h" #include "chromeos/network/network_handler.h" diff --git a/chrome/browser/ash/login/lock/screen_locker.cc b/chrome/browser/ash/login/lock/screen_locker.cc index de26604afd6397..e581a15309fbba 100644 --- a/chrome/browser/ash/login/lock/screen_locker.cc +++ b/chrome/browser/ash/login/lock/screen_locker.cc @@ -7,6 +7,8 @@ #include #include "ash/components/audio/sounds.h" +#include "ash/components/login/auth/authenticator.h" +#include "ash/components/login/auth/extended_authenticator.h" #include "ash/components/login/session/session_termination_manager.h" #include "ash/constants/ash_pref_names.h" #include "ash/public/cpp/login_screen.h" @@ -54,8 +56,6 @@ #include "chrome/grit/generated_resources.h" #include "chromeos/dbus/biod/constants.pb.h" #include "chromeos/dbus/session_manager/session_manager_client.h" -#include "chromeos/login/auth/authenticator.h" -#include "chromeos/login/auth/extended_authenticator.h" #include "components/password_manager/core/browser/hash_password_manager.h" #include "components/prefs/pref_change_registrar.h" #include "components/session_manager/core/session_manager.h" diff --git a/chrome/browser/ash/login/lock/screen_locker.h b/chrome/browser/ash/login/lock/screen_locker.h index 6ff18530f65017..23e03f18afea92 100644 --- a/chrome/browser/ash/login/lock/screen_locker.h +++ b/chrome/browser/ash/login/lock/screen_locker.h @@ -10,6 +10,13 @@ #include #include +#include "ash/components/login/auth/auth_status_consumer.h" +// TODO(https://crbug.com/1164001): move to forward declaration. +#include "ash/components/login/auth/authenticator.h" +#include "ash/components/login/auth/challenge_response_key.h" +// TODO(https://crbug.com/1164001): move to forward declaration. +#include "ash/components/login/auth/extended_authenticator.h" +#include "ash/components/login/auth/user_context.h" #include "ash/public/cpp/login_types.h" #include "base/callback_forward.h" #include "base/memory/ref_counted.h" @@ -21,13 +28,6 @@ #include "chrome/browser/ash/login/help_app_launcher.h" #include "chrome/browser/ash/login/security_token_pin_dialog_host_login_impl.h" #include "chrome/browser/ash/login/ui/login_display.h" -#include "chromeos/login/auth/auth_status_consumer.h" -// TODO(https://crbug.com/1164001): move to forward declaration. -#include "chromeos/login/auth/authenticator.h" -#include "chromeos/login/auth/challenge_response_key.h" -// TODO(https://crbug.com/1164001): move to forward declaration. -#include "chromeos/login/auth/extended_authenticator.h" -#include "chromeos/login/auth/user_context.h" #include "components/user_manager/user.h" #include "components/user_manager/user_manager.h" #include "mojo/public/cpp/bindings/receiver.h" diff --git a/chrome/browser/ash/login/lock/screen_locker_tester.cc b/chrome/browser/ash/login/lock/screen_locker_tester.cc index 50c6397f630ce0..ae6abb6c7c77b1 100644 --- a/chrome/browser/ash/login/lock/screen_locker_tester.cc +++ b/chrome/browser/ash/login/lock/screen_locker_tester.cc @@ -7,17 +7,17 @@ #include #include +#include "ash/components/login/auth/auth_status_consumer.h" +#include "ash/components/login/auth/fake_extended_authenticator.h" +#include "ash/components/login/auth/key.h" +#include "ash/components/login/auth/stub_authenticator.h" +#include "ash/components/login/auth/user_context.h" #include "ash/public/cpp/login_screen_test_api.h" #include "base/run_loop.h" #include "base/scoped_observation.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/ash/login/lock/screen_locker.h" #include "chrome/browser/chrome_notification_types.h" -#include "chromeos/login/auth/auth_status_consumer.h" -#include "chromeos/login/auth/fake_extended_authenticator.h" -#include "chromeos/login/auth/key.h" -#include "chromeos/login/auth/stub_authenticator.h" -#include "chromeos/login/auth/user_context.h" #include "components/session_manager/session_manager_types.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/render_frame_host.h" diff --git a/chrome/browser/ash/login/login_client_cert_usage_observer.cc b/chrome/browser/ash/login/login_client_cert_usage_observer.cc index 957a62b93e55ba..0de8860754484b 100644 --- a/chrome/browser/ash/login/login_client_cert_usage_observer.cc +++ b/chrome/browser/ash/login/login_client_cert_usage_observer.cc @@ -7,13 +7,13 @@ #include #include +#include "ash/components/login/auth/challenge_response/cert_utils.h" #include "base/logging.h" #include "base/strings/string_piece.h" #include "chrome/browser/ash/certificate_provider/certificate_provider_service.h" #include "chrome/browser/ash/certificate_provider/certificate_provider_service_factory.h" #include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/profiles/profile.h" -#include "chromeos/login/auth/challenge_response/cert_utils.h" #include "net/cert/asn1_util.h" #include "net/cert/x509_util.h" #include "third_party/abseil-cpp/absl/types/optional.h" diff --git a/chrome/browser/ash/login/login_client_cert_usage_observer.h b/chrome/browser/ash/login/login_client_cert_usage_observer.h index 2f256e516ceeac..d3aa6793f36595 100644 --- a/chrome/browser/ash/login/login_client_cert_usage_observer.h +++ b/chrome/browser/ash/login/login_client_cert_usage_observer.h @@ -8,9 +8,9 @@ #include #include +#include "ash/components/login/auth/challenge_response_key.h" #include "base/memory/ref_counted.h" #include "chrome/browser/ash/certificate_provider/certificate_provider_service.h" -#include "chromeos/login/auth/challenge_response_key.h" #include "net/cert/x509_certificate.h" namespace ash { diff --git a/chrome/browser/ash/login/login_manager_test.cc b/chrome/browser/ash/login/login_manager_test.cc index 8319a6f42f1ddd..b2ef8043246872 100644 --- a/chrome/browser/ash/login/login_manager_test.cc +++ b/chrome/browser/ash/login/login_manager_test.cc @@ -6,6 +6,8 @@ #include +#include "ash/components/login/auth/key.h" +#include "ash/components/login/auth/user_context.h" #include "ash/constants/ash_switches.h" #include "ash/metrics/login_unlock_throughput_recorder.h" #include "ash/shell.h" @@ -20,8 +22,6 @@ #include "chrome/browser/ash/login/test/profile_prepared_waiter.h" #include "chrome/browser/ash/login/ui/login_display_host_webui.h" #include "chrome/browser/browser_process.h" -#include "chromeos/login/auth/key.h" -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" #include "components/prefs/scoped_user_pref_update.h" #include "components/user_manager/known_user.h" diff --git a/chrome/browser/ash/login/login_manager_test.h b/chrome/browser/ash/login/login_manager_test.h index f88de0e7540442..8c7c08aafa8e77 100644 --- a/chrome/browser/ash/login/login_manager_test.h +++ b/chrome/browser/ash/login/login_manager_test.h @@ -7,10 +7,10 @@ #include +// TODO(https://crbug.com/1164001): move to forward declaration. +#include "ash/components/login/auth/user_context.h" #include "chrome/browser/ash/login/test/embedded_test_server_setup_mixin.h" #include "chrome/test/base/mixin_based_in_process_browser_test.h" -// TODO(https://crbug.com/1164001): move to forward declaration. -#include "chromeos/login/auth/user_context.h" class AccountId; diff --git a/chrome/browser/ash/login/login_ui_keyboard_browsertest.cc b/chrome/browser/ash/login/login_ui_keyboard_browsertest.cc index 188ebded803a4e..ac52e21159151b 100644 --- a/chrome/browser/ash/login/login_ui_keyboard_browsertest.cc +++ b/chrome/browser/ash/login/login_ui_keyboard_browsertest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "ash/components/login/auth/user_context.h" #include "ash/constants/ash_features.h" #include "ash/public/cpp/login_screen_test_api.h" #include "base/command_line.h" @@ -32,7 +33,6 @@ #include "chrome/browser/ui/ash/login_screen_shown_observer.h" #include "chrome/browser/ui/webui/chromeos/login/user_creation_screen_handler.h" #include "chrome/common/pref_names.h" -#include "chromeos/login/auth/user_context.h" #include "components/prefs/pref_service.h" #include "components/user_manager/known_user.h" #include "content/public/test/browser_test.h" diff --git a/chrome/browser/ash/login/oobe_browsertest.cc b/chrome/browser/ash/login/oobe_browsertest.cc index 576dc2d4951769..1329f38e5633b8 100644 --- a/chrome/browser/ash/login/oobe_browsertest.cc +++ b/chrome/browser/ash/login/oobe_browsertest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "ash/components/login/auth/cryptohome_key_constants.h" #include "ash/constants/ash_switches.h" #include "ash/display/window_tree_host_manager.h" #include "ash/public/cpp/test/shell_test_api.h" @@ -33,7 +34,6 @@ #include "chromeos/dbus/cryptohome/key.pb.h" #include "chromeos/dbus/cryptohome/rpc.pb.h" #include "chromeos/dbus/userdataauth/fake_userdataauth_client.h" -#include "chromeos/login/auth/cryptohome_key_constants.h" #include "components/account_id/account_id.h" #include "components/user_manager/known_user.h" #include "components/user_manager/user.h" diff --git a/chrome/browser/ash/login/password_change_browsertest.cc b/chrome/browser/ash/login/password_change_browsertest.cc index 7213849f81e3bc..b089c1a233e5ee 100644 --- a/chrome/browser/ash/login/password_change_browsertest.cc +++ b/chrome/browser/ash/login/password_change_browsertest.cc @@ -6,6 +6,9 @@ #include #include +#include "ash/components/login/auth/stub_authenticator.h" +#include "ash/components/login/auth/stub_authenticator_builder.h" +#include "ash/components/login/auth/user_context.h" #include "ash/public/cpp/login_screen_test_api.h" #include "base/auto_reset.h" #include "base/bind.h" @@ -35,9 +38,6 @@ #include "chrome/browser/ui/webui/chromeos/login/gaia_password_changed_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" #include "chrome/test/base/interactive_test_utils.h" -#include "chromeos/login/auth/stub_authenticator.h" -#include "chromeos/login/auth/stub_authenticator_builder.h" -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" #include "components/user_manager/known_user.h" #include "components/user_manager/user_manager.h" diff --git a/chrome/browser/ash/login/quick_unlock/auth_token.cc b/chrome/browser/ash/login/quick_unlock/auth_token.cc index 6e2b9805cc98ca..43379b8c0ce345 100644 --- a/chrome/browser/ash/login/quick_unlock/auth_token.cc +++ b/chrome/browser/ash/login/quick_unlock/auth_token.cc @@ -4,10 +4,10 @@ #include "chrome/browser/ash/login/quick_unlock/auth_token.h" +#include "ash/components/login/auth/user_context.h" #include "base/bind.h" #include "base/task/single_thread_task_runner.h" #include "base/threading/thread_task_runner_handle.h" -#include "chromeos/login/auth/user_context.h" namespace ash { namespace quick_unlock { diff --git a/chrome/browser/ash/login/quick_unlock/pin_backend.h b/chrome/browser/ash/login/quick_unlock/pin_backend.h index 63423442e7ebad..770127ce6eed2e 100644 --- a/chrome/browser/ash/login/quick_unlock/pin_backend.h +++ b/chrome/browser/ash/login/quick_unlock/pin_backend.h @@ -7,8 +7,8 @@ #include +#include "ash/components/login/auth/key.h" #include "base/callback.h" -#include "chromeos/login/auth/key.h" #include "components/prefs/pref_service.h" class AccountId; diff --git a/chrome/browser/ash/login/quick_unlock/pin_storage_cryptohome.cc b/chrome/browser/ash/login/quick_unlock/pin_storage_cryptohome.cc index bab2448c286641..4a63422ce6faef 100644 --- a/chrome/browser/ash/login/quick_unlock/pin_storage_cryptohome.cc +++ b/chrome/browser/ash/login/quick_unlock/pin_storage_cryptohome.cc @@ -4,6 +4,8 @@ #include "chrome/browser/ash/login/quick_unlock/pin_storage_cryptohome.h" +#include "ash/components/login/auth/cryptohome_key_constants.h" +#include "ash/components/login/auth/user_context.h" #include "ash/constants/ash_pref_names.h" #include "base/bind.h" #include "base/logging.h" @@ -15,8 +17,6 @@ #include "chromeos/cryptohome/userdataauth_util.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/userdataauth/userdataauth_client.h" -#include "chromeos/login/auth/cryptohome_key_constants.h" -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" #include "components/user_manager/known_user.h" diff --git a/chrome/browser/ash/login/quick_unlock/pin_storage_cryptohome.h b/chrome/browser/ash/login/quick_unlock/pin_storage_cryptohome.h index 88e4b3103c0027..74e6576cf6e3c9 100644 --- a/chrome/browser/ash/login/quick_unlock/pin_storage_cryptohome.h +++ b/chrome/browser/ash/login/quick_unlock/pin_storage_cryptohome.h @@ -7,10 +7,10 @@ #include +// TODO(https://crbug.com/1164001): move to forward declaration +#include "ash/components/login/auth/user_context.h" #include "base/callback.h" #include "base/memory/weak_ptr.h" -// TODO(https://crbug.com/1164001): move to forward declaration -#include "chromeos/login/auth/user_context.h" #include "third_party/abseil-cpp/absl/types/optional.h" class AccountId; diff --git a/chrome/browser/ash/login/quick_unlock/pin_storage_cryptohome_unittest.cc b/chrome/browser/ash/login/quick_unlock/pin_storage_cryptohome_unittest.cc index c3d30365aeb2c7..068589c6dad878 100644 --- a/chrome/browser/ash/login/quick_unlock/pin_storage_cryptohome_unittest.cc +++ b/chrome/browser/ash/login/quick_unlock/pin_storage_cryptohome_unittest.cc @@ -6,6 +6,7 @@ #include +#include "ash/components/login/auth/cryptohome_key_constants.h" #include "base/bind.h" #include "base/logging.h" #include "base/run_loop.h" @@ -17,7 +18,6 @@ #include "chromeos/dbus/cryptohome/rpc.pb.h" #include "chromeos/dbus/userdataauth/fake_cryptohome_misc_client.h" #include "chromeos/dbus/userdataauth/fake_userdataauth_client.h" -#include "chromeos/login/auth/cryptohome_key_constants.h" #include "content/public/test/browser_task_environment.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/ash/login/quick_unlock/pin_storage_prefs.h b/chrome/browser/ash/login/quick_unlock/pin_storage_prefs.h index bd88f71c1ceabf..0b6dd6037e94c1 100644 --- a/chrome/browser/ash/login/quick_unlock/pin_storage_prefs.h +++ b/chrome/browser/ash/login/quick_unlock/pin_storage_prefs.h @@ -7,8 +7,8 @@ #include +#include "ash/components/login/auth/key.h" #include "base/gtest_prod_util.h" -#include "chromeos/login/auth/key.h" class PrefRegistrySimple; class PrefService; diff --git a/chrome/browser/ash/login/quick_unlock/quick_unlock_storage.h b/chrome/browser/ash/login/quick_unlock/quick_unlock_storage.h index 420ae829f83e68..7bf69dba72d3f2 100644 --- a/chrome/browser/ash/login/quick_unlock/quick_unlock_storage.h +++ b/chrome/browser/ash/login/quick_unlock/quick_unlock_storage.h @@ -5,9 +5,9 @@ #ifndef CHROME_BROWSER_ASH_LOGIN_QUICK_UNLOCK_QUICK_UNLOCK_STORAGE_H_ #define CHROME_BROWSER_ASH_LOGIN_QUICK_UNLOCK_QUICK_UNLOCK_STORAGE_H_ +#include "ash/components/login/auth/user_context.h" #include "base/time/default_clock.h" #include "base/time/time.h" -#include "chromeos/login/auth/user_context.h" #include "components/keyed_service/core/keyed_service.h" class Profile; diff --git a/chrome/browser/ash/login/quick_unlock/quick_unlock_storage_unittest.cc b/chrome/browser/ash/login/quick_unlock/quick_unlock_storage_unittest.cc index 8f00eefd779807..c9226ab5059548 100644 --- a/chrome/browser/ash/login/quick_unlock/quick_unlock_storage_unittest.cc +++ b/chrome/browser/ash/login/quick_unlock/quick_unlock_storage_unittest.cc @@ -6,6 +6,7 @@ #include +#include "ash/components/login/auth/user_context.h" #include "ash/constants/ash_pref_names.h" #include "base/time/time.h" #include "chrome/browser/ash/login/quick_unlock/auth_token.h" @@ -14,7 +15,6 @@ #include "chrome/browser/ash/login/quick_unlock/quick_unlock_factory.h" #include "chrome/browser/ash/login/quick_unlock/quick_unlock_utils.h" #include "chrome/test/base/testing_profile.h" -#include "chromeos/login/auth/user_context.h" #include "components/prefs/pref_service.h" #include "content/public/test/browser_task_environment.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/ash/login/reporting/login_logout_reporter.h b/chrome/browser/ash/login/reporting/login_logout_reporter.h index 2a8db2a67fca61..32a3cdc924a77f 100644 --- a/chrome/browser/ash/login/reporting/login_logout_reporter.h +++ b/chrome/browser/ash/login/reporting/login_logout_reporter.h @@ -5,12 +5,12 @@ #ifndef CHROME_BROWSER_ASH_LOGIN_REPORTING_LOGIN_LOGOUT_REPORTER_H_ #define CHROME_BROWSER_ASH_LOGIN_REPORTING_LOGIN_LOGOUT_REPORTER_H_ +#include "ash/components/login/auth/auth_status_consumer.h" #include "base/containers/queue.h" #include "base/scoped_observation.h" #include "chrome/browser/ash/policy/status_collector/managed_session_service.h" #include "chrome/browser/policy/messaging_layer/proto/synced/login_logout_event.pb.h" #include "chrome/browser/profiles/profile.h" -#include "chromeos/login/auth/auth_status_consumer.h" #include "components/policy/core/common/cloud/dm_token.h" #include "components/reporting/client/report_queue_provider.h" diff --git a/chrome/browser/ash/login/saml/in_session_password_change_manager.cc b/chrome/browser/ash/login/saml/in_session_password_change_manager.cc index 3ab97b4066c620..8856e64bc12f19 100644 --- a/chrome/browser/ash/login/saml/in_session_password_change_manager.cc +++ b/chrome/browser/ash/login/saml/in_session_password_change_manager.cc @@ -4,6 +4,7 @@ #include "chrome/browser/ash/login/saml/in_session_password_change_manager.h" +#include "ash/components/login/auth/user_context.h" #include "ash/constants/ash_features.h" #include "ash/public/cpp/session/session_activation_observer.h" #include "ash/public/cpp/session/session_controller.h" @@ -21,7 +22,6 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_dialogs.h" #include "chrome/common/chrome_features.h" -#include "chromeos/login/auth/user_context.h" #include "components/prefs/pref_service.h" #include "components/user_manager/known_user.h" #include "components/user_manager/user_manager.h" diff --git a/chrome/browser/ash/login/saml/in_session_password_change_manager.h b/chrome/browser/ash/login/saml/in_session_password_change_manager.h index 44bc26f3a10a9d..e66c3a9443c44f 100644 --- a/chrome/browser/ash/login/saml/in_session_password_change_manager.h +++ b/chrome/browser/ash/login/saml/in_session_password_change_manager.h @@ -8,16 +8,16 @@ #include #include +#include "ash/components/login/auth/auth_status_consumer.h" +// TODO(https://crbug.com/1164001): move to forward declaration. +#include "ash/components/login/auth/cryptohome_authenticator.h" +// TODO(https://crbug.com/1164001): move to forward declaration. +#include "ash/components/login/auth/user_context.h" #include "ash/public/cpp/session/session_activation_observer.h" #include "base/memory/scoped_refptr.h" #include "base/observer_list.h" #include "base/time/time.h" #include "chrome/browser/ash/login/saml/password_sync_token_fetcher.h" -#include "chromeos/login/auth/auth_status_consumer.h" -// TODO(https://crbug.com/1164001): move to forward declaration. -#include "chromeos/login/auth/cryptohome_authenticator.h" -// TODO(https://crbug.com/1164001): move to forward declaration. -#include "chromeos/login/auth/user_context.h" class Profile; diff --git a/chrome/browser/ash/login/saml/in_session_password_change_manager_unittest.cc b/chrome/browser/ash/login/saml/in_session_password_change_manager_unittest.cc index 3cc66df8cd6fbc..0bb5853b418820 100644 --- a/chrome/browser/ash/login/saml/in_session_password_change_manager_unittest.cc +++ b/chrome/browser/ash/login/saml/in_session_password_change_manager_unittest.cc @@ -4,6 +4,7 @@ #include "chrome/browser/ash/login/saml/in_session_password_change_manager.h" +#include "ash/components/login/auth/saml_password_attributes.h" #include "ash/public/cpp/session/session_activation_observer.h" #include "ash/public/cpp/session/session_controller.h" #include "base/strings/utf_string_conversions.h" @@ -17,7 +18,6 @@ #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile_manager.h" -#include "chromeos/login/auth/saml_password_attributes.h" #include "components/user_manager/scoped_user_manager.h" #include "components/user_manager/user_names.h" #include "content/public/test/browser_task_environment.h" diff --git a/chrome/browser/ash/login/saml/in_session_password_sync_manager.cc b/chrome/browser/ash/login/saml/in_session_password_sync_manager.cc index 6a2cb023c83f31..2d3ad13747fed6 100644 --- a/chrome/browser/ash/login/saml/in_session_password_sync_manager.cc +++ b/chrome/browser/ash/login/saml/in_session_password_sync_manager.cc @@ -6,6 +6,8 @@ #include +#include "ash/components/login/auth/extended_authenticator.h" +#include "ash/components/login/auth/user_context.h" #include "ash/components/proximity_auth/screenlock_bridge.h" #include "ash/constants/ash_switches.h" #include "base/command_line.h" @@ -19,8 +21,6 @@ #include "chrome/browser/ash/login/saml/password_sync_token_fetcher.h" #include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/ash/settings/cros_settings.h" -#include "chromeos/login/auth/extended_authenticator.h" -#include "chromeos/login/auth/user_context.h" #include "components/prefs/pref_service.h" #include "components/session_manager/core/session_manager.h" #include "components/session_manager/core/session_manager_observer.h" diff --git a/chrome/browser/ash/login/saml/in_session_password_sync_manager.h b/chrome/browser/ash/login/saml/in_session_password_sync_manager.h index c0cd50a53913c5..1fa3d8092757f4 100644 --- a/chrome/browser/ash/login/saml/in_session_password_sync_manager.h +++ b/chrome/browser/ash/login/saml/in_session_password_sync_manager.h @@ -8,18 +8,18 @@ #include #include +#include "ash/components/login/auth/auth_status_consumer.h" +// TODO(https://crbug.com/1164001): move to forward declaration. +#include "ash/components/login/auth/cryptohome_authenticator.h" +// TODO(https://crbug.com/1164001): move to forward declaration. +#include "ash/components/login/auth/extended_authenticator.h" +#include "ash/components/login/auth/user_context.h" #include "ash/components/proximity_auth/screenlock_bridge.h" +#include "base/callback_forward.h" #include "base/time/clock.h" #include "chrome/browser/ash/login/saml/password_sync_token_fetcher.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_dialogs.h" -#include "chromeos/login/auth/auth_status_consumer.h" -// TODO(https://crbug.com/1164001): move to forward declaration. -#include "chromeos/login/auth/cryptohome_authenticator.h" -// TODO(https://crbug.com/1164001): move to forward declaration. -#include "base/callback_forward.h" -#include "chromeos/login/auth/extended_authenticator.h" -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" #include "components/keyed_service/core/keyed_service.h" #include "components/prefs/pref_change_registrar.h" diff --git a/chrome/browser/ash/login/saml/in_session_password_sync_manager_unittest.cc b/chrome/browser/ash/login/saml/in_session_password_sync_manager_unittest.cc index 46726259c95a59..c3d7268934f9ac 100644 --- a/chrome/browser/ash/login/saml/in_session_password_sync_manager_unittest.cc +++ b/chrome/browser/ash/login/saml/in_session_password_sync_manager_unittest.cc @@ -4,6 +4,7 @@ #include "chrome/browser/ash/login/saml/in_session_password_sync_manager.h" +#include "ash/components/login/auth/user_context.h" #include "ash/constants/ash_features.h" #include "base/test/scoped_feature_list.h" #include "base/time/default_clock.h" @@ -15,7 +16,6 @@ #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile_manager.h" -#include "chromeos/login/auth/user_context.h" #include "components/user_manager/known_user.h" #include "components/user_manager/scoped_user_manager.h" #include "components/user_manager/user_names.h" diff --git a/chrome/browser/ash/login/saml/password_expiry_notification.cc b/chrome/browser/ash/login/saml/password_expiry_notification.cc index 57eed67ebf47a9..a1b997ef5c99a8 100644 --- a/chrome/browser/ash/login/saml/password_expiry_notification.cc +++ b/chrome/browser/ash/login/saml/password_expiry_notification.cc @@ -8,6 +8,7 @@ #include #include +#include "ash/components/login/auth/saml_password_attributes.h" #include "ash/public/cpp/notification_utils.h" #include "ash/public/cpp/session/session_activation_observer.h" #include "ash/public/cpp/session/session_controller.h" @@ -26,7 +27,6 @@ #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_ui.h" #include "chrome/common/pref_names.h" -#include "chromeos/login/auth/saml_password_attributes.h" #include "chromeos/strings/grit/chromeos_strings.h" #include "components/prefs/pref_service.h" #include "components/vector_icons/vector_icons.h" diff --git a/chrome/browser/ash/login/saml/password_expiry_notification_unittest.cc b/chrome/browser/ash/login/saml/password_expiry_notification_unittest.cc index e64bcedce2c1c8..3f20e754ea1e0b 100644 --- a/chrome/browser/ash/login/saml/password_expiry_notification_unittest.cc +++ b/chrome/browser/ash/login/saml/password_expiry_notification_unittest.cc @@ -4,6 +4,7 @@ #include "chrome/browser/ash/login/saml/password_expiry_notification.h" +#include "ash/components/login/auth/saml_password_attributes.h" #include "ash/public/cpp/session/session_activation_observer.h" #include "ash/public/cpp/session/session_controller.h" #include "base/strings/utf_string_conversions.h" @@ -17,7 +18,6 @@ #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile_manager.h" -#include "chromeos/login/auth/saml_password_attributes.h" #include "components/user_manager/scoped_user_manager.h" #include "components/user_manager/user_names.h" #include "content/public/test/browser_task_environment.h" diff --git a/chrome/browser/ash/login/saml/password_sync_token_verifier_unittest.cc b/chrome/browser/ash/login/saml/password_sync_token_verifier_unittest.cc index 4292183badf9f3..4e978ceca8fcae 100644 --- a/chrome/browser/ash/login/saml/password_sync_token_verifier_unittest.cc +++ b/chrome/browser/ash/login/saml/password_sync_token_verifier_unittest.cc @@ -4,6 +4,7 @@ #include "chrome/browser/ash/login/saml/password_sync_token_verifier.h" +#include "ash/components/login/auth/user_context.h" #include "base/test/metrics/histogram_tester.h" #include "base/time/default_clock.h" #include "chrome/browser/ash/login/login_pref_names.h" @@ -13,7 +14,6 @@ #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile_manager.h" -#include "chromeos/login/auth/user_context.h" #include "components/user_manager/known_user.h" #include "components/user_manager/scoped_user_manager.h" #include "components/user_manager/user_names.h" diff --git a/chrome/browser/ash/login/saml/saml_browsertest.cc b/chrome/browser/ash/login/saml/saml_browsertest.cc index 6148980323c2a7..c714403c5ef7c9 100644 --- a/chrome/browser/ash/login/saml/saml_browsertest.cc +++ b/chrome/browser/ash/login/saml/saml_browsertest.cc @@ -8,6 +8,8 @@ #include #include "ash/components/attestation/mock_attestation_flow.h" +#include "ash/components/login/auth/key.h" +#include "ash/components/login/auth/saml_password_attributes.h" #include "ash/components/settings/cros_settings_names.h" #include "ash/constants/ash_features.h" #include "ash/constants/ash_switches.h" @@ -77,8 +79,6 @@ #include "chromeos/dbus/shill/shill_manager_client.h" #include "chromeos/dbus/userdataauth/fake_cryptohome_misc_client.h" #include "chromeos/dbus/userdataauth/fake_userdataauth_client.h" -#include "chromeos/login/auth/key.h" -#include "chromeos/login/auth/saml_password_attributes.h" #include "chromeos/tpm/stub_install_attributes.h" #include "components/account_id/account_id.h" #include "components/content_settings/core/browser/host_content_settings_map.h" diff --git a/chrome/browser/ash/login/saml/saml_profile_prefs.cc b/chrome/browser/ash/login/saml/saml_profile_prefs.cc index 51d887b2734746..796aceb435ff81 100644 --- a/chrome/browser/ash/login/saml/saml_profile_prefs.cc +++ b/chrome/browser/ash/login/saml/saml_profile_prefs.cc @@ -4,9 +4,9 @@ #include "chrome/browser/ash/login/saml/saml_profile_prefs.h" +#include "ash/components/login/auth/saml_password_attributes.h" #include "chrome/browser/ash/login/login_constants.h" #include "chrome/browser/ash/login/login_pref_names.h" -#include "chromeos/login/auth/saml_password_attributes.h" #include "components/prefs/pref_registry_simple.h" namespace ash { diff --git a/chrome/browser/ash/login/screens/active_directory_login_screen.cc b/chrome/browser/ash/login/screens/active_directory_login_screen.cc index 9ced5b0704b24b..2acc851e0edd9e 100644 --- a/chrome/browser/ash/login/screens/active_directory_login_screen.cc +++ b/chrome/browser/ash/login/screens/active_directory_login_screen.cc @@ -4,6 +4,8 @@ #include "chrome/browser/ash/login/screens/active_directory_login_screen.h" +#include "ash/components/login/auth/cryptohome_key_constants.h" +#include "ash/components/login/auth/key.h" #include "chrome/browser/ash/login/screens/signin_fatal_error_screen.h" #include "chrome/browser/ash/login/ui/login_display_host.h" #include "chrome/browser/ash/login/ui/signin_ui.h" @@ -12,8 +14,6 @@ #include "chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h" #include "chrome/grit/generated_resources.h" -#include "chromeos/login/auth/cryptohome_key_constants.h" -#include "chromeos/login/auth/key.h" #include "chromeos/network/network_state.h" #include "chromeos/network/network_state_handler.h" #include "components/user_manager/known_user.h" diff --git a/chrome/browser/ash/login/screens/active_directory_login_screen.h b/chrome/browser/ash/login/screens/active_directory_login_screen.h index 16c4c9991d1ea0..02249482b1ebbc 100644 --- a/chrome/browser/ash/login/screens/active_directory_login_screen.h +++ b/chrome/browser/ash/login/screens/active_directory_login_screen.h @@ -8,6 +8,8 @@ #include #include +// TODO(https://crbug.com/1164001): move to forward declaration. +#include "ash/components/login/auth/key.h" #include "base/callback.h" #include "base/scoped_observation.h" #include "chrome/browser/ash/authpolicy/authpolicy_helper.h" @@ -16,8 +18,6 @@ // TODO(https://crbug.com/1164001): move to forward declaration. #include "chrome/browser/ui/webui/chromeos/login/active_directory_login_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" -// TODO(https://crbug.com/1164001): move to forward declaration. -#include "chromeos/login/auth/key.h" namespace ash { diff --git a/chrome/browser/ash/login/screens/active_directory_password_change_screen.cc b/chrome/browser/ash/login/screens/active_directory_password_change_screen.cc index 36db75a55eca1c..16d4fe2625e9e3 100644 --- a/chrome/browser/ash/login/screens/active_directory_password_change_screen.cc +++ b/chrome/browser/ash/login/screens/active_directory_password_change_screen.cc @@ -6,13 +6,13 @@ #include +#include "ash/components/login/auth/cryptohome_key_constants.h" +#include "ash/components/login/auth/key.h" #include "base/bind.h" #include "chrome/browser/ash/login/ui/login_display_host.h" #include "chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" #include "chrome/grit/generated_resources.h" -#include "chromeos/login/auth/cryptohome_key_constants.h" -#include "chromeos/login/auth/key.h" #include "components/user_manager/known_user.h" #include "ui/base/l10n/l10n_util.h" diff --git a/chrome/browser/ash/login/screens/active_directory_password_change_screen.h b/chrome/browser/ash/login/screens/active_directory_password_change_screen.h index e147a5a009eec1..7ff1170c679c77 100644 --- a/chrome/browser/ash/login/screens/active_directory_password_change_screen.h +++ b/chrome/browser/ash/login/screens/active_directory_password_change_screen.h @@ -8,13 +8,13 @@ #include #include +// TODO(https://crbug.com/1164001): move to forward declaration. +#include "ash/components/login/auth/key.h" #include "chrome/browser/ash/authpolicy/authpolicy_helper.h" #include "chrome/browser/ash/login/screen_manager.h" #include "chrome/browser/ash/login/screens/base_screen.h" // TODO(https://crbug.com/1164001): move to forward declaration. #include "chrome/browser/ui/webui/chromeos/login/active_directory_password_change_screen_handler.h" -// TODO(https://crbug.com/1164001): move to forward declaration. -#include "chromeos/login/auth/key.h" namespace authpolicy { class ActiveDirectoryAccountInfo; diff --git a/chrome/browser/ash/login/screens/encryption_migration_screen.h b/chrome/browser/ash/login/screens/encryption_migration_screen.h index d7b12deb926737..7f1019366b4c7e 100644 --- a/chrome/browser/ash/login/screens/encryption_migration_screen.h +++ b/chrome/browser/ash/login/screens/encryption_migration_screen.h @@ -8,6 +8,7 @@ #include #include +#include "ash/components/login/auth/user_context.h" #include "base/callback_forward.h" #include "base/scoped_observation.h" #include "chrome/browser/ash/login/screens/base_screen.h" @@ -20,7 +21,6 @@ #include "chromeos/dbus/cryptohome/rpc.pb.h" #include "chromeos/dbus/power/power_manager_client.h" #include "chromeos/dbus/userdataauth/userdataauth_client.h" -#include "chromeos/login/auth/user_context.h" #include "mojo/public/cpp/bindings/remote.h" #include "services/device/public/mojom/wake_lock.mojom.h" #include "third_party/cros_system_api/dbus/cryptohome/dbus-constants.h" diff --git a/chrome/browser/ash/login/screens/encryption_migration_screen_unittest.cc b/chrome/browser/ash/login/screens/encryption_migration_screen_unittest.cc index d84f752a0d079a..614b47de3d91ee 100644 --- a/chrome/browser/ash/login/screens/encryption_migration_screen_unittest.cc +++ b/chrome/browser/ash/login/screens/encryption_migration_screen_unittest.cc @@ -5,6 +5,8 @@ #include #include +#include "ash/components/login/auth/key.h" +#include "ash/components/login/auth/user_context.h" #include "base/bind.h" #include "base/memory/ptr_util.h" #include "base/test/task_environment.h" @@ -18,8 +20,6 @@ #include "chromeos/dbus/power/fake_power_manager_client.h" #include "chromeos/dbus/power/power_policy_controller.h" #include "chromeos/dbus/userdataauth/fake_userdataauth_client.h" -#include "chromeos/login/auth/key.h" -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" #include "components/user_manager/scoped_user_manager.h" #include "components/user_manager/user_names.h" diff --git a/chrome/browser/ash/login/screens/error_screen.h b/chrome/browser/ash/login/screens/error_screen.h index 696a9220b5d338..36d0c30bb0da21 100644 --- a/chrome/browser/ash/login/screens/error_screen.h +++ b/chrome/browser/ash/login/screens/error_screen.h @@ -7,6 +7,7 @@ #include +#include "ash/components/login/auth/login_performer.h" #include "base/callback_list.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/ash/login/screens/base_screen.h" @@ -17,7 +18,6 @@ // TODO(https://crbug.com/1164001): move to forward declaration. #include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" -#include "chromeos/login/auth/login_performer.h" #include "chromeos/network/network_connection_observer.h" #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" diff --git a/chrome/browser/ash/login/screens/family_link_notice_browsertest.cc b/chrome/browser/ash/login/screens/family_link_notice_browsertest.cc index fa1d47efb272e2..2fdc2fbd1f0212 100644 --- a/chrome/browser/ash/login/screens/family_link_notice_browsertest.cc +++ b/chrome/browser/ash/login/screens/family_link_notice_browsertest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "chrome/browser/ash/login/screens/family_link_notice_screen.h" +#include "ash/components/login/auth/stub_authenticator_builder.h" #include "ash/constants/ash_features.h" #include "chrome/browser/ash/login/oobe_screen.h" #include "chrome/browser/ash/login/test/fake_gaia_mixin.h" @@ -19,7 +20,6 @@ #include "chrome/browser/ui/webui/chromeos/login/family_link_notice_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/user_creation_screen_handler.h" #include "chrome/common/pref_names.h" -#include "chromeos/login/auth/stub_authenticator_builder.h" #include "components/prefs/pref_service.h" #include "content/public/test/browser_test.h" diff --git a/chrome/browser/ash/login/screens/offline_login_screen.cc b/chrome/browser/ash/login/screens/offline_login_screen.cc index cd9cf72e08fe42..12570951c20c9b 100644 --- a/chrome/browser/ash/login/screens/offline_login_screen.cc +++ b/chrome/browser/ash/login/screens/offline_login_screen.cc @@ -4,6 +4,8 @@ #include "chrome/browser/ash/login/screens/offline_login_screen.h" +#include "ash/components/login/auth/key.h" +#include "ash/components/login/auth/user_context.h" #include "base/bind.h" #include "base/metrics/histogram_functions.h" #include "base/time/default_clock.h" @@ -21,8 +23,6 @@ #include "chrome/browser/ui/webui/chromeos/login/offline_login_screen_handler.h" #include "chrome/grit/chromium_strings.h" #include "chrome/grit/generated_resources.h" -#include "chromeos/login/auth/key.h" -#include "chromeos/login/auth/user_context.h" #include "components/user_manager/known_user.h" #include "google_apis/gaia/gaia_auth_util.h" diff --git a/chrome/browser/ash/login/screens/pin_setup_screen.cc b/chrome/browser/ash/login/screens/pin_setup_screen.cc index cb5bf83e2e8ab9..b55155e6993a75 100644 --- a/chrome/browser/ash/login/screens/pin_setup_screen.cc +++ b/chrome/browser/ash/login/screens/pin_setup_screen.cc @@ -6,6 +6,8 @@ #include +#include "ash/components/login/auth/cryptohome_key_constants.h" +#include "ash/components/login/auth/user_context.h" #include "ash/constants/ash_features.h" #include "ash/constants/ash_switches.h" #include "ash/public/cpp/tablet_mode.h" @@ -22,8 +24,6 @@ #include "chrome/browser/policy/profile_policy_connector.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/webui/chromeos/login/pin_setup_screen_handler.h" -#include "chromeos/login/auth/cryptohome_key_constants.h" -#include "chromeos/login/auth/user_context.h" #include "components/prefs/pref_service.h" #include "components/user_manager/user_manager.h" diff --git a/chrome/browser/ash/login/screens/pin_setup_screen_browsertest.cc b/chrome/browser/ash/login/screens/pin_setup_screen_browsertest.cc index 6c7db81c359bb3..50452880596c15 100644 --- a/chrome/browser/ash/login/screens/pin_setup_screen_browsertest.cc +++ b/chrome/browser/ash/login/screens/pin_setup_screen_browsertest.cc @@ -4,6 +4,7 @@ #include "chrome/browser/ash/login/screens/pin_setup_screen.h" +#include "ash/components/login/auth/stub_authenticator_builder.h" #include "ash/constants/ash_features.h" #include "ash/public/cpp/test/shell_test_api.h" #include "base/auto_reset.h" @@ -24,7 +25,6 @@ #include "chrome/browser/ash/login/wizard_controller.h" #include "chrome/browser/ui/webui/chromeos/login/pin_setup_screen_handler.h" #include "chromeos/dbus/userdataauth/fake_userdataauth_client.h" -#include "chromeos/login/auth/stub_authenticator_builder.h" #include "components/user_manager/user_type.h" #include "content/public/test/browser_test.h" #include "testing/gmock/include/gmock/gmock.h" diff --git a/chrome/browser/ash/login/security_token_login_browsertest.cc b/chrome/browser/ash/login/security_token_login_browsertest.cc index 4a5c3fb03b0197..0c9ba725646054 100644 --- a/chrome/browser/ash/login/security_token_login_browsertest.cc +++ b/chrome/browser/ash/login/security_token_login_browsertest.cc @@ -8,6 +8,8 @@ #include #include +#include "ash/components/login/auth/auth_status_consumer.h" +#include "ash/components/login/auth/challenge_response/known_user_pref_utils.h" #include "ash/constants/ash_switches.h" #include "ash/public/cpp/login_screen_test_api.h" #include "ash/public/cpp/session/session_controller.h" @@ -38,8 +40,6 @@ #include "chromeos/dbus/cryptohome/rpc.pb.h" #include "chromeos/dbus/dbus_method_call_status.h" #include "chromeos/dbus/userdataauth/fake_userdataauth_client.h" -#include "chromeos/login/auth/auth_status_consumer.h" -#include "chromeos/login/auth/challenge_response/known_user_pref_utils.h" #include "components/account_id/account_id.h" #include "components/policy/core/browser/browser_policy_connector.h" #include "components/policy/core/common/mock_configuration_policy_provider.h" diff --git a/chrome/browser/ash/login/security_token_session_controller.cc b/chrome/browser/ash/login/security_token_session_controller.cc index 2989b7f20ad439..3510d59fadd1d9 100644 --- a/chrome/browser/ash/login/security_token_session_controller.cc +++ b/chrome/browser/ash/login/security_token_session_controller.cc @@ -7,6 +7,8 @@ #include #include +#include "ash/components/login/auth/challenge_response/known_user_pref_utils.h" +#include "ash/components/login/auth/challenge_response_key.h" #include "ash/public/cpp/notification_utils.h" #include "base/bind.h" #include "base/callback_helpers.h" @@ -29,8 +31,6 @@ #include "chrome/browser/ui/ash/security_token_session_restriction_view.h" #include "chrome/common/pref_names.h" #include "chrome/grit/generated_resources.h" -#include "chromeos/login/auth/challenge_response/known_user_pref_utils.h" -#include "chromeos/login/auth/challenge_response_key.h" #include "chromeos/ui/vector_icons/vector_icons.h" #include "components/prefs/pref_change_registrar.h" #include "components/prefs/pref_registry_simple.h" diff --git a/chrome/browser/ash/login/session/user_session_manager.cc b/chrome/browser/ash/login/session/user_session_manager.cc index de97b0507ac15e..8b4bed6a4811ef 100644 --- a/chrome/browser/ash/login/session/user_session_manager.cc +++ b/chrome/browser/ash/login/session/user_session_manager.cc @@ -16,6 +16,9 @@ #include "ash/components/account_manager/account_manager_factory.h" #include "ash/components/arc/arc_prefs.h" +#include "ash/components/login/auth/auth_session_authenticator.h" +#include "ash/components/login/auth/challenge_response/known_user_pref_utils.h" +#include "ash/components/login/auth/stub_authenticator_builder.h" #include "ash/components/login/session/session_termination_manager.h" #include "ash/components/settings/cros_settings_names.h" #include "ash/constants/ash_features.h" @@ -123,9 +126,6 @@ #include "chromeos/dbus/session_manager/session_manager_client.h" #include "chromeos/dbus/tpm_manager/tpm_manager.pb.h" #include "chromeos/dbus/tpm_manager/tpm_manager_client.h" -#include "chromeos/login/auth/auth_session_authenticator.h" -#include "chromeos/login/auth/challenge_response/known_user_pref_utils.h" -#include "chromeos/login/auth/stub_authenticator_builder.h" #include "chromeos/network/portal_detector/network_portal_detector.h" #include "chromeos/network/portal_detector/network_portal_detector_strategy.h" #include "chromeos/tpm/prepare_tpm.h" diff --git a/chrome/browser/ash/login/session/user_session_manager.h b/chrome/browser/ash/login/session/user_session_manager.h index 46089f2d704aca..c6d680e93d22e3 100644 --- a/chrome/browser/ash/login/session/user_session_manager.h +++ b/chrome/browser/ash/login/session/user_session_manager.h @@ -13,6 +13,12 @@ #include #include "ash/components/arc/net/always_on_vpn_manager.h" +// TODO(https://crbug.com/1164001): move to forward declaration. +#include "ash/components/login/auth/auth_status_consumer.h" +#include "ash/components/login/auth/authenticator.h" +// TODO(https://crbug.com/1164001): move to forward declaration. +#include "ash/components/login/auth/stub_authenticator_builder.h" +#include "ash/components/login/auth/user_context.h" #include "base/callback.h" #include "base/containers/flat_map.h" #include "base/containers/flat_set.h" @@ -41,12 +47,6 @@ #include "chrome/browser/ash/web_applications/help_app/help_app_notification_controller.h" #include "chromeos/dbus/session_manager/session_manager_client.h" #include "chromeos/dbus/tpm_manager/tpm_manager.pb.h" -// TODO(https://crbug.com/1164001): move to forward declaration. -#include "chromeos/login/auth/auth_status_consumer.h" -#include "chromeos/login/auth/authenticator.h" -// TODO(https://crbug.com/1164001): move to forward declaration. -#include "chromeos/login/auth/stub_authenticator_builder.h" -#include "chromeos/login/auth/user_context.h" #include "components/user_manager/user.h" #include "components/user_manager/user_manager.h" #include "services/network/public/cpp/network_connection_tracker.h" diff --git a/chrome/browser/ash/login/session/user_session_manager_test.cc b/chrome/browser/ash/login/session/user_session_manager_test.cc index 3af7e20d4c392a..71ed9feac4b04f 100644 --- a/chrome/browser/ash/login/session/user_session_manager_test.cc +++ b/chrome/browser/ash/login/session/user_session_manager_test.cc @@ -4,6 +4,8 @@ #include "chrome/browser/ash/login/session/user_session_manager.h" +#include "ash/components/login/auth/key.h" +#include "ash/components/login/auth/user_context.h" #include "base/callback_helpers.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/ash/login/demo_mode/demo_session.h" @@ -15,8 +17,6 @@ #include "chrome/test/base/testing_profile_manager.h" #include "chromeos/dbus/session_manager/fake_session_manager_client.h" #include "chromeos/dbus/session_manager/session_manager_client.h" -#include "chromeos/login/auth/key.h" -#include "chromeos/login/auth/user_context.h" #include "components/language/core/browser/pref_names.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "components/user_manager/fake_user_manager.h" diff --git a/chrome/browser/ash/login/session/user_session_manager_test_api.cc b/chrome/browser/ash/login/session/user_session_manager_test_api.cc index e6ef0f188da627..9c539281beec50 100644 --- a/chrome/browser/ash/login/session/user_session_manager_test_api.cc +++ b/chrome/browser/ash/login/session/user_session_manager_test_api.cc @@ -4,7 +4,7 @@ #include "chrome/browser/ash/login/session/user_session_manager_test_api.h" -#include "chromeos/login/auth/stub_authenticator_builder.h" +#include "ash/components/login/auth/stub_authenticator_builder.h" namespace ash { namespace test { diff --git a/chrome/browser/ash/login/shill_profile_loading_browsertest.cc b/chrome/browser/ash/login/shill_profile_loading_browsertest.cc index a82145c2a1c892..55eb7a907b0480 100644 --- a/chrome/browser/ash/login/shill_profile_loading_browsertest.cc +++ b/chrome/browser/ash/login/shill_profile_loading_browsertest.cc @@ -14,6 +14,7 @@ // This test case verifies that chrome triggers LoadShillProfile for the // unmanaged user case and the managed user with/without network policy cases. +#include "ash/components/login/auth/user_context.h" #include "ash/public/cpp/login_screen_test_api.h" #include "base/bind.h" #include "base/bind_internal.h" @@ -29,7 +30,6 @@ #include "chromeos/dbus/session_manager/fake_session_manager_client.h" #include "chromeos/dbus/session_manager/session_manager_client.h" #include "chromeos/dbus/shill/fake_shill_profile_client.h" -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" #include "components/policy/proto/chrome_settings.pb.h" #include "components/user_manager/user_names.h" diff --git a/chrome/browser/ash/login/signin/oauth2_browsertest.cc b/chrome/browser/ash/login/signin/oauth2_browsertest.cc index 869cc53c4bc062..c702fa76d2f43f 100644 --- a/chrome/browser/ash/login/signin/oauth2_browsertest.cc +++ b/chrome/browser/ash/login/signin/oauth2_browsertest.cc @@ -7,6 +7,8 @@ #include #include +#include "ash/components/login/auth/key.h" +#include "ash/components/login/auth/user_context.h" #include "ash/public/cpp/login_screen_test_api.h" #include "base/bind.h" #include "base/memory/ref_counted.h" @@ -43,8 +45,6 @@ #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "chrome/test/base/ui_test_utils.h" -#include "chromeos/login/auth/key.h" -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" #include "components/javascript_dialogs/tab_modal_dialog_manager.h" #include "components/prefs/pref_service.h" diff --git a/chrome/browser/ash/login/signin/oauth2_token_initializer.h b/chrome/browser/ash/login/signin/oauth2_token_initializer.h index 0265ec0191c492..16719477f354e6 100644 --- a/chrome/browser/ash/login/signin/oauth2_token_initializer.h +++ b/chrome/browser/ash/login/signin/oauth2_token_initializer.h @@ -7,9 +7,9 @@ #include +#include "ash/components/login/auth/user_context.h" #include "base/callback.h" #include "chrome/browser/ash/login/signin/oauth2_token_fetcher.h" -#include "chromeos/login/auth/user_context.h" namespace ash { diff --git a/chrome/browser/ash/login/signin/offline_signin_limiter.h b/chrome/browser/ash/login/signin/offline_signin_limiter.h index 3eb0207d7903df..09dce0c00075a8 100644 --- a/chrome/browser/ash/login/signin/offline_signin_limiter.h +++ b/chrome/browser/ash/login/signin/offline_signin_limiter.h @@ -7,10 +7,10 @@ #include +#include "ash/components/login/auth/user_context.h" #include "base/power_monitor/power_observer.h" #include "base/time/time.h" #include "base/timer/wall_clock_timer.h" -#include "chromeos/login/auth/user_context.h" #include "components/keyed_service/core/keyed_service.h" #include "components/prefs/pref_change_registrar.h" #include "components/session_manager/core/session_manager_observer.h" diff --git a/chrome/browser/ash/login/test/logged_in_user_mixin.cc b/chrome/browser/ash/login/test/logged_in_user_mixin.cc index 73aa8c7fb855cd..c7eb50dae3cfd9 100644 --- a/chrome/browser/ash/login/test/logged_in_user_mixin.cc +++ b/chrome/browser/ash/login/test/logged_in_user_mixin.cc @@ -6,9 +6,9 @@ #include +#include "ash/components/login/auth/stub_authenticator_builder.h" +#include "ash/components/login/auth/user_context.h" #include "chrome/browser/ash/login/wizard_controller.h" -#include "chromeos/login/auth/stub_authenticator_builder.h" -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" #include "net/dns/mock_host_resolver.h" diff --git a/chrome/browser/ash/login/test/login_manager_mixin.cc b/chrome/browser/ash/login/test/login_manager_mixin.cc index a79991b29fdcbc..5fc81a52be7606 100644 --- a/chrome/browser/ash/login/test/login_manager_mixin.cc +++ b/chrome/browser/ash/login/test/login_manager_mixin.cc @@ -8,6 +8,10 @@ #include #include +#include "ash/components/login/auth/auth_status_consumer.h" +#include "ash/components/login/auth/key.h" +#include "ash/components/login/auth/stub_authenticator_builder.h" +#include "ash/components/login/auth/user_context.h" #include "base/command_line.h" #include "base/containers/contains.h" #include "base/strings/string_util.h" @@ -23,10 +27,6 @@ #include "chrome/browser/ash/login/ui/login_display_host.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" -#include "chromeos/login/auth/auth_status_consumer.h" -#include "chromeos/login/auth/key.h" -#include "chromeos/login/auth/stub_authenticator_builder.h" -#include "chromeos/login/auth/user_context.h" #include "components/prefs/pref_service.h" #include "components/prefs/scoped_user_pref_update.h" #include "components/user_manager/known_user.h" diff --git a/chrome/browser/ash/login/test/login_manager_mixin.h b/chrome/browser/ash/login/test/login_manager_mixin.h index c108d32d44557d..76befd92da8c6e 100644 --- a/chrome/browser/ash/login/test/login_manager_mixin.h +++ b/chrome/browser/ash/login/test/login_manager_mixin.h @@ -8,13 +8,13 @@ #include #include +// TODO(https://crbug.com/1164001): move to forward declaration. +#include "ash/components/login/auth/stub_authenticator_builder.h" +#include "ash/components/login/auth/user_context.h" #include "chrome/browser/ash/login/test/fake_gaia_mixin.h" #include "chrome/browser/ash/login/test/local_state_mixin.h" #include "chrome/browser/ash/login/test/session_flags_manager.h" #include "chrome/test/base/mixin_based_in_process_browser_test.h" -// TODO(https://crbug.com/1164001): move to forward declaration. -#include "chromeos/login/auth/stub_authenticator_builder.h" -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" #include "components/user_manager/user.h" #include "components/user_manager/user_type.h" diff --git a/chrome/browser/ash/login/test/offline_login_test_mixin.cc b/chrome/browser/ash/login/test/offline_login_test_mixin.cc index 49d1e9a593cd96..2244953ba8dc81 100644 --- a/chrome/browser/ash/login/test/offline_login_test_mixin.cc +++ b/chrome/browser/ash/login/test/offline_login_test_mixin.cc @@ -4,6 +4,7 @@ #include "chrome/browser/ash/login/test/offline_login_test_mixin.h" +#include "ash/components/login/auth/user_context.h" #include "ash/components/settings/cros_settings_names.h" #include "ash/components/settings/cros_settings_provider.h" #include "chrome/browser/ash/login/session/user_session_manager_test_api.h" @@ -19,7 +20,6 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/ui/webui/chromeos/login/error_screen_handler.h" #include "chrome/test/base/mixin_based_in_process_browser_test.h" -#include "chromeos/login/auth/user_context.h" #include "chromeos/network/network_state_test_helper.h" #include "content/public/test/test_utils.h" diff --git a/chrome/browser/ash/login/test/profile_prepared_waiter.h b/chrome/browser/ash/login/test/profile_prepared_waiter.h index 7744f27b5abecf..af53f5a5672e6f 100644 --- a/chrome/browser/ash/login/test/profile_prepared_waiter.h +++ b/chrome/browser/ash/login/test/profile_prepared_waiter.h @@ -5,8 +5,8 @@ #ifndef CHROME_BROWSER_ASH_LOGIN_TEST_PROFILE_PREPARED_WAITER_H_ #define CHROME_BROWSER_ASH_LOGIN_TEST_PROFILE_PREPARED_WAITER_H_ +#include "ash/components/login/auth/auth_status_consumer.h" #include "base/run_loop.h" -#include "chromeos/login/auth/auth_status_consumer.h" #include "components/account_id/account_id.h" namespace ash { diff --git a/chrome/browser/ash/login/ui/login_display.h b/chrome/browser/ash/login/ui/login_display.h index f9c00f1372ab9c..4a66bee6c1d18f 100644 --- a/chrome/browser/ash/login/ui/login_display.h +++ b/chrome/browser/ash/login/ui/login_display.h @@ -5,11 +5,11 @@ #ifndef CHROME_BROWSER_ASH_LOGIN_UI_LOGIN_DISPLAY_H_ #define CHROME_BROWSER_ASH_LOGIN_UI_LOGIN_DISPLAY_H_ +// TODO(https://crbug.com/1164001): move to forward declaration. +#include "ash/components/login/auth/user_context.h" #include "base/callback.h" #include "chrome/browser/ash/login/help_app_launcher.h" #include "chrome/browser/ash/login/signin_specifics.h" -// TODO(https://crbug.com/1164001): move to forward declaration. -#include "chromeos/login/auth/user_context.h" #include "components/user_manager/user.h" #include "components/user_manager/user_manager.h" #include "ui/gfx/geometry/rect.h" diff --git a/chrome/browser/ash/login/ui/login_display_host_mojo.cc b/chrome/browser/ash/login/ui/login_display_host_mojo.cc index a30c24f3069279..cd18a45ee69c8c 100644 --- a/chrome/browser/ash/login/ui/login_display_host_mojo.cc +++ b/chrome/browser/ash/login/ui/login_display_host_mojo.cc @@ -6,6 +6,7 @@ #include +#include "ash/components/login/auth/user_context.h" #include "ash/constants/ash_features.h" #include "ash/constants/ash_pref_names.h" #include "ash/constants/ash_switches.h" @@ -45,7 +46,6 @@ #include "chrome/browser/ui/webui/chromeos/login/signin_fatal_error_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/user_creation_screen_handler.h" #include "chrome/common/channel_info.h" -#include "chromeos/login/auth/user_context.h" #include "components/startup_metric_utils/browser/startup_metric_utils.h" #include "components/user_manager/known_user.h" #include "components/user_manager/user.h" diff --git a/chrome/browser/ash/login/ui/login_display_host_mojo.h b/chrome/browser/ash/login/ui/login_display_host_mojo.h index 903336675fe442..1533a807c811ef 100644 --- a/chrome/browser/ash/login/ui/login_display_host_mojo.h +++ b/chrome/browser/ash/login/ui/login_display_host_mojo.h @@ -9,6 +9,8 @@ #include #include +#include "ash/components/login/auth/auth_status_consumer.h" +#include "ash/components/login/auth/challenge_response_key.h" #include "base/callback_forward.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" @@ -20,8 +22,6 @@ #include "chrome/browser/ash/login/ui/oobe_ui_dialog_delegate.h" #include "chrome/browser/ui/ash/login_screen_client_impl.h" #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" -#include "chromeos/login/auth/auth_status_consumer.h" -#include "chromeos/login/auth/challenge_response_key.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/views/view.h" #include "ui/views/view_observer.h" diff --git a/chrome/browser/ash/login/ui/signin_ui.h b/chrome/browser/ash/login/ui/signin_ui.h index 2e126b371bd195..c733ca29068e77 100644 --- a/chrome/browser/ash/login/ui/signin_ui.h +++ b/chrome/browser/ash/login/ui/signin_ui.h @@ -4,10 +4,10 @@ #ifndef CHROME_BROWSER_ASH_LOGIN_UI_SIGNIN_UI_H_ #define CHROME_BROWSER_ASH_LOGIN_UI_SIGNIN_UI_H_ +#include "ash/components/login/auth/user_context.h" #include "base/callback.h" #include "chrome/browser/ash/login/oobe_screen.h" #include "chrome/browser/ash/login/screens/encryption_migration_mode.h" -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" namespace ash { diff --git a/chrome/browser/ash/login/user_flags_login_browsertest.cc b/chrome/browser/ash/login/user_flags_login_browsertest.cc index 8599e5a16f0d70..1516fdd813eea6 100644 --- a/chrome/browser/ash/login/user_flags_login_browsertest.cc +++ b/chrome/browser/ash/login/user_flags_login_browsertest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "ash/components/login/auth/user_context.h" #include "base/test/bind.h" #include "chrome/browser/about_flags.h" #include "chrome/browser/ash/login/session/user_session_manager_test_api.h" @@ -13,7 +14,6 @@ #include "chrome/test/base/mixin_based_in_process_browser_test.h" #include "chromeos/cryptohome/cryptohome_parameters.h" #include "chromeos/dbus/session_manager/fake_session_manager_client.h" -#include "chromeos/login/auth/user_context.h" #include "components/flags_ui/feature_entry_macros.h" #include "components/flags_ui/flags_state.h" #include "components/flags_ui/pref_service_flags_storage.h" diff --git a/chrome/browser/ash/login/user_flow.h b/chrome/browser/ash/login/user_flow.h index 60dbcfe67beba8..e14a9976698ccf 100644 --- a/chrome/browser/ash/login/user_flow.h +++ b/chrome/browser/ash/login/user_flow.h @@ -5,9 +5,9 @@ #ifndef CHROME_BROWSER_ASH_LOGIN_USER_FLOW_H_ #define CHROME_BROWSER_ASH_LOGIN_USER_FLOW_H_ -#include "chromeos/login/auth/auth_status_consumer.h" +#include "ash/components/login/auth/auth_status_consumer.h" // TODO(https://crbug.com/1164001): move to forward declaration. -#include "chromeos/login/auth/user_context.h" +#include "ash/components/login/auth/user_context.h" #include "components/account_id/account_id.h" #include "components/user_manager/user.h" diff --git a/chrome/browser/ash/login/wizard_context.cc b/chrome/browser/ash/login/wizard_context.cc index bba478a511c942..58c6d6ad36edb7 100644 --- a/chrome/browser/ash/login/wizard_context.cc +++ b/chrome/browser/ash/login/wizard_context.cc @@ -4,9 +4,9 @@ #include "chrome/browser/ash/login/wizard_context.h" +#include "ash/components/login/auth/user_context.h" #include "build/branding_buildflags.h" #include "chrome/browser/ui/webui/chromeos/login/family_link_notice_screen_handler.h" -#include "chromeos/login/auth/user_context.h" namespace ash { diff --git a/chrome/browser/ash/login/wizard_context.h b/chrome/browser/ash/login/wizard_context.h index f4a79c496e1e64..06542ca453a75f 100644 --- a/chrome/browser/ash/login/wizard_context.h +++ b/chrome/browser/ash/login/wizard_context.h @@ -7,10 +7,10 @@ #include +// TODO(https://crbug.com/1164001): move to forward declaration. +#include "ash/components/login/auth/user_context.h" #include "base/values.h" #include "chrome/browser/ash/login/oobe_screen.h" -// TODO(https://crbug.com/1164001): move to forward declaration. -#include "chromeos/login/auth/user_context.h" namespace ash { diff --git a/chrome/browser/ash/platform_keys/key_permissions/key_permissions_manager_browsertest.cc b/chrome/browser/ash/platform_keys/key_permissions/key_permissions_manager_browsertest.cc index b2baf9ce904941..e766d510a72fc1 100644 --- a/chrome/browser/ash/platform_keys/key_permissions/key_permissions_manager_browsertest.cc +++ b/chrome/browser/ash/platform_keys/key_permissions/key_permissions_manager_browsertest.cc @@ -10,6 +10,7 @@ #include #include +#include "ash/components/login/auth/user_context.h" #include "base/values.h" #include "chrome/browser/ash/login/test/device_state_mixin.h" #include "chrome/browser/ash/login/test/login_manager_mixin.h" @@ -26,7 +27,6 @@ #include "chrome/browser/profiles/profile_manager.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/mixin_based_in_process_browser_test.h" -#include "chromeos/login/auth/user_context.h" #include "components/prefs/pref_test_utils.h" #include "components/signin/public/identity_manager/identity_test_utils.h" #include "content/public/test/browser_test.h" diff --git a/chrome/browser/ash/platform_keys/platform_keys_service_browsertest.cc b/chrome/browser/ash/platform_keys/platform_keys_service_browsertest.cc index e6f90416c0b7c9..5cf231cc5b0e09 100644 --- a/chrome/browser/ash/platform_keys/platform_keys_service_browsertest.cc +++ b/chrome/browser/ash/platform_keys/platform_keys_service_browsertest.cc @@ -8,6 +8,7 @@ #include #include +#include "ash/components/login/auth/user_context.h" #include "base/bind.h" #include "base/callback.h" #include "base/command_line.h" @@ -40,7 +41,6 @@ #include "chrome/browser/ui/browser.h" #include "chrome/test/base/mixin_based_in_process_browser_test.h" #include "chrome/test/base/testing_profile.h" -#include "chromeos/login/auth/user_context.h" #include "components/policy/core/common/policy_switches.h" #include "components/signin/public/identity_manager/identity_test_utils.h" #include "content/public/browser/browser_task_traits.h" diff --git a/chrome/browser/ash/policy/affiliation/affiliation_test_helper.cc b/chrome/browser/ash/policy/affiliation/affiliation_test_helper.cc index fb1cc772894d21..6f6518a164fca9 100644 --- a/chrome/browser/ash/policy/affiliation/affiliation_test_helper.cc +++ b/chrome/browser/ash/policy/affiliation/affiliation_test_helper.cc @@ -9,6 +9,8 @@ #include #include +#include "ash/components/login/auth/key.h" +#include "ash/components/login/auth/user_context.h" #include "ash/constants/ash_switches.h" #include "base/command_line.h" #include "base/containers/contains.h" @@ -30,8 +32,6 @@ #include "chromeos/dbus/session_manager/fake_session_manager_client.h" #include "chromeos/dbus/session_manager/session_manager_client.h" #include "chromeos/dbus/userdataauth/userdataauth_client.h" -#include "chromeos/login/auth/key.h" -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" #include "components/policy/core/common/cloud/cloud_policy_core.h" #include "components/policy/core/common/cloud/cloud_policy_store.h" diff --git a/chrome/browser/ash/policy/core/device_local_account_browsertest.cc b/chrome/browser/ash/policy/core/device_local_account_browsertest.cc index 08ecd028cc8bbe..40c86e282bef72 100644 --- a/chrome/browser/ash/policy/core/device_local_account_browsertest.cc +++ b/chrome/browser/ash/policy/core/device_local_account_browsertest.cc @@ -11,6 +11,7 @@ #include #include +#include "ash/components/login/auth/user_context.h" #include "ash/components/settings/timezone_settings.h" #include "ash/constants/ash_paths.h" #include "ash/constants/ash_switches.h" @@ -113,7 +114,6 @@ #include "chrome/grit/chromium_strings.h" #include "chrome/grit/generated_resources.h" #include "chromeos/dbus/session_manager/fake_session_manager_client.h" -#include "chromeos/login/auth/user_context.h" #include "chromeos/network/policy_certificate_provider.h" #include "components/crx_file/crx_verifier.h" #include "components/policy/core/common/cloud/cloud_policy_constants.h" diff --git a/chrome/browser/ash/policy/login/login_policy_test_base.cc b/chrome/browser/ash/policy/login/login_policy_test_base.cc index b426f8570dc511..8b8655bb003610 100644 --- a/chrome/browser/ash/policy/login/login_policy_test_base.cc +++ b/chrome/browser/ash/policy/login/login_policy_test_base.cc @@ -6,6 +6,7 @@ #include +#include "ash/components/login/auth/user_context.h" #include "ash/constants/ash_switches.h" #include "base/values.h" #include "chrome/browser/ash/login/test/login_manager_mixin.h" @@ -17,7 +18,6 @@ #include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" -#include "chromeos/login/auth/user_context.h" #include "google_apis/gaia/fake_gaia.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/ash/policy/status_collector/managed_session_service.h b/chrome/browser/ash/policy/status_collector/managed_session_service.h index bc9c176551e09f..a71d3d1da5caa2 100644 --- a/chrome/browser/ash/policy/status_collector/managed_session_service.h +++ b/chrome/browser/ash/policy/status_collector/managed_session_service.h @@ -5,6 +5,7 @@ #ifndef CHROME_BROWSER_ASH_POLICY_STATUS_COLLECTOR_MANAGED_SESSION_SERVICE_H_ #define CHROME_BROWSER_ASH_POLICY_STATUS_COLLECTOR_MANAGED_SESSION_SERVICE_H_ +#include "ash/components/login/auth/auth_status_consumer.h" #include "ash/components/login/session/session_termination_manager.h" #include "base/observer_list.h" #include "base/observer_list_types.h" @@ -16,7 +17,6 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_observer.h" #include "chromeos/dbus/power/power_manager_client.h" -#include "chromeos/login/auth/auth_status_consumer.h" #include "components/account_id/account_id.h" #include "components/session_manager/core/session_manager.h" #include "components/session_manager/core/session_manager_observer.h" diff --git a/chrome/browser/ash/remote_apps/remote_apps_manager_browsertest.cc b/chrome/browser/ash/remote_apps/remote_apps_manager_browsertest.cc index 6b60992ae12a68..0ecfac87b85a93 100644 --- a/chrome/browser/ash/remote_apps/remote_apps_manager_browsertest.cc +++ b/chrome/browser/ash/remote_apps/remote_apps_manager_browsertest.cc @@ -7,6 +7,7 @@ #include "ash/app_list/app_list_model_provider.h" #include "ash/app_list/model/app_list_item.h" #include "ash/app_list/model/app_list_model.h" +#include "ash/components/login/auth/user_context.h" #include "ash/constants/ash_switches.h" #include "ash/public/cpp/accelerators.h" #include "ash/public/cpp/app_list/app_list_types.h" @@ -34,7 +35,6 @@ #include "chrome/browser/ui/app_list/app_list_client_impl.h" #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" #include "chrome/browser/ui/ash/shelf/chrome_shelf_controller.h" -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" #include "components/policy/proto/chrome_device_policy.pb.h" #include "components/services/app_service/public/cpp/icon_types.h" diff --git a/chrome/browser/ash/web_applications/personalization_app/chrome_personalization_app_ui_delegate_unittest.cc b/chrome/browser/ash/web_applications/personalization_app/chrome_personalization_app_ui_delegate_unittest.cc index a3a1d7ec0ebf2f..56d56526ff98b2 100644 --- a/chrome/browser/ash/web_applications/personalization_app/chrome_personalization_app_ui_delegate_unittest.cc +++ b/chrome/browser/ash/web_applications/personalization_app/chrome_personalization_app_ui_delegate_unittest.cc @@ -347,7 +347,7 @@ INSTANTIATE_TEST_SUITE_P(All, TEST_P(ChromePersonalizationAppUiDelegateGooglePhotosTest, FetchCount) { base::RunLoop loop; wallpaper_provider_remote()->get()->FetchGooglePhotosCount( - base::BindLambdaForTesting([&, this](int64_t count) { + base::BindLambdaForTesting([&, this](int count) { EXPECT_EQ(count, GooglePhotosEnabled() ? 0 : -1); loop.QuitClosure().Run(); })); diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 90760c852fd5a2..c0d0af038b56b9 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -55,6 +55,7 @@ #include "chrome/browser/federated_learning/floc_eligibility_observer.h" #include "chrome/browser/federated_learning/floc_id_provider.h" #include "chrome/browser/federated_learning/floc_id_provider_factory.h" +#include "chrome/browser/first_party_sets/first_party_sets_pref_names.h" #include "chrome/browser/font_access/chrome_font_access_delegate.h" #include "chrome/browser/font_family_cache.h" #include "chrome/browser/gpu/chrome_browser_main_extra_parts_gpu.h" @@ -285,6 +286,7 @@ #include "media/media_buildflags.h" #include "media/mojo/buildflags.h" #include "mojo/public/cpp/bindings/remote.h" +#include "net/base/features.h" #include "net/cookies/site_for_cookies.h" #include "net/ssl/client_cert_store.h" #include "net/ssl/ssl_cert_request_info.h" @@ -6377,3 +6379,24 @@ bool ChromeContentBrowserClient::ShouldDisableOriginAgentClusterDefault( ->GetPrefs() ->GetBoolean(prefs::kOriginAgentClusterDefaultEnabled); } + +bool ChromeContentBrowserClient::IsFirstPartySetsEnabled() { + // TODO(https://crbug.com/1269360): move this logic into + // FirstPartySetsUtil::IsFirstPartySetsEnabled + if (!base::FeatureList::IsEnabled(net::features::kFirstPartySets)) { + return false; + } + + PrefService* local_state; + if (g_browser_process) { + local_state = g_browser_process->local_state(); + } else { + local_state = startup_data_.chrome_feature_list_creator()->local_state(); + } + + if (!local_state || + !local_state->HasPrefPath(first_party_sets::kFirstPartySetsEnabled)) { + return true; + } + return local_state->GetBoolean(first_party_sets::kFirstPartySetsEnabled); +} diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h index ee247be43bca02..5c543afb61e893 100644 --- a/chrome/browser/chrome_content_browser_client.h +++ b/chrome/browser/chrome_content_browser_client.h @@ -766,6 +766,7 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient { void OnWebContentsCreated(content::WebContents* web_contents) override; bool IsFindInPageDisabledForOrigin(const url::Origin& origin) override; + bool IsFirstPartySetsEnabled() override; void FlushBackgroundAttributions(base::OnceClosure callback) override; bool ShouldPreconnectNavigation( diff --git a/chrome/browser/chromeos/BUILD.gn b/chrome/browser/chromeos/BUILD.gn index 8e03db93a8620c..ca66eb6b2456bb 100644 --- a/chrome/browser/chromeos/BUILD.gn +++ b/chrome/browser/chromeos/BUILD.gn @@ -94,6 +94,7 @@ source_set("chromeos") { "//ash/components/enhanced_network_tts/mojom", "//ash/components/fwupd", "//ash/components/geolocation", + "//ash/components/login/auth", "//ash/components/login/session", "//ash/components/peripheral_notification", "//ash/components/phonehub", @@ -184,6 +185,7 @@ source_set("chromeos") { "//chrome/browser/profiles", "//chrome/browser/profiles:profile", "//chrome/browser/resource_coordinator:tab_metrics_event_proto", + "//chrome/browser/resources/chromeos:app_icon_resources", "//chrome/browser/resources/settings:resources_grit", "//chrome/browser/supervised_user/supervised_user_features", "//chrome/browser/ui/webui/bluetooth_internals:mojo_bindings", @@ -296,7 +298,6 @@ source_set("chromeos") { "//chromeos/ime:gencode", "//chromeos/language/language_packs", "//chromeos/language/public/mojom", - "//chromeos/login/auth", "//chromeos/login/login_state", "//chromeos/memory", "//chromeos/network", @@ -334,6 +335,7 @@ source_set("chromeos") { "//chromeos/utils", "//components/app_restore", "//components/arc", + "//components/arc/common", "//components/autofill/core/browser", "//components/browser_sync", "//components/captive_portal/core", @@ -3820,6 +3822,7 @@ static_library("test_support") { "//ash/components/attestation:test_support", "//ash/components/drivefs", "//ash/components/drivefs:test_support", + "//ash/components/login/auth", "//ash/components/settings", "//ash/constants", "//ash/services/ime:test_support", @@ -3839,7 +3842,6 @@ static_library("test_support") { "//chromeos/dbus/session_manager", "//chromeos/dbus/userdataauth:userdataauth", "//chromeos/dbus/userdataauth:userdataauth_proto", - "//chromeos/login/auth", "//chromeos/printing", "//chromeos/services/multidevice_setup/public/cpp:test_support", "//chromeos/system", @@ -4702,6 +4704,7 @@ source_set("unit_tests") { "//ash/components/attestation:test_support", "//ash/components/audio", "//ash/components/disks:test_support", + "//ash/components/login/auth", "//ash/components/phonehub:test_support", "//ash/components/proximity_auth", "//ash/components/proximity_auth:test_support", @@ -4755,7 +4758,6 @@ source_set("unit_tests") { "//chromeos/dbus/virtual_file_provider", "//chromeos/dbus/vm_plugin_dispatcher", "//chromeos/ime:gencode", - "//chromeos/login/auth", "//chromeos/login/login_state", "//chromeos/login/login_state:test_support", "//chromeos/network", @@ -4774,6 +4776,7 @@ source_set("unit_tests") { "//chromeos/ui/frame:test_support", "//components/account_manager_core:test_support", "//components/arc", + "//components/arc/common", "//components/component_updater:test_support", "//components/content_settings/core/browser", "//components/crx_file", diff --git a/chrome/browser/chromeos/extensions/gfx_utils.cc b/chrome/browser/chromeos/extensions/gfx_utils.cc index 5f5fe38f3c1a47..f70b9556bab826 100644 --- a/chrome/browser/chromeos/extensions/gfx_utils.cc +++ b/chrome/browser/chromeos/extensions/gfx_utils.cc @@ -13,11 +13,11 @@ #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/pref_names.h" +#include "chrome/grit/app_icon_resources.h" #include "components/prefs/pref_service.h" #include "extensions/browser/extension_registry.h" #include "extensions/common/constants.h" #include "ui/base/resource/resource_bundle.h" -#include "ui/chromeos/resources/grit/ui_chromeos_resources.h" #include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia_operations.h" diff --git a/chrome/browser/chromeos/extensions/login_screen/login/login_api.cc b/chrome/browser/chromeos/extensions/login_screen/login/login_api.cc index d940e02bd42786..d8030e1b9c9609 100644 --- a/chrome/browser/chromeos/extensions/login_screen/login/login_api.cc +++ b/chrome/browser/chromeos/extensions/login_screen/login/login_api.cc @@ -7,6 +7,8 @@ #include #include +#include "ash/components/login/auth/key.h" +#include "ash/components/login/auth/user_context.h" #include "base/bind.h" #include "base/logging.h" #include "base/values.h" @@ -19,8 +21,6 @@ #include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/common/extensions/api/login.h" #include "chrome/common/pref_names.h" -#include "chromeos/login/auth/key.h" -#include "chromeos/login/auth/user_context.h" #include "components/prefs/pref_service.h" #include "components/session_manager/core/session_manager.h" #include "components/user_manager/user.h" diff --git a/chrome/browser/chromeos/extensions/login_screen/login/login_api_lock_handler.cc b/chrome/browser/chromeos/extensions/login_screen/login/login_api_lock_handler.cc index eb5db9099e8f5d..ed3a132870f4bf 100644 --- a/chrome/browser/chromeos/extensions/login_screen/login/login_api_lock_handler.cc +++ b/chrome/browser/chromeos/extensions/login_screen/login/login_api_lock_handler.cc @@ -6,11 +6,11 @@ #include +#include "ash/components/login/auth/user_context.h" #include "base/bind.h" #include "base/no_destructor.h" #include "chrome/browser/ash/login/lock/screen_locker.h" #include "chrome/browser/ui/ash/session_controller_client_impl.h" -#include "chromeos/login/auth/user_context.h" namespace chromeos { diff --git a/chrome/browser/chromeos/extensions/login_screen/login/login_api_unittest.cc b/chrome/browser/chromeos/extensions/login_screen/login/login_api_unittest.cc index ca8fbf03a17a48..964f21639e144c 100644 --- a/chrome/browser/chromeos/extensions/login_screen/login/login_api_unittest.cc +++ b/chrome/browser/chromeos/extensions/login_screen/login/login_api_unittest.cc @@ -9,6 +9,8 @@ #include #include +#include "ash/components/login/auth/key.h" +#include "ash/components/login/auth/user_context.h" #include "ash/components/settings/cros_settings_names.h" #include "base/callback.h" #include "base/callback_helpers.h" @@ -30,8 +32,6 @@ #include "chrome/common/pref_names.h" #include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile_manager.h" -#include "chromeos/login/auth/key.h" -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" #include "components/prefs/pref_service.h" #include "components/session_manager/core/session_manager.h" diff --git a/chrome/browser/chromeos/extensions/login_screen/login/shared_session_handler.cc b/chrome/browser/chromeos/extensions/login_screen/login/shared_session_handler.cc index 48c3856e5320b9..5fa4a40f2ef356 100644 --- a/chrome/browser/chromeos/extensions/login_screen/login/shared_session_handler.cc +++ b/chrome/browser/chromeos/extensions/login_screen/login/shared_session_handler.cc @@ -6,6 +6,7 @@ #include +#include "ash/components/login/auth/user_context.h" #include "ash/components/settings/cros_settings_names.h" #include "base/bind.h" #include "base/no_destructor.h" @@ -15,7 +16,6 @@ #include "chrome/browser/chromeos/extensions/login_screen/login/login_api.h" #include "chrome/browser/chromeos/extensions/login_screen/login/login_api_lock_handler.h" #include "chrome/browser/ui/ash/session_controller_client_impl.h" -#include "chromeos/login/auth/user_context.h" #include "components/session_manager/core/session_manager.h" #include "components/session_manager/session_manager_types.h" #include "components/user_manager/user.h" diff --git a/chrome/browser/component_updater/first_party_sets_component_installer.cc b/chrome/browser/component_updater/first_party_sets_component_installer.cc index e4725eee52af23..0f46964054c381 100644 --- a/chrome/browser/component_updater/first_party_sets_component_installer.cc +++ b/chrome/browser/component_updater/first_party_sets_component_installer.cc @@ -15,7 +15,10 @@ #include "base/task/post_task.h" #include "base/task/thread_pool.h" #include "base/version.h" +#include "chrome/browser/browser_process.h" +#include "chrome/browser/first_party_sets/first_party_sets_pref_names.h" #include "components/component_updater/component_updater_paths.h" +#include "components/prefs/pref_service.h" #include "content/public/browser/network_service_instance.h" #include "net/base/features.h" #include "net/cookies/cookie_util.h" @@ -50,14 +53,30 @@ base::FilePath& GetConfigPathInstance() { return *instance; } +// Determine if First-Party Sets is enabled by checking both the feature +// and the enterprise policy. +bool IsFirstPartySetsEnabled() { + // TODO(https://crbug.com/1269360): move this logic into + // FirstPartySetsUtil + if (!base::FeatureList::IsEnabled(net::features::kFirstPartySets)) { + return false; + } + auto* local_state = g_browser_process->local_state(); + if (!local_state || + !local_state->HasPrefPath(first_party_sets::kFirstPartySetsEnabled)) { + return true; + } + return local_state->GetBoolean(first_party_sets::kFirstPartySetsEnabled); +} + // Invokes `on_sets_ready` with the contents of the component, if: // * the component has been installed; and -// * the `kFirstPartySets` feature is enabled; and +// * First-Party Sets is enabled; and // * the component was read successfully. void SetFirstPartySetsConfig( base::OnceCallback on_sets_ready) { const base::FilePath instance_path = GetConfigPathInstance(); - if (instance_path.empty() || !net::cookie_util::IsFirstPartySetsEnabled()) { + if (instance_path.empty() || !IsFirstPartySetsEnabled()) { return; } diff --git a/chrome/browser/devtools/BUILD.gn b/chrome/browser/devtools/BUILD.gn index 53a271ff1c92e3..c2f6d9d2996273 100644 --- a/chrome/browser/devtools/BUILD.gn +++ b/chrome/browser/devtools/BUILD.gn @@ -141,7 +141,6 @@ static_library("devtools") { "//components/viz/host", "//components/web_modal", "//components/zoom", - "//extensions/browser", "//net/server:http_server", "//skia", "//third_party/icu", @@ -229,6 +228,7 @@ static_library("devtools") { ] } } + if (is_mac) { sources += [ "devtools_dock_tile_mac.mm" ] } else { @@ -272,7 +272,10 @@ static_library("devtools") { } if (enable_extensions) { - deps += [ "//chrome/common/extensions/api" ] + deps += [ + "//chrome/common/extensions/api", + "//extensions/browser", + ] } } diff --git a/chrome/browser/extensions/BUILD.gn b/chrome/browser/extensions/BUILD.gn index e6dccdf5ca075a..5852e8c9502ec2 100644 --- a/chrome/browser/extensions/BUILD.gn +++ b/chrome/browser/extensions/BUILD.gn @@ -1108,6 +1108,7 @@ static_library("extensions") { "//ash/components/attestation", "//ash/components/disks", "//ash/components/enhanced_network_tts/mojom", + "//ash/components/login/auth", "//ash/components/proximity_auth", "//ash/components/settings", "//ash/constants", @@ -1133,7 +1134,6 @@ static_library("extensions") { "//chromeos/dbus/util", "//chromeos/language/language_packs", "//chromeos/language/public/mojom", - "//chromeos/login/auth", "//chromeos/login/login_state", "//chromeos/network", "//chromeos/process_proxy", diff --git a/chrome/browser/extensions/api/passwords_private/passwords_private_utils_chromeos.cc b/chrome/browser/extensions/api/passwords_private/passwords_private_utils_chromeos.cc index 7490450cde78ab..1c9067652a229a 100644 --- a/chrome/browser/extensions/api/passwords_private/passwords_private_utils_chromeos.cc +++ b/chrome/browser/extensions/api/passwords_private/passwords_private_utils_chromeos.cc @@ -7,12 +7,12 @@ #include "components/password_manager/core/browser/password_access_authenticator.h" #if BUILDFLAG(IS_CHROMEOS_ASH) +#include "ash/components/login/auth/password_visibility_utils.h" #include "chrome/browser/ash/login/quick_unlock/auth_token.h" #include "chrome/browser/ash/login/quick_unlock/quick_unlock_factory.h" #include "chrome/browser/ash/login/quick_unlock/quick_unlock_storage.h" #include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/profiles/profile.h" -#include "chromeos/login/auth/password_visibility_utils.h" #include "components/user_manager/user.h" #endif // BUILDFLAG(IS_CHROMEOS_ASH) diff --git a/chrome/browser/extensions/api/quick_unlock_private/quick_unlock_private_api.cc b/chrome/browser/extensions/api/quick_unlock_private/quick_unlock_private_api.cc index ffe0ac6aeb13bc..bc013a8cf552de 100644 --- a/chrome/browser/extensions/api/quick_unlock_private/quick_unlock_private_api.cc +++ b/chrome/browser/extensions/api/quick_unlock_private/quick_unlock_private_api.cc @@ -8,6 +8,8 @@ #include #include +#include "ash/components/login/auth/extended_authenticator.h" +#include "ash/components/login/auth/user_context.h" #include "ash/constants/ash_pref_names.h" #include "base/bind.h" #include "base/containers/contains.h" @@ -21,8 +23,6 @@ #include "chrome/browser/extensions/api/quick_unlock_private/quick_unlock_private_ash_utils.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" -#include "chromeos/login/auth/extended_authenticator.h" -#include "chromeos/login/auth/user_context.h" #include "components/prefs/pref_service.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" diff --git a/chrome/browser/extensions/api/quick_unlock_private/quick_unlock_private_api_unittest.cc b/chrome/browser/extensions/api/quick_unlock_private/quick_unlock_private_api_unittest.cc index 45677b681233e2..236fbb4f572a67 100644 --- a/chrome/browser/extensions/api/quick_unlock_private/quick_unlock_private_api_unittest.cc +++ b/chrome/browser/extensions/api/quick_unlock_private/quick_unlock_private_api_unittest.cc @@ -8,6 +8,7 @@ #include +#include "ash/components/login/auth/fake_extended_authenticator.h" #include "ash/constants/ash_features.h" #include "ash/constants/ash_pref_names.h" #include "base/bind.h" @@ -40,7 +41,6 @@ #include "chromeos/cryptohome/system_salt_getter.h" #include "chromeos/dbus/userdataauth/fake_cryptohome_misc_client.h" #include "chromeos/dbus/userdataauth/fake_userdataauth_client.h" -#include "chromeos/login/auth/fake_extended_authenticator.h" #include "chromeos/services/device_sync/public/cpp/fake_device_sync_client.h" #include "chromeos/services/multidevice_setup/public/cpp/fake_multidevice_setup_client.h" #include "chromeos/services/secure_channel/public/cpp/client/fake_secure_channel_client.h" diff --git a/chrome/browser/extensions/api/quick_unlock_private/quick_unlock_private_ash_utils.cc b/chrome/browser/extensions/api/quick_unlock_private/quick_unlock_private_ash_utils.cc index 8df8222924fe5c..2c1674dd79619d 100644 --- a/chrome/browser/extensions/api/quick_unlock_private/quick_unlock_private_ash_utils.cc +++ b/chrome/browser/extensions/api/quick_unlock_private/quick_unlock_private_ash_utils.cc @@ -6,6 +6,8 @@ #include +#include "ash/components/login/auth/extended_authenticator.h" +#include "ash/components/login/auth/user_context.h" #include "base/bind.h" #include "chrome/browser/ash/login/quick_unlock/auth_token.h" #include "chrome/browser/ash/login/quick_unlock/fingerprint_storage.h" @@ -15,8 +17,6 @@ #include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/extensions/api/quick_unlock_private.h" -#include "chromeos/login/auth/extended_authenticator.h" -#include "chromeos/login/auth/user_context.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" diff --git a/chrome/browser/extensions/api/quick_unlock_private/quick_unlock_private_ash_utils.h b/chrome/browser/extensions/api/quick_unlock_private/quick_unlock_private_ash_utils.h index bbb50c8c3c92c5..253e5d1b83d83e 100644 --- a/chrome/browser/extensions/api/quick_unlock_private/quick_unlock_private_ash_utils.h +++ b/chrome/browser/extensions/api/quick_unlock_private/quick_unlock_private_ash_utils.h @@ -7,9 +7,9 @@ #include +#include "ash/components/login/auth/auth_status_consumer.h" #include "base/callback.h" #include "base/memory/ref_counted.h" -#include "chromeos/login/auth/auth_status_consumer.h" #include "content/public/browser/browser_thread.h" class Profile; diff --git a/chrome/browser/extensions/api/storage/managed_value_store_cache.cc b/chrome/browser/extensions/api/storage/managed_value_store_cache.cc index 8c8e78997520f8..7971c45e64058b 100644 --- a/chrome/browser/extensions/api/storage/managed_value_store_cache.cc +++ b/chrome/browser/extensions/api/storage/managed_value_store_cache.cc @@ -188,9 +188,8 @@ void ManagedValueStoreCache::ExtensionTracker::LoadSchemasOnFileTaskRunner( for (ExtensionSet::const_iterator it = extensions->begin(); it != extensions->end(); ++it) { - std::string schema_file; - if (!(*it)->manifest()->GetString( - manifest_keys::kStorageManagedSchema, &schema_file)) { + if (!(*it)->manifest()->FindStringPath( + manifest_keys::kStorageManagedSchema)) { // TODO(joaodasilva): Remove this. http://crbug.com/325349 (*components)[(*it)->id()] = policy::Schema(); continue; diff --git a/chrome/browser/extensions/api/terminal/terminal_private_api.cc b/chrome/browser/extensions/api/terminal/terminal_private_api.cc index 782e18db5afd37..c41de4c34c6397 100644 --- a/chrome/browser/extensions/api/terminal/terminal_private_api.cc +++ b/chrome/browser/extensions/api/terminal/terminal_private_api.cc @@ -10,6 +10,7 @@ #include #include +#include "ash/constants/ash_features.h" #include "ash/constants/ash_pref_names.h" #include "base/bind.h" #include "base/callback.h" @@ -635,6 +636,16 @@ TerminalPrivateOpenOptionsPageFunction::Run() { return RespondNow(NoArguments()); } +TerminalPrivateGetOSInfoFunction::~TerminalPrivateGetOSInfoFunction() = default; + +ExtensionFunction::ResponseAction TerminalPrivateGetOSInfoFunction::Run() { + base::DictionaryValue info; + info.SetBoolKey("tmux_integration", + base::FeatureList::IsEnabled( + chromeos::features::kTerminalTmuxIntegration)); + return RespondNow(OneArgument(std::move(info))); +} + TerminalPrivateGetSettingsFunction::~TerminalPrivateGetSettingsFunction() = default; diff --git a/chrome/browser/extensions/api/terminal/terminal_private_api.h b/chrome/browser/extensions/api/terminal/terminal_private_api.h index df8235ee62fc6c..fee51cb124905c 100644 --- a/chrome/browser/extensions/api/terminal/terminal_private_api.h +++ b/chrome/browser/extensions/api/terminal/terminal_private_api.h @@ -199,6 +199,17 @@ class TerminalPrivateOpenOptionsPageFunction : public ExtensionFunction { ExtensionFunction::ResponseAction Run() override; }; +class TerminalPrivateGetOSInfoFunction : public ExtensionFunction { + public: + DECLARE_EXTENSION_FUNCTION("terminalPrivate.getOSInfo", + TERMINALPRIVATE_GETOSINFO) + + protected: + ~TerminalPrivateGetOSInfoFunction() override; + + ExtensionFunction::ResponseAction Run() override; +}; + class TerminalPrivateGetSettingsFunction : public ExtensionFunction { public: DECLARE_EXTENSION_FUNCTION("terminalPrivate.getSettings", diff --git a/chrome/browser/extensions/extension_management.cc b/chrome/browser/extensions/extension_management.cc index a9b3713a72aec9..d5a1f3ea140ebd 100644 --- a/chrome/browser/extensions/extension_management.cc +++ b/chrome/browser/extensions/extension_management.cc @@ -129,10 +129,10 @@ bool ExtensionManagement::BlocklistedByDefault() const { ExtensionManagement::InstallationMode ExtensionManagement::GetInstallationMode( const Extension* extension) { - std::string update_url; - if (extension->manifest()->GetString(manifest_keys::kUpdateURL, &update_url)) - return GetInstallationMode(extension->id(), update_url); - return GetInstallationMode(extension->id(), std::string()); + const std::string* update_url = + extension->manifest()->FindStringPath(manifest_keys::kUpdateURL); + return GetInstallationMode(extension->id(), + update_url ? *update_url : std::string()); } ExtensionManagement::InstallationMode ExtensionManagement::GetInstallationMode( @@ -282,10 +282,10 @@ bool ExtensionManagement::IsAllowedManifestType( APIPermissionSet ExtensionManagement::GetBlockedAPIPermissions( const Extension* extension) { - std::string update_url; - if (extension->manifest()->GetString(manifest_keys::kUpdateURL, &update_url)) - return GetBlockedAPIPermissions(extension->id(), update_url); - return GetBlockedAPIPermissions(extension->id(), std::string()); + const std::string* update_url = + extension->manifest()->FindStringPath(manifest_keys::kUpdateURL); + return GetBlockedAPIPermissions(extension->id(), + update_url ? *update_url : std::string()); } APIPermissionSet ExtensionManagement::GetBlockedAPIPermissions( @@ -364,10 +364,10 @@ std::unique_ptr ExtensionManagement::GetBlockedPermissions( bool ExtensionManagement::IsPermissionSetAllowed(const Extension* extension, const PermissionSet& perms) { - std::string update_url; - if (extension->manifest()->GetString(manifest_keys::kUpdateURL, &update_url)) - return IsPermissionSetAllowed(extension->id(), update_url, perms); - return IsPermissionSetAllowed(extension->id(), std::string(), perms); + const std::string* update_url = + extension->manifest()->FindStringPath(manifest_keys::kUpdateURL); + return IsPermissionSetAllowed( + extension->id(), update_url ? *update_url : std::string(), perms); } bool ExtensionManagement::IsPermissionSetAllowed( @@ -436,8 +436,7 @@ void ExtensionManagement::Refresh() { pref_names::kAllowedTypes, true, base::Value::Type::LIST)); const base::DictionaryValue* dict_pref = static_cast( - LoadPreference(pref_names::kExtensionManagement, - true, + LoadPreference(pref_names::kExtensionManagement, true, base::Value::Type::DICTIONARY)); const base::Value* extension_request_pref = LoadPreference( prefs::kCloudExtensionRequestEnabled, false, base::Value::Type::BOOLEAN); @@ -559,7 +558,8 @@ void ExtensionManagement::Refresh() { subdict, internal::IndividualSettings::SCOPE_UPDATE_URL)) { settings_by_update_url_.erase(update_url); LOG(WARNING) << "Malformed Extension Management settings for " - "extensions with update url: " << update_url << "."; + "extensions with update url: " + << update_url << "."; } } else { std::vector extension_ids = base::SplitString( @@ -830,8 +830,7 @@ ExtensionManagementFactory::ExtensionManagementFactory() DependsOn(InstallStageTrackerFactory::GetInstance()); } -ExtensionManagementFactory::~ExtensionManagementFactory() { -} +ExtensionManagementFactory::~ExtensionManagementFactory() {} KeyedService* ExtensionManagementFactory::BuildServiceInstanceFor( content::BrowserContext* context) const { diff --git a/chrome/browser/first_party_sets/README.md b/chrome/browser/first_party_sets/README.md new file mode 100644 index 00000000000000..f72acb1bfc7988 --- /dev/null +++ b/chrome/browser/first_party_sets/README.md @@ -0,0 +1,13 @@ +First-Party Sets +================ + +This directory is home to all First-Party Sets related code that requires being in the browser process (under chrome/browser/). + +Most other First-Party Sets code lives in the Network Service under [/services/network/first_party_sets/](https://source.chromium.org/chromium/chromium/src/+/main:services/network/first_party_sets/). + +Relevant documentation: + +[Github explainer](https://github.com/privacycg/first-party-sets) + +[First-Party Sets & SameParty Prototype Design Doc](https://docs.google.com/document/d/16m5IfppdmmL-Zwk9zW8tJD4iHTVGJOLRP7g-QwBwX5c/edit?usp=sharing) + diff --git a/chrome/browser/first_party_sets/first_party_sets_pref_names.cc b/chrome/browser/first_party_sets/first_party_sets_pref_names.cc new file mode 100644 index 00000000000000..ccfcd728a21dc2 --- /dev/null +++ b/chrome/browser/first_party_sets/first_party_sets_pref_names.cc @@ -0,0 +1,22 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/first_party_sets/first_party_sets_pref_names.h" + +#include "components/pref_registry/pref_registry_syncable.h" +#include "components/prefs/pref_registry_simple.h" + +namespace first_party_sets { + +// *************** LOCAL STATE PREFS *************** + +// A boolean pref indicating whether First-Party Sets is enabled by enterprise +// policy. +const char kFirstPartySetsEnabled[] = "first_party_sets.enabled"; + +void RegisterLocalStatePrefs(PrefRegistrySimple* registry) { + registry->RegisterBooleanPref(kFirstPartySetsEnabled, true); +} + +} // namespace first_party_sets diff --git a/chrome/browser/first_party_sets/first_party_sets_pref_names.h b/chrome/browser/first_party_sets/first_party_sets_pref_names.h new file mode 100644 index 00000000000000..1acf3f37135e29 --- /dev/null +++ b/chrome/browser/first_party_sets/first_party_sets_pref_names.h @@ -0,0 +1,19 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_FIRST_PARTY_SETS_FIRST_PARTY_SETS_PREF_NAMES_H_ +#define CHROME_BROWSER_FIRST_PARTY_SETS_FIRST_PARTY_SETS_PREF_NAMES_H_ + +class PrefRegistrySimple; + +namespace first_party_sets { + +// Add Local State prefs below. +extern const char kFirstPartySetsEnabled[]; + +void RegisterLocalStatePrefs(PrefRegistrySimple* registry); + +} // namespace first_party_sets + +#endif // CHROME_BROWSER_FIRST_PARTY_SETS_FIRST_PARTY_SETS_PREF_NAMES_H_ diff --git a/chrome/browser/first_party_sets/first_party_sets_util.cc b/chrome/browser/first_party_sets/first_party_sets_util.cc index 7bdfadc55ae102..a2fed2e481e6d3 100644 --- a/chrome/browser/first_party_sets/first_party_sets_util.cc +++ b/chrome/browser/first_party_sets/first_party_sets_util.cc @@ -84,4 +84,4 @@ void FirstPartySetsUtil::SendAndUpdatePersistedSets( base::BindOnce(&LoadSetsFromDisk, persisted_sets_path), base::BindOnce(&SendPersistedSets, std::move(send_sets), persisted_sets_path)); -} \ No newline at end of file +} diff --git a/chrome/browser/lacros/DEPS b/chrome/browser/lacros/DEPS index 1a5b0d5af7b159..d3766520aca0fc 100644 --- a/chrome/browser/lacros/DEPS +++ b/chrome/browser/lacros/DEPS @@ -1,6 +1,6 @@ include_rules = [ "+chrome/browser/ui/views", "+components/account_manager_core", - "+components/arc", + "+components/arc/lacros", "+components/memory_pressure", ] diff --git a/chrome/browser/lacros/arc/arc_icon_cache.cc b/chrome/browser/lacros/arc/arc_icon_cache.cc new file mode 100644 index 00000000000000..6e25bf15cfd63b --- /dev/null +++ b/chrome/browser/lacros/arc/arc_icon_cache.cc @@ -0,0 +1,89 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/lacros/arc/arc_icon_cache.h" + +#include "base/callback.h" +#include "chromeos/lacros/lacros_service.h" +#include "components/arc/common/intent_helper/link_handler_model.h" + +ArcIconCache::ArcIconCache() = default; + +ArcIconCache::~ArcIconCache() { + arc::LinkHandlerModel::SetDelegate(nullptr); +} + +void ArcIconCache::Start() { + auto* lacros_service = chromeos::LacrosService::Get(); + if (!lacros_service->IsAvailable()) { + LOG(WARNING) << "ARC is not supported in Lacros."; + return; + } + arc::LinkHandlerModel::SetDelegate(this); + lacros_service->GetRemote()->AddObserver( + receiver_.BindNewPipeAndPassRemoteWithVersion()); +} + +void ArcIconCache::OnIconInvalidated(const std::string& package_name) { + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); + icon_loader_.InvalidateIcons(package_name); +} + +ArcIconCache::GetResult ArcIconCache::GetActivityIcons( + const std::vector& activities, + OnIconsReadyCallback cb) { + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); + return icon_loader_.GetActivityIcons(activities, std::move(cb)); +} + +bool ArcIconCache::RequestUrlHandlerList( + const std::string& url, + RequestUrlHandlerListCallback callback) { + auto* service = chromeos::LacrosService::Get(); + if (!service || !service->IsAvailable()) { + LOG(WARNING) << "ARC is not supported in Lacros."; + return false; + } + + if (service->GetInterfaceVersion(crosapi::mojom::Arc::Uuid_) < + int{crosapi::mojom::Arc::MethodMinVersions:: + kRequestUrlHandlerListMinVersion}) { + LOG(WARNING) << "RequestUrlHandlerList is not supported in Lacros."; + return false; + } + + service->GetRemote()->RequestUrlHandlerList( + url, base::BindOnce(&ArcIconCache::OnRequestUrlHandlerList, + weak_ptr_factory_.GetWeakPtr(), std::move(callback))); + return true; +} + +void ArcIconCache::OnRequestUrlHandlerList( + RequestUrlHandlerListCallback callback, + std::vector handlers) { + std::vector converted_handlers; + for (auto const& handler : handlers) { + converted_handlers.push_back(IntentHandlerInfo( + handler->name, handler->package_name, handler->activity_name)); + } + std::move(callback).Run(std::move(converted_handlers)); +} + +bool ArcIconCache::HandleUrl(const std::string& url, + const std::string& package_name) { + auto* service = chromeos::LacrosService::Get(); + if (!service || !service->IsAvailable()) { + LOG(WARNING) << "ARC is not supported in Lacros."; + return false; + } + + if (service->GetInterfaceVersion(crosapi::mojom::Arc::Uuid_) < + int{crosapi::mojom::Arc::MethodMinVersions::kHandleUrlMinVersion}) { + LOG(WARNING) << "HandleUrl is not supported in Lacros."; + return false; + } + + service->GetRemote()->HandleUrl(url, package_name); + return true; +} diff --git a/chrome/browser/lacros/arc/arc_icon_cache.h b/chrome/browser/lacros/arc/arc_icon_cache.h new file mode 100644 index 00000000000000..0a13c59ef1052e --- /dev/null +++ b/chrome/browser/lacros/arc/arc_icon_cache.h @@ -0,0 +1,65 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_LACROS_ARC_ARC_ICON_CACHE_H_ +#define CHROME_BROWSER_LACROS_ARC_ARC_ICON_CACHE_H_ + +#include +#include + +#include "base/memory/weak_ptr.h" +#include "base/threading/thread_checker.h" +#include "chromeos/crosapi/mojom/arc.mojom.h" +#include "components/arc/common/intent_helper/activity_icon_loader.h" +#include "components/arc/common/intent_helper/link_handler_model_delegate.h" +#include "mojo/public/cpp/bindings/receiver.h" + +// This class receives arc icon info updates from Ash. It can only be used on +// the main thread. +class ArcIconCache : public arc::LinkHandlerModelDelegate, + public crosapi::mojom::ArcObserver { + public: + ArcIconCache(); + ArcIconCache(const ArcIconCache&) = delete; + ArcIconCache& operator=(const ArcIconCache&) = delete; + ~ArcIconCache() override; + + // Start observing ARC in ash-chrome. + void Start(); + + // arc::LinkHandlerModelDelegate: + // Retrieves icons for the |activities| and calls |cb|. + // See ActivityIconLoader::GetActivityIcons() for more details. + GetResult GetActivityIcons(const std::vector& activities, + OnIconsReadyCallback cb) override; + // Calls RequestUrlHandlerList mojo API. + bool RequestUrlHandlerList(const std::string& url, + RequestUrlHandlerListCallback callback) override; + // Calls HandleUrl mojo API. + bool HandleUrl(const std::string& url, + const std::string& package_name) override; + + private: + THREAD_CHECKER(thread_checker_); + + // crosapi::mojom::ArcObserver + void OnIconInvalidated(const std::string& package_name) override; + + // Convert vector of crosapi::mojom::IntentHandlerInfoPtr to vector of + // ArcIconCacheDelegate::IntentHandlerInfo. + void OnRequestUrlHandlerList( + RequestUrlHandlerListCallback callback, + std::vector handlers); + + // Cached activity icons. + ActivityIconLoader icon_loader_; + + // Receives mojo messages from ash-chrome. + mojo::Receiver receiver_{this}; + + // This must come last to make sure weak pointers are invalidated first. + base::WeakPtrFactory weak_ptr_factory_{this}; +}; + +#endif // CHROME_BROWSER_LACROS_ARC_ARC_ICON_CACHE_H_ diff --git a/chrome/browser/lacros/arc_icon_cache_lacros.cc b/chrome/browser/lacros/arc_icon_cache_lacros.cc deleted file mode 100644 index 50930e8b00ee58..00000000000000 --- a/chrome/browser/lacros/arc_icon_cache_lacros.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2021 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/lacros/arc_icon_cache_lacros.h" - -#include "chromeos/lacros/lacros_service.h" - -ArcIconCacheLacros::ArcIconCacheLacros() = default; -ArcIconCacheLacros::~ArcIconCacheLacros() = default; - -void ArcIconCacheLacros::Start() { - auto* lacros_service = chromeos::LacrosService::Get(); - if (!lacros_service->IsAvailable()) { - LOG(WARNING) << "ARC is not supported in Lacros."; - return; - } - lacros_service->GetRemote()->AddObserver( - receiver_.BindNewPipeAndPassRemoteWithVersion()); -} - -void ArcIconCacheLacros::OnIconInvalidated(const std::string& package_name) { - DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); - icon_loader_.InvalidateIcons(package_name); -} diff --git a/chrome/browser/lacros/arc_icon_cache_lacros.h b/chrome/browser/lacros/arc_icon_cache_lacros.h deleted file mode 100644 index eb856fb3c3fc48..00000000000000 --- a/chrome/browser/lacros/arc_icon_cache_lacros.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2021 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_LACROS_ARC_ICON_CACHE_LACROS_H_ -#define CHROME_BROWSER_LACROS_ARC_ICON_CACHE_LACROS_H_ - -#include - -#include "base/threading/thread_checker.h" -#include "chromeos/crosapi/mojom/arc.mojom.h" -#include "components/arc/common/intent_helper/activity_icon_loader.h" -#include "mojo/public/cpp/bindings/receiver.h" - -// This class receives arc icon info updates from Ash. It can only be used on -// the main thread. -class ArcIconCacheLacros : public crosapi::mojom::ArcObserver { - public: - ArcIconCacheLacros(); - ArcIconCacheLacros(const ArcIconCacheLacros&) = delete; - ArcIconCacheLacros& operator=(const ArcIconCacheLacros&) = delete; - ~ArcIconCacheLacros() override; - - // Start observing ARC in ash-chrome. - void Start(); - - private: - THREAD_CHECKER(thread_checker_); - - // crosapi::mojom::ArcObserver - void OnIconInvalidated(const std::string& package_name) override; - - // Cached activity icons. - arc::internal::ActivityIconLoader icon_loader_; - - // Receives mojo messages from ash-chrome. - mojo::Receiver receiver_{this}; -}; - -#endif // CHROME_BROWSER_LACROS_ARC_ICON_CACHE_LACROS_H_ diff --git a/chrome/browser/lacros/browser_service_lacros.cc b/chrome/browser/lacros/browser_service_lacros.cc index d7b3c0d87f325e..c5f586b266f10d 100644 --- a/chrome/browser/lacros/browser_service_lacros.cc +++ b/chrome/browser/lacros/browser_service_lacros.cc @@ -256,6 +256,7 @@ void BrowserServiceLacros::OpenUrl(const GURL& url, OpenUrlCallback callback) { if (url.SchemeIs(content::kChromeUIScheme) && (url.host() == chrome::kChromeUIFlagsHost || url.host() == chrome::kChromeUIVersionHost || + url.host() == chrome::kChromeUIAboutHost || url.host() == chrome::kChromeUIComponentsHost)) { if (ActivateTabMatchingURLWithoutRef(profile, url)) { std::move(callback).Run(); diff --git a/chrome/browser/lacros/chrome_browser_main_extra_parts_lacros.cc b/chrome/browser/lacros/chrome_browser_main_extra_parts_lacros.cc index 4a3cf0391245c4..487bdbbd690f6f 100644 --- a/chrome/browser/lacros/chrome_browser_main_extra_parts_lacros.cc +++ b/chrome/browser/lacros/chrome_browser_main_extra_parts_lacros.cc @@ -5,7 +5,7 @@ #include "chrome/browser/lacros/chrome_browser_main_extra_parts_lacros.h" #include "chrome/browser/lacros/app_mode/kiosk_session_service_lacros.h" -#include "chrome/browser/lacros/arc_icon_cache_lacros.h" +#include "chrome/browser/lacros/arc/arc_icon_cache.h" #include "chrome/browser/lacros/automation_manager_lacros.h" #include "chrome/browser/lacros/browser_service_lacros.h" #include "chrome/browser/lacros/download_controller_client_lacros.h" @@ -78,7 +78,7 @@ void ChromeBrowserMainExtraPartsLacros::PostBrowserStart() { } #endif - arc_icon_cache_ = std::make_unique(); + arc_icon_cache_ = std::make_unique(); arc_icon_cache_->Start(); // Start Lacros' drive mount point path caching, since it is available in Ash. diff --git a/chrome/browser/lacros/chrome_browser_main_extra_parts_lacros.h b/chrome/browser/lacros/chrome_browser_main_extra_parts_lacros.h index 5ff9ce64084bee..7a56eac7871972 100644 --- a/chrome/browser/lacros/chrome_browser_main_extra_parts_lacros.h +++ b/chrome/browser/lacros/chrome_browser_main_extra_parts_lacros.h @@ -9,7 +9,7 @@ #include -class ArcIconCacheLacros; +class ArcIconCache; class AutomationManagerLacros; class BrowserServiceLacros; class DriveFsCache; @@ -46,7 +46,7 @@ class ChromeBrowserMainExtraPartsLacros : public ChromeBrowserMainExtraParts { void PostBrowserStart() override; // Receiver and cache of arc icon info updates. - std::unique_ptr arc_icon_cache_; + std::unique_ptr arc_icon_cache_; std::unique_ptr automation_manager_; diff --git a/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc b/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc index 86f5d07aa6546b..7393962ca885d0 100644 --- a/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc +++ b/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc @@ -8,9 +8,7 @@ #include #include -#include "base/allocator/buildflags.h" -#include "base/allocator/partition_alloc_features.h" -#include "base/allocator/partition_allocator/partition_alloc_config.h" +#include "base/allocator/partition_alloc_support.h" #include "base/bind.h" #include "base/command_line.h" #include "base/cpu.h" @@ -585,176 +583,6 @@ void ChromeBrowserMainExtraPartsMetrics::PreBrowserStart() { #endif // defined(OS_WIN) - // Records whether or not PartitionAlloc is used as the default allocator. - ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial( - "PartitionAllocEverywhere", -#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) - "Enabled" -#else - "Disabled" -#endif - ); - - // Records whether or not PartitionAlloc-Everywhere is enabled, and whether - // PCScan is enabled on top of it. This is meant for a 3-way experiment with 2 - // binaries: - // - binary A: deployed to 33% users, with PA-E and PCScan off. - // - binary B: deployed to 66% users, with PA-E on, half of which having - // PCScan on - // - // NOTE, deliberately don't use PA_ALLOW_PCSCAN which depends on bitness. - // In the 32-bit case, PCScan is always disabled, but we'll deliberately - // misrepresent it as enabled here (and later ignored when analyzing results), - // in order to keep each population at 33%. - ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial( - "PartitionAllocEverywhereAndPCScan", -#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) - base::FeatureList::IsEnabled( - base::features::kPartitionAllocPCScanBrowserOnly) - ? "EnabledWithPCScan" - : "EnabledWithoutPCScan" -#else - "Disabled" -#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) - ); - - // BackupRefPtr_Effective and PCScan_Effective record whether or not - // BackupRefPtr and/or PCScan are enabled. The experiments aren't independent, - // so having a synthetic Finch will help look only at cases where one isn't - // affected by the other. - -#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) - // Whether PartitionAllocBackupRefPtr is enabled (as determined by - // FeatureList::IsEnabled). - bool brp_finch_enabled = false; - ALLOW_UNUSED_LOCAL(brp_finch_enabled); - // Whether PartitionAllocBackupRefPtr is set up for the default behavior. The - // default behavior is when either the Finch flag is disabled, or is enabled - // in brp-mode=disabled (these two options are equivalent). - bool brp_nondefault_behavior = false; - ALLOW_UNUSED_LOCAL(brp_nondefault_behavior); - // Whether PartitionAllocBackupRefPtr is set up to enable BRP protection. It - // requires the Finch flag to be enabled and brp-mode!=disabled*. Some modes, - // e.g. disabled-but-3-way-split, do something (hence can't be considered the - // default behavior), but don't enable BRP protection. - bool brp_truly_enabled = false; - ALLOW_UNUSED_LOCAL(brp_truly_enabled); -#if BUILDFLAG(USE_BACKUP_REF_PTR) - if (base::FeatureList::IsEnabled(base::features::kPartitionAllocBackupRefPtr)) - brp_finch_enabled = true; - if (brp_finch_enabled && base::features::kBackupRefPtrModeParam.Get() != - base::features::BackupRefPtrMode::kDisabled) - brp_nondefault_behavior = true; - if (brp_finch_enabled && base::features::kBackupRefPtrModeParam.Get() == - base::features::BackupRefPtrMode::kEnabled) - brp_truly_enabled = true; -#endif // BUILDFLAG(USE_BACKUP_REF_PTR) - bool pcscan_enabled = -#if defined(PA_ALLOW_PCSCAN) - base::FeatureList::IsEnabled( - base::features::kPartitionAllocPCScanBrowserOnly); -#else - false; -#endif - - std::string brp_group_name; - if (pcscan_enabled) { - // If PCScan is enabled, just ignore the population. - brp_group_name = "Ignore_PCScanIsOn"; - } else if (!brp_finch_enabled) { - // The control group is actually disguised as "enabled", but in fact it's - // disabled using a param. This is to differentiate the population that - // participates in the control group, from the population that isn't in any - // group. - brp_group_name = "Ignore_NoGroup"; - } else { - switch (base::features::kBackupRefPtrModeParam.Get()) { - case base::features::BackupRefPtrMode::kDisabled: - brp_group_name = "Disabled"; - break; - case base::features::BackupRefPtrMode::kEnabled: -#if BUILDFLAG(PUT_REF_COUNT_IN_PREVIOUS_SLOT) - brp_group_name = "EnabledPrevSlot"; -#else - brp_group_name = "EnabledBeforeAlloc"; -#endif - break; - case base::features::BackupRefPtrMode::kDisabledButSplitPartitions2Way: - brp_group_name = "DisabledBut2WaySplit"; - break; - case base::features::BackupRefPtrMode::kDisabledButSplitPartitions3Way: - brp_group_name = "DisabledBut3WaySplit"; - break; - } - - if (base::features::kBackupRefPtrModeParam.Get() != - base::features::BackupRefPtrMode::kDisabled) { - std::string process_selector; - switch (base::features::kBackupRefPtrEnabledProcessesParam.Get()) { - case base::features::BackupRefPtrEnabledProcesses::kBrowserOnly: - process_selector = "BrowserOnly"; - break; - case base::features::BackupRefPtrEnabledProcesses::kBrowserAndRenderer: - process_selector = "BrowserAndRenderer"; - break; - case base::features::BackupRefPtrEnabledProcesses::kNonRenderer: - process_selector = "NonRenderer"; - break; - case base::features::BackupRefPtrEnabledProcesses::kAllProcesses: - process_selector = "AllProcesses"; - break; - } - - brp_group_name += ("_" + process_selector); - } - } - ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial( - "BackupRefPtr_Effective", brp_group_name); - - std::string pcscan_group_name; - std::string pcscan_group_name_fallback; -#if defined(PA_ALLOW_PCSCAN) - if (brp_truly_enabled) { - // If BRP protection is enabled, just ignore the population. Check - // brp_truly_enabled, not brp_finch_enabled, because there are certain modes - // where BRP protection is actually disabled. - pcscan_group_name = "Ignore_BRPIsOn"; - } else { - pcscan_group_name = (pcscan_enabled ? "Enabled" : "Disabled"); - } - // In case we are incorrect that PCScan is independent of partition-split - // modes, create a fallback trial that only takes into account the BRP Finch - // settings that preserve the default behavior. - if (brp_nondefault_behavior) { - pcscan_group_name_fallback = "Ignore_BRPIsOn"; - } else { - pcscan_group_name_fallback = (pcscan_enabled ? "Enabled" : "Disabled"); - } -#else - // On certain platforms, PCScan is not supported and permanently disabled. - // Don't lump it into "Disabled", so that belonging to "Enabled"/"Disabled" is - // fully controlled by Finch and thus have identical population sizes. - pcscan_group_name = "Unavailable"; - pcscan_group_name_fallback = "Unavailable"; -#endif // defined(PA_ALLOW_PCSCAN) - ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial("PCScan_Effective", - pcscan_group_name); - ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial( - "PCScan_Effective_Fallback", pcscan_group_name_fallback); - - // This synthetic Finch setting reflects the new USE_BACKUP_REF_PTR behavior, - // which simply compiles in the BackupRefPtr support, but keeps it disabled at - // run-time (which can be further enabled via Finch). - ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial( - "BackupRefPtrSupport", -#if BUILDFLAG(USE_BACKUP_REF_PTR) - "CompiledIn" -#else - "Disabled" -#endif // BUILDFLAG(USE_BACKUP_REF_PTR) - ); -#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) - #if defined(OS_ANDROID) // No need to filter out on Android, because it doesn't support // ChromeVariations policy. @@ -773,54 +601,15 @@ void ChromeBrowserMainExtraPartsMetrics::PreBrowserStart() { "EnterpriseSynthetic", is_enterprise ? "IsEnterprise" : "IsNotEnterprise"); - // This synthetic field trial for the BackupRefPtr binary A/B experiment is - // set up such that: - // 1) Enterprises are excluded from experiment, to make sure we honor - // ChromeVariations policy. - // 2) The experiment binary (USE_BACKUP_REF_PTR) is delivered via Google - // Update to fraction X of the non-enterprise population. - // 3) The control group is established in fraction X of non-enterprise - // popluation via Finch (PartitionAllocBackupRefPtrControl). Since this - // Finch is applicable only to 1-X of the non-enterprise population, we - // need to set it to Y=X/(1-X). E.g. if X=.333, Y=.5; if X=.01, Y=.0101. -#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) -#if BUILDFLAG(USE_BACKUP_REF_PTR) - constexpr bool kIsBrpOn = true; // experiment binary only -#else - constexpr bool kIsBrpOn = false; // non-experiment binary -#endif - const bool is_brp_control = base::FeatureList::IsEnabled( - base::features::kPartitionAllocBackupRefPtrControl); - const char* group_name; - if (is_enterprise) { - if (kIsBrpOn) { // is_enterprise && kIsBrpOn - group_name = "Excluded_Enterprise_BrpOn"; - } else { // is_enterprise && !kIsBrpOn - group_name = "Excluded_Enterprise_BrpOff"; - } - } else { - if (kIsBrpOn) { // !is_enterprise && kIsBrpOn - group_name = "Enabled"; - } else { // !is_enterprise && !kIsBrpOn - if (is_brp_control) { - group_name = "Control"; - } else { - group_name = "Excluded_NonEnterprise"; - } - } + // Register synthetic Finch trials proposed by PartitionAlloc. + auto pa_trials = base::allocator::ProposeSyntheticFinchTrials(is_enterprise); + for (auto& trial : pa_trials) { + std::string trial_name; + std::string group_name; + std::tie(trial_name, group_name) = trial; + ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial(trial_name, + group_name); } - ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial( - "BackupRefPtrNoEnterprise", group_name); -#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) - - ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial( - "FakeBinaryExperiment", -#if BUILDFLAG(USE_FAKE_BINARY_EXPERIMENT) - "Enabled" -#else - "Disabled" -#endif - ); } void ChromeBrowserMainExtraPartsMetrics::PostBrowserStart() { diff --git a/chrome/browser/net/nss_context_chromeos_browsertest.cc b/chrome/browser/net/nss_context_chromeos_browsertest.cc index 0b25ee769e0c8e..dac17e63a77288 100644 --- a/chrome/browser/net/nss_context_chromeos_browsertest.cc +++ b/chrome/browser/net/nss_context_chromeos_browsertest.cc @@ -6,6 +6,7 @@ #include +#include "ash/components/login/auth/user_context.h" #include "base/bind.h" #include "base/run_loop.h" #include "chrome/browser/ash/login/login_manager_test.h" @@ -17,7 +18,6 @@ #include "chrome/browser/ash/scoped_test_system_nss_key_slot_mixin.h" #include "chrome/browser/net/nss_service.h" #include "chrome/browser/profiles/profile.h" -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" #include "components/signin/public/identity_manager/identity_test_utils.h" #include "components/user_manager/user.h" diff --git a/chrome/browser/password_manager/chrome_password_manager_client.cc b/chrome/browser/password_manager/chrome_password_manager_client.cc index 377f8cfdc61d9d..a211aabdd5fb44 100644 --- a/chrome/browser/password_manager/chrome_password_manager_client.cc +++ b/chrome/browser/password_manager/chrome_password_manager_client.cc @@ -92,6 +92,7 @@ #include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/navigation_handle.h" +#include "content/public/browser/page.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host_view.h" @@ -1280,14 +1281,7 @@ void ChromePasswordManagerClient::DidStartNavigation( log_manager_->SetSuspended(web_contents()->GetWebUI() != nullptr); } -void ChromePasswordManagerClient::DidFinishNavigation( - content::NavigationHandle* navigation_handle) { - if (!navigation_handle->IsInPrimaryMainFrame() || - navigation_handle->IsSameDocument() || - !navigation_handle->HasCommitted()) { - return; - } - +void ChromePasswordManagerClient::PrimaryPageChanged(content::Page& page) { // Send any collected metrics by destroying the metrics recorder. metrics_recorder_.reset(); @@ -1301,8 +1295,8 @@ void ChromePasswordManagerClient::DidFinishNavigation( password_reuse_detection_manager_.DidNavigateMainFrame(GetLastCommittedURL()); - AddToWidgetInputEventObservers( - navigation_handle->GetRenderFrameHost()->GetRenderWidgetHost(), this); + AddToWidgetInputEventObservers(page.GetMainDocument().GetRenderWidgetHost(), + this); #if defined(OS_ANDROID) // This unblocklisted info is only used after form submission to determine diff --git a/chrome/browser/password_manager/chrome_password_manager_client.h b/chrome/browser/password_manager/chrome_password_manager_client.h index 291fe99a8257f6..2f329c313ea556 100644 --- a/chrome/browser/password_manager/chrome_password_manager_client.h +++ b/chrome/browser/password_manager/chrome_password_manager_client.h @@ -316,8 +316,7 @@ class ChromePasswordManagerClient // content::WebContentsObserver overrides. void DidStartNavigation( content::NavigationHandle* navigation_handle) override; - void DidFinishNavigation( - content::NavigationHandle* navigation_handle) override; + void PrimaryPageChanged(content::Page& page) override; void WebContentsDestroyed() override; // TODO(crbug.com/1006430): Paste event is not captured on Android. #if !defined(OS_ANDROID) diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc index 7cde01a9bc3886..e6d8b31c16c292 100644 --- a/chrome/browser/prefs/browser_prefs.cc +++ b/chrome/browser/prefs/browser_prefs.cc @@ -26,6 +26,7 @@ #include "chrome/browser/enterprise/reporting/prefs.h" #include "chrome/browser/enterprise/util/managed_browser_utils.h" #include "chrome/browser/external_protocol/external_protocol_handler.h" +#include "chrome/browser/first_party_sets/first_party_sets_pref_names.h" #include "chrome/browser/first_run/first_run.h" #include "chrome/browser/gpu/gpu_mode_manager.h" #include "chrome/browser/lifetime/browser_shutdown.h" @@ -932,6 +933,7 @@ void RegisterLocalState(PrefRegistrySimple* registry) { enterprise_reporting::RegisterLocalStatePrefs(registry); ExternalProtocolHandler::RegisterPrefs(registry); flags_ui::PrefServiceFlagsStorage::RegisterPrefs(registry); + first_party_sets::RegisterLocalStatePrefs(registry); GpuModeManager::RegisterPrefs(registry); signin::IdentityManager::RegisterLocalStatePrefs(registry); invalidation::FCMInvalidationService::RegisterPrefs(registry); diff --git a/chrome/browser/resources/BUILD.gn b/chrome/browser/resources/BUILD.gn index 8091d44d61a0dc..d1e8c64a9e4fd7 100644 --- a/chrome/browser/resources/BUILD.gn +++ b/chrome/browser/resources/BUILD.gn @@ -56,6 +56,7 @@ group("resources") { ":bluetooth_pairing_dialog_resources", ":internet_config_dialog_resources", ":internet_detail_dialog_resources", + "chromeos:app_icon_resources", "chromeos:multidevice_setup_resources", "chromeos/accessibility:build", "chromeos/audio:resources", diff --git a/chrome/browser/resources/chromeos/BUILD.gn b/chrome/browser/resources/chromeos/BUILD.gn index 2a8a397c558410..34ef1ed125ada5 100644 --- a/chrome/browser/resources/chromeos/BUILD.gn +++ b/chrome/browser/resources/chromeos/BUILD.gn @@ -9,6 +9,19 @@ import("//tools/grit/grit_rule.gni") assert(is_chromeos, "Only Chrome OS resources in //c/b/resources//chromeos.") +grit("app_icon_resources") { + source = "app_icon/app_icon_resources.grd" + defines = chrome_grit_defines + outputs = [ + "grit/app_icon_resources.h", + "grit/app_icon_resources_map.cc", + "grit/app_icon_resources_map.h", + "app_icon_resources_100_percent.pak", + "app_icon_resources_200_percent.pak", + ] + output_dir = "$root_gen_dir/chrome" +} + grit("multidevice_setup_resources") { multidevice_setup_gen_dir = "$root_gen_dir/chrome/browser/resources/chromeos/multidevice_setup" diff --git a/chrome/browser/resources/chromeos/app_icon/app_icon_resources.grd b/chrome/browser/resources/chromeos/app_icon/app_icon_resources.grd new file mode 100644 index 00000000000000..14af7c42ce63f6 --- /dev/null +++ b/chrome/browser/resources/chromeos/app_icon/app_icon_resources.grd @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ui/chromeos/resources/default_100_percent/badges/block-icon-badge.png b/chrome/browser/resources/chromeos/app_icon/default_100_percent/badges/block-icon-badge.png similarity index 100% rename from ui/chromeos/resources/default_100_percent/badges/block-icon-badge.png rename to chrome/browser/resources/chromeos/app_icon/default_100_percent/badges/block-icon-badge.png diff --git a/ui/chromeos/resources/default_100_percent/badges/chrome-icon-badge.png b/chrome/browser/resources/chromeos/app_icon/default_100_percent/badges/chrome-icon-badge.png similarity index 100% rename from ui/chromeos/resources/default_100_percent/badges/chrome-icon-badge.png rename to chrome/browser/resources/chromeos/app_icon/default_100_percent/badges/chrome-icon-badge.png diff --git a/ui/chromeos/resources/default_100_percent/badges/hourglass-icon-badge.png b/chrome/browser/resources/chromeos/app_icon/default_100_percent/badges/hourglass-icon-badge.png similarity index 100% rename from ui/chromeos/resources/default_100_percent/badges/hourglass-icon-badge.png rename to chrome/browser/resources/chromeos/app_icon/default_100_percent/badges/hourglass-icon-badge.png diff --git a/ui/chromeos/resources/default_100_percent/mask/badge-mask.png b/chrome/browser/resources/chromeos/app_icon/default_100_percent/mask/badge-mask.png similarity index 100% rename from ui/chromeos/resources/default_100_percent/mask/badge-mask.png rename to chrome/browser/resources/chromeos/app_icon/default_100_percent/mask/badge-mask.png diff --git a/ui/chromeos/resources/default_100_percent/mask/mask.png b/chrome/browser/resources/chromeos/app_icon/default_100_percent/mask/mask.png similarity index 100% rename from ui/chromeos/resources/default_100_percent/mask/mask.png rename to chrome/browser/resources/chromeos/app_icon/default_100_percent/mask/mask.png diff --git a/ui/chromeos/resources/default_200_percent/badges/block-icon-badge.png b/chrome/browser/resources/chromeos/app_icon/default_200_percent/badges/block-icon-badge.png similarity index 100% rename from ui/chromeos/resources/default_200_percent/badges/block-icon-badge.png rename to chrome/browser/resources/chromeos/app_icon/default_200_percent/badges/block-icon-badge.png diff --git a/ui/chromeos/resources/default_200_percent/badges/chrome-icon-badge.png b/chrome/browser/resources/chromeos/app_icon/default_200_percent/badges/chrome-icon-badge.png similarity index 100% rename from ui/chromeos/resources/default_200_percent/badges/chrome-icon-badge.png rename to chrome/browser/resources/chromeos/app_icon/default_200_percent/badges/chrome-icon-badge.png diff --git a/ui/chromeos/resources/default_200_percent/badges/hourglass-icon-badge.png b/chrome/browser/resources/chromeos/app_icon/default_200_percent/badges/hourglass-icon-badge.png similarity index 100% rename from ui/chromeos/resources/default_200_percent/badges/hourglass-icon-badge.png rename to chrome/browser/resources/chromeos/app_icon/default_200_percent/badges/hourglass-icon-badge.png diff --git a/ui/chromeos/resources/default_200_percent/mask/badge-mask.png b/chrome/browser/resources/chromeos/app_icon/default_200_percent/mask/badge-mask.png similarity index 100% rename from ui/chromeos/resources/default_200_percent/mask/badge-mask.png rename to chrome/browser/resources/chromeos/app_icon/default_200_percent/mask/badge-mask.png diff --git a/ui/chromeos/resources/default_200_percent/mask/mask.png b/chrome/browser/resources/chromeos/app_icon/default_200_percent/mask/mask.png similarity index 100% rename from ui/chromeos/resources/default_200_percent/mask/mask.png rename to chrome/browser/resources/chromeos/app_icon/default_200_percent/mask/mask.png diff --git a/chrome/browser/resources/print_preview/data/user_manager.ts b/chrome/browser/resources/print_preview/data/user_manager.ts index e3fc3774ed533f..fd8e412dbe8b76 100644 --- a/chrome/browser/resources/print_preview/data/user_manager.ts +++ b/chrome/browser/resources/print_preview/data/user_manager.ts @@ -20,7 +20,7 @@ type UpdateUsersPayload = { const PrintPreviewUserManagerElementBase = WebUIListenerMixin(PolymerElement); -export class PrintPreviewUserManagerElement extends +class PrintPreviewUserManagerElement extends PrintPreviewUserManagerElementBase { static get is() { return 'print-preview-user-manager'; diff --git a/chrome/browser/resources/print_preview/print_preview.ts b/chrome/browser/resources/print_preview/print_preview.ts index 09693e743a6e1d..e9dc09f472cdec 100644 --- a/chrome/browser/resources/print_preview/print_preview.ts +++ b/chrome/browser/resources/print_preview/print_preview.ts @@ -29,7 +29,6 @@ export {PrinterState, PrinterStatus, PrinterStatusReason, PrinterStatusSeverity} export {ScalingType} from './data/scaling.js'; export {Size} from './data/size.js'; export {Error, State} from './data/state.js'; -export {PrintPreviewUserManagerElement} from './data/user_manager.js'; export {BackgroundGraphicsModeRestriction, CapabilitiesResponse, ColorModeRestriction, DuplexModeRestriction, NativeInitialSettings, NativeLayer, NativeLayerImpl} from './native_layer.js'; // export {PinModeRestriction} from './native_layer.js'; diff --git a/chrome/browser/resources/print_preview/ui/settings_select.ts b/chrome/browser/resources/print_preview/ui/settings_select.ts index 30c77f75984223..25aeae409ab88a 100644 --- a/chrome/browser/resources/print_preview/ui/settings_select.ts +++ b/chrome/browser/resources/print_preview/ui/settings_select.ts @@ -8,7 +8,7 @@ import './print_preview_shared_css.js'; import {assert, assertNotReached} from 'chrome://resources/js/assert.m.js'; import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -import {CapabilityWithReset, SelectOption} from '../data/cdd.js'; +import {SelectOption} from '../data/cdd.js'; import {getStringForCurrentLocale} from '../print_preview_utils.js'; import {SelectMixin} from './select_mixin.js'; @@ -40,7 +40,7 @@ export class PrintPreviewSettingsSelectElement extends } ariaLabel: string; - capability: CapabilityWithReset&{option: SelectOption[]}; + capability: SelectOption[]; settingName: string; disabled: boolean; diff --git a/chrome/browser/resources/settings/chromeos/os_bluetooth_page/os_paired_bluetooth_list_item.html b/chrome/browser/resources/settings/chromeos/os_bluetooth_page/os_paired_bluetooth_list_item.html index 866aef7bd39f47..25428e0a3643cb 100644 --- a/chrome/browser/resources/settings/chromeos/os_bluetooth_page/os_paired_bluetooth_list_item.html +++ b/chrome/browser/resources/settings/chromeos/os_bluetooth_page/os_paired_bluetooth_list_item.html @@ -34,10 +34,8 @@
diff --git a/chrome/browser/resources/settings/chromeos/os_bluetooth_page/os_paired_bluetooth_list_item.js b/chrome/browser/resources/settings/chromeos/os_bluetooth_page/os_paired_bluetooth_list_item.js index b9a6cac38659a1..0031c378d78407 100644 --- a/chrome/browser/resources/settings/chromeos/os_bluetooth_page/os_paired_bluetooth_list_item.js +++ b/chrome/browser/resources/settings/chromeos/os_bluetooth_page/os_paired_bluetooth_list_item.js @@ -302,18 +302,6 @@ class SettingsPairedBluetoothListItemElement extends return this.i18n(stringName, this.itemIndex + 1, this.listSize, deviceName); } - /** - * @param {!chromeos.bluetoothConfig.mojom.PairedBluetoothDeviceProperties} - * device - * @return {string} - * @private - */ - getSubpageButtonA11yLabel_(device) { - const deviceName = this.getDeviceName_(device); - return this.i18n( - 'bluetoothPairedDeviceItemSubpageButtonA11yLabel', deviceName); - } - /** @private */ onShowTooltip_() { this.fireTooltipStateChangeEvent_(/*showTooltip=*/ true); diff --git a/chrome/browser/safe_browsing/incident_reporting/extension_data_collection.cc b/chrome/browser/safe_browsing/incident_reporting/extension_data_collection.cc index d09e7a8761cd25..c0cd773fe28e37 100644 --- a/chrome/browser/safe_browsing/incident_reporting/extension_data_collection.cc +++ b/chrome/browser/safe_browsing/incident_reporting/extension_data_collection.cc @@ -51,10 +51,9 @@ void PopulateExtensionInfo( extension_info->set_state(Info::STATE_TERMINATED); extension_info->set_type(extension.GetType()); - std::string update_url; - if (extension.manifest()->GetString(extensions::manifest_keys::kUpdateURL, - &update_url)) { - extension_info->set_update_url(update_url); + if (const std::string* update_url = extension.manifest()->FindStringPath( + extensions::manifest_keys::kUpdateURL)) { + extension_info->set_update_url(*update_url); } extension_info->set_installed_by_default( diff --git a/chrome/browser/sharing_hub/sharing_hub_features.cc b/chrome/browser/sharing_hub/sharing_hub_features.cc index 96dcc4eaf1ad40..fe0aa5840ba292 100644 --- a/chrome/browser/sharing_hub/sharing_hub_features.cc +++ b/chrome/browser/sharing_hub/sharing_hub_features.cc @@ -20,9 +20,9 @@ namespace { bool SharingHubDisabledByPolicy(content::BrowserContext* context) { #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) const PrefService* prefs = Profile::FromBrowserContext(context)->GetPrefs(); - return prefs->GetBoolean(prefs::kDesktopSharingHubEnabled); + return !prefs->GetBoolean(prefs::kDesktopSharingHubEnabled); #else - return true; + return false; #endif } diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn index 7cc9513f87182a..ea001ba0533bf2 100644 --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn @@ -1893,6 +1893,8 @@ static_library("ui") { "app_list/arc/arc_vpn_provider_manager.h", "app_list/arc/arc_vpn_provider_manager_factory.cc", "app_list/arc/arc_vpn_provider_manager_factory.h", + "app_list/arc/intent.cc", + "app_list/arc/intent.h", "app_list/chrome_app_list_item.cc", "app_list/chrome_app_list_item.h", "app_list/chrome_app_list_item_manager.cc", @@ -2898,6 +2900,7 @@ static_library("ui") { "//ash/components/disks", "//ash/components/drivefs", "//ash/components/drivefs/mojom:mojom", + "//ash/components/login/auth", "//ash/components/login/session", "//ash/components/peripheral_notification", "//ash/components/phonehub", @@ -3011,7 +3014,6 @@ static_library("ui") { "//chromeos/dbus/userdataauth", "//chromeos/dbus/userdataauth:userdataauth_proto", "//chromeos/dbus/util", - "//chromeos/login/auth", "//chromeos/login/login_state", "//chromeos/network", "//chromeos/printing", diff --git a/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/suggestions/CachedZeroSuggestionsManager.java b/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/suggestions/CachedZeroSuggestionsManager.java index ff7dfa7e8e2d33..e4c24ce1aed4a6 100644 --- a/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/suggestions/CachedZeroSuggestionsManager.java +++ b/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/suggestions/CachedZeroSuggestionsManager.java @@ -182,7 +182,7 @@ static List readCachedSuggestionList(SharedPreferencesManager AutocompleteMatch suggestion = new AutocompleteMatch(nativeType, subtypes, isSearchType, 0, 0, displayText, classifications, description, classifications, null, null, url, GURL.emptyGURL(), null, isDeletable, postContentType, postData, groupId, - null, null, false, null); + null, null, false, null, null); suggestions.add(suggestion); } diff --git a/chrome/browser/ui/app_list/app_service/app_service_context_menu.cc b/chrome/browser/ui/app_list/app_service/app_service_context_menu.cc index 0d8e24e5f10ad7..db7d178ea3afbf 100644 --- a/chrome/browser/ui/app_list/app_service/app_service_context_menu.cc +++ b/chrome/browser/ui/app_list/app_service/app_service_context_menu.cc @@ -104,6 +104,20 @@ void ShowOptionsPage(AppListControllerDelegate* controller, controller->ShowOptionsPage(profile, app_id); } +void ExecuteLaunchCommand(app_list::AppContextMenuDelegate* delegate, + int event_flags, + bool post_task) { + DCHECK(delegate); + if (post_task) { + content::GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(ExecuteLaunchCommand, delegate, event_flags, + /*post_task=*/false)); + return; + } + + delegate->ExecuteLaunchCommand(event_flags); +} + } // namespace AppServiceContextMenu::AppServiceContextMenu( @@ -164,7 +178,7 @@ void AppServiceContextMenu::ExecuteCommand(int command_id, int event_flags) { controller()->GetAppListDisplayId()); switch (command_id) { case ash::LAUNCH_NEW: - delegate()->ExecuteLaunchCommand(event_flags); + ExecuteLaunchCommand(delegate(), event_flags, /*post_task=*/true); ash::full_restore::FullRestoreService::MaybeCloseNotification(profile()); break; diff --git a/chrome/browser/ui/app_list/arc/arc_app_unittest.cc b/chrome/browser/ui/app_list/arc/arc_app_unittest.cc index 40d2312415b594..f532bb3d117ea4 100644 --- a/chrome/browser/ui/app_list/arc/arc_app_unittest.cc +++ b/chrome/browser/ui/app_list/arc/arc_app_unittest.cc @@ -67,6 +67,7 @@ #include "chrome/browser/ui/app_list/arc/arc_package_syncable_service.h" #include "chrome/browser/ui/app_list/arc/arc_package_syncable_service_factory.h" #include "chrome/browser/ui/app_list/arc/arc_pai_starter.h" +#include "chrome/browser/ui/app_list/arc/intent.h" #include "chrome/browser/ui/app_list/arc/mock_arc_app_list_prefs_observer.h" #include "chrome/browser/ui/app_list/chrome_app_list_item.h" #include "chrome/browser/ui/app_list/test/fake_app_list_model_updater.h" diff --git a/chrome/browser/ui/app_list/arc/arc_app_utils.cc b/chrome/browser/ui/app_list/arc/arc_app_utils.cc index 1a8356accc7d3d..8af50bf6c66516 100644 --- a/chrome/browser/ui/app_list/arc/arc_app_utils.cc +++ b/chrome/browser/ui/app_list/arc/arc_app_utils.cc @@ -27,7 +27,6 @@ #include "base/scoped_multi_source_observation.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_piece.h" -#include "base/strings/string_split.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/synchronization/waitable_event.h" @@ -44,6 +43,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_observer.h" #include "chrome/browser/ui/app_list/app_list_client_impl.h" +#include "chrome/browser/ui/app_list/arc/intent.h" #include "chrome/browser/ui/app_list/search/ranking/launch_data.h" #include "chrome/browser/ui/app_list/search/search_controller.h" #include "chrome/browser/ui/app_list/search/search_result_ranker/ranking_item_util.h" @@ -92,8 +92,6 @@ constexpr char kIntentHelperClassName[] = constexpr char kSetInTouchModeIntent[] = "org.chromium.arc.intent_helper.SET_IN_TOUCH_MODE"; -constexpr char kActionMain[] = "android.intent.action.MAIN"; - constexpr char kAndroidClockAppId[] = "ddmmnabaeomoacfpfjgghfpocfolhjlg"; constexpr char kAndroidFilesAppId[] = "gmiohhmfhgfclpeacmdfancbipocempm"; @@ -219,21 +217,9 @@ std::string ConstructArcAppShortcutUrl(const std::string& app_id, } // namespace // Package names, kept in sorted order. -const char kInitialStartParam[] = "initialStart"; -const char kCategoryLauncher[] = "android.intent.category.LAUNCHER"; -const char kRequestStartTimeParamTemplate[] = - "S.org.chromium.arc.request.start=%" PRId64; const char kPlayStoreActivity[] = "com.android.vending.AssetBrowserActivity"; const char kPlayStorePackage[] = "com.android.vending"; -// Intent labels, kept in sorted order. -constexpr char kAction[] = "action"; -constexpr char kCategory[] = "category"; -constexpr char kComponent[] = "component"; -constexpr char kEndSuffix[] = "end"; -constexpr char kIntentPrefix[] = "#Intent"; -constexpr char kLaunchFlags[] = "launchFlags"; - // App IDs, kept in sorted order. const char kGmailAppId[] = "hhkfkjpmacfncmbapfohfocpjpdnobjg"; const char kGoogleCalendarAppId[] = "decaoeahkmjpajbmlbpogjjkjbjokeed"; @@ -334,9 +320,9 @@ bool LaunchAppWithIntent(content::BrowserContext* context, if (window_info) window_info->display_id = GetValidDisplayId(window_info->display_id); - ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); + ArcAppListPrefs* const prefs = ArcAppListPrefs::Get(context); std::unique_ptr app_info = prefs->GetApp(app_id); - absl::optional launch_intent_to_send = std::move(launch_intent); + absl::optional launch_intent_to_send = launch_intent; if (app_info && !app_info->ready) { if (!IsArcPlayStoreEnabledForProfile(profile)) { if (prefs->IsDefault(app_id)) { @@ -400,14 +386,19 @@ bool LaunchAppWithIntent(content::BrowserContext* context, } prefs->SetLastLaunchTime(app_id); return true; - } else if (app_id == kPlayStoreAppId && !launch_intent_to_send) { + } else if (app_id == kPlayStoreAppId) { // Record launch request time in order to track Play Store default launch // performance. - launch_intent_to_send = GetLaunchIntent( - kPlayStorePackage, kPlayStoreActivity, - {base::StringPrintf( - kRequestStartTimeParamTemplate, - (base::TimeTicks::Now() - base::TimeTicks()).InMilliseconds())}); + const std::vector extra = {base::StringPrintf( + "%s=%" PRId64, kRequestStartTimeParamKey, + (base::TimeTicks::Now() - base::TimeTicks()).InMilliseconds())}; + if (!launch_intent_to_send) { + launch_intent_to_send = + GetLaunchIntent(kPlayStorePackage, kPlayStoreActivity, extra); + } else { + launch_intent_to_send = + AppendLaunchIntent(launch_intent_to_send.value(), extra); + } } arc::ArcBootPhaseMonitorBridge::RecordFirstAppLaunchDelayUMA(context); @@ -587,89 +578,6 @@ bool IsArcItem(content::BrowserContext* context, const std::string& id) { return arc_prefs->IsRegistered(arc_app_shelf_id.app_id()); } -std::string GetLaunchIntent(const std::string& package_name, - const std::string& activity, - const std::vector& extra_params) { - std::string extra_params_extracted; - for (const auto& extra_param : extra_params) { - extra_params_extracted += extra_param; - extra_params_extracted += ";"; - } - - // Remove the |package_name| prefix, if activity starts with it. - const char* activity_compact_name = - activity.find(package_name.c_str()) == 0 - ? activity.c_str() + package_name.length() - : activity.c_str(); - - // Construct a string in format: - // #Intent;action=android.intent.action.MAIN; - // category=android.intent.category.LAUNCHER; - // launchFlags=0x10210000; - // component=package_name/activity; - // param1;param2;end - return base::StringPrintf( - "%s;%s=%s;%s=%s;%s=0x%x;%s=%s/%s;%s%s", kIntentPrefix, kAction, - kActionMain, kCategory, kCategoryLauncher, kLaunchFlags, - Intent::FLAG_ACTIVITY_NEW_TASK | - Intent::FLAG_ACTIVITY_RESET_TASK_IF_NEEDED, - kComponent, package_name.c_str(), activity_compact_name, - extra_params_extracted.c_str(), kEndSuffix); -} - -bool ParseIntent(const std::string& intent_as_string, Intent* intent) { - DCHECK(intent); - const std::vector parts = base::SplitStringPiece( - intent_as_string, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); - if (parts.size() < 2 || parts.front() != kIntentPrefix || - parts.back() != kEndSuffix) { - DVLOG(1) << "Failed to split intent " << intent_as_string << "."; - return false; - } - - for (size_t i = 1; i < parts.size() - 1; ++i) { - const size_t separator = parts[i].find('='); - if (separator == std::string::npos) { - intent->AddExtraParam(std::string(parts[i])); - continue; - } - const base::StringPiece key = parts[i].substr(0, separator); - const base::StringPiece value = parts[i].substr(separator + 1); - if (key == kAction) { - intent->set_action(std::string(value)); - } else if (key == kCategory) { - intent->set_category(std::string(value)); - } else if (key == kLaunchFlags) { - uint32_t launch_flags; - const bool parsed = base::HexStringToUInt(value, &launch_flags); - if (!parsed) { - DVLOG(1) << "Failed to parse launchFlags: " << value << "."; - return false; - } - intent->set_launch_flags(launch_flags); - } else if (key == kComponent) { - const size_t component_separator = value.find('/'); - if (component_separator == std::string::npos) - return false; - intent->set_package_name( - std::string(value.substr(0, component_separator))); - const base::StringPiece activity_compact_name = - value.substr(component_separator + 1); - if (!activity_compact_name.empty() && activity_compact_name[0] == '.') { - std::string activity(value.substr(0, component_separator)); - activity += std::string(activity_compact_name); - intent->set_activity(activity); - } else { - intent->set_activity(std::string(activity_compact_name)); - } - } else { - intent->AddExtraParam(std::string(parts[i])); - } - } - - return true; -} - void GetLocaleAndPreferredLanguages(const Profile* profile, std::string* out_locale, std::string* out_preferred_languages) { @@ -766,18 +674,6 @@ void RemoveAppLaunchObserver(content::BrowserContext* context, it->second.RemoveObserver(observer); } -Intent::Intent() = default; - -Intent::~Intent() = default; - -void Intent::AddExtraParam(const std::string& extra_param) { - extra_params_.push_back(extra_param); -} - -bool Intent::HasExtraParam(const std::string& extra_param) const { - return base::Contains(extra_params_, extra_param); -} - const std::string GetAppFromAppOrGroupId(content::BrowserContext* context, const std::string& app_or_group_id) { const arc::ArcAppShelfId app_shelf_id = diff --git a/chrome/browser/ui/app_list/arc/arc_app_utils.h b/chrome/browser/ui/app_list/arc/arc_app_utils.h index afee80904f783e..39f4c307efe5ef 100644 --- a/chrome/browser/ui/app_list/arc/arc_app_utils.h +++ b/chrome/browser/ui/app_list/arc/arc_app_utils.h @@ -25,19 +25,9 @@ class BrowserContext; namespace arc { -extern const char kInitialStartParam[]; -extern const char kCategoryLauncher[]; -extern const char kRequestStartTimeParamTemplate[]; extern const char kPlayStoreActivity[]; extern const char kPlayStorePackage[]; -extern const char kAction[]; -extern const char kCategory[]; -extern const char kComponent[]; -extern const char kEndSuffix[]; -extern const char kIntentPrefix[]; -extern const char kLaunchFlags[]; - extern const char kCameraMigrationAppId[]; extern const char kGmailAppId[]; extern const char kGoogleCalendarAppId[]; @@ -57,54 +47,6 @@ extern const char kYoutubeMusicAppId[]; extern const char kYoutubeMusicWebApkAppId[]; extern const char kAndroidContactsAppId[]; -// Represents unparsed intent. -class Intent { - public: - Intent(); - - Intent(const Intent&) = delete; - Intent& operator=(const Intent&) = delete; - - ~Intent(); - - enum LaunchFlags : uint32_t { - FLAG_ACTIVITY_NEW_TASK = 0x10000000, - FLAG_RECEIVER_NO_ABORT = 0x08000000, - FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000, - FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000, - }; - - void AddExtraParam(const std::string& extra_param); - bool HasExtraParam(const std::string& extra_param) const; - - const std::string& action() const { return action_; } - void set_action(const std::string& action) { action_ = action; } - - const std::string& category() const { return category_; } - void set_category(const std::string& category) { category_ = category; } - - const std::string& package_name() const { return package_name_; } - void set_package_name(const std::string& package_name) { - package_name_ = package_name; - } - - const std::string& activity() const { return activity_; } - void set_activity(const std::string& activity) { activity_ = activity; } - - uint32_t launch_flags() const { return launch_flags_; } - void set_launch_flags(uint32_t launch_flags) { launch_flags_ = launch_flags; } - - const std::vector& extra_params() { return extra_params_; } - - private: - std::string action_; // Extracted from action. - std::string category_; // Extracted from category. - std::string package_name_; // Extracted from component. - std::string activity_; // Extracted from component. - uint32_t launch_flags_ = 0; // Extracted from launchFlags; - std::vector extra_params_; // Other parameters not listed above. -}; - // Observes ARC app launches. class AppLaunchObserver : public base::CheckedObserver { public: @@ -179,17 +121,6 @@ bool ShowPackageInfo(const std::string& package_name, // Returns true if |id| represents either ARC app or ARC shelf group. bool IsArcItem(content::BrowserContext* context, const std::string& id); -// Returns intent that can be used to launch an activity specified by -// |package_name| and |activity|. |extra_params| is the list of optional -// parameters encoded to intent. -std::string GetLaunchIntent(const std::string& package_name, - const std::string& activity, - const std::vector& extra_params); - -// Parses provided |intent_as_string|. Returns false if |intent_as_string| -// cannot be parsed. -bool ParseIntent(const std::string& intent_as_string, Intent* intent); - // Returns current active locale and list of preferred languages for the given // |profile|. void GetLocaleAndPreferredLanguages(const Profile* profle, diff --git a/chrome/browser/ui/app_list/arc/arc_app_utils_unittest.cc b/chrome/browser/ui/app_list/arc/arc_app_utils_unittest.cc index 91331113d586f1..0b8f9f8cdce70d 100644 --- a/chrome/browser/ui/app_list/arc/arc_app_utils_unittest.cc +++ b/chrome/browser/ui/app_list/arc/arc_app_utils_unittest.cc @@ -9,26 +9,12 @@ #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" #include "chrome/browser/ui/app_list/arc/arc_app_test.h" #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" -#include "chrome/browser/ui/ash/shelf/arc_app_shelf_id.h" #include "chrome/test/base/testing_profile.h" #include "content/public/test/browser_task_environment.h" #include "testing/gtest/include/gtest/gtest.h" namespace { -constexpr char kTestPackage[] = "com.test.app"; -constexpr char kTestActivity[] = "com.test.app.some.activity"; -constexpr char kTestShelfGroupId[] = "some_shelf_group"; -constexpr char kIntentWithShelfGroupId[] = - "#Intent;launchFlags=0x18001000;" - "component=com.test.app/com.test.app.some.activity;" - "S.org.chromium.arc.shelf_group_id=some_shelf_group;end"; - -std::string GetPlayStoreInitialLaunchIntent() { - return arc::GetLaunchIntent(arc::kPlayStorePackage, arc::kPlayStoreActivity, - {arc::kInitialStartParam}); -} - void GetAndroidIdBlocking(bool* out_ok, int64_t* out_android_id) { base::RunLoop run_loop; arc::GetAndroidId(base::BindOnce( @@ -46,52 +32,6 @@ void GetAndroidIdBlocking(bool* out_ok, int64_t* out_android_id) { using ArcAppUtilsTest = testing::Test; -TEST_F(ArcAppUtilsTest, LaunchIntent) { - const std::string launch_intent = GetPlayStoreInitialLaunchIntent(); - - arc::Intent intent1; - EXPECT_TRUE(arc::ParseIntent(launch_intent, &intent1)); - EXPECT_EQ(intent1.action(), "android.intent.action.MAIN"); - EXPECT_EQ(intent1.category(), "android.intent.category.LAUNCHER"); - EXPECT_EQ(intent1.package_name(), arc::kPlayStorePackage); - EXPECT_EQ(intent1.activity(), arc::kPlayStoreActivity); - EXPECT_EQ(intent1.launch_flags(), - arc::Intent::FLAG_ACTIVITY_NEW_TASK | - arc::Intent::FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); - ASSERT_EQ(intent1.extra_params().size(), 1U); - EXPECT_TRUE(intent1.HasExtraParam(arc::kInitialStartParam)); - - arc::Intent intent2; - EXPECT_TRUE(arc::ParseIntent(kIntentWithShelfGroupId, &intent2)); - EXPECT_EQ(intent2.action(), ""); - EXPECT_EQ(intent2.category(), ""); - EXPECT_EQ(intent2.package_name(), kTestPackage); - EXPECT_EQ(intent2.activity(), kTestActivity); - EXPECT_EQ(intent2.launch_flags(), - arc::Intent::FLAG_ACTIVITY_NEW_TASK | - arc::Intent::FLAG_RECEIVER_NO_ABORT | - arc::Intent::FLAG_ACTIVITY_LAUNCH_ADJACENT); - ASSERT_EQ(intent2.extra_params().size(), 1U); - EXPECT_TRUE(intent2.HasExtraParam( - "S.org.chromium.arc.shelf_group_id=some_shelf_group")); -} - -TEST_F(ArcAppUtilsTest, ShelfGroupId) { - const std::string intent_with_shelf_group_id(kIntentWithShelfGroupId); - const std::string shelf_app_id = - ArcAppListPrefs::GetAppId(kTestPackage, kTestActivity); - arc::ArcAppShelfId shelf_id1 = arc::ArcAppShelfId::FromIntentAndAppId( - intent_with_shelf_group_id, shelf_app_id); - EXPECT_TRUE(shelf_id1.has_shelf_group_id()); - EXPECT_EQ(shelf_id1.shelf_group_id(), kTestShelfGroupId); - EXPECT_EQ(shelf_id1.app_id(), shelf_app_id); - - arc::ArcAppShelfId shelf_id2 = arc::ArcAppShelfId::FromIntentAndAppId( - GetPlayStoreInitialLaunchIntent(), arc::kPlayStoreAppId); - EXPECT_FALSE(shelf_id2.has_shelf_group_id()); - EXPECT_EQ(shelf_id2.app_id(), arc::kPlayStoreAppId); -} - // Tests that IsArcItem does not crash or DCHECK with invalid crx file ids. TEST_F(ArcAppUtilsTest, IsArcItemDoesNotCrashWithInvalidCrxFileIds) { // TestingProfile checks CurrentlyOn(cotnent::BrowserThread::UI). diff --git a/chrome/browser/ui/app_list/arc/intent.cc b/chrome/browser/ui/app_list/arc/intent.cc new file mode 100644 index 00000000000000..b2ec4766d6a332 --- /dev/null +++ b/chrome/browser/ui/app_list/arc/intent.cc @@ -0,0 +1,168 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/app_list/arc/intent.h" + +#include + +#include "base/containers/contains.h" +#include "base/logging.h" +#include "base/memory/ptr_util.h" +#include "base/strings/string_number_conversions.h" +#include "base/strings/string_split.h" +#include "base/strings/string_util.h" +#include "base/strings/stringprintf.h" +#include "base/time/time.h" + +namespace arc { + +namespace { +constexpr char kActionMain[] = "android.intent.action.MAIN"; +} + +constexpr char kInitialStartParam[] = "initialStart"; +constexpr char kCategoryLauncher[] = "android.intent.category.LAUNCHER"; +constexpr char kRequestStartTimeParamKey[] = "S.org.chromium.arc.request.start"; +constexpr char kRequestDeferredStartTimeParamKey[] = + "S.org.chromium.arc.request.deferred.start"; +// Intent labels, kept in sorted order. +constexpr char kAction[] = "action"; +constexpr char kCategory[] = "category"; +constexpr char kComponent[] = "component"; +constexpr char kEndSuffix[] = "end"; +constexpr char kIntentPrefix[] = "#Intent"; +constexpr char kLaunchFlags[] = "launchFlags"; + +Intent::Intent() = default; +Intent::~Intent() = default; + +// static +std::unique_ptr Intent::Get(const std::string& intent_as_string) { + const std::vector parts = base::SplitStringPiece( + intent_as_string, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); + if (parts.size() < 2 || parts.front() != kIntentPrefix || + parts.back() != kEndSuffix) { + DVLOG(1) << "Failed to split intent " << intent_as_string << "."; + return nullptr; + } + + auto intent = base::WrapUnique(new Intent()); + + for (size_t i = 1; i < parts.size() - 1; ++i) { + const size_t separator = parts[i].find('='); + if (separator == std::string::npos) { + intent->AddExtraParam(std::string(parts[i])); + continue; + } + const base::StringPiece key = parts[i].substr(0, separator); + const base::StringPiece value = parts[i].substr(separator + 1); + if (key == kAction) { + intent->set_action(std::string(value)); + } else if (key == kCategory) { + intent->set_category(std::string(value)); + } else if (key == kLaunchFlags) { + uint32_t launch_flags; + const bool parsed = base::HexStringToUInt(value, &launch_flags); + if (!parsed) { + DVLOG(1) << "Failed to parse launchFlags: " << value << "."; + return nullptr; + } + intent->set_launch_flags(launch_flags); + } else if (key == kComponent) { + const size_t component_separator = value.find('/'); + if (component_separator == std::string::npos) + return nullptr; + intent->set_package_name( + std::string(value.substr(0, component_separator))); + const base::StringPiece activity_compact_name = + value.substr(component_separator + 1); + if (!activity_compact_name.empty() && activity_compact_name[0] == '.') { + std::string activity(value.substr(0, component_separator)); + activity += std::string(activity_compact_name); + intent->set_activity(activity); + } else { + intent->set_activity(std::string(activity_compact_name)); + } + } else { + intent->AddExtraParam(std::string(parts[i])); + } + } + + return intent; +} + +void Intent::AddExtraParam(const std::string& extra_param) { + extra_params_.push_back(extra_param); +} + +bool Intent::HasExtraParam(const std::string& extra_param) const { + return base::Contains(extra_params_, extra_param); +} + +bool Intent::GetExtraParamValue(const std::string& extra_param_key, + std::string* out) const { + const std::string find_key = extra_param_key + "="; + for (const auto& extra_param : extra_params()) { + if (!extra_param.find(find_key)) { + *out = extra_param.substr(find_key.length()); + return true; + } + } + return false; +} + +std::string GetLaunchIntent(const std::string& package_name, + const std::string& activity, + const std::vector& extra_params) { + const std::string extra_params_extracted = + base::JoinString(extra_params, ";") + ';'; + + // Remove the |package_name| prefix, if activity starts with it. + const char* activity_compact_name = + activity.find(package_name.c_str()) == 0 + ? activity.c_str() + package_name.length() + : activity.c_str(); + + // Construct a string in format: + // #Intent;action=android.intent.action.MAIN; + // category=android.intent.category.LAUNCHER; + // launchFlags=0x10210000; + // component=package_name/activity; + // param1;param2;end + return base::StringPrintf( + "%s;%s=%s;%s=%s;%s=0x%x;%s=%s/%s;%s%s", kIntentPrefix, kAction, + kActionMain, kCategory, kCategoryLauncher, kLaunchFlags, + Intent::FLAG_ACTIVITY_NEW_TASK | + Intent::FLAG_ACTIVITY_RESET_TASK_IF_NEEDED, + kComponent, package_name.c_str(), activity_compact_name, + extra_params_extracted.c_str(), kEndSuffix); +} + +std::string AppendLaunchIntent(const std::string& launch_intent, + const std::vector& extra_params) { + size_t insert_point = launch_intent.rfind(';'); + if (insert_point == std::string::npos) { + LOG(ERROR) << "Failed to append invalid intent " << launch_intent; + return launch_intent; + } + ++insert_point; + + const std::string end = launch_intent.substr(insert_point); + if (end != kEndSuffix) { + LOG(ERROR) << "Failed to append invalid intent " << launch_intent; + return launch_intent; + } + + const std::string extra_params_extracted = + base::JoinString(extra_params, ";") + ';'; + return launch_intent.substr(0, insert_point) + extra_params_extracted + end; +} + +std::string CreateIntentTicksExtraParam(const std::string& param_key, + const base::TimeTicks& ticks) { + return base::StringPrintf("%s=%" PRId64, param_key.c_str(), + (ticks - base::TimeTicks()).InMilliseconds()); +} + +} // namespace arc diff --git a/chrome/browser/ui/app_list/arc/intent.h b/chrome/browser/ui/app_list/arc/intent.h new file mode 100644 index 00000000000000..dcaf676f4e4fe2 --- /dev/null +++ b/chrome/browser/ui/app_list/arc/intent.h @@ -0,0 +1,107 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_APP_LIST_ARC_INTENT_H_ +#define CHROME_BROWSER_UI_APP_LIST_ARC_INTENT_H_ + +#include + +#include +#include + +namespace base { +class TimeTicks; +} + +namespace arc { + +extern const char kInitialStartParam[]; +extern const char kRequestStartTimeParamKey[]; +extern const char kRequestDeferredStartTimeParamKey[]; + +extern const char kAction[]; +extern const char kCategory[]; +extern const char kComponent[]; +extern const char kEndSuffix[]; +extern const char kIntentPrefix[]; +extern const char kLaunchFlags[]; +extern const char kCategoryLauncher[]; + +// Represents parsed intent. +class Intent { + public: + Intent(const Intent&) = delete; + Intent& operator=(const Intent&) = delete; + + ~Intent(); + + enum LaunchFlags : uint32_t { + FLAG_ACTIVITY_NEW_TASK = 0x10000000, + FLAG_RECEIVER_NO_ABORT = 0x08000000, + FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000, + FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000, + }; + + // Parses provided |intent_as_string|. Returns nullptr if |intent_as_string| + // cannot be parsed. + static std::unique_ptr Get(const std::string& intent_as_string); + + void AddExtraParam(const std::string& extra_param); + bool HasExtraParam(const std::string& extra_param) const; + + // Extra param mighgt be key=value pair. Enumetates |extra_params_| and finds + // one that starts with requested |extra_param_key|. If found value is stored + // in |out| and true is returned. + bool GetExtraParamValue(const std::string& extra_param_key, + std::string* out) const; + + const std::string& action() const { return action_; } + void set_action(const std::string& action) { action_ = action; } + + const std::string& category() const { return category_; } + void set_category(const std::string& category) { category_ = category; } + + const std::string& package_name() const { return package_name_; } + void set_package_name(const std::string& package_name) { + package_name_ = package_name; + } + + const std::string& activity() const { return activity_; } + void set_activity(const std::string& activity) { activity_ = activity; } + + uint32_t launch_flags() const { return launch_flags_; } + void set_launch_flags(uint32_t launch_flags) { launch_flags_ = launch_flags; } + + const std::vector& extra_params() const { return extra_params_; } + + private: + Intent(); + + std::string action_; // Extracted from action. + std::string category_; // Extracted from category. + std::string package_name_; // Extracted from component. + std::string activity_; // Extracted from component. + uint32_t launch_flags_ = 0; // Extracted from launchFlags; + std::vector extra_params_; // Other parameters not listed above. +}; + +// Returns intent that can be used to launch an activity specified by +// |package_name| and |activity|. |extra_params| is the list of optional +// parameters encoded to intent. +std::string GetLaunchIntent(const std::string& package_name, + const std::string& activity, + const std::vector& extra_params); + +// This takes existing |launch_intent| and appends it with |extra_params|. +std::string AppendLaunchIntent(const std::string& launch_intent, + const std::vector& extra_params); + +// Helper function that creates pair key=value where value represents |ticks|. +// |ticks| is converted to ms. +std::string CreateIntentTicksExtraParam(const std::string& param_key, + const base::TimeTicks& ticks); + +} // namespace arc + +#endif // CHROME_BROWSER_UI_APP_LIST_ARC_INTENT_H_ diff --git a/chrome/browser/ui/app_list/arc/intent_unittest.cc b/chrome/browser/ui/app_list/arc/intent_unittest.cc new file mode 100644 index 00000000000000..930c89ae287316 --- /dev/null +++ b/chrome/browser/ui/app_list/arc/intent_unittest.cc @@ -0,0 +1,115 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include + +#include "chrome/browser/ui/app_list/arc/arc_app_utils.h" +#include "chrome/browser/ui/app_list/arc/intent.h" +#include "chrome/browser/ui/ash/shelf/arc_app_shelf_id.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace arc { + +namespace { + +constexpr char kTestPackage[] = "com.test.app"; +constexpr char kTestActivity[] = "com.test.app.some.activity"; +constexpr char kTestShelfGroupId[] = "some_shelf_group"; +constexpr char kIntentWithShelfGroupId[] = + "#Intent;launchFlags=0x18001000;" + "component=com.test.app/com.test.app.some.activity;" + "S.org.chromium.arc.shelf_group_id=some_shelf_group;end"; + +std::string GetPlayStoreInitialLaunchIntent() { + return GetLaunchIntent(kPlayStorePackage, kPlayStoreActivity, + {kInitialStartParam}); +} + +} // namespace + +using ArcIntentTest = testing::Test; + +TEST_F(ArcIntentTest, LaunchIntent) { + const std::string launch_intent = GetPlayStoreInitialLaunchIntent(); + + auto intent1 = Intent::Get(launch_intent); + ASSERT_TRUE(intent1); + EXPECT_EQ(intent1->action(), "android.intent.action.MAIN"); + EXPECT_EQ(intent1->category(), "android.intent.category.LAUNCHER"); + EXPECT_EQ(intent1->package_name(), kPlayStorePackage); + EXPECT_EQ(intent1->activity(), kPlayStoreActivity); + EXPECT_EQ(intent1->launch_flags(), + Intent::FLAG_ACTIVITY_NEW_TASK | + Intent::FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); + ASSERT_EQ(intent1->extra_params().size(), 1U); + EXPECT_TRUE(intent1->HasExtraParam(kInitialStartParam)); + + auto intent2 = Intent::Get(kIntentWithShelfGroupId); + ASSERT_TRUE(intent2); + EXPECT_EQ(intent2->action(), ""); + EXPECT_EQ(intent2->category(), ""); + EXPECT_EQ(intent2->package_name(), kTestPackage); + EXPECT_EQ(intent2->activity(), kTestActivity); + EXPECT_EQ(intent2->launch_flags(), Intent::FLAG_ACTIVITY_NEW_TASK | + Intent::FLAG_RECEIVER_NO_ABORT | + Intent::FLAG_ACTIVITY_LAUNCH_ADJACENT); + ASSERT_EQ(intent2->extra_params().size(), 1U); + EXPECT_TRUE(intent2->HasExtraParam( + "S.org.chromium.arc.shelf_group_id=some_shelf_group")); +} + +TEST_F(ArcIntentTest, AppendLaunchIntent) { + const std::string param1 = + CreateIntentTicksExtraParam(kRequestDeferredStartTimeParamKey, + base::TimeTicks() + base::Milliseconds(100)); + const std::string param2 = CreateIntentTicksExtraParam( + kRequestStartTimeParamKey, base::TimeTicks() + base::Milliseconds(200)); + const std::string launch_intent = + AppendLaunchIntent(GetPlayStoreInitialLaunchIntent(), {param1, param2}); + + auto intent = Intent::Get(launch_intent); + ASSERT_TRUE(intent); + EXPECT_EQ(intent->action(), "android.intent.action.MAIN"); + EXPECT_EQ(intent->category(), "android.intent.category.LAUNCHER"); + EXPECT_EQ(intent->package_name(), kPlayStorePackage); + EXPECT_EQ(intent->activity(), kPlayStoreActivity); + EXPECT_EQ(intent->launch_flags(), + Intent::FLAG_ACTIVITY_NEW_TASK | + Intent::FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); + ASSERT_EQ(intent->extra_params().size(), 3U); + EXPECT_TRUE(intent->HasExtraParam(kInitialStartParam)); + std::string deferred_time; + EXPECT_TRUE(intent->GetExtraParamValue(kRequestDeferredStartTimeParamKey, + &deferred_time)); + EXPECT_EQ("100", deferred_time); + std::string start_time; + EXPECT_TRUE( + intent->GetExtraParamValue(kRequestStartTimeParamKey, &start_time)); + EXPECT_EQ("200", start_time); +} + +TEST_F(ArcIntentTest, CreateIntentTicksExtraParam) { + EXPECT_EQ("S.org.chromium.arc.request.deferred.start=12345", + CreateIntentTicksExtraParam( + "S.org.chromium.arc.request.deferred.start", + base::TimeTicks() + base::Milliseconds(12345))); +} + +TEST_F(ArcIntentTest, ShelfGroupId) { + const std::string intent_with_shelf_group_id(kIntentWithShelfGroupId); + const std::string shelf_app_id = + ArcAppListPrefs::GetAppId(kTestPackage, kTestActivity); + ArcAppShelfId shelf_id1 = ArcAppShelfId::FromIntentAndAppId( + intent_with_shelf_group_id, shelf_app_id); + EXPECT_TRUE(shelf_id1.has_shelf_group_id()); + EXPECT_EQ(shelf_id1.shelf_group_id(), kTestShelfGroupId); + EXPECT_EQ(shelf_id1.app_id(), shelf_app_id); + + ArcAppShelfId shelf_id2 = ArcAppShelfId::FromIntentAndAppId( + GetPlayStoreInitialLaunchIntent(), kPlayStoreAppId); + EXPECT_FALSE(shelf_id2.has_shelf_group_id()); + EXPECT_EQ(shelf_id2.app_id(), kPlayStoreAppId); +} + +} // namespace arc diff --git a/chrome/browser/ui/ash/assistant/assistant_test_mixin.cc b/chrome/browser/ui/ash/assistant/assistant_test_mixin.cc index de06155fdabe2e..dbe8ce279126bc 100644 --- a/chrome/browser/ui/ash/assistant/assistant_test_mixin.cc +++ b/chrome/browser/ui/ash/assistant/assistant_test_mixin.cc @@ -11,6 +11,7 @@ #include "ash/assistant/model/ui/assistant_card_element.h" #include "ash/assistant/ui/assistant_ui_constants.h" #include "ash/assistant/ui/main_stage/assistant_ui_element_view.h" +#include "ash/components/login/auth/user_context.h" #include "ash/constants/ash_switches.h" #include "ash/public/cpp/assistant/assistant_state.h" #include "ash/public/cpp/test/assistant_test_api.h" @@ -24,7 +25,6 @@ #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/ash/assistant/test_support/fake_s3_server.h" #include "chrome/test/base/mixin_based_in_process_browser_test.h" -#include "chromeos/login/auth/user_context.h" #include "components/account_id/account_id.h" #include "components/language/core/browser/pref_names.h" #include "google_apis/gaia/gaia_urls.h" diff --git a/chrome/browser/ui/ash/assistant/device_actions.cc b/chrome/browser/ui/ash/assistant/device_actions.cc index c1d4add9bd89b7..bf0d1f4e9467c8 100644 --- a/chrome/browser/ui/ash/assistant/device_actions.cc +++ b/chrome/browser/ui/ash/assistant/device_actions.cc @@ -20,6 +20,7 @@ #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" +#include "chrome/browser/ui/app_list/arc/intent.h" #include "chromeos/dbus/power/power_manager_client.h" #include "chromeos/dbus/power_manager/backlight.pb.h" #include "chromeos/network/network_event_log.h" diff --git a/chrome/browser/ui/ash/in_session_auth_dialog_client.h b/chrome/browser/ui/ash/in_session_auth_dialog_client.h index 8115e14fd13082..512023c542cb9e 100644 --- a/chrome/browser/ui/ash/in_session_auth_dialog_client.h +++ b/chrome/browser/ui/ash/in_session_auth_dialog_client.h @@ -5,13 +5,13 @@ #ifndef CHROME_BROWSER_UI_ASH_IN_SESSION_AUTH_DIALOG_CLIENT_H_ #define CHROME_BROWSER_UI_ASH_IN_SESSION_AUTH_DIALOG_CLIENT_H_ +#include "ash/components/login/auth/auth_status_consumer.h" +#include "ash/components/login/auth/extended_authenticator.h" +#include "ash/components/login/auth/user_context.h" #include "ash/public/cpp/in_session_auth_dialog_client.h" #include "base/callback.h" #include "base/memory/scoped_refptr.h" #include "base/memory/weak_ptr.h" -#include "chromeos/login/auth/auth_status_consumer.h" -#include "chromeos/login/auth/extended_authenticator.h" -#include "chromeos/login/auth/user_context.h" #include "third_party/abseil-cpp/absl/types/optional.h" namespace aura { diff --git a/chrome/browser/ui/ash/in_session_auth_dialog_client_unittest.cc b/chrome/browser/ui/ash/in_session_auth_dialog_client_unittest.cc index 787ef9b0ac92d2..2f9d7783652d5b 100644 --- a/chrome/browser/ui/ash/in_session_auth_dialog_client_unittest.cc +++ b/chrome/browser/ui/ash/in_session_auth_dialog_client_unittest.cc @@ -4,6 +4,7 @@ #include "chrome/browser/ui/ash/in_session_auth_dialog_client.h" +#include "ash/components/login/auth/fake_extended_authenticator.h" #include "ash/public/cpp/in_session_auth_dialog_client.h" #include "ash/public/cpp/in_session_auth_dialog_controller.h" #include "base/callback.h" @@ -12,7 +13,6 @@ #include "base/test/bind.h" #include "chrome/browser/ash/login/users/fake_chrome_user_manager.h" #include "chrome/browser/ash/profiles/profile_helper.h" -#include "chromeos/login/auth/fake_extended_authenticator.h" #include "components/account_id/account_id.h" #include "components/user_manager/scoped_user_manager.h" #include "content/public/test/browser_task_environment.h" diff --git a/chrome/browser/ui/ash/projector/projector_app_client_impl.cc b/chrome/browser/ui/ash/projector/projector_app_client_impl.cc index 737a4316ad35be..31bf81bccfb0a3 100644 --- a/chrome/browser/ui/ash/projector/projector_app_client_impl.cc +++ b/chrome/browser/ui/ash/projector/projector_app_client_impl.cc @@ -96,9 +96,9 @@ ProjectorAppClientImpl::GetUrlLoaderFactory() { } void ProjectorAppClientImpl::OnNewScreencastPreconditionChanged( - bool can_start) { + const ash::NewScreencastPrecondition& precondition) { for (auto& observer : observers_) - observer.OnNewScreencastPreconditionChanged(can_start); + observer.OnNewScreencastPreconditionChanged(precondition); } const std::set& diff --git a/chrome/browser/ui/ash/projector/projector_app_client_impl.h b/chrome/browser/ui/ash/projector/projector_app_client_impl.h index 794db215499050..a5930c7a282cc3 100644 --- a/chrome/browser/ui/ash/projector/projector_app_client_impl.h +++ b/chrome/browser/ui/ash/projector/projector_app_client_impl.h @@ -39,7 +39,8 @@ class ProjectorAppClientImpl : public ash::ProjectorAppClient { void RemoveObserver(Observer* observer) override; signin::IdentityManager* GetIdentityManager() override; network::mojom::URLLoaderFactory* GetUrlLoaderFactory() override; - void OnNewScreencastPreconditionChanged(bool can_start) override; + void OnNewScreencastPreconditionChanged( + const ash::NewScreencastPrecondition& precondition) override; const std::set& GetPendingScreencasts() const override; bool ShouldDownloadSoda() override; diff --git a/chrome/browser/ui/ash/projector/projector_client_impl.cc b/chrome/browser/ui/ash/projector/projector_client_impl.cc index 33507470f28842..fd63d6164e4ba0 100644 --- a/chrome/browser/ui/ash/projector/projector_client_impl.cc +++ b/chrome/browser/ui/ash/projector/projector_client_impl.cc @@ -169,6 +169,7 @@ void ProjectorClientImpl::MinimizeProjectorApp() const { } void ProjectorClientImpl::OnNewScreencastPreconditionChanged( - bool can_start) const { - ash::ProjectorAppClient::Get()->OnNewScreencastPreconditionChanged(can_start); + const ash::NewScreencastPrecondition& precondition) const { + ash::ProjectorAppClient::Get()->OnNewScreencastPreconditionChanged( + precondition); } diff --git a/chrome/browser/ui/ash/projector/projector_client_impl.h b/chrome/browser/ui/ash/projector/projector_client_impl.h index c2fe2c9eaad4a1..b6009d49013fa4 100644 --- a/chrome/browser/ui/ash/projector/projector_client_impl.h +++ b/chrome/browser/ui/ash/projector/projector_client_impl.h @@ -48,7 +48,8 @@ class ProjectorClientImpl : public ash::ProjectorClient, bool IsDriveFsMounted() const override; void OpenProjectorApp() const override; void MinimizeProjectorApp() const override; - void OnNewScreencastPreconditionChanged(bool can_start) const override; + void OnNewScreencastPreconditionChanged( + const ash::NewScreencastPrecondition& precondition) const override; // SpeechRecognizerDelegate: void OnSpeechResult( diff --git a/chrome/browser/ui/ash/shelf/app_service/app_service_app_window_arc_tracker.cc b/chrome/browser/ui/ash/shelf/app_service/app_service_app_window_arc_tracker.cc index 5b760fcf0d3007..0af43a6e01b117 100644 --- a/chrome/browser/ui/ash/shelf/app_service/app_service_app_window_arc_tracker.cc +++ b/chrome/browser/ui/ash/shelf/app_service/app_service_app_window_arc_tracker.cc @@ -12,6 +12,7 @@ #include "ash/public/cpp/window_properties.h" #include "base/containers/contains.h" #include "base/feature_list.h" +#include "base/strings/string_number_conversions.h" #include "base/task/post_task.h" #include "base/task/thread_pool.h" #include "base/time/time.h" @@ -25,6 +26,7 @@ #include "chrome/browser/ash/arc/session/arc_session_manager.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" +#include "chrome/browser/ui/app_list/arc/intent.h" #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_helper.h" #include "chrome/browser/ui/ash/shelf/app_service/app_service_app_window_shelf_controller.h" #include "chrome/browser/ui/ash/shelf/app_service/app_service_app_window_shelf_item_controller.h" @@ -46,6 +48,53 @@ constexpr char kArcPaymentAppPackage[] = "org.chromium.arc.payment_app"; constexpr char kArcPaymentAppInvokePaymentAppActivity[] = "org.chromium.arc.payment_app.InvokePaymentAppActivity"; +// Calculates time delta from the current time and reference time encoded into +// |intent| and defined by |param_key|. Returns false if could not be parsed or +// not found. Result is returned in |out|. +bool GetTimeDeltaFromIntent(const arc::Intent& intent, + const std::string& param_key, + base::TimeDelta* out) { + std::string time_ms_string; + if (!intent.GetExtraParamValue(param_key, &time_ms_string)) + return false; + + int64_t time_ms; + if (!base::StringToInt64(time_ms_string, &time_ms)) { + LOG(ERROR) << "Failed to parse start time value " << time_ms_string; + return false; + } + + *out = (base::TimeTicks::Now() - base::TimeTicks()) - + base::Milliseconds(time_ms); + DCHECK_GE(*out, base::TimeDelta()); + return true; +} + +void HandlePlayStoreLaunch(const arc::Intent& intent) { + // Don't track initial Play Store launch. We currently shows Play Store in + // very rare case in-session provisioning. + if (intent.HasExtraParam(arc::kInitialStartParam)) + return; + + base::TimeDelta launch_time; + // This param is injected by |arc:: LaunchAppWithIntent|. + if (!GetTimeDeltaFromIntent(intent, arc::kRequestStartTimeParamKey, + &launch_time)) { + return; + } + arc::UpdatePlayStoreLaunchTime(launch_time); +} + +void MaybeHandleDeferredLaunch(const arc::Intent& intent) { + base::TimeDelta launch_time; + // This param is injected by |arc:: LaunchAppWithIntent|. + if (!GetTimeDeltaFromIntent(intent, arc::kRequestDeferredStartTimeParamKey, + &launch_time)) { + return; + } + arc::UpdateDeferredLaunchTime(launch_time); +} + } // namespace AppServiceAppWindowArcTracker::AppServiceAppWindowArcTracker( @@ -408,8 +457,18 @@ void AppServiceAppWindowArcTracker::AttachControllerToWindow( window->SetProperty(ash::kAppIDKey, shelf_id.app_id); window->SetProperty(aura::client::kSkipImeProcessing, true); + if (info->launch_intent().empty()) + return; + + auto intent = arc::Intent::Get(info->launch_intent()); + if (!intent) { + LOG(ERROR) << "Failed to parse launch intent: " << info->launch_intent(); + return; + } + if (info->app_shelf_id().app_id() == arc::kPlayStoreAppId) - HandlePlayStoreLaunch(info); + HandlePlayStoreLaunch(*intent); + MaybeHandleDeferredLaunch(*intent); } void AppServiceAppWindowArcTracker::AddCandidateWindow(aura::Window* window) { @@ -508,16 +567,6 @@ void AppServiceAppWindowArcTracker::AttachControllerToSession(int session_id) { app_shelf_group_to_controller_map_[app_shelf_id] = item_controller; } -void AppServiceAppWindowArcTracker::OnArcOptInManagementCheckStarted() { - // In case of retry this time is updated and we measure only successful run. - opt_in_management_check_start_time_ = base::Time::Now(); -} - -void AppServiceAppWindowArcTracker::OnArcSessionStopped( - arc::ArcStopReason stop_reason) { - opt_in_management_check_start_time_ = base::Time(); -} - void AppServiceAppWindowArcTracker::OnArcPlayStoreEnabledChanged(bool enabled) { if (enabled) return; @@ -533,37 +582,6 @@ void AppServiceAppWindowArcTracker::OnArcPlayStoreEnabledChanged(bool enabled) { DCHECK(session_id_to_arc_app_window_info_.empty()); } -void AppServiceAppWindowArcTracker::HandlePlayStoreLaunch( - ArcAppWindowInfo* app_window_info) { - arc::Intent intent; - if (!arc::ParseIntent(app_window_info->launch_intent(), &intent)) - return; - - if (!opt_in_management_check_start_time_.is_null()) { - if (intent.HasExtraParam(arc::kInitialStartParam)) { - DCHECK(!arc::IsRobotOrOfflineDemoAccountMode()); - arc::UpdatePlayStoreShownTimeDeprecated( - base::Time::Now() - opt_in_management_check_start_time_, - app_service_controller_->owner()->profile()); - VLOG(1) << "Play Store is initially shown."; - } - opt_in_management_check_start_time_ = base::Time(); - return; - } - - for (const auto& param : intent.extra_params()) { - int64_t start_request_ms; - if (sscanf(param.c_str(), arc::kRequestStartTimeParamTemplate, - &start_request_ms) != 1) - continue; - const base::TimeDelta launch_time = base::TimeTicks::Now() - - base::TimeTicks() - - base::Milliseconds(start_request_ms); - DCHECK_GE(launch_time, base::TimeDelta()); - arc::UpdatePlayStoreLaunchTime(launch_time); - } -} - int AppServiceAppWindowArcTracker::GetTaskIdSharingLogicalWindow(int task_id) { auto fixed_it = task_id_to_arc_app_window_info_.find(task_id); if (fixed_it == task_id_to_arc_app_window_info_.end()) diff --git a/chrome/browser/ui/ash/shelf/app_service/app_service_app_window_arc_tracker.h b/chrome/browser/ui/ash/shelf/app_service/app_service_app_window_arc_tracker.h index 048b394131976e..ee9872ed553bbb 100644 --- a/chrome/browser/ui/ash/shelf/app_service/app_service_app_window_arc_tracker.h +++ b/chrome/browser/ui/ash/shelf/app_service/app_service_app_window_arc_tracker.h @@ -28,10 +28,6 @@ namespace aura { class window; } -namespace base { -class Time; -} - namespace gfx { class ImageSkia; } @@ -120,12 +116,8 @@ class AppServiceAppWindowArcTracker : public ArcAppListPrefs::Observer, void AttachControllerToSession(int session_id); // arc::ArcSessionManagerObserver: - void OnArcOptInManagementCheckStarted() override; - void OnArcSessionStopped(arc::ArcStopReason stop_reason) override; void OnArcPlayStoreEnabledChanged(bool enabled) override; - void HandlePlayStoreLaunch(ArcAppWindowInfo* app_window_info); - // Returns a task ID different from |task_id| that is part of the same // logical window. Return arc::kNoTaskId if there is no such window. // For consistency, always return the lowest such task ID. @@ -165,12 +157,6 @@ class AppServiceAppWindowArcTracker : public ArcAppListPrefs::Observer, int active_task_id_ = arc::kNoTaskId; int active_session_id_ = arc::kNoTaskId; - // The time when the ARC OptIn management check was started. This happens - // right after user agrees the ToS or in some cases for managed user when ARC - // starts for the first time. OptIn management check is preceding step before - // ARC container is actually started. - base::Time opt_in_management_check_start_time_; - base::WeakPtrFactory weak_ptr_factory_{this}; }; diff --git a/chrome/browser/ui/ash/shelf/arc_app_shelf_id.cc b/chrome/browser/ui/ash/shelf/arc_app_shelf_id.cc index 92e224ea6ec5b4..3e616d776b19fe 100644 --- a/chrome/browser/ui/ash/shelf/arc_app_shelf_id.cc +++ b/chrome/browser/ui/ash/shelf/arc_app_shelf_id.cc @@ -7,7 +7,7 @@ #include "base/strings/string_split.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" -#include "chrome/browser/ui/app_list/arc/arc_app_utils.h" +#include "chrome/browser/ui/app_list/arc/intent.h" #include "components/crx_file/id_util.h" namespace arc { @@ -52,12 +52,12 @@ ArcAppShelfId ArcAppShelfId::FromIntentAndAppId(const std::string& intent, if (intent.empty()) return ArcAppShelfId(std::string(), app_id); - Intent parsed_intent; - if (!ParseIntent(intent, &parsed_intent)) + auto parsed_intent = Intent::Get(intent); + if (!parsed_intent) return ArcAppShelfId(std::string(), app_id); const std::string prefix(kShelfGroupIntentPrefix); - for (const auto& param : parsed_intent.extra_params()) { + for (const auto& param : parsed_intent->extra_params()) { if (base::StartsWith(param, prefix, base::CompareCase::SENSITIVE)) return ArcAppShelfId(param.substr(prefix.length()), app_id); } diff --git a/chrome/browser/ui/ash/shelf/arc_app_window_info.cc b/chrome/browser/ui/ash/shelf/arc_app_window_info.cc index 33c8bb0dfde4ef..a1fdd62b6d283e 100644 --- a/chrome/browser/ui/ash/shelf/arc_app_window_info.cc +++ b/chrome/browser/ui/ash/shelf/arc_app_window_info.cc @@ -6,6 +6,7 @@ #include "ash/public/cpp/window_properties.h" #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" +#include "chrome/browser/ui/app_list/arc/intent.h" namespace { @@ -16,11 +17,11 @@ constexpr char kLogicalWindowIntentPrefix[] = "S.org.chromium.arc.logical_window_id="; std::string GetLogicalWindowIdFromIntent(const std::string& launch_intent) { - arc::Intent intent; - if (!arc::ParseIntent(launch_intent, &intent)) + auto intent = arc::Intent::Get(launch_intent); + if (!intent) return std::string(); const std::string prefix(kLogicalWindowIntentPrefix); - for (const auto& param : intent.extra_params()) { + for (const auto& param : intent->extra_params()) { if (base::StartsWith(param, prefix, base::CompareCase::SENSITIVE)) return param.substr(prefix.length()); } diff --git a/chrome/browser/ui/ash/shelf/arc_shelf_spinner_item_controller.cc b/chrome/browser/ui/ash/shelf/arc_shelf_spinner_item_controller.cc index a49419fe7836b2..134355be3358e2 100644 --- a/chrome/browser/ui/ash/shelf/arc_shelf_spinner_item_controller.cc +++ b/chrome/browser/ui/ash/shelf/arc_shelf_spinner_item_controller.cc @@ -21,6 +21,7 @@ ArcShelfSpinnerItemController::ArcShelfSpinnerItemController( : ShelfSpinnerItemController(arc_app_id), event_flags_(event_flags), user_interaction_type_(user_interaction_type), + request_time_(base::TimeTicks::Now()), window_info_(std::move(window_info)) { arc::ArcSessionManager* arc_session_manager = arc::ArcSessionManager::Get(); // arc::ArcSessionManager might not be set in tests. @@ -87,8 +88,21 @@ void ArcShelfSpinnerItemController::OnAppStatesChanged( return; // Close() destroys this object, so start launching the app first. - arc::LaunchApp(observed_profile_, arc_app_id, event_flags_, - user_interaction_type_, std::move(window_info_)); + + // Embed deferred time only for app launches. Don't modify shortcuts. + // Shortcuts do not have activity so they are not compatible. + if (!app_info.shortcut) { + const std::string launch_intent = arc::GetLaunchIntent( + app_info.package_name, app_info.activity, + {arc::CreateIntentTicksExtraParam( + arc::kRequestDeferredStartTimeParamKey, request_time_)}); + arc::LaunchAppWithIntent(observed_profile_, arc_app_id, launch_intent, + event_flags_, user_interaction_type_, + std::move(window_info_)); + } else { + arc::LaunchApp(observed_profile_, arc_app_id, event_flags_, + user_interaction_type_, std::move(window_info_)); + } Close(); } diff --git a/chrome/browser/ui/ash/shelf/arc_shelf_spinner_item_controller.h b/chrome/browser/ui/ash/shelf/arc_shelf_spinner_item_controller.h index be556efdaf815d..247e62478a80d6 100644 --- a/chrome/browser/ui/ash/shelf/arc_shelf_spinner_item_controller.h +++ b/chrome/browser/ui/ash/shelf/arc_shelf_spinner_item_controller.h @@ -16,6 +16,7 @@ #include "chrome/browser/ash/arc/session/arc_session_manager_observer.h" #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" +#include "chrome/browser/ui/app_list/arc/intent.h" #include "chrome/browser/ui/ash/shelf/shelf_spinner_item_controller.h" // ArcShelfSpinnerItemController displays the icon of the ARC app that @@ -67,6 +68,9 @@ class ArcShelfSpinnerItemController : public ShelfSpinnerItemController, // Stores how this action was initiated. const arc::UserInteractionType user_interaction_type_; + // Time when this controller item was created. + base::TimeTicks request_time_; + arc::mojom::WindowInfoPtr window_info_; // Unowned diff --git a/chrome/browser/ui/ash/shelf/chrome_shelf_controller_unittest.cc b/chrome/browser/ui/ash/shelf/chrome_shelf_controller_unittest.cc index 3f49277e259d97..9575d27b17adb2 100644 --- a/chrome/browser/ui/ash/shelf/chrome_shelf_controller_unittest.cc +++ b/chrome/browser/ui/ash/shelf/chrome_shelf_controller_unittest.cc @@ -2280,17 +2280,22 @@ TEST_F(ChromeShelfControllerWithArcTest, ArcDeferredLaunch) { EXPECT_FALSE(shelf_controller_->GetItem(shelf_id_app_3)); EXPECT_FALSE(shelf_controller_->GetItem(shelf_id_shortcut)); - ASSERT_EQ(2U, arc_test_.app_instance()->launch_requests().size()); - ASSERT_EQ(1U, arc_test_.app_instance()->launch_intents().size()); - - const arc::FakeAppInstance::Request* request1 = - arc_test_.app_instance()->launch_requests()[0].get(); - const arc::FakeAppInstance::Request* request2 = - arc_test_.app_instance()->launch_requests()[1].get(); - - EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(gmail)) || - (request1->IsForApp(gmail) && request2->IsForApp(app2))); - EXPECT_EQ(arc_test_.app_instance()->launch_intents()[0].c_str(), + EXPECT_EQ(0U, arc_test_.app_instance()->launch_requests().size()); + ASSERT_EQ(3U, arc_test_.app_instance()->launch_intents().size()); + + EXPECT_GE(arc_test_.app_instance()->launch_intents()[0].find( + "component=fake.app.1/.activity;"), + 0); + EXPECT_GE(arc_test_.app_instance()->launch_intents()[0].find( + "S.org.chromium.arc.request.deferred.start="), + 0); + EXPECT_GE(arc_test_.app_instance()->launch_intents()[1].find( + "component=fake.app.2/.activity;"), + 0); + EXPECT_GE(arc_test_.app_instance()->launch_intents()[1].find( + "S.org.chromium.arc.request.deferred.start="), + 0); + EXPECT_EQ(arc_test_.app_instance()->launch_intents()[2].c_str(), shortcut.intent_uri); } @@ -4610,6 +4615,47 @@ TEST_F(ChromeShelfControllerArcDefaultAppsTest, PlayStoreLaunchMetric) { play_store_window->Close(); } +TEST_F(ChromeShelfControllerArcDefaultAppsTest, DeferredLaunchMetric) { + extension_service_->AddExtension(arc_support_host_.get()); + arc_test_.SetUp(profile()); + + InitShelfController(); + EnablePlayStore(true); + + constexpr char kHistogramName[] = + "Arc.FirstAppLaunchDelay.TimeDeltaUntilAppLaunch"; + + // Launch Play Store in deferred mode. + arc::LaunchApp(profile(), arc::kPlayStoreAppId, ui::EF_LEFT_MOUSE_BUTTON, + arc::UserInteractionType::NOT_USER_INITIATED); + + arc::mojom::AppInfo app; + app.activity = arc::kPlayStoreActivity; + app.package_name = arc::kPlayStorePackage; + + EXPECT_FALSE(base::StatisticsRecorder::FindHistogram(kHistogramName)); + + arc_test_.app_instance()->SendRefreshAppList({app}); + + // No window attached at this time. + EXPECT_FALSE(base::StatisticsRecorder::FindHistogram(kHistogramName)); + + std::string play_store_window_id("org.chromium.arc.1"); + views::Widget* const play_store_window = + CreateArcWindow(play_store_window_id); + ASSERT_EQ(1U, arc_test_.app_instance()->launch_intents().size()); + arc_test_.app_instance()->SendTaskCreated( + 1, app, arc_test_.app_instance()->launch_intents()[0]); + + // UMA is reported since app becomes ready. + base::HistogramBase* const histogram = + base::StatisticsRecorder::FindHistogram(kHistogramName); + ASSERT_TRUE(histogram); + std::unique_ptr samples = histogram->SnapshotDelta(); + ASSERT_EQ(1, samples->TotalCount()); + play_store_window->Close(); +} + // Tests that the Play Store is not visible in AOSP image and visible in default // images. TEST_P(ChromeShelfControllerPlayStoreAvailabilityTest, Visible) { diff --git a/chrome/browser/ui/autofill/payments/card_unmask_otp_input_dialog_controller_impl.cc b/chrome/browser/ui/autofill/payments/card_unmask_otp_input_dialog_controller_impl.cc index 417148cac42f91..2a5824ed6b4e0f 100644 --- a/chrome/browser/ui/autofill/payments/card_unmask_otp_input_dialog_controller_impl.cc +++ b/chrome/browser/ui/autofill/payments/card_unmask_otp_input_dialog_controller_impl.cc @@ -47,6 +47,11 @@ void CardUnmaskOtpInputDialogControllerImpl::ShowDialog( void CardUnmaskOtpInputDialogControllerImpl::OnOtpVerificationResult( OtpUnmaskResult result) { + // This can be invoked when the dialog is not visible. In this case we do + // nothing. + if (!dialog_view_) + return; + switch (result) { case OtpUnmaskResult::kSuccess: dialog_view_->Dismiss(/*show_confirmation_before_closing=*/true, diff --git a/chrome/browser/ui/autofill/payments/card_unmask_otp_input_dialog_controller_impl.h b/chrome/browser/ui/autofill/payments/card_unmask_otp_input_dialog_controller_impl.h index 83c3e6b11d1a32..f101c92305ccaf 100644 --- a/chrome/browser/ui/autofill/payments/card_unmask_otp_input_dialog_controller_impl.h +++ b/chrome/browser/ui/autofill/payments/card_unmask_otp_input_dialog_controller_impl.h @@ -65,6 +65,8 @@ class CardUnmaskOtpInputDialogControllerImpl explicit CardUnmaskOtpInputDialogControllerImpl( content::WebContents* web_contents); + raw_ptr dialog_view_ = nullptr; + private: friend class content::WebContentsUserData< CardUnmaskOtpInputDialogControllerImpl>; @@ -79,8 +81,6 @@ class CardUnmaskOtpInputDialogControllerImpl // Weak reference to the delegate. Used to handle events of the dialog. base::WeakPtr delegate_; - raw_ptr dialog_view_ = nullptr; - // Indicates whether any temporary error has been shown on the dialog. Used // for logging. bool temporary_error_shown_ = false; diff --git a/chrome/browser/ui/autofill/payments/card_unmask_otp_input_dialog_controller_impl_unittest.cc b/chrome/browser/ui/autofill/payments/card_unmask_otp_input_dialog_controller_impl_unittest.cc index 4a77ef82641555..7ec2d61f1ac85c 100644 --- a/chrome/browser/ui/autofill/payments/card_unmask_otp_input_dialog_controller_impl_unittest.cc +++ b/chrome/browser/ui/autofill/payments/card_unmask_otp_input_dialog_controller_impl_unittest.cc @@ -6,7 +6,6 @@ #include "base/test/metrics/histogram_tester.h" #include "build/build_config.h" -#include "chrome/browser/ui/autofill/payments/card_unmask_otp_input_dialog_view.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "components/autofill/core/browser/metrics/autofill_metrics.h" @@ -18,6 +17,16 @@ namespace autofill { namespace { +class TestCardUnmaskOtpInputDialogView : public CardUnmaskOtpInputDialogView { + public: + TestCardUnmaskOtpInputDialogView() = default; + ~TestCardUnmaskOtpInputDialogView() override = default; + void ShowPendingState() override {} + void ShowInvalidState(const std::u16string& invalid_label_text) override {} + void Dismiss(bool show_confirmation_before_closing, + bool user_closed_dialog) override {} +}; + class TestCardUnmaskOtpInputDialogControllerImpl : public CardUnmaskOtpInputDialogControllerImpl { public: @@ -31,6 +40,10 @@ class TestCardUnmaskOtpInputDialogControllerImpl explicit TestCardUnmaskOtpInputDialogControllerImpl( content::WebContents* web_contents) : CardUnmaskOtpInputDialogControllerImpl(web_contents) {} + + void ShowDialog(TestCardUnmaskOtpInputDialogView* dialog_view) { + dialog_view_ = dialog_view; + } }; } // namespace @@ -55,6 +68,12 @@ class CardUnmaskOtpInputDialogControllerImplTest TestCardUnmaskOtpInputDialogControllerImpl::FromWebContents( web_contents())); } + + TestCardUnmaskOtpInputDialogView* test_dialog() { return test_dialog_.get(); } + + private: + std::unique_ptr test_dialog_ = + std::make_unique(); }; TEST_F(CardUnmaskOtpInputDialogControllerImplTest, @@ -82,6 +101,7 @@ TEST_F(CardUnmaskOtpInputDialogControllerImplTest, base::HistogramTester histogram_tester; DCHECK(controller()); + controller()->ShowDialog(test_dialog()); controller()->OnOtpVerificationResult(OtpUnmaskResult::kOtpMismatch); controller()->OnDialogClosed(/*user_closed_dialog=*/true, /*server_request_succeeded=*/false); @@ -106,6 +126,7 @@ TEST_F(CardUnmaskOtpInputDialogControllerImplTest, base::HistogramTester histogram_tester; DCHECK(controller()); + controller()->ShowDialog(test_dialog()); controller()->OnOkButtonClicked(/*otp=*/u"123456"); controller()->OnOtpVerificationResult(OtpUnmaskResult::kOtpExpired); controller()->OnDialogClosed(/*user_closed_dialog=*/true, diff --git a/chrome/browser/ui/omnibox/omnibox_pedal_implementations.cc b/chrome/browser/ui/omnibox/omnibox_pedal_implementations.cc index 3456b7bc558a6f..d2e8131c94cd77 100644 --- a/chrome/browser/ui/omnibox/omnibox_pedal_implementations.cc +++ b/chrome/browser/ui/omnibox/omnibox_pedal_implementations.cc @@ -85,7 +85,6 @@ class OmniboxPedalClearBrowsingData : public OmniboxPedal { // ============================================================================= -#if !defined(OS_ANDROID) class OmniboxPedalManagePasswords : public OmniboxPedal { public: OmniboxPedalManagePasswords() @@ -123,11 +122,9 @@ class OmniboxPedalManagePasswords : public OmniboxPedal { protected: ~OmniboxPedalManagePasswords() override = default; }; -#endif // !defined(OS_ANDROID) // ============================================================================= -#if !defined(OS_ANDROID) class OmniboxPedalUpdateCreditCard : public OmniboxPedal { public: OmniboxPedalUpdateCreditCard() @@ -166,11 +163,9 @@ class OmniboxPedalUpdateCreditCard : public OmniboxPedal { protected: ~OmniboxPedalUpdateCreditCard() override = default; }; -#endif // !defined(OS_ANDROID) // ============================================================================= -#if !defined(OS_ANDROID) class OmniboxPedalLaunchIncognito : public OmniboxPedal { public: OmniboxPedalLaunchIncognito() @@ -218,7 +213,6 @@ class OmniboxPedalLaunchIncognito : public OmniboxPedal { protected: ~OmniboxPedalLaunchIncognito() override = default; }; -#endif // !defined(OS_ANDROID) // ============================================================================= @@ -318,7 +312,6 @@ class OmniboxPedalUpdateChrome : public OmniboxPedal { // ============================================================================= -#if !defined(OS_ANDROID) class OmniboxPedalRunChromeSafetyCheck : public OmniboxPedal { public: OmniboxPedalRunChromeSafetyCheck() @@ -362,7 +355,6 @@ class OmniboxPedalRunChromeSafetyCheck : public OmniboxPedal { protected: ~OmniboxPedalRunChromeSafetyCheck() override = default; }; -#endif // !defined(OS_ANDROID) // ============================================================================= @@ -530,7 +522,6 @@ class OmniboxPedalManageSync : public OmniboxPedal { // ============================================================================= -#if !defined(OS_ANDROID) class OmniboxPedalManageSiteSettings : public OmniboxPedal { public: OmniboxPedalManageSiteSettings() @@ -564,7 +555,6 @@ class OmniboxPedalManageSiteSettings : public OmniboxPedal { protected: ~OmniboxPedalManageSiteSettings() override = default; }; -#endif // !defined(OS_ANDROID) // ============================================================================= @@ -1115,7 +1105,6 @@ class OmniboxPedalCloseIncognitoWindows : public OmniboxPedal { // ============================================================================= -#if !defined(OS_ANDROID) class OmniboxPedalPlayChromeDinoGame : public OmniboxPedal { public: OmniboxPedalPlayChromeDinoGame() @@ -1183,7 +1172,6 @@ class OmniboxPedalPlayChromeDinoGame : public OmniboxPedal { protected: ~OmniboxPedalPlayChromeDinoGame() override = default; }; -#endif // !defined(OS_ANDROID) // ============================================================================= @@ -1268,7 +1256,6 @@ class OmniboxPedalManageGooglePrivacy : public OmniboxPedalAuthRequired { // ============================================================================= -#if !defined(OS_ANDROID) class OmniboxPedalManageChromeSettings : public OmniboxPedal { public: OmniboxPedalManageChromeSettings() @@ -1300,7 +1287,6 @@ class OmniboxPedalManageChromeSettings : public OmniboxPedal { protected: ~OmniboxPedalManageChromeSettings() override = default; }; -#endif // !defined(OS_ANDROID) // ============================================================================= @@ -1340,7 +1326,6 @@ class OmniboxPedalManageChromeDownloads : public OmniboxPedal { // ============================================================================= -#if !defined(OS_ANDROID) class OmniboxPedalViewChromeHistory : public OmniboxPedal { public: OmniboxPedalViewChromeHistory() @@ -1372,7 +1357,6 @@ class OmniboxPedalViewChromeHistory : public OmniboxPedal { protected: ~OmniboxPedalViewChromeHistory() override = default; }; -#endif // !defined(OS_ANDROID) // ============================================================================= @@ -1425,7 +1409,6 @@ class OmniboxPedalShareThisPage : public OmniboxPedal { // ============================================================================= -#if !defined(OS_ANDROID) class OmniboxPedalManageChromeAccessibility : public OmniboxPedal { public: OmniboxPedalManageChromeAccessibility() @@ -1457,7 +1440,6 @@ class OmniboxPedalManageChromeAccessibility : public OmniboxPedal { protected: ~OmniboxPedalManageChromeAccessibility() override = default; }; -#endif // !defined(OS_ANDROID) // ============================================================================= @@ -1631,6 +1613,15 @@ GetPedalImplementations(bool incognito, bool testing) { #if defined(OS_ANDROID) if (OmniboxFieldTrial::IsPedalsAndroidBatch1Enabled()) { add(new OmniboxPedalClearBrowsingData(incognito)); + add(new OmniboxPedalManagePasswords()); + add(new OmniboxPedalUpdateCreditCard()); + add(new OmniboxPedalLaunchIncognito()); + add(new OmniboxPedalRunChromeSafetyCheck()); + add(new OmniboxPedalPlayChromeDinoGame()); + add(new OmniboxPedalManageSiteSettings()); + add(new OmniboxPedalManageChromeSettings()); + add(new OmniboxPedalViewChromeHistory()); + add(new OmniboxPedalManageChromeAccessibility()); } #else // defined(OS_ANDROID) diff --git a/chrome/browser/ui/passwords/credential_leak_dialog_controller.h b/chrome/browser/ui/passwords/credential_leak_dialog_controller.h index 2f7a567a2e8adb..8c4c34a9c662ed 100644 --- a/chrome/browser/ui/passwords/credential_leak_dialog_controller.h +++ b/chrome/browser/ui/passwords/credential_leak_dialog_controller.h @@ -24,6 +24,10 @@ class CredentialLeakDialogController : public PasswordBaseDialogController { // e.g. by pressing the Esc key. virtual void OnCloseDialog() = 0; + // Called when the controller and dialog should drop references to each other + // because one of the two is going away. + virtual void ResetDialog() = 0; + // Returns the label for the accept button. virtual std::u16string GetAcceptButtonLabel() const = 0; diff --git a/chrome/browser/ui/passwords/credential_leak_dialog_controller_impl.cc b/chrome/browser/ui/passwords/credential_leak_dialog_controller_impl.cc index 66ff430e51ec1e..f2dbf142df9431 100644 --- a/chrome/browser/ui/passwords/credential_leak_dialog_controller_impl.cc +++ b/chrome/browser/ui/passwords/credential_leak_dialog_controller_impl.cc @@ -63,6 +63,13 @@ void CredentialLeakDialogControllerImpl::OnCloseDialog() { delegate_->OnLeakDialogHidden(); } +void CredentialLeakDialogControllerImpl::ResetDialog() { + if (credential_leak_dialog_) { + credential_leak_dialog_->ControllerGone(); + credential_leak_dialog_ = nullptr; + } +} + std::u16string CredentialLeakDialogControllerImpl::GetAcceptButtonLabel() const { return password_manager::GetAcceptButtonLabel(leak_type_); @@ -88,10 +95,3 @@ bool CredentialLeakDialogControllerImpl::ShouldCheckPasswords() const { bool CredentialLeakDialogControllerImpl::ShouldShowCancelButton() const { return password_manager::ShouldShowCancelButton(leak_type_); } - -void CredentialLeakDialogControllerImpl::ResetDialog() { - if (credential_leak_dialog_) { - credential_leak_dialog_->ControllerGone(); - credential_leak_dialog_ = nullptr; - } -} diff --git a/chrome/browser/ui/passwords/credential_leak_dialog_controller_impl.h b/chrome/browser/ui/passwords/credential_leak_dialog_controller_impl.h index b84eb124b5499b..b7a9215411f6e5 100644 --- a/chrome/browser/ui/passwords/credential_leak_dialog_controller_impl.h +++ b/chrome/browser/ui/passwords/credential_leak_dialog_controller_impl.h @@ -36,6 +36,7 @@ class CredentialLeakDialogControllerImpl void OnCancelDialog() override; void OnAcceptDialog() override; void OnCloseDialog() override; + void ResetDialog() override; std::u16string GetAcceptButtonLabel() const override; std::u16string GetCancelButtonLabel() const override; std::u16string GetDescription() const override; @@ -44,9 +45,6 @@ class CredentialLeakDialogControllerImpl bool ShouldShowCancelButton() const override; private: - // Release |credential_leak_dialog_| and close the open dialog. - void ResetDialog(); - raw_ptr credential_leak_dialog_ = nullptr; raw_ptr delegate_; const password_manager::CredentialLeakType leak_type_; diff --git a/chrome/browser/ui/search/ntp_user_data_logger.cc b/chrome/browser/ui/search/ntp_user_data_logger.cc index 221687b263906a..66ac34aa371f33 100644 --- a/chrome/browser/ui/search/ntp_user_data_logger.cc +++ b/chrome/browser/ui/search/ntp_user_data_logger.cc @@ -10,6 +10,7 @@ #include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_macros.h" #include "base/metrics/user_metrics.h" +#include "base/trace_event/trace_event.h" #include "chrome/browser/after_startup_task_utils.h" #include "chrome/browser/search/background/ntp_custom_background_service.h" #include "chrome/browser/search/background/ntp_custom_background_service_factory.h" @@ -24,6 +25,8 @@ namespace { +constexpr char kUIEventCategory[] = "ui"; + // Logs CustomizedShortcutSettings on the NTP. void LogCustomizedShortcutSettings(bool using_most_visited, bool is_visible) { CustomizedShortcutSettings setting; @@ -276,12 +279,17 @@ bool IsImpressionFromPreinstalledApp( UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, base::Milliseconds(1), \ base::Seconds(60), 100) -NTPUserDataLogger::NTPUserDataLogger(Profile* profile, const GURL& ntp_url) - : has_emitted_(false), - should_record_doodle_load_time_(true), - during_startup_(!AfterStartupTaskUtils::IsBrowserStartupComplete()), +NTPUserDataLogger::NTPUserDataLogger(Profile* profile, + const GURL& ntp_url, + base::Time ntp_navigation_start_time) + : during_startup_(!AfterStartupTaskUtils::IsBrowserStartupComplete()), ntp_url_(ntp_url), - profile_(profile) {} + profile_(profile), + // TODO(https://crbug.com/1280310): Migrate NTP navigation startup time + // from base::Time to base::TimeTicks top avoid time glitches. + ntp_navigation_start_time_( + base::TimeTicks::UnixEpoch() + + (ntp_navigation_start_time - base::Time::UnixEpoch())) {} NTPUserDataLogger::~NTPUserDataLogger() = default; @@ -328,6 +336,8 @@ void NTPUserDataLogger::LogEvent(NTPLoggingEventType event, break; case NTP_ONE_GOOGLE_BAR_SHOWN: UMA_HISTOGRAM_LOAD_TIME("NewTabPage.OneGoogleBar.ShownTime", time); + EmitNtpTraceEvent("NewTabPage.OneGoogleBar.ShownTime", time); + break; case NTP_BACKGROUND_CUSTOMIZED: case NTP_SHORTCUT_CUSTOMIZED: @@ -372,6 +382,8 @@ void NTPUserDataLogger::LogEvent(NTPLoggingEventType event, break; case NTP_MIDDLE_SLOT_PROMO_SHOWN: UMA_HISTOGRAM_LOAD_TIME("NewTabPage.Promos.ShownTime", time); + EmitNtpTraceEvent("NewTabPage.Promos.ShownTime", time); + break; case NTP_MIDDLE_SLOT_PROMO_LINK_CLICKED: UMA_HISTOGRAM_EXACT_LINEAR("NewTabPage.Promos.LinkClicked", 1, 1); @@ -401,6 +413,7 @@ void NTPUserDataLogger::LogEvent(NTPLoggingEventType event, break; case NTP_APP_RENDERED: UMA_HISTOGRAM_LOAD_TIME("NewTabPage.MainUi.ShownTime", time); + EmitNtpTraceEvent("NewTabPage.MainUi.ShownTime", time); break; } } @@ -513,6 +526,16 @@ void NTPUserDataLogger::EmitNtpStatistics(base::TimeDelta load_time, during_startup_ = false; } +void NTPUserDataLogger::EmitNtpTraceEvent(const char* event_name, + base::TimeDelta duration) { + TRACE_EVENT_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0(kUIEventCategory, event_name, + TRACE_ID_LOCAL(this), + ntp_navigation_start_time_); + TRACE_EVENT_NESTABLE_ASYNC_END_WITH_TIMESTAMP0( + kUIEventCategory, event_name, TRACE_ID_LOCAL(this), + ntp_navigation_start_time_ + duration); +} + void NTPUserDataLogger::RecordDoodleImpression(base::TimeDelta time, bool is_cta, bool from_cache) { @@ -520,6 +543,8 @@ void NTPUserDataLogger::RecordDoodleImpression(base::TimeDelta time, is_cta ? LOGO_IMPRESSION_TYPE_CTA : LOGO_IMPRESSION_TYPE_STATIC; UMA_HISTOGRAM_ENUMERATION("NewTabPage.LogoShown", logo_type, LOGO_IMPRESSION_TYPE_MAX); + EmitNtpTraceEvent("NewTabPage.LogoShown", time); + if (from_cache) { UMA_HISTOGRAM_ENUMERATION("NewTabPage.LogoShown.FromCache", logo_type, LOGO_IMPRESSION_TYPE_MAX); diff --git a/chrome/browser/ui/search/ntp_user_data_logger.h b/chrome/browser/ui/search/ntp_user_data_logger.h index e4ef648fa0f40c..86624f94ac03bb 100644 --- a/chrome/browser/ui/search/ntp_user_data_logger.h +++ b/chrome/browser/ui/search/ntp_user_data_logger.h @@ -26,7 +26,9 @@ class NTPUserDataLogger { public: // Creates a NTPUserDataLogger. MUST be called only when the NTP is active. - NTPUserDataLogger(Profile* profile, const GURL& ntp_url); + NTPUserDataLogger(Profile* profile, + const GURL& ntp_url, + base::Time ntp_navigation_start_time); NTPUserDataLogger(const NTPUserDataLogger&) = delete; NTPUserDataLogger& operator=(const NTPUserDataLogger&) = delete; @@ -70,6 +72,8 @@ class NTPUserDataLogger { bool using_most_visited, bool is_visible); + void EmitNtpTraceEvent(const char* event_name, base::TimeDelta duration); + void RecordDoodleImpression(base::TimeDelta time, bool is_cta, bool from_cache); @@ -92,9 +96,9 @@ class NTPUserDataLogger { logged_impressions_; // Whether we have already emitted NTP stats for this web contents. - bool has_emitted_; + bool has_emitted_ = false; - bool should_record_doodle_load_time_; + bool should_record_doodle_load_time_ = true; // Are stats being logged during Chrome startup? bool during_startup_; @@ -104,6 +108,9 @@ class NTPUserDataLogger { // The profile in which this New Tab Page was loaded. raw_ptr profile_; + + // Keeps the starting time of NTP navigation. + const base::TimeTicks ntp_navigation_start_time_; }; #endif // CHROME_BROWSER_UI_SEARCH_NTP_USER_DATA_LOGGER_H_ diff --git a/chrome/browser/ui/search/ntp_user_data_logger_unittest.cc b/chrome/browser/ui/search/ntp_user_data_logger_unittest.cc index 5d0371552ef301..5ea8a2f9964df6 100644 --- a/chrome/browser/ui/search/ntp_user_data_logger_unittest.cc +++ b/chrome/browser/ui/search/ntp_user_data_logger_unittest.cc @@ -70,7 +70,7 @@ std::vector FillImpressions(int numImpressions, int count) { class TestNTPUserDataLogger : public NTPUserDataLogger { public: explicit TestNTPUserDataLogger(const GURL& ntp_url) - : NTPUserDataLogger(nullptr, ntp_url) {} + : NTPUserDataLogger(nullptr, ntp_url, base::Time::Now()) {} ~TestNTPUserDataLogger() override {} diff --git a/chrome/browser/ui/views/autofill/payments/offer_notification_bubble_views.cc b/chrome/browser/ui/views/autofill/payments/offer_notification_bubble_views.cc index 0c23fc9934dd69..5af367bce7b0e1 100644 --- a/chrome/browser/ui/views/autofill/payments/offer_notification_bubble_views.cc +++ b/chrome/browser/ui/views/autofill/payments/offer_notification_bubble_views.cc @@ -77,8 +77,8 @@ void OfferNotificationBubbleViews::AddedToWidget() { bundle.GetImageSkiaNamed(IDR_AUTOFILL_OFFERS); auto image_view = std::make_unique( *autofill_offers_banner, *autofill_offers_banner, - base::BindRepeating(&views::BubbleFrameView::GetBackgroundColor, - base::Unretained(GetBubbleFrameView()))); + base::BindRepeating(&views::BubbleDialogDelegate::GetBackgroundColor, + base::Unretained(this))); GetBubbleFrameView()->SetHeaderView(std::move(image_view)); } } diff --git a/chrome/browser/ui/views/autofill/payments/save_card_offer_bubble_views.cc b/chrome/browser/ui/views/autofill/payments/save_card_offer_bubble_views.cc index bc2710c081bf21..5598f3a49648bc 100644 --- a/chrome/browser/ui/views/autofill/payments/save_card_offer_bubble_views.cc +++ b/chrome/browser/ui/views/autofill/payments/save_card_offer_bubble_views.cc @@ -140,8 +140,8 @@ void SaveCardOfferBubbleViews::AddedToWidget() { auto image_view = std::make_unique( *bundle.GetImageSkiaNamed(IDR_SAVE_CARD), *bundle.GetImageSkiaNamed(IDR_SAVE_CARD_DARK), - base::BindRepeating(&views::BubbleFrameView::GetBackgroundColor, - base::Unretained(GetBubbleFrameView()))); + base::BindRepeating(&views::BubbleDialogDelegate::GetBackgroundColor, + base::Unretained(this))); GetBubbleFrameView()->SetHeaderView(std::move(image_view)); } diff --git a/chrome/browser/ui/views/autofill/save_address_profile_view.cc b/chrome/browser/ui/views/autofill/save_address_profile_view.cc index e51e2deaf62a1f..26bc608cc39472 100644 --- a/chrome/browser/ui/views/autofill/save_address_profile_view.cc +++ b/chrome/browser/ui/views/autofill/save_address_profile_view.cc @@ -357,8 +357,8 @@ void SaveAddressProfileView::AddedToWidget() { auto image_view = std::make_unique( *bundle.GetImageSkiaNamed(IDR_SAVE_ADDRESS), *bundle.GetImageSkiaNamed(IDR_SAVE_ADDRESS_DARK), - base::BindRepeating(&views::BubbleFrameView::GetBackgroundColor, - base::Unretained(GetBubbleFrameView()))); + base::BindRepeating(&views::BubbleDialogDelegate::GetBackgroundColor, + base::Unretained(this))); GetBubbleFrameView()->SetHeaderView(std::move(image_view)); } diff --git a/chrome/browser/ui/views/extensions/extensions_tabbed_menu_view.cc b/chrome/browser/ui/views/extensions/extensions_tabbed_menu_view.cc index 459048902c6b3b..ed660cc7d453ef 100644 --- a/chrome/browser/ui/views/extensions/extensions_tabbed_menu_view.cc +++ b/chrome/browser/ui/views/extensions/extensions_tabbed_menu_view.cc @@ -5,14 +5,19 @@ #include "chrome/browser/ui/views/extensions/extensions_tabbed_menu_view.h" #include +#include #include #include "base/feature_list.h" #include "base/i18n/case_conversion.h" +#include "base/strings/utf_string_conversions.h" #include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/extensions/extension_action_view_controller.h" #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" #include "chrome/browser/ui/toolbar/toolbar_actions_model.h" #include "chrome/browser/ui/ui_features.h" +#include "chrome/browser/ui/views/chrome_layout_provider.h" +#include "chrome/browser/ui/views/chrome_typography.h" #include "chrome/browser/ui/views/extensions/extensions_menu_item_view.h" #include "chrome/browser/ui/views/extensions/extensions_toolbar_container.h" #include "chrome/grit/generated_resources.h" @@ -95,7 +100,14 @@ ExtensionsTabbedMenuView::ExtensionsTabbedMenuView( browser_(browser), extensions_container_(extensions_container), toolbar_model_(ToolbarActionsModel::Get(browser_->profile())), - allow_pinning_(allow_pinning) { + allow_pinning_(allow_pinning), + requests_access_{ + nullptr, nullptr, + IDS_EXTENSIONS_MENU_SITE_ACCESS_TAB_REQUESTS_ACCESS_SECTION_TITLE, + ToolbarActionViewController::PageInteractionStatus::kPending}, + has_access_{nullptr, nullptr, + IDS_EXTENSIONS_MENU_SITE_ACCESS_TAB_HAS_ACCESS_SECTION_TITLE, + ToolbarActionViewController::PageInteractionStatus::kActive} { // Ensure layer masking is used for the extensions menu to ensure buttons with // layer effects sitting flush with the bottom of the bubble are clipped // appropriately. @@ -115,8 +127,6 @@ ExtensionsTabbedMenuView::ExtensionsTabbedMenuView( // Let anchor view's MenuButtonController handle the highlight. set_highlight_button_when_shown(false); - set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric( - views::DISTANCE_BUBBLE_PREFERRED_WIDTH)); SetLayoutManager(std::make_unique( views::BoxLayout::Orientation::kVertical)); @@ -182,6 +192,26 @@ ExtensionsTabbedMenuView::GetInstalledItemsForTesting() const { return menu_item_views; } +std::vector +ExtensionsTabbedMenuView::GetHasAccessItemsForTesting() const { + std::vector menu_item_views; + if (IsShowing()) { + for (views::View* view : has_access_.items->children()) + menu_item_views.push_back(GetAsMenuItemView(view)); + } + return menu_item_views; +} + +std::vector +ExtensionsTabbedMenuView::GetRequestsAccessItemsForTesting() const { + std::vector menu_item_views; + if (IsShowing()) { + for (views::View* view : requests_access_.items->children()) + menu_item_views.push_back(GetAsMenuItemView(view)); + } + return menu_item_views; +} + size_t ExtensionsTabbedMenuView::GetSelectedTabIndex() const { return tabbed_pane_->GetSelectedTabIndex(); } @@ -204,6 +234,8 @@ void ExtensionsTabbedMenuView::OnTabStripModelChanged( Update(); } +// TODO(crbug.com/1263310): Update site access items for toolbar changes. + void ExtensionsTabbedMenuView::OnToolbarActionAdded( const ToolbarActionsModel::ActionId& action_id) { auto extension_name = toolbar_model_->GetExtensionName(action_id); @@ -259,9 +291,8 @@ void ExtensionsTabbedMenuView::Populate() { tabbed_pane_ = AddChildView(std::make_unique()); tabbed_pane_->SetFocusBehavior(views::View::FocusBehavior::NEVER); - // TODO(crbug.com/1263310): Populate site access tab. CreateTab(tabbed_pane_, 0, IDS_EXTENSIONS_MENU_SITE_ACCESS_TAB_TITLE, - std::make_unique()); + CreateSiteAccessContainer()); auto installed_items = std::make_unique(); installed_items->SetLayoutManager(std::make_unique( @@ -280,8 +311,13 @@ void ExtensionsTabbedMenuView::Populate() { toolbar_model_->action_ids().end()); std::sort(sorted_ids.begin(), sorted_ids.end(), sort_by_name); - for (size_t i = 0; i < sorted_ids.size(); ++i) + for (size_t i = 0; i < sorted_ids.size(); ++i) { CreateAndInsertInstalledExtension(sorted_ids[i], i); + CreateAndInsertSiteAccessItem(sorted_ids[i]); + } + + UpdateSiteAccessSectionsVisibility(); + ConsistencyCheck(); } @@ -292,6 +328,61 @@ void ExtensionsTabbedMenuView::Update() { } } +std::unique_ptr +ExtensionsTabbedMenuView::CreateSiteAccessContainer() { + auto site_access_container = std::make_unique(); + site_access_container->SetLayoutManager(std::make_unique( + views::BoxLayout::Orientation::kVertical)); + + auto current_site = base::UTF8ToUTF16(browser_->tab_strip_model() + ->GetActiveWebContents() + ->GetLastCommittedURL() + .host()); + + auto create_section = + [current_site](ExtensionsTabbedMenuView::SiteAccessSection* section) { + auto section_container = std::make_unique(); + section->container = section_container.get(); + section_container->SetLayoutManager(std::make_unique( + views::BoxLayout::Orientation::kVertical)); + + const int horizontal_spacing = + ChromeLayoutProvider::Get()->GetDistanceMetric( + views::DISTANCE_BUTTON_HORIZONTAL_PADDING); + + // Add an emphasized short header explaining the section. + auto header = std::make_unique( + l10n_util::GetStringFUTF16(section->header_string_id, current_site), + ChromeTextContext::CONTEXT_DIALOG_BODY_TEXT_SMALL, + ChromeTextStyle::STYLE_EMPHASIZED); + header->SetHorizontalAlignment(gfx::ALIGN_LEFT); + header->SetBorder(views::CreateEmptyBorder( + ChromeLayoutProvider::Get()->GetDistanceMetric( + DISTANCE_CONTROL_LIST_VERTICAL), + horizontal_spacing, 0, horizontal_spacing)); + section_container->AddChildView(std::move(header)); + + // Add an empty section for the menu items of the section. Items will be + // populated later. + auto items = std::make_unique(); + items->SetLayoutManager(std::make_unique( + views::BoxLayout::Orientation::kVertical)); + section->items = items.get(); + section_container->AddChildView(std::move(items)); + + // Start off with the section invisible. We'll update it as we add items + // if necessary. + section_container->SetVisible(false); + + return section_container; + }; + + site_access_container->AddChildView(create_section(&requests_access_)); + site_access_container->AddChildView(create_section(&has_access_)); + + return site_access_container; +} + void ExtensionsTabbedMenuView::CreateAndInsertInstalledExtension( const ToolbarActionsModel::ActionId& id, int index) { @@ -304,6 +395,48 @@ void ExtensionsTabbedMenuView::CreateAndInsertInstalledExtension( installed_items_->AddChildViewAt(std::move(item), index); } +void ExtensionsTabbedMenuView::CreateAndInsertSiteAccessItem( + const ToolbarActionsModel::ActionId& id) { + std::unique_ptr controller = + ExtensionActionViewController::Create(id, browser_, + extensions_container_); + auto item = std::make_unique( + ExtensionsMenuItemView::MenuItemType::kSiteAccess, browser_, + std::move(controller), allow_pinning_); + + const ToolbarActionViewController::PageInteractionStatus status = + item->view_controller()->GetPageInteractionStatus( + browser_->tab_strip_model()->GetActiveWebContents()); + + switch (status) { + case ToolbarActionViewController::PageInteractionStatus::kNone: + break; + case ToolbarActionViewController::PageInteractionStatus::kPending: + requests_access_.items->AddChildView(std::move(item)); + break; + case ToolbarActionViewController::PageInteractionStatus::kActive: + has_access_.items->AddChildView(std::move(item)); + break; + } +} + +void ExtensionsTabbedMenuView::UpdateSiteAccessSectionsVisibility() { + auto update_section = [](SiteAccessSection* section) { + bool should_be_visible = !section->items->children().empty(); + if (section->container->GetVisible() != should_be_visible) + section->container->SetVisible(should_be_visible); + }; + + update_section(&has_access_); + update_section(&requests_access_); + + // TODO(crbug.com/1263310): If no extensions have or request access to the + // current site, show respective message. + + // TODO(crbug.com/1263310): If user is on a chrome:-scheme page, show + // respective message. +} + void ExtensionsTabbedMenuView::ConsistencyCheck() { #if DCHECK_IS_ON() const base::flat_set& action_ids = toolbar_model_->action_ids(); diff --git a/chrome/browser/ui/views/extensions/extensions_tabbed_menu_view.h b/chrome/browser/ui/views/extensions/extensions_tabbed_menu_view.h index 02e22ea42317f8..a97686139ee42e 100644 --- a/chrome/browser/ui/views/extensions/extensions_tabbed_menu_view.h +++ b/chrome/browser/ui/views/extensions/extensions_tabbed_menu_view.h @@ -14,6 +14,7 @@ #include "ui/views/bubble/bubble_dialog_delegate_view.h" namespace views { +class View; class TabbedPane; } // namespace views @@ -62,6 +63,14 @@ class ExtensionsTabbedMenuView : public views::BubbleDialogDelegateView, // exists. std::vector GetInstalledItemsForTesting() const; + // Returns the currently-showing `has_access_` extension items in the site + // access tab, if any exists. + std::vector GetHasAccessItemsForTesting() const; + + // Returns the currently-showing `requests_access_` extension items in the + // site access tab, if any exists. + std::vector GetRequestsAccessItemsForTesting() const; + // Returns the index of the currently selected tab. size_t GetSelectedTabIndex() const; @@ -88,17 +97,43 @@ class ExtensionsTabbedMenuView : public views::BubbleDialogDelegateView, void OnToolbarPinnedActionsChanged() override; private: + struct SiteAccessSection { + // The root view for this section used to toggle the visibility of the + // entire section (depending on whether there are any menu items). + raw_ptr container; + + // The view containing only the menu items for this section. + raw_ptr items; + + // The id of the string to use for the section heading. Does not include the + // current site string. + const int header_string_id; + + // The PageInteractionStatus that this section is handling. + const ToolbarActionViewController::PageInteractionStatus page_status; + }; + // Initially creates the tabs. void Populate(); // Updates the menu. void Update(); + // Creates and returns the site access container with empty sections. + std::unique_ptr CreateSiteAccessContainer(); + // Adds a menu item in the installed extensions for a newly-added extension. void CreateAndInsertInstalledExtension( const ToolbarActionsModel::ActionId& id, int index); + // Adds a menu item in the corresponding site access section. + void CreateAndInsertSiteAccessItem(const ToolbarActionsModel::ActionId& id); + + // Updates the visibility of the site access sections. A given section should + // be visible if there are any extensions displayed in it. + void UpdateSiteAccessSectionsVisibility(); + // Runs a set of consistency checks on the appearance of the menu. This is a // no-op if DCHECKs are disabled. void ConsistencyCheck(); @@ -117,6 +152,10 @@ class ExtensionsTabbedMenuView : public views::BubbleDialogDelegateView, // separated for easy insertion and iteration of menu items. The children are // guaranteed to only be ExtensionMenuItemViews. views::View* installed_items_ = nullptr; + + // The different sections in the site access tab. + SiteAccessSection requests_access_; + SiteAccessSection has_access_; }; #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSIONS_TABBED_MENU_VIEW_H_ diff --git a/chrome/browser/ui/views/extensions/extensions_tabbed_menu_view_unittest.cc b/chrome/browser/ui/views/extensions/extensions_tabbed_menu_view_unittest.cc index 1f866299f73a80..81e9185696f1f8 100644 --- a/chrome/browser/ui/views/extensions/extensions_tabbed_menu_view_unittest.cc +++ b/chrome/browser/ui/views/extensions/extensions_tabbed_menu_view_unittest.cc @@ -67,6 +67,10 @@ class ExtensionsTabbedMenuViewUnitTest : public ExtensionsToolbarUnitTest { ExtensionsTabbedMenuViewUnitTest& operator=( const ExtensionsTabbedMenuViewUnitTest&) = delete; + content::WebContentsTester* web_contents_tester() { + return web_contents_tester_; + } + ExtensionsToolbarButton* extensions_button() { return extensions_container() ->GetExtensionsToolbarControls() @@ -84,11 +88,23 @@ class ExtensionsTabbedMenuViewUnitTest : public ExtensionsToolbarUnitTest { return ExtensionsTabbedMenuView::GetExtensionsTabbedMenuViewForTesting() ->GetInstalledItemsForTesting(); } + std::vector has_access_items() { + return ExtensionsTabbedMenuView::GetExtensionsTabbedMenuViewForTesting() + ->GetHasAccessItemsForTesting(); + } + std::vector requests_access_items() { + return ExtensionsTabbedMenuView::GetExtensionsTabbedMenuViewForTesting() + ->GetRequestsAccessItemsForTesting(); + } // Asserts there is exactly 1 menu item and then returns it. ExtensionsMenuItemView* GetOnlyInstalledMenuItem(); - void ShowTabbedMenu(); + // Opens the tabbed menu in the installed tab. + void ShowInstalledTabInMenu(); + + // Opens the tabbed menu in the site access tab. + void ShowSiteAccessTabInMenu(); void ClickSiteAccessButton(); void ClickExtensionsButton(); @@ -99,8 +115,12 @@ class ExtensionsTabbedMenuViewUnitTest : public ExtensionsToolbarUnitTest { extensions_tabbed_menu()->GetWidget()->LayoutRootViewIfNecessary(); } + // ExtensionsToolbarUnitTest: + void SetUp() override; + private: base::test::ScopedFeatureList scoped_feature_list_; + content::WebContentsTester* web_contents_tester_; }; ExtensionsTabbedMenuViewUnitTest::ExtensionsTabbedMenuViewUnitTest() { @@ -108,6 +128,13 @@ ExtensionsTabbedMenuViewUnitTest::ExtensionsTabbedMenuViewUnitTest() { features::kExtensionsMenuAccessControl); } +void ExtensionsTabbedMenuViewUnitTest::SetUp() { + ExtensionsToolbarUnitTest::SetUp(); + // Menu needs web contents at construction, so we need to add them to every + // test. + web_contents_tester_ = AddWebContentsAndGetTester(); +} + ExtensionsMenuItemView* ExtensionsTabbedMenuViewUnitTest::GetOnlyInstalledMenuItem() { std::vector items = installed_items(); @@ -118,12 +145,18 @@ ExtensionsTabbedMenuViewUnitTest::GetOnlyInstalledMenuItem() { return *items.begin(); } -void ExtensionsTabbedMenuViewUnitTest::ShowTabbedMenu() { +void ExtensionsTabbedMenuViewUnitTest::ShowInstalledTabInMenu() { ExtensionsTabbedMenuView::ShowBubble( extensions_button(), browser(), extensions_container(), ExtensionsToolbarButton::ButtonType::kExtensions, true); } +void ExtensionsTabbedMenuViewUnitTest::ShowSiteAccessTabInMenu() { + ExtensionsTabbedMenuView::ShowBubble( + extensions_button(), browser(), extensions_container(), + ExtensionsToolbarButton::ButtonType::kSiteAccess, true); +} + void ExtensionsTabbedMenuViewUnitTest::ClickSiteAccessButton() { ClickButton(site_access_button()); LayoutContainerIfNecessary(); @@ -146,16 +179,13 @@ void ExtensionsTabbedMenuViewUnitTest::ClickContextMenuButton( } TEST_F(ExtensionsTabbedMenuViewUnitTest, ButtonOpensAndClosesCorrespondingTab) { - content::WebContentsTester* web_contents_tester = - AddWebContentsAndGetTester(); - // Load an extension with all urls permissions so the site access button is // visible. InstallExtensionWithHostPermissions("all_urls", {""}); // Navigate to an url where the extension should have access to. const GURL url("http://www.a.com"); - web_contents_tester->NavigateAndCommit(url); + web_contents_tester()->NavigateAndCommit(url); WaitForAnimation(); EXPECT_TRUE(site_access_button()->GetVisible()); EXPECT_FALSE(ExtensionsTabbedMenuView::IsShowing()); @@ -184,16 +214,13 @@ TEST_F(ExtensionsTabbedMenuViewUnitTest, ButtonOpensAndClosesCorrespondingTab) { } TEST_F(ExtensionsTabbedMenuViewUnitTest, TogglingButtonsClosesMenu) { - content::WebContentsTester* web_contents_tester = - AddWebContentsAndGetTester(); - // Load an extension with all urls permissions so the site access button is // visible. InstallExtensionWithHostPermissions("all_urls", {""}); // Navigate to an url where the extension should have access to. const GURL url("http://www.a.com"); - web_contents_tester->NavigateAndCommit(url); + web_contents_tester()->NavigateAndCommit(url); WaitForAnimation(); EXPECT_TRUE(site_access_button()->GetVisible()); EXPECT_FALSE(ExtensionsTabbedMenuView::IsShowing()); @@ -232,7 +259,7 @@ TEST_F(ExtensionsTabbedMenuViewUnitTest, constexpr char kExtensionName[] = "Test 1"; InstallExtension(kExtensionName); - ShowTabbedMenu(); + ShowInstalledTabInMenu(); ASSERT_EQ(installed_items().size(), 1u); EXPECT_EQ(base::UTF16ToUTF8((*installed_items().begin()) @@ -252,7 +279,7 @@ TEST_F(ExtensionsTabbedMenuViewUnitTest, constexpr char kExtensionCName[] = "C Extension"; InstallExtension(kExtensionCName); - ShowTabbedMenu(); + ShowInstalledTabInMenu(); std::vector items = installed_items(); ASSERT_EQ(items.size(), 4u); @@ -268,7 +295,7 @@ TEST_F(ExtensionsTabbedMenuViewUnitTest, constexpr char kName[] = "Test Name"; InstallExtension(kName); - ShowTabbedMenu(); + ShowInstalledTabInMenu(); ExtensionsMenuItemView* installed_item = GetOnlyInstalledMenuItem(); ASSERT_TRUE(installed_item); @@ -297,7 +324,8 @@ TEST_F(ExtensionsTabbedMenuViewUnitTest, constexpr char kExtensionC[] = "C Extension"; InstallExtension(kExtensionC); - ShowTabbedMenu(); + ShowInstalledTabInMenu(); + std::vector items = installed_items(); // Verify the order of the extensions is A,B,C. @@ -355,7 +383,7 @@ TEST_F(ExtensionsTabbedMenuViewUnitTest, InstalledTab_PinnedExtensionAppearsInAnotherWindow) { InstallExtension("Test Name"); - ShowTabbedMenu(); + ShowInstalledTabInMenu(); AdditionalBrowser browser2( CreateBrowser(browser()->profile(), browser()->type(), @@ -385,7 +413,7 @@ TEST_F(ExtensionsTabbedMenuViewUnitTest, InstallExtension(kExtensionA); InstallExtension(kExtensionC); - ShowTabbedMenu(); + ShowInstalledTabInMenu(); // Verify the order of the extensions is A,C. { @@ -428,7 +456,7 @@ TEST_F(ExtensionsTabbedMenuViewUnitTest, constexpr char kName[] = "Test Extension"; auto extension_id = InstallExtension(kName)->id(); - ShowTabbedMenu(); + ShowInstalledTabInMenu(); ExtensionsMenuItemView* menu_item = GetOnlyInstalledMenuItem(); EXPECT_EQ(installed_items().size(), 1u); @@ -464,7 +492,7 @@ TEST_F(ExtensionsTabbedMenuViewUnitTest, InstalledTab_ReloadExtension) { scoped_refptr extension = loader.LoadExtension(extension_directory.UnpackedPath()); - ShowTabbedMenu(); + ShowInstalledTabInMenu(); ExtensionsMenuItemView* installed_item = GetOnlyInstalledMenuItem(); EXPECT_EQ(installed_items().size(), 1u); @@ -502,7 +530,7 @@ TEST_F(ExtensionsTabbedMenuViewUnitTest, InstalledTab_ReloadExtensionFailed) { scoped_refptr extension = loader.LoadExtension(extension_directory.UnpackedPath()); - ShowTabbedMenu(); + ShowInstalledTabInMenu(); ExtensionsMenuItemView* installed_item = GetOnlyInstalledMenuItem(); EXPECT_EQ(installed_items().size(), 1u); @@ -531,10 +559,37 @@ TEST_F(ExtensionsTabbedMenuViewUnitTest, InstalledTab_ReloadExtensionFailed) { EXPECT_FALSE(views::IsViewClass(child)); } +TEST_F(ExtensionsTabbedMenuViewUnitTest, + SiteAccessTab_ExtensionsInCorrectSiteAccessSection) { + constexpr char kHasAccessName[] = "Has Access Extension"; + InstallExtensionWithHostPermissions(kHasAccessName, {""}); + constexpr char kNoAccessName[] = "No Access Extension"; + InstallExtension(kNoAccessName); + + const GURL url_a("http://www.a.com"); + web_contents_tester()->NavigateAndCommit(url_a); + ShowSiteAccessTabInMenu(); + + // Extension with permission has site access by default (except for + // forbidden websites such as chrome:-scheme), and it should be in the has + // access section. + ASSERT_EQ(has_access_items().size(), 1u); + EXPECT_EQ(base::UTF16ToUTF8((*has_access_items().begin()) + ->primary_action_button_for_testing() + ->label_text_for_testing()), + kHasAccessName); + // Extension with no host permissions does not have site access, and it should + // not be in any site access section. + EXPECT_EQ(requests_access_items().size(), 0u); +} + +// TODO(crbug.com/1263310): Verify menu gets updated after permission changes +// using the menu item dropdown. + TEST_F(ExtensionsTabbedMenuViewUnitTest, WindowTitle) { InstallExtension("Test Extension"); - ShowTabbedMenu(); + ShowInstalledTabInMenu(); ExtensionsTabbedMenuView* menu = extensions_tabbed_menu(); EXPECT_FALSE(menu->GetWindowTitle().empty()); diff --git a/chrome/browser/ui/views/incognito_clear_browsing_data_dialog.cc b/chrome/browser/ui/views/incognito_clear_browsing_data_dialog.cc index 00aadedf7c0493..142a9b12a734fa 100644 --- a/chrome/browser/ui/views/incognito_clear_browsing_data_dialog.cc +++ b/chrome/browser/ui/views/incognito_clear_browsing_data_dialog.cc @@ -6,7 +6,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" -#include "chrome/browser/ui/views/accessibility/non_accessible_image_view.h" +#include "chrome/browser/ui/views/accessibility/theme_tracking_non_accessible_image_view.h" #include "chrome/browser/ui/views/chrome_typography.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/grit/generated_resources.h" @@ -87,9 +87,13 @@ IncognitoClearBrowsingDataDialog::IncognitoClearBrowsingDataDialog( views::DISTANCE_BUBBLE_PREFERRED_WIDTH)); // Header art - auto header_view = std::make_unique(); - header_view_ = header_view.get(); - AddChildView(std::move(header_view)); + ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); + auto image_view = std::make_unique( + *bundle.GetImageSkiaNamed(IDR_INCOGNITO_DATA_NOT_SAVED_HEADER_LIGHT), + *bundle.GetImageSkiaNamed(IDR_INCOGNITO_DATA_NOT_SAVED_HEADER_DARK), + base::BindRepeating(&views::BubbleDialogDelegate::GetBackgroundColor, + base::Unretained(this))); + AddChildView(std::move(image_view)); // Set bubble regarding to the type. if (type == kHistoryDisclaimerBubble) @@ -185,19 +189,6 @@ void IncognitoClearBrowsingDataDialog::OnCancelButtonClicked() { CloseDialog(); } -void IncognitoClearBrowsingDataDialog::OnThemeChanged() { - BubbleDialogDelegateView::OnThemeChanged(); - header_view_->SetImage(GetHeaderArt()); -} - -gfx::ImageSkia* IncognitoClearBrowsingDataDialog::GetHeaderArt() { - bool is_dark = - color_utils::IsDark(GetBubbleFrameView()->GetBackgroundColor()); - return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( - is_dark ? IDR_INCOGNITO_DATA_NOT_SAVED_HEADER_DARK - : IDR_INCOGNITO_DATA_NOT_SAVED_HEADER_LIGHT); -} - BEGIN_METADATA(IncognitoClearBrowsingDataDialog, views::BubbleDialogDelegateView) END_METADATA diff --git a/chrome/browser/ui/views/incognito_clear_browsing_data_dialog.h b/chrome/browser/ui/views/incognito_clear_browsing_data_dialog.h index affc55ecc028e7..caf0c096901f02 100644 --- a/chrome/browser/ui/views/incognito_clear_browsing_data_dialog.h +++ b/chrome/browser/ui/views/incognito_clear_browsing_data_dialog.h @@ -11,16 +11,11 @@ #include "ui/views/bubble/bubble_dialog_delegate_view.h" class Profile; -class NonAccessibleImageView; namespace views { class View; } // namespace views -namespace gfx { -class ImageSkia; -} - class IncognitoClearBrowsingDataDialog : public views::BubbleDialogDelegateView { public: @@ -48,8 +43,6 @@ class IncognitoClearBrowsingDataDialog const IncognitoClearBrowsingDataDialog& other) = delete; ~IncognitoClearBrowsingDataDialog() override; - void OnThemeChanged() override; - private: explicit IncognitoClearBrowsingDataDialog(views::View* anchor_view, Profile* incognito_profile, @@ -57,8 +50,6 @@ class IncognitoClearBrowsingDataDialog static void CloseDialog(); - gfx::ImageSkia* GetHeaderArt(); - // Helper methods to add functionality to the button. void OnCloseWindowsButtonClicked(); void OnCancelButtonClicked(); @@ -67,7 +58,6 @@ class IncognitoClearBrowsingDataDialog void SetDialogForHistoryDisclaimerBubbleType(); raw_ptr incognito_profile_; - raw_ptr header_view_; base::OnceClosure destructor_callback_ = base::DoNothing(); }; diff --git a/chrome/browser/ui/views/incognito_clear_browsing_data_dialog_browsertest.cc b/chrome/browser/ui/views/incognito_clear_browsing_data_dialog_browsertest.cc index 01202a08c69b95..40748b59994454 100644 --- a/chrome/browser/ui/views/incognito_clear_browsing_data_dialog_browsertest.cc +++ b/chrome/browser/ui/views/incognito_clear_browsing_data_dialog_browsertest.cc @@ -7,6 +7,7 @@ #include "base/test/bind.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/test/test_browser_dialog.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/toolbar_button_provider.h" #include "chrome/browser/ui/views/incognito_clear_browsing_data_dialog.h" @@ -18,9 +19,10 @@ #include "content/public/test/browser_test.h" #include "ui/views/controls/button/label_button.h" -class IncognitoClearBrowsingDataDialogBrowserTest - : public InProcessBrowserTest { +class IncognitoClearBrowsingDataDialogBrowserTest : public DialogBrowserTest { public: + void ShowUi(const std::string& name) override { OpenDialog(); } + void OpenDialog() { incognito_browser_ = CreateIncognitoBrowser(browser()->profile()); views::View* view = static_cast( @@ -44,6 +46,11 @@ class IncognitoClearBrowsingDataDialogBrowserTest raw_ptr incognito_browser_ = nullptr; }; +IN_PROC_BROWSER_TEST_F(IncognitoClearBrowsingDataDialogBrowserTest, + InvokeUi_default) { + ShowAndVerifyUi(); +} + IN_PROC_BROWSER_TEST_F(IncognitoClearBrowsingDataDialogBrowserTest, TestDialogIsShown) { OpenDialog(); diff --git a/chrome/browser/ui/views/page_info/accuracy_tip_bubble_view.cc b/chrome/browser/ui/views/page_info/accuracy_tip_bubble_view.cc index 1477dc25d2e2ee..e4e2c084da95ea 100644 --- a/chrome/browser/ui/views/page_info/accuracy_tip_bubble_view.cc +++ b/chrome/browser/ui/views/page_info/accuracy_tip_bubble_view.cc @@ -130,8 +130,8 @@ AccuracyTipBubbleView::AccuracyTipBubbleView( auto header_view = std::make_unique( *bundle.GetImageSkiaNamed(IDR_ACCURACY_TIP_ILLUSTRATION_LIGHT), *bundle.GetImageSkiaNamed(IDR_ACCURACY_TIP_ILLUSTRATION_DARK), - base::BindRepeating(&views::BubbleFrameView::GetBackgroundColor, - base::Unretained(GetBubbleFrameView()))); + base::BindRepeating(&views::BubbleDialogDelegate::GetBackgroundColor, + base::Unretained(this))); set_fixed_width(header_view->GetPreferredSize().width()); GetBubbleFrameView()->SetHeaderView(std::move(header_view)); diff --git a/chrome/browser/ui/views/page_info/safety_tip_page_info_bubble_view.cc b/chrome/browser/ui/views/page_info/safety_tip_page_info_bubble_view.cc index 4e46d3c26381bb..5d1ebaf85d0c4a 100644 --- a/chrome/browser/ui/views/page_info/safety_tip_page_info_bubble_view.cc +++ b/chrome/browser/ui/views/page_info/safety_tip_page_info_bubble_view.cc @@ -11,7 +11,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_window.h" -#include "chrome/browser/ui/views/accessibility/non_accessible_image_view.h" +#include "chrome/browser/ui/views/accessibility/theme_tracking_non_accessible_image_view.h" #include "chrome/browser/ui/views/bubble_anchor_util_views.h" #include "chrome/browser/ui/views/chrome_layout_provider.h" #include "chrome/browser/ui/views/page_info/page_info_view_factory.h" @@ -33,28 +33,6 @@ #include "ui/views/widget/widget.h" #include "url/gurl.h" -namespace { - -int GetSafetyTipBannerId(security_state::SafetyTipStatus safety_tip_status, - bool is_dark) { - switch (safety_tip_status) { - case security_state::SafetyTipStatus::kBadReputation: - case security_state::SafetyTipStatus::kLookalike: - return is_dark ? IDR_SAFETY_TIP_ILLUSTRATION_DARK - : IDR_SAFETY_TIP_ILLUSTRATION_LIGHT; - case security_state::SafetyTipStatus::kBadReputationIgnored: - case security_state::SafetyTipStatus::kLookalikeIgnored: - case security_state::SafetyTipStatus::kDigitalAssetLinkMatch: - case security_state::SafetyTipStatus::kBadKeyword: - case security_state::SafetyTipStatus::kUnknown: - case security_state::SafetyTipStatus::kNone: - NOTREACHED(); - return 0; - } -} - -} // namespace - SafetyTipPageInfoBubbleView::SafetyTipPageInfoBubbleView( views::View* anchor_view, const gfx::Rect& anchor_rect, @@ -109,16 +87,14 @@ SafetyTipPageInfoBubbleView::SafetyTipPageInfoBubbleView( gfx::Insets(insets.top(), insets.left(), 0, insets.right()), insets.bottom())); - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - const bool use_dark = - color_utils::IsDark(GetBubbleFrameView()->GetBackgroundColor()); - const gfx::ImageSkia* image = - rb.GetNativeImageNamed(GetSafetyTipBannerId(safety_tip_status, use_dark)) - .ToImageSkia(); - auto image_view = std::make_unique(); - image_view->SetImage(*image); - views::BubbleFrameView* frame_view = GetBubbleFrameView(); - frame_view->SetHeaderView(std::move(image_view)); + // Configure header view. + auto& bundle = ui::ResourceBundle::GetSharedInstance(); + auto header_view = std::make_unique( + *bundle.GetImageSkiaNamed(IDR_SAFETY_TIP_ILLUSTRATION_LIGHT), + *bundle.GetImageSkiaNamed(IDR_SAFETY_TIP_ILLUSTRATION_DARK), + base::BindRepeating(&views::BubbleDialogDelegate::GetBackgroundColor, + base::Unretained(this))); + GetBubbleFrameView()->SetHeaderView(std::move(header_view)); // Add text description. auto* text_label = AddChildView(std::make_unique( diff --git a/chrome/browser/ui/views/passwords/credential_leak_dialog_view.cc b/chrome/browser/ui/views/passwords/credential_leak_dialog_view.cc index 1091e1754e20ae..7f5cc0022039ab 100644 --- a/chrome/browser/ui/views/passwords/credential_leak_dialog_view.cc +++ b/chrome/browser/ui/views/passwords/credential_leak_dialog_view.cc @@ -78,7 +78,10 @@ CredentialLeakDialogView::CredentialLeakDialogView( &CredentialLeakDialogController::OnCloseDialog)); } -CredentialLeakDialogView::~CredentialLeakDialogView() = default; +CredentialLeakDialogView::~CredentialLeakDialogView() { + if (controller_) + std::exchange(controller_, nullptr)->ResetDialog(); +} void CredentialLeakDialogView::ShowCredentialLeakPrompt() { InitWindow(); diff --git a/chrome/browser/ui/views/passwords/password_bubble_view_base.cc b/chrome/browser/ui/views/passwords/password_bubble_view_base.cc index 58f76e2df67004..fbc946573280db 100644 --- a/chrome/browser/ui/views/passwords/password_bubble_view_base.cc +++ b/chrome/browser/ui/views/passwords/password_bubble_view_base.cc @@ -174,8 +174,8 @@ void PasswordBubbleViewBase::SetBubbleHeader(int light_image_id, auto image_view = std::make_unique( *bundle.GetImageSkiaNamed(light_image_id), *bundle.GetImageSkiaNamed(dark_image_id), - base::BindRepeating(&views::BubbleFrameView::GetBackgroundColor, - base::Unretained(GetBubbleFrameView()))); + base::BindRepeating(&views::BubbleDialogDelegate::GetBackgroundColor, + base::Unretained(this))); gfx::Size preferred_size = image_view->GetPreferredSize(); if (preferred_size.width()) { diff --git a/chrome/browser/ui/views/passwords/password_dialog_view_browsertest.cc b/chrome/browser/ui/views/passwords/password_dialog_view_browsertest.cc index 58075da406951e..2cd632599abc15 100644 --- a/chrome/browser/ui/views/passwords/password_dialog_view_browsertest.cc +++ b/chrome/browser/ui/views/passwords/password_dialog_view_browsertest.cc @@ -535,6 +535,14 @@ void PasswordDialogViewTest::ShowUi(const std::string& name) { } GURL origin("https://example.com"); + if (name == "CredentialLeak") { + CredentialLeakType leak_type = + CredentialLeakFlags::kPasswordSaved | + CredentialLeakFlags::kPasswordUsedOnOtherSites; + controller()->OnCredentialLeak(leak_type, origin); + return; + } + std::vector> local_credentials; password_manager::PasswordForm form; @@ -588,6 +596,14 @@ void PasswordDialogViewTest::ShowUi(const std::string& name) { } } +IN_PROC_BROWSER_TEST_F(PasswordDialogViewTest, InvokeUi_AutoSigninFirstRun) { + ShowAndVerifyUi(); +} + +IN_PROC_BROWSER_TEST_F(PasswordDialogViewTest, InvokeUi_CredentialLeak) { + ShowAndVerifyUi(); +} + IN_PROC_BROWSER_TEST_F(PasswordDialogViewTest, InvokeUi_PopupAutoSigninPrompt) { ShowAndVerifyUi(); } @@ -604,8 +620,4 @@ IN_PROC_BROWSER_TEST_F( ShowAndVerifyUi(); } -IN_PROC_BROWSER_TEST_F(PasswordDialogViewTest, InvokeUi_AutoSigninFirstRun) { - ShowAndVerifyUi(); -} - } // namespace diff --git a/chrome/browser/ui/views/select_file_dialog_extension.cc b/chrome/browser/ui/views/select_file_dialog_extension.cc index 59af2f401cc429..f5755f3a28427d 100644 --- a/chrome/browser/ui/views/select_file_dialog_extension.cc +++ b/chrome/browser/ui/views/select_file_dialog_extension.cc @@ -512,7 +512,7 @@ void SelectFileDialogExtension::SelectFileWithFileManagerParams( this, routing_id, file_manager_url, dialog_title); dialog_delegate->SetModal(owner.window != nullptr); dialog_delegate->set_can_resize(can_resize_); - dialog_delegate->ShowSystemDialog(parent_window); + dialog_delegate->ShowSystemDialogForBrowserContext(profile_, parent_window); } else { ExtensionDialog::InitParams dialog_params( {kFileManagerWidth, kFileManagerHeight}); diff --git a/chrome/browser/ui/views/sharing/sharing_dialog_view.cc b/chrome/browser/ui/views/sharing/sharing_dialog_view.cc index 2ccd33e44083ec..d6cc17a48db2b1 100644 --- a/chrome/browser/ui/views/sharing/sharing_dialog_view.cc +++ b/chrome/browser/ui/views/sharing/sharing_dialog_view.cc @@ -148,8 +148,8 @@ void SharingDialogView::AddedToWidget() { gfx::kPlaceholderColor), gfx::CreateVectorIcon(*data_.header_icons->dark, gfx::kPlaceholderColor), - base::BindRepeating(&views::BubbleFrameView::GetBackgroundColor, - base::Unretained(frame_view))); + base::BindRepeating(&views::BubbleDialogDelegate::GetBackgroundColor, + base::Unretained(this))); constexpr gfx::Size kHeaderImageSize(320, 100); image_view->SetPreferredSize(kHeaderImageSize); image_view->SetVerticalAlignment(views::ImageView::Alignment::kLeading); diff --git a/chrome/browser/ui/webui/chromeos/in_session_password_change/confirm_password_change_handler.cc b/chrome/browser/ui/webui/chromeos/in_session_password_change/confirm_password_change_handler.cc index af0eaf25ea4999..3dda4529c26993 100644 --- a/chrome/browser/ui/webui/chromeos/in_session_password_change/confirm_password_change_handler.cc +++ b/chrome/browser/ui/webui/chromeos/in_session_password_change/confirm_password_change_handler.cc @@ -6,12 +6,12 @@ #include +#include "ash/components/login/auth/saml_password_attributes.h" #include "base/check.h" #include "base/values.h" #include "chrome/browser/ash/login/saml/in_session_password_change_manager.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/pref_names.h" -#include "chromeos/login/auth/saml_password_attributes.h" #include "components/prefs/pref_service.h" #include "components/user_manager/user_manager.h" diff --git a/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.cc b/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.cc index e3be9c7171f1be..a77dca027b6994 100644 --- a/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.cc +++ b/chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.cc @@ -4,6 +4,8 @@ #include "chrome/browser/ui/webui/chromeos/in_session_password_change/lock_screen_reauth_handler.h" +#include "ash/components/login/auth/challenge_response/cert_utils.h" +#include "ash/components/login/auth/cryptohome_key_constants.h" #include "ash/constants/ash_features.h" #include "base/notreached.h" #include "chrome/browser/ash/login/saml/in_session_password_sync_manager.h" @@ -18,8 +20,6 @@ #include "chrome/grit/generated_resources.h" #include "chrome/installer/util/google_update_settings.h" #include "chromeos/dbus/util/version_loader.h" -#include "chromeos/login/auth/challenge_response/cert_utils.h" -#include "chromeos/login/auth/cryptohome_key_constants.h" #include "components/account_id/account_id.h" #include "components/signin/public/identity_manager/account_info.h" #include "components/user_manager/known_user.h" diff --git a/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_handler.cc b/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_handler.cc index 6f390fbe83c0f6..a0984a51f07e9a 100644 --- a/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_handler.cc +++ b/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_handler.cc @@ -6,6 +6,7 @@ #include +#include "ash/components/login/auth/saml_password_attributes.h" #include "base/logging.h" #include "base/values.h" #include "chrome/browser/ash/login/auth/chrome_cryptohome_authenticator.h" @@ -13,7 +14,6 @@ #include "chrome/browser/ash/login/saml/in_session_password_change_manager.h" #include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/profiles/profile.h" -#include "chromeos/login/auth/saml_password_attributes.h" #include "components/prefs/pref_service.h" #include "components/user_manager/user_manager.h" diff --git a/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_ui.cc b/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_ui.cc index 117674b67c987d..e6d6433b019dc8 100644 --- a/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_ui.cc +++ b/chrome/browser/ui/webui/chromeos/in_session_password_change/password_change_ui.cc @@ -6,6 +6,7 @@ #include +#include "ash/components/login/auth/saml_password_attributes.h" #include "ash/constants/ash_switches.h" #include "base/bind.h" #include "base/command_line.h" @@ -22,7 +23,6 @@ #include "chrome/common/webui_url_constants.h" #include "chrome/grit/browser_resources.h" #include "chrome/grit/generated_resources.h" -#include "chromeos/login/auth/saml_password_attributes.h" #include "chromeos/strings/grit/chromeos_strings.h" #include "components/prefs/pref_service.h" #include "components/strings/grit/components_strings.h" diff --git a/chrome/browser/ui/webui/chromeos/in_session_password_change/urgent_password_expiry_notification_handler.cc b/chrome/browser/ui/webui/chromeos/in_session_password_change/urgent_password_expiry_notification_handler.cc index d4f27df1527e13..4030125250ac6e 100644 --- a/chrome/browser/ui/webui/chromeos/in_session_password_change/urgent_password_expiry_notification_handler.cc +++ b/chrome/browser/ui/webui/chromeos/in_session_password_change/urgent_password_expiry_notification_handler.cc @@ -6,12 +6,12 @@ #include +#include "ash/components/login/auth/saml_password_attributes.h" #include "base/values.h" #include "chrome/browser/ash/login/saml/in_session_password_change_manager.h" #include "chrome/browser/ash/login/saml/password_expiry_notification.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/pref_names.h" -#include "chromeos/login/auth/saml_password_attributes.h" #include "components/prefs/pref_service.h" #include "components/user_manager/user_manager.h" diff --git a/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc index 991a0d78b2faa8..43f4705c02bd80 100644 --- a/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc @@ -7,6 +7,11 @@ #include #include +#include "ash/components/login/auth/challenge_response/cert_utils.h" +#include "ash/components/login/auth/cryptohome_key_constants.h" +#include "ash/components/login/auth/saml_password_attributes.h" +#include "ash/components/login/auth/sync_trusted_vault_keys.h" +#include "ash/components/login/auth/user_context.h" #include "ash/components/security_token_pin/constants.h" #include "ash/components/security_token_pin/error_generator.h" #include "ash/components/settings/cros_settings_names.h" @@ -78,11 +83,6 @@ #include "chrome/installer/util/google_update_settings.h" #include "chromeos/components/onc/certificate_scope.h" #include "chromeos/dbus/util/version_loader.h" -#include "chromeos/login/auth/challenge_response/cert_utils.h" -#include "chromeos/login/auth/cryptohome_key_constants.h" -#include "chromeos/login/auth/saml_password_attributes.h" -#include "chromeos/login/auth/sync_trusted_vault_keys.h" -#include "chromeos/login/auth/user_context.h" #include "chromeos/strings/grit/chromeos_strings.h" #include "components/login/localized_values_builder.h" #include "components/policy/proto/chrome_device_policy.pb.h" diff --git a/chrome/browser/ui/webui/chromeos/login/online_login_helper.cc b/chrome/browser/ui/webui/chromeos/login/online_login_helper.cc index 8a749ec7d1cf8f..ecdba2496a2ae2 100644 --- a/chrome/browser/ui/webui/chromeos/login/online_login_helper.cc +++ b/chrome/browser/ui/webui/chromeos/login/online_login_helper.cc @@ -4,6 +4,8 @@ #include "chrome/browser/ui/webui/chromeos/login/online_login_helper.h" +#include "ash/components/login/auth/challenge_response/cert_utils.h" +#include "ash/components/login/auth/cryptohome_key_constants.h" #include "chrome/browser/ash/login/signin_partition_manager.h" #include "chrome/browser/ash/login/ui/login_display_host_webui.h" #include "chrome/browser/ash/login/ui/signin_ui.h" @@ -13,8 +15,6 @@ #include "chrome/grit/generated_resources.h" #include "chrome/installer/util/google_update_settings.h" #include "chromeos/dbus/util/version_loader.h" -#include "chromeos/login/auth/challenge_response/cert_utils.h" -#include "chromeos/login/auth/cryptohome_key_constants.h" #include "components/sync/driver/sync_driver_switches.h" #include "content/public/browser/storage_partition.h" #include "google_apis/gaia/gaia_urls.h" diff --git a/chrome/browser/ui/webui/chromeos/login/online_login_helper.h b/chrome/browser/ui/webui/chromeos/login/online_login_helper.h index cc3925f63ec1c8..2044646b26eec0 100644 --- a/chrome/browser/ui/webui/chromeos/login/online_login_helper.h +++ b/chrome/browser/ui/webui/chromeos/login/online_login_helper.h @@ -7,12 +7,12 @@ #include +#include "ash/components/login/auth/cryptohome_authenticator.h" #include "chrome/browser/ash/login/login_client_cert_usage_observer.h" #include "chrome/browser/ash/login/signin_partition_manager.h" #include "chrome/browser/ash/login/ui/login_display_host.h" #include "chrome/browser/ash/login/ui/signin_ui.h" #include "chrome/browser/extensions/api/cookies/cookies_api.h" -#include "chromeos/login/auth/cryptohome_authenticator.h" #include "components/login/base_screen_handler_utils.h" #include "components/user_manager/user_manager.h" #include "content/public/browser/storage_partition.h" diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc index 1a667453c804aa..6be341c65c14ff 100644 --- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc @@ -11,6 +11,8 @@ #include #include +#include "ash/components/login/auth/key.h" +#include "ash/components/login/auth/user_context.h" #include "ash/components/proximity_auth/screenlock_bridge.h" #include "ash/public/mojom/tray_action.mojom.h" #include "base/bind.h" @@ -68,8 +70,6 @@ #include "chrome/common/url_constants.h" #include "chrome/grit/generated_resources.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/login/auth/key.h" -#include "chromeos/login/auth/user_context.h" #include "chromeos/network/network_state.h" #include "chromeos/network/network_state_handler.h" #include "chromeos/strings/grit/chromeos_strings.h" diff --git a/chrome/browser/ui/webui/cr_components/most_visited/most_visited_handler.cc b/chrome/browser/ui/webui/cr_components/most_visited/most_visited_handler.cc index 527b9a953dba1e..1083297497a1f8 100644 --- a/chrome/browser/ui/webui/cr_components/most_visited/most_visited_handler.cc +++ b/chrome/browser/ui/webui/cr_components/most_visited/most_visited_handler.cc @@ -52,7 +52,7 @@ MostVisitedHandler::MostVisitedHandler( most_visited_sites_( ChromeMostVisitedSitesFactory::NewForProfile(profile)), web_contents_(web_contents), - logger_(profile, ntp_url), + logger_(profile, ntp_url, ntp_navigation_start_time), ntp_navigation_start_time_(ntp_navigation_start_time), page_handler_(this, std::move(pending_page_handler)), page_(std::move(pending_page)) { diff --git a/chrome/browser/ui/webui/history_clusters/history_clusters_handler.cc b/chrome/browser/ui/webui/history_clusters/history_clusters_handler.cc index b94e0eed3bf7ad..9c68f838526772 100644 --- a/chrome/browser/ui/webui/history_clusters/history_clusters_handler.cc +++ b/chrome/browser/ui/webui/history_clusters/history_clusters_handler.cc @@ -20,6 +20,7 @@ #include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" +#include "components/history/core/browser/history_types.h" #include "components/history_clusters/core/features.h" #include "components/history_clusters/core/history_clusters_prefs.h" #include "components/prefs/pref_service.h" @@ -36,7 +37,8 @@ namespace history_clusters { namespace { // Creates a `mojom::VisitPtr` from a `history_clusters::Visit`. -mojom::URLVisitPtr VisitToMojom(Profile* profile, const Visit& visit) { +mojom::URLVisitPtr VisitToMojom(Profile* profile, + const history::ClusterVisit& visit) { auto visit_mojom = mojom::URLVisit::New(); visit_mojom->normalized_url = visit.normalized_url; diff --git a/chrome/browser/ui/webui/history_clusters/history_clusters_handler_unittest.cc b/chrome/browser/ui/webui/history_clusters/history_clusters_handler_unittest.cc index 38f05360616128..3de98e065fc633 100644 --- a/chrome/browser/ui/webui/history_clusters/history_clusters_handler_unittest.cc +++ b/chrome/browser/ui/webui/history_clusters/history_clusters_handler_unittest.cc @@ -24,10 +24,11 @@ namespace history_clusters { namespace { -Visit CreateVisit(std::string url, - float score, - std::vector related_searches = {}) { - Visit visit; +history::ClusterVisit CreateVisit( + std::string url, + float score, + std::vector related_searches = {}) { + history::ClusterVisit visit; visit.annotated_visit = { {GURL{url}, 0}, {}, {}, {}, 0, 0, history::VisitSource::SOURCE_BROWSED}; visit.annotated_visit.content_annotations.related_searches = related_searches; @@ -54,7 +55,7 @@ TEST_F(HistoryClustersHandlerTest, QueryClustersResultToMojom_BelowTheFold) { QueryClustersResult result; // High scoring visits should always be above the fold. - Cluster cluster1; + history::Cluster cluster1; cluster1.cluster_id = 4; cluster1.visits.push_back(CreateVisit("https://high-score-1", 1)); cluster1.visits.push_back(CreateVisit("https://high-score-2", .8)); @@ -64,7 +65,7 @@ TEST_F(HistoryClustersHandlerTest, QueryClustersResultToMojom_BelowTheFold) { cluster1.keywords.push_back(u"keyword"); // Low scoring visits should be above the fold only if they're one of top 4. - Cluster cluster2; + history::Cluster cluster2; cluster2.cluster_id = 6; cluster2.visits.push_back(CreateVisit("https://low-score-1", .4)); cluster2.visits.push_back(CreateVisit("https://low-score-2", .4)); @@ -74,7 +75,7 @@ TEST_F(HistoryClustersHandlerTest, QueryClustersResultToMojom_BelowTheFold) { cluster2.keywords.push_back(u"keyword"); // 0 scoring visits should be above the fold only if they're 1st. - Cluster cluster3; + history::Cluster cluster3; cluster3.cluster_id = 8; cluster3.visits.push_back(CreateVisit("https://zero-score-1", 0)); cluster3.visits.push_back(CreateVisit("https://zero-score-2", 0)); @@ -131,7 +132,7 @@ TEST_F(HistoryClustersHandlerTest, QueryClustersResultToMojom_BelowTheFold) { TEST_F(HistoryClustersHandlerTest, QueryClustersResultToMojom_RelatedSearches) { QueryClustersResult result; - Cluster cluster; + history::Cluster cluster; cluster.cluster_id = 4; // Should include the top visit's related searches. cluster.visits.push_back( diff --git a/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc b/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc index 8c9d607999b665..83bddc5eab0f39 100644 --- a/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc +++ b/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc @@ -360,7 +360,9 @@ NewTabPageHandler::NewTabPageHandler( profile_(profile), web_contents_(web_contents), ntp_navigation_start_time_(ntp_navigation_start_time), - logger_(profile, GURL(chrome::kChromeUINewTabPageURL)), + logger_(profile, + GURL(chrome::kChromeUINewTabPageURL), + ntp_navigation_start_time), promo_service_(PromoServiceFactory::GetForProfile(profile)), page_{std::move(pending_page)}, receiver_{this, std::move(pending_page_handler)} { diff --git a/chrome/browser/ui/webui/settings/chromeos/bluetooth_section.cc b/chrome/browser/ui/webui/settings/chromeos/bluetooth_section.cc index 790c493d899902..db9d813f66ebd8 100644 --- a/chrome/browser/ui/webui/settings/chromeos/bluetooth_section.cc +++ b/chrome/browser/ui/webui/settings/chromeos/bluetooth_section.cc @@ -290,8 +290,6 @@ void BluetoothSection::AddLoadTimeData(content::WebUIDataSource* html_source) { IDS_SETTINGS_BLUETOOTH_PAIRED_DEVICE_ITEM_A11Y_LABEL_TYPE_TABLET}, {"bluetoothPairedDeviceItemA11yLabelTypeTabletWithBatteryInfo", IDS_SETTINGS_BLUETOOTH_PAIRED_DEVICE_ITEM_A11Y_LABEL_TYPE_TABLET_WITH_BATTERY_INFO}, - {"bluetoothPairedDeviceItemSubpageButtonA11yLabel", - IDS_SETTINGS_BLUETOOTH_PAIRED_DEVICE_ITEM_SUBPAGE_BUTTON_A11Y_LABEL}, {"bluetoothPairDevicePageTitle", IDS_SETTINGS_BLUETOOTH_PAIR_DEVICE_TITLE}, {"bluetoothRemove", IDS_SETTINGS_BLUETOOTH_REMOVE}, diff --git a/chrome/browser/ui/webui/settings/settings_ui.cc b/chrome/browser/ui/webui/settings/settings_ui.cc index 6153eca4dcf07b..9b40b57aa0eb00 100644 --- a/chrome/browser/ui/webui/settings/settings_ui.cc +++ b/chrome/browser/ui/webui/settings/settings_ui.cc @@ -103,6 +103,7 @@ #if BUILDFLAG(IS_CHROMEOS_ASH) #include "ash/components/account_manager/account_manager_factory.h" #include "ash/components/arc/arc_util.h" +#include "ash/components/login/auth/password_visibility_utils.h" #include "ash/components/phonehub/phone_hub_manager.h" #include "ash/constants/ash_features.h" #include "ash/webui/eche_app_ui/eche_app_manager.h" @@ -120,7 +121,6 @@ #include "chrome/browser/ui/webui/settings/chromeos/multidevice_handler.h" #include "chrome/common/chrome_switches.h" #include "chrome/grit/browser_resources.h" -#include "chromeos/login/auth/password_visibility_utils.h" #include "components/account_manager_core/chromeos/account_manager.h" #include "components/account_manager_core/chromeos/account_manager_facade_factory.h" #include "components/user_manager/user.h" diff --git a/chrome/build/linux.pgo.txt b/chrome/build/linux.pgo.txt index 411643fc140f4f..b0c86d47861b5a 100644 --- a/chrome/build/linux.pgo.txt +++ b/chrome/build/linux.pgo.txt @@ -1 +1 @@ -chrome-linux-main-1639591173-b7d6da1a5c5f60f0b1959e21ff4b40acc3fbb5da.profdata +chrome-linux-main-1639612728-dac077a8ded011f5ad0cbb0bd45b03560bfb98d0.profdata diff --git a/chrome/build/mac.pgo.txt b/chrome/build/mac.pgo.txt index 5014d5c2d73972..2cb08684c9328a 100644 --- a/chrome/build/mac.pgo.txt +++ b/chrome/build/mac.pgo.txt @@ -1 +1 @@ -chrome-mac-main-1639591173-0244749f96275593dcee7f94bfec65b371fce288.profdata +chrome-mac-main-1639612728-ae0265bcbcdf930224c3c28fafee767fff83f4be.profdata diff --git a/chrome/build/win32.pgo.txt b/chrome/build/win32.pgo.txt index 2837d9c14945da..86ef5ea98cc44b 100644 --- a/chrome/build/win32.pgo.txt +++ b/chrome/build/win32.pgo.txt @@ -1 +1 @@ -chrome-win32-main-1639580383-b8027ac27b70be2c1132df9ac8ecd76a61e2f927.profdata +chrome-win32-main-1639623365-4a58a889fdbaddffab410e90a85547617b4d2607.profdata diff --git a/chrome/chrome_paks.gni b/chrome/chrome_paks.gni index b676c7bc87f46f..694fb4583f5b83 100644 --- a/chrome/chrome_paks.gni +++ b/chrome/chrome_paks.gni @@ -64,11 +64,13 @@ template("chrome_repack_percent") { sources += [ "$root_gen_dir/ash/app_list/resources/app_list_resources_${percent}_percent.pak", "$root_gen_dir/ash/login/resources/login_resources_${percent}_percent.pak", + "$root_gen_dir/chrome/app_icon_resources_${percent}_percent.pak", "$root_gen_dir/ui/chromeos/resources/ui_chromeos_resources_${percent}_percent.pak", ] deps += [ "//ash/app_list/resources", "//ash/login/resources", + "//chrome/browser/resources/chromeos:app_icon_resources", "//ui/chromeos/resources", ] } diff --git a/chrome/common/extensions/api/storage/storage_schema_manifest_handler.cc b/chrome/common/extensions/api/storage/storage_schema_manifest_handler.cc index 06837d06d2c0e9..86115be236954c 100644 --- a/chrome/common/extensions/api/storage/storage_schema_manifest_handler.cc +++ b/chrome/common/extensions/api/storage/storage_schema_manifest_handler.cc @@ -35,7 +35,10 @@ policy::Schema StorageSchemaManifestHandler::GetSchema( const Extension* extension, std::string* error) { std::string path; - extension->manifest()->GetString(kStorageManagedSchema, &path); + if (const std::string* temp = + extension->manifest()->FindStringPath(kStorageManagedSchema)) { + path = *temp; + } base::FilePath file = base::FilePath::FromUTF8Unsafe(path); if (file.IsAbsolute() || file.ReferencesParent()) { *error = base::StringPrintf("%s must be a relative path without ..", @@ -59,8 +62,7 @@ policy::Schema StorageSchemaManifestHandler::GetSchema( bool StorageSchemaManifestHandler::Parse(Extension* extension, std::u16string* error) { - std::string path; - if (!extension->manifest()->GetString(kStorageManagedSchema, &path)) { + if (extension->manifest()->FindStringPath(kStorageManagedSchema) == nullptr) { *error = base::ASCIIToUTF16( base::StringPrintf("%s must be a string", kStorageManagedSchema)); return false; diff --git a/chrome/common/extensions/api/terminal_private.json b/chrome/common/extensions/api/terminal_private.json index ee397393b67036..ab5a66fd7ae0de 100644 --- a/chrome/common/extensions/api/terminal_private.json +++ b/chrome/common/extensions/api/terminal_private.json @@ -203,6 +203,29 @@ "parameters": [] } }, + { + "name": "getOSInfo", + "type": "function", + "description": "Returns an object containing info about ChromeOS settings that affect the Terminal, e.g. which feature flags are enabled.", + "parameters": [], + "returns_async": { + "name": "callback", + "description": "Callback that will be called with the info object.", + "parameters": [ + { + "name": "info", + "type": "object", + "properties": { + "tmux_integration": { + "description": "True if tmux control mode integration is enabled.", + "type": "boolean" + } + }, + "description": "Information about which features are enabled." + } + ] + } + }, { "name": "getSettings", "type": "function", diff --git a/chrome/common/extensions/chrome_manifest_url_handlers.cc b/chrome/common/extensions/chrome_manifest_url_handlers.cc index 2139f6bfdafd12..42bdbd1d0f9127 100644 --- a/chrome/common/extensions/chrome_manifest_url_handlers.cc +++ b/chrome/common/extensions/chrome_manifest_url_handlers.cc @@ -58,12 +58,13 @@ DevToolsPageHandler::~DevToolsPageHandler() = default; bool DevToolsPageHandler::Parse(Extension* extension, std::u16string* error) { std::unique_ptr manifest_url(new ManifestURL); - std::string devtools_str; - if (!extension->manifest()->GetString(keys::kDevToolsPage, &devtools_str)) { + const std::string* devtools_str = + extension->manifest()->FindStringPath(keys::kDevToolsPage); + if (!devtools_str) { *error = errors::kInvalidDevToolsPage; return false; } - GURL url = extension->GetResourceURL(devtools_str); + GURL url = extension->GetResourceURL(*devtools_str); const bool is_extension_url = url.SchemeIs(kExtensionScheme) && url.host_piece() == extension->id(); // TODO(caseq): using http(s) is unsupported and will be disabled in m83. diff --git a/chrome/common/extensions/manifest_handlers/minimum_chrome_version_checker.cc b/chrome/common/extensions/manifest_handlers/minimum_chrome_version_checker.cc index 1edfe6d6d68f3e..6b1b7cbdeb8fcb 100644 --- a/chrome/common/extensions/manifest_handlers/minimum_chrome_version_checker.cc +++ b/chrome/common/extensions/manifest_handlers/minimum_chrome_version_checker.cc @@ -27,14 +27,14 @@ MinimumChromeVersionChecker::~MinimumChromeVersionChecker() { bool MinimumChromeVersionChecker::Parse(Extension* extension, std::u16string* error) { - std::string minimum_version_string; - if (!extension->manifest()->GetString(keys::kMinimumChromeVersion, - &minimum_version_string)) { + const std::string* minimum_version_string = + extension->manifest()->FindStringPath(keys::kMinimumChromeVersion); + if (minimum_version_string == nullptr) { *error = errors::kInvalidMinimumChromeVersion; return false; } - base::Version minimum_version(minimum_version_string); + base::Version minimum_version(*minimum_version_string); if (!minimum_version.IsValid()) { *error = errors::kInvalidMinimumChromeVersion; return false; @@ -49,8 +49,7 @@ bool MinimumChromeVersionChecker::Parse(Extension* extension, if (current_version.CompareTo(minimum_version) < 0) { *error = ErrorUtils::FormatErrorMessageUTF16( errors::kChromeVersionTooLow, - l10n_util::GetStringUTF8(IDS_PRODUCT_NAME), - minimum_version_string); + l10n_util::GetStringUTF8(IDS_PRODUCT_NAME), *minimum_version_string); return false; } return true; diff --git a/chrome/common/extensions/manifest_unittest.cc b/chrome/common/extensions/manifest_unittest.cc index f80a9f4824f836..fd761e208cbf4f 100644 --- a/chrome/common/extensions/manifest_unittest.cc +++ b/chrome/common/extensions/manifest_unittest.cc @@ -109,14 +109,16 @@ TEST_F(ManifestUnitTest, Extension) { AssertType(manifest.get(), Manifest::TYPE_EXTENSION); // The known key 'background.page' should be accessible. - std::string value; - EXPECT_TRUE(manifest->GetString(keys::kBackgroundPage, &value)); - EXPECT_EQ("bg.html", value); - - // The unknown key 'unknown_key' should be accesible. - value.clear(); - EXPECT_TRUE(manifest->GetString("unknown_key", &value)); - EXPECT_EQ("foo", value); + const std::string* background_page = + manifest->FindStringPath(keys::kBackgroundPage); + ASSERT_TRUE(background_page); + EXPECT_EQ("bg.html", *background_page); + + // The unknown key 'unknown_key' should be accessible. + const std::string* unknown_key_value = + manifest->FindStringPath("unknown_key"); + ASSERT_TRUE(unknown_key_value); + EXPECT_EQ("foo", *unknown_key_value); // Test EqualsForTesting. auto manifest2 = std::make_unique( diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index 85d0971203acac..d4ed0a57b830cf 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn @@ -350,11 +350,16 @@ static_library("test_support") { "//components/ukm:test_support", "//components/ukm:ukm_test_helper", "//components/web_modal", - "//extensions/browser:test_support", - "//extensions/common:test_support", "//ui/snapshot", ] + if (enable_extensions) { + public_deps += [ + "//extensions/browser:test_support", + "//extensions/common:test_support", + ] + } + deps += [ "//components/constrained_window" ] sources += [ @@ -1070,7 +1075,6 @@ if (!is_android && !is_fuchsia) { "//chrome/browser/continuous_search:browser_tests", "//chrome/browser/devtools", "//chrome/browser/devtools:test_support", - "//chrome/browser/extensions:test_support", "//chrome/browser/image_decoder:browser_tests", "//chrome/browser/media/router:media_router_feature", "//chrome/browser/media/router:test_support", @@ -1297,9 +1301,6 @@ if (!is_android && !is_fuchsia) { "//device/bluetooth:mocks", "//device/fido:cablev2_test_util", "//device/fido:test_support", - "//extensions/browser/updater", - "//extensions/buildflags", - "//extensions/renderer", "//google_apis:test_support", "//media:media_buildflags", "//media:test_support", @@ -1360,6 +1361,15 @@ if (!is_android && !is_fuchsia) { "//v8", ] + if (enable_extensions) { + deps += [ + "//chrome/browser/extensions:test_support", + "//extensions/browser/updater", + "//extensions/buildflags", + "//extensions/renderer", + ] + } + # Runtime dependencies data_deps = [ "//chrome:browser_tests_pak", @@ -1540,7 +1550,6 @@ if (!is_android && !is_fuchsia) { "../browser/enterprise/connectors/connectors_service_browsertest.cc", "../browser/enterprise/reporting/report_scheduler_browsertest.cc", "../browser/enterprise/util/managed_browser_utils_browsertest.cc", - "../browser/extensions/protocol_handler_apitest.cc", "../browser/fast_shutdown_browsertest.cc", "../browser/favicon/content_favicon_driver_browsertest.cc", "../browser/federated_learning/floc_eligibility_browsertest.cc", @@ -2153,10 +2162,6 @@ if (!is_android && !is_fuchsia) { "../browser/speech/speech_recognition_browsertest.cc", ] - if (enable_extensions) { - sources += [ "../browser/extensions/preinstalled_apps_browsertest.cc" ] - } - if (enable_click_to_call) { sources += [ "../browser/ui/views/sharing/click_to_call_browsertest.cc" ] } @@ -2703,10 +2708,12 @@ if (!is_android && !is_fuchsia) { "../browser/extensions/navigation_observer_browsertest.cc", "../browser/extensions/options_page_apitest.cc", "../browser/extensions/page_action_browsertest.cc", + "../browser/extensions/preinstalled_apps_browsertest.cc", "../browser/extensions/printer_provider_apitest.cc", "../browser/extensions/process_management_browsertest.cc", "../browser/extensions/process_manager_browsertest.cc", "../browser/extensions/process_util_browsertest.cc", + "../browser/extensions/protocol_handler_apitest.cc", "../browser/extensions/renderer_initialization_browsertest.cc", "../browser/extensions/sandboxed_pages_apitest.cc", "../browser/extensions/script_executor_browsertest.cc", @@ -2796,23 +2803,53 @@ if (!is_android && !is_fuchsia) { if (is_chromeos_ash) { sources += [ "../browser/apps/platform_apps/api/arc_apps_private/arc_apps_private_apitest.cc", + "../browser/chromeos/extensions/accessibility_features_apitest.cc", + "../browser/chromeos/extensions/action_handlers/action_handlers_apitest.cc", + "../browser/chromeos/extensions/autotest_private/autotest_private_apitest.cc", + "../browser/chromeos/extensions/default_keyboard_extension_browser_test.cc", + "../browser/chromeos/extensions/default_keyboard_extension_browser_test.h", + "../browser/chromeos/extensions/echo_private_apitest.cc", + "../browser/chromeos/extensions/file_manager/file_manager_private_apitest.cc", + "../browser/chromeos/extensions/file_system_provider/file_system_provider_apitest.cc", + "../browser/chromeos/extensions/incoming_native_messaging_apitest.cc", + "../browser/chromeos/extensions/info_private_apitest.cc", + "../browser/chromeos/extensions/input_method_apitest_chromeos.cc", + "../browser/chromeos/extensions/login_screen/login/cleanup/extension_cleanup_handler_browsertest.cc", + "../browser/chromeos/extensions/login_screen/login/login_apitest.cc", + "../browser/chromeos/extensions/login_screen/login_screen_ui/login_screen_ui_apitest.cc", + "../browser/chromeos/extensions/speech/speech_recognition_private_apitest.cc", + "../browser/chromeos/extensions/speech/speech_recognition_private_base_test.cc", + "../browser/chromeos/extensions/speech/speech_recognition_private_base_test.h", + "../browser/chromeos/extensions/speech/speech_recognition_private_manager_browsertest.cc", + "../browser/chromeos/extensions/speech/speech_recognition_private_recognizer_browsertest.cc", + "../browser/chromeos/extensions/users_private/users_private_apitest.cc", + "../browser/chromeos/extensions/wallpaper_apitest.cc", + "../browser/chromeos/extensions/wallpaper_manager_browsertest.cc", + "../browser/chromeos/extensions/wallpaper_private_apitest.cc", + "../browser/chromeos/extensions/wm/wm_desks_private_apitest.cc", "../browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_apitest_chromeos.cc", + "../browser/extensions/api/certificate_provider/certificate_provider_apitest.cc", "../browser/extensions/api/crash_report_private/crash_report_private_apitest.cc", "../browser/extensions/api/enterprise_device_attributes/enterprise_device_attributes_apitest.cc", "../browser/extensions/api/enterprise_networking_attributes/enterprise_networking_attributes_ash_apitest.cc", "../browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_apitest_nss.cc", + "../browser/extensions/api/file_manager/file_browser_handler_api_ash_test.cc", "../browser/extensions/api/file_system/file_system_apitest_chromeos.cc", "../browser/extensions/api/force_installed_affiliated_extension_apitest.cc", "../browser/extensions/api/force_installed_affiliated_extension_apitest.h", "../browser/extensions/api/input_ime/input_ime_apitest_chromeos.cc", + "../browser/extensions/api/networking_private/networking_private_apitest.cc", + "../browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc", "../browser/extensions/api/platform_keys/platform_keys_apitest_nss.cc", "../browser/extensions/api/platform_keys/platform_keys_test_base.cc", "../browser/extensions/api/platform_keys/platform_keys_test_base.h", + "../browser/extensions/api/settings_private/settings_private_browsertest_chromeos.cc", "../browser/extensions/api/system_display/system_display_chromeos_apitest.cc", "../browser/extensions/api/terminal/terminal_private_apitest.cc", "../browser/extensions/api/terminal/terminal_private_browsertest.cc", "../browser/extensions/api/video_capture/video_capture_apitest_chromeos.cc", "../browser/extensions/api/virtual_keyboard_private/virtual_keyboard_private_apitest.cc", + "../browser/extensions/api/vpn_provider/vpn_provider_apitest.cc", ] deps += [ @@ -3395,30 +3432,6 @@ if (!is_android && !is_fuchsia) { "../browser/ash/web_applications/system_web_app_integration_test.h", "../browser/ash/wilco_dtc_supportd/wilco_dtc_supportd_web_request_service_browsertest.cc", "../browser/chrome_main_browsertest.cc", - "../browser/chromeos/extensions/accessibility_features_apitest.cc", - "../browser/chromeos/extensions/action_handlers/action_handlers_apitest.cc", - "../browser/chromeos/extensions/autotest_private/autotest_private_apitest.cc", - "../browser/chromeos/extensions/default_keyboard_extension_browser_test.cc", - "../browser/chromeos/extensions/default_keyboard_extension_browser_test.h", - "../browser/chromeos/extensions/echo_private_apitest.cc", - "../browser/chromeos/extensions/file_manager/file_manager_private_apitest.cc", - "../browser/chromeos/extensions/file_system_provider/file_system_provider_apitest.cc", - "../browser/chromeos/extensions/incoming_native_messaging_apitest.cc", - "../browser/chromeos/extensions/info_private_apitest.cc", - "../browser/chromeos/extensions/input_method_apitest_chromeos.cc", - "../browser/chromeos/extensions/login_screen/login/cleanup/extension_cleanup_handler_browsertest.cc", - "../browser/chromeos/extensions/login_screen/login/login_apitest.cc", - "../browser/chromeos/extensions/login_screen/login_screen_ui/login_screen_ui_apitest.cc", - "../browser/chromeos/extensions/speech/speech_recognition_private_apitest.cc", - "../browser/chromeos/extensions/speech/speech_recognition_private_base_test.cc", - "../browser/chromeos/extensions/speech/speech_recognition_private_base_test.h", - "../browser/chromeos/extensions/speech/speech_recognition_private_manager_browsertest.cc", - "../browser/chromeos/extensions/speech/speech_recognition_private_recognizer_browsertest.cc", - "../browser/chromeos/extensions/users_private/users_private_apitest.cc", - "../browser/chromeos/extensions/wallpaper_apitest.cc", - "../browser/chromeos/extensions/wallpaper_manager_browsertest.cc", - "../browser/chromeos/extensions/wallpaper_private_apitest.cc", - "../browser/chromeos/extensions/wm/wm_desks_private_apitest.cc", "../browser/chromeos/policy/dlp/data_transfer_dlp_controller_browsertest.cc", "../browser/chromeos/policy/dlp/dlp_content_restriction_set_browsertest.cc", "../browser/chromeos/policy/dlp/dlp_content_tab_helper_browsertest.cc", @@ -3433,12 +3446,6 @@ if (!is_android && !is_fuchsia) { "../browser/chromeos/policy/dlp/mock_dlp_rules_manager.h", "../browser/device_api/device_attribute_api_browsertest.cc", "../browser/drive/drive_notification_manager_factory_browsertest.cc", - "../browser/extensions/api/certificate_provider/certificate_provider_apitest.cc", - "../browser/extensions/api/file_manager/file_browser_handler_api_ash_test.cc", - "../browser/extensions/api/networking_private/networking_private_apitest.cc", - "../browser/extensions/api/networking_private/networking_private_chromeos_apitest.cc", - "../browser/extensions/api/settings_private/settings_private_browsertest_chromeos.cc", - "../browser/extensions/api/vpn_provider/vpn_provider_apitest.cc", "../browser/metrics/chromeos_metrics_provider_browsertest.cc", "../browser/metrics/family_link_user_metrics_provider_browsertest.cc", "../browser/metrics/family_user_metrics_provider_browsertest.cc", @@ -3669,6 +3676,9 @@ if (!is_android && !is_fuchsia) { "//ash/components/drivefs:test_support", "//ash/components/drivefs/mojom", "//ash/components/geolocation", + "//ash/components/login/auth", + "//ash/components/login/auth:challenge_response_key", + "//ash/components/login/auth:test_support", "//ash/components/smbfs", "//ash/components/timezone", "//ash/keyboard/ui:test_support", @@ -3738,9 +3748,6 @@ if (!is_android && !is_fuchsia) { "//chromeos/dbus/update_engine", "//chromeos/dbus/upstart", "//chromeos/dbus/vm_plugin_dispatcher", - "//chromeos/login/auth", - "//chromeos/login/auth:challenge_response_key", - "//chromeos/login/auth:test_support", "//chromeos/login/login_state:test_support", "//chromeos/process_proxy", "//chromeos/services/assistant:lib", @@ -6292,6 +6299,7 @@ test("unit_tests") { "//ash/components/audio", "//ash/components/disks", "//ash/components/disks:test_support", + "//ash/components/login/auth:test_support", "//ash/components/login/session", "//ash/components/proximity_auth", "//ash/components/proximity_auth:test_support", @@ -6331,7 +6339,6 @@ test("unit_tests") { "//chromeos/dbus/shill", "//chromeos/dbus/update_engine", "//chromeos/dbus/update_engine:proto", - "//chromeos/login/auth:test_support", "//chromeos/login/login_state:test_support", "//chromeos/services/assistant/public/cpp", "//chromeos/services/assistant/public/shared", @@ -6582,6 +6589,7 @@ test("unit_tests") { "../browser/ui/app_list/arc/arc_app_utils_unittest.cc", "../browser/ui/app_list/arc/arc_default_app_list_unittest.cc", "../browser/ui/app_list/arc/arc_vpn_provider_unittest.cc", + "../browser/ui/app_list/arc/intent_unittest.cc", "../browser/ui/app_list/arc/mock_arc_app_list_prefs_observer.cc", "../browser/ui/app_list/arc/mock_arc_app_list_prefs_observer.h", "../browser/ui/app_list/chrome_app_list_item_manager_unittest.cc", @@ -8626,10 +8634,10 @@ if (!is_android && !is_fuchsia) { if (is_chromeos_ash) { deps += [ + "//ash/components/login/auth", "//chrome/browser/chromeos:test_support", "//chrome/browser/media/router:test_support", "//chromeos/dbus", - "//chromeos/login/auth", "//chromeos/ui/frame:test_support", "//components/exo/wayland:weston_test_stub", "//ui/display:display_manager_test_api", diff --git a/chrome/test/data/extensions/platform_apps/web_view/shim/guest_noreferrer.html b/chrome/test/data/extensions/platform_apps/web_view/shim/guest_noreferrer.html index 1004d147a2f282..caa768f640f422 100644 --- a/chrome/test/data/extensions/platform_apps/web_view/shim/guest_noreferrer.html +++ b/chrome/test/data/extensions/platform_apps/web_view/shim/guest_noreferrer.html @@ -14,7 +14,7 @@ -Noreferrer guest link diff --git a/chrome/test/data/extensions/theme/Cached Theme.pak b/chrome/test/data/extensions/theme/Cached Theme.pak deleted file mode 100644 index cc16deb3453fe5..00000000000000 Binary files a/chrome/test/data/extensions/theme/Cached Theme.pak and /dev/null differ diff --git a/chrome/test/data/webui/chromeos/diagnostics/input_list_test.js b/chrome/test/data/webui/chromeos/diagnostics/input_list_test.js index 5e73a2c535aa6a..b0919b7e475670 100644 --- a/chrome/test/data/webui/chromeos/diagnostics/input_list_test.js +++ b/chrome/test/data/webui/chromeos/diagnostics/input_list_test.js @@ -4,7 +4,7 @@ import 'chrome://diagnostics/input_list.js'; -import {ConnectionType, KeyboardInfo, MechanicalLayout, NumberPadPresence, PhysicalLayout, TopRowKey, TouchDeviceInfo, TouchDeviceType} from 'chrome://diagnostics/diagnostics_types.js'; +import {ConnectionType, KeyboardInfo, MechanicalLayout, NumberPadPresence, PhysicalLayout, TouchDeviceInfo, TouchDeviceType} from 'chrome://diagnostics/diagnostics_types.js'; import {fakeKeyboards, fakeTouchDevices} from 'chrome://diagnostics/fake_data.js'; import {FakeInputDataProvider} from 'chrome://diagnostics/fake_input_data_provider.js'; import {setInputDataProviderForTesting} from 'chrome://diagnostics/mojo_interface_provider.js'; @@ -87,12 +87,6 @@ export function inputListTestSuite() { mechanicalLayout: MechanicalLayout.kUnknown, hasAssistantKey: false, numberPadPresent: NumberPadPresence.kUnknown, - topRowKeys: [ - TopRowKey.kBack, TopRowKey.kForward, TopRowKey.kRefresh, - TopRowKey.kFullscreen, TopRowKey.kOverview, - TopRowKey.kScreenBrightnessDown, TopRowKey.kScreenBrightnessUp, - TopRowKey.kVolumeMute, TopRowKey.kVolumeDown, TopRowKey.kVolumeUp - ], }; let keyboardCard; return initializeInputList() diff --git a/chrome/test/data/webui/chromeos/personalization_app/personalization_app_controller_test.js b/chrome/test/data/webui/chromeos/personalization_app/personalization_app_controller_test.js index b4ef8c21cd895b..6dc497fe9fef41 100644 --- a/chrome/test/data/webui/chromeos/personalization_app/personalization_app_controller_test.js +++ b/chrome/test/data/webui/chromeos/personalization_app/personalization_app_controller_test.js @@ -61,7 +61,7 @@ suite('Personalization app controller', () => { let expectedCount, expectedAlbums, expectedPhotos; if (isGooglePhotosIntegrationEnabled) { - expectedCount = 0n; + expectedCount = 0; expectedAlbums = []; expectedPhotos = []; } else { @@ -802,4 +802,4 @@ suite('local images available but no internet connection', () => { ], personalizationStore.states.map(filterAndFlattenState(['error']))); }); -}); \ No newline at end of file +}); diff --git a/chrome/test/data/webui/chromeos/personalization_app/test_wallpaper_interface_provider.js b/chrome/test/data/webui/chromeos/personalization_app/test_wallpaper_interface_provider.js index fecf712c7eb38a..120c5f12abc26b 100644 --- a/chrome/test/data/webui/chromeos/personalization_app/test_wallpaper_interface_provider.js +++ b/chrome/test/data/webui/chromeos/personalization_app/test_wallpaper_interface_provider.js @@ -162,7 +162,7 @@ export class TestWallpaperProvider extends TestBrowserProxy { fetchGooglePhotosCount() { this.methodCalled('fetchGooglePhotosCount'); const count = - loadTimeData.getBoolean('isGooglePhotosIntegrationEnabled') ? 0n : -1n; + loadTimeData.getBoolean('isGooglePhotosIntegrationEnabled') ? 0 : -1; return Promise.resolve({count: count}); } diff --git a/chrome/test/data/webui/chromeos/personalization_app/wallpaper_collections_element_test.js b/chrome/test/data/webui/chromeos/personalization_app/wallpaper_collections_element_test.js index 9490a018773be7..992a67951169cb 100644 --- a/chrome/test/data/webui/chromeos/personalization_app/wallpaper_collections_element_test.js +++ b/chrome/test/data/webui/chromeos/personalization_app/wallpaper_collections_element_test.js @@ -65,7 +65,7 @@ export function WallpaperCollectionsTest() { wallpaperCollectionsElement = initElement(WallpaperCollections.is); - personalizationStore.data.googlePhotos.count = 1234n; + personalizationStore.data.googlePhotos.count = 1234; personalizationStore.data.loading.googlePhotos.count = false; personalizationStore.notifyObservers(); diff --git a/chrome/test/data/webui/print_preview/BUILD.gn b/chrome/test/data/webui/print_preview/BUILD.gn index 80090195aad022..66cac052e5a349 100644 --- a/chrome/test/data/webui/print_preview/BUILD.gn +++ b/chrome/test/data/webui/print_preview/BUILD.gn @@ -28,13 +28,9 @@ preprocessed_tests = [ "print_preview_sidebar_test.ts", "print_preview_test_utils.ts", "restore_state_test.ts", - "user_manager_test.ts", + "user_manager_test.js", ] -if (is_mac || is_win) { - preprocessed_tests += [ "system_dialog_browsertest.ts" ] -} - # Print Preview test files that do not require preprocessing. If adding # // { @@ -72,23 +72,23 @@ suite('SettingsSelectTest', function() { ], }; flush(); - const option0 = JSON.stringify(settingsSelect.capability!.option[0]!); - const option1 = JSON.stringify(settingsSelect.capability!.option[1]!); - const select = settingsSelect.shadowRoot!.querySelector('select')!; + const option0 = JSON.stringify(settingsSelect.capability.option[0]); + const option1 = JSON.stringify(settingsSelect.capability.option[1]); + const select = settingsSelect.shadowRoot.querySelector('select'); // Normally done for initialization by the model and parent section. settingsSelect.set( - 'settings.fruit.value', settingsSelect.capability!.option[1]!); + 'settings.fruit.value', settingsSelect.capability.option[1]); settingsSelect.selectValue(option1); // Verify that the selected option and names are as expected. assertEquals(2, select.options.length); assertEquals(1, select.selectedIndex); assertFalse(settingsSelect.getSetting('fruit').setFromUi); - assertEquals('lime', select.options[0]!.textContent!.trim()); - assertEquals('orange', select.options[1]!.textContent!.trim()); - assertEquals(option0, select.options[0]!.value); - assertEquals(option1, select.options[1]!.value); + assertEquals('lime', select.options[0].textContent.trim()); + assertEquals('orange', select.options[1].textContent.trim()); + assertEquals(option0, select.options[0].value); + assertEquals(option1, select.options[1].value); // Verify that selecting an new option in the dropdown sets the setting. await selectOption(settingsSelect, option0); diff --git a/chrome/test/data/webui/print_preview/system_dialog_browsertest.ts b/chrome/test/data/webui/print_preview/system_dialog_browsertest.js similarity index 56% rename from chrome/test/data/webui/print_preview/system_dialog_browsertest.ts rename to chrome/test/data/webui/print_preview/system_dialog_browsertest.js index d68c9ecfc53786..5ba9176c1af80a 100644 --- a/chrome/test/data/webui/print_preview/system_dialog_browsertest.ts +++ b/chrome/test/data/webui/print_preview/system_dialog_browsertest.js @@ -2,40 +2,39 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import {CrButtonElement, NativeLayerImpl, PluginProxyImpl, PrintPreviewLinkContainerElement, PrintPreviewSidebarElement, ScalingType, whenReady} from 'chrome://print/print_preview.js'; +import {Destination, DestinationConnectionStatus, DestinationOrigin, DestinationType, NativeLayerImpl, PluginProxyImpl, PrintPreviewLinkContainerElement, PrintPreviewSidebarElement, whenReady} from 'chrome://print/print_preview.js'; import {assert} from 'chrome://resources/js/assert.m.js'; -import {assertEquals, assertFalse, assertTrue} from 'chrome://webui-test/chai_assert.js'; +import {isWindows} from 'chrome://resources/js/cr.m.js'; import {eventToPromise, waitBeforeNextRender} from 'chrome://webui-test/test_util.js'; import {NativeLayerStub} from './native_layer_stub.js'; -import {getDefaultInitialSettings, selectOption} from './print_preview_test_utils.js'; +import {getCddTemplate, getDefaultInitialSettings, selectOption} from './print_preview_test_utils.js'; import {TestPluginProxy} from './test_plugin_proxy.js'; -const system_dialog_browsertest = { - suiteName: 'SystemDialogBrowserTest', - TestNames: { - LinkTriggersLocalPrint: 'link triggers local print', - InvalidSettingsDisableLink: 'invalid settings disable link', - }, +window.system_dialog_browsertest = {}; +system_dialog_browsertest.suiteName = 'SystemDialogBrowserTest'; +/** @enum {string} */ +system_dialog_browsertest.TestNames = { + LinkTriggersLocalPrint: 'link triggers local print', + InvalidSettingsDisableLink: 'invalid settings disable link', }; -Object.assign(window, {system_dialog_browsertest: system_dialog_browsertest}); - suite(system_dialog_browsertest.suiteName, function() { - let sidebar: PrintPreviewSidebarElement; + /** @type {?PrintPreviewSidebarElement} */ + let sidebar = null; - let nativeLayer: NativeLayerStub; + /** @type {?NativeLayer} */ + let nativeLayer = null; - let linkContainer: PrintPreviewLinkContainerElement; + /** @type {?PrintPreviewLinkContainerElement} */ + let linkContainer = null; - let link: HTMLElement; + /** @type {?HTMLElement} */ + let link = null; - // - let printTicketKey: string = 'showSystemDialog'; - // - // - let printTicketKey: string = 'openPDFinPreview'; - // + /** @type {string} */ + let printTicketKey = ''; + /** @override */ setup(function() { nativeLayer = new NativeLayerStub(); NativeLayerImpl.setInstance(nativeLayer); @@ -50,7 +49,8 @@ suite(system_dialog_browsertest.suiteName, function() { const page = document.createElement('print-preview-app'); document.body.appendChild(page); - sidebar = page.shadowRoot!.querySelector('print-preview-sidebar')!; + const previewArea = page.$.previewArea; + sidebar = page.shadowRoot.querySelector('print-preview-sidebar'); return Promise .all([ waitBeforeNextRender(page), @@ -59,22 +59,15 @@ suite(system_dialog_browsertest.suiteName, function() { nativeLayer.whenCalled('getPrinterCapabilities'), ]) .then(function() { - linkContainer = sidebar.shadowRoot!.querySelector( - 'print-preview-link-container')!; + linkContainer = + sidebar.shadowRoot.querySelector('print-preview-link-container'); return nativeLayer.whenCalled('getPreview'); }) .then(function() { - assertEquals( - 'FooDevice', - sidebar.shadowRoot! - .querySelector( - 'print-preview-destination-settings')!.destination!.id); - // - link = linkContainer.$.systemDialogLink; - // - // - link = linkContainer.$.openPdfInPreviewLink; - // + assertEquals('FooDevice', page.destination_.id); + link = isWindows ? linkContainer.$.systemDialogLink : + linkContainer.$.openPdfInPreviewLink; + printTicketKey = isWindows ? 'showSystemDialog' : 'openPDFInPreview'; }); }); @@ -85,8 +78,8 @@ suite(system_dialog_browsertest.suiteName, function() { assertFalse(link.hidden); link.click(); // Should result in a print call and dialog should close. - return nativeLayer.whenCalled('print').then((printTicket: string) => { - assertTrue(JSON.parse(printTicket)[printTicketKey]); + return nativeLayer.whenCalled('print').then(function(printTicket) { + expectTrue(JSON.parse(printTicket)[printTicketKey]); return nativeLayer.whenCalled('dialogClose'); }); }); @@ -98,24 +91,26 @@ suite(system_dialog_browsertest.suiteName, function() { assertFalse(link.hidden); const moreSettingsElement = - sidebar.shadowRoot!.querySelector('print-preview-more-settings')!; + sidebar.shadowRoot.querySelector('print-preview-more-settings'); moreSettingsElement.$.label.click(); - const scalingSettings = sidebar.shadowRoot!.querySelector( - 'print-preview-scaling-settings')!; + const scalingSettings = + sidebar.shadowRoot.querySelector('print-preview-scaling-settings'); assertFalse(scalingSettings.hidden); nativeLayer.resetResolver('getPreview'); let previewCalls = 0; // Set scaling settings to custom. - return selectOption(scalingSettings, ScalingType.CUSTOM.toString()) + return selectOption( + scalingSettings, + scalingSettings.ScalingValue.CUSTOM.toString()) .then(() => { previewCalls = nativeLayer.getCallCount('getPreview'); // Set an invalid input. const scalingSettingsInput = - scalingSettings.shadowRoot! - .querySelector('print-preview-number-settings-section')!.$ - .userValue.inputElement; + scalingSettings.shadowRoot + .querySelector('print-preview-number-settings-section') + .$.userValue.inputElement; scalingSettingsInput.value = '0'; scalingSettingsInput.dispatchEvent( new CustomEvent('input', {composed: true, bubbles: true})); @@ -124,15 +119,14 @@ suite(system_dialog_browsertest.suiteName, function() { }) .then(() => { // Expect disabled print button - const parentElement = sidebar.shadowRoot!.querySelector( - 'print-preview-button-strip')!; + const parentElement = sidebar.shadowRoot.querySelector( + 'print-preview-button-strip'); const printButton = - parentElement.shadowRoot!.querySelector( - '.action-button')!; + parentElement.shadowRoot.querySelector('.action-button'); assertTrue(printButton.disabled); assertTrue(linkContainer.disabled); assertFalse(link.hidden); - assertTrue(link.querySelector('cr-icon-button')!.disabled); + assertTrue(link.querySelector('cr-icon-button').disabled); // No new preview assertEquals( diff --git a/chrome/test/data/webui/print_preview/tsconfig_base.json b/chrome/test/data/webui/print_preview/tsconfig_base.json index 63561619c9429b..6dbee097acee44 100644 --- a/chrome/test/data/webui/print_preview/tsconfig_base.json +++ b/chrome/test/data/webui/print_preview/tsconfig_base.json @@ -1,6 +1,7 @@ { "extends": "../../../../../tools/typescript/tsconfig_base.json", "compilerOptions": { + "allowJs": true, "typeRoots": [ "./../../../../../third_party/node/node_modules/@types" ] diff --git a/chrome/test/data/webui/print_preview/user_manager_test.ts b/chrome/test/data/webui/print_preview/user_manager_test.js similarity index 81% rename from chrome/test/data/webui/print_preview/user_manager_test.ts rename to chrome/test/data/webui/print_preview/user_manager_test.js index 15f5297413a98c..35546ced6cc89c 100644 --- a/chrome/test/data/webui/print_preview/user_manager_test.ts +++ b/chrome/test/data/webui/print_preview/user_manager_test.js @@ -2,11 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import {CloudPrintInterfaceImpl, DestinationStore, LocalDestinationInfo, NativeLayerImpl, PrintPreviewUserManagerElement} from 'chrome://print/print_preview.js'; +import {CloudPrintInterfaceImpl, DestinationStore, NativeLayerImpl} from 'chrome://print/print_preview.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; import {webUIListenerCallback} from 'chrome://resources/js/cr.m.js'; -import {assertEquals} from 'chrome://webui-test/chai_assert.js'; import {CloudPrintInterfaceStub} from './cloud_print_interface_stub.js'; + // import {setNativeLayerCrosInstance} from './native_layer_cros_stub.js'; // @@ -16,21 +17,27 @@ import {createDestinationStore, getCloudDestination, getDestinations, setupTestL suite('UserManagerTest', function() { - let userManager: PrintPreviewUserManagerElement; + /** @type {?PrintPreviewUserManagerElement} */ + let userManager = null; - let destinationStore: DestinationStore; + /** @type {?DestinationStore} */ + let destinationStore = null; - let nativeLayer: NativeLayerStub; + /** @type {?NativeLayer} */ + let nativeLayer = null; - let cloudPrintInterface: CloudPrintInterfaceStub; + /** @type {?CloudPrintInterface} */ + let cloudPrintInterface = null; - const account1: string = 'foo@chromium.org'; - const account2: string = 'bar@chromium.org'; + const account1 = 'foo@chromium.org'; + const account2 = 'bar@chromium.org'; + /** @override */ suiteSetup(function() { setupTestListenerElement(); }); + /** @override */ setup(function() { document.body.innerHTML = ''; @@ -50,12 +57,14 @@ suite('UserManagerTest', function() { // Initialize destination store. destinationStore = createDestinationStore(); destinationStore.setCloudPrintInterface(cloudPrintInterface); - const localDestinations: LocalDestinationInfo[] = []; - getDestinations(localDestinations); + const localDestinations = []; + const destinations = getDestinations(localDestinations); nativeLayer.setLocalDestinations(localDestinations); // Set up user manager + userManager.appKioskMode = false; userManager.destinationStore = destinationStore; + userManager.shouldReloadCookies = false; userManager.cloudPrintDisabled = false; document.body.appendChild(userManager); diff --git a/chrome/test/data/webui/settings/chromeos/os_paired_bluetooth_list_item_tests.js b/chrome/test/data/webui/settings/chromeos/os_paired_bluetooth_list_item_tests.js index 383c338d3e90b5..f60c19e0d0d3ed 100644 --- a/chrome/test/data/webui/settings/chromeos/os_paired_bluetooth_list_item_tests.js +++ b/chrome/test/data/webui/settings/chromeos/os_paired_bluetooth_list_item_tests.js @@ -88,10 +88,6 @@ suite('OsPairedBluetoothListItemTest', function() { pairedBluetoothListItem.i18n( 'bluetoothPairedDeviceItemA11yLabelTypeUnknown', itemIndex + 1, listSize, publicName)); - assertEquals( - getSubpageButtonA11yLabel(), - pairedBluetoothListItem.i18n( - 'bluetoothPairedDeviceItemSubpageButtonA11yLabel', publicName)); // Set device nickname, type and battery info. const nickname = 'nickname'; @@ -116,10 +112,6 @@ suite('OsPairedBluetoothListItemTest', function() { pairedBluetoothListItem.i18n( 'bluetoothPairedDeviceItemA11yLabelTypeComputerWithBatteryInfo', itemIndex + 1, listSize, nickname, batteryPercentage)); - assertEquals( - getSubpageButtonA11yLabel(), - pairedBluetoothListItem.i18n( - 'bluetoothPairedDeviceItemSubpageButtonA11yLabel', nickname)); }); test('Battery percentage out of bounds', async function() { diff --git a/chrome/updater/win/setup/setup_util.cc b/chrome/updater/win/setup/setup_util.cc index a136926e4157cd..3173d9a2596953 100644 --- a/chrome/updater/win/setup/setup_util.cc +++ b/chrome/updater/win/setup/setup_util.cc @@ -35,30 +35,7 @@ #include "chrome/updater/win/win_constants.h" #include "chrome/updater/win/win_util.h" -// Specialization for std::hash so that IID instances can be stored in an -// associative container. This implementation of the hash function adds -// together four 32-bit integers which make up an IID. The function does not -// have to be efficient or guarantee no collisions. It is used infrequently, -// for a small number of IIDs, and the container deals with collisions. -template <> -struct std::hash { - size_t operator()(const IID& iid) const { - return iid.Data1 + (iid.Data2 + (iid.Data3 << 16)) + [&iid]() { - size_t val = 0; - for (int i = 0; i < 2; ++i) { - for (int j = 0; j < 4; ++j) { - val += (iid.Data4[j + i * 4] << (j * 4)); - } - } - return val; - }(); - } -}; - namespace updater { -namespace { - -} // namespace bool RegisterWakeTask(const base::CommandLine& run_command, UpdaterScope scope) { diff --git a/chrome/updater/win/win_util.h b/chrome/updater/win/win_util.h index f5f0097968d630..97ee823947289d 100644 --- a/chrome/updater/win/win_util.h +++ b/chrome/updater/win/win_util.h @@ -7,10 +7,11 @@ #include -#include - +#include #include +#include "base/containers/span.h" +#include "base/hash/hash.h" #include "base/process/process_iterator.h" #include "base/win/atl.h" #include "base/win/scoped_handle.h" @@ -21,6 +22,17 @@ namespace base { class FilePath; } +// Specialization for std::hash so that IID values can be stored in an +// associative container. +template <> +struct std::hash { + size_t operator()(const IID& iid) const { + static_assert(sizeof(iid) == 16, "IID storage must be contiguous."); + return base::FastHash(base::span( + reinterpret_cast(&iid), sizeof(iid))); + } +}; + namespace updater { class ProcessFilterName : public base::ProcessFilter { diff --git a/chromecast/cast_core/BUILD.gn b/chromecast/cast_core/BUILD.gn index 07da09b27ffe77..9ca6302755fb9b 100644 --- a/chromecast/cast_core/BUILD.gn +++ b/chromecast/cast_core/BUILD.gn @@ -111,18 +111,22 @@ cast_source_set("grpc_webui") { "//chromecast/base", "//chromecast/base:chromecast_switches", "//chromecast/base:default_create_sys_info", - "//chromecast/browser:browser_base", - "//chromecast/browser:public", + "//chromecast/browser", "//third_party/blink/public/common:headers", - "//third_party/cast_core/public/src/proto/v2:core_application_service_proto", "//third_party/grpc:grpc++", ] + public_deps = [ + "//chromecast/browser:public", + "//third_party/cast_core/public/src/proto/v2:core_application_service_proto", + ] + if (enable_chromecast_extensions) { sources += [ "grpc_webui_controller_extension.cc", "grpc_webui_controller_extension.h", ] + deps += [ "//components/guest_view/browser", "//extensions/browser", @@ -174,16 +178,17 @@ cast_source_set("cast_runtime_service") { ] public_deps = [ + ":runtime_application_dispatcher", "//base", + "//chromecast/browser", "//chromecast/media/cma/backend/proxy:headers", + "//chromecast/metrics:cast_event_builder_simple", "//chromecast/service", ] } -cast_source_set("cast_runtime_service_impl") { +cast_source_set("runtime_application_dispatcher") { sources = [ - "cast_runtime_service_impl.cc", - "cast_runtime_service_impl.h", "runtime_application_base.cc", "runtime_application_base.h", "runtime_application_dispatcher.cc", @@ -195,14 +200,13 @@ cast_source_set("cast_runtime_service_impl") { ] public_deps = [ - ":cast_runtime_service", ":grpc_impl", ":grpc_support", ":grpc_webui", ":metrics_recorder", ":runtime_application", "//base", - "//chromecast/browser:public", + "//chromecast/browser", "//chromecast/common:feature_constants", "//components/cast_streaming/public/mojom", "//components/url_rewrite/browser", @@ -217,7 +221,6 @@ cast_source_set("cast_runtime_service_impl") { deps = [ ":core_service_bindings", ":streaming_receiver_session_client", - "//chromecast/browser:browser_base", "//chromecast/cast_core/url_rewrite", "//chromecast/metrics:cast_event_builder_simple", "//components/cast/message_port", @@ -228,45 +231,31 @@ cast_source_set("cast_runtime_service_impl") { "//third_party/blink/public/common:headers", "//third_party/openscreen/src/cast/common:public", ] - - if (chromecast_branding == "public") { - sources += [ "cast_runtime_service_simple.cc" ] - } else { - deps += [ "//chromecast/internal/cast_core/runtime:cast_runtime_service" ] - } } -cast_source_set("renderer") { +cast_source_set("streaming_receiver_session_client") { sources = [ - "cast_runtime_content_renderer_client.cc", - "cast_runtime_content_renderer_client.h", - "cast_runtime_url_loader_throttle_provider.cc", - "cast_runtime_url_loader_throttle_provider.h", - "url_rewrite_rules_provider.cc", - "url_rewrite_rules_provider.h", + "streaming_receiver_session_client.cc", + "streaming_receiver_session_client.h", + ] + + public_deps = [ + "//base", + "//chromecast/browser:public", + "//components/cast/message_port", + "//components/cast_streaming/browser", ] deps = [ - ":cors_exempt_headers", "//base", - "//chromecast/renderer:renderer_base", + "//chromecast/shared:platform_info_serializer", + "//components/cast/message_port:message_port_core", "//components/cast_streaming/public", - "//components/cast_streaming/renderer", - "//components/cast_streaming/renderer:renderer_controller_proxy_factory", - "//components/url_rewrite/common", - "//components/url_rewrite/renderer", - "//content/public/renderer", - "//media", + "//components/cast_streaming/public/mojom", + "//content/public/browser", + "//mojo/public/cpp/bindings", + "//third_party/blink/public/common:headers", ] - - if (enable_cast_media_runtime) { - sources += [ "cast_content_renderer_client_factory.cc" ] - } - - # TODO(vigeni): Doesn't look like this is needed. - if (chromecast_branding != "public") { - deps += [ "//chromecast/internal/cast_core/runtime:renderer" ] - } } cast_source_set("browser") { @@ -279,7 +268,6 @@ cast_source_set("browser") { deps = [ ":cast_runtime_service", ":cors_exempt_headers", - ":runtime_application", "//base", "//components/url_rewrite/browser", "//components/url_rewrite/common", @@ -288,46 +276,47 @@ cast_source_set("browser") { "//third_party/cast_core/public/src/proto/runtime:runtime_service_proto", ] - public_deps = [ - "//chromecast/browser", - ] + public_deps = [ "//chromecast/browser" ] if (enable_cast_media_runtime) { sources += [ "cast_content_browser_client_factory.cc" ] } else { deps += [ "//chromecast/browser:simple_client" ] } +} - if (chromecast_branding == "public") { - sources += [ "cast_runtime_content_browser_client_simple.cc" ] - } else { - deps += [ "//chromecast/internal/cast_core/runtime:browser" ] - } +cast_source_set("browser_simple") { + sources = [ "cast_runtime_content_browser_client_simple.cc" ] + + deps = [ ":browser" ] } -cast_source_set("streaming_receiver_session_client") { +cast_source_set("renderer") { sources = [ - "streaming_receiver_session_client.cc", - "streaming_receiver_session_client.h", - ] - - public_deps = [ - "//base", - "//chromecast/browser:public", - "//components/cast/message_port", - "//components/cast_streaming/browser", + "cast_runtime_content_renderer_client.cc", + "cast_runtime_content_renderer_client.h", + "cast_runtime_url_loader_throttle_provider.cc", + "cast_runtime_url_loader_throttle_provider.h", + "url_rewrite_rules_provider.cc", + "url_rewrite_rules_provider.h", ] deps = [ + ":cors_exempt_headers", "//base", - "//chromecast/shared:platform_info_serializer", - "//components/cast/message_port:message_port_core", + "//chromecast/renderer:renderer_base", "//components/cast_streaming/public", - "//components/cast_streaming/public/mojom", - "//content/public/browser", - "//mojo/public/cpp/bindings", - "//third_party/blink/public/common:headers", + "//components/cast_streaming/renderer", + "//components/cast_streaming/renderer:renderer_controller_proxy_factory", + "//components/url_rewrite/common", + "//components/url_rewrite/renderer", + "//content/public/renderer", + "//media", ] + + if (enable_cast_media_runtime) { + sources += [ "cast_content_renderer_client_factory.cc" ] + } } # When built for use with Cast Core, enble_cast_media_runtime must be true. @@ -335,13 +324,14 @@ cast_executable("core_runtime_simple") { sources = [ "cast_runtime_main.cc" ] deps = [ - ":browser", - ":cast_runtime_service_impl", + ":browser_simple", ":renderer", "//chromecast:cast_shell_pak", "//chromecast:chromecast_locales_pak", "//chromecast/app", "//chromecast/base:default_create_sys_info", + "//chromecast/browser:browser_base", + "//chromecast/browser:prefs_simple", "//chromecast/browser:simple_main_parts", "//chromecast/utility:simple_client", "//content/public/app", @@ -371,41 +361,48 @@ cast_source_set("unit_tests") { "cast_runtime_histogram_flattener_unittest.cc", "cast_runtime_metrics_test_helpers.cc", "cast_runtime_metrics_test_helpers.h", - "cast_runtime_service_dummy.cc", "cors_exempt_headers_unittest.cc", "grpc_resource_data_source_unittest.cc", "streaming_receiver_session_client_unittest.cc", ] deps = [ - ":browser", - ":cast_runtime_service", ":cors_exempt_headers", ":grpc_webui", ":metrics_recorder", ":streaming_receiver_session_client", "//base", "//base/test:test_support", - "//chromecast/base/metrics", - "//chromecast/browser:simple_main_parts", "//chromecast/browser:test_support", - "//chromecast/cast_core/url_rewrite:unit_tests", "//chromecast/common:cors_exempt_headers", "//chromecast/shared:platform_info_serializer", "//components/cast_streaming/browser", - "//components/cast_streaming/public/mojom", - "//mojo/core/test:run_all_unittests", - "//mojo/public/cpp/bindings", + "//components/cast_streaming/public", "//testing/gmock", "//testing/gtest", "//third_party/cast_core/public/src/proto/metrics:metrics_recorder_proto", - "//third_party/cast_core/public/src/proto/v2:core_application_service_proto", "//third_party/grpc:grpc++", - "//third_party/inspector_protocol:crdtp", "//third_party/metrics_proto", ] } +# A group of all unit test targets to be linked internally. +group("all_unit_tests") { + testonly = true + + deps = [ + ":unit_tests", + "//chromecast/cast_core/url_rewrite:unit_tests", + ] +} + test("cast_cast_core_unittests") { - deps = [ ":unit_tests" ] + deps = [ + ":all_unit_tests", + ":browser_simple", + ":renderer", + "//chromecast/browser:prefs_simple", + "//chromecast/browser:simple_main_parts", + "//mojo/core/test:run_all_unittests", + ] } diff --git a/chromecast/cast_core/cast_runtime_content_browser_client.cc b/chromecast/cast_core/cast_runtime_content_browser_client.cc index 1af142943b6fe0..5b75fb5b1cc2dd 100644 --- a/chromecast/cast_core/cast_runtime_content_browser_client.cc +++ b/chromecast/cast_core/cast_runtime_content_browser_client.cc @@ -25,6 +25,10 @@ CastRuntimeContentBrowserClient::CastRuntimeContentBrowserClient( CastRuntimeContentBrowserClient::~CastRuntimeContentBrowserClient() = default; +CastRuntimeService* CastRuntimeContentBrowserClient::GetCastRuntimeService() { + return cast_runtime_service_; +} + std::unique_ptr CastRuntimeContentBrowserClient::CreateCastService( content::BrowserContext* browser_context, CastSystemMemoryPressureEvaluatorAdjuster* memory_pressure_adjuster, @@ -41,9 +45,8 @@ std::unique_ptr CastRuntimeContentBrowserClient::CreateCastService( return client->GetSystemNetworkContext(); }, this); - auto cast_runtime_service = CastRuntimeService::Create( - GetMediaTaskRunner(), web_service, media_pipeline_backend_manager(), - std::move(network_context_getter), pref_service, video_plane_controller); + auto cast_runtime_service = std::make_unique( + web_service, std::move(network_context_getter)); cast_runtime_service_ = cast_runtime_service.get(); return cast_runtime_service; } @@ -108,9 +111,10 @@ CastRuntimeContentBrowserClient::CreateURLLoaderThrottles( std::unique_ptr CastRuntimeContentBrowserClient::CreateUrlRewriteRulesThrottle( content::WebContents* web_contents) { - DCHECK(cast_runtime_service_); + CastRuntimeService* cast_runtime_service = GetCastRuntimeService(); + DCHECK(cast_runtime_service); - RuntimeApplication* app = cast_runtime_service_->GetRuntimeApplication(); + RuntimeApplication* app = cast_runtime_service->GetRuntimeApplication(); DCHECK(app); url_rewrite::UrlRequestRewriteRulesManager* url_rewrite_rules_manager = diff --git a/chromecast/cast_core/cast_runtime_content_browser_client.h b/chromecast/cast_core/cast_runtime_content_browser_client.h index 61fb5dd3b7b767..c1f0b5beef274a 100644 --- a/chromecast/cast_core/cast_runtime_content_browser_client.h +++ b/chromecast/cast_core/cast_runtime_content_browser_client.h @@ -21,6 +21,9 @@ class CastRuntimeContentBrowserClient : public shell::CastContentBrowserClient { CastFeatureListCreator* feature_list_creator); ~CastRuntimeContentBrowserClient() override; + // Returns an instance of |CastRuntimeService|. + virtual CastRuntimeService* GetCastRuntimeService(); + // CastContentBrowserClient overrides: std::unique_ptr CreateCastService( content::BrowserContext* browser_context, @@ -30,7 +33,7 @@ class CastRuntimeContentBrowserClient : public shell::CastContentBrowserClient { CastWindowManager* window_manager, CastWebService* web_service, DisplaySettingsManager* display_settings_manager, - shell::AccessibilityServiceImpl* accessibility_service) final; + shell::AccessibilityServiceImpl* accessibility_service) override; void OverrideWebkitPrefs(content::WebContents* web_contents, blink::web_pref::WebPreferences* prefs) override; std::unique_ptr<::media::CdmFactory> CreateCdmFactory( diff --git a/chromecast/cast_core/cast_runtime_service.cc b/chromecast/cast_core/cast_runtime_service.cc index 0772752d478430..bfa3ed33a4c208 100644 --- a/chromecast/cast_core/cast_runtime_service.cc +++ b/chromecast/cast_core/cast_runtime_service.cc @@ -4,8 +4,63 @@ #include "chromecast/cast_core/cast_runtime_service.h" +#include "base/command_line.h" +#include "base/process/process.h" +#include "chromecast/browser/cast_browser_process.h" +#include "chromecast/metrics/cast_event_builder_simple.h" + namespace chromecast { +namespace { + +const char kCastCoreRuntimeIdSwitch[] = "cast-core-runtime-id"; +const char kRuntimeServicePathSwitch[] = "runtime-service-path"; + +} // namespace + +CastRuntimeService::CastRuntimeService( + CastWebService* web_service, + NetworkContextGetter network_context_getter) + : app_dispatcher_(web_service, this, std::move(network_context_getter)) {} CastRuntimeService::~CastRuntimeService() = default; +void CastRuntimeService::InitializeInternal() {} + +void CastRuntimeService::FinalizeInternal() {} + +void CastRuntimeService::StartInternal() { + auto* command_line = base::CommandLine::ForCurrentProcess(); + std::string runtime_id = + command_line->GetSwitchValueASCII(kCastCoreRuntimeIdSwitch); + std::string runtime_service_path = + command_line->GetSwitchValueASCII(kRuntimeServicePathSwitch); + if (!app_dispatcher_.Start(runtime_id, runtime_service_path)) { + base::Process::TerminateCurrentProcessImmediately(1); + } +} + +void CastRuntimeService::StopInternal() { + app_dispatcher_.Stop(); +} + +std::unique_ptr CastRuntimeService::CreateEventBuilder() { + return std::make_unique(); +} + +const std::string& CastRuntimeService::GetAudioChannelEndpoint() { + return app_dispatcher_.GetCastMediaServiceGrpcEndpoint(); +} + +WebCryptoServer* CastRuntimeService::GetWebCryptoServer() { + return nullptr; +} + +receiver::MediaManager* CastRuntimeService::GetMediaManager() { + return nullptr; +} + +RuntimeApplication* CastRuntimeService::GetRuntimeApplication() { + return app_dispatcher_.GetRuntimeApplication(); +} + } // namespace chromecast diff --git a/chromecast/cast_core/cast_runtime_service.h b/chromecast/cast_core/cast_runtime_service.h index f7b63923e596d2..816658d8763f12 100644 --- a/chromecast/cast_core/cast_runtime_service.h +++ b/chromecast/cast_core/cast_runtime_service.h @@ -8,15 +8,12 @@ #include #include "base/memory/scoped_refptr.h" +#include "chromecast/cast_core/cast_runtime_metrics_recorder.h" +#include "chromecast/cast_core/cast_runtime_service.h" +#include "chromecast/cast_core/runtime_application_dispatcher.h" #include "chromecast/media/cma/backend/proxy/cast_runtime_audio_channel_endpoint_manager.h" #include "chromecast/service/cast_service.h" -class PrefService; - -namespace base { -class SingleThreadTaskRunner; -} // namespace base - namespace network { namespace mojom { class NetworkContext; @@ -29,11 +26,6 @@ class CastWebService; class WebCryptoServer; class RuntimeApplication; -namespace media { -class MediaPipelineBackendManager; -class VideoPlaneController; -} // namespace media - namespace receiver { class MediaManager; } // namespace receiver @@ -43,34 +35,40 @@ class MediaManager; // implementation. class CastRuntimeService : public CastService, + public CastRuntimeMetricsRecorder::EventBuilderFactory, public media::CastRuntimeAudioChannelEndpointManager { public: using NetworkContextGetter = base::RepeatingCallback; - // Creates an instance of |CastRuntimeService| interface. - static std::unique_ptr Create( - scoped_refptr task_runner, - CastWebService* web_service, - media::MediaPipelineBackendManager* media_pipeline_backend_manager, - NetworkContextGetter network_context_getter, - PrefService* pref_service, - media::VideoPlaneController* video_plane_controller); - + CastRuntimeService(CastWebService* web_service, + NetworkContextGetter network_context_getter); ~CastRuntimeService() override; // Returns WebCryptoServer. - virtual WebCryptoServer* GetWebCryptoServer() = 0; + virtual WebCryptoServer* GetWebCryptoServer(); // Returns MediaManager. - virtual receiver::MediaManager* GetMediaManager() = 0; - - // Returns a pointer to CastWebService object with lifespan - // equal to CastRuntimeService main object. - virtual CastWebService* GetCastWebService() = 0; + virtual receiver::MediaManager* GetMediaManager(); // Returns a pointer to RuntimeApplication. - virtual RuntimeApplication* GetRuntimeApplication() = 0; + virtual RuntimeApplication* GetRuntimeApplication(); + + protected: + // CastService implementation: + void InitializeInternal() override; + void FinalizeInternal() override; + void StartInternal() override; + void StopInternal() override; + + // CastRuntimeMetricsRecorder::EventBuilderFactory implementation: + std::unique_ptr CreateEventBuilder() override; + + // CastRuntimeAudioChannelEndpointManager implementation: + const std::string& GetAudioChannelEndpoint() override; + + private: + RuntimeApplicationDispatcher app_dispatcher_; }; } // namespace chromecast diff --git a/chromecast/cast_core/cast_runtime_service_dummy.cc b/chromecast/cast_core/cast_runtime_service_dummy.cc deleted file mode 100644 index c6b0fe3845ad54..00000000000000 --- a/chromecast/cast_core/cast_runtime_service_dummy.cc +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2021 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chromecast/cast_core/cast_runtime_service.h" - -#include "base/no_destructor.h" -#include "base/task/single_thread_task_runner.h" - -namespace chromecast { - -namespace { - -class CastRuntimeServiceDummy : public CastRuntimeService { - public: - ~CastRuntimeServiceDummy() override = default; - - // CastRuntimeService implementation: - WebCryptoServer* GetWebCryptoServer() override { return nullptr; } - receiver::MediaManager* GetMediaManager() override { return nullptr; } - CastWebService* GetCastWebService() override { return nullptr; } - RuntimeApplication* GetRuntimeApplication() override { return nullptr; } - - // CastService implementation: - void InitializeInternal() override {} - void FinalizeInternal() override {} - void StartInternal() override {} - void StopInternal() override {} - - // CastRuntimeAudioChannelEndpointManager implementation: - const std::string& GetAudioChannelEndpoint() override { - static const std::string kFakeAudioChannelEndpoint = ""; - return kFakeAudioChannelEndpoint; - } -}; - -} // namespace - -// static -std::unique_ptr CastRuntimeService::Create( - scoped_refptr task_runner, - CastWebService* web_service, - media::MediaPipelineBackendManager* media_pipeline_backend_manager, - CastRuntimeService::NetworkContextGetter network_context_getter, - PrefService* pref_service, - media::VideoPlaneController* video_plane_controller) { - return std::make_unique(); -} - -} // namespace chromecast diff --git a/chromecast/cast_core/cast_runtime_service_impl.cc b/chromecast/cast_core/cast_runtime_service_impl.cc deleted file mode 100644 index 4e334890191a4f..00000000000000 --- a/chromecast/cast_core/cast_runtime_service_impl.cc +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2021 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chromecast/cast_core/cast_runtime_service_impl.h" - -#include "base/command_line.h" -#include "base/process/process.h" -#include "chromecast/browser/cast_browser_process.h" -#include "chromecast/metrics/cast_event_builder_simple.h" - -namespace chromecast { -namespace { - -const char kCastCoreRuntimeIdSwitch[] = "cast-core-runtime-id"; -const char kRuntimeServicePathSwitch[] = "runtime-service-path"; - -} // namespace - -CastRuntimeServiceImpl::CastRuntimeServiceImpl( - CastWebService* web_service, - NetworkContextGetter network_context_getter) - : web_service_(web_service), - app_dispatcher_(web_service, this, std::move(network_context_getter)) {} - -CastRuntimeServiceImpl::~CastRuntimeServiceImpl() = default; - -void CastRuntimeServiceImpl::InitializeInternal() {} - -void CastRuntimeServiceImpl::FinalizeInternal() {} - -void CastRuntimeServiceImpl::StartInternal() { - auto* command_line = base::CommandLine::ForCurrentProcess(); - std::string runtime_id = - command_line->GetSwitchValueASCII(kCastCoreRuntimeIdSwitch); - std::string runtime_service_path = - command_line->GetSwitchValueASCII(kRuntimeServicePathSwitch); - if (!app_dispatcher_.Start(runtime_id, runtime_service_path)) { - base::Process::TerminateCurrentProcessImmediately(1); - } -} - -void CastRuntimeServiceImpl::StopInternal() { - app_dispatcher_.Stop(); -} - -std::unique_ptr CastRuntimeServiceImpl::CreateEventBuilder() { - return std::make_unique(); -} - -const std::string& CastRuntimeServiceImpl::GetAudioChannelEndpoint() { - return app_dispatcher_.GetCastMediaServiceGrpcEndpoint(); -} - -WebCryptoServer* CastRuntimeServiceImpl::GetWebCryptoServer() { - return nullptr; -} - -receiver::MediaManager* CastRuntimeServiceImpl::GetMediaManager() { - return nullptr; -} - -CastWebService* CastRuntimeServiceImpl::GetCastWebService() { - return web_service_; -} - -RuntimeApplication* CastRuntimeServiceImpl::GetRuntimeApplication() { - return app_dispatcher_.GetRuntimeApplication(); -} - -} // namespace chromecast diff --git a/chromecast/cast_core/cast_runtime_service_impl.h b/chromecast/cast_core/cast_runtime_service_impl.h deleted file mode 100644 index 46353972a66c6d..00000000000000 --- a/chromecast/cast_core/cast_runtime_service_impl.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2021 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROMECAST_CAST_CORE_CAST_RUNTIME_SERVICE_IMPL_H_ -#define CHROMECAST_CAST_CORE_CAST_RUNTIME_SERVICE_IMPL_H_ - -#include - -#include "chromecast/cast_core/cast_runtime_metrics_recorder.h" -#include "chromecast/cast_core/cast_runtime_service.h" -#include "chromecast/cast_core/runtime_application_dispatcher.h" - -namespace chromecast { - -class CastWebService; -class CastEventBuilder; -class RuntimeApplication; - -// This interface is to be used for building the Cast Runtime Service and act as -// the border between shared Chromium code and the specifics of that -// implementation. -class CastRuntimeServiceImpl - : public CastRuntimeService, - public CastRuntimeMetricsRecorder::EventBuilderFactory { - public: - CastRuntimeServiceImpl(CastWebService* web_service, - NetworkContextGetter network_context_getter); - ~CastRuntimeServiceImpl() override; - - protected: - // CastService implementation: - void InitializeInternal() override; - void FinalizeInternal() override; - void StartInternal() override; - void StopInternal() override; - - // CastRuntimeMetricsRecorder::EventBuilderFactory implementation: - std::unique_ptr CreateEventBuilder() override; - - // CastRuntimeService implementation: - WebCryptoServer* GetWebCryptoServer() override; - receiver::MediaManager* GetMediaManager() override; - CastWebService* GetCastWebService() override; - RuntimeApplication* GetRuntimeApplication() override; - - // CastRuntimeAudioChannelEndpointManager implementation: - const std::string& GetAudioChannelEndpoint() override; - - private: - CastWebService* const web_service_; - RuntimeApplicationDispatcher app_dispatcher_; -}; - -} // namespace chromecast - -#endif // CHROMECAST_CAST_CORE_CAST_RUNTIME_SERVICE_IMPL_H_ diff --git a/chromecast/cast_core/cast_runtime_service_simple.cc b/chromecast/cast_core/cast_runtime_service_simple.cc deleted file mode 100644 index efb682a3cb9b41..00000000000000 --- a/chromecast/cast_core/cast_runtime_service_simple.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2021 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/task/single_thread_task_runner.h" -#include "chromecast/cast_core/cast_runtime_service.h" -#include "chromecast/cast_core/cast_runtime_service_impl.h" - -namespace chromecast { - -std::unique_ptr CastRuntimeService::Create( - scoped_refptr task_runner, - CastWebService* web_service, - media::MediaPipelineBackendManager* media_pipeline_backend_manager, - CastRuntimeService::NetworkContextGetter network_context_getter, - PrefService* pref_service, - media::VideoPlaneController* video_plane_controller) { - return std::make_unique( - web_service, std::move(network_context_getter)); -} - -} // namespace chromecast diff --git a/chromecast/common/cast_redirect_manifest_handler.cc b/chromecast/common/cast_redirect_manifest_handler.cc index 0fd6c012b0d948..1953627a8c7b6f 100644 --- a/chromecast/common/cast_redirect_manifest_handler.cc +++ b/chromecast/common/cast_redirect_manifest_handler.cc @@ -42,9 +42,9 @@ bool CastRedirectHandler::Parse(extensions::Extension* extension, } } - std::string url; - if (extension->manifest()->GetString(kCastUrl, &url)) { - info->cast_url = url; + if (const std::string* url = + extension->manifest()->FindStringPath(kCastUrl)) { + info->cast_url = *url; } if (!info->redirects.empty() || !info->cast_url.empty()) { diff --git a/chromeos/BUILD.gn b/chromeos/BUILD.gn index b4bd9245084f69..c39bc753713b10 100644 --- a/chromeos/BUILD.gn +++ b/chromeos/BUILD.gn @@ -74,7 +74,6 @@ source_set("test_support_source_set") { if (is_chromeos_ash) { deps += [ "//chromeos/dbus:test_support", - "//chromeos/login/auth:test_support", "//chromeos/login/login_state:test_support", "//chromeos/network:test_support", "//chromeos/tpm:test_support", @@ -117,7 +116,6 @@ test("chromeos_unittests") { "//chromeos/dbus:unit_tests", "//chromeos/dbus/services:unit_tests", "//chromeos/language/language_packs:unit_tests", - "//chromeos/login/auth:unit_tests", "//chromeos/login/login_state:unit_tests", "//chromeos/memory:unit_tests", "//chromeos/network:test_support", diff --git a/chromeos/crosapi/mojom/arc.mojom b/chromeos/crosapi/mojom/arc.mojom index 736b0ed66b99c8..5384f939eadd6f 100644 --- a/chromeos/crosapi/mojom/arc.mojom +++ b/chromeos/crosapi/mojom/arc.mojom @@ -76,8 +76,8 @@ interface ArcObserver { }; // Interacts with ARC. -// Next version: 1 -// Next method id: 3 +// Next version: 2 +// Next method id: 4 [Stable, Uuid="a39a22dd-2f5c-4c99-b0ea-d83d5b1c987f"] interface Arc { // Registers ArcObserver in Lacros-chrome to Ash-chrome @@ -97,4 +97,8 @@ interface Arc { // An array of IntentHandlerInfo will be returned. RequestUrlHandlerList@2(string url) => (array handlers); + + // Handles the URL by sending an ACTION_VIEW intent to the package. The + // most suitable activity for the URL within the package will be started. + [MinVersion=1] HandleUrl@3(string url, string package_name); }; diff --git a/chromeos/cryptohome/BUILD.gn b/chromeos/cryptohome/BUILD.gn index 5e4461f31acf4f..8b0d926b586fa2 100644 --- a/chromeos/cryptohome/BUILD.gn +++ b/chromeos/cryptohome/BUILD.gn @@ -10,13 +10,13 @@ assert(is_chromeos, "Non-Chrome-OS builds must not depend on //chromeos") component("cryptohome") { defines = [ "IS_CHROMEOS_CRYPTOHOME_IMPL" ] deps = [ + "//ash/components/login/auth:challenge_response_key", "//base", "//chromeos/dbus:common", "//chromeos/dbus/cryptohome", "//chromeos/dbus/cryptohome:cryptohome_proto", "//chromeos/dbus/userdataauth:userdataauth", "//chromeos/dbus/userdataauth:userdataauth_proto", - "//chromeos/login/auth:challenge_response_key", "//components/account_id", "//components/device_event_log", "//components/user_manager", @@ -37,13 +37,13 @@ source_set("unit_tests") { testonly = true deps = [ ":cryptohome", + "//ash/components/login/auth:challenge_response_key", "//base", "//base/test:test_support", "//chromeos/dbus:test_support", "//chromeos/dbus/cryptohome:cryptohome_proto", "//chromeos/dbus/userdataauth:userdataauth", "//chromeos/dbus/userdataauth:userdataauth_proto", - "//chromeos/login/auth:challenge_response_key", "//testing/gtest:gtest", ] sources = [ diff --git a/chromeos/cryptohome/DEPS b/chromeos/cryptohome/DEPS index fc7d0d5a16d0cd..410db2176b6391 100644 --- a/chromeos/cryptohome/DEPS +++ b/chromeos/cryptohome/DEPS @@ -1,9 +1,9 @@ noparent = True include_rules = [ + "+ash/components/login/auth", "+base", "+chromeos/dbus", - "+chromeos/login/auth", "+components/account_id", "+components/device_event_log", "+components/user_manager", diff --git a/chromeos/cryptohome/cryptohome_parameters.h b/chromeos/cryptohome/cryptohome_parameters.h index dcf6bf163cfd6e..f4f1fc3f4a373c 100644 --- a/chromeos/cryptohome/cryptohome_parameters.h +++ b/chromeos/cryptohome/cryptohome_parameters.h @@ -11,9 +11,9 @@ #include #include +#include "ash/components/login/auth/challenge_response_key.h" #include "base/component_export.h" #include "chromeos/dbus/cryptohome/rpc.pb.h" -#include "chromeos/login/auth/challenge_response_key.h" class AccountId; diff --git a/chromeos/cryptohome/cryptohome_util_unittest.cc b/chromeos/cryptohome/cryptohome_util_unittest.cc index 418a40fe9c1e52..1ac8195d3942b3 100644 --- a/chromeos/cryptohome/cryptohome_util_unittest.cc +++ b/chromeos/cryptohome/cryptohome_util_unittest.cc @@ -6,10 +6,10 @@ #include +#include "ash/components/login/auth/challenge_response_key.h" #include "chromeos/cryptohome/cryptohome_parameters.h" #include "chromeos/dbus/cryptohome/key.pb.h" #include "chromeos/dbus/cryptohome/rpc.pb.h" -#include "chromeos/login/auth/challenge_response_key.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" diff --git a/chromeos/dbus/BUILD.gn b/chromeos/dbus/BUILD.gn index 208375a697e3d0..ac47de7f38cf14 100644 --- a/chromeos/dbus/BUILD.gn +++ b/chromeos/dbus/BUILD.gn @@ -125,6 +125,7 @@ source_set("unit_tests") { "//base/test:test_support", "//chromeos/dbus/audio", "//chromeos/dbus/authpolicy", + "//chromeos/dbus/authpolicy:authpolicy_proto", "//chromeos/dbus/biod:test_support", "//chromeos/dbus/cec_service:unit_tests", "//chromeos/dbus/cros_disks:unit_tests", diff --git a/chromeos/profiles/orderfile.newest.txt b/chromeos/profiles/orderfile.newest.txt index d5652da902d1a6..05233f5313e14d 100644 --- a/chromeos/profiles/orderfile.newest.txt +++ b/chromeos/profiles/orderfile.newest.txt @@ -1 +1 @@ -chromeos-chrome-orderfile-field-98-4729.0-1638787322-benchmark-98.0.4758.5-r1.orderfile.xz +chromeos-chrome-orderfile-field-98-4744.1-1639393599-benchmark-98.0.4758.7-r1.orderfile.xz diff --git a/components/BUILD.gn b/components/BUILD.gn index 8707a86f02828e..894a287a16592c 100644 --- a/components/BUILD.gn +++ b/components/BUILD.gn @@ -928,6 +928,7 @@ if (is_android) { "//components/gcm_driver/android:components_gcm_driver_junit_tests", "//components/image_fetcher:junit", "//components/installedapp/android:junit", + "//components/language/android:junit", "//components/media_router/browser/android:junit", "//components/messages/android:junit", "//components/messages/android/internal:junit", diff --git a/components/arc/BUILD.gn b/components/arc/BUILD.gn index 2bc11e54fb5e9c..ae01a8ec0e044c 100644 --- a/components/arc/BUILD.gn +++ b/components/arc/BUILD.gn @@ -17,8 +17,6 @@ static_library("arc") { "intent_helper/intent_constants.h", "intent_helper/intent_filter.cc", "intent_helper/intent_filter.h", - "intent_helper/link_handler_model.cc", - "intent_helper/link_handler_model.h", "intent_helper/open_url_delegate.h", ] @@ -53,7 +51,6 @@ source_set("unit_tests") { "intent_helper/arc_intent_helper_bridge_unittest.cc", "intent_helper/custom_tab_unittest.cc", "intent_helper/intent_filter_unittest.cc", - "intent_helper/link_handler_model_unittest.cc", ] deps = [ diff --git a/components/arc/common/BUILD.gn b/components/arc/common/BUILD.gn index 5e4067e64c4f23..075cdc1993a72e 100644 --- a/components/arc/common/BUILD.gn +++ b/components/arc/common/BUILD.gn @@ -10,11 +10,15 @@ static_library("common") { "intent_helper/activity_icon_loader.cc", "intent_helper/activity_icon_loader.h", "intent_helper/adaptive_icon_delegate.h", + "intent_helper/link_handler_model.cc", + "intent_helper/link_handler_model.h", + "intent_helper/link_handler_model_delegate.h", ] deps = [ "//base", "//build:chromeos_buildflags", + "//components/google/core/common", "//ui/base", "//ui/gfx", "//url:url", @@ -22,7 +26,9 @@ static_library("common") { if (is_chromeos_ash) { deps += [ + "//ash/components/arc", "//ash/components/arc:arc_base_utils", + "//ash/components/arc:arc_metrics_constants", "//ash/components/arc/mojom", "//ash/components/arc/session", ] @@ -38,12 +44,16 @@ static_library("common") { source_set("unit_tests") { testonly = true - sources = [ "intent_helper/activity_icon_loader_unittest.cc" ] + sources = [ + "intent_helper/activity_icon_loader_unittest.cc", + "intent_helper/link_handler_model_unittest.cc", + ] deps = [ ":common", "//base/test:test_support", "//testing/gtest", "//ui/gfx", + "//url:url", ] } diff --git a/components/arc/common/intent_helper/DEPS b/components/arc/common/intent_helper/DEPS index a80fe55ee50896..78adacd3352bb6 100644 --- a/components/arc/common/intent_helper/DEPS +++ b/components/arc/common/intent_helper/DEPS @@ -1,9 +1,11 @@ include_rules = [ "+ash/components/arc/arc_util.h", + "+ash/components/arc/metrics", + "+ash/components/arc/mojom", + "+ash/components/arc/session", "+chromeos/crosapi/mojom", "+chromeos/lacros", - "+components/arc/mojom", - "+components/arc/session", + "+components/google/core/common/google_util.h", "+ui/base", "+ui/gfx", ] diff --git a/components/arc/intent_helper/link_handler_model.cc b/components/arc/common/intent_helper/link_handler_model.cc similarity index 60% rename from components/arc/intent_helper/link_handler_model.cc rename to components/arc/common/intent_helper/link_handler_model.cc index 971badd661e439..1ae714720f6f8d 100644 --- a/components/arc/intent_helper/link_handler_model.cc +++ b/components/arc/common/intent_helper/link_handler_model.cc @@ -2,28 +2,33 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/arc/intent_helper/link_handler_model.h" +#include "components/arc/common/intent_helper/link_handler_model.h" #include -#include "ash/components/arc/metrics/arc_metrics_constants.h" -#include "ash/components/arc/metrics/arc_metrics_service.h" -#include "ash/components/arc/session/arc_bridge_service.h" -#include "ash/components/arc/session/arc_service_manager.h" #include "base/bind.h" #include "base/memory/ptr_util.h" #include "base/metrics/histogram_macros.h" +#include "base/notreached.h" #include "base/strings/utf_string_conversions.h" -#include "components/arc/intent_helper/arc_intent_helper_bridge.h" +#include "build/chromeos_buildflags.h" #include "components/google/core/common/google_util.h" #include "url/url_util.h" +#if BUILDFLAG(IS_CHROMEOS_ASH) +#include "ash/components/arc/metrics/arc_metrics_constants.h" +#include "ash/components/arc/metrics/arc_metrics_service.h" +#endif + namespace arc { namespace { constexpr int kMaxValueLen = 2048; +// Not owned. Must outlive all LinkHandlerModel instances. +LinkHandlerModelDelegate* g_link_handler_model_delegate = nullptr; + bool GetQueryValue(const GURL& url, const std::string& key_to_find, std::u16string* out) { @@ -69,33 +74,40 @@ void LinkHandlerModel::AddObserver(Observer* observer) { } void LinkHandlerModel::OpenLinkWithHandler(uint32_t handler_id) { - auto* arc_service_manager = ArcServiceManager::Get(); - if (!arc_service_manager) + if (handler_id >= handlers_.size()) return; - auto* instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_service_manager->arc_bridge_service()->intent_helper(), HandleUrl); - if (!instance) + + if (!g_link_handler_model_delegate) { + LOG(DFATAL) << "LinkHandlerModelDelegate is not set."; return; - if (handler_id >= handlers_.size()) + } + + if (!g_link_handler_model_delegate->HandleUrl( + url_.spec(), handlers_[handler_id].package_name)) { return; - instance->HandleUrl(url_.spec(), handlers_[handler_id]->package_name); + } +#if BUILDFLAG(IS_CHROMEOS_ASH) + // TODO(crbug.com/1275075): Take metrics in Lacros as well. ArcMetricsService::RecordArcUserInteraction( context_, arc::UserInteractionType::APP_STARTED_FROM_LINK_CONTEXT_MENU); +#endif +} + +// static +void LinkHandlerModel::SetDelegate(LinkHandlerModelDelegate* delegate) { + // SetDelegate should be called only when overwriting nullptr or unsetting to + // nullptr except for testing. + if (g_link_handler_model_delegate && delegate) { + LOG(ERROR) << "g_link_handler_model_delegate is modified. " + << "This should not happen except for testing."; + } + g_link_handler_model_delegate = delegate; } LinkHandlerModel::LinkHandlerModel() = default; bool LinkHandlerModel::Init(content::BrowserContext* context, const GURL& url) { - auto* arc_service_manager = ArcServiceManager::Get(); - if (!arc_service_manager) - return false; - auto* instance = ARC_GET_INSTANCE_FOR_METHOD( - arc_service_manager->arc_bridge_service()->intent_helper(), - RequestUrlHandlerList); - if (!instance) - return false; - DCHECK(context); context_ = context; @@ -104,32 +116,50 @@ bool LinkHandlerModel::Init(content::BrowserContext* context, const GURL& url) { // callback function, OnUrlHandlerList, is called within a few milliseconds // even on the slowest Chromebook we support. url_ = RewriteUrlFromQueryIfAvailable(url); - instance->RequestUrlHandlerList( + + if (!g_link_handler_model_delegate) { + // g_link_handler_model_delegate should be already set on the product. + // It is not set for some tests such as browser_tests since crosapi is + // disabled. + LOG(ERROR) << "LinkHandlerModelDelegate is not set. " + << "This should not happen except for testing."; + return false; + } + + return g_link_handler_model_delegate->RequestUrlHandlerList( url_.spec(), base::BindOnce(&LinkHandlerModel::OnUrlHandlerList, weak_ptr_factory_.GetWeakPtr())); - return true; } void LinkHandlerModel::OnUrlHandlerList( - std::vector handlers) { - handlers_ = ArcIntentHelperBridge::FilterOutIntentHelper(std::move(handlers)); + std::vector handlers) { + for (auto& handler : handlers) { + if (handler.package_name == "org.chromium.arc.intent_helper") + continue; + handlers_.push_back(std::move(handler)); + } bool icon_info_notified = false; - auto* intent_helper_bridge = - ArcIntentHelperBridge::GetForBrowserContext(context_); - if (intent_helper_bridge) { - std::vector activities; - for (size_t i = 0; i < handlers_.size(); ++i) { - activities.emplace_back(handlers_[i]->package_name, - handlers_[i]->activity_name); - } - const ArcIntentHelperBridge::GetResult result = - intent_helper_bridge->GetActivityIcons( - activities, base::BindOnce(&LinkHandlerModel::NotifyObserver, - weak_ptr_factory_.GetWeakPtr())); - icon_info_notified = - internal::ActivityIconLoader::HasIconsReadyCallbackRun(result); + if (!g_link_handler_model_delegate) { + // g_link_handler_model_delegate should be already set on the product. + // It is not set for some tests such as browser_tests since crosapi is + // disabled. + LOG(ERROR) << "LinkHandlerModelDelegate is not set. " + << "This should not happen except for testing."; + } + + std::vector activities; + for (size_t i = 0; i < handlers_.size(); ++i) { + activities.emplace_back(handlers_[i].package_name, + handlers_[i].activity_name); } + const LinkHandlerModelDelegate::GetResult result = + g_link_handler_model_delegate->GetActivityIcons( + activities, base::BindOnce(&LinkHandlerModel::NotifyObserver, + weak_ptr_factory_.GetWeakPtr())); + icon_info_notified = + LinkHandlerModelDelegate::ActivityIconLoader::HasIconsReadyCallbackRun( + result); if (!icon_info_notified) { // Call NotifyObserver() without icon information, unless @@ -140,7 +170,7 @@ void LinkHandlerModel::OnUrlHandlerList( } void LinkHandlerModel::NotifyObserver( - std::unique_ptr icons) { + std::unique_ptr icons) { if (icons) { icons_.insert(icons->begin(), icons->end()); icons.reset(); @@ -149,13 +179,13 @@ void LinkHandlerModel::NotifyObserver( std::vector handlers; for (size_t i = 0; i < handlers_.size(); ++i) { gfx::Image icon; - const ArcIntentHelperBridge::ActivityName activity( - handlers_[i]->package_name, handlers_[i]->activity_name); + const LinkHandlerModelDelegate::ActivityName activity( + handlers_[i].package_name, handlers_[i].activity_name); const auto it = icons_.find(activity); if (it != icons_.end()) icon = it->second.icon16; // Use the handler's index as an ID. - LinkHandlerInfo handler = {base::UTF8ToUTF16(handlers_[i]->name), icon, + LinkHandlerInfo handler = {base::UTF8ToUTF16(handlers_[i].name), icon, static_cast(i)}; handlers.push_back(handler); } diff --git a/components/arc/intent_helper/link_handler_model.h b/components/arc/common/intent_helper/link_handler_model.h similarity index 76% rename from components/arc/intent_helper/link_handler_model.h rename to components/arc/common/intent_helper/link_handler_model.h index 7d63af27f01219..6a98ff92dc1aa9 100644 --- a/components/arc/intent_helper/link_handler_model.h +++ b/components/arc/common/intent_helper/link_handler_model.h @@ -2,17 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef COMPONENTS_ARC_INTENT_HELPER_LINK_HANDLER_MODEL_H_ -#define COMPONENTS_ARC_INTENT_HELPER_LINK_HANDLER_MODEL_H_ +#ifndef COMPONENTS_ARC_COMMON_INTENT_HELPER_LINK_HANDLER_MODEL_H_ +#define COMPONENTS_ARC_COMMON_INTENT_HELPER_LINK_HANDLER_MODEL_H_ #include #include #include -#include "ash/components/arc/mojom/intent_helper.mojom.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" -#include "components/arc/intent_helper/arc_intent_helper_bridge.h" +#include "components/arc/common/intent_helper/link_handler_model_delegate.h" #include "url/gurl.h" namespace content { @@ -52,6 +51,9 @@ class LinkHandlerModel { static GURL RewriteUrlFromQueryIfAvailableForTesting(const GURL& url); + // Sets the LinkHandlerModelDelegate instance. + static void SetDelegate(LinkHandlerModelDelegate* delegate); + private: LinkHandlerModel(); @@ -60,9 +62,10 @@ class LinkHandlerModel { // the caller should delete |this| object. bool Init(content::BrowserContext* context, const GURL& url); - void OnUrlHandlerList(std::vector handlers); + void OnUrlHandlerList( + std::vector handlers); void NotifyObserver( - std::unique_ptr icons); + std::unique_ptr icons); // Checks if the |url| matches the following pattern: // "http(s):///url?...&url=&..." @@ -77,13 +80,13 @@ class LinkHandlerModel { base::ObserverList::Unchecked observer_list_; // Url handler info passed from ARC. - std::vector handlers_; + std::vector handlers_; // Activity icon info passed from ARC. - ArcIntentHelperBridge::ActivityToIconsMap icons_; + LinkHandlerModelDelegate::ActivityToIconsMap icons_; base::WeakPtrFactory weak_ptr_factory_{this}; }; } // namespace arc -#endif // COMPONENTS_ARC_INTENT_HELPER_LINK_HANDLER_MODEL_H_ +#endif // COMPONENTS_ARC_COMMON_INTENT_HELPER_LINK_HANDLER_MODEL_H_ diff --git a/components/arc/common/intent_helper/link_handler_model_delegate.h b/components/arc/common/intent_helper/link_handler_model_delegate.h new file mode 100644 index 00000000000000..d9c2dc31d51ea2 --- /dev/null +++ b/components/arc/common/intent_helper/link_handler_model_delegate.h @@ -0,0 +1,67 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_ARC_COMMON_INTENT_HELPER_LINK_HANDLER_MODEL_DELEGATE_H_ +#define COMPONENTS_ARC_COMMON_INTENT_HELPER_LINK_HANDLER_MODEL_DELEGATE_H_ + +#include +#include + +#include "base/callback.h" +#include "components/arc/common/intent_helper/activity_icon_loader.h" + +namespace arc { + +// LinkHandlerModelDelegate provides API to access to ARC Activity Icons cache. +class LinkHandlerModelDelegate { + public: + virtual ~LinkHandlerModelDelegate() = default; + + // internal::ActivityIconLoader types. + using ActivityIconLoader = internal::ActivityIconLoader; + using ActivityName = internal::ActivityIconLoader::ActivityName; + using ActivityToIconsMap = internal::ActivityIconLoader::ActivityToIconsMap; + using GetResult = internal::ActivityIconLoader::GetResult; + using OnIconsReadyCallback = + internal::ActivityIconLoader::OnIconsReadyCallback; + + struct IntentHandlerInfo { + IntentHandlerInfo(const std::string& name, + const std::string& package_name, + const std::string& activity_name) + : name(name), + package_name(package_name), + activity_name(activity_name) {} + ~IntentHandlerInfo() = default; + + // The name of the package used as a description text. + std::string name; + // The name of the package used as an ID. + std::string package_name; + // A hint for retrieving the package's icon. + std::string activity_name; + }; + + using RequestUrlHandlerListCallback = + base::OnceCallback)>; + + // Retrieves icons for the |activities| and calls |callback|. + // See internal::ActivityIconLoader::GetActivityIcons() for more details. + virtual GetResult GetActivityIcons( + const std::vector& activities, + OnIconsReadyCallback callback) = 0; + + // Calls RequestUrlHandlerList mojo API. + virtual bool RequestUrlHandlerList( + const std::string& url, + RequestUrlHandlerListCallback callback) = 0; + + // Calls HandleUrl mojo API. + virtual bool HandleUrl(const std::string& url, + const std::string& package_name) = 0; +}; + +} // namespace arc + +#endif // COMPONENTS_ARC_COMMON_INTENT_HELPER_LINK_HANDLER_MODEL_DELEGATE_H_ diff --git a/components/arc/intent_helper/link_handler_model_unittest.cc b/components/arc/common/intent_helper/link_handler_model_unittest.cc similarity index 98% rename from components/arc/intent_helper/link_handler_model_unittest.cc rename to components/arc/common/intent_helper/link_handler_model_unittest.cc index 56bb968ba55192..1745dd96e1753a 100644 --- a/components/arc/intent_helper/link_handler_model_unittest.cc +++ b/components/arc/common/intent_helper/link_handler_model_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 "components/arc/intent_helper/link_handler_model.h" +#include "components/arc/common/intent_helper/link_handler_model.h" #include diff --git a/components/arc/intent_helper/arc_intent_helper_bridge.cc b/components/arc/intent_helper/arc_intent_helper_bridge.cc index fa25fcb217bb89..239264c5c8763c 100644 --- a/components/arc/intent_helper/arc_intent_helper_bridge.cc +++ b/components/arc/intent_helper/arc_intent_helper_bridge.cc @@ -20,6 +20,7 @@ #include "base/metrics/histogram_macros.h" #include "base/strings/string_util.h" #include "base/values.h" +#include "components/arc/common/intent_helper/link_handler_model.h" #include "components/arc/intent_helper/control_camera_app_delegate.h" #include "components/arc/intent_helper/intent_constants.h" #include "components/arc/intent_helper/open_url_delegate.h" @@ -160,11 +161,13 @@ ArcIntentHelperBridge::ArcIntentHelperBridge(content::BrowserContext* context, arc_bridge_service_(bridge_service), allowed_arc_schemes_(std::cbegin(kArcSchemes), std::cend(kArcSchemes)) { arc_bridge_service_->intent_helper()->SetHost(this); + LinkHandlerModel::SetDelegate(this); } ArcIntentHelperBridge::~ArcIntentHelperBridge() { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); arc_bridge_service_->intent_helper()->SetHost(nullptr); + LinkHandlerModel::SetDelegate(nullptr); for (auto& observer : observer_list_) observer.OnArcIntentHelperBridgeDestruction(); } @@ -376,6 +379,57 @@ ArcIntentHelperBridge::GetResult ArcIntentHelperBridge::GetActivityIcons( return icon_loader_.GetActivityIcons(activities, std::move(callback)); } +bool ArcIntentHelperBridge::RequestUrlHandlerList( + const std::string& url, + RequestUrlHandlerListCallback callback) { + auto* arc_service_manager = ArcServiceManager::Get(); + arc::mojom::IntentHelperInstance* instance = nullptr; + + if (arc_service_manager) { + instance = ARC_GET_INSTANCE_FOR_METHOD( + arc_service_manager->arc_bridge_service()->intent_helper(), + RequestUrlHandlerList); + } + if (!instance) { + LOG(ERROR) << "Failed to get instance for RequestUrlHandlerList()."; + return false; + } + + instance->RequestUrlHandlerList( + url, base::BindOnce(&ArcIntentHelperBridge::OnRequestUrlHandlerList, + weak_ptr_factory_.GetWeakPtr(), std::move(callback))); + return true; +} + +void ArcIntentHelperBridge::OnRequestUrlHandlerList( + RequestUrlHandlerListCallback callback, + std::vector handlers) { + std::vector converted_handlers; + for (auto const& handler : handlers) { + converted_handlers.push_back(IntentHandlerInfo( + handler->name, handler->package_name, handler->activity_name)); + } + std::move(callback).Run(std::move(converted_handlers)); +} + +bool ArcIntentHelperBridge::HandleUrl(const std::string& url, + const std::string& package_name) { + auto* arc_service_manager = ArcServiceManager::Get(); + arc::mojom::IntentHelperInstance* instance = nullptr; + + if (arc_service_manager) { + instance = ARC_GET_INSTANCE_FOR_METHOD( + arc_service_manager->arc_bridge_service()->intent_helper(), HandleUrl); + } + if (!instance) { + LOG(ERROR) << "Failed to get instance for HandleUrl()."; + return false; + } + + instance->HandleUrl(url, package_name); + return true; +} + bool ArcIntentHelperBridge::ShouldChromeHandleUrl(const GURL& url) { if (!url.SchemeIsHTTPOrHTTPS()) { // Chrome will handle everything that is not http and https. diff --git a/components/arc/intent_helper/arc_intent_helper_bridge.h b/components/arc/intent_helper/arc_intent_helper_bridge.h index 04bda767472afe..ccbc28f2f4ed1d 100644 --- a/components/arc/intent_helper/arc_intent_helper_bridge.h +++ b/components/arc/intent_helper/arc_intent_helper_bridge.h @@ -12,9 +12,10 @@ #include #include "ash/components/arc/mojom/intent_helper.mojom.h" +#include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "base/threading/thread_checker.h" -#include "components/arc/common/intent_helper/activity_icon_loader.h" +#include "components/arc/common/intent_helper/link_handler_model_delegate.h" #include "components/arc/intent_helper/arc_intent_helper_observer.h" #include "components/keyed_service/core/keyed_service.h" #include "url/gurl.h" @@ -35,7 +36,8 @@ class OpenUrlDelegate; // Receives intents from ARC. class ArcIntentHelperBridge : public KeyedService, - public mojom::IntentHelperHost { + public mojom::IntentHelperHost, + public LinkHandlerModelDelegate { public: class Delegate { public: @@ -111,16 +113,13 @@ class ArcIntentHelperBridge : public KeyedService, void OnOpenAppWithIntent(const GURL& start_url, arc::mojom::LaunchIntentPtr intent) override; - // Retrieves icons for the |activities| and calls |callback|. - // See ActivityIconLoader::GetActivityIcons() for more details. - using ActivityName = internal::ActivityIconLoader::ActivityName; - // A part of OnIconsReadyCallback signature. - using ActivityToIconsMap = internal::ActivityIconLoader::ActivityToIconsMap; - using OnIconsReadyCallback = - internal::ActivityIconLoader::OnIconsReadyCallback; - using GetResult = internal::ActivityIconLoader::GetResult; + // LinkHandlerModelDelegete: GetResult GetActivityIcons(const std::vector& activities, - OnIconsReadyCallback callback); + OnIconsReadyCallback callback) override; + bool RequestUrlHandlerList(const std::string& url, + RequestUrlHandlerListCallback callback) override; + bool HandleUrl(const std::string& url, + const std::string& package_name) override; // Returns true when |url| can only be handled by Chrome. Otherwise, which is // when there might be one or more ARC apps that can handle |url|, returns @@ -164,10 +163,16 @@ class ArcIntentHelperBridge : public KeyedService, private: THREAD_CHECKER(thread_checker_); + // Convert vector of mojom::IntentHandlerInfoPtr to vector of + // LinkHandlerModelDelegate::IntentHandlerInfo. + void OnRequestUrlHandlerList( + RequestUrlHandlerListCallback callback, + std::vector handlers); + content::BrowserContext* const context_; ArcBridgeService* const arc_bridge_service_; // Owned by ArcServiceManager. - internal::ActivityIconLoader icon_loader_; + ActivityIconLoader icon_loader_; // A map of each package name to the intent filters for that package. // Used to determine if Chrome should handle a URL without handing off to @@ -189,6 +194,8 @@ class ArcIntentHelperBridge : public KeyedService, std::vector deleted_preferred_apps_; std::unique_ptr delegate_; + + base::WeakPtrFactory weak_ptr_factory_{this}; }; } // namespace arc diff --git a/components/autofill/core/browser/payments/credit_card_otp_authenticator.cc b/components/autofill/core/browser/payments/credit_card_otp_authenticator.cc index cd4b6e7f06f67a..022ce0acf17be4 100644 --- a/components/autofill/core/browser/payments/credit_card_otp_authenticator.cc +++ b/components/autofill/core/browser/payments/credit_card_otp_authenticator.cc @@ -144,8 +144,8 @@ void CreditCardOtpAuthenticator::OnDidSelectChallengeOption( } bool server_success = result == AutofillClient::PaymentsRpcResult::kSuccess; - // Dismiss the pending authentication selection dialog so that other dialogs - // can be shown. + // Dismiss the pending authentication selection dialog if it is visible so + // that other dialogs can be shown. autofill_client_->DismissUnmaskAuthenticatorSelectionDialog(server_success); if (server_success) { DCHECK(!context_token.empty()); @@ -156,6 +156,11 @@ void CreditCardOtpAuthenticator::OnDidSelectChallengeOption( return; } + // If the OTP input dialog is visible, also dismiss it. The two dialogs will + // not be shown at the same time but either one of them can be visible when + // this function is invoked. + autofill_client_->OnUnmaskOtpVerificationResult( + OtpUnmaskResult::kPermanentFailure); // Show the virtual card permanent error dialog if server explicitly returned // vcn permanent error, show temporary error dialog for the rest failure cases // since currently only virtual card is supported. diff --git a/components/browser_ui/styles/android/BUILD.gn b/components/browser_ui/styles/android/BUILD.gn index a8dcf9e4063068..b296042a2439b7 100644 --- a/components/browser_ui/styles/android/BUILD.gn +++ b/components/browser_ui/styles/android/BUILD.gn @@ -23,6 +23,7 @@ android_library("java") { android_resources("java_resources") { sources = [ + "java/res/color-v29/default_control_color_highlight.xml", "java/res/color/default_icon_color_accent1_tint_list.xml", "java/res/color/default_icon_color_light_tint_list.xml", "java/res/color/default_icon_color_secondary_light_tint_list.xml", diff --git a/components/browser_ui/styles/android/java/res/color-v29/default_control_color_highlight.xml b/components/browser_ui/styles/android/java/res/color-v29/default_control_color_highlight.xml new file mode 100644 index 00000000000000..83d9240370b2b0 --- /dev/null +++ b/components/browser_ui/styles/android/java/res/color-v29/default_control_color_highlight.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/components/browser_ui/styles/android/java/res/values-night/colors.xml b/components/browser_ui/styles/android/java/res/values-night/colors.xml index 5c5c4bbd2722c8..b6b7e151fd56f1 100644 --- a/components/browser_ui/styles/android/java/res/values-night/colors.xml +++ b/components/browser_ui/styles/android/java/res/values-night/colors.xml @@ -6,5 +6,7 @@ - @color/default_control_color_highlight_dark + + @color/default_control_color_highlight_dark + diff --git a/components/browser_ui/styles/android/java/res/values/colors.xml b/components/browser_ui/styles/android/java/res/values/colors.xml index 312a0b11d534bf..059e4132092a49 100644 --- a/components/browser_ui/styles/android/java/res/values/colors.xml +++ b/components/browser_ui/styles/android/java/res/values/colors.xml @@ -19,9 +19,14 @@ - + @color/default_control_color_highlight_light + + + @color/default_control_color_highlight_baseline + @color/default_control_color_normal_light diff --git a/components/browser_ui/styles/android/java/res/values/dimens.xml b/components/browser_ui/styles/android/java/res/values/dimens.xml index 680676022f58f4..f78a9414a5ad4c 100644 --- a/components/browser_ui/styles/android/java/res/values/dimens.xml +++ b/components/browser_ui/styles/android/java/res/values/dimens.xml @@ -20,4 +20,5 @@ 0.2 0.2 + 0.1 diff --git a/components/browser_ui/styles/android/java/res/values/semantic_colors_dynamic.xml b/components/browser_ui/styles/android/java/res/values/semantic_colors_dynamic.xml index b7f3f27904f23b..656460013030d2 100644 --- a/components/browser_ui/styles/android/java/res/values/semantic_colors_dynamic.xml +++ b/components/browser_ui/styles/android/java/res/values/semantic_colors_dynamic.xml @@ -8,6 +8,7 @@ ?attr/colorSurface ?attr/colorSurface ?attr/colorPrimary + @color/default_control_color_highlight ?attr/colorOnSurfaceVariant ?attr/colorOnSurface ?attr/colorPrimary @@ -22,6 +23,7 @@ @color/default_bg_color_baseline @color/default_bg_color_elev_0_baseline @color/default_control_color_active_baseline + @color/default_control_color_highlight_baseline @color/default_control_color_normal_baseline @color/default_icon_color_baseline @color/default_icon_color_accent1_baseline diff --git a/components/browser_ui/styles/android/java/res/values/styles.xml b/components/browser_ui/styles/android/java/res/values/styles.xml index ab4e2a5b300019..1af4b85d230831 100644 --- a/components/browser_ui/styles/android/java/res/values/styles.xml +++ b/components/browser_ui/styles/android/java/res/values/styles.xml @@ -102,7 +102,7 @@ @null 48dp @style/TextAppearance.TextLarge.Primary - @color/control_highlight_color + @macro/default_control_color_highlight - - - - + )HTML"); Compositor().BeginFrame(); - auto forced_activatable_locks = GetDocument() - .GetDisplayLockDocumentState() - .GetScopedForceActivatableLocks(); - GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kFindInPage); GetTextFinder().Find(/*identifier=*/0, WebString(String("hidden")), *mojom::blink::FindOptions::New(), /*wrap_within_frame=*/false); Compositor().BeginFrame(); - Compositor().BeginFrame(); HeapVector> markers = GetDocument().Markers().Markers(); @@ -769,21 +752,7 @@ TEST_F(TextFinderSimTest, BeforeMatchExpandedHiddenMatchableUkm) { LoadURL("https://example.com/test.html"); request.Complete(R"HTML( - - - - - + )HTML"); Compositor().BeginFrame(); @@ -792,57 +761,23 @@ TEST_F(TextFinderSimTest, BeforeMatchExpandedHiddenMatchableUkm) { static_cast(GetDocument().UkmRecorder()); EXPECT_EQ(recorder->entries_count(), 0u); - auto forced_activatable_locks = GetDocument() - .GetDisplayLockDocumentState() - .GetScopedForceActivatableLocks(); - GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kFindInPage); GetTextFinder().Find(/*identifier=*/0, WebString(String("hidden")), *mojom::blink::FindOptions::New(), /*wrap_within_frame=*/false); Compositor().BeginFrame(); - Compositor().BeginFrame(); auto entries = recorder->GetEntriesByName("Blink.FindInPage"); - ASSERT_EQ(entries.size(), 1u); + // There are two entries because + // DisplayLockUtilities::ActivateFindInPageMatchRangeIfNeeded followed by + // DisplayLockContext::CommitForActivationWithSignal sets a + // "HasFindInPageContentVisibilityActiveMatch" UKM. + ASSERT_EQ(entries.size(), 2u); - EXPECT_TRUE(ukm::TestUkmRecorder::EntryHasMetric( + EXPECT_FALSE(ukm::TestUkmRecorder::EntryHasMetric( entries[0], "BeforematchExpandedHiddenMatchable")); -} - -TEST_F(TextFinderSimTest, BeforeMatchExpandedHiddenMatchableUkmNoHandler) { - SimRequest request("https://example.com/test.html", "text/html"); - LoadURL("https://example.com/test.html"); - request.Complete(R"HTML( - - - - - )HTML"); - Compositor().BeginFrame(); - - GetDocument().ukm_recorder_ = std::make_unique(); - auto* recorder = - static_cast(GetDocument().UkmRecorder()); - EXPECT_EQ(recorder->entries_count(), 0u); - - auto forced_activatable_locks = GetDocument() - .GetDisplayLockDocumentState() - .GetScopedForceActivatableLocks(); - GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kFindInPage); - GetTextFinder().Find(/*identifier=*/0, WebString(String("hidden")), - *mojom::blink::FindOptions::New(), - /*wrap_within_frame=*/false); - - Compositor().BeginFrame(); - Compositor().BeginFrame(); - - auto entries = recorder->GetEntriesByName("Blink.FindInPage"); - EXPECT_EQ(entries.size(), 0u); + EXPECT_TRUE(ukm::TestUkmRecorder::EntryHasMetric( + entries[1], "BeforematchExpandedHiddenMatchable")); } TEST_F(TextFinderSimTest, BeforeMatchExpandedHiddenMatchableUseCounter) { @@ -850,34 +785,15 @@ TEST_F(TextFinderSimTest, BeforeMatchExpandedHiddenMatchableUseCounter) { LoadURL("https://example.com/test.html"); request.Complete(R"HTML( - - - - - + )HTML"); Compositor().BeginFrame(); - auto forced_activatable_locks = GetDocument() - .GetDisplayLockDocumentState() - .GetScopedForceActivatableLocks(); - GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kFindInPage); GetTextFinder().Find(/*identifier=*/0, WebString(String("hidden")), *mojom::blink::FindOptions::New(), /*wrap_within_frame=*/false); Compositor().BeginFrame(); - Compositor().BeginFrame(); EXPECT_TRUE(GetDocument().IsUseCounted( WebFeature::kBeforematchRevealedHiddenMatchable)); @@ -889,26 +805,15 @@ TEST_F(TextFinderSimTest, LoadURL("https://example.com/test.html"); request.Complete(R"HTML( - - - +
hidden
)HTML"); Compositor().BeginFrame(); - auto forced_activatable_locks = GetDocument() - .GetDisplayLockDocumentState() - .GetScopedForceActivatableLocks(); - GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kFindInPage); GetTextFinder().Find(/*identifier=*/0, WebString(String("hidden")), *mojom::blink::FindOptions::New(), /*wrap_within_frame=*/false); Compositor().BeginFrame(); - Compositor().BeginFrame(); EXPECT_FALSE(GetDocument().IsUseCounted( WebFeature::kBeforematchRevealedHiddenMatchable)); diff --git a/third_party/blink/renderer/core/frame/find_in_page.cc b/third_party/blink/renderer/core/frame/find_in_page.cc index 11c1a62f123d2a..22c97f56cc033c 100644 --- a/third_party/blink/renderer/core/frame/find_in_page.cc +++ b/third_party/blink/renderer/core/frame/find_in_page.cc @@ -174,16 +174,6 @@ bool FindInPage::FindInternal(int identifier, // Unlikely, but just in case we try to find-in-page on a detached frame. DCHECK(frame_->GetFrame()->GetPage()); - auto forced_activatable_locks = frame_->GetFrame() - ->GetDocument() - ->GetDisplayLockDocumentState() - .GetScopedForceActivatableLocks(); - - // Up-to-date, clean tree is required for finding text in page, since it - // relies on TextIterator to look over the text. - frame_->GetFrame()->GetDocument()->UpdateStyleAndLayout( - DocumentUpdateReason::kFindInPage); - return EnsureTextFinder().Find(identifier, search_text, options, wrap_within_frame, active_now); } diff --git a/third_party/blink/renderer/core/frame/local_frame_view.cc b/third_party/blink/renderer/core/frame/local_frame_view.cc index 0fe738fae93776..43ca630bafeb63 100644 --- a/third_party/blink/renderer/core/frame/local_frame_view.cc +++ b/third_party/blink/renderer/core/frame/local_frame_view.cc @@ -130,7 +130,6 @@ #include "third_party/blink/renderer/core/page/validation_message_client.h" #include "third_party/blink/renderer/core/paint/block_paint_invalidator.h" #include "third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.h" -#include "third_party/blink/renderer/core/paint/compositing/compositing_inputs_updater.h" #include "third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.h" #include "third_party/blink/renderer/core/paint/cull_rect_updater.h" #include "third_party/blink/renderer/core/paint/frame_painter.h" diff --git a/third_party/blink/renderer/core/frame/web_local_frame_impl.cc b/third_party/blink/renderer/core/frame/web_local_frame_impl.cc index 287ebf4a79b9eb..643e74f0431a99 100644 --- a/third_party/blink/renderer/core/frame/web_local_frame_impl.cc +++ b/third_party/blink/renderer/core/frame/web_local_frame_impl.cc @@ -266,6 +266,11 @@ #include "third_party/blink/renderer/platform/wtf/casting.h" #include "third_party/blink/renderer/platform/wtf/hash_map.h" +#if defined(OS_WIN) +#include "third_party/blink/public/web/win/web_font_family_names.h" +#include "third_party/blink/renderer/core/layout/layout_font_accessor_win.h" +#endif + namespace blink { namespace { @@ -670,6 +675,21 @@ bool WebLocalFrameImpl::LastActivationWasRestricted() const { return GetFrame()->LastActivationWasRestricted(); } +#if defined(OS_WIN) +WebFontFamilyNames WebLocalFrameImpl::GetWebFontFamilyNames() const { + FontFamilyNames font_family_names; + GetFontsUsedByFrame(*GetFrame(), font_family_names); + WebFontFamilyNames result; + for (const String& font_family_name : font_family_names.primary_fonts) + result.primary_family_names.push_back(font_family_name); + for (const String& font_family_name : font_family_names.fallback_fonts) { + if (!font_family_names.primary_fonts.Contains(font_family_name)) + result.fallback_family_names.push_back(font_family_name); + } + return result; +} +#endif + WebLocalFrame* WebLocalFrame::FrameForContext(v8::Local context) { return WebLocalFrameImpl::FromFrame(ToLocalFrameIfNotDetached(context)); } diff --git a/third_party/blink/renderer/core/frame/web_local_frame_impl.h b/third_party/blink/renderer/core/frame/web_local_frame_impl.h index 9af2d999ae1803..acdd80bb849b53 100644 --- a/third_party/blink/renderer/core/frame/web_local_frame_impl.h +++ b/third_party/blink/renderer/core/frame/web_local_frame_impl.h @@ -328,6 +328,9 @@ class CORE_EXPORT WebLocalFrameImpl final bool HasTransientUserActivation() override; bool ConsumeTransientUserActivation(UserActivationUpdateSource) override; bool LastActivationWasRestricted() const override; +#if defined(OS_WIN) + WebFontFamilyNames GetWebFontFamilyNames() const override; +#endif void SetTargetToCurrentHistoryItem(const WebString& target) override; void UpdateCurrentHistoryItem() override; PageState CurrentHistoryItemToPageState() override; diff --git a/third_party/blink/renderer/core/layout/build.gni b/third_party/blink/renderer/core/layout/build.gni index 716b9ca66fea1e..84608afd55fa7f 100644 --- a/third_party/blink/renderer/core/layout/build.gni +++ b/third_party/blink/renderer/core/layout/build.gni @@ -756,6 +756,8 @@ if (is_win) { "layout_theme_win.cc", "layout_theme_win.h", "web_font_rendering_win.cc", + "layout_font_accessor_win.h", + "layout_font_accessor_win.cc", ] } else { # Not Windows. blink_core_sources_layout += [ "layout_theme_font_provider_default.cc" ] diff --git a/third_party/blink/renderer/core/layout/layout_box.h b/third_party/blink/renderer/core/layout/layout_box.h index e55839ccfcaefd..a9ee4430b00f46 100644 --- a/third_party/blink/renderer/core/layout/layout_box.h +++ b/third_party/blink/renderer/core/layout/layout_box.h @@ -2085,6 +2085,11 @@ class CORE_EXPORT LayoutBox : public LayoutBoxModelObject { // call SetBackgroundPaintLocation() with the value to be used for painting. BackgroundPaintLocation ComputeBackgroundPaintLocationIfComposited() const; + bool HasFragmentItems() const { + NOT_DESTROYED(); + return ChildrenInline() && PhysicalFragments().HasFragmentItems(); + } + protected: ~LayoutBox() override; @@ -2196,10 +2201,6 @@ class CORE_EXPORT LayoutBox : public LayoutBoxModelObject { TextDirection ResolvedDirection() const; private: - bool HasFragmentItems() const { - NOT_DESTROYED(); - return ChildrenInline() && PhysicalFragments().HasFragmentItems(); - } inline bool LayoutOverflowIsSet() const { NOT_DESTROYED(); return overflow_ && overflow_->layout_overflow; diff --git a/third_party/blink/renderer/core/layout/layout_font_accessor_win.cc b/third_party/blink/renderer/core/layout/layout_font_accessor_win.cc new file mode 100644 index 00000000000000..d371e354cce04f --- /dev/null +++ b/third_party/blink/renderer/core/layout/layout_font_accessor_win.cc @@ -0,0 +1,87 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "third_party/blink/renderer/core/layout/layout_font_accessor_win.h" + +#include "third_party/blink/renderer/core/frame/local_frame.h" +#include "third_party/blink/renderer/core/layout/layout_block_flow.h" +#include "third_party/blink/renderer/core/layout/layout_box.h" +#include "third_party/blink/renderer/core/layout/layout_object.h" +#include "third_party/blink/renderer/core/layout/layout_view.h" +#include "third_party/blink/renderer/core/layout/ng/inline/ng_fragment_item.h" +#include "third_party/blink/renderer/core/layout/ng/inline/ng_inline_cursor.h" +#include "third_party/blink/renderer/core/layout/ng/ng_link.h" +#include "third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h" +#include "third_party/blink/renderer/platform/fonts/font_platform_data.h" +#include "third_party/blink/renderer/platform/fonts/shaping/shape_result_view.h" +#include "third_party/blink/renderer/platform/fonts/simple_font_data.h" + +namespace blink { + +namespace { + +void GetFontsUsedByLayoutObject(const LayoutObject& layout_object, + FontFamilyNames& result); + +void GetFontsUsedByFragment(const NGPhysicalBoxFragment& fragment, + FontFamilyNames& result) { + for (NGInlineCursor cursor(fragment); cursor; cursor.MoveToNext()) { + const NGFragmentItem& item = *cursor.Current().Item(); + if (item.IsText()) { + const ShapeResultView* shape_result_view = item.TextShapeResult(); + if (shape_result_view) { + const String font_family = + shape_result_view->PrimaryFont()->PlatformData().FontFamilyName(); + if (!font_family.IsEmpty()) + result.primary_fonts.insert(font_family); + HashSet fallback_font_data; + shape_result_view->FallbackFonts(&fallback_font_data); + for (const SimpleFontData* font_data : fallback_font_data) { + result.fallback_fonts.insert( + font_data->PlatformData().FontFamilyName()); + } + } + continue; + } + + // If this is a nested BFC (e.g., inline block, floats), compute its area. + if (item.Type() == NGFragmentItem::kBox) { + if (const auto* layout_box = DynamicTo(item.GetLayoutObject())) + GetFontsUsedByLayoutObject(*layout_box, result); + } + } + + // Traverse out-of-flow children. They are not in |NGFragmentItems|. + for (const NGLink& child : fragment.Children()) { + if (const auto* child_layout_box = + DynamicTo(child->GetLayoutObject())) + GetFontsUsedByLayoutObject(*child_layout_box, result); + } +} + +void GetFontsUsedByLayoutObject(const LayoutObject& layout_object, + FontFamilyNames& result) { + const LayoutObject* target = &layout_object; + while (target) { + // Use |NGInlineCursor| to traverse if |target| is an IFC. + if (const auto* block_flow = DynamicTo(target)) { + if (block_flow->HasFragmentItems()) { + for (const NGPhysicalBoxFragment& fragment : + block_flow->PhysicalFragments()) + GetFontsUsedByFragment(fragment, result); + target = target->NextInPreOrderAfterChildren(&layout_object); + continue; + } + } + target = target->NextInPreOrder(&layout_object); + } +} + +} // namespace + +void GetFontsUsedByFrame(const LocalFrame& frame, FontFamilyNames& result) { + GetFontsUsedByLayoutObject(frame.ContentLayoutObject()->RootBox(), result); +} + +} // namespace blink diff --git a/third_party/blink/renderer/core/layout/layout_font_accessor_win.h b/third_party/blink/renderer/core/layout/layout_font_accessor_win.h new file mode 100644 index 00000000000000..2063b15921fada --- /dev/null +++ b/third_party/blink/renderer/core/layout/layout_font_accessor_win.h @@ -0,0 +1,24 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_FONT_ACCESSOR_WIN_H_ +#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_FONT_ACCESSOR_WIN_H_ + +#include "third_party/blink/renderer/platform/wtf/hash_set.h" +#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" + +namespace blink { + +class LocalFrame; + +struct FontFamilyNames { + WTF::HashSet primary_fonts; + WTF::HashSet fallback_fonts; +}; + +void GetFontsUsedByFrame(const LocalFrame& frame, FontFamilyNames& result); + +} // namespace blink + +#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_FONT_ACCESSOR_WIN_H_ diff --git a/third_party/blink/renderer/core/paint/build.gni b/third_party/blink/renderer/core/paint/build.gni index a4869e79583439..85026b6aa89e74 100644 --- a/third_party/blink/renderer/core/paint/build.gni +++ b/third_party/blink/renderer/core/paint/build.gni @@ -38,16 +38,12 @@ blink_core_sources_paint = [ "compositing/composited_layer_mapping.h", "compositing/compositing_inputs_root.cc", "compositing/compositing_inputs_root.h", - "compositing/compositing_inputs_updater.cc", - "compositing/compositing_inputs_updater.h", "compositing/compositing_layer_assigner.cc", "compositing/compositing_layer_assigner.h", "compositing/compositing_layer_property_updater.cc", "compositing/compositing_layer_property_updater.h", "compositing/compositing_reason_finder.cc", "compositing/compositing_reason_finder.h", - "compositing/compositing_requirements_updater.cc", - "compositing/compositing_requirements_updater.h", "compositing/compositing_state.h", "compositing/compositing_update_type.h", "compositing/graphics_layer_tree_builder.cc", diff --git a/third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.cc b/third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.cc index c8fc2eee447ba9..982fb666ad4ab5 100644 --- a/third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.cc +++ b/third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.cc @@ -407,10 +407,6 @@ void CompositedLayerMapping::ComputeBoundsOfOwningLayer( GetLayoutObject().SetShouldCheckForPaintInvalidation(); } - // Otherwise discard the sub-pixel remainder because paint offset can't be - // transformed by a non-translation transform. - owning_layer_->SetSubpixelAccumulation(subpixel_accumulation); - absl::optional mask_bounding_box = CSSMaskPainter::MaskBoundingBox(GetLayoutObject(), subpixel_accumulation); absl::optional clip_path_bounding_box = @@ -526,16 +522,12 @@ void CompositedLayerMapping::UpdateSquashingLayerGeometry( gfx::Vector2d new_offset_from_layout_object = -ToRoundedVector2d(offset_from_squash_layer_origin); - PhysicalOffset subpixel_accumulation = - offset_from_squash_layer_origin + - PhysicalOffset(new_offset_from_layout_object); if (layer->offset_from_layout_object_set && layer->offset_from_layout_object != new_offset_from_layout_object) { layers_needing_paint_invalidation.push_back(layer->paint_layer); } layer->offset_from_layout_object = new_offset_from_layout_object; layer->offset_from_layout_object_set = true; - layer->paint_layer->SetSubpixelAccumulation(subpixel_accumulation); } non_scrolling_squashing_layer_->SetSize(squash_layer_bounds.size()); @@ -686,9 +678,6 @@ void CompositedLayerMapping::UpdateScrollingContentsLayerGeometry( PhysicalOffset(scrolling_contents_layer_->OffsetFromLayoutObject()); gfx::Vector2d new_offset_from_layout_object = -ToRoundedVector2d(offset_from_scrolling_contents_layer); - PhysicalOffset subpixel_accumulation = - offset_from_scrolling_contents_layer + - PhysicalOffset(new_offset_from_layout_object); if (layer->offset_from_layout_object_set && layer->offset_from_layout_object != new_offset_from_layout_object) { @@ -696,7 +685,6 @@ void CompositedLayerMapping::UpdateScrollingContentsLayerGeometry( } layer->offset_from_layout_object = new_offset_from_layout_object; layer->offset_from_layout_object_set = true; - layer->paint_layer->SetSubpixelAccumulation(subpixel_accumulation); } for (auto& layer : squashed_layers_in_scrolling_contents_) { UpdateLocalClipRectForSquashedLayer( diff --git a/third_party/blink/renderer/core/paint/compositing/compositing_inputs_updater.cc b/third_party/blink/renderer/core/paint/compositing/compositing_inputs_updater.cc deleted file mode 100644 index bf0770dfb6f596..00000000000000 --- a/third_party/blink/renderer/core/paint/compositing/compositing_inputs_updater.cc +++ /dev/null @@ -1,272 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "third_party/blink/renderer/core/paint/compositing/compositing_inputs_updater.h" - -#include "third_party/blink/renderer/core/display_lock/display_lock_utilities.h" -#include "third_party/blink/renderer/core/dom/document.h" -#include "third_party/blink/renderer/core/frame/local_frame_view.h" -#include "third_party/blink/renderer/core/layout/layout_block.h" -#include "third_party/blink/renderer/core/layout/layout_embedded_content.h" -#include "third_party/blink/renderer/core/layout/layout_view.h" -#include "third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.h" -#include "third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.h" -#include "third_party/blink/renderer/core/paint/paint_layer.h" -#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h" -#include "third_party/blink/renderer/platform/heap/handle.h" -#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h" -#include "third_party/blink/renderer/platform/instrumentation/use_counter.h" - -namespace blink { - -CompositingInputsUpdater::CompositingInputsUpdater( - PaintLayer* root_layer, - PaintLayer* compositing_inputs_root) - : root_layer_(root_layer), - compositing_inputs_root_(compositing_inputs_root) { -} - -CompositingInputsUpdater::~CompositingInputsUpdater() = default; - -bool CompositingInputsUpdater::LayerOrDescendantShouldBeComposited( - PaintLayer* layer) { - if (auto* layout_view = DynamicTo(layer->GetLayoutObject())) { - if (layout_view->GetFrameView()->ShouldThrottleRendering()) { - if (auto* inner_compositor = layout_view->Compositor()) - return inner_compositor->StaleInCompositingMode(); - return false; - } - } - DCHECK(!layer->GetLayoutObject().GetFrameView()->ShouldThrottleRendering()); - return layer->DescendantHasDirectOrScrollingCompositingReason() || - layer->NeedsCompositedScrolling(); -} - -void CompositingInputsUpdater::Update() { - TRACE_EVENT0("blink", "CompositingInputsUpdater::update"); - - AncestorInfo info; - UpdateType update_type = kDoNotForceUpdate; - PaintLayer* layer = - compositing_inputs_root_ ? compositing_inputs_root_ : root_layer_; - - // We don't need to do anything if the layer is under a locked display lock - // that prevents updates. - if (DisplayLockUtilities::LockedAncestorPreventingPrePaint( - layer->GetLayoutObject())) { - return; - } - - ApplyAncestorInfoToSelfAndAncestorsRecursively(layer, update_type, info); - UpdateSelfAndDescendantsRecursively(layer, update_type, info); - - if (LayerOrDescendantShouldBeComposited(layer)) { - // Update all parent layers - PaintLayer* parent_layer = layer->Parent(); - while (parent_layer && - !parent_layer->DescendantHasDirectOrScrollingCompositingReason()) { - parent_layer->SetDescendantHasDirectOrScrollingCompositingReason(true); - parent_layer = parent_layer->Parent(); - } - } -} - -void CompositingInputsUpdater::ApplyAncestorInfoToSelfAndAncestorsRecursively( - PaintLayer* layer, - UpdateType& update_type, - AncestorInfo& info) { - if (!layer) - return; - - // We first recursively call ApplyAncestorInfoToSelfAndAncestorsRecursively() - // to ensure that we start to compute AncestorInfo from the root layer (as we - // need to do a top-down tree walk to incrementally update this information). - ApplyAncestorInfoToSelfAndAncestorsRecursively(layer->Parent(), update_type, - info); - UpdateAncestorInfo(layer, update_type, info); -} - -void CompositingInputsUpdater::UpdateSelfAndDescendantsRecursively( - PaintLayer* layer, - UpdateType update_type, - AncestorInfo info) { - // UpdateAncestorInfo has been already computed in ApplyAncestorInfo() for - // layers from root_layer_ down to compositing_inputs_root_ both included. - if (layer != root_layer_ && layer != compositing_inputs_root_) - UpdateAncestorInfo(layer, update_type, info); - - PaintLayerCompositor* compositor = - layer->GetLayoutObject().View()->Compositor(); - - // The sequence of updates to compositing triggers goes like this: - // 1. Apply all triggers from kComboAllDirectNonStyleDeterminedReasons for - // |layer|. This may depend on ancestor composited scrolling (i.e. step - // 2 for an ancestor PaintLayer). - // 2. Put |layer| in composited scrolling mode if needed. - // 3. Reset DescendantHasDirectCompositingReason to false for |layer|. - // 4. Recurse into child PaintLayers. - // 5. Set DescendantHasDirectCompositingReason to true if it was for any - // child. - // 6. If |layer| is the root, composite if - // DescendantHasDirectCompositingReason is true for |layer|. - - // Note that prepaint may use the compositing information, so only skip - // recursing it if we're skipping prepaint. - bool recursion_blocked_by_display_lock = - layer->GetLayoutObject().ChildPrePaintBlockedByDisplayLock(); - - bool should_recurse = update_type == kForceUpdate; - - layer->SetDescendantHasDirectOrScrollingCompositingReason(false); - bool descendant_has_direct_compositing_reason = false; - - auto* first_child = - recursion_blocked_by_display_lock ? nullptr : layer->FirstChild(); - for (PaintLayer* child = first_child; child; child = child->NextSibling()) { - if (should_recurse) - UpdateSelfAndDescendantsRecursively(child, update_type, info); - descendant_has_direct_compositing_reason |= - LayerOrDescendantShouldBeComposited(child); - } - if (!descendant_has_direct_compositing_reason && - layer->GetLayoutObject().IsLayoutEmbeddedContent()) { - if (LayoutView* embedded_layout_view = - To(layer->GetLayoutObject()) - .ChildLayoutView()) { - descendant_has_direct_compositing_reason |= - LayerOrDescendantShouldBeComposited(embedded_layout_view->Layer()); - } - } - layer->SetDescendantHasDirectOrScrollingCompositingReason( - descendant_has_direct_compositing_reason); - - if ((layer->IsRootLayer() || layer->NeedsReorderOverlayOverflowControls()) && - layer->ScrollsOverflow() && - layer->DescendantHasDirectOrScrollingCompositingReason() && - !layer->NeedsCompositedScrolling()) - layer->GetScrollableArea()->UpdateNeedsCompositedScrolling(true); - - compositor->ClearCompositingInputsRoot(); -} - -bool CompositingInputsUpdater::NeedsPaintOffsetTranslationForCompositing( - PaintLayer* layer) { - return false; -} - -void CompositingInputsUpdater::UpdateAncestorInfo(PaintLayer* const layer, - UpdateType& update_type, - AncestorInfo& info) { - LayoutBoxModelObject& layout_object = layer->GetLayoutObject(); - const ComputedStyle& style = layout_object.StyleRef(); - - PaintLayer* enclosing_stacking_composited_layer = - info.enclosing_stacking_composited_layer; - PaintLayer* enclosing_squashing_composited_layer = - info.enclosing_squashing_composited_layer; - - switch (layer->GetCompositingState()) { - case kNotComposited: - break; - case kPaintsIntoOwnBacking: - if (layout_object.IsStackingContext()) - enclosing_stacking_composited_layer = layer; - break; - case kPaintsIntoGroupedBacking: - enclosing_squashing_composited_layer = - &layer->GroupedMapping()->OwningLayer(); - break; - } - - if (style.GetPosition() == EPosition::kAbsolute) { - info.escape_clip_to = info.escape_clip_to_for_absolute; - info.scrolling_ancestor = info.scrolling_ancestor_for_absolute; - info.needs_reparent_scroll = info.needs_reparent_scroll_for_absolute; - } else if (style.GetPosition() == EPosition::kFixed) { - info.escape_clip_to = info.escape_clip_to_for_fixed; - info.scrolling_ancestor = info.scrolling_ancestor_for_fixed; - info.needs_reparent_scroll = info.needs_reparent_scroll_for_fixed; - } - - if (layout_object.ShouldApplyLayoutContainment()) - info.nearest_contained_layout_layer = layer; - - info.enclosing_stacking_composited_layer = - enclosing_stacking_composited_layer; - info.enclosing_squashing_composited_layer = - enclosing_squashing_composited_layer; - - // Handles sibling scroll problem, i.e. a non-stacking context scroller - // needs to propagate scroll to its descendants that are siblings in - // paint order. For example: - //
- //
Paint sibling.
- //
- if (layer->ScrollsOverflow()) { - info.scrolling_ancestor = layer; - info.needs_reparent_scroll = true; - } - if (layout_object.CanContainAbsolutePositionObjects()) { - info.clip_chain_parent_for_absolute = layer; - info.escape_clip_to_for_absolute = info.escape_clip_to; - info.scrolling_ancestor_for_absolute = info.scrolling_ancestor; - info.needs_reparent_scroll_for_absolute = info.needs_reparent_scroll; - } - - // LayoutView isn't really the containing block for fixed-pos descendants - // in the sense that they don't scroll along with its in-flow contents. - // However LayoutView does clip them. - if (layout_object.CanContainFixedPositionObjects() && - !IsA(layout_object)) { - info.clip_chain_parent_for_fixed = layer; - info.escape_clip_to_for_fixed = info.escape_clip_to; - info.scrolling_ancestor_for_fixed = info.scrolling_ancestor; - info.needs_reparent_scroll_for_fixed = info.needs_reparent_scroll; - } - if (IsA(layout_object)) - info.clip_chain_parent_for_fixed = layer; - - // CSS clip affects all descendants, not just containing-block descendants. - // We don't have to set clip_chain_parent_for_absolute here because CSS clip - // requires position:absolute, so the element must contain absolute-positioned - // descendants. - // However it is incorrect to let fixed-positioned descendants to inherit the - // clip state from this element either, because the overflow clip and the - // inherited clip of the current element shouldn't apply to them if the - // current element is not a fixed-pos container. This is a known bug but too - // difficult to fix in SPv1 compositing. - if (layout_object.HasClip()) - info.clip_chain_parent_for_fixed = layer; - - if (layout_object.IsStackingContext()) { - info.escape_clip_to = nullptr; - info.escape_clip_to_for_absolute = nullptr; - info.escape_clip_to_for_fixed = nullptr; - // Workaround crbug.com/817175 - // We can't escape clip to a layer that paints after us, because in SPv1 - // cc needs to reverse engineer clip tree from the layer tree, and we - // can't refer to a clip node that hasn't been built yet. - // This will result in wrong clip in some rare cases, for example: - //
- //
- //
- //
- //
- if (info.escape_clip_to_for_absolute && style.EffectiveZIndex() < 0 && - !info.escape_clip_to_for_absolute->GetLayoutObject() - .IsStackingContext()) - info.escape_clip_to_for_absolute = nullptr; - if (info.escape_clip_to_for_fixed && style.EffectiveZIndex() < 0 && - !info.escape_clip_to_for_fixed->GetLayoutObject().IsStackingContext()) - info.escape_clip_to_for_fixed = nullptr; - - info.needs_reparent_scroll = info.needs_reparent_scroll_for_absolute = - info.needs_reparent_scroll_for_fixed = false; - } - - if (layout_object.IsStickyPositioned()) - info.is_under_position_sticky = true; -} - -} // namespace blink diff --git a/third_party/blink/renderer/core/paint/compositing/compositing_inputs_updater.h b/third_party/blink/renderer/core/paint/compositing/compositing_inputs_updater.h deleted file mode 100644 index b71072ec524682..00000000000000 --- a/third_party/blink/renderer/core/paint/compositing/compositing_inputs_updater.h +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_COMPOSITING_COMPOSITING_INPUTS_UPDATER_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_COMPOSITING_COMPOSITING_INPUTS_UPDATER_H_ - -#include "base/dcheck_is_on.h" -#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" - -namespace blink { - -class PaintLayer; - -class CompositingInputsUpdater { - STACK_ALLOCATED(); - - public: - explicit CompositingInputsUpdater(PaintLayer* root_layer, - PaintLayer* compositing_inputs_root); - ~CompositingInputsUpdater(); - - void Update(); - - // Combine all reasons for compositing a layer into a single boolean value - bool LayerOrDescendantShouldBeComposited(PaintLayer*); - - private: - enum UpdateType { - kDoNotForceUpdate, - kForceUpdate, - }; - - struct AncestorInfo { - STACK_ALLOCATED(); - - public: - // The ancestor composited PaintLayer which is also a stacking context. - PaintLayer* enclosing_stacking_composited_layer = nullptr; - // A "squashing composited layer" is a PaintLayer that owns a squashing - // layer. This variable stores the squashing composited layer for the - // nearest PaintLayer ancestor which is squashed. - PaintLayer* enclosing_squashing_composited_layer = nullptr; - - PaintLayer* clip_chain_parent_for_absolute = nullptr; - PaintLayer* clip_chain_parent_for_fixed = nullptr; - // These flags are set if we encountered a stacking context - // that will make descendants to inherit more clip than desired, - // so we have to setup an alternative clip parent instead. - PaintLayer* escape_clip_to = nullptr; - PaintLayer* escape_clip_to_for_absolute = nullptr; - PaintLayer* escape_clip_to_for_fixed = nullptr; - - PaintLayer* scrolling_ancestor = nullptr; - PaintLayer* scrolling_ancestor_for_absolute = nullptr; - PaintLayer* scrolling_ancestor_for_fixed = nullptr; - - // The nearest layer up in the ancestor chain that has layout containment - // applied to it, including the self layer. - PaintLayer* nearest_contained_layout_layer = nullptr; - - // These flags are set to true if a non-stacking context scroller - // is encountered, so that a descendant element won't inherit scroll - // translation from its compositing ancestor directly thus having to - // setup an alternative scroll parent instead. - bool needs_reparent_scroll = false; - bool needs_reparent_scroll_for_absolute = false; - bool needs_reparent_scroll_for_fixed = false; - - bool is_under_position_sticky = false; - }; - - void UpdateSelfAndDescendantsRecursively(PaintLayer*, - UpdateType, - AncestorInfo); - // This is a recursive method to update AncestorInfo - // starting from the root layer down to the compositing_inputs_root_. - void ApplyAncestorInfoToSelfAndAncestorsRecursively(PaintLayer*, - UpdateType&, - AncestorInfo&); - // This method takes care of updating AncestorInfo taking into account the - // current value of AncestorInfo. - void UpdateAncestorInfo(PaintLayer* const, UpdateType&, AncestorInfo&); - - bool NeedsPaintOffsetTranslationForCompositing(PaintLayer*); - - PaintLayer* root_layer_; - PaintLayer* compositing_inputs_root_; -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_COMPOSITING_COMPOSITING_INPUTS_UPDATER_H_ diff --git a/third_party/blink/renderer/core/paint/compositing/compositing_requirements_updater.cc b/third_party/blink/renderer/core/paint/compositing/compositing_requirements_updater.cc deleted file mode 100644 index e8d646e5a32c26..00000000000000 --- a/third_party/blink/renderer/core/paint/compositing/compositing_requirements_updater.cc +++ /dev/null @@ -1,578 +0,0 @@ -/* - * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. - * Copyright (C) 2014 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "third_party/blink/renderer/core/paint/compositing/compositing_requirements_updater.h" - -#include "third_party/blink/renderer/core/html/media/html_media_element.h" -#include "third_party/blink/renderer/core/layout/layout_embedded_content.h" -#include "third_party/blink/renderer/core/layout/layout_view.h" -#include "third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.h" -#include "third_party/blink/renderer/core/paint/paint_layer.h" -#include "third_party/blink/renderer/core/paint/paint_layer_paint_order_iterator.h" -#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h" -#include "third_party/blink/renderer/platform/heap/collection_support/clear_collection_scope.h" -#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h" - -namespace blink { - -class OverlapMapContainer { - public: - void Add(const gfx::Rect& bounds) { - layer_rects_.push_back(bounds); - bounding_box_.Union(bounds); - } - - bool OverlapsLayers(const gfx::Rect& bounds) const { - // Checking with the bounding box will quickly reject cases when - // layers are created for lists of items going in one direction and - // never overlap with each other. - if (!bounds.Intersects(bounding_box_)) - return false; - for (unsigned i = 0; i < layer_rects_.size(); i++) { - if (layer_rects_[i].Intersects(bounds)) - return true; - } - return false; - } - - void Unite(const OverlapMapContainer& other_container) { - layer_rects_.AppendVector(other_container.layer_rects_); - bounding_box_.Union(other_container.bounding_box_); - } - - private: - Vector layer_rects_; - gfx::Rect bounding_box_; -}; - -struct OverlapMapContainers { - OverlapMapContainer clipped; - OverlapMapContainer unclipped; -}; - -class CompositingRequirementsUpdater::OverlapMap { - public: - OverlapMap() { - // Begin by assuming the root layer will be composited so that there - // is something on the stack. The root layer should also never get a - // finishCurrentOverlapTestingContext() call. - BeginNewOverlapTestingContext(); - } - OverlapMap(const OverlapMap&) = delete; - OverlapMap& operator=(const OverlapMap&) = delete; - - // Each rect added is marked as clipped or unclipped. clipped rects may - // overlap only with other clipped rects, but unclipped rects may overlap - // with anything. - // - // This is used to model composited overflow scrolling, where PaintLayers - // within the scroller are not clipped for overlap testing, whereas - // PaintLayers not within it are. This is necessary because PaintLayerClipper - // is not smart enough to understand not to clip composited overflow clips, - // but still clip otherwise. - void Add(PaintLayer* layer, const gfx::Rect& bounds, bool is_clipped) { - DCHECK(!layer->IsRootLayer()); - if (bounds.IsEmpty()) - return; - - // Layers do not contribute to overlap immediately--instead, they will - // contribute to overlap as soon as they have been recursively processed - // and popped off the stack. - DCHECK_GE(overlap_stack_.size(), 2ul); - if (is_clipped) - overlap_stack_[overlap_stack_.size() - 2].clipped.Add(bounds); - else - overlap_stack_[overlap_stack_.size() - 2].unclipped.Add(bounds); - } - - bool OverlapsLayers(const gfx::Rect& bounds, bool is_clipped) const { - bool clipped_overlap = overlap_stack_.back().clipped.OverlapsLayers(bounds); - if (is_clipped) - return clipped_overlap; - // Unclipped is allowed to overlap clipped, but not vice-versa. - return clipped_overlap || - overlap_stack_.back().unclipped.OverlapsLayers(bounds); - } - - void BeginNewOverlapTestingContext() { - // This effectively creates a new "clean slate" for overlap state. - // This is used when we know that a subtree or remaining set of - // siblings does not need to check overlap with things behind it. - overlap_stack_.Grow(overlap_stack_.size() + 1); - } - - void FinishCurrentOverlapTestingContext() { - // The overlap information on the top of the stack is still necessary - // for checking overlap of any layers outside this context that may - // overlap things from inside this context. Therefore, we must merge - // the information from the top of the stack before popping the stack. - // - // FIXME: we may be able to avoid this deep copy by rearranging how - // overlapMap state is managed. - overlap_stack_[overlap_stack_.size() - 2].clipped.Unite( - overlap_stack_.back().clipped); - overlap_stack_[overlap_stack_.size() - 2].unclipped.Unite( - overlap_stack_.back().unclipped); - overlap_stack_.pop_back(); - } - - private: - Vector overlap_stack_; -}; - -class CompositingRequirementsUpdater::RecursionData { - STACK_ALLOCATED(); - - public: - explicit RecursionData(PaintLayer* compositing_ancestor) - : compositing_ancestor_(compositing_ancestor), - subtree_is_compositing_(false), - has_unisolated_composited_blending_descendant_(false), - testing_overlap_(true) {} - - PaintLayer* compositing_ancestor_; - bool subtree_is_compositing_; - bool has_unisolated_composited_blending_descendant_; - bool testing_overlap_; -}; - -static bool RequiresCompositingOrSquashing(CompositingReasons reasons) { -#if DCHECK_IS_ON() - bool fast_answer = reasons != CompositingReason::kNone; - bool slow_answer = RequiresCompositing(reasons) || RequiresSquashing(reasons); - DCHECK_EQ(slow_answer, fast_answer); -#endif - return reasons != CompositingReason::kNone; -} - -static CompositingReasons SubtreeReasonsForCompositing( - PaintLayer* layer, - bool has_composited_descendants, - bool has3d_transformed_descendants) { - CompositingReasons subtree_reasons = CompositingReason::kNone; - if (!has_composited_descendants) - return subtree_reasons; - - if (layer->ShouldIsolateCompositedDescendants()) { - DCHECK(layer->GetLayoutObject().IsStackingContext()); - subtree_reasons |= CompositingReason::kIsolateCompositedDescendants; - } - - if (layer->GetLayoutObject().IsVideo() && - To(layer->GetLayoutObject().GetNode()) - ->IsFullscreen()) { - subtree_reasons |= - CompositingReason::kFullscreenVideoWithCompositedDescendants; - } - - // A layer with preserve-3d or perspective only needs to be composited if - // there are descendant layers that will be affected by the preserve-3d or - // perspective. - if (has3d_transformed_descendants) { - const ComputedStyle& style = layer->GetLayoutObject().StyleRef(); - if (style.UsedTransformStyle3D() == ETransformStyle3D::kPreserve3d) - subtree_reasons |= CompositingReason::kPreserve3DWith3DDescendants; - - // Perspective (specified either by perspective or transform properties) - // with 3d descendants need a render surface for flattening purposes. - if (style.HasPerspective() || style.Transform().HasPerspective()) - subtree_reasons |= CompositingReason::kPerspectiveWith3DDescendants; - } - - return subtree_reasons; -} - -CompositingRequirementsUpdater::CompositingRequirementsUpdater( - LayoutView& layout_view) - : layout_view_(layout_view) {} - -void CompositingRequirementsUpdater::Update(PaintLayer* root) { - TRACE_EVENT0("blink", "CompositingRequirementsUpdater::updateRecursive"); - - // Go through the layers in presentation order, so that we can compute which - // Layers need compositing layers. - // FIXME: we could maybe do this and the hierarchy update in one pass, but the - // parenting logic would be more complex. - RecursionData recursion_data(root); - OverlapMap overlap_test_request_map; - bool saw3d_transform = false; - - // FIXME: Passing these unclippedDescendants down and keeping track - // of them dynamically, we are requiring a full tree walk. This - // should be removed as soon as proper overlap testing based on - // scrolling and animation bounds is implemented (crbug.com/252472). - HeapVector> unclipped_descendants; - ClearCollectionScope>> scope( - &unclipped_descendants); - gfx::Rect absolute_descendant_bounding_box; - UpdateRecursive(nullptr, root, overlap_test_request_map, recursion_data, - saw3d_transform, unclipped_descendants, - absolute_descendant_bounding_box); -} - -#if DCHECK_IS_ON() -static void CheckSubtreeHasNoCompositing(PaintLayer* layer) { - if (layer->GetLayoutObject().ChildPrePaintBlockedByDisplayLock()) - return; - - PaintLayerPaintOrderIterator iterator(layer, kAllChildren); - while (PaintLayer* cur_layer = iterator.Next()) { - DCHECK(cur_layer->GetCompositingState() == kNotComposited); - DCHECK(!cur_layer->CanBeComposited()); - CheckSubtreeHasNoCompositing(cur_layer); - } -} -#endif - -void CompositingRequirementsUpdater::UpdateRecursive( - PaintLayer* ancestor_layer, - PaintLayer* layer, - OverlapMap& overlap_map, - RecursionData& current_recursion_data, - bool& descendant_has3d_transform, - HeapVector>& unclipped_descendants, - gfx::Rect& absolute_descendant_bounding_box) { - PaintLayerCompositor* compositor = layout_view_.Compositor(); - - CompositingReasons reasons_to_composite = CompositingReason::kNone; - CompositingReasons direct_reasons = CompositingReason::kNone; - - bool has_non_root_composited_scrolling_ancestor = false; - bool use_clipped_bounding_rect = !has_non_root_composited_scrolling_ancestor; - - const bool layer_can_be_composited = layer->CanBeComposited(); - - CompositingReasons direct_from_paint_layer = 0; - direct_reasons |= direct_from_paint_layer; - - if (layer->GetScrollableArea() && - layer->GetScrollableArea()->NeedsCompositedScrolling()) - direct_reasons |= CompositingReason::kOverflowScrolling; - - bool can_be_composited = layer->CanBeComposited(); - if (can_be_composited) - reasons_to_composite |= direct_reasons; - - const LayoutObject& layout_object = layer->GetLayoutObject(); - - // Next, accumulate reasons related to overlap. - // If overlap testing is used, this reason will be overridden. If overlap - // testing is not used, we must assume we overlap if there is anything - // composited behind us in paint-order. - CompositingReasons overlap_compositing_reason = - (layer_can_be_composited && - current_recursion_data.subtree_is_compositing_) - ? CompositingReason::kAssumedOverlap - : CompositingReason::kNone; - - if (has_non_root_composited_scrolling_ancestor) { - Vector unclipped_descendants_to_remove; - for (wtf_size_t i = 0; i < unclipped_descendants.size(); i++) { - PaintLayer* unclipped_descendant = unclipped_descendants.at(i); - // If we've reached the containing block of one of the unclipped - // descendants, that element is no longer relevant to whether or not we - // should opt in. Unfortunately we can't easily remove from the list - // while we're iterating, so we have to store it for later removal. - if (unclipped_descendant->GetLayoutObject().ContainingBlock() == - &layout_object) { - unclipped_descendants_to_remove.push_back(i); - continue; - } - if (layer_can_be_composited && - layer->ScrollsWithRespectTo(unclipped_descendant)) - reasons_to_composite |= CompositingReason::kAssumedOverlap; - } - - // Remove irrelevant unclipped descendants in reverse order so our stored - // indices remain valid. - for (wtf_size_t i = 0; i < unclipped_descendants_to_remove.size(); i++) { - unclipped_descendants.EraseAt(unclipped_descendants_to_remove.at( - unclipped_descendants_to_remove.size() - i - 1)); - } - } - - if (reasons_to_composite & CompositingReason::kOutOfFlowClipping) { - // TODO(schenney): We only need to promote when the clipParent is not a - // descendant of the ancestor scroller, which we do not check for here. - // Hence we might be promoting needlessly. - unclipped_descendants.push_back(layer); - } - - gfx::Rect abs_bounds = layer->ExpandedBoundingBoxForCompositingOverlapTest( - use_clipped_bounding_rect); - - absolute_descendant_bounding_box = abs_bounds; - if (layer_can_be_composited && current_recursion_data.testing_overlap_ && - !RequiresCompositingOrSquashing(direct_reasons)) { - bool overlaps = - overlap_map.OverlapsLayers(abs_bounds, use_clipped_bounding_rect); - overlap_compositing_reason = - overlaps ? CompositingReason::kOverlap : CompositingReason::kNone; - } - - reasons_to_composite |= overlap_compositing_reason; - - // The children of this layer don't need to composite, unless there is - // a compositing layer among them, so start by inheriting the compositing - // ancestor with m_subtreeIsCompositing set to false. - RecursionData child_recursion_data = current_recursion_data; - child_recursion_data.subtree_is_compositing_ = false; - - // Embedded objects treat the embedded document as a child for the purposes - // of composited layer decisions. Look into the embedded document to determine - // if it is composited. - bool contains_composited_layer = - (layer->GetLayoutObject().IsLayoutEmbeddedContent() && - To(layer->GetLayoutObject()) - .ContentDocumentContainsGraphicsLayer()); - - bool will_be_composited_or_squashed = - can_be_composited && RequiresCompositingOrSquashing(reasons_to_composite); - - if (will_be_composited_or_squashed || contains_composited_layer) { - if (will_be_composited_or_squashed) { - // This layer now acts as the ancestor for child layers. - child_recursion_data.compositing_ancestor_ = layer; - } - - // Here we know that all children and the layer's own contents can blindly - // paint into this layer's backing, until a descendant is composited. So, we - // don't need to check for overlap with anything behind this layer. - overlap_map.BeginNewOverlapTestingContext(); - // This layer is going to be composited, so children can safely ignore the - // fact that there's an animation running behind this layer, meaning they - // can rely on the overlap map testing again. - child_recursion_data.testing_overlap_ = true; - } - -#if DCHECK_IS_ON() - PaintLayerListMutationDetector mutation_checker(layer); -#endif - - bool any_descendant_has3d_transform = false; - bool will_have_foreground_layer = false; - - bool needs_recursion_for_composited_scrolling_plus_fixed_or_sticky = - (layer->HasFixedPositionDescendant() || - layer->HasStickyPositionDescendant()) && - (has_non_root_composited_scrolling_ancestor || - (layer->GetScrollableArea() && - layer->GetScrollableArea()->NeedsCompositedScrolling())); - - bool needs_recursion_for_out_of_flow_descendant = - layer->HasNonContainedAbsolutePositionDescendant(); - - // Skip recursion if there are no descendants which: - // * may have their own reason for compositing, - // * have compositing already from the previous frame, or - // * may escape |layer|'s clip. - // * may need compositing requirements update for another reason ( - // e.g. change of stacking order) - bool recursion_blocked_by_display_lock = - layer->GetLayoutObject().ChildPrePaintBlockedByDisplayLock(); - bool skip_children_ignoring_display_lock = - (!layer->DescendantHasDirectOrScrollingCompositingReason() && - !needs_recursion_for_composited_scrolling_plus_fixed_or_sticky && - !needs_recursion_for_out_of_flow_descendant && - layer->GetLayoutObject().ShouldClipOverflowAlongEitherAxis()); - bool skip_children = - recursion_blocked_by_display_lock || skip_children_ignoring_display_lock; - - if (!skip_children) { - PaintLayerPaintOrderIterator iterator(layer, kNegativeZOrderChildren); - while (PaintLayer* child_layer = iterator.Next()) { - gfx::Rect absolute_child_descendant_bounding_box; - UpdateRecursive(layer, child_layer, overlap_map, child_recursion_data, - any_descendant_has3d_transform, unclipped_descendants, - absolute_child_descendant_bounding_box); - absolute_descendant_bounding_box.Union( - absolute_child_descendant_bounding_box); - - // If we have to make a layer for this child, make one now so we can have - // a contents layer (since we need to ensure that the -ve z-order child - // renders underneath our contents). - if (child_recursion_data.subtree_is_compositing_) { - reasons_to_composite |= CompositingReason::kNegativeZIndexChildren; - - if (!will_be_composited_or_squashed) { - // make layer compositing - child_recursion_data.compositing_ancestor_ = layer; - overlap_map.BeginNewOverlapTestingContext(); - will_be_composited_or_squashed = true; - will_have_foreground_layer = true; - - // FIXME: temporary solution for the first negative z-index composited - // child: re-compute the absBounds for the child so that we can add - // the negative z-index child's bounds to the new overlap context. - overlap_map.BeginNewOverlapTestingContext(); - overlap_map.Add(child_layer, - child_layer->ClippedAbsoluteBoundingBox(), true); - overlap_map.FinishCurrentOverlapTestingContext(); - } - } - } - } - - if (will_have_foreground_layer) { - DCHECK(will_be_composited_or_squashed); - // A foreground layer effectively is a new backing for all subsequent - // children, so we don't need to test for overlap with anything behind this. - // So, we can finish the previous context that was accumulating rects for - // the negative z-index children, and start with a fresh new empty context. - overlap_map.FinishCurrentOverlapTestingContext(); - overlap_map.BeginNewOverlapTestingContext(); - // This layer is going to be composited, so children can safely ignore the - // fact that there's an animation running behind this layer, meaning they - // can rely on the overlap map testing again. - child_recursion_data.testing_overlap_ = true; - } - - if (!skip_children) { - PaintLayerPaintOrderIterator iterator(layer, - kNormalFlowAndPositiveZOrderChildren); - while (PaintLayer* child_layer = iterator.Next()) { - gfx::Rect absolute_child_descendant_bounding_box; - UpdateRecursive(layer, child_layer, overlap_map, child_recursion_data, - any_descendant_has3d_transform, unclipped_descendants, - absolute_child_descendant_bounding_box); - absolute_descendant_bounding_box.Union( - absolute_child_descendant_bounding_box); - } - } - -#if DCHECK_IS_ON() - if (skip_children) - CheckSubtreeHasNoCompositing(layer); -#endif - - // Now that the subtree has been traversed, we can check for compositing - // reasons that depended on the state of the subtree. - - if (layer->GetLayoutObject().IsStackingContext()) { - layer->SetShouldIsolateCompositedDescendants( - child_recursion_data.has_unisolated_composited_blending_descendant_); - } else { - layer->SetShouldIsolateCompositedDescendants(false); - current_recursion_data.has_unisolated_composited_blending_descendant_ = - child_recursion_data.has_unisolated_composited_blending_descendant_; - } - - // Subsequent layers in the parent's stacking context may also need to - // composite. - if (child_recursion_data.subtree_is_compositing_ || contains_composited_layer) - current_recursion_data.subtree_is_compositing_ = true; - - if (layer->IsRootLayer()) { - // The root layer needs to be composited if anything else in the tree is - // composited. Otherwise, we can disable compositing entirely. - if (child_recursion_data.subtree_is_compositing_ || - RequiresCompositingOrSquashing(reasons_to_composite)) { -#if DCHECK_IS_ON() - if (layer->GetScrollableArea()) { - // The reason for compositing should not be due to composited scrolling. - // It should only be compositing in order to represent composited - // content within a composited subframe. - bool was = layer->NeedsCompositedScrolling(); - layer->GetScrollableArea()->UpdateNeedsCompositedScrolling(true); - DCHECK(was == layer->NeedsCompositedScrolling()); - } -#endif - - reasons_to_composite |= CompositingReason::kRoot; - } else { - compositor->SetCompositingModeEnabled(false); - reasons_to_composite = CompositingReason::kNone; - } - } else { - // All layers (even ones that aren't being composited) need to get added to - // the overlap map. Layers that are not separately composited will paint - // into their compositing ancestor's backing, and so are still considered - // for overlap. - if ((child_recursion_data.compositing_ancestor_ && - !child_recursion_data.compositing_ancestor_->IsRootLayer()) || - contains_composited_layer) { - overlap_map.Add(layer, abs_bounds, use_clipped_bounding_rect); - } - - // Now check for reasons to become composited that depend on the state of - // descendant layers. - CompositingReasons subtree_compositing_reasons = - SubtreeReasonsForCompositing( - layer, child_recursion_data.subtree_is_compositing_, - any_descendant_has3d_transform); - if (layer_can_be_composited) - reasons_to_composite |= subtree_compositing_reasons; - if (!will_be_composited_or_squashed && can_be_composited && - RequiresCompositingOrSquashing(subtree_compositing_reasons)) { - child_recursion_data.compositing_ancestor_ = layer; - // FIXME: this context push is effectively a no-op but needs to exist for - // now, because the code is designed to push overlap information to the - // second-from-top context of the stack. - overlap_map.BeginNewOverlapTestingContext(); - overlap_map.Add(layer, absolute_descendant_bounding_box, - use_clipped_bounding_rect); - will_be_composited_or_squashed = true; - } - - if (will_be_composited_or_squashed && - layer->GetLayoutObject().StyleRef().HasBlendMode()) { - current_recursion_data.has_unisolated_composited_blending_descendant_ = - true; - } - - // Tell the parent it has compositing descendants. - if (will_be_composited_or_squashed) - current_recursion_data.subtree_is_compositing_ = true; - - // Turn overlap testing off for later layers if it's already off, or if we - // have an animating transform. - if (!child_recursion_data.testing_overlap_ || - layer->GetLayoutObject().StyleRef().HasCurrentTransformAnimation()) { - current_recursion_data.testing_overlap_ = false; - } - - if (child_recursion_data.compositing_ancestor_ == layer || - contains_composited_layer) { - overlap_map.FinishCurrentOverlapTestingContext(); - } - - descendant_has3d_transform |= - any_descendant_has3d_transform || layer->Has3DTransform(); - } - - // Layer assignment is needed for allocating or removing composited - // layers related to this PaintLayer; hence the below conditions. - if (reasons_to_composite || layer->GetCompositingState() != kNotComposited) { - layer->SetNeedsCompositingLayerAssignment(); - } else if (contains_composited_layer) { - // If this is an iframe whose content document is composited, then we need - // CompositedLayerAssigner to process this layer, to ensure that we don't - // squash layers painted before the iframe with layers painted after it. - layer->PropagateDescendantNeedsCompositingLayerAssignment(); - } -} - -} // namespace blink diff --git a/third_party/blink/renderer/core/paint/compositing/compositing_requirements_updater.h b/third_party/blink/renderer/core/paint/compositing/compositing_requirements_updater.h deleted file mode 100644 index ef665be06f9e87..00000000000000 --- a/third_party/blink/renderer/core/paint/compositing/compositing_requirements_updater.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. - * Copyright (C) 2014 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_COMPOSITING_COMPOSITING_REQUIREMENTS_UPDATER_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_COMPOSITING_COMPOSITING_REQUIREMENTS_UPDATER_H_ - -#include "third_party/blink/renderer/platform/graphics/compositing_reasons.h" -#include "third_party/blink/renderer/platform/heap/collection_support/heap_vector.h" -#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" -#include "third_party/blink/renderer/platform/wtf/vector.h" -#include "ui/gfx/geometry/rect.h" - -namespace blink { - -class PaintLayer; -class LayoutView; - -class CompositingRequirementsUpdater { - STACK_ALLOCATED(); - - public: - CompositingRequirementsUpdater(LayoutView&); - - // Recurse through the layers in z-index and overflow order (which is - // equivalent to painting order) - // For the z-order children of a compositing layer: - // If a child layers has a compositing layer, then all subsequent layers - // must be compositing in order to render above that layer. - // - // If a child in the negative z-order list is compositing, then the layer - // itself must be compositing so that its contents render over that - // child. This implies that its positive z-index children must also be - // compositing. - // - void Update(PaintLayer* root); - - private: - class OverlapMap; - class RecursionData; - - void UpdateRecursive(PaintLayer* ancestor_layer, - PaintLayer* current_layer, - OverlapMap&, - RecursionData&, - bool& descendant_has3d_transform, - HeapVector>& unclipped_descendants, - gfx::Rect& absolute_descendant_bounding_box); - - LayoutView& layout_view_; -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_COMPOSITING_COMPOSITING_REQUIREMENTS_UPDATER_H_ diff --git a/third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.cc b/third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.cc index 9b65607fac8334..fcd49e79a35b4d 100644 --- a/third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.cc +++ b/third_party/blink/renderer/core/paint/compositing/paint_layer_compositor.cc @@ -44,9 +44,7 @@ #include "third_party/blink/renderer/core/page/chrome_client.h" #include "third_party/blink/renderer/core/page/page.h" #include "third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.h" -#include "third_party/blink/renderer/core/paint/compositing/compositing_inputs_updater.h" #include "third_party/blink/renderer/core/paint/compositing/compositing_layer_assigner.h" -#include "third_party/blink/renderer/core/paint/compositing/compositing_requirements_updater.h" #include "third_party/blink/renderer/core/paint/compositing/graphics_layer_tree_builder.h" #include "third_party/blink/renderer/core/paint/compositing/graphics_layer_updater.h" #include "third_party/blink/renderer/core/paint/object_paint_invalidator.h" @@ -77,7 +75,6 @@ void PaintLayerCompositor::CleanUp() { bool PaintLayerCompositor::InCompositingMode() const { // FIXME: This should assert that lifecycle is >= CompositingClean since // the last step of updateIfNeeded can set this bit to false. - DCHECK(layout_view_->Layer()->IsAllowedToQueryCompositingState()); return compositing_; } @@ -146,17 +143,6 @@ void PaintLayerCompositor::UpdateInputsIfNeededRecursiveInternal( layout_view_->CommitPendingSelection(); - if (pending_update_type_ >= kCompositingUpdateAfterCompositingInputChange) { - CompositingInputsUpdater updater(RootLayer(), GetCompositingInputsRoot()); - updater.Update(); - // TODO(chrishtr): we should only need to do this if compositing state - // changed, but - // compositing/iframe-graphics-tree-changes-parents-does-not.html - // breaks otherwise. - if (updater.LayerOrDescendantShouldBeComposited(RootLayer())) - SetOwnerNeedsCompositingInputsUpdate(); - } - Lifecycle().AdvanceTo(DocumentLifecycle::kCompositingInputsClean); } @@ -279,8 +265,6 @@ void PaintLayerCompositor::UpdateAssignmentsIfNeeded( &layers_needing_paint_invalidation); if (update_type >= kCompositingUpdateAfterCompositingInputChange) { - CompositingRequirementsUpdater(*layout_view_).Update(update_root); - CompositingLayerAssigner layer_assigner(this); layer_assigner.Assign(update_root, layers_needing_paint_invalidation); // TODO(szager): Remove this after diagnosing crash. diff --git a/third_party/blink/renderer/core/paint/paint_and_raster_invalidation_test.cc b/third_party/blink/renderer/core/paint/paint_and_raster_invalidation_test.cc index e2cb5f8725c2d9..a9f8de07ae72ae 100644 --- a/third_party/blink/renderer/core/paint/paint_and_raster_invalidation_test.cc +++ b/third_party/blink/renderer/core/paint/paint_and_raster_invalidation_test.cc @@ -28,23 +28,9 @@ static ContentLayerClientImpl* GetContentLayerClient( const RasterInvalidationTracking* GetRasterInvalidationTracking( const LocalFrameView& root_frame_view, wtf_size_t index) { - if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) { - if (auto* client = GetContentLayerClient(root_frame_view, index)) - return client->GetRasterInvalidator().GetTracking(); - return nullptr; - } - const GraphicsLayer* graphics_layer = nullptr; - ForAllGraphicsLayers( - *root_frame_view.GetLayoutView()->Layer()->GraphicsLayerBacking(), - [&index, &graphics_layer](const GraphicsLayer& layer) { - if (index-- == 0) { - graphics_layer = &layer; - return false; - } - return true; - }, - [](const GraphicsLayer&, const cc::Layer&) {}); - return graphics_layer->GetRasterInvalidationTracking(); + if (auto* client = GetContentLayerClient(root_frame_view, index)) + return client->GetRasterInvalidator().GetTracking(); + return nullptr; } void SetUpHTML(PaintAndRasterInvalidationTest& test) { @@ -110,14 +96,11 @@ TEST_P(PaintAndRasterInvalidationTest, TrackingForTracing) {
)HTML"); auto* target = GetDocument().getElementById("target"); - auto& cc_layer = - RuntimeEnabledFeatures::CompositeAfterPaintEnabled() - ? *GetDocument() - .View() - ->GetPaintArtifactCompositor() - ->RootLayer() - ->children()[1] - : GetLayoutView().Layer()->GraphicsLayerBacking()->CcLayer(); + auto& cc_layer = *GetDocument() + .View() + ->GetPaintArtifactCompositor() + ->RootLayer() + ->children()[1]; { ScopedEnablePaintInvalidationTracing tracing; @@ -575,19 +558,11 @@ TEST_P(PaintAndRasterInvalidationTest, auto container_raster_invalidation_tracking = [&]() -> const RasterInvalidationTracking* { - if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) - return GetRasterInvalidationTracking(1); - return target_obj->Layer() - ->GraphicsLayerBacking(target_obj) - ->GetRasterInvalidationTracking(); + return GetRasterInvalidationTracking(1); }; auto contents_raster_invalidation_tracking = [&]() -> const RasterInvalidationTracking* { - if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) - return GetRasterInvalidationTracking(2); - return target_obj->Layer() - ->GraphicsLayerBacking() - ->GetRasterInvalidationTracking(); + return GetRasterInvalidationTracking(2); }; // Resize the content. @@ -635,19 +610,11 @@ TEST_P(PaintAndRasterInvalidationTest, auto* target_obj = To(target->GetLayoutObject()); auto container_raster_invalidation_tracking = [&]() -> const RasterInvalidationTracking* { - if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) - return GetRasterInvalidationTracking(1); - return target_obj->Layer() - ->GraphicsLayerBacking(target_obj) - ->GetRasterInvalidationTracking(); + return GetRasterInvalidationTracking(1); }; auto contents_raster_invalidation_tracking = [&]() -> const RasterInvalidationTracking* { - if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) - return GetRasterInvalidationTracking(2); - return target_obj->Layer() - ->GraphicsLayerBacking() - ->GetRasterInvalidationTracking(); + return GetRasterInvalidationTracking(2); }; // Resize the content. @@ -744,11 +711,7 @@ TEST_P(PaintAndRasterInvalidationTest, CompositedSolidBackgroundResize) { target_object->GetBackgroundPaintLocation()); const auto* contents_raster_invalidation_tracking = - RuntimeEnabledFeatures::CompositeAfterPaintEnabled() - ? GetRasterInvalidationTracking(2) - : target_object->Layer() - ->GraphicsLayerBacking() - ->GetRasterInvalidationTracking(); + GetRasterInvalidationTracking(2); const auto& client = target_object->GetScrollableArea() ->GetScrollingBackgroundDisplayItemClient(); EXPECT_THAT(contents_raster_invalidation_tracking->Invalidations(), @@ -756,11 +719,7 @@ TEST_P(PaintAndRasterInvalidationTest, CompositedSolidBackgroundResize) { client.Id(), client.DebugName(), gfx::Rect(50, 0, 50, 500), PaintInvalidationReason::kIncremental})); const auto* container_raster_invalidation_tracking = - RuntimeEnabledFeatures::CompositeAfterPaintEnabled() - ? GetRasterInvalidationTracking(1) - : target_object->Layer() - ->GraphicsLayerBacking(target_object) - ->GetRasterInvalidationTracking(); + GetRasterInvalidationTracking(1); EXPECT_THAT( container_raster_invalidation_tracking->Invalidations(), UnorderedElementsAre(RasterInvalidationInfo{ diff --git a/third_party/blink/renderer/core/paint/paint_controller_paint_test.h b/third_party/blink/renderer/core/paint/paint_controller_paint_test.h index 060ef16437e6ff..ce6718212e9b5f 100644 --- a/third_party/blink/renderer/core/paint/paint_controller_paint_test.h +++ b/third_party/blink/renderer/core/paint/paint_controller_paint_test.h @@ -28,12 +28,7 @@ class PaintControllerPaintTestBase : public RenderingTest { protected: LayoutView& GetLayoutView() const { return *GetDocument().GetLayoutView(); } PaintController& RootPaintController() const { - if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) - return GetDocument().View()->GetPaintControllerForTesting(); - return GetLayoutView() - .Layer() - ->GraphicsLayerBacking() - ->GetPaintController(); + return GetDocument().View()->GetPaintControllerForTesting(); } void SetUp() override { diff --git a/third_party/blink/renderer/core/paint/paint_layer.cc b/third_party/blink/renderer/core/paint/paint_layer.cc index 3a9292b66e7b4b..3613ba8dfe07f0 100644 --- a/third_party/blink/renderer/core/paint/paint_layer.cc +++ b/third_party/blink/renderer/core/paint/paint_layer.cc @@ -109,9 +109,6 @@ namespace blink { namespace { -static CompositingQueryMode g_compositing_query_mode = - kCompositingQueriesAreOnlyAllowedInCertainDocumentLifecyclePhases; - #if defined(OS_LINUX) || defined(OS_CHROMEOS) struct SameSizeAsPaintLayer : GarbageCollected, DisplayItemClient { // The bit fields may fit into the machine word of DisplayItemClient which @@ -185,7 +182,6 @@ PaintLayer::PaintLayer(LayoutBoxModelObject* layout_object) needs_position_update_(!IsRootLayer()), #endif has3d_transformed_descendant_(false), - should_isolate_composited_descendants_(false), self_needs_repaint_(false), descendant_needs_repaint_(false), needs_cull_rect_update_(false), @@ -203,14 +199,10 @@ PaintLayer::PaintLayer(LayoutBoxModelObject* layout_object) backdrop_filter_on_effect_node_dirty_(false), has_filter_that_moves_pixels_(false), is_under_svg_hidden_container_(false), - descendant_has_direct_or_scrolling_compositing_reason_(false), - needs_compositing_layer_assignment_(false), - descendant_needs_compositing_layer_assignment_(false), has_self_painting_layer_descendant_(false), needs_reorder_overlay_overflow_controls_(false), static_inline_edge_(InlineEdge::kInlineStart), static_block_edge_(BlockEdge::kBlockStart), - needs_check_raster_invalidation_(false), #if DCHECK_IS_ON() layer_list_mutation_allowed_(true), #endif @@ -282,16 +274,6 @@ bool PaintLayer::PaintsWithFilters() const { return true; } -PhysicalOffset PaintLayer::SubpixelAccumulation() const { - return rare_data_ ? rare_data_->subpixel_accumulation : PhysicalOffset(); -} - -void PaintLayer::SetSubpixelAccumulation(const PhysicalOffset& accumulation) { - DCHECK(!RuntimeEnabledFeatures::CompositeAfterPaintEnabled()); - if (rare_data_ || !accumulation.IsZero()) - EnsureRareData().subpixel_accumulation = accumulation; -} - void PaintLayer::UpdateLayerPositionsAfterLayout() { TRACE_EVENT0("blink,benchmark", "PaintLayer::updateLayerPositionsAfterLayout"); @@ -950,8 +932,6 @@ PaintLayer::EnclosingLayerForPaintInvalidationCrossingFrameBoundaries() const { } PaintLayer* PaintLayer::EnclosingLayerForPaintInvalidation() const { - DCHECK(IsAllowedToQueryCompositingState()); - if (IsPaintInvalidationContainer()) return const_cast(this); @@ -1020,16 +1000,6 @@ void PaintLayer::SetNeedsGraphicsLayerRebuild() { Compositor()->SetNeedsCompositingUpdate(kCompositingUpdateRebuildTree); } -void PaintLayer::SetNeedsCheckRasterInvalidation() { - DCHECK_EQ(GetLayoutObject().GetDocument().Lifecycle().GetState(), - DocumentLifecycle::kInPrePaint); - needs_check_raster_invalidation_ = true; - // We need to mark |this| as needing layer assignment also, because - // CompositingLayerAssigner is where we transfer the raster invalidation - // checking bit from PaintLayer to GraphicsLayer. - SetNeedsCompositingLayerAssignment(); -} - void PaintLayer::SetNeedsVisualOverflowRecalc() { DCHECK(IsSelfPaintingLayer()); #if DCHECK_IS_ON() @@ -1062,16 +1032,6 @@ bool PaintLayer::HasNonIsolatedDescendantWithBlendMode() const { return false; } -void PaintLayer::SetShouldIsolateCompositedDescendants( - bool should_isolate_composited_descendants) { - if (should_isolate_composited_descendants_ == - static_cast(should_isolate_composited_descendants)) - return; - - should_isolate_composited_descendants_ = - should_isolate_composited_descendants; -} - bool PaintLayer::HasAncestorWithFilterThatMovesPixels() const { for (const PaintLayer* curr = this; curr; curr = curr->Parent()) { if (curr->HasFilterThatMovesPixels()) @@ -2312,24 +2272,6 @@ bool PaintLayer::IsReplacedNormalFlowStacking() const { return GetLayoutObject().IsSVGForeignObject(); } -void PaintLayer::SetNeedsCompositingLayerAssignment() { - needs_compositing_layer_assignment_ = true; - PropagateDescendantNeedsCompositingLayerAssignment(); -} - -void PaintLayer::PropagateDescendantNeedsCompositingLayerAssignment() { - for (PaintLayer* curr = CompositingContainer(); - curr && !curr->StackingDescendantNeedsCompositingLayerAssignment(); - curr = curr->CompositingContainer()) { - curr->descendant_needs_compositing_layer_assignment_ = true; - } -} - -void PaintLayer::ClearNeedsCompositingLayerAssignment() { - needs_compositing_layer_assignment_ = false; - descendant_needs_compositing_layer_assignment_ = false; -} - PaintLayer* PaintLayer::HitTestChildren( PaintLayerIteration children_to_visit, const PaintLayer& transform_container, @@ -2778,38 +2720,6 @@ PhysicalRect PaintLayer::BoundingBoxForCompositingInternal( return result; } -bool PaintLayer::IsAllowedToQueryCompositingState() const { - if (g_compositing_query_mode == kCompositingQueriesAreAllowed || - RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) - return true; - if (!GetLayoutObject().GetFrameView()->IsUpdatingLifecycle()) - return true; - return GetLayoutObject().GetDocument().Lifecycle().GetState() >= - DocumentLifecycle::kInCompositingAssignmentsUpdate; -} - -bool PaintLayer::IsAllowedToQueryCompositingInputs() const { - if (g_compositing_query_mode == kCompositingQueriesAreAllowed || - RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) - return true; - return GetLayoutObject().GetDocument().Lifecycle().GetState() >= - DocumentLifecycle::kCompositingInputsClean; -} - -GraphicsLayer* PaintLayer::GraphicsLayerBacking(const LayoutObject* obj) const { - switch (GetCompositingState()) { - case kNotComposited: - return nullptr; - case kPaintsIntoGroupedBacking: - return GroupedMapping()->SquashingLayer(*this); - default: - return (obj != &GetLayoutObject() && - GetCompositedLayerMapping()->ScrollingContentsLayer()) - ? GetCompositedLayerMapping()->ScrollingContentsLayer() - : GetCompositedLayerMapping()->MainGraphicsLayer(); - } -} - bool PaintLayer::NeedsCompositedScrolling() const { return scrollable_area_ && scrollable_area_->NeedsCompositedScrolling(); } diff --git a/third_party/blink/renderer/core/paint/paint_layer.h b/third_party/blink/renderer/core/paint/paint_layer.h index 9100192e0c1911..4501490463a987 100644 --- a/third_party/blink/renderer/core/paint/paint_layer.h +++ b/third_party/blink/renderer/core/paint/paint_layer.h @@ -78,15 +78,8 @@ class PaintLayerScrollableArea; class ScrollingCoordinator; class TransformationMatrix; -using PaintLayerId = uint64_t; - enum IncludeSelfOrNot { kIncludeSelf, kExcludeSelf }; -enum CompositingQueryMode { - kCompositingQueriesAreAllowed, - kCompositingQueriesAreOnlyAllowedInCertainDocumentLifecyclePhases -}; - // Used in PaintLayerPaintOrderIterator. enum PaintLayerIteration { kNegativeZOrderChildren = 1, @@ -133,10 +126,6 @@ struct CORE_EXPORT PaintLayerRareData final Member enclosing_pagination_layer; Member resource_info; - - // The accumulated subpixel offset of a composited layer's composited bounds - // compared to absolute coordinates. - PhysicalOffset subpixel_accumulation; }; // PaintLayer is an old object that handles lots of unrelated operations. @@ -481,8 +470,10 @@ class CORE_EXPORT PaintLayer : public GarbageCollected, return position; } - PhysicalOffset SubpixelAccumulation() const; - void SetSubpixelAccumulation(const PhysicalOffset&); + PhysicalOffset SubpixelAccumulation() const { + // TODO(pdr): Remove this. + return PhysicalOffset(); + } bool HasTransformRelatedProperty() const { return GetLayoutObject().HasTransformRelatedProperty(); @@ -524,26 +515,11 @@ class CORE_EXPORT PaintLayer : public GarbageCollected, return kNotComposited; } - // This returns true if our document is in a phase of its lifestyle during - // which compositing state may legally be read. - bool IsAllowedToQueryCompositingState() const; - - bool IsAllowedToQueryCompositingInputs() const; - CompositedLayerMapping* GetCompositedLayerMapping() const { // TODO(pdr): Remove this. return nullptr; } - // Returns the GraphicsLayer owned by this PaintLayer's - // CompositedLayerMapping (or groupedMapping()'s, if squashed), - // into which the given LayoutObject paints. If null, assumes the - // LayoutObject is *not* layoutObject(). - // Assumes that the given LayoutObject paints into one of the GraphicsLayers - // associated with this PaintLayer. - // Returns nullptr if this PaintLayer is not composited. - GraphicsLayer* GraphicsLayerBacking(const LayoutObject* = nullptr) const; - bool HasCompositedLayerMapping() const { // TODO(pdr): Remove this. return false; @@ -674,15 +650,6 @@ class CORE_EXPORT PaintLayer : public GarbageCollected, // layer tree. void SetNeedsGraphicsLayerRebuild(); - // Mark this PaintLayer as needing raster invalidation checking after the - // next compositing update step. - void SetNeedsCheckRasterInvalidation(); - bool NeedsCheckRasterInvalidation() const { - return needs_check_raster_invalidation_; - } - void ClearNeedsCheckRasterInvalidation() { - needs_check_raster_invalidation_ = false; - } void UpdateAncestorScrollContainerLayer( const PaintLayer* ancestor_scroll_container_layer) { ancestor_scroll_container_layer_ = ancestor_scroll_container_layer; @@ -750,12 +717,6 @@ class CORE_EXPORT PaintLayer : public GarbageCollected, return SquashingDisallowedReason::kNone; } - bool ShouldIsolateCompositedDescendants() const { - DCHECK(IsAllowedToQueryCompositingState()); - return should_isolate_composited_descendants_; - } - void SetShouldIsolateCompositedDescendants(bool); - void UpdateDescendantDependentFlags(); void UpdateSelfPaintingLayer(); @@ -849,13 +810,6 @@ class CORE_EXPORT PaintLayer : public GarbageCollected, needs_paint_phase_float_ = true; } - bool DescendantHasDirectOrScrollingCompositingReason() const { - return descendant_has_direct_or_scrolling_compositing_reason_; - } - void SetDescendantHasDirectOrScrollingCompositingReason(bool value) { - descendant_has_direct_or_scrolling_compositing_reason_ = value; - } - bool Has3DTransformedDescendant() const { DCHECK(!needs_descendant_dependent_flags_update_); return has3d_transformed_descendant_; @@ -883,13 +837,6 @@ class CORE_EXPORT PaintLayer : public GarbageCollected, void ClearNeedsCompositingLayerAssignment(); void PropagateDescendantNeedsCompositingLayerAssignment(); - bool NeedsCompositingLayerAssignment() const { - return needs_compositing_layer_assignment_; - } - bool StackingDescendantNeedsCompositingLayerAssignment() const { - return descendant_needs_compositing_layer_assignment_; - } - void DirtyStackingContextZOrderLists(); PhysicalOffset OffsetForInFlowRelPosition() const { @@ -1087,9 +1034,6 @@ class CORE_EXPORT PaintLayer : public GarbageCollected, // in a preserves3D hierarchy. Hint to do 3D-aware hit testing. unsigned has3d_transformed_descendant_ : 1; - // Should be for stacking contexts having unisolated blending descendants. - unsigned should_isolate_composited_descendants_ : 1; - unsigned self_needs_repaint_ : 1; unsigned descendant_needs_repaint_ : 1; @@ -1127,19 +1071,12 @@ class CORE_EXPORT PaintLayer : public GarbageCollected, // ancestor. unsigned is_under_svg_hidden_container_ : 1; - unsigned descendant_has_direct_or_scrolling_compositing_reason_ : 1; - - unsigned needs_compositing_layer_assignment_ : 1; - unsigned descendant_needs_compositing_layer_assignment_ : 1; - unsigned has_self_painting_layer_descendant_ : 1; unsigned needs_reorder_overlay_overflow_controls_ : 1; unsigned static_inline_edge_ : 2; unsigned static_block_edge_ : 2; - unsigned needs_check_raster_invalidation_ : 1; - #if DCHECK_IS_ON() mutable unsigned layer_list_mutation_allowed_ : 1; bool is_destroyed_ = false; diff --git a/third_party/blink/renderer/core/paint/paint_layer_painter_test.cc b/third_party/blink/renderer/core/paint/paint_layer_painter_test.cc index f25e767ba1ff2d..5947d5b11a045f 100644 --- a/third_party/blink/renderer/core/paint/paint_layer_painter_test.cc +++ b/third_party/blink/renderer/core/paint/paint_layer_painter_test.cc @@ -23,13 +23,6 @@ class PaintLayerPainterTest : public PaintControllerPaintTest { USING_FAST_MALLOC(PaintLayerPainterTest); public: - PaintController& MainGraphicsLayerPaintController() { - return GetLayoutView() - .Layer() - ->GraphicsLayerBacking(&GetLayoutView()) - ->GetPaintController(); - } - CullRect GetCullRect(const PaintLayer& layer) { if (RuntimeEnabledFeatures::CullRectUpdateEnabled()) return layer.GetLayoutObject().FirstFragment().GetCullRect(); diff --git a/third_party/blink/renderer/core/paint/paint_layer_scrollable_area_test.cc b/third_party/blink/renderer/core/paint/paint_layer_scrollable_area_test.cc index 96c0297f436f6d..93125ee47c3156 100644 --- a/third_party/blink/renderer/core/paint/paint_layer_scrollable_area_test.cc +++ b/third_party/blink/renderer/core/paint/paint_layer_scrollable_area_test.cc @@ -95,24 +95,9 @@ class PaintLayerScrollableAreaTest : public PaintControllerPaintTest { return false; } - if (!RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) { - DCHECK_EQ(composited, layer->NeedsCompositedScrolling()); - DCHECK_EQ(composited, scrollable_area->NeedsCompositedScrolling()); - if (composited) - DCHECK(layer->GraphicsLayerBacking()); - } return composited; } - bool GraphicsLayerContentsOpaque(const LayoutObject* scroller) { - DCHECK(!RuntimeEnabledFeatures::CompositeAfterPaintEnabled()); - return To(scroller) - ->Layer() - ->GraphicsLayerBacking() - ->CcLayer() - .contents_opaque(); - } - private: void SetUp() override { EnableCompositing(); @@ -137,8 +122,6 @@ TEST_P(PaintLayerScrollableAreaTest, OpaqueContainedLayersPromoted) { auto* scroller = GetLayoutObjectByElementId("scroller"); EXPECT_TRUE(UsesCompositedScrolling(scroller)); - if (!RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) - EXPECT_TRUE(GraphicsLayerContentsOpaque(scroller)); } TEST_P(PaintLayerScrollableAreaTest, NonStackingContextScrollerPromoted) { @@ -212,8 +195,6 @@ TEST_P(PaintLayerScrollableAreaTest, OpaqueLayersPromotedOnStyleChange) { "background: white local content-box;"); UpdateAllLifecyclePhasesForTest(); EXPECT_TRUE(UsesCompositedScrolling(scroller->GetLayoutObject())); - if (!RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) - EXPECT_TRUE(GraphicsLayerContentsOpaque(scroller->GetLayoutObject())); } // Tests that a transform on the scroller or an ancestor doesn't prevent @@ -234,8 +215,6 @@ TEST_P(PaintLayerScrollableAreaTest, Element* parent = GetDocument().getElementById("parent"); Element* scroller = GetDocument().getElementById("scroller"); EXPECT_TRUE(UsesCompositedScrolling(scroller->GetLayoutObject())); - if (!RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) - EXPECT_TRUE(GraphicsLayerContentsOpaque(scroller->GetLayoutObject())); // Change the parent to have a transform. parent->setAttribute(html_names::kStyleAttr, "transform: translate(1px, 0);"); @@ -246,8 +225,6 @@ TEST_P(PaintLayerScrollableAreaTest, parent->removeAttribute(html_names::kStyleAttr); UpdateAllLifecyclePhasesForTest(); EXPECT_TRUE(UsesCompositedScrolling(scroller->GetLayoutObject())); - if (!RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) - EXPECT_TRUE(GraphicsLayerContentsOpaque(scroller->GetLayoutObject())); // Apply a transform to the scroller directly. scroller->setAttribute(html_names::kStyleAttr, @@ -272,8 +249,6 @@ TEST_P(PaintLayerScrollableAreaTest, Element* parent = GetDocument().getElementById("parent"); Element* scroller = GetDocument().getElementById("scroller"); EXPECT_TRUE(UsesCompositedScrolling(scroller->GetLayoutObject())); - if (!RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) - EXPECT_TRUE(GraphicsLayerContentsOpaque(scroller->GetLayoutObject())); // Change the parent to be partially translucent. parent->setAttribute(html_names::kStyleAttr, "opacity: 0.5;"); @@ -284,8 +259,6 @@ TEST_P(PaintLayerScrollableAreaTest, parent->setAttribute(html_names::kStyleAttr, "opacity: 1;"); UpdateAllLifecyclePhasesForTest(); EXPECT_TRUE(UsesCompositedScrolling(scroller->GetLayoutObject())); - if (!RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) - EXPECT_TRUE(GraphicsLayerContentsOpaque(scroller->GetLayoutObject())); // Make the scroller translucent. scroller->setAttribute(html_names::kStyleAttr, "opacity: 0.5"); diff --git a/third_party/blink/renderer/modules/BUILD.gn b/third_party/blink/renderer/modules/BUILD.gn index cea17d196ad24a..6579fcde9a5fb8 100644 --- a/third_party/blink/renderer/modules/BUILD.gn +++ b/third_party/blink/renderer/modules/BUILD.gn @@ -580,6 +580,7 @@ source_set("unit_tests") { "service_worker/service_worker_installed_scripts_manager_test.cc", "service_worker/thread_safe_script_container_test.cc", "service_worker/web_embedded_worker_impl_test.cc", + "service_worker/web_service_worker_fetch_context_impl_test.cc", "video_rvfc/video_frame_callback_requester_impl_test.cc", "video_rvfc/video_frame_request_callback_collection_test.cc", "wake_lock/wake_lock_manager_test.cc", diff --git a/third_party/blink/renderer/modules/handwriting/handwriting_recognition_service.cc b/third_party/blink/renderer/modules/handwriting/handwriting_recognition_service.cc index 42e28d47798d4c..def5ab85b4778a 100644 --- a/third_party/blink/renderer/modules/handwriting/handwriting_recognition_service.cc +++ b/third_party/blink/renderer/modules/handwriting/handwriting_recognition_service.cc @@ -31,7 +31,7 @@ void OnCreateHandwritingRecognizer( switch (result) { case handwriting::mojom::blink::CreateHandwritingRecognizerResult::kError: { resolver->Reject(MakeGarbageCollected( - DOMExceptionCode::kNotSupportedError, "Internal error.")); + DOMExceptionCode::kUnknownError, "Internal error.")); return; } case handwriting::mojom::blink::CreateHandwritingRecognizerResult:: diff --git a/third_party/blink/renderer/modules/service_worker/BUILD.gn b/third_party/blink/renderer/modules/service_worker/BUILD.gn index 8c03079eede38b..269c141f2f6fa4 100644 --- a/third_party/blink/renderer/modules/service_worker/BUILD.gn +++ b/third_party/blink/renderer/modules/service_worker/BUILD.gn @@ -62,6 +62,8 @@ blink_modules_sources("service_worker") { "thread_safe_script_container.h", "wait_until_observer.cc", "wait_until_observer.h", + "web_service_worker_fetch_context_impl.cc", + "web_service_worker_fetch_context_impl.h", ] public_deps = [ "//third_party/blink/renderer/platform" ] diff --git a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc index d15c0695ef1c20..0c749e04a11ec3 100644 --- a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc +++ b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc @@ -55,7 +55,6 @@ #include "third_party/blink/public/mojom/web_feature/web_feature.mojom-blink.h" #include "third_party/blink/public/mojom/worker/subresource_loader_updater.mojom.h" #include "third_party/blink/public/platform/modules/service_worker/web_service_worker_error.h" -#include "third_party/blink/public/platform/modules/service_worker/web_service_worker_fetch_context.h" #include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/web_url.h" #include "third_party/blink/renderer/bindings/core/v8/callback_promise_adapter.h" @@ -126,6 +125,7 @@ #include "third_party/blink/renderer/modules/service_worker/service_worker_thread.h" #include "third_party/blink/renderer/modules/service_worker/service_worker_window_client.h" #include "third_party/blink/renderer/modules/service_worker/wait_until_observer.h" +#include "third_party/blink/renderer/modules/service_worker/web_service_worker_fetch_context_impl.h" #include "third_party/blink/renderer/platform/bindings/script_state.h" #include "third_party/blink/renderer/platform/bindings/v8_throw_exception.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" @@ -1595,7 +1595,7 @@ void ServiceWorkerGlobalScope::InitializeGlobalScope( GetTaskRunner(TaskType::kInternalDefault)); if (subresource_loader_factories) { - static_cast(web_worker_fetch_context()) + static_cast(web_worker_fetch_context()) ->GetSubresourceLoaderUpdater() ->UpdateSubresourceLoaderFactories( std::move(subresource_loader_factories)); diff --git a/third_party/blink/renderer/modules/service_worker/web_embedded_worker_impl_test.cc b/third_party/blink/renderer/modules/service_worker/web_embedded_worker_impl_test.cc index 56f9d0b55f49b9..e1ca3b7bce0372 100644 --- a/third_party/blink/renderer/modules/service_worker/web_embedded_worker_impl_test.cc +++ b/third_party/blink/renderer/modules/service_worker/web_embedded_worker_impl_test.cc @@ -140,9 +140,6 @@ class FakeWebServiceWorkerFetchContext final return {}; } void SetIsOfflineMode(bool is_offline_mode) override {} - mojom::SubresourceLoaderUpdater* GetSubresourceLoaderUpdater() override { - return nullptr; - } private: FakeWebURLLoaderFactory fake_web_url_loader_factory_; diff --git a/third_party/blink/renderer/modules/service_worker/web_service_worker_fetch_context_impl.cc b/third_party/blink/renderer/modules/service_worker/web_service_worker_fetch_context_impl.cc new file mode 100644 index 00000000000000..bdc58ed81b76a6 --- /dev/null +++ b/third_party/blink/renderer/modules/service_worker/web_service_worker_fetch_context_impl.cc @@ -0,0 +1,237 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "third_party/blink/renderer/modules/service_worker/web_service_worker_fetch_context_impl.h" + +#include "mojo/public/cpp/bindings/pending_remote.h" +#include "services/network/public/cpp/wrapper_shared_url_loader_factory.h" +#include "third_party/blink/public/common/loader/loader_constants.h" +#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink.h" +#include "third_party/blink/public/platform/internet_disconnected_web_url_loader.h" +#include "third_party/blink/public/platform/url_loader_throttle_provider.h" +#include "third_party/blink/public/platform/web_url_loader_factory.h" +#include "third_party/blink/public/platform/web_url_request_extra_data.h" +#include "third_party/blink/public/platform/websocket_handshake_throttle_provider.h" + +namespace blink { + +// static +scoped_refptr +WebServiceWorkerFetchContext::Create( + const RendererPreferences& renderer_preferences, + const WebURL& worker_script_url, + std::unique_ptr + pending_url_loader_factory, + std::unique_ptr + pending_script_loader_factory, + const WebURL& script_url_to_skip_throttling, + std::unique_ptr throttle_provider, + std::unique_ptr + websocket_handshake_throttle_provider, + CrossVariantMojoReceiver< + mojom::blink::RendererPreferenceWatcherInterfaceBase> + preference_watcher_receiver, + CrossVariantMojoReceiver< + mojom::blink::SubresourceLoaderUpdaterInterfaceBase> + pending_subresource_loader_updater, + const WebVector& cors_exempt_header_list) { + // Create isolated copies for `worker_script_url` and + // `script_url_to_skip_throttling` as the fetch context will be used on a + // service worker thread that is different from the current thread. + return base::MakeRefCounted( + renderer_preferences, KURL::CreateIsolated(worker_script_url.GetString()), + std::move(pending_url_loader_factory), + std::move(pending_script_loader_factory), + KURL::CreateIsolated(script_url_to_skip_throttling.GetString()), + std::move(throttle_provider), + std::move(websocket_handshake_throttle_provider), + std::move(preference_watcher_receiver), + std::move(pending_subresource_loader_updater), cors_exempt_header_list); +} + +WebServiceWorkerFetchContextImpl::WebServiceWorkerFetchContextImpl( + const RendererPreferences& renderer_preferences, + const KURL& worker_script_url, + std::unique_ptr + pending_url_loader_factory, + std::unique_ptr + pending_script_loader_factory, + const KURL& script_url_to_skip_throttling, + std::unique_ptr throttle_provider, + std::unique_ptr + websocket_handshake_throttle_provider, + mojo::PendingReceiver + preference_watcher_receiver, + mojo::PendingReceiver + pending_subresource_loader_updater, + const WebVector& cors_exempt_header_list) + : renderer_preferences_(renderer_preferences), + worker_script_url_(worker_script_url), + pending_url_loader_factory_(std::move(pending_url_loader_factory)), + pending_script_loader_factory_(std::move(pending_script_loader_factory)), + script_url_to_skip_throttling_(script_url_to_skip_throttling), + throttle_provider_(std::move(throttle_provider)), + websocket_handshake_throttle_provider_( + std::move(websocket_handshake_throttle_provider)), + preference_watcher_pending_receiver_( + std::move(preference_watcher_receiver)), + pending_subresource_loader_updater_( + std::move(pending_subresource_loader_updater)), + cors_exempt_header_list_(cors_exempt_header_list) {} + +WebServiceWorkerFetchContextImpl::~WebServiceWorkerFetchContextImpl() = default; + +void WebServiceWorkerFetchContextImpl::SetTerminateSyncLoadEvent( + base::WaitableEvent* terminate_sync_load_event) { + DCHECK(!terminate_sync_load_event_); + terminate_sync_load_event_ = terminate_sync_load_event; +} + +void WebServiceWorkerFetchContextImpl::InitializeOnWorkerThread( + AcceptLanguagesWatcher* watcher) { + preference_watcher_receiver_.Bind( + std::move(preference_watcher_pending_receiver_)); + subresource_loader_updater_.Bind( + std::move(pending_subresource_loader_updater_)); + + web_url_loader_factory_ = std::make_unique( + network::SharedURLLoaderFactory::Create( + std::move(pending_url_loader_factory_)), + cors_exempt_header_list_, terminate_sync_load_event_); + + internet_disconnected_web_url_loader_factory_ = + std::make_unique(); + + if (pending_script_loader_factory_) { + web_script_loader_factory_ = std::make_unique( + network::SharedURLLoaderFactory::Create( + std::move(pending_script_loader_factory_)), + cors_exempt_header_list_, terminate_sync_load_event_); + } + + accept_languages_watcher_ = watcher; +} + +WebURLLoaderFactory* WebServiceWorkerFetchContextImpl::GetURLLoaderFactory() { + if (is_offline_mode_) + return internet_disconnected_web_url_loader_factory_.get(); + return web_url_loader_factory_.get(); +} + +std::unique_ptr +WebServiceWorkerFetchContextImpl::WrapURLLoaderFactory( + CrossVariantMojoRemote + url_loader_factory) { + return std::make_unique( + base::MakeRefCounted( + std::move(url_loader_factory)), + cors_exempt_header_list_, terminate_sync_load_event_); +} + +WebURLLoaderFactory* +WebServiceWorkerFetchContextImpl::GetScriptLoaderFactory() { + return web_script_loader_factory_.get(); +} + +void WebServiceWorkerFetchContextImpl::WillSendRequest(WebURLRequest& request) { + if (renderer_preferences_.enable_do_not_track) { + request.SetHttpHeaderField(WebString::FromUTF8(kDoNotTrackHeader), "1"); + } + auto url_request_extra_data = base::MakeRefCounted(); + url_request_extra_data->set_originated_from_service_worker(true); + + const bool needs_to_skip_throttling = + static_cast(request.Url()) == script_url_to_skip_throttling_ && + (request.GetRequestContext() == + mojom::blink::RequestContextType::SERVICE_WORKER || + request.GetRequestContext() == mojom::blink::RequestContextType::SCRIPT); + if (needs_to_skip_throttling) { + // Throttling is needed when the skipped script is loaded again because it's + // served from ServiceWorkerInstalledScriptLoader after the second time, + // while at the first time the script comes from + // ServiceWorkerUpdatedScriptLoader which uses ThrottlingURLLoader in the + // browser process. See also comments at + // EmbeddedWorkerStartParams::script_url_to_skip_throttling. + // TODO(https://crbug.com/993641): need to simplify throttling for service + // worker scripts. + script_url_to_skip_throttling_ = KURL(); + } else if (throttle_provider_) { + url_request_extra_data->set_url_loader_throttles( + throttle_provider_->CreateThrottles(MSG_ROUTING_NONE, request)); + } + + request.SetURLRequestExtraData(std::move(url_request_extra_data)); + + if (!renderer_preferences_.enable_referrers) { + request.SetReferrerString(WebString()); + request.SetReferrerPolicy(network::mojom::ReferrerPolicy::kNever); + } +} + +mojom::ControllerServiceWorkerMode +WebServiceWorkerFetchContextImpl::GetControllerServiceWorkerMode() const { + return mojom::ControllerServiceWorkerMode::kNoController; +} + +net::SiteForCookies WebServiceWorkerFetchContextImpl::SiteForCookies() const { + // According to the spec, we can use the |worker_script_url_| for + // SiteForCookies, because "site for cookies" for the service worker is + // the service worker's origin's host's registrable domain. + // https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-07#section-2.1.2 + return net::SiteForCookies::FromUrl(worker_script_url_); +} + +absl::optional +WebServiceWorkerFetchContextImpl::TopFrameOrigin() const { + return absl::nullopt; +} + +std::unique_ptr +WebServiceWorkerFetchContextImpl::CreateWebSocketHandshakeThrottle( + scoped_refptr task_runner) { + if (!websocket_handshake_throttle_provider_) + return nullptr; + return websocket_handshake_throttle_provider_->CreateThrottle( + MSG_ROUTING_NONE, std::move(task_runner)); +} + +mojom::blink::SubresourceLoaderUpdater* +WebServiceWorkerFetchContextImpl::GetSubresourceLoaderUpdater() { + return this; +} + +void WebServiceWorkerFetchContextImpl::UpdateSubresourceLoaderFactories( + std::unique_ptr + subresource_loader_factories) { + web_url_loader_factory_ = std::make_unique( + network::SharedURLLoaderFactory::Create( + std::move(subresource_loader_factories)), + cors_exempt_header_list_, terminate_sync_load_event_); +} + +void WebServiceWorkerFetchContextImpl::NotifyUpdate( + const RendererPreferences& new_prefs) { + DCHECK(accept_languages_watcher_); + if (renderer_preferences_.accept_languages != new_prefs.accept_languages) + accept_languages_watcher_->NotifyUpdate(); + renderer_preferences_ = new_prefs; +} + +WebString WebServiceWorkerFetchContextImpl::GetAcceptLanguages() const { + return WebString::FromUTF8(renderer_preferences_.accept_languages); +} + +CrossVariantMojoReceiver +WebServiceWorkerFetchContextImpl::TakePendingWorkerTimingReceiver( + int request_id) { + // No receiver exists because requests from service workers are never handled + // by a service worker. + return {}; +} + +void WebServiceWorkerFetchContextImpl::SetIsOfflineMode(bool is_offline_mode) { + is_offline_mode_ = is_offline_mode; +} + +} // namespace blink diff --git a/content/renderer/service_worker/service_worker_fetch_context_impl.h b/third_party/blink/renderer/modules/service_worker/web_service_worker_fetch_context_impl.h similarity index 51% rename from content/renderer/service_worker/service_worker_fetch_context_impl.h rename to third_party/blink/renderer/modules/service_worker/web_service_worker_fetch_context_impl.h index 91047ad5aa879d..d069db73b012e1 100644 --- a/content/renderer/service_worker/service_worker_fetch_context_impl.h +++ b/third_party/blink/renderer/modules/service_worker/web_service_worker_fetch_context_impl.h @@ -2,34 +2,29 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_FETCH_CONTEXT_IMPL_H_ -#define CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_FETCH_CONTEXT_IMPL_H_ +#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_SERVICE_WORKER_WEB_SERVICE_WORKER_FETCH_CONTEXT_IMPL_H_ +#define THIRD_PARTY_BLINK_RENDERER_MODULES_SERVICE_WORKER_WEB_SERVICE_WORKER_FETCH_CONTEXT_IMPL_H_ -#include "content/common/content_export.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/receiver.h" -#include "services/network/public/cpp/shared_url_loader_factory.h" #include "third_party/blink/public/common/renderer_preferences/renderer_preferences.h" -#include "third_party/blink/public/mojom/renderer_preference_watcher.mojom.h" +#include "third_party/blink/public/mojom/renderer_preference_watcher.mojom-blink.h" #include "third_party/blink/public/mojom/service_worker/service_worker.mojom-forward.h" -#include "third_party/blink/public/mojom/worker/subresource_loader_updater.mojom.h" +#include "third_party/blink/public/mojom/worker/subresource_loader_updater.mojom-blink.h" + #include "third_party/blink/public/platform/modules/service_worker/web_service_worker_fetch_context.h" #include "third_party/blink/public/platform/web_string.h" #include "third_party/blink/public/platform/web_vector.h" -#include "url/gurl.h" +#include "third_party/blink/renderer/platform/weborigin/kurl.h" namespace blink { -class InternetDisconnectedWebURLLoaderFactory; -class URLLoaderThrottleProvider; -class WebSocketHandshakeThrottleProvider; -} -namespace content { +class InternetDisconnectedWebURLLoaderFactory; -class CONTENT_EXPORT ServiceWorkerFetchContextImpl final - : public blink::WebServiceWorkerFetchContext, - public blink::mojom::RendererPreferenceWatcher, - public blink::mojom::SubresourceLoaderUpdater { +class BLINK_EXPORT WebServiceWorkerFetchContextImpl final + : public WebServiceWorkerFetchContext, + public mojom::blink::RendererPreferenceWatcher, + public mojom::blink::SubresourceLoaderUpdater { public: // |pending_url_loader_factory| is used for regular loads from the service // worker (i.e., Fetch API). It typically goes to network, but it might @@ -41,63 +36,58 @@ class CONTENT_EXPORT ServiceWorkerFetchContextImpl final // |script_url_to_skip_throttling| is a URL which is already throttled in the // browser process so that it doesn't need to be throttled in the renderer // again. - ServiceWorkerFetchContextImpl( - const blink::RendererPreferences& renderer_preferences, - const GURL& worker_script_url, + WebServiceWorkerFetchContextImpl( + const RendererPreferences& renderer_preferences, + const KURL& worker_script_url, std::unique_ptr pending_url_loader_factory, std::unique_ptr pending_script_loader_factory, - const GURL& script_url_to_skip_throttling, - std::unique_ptr throttle_provider, - std::unique_ptr + const KURL& script_url_to_skip_throttling, + std::unique_ptr throttle_provider, + std::unique_ptr websocket_handshake_throttle_provider, - mojo::PendingReceiver + mojo::PendingReceiver preference_watcher_receiver, - mojo::PendingReceiver + mojo::PendingReceiver pending_subresource_loader_updater, - const std::vector& cors_exempt_header_list); + const WebVector& cors_exempt_header_list); - // blink::WebServiceWorkerFetchContext implementation: + // WebServiceWorkerFetchContext implementation: void SetTerminateSyncLoadEvent(base::WaitableEvent*) override; - void InitializeOnWorkerThread(blink::AcceptLanguagesWatcher*) override; - blink::WebURLLoaderFactory* GetURLLoaderFactory() override; - std::unique_ptr WrapURLLoaderFactory( - blink::CrossVariantMojoRemote< - network::mojom::URLLoaderFactoryInterfaceBase> url_loader_factory) - override; - blink::WebURLLoaderFactory* GetScriptLoaderFactory() override; - void WillSendRequest(blink::WebURLRequest&) override; - blink::mojom::ControllerServiceWorkerMode GetControllerServiceWorkerMode() + void InitializeOnWorkerThread(AcceptLanguagesWatcher*) override; + WebURLLoaderFactory* GetURLLoaderFactory() override; + std::unique_ptr WrapURLLoaderFactory( + CrossVariantMojoRemote + url_loader_factory) override; + WebURLLoaderFactory* GetScriptLoaderFactory() override; + void WillSendRequest(WebURLRequest&) override; + mojom::ControllerServiceWorkerMode GetControllerServiceWorkerMode() const override; net::SiteForCookies SiteForCookies() const override; - absl::optional TopFrameOrigin() const override; - std::unique_ptr - CreateWebSocketHandshakeThrottle( + absl::optional TopFrameOrigin() const override; + std::unique_ptr CreateWebSocketHandshakeThrottle( scoped_refptr task_runner) override; - blink::WebString GetAcceptLanguages() const override; - blink::CrossVariantMojoReceiver< - blink::mojom::WorkerTimingContainerInterfaceBase> + WebString GetAcceptLanguages() const override; + CrossVariantMojoReceiver TakePendingWorkerTimingReceiver(int request_id) override; void SetIsOfflineMode(bool) override; - blink::mojom::SubresourceLoaderUpdater* GetSubresourceLoaderUpdater() - override; - // blink::mojom::SubresourceLoaderUpdater implementation: + mojom::blink::SubresourceLoaderUpdater* GetSubresourceLoaderUpdater(); + + // mojom::blink::SubresourceLoaderUpdater implementation: void UpdateSubresourceLoaderFactories( - std::unique_ptr + std::unique_ptr subresource_loader_factories) override; private: - ~ServiceWorkerFetchContextImpl() override; - - // Implements blink::mojom::RendererPreferenceWatcher. - void NotifyUpdate(const blink::RendererPreferences& new_prefs) override; + ~WebServiceWorkerFetchContextImpl() override; - blink::WebVector cors_exempt_header_list(); + // Implements mojom::blink::RendererPreferenceWatcher. + void NotifyUpdate(const RendererPreferences& new_prefs) override; - blink::RendererPreferences renderer_preferences_; - const GURL worker_script_url_; + RendererPreferences renderer_preferences_; + const KURL worker_script_url_; // Consumed on the worker thread to create |web_url_loader_factory_|. std::unique_ptr pending_url_loader_factory_; @@ -107,44 +97,44 @@ class CONTENT_EXPORT ServiceWorkerFetchContextImpl final // A script URL that should skip throttling when loaded because it's already // being loaded in the browser process and went through throttles there. It's - // valid only once and set to invalid GURL once the script is served. - GURL script_url_to_skip_throttling_; + // valid only once and set to invalid KURL once the script is served. + KURL script_url_to_skip_throttling_; // Responsible for regular loads from the service worker (i.e., Fetch API). - std::unique_ptr web_url_loader_factory_; + std::unique_ptr web_url_loader_factory_; // Responsible for loads which always fail as INTERNET_DISCONNECTED // error, which is used in offline mode. - std::unique_ptr + std::unique_ptr internet_disconnected_web_url_loader_factory_; // Responsible for script loads from the service worker (i.e., the // classic/module main script, module imported scripts, or importScripts()). - std::unique_ptr web_script_loader_factory_; + std::unique_ptr web_script_loader_factory_; - std::unique_ptr throttle_provider_; - std::unique_ptr + std::unique_ptr throttle_provider_; + std::unique_ptr websocket_handshake_throttle_provider_; - mojo::Receiver + mojo::Receiver preference_watcher_receiver_{this}; - mojo::Receiver + mojo::Receiver subresource_loader_updater_{this}; // These mojo objects are kept while starting up the worker thread. Valid // until InitializeOnWorkerThread(). - mojo::PendingReceiver + mojo::PendingReceiver preference_watcher_pending_receiver_; - mojo::PendingReceiver + mojo::PendingReceiver pending_subresource_loader_updater_; // This is owned by ThreadedMessagingProxyBase on the main thread. base::WaitableEvent* terminate_sync_load_event_ = nullptr; - blink::AcceptLanguagesWatcher* accept_languages_watcher_ = nullptr; + AcceptLanguagesWatcher* accept_languages_watcher_ = nullptr; - std::vector cors_exempt_header_list_; + WebVector cors_exempt_header_list_; bool is_offline_mode_ = false; }; -} // namespace content +} // namespace blink -#endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_FETCH_CONTEXT_IMPL_H_ +#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_SERVICE_WORKER_WEB_SERVICE_WORKER_FETCH_CONTEXT_IMPL_H_ diff --git a/content/renderer/service_worker/service_worker_fetch_context_impl_unittest.cc b/third_party/blink/renderer/modules/service_worker/web_service_worker_fetch_context_impl_test.cc similarity index 54% rename from content/renderer/service_worker/service_worker_fetch_context_impl_unittest.cc rename to third_party/blink/renderer/modules/service_worker/web_service_worker_fetch_context_impl_test.cc index ada1226994086b..395cd046198c90 100644 --- a/content/renderer/service_worker/service_worker_fetch_context_impl_unittest.cc +++ b/third_party/blink/renderer/modules/service_worker/web_service_worker_fetch_context_impl_test.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/renderer/service_worker/service_worker_fetch_context_impl.h" +#include "third_party/blink/renderer/modules/service_worker/web_service_worker_fetch_context_impl.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/blink/public/common/renderer_preferences/renderer_preferences.h" @@ -10,28 +10,27 @@ #include "third_party/blink/public/platform/web_url_request_extra_data.h" #include "third_party/blink/public/platform/websocket_handshake_throttle_provider.h" -namespace content { +namespace blink { -class ServiceWorkerFetchContextImplTest : public testing::Test { +class WebServiceWorkerFetchContextImplTest : public testing::Test { public: - ServiceWorkerFetchContextImplTest() = default; + WebServiceWorkerFetchContextImplTest() = default; - class FakeURLLoaderThrottle : public blink::URLLoaderThrottle { + class FakeURLLoaderThrottle : public URLLoaderThrottle { public: FakeURLLoaderThrottle() = default; }; - class FakeURLLoaderThrottleProvider - : public blink::URLLoaderThrottleProvider { - std::unique_ptr Clone() override { + class FakeURLLoaderThrottleProvider : public URLLoaderThrottleProvider { + std::unique_ptr Clone() override { NOTREACHED(); return nullptr; } - blink::WebVector> CreateThrottles( + WebVector> CreateThrottles( int render_frame_id, - const blink::WebURLRequest& request) override { - blink::WebVector> throttles; + const WebURLRequest& request) override { + WebVector> throttles; throttles.emplace_back(std::make_unique()); return throttles; } @@ -40,48 +39,48 @@ class ServiceWorkerFetchContextImplTest : public testing::Test { }; }; -TEST_F(ServiceWorkerFetchContextImplTest, SkipThrottling) { - const GURL kScriptUrl("https://example.com/main.js"); - const GURL kScriptUrlToSkipThrottling("https://example.com/skip.js"); - auto context = base::MakeRefCounted( - blink::RendererPreferences(), kScriptUrl, +TEST_F(WebServiceWorkerFetchContextImplTest, SkipThrottling) { + const KURL kScriptUrl("https://example.com/main.js"); + const KURL kScriptUrlToSkipThrottling("https://example.com/skip.js"); + auto context = WebServiceWorkerFetchContext::Create( + RendererPreferences(), kScriptUrl, /*pending_url_loader_factory=*/nullptr, /*pending_script_loader_factory=*/nullptr, kScriptUrlToSkipThrottling, std::make_unique(), /*websocket_handshake_throttle_provider=*/nullptr, mojo::NullReceiver(), mojo::NullReceiver(), - /*cors_exempt_header_list=*/std::vector()); + /*cors_exempt_header_list=*/WebVector()); { // Call WillSendRequest() for kScriptURL. - blink::WebURLRequest request; + WebURLRequest request; request.SetUrl(kScriptUrl); - request.SetRequestContext(blink::mojom::RequestContextType::SERVICE_WORKER); + request.SetRequestContext(mojom::RequestContextType::SERVICE_WORKER); context->WillSendRequest(request); // Throttles should be created by the provider. - auto* url_request_extra_data = static_cast( + auto* url_request_extra_data = static_cast( request.GetURLRequestExtraData().get()); ASSERT_TRUE(url_request_extra_data); - blink::WebVector> throttles = + WebVector> throttles = url_request_extra_data->TakeURLLoaderThrottles(); EXPECT_EQ(1u, throttles.size()); } { // Call WillSendRequest() for kScriptURLToSkipThrottling. - blink::WebURLRequest request; + WebURLRequest request; request.SetUrl(kScriptUrlToSkipThrottling); - request.SetRequestContext(blink::mojom::RequestContextType::SERVICE_WORKER); + request.SetRequestContext(mojom::RequestContextType::SERVICE_WORKER); context->WillSendRequest(request); // Throttles should not be created by the provider. - auto* url_request_extra_data = static_cast( + auto* url_request_extra_data = static_cast( request.GetURLRequestExtraData().get()); ASSERT_TRUE(url_request_extra_data); - blink::WebVector> throttles = + WebVector> throttles = url_request_extra_data->TakeURLLoaderThrottles(); EXPECT_TRUE(throttles.empty()); } } -} // namespace content +} // namespace blink diff --git a/third_party/blink/renderer/platform/peerconnection/rtc_video_encoder.cc b/third_party/blink/renderer/platform/peerconnection/rtc_video_encoder.cc index 14d2a2f5dc6093..02f5ba029ed96f 100644 --- a/third_party/blink/renderer/platform/peerconnection/rtc_video_encoder.cc +++ b/third_party/blink/renderer/platform/peerconnection/rtc_video_encoder.cc @@ -1020,6 +1020,10 @@ void RTCVideoEncoder::Impl::BitstreamBufferReady( (metadata.key_frame ? webrtc::VideoFrameType::kVideoFrameKey : webrtc::VideoFrameType::kVideoFrameDelta); image.content_type_ = video_content_type_; + // Default invalid qp value is -1 in webrtc::EncodedImage and + // media::BitstreamBufferMetadata, and libwebrtc would parse bitstream to get + // the qp if |qp_| is less than zero. + image.qp_ = metadata.qp; webrtc::CodecSpecificInfo info; info.codecType = video_codec_type_; diff --git a/third_party/blink/tools/blinkpy/web_tests/port/fuchsia.py b/third_party/blink/tools/blinkpy/web_tests/port/fuchsia.py index a6a5b592b6322d..fff487f8a80e5b 100644 --- a/third_party/blink/tools/blinkpy/web_tests/port/fuchsia.py +++ b/third_party/blink/tools/blinkpy/web_tests/port/fuchsia.py @@ -66,8 +66,8 @@ def _import_fuchsia_runner(): import aemu_target global ConnectPortForwardingTask from common import ConnectPortForwardingTask - global _GetPathToBuiltinTarget, _LoadTargetClass - from common_args import _GetPathToBuiltinTarget, _LoadTargetClass + global _GetPathToBuiltinTarget, _LoadTargetClass, InitializeTargetArgs + from common_args import _GetPathToBuiltinTarget, _LoadTargetClass, InitializeTargetArgs global device_target import device_target global fuchsia_target @@ -245,24 +245,16 @@ def _cpu_cores(self): def setup_test_run(self): super(FuchsiaPort, self).setup_test_run() try: - target_args = Namespace( - out_dir=self._build_path(), - fuchsia_out_dir=self.get_option('fuchsia_out_dir'), - target_cpu=self._target_cpu(), - ssh_config=self.get_option('fuchsia_ssh_config'), - os_check='ignore', - host=self.get_option('fuchsia_host'), - port=self.get_option('fuchsia_port'), - node_name=self.get_option('fuchsia_node_name'), - cpu_cores=self._cpu_cores(), - require_kvm=True, - ram_size_mb=8192, - enable_graphics=False, - hardware_gpu=False, - with_network=False, - logs_dir=self.results_directory(), - custom_image=None, - system_image_dir=None) + target_args = InitializeTargetArgs() + target_args.out_dir = self._build_path() + target_args.target_cpu = self._target_cpu() + target_args.fuchsia_out_dir = self.get_option('fuchsia_out_dir') + target_args.ssh_config = self.get_option('fuchsia_ssh_config') + target_args.host = self.get_option('fuchsia_host') + target_args.port = self.get_option('fuchsia_port') + target_args.node_name = self.get_option('fuchsia_node_name') + target_args.cpu_cores = self._cpu_cores() + target_args.logs_dir = self.results_directory() target = _LoadTargetClass( _GetPathToBuiltinTarget( self._target_device)).CreateFromArgs(target_args) diff --git a/third_party/blink/web_tests/TestExpectations b/third_party/blink/web_tests/TestExpectations index 9467787c596828..47c8f0859dfdcf 100644 --- a/third_party/blink/web_tests/TestExpectations +++ b/third_party/blink/web_tests/TestExpectations @@ -104,9 +104,6 @@ external/wpt/css/compositing/root-element-background-transparency.html [ Failure # These tests either fail outright, or become flaky, when these two flags/parameters are enabled: # --enable-features=ForceSynchronousHTMLParsing,LoaderDataPipeTuning:allocation_size_bytes/2097152/loader_chunk_size/1048576 -# app-history tests - fail: -crbug.com/1254926 external/wpt/app-history/navigate/navigate-same-document-event-order.html [ Failure ] - # Extra line info appears in the output in some cases. crbug.com/1254932 http/tests/preload/meta-csp.html [ Failure ] @@ -2815,6 +2812,12 @@ crbug.com/626703 [ Mac ] external/wpt/css/css-text/line-breaking/segment-break-t crbug.com/626703 [ Fuchsia ] external/wpt/dom/historical.html [ Skip ] # ====== New tests from wpt-importer added here ====== +crbug.com/626703 [ Mac11-arm64 ] external/wpt/css/CSS2/normal-flow/width-081.xht [ Failure Crash ] +crbug.com/626703 [ Mac11-arm64 ] external/wpt/css/css-contain/contain-layout-ignored-cases-no-principal-box-002.html [ Failure Crash ] +crbug.com/626703 [ Mac11-arm64 ] external/wpt/css/css-writing-modes/margin-collapse-vrl-014.xht [ Failure Crash ] +crbug.com/626703 [ Mac11-arm64 ] virtual/not-site-per-process/external/wpt/html/browsers/origin/origin-keyed-agent-clusters/1-iframe/parent-no-child-yes-port.sub.https.html [ Failure Crash ] +crbug.com/626703 [ Mac11 ] virtual/threaded/external/wpt/scroll-animations/css/at-scroll-timeline-paused-animations.html [ Failure Crash ] +crbug.com/626703 [ Mac11-arm64 ] virtual/threaded/external/wpt/scroll-animations/css/at-scroll-timeline-responsiveness-from-endpoint.html [ Failure Crash ] crbug.com/626703 external/wpt/css/css-color/display-p3-001.html [ Failure ] crbug.com/626703 external/wpt/css/css-color/display-p3-002.html [ Failure ] crbug.com/626703 external/wpt/css/css-color/display-p3-003.html [ Failure ] @@ -2833,7 +2836,6 @@ crbug.com/626703 [ Win ] virtual/system-color-compute/external/wpt/css/css-color crbug.com/626703 virtual/system-color-compute/external/wpt/css/css-color/display-p3-004.html [ Failure ] crbug.com/626703 virtual/system-color-compute/external/wpt/css/css-color/display-p3-005.html [ Failure ] crbug.com/626703 virtual/system-color-compute/external/wpt/css/css-color/display-p3-006.html [ Failure ] -crbug.com/626703 [ Mac11-arm64 ] external/wpt/css/css-sizing/table-child-percentage-height-with-border-box.html [ Failure ] crbug.com/626703 [ Mac11-arm64 ] external/wpt/fetch/api/basic/status.h2.any.worker.html [ Timeout ] crbug.com/626703 [ Mac11-arm64 ] external/wpt/infrastructure/server/http2-websocket.sub.h2.any.worker.html [ Timeout ] crbug.com/626703 [ Mac11-arm64 ] external/wpt/websockets/Close-1000-reason.any.worker.html?wpt_flags=h2 [ Timeout ] @@ -2851,13 +2853,6 @@ crbug.com/626703 [ Mac11-arm64 ] external/wpt/websockets/unload-a-document/005.h crbug.com/626703 [ Mac11-arm64 ] external/wpt/css/css-color/color-contrast-001.html [ Failure ] crbug.com/626703 [ Mac11-arm64 ] external/wpt/css/css-color/xyz-d50-004.html [ Failure ] crbug.com/626703 [ Mac11-arm64 ] external/wpt/css/css-color/xyz-d65-004.html [ Failure ] -crbug.com/626703 [ Linux ] external/wpt/css/css-sizing/table-child-percentage-height-with-border-box.html [ Failure ] -crbug.com/626703 [ Mac10.12 ] external/wpt/css/css-sizing/table-child-percentage-height-with-border-box.html [ Failure ] -crbug.com/626703 [ Mac10.13 ] external/wpt/css/css-sizing/table-child-percentage-height-with-border-box.html [ Failure ] -crbug.com/626703 [ Mac10.14 ] external/wpt/css/css-sizing/table-child-percentage-height-with-border-box.html [ Failure ] -crbug.com/626703 [ Mac10.15 ] external/wpt/css/css-sizing/table-child-percentage-height-with-border-box.html [ Failure ] -crbug.com/626703 [ Mac11 ] external/wpt/css/css-sizing/table-child-percentage-height-with-border-box.html [ Failure ] -crbug.com/626703 [ Win ] external/wpt/css/css-sizing/table-child-percentage-height-with-border-box.html [ Failure ] crbug.com/626703 [ Mac11-arm64 ] external/wpt/css/css-text-decor/text-emphasis-color-property-001a.html [ Failure ] crbug.com/626703 [ Mac11-arm64 ] external/wpt/css/css-text-decor/text-emphasis-color-property-002.html [ Failure ] crbug.com/626703 [ Mac11-arm64 ] external/wpt/css/css-text-decor/text-emphasis-line-height-001b.html [ Failure ] @@ -3862,7 +3857,7 @@ crbug.com/626703 [ Mac10.15 ] virtual/web-bluetooth-new-permissions-backend/exte crbug.com/626703 [ Mac10.15 ] virtual/web-bluetooth-new-permissions-backend/external/wpt/bluetooth/characteristic/writeValue/write-succeeds.https.window.html [ Timeout ] crbug.com/626703 [ Mac10.15 ] virtual/web-bluetooth-new-permissions-backend/external/wpt/bluetooth/requestDevice/canonicalizeFilter/empty-services-member.https.window.html [ Timeout ] crbug.com/626703 [ Mac11 ] virtual/web-bluetooth-new-permissions-backend/external/wpt/bluetooth/requestDevice/canonicalizeFilter/max-length-name-unicode.https.window.html [ Crash ] -crbug.com/626703 [ Mac10.15 ] virtual/web-bluetooth-new-permissions-backend/external/wpt/bluetooth/service/getCharacteristics/characteristics-found-with-uuid.https.html [ Timeout ] +crbug.com/626703 [ Mac10.15 ] virtual/web-bluetooth-new-permissions-backend/external/wpt/bluetooth/service/getCharacteristics/characteristics-found-with-uuid.https.window.html [ Timeout ] crbug.com/626703 [ Mac10.15 ] virtual/web-bluetooth-new-permissions-backend/external/wpt/bluetooth/service/getCharacteristics/gen-reconnect-during-with-uuid.https.window.html [ Timeout ] crbug.com/626703 [ Mac10.15 ] virtual/web-bluetooth-new-permissions-backend/wpt_internal/bluetooth/characteristic/getDescriptors/gen-descriptor-disconnect-called-during-error-with-uuid.https.html [ Timeout ] crbug.com/626703 [ Mac10.15 ] virtual/web-bluetooth-new-permissions-backend/wpt_internal/bluetooth/characteristic/getDescriptors/gen-descriptor-garbage-collection-ran-during-success.https.html [ Timeout ] diff --git a/third_party/blink/web_tests/accessibility/accessibility-beforematch-marker-crash.html b/third_party/blink/web_tests/accessibility/accessibility-beforematch-marker-crash.html index d02342993a9c7b..11498ecc63c695 100644 --- a/third_party/blink/web_tests/accessibility/accessibility-beforematch-marker-crash.html +++ b/third_party/blink/web_tests/accessibility/accessibility-beforematch-marker-crash.html @@ -1,20 +1,16 @@ - -
  • +
  • -
    hello
    +
    - - - - -
    match one
    -
    spacer one
    -
    match two
    -
    spacer two
    -
    match three
    - - diff --git a/third_party/blink/web_tests/editing/text-iterator/beforematch-remove-match.html b/third_party/blink/web_tests/editing/text-iterator/beforematch-remove-match.html index 0f523caaebd975..f372ca956092d8 100644 --- a/third_party/blink/web_tests/editing/text-iterator/beforematch-remove-match.html +++ b/third_party/blink/web_tests/editing/text-iterator/beforematch-remove-match.html @@ -15,6 +15,7 @@ async_test(t => { const match = document.createElement('div'); match.textContent = 'match'; + match.setAttribute('hidden', 'until-found'); document.body.appendChild(match); match.addEventListener('beforematch', () => { diff --git a/third_party/blink/web_tests/editing/text-iterator/beforematch-second-match.html b/third_party/blink/web_tests/editing/text-iterator/beforematch-second-match.html index 2a946c705a96b9..205aa51233523e 100644 --- a/third_party/blink/web_tests/editing/text-iterator/beforematch-second-match.html +++ b/third_party/blink/web_tests/editing/text-iterator/beforematch-second-match.html @@ -8,7 +8,7 @@ }
    -
    match
    +
    match
    @@ -22,20 +22,15 @@ testRunner.findString('match', ['Async']); requestAnimationFrame(t.step_func(() => { - requestAnimationFrame(t.step_func(() => { - // Schedule another double rAF for the second async step - requestAnimationFrame(t.step_func(() => { - requestAnimationFrame(t.step_func_done(() => { - // verify that matchTwo is scrolled into view - const offsetBeforeScroll = window.pageYOffset; - matchTwo.scrollIntoView(); - const offsetAfterScroll = window.pageYOffset; + requestAnimationFrame(t.step_func_done(() => { + // verify that matchTwo is scrolled into view + const offsetBeforeScroll = window.pageYOffset; + matchTwo.scrollIntoView(); + const offsetAfterScroll = window.pageYOffset; - assert_not_equals(window.pageYOffset, 0, 'find-in-page should scroll after two rAFs.'); - assert_equals(offsetAfterScroll, offsetBeforeScroll, - `scrollIntoView shouldn't affect the scroll offset because the element should already be scrolled into view.`); - })); - })); + assert_not_equals(window.pageYOffset, 0, 'find-in-page should scroll after two rAFs.'); + assert_equals(offsetAfterScroll, offsetBeforeScroll, + `scrollIntoView shouldn't affect the scroll offset because the element should already be scrolled into view.`); })); })); }, `Removing the target element in the beforematch handler should make find-in-page scroll to the next match in the page.`); diff --git a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json index 267cb7c132a89b..145303544da049 100644 --- a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json +++ b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json @@ -14353,6 +14353,49 @@ ] } }, + "scroll-animations": { + "css": { + "at-scroll-timeline-default-descriptors-iframe-print.html": [ + "0b73d7f03474d617767ec636a2712a56eed6c79c", + [ + null, + [ + [ + "/scroll-animations/css/at-scroll-timeline-default-descriptors-iframe-ref.html", + "==" + ] + ], + {} + ] + ], + "at-scroll-timeline-default-descriptors-print.tentative.html": [ + "418ed3c5495b77d58bcc87c7519264491c29462a", + [ + null, + [ + [ + "/scroll-animations/css/at-scroll-timeline-default-descriptors-ref.html", + "==" + ] + ], + {} + ] + ], + "at-scroll-timeline-specified-scroller-print.html": [ + "5543088324d60ab425b1f5ad1775f6406c85a768", + [ + null, + [ + [ + "/scroll-animations/css/at-scroll-timeline-specified-scroller-print-ref.html", + "==" + ] + ], + {} + ] + ] + } + }, "selection": { "selection-shadow-dom-crash-print.html": [ "cf62609173953e30ccce13fd52459c0e48147c63", @@ -226306,6 +226349,10 @@ "0dd796f609c0659bd489e10cb02ac4816a88960b", [] ], + "page-with-base-url-common.html": [ + "8d9fedcc2b40d2eaeff55727ffa476a6e7c0e479", + [] + ], "service-worker-page.html": [ "a10ff35dce7768c6e7b6f68647207a8fa35c2a6d", [] @@ -307194,7 +307241,7 @@ [] ], "webxr-test.js": [ - "d3806c2542ffa1ffe269bae2c7ab479d69562b8d", + "8a541cae1b06f6bbda0b462ca618e565c76fba41", [] ], "webxr-test.js.headers": [ @@ -307505,6 +307552,18 @@ "e87901e30a2c43b3d7e77c78805b1a6db87a920d", [] ], + "at-scroll-timeline-paused-animations-expected.txt": [ + "7847b21efc76ba26eff173aa959831c433cca465", + [] + ], + "at-scroll-timeline-responsiveness-from-endpoint-expected.txt": [ + "898f1cf7348d6ca5380a5e6674f7747203757944", + [] + ], + "at-scroll-timeline-specified-scroller-print-ref.html": [ + "fa945ce72f0888ba98ddd2db5f3af8d559003845", + [] + ], "scroll-timeline-cssom.tentative-expected.txt": [ "116f38ce142edb0efb004461c1a8a9a314c36283", [] @@ -335186,6 +335245,13 @@ {} ] ], + "navigate-base-url.html": [ + "b11a71a9312785fc0b151a1c3e294a18f4cfabf4", + [ + null, + {} + ] + ], "navigate-cross-document-event-order.html": [ "1c1758a002eb8ac5e8ba8945dc6163d32a1a70f4", [ @@ -335236,7 +335302,7 @@ ] ], "navigate-same-document-event-order.html": [ - "1ec2ffdd25f0120fa751a12274ef43285d59eef6", + "4be537fb7ae1c2223fa536b476da614f54d8e3e4", [ null, {} @@ -335271,7 +335337,14 @@ ] ], "navigate-transitionWhile-reject-event-order.html": [ - "ca7301620bcc1ec7f4f8a8ff90e897f15f7e9014", + "96e742766cccc8430c03f1446f15a2a3a98cf923", + [ + null, + {} + ] + ], + "reload-base-url.html": [ + "35b29b9d2fb032f97f7bd8ba607f928aec60571e", [ null, {} @@ -451219,7 +451292,7 @@ }, "the-selectmenu-element": { "selectmenu-events.tentative.html": [ - "99a1bee721166e20be14182a4d6f47dde1e5a7bc", + "827ebc3b7caf5138846f6df84eaa8e4af3e88215", [ null, { @@ -493016,6 +493089,20 @@ {} ] ], + "at-scroll-timeline-paused-animations.html": [ + "7bf1289ebef1e963a159b89675030d1b71c37065", + [ + null, + {} + ] + ], + "at-scroll-timeline-responsiveness-from-endpoint.html": [ + "3eafe2f973ea6691773e131096717fa64001678a", + [ + null, + {} + ] + ], "at-scroll-timeline-sampling.html": [ "3b0701acd886690621d566fb708ef963db088c98", [ diff --git a/third_party/blink/web_tests/external/wpt/accelerometer/Accelerometer.https.html b/third_party/blink/web_tests/external/wpt/accelerometer/Accelerometer.https.html index e8af0393fc5691..0db87d2efc3dd1 100644 --- a/third_party/blink/web_tests/external/wpt/accelerometer/Accelerometer.https.html +++ b/third_party/blink/web_tests/external/wpt/accelerometer/Accelerometer.https.html @@ -30,16 +30,4 @@ verifyXyzSensorReading, ['accelerometer']); -runGenericSensorTests( - 'GravitySensor', - kReadings, - verifyXyzSensorReading, - ['accelerometer']); - -runGenericSensorTests( - 'LinearAccelerationSensor', - kReadings, - verifyXyzSensorReading, - ['accelerometer']); - diff --git a/third_party/blink/web_tests/external/wpt/accelerometer/GravitySensor.https.html b/third_party/blink/web_tests/external/wpt/accelerometer/GravitySensor.https.html new file mode 100644 index 00000000000000..6fb21e5572813e --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/accelerometer/GravitySensor.https.html @@ -0,0 +1,33 @@ + + +Gravity Sensor Test + + + + + + + + diff --git a/third_party/blink/web_tests/external/wpt/accelerometer/LinearAccelerationSensor.https.html b/third_party/blink/web_tests/external/wpt/accelerometer/LinearAccelerationSensor.https.html new file mode 100644 index 00000000000000..8dd3446f409169 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/accelerometer/LinearAccelerationSensor.https.html @@ -0,0 +1,33 @@ + + +Linear Acceleration Sensor Test + + + + + + + + diff --git a/third_party/blink/web_tests/external/wpt/app-history/navigate/navigate-same-document-event-order.html b/third_party/blink/web_tests/external/wpt/app-history/navigate/navigate-same-document-event-order.html index 1ec2ffdd25f012..4be537fb7ae1c2 100644 --- a/third_party/blink/web_tests/external/wpt/app-history/navigate/navigate-same-document-event-order.html +++ b/third_party/blink/web_tests/external/wpt/app-history/navigate/navigate-same-document-event-order.html @@ -5,7 +5,14 @@ async_test(t => { let events = []; function finish() { - assert_array_equals(events, ["onnavigate", "onnavigatesuccess", "promisefulfilled", "onpopstate", "onhashchange"]); + // Until https://github.com/whatwg/html/issues/1792 (see also https://crbug.com/1254926) is + // resolved, ignore the ordering of hashchange and popstate (while still testing that they are + // the last two, in some order, and come in at most one task after "promisefulfilled"). + // TODO(domenic): fix the spec, write non-app history tests, then reenable these checks. + assert_array_equals( + events.slice(0, -2), + ["onnavigate", "onnavigatesuccess", "promisefulfilled"/*, "onpopstate", "onhashchange"*/] + ); t.done(); } diff --git a/third_party/blink/web_tests/external/wpt/app-history/navigate/navigate-transitionWhile-reject-event-order.html b/third_party/blink/web_tests/external/wpt/app-history/navigate/navigate-transitionWhile-reject-event-order.html index ca7301620bcc1e..96e742766cccc8 100644 --- a/third_party/blink/web_tests/external/wpt/app-history/navigate/navigate-transitionWhile-reject-event-order.html +++ b/third_party/blink/web_tests/external/wpt/app-history/navigate/navigate-transitionWhile-reject-event-order.html @@ -5,7 +5,14 @@ async_test(t => { let events = []; function finish() { - assert_array_equals(events, ["onnavigate", "committed promisefulfilled", "onnavigateerror", "finished promiserejected", "onhashchange", "onpopstate"]); + // Until https://github.com/whatwg/html/issues/1792 (see also https://crbug.com/1254926) is + // resolved, ignore the ordering of hashchange and popstate (while still testing that they are + // the last two, in some order, and come in at most one task after "finished promiserejected"). + // TODO(domenic): fix the spec, write non-app history tests, then reenable these checks. + assert_array_equals( + events.slice(0, -2), + ["onnavigate", "committed promisefulfilled", "onnavigateerror", "finished promiserejected"/*, "onhashchange", "onpopstate"*/] + ); t.done(); } diff --git a/third_party/blink/web_tests/external/wpt/bluetooth/service/device-same-from-2-services.https.html b/third_party/blink/web_tests/external/wpt/bluetooth/service/device-same-from-2-services.https.html deleted file mode 100644 index 4c479dda90b3d5..00000000000000 --- a/third_party/blink/web_tests/external/wpt/bluetooth/service/device-same-from-2-services.https.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - diff --git a/third_party/blink/web_tests/external/wpt/bluetooth/service/device-same-from-2-services.https.window.js b/third_party/blink/web_tests/external/wpt/bluetooth/service/device-same-from-2-services.https.window.js new file mode 100644 index 00000000000000..4870105d5cf221 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/bluetooth/service/device-same-from-2-services.https.window.js @@ -0,0 +1,16 @@ +// META: script=/resources/testharness.js +// META: script=/resources/testharnessreport.js +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js +// META: script=/bluetooth/resources/bluetooth-test.js +// META: script=/bluetooth/resources/bluetooth-fake-devices.js +'use strict'; +const test_desc = 'Same parent device returned from multiple services.'; + +bluetooth_test(async () => { + let {device} = await getTwoHealthThermometerServicesDevice( + {filters: [{services: ['health_thermometer']}]}); + let [service1, service2] = + await device.gatt.getPrimaryServices('health_thermometer'); + assert_equals(service1.device, service2.device); +}, test_desc); diff --git a/third_party/blink/web_tests/external/wpt/bluetooth/service/device-same-object.https.html b/third_party/blink/web_tests/external/wpt/bluetooth/service/device-same-object.https.html deleted file mode 100644 index d9590b17dc23fe..00000000000000 --- a/third_party/blink/web_tests/external/wpt/bluetooth/service/device-same-object.https.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - diff --git a/third_party/blink/web_tests/external/wpt/bluetooth/service/device-same-object.https.window.js b/third_party/blink/web_tests/external/wpt/bluetooth/service/device-same-object.https.window.js new file mode 100644 index 00000000000000..cca0b344eae86c --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/bluetooth/service/device-same-object.https.window.js @@ -0,0 +1,15 @@ +// META: script=/resources/testharness.js +// META: script=/resources/testharnessreport.js +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js +// META: script=/bluetooth/resources/bluetooth-test.js +// META: script=/bluetooth/resources/bluetooth-fake-devices.js +'use strict'; +const test_desc = '[SameObject] test for BluetoothRemoteGATTService device.'; + +bluetooth_test(async () => { + let {device} = await getHealthThermometerDevice( + {filters: [{services: ['health_thermometer']}]}); + let service = await device.gatt.getPrimaryService('health_thermometer'); + assert_equals(service.device, device); +}, test_desc); diff --git a/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristic/characteristic-found.https.html b/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristic/characteristic-found.https.html deleted file mode 100644 index 0fb2ff3532f050..00000000000000 --- a/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristic/characteristic-found.https.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - diff --git a/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristic/characteristic-found.https.window.js b/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristic/characteristic-found.https.window.js new file mode 100644 index 00000000000000..699f9938a5e118 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristic/characteristic-found.https.window.js @@ -0,0 +1,27 @@ +// META: script=/resources/testharness.js +// META: script=/resources/testharnessreport.js +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js +// META: script=/bluetooth/resources/bluetooth-test.js +// META: script=/bluetooth/resources/bluetooth-fake-devices.js +'use strict'; +const test_desc = 'Request for characteristic. Should return right ' + + 'characteristic.'; + +bluetooth_test(async () => { + let {device} = await getHealthThermometerDevice(); + let service = await device.gatt.getPrimaryService('health_thermometer'); + let characteristics = await Promise.all([ + service.getCharacteristic(measurement_interval.alias), + service.getCharacteristic(measurement_interval.name), + service.getCharacteristic(measurement_interval.uuid) + ]); + characteristics.forEach(characteristic => { + assert_equals( + characteristic.uuid, measurement_interval.uuid, + 'Characteristic UUID should be the same as requested UUID.'); + assert_equals( + characteristic.service, service, + 'Characteristic service should be the same as service.'); + }); +}, test_desc); diff --git a/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/blocklisted-characteristics.https.html b/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/blocklisted-characteristics.https.html deleted file mode 100644 index 3298f5fd3d054c..00000000000000 --- a/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/blocklisted-characteristics.https.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - diff --git a/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/blocklisted-characteristics.https.window.js b/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/blocklisted-characteristics.https.window.js new file mode 100644 index 00000000000000..7458c56a175555 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/blocklisted-characteristics.https.window.js @@ -0,0 +1,19 @@ +// META: script=/resources/testharness.js +// META: script=/resources/testharnessreport.js +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js +// META: script=/bluetooth/resources/bluetooth-test.js +// META: script=/bluetooth/resources/bluetooth-fake-devices.js +'use strict'; +const test_desc = 'The Device Information service is composed of blocklisted ' + + 'characteristics so we shouldn\'t find any.'; +const expected = + new DOMException('No Characteristics found in service.', 'NotFoundError'); + +bluetooth_test(async () => { + let {device} = + await getHIDDevice({filters: [{services: ['device_information']}]}); + let service = await device.gatt.getPrimaryService('device_information'); + return assert_promise_rejects_with_message( + service.getCharacteristics(), expected); +}, test_desc); diff --git a/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/characteristics-found-with-uuid.https.html b/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/characteristics-found-with-uuid.https.html deleted file mode 100644 index 6188adbafb9d66..00000000000000 --- a/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/characteristics-found-with-uuid.https.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - diff --git a/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/characteristics-found-with-uuid.https.window.js b/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/characteristics-found-with-uuid.https.window.js new file mode 100644 index 00000000000000..8778807b93b2cd --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/characteristics-found-with-uuid.https.window.js @@ -0,0 +1,42 @@ +// META: script=/resources/testharness.js +// META: script=/resources/testharnessreport.js +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js +// META: script=/bluetooth/resources/bluetooth-test.js +// META: script=/bluetooth/resources/bluetooth-fake-devices.js +'use strict'; +const test_desc = 'Find characteristics with UUID in service.'; + +bluetooth_test(async () => { + let {device, fake_peripheral} = await getDiscoveredHealthThermometerDevice(); + // Setup a device with two measurement intervals. + await fake_peripheral.setNextGATTConnectionResponse({code: HCI_SUCCESS}); + await device.gatt.connect(); + let fake_health_thermometer = + await fake_peripheral.addFakeService({uuid: 'health_thermometer'}); + await Promise.all([ + fake_health_thermometer.addFakeCharacteristic({ + uuid: 'measurement_interval', + properties: ['read', 'write', 'indicate'] + }), + fake_health_thermometer.addFakeCharacteristic({ + uuid: 'measurement_interval', + properties: ['read', 'write', 'indicate'] + }), + fake_health_thermometer.addFakeCharacteristic( + {uuid: 'temperature_measurement', properties: ['indicate']}) + ]); + await fake_peripheral.setNextGATTDiscoveryResponse({code: HCI_SUCCESS}); + let service = await device.gatt.getPrimaryService('health_thermometer'); + // Actual test starts. + let characteristics_arrays = await Promise.all([ + service.getCharacteristics(measurement_interval.alias), + service.getCharacteristics(measurement_interval.name), + service.getCharacteristics(measurement_interval.uuid) + ]); + characteristics_arrays.forEach(characteristics => { + assert_equals(characteristics.length, 2); + assert_equals(characteristics[0].uuid, measurement_interval.uuid); + assert_equals(characteristics[1].uuid, measurement_interval.uuid); + }); +}, test_desc); diff --git a/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/characteristics-found.https.html b/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/characteristics-found.https.html deleted file mode 100644 index 6812cd977f2e54..00000000000000 --- a/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/characteristics-found.https.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - diff --git a/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/characteristics-found.https.window.js b/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/characteristics-found.https.window.js new file mode 100644 index 00000000000000..f1b9ecd176a91c --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/characteristics-found.https.window.js @@ -0,0 +1,44 @@ +// META: script=/resources/testharness.js +// META: script=/resources/testharnessreport.js +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js +// META: script=/bluetooth/resources/bluetooth-test.js +// META: script=/bluetooth/resources/bluetooth-fake-devices.js +'use strict'; +const test_desc = 'Find all characteristics in a service.'; + +bluetooth_test(async () => { + let {device, fake_peripheral} = await getDiscoveredHealthThermometerDevice(); + // Setup a device with two measurement intervals. + await fake_peripheral.setNextGATTConnectionResponse({code: HCI_SUCCESS}); + await device.gatt.connect(); + let fake_health_thermometer = + await fake_peripheral.addFakeService({uuid: 'health_thermometer'}); + await Promise.all([ + fake_health_thermometer.addFakeCharacteristic({ + uuid: 'measurement_interval', + properties: ['read', 'write', 'indicate'] + }), + fake_health_thermometer.addFakeCharacteristic({ + uuid: 'measurement_interval', + properties: ['read', 'write', 'indicate'] + }), + fake_health_thermometer.addFakeCharacteristic( + {uuid: 'temperature_measurement', properties: ['indicate']}) + ]); + await fake_peripheral.setNextGATTDiscoveryResponse({code: HCI_SUCCESS}); + let service = await device.gatt.getPrimaryService('health_thermometer'); + // Actual test starts. + let characteristics = await service.getCharacteristics(); + // Expect three characteristic instances. + assert_equals(characteristics.length, 3); + + let uuid_set = new Set(characteristics.map(c => c.uuid)); + // Two of the expected characteristics are + // 'measurement_interval', so only 2 unique UUID. + assert_equals(uuid_set.size, 2); + assert_true( + uuid_set.has(BluetoothUUID.getCharacteristic('measurement_interval'))); + assert_true( + uuid_set.has(BluetoothUUID.getCharacteristic('temperature_measurement'))); +}, test_desc); diff --git a/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/characteristics-not-found.https.html b/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/characteristics-not-found.https.html deleted file mode 100644 index a629b5e1c11bf3..00000000000000 --- a/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/characteristics-not-found.https.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - diff --git a/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/characteristics-not-found.https.window.js b/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/characteristics-not-found.https.window.js new file mode 100644 index 00000000000000..93048fce2a5e64 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/bluetooth/service/getCharacteristics/characteristics-not-found.https.window.js @@ -0,0 +1,17 @@ +// META: script=/resources/testharness.js +// META: script=/resources/testharnessreport.js +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js +// META: script=/bluetooth/resources/bluetooth-test.js +// META: script=/bluetooth/resources/bluetooth-fake-devices.js +'use strict'; +const test_desc = 'Request for absent characteristics. Reject with ' + + 'NotFoundError.'; +const expected = + new DOMException('No Characteristics found in service.', 'NotFoundError'); + +bluetooth_test(async () => { + let {service} = await getEmptyHealthThermometerService(); + return assert_promise_rejects_with_message( + service.getCharacteristics(), expected); +}, test_desc); diff --git a/third_party/blink/web_tests/external/wpt/css/css-sizing/table-child-percentage-height-with-border-box-expected.html b/third_party/blink/web_tests/external/wpt/css/css-sizing/table-child-percentage-height-with-border-box-expected.html index 2b0a2f451c59b2..b9d2418b18b5d7 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-sizing/table-child-percentage-height-with-border-box-expected.html +++ b/third_party/blink/web_tests/external/wpt/css/css-sizing/table-child-percentage-height-with-border-box-expected.html @@ -9,20 +9,18 @@ } body { box-sizing: border-box; - display: table; margin: 0 auto; width: 100%; height: 100%; } .content { box-sizing: border-box; - display: table-row; width: 100%; height: 100%; background-color: red; } .wrapper { - box-sizing: content-box; + box-sizing: border-box; width: 100%; height: 100%; background-color: green; diff --git a/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-default-descriptors-iframe-print.html b/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-default-descriptors-iframe-print.html new file mode 100644 index 00000000000000..0b73d7f03474d6 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-default-descriptors-iframe-print.html @@ -0,0 +1,69 @@ + + +The default scroll-timeline at rule in the iframe for print + + + + + + + + diff --git a/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-default-descriptors-print.tentative.html b/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-default-descriptors-print.tentative.html new file mode 100644 index 00000000000000..418ed3c5495b77 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-default-descriptors-print.tentative.html @@ -0,0 +1,61 @@ + + +The default scroll-timeline at rule for print + + + + + + + +
    +
    + + diff --git a/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-paused-animations-expected.txt b/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-paused-animations-expected.txt new file mode 100644 index 00000000000000..7847b21efc76ba --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-paused-animations-expected.txt @@ -0,0 +1,5 @@ +This is a testharness.js-based test. +FAIL Test that the scroll animation is paused assert_equals: expected "100px" but got "50px" +FAIL Test that the scroll animation is paused by updating animation-play-state assert_equals: expected "100px" but got "50px" +Harness: the test ran to completion. + diff --git a/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-paused-animations.html b/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-paused-animations.html new file mode 100644 index 00000000000000..7bf1289ebef1e9 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-paused-animations.html @@ -0,0 +1,69 @@ + + +The default scroll-timeline at rule with paused animations + + + + + + + +
    + + diff --git a/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-responsiveness-from-endpoint-expected.txt b/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-responsiveness-from-endpoint-expected.txt new file mode 100644 index 00000000000000..898f1cf7348d6c --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-responsiveness-from-endpoint-expected.txt @@ -0,0 +1,4 @@ +This is a testharness.js-based test. +FAIL Test that the scroll animation is still responsive after moving from 100% assert_equals: expected "100px" but got "50px" +Harness: the test ran to completion. + diff --git a/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-responsiveness-from-endpoint.html b/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-responsiveness-from-endpoint.html new file mode 100644 index 00000000000000..3eafe2f973ea66 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-responsiveness-from-endpoint.html @@ -0,0 +1,49 @@ + + +The default scroll-timeline at rule with animation moving from end point + + + + + + + +
    + + diff --git a/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-specified-scroller-print-ref.html b/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-specified-scroller-print-ref.html new file mode 100644 index 00000000000000..fa945ce72f0888 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-specified-scroller-print-ref.html @@ -0,0 +1,38 @@ + + +Reference for @scroll-timeline with a specified scroller + + +
    +
    +
    +
    + + diff --git a/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-specified-scroller-print.html b/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-specified-scroller-print.html new file mode 100644 index 00000000000000..5543088324d60a --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/scroll-animations/css/at-scroll-timeline-specified-scroller-print.html @@ -0,0 +1,56 @@ + + +The scroll-timeline at rule with a specified scroller for print + + + + + + + +
    +
    +
    +
    + + diff --git a/third_party/blink/web_tests/wpt_internal/webcodecs/basic_video_encoding.https.any.js b/third_party/blink/web_tests/wpt_internal/webcodecs/basic_video_encoding.https.any.js index 756fe7ab3c48c0..17b271eb600003 100644 --- a/third_party/blink/web_tests/wpt_internal/webcodecs/basic_video_encoding.https.any.js +++ b/third_party/blink/web_tests/wpt_internal/webcodecs/basic_video_encoding.https.any.js @@ -31,6 +31,7 @@ async function encode_decode_test(codec, avc_format) { output(chunk, metadata) { let config = metadata.decoderConfig; if (config) { + config.hardwareAcceleration = acc; decoder.configure(config); } decoder.decode(chunk); diff --git a/third_party/closure_compiler/externs/terminal_private.js b/third_party/closure_compiler/externs/terminal_private.js index 57ac93cd697c5e..86139eb7f2f4d4 100644 --- a/third_party/closure_compiler/externs/terminal_private.js +++ b/third_party/closure_compiler/externs/terminal_private.js @@ -97,6 +97,15 @@ chrome.terminalPrivate.openWindow = function(data) {}; */ chrome.terminalPrivate.openOptionsPage = function(callback) {}; +/** + * Returns an object containing info about ChromeOS settings that affect the + * Terminal, e.g. which feature flags are enabled. + * @param {function({ + * tmux_integration: boolean + * }): void} callback Callback that will be called with the info object. + */ +chrome.terminalPrivate.getOSInfo = function(callback) {}; + /** * Returns an object (DictionaryValue) containing UI settings such as font style * and colors used by terminal and stored as a syncable pref. The UI currently diff --git a/tools/accessibility/rebase_dump_accessibility_tree_test.py b/tools/accessibility/rebase_dump_accessibility_tree_test.py index 513b1056c0d80d..8cdab8b0f351d8 100755 --- a/tools/accessibility/rebase_dump_accessibility_tree_test.py +++ b/tools/accessibility/rebase_dump_accessibility_tree_test.py @@ -48,13 +48,13 @@ def Fix(line): line = result.group(1) # For Android tests: if line[:2] == 'I ': - result = re.search('I \d+\.\d+s run_tests_on_device\([0-9a-f]+\) (.*)', + result = re.search('I \d+\.\d+s run_tests_on_device\([0-9a-f]+\)\s+(.*)', line) if result: - line = group(1) + line = result.group(1) # For Android content_shell_test_apk tests: elif line[:2] == 'C ': - result = re.search('C \d+\.\d+s Main ([T|E|A|W|\+](.*))', line) + result = re.search('C \d+\.\d+s Main\s+([T|E|A|W|\+](.*))', line) if result: line = result.group(1) diff --git a/tools/gritsettings/resource_ids.spec b/tools/gritsettings/resource_ids.spec index f3a209264743ce..fa3364f01e0228 100644 --- a/tools/gritsettings/resource_ids.spec +++ b/tools/gritsettings/resource_ids.spec @@ -133,6 +133,9 @@ "META": {"sizes": {"includes": [50]}}, "includes": [1380], }, + "chrome/browser/resources/chromeos/app_icon/app_icon_resources.grd": { + "structures": [1390], + }, "chrome/browser/resources/chromeos/login/oobe_conditional_resources.grd": { "META": {"sizes": {"includes": [150], "structures": [300]}}, "includes": [1400], diff --git a/tools/mb/mb.py b/tools/mb/mb.py index 67391c795e940a..0ed61641b89f57 100755 --- a/tools/mb/mb.py +++ b/tools/mb/mb.py @@ -20,7 +20,6 @@ import os import pipes import platform -import pprint import re import shutil import sys @@ -1574,12 +1573,12 @@ def WriteIsolateFiles(self, build_dir, command, target, runtime_deps, vals, return 1 self.WriteFile(isolate_path, - pprint.pformat({ + json.dumps({ 'variables': { 'command': command, 'files': files, } - }) + '\n') + }, sort_keys=True) + '\n') self.WriteJSON( { diff --git a/tools/mb/mb_unittest.py b/tools/mb/mb_unittest.py index 935ba620a9e343..3af390fb90341d 100755 --- a/tools/mb/mb_unittest.py +++ b/tools/mb/mb_unittest.py @@ -293,6 +293,8 @@ def close(self): class UnitTest(unittest.TestCase): + maxDiff = None + def fake_mbw(self, files=None, win32=False): mbw = FakeMBW(win32=win32) mbw.files.setdefault(mbw.default_config, TEST_CONFIG) @@ -750,8 +752,13 @@ def test_run(self): '/fake_src/out/Default/base_unittests.runtime_deps': ("base_unittests\n"), } - self.check(['run', '-c', 'debug_goma', '//out/Default', - 'base_unittests'], files=files, ret=0) + mbw = self.check(['run', '-c', 'debug_goma', '//out/Default', + 'base_unittests'], files=files, ret=0) + # pylint: disable=line-too-long + self.assertEqual( + mbw.files['/fake_src/out/Default/base_unittests.isolate'], + '{"variables": {"command": ["vpython3", "../../testing/test_env.py", "./base_unittests", "--test-launcher-bot-mode", "--asan=0", "--lsan=0", "--msan=0", "--tsan=0", "--cfi-diag=0"], "files": ["../../.vpython3", "../../testing/test_env.py"]}}\n') + # pylint: enable=line-too-long def test_run_swarmed(self): files = { diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index f75796523e75fb..eb61b75cca2bb0 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml @@ -30537,6 +30537,7 @@ Called by update_extension_histograms.py.--> + @@ -48286,6 +48287,7 @@ Called by update_gpu_driver_bug_workaround_entries.py.--> + @@ -87528,6 +87530,13 @@ Full version information for the fingerprint enum values: + + + + + + + diff --git a/tools/metrics/histograms/metadata/arc/histograms.xml b/tools/metrics/histograms/metadata/arc/histograms.xml index eca0fb1190fd4a..844fa450bd0f5c 100644 --- a/tools/metrics/histograms/metadata/arc/histograms.xml +++ b/tools/metrics/histograms/metadata/arc/histograms.xml @@ -848,18 +848,34 @@ chromium-metrics-reviews@google.com. + expires_after="2022-09-01"> yusukes@google.com khmel@google.com - How long the user sees the spinning icon waiting for ARC container boot. - Zero when the container has already been up and running when the user - launches the ARC app. + Elapsed time from the when user requests app launch before ARC boot and ARC + is booted. Note, ARC booted does not mean app is actually shown. You may + consider Arc.FirstAppLaunchDelay.TimeDeltaUntilAppLaunch also. Unlike + Arc.FirstAppLaunchDelay.TimeDeltaUntilAppLaunch, this metric is recorded + only up to once a user session. Zero when the container has already been up + and running when the user launches the ARC app. + + + + + khmel@google.com + alanding@google.com + + How long the user sees the spinning icon waiting for ARC boot. This metric + is not recorded at all if the user launches apps only after ARC is booted. + Unlike Arc.FirstAppLaunchDelay.TimeDelta, this metric might be recorded + multiple times per a user session, for example when users starts multiple + ARC apps while ARC is booting. + expires_after="2022-09-01"> yusukes@google.com khmel@google.com diff --git a/tools/metrics/histograms/metadata/file/histograms.xml b/tools/metrics/histograms/metadata/file/histograms.xml index c4e32edd3f57bd..fece4e6e0ab3ce 100644 --- a/tools/metrics/histograms/metadata/file/histograms.xml +++ b/tools/metrics/histograms/metadata/file/histograms.xml @@ -705,6 +705,10 @@ chromium-metrics-reviews@google.com. + + Removed in M99. File sharing is now done by Sharesheet, not Files.app. + Replaced with ChromeOS.Sharesheet.Invocation.Mimetype. + simmonsjosh@google.com src/ui/file_manager/OWNERS diff --git a/tools/metrics/histograms/metadata/language/histograms.xml b/tools/metrics/histograms/metadata/language/histograms.xml index 7d170b35149e50..4efd25cf297197 100644 --- a/tools/metrics/histograms/metadata/language/histograms.xml +++ b/tools/metrics/histograms/metadata/language/histograms.xml @@ -361,6 +361,22 @@ chromium-metrics-reviews@google.com. + + jds@google.com + chrome-language@google.com + + The result of initializing ULP, including {AccountType}. + + Recorded once at startup when ULP is initialized. + + + + + + + + jds@google.com diff --git a/tools/metrics/histograms/metadata/others/histograms.xml b/tools/metrics/histograms/metadata/others/histograms.xml index 6a6b5887548786..fbe2e85ef4ea92 100644 --- a/tools/metrics/histograms/metadata/others/histograms.xml +++ b/tools/metrics/histograms/metadata/others/histograms.xml @@ -4807,7 +4807,7 @@ chromium-metrics-reviews@google.com. + enum="DirectSocketPermissionFailureType" expires_after="2022-06-07"> ericwilligers@chromium.org glenrob@chromium.org diff --git a/tools/metrics/histograms/metadata/page/histograms.xml b/tools/metrics/histograms/metadata/page/histograms.xml index 94dbc8af9685ad..3f5260369fd6e3 100644 --- a/tools/metrics/histograms/metadata/page/histograms.xml +++ b/tools/metrics/histograms/metadata/page/histograms.xml @@ -710,7 +710,7 @@ chromium-metrics-reviews@google.com. + units="ms" expires_after="2022-06-27"> ksakamoto@chromium.org asamidoi@chromium.org src/content/browser/prerender/OWNERS @@ -728,7 +728,7 @@ chromium-metrics-reviews@google.com. + units="ms" expires_after="2022-06-27"> ksakamoto@chromium.org asamidoi@chromium.org src/content/browser/prerender/OWNERS @@ -747,7 +747,7 @@ chromium-metrics-reviews@google.com. + units="ms" expires_after="2022-06-27"> ksakamoto@chromium.org asamidoi@chromium.org src/content/browser/prerender/OWNERS @@ -765,7 +765,7 @@ chromium-metrics-reviews@google.com. + units="ms" expires_after="2022-06-27"> ksakamoto@chromium.org asamidoi@chromium.org src/content/browser/prerender/OWNERS @@ -784,7 +784,7 @@ chromium-metrics-reviews@google.com. + units="ms" expires_after="2022-06-27"> ksakamoto@chromium.org asamidoi@chromium.org src/content/browser/prerender/OWNERS @@ -804,7 +804,7 @@ chromium-metrics-reviews@google.com. + units="ms" expires_after="2022-06-27"> ksakamoto@chromium.org asamidoi@chromium.org src/content/browser/prerender/OWNERS @@ -823,7 +823,7 @@ chromium-metrics-reviews@google.com. + units="ms" expires_after="2022-06-27"> ksakamoto@chromium.org asamidoi@chromium.org src/content/browser/prerender/OWNERS diff --git a/tools/perf/core/perfetto_binary_roller/binary_deps.json b/tools/perf/core/perfetto_binary_roller/binary_deps.json index c04afacbe0e212..16a869ad9715f7 100644 --- a/tools/perf/core/perfetto_binary_roller/binary_deps.json +++ b/tools/perf/core/perfetto_binary_roller/binary_deps.json @@ -5,8 +5,8 @@ "remote_path": "perfetto_binaries/trace_processor_shell/linux_arm/49b4b5dcbc312d8d2c3751cf29238b8efeb4e494/trace_processor_shell" }, "win": { - "hash": "c4efce6c0cefe5e1c137bbbfe5ed1189b38b8da9", - "remote_path": "perfetto_binaries/trace_processor_shell/win/22467673a50f5599e7d8b1f49982faf7c1bc30d9/trace_processor_shell.exe" + "hash": "6cd3704685eb81ad27d4246180ee629c1c6d9488", + "remote_path": "perfetto_binaries/trace_processor_shell/win/15e3467297c3877d090e92940a04b085318ab933/trace_processor_shell.exe" }, "mac": { "hash": "11daea10c30ca26ac3695540f3b07b83665ed7e1", @@ -17,8 +17,8 @@ "remote_path": "perfetto_binaries/trace_processor_shell/linux_arm64/49b4b5dcbc312d8d2c3751cf29238b8efeb4e494/trace_processor_shell" }, "linux": { - "hash": "bedc0c16f454388d206b5b054fc36122bbeb4ba2", - "remote_path": "perfetto_binaries/trace_processor_shell/linux/22467673a50f5599e7d8b1f49982faf7c1bc30d9/trace_processor_shell" + "hash": "46bd1cb0b881714948a74f091500c22f241fea08", + "remote_path": "perfetto_binaries/trace_processor_shell/linux/15e3467297c3877d090e92940a04b085318ab933/trace_processor_shell" } }, "power_profile.sql": { diff --git a/ui/android/java/src/org/chromium/ui/base/Clipboard.java b/ui/android/java/src/org/chromium/ui/base/Clipboard.java index 25d1fb85d2dc69..ce4d8e3e4774ce 100644 --- a/ui/android/java/src/org/chromium/ui/base/Clipboard.java +++ b/ui/android/java/src/org/chromium/ui/base/Clipboard.java @@ -49,6 +49,7 @@ import org.chromium.ui.widget.Toast; import org.chromium.url.GURL; +import java.io.ByteArrayOutputStream; import java.io.FileInputStream; import java.io.IOException; import java.util.List; @@ -69,6 +70,9 @@ public class Clipboard implements ClipboardManager.OnPrimaryClipChangedListener // This mime type annotates that clipboard contains a text. private static final String TEXT_MIME_TYPE = "text/*"; + // This mime type annotates that clipboard contains a PNG image. + private static final String PNG_MIME_TYPE = "image/png"; + @SuppressLint("StaticFieldLeak") private static Clipboard sInstance; @@ -406,8 +410,27 @@ public byte[] getPng() { ContentResolver cr = ContextUtils.getApplicationContext().getContentResolver(); String mimeType = cr.getType(uri); - if (!"image/png".equalsIgnoreCase(mimeType)) return null; + if (!PNG_MIME_TYPE.equalsIgnoreCase(mimeType)) { + if (!hasImage()) return null; + + // Android system clipboard contains an image, but it is not a PNG. + // Try reading it as a bitmap and encoding to a PNG. + try { + // TODO(crbug.com/1280468): This uses the unsafe ImageDecoder class. + Bitmap bitmap = ApiCompatibilityUtils.getBitmapByUri(cr, uri); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + // |quality| is ignored since PNG encoding is lossless. See + // https://developer.android.com/reference/android/graphics/Bitmap.CompressFormat#PNG. + bitmap.compress(Bitmap.CompressFormat.PNG, /*quality=*/100, baos); + if (baos.size() > MAX_ALLOWED_PNG_SIZE_BYTES) return null; + + return baos.toByteArray(); + } catch (IOException | OutOfMemoryError e) { + return null; + } + } + // The image is a PNG. Read and return the raw bytes. FileInputStream fileStream = null; try (AssetFileDescriptor afd = cr.openAssetFileDescriptor(uri, "r")) { if (afd == null || afd.getLength() > MAX_ALLOWED_PNG_SIZE_BYTES @@ -722,16 +745,6 @@ private void revokeUriPermissionForLastSharedImage() { mImageFileProvider.clearLastCopiedImageMetadata(); } - /** - * Check if |bitmap| is support by native side. gfx::CreateSkBitmapFromJavaBitmap only support - * ARGB_8888 and ALPHA_8. - */ - private boolean bitmapSupportByGfx(Bitmap bitmap) { - return bitmap != null - && (bitmap.getConfig() == Bitmap.Config.ARGB_8888 - || bitmap.getConfig() == Bitmap.Config.ALPHA_8); - } - /** * Allows the ClipboardManager Android Service to be replaced with a mock for tests, returning * the original so that it can be restored. diff --git a/ui/chromeos/resources/ui_chromeos_resources.grd b/ui/chromeos/resources/ui_chromeos_resources.grd index 92149b52f91288..68f5fc7a152114 100644 --- a/ui/chromeos/resources/ui_chromeos_resources.grd +++ b/ui/chromeos/resources/ui_chromeos_resources.grd @@ -11,17 +11,6 @@ - - - - - - - - - - - diff --git a/ui/events/keycodes/dom/dom_code_data.inc b/ui/events/keycodes/dom/dom_code_data.inc index dd8ac4938881a3..c96987d0a5a01c 100644 --- a/ui/events/keycodes/dom/dom_code_data.inc +++ b/ui/events/keycodes/dom/dom_code_data.inc @@ -76,13 +76,6 @@ // Apple keyboards with USB 0x070049 [Insert] labelled "Help" have not // been made since 2007. -// ChromeOS notes: -// -// Any keys that are added or updated specifically for use in the ChromeOS -// top-row should also be updated in sections of Input Diagnostics: -// ash/webui/diagnostics_ui/mojom/input_data_provider.mojom: enum TopRowKey -// ash/webui/diagnostics_ui/backend/input_data_provider_keyboard.cc: kScancodeMapping - DOM_CODE_DECLARATION { // USB evdev XKB Win Mac Code diff --git a/ui/file_manager/file_manager/foreground/js/file_manager_commands.js b/ui/file_manager/file_manager/foreground/js/file_manager_commands.js index e1d4a27e581bc8..6545d8984db27a 100644 --- a/ui/file_manager/file_manager/foreground/js/file_manager_commands.js +++ b/ui/file_manager/file_manager/foreground/js/file_manager_commands.js @@ -1757,7 +1757,6 @@ CommandHandler.COMMANDS_['open-with'] = new class extends FilesCommand { CommandHandler.COMMANDS_['invoke-sharesheet'] = new class extends FilesCommand { execute(event, fileManager) { const entries = fileManager.selectionHandler.selection.entries; - FileTasks.recordSharingFileTypesUMA_(entries); const launchSource = CommandUtil.getSharesheetLaunchSource(event); chrome.fileManagerPrivate.invokeSharesheet(entries, launchSource, () => { if (chrome.runtime.lastError) { diff --git a/ui/file_manager/file_manager/foreground/js/file_tasks.js b/ui/file_manager/file_manager/foreground/js/file_tasks.js index d0acb2fc42645f..f0a46e1067ef8a 100644 --- a/ui/file_manager/file_manager/foreground/js/file_tasks.js +++ b/ui/file_manager/file_manager/foreground/js/file_tasks.js @@ -228,18 +228,6 @@ export class FileTasks { return extension; } - /** - * Records UMA statistics for file types being shared in Share action. - * @param {!Array} entries File entries to be shared. - */ - static recordSharingFileTypesUMA_(entries) { - for (const entry of entries) { - metrics.recordEnum( - 'Share.FileType', FileTasks.getViewFileType(entry), - FileTasks.UMA_INDEX_KNOWN_EXTENSIONS); - } - } - /** * Records trial of opening file grouped by extensions. * diff --git a/ui/file_manager/file_manager/foreground/js/file_tasks_unittest.m.js b/ui/file_manager/file_manager/foreground/js/file_tasks_unittest.m.js index 3a8b3890675500..f27b66bfbb8b90 100644 --- a/ui/file_manager/file_manager/foreground/js/file_tasks_unittest.m.js +++ b/ui/file_manager/file_manager/foreground/js/file_tasks_unittest.m.js @@ -616,22 +616,6 @@ export function testGetViewFileType() { } } -/** - * Checks that we are correctly recording UMA about Share action. - */ -export function testRecordSharingFileTypes() { - // Setup: create a fake metrics object that can be examined for content. - const mockFileSystem = new MockFileSystem('volumeId'); - - // Actual tests. - FileTasks.recordSharingFileTypesUMA_([ - MockFileEntry.create(mockFileSystem, '/test.log'), - MockFileEntry.create(mockFileSystem, '/test.doc'), - MockFileEntry.create(mockFileSystem, '/test.__no_such_extension__'), - ]); - assertArrayEquals(enumMap.get('Share.FileType'), ['.log', '.doc', 'other']); -} - /** * Checks that the progress center is properly updated when mounting archives * successfully. diff --git a/ui/views/bubble/bubble_dialog_delegate_view.cc b/ui/views/bubble/bubble_dialog_delegate_view.cc index af0b8a693a600e..0b2eef37bf2741 100644 --- a/ui/views/bubble/bubble_dialog_delegate_view.cc +++ b/ui/views/bubble/bubble_dialog_delegate_view.cc @@ -628,6 +628,11 @@ gfx::Rect BubbleDialogDelegate::GetAnchorRect() const { return anchor_rect_.value(); } +SkColor BubbleDialogDelegate::GetBackgroundColor() { + UpdateColorsFromTheme(); + return color(); +} + ui::LayerType BubbleDialogDelegate::GetLayerType() const { return ui::LAYER_TEXTURED; } diff --git a/ui/views/bubble/bubble_dialog_delegate_view.h b/ui/views/bubble/bubble_dialog_delegate_view.h index 05d6925e34aa31..64b5d500ecdbbd 100644 --- a/ui/views/bubble/bubble_dialog_delegate_view.h +++ b/ui/views/bubble/bubble_dialog_delegate_view.h @@ -200,11 +200,16 @@ class VIEWS_EXPORT BubbleDialogDelegate : public DialogDelegate { ////////////////////////////////////////////////////////////////////////////// // Layout & colors: // - // In general you shouldn't need to call any of these. If the default bubble + // In general you shouldn't need to call any setters. If the default bubble // look and feel does not work for your use case, BubbleDialogDelegate may not // be a good fit for the UI you are building. - // The bubble's background color: + // Ensures the bubble's background color is up-to-date, then returns it. + SkColor GetBackgroundColor(); + + // Direct access to the background color. Only use the getter when you know + // you don't need to worry about the color being out-of-date due to a recent + // theme update. SkColor color() const { return color_; } void set_color(SkColor color) { color_ = color; diff --git a/ui/webui/resources/cr_elements/cr_icon_button/cr_icon_button.m.d.ts b/ui/webui/resources/cr_elements/cr_icon_button/cr_icon_button.m.d.ts index 674e2412491226..cc31c31044c432 100644 --- a/ui/webui/resources/cr_elements/cr_icon_button/cr_icon_button.m.d.ts +++ b/ui/webui/resources/cr_elements/cr_icon_button/cr_icon_button.m.d.ts @@ -5,7 +5,7 @@ import {LegacyElementMixin} from 'chrome://resources/polymer/v3_0/polymer/lib/legacy/legacy-element-mixin.js'; interface CrIconButtonElement extends LegacyElementMixin, HTMLElement { - disabled: boolean; + disabled: boolean|null|undefined; customTabIndex: number|null|undefined; ironIcon: string|null|undefined; hostAttributes: object|null;